wrong_submission_id
stringlengths 10
10
| problem_id
stringlengths 6
6
| user_id
stringlengths 10
10
| time_limit
float64 1k
8k
| memory_limit
float64 131k
1.05M
| wrong_status
stringclasses 2
values | wrong_cpu_time
float64 10
40k
| wrong_memory
float64 2.94k
3.37M
| wrong_code_size
int64 1
15.5k
| problem_description
stringlengths 1
4.75k
| wrong_code
stringlengths 1
6.92k
| acc_submission_id
stringlengths 10
10
| acc_status
stringclasses 1
value | acc_cpu_time
float64 10
27.8k
| acc_memory
float64 2.94k
960k
| acc_code_size
int64 19
14.9k
| acc_code
stringlengths 19
14.9k
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s385445846
|
p02843
|
u816637025
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 58
|
AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible. (Ignore consumption tax.)
|
N=int(input())
d,m=divmod(N,100)
print(['1','0'][m < d*5])
|
s314710641
|
Accepted
| 17
| 2,940
| 59
|
N=int(input())
d,m=divmod(N,100)
print(['0','1'][m<=(d*5)])
|
s017912826
|
p03549
|
u343523393
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 85
|
Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
|
N,M=list(map(int,input().split()))
p=1/(2**M)
#print(p)
print((1900*M+100*(N-M))*1/p)
|
s118307234
|
Accepted
| 17
| 2,940
| 90
|
N,M=list(map(int,input().split()))
p=1/(2**M)
#print(p)
print(int((1900*M+100*(N-M))*1/p))
|
s245496689
|
p03836
|
u221345507
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,432
| 521
|
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
sx, sy, tx, ty = map(int,input().split())
ans = []
firstup = (ty-sy)*['U']
firstright = (tx-sx)*['R']
firstdown = (ty-sy)*['D']
firstleft = (tx-sx)*['L']
second_offset = ['R']
secoudup = firstup+['U']
secoundright = firstright + ['R']
second_offset2 = ['D']
second_offset3 = ['R']
secounddown = firstdown +['D']
secondleft = firstleft + ['L']
second_offset4 = ['U']
ans = firstup+firstright+firstdown+firstleft+second_offset+secoudup+second_offset2+second_offset3+secounddown+secondleft+second_offset4
print(''.join(ans))
|
s567573772
|
Accepted
| 20
| 3,432
| 533
|
sx, sy, tx, ty = map(int,input().split())
ans = []
firstup = (ty-sy)*['U']
firstright = (tx-sx)*['R']
firstdown = (ty-sy)*['D']
firstleft = (tx-sx)*['L']
second_offset = ['L']
secoudup = firstup+['U']
secondright = firstright + ['R']
second_offset2 = ['D']
second_offset3 = ['R']
secounddown = firstdown +['D']
secondleft = firstleft + ['L']
second_offset4 = ['U']
ans = firstup+firstright+firstdown+firstleft+second_offset+secoudup+secondright+second_offset2+second_offset3+secounddown+secondleft+second_offset4
print(''.join(ans))
|
s271960603
|
p03729
|
u608088992
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 83
|
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
|
A, B, C = input().split()
print("Yes" if A[-1] == B[0] and B[-1] == C[0] else "No")
|
s290989132
|
Accepted
| 17
| 2,940
| 83
|
A, B, C = input().split()
print("YES" if A[-1] == B[0] and B[-1] == C[0] else "NO")
|
s559182560
|
p02850
|
u572193732
| 2,000
| 1,048,576
|
Wrong Answer
| 2,106
| 89,836
| 480
|
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colorings satisfying the condition above, construct one that uses the minimum number of colors.
|
from collections import deque
N = int(input())
edge = [set() for i in range(N+1)]
for i in range(N-1):
a, b = map(int, input().split())
edge[a].add((b, i))
edge[b].add((a, i))
r = [0] * (N-1)
q = deque([(0, 1)])
while q:
print(edge)
preC, fromv = q.popleft()
c = 0
for tov, i in edge[fromv]:
edge[tov].remove((fromv, i))
c += 1 + (c + 1 == preC)
q.append((c, tov))
r[i] = c
print(max(r))
for x in r:
print(x)
|
s190298426
|
Accepted
| 717
| 51,784
| 464
|
from collections import deque
N = int(input())
edge = [set() for i in range(N+1)]
for i in range(N-1):
a, b = map(int, input().split())
edge[a].add((b, i))
edge[b].add((a, i))
r = [0] * (N-1)
q = deque([(0, 1)])
while q:
preC, fromv = q.popleft()
c = 0
for tov, i in edge[fromv]:
edge[tov].remove((fromv, i))
c += 1 + (c + 1 == preC)
q.append((c, tov))
r[i] = c
print(max(r))
for x in r:
print(x)
|
s655960174
|
p02257
|
u852112234
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,660
| 271
|
A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. Write a program which reads a list of _N_ integers and prints the number of prime numbers in the list.
|
import math
N = int(input())
ans = 0
for i in range(N):
num = int(input())
rt = math.ceil(math.sqrt(num))
div = 2
while (rt > div):
if num % div:
div += 1
else:
break
if div == rt:
ans += 1
print(ans)
|
s582134924
|
Accepted
| 1,130
| 5,672
| 358
|
import math
N = int(input())
ans = 0
for i in range(N):
num = int(input())
if num == 2:
ans +=1
continue
rt = math.ceil(math.sqrt(num))
div = 2
bool = True
while (rt >= div):
if num % div:
div += 1
else:
bool = False
break
if bool:
ans += 1
print(ans)
|
s229578682
|
p03685
|
u923270446
| 2,000
| 262,144
|
Wrong Answer
| 468
| 42,676
| 546
|
Snuke is playing a puzzle game. In this game, you are given a rectangular board of dimensions R × C, filled with numbers. Each integer i from 1 through N is written twice, at the coordinates (x_{i,1},y_{i,1}) and (x_{i,2},y_{i,2}). The objective is to draw a curve connecting the pair of points where the same integer is written, for every integer from 1 through N. Here, the curves may not go outside the board or cross each other. Determine whether this is possible.
|
import cmath
r, c, n = map(int, input().split())
lis = []
for i in range(n):
x1, y1, x2, y2 = map(int, input().split())
if 0 < x1 < r and 0 < x2 < r and 0 < y1 < c and 0 < y2 < c:
continue
else:
lis.append((i, x1 - r / 2 + (y1 - c / 2) * 1j))
lis.append((i, x2 - r / 2 + (y2 - c / 2) * 1j))
lis.sort(key=lambda x: cmath.phase(x[1]))
stack = []
for i in lis:
if stack == [] or stack[-1] != i[0]:
stack.append(i[0])
else:
stack.pop()
if stack == []:
print("YES")
else:
print("NO")
|
s415308196
|
Accepted
| 474
| 42,720
| 567
|
import cmath
r, c, n = map(int, input().split())
lis = []
for i in range(n):
x1, y1, x2, y2 = map(int, input().split())
if (0 < x1 < r and 0 < y1 < c) or (0 < x2 < r and 0 < y2 < c):
continue
else:
lis.append((i, x1 - r / 2 + (y1 - c / 2) * 1j))
lis.append((i, x2 - r / 2 + (y2 - c / 2) * 1j))
lis.sort(key=lambda x: cmath.phase(x[1]))
stack = []
for i in lis:
if stack == [] or stack[-1] != i[0]:
stack.append(i[0])
else:
stack.pop()
if stack == []:
print("YES")
else:
print("NO")
|
s276370592
|
p03826
|
u256868077
| 2,000
| 262,144
|
Wrong Answer
| 22
| 3,316
| 52
|
There are two rectangles. The lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B. The lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D. Print the area of the rectangle with the larger area. If the two rectangles have equal areas, print that area.
|
a,b,c,d=map(int,input().split())
print(max(a*d,c*d))
|
s928552986
|
Accepted
| 17
| 2,940
| 53
|
a,b,c,d=map(int,input().split())
print(max(a*b,c*d))
|
s687757643
|
p03943
|
u589381719
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 83
|
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
n=list(map(int,input().split()))
n.sort()
print("YES" if n[2]==n[0]+n[1] else "NO")
|
s568788248
|
Accepted
| 17
| 2,940
| 83
|
n=list(map(int,input().split()))
n.sort()
print("Yes" if n[2]==n[0]+n[1] else "No")
|
s271020854
|
p00002
|
u889593139
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,588
| 118
|
Write a program which computes the digit number of sum of two integers a and b.
|
while True:
try:
a, b = map(int, input().split())
print(len(list(a+b)))
except:
break
|
s395955333
|
Accepted
| 20
| 5,584
| 109
|
while True:
try:
print(len(str(sum(list(map(int, input().split()))))))
except:
break
|
s702571875
|
p03407
|
u618373524
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 66
|
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
a,b,c = map(int,input().split())
print("YES" if a+b >= c else"NO")
|
s823493699
|
Accepted
| 17
| 2,940
| 66
|
a,b,c = map(int,input().split())
print("Yes" if a+b >= c else"No")
|
s531335503
|
p03474
|
u771532493
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 227
|
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
|
A,B=map(int,input().split())
S=input()
ass=True
for i in range(len(S)):
if i==A-1:
if S[i]!='-':
ass=False
break
else:
if S[i]=='-':
ass=False
break
if ass:
print('Yes')
else:
print('No')
|
s500679893
|
Accepted
| 18
| 3,060
| 226
|
A,B=map(int,input().split())
S=input()
ass=True
for i in range(len(S)):
if i==A:
if S[i]!='-':
ass=False
break
else:
if S[i]=='-':
ass=False
break
if ass:
print('Yes')
else:
print('No')
|
s711759662
|
p03080
|
u997641430
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 142
|
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
|
N=int(input())
s=input()
r=0
b=0
for _ in s:
if s=='R':
r+=1
else:
b+=1
if r>b:
print('Yes')
else:
print('No')
|
s165530778
|
Accepted
| 17
| 2,940
| 92
|
input()
S=list(input())
if S.count('R')>S.count('B'):
print('Yes')
else:
print('No')
|
s401323878
|
p03149
|
u923181378
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 86
|
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".
|
a=list(input().split())
a.sort()
b=[1,7,9,4]
if a==b:
print('YES')
else: print('NO')
|
s810512557
|
Accepted
| 18
| 2,940
| 95
|
a=list(map(int,input().split()))
a.sort()
b=[1,4,7,9]
if a==b:
print('YES')
else: print('NO')
|
s297819645
|
p02601
|
u048947465
| 2,000
| 1,048,576
|
Wrong Answer
| 28
| 9,132
| 356
|
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
|
r, g, b = [int(x) for x in input().split()]
times = int(input())
def check(r, g, b, times):
while True:
if b > g > r:
return 'Yes'
elif b < g:
times -= 1
b *= 2
elif g < r:
times -= 1
g *= 2
if times > -1:
return 'No'
print(check(r, g, b, times))
|
s934816832
|
Accepted
| 27
| 9,164
| 357
|
r, g, b = [int(x) for x in input().split()]
times = int(input())
def check(r, g, b, times):
while True:
if b > g > r:
return 'Yes'
elif b <= g:
times -= 1
b *= 2
elif g <= r:
times -= 1
g *= 2
if times < 0:
return 'No'
print(check(r, g, b, times))
|
s808088849
|
p03387
|
u079022693
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 369
|
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
|
from sys import stdin
def main():
readline=stdin.readline
a,b,c=map(int,readline().split())
li=[a,b,c]
li.sort()
x=li[0]
y=li[1]
z=li[2]
cnt=0
cnt+=z-y
x+=z-y
y+=z-y
print(x,y,z)
if (z-x)%2==0:
cnt+=(z-x)//2
else:
cnt+=(z-x+1)//2+1
print(cnt)
if __name__=="__main__":
main()
|
s039488581
|
Accepted
| 17
| 3,064
| 352
|
from sys import stdin
def main():
readline=stdin.readline
a,b,c=map(int,readline().split())
li=[a,b,c]
li.sort()
x=li[0]
y=li[1]
z=li[2]
cnt=0
cnt+=z-y
x+=z-y
y+=z-y
if (z-x)%2==0:
cnt+=(z-x)//2
else:
cnt+=(z-x+1)//2+1
print(cnt)
if __name__=="__main__":
main()
|
s575528416
|
p03659
|
u737298927
| 2,000
| 262,144
|
Wrong Answer
| 144
| 24,812
| 208
|
Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it. They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card. Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively. They would like to minimize |x-y|. Find the minimum possible value of |x-y|.
|
n = int(input())
a = list(map(int, input().split()))
x = 0
y = sum(a)
ans = float("inf")
for i in range(n):
x += a[i]
y -= a[i]
if i == 0 or i == n:
ans = min(ans, abs(x - y))
print(ans)
|
s348497852
|
Accepted
| 206
| 24,832
| 206
|
n = int(input())
a = list(map(int, input().split()))
x = 0
y = sum(a)
ans = float("inf")
for i in range(n):
x += a[i]
y -= a[i]
if not i == n - 1:
ans = min(ans, abs(x - y))
print(ans)
|
s601513872
|
p02972
|
u490642448
| 2,000
| 1,048,576
|
Wrong Answer
| 47
| 7,148
| 341
|
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
|
#import numpy as np
n = int(input())
a_s = list(map(int, input().split()))
n = 3
a_s =[1,0,0]
ans = [0]*(n+1)
#ans = np.zeros(n+1).astype(int)
i=1
for i in range(n,0,-1):
sum_num = 0
for j in range(i,n+1,i):
sum_num += ans[j]
if((sum_num & 1) != a_s[i-1]):
ans[i] = 1
print(' '.join(map(str,ans[1:])))
|
s023805913
|
Accepted
| 604
| 19,772
| 419
|
#import numpy as np
n = int(input())
a_s = list(map(int, input().split()))
m = 0
ans = [0]*(n+1)
#ans = np.zeros(n+1).astype(int)
i=1
for i in range(n,0,-1):
sum_num = 0
for j in range(i,n+1,i):
sum_num += ans[j]
if((sum_num & 1) != a_s[i-1]):
m += 1
ans[i] = 1
ans2 = []
for i in range(1,n+1):
if ans[i]==1:
ans2.append(i)
print(m)
print(' '.join(map(str,ans2)))
|
s908389951
|
p02833
|
u619144316
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 187
|
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
|
N = int(input())
if N % 2 == 1:
print(0)
else:
cnt = 0
for i in range(0,30):
tmp = 10*(5**i)
a = N // tmp
print(tmp,a)
cnt += a
print(cnt)
|
s332678047
|
Accepted
| 17
| 2,940
| 166
|
N = int(input())
if N % 2 == 1:
print(0)
else:
cnt = 0
for i in range(0,30):
tmp = 10*(5**i)
a = N // tmp
cnt += a
print(cnt)
|
s060278879
|
p03047
|
u858485368
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 45
|
Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers?
|
N, K= map(int, input().split())
print(N+1+K)
|
s957284925
|
Accepted
| 17
| 2,940
| 45
|
N, K= map(int, input().split())
print(N+1-K)
|
s585505804
|
p03611
|
u968404618
| 2,000
| 262,144
|
Wrong Answer
| 127
| 27,360
| 219
|
You are given an integer sequence of length N, a_1,a_2,...,a_N. For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices.
|
import collections
n = int(input())
A = list(map(int, input().split()))
x = []
x_append = x.append
for a in A:
x_append(a-1)
x_append(a)
x_append(a+1)
X = collections.Counter(x)
print(X.most_common(1))
|
s258280778
|
Accepted
| 146
| 35,440
| 202
|
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
B = []
for a in A:
B.append(a-1)
B.append(a)
B.append(a+1)
C = Counter(B)
print(C.most_common()[0][1])
|
s503835185
|
p02694
|
u594803920
| 2,000
| 1,048,576
|
Wrong Answer
| 22
| 9,168
| 102
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
x = int(input())
m = 100
year = 0
while m <= x:
year += 1
m *= 1.01
m = int(m)
print(year)
|
s231224515
|
Accepted
| 22
| 9,164
| 101
|
x = int(input())
m = 100
year = 0
while m < x:
year += 1
m *= 1.01
m = int(m)
print(year)
|
s331937718
|
p03623
|
u432805419
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 119
|
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
a = list(map(int,input().split()))
b = abs(a[0] - a[1])
c = abs(a[0] - a[2])
if b <= c:
print("B")
else:
print("C")
|
s843112405
|
Accepted
| 17
| 2,940
| 119
|
a = list(map(int,input().split()))
b = abs(a[0] - a[1])
c = abs(a[0] - a[2])
if b <= c:
print("A")
else:
print("B")
|
s114098208
|
p03387
|
u403331159
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 139
|
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
|
a=list(map(int,input().split()))
a.sort()
cnt=0
cnt+=a[2]-a[1]
a[0]+=cnt
if a[0]%2==0:
cnt+=a[2]-a[0]
else:
cnt+=a[2]-a[0]+1
print(cnt)
|
s345971885
|
Accepted
| 18
| 3,188
| 414
|
import math
a=list(map(int,input().split()))
a.sort()
cnt=0
if a[0]==a[1]==a[2]:
print(0)
exit()
if a[0]==[1]:
print(a[2]-a[1])
exit()
if a[1]==a[2]:
if (a[2]-a[0])%2==0:
print(math.ceil((a[2]-a[0])/2))
exit()
else:
print(math.ceil((a[2]-a[0])/2+1))
exit()
cnt+=a[2]-a[1]
a[0]+=cnt
if (a[2]-a[0])%2==0:
cnt+=math.ceil((a[2]-a[0])/2)
else:
cnt+=math.ceil((a[2]-a[0])/2+1)
print(cnt)
|
s485904962
|
p03435
|
u572561929
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 363
|
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct.
|
c = ['' for _ in range(3)]
c[0] = list(map(int, input().split()))
c[1] = list(map(int, input().split()))
c[2] = list(map(int, input().split()))
ans = 'Yes'
print(c)
for i in range(2):
for j in range(2):
if c[i][j] + c[i + 1][j + 1] != c[i][j + 1] + c[i + 1][j]:
ans = 'No'
break
else:
continue
break
print(ans)
|
s500490378
|
Accepted
| 17
| 3,064
| 445
|
c = ['' for _ in range(3)]
c[0] = list(map(int, input().split()))
c[1] = list(map(int, input().split()))
c[2] = list(map(int, input().split()))
ans = 'Yes'
for i in range(2):
line = [0 for _ in range(3)]
column = [0 for _ in range(3)]
for j in range(3):
line[j] = c[i + 1][j] - c[i][j]
column[j] = c[i + 1][j] - c[i][j]
if len(set(line)) != 1 or len(set(column)) != 1:
ans = 'No'
break
print(ans)
|
s644497203
|
p03679
|
u739843002
| 2,000
| 262,144
|
Wrong Answer
| 33
| 9,100
| 155
|
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
|
tmp = input().split(" ")
X = int(tmp[0])
A = int(tmp[1])
B = int(tmp[2])
print("delicious") if B <= A else print("safe") if B <= X else print("dangerous")
|
s122630207
|
Accepted
| 22
| 9,132
| 160
|
tmp = input().split(" ")
X = int(tmp[0])
A = int(tmp[1])
B = int(tmp[2])
print("delicious") if B <= A else print("safe") if B <= A + X else print("dangerous")
|
s221473510
|
p03369
|
u500279510
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 70
|
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
|
S = input()
ra = 700
s = S.count('○')
fra = ra + 100 * s
print(fra)
|
s067692923
|
Accepted
| 17
| 2,940
| 68
|
S = input()
ra = 700
s = S.count('o')
fra = ra + 100 * s
print(fra)
|
s601490111
|
p03023
|
u989326345
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 3,060
| 40
|
Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees, but do not print units.
|
N=int(input())
ans=180*(N-1)
print(ans)
|
s583484396
|
Accepted
| 17
| 2,940
| 40
|
N=int(input())
ans=180*(N-2)
print(ans)
|
s327570226
|
p03601
|
u555811857
| 3,000
| 262,144
|
Wrong Answer
| 23
| 3,188
| 947
|
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the beaker. * Operation 3: Put C grams of sugar into the beaker. * Operation 4: Put D grams of sugar into the beaker. In our experimental environment, E grams of sugar can dissolve into 100 grams of water. Snuke will make sugar water with the highest possible density. The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted. We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.
|
# -*- coding: utf-8 -*-
import heapq
import math
tmp = input()
A, B, C, D, E, F = [int(a) for a in tmp.split()]
n1, n2 = [F // (a * 100) for a in [A, B]]
ws = []
for i in range(n1+1):
for j in range(n2+1):
if i == 0 and j == 0: continue
a1, a2 = i, j
w = (a1 * A + a2 * B) * 100
if w <= F:
ws.append(w)
else:
break
ws = sorted(ws)
ss = []
for w in ws:
remain = F - w
max_sugar = w / 100.0 * E
max_sugar = min(remain, max_sugar)
x = 0
max_tmp = -1
while x * C < max_sugar:
y = (max_sugar - (x * C) ) // D
s = x*C + y*D
if s > max_tmp:
max_tmp = s
x += 1
ss.append([w, max_tmp])
max_tmp = None
for i, a in enumerate(ss):
noudo = 1.0 * a[1] / (a[0] + a[1])
if max_tmp is None or max_tmp[2] < noudo:
max_tmp = [a[0], a[1], noudo]
print(max_tmp[0]+max_tmp[1], max_tmp[1])
|
s620565322
|
Accepted
| 23
| 3,188
| 957
|
# -*- coding: utf-8 -*-
import heapq
import math
tmp = input()
A, B, C, D, E, F = [int(a) for a in tmp.split()]
n1, n2 = [F // (a * 100) for a in [A, B]]
ws = []
for i in range(n1+1):
for j in range(n2+1):
if i == 0 and j == 0: continue
a1, a2 = i, j
w = (a1 * A + a2 * B) * 100
if w <= F:
ws.append(w)
else:
break
ws = sorted(ws)
ss = []
for w in ws:
remain = F - w
max_sugar = w / 100.0 * E
max_sugar = min(remain, max_sugar)
x = 0
max_tmp = -1
while x * C < max_sugar:
y = (max_sugar - (x * C) ) // D
s = x*C + y*D
if s > max_tmp:
max_tmp = s
x += 1
ss.append([w, max_tmp])
max_tmp = None
for i, a in enumerate(ss):
noudo = 1.0 * a[1] / (a[0] + a[1])
if max_tmp is None or max_tmp[2] < noudo:
max_tmp = [a[0], a[1], noudo]
print(int(max_tmp[0]+max_tmp[1]), int(max_tmp[1]))
|
s128283428
|
p04035
|
u231685196
| 2,000
| 262,144
|
Wrong Answer
| 288
| 31,028
| 531
|
We have N pieces of ropes, numbered 1 through N. The length of piece i is a_i. At first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly: * Choose a (connected) rope with a total length of at least L, then untie one of its knots. Is it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.
|
n,l = map(int,input().split())
arr = list(map(int,input().split()))
ext = [[i,arr[i]] for i in range(n)]
ext.sort(key=lambda x:x[1])
if ext[-1][1] + ext[-2][1] < l:
print("Impossible")
else:
print("Possibble")
resolved = set()
resolved.add(0)
resolved.add(n)
for i in range(n):
left = ext[i][0]
right = left+1
if left not in resolved:
print(left)
resolved.add(left)
if right not in resolved:
print(right)
resolved.add(right)
|
s404459123
|
Accepted
| 127
| 14,180
| 465
|
n,l = map(int,input().split())
arr = list(map(int,input().split()))
key = 0
flag = False
for i in range(n-1):
if arr[i] + arr[i+1] >= l:
key = [i,i+1]
flag = True
break
# print(key)
if flag:
print("Possible")
for i in range(key[0]):
print(i+1)
temp = []
for i in range(key[1]+1,n):
temp.append(i)
temp.reverse()
for t in temp:
print(t)
print(key[1])
else:
print("Impossible")
|
s951829989
|
p04029
|
u883048396
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,316
| 74
|
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
def calcTriangle(x):
return x*(x-1)//2
print(calcTriangle(int(input())))
|
s896681757
|
Accepted
| 19
| 3,316
| 75
|
def calcTriangle(x):
return x*(x+1)//2
print(calcTriangle(int(input())))
|
s753470108
|
p02613
|
u025236579
| 2,000
| 1,048,576
|
Wrong Answer
| 150
| 16,120
| 460
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
def judge_status_summary():
N = int(input())
S = [input() for _ in range(N)]
result_list = ['AC', 'WA', 'TLE', 'RE']
count_list = [0, 0, 0, 0]
for i in range(N):
one_count_up_inxex = result_list.index(S[i])
count_list[one_count_up_inxex] += 1
for i in range(4):
print(result_list[i], '×', count_list[i])
judge_status_summary()
|
s077720293
|
Accepted
| 147
| 16,224
| 459
|
def judge_status_summary():
N = int(input())
S = [input() for _ in range(N)]
result_list = ['AC', 'WA', 'TLE', 'RE']
count_list = [0, 0, 0, 0]
for i in range(N):
one_count_up_inxex = result_list.index(S[i])
count_list[one_count_up_inxex] += 1
for i in range(4):
print(result_list[i], 'x', count_list[i])
judge_status_summary()
|
s589313350
|
p03469
|
u233131404
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 92
|
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
|
a=str(input())
if a[:8]=="2017/01/":
A="2017/01/"+a[-2:]
print(A)
else:
print(a)
|
s236523713
|
Accepted
| 17
| 2,940
| 92
|
a=str(input())
if a[:8]=="2017/01/":
A="2018/01/"+a[-2:]
print(A)
else:
print(a)
|
s052915189
|
p03409
|
u231095456
| 2,000
| 262,144
|
Wrong Answer
| 21
| 3,316
| 475
|
On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.
|
N = int(input())
red = [tuple(map(int,input().split())) for _ in range(N)]
blue = [tuple(map(int,input().split())) for _ in range(N)]
red.sort(key=lambda x:x[0])
red.sort(key=lambda x:x[1])
blue.sort(key=lambda x:x[0])
blue.sort(key=lambda x:x[1])
ans = 0
for i in range(N):
a,b = red[i]
for j in range(len(blue)):
c,d = blue[j]
if a < c and b < d:
print(a,b,c,d)
blue.pop(j)
ans += 1
break
print(ans)
|
s650048856
|
Accepted
| 19
| 3,064
| 408
|
N = int(input())
red = [tuple(map(int,input().split())) for _ in range(N)]
blue = [tuple(map(int,input().split())) for _ in range(N)]
red.sort(key=lambda x:x[0], reverse=True)
blue.sort(key=lambda x:x[1])
ans = 0
for i in range(N):
a,b = red[i]
for j in range(len(blue)):
c,d = blue[j]
if a < c and b < d:
blue.pop(j)
ans += 1
break
print(ans)
|
s709800116
|
p03598
|
u999503965
| 2,000
| 262,144
|
Wrong Answer
| 28
| 9,028
| 145
|
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N. When activated, each type of robot will operate as follows. * When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. * When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.
|
n=int(input())
k=int(input())
l=list(map(int,input().split()))
ans=0
for i in l:
if i>=k/2:
ans+=abs(k-i)*2
else:
ans+=i
print(ans)
|
s581690066
|
Accepted
| 29
| 9,192
| 148
|
n=int(input())
k=int(input())
l=list(map(int,input().split()))
ans=0
for i in l:
if i>=k/2:
ans+=abs(k-i)*2
else:
ans+=i*2
print(ans)
|
s690253198
|
p03564
|
u757030836
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 157
|
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.
|
n = int(input())
k = int(input())
ans = 1
for i in range(n):
if ans + k >= ans*2:
ans += k
if ans + k < ans*2:
ans = ans * 2
print(ans)
|
s181921952
|
Accepted
| 17
| 2,940
| 157
|
n = int(input())
k = int(input())
ans = 1
for i in range(n):
if ans + k <= ans*2:
ans += k
if ans + k > ans*2:
ans = ans * 2
print(ans)
|
s599890523
|
p03359
|
u131405882
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 72
|
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
|
a, b = map(int,input().split())
if a > b:
print(a)
else:
print(a + 1)
|
s831670474
|
Accepted
| 17
| 2,940
| 70
|
a, b = map(int,input().split())
if a > b:
print(a-1)
else:
print(a)
|
s369226572
|
p03644
|
u305965165
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 98
|
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
n = int(input())
res = 1
for i in range(10):
if 2**i > n:
res = 2**(i-1)
print(res)
|
s943177194
|
Accepted
| 17
| 2,940
| 112
|
n = int(input())
res = 1
for i in range(10):
if 2**i > n:
res = 2**(i-1)
break
print(res)
|
s627405674
|
p03693
|
u973053237
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 87
|
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
a,b,c=map(int,input().split())
if (10*b+c)%4==0:
print("Yes")
else:
print("No")
|
s823806566
|
Accepted
| 17
| 2,940
| 87
|
a,b,c=map(int,input().split())
if (10*b+c)%4==0:
print("YES")
else:
print("NO")
|
s139746677
|
p03853
|
u226155577
| 2,000
| 262,144
|
Wrong Answer
| 23
| 3,064
| 51
|
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
|
for i in open(0).read().split()[1:]:print(i+"\n"+i)
|
s246279137
|
Accepted
| 23
| 3,064
| 51
|
for i in open(0).read().split()[2:]:print(i+"\n"+i)
|
s635362272
|
p03485
|
u780354103
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 109
|
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a,b = map(int, input().split())
if (a + b) % 2 == 0:
print((a + b) / 2)
else:
print((a + b) / 2 + 1)
|
s822055137
|
Accepted
| 17
| 2,940
| 62
|
a,b = map(int,open(0).read().split())
print(-(-(a + b) // 2))
|
s586400065
|
p03372
|
u347640436
| 2,000
| 262,144
|
Wrong Answer
| 873
| 24,896
| 734
|
"Teishi-zushi", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter. Nakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories. Nakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter. Whenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger.
|
N, C = map(int, input().split())
x = [None] * N
v = [None] * N
for i in range(N):
x[i], v[i] = map(int, input().split())
a0 = [None] * N
a = v[0] - x[0]
a0[0] = max(0, a)
for i in range(1, N):
a += v[i] - (x[i] - x[i - 1])
a0[i] = max(a, a0[i - 1])
a1 = [None] * N
a = v[N - 1] - (C - x[N - 1])
a1[0] = max(0, a)
for i in range(1, N):
print(a, (C - x[N - 1 - (i - 1)]), (C - x[N - 1 - i]))
a += v[N - 1 - i] - ((C - x[N - 1 - (i - 1)]) - (C - x[N - 1 - i]))
a1[i] = max(a, a1[i - 1])
result = max(a0[N - 1], a1[N - 1])
for i in range(N):
result = max(result, a0[i] - x[i] + a1[N - 1 - (i + 1)])
for i in range(N):
result = max(result, a1[i] - (C - x[N - 1 - i]) + a0[N - 1 - (i + 1)])
print(result)
|
s539700714
|
Accepted
| 583
| 20,176
| 683
|
N, C = map(int, input().split())
x = [None] * N
v = [None] * N
for i in range(N):
x[i], v[i] = map(int, input().split())
a0 = [None] * N
a = v[0] - x[0]
a0[0] = max(0, a)
for i in range(1, N):
a += v[i] - (x[i] - x[i - 1])
a0[i] = max(a, a0[i - 1])
a1 = [None] * N
a = v[N - 1] - (C - x[N - 1])
a1[0] = max(0, a)
for i in range(1, N):
a += v[N - 1 - i] - ((C - x[N - 1 - i]) - (C - x[N - 1 - (i - 1)]))
a1[i] = max(a, a1[i - 1])
result = max(a0[N - 1], a1[N - 1])
for i in range(N - 1):
result = max(result, a0[i] - x[i] + a1[N - 1 - (i + 1)])
for i in range(N - 1):
result = max(result, a1[i] - (C - x[N - 1 - i]) + a0[N - 1 - (i + 1)])
print(result)
|
s108926370
|
p02422
|
u957680575
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,512
| 321
|
Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
|
S=input()
m=int(input())
for i in range(m):
C=input().split()
a=int(C[1])-1
if a<0:
a=0
b=int(C[2])
if C[0]=="print":
print(S[a:b])
elif C[0]=="reverse":
S=S[:a]+S[b-len(S)-1:a-len(S)-1:-1]+S[b:]
elif C[0]=="replace":
S=S[:a]+C[3]+S[b:]
|
s806812235
|
Accepted
| 20
| 7,696
| 290
|
S=input()
m=int(input())
for i in range(m):
C=input().split()
a=int(C[1])
b=int(C[2])+1
if C[0]=="print":
print(S[a:b])
elif C[0]=="reverse":
S=S[:a]+S[b-len(S)-1:a-len(S)-1:-1]+S[b:]
elif C[0]=="replace":
S=S[:a]+C[3]+S[b:]
|
s931249104
|
p02396
|
u605451279
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,640
| 66
|
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
|
count = 0
while count < 1000:
count += 1
print("Hello World")
|
s029789819
|
Accepted
| 140
| 5,604
| 150
|
count = 0
for i in range(10000):
a = input()
a = int(a)
if a > 0:
count += 1
print('Case '+str(count)+': '+str(a))
else:
break
|
s890086998
|
p02678
|
u970308980
| 2,000
| 1,048,576
|
Wrong Answer
| 775
| 41,220
| 592
|
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
import sys
from collections import defaultdict, deque
sys.setrecursionlimit(10 ** 7)
# ----------
INF = float("inf")
MOD = 10 ** 9 + 7
# ----------
N, M = map(int, input().split())
G = defaultdict(list)
for i in range(M):
a, b = map(int, input().split())
a -= 1
b -= 1
G[a].append(b)
G[b].append(a)
q = deque()
ans = [-1 for _ in range(N)]
ans[0] = 0
q.append(0)
while q:
v = q.popleft()
for u in G[v]:
if ans[u] != -1:
continue
ans[u] = v + 1
q.append(u)
for i in range(1,N):
print(ans[i])
|
s556375450
|
Accepted
| 739
| 41,280
| 605
|
import sys
from collections import defaultdict, deque
sys.setrecursionlimit(10 ** 7)
# ----------
INF = float("inf")
MOD = 10 ** 9 + 7
# ----------
N, M = map(int, input().split())
G = defaultdict(list)
for i in range(M):
a, b = map(int, input().split())
a -= 1
b -= 1
G[a].append(b)
G[b].append(a)
q = deque()
ans = [-1 for _ in range(N)]
ans[0] = 0
q.append(0)
while q:
v = q.popleft()
for u in G[v]:
if ans[u] != -1:
continue
ans[u] = v + 1
q.append(u)
print('Yes')
for i in range(1,N):
print(ans[i])
|
s823990946
|
p03455
|
u279649868
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 94
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a,b=map(int,input().split())
product=a*b
if product%2==0:
print("even")
else:
print("odd")
|
s184101009
|
Accepted
| 17
| 2,940
| 95
|
a,b=map(int,input().split())
product=a*b
if product%2==0:
print("Even")
else:
print("Odd")
|
s297399002
|
p03457
|
u546074985
| 2,000
| 262,144
|
Wrong Answer
| 515
| 27,300
| 684
|
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
if __name__ == '__main__':
N = int(input()) + 1
P = [list(map(int, input().split())) for x in range(N-1)]
P.insert(0, [0,0,0])
#print(N, P)
for i in range(1, N):
t = abs(P[i-1][0] - P[i][0])
if t%2 == 0:
if (abs( sum(P[i-1][1:]) - sum(P[i][1:]) ) <= t) and (abs( sum(P[i-1][1:]) - sum(P[i][1:]))) % 2 == 0:
pass
else:
break
else:
if (abs( sum(P[i-1][1:]) - sum(P[i][1:]) ) <= t) and (abs( sum(P[i-1][1:]) - sum(P[i][1:]))) % 2 == 1:
pass
else:
break
else:
print('OK')
exit()
print('NO')
|
s653874050
|
Accepted
| 509
| 27,300
| 685
|
if __name__ == '__main__':
N = int(input()) + 1
P = [list(map(int, input().split())) for x in range(N-1)]
P.insert(0, [0,0,0])
#print(N, P)
for i in range(1, N):
t = abs(P[i-1][0] - P[i][0])
if t%2 == 0:
if (abs( sum(P[i-1][1:]) - sum(P[i][1:]) ) <= t) and (abs( sum(P[i-1][1:]) - sum(P[i][1:]))) % 2 == 0:
pass
else:
break
else:
if (abs( sum(P[i-1][1:]) - sum(P[i][1:]) ) <= t) and (abs( sum(P[i-1][1:]) - sum(P[i][1:]))) % 2 == 1:
pass
else:
break
else:
print('Yes')
exit()
print('No')
|
s462235770
|
p03456
|
u146803137
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 288
|
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
import math
def py():
print("Yes")
def pn():
print("No")
def iin():
x = int(input())
return x
neko = 0
nya = 0
nuko = 0
a,b = input().split()
neko = int(a + b)
for i in range(100):
if i*i == neko:
print(i)
nya = 1
break
if(nya == 0):
pn()
|
s129846874
|
Accepted
| 18
| 3,060
| 285
|
import math
def py():
print("Yes")
def pn():
print("No")
def iin():
x = int(input())
return x
neko = 0
nya = 0
nuko = 0
a,b = input().split()
neko = int(a + b)
for i in range(1000):
if i*i == neko:
py()
nya = 1
break
if(nya == 0):
pn()
|
s223963697
|
p03609
|
u710789518
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 51
|
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
|
X, t = map(int, input().split())
print(min(0, X-t))
|
s197681848
|
Accepted
| 17
| 2,940
| 51
|
X, t = map(int, input().split())
print(max(0, X-t))
|
s218819625
|
p03435
|
u048867491
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 260
|
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct.
|
c=[]
for _ in range(3):
c.append( list(map(int,input().split())))
ans = True
a=[c[0][0],c[1][0],c[2][0]]
b=[c[0][0]-a[0],c[0][1]-a[0],c[0][2]-a[0]]
for i in range(3):
for j in range(3):
if c[i][j] != a[i]+b[j]:
ans = False
print(ans)
|
s363932962
|
Accepted
| 17
| 3,064
| 261
|
c=[]
for _ in range(3):
c.append( list(map(int,input().split())))
ans = "Yes"
a=[c[0][0],c[1][0],c[2][0]]
b=[c[0][0]-a[0],c[0][1]-a[0],c[0][2]-a[0]]
for i in range(3):
for j in range(3):
if c[i][j] != a[i]+b[j]:
ans = "No"
print(ans)
|
s402398023
|
p03377
|
u281303342
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,316
| 63
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
A,B,X = map(int,input().split())
print("Yes" if X<=B else "No")
|
s895074120
|
Accepted
| 18
| 2,940
| 406
|
# Python3 (3.4.3)
import sys
input = sys.stdin.readline
# -------------------------------------------------------------
# function
# -------------------------------------------------------------
# -------------------------------------------------------------
# main
# -------------------------------------------------------------
A,B,X = map(int,input().split())
print("YES" if A <= X <= A+B else "NO")
|
s820661188
|
p03063
|
u550943777
| 2,000
| 1,048,576
|
Wrong Answer
| 55
| 3,500
| 150
|
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.
|
N = int(input())
s = input()
cnt = 0
if '
for i in range(1,N):
if s[i] == '.' and s[i-1] == '#':
cnt += 1
print(cnt)
|
s461399763
|
Accepted
| 103
| 3,500
| 205
|
N = int(input())
s = input()
white = s.count('.')
black = 0
cnt = black + white
for i in s:
if i == '#':
black += 1
else:
white -= 1
cnt = min(cnt,black + white)
print(cnt)
|
s826705811
|
p03080
|
u481244478
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 213
|
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
|
cnt = int(input())
color = input()
r_c = 0
b_c = 0
for i in range(cnt):
if color[i] == 'R':
r_c += 1
elif color[i] == 'B':
b_c += 1
if r_c > b_c:
print("YES")
else:
print("NO")
|
s196208971
|
Accepted
| 17
| 2,940
| 213
|
cnt = int(input())
color = input()
r_c = 0
b_c = 0
for i in range(cnt):
if color[i] == 'R':
r_c += 1
elif color[i] == 'B':
b_c += 1
if r_c > b_c:
print("Yes")
else:
print("No")
|
s852742335
|
p03626
|
u788068140
| 2,000
| 262,144
|
Wrong Answer
| 29
| 9,160
| 764
|
We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square. Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors. Find the number of such ways to paint the dominoes, modulo 1000000007. The arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner: * Each domino is represented by a different English letter (lowercase or uppercase). * The j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.
|
N = int(input())
S1 = input()
S2 = input()
def prepare(s1,s2,n):
result = []
i = 0
while i < n:
if s1[i] == s2[i]:
result.append(1)
i += 1
else:
result.append(0)
i += 2
return result
def calculate(arr):
ans = 3
for index in range(1, len(arr)):
#xo
if (arr[index - 1] == 1) and (arr[index] == 0):
ans *= 2
#xx
if (arr[index - 1] == 1) and (arr[index] == 1):
ans *= 2
#oo
if (arr[index - 1] == 0) and (arr[index] == 0):
ans *= 3
#ox
if (arr[index - 1] == 0) and (arr[index] == 1):
ans *= 1
print(ans % 1000000007)
arr = prepare(S1,S2,N)
calculate(arr)
|
s288272319
|
Accepted
| 29
| 9,232
| 904
|
N = int(input())
S1 = input()
S2 = input()
def prepare(s1,s2,n):
result = []
i = 0
while i < n:
if s1[i] == s2[i]:
result.append(1)
i += 1
else:
result.append(0)
i += 2
return result
def calculate(arr):
ans = 1
for index in range(len(arr)):
if index == 0:
if arr[index] == 0:
ans = 6
else:
ans = 3
continue
#xo
if (arr[index - 1] == 1) and (arr[index] == 0):
ans *= 2
#xx
if (arr[index - 1] == 1) and (arr[index] == 1):
ans *= 2
#oo
if (arr[index - 1] == 0) and (arr[index] == 0):
ans *= 3
#ox
if (arr[index - 1] == 0) and (arr[index] == 1):
ans *= 1
print(ans % 1000000007)
arr = prepare(S1,S2,N)
calculate(arr)
|
s774663330
|
p03671
|
u713627549
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 195
|
Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
|
#s = list(input())
s = input()
n = len(s)
count = 0
if n % 2 == 1:
count += 1
while s[0 : int((n-count)/2)] != s[int((n-count)/2) : n-count]:
count += 2
print(n-count)
|
s545942156
|
Accepted
| 18
| 2,940
| 122
|
#a, b, c = map(int, input().split())
abc = list(int(i) for i in input().split())
abc.sort()
z = abc[0] + abc[1]
print(z)
|
s682670072
|
p02255
|
u908984540
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,668
| 446
|
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
# -*- coding: utf-8 -*-
input_num = int(input())
num_list = [int(i) for i in input().split()]
for i in range(1, len(num_list)):
v = num_list[i]
j = i - 1
while j >= 0 and num_list[j] > v:
num_list[j+1] = num_list[j]
j -= 1
num_list[j+1] = v
for i in range(len(num_list)):
print(str(num_list[i]), end="")
if i < len(num_list)-1:
print(" ", end="")
else:
print()
|
s381909707
|
Accepted
| 20
| 5,980
| 299
|
def insertion_sort(A):
for i in range(1, len(A)):
v = A[i]
j = i - 1
print(*A)
while j >= 0 and A[j] > v:
A[j+1] = A[j]
A[j] = v
j -= 1
return A
n = input()
A = [int(x) for x in input().split()]
print(*insertion_sort(A))
|
s023152143
|
p03846
|
u127499732
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 8,756
| 138
|
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
|
n,l=int(input()),list(input())
f=any(l.count(l[i])!=2 and l.count(0)==1 for i in range(n))
print(2**(n//2)%1000000007 if f is True else 0)
|
s882528690
|
Accepted
| 58
| 14,316
| 373
|
def main():
from collections import Counter
n, *a = map(int, open(0).read().split())
c = Counter(a)
if n % 2 == 0:
f = all(x == 2 for x in c.values())
else:
g = c.pop(0) == 1
f = all(x == 2 for x in c.values()) and g
ans = 2 ** (n // 2) % 1000000007 if f is True else 0
print(ans)
if __name__ == '__main__':
main()
|
s763684552
|
p02394
|
u630518143
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,596
| 205
|
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.
|
nums = [int(e) for e in input().split()]
if (nums[2]+nums[4])<=nums[0] and (nums[3]+nums[4])<=nums[1] and (nums[3]-nums[4])>=nums[1] and (nums[3]-nums[4])>=nums[1]:
print("Yes")
else:
print("No")
|
s479204128
|
Accepted
| 20
| 5,604
| 193
|
nums = [int(e) for e in input().split()]
if (nums[2]+nums[4])<=nums[0] and (nums[3]+nums[4])<=nums[1] and (nums[2]-nums[4])>=0 and (nums[3]-nums[4])>=0:
print("Yes")
else:
print("No")
|
s058404998
|
p03379
|
u057109575
| 2,000
| 262,144
|
Wrong Answer
| 254
| 25,052
| 158
|
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
|
N, *X = map(int, open(0).read().split())
mid_l = sorted(X)[(N + 1) // 2 - 1]
mid_r = sorted(X)[(N + 1) // 2]
print([mid_l if v > mid_l else mid_r for v in X])
|
s869724316
|
Accepted
| 310
| 25,052
| 170
|
N, *X = map(int, open(0).read().split())
mid_l = sorted(X)[(N + 1) // 2 - 1]
mid_r = sorted(X)[(N + 1) // 2]
print(*[mid_l if v > mid_l else mid_r for v in X], sep='\n')
|
s589840691
|
p02396
|
u148628801
| 1,000
| 131,072
|
Wrong Answer
| 130
| 7,356
| 137
|
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
|
counter = 0
while True:
x = input()
if x == "0":
break
print("Case " + str(counter) + ":" + str(x))
counter += 1
|
s915108095
|
Accepted
| 120
| 7,328
| 138
|
counter = 1
while True:
x = input()
if x == "0":
break
print("Case " + str(counter) + ": " + str(x))
counter += 1
|
s400794384
|
p02614
|
u914802579
| 1,000
| 1,048,576
|
Wrong Answer
| 40
| 9,216
| 457
|
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
|
h,w,r = map(int,input().split())
l=[];an=0
cr=[];k=[0]*w
for i in range(h):
x=list(input())
l.append(x)
cr.append(x.count('#'))
for j in range(w):
if x[j]=='#':
k[j]+=1
ar=cr+k;tot=sum(cr)
tt=len(ar)
for i in range(1<<tt):
re=tot;rr=[]
cc=[]
for j in range(tt):
if i&(1<<j):
re-=ar[j]
if j>=h:
cc.append(h-j)
else:
rr.append(j)
#print(i,rr,cc,re)
if re==r:
an+=1
#print(i,re)
print(an)
|
s183253534
|
Accepted
| 46
| 9,200
| 526
|
h,w,r = map(int,input().split())
l=[];an=0
cr=[];k=[0]*w
for i in range(h):
x=list(input())
l.append(x)
cr.append(x.count('#'))
for j in range(w):
if x[j]=='#':
k[j]+=1
ar=cr+k;tot=sum(cr)
tt=len(ar)
for i in range(1<<tt):
re=tot;rr=[]
cc=[]
for j in range(tt):
if i&(1<<j):
re-=ar[j]
if j>=h:
cc.append(j-h)
else:
rr.append(j)
for j in rr:
for y in cc:
if l[j][y]=='#':
re+=1
#print(i,rr,cc,re)
if re==r:
an+=1
#print(i,re)
print(an)
|
s239466191
|
p02795
|
u628965061
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 77
|
We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all the squares in that column black. At least how many operations do you need in order to have N or more black squares in the grid? It is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.
|
h=int(input())
w=int(input())
n=int(input())
ans=n/(max(h,w))
print(int(ans))
|
s581701545
|
Accepted
| 17
| 2,940
| 100
|
import math
h=int(input())
w=int(input())
n=int(input())
ans=math.ceil(n/(max(h,w)))
print(int(ans))
|
s998344050
|
p04043
|
u077898957
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 95
|
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
A = sorted(map(int,input().split()))
print('Yes' if A[0]==5 and A[1]==5 and A[2]==7 else 'No')
|
s948082286
|
Accepted
| 17
| 2,940
| 91
|
A = sorted(input().split())
print('YES' if A[0]=='5' and A[1]=='5' and A[2]=='7' else 'NO')
|
s143500041
|
p03251
|
u374103100
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,064
| 378
|
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.sort()
y.sort()
if x[-1] < y[0]:
for i in range(x[-1], y[0]):
if X < i <= Y:
print("X({}) < i({}) <= Y({})".format(X, i, Y))
print("No War")
exit()
print("War")
|
s291039789
|
Accepted
| 18
| 3,060
| 384
|
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.sort()
y.sort()
if x[-1] < y[0]:
for i in range(x[-1]+1, y[0]+1):
if X < i <= Y:
print("No War")
exit()
print("War")
|
s346422634
|
p02612
|
u548976218
| 2,000
| 1,048,576
|
Wrong Answer
| 32
| 9,144
| 30
|
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input())
print(n%1000)
|
s550705268
|
Accepted
| 27
| 9,156
| 74
|
n = int(input())
if n%1000 == 0:
print(0)
else:
print(1000-n%1000)
|
s004672502
|
p03779
|
u390958150
| 2,000
| 262,144
|
Wrong Answer
| 66
| 3,536
| 95
|
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.
|
X = int(input())
count = 0
step = 0
while X > step:
count += 1
step += count
print(count)
|
s431048038
|
Accepted
| 34
| 2,940
| 73
|
X = int(input())
i = 0
while i * (i + 1) / 2 < X:
i += 1
print(i)
|
s022492341
|
p03067
|
u688126754
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 187
|
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
|
tmp_lst = input().split()
A, B, C = int(tmp_lst[0]), int(tmp_lst[1]), int(tmp_lst[2])
if A < C and C < B:
print("YES")
elif B < C and C < A:
print("YES")
else:
print("NO")
|
s662241233
|
Accepted
| 17
| 2,940
| 187
|
tmp_lst = input().split()
A, B, C = int(tmp_lst[0]), int(tmp_lst[1]), int(tmp_lst[2])
if A < C and C < B:
print("Yes")
elif B < C and C < A:
print("Yes")
else:
print("No")
|
s795543168
|
p04045
|
u634208461
| 2,000
| 262,144
|
Wrong Answer
| 19
| 2,940
| 185
|
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier.
|
import sys
N, K = map(int, input().split())
D = list(input().split())
for i in range(N, 100 * N):
for d in D:
if d not in str(i):
print(i)
sys.exit()
|
s301029019
|
Accepted
| 75
| 2,940
| 195
|
import sys
N, K = map(int, input().split())
D = list(input().split())
D = set(D)
for i in range(N, 100 * N):
if D & set(str(i)):
continue
else:
print(i)
sys.exit()
|
s907174592
|
p03854
|
u000842852
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,188
| 367
|
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
def main():
S = input()
while len(S)>=5:
if len(S)>=7 and S[:-7]=="dreamer":
S = S[-7:]
continue
elif len(S)>=6 and S[:-6]=="eraser":
S = S[-6:]
continue
elif S[:-5]=="dream" or S[:-5]=="erase":
S = S[-5:]
continue
else:
break
if len(S)==0:
print('Yes')
else:
print('No')
main()
|
s405319297
|
Accepted
| 71
| 3,244
| 363
|
def main():
S = input()
while len(S)>=5:
if len(S)>=7 and S[-7:]=="dreamer":
S = S[:-7]
continue
elif len(S)>=6 and S[-6:]=="eraser":
S = S[:-6]
continue
elif S[-5:]=="dream" or S[-5:]=="erase":
S = S[:-5]
continue
else:
break
if len(S)==0:
print('YES')
else:
print('NO')
main()
|
s483706325
|
p03795
|
u457554982
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 47
|
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
n=int(input())
ans=n*800-150*(n//15)
print(ans)
|
s648945444
|
Accepted
| 17
| 2,940
| 52
|
n=int(input())
ans=int(n*800-200*(n//15))
print(ans)
|
s407162882
|
p02841
|
u373047809
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 134
|
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month.
|
_,s=open(0)
c=0
for i in range(1000):
p=0;F=1
for j in str(i).zfill(3):
q=s[p:].find(j)
if q<0:F=0;break
p+=q+1
c+=F
print(c)
|
s857579606
|
Accepted
| 17
| 2,940
| 47
|
print(max(2-int(open(0).read().split()[3]), 0))
|
s885933757
|
p03455
|
u920103253
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 95
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a,b = [int(x) for x in input().split()]
if a*b//2==0:
print("Even")
else:
print("Odd")
|
s316093175
|
Accepted
| 17
| 2,940
| 96
|
a,b = [int(x) for x in input().split()]
if (a*b)%2==0:
print("Even")
else:
print("Odd")
|
s330048095
|
p03623
|
u957872856
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 91
|
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
a, b, c= map(int, input().split())
if abs(a-b) >= abs(a-c):
print("A")
else:
print("B")
|
s384046584
|
Accepted
| 18
| 2,940
| 77
|
x, a, b = map(int,input().split())
print("A" if abs(x-a) < abs(x-b) else "B")
|
s298274398
|
p03997
|
u453642820
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 55
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a,b,h=[int(input()) for i in range(3)]
print((a+b)*h/2)
|
s334118045
|
Accepted
| 17
| 2,940
| 60
|
a,b,h=[int(input()) for i in range(3)]
print(int((a+b)*h/2))
|
s715349977
|
p00001
|
u650459696
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,528
| 286
|
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
|
mt=[]
for i in range(10):
mt.append(int(input()))
high=[0,0,0]
for i in range(10):
if mt[i] > high[0]:
high=[mt[i]]+high[:2]
elif mt[i] > high[1]:
high=[high[0]]+[mt[1]]+[high[1]]
elif mt[i] > high[2]:
high=high[:2]+[mt[i]]
print(high,sep='\n')
|
s593867604
|
Accepted
| 30
| 7,640
| 278
|
mt=[]
high=[0,0,0]
for i in range(10):
mt.append(int(input()))
if mt[i] > high[0]:
high=[mt[i]]+high[:2]
elif mt[i] > high[1]:
high=[high[0]]+[mt[i]]+[high[1]]
elif mt[i] > high[2]:
high=high[:2]+[mt[i]]
print ('\n'.join(map(str,high)))
|
s965302213
|
p02578
|
u718536599
| 2,000
| 1,048,576
|
Wrong Answer
| 165
| 32,216
| 207
|
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
|
n=int(input())
a_list=list(map(int,input().split()))
b_list=[]
for i in range(n-1):
d=a_list[i]-a_list[i+1]
if(d>=0):
b_list.append(d)
a_list[i+1]+=d
ans=sum(b_list)
print(b_list)
print(ans)
|
s389348063
|
Accepted
| 158
| 31,996
| 193
|
n=int(input())
a_list=list(map(int,input().split()))
b_list=[]
for i in range(n-1):
d=a_list[i]-a_list[i+1]
if(d>=0):
b_list.append(d)
a_list[i+1]+=d
ans=sum(b_list)
print(ans)
|
s303432485
|
p03997
|
u890950695
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 210
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())
h = int(input())
print("{}".format((a+b)*h/2))
|
s354610955
|
Accepted
| 17
| 2,940
| 215
|
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())
h = int(input())
print("{:.0f}".format((a+b)*h/2))
|
s186226025
|
p03371
|
u170183831
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 218
|
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
|
a, b, c, x, y = map(int, input().split())
ret = 0
if 2 * c <= a + b:
m = min(x, y)
ret += m * c
x -= m
y -= m
ret += min(2 * c, a) * x
ret += min(2 * c, b) * y
else:
ret += a * x
ret += b * y
print(ret)
|
s508264674
|
Accepted
| 20
| 2,940
| 183
|
a, b, c, x, y = map(int, input().split())
ret = 0
if 2 * c <= a + b:
m = min(x, y)
ret += m * 2 * c
x -= m
y -= m
ret += min(2 * c, a) * x
ret += min(2 * c, b) * y
print(ret)
|
s964933017
|
p02578
|
u583276018
| 2,000
| 1,048,576
|
Wrong Answer
| 179
| 32,368
| 146
|
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
|
n = int(input())
a = list(map(int, input().split()))
m = 0
ma = a[0]
for i in range(1, n):
ma = max(ma, a[i])
m = max(m, ma-a[i])
print(m)
|
s233828848
|
Accepted
| 145
| 32,228
| 139
|
n = int(input())
a = list(map(int, input().split()))
m = 0
ma = a[0]
for i in range(1, n):
ma = max(ma, a[i])
m += ma-a[i]
print(m)
|
s696653449
|
p03997
|
u099212858
| 2,000
| 262,144
|
Wrong Answer
| 25
| 9,128
| 68
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a = int(input())
b = int(input())
h = int(input())
print((a+b)*h/2)
|
s659137700
|
Accepted
| 26
| 9,020
| 73
|
a = int(input())
b = int(input())
h = int(input())
print(int((a+b)*h/2))
|
s873250216
|
p02396
|
u967794515
| 1,000
| 131,072
|
Wrong Answer
| 120
| 7,544
| 194
|
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
|
# coding: utf-8
# Here your code !
i = 0
while i < 1000:
num = input().rstrip()
if int(num) > 0:
print("Case i: " + num)
else:
print("Case i: " + num)
break
|
s094629538
|
Accepted
| 130
| 7,592
| 196
|
# coding: utf-8
# Here your code !
i = 0
while i < 10000:
num = input().rstrip()
if int(num) > 0:
i += 1
print("Case " + str(i) + ": " + str(num))
else:
break
|
s702061719
|
p03386
|
u150641538
| 2,000
| 262,144
|
Wrong Answer
| 2,238
| 1,957,144
| 117
|
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
a,b,k=map(int,input().split())
l=[i for i in range(1,b+1)]
l=l[a-1:]
l=l[:k]+l[-k:]
l=set(l)
for i in l:
print(i)
|
s047603010
|
Accepted
| 18
| 3,064
| 161
|
a,b,k=map(int,input().split())
l=[i for i in range(a,min(a+k,b+1))]
s=[i for i in range(max(a,b-k+1),b+1)]
l=l+s
l=list(set(l))
l.sort()
for i in l:
print(i)
|
s995036175
|
p03609
|
u391328897
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 79
|
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
|
a, b = map(int, input().split())
if b-a > 0:
print(b-a)
else:
print(0)
|
s029831196
|
Accepted
| 17
| 2,940
| 79
|
a, b = map(int, input().split())
if a-b > 0:
print(a-b)
else:
print(0)
|
s109413846
|
p03494
|
u698919163
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 171
|
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
N = int(input())
A = list(map(int,input().split()))
ans = 0
for a in A:
if a % 2 == 0:
ans += 1
else:
print(0)
exit()
print(ans)
|
s343911890
|
Accepted
| 19
| 3,060
| 284
|
N = int(input())
A = list(map(int,input().split()))
ans = 0
flag = True
while flag == True:
for i in range(N):
if A[i] % 2 == 0:
A[i] = A[i]//2
else:
flag = False
break
if flag == True:
ans += 1
print(ans)
|
s930611718
|
p03471
|
u345057610
| 2,000
| 262,144
|
Wrong Answer
| 2,206
| 9,088
| 249
|
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
n,y = map(int, input().split())
for i in range(n+1):
for j in range(n+1-i):
for k in range(n+1-i-j):
sum = 10000*i + 5000*j + 1000*k
if sum == y:
print(i,j,k)
break
print(-1,-1,-1)
|
s258442238
|
Accepted
| 640
| 9,136
| 263
|
n,y = map(int, input().split())
a = -1
b = -1
c = -1
for i in range(n+1):
for j in range(n+1-i):
k = n-i-j
sum = 10000*i + 5000*j + 1000*k
if sum == y:
a = i
b = j
c = k
print(a,b,c)
|
s493192962
|
p02936
|
u523087093
| 2,000
| 1,048,576
|
Wrong Answer
| 2,106
| 46,564
| 523
|
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations.
|
from collections import deque
N, Q = map(int, input().split())
tree = [[] for _ in range(N)]
counters = deque([0] * N)
answer = [0] * N
for _ in range(N-1):
index, child = map(int, input().split())
tree[index-1].append(child-1)
for _ in range(Q):
index, count = map(int, input().split())
counters[index-1] += count
for i in range(N):
count = counters.popleft()
answer[i] += count
for j in range(len(tree[i])):
answer[tree[i][j]] += answer[i]
for i in answer:
print(i, end=' ')
|
s224564215
|
Accepted
| 1,203
| 58,280
| 650
|
from collections import deque
N, Q = map(int, input().split())
graph = [[] for _ in range(N+1)]
for _ in range(N-1):
a, b = map(int, input().split())
graph[a].append(b)
graph[b].append(a)
counts = [0] * (N+1)
for _ in range(Q):
p, x = map(int, input().split())
counts[p] += x
visited = [-1] * (N+1)
q = deque()
q.append(1)
visited[1] = 1
while q:
node = q.pop()
next_nodes = graph[node]
for next in next_nodes:
if visited[next] != -1:
continue
q.append(next)
visited[next] = 1
counts[next] += counts[node]
print(*counts[1:])
|
s599193488
|
p02238
|
u089830331
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,652
| 418
|
Depth-first search (DFS) follows the strategy to search ”deeper” in the graph whenever possible. In DFS, edges are recursively explored out of the most recently discovered vertex $v$ that still has unexplored edges leaving it. When all of $v$'s edges have been explored, the search ”backtracks” to explore edges leaving the vertex from which $v$ was discovered. This process continues until all the vertices that are reachable from the original source vertex have been discovered. If any undiscovered vertices remain, then one of them is selected as a new source and the search is repeated from that source. DFS timestamps each vertex as follows: * $d[v]$ records when $v$ is first discovered. * $f[v]$ records when the search finishes examining $v$’s adjacency list. Write a program which reads a directed graph $G = (V, E)$ and demonstrates DFS on the graph based on the following rules: * $G$ is given in an adjacency-list. Vertices are identified by IDs $1, 2,... n$ respectively. * IDs in the adjacency list are arranged in ascending order. * The program should report the discover time and the finish time for each vertex. * When there are several candidates to visit during DFS, the algorithm should select the vertex with the smallest ID. * The timestamp starts with 1.
|
G = {}
for _ in range(int(input())):
x = list(map(int, input().split()))
G[x[0]] = sorted(x[2:])
t = 1
stack = [1]
timestamp = {1:[t]}
while len(stack) > 0:
t += 1
v = stack[-1]
while len(G[v]) > 0:
v = G[v].pop(0)
if v in timestamp: continue
stack.append(v)
timestamp[v] = [t]
break
else:
v = stack.pop()
timestamp[v].append(t)
for i in timestamp:
print(i, *timestamp[i])
|
s067732905
|
Accepted
| 30
| 7,732
| 886
|
def get_unvisted_child(v, timestamp):
while len(G[v]) > 0:
c = G[v].pop(0)
if not c in timestamp: return c
return -1
def get_unvisited_node(G, timestamp):
for v in sorted(G):
if not v in timestamp: return v
return -1
def dept_first_search(G):
t = 1
timestamp = {}
stack = []
v = get_unvisited_node(G, timestamp)
while v > 0:
stack.append(v)
timestamp[v] = [t]
t += 1
while len(stack) > 0:
v = stack[-1]
c = get_unvisted_child(v, timestamp)
if c > 0:
#c = G[v].pop(0)
stack.append(c)
timestamp[c] = [t]
else:
timestamp[v].append(t)
stack.pop()
t += 1
v = get_unvisited_node(G, timestamp)
for v in sorted(timestamp):
print(v, *timestamp[v])
G = {}
for i in range(int(input())):
x = list(map(int, input().split()))
G[x[0]] = x[2:]
dept_first_search(G)
|
s397172646
|
p03567
|
u523964576
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 539
|
Snuke built an online judge to hold a programming contest. When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.) Determine whether the judge can return the string `AC` as the verdict to a program.
|
s=input()
c=s.replace("x","")
def insert(s,n,b):
c=s[n]
a=s.split(c)
h=a[0]+b+c+a[1]
return h
def kaibun(s):
n=0
for i in range(int(len(s)/2)):
if s[i]!=s[len(s)-1-i]:
n=1
return n
center=int(len(c)/2)
num=0
j=1
f=c[:center+1]
if kaibun(c)==1:
print(-1)
else:
for ch in f:
i=num
while(1):
if ch==s[i]:
break
i+=1
num=i
print(len(s)-num)
|
s071797104
|
Accepted
| 17
| 2,940
| 62
|
s=input()
if "AC" in s:
print("Yes")
else:
print("No")
|
s987459964
|
p03625
|
u394721319
| 2,000
| 262,144
|
Wrong Answer
| 222
| 14,556
| 319
|
We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
|
from bisect import bisect_right, bisect_left
N = int(input())
A = [int(zz) for zz in input().split()]
A.sort()
B = set(A)
ans = []
for i in B:
p = bisect_right(A, i) - bisect_left(A, i)
if p > 2:
ans.append(i)
ans.sort(reverse=True)
if len(ans) >= 2:
print(ans[0] * ans[1])
else:
print(0)
|
s548450622
|
Accepted
| 228
| 14,484
| 394
|
from bisect import bisect_right, bisect_left
N = int(input())
A = [int(zz) for zz in input().split()]
A.sort()
B = set(A)
ans = []
for i in B:
p = bisect_right(A, i) - bisect_left(A, i)
if 4 > p >= 2:
ans.append(i)
elif p >= 4:
ans.append(i)
ans.append(i)
ans.sort(reverse=True)
if len(ans) >= 2:
print(ans[0] * ans[1])
else:
print(0)
|
s502704698
|
p03455
|
u426250125
| 2,000
| 262,144
|
Wrong Answer
| 34
| 9,144
| 86
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a,b = map(int, input().split())
if a*b // 2 == 0:
print('Even')
else:
print('Odd')
|
s927777838
|
Accepted
| 24
| 9,012
| 87
|
a,b = map(int, input().split())
if a * b % 2 == 0:
print('Even')
else:
print('Odd')
|
s773496508
|
p03502
|
u502314533
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 100
|
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
|
use = int(input())
if sum([int(i) for i in str(use)]) % use == 0:
print("YES")
else: print("NO")
|
s226926942
|
Accepted
| 17
| 3,064
| 100
|
use = int(input())
if use % sum([int(i) for i in str(use)]) == 0:
print("Yes")
else: print("No")
|
s185824424
|
p03478
|
u201565171
| 2,000
| 262,144
|
Wrong Answer
| 34
| 3,188
| 181
|
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
N,A,B=map(int,input().split())
S=[]
for i in range(1,N+1):
tmp=list(map(int,str(i)))
S.append(sum(tmp))
Ans=0
for i in S:
if i >= A and i<=B:
Ans+=i
print(Ans)
|
s670526667
|
Accepted
| 37
| 3,188
| 196
|
N,A,B=map(int,input().split())
S=[]
for i in range(1,N+1):
tmp=list(map(int,str(i)))
S.append(sum(tmp))
Ans=0
for i in range(N):
if S[i] >= A and S[i]<=B:
Ans+=i+1
print(Ans)
|
s571177107
|
p02389
|
u009101629
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,596
| 60
|
Write a program which calculates the area and perimeter of a given rectangle.
|
lis = [int(x)for x in input().split()]
print(lis[0]*lis[1])
|
s744179905
|
Accepted
| 20
| 5,596
| 97
|
lis = [int(x) for x in input().split()]
print(str(lis[0]*lis[1]) + " " + str(lis[0]*2+lis[1]*2))
|
s056263348
|
p03693
|
u375500286
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 74
|
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
a,b,c=map(int,input().split())
print("YES" if 100*a+10*b+c%4==0 else "NO")
|
s300998433
|
Accepted
| 17
| 2,940
| 76
|
a,b,c=map(int,input().split())
print("YES" if (100*a+10*b+c)%4==0 else "NO")
|
s978928836
|
p03493
|
u483722302
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 103
|
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
# -*- coding: utf-8 -*-
a = input()
ans = 0
for c in a:
if c == '0':
ans += 1
print(ans)
|
s760455685
|
Accepted
| 18
| 2,940
| 103
|
# -*- coding: utf-8 -*-
a = input()
ans = 0
for c in a:
if c == '1':
ans += 1
print(ans)
|
s696956781
|
p03494
|
u189385406
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 183
|
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
N = int(input())
A = input().split()
x = 0
def even(x):
for i in A:
if A[i]%2 != 0:
break
else:
x+=1
return x
if x == N:
print(min(A)/2 -1)
else:
print(x)
|
s870481414
|
Accepted
| 18
| 2,940
| 172
|
N = int(input())
A = list(map(int, input().split()))
count = 0
while True:
for i in range(N):
if A[i]%2 != 0:
print(count)
exit()
A[i] /= 2
count+=1
|
s649986158
|
p03141
|
u981767024
| 2,000
| 1,048,576
|
Wrong Answer
| 616
| 40,244
| 527
|
There are N dishes of cuisine placed in front of Takahashi and Aoki. For convenience, we call these dishes Dish 1, Dish 2, ..., Dish N. When Takahashi eats Dish i, he earns A_i points of _happiness_ ; when Aoki eats Dish i, she earns B_i points of happiness. Starting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat. Here, both of them choose dishes so that the following value is maximized: "the sum of the happiness he/she will earn in the end" minus "the sum of the happiness the other person will earn in the end". Find the value: "the sum of the happiness Takahashi earns in the end" minus "the sum of the happiness Aoki earns in the end".
|
# 2019/01/27
from operator import itemgetter
# Input
n = int(input())
ablist = list()
for idx in range(n):
a, b = map(int, input().split())
ablist.append([a, b, abs(a-b)])
ablist.sort(key=itemgetter(0, 1), reverse=True)
tsum = 0
asum = 0
# Sum
for idx in range(n):
if idx % 2 == 0:
# Turn of Takahashi
tsum += ablist[idx][0]
else:
# Turn of Aoki
asum += ablist[idx][1]
# Output
print(ablist,tsum,asum)
print(tsum - asum)
|
s527875674
|
Accepted
| 448
| 24,944
| 494
|
# 2019/01/27
from operator import itemgetter
# Input
n = int(input())
ablist = list()
for idx in range(n):
a, b = map(int, input().split())
ablist.append([a, b, a+b])
ablist.sort(key=itemgetter(2), reverse=True)
tsum = 0
asum = 0
# Sum
for idx in range(n):
if idx % 2 == 0:
# Turn of Takahashi
tsum += ablist[idx][0]
else:
# Turn of Aoki
asum += ablist[idx][1]
ans1 = tsum - asum
# Output
print(ans1)
|
s263375268
|
p03694
|
u050428930
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 53
|
It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts. There are N houses along _TopCoDeer street_. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses. Find the minimum distance to be traveled when AtCoDeer can start and end his travel at any positions.
|
s=list(map(int,input().split()))
print(max(s)-min(s))
|
s770792307
|
Accepted
| 18
| 3,060
| 61
|
input()
s=list(map(int,input().split()))
print(max(s)-min(s))
|
s272471124
|
p03478
|
u392029857
| 2,000
| 262,144
|
Wrong Answer
| 27
| 3,060
| 246
|
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
N, A, B = map(int, input().split())
numbers = range(A, N + 1)
somesums = []
for i in numbers:
p = i
sums = 0
while p >= 1:
sums += p%10
p //= 10
if A <= sums <= B:
somesums.append(sums)
print(sum(somesums))
|
s431258838
|
Accepted
| 30
| 3,064
| 232
|
N, A, B = map(int, input().split())
numbers = range(A, N + 1)
somesums = 0
for i in numbers:
p = i
sums = 0
while p >= 1:
sums += p%10
p //= 10
if A <= sums <= B:
somesums += i
print(somesums)
|
s203644502
|
p03543
|
u566264434
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 83
|
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
|
a,b,c,d=input()
if b==c and (a==b or c==d):
print("YES")
else:
print("NO")
|
s805197045
|
Accepted
| 17
| 2,940
| 83
|
a,b,c,d=input()
if b==c and (a==b or c==d):
print("Yes")
else:
print("No")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.