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
s885461286
p03720
u676264453
2,000
262,144
Wrong Answer
17
3,064
324
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
N,M = map(int, input().split()) a = [] for i in range(M): tmp_l = map(int, input().split()) for i in tmp_l: a.append(i) itr = 0 count = 0 d = {} print(list(range(1,N+1,1))) print(a) for j in list(range(1,N+1,1)): d[j] = 0 for k in a: d[k] = d[k] + 1 for o in list(range(1,N+1,1)): print(d[o])
s544722719
Accepted
17
3,064
287
N,M = map(int, input().split()) a = [] for i in range(M): tmp_l = map(int, input().split()) for i in tmp_l: a.append(i) itr = 0 count = 0 d = {} for j in list(range(1,N+1,1)): d[j] = 0 for k in a: d[k] = d[k] + 1 for o in list(range(1,N+1,1)): print(d[o])
s148932156
p03635
u952708174
2,000
262,144
Wrong Answer
17
2,940
119
In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?
string=input('') first=string[0] last=string[len(string)-1] mid=str(len(string[1:len(string)-1])) print(first+mid+last)
s610978522
Accepted
17
2,940
59
n, m = (int(i) for i in input().split()) print((n-1)*(m-1))
s443575638
p03223
u543954314
2,000
1,048,576
Wrong Answer
231
7,764
198
You are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.
n = int(input()) a = [int(input()) for _ in range(n)] a.sort() a1 = a[:n//2] a2 = a[n-1:n//2-1:-1] ans = 0 if n%2==0: a2 += [a1[-1]] for i in range(n//2): ans += a2[i]+a2[i+1]-a1[i]*2 print(ans)
s578011827
Accepted
214
8,532
338
n = int(input()) l = [int(input()) for _ in range(n)] l.sort() if n%2: s1 = l[:(n-1)//2] b1 = l[(n-1)//2:] t1 = sum(b1)*2 - sum(s1)*2 -sum(b1[:2]) s2 = l[:(n+1)//2] b2 = l[(n+1)//2:] t2 = sum(b2)*2 - sum(s2)*2 + sum(s2[-2:]) t = max(t1,t2) else: s = l[:n//2] b = l[n//2:] t = sum(b)*2 - sum(s)*2 -b[0] + s[-1] print(t)
s484818270
p02927
u927530154
2,000
1,048,576
Wrong Answer
20
3,060
315
Today is August 24, one of the five Product Days in a year. A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day): * d_1 \geq 2 * d_{10} \geq 2 * d_1 \times d_{10} = m Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D. In Takahashi Calendar, how many Product Days does a year have?
def seki_day(m, d): d10 = d // 10 d1 = d - d10 * 10 if d1 >= 2 and m == d10 * d1: print(m, d) return 1 else: return 0 M, D = [int(x) for x in input().split()] count = 0 for m in range(1, M + 1): for d in range(22, D + 1): count += seki_day(m, d) print(count)
s371241270
Accepted
19
2,940
295
def seki_day(m, d): d10 = d // 10 d1 = d - d10 * 10 if d1 >= 2 and m == d10 * d1: return 1 else: return 0 M, D = [int(x) for x in input().split()] count = 0 for m in range(1, M + 1): for d in range(22, D + 1): count += seki_day(m, d) print(count)
s616066216
p03625
u816631826
2,000
262,144
Wrong Answer
115
18,216
337
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.
n = int(input()) vals = list(map(int, input().split())) d= {} a = [0, 0] for i in range(n): if(vals[i] in d.keys()): d[vals[i]] += 1 else: d[vals[i]] = 1 print(d) for i in d.keys(): if(d[i] >= 4): a.append(i) a.append(i) elif(d[i] >= 2): a.append(i) a.sort() print(a[-1]*a[-2])
s784062218
Accepted
111
14,252
256
n=int(input()) a=[int(x) for x in input().split()] a.sort() lar=sec=i=0 while(i<n-1): if a[i]==a[i+1]: i+=1 if a[i]>lar: sec=lar lar=a[i] elif a[i]>sec: sec=a[i] i+=1 print(lar*sec)
s664924598
p03578
u513900925
2,000
262,144
Wrong Answer
2,105
35,420
441
Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems. Determine whether Rng can complete the problem set without creating new candidates of problems.
N = int(input()) a = [int(i) for i in input().split()] M = int(input()) b = [int(i) for i in input().split()] a.sort() b.sort() p=0 for i in range (len(b)): for j in range(len(a)): if b[i] == a[j]: a = a[j+1:N] break else: if j ==len(a)-1: print("No") p =1 break if p ==1: break if i == len(b)-1: print("Yes")
s276768900
Accepted
297
41,316
352
N = int(input()) D = list(map(int, input().split())) M = int(input()) T = list(map(int, input().split())) d_dict = {} for d in D: if d not in d_dict: d_dict[d] = 0 d_dict[d] += 1 count = 0 for t in T: if t in d_dict and d_dict[t] > 0: d_dict[t] -= 1 count += 1 if count == M: print("YES") else: print("NO")
s238269117
p03680
u026155812
2,000
262,144
Wrong Answer
2,104
7,084
226
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.
import sys N = int(input()) a = [] for i in range(N): a.append(int(input())) ls = [] cur = a[0] ans = 0 while not cur in ls: ls.append(cur) cur = a[cur-1] ans += 1 if cur == 2: print(ans) print(-1)
s042297455
Accepted
224
13,220
323
# 2019/6/25 import sys N = int(input()) a = [] for i in range(N): a.append(int(input())) if not 2 in a: print(-1) sys.exit() s = set() cur = 1 ans = 0 while not cur in s: if a[cur-1] == 2: print(ans+1) sys.exit() else: s.add(cur) cur = a[cur-1] ans += 1 print(-1)
s615266456
p03486
u172569352
2,000
262,144
Wrong Answer
19
2,940
142
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
s = ''.join(sorted(list(input()))) t = ''.join(sorted(list(input()), reverse=True)) print(s) if s < t: print('Yes') else: print('No')
s983383643
Accepted
17
2,940
133
s = ''.join(sorted(list(input()))) t = ''.join(sorted(list(input()), reverse=True)) if s < t: print('Yes') else: print('No')
s650402454
p02694
u815931251
2,000
1,048,576
Wrong Answer
21
9,164
133
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()) year = 0 sum = 100 while sum <= x: year = year + 1 sum = (int)(sum * 101 / 100) print("{}".format(year))
s232144653
Accepted
22
9,168
132
x = (int)(input()) year = 0 sum = 100 while sum < x: year = year + 1 sum = (int)(sum * 101 / 100) print("{}".format(year))
s272007542
p03407
u057463552
2,000
262,144
Wrong Answer
17
2,940
85
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()) if A +B >= C: print("YES") else: print("NO")
s292300063
Accepted
17
2,940
85
A,B,C = map(int,input().split()) if A +B >= C: print("Yes") else: print("No")
s180764597
p03623
u762540523
2,000
262,144
Wrong Answer
17
2,940
60
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|.
x,a,b=map(int,input().split()) print(min(abs(x-a),abs(x-b)))
s640863054
Accepted
17
2,940
61
x,a,b=map(int,input().split()) print("BA"[abs(x-a)<abs(x-b)])
s466694583
p04044
u708211626
2,000
262,144
Wrong Answer
29
9,168
125
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
a=input() b=[] for i in range(int(a[0])): b.append(input()) f=sorted(b) for i in range(int(a[0])): print(f[i],end='')
s147045285
Accepted
28
9,164
106
a,b=map(int,input().split()) c=[] for i in range(a): c.append(input()) d=sorted(c) print(''.join(d))
s744399179
p02646
u199356004
2,000
1,048,576
Wrong Answer
24
9,180
148
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
A,V = [int(i) for i in input().split() ] B,W = [int(i) for i in input().split() ] T = int(input()) print ( "Yes" if A+(V*T) >= B+(W*T) else "No" )
s413400523
Accepted
20
9,168
164
A,V = [int(i) for i in input().split() ] B,W = [int(i) for i in input().split() ] T = int(input()) print ("YES" if V-W > 0 and abs(A-B) / (V-W) <= T else "NO" )
s841166106
p03565
u106778233
2,000
262,144
Wrong Answer
17
3,060
194
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
S,T=input(),input() m=len(S) for i in range(len(T)-m+1): if all(c in"?"+d for c,d in zip(S[-i-m:],T)): S=S.replace("?","a") print(S[:-i-m]+T+S[-i:]) quit() print("UNRESTORABLE")
s577543088
Accepted
19
2,940
183
S,T=input(),input();l,m=len(S),len(T) for i in range(l-m+1): if all(c in"?"+d for c,d in zip(S[-i-m:],T)):S=S.replace("?","a");print(S[:-i-m]+T+S[l-i:]);quit() print("UNRESTORABLE")
s158337563
p03605
u783589546
2,000
262,144
Wrong Answer
17
2,940
59
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
n = input() if "9" in n: print("YES") else: print("NO")
s944738831
Accepted
17
2,940
59
n = input() if "9" in n: print("Yes") else: print("No")
s996634324
p03080
u502389123
2,000
1,048,576
Wrong Answer
17
3,064
133
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() cnt = 0 for s in S: if "R" == cnt: cnt += 1 if cnt > N - cnt: print("Yes") else: print("No")
s440532905
Accepted
17
2,940
131
N = int(input()) S = input() cnt = 0 for s in S: if "R" == s: cnt += 1 if cnt > N - cnt: print("Yes") else: print("No")
s364400357
p02694
u085530099
2,000
1,048,576
Wrong Answer
23
9,164
116
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?
import math x = int(input()) t = 100 count = 0 while t <= x: count += 1 t = t+(math.floor(t*1/100)) print(count)
s412245265
Accepted
21
9,192
115
import math x = int(input()) t = 100 count = 0 while t < x: count += 1 t = t+(math.floor(t*1/100)) print(count)
s903313028
p03943
u182047166
2,000
262,144
Wrong Answer
17
2,940
107
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.
a, b, c = map(int, input().split()) if a+b == c or b+c==a or c+a==b: print("YES") else: print("NO")
s744016840
Accepted
17
2,940
117
a, b, c = map(int, input().split()) if a + b == c or b + c == a or c + a == b: print("Yes") else: print("No")
s686459407
p03067
u353099601
2,000
1,048,576
Wrong Answer
17
2,940
119
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.
A, B, C = map(int, input().split()) if A < C < B: print('YES') elif B < C < A: print('YES') else: print('NO')
s013384574
Accepted
19
2,940
116
A, B, C = map(int, input().split()) if A < C < B: print('Yes') elif B < C < A: print('Yes') else: print('No')
s966822256
p03719
u670180528
2,000
262,144
Wrong Answer
19
2,940
55
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
a,b,c=map(int,input().split());print("NYoe s"[a<=c<=b])
s450785024
Accepted
17
2,940
59
a,b,c=map(int,input().split());print("NYoe s"[a<=c<=b::2])
s928592328
p02865
u207576418
2,000
1,048,576
Wrong Answer
18
2,940
88
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
n = int(input()) a = 0 if n % 2 == 0: a = n / 2 - 1 else: a = (n-1)/2 print(a)
s679209536
Accepted
17
2,940
93
n = int(input()) a = 0 if n % 2 == 0: a = n / 2 - 1 else: a = (n-1)/2 print(int(a))
s623313291
p03844
u434500430
2,000
262,144
Wrong Answer
17
2,940
109
Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
A, Op, B = input().split() A = int(A) B = int(B) if A == '+': print(A+B) elif Op == '-': print(A-B)
s332566941
Accepted
17
2,940
110
A, Op, B = input().split() A = int(A) B = int(B) if Op == '+': print(A+B) elif Op == '-': print(A-B)
s210193135
p03455
u058518059
2,000
262,144
Wrong Answer
17
2,940
90
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")
s198463291
Accepted
17
2,940
84
a, b = map(int, input().split()) if a*b%2 == 0: print("Even") else: print("Odd")
s976430854
p02608
u532141811
2,000
1,048,576
Wrong Answer
923
9,116
283
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
N = int(input()) ans =[0]*(N+1) for x in range(1, 101): for y in range(1, 101): for z in range(1, 101): s = x**2 + y**2 + z**2 s += x*y + y*z + z*x if s > N: continue ans[s] += 1 for i in ans: print(i)
s733519384
Accepted
824
9,112
263
N = int(input()) ans =[0]*(N+1) for x in range(1, 101): for y in range(1, 101): for z in range(1, 101): s = x**2 + y**2 + z**2 + x*y + y*z + z*x if s <= N: ans[s] += 1 for i in range(1, N+1): print(ans[i])
s958724203
p03943
u802772880
2,000
262,144
Wrong Answer
17
2,940
79
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.
a=map(int,input().split()) ans='No' if 2*max(a)==sum(a): ans='Yes' print(ans)
s915806697
Accepted
17
2,940
86
a=list(map(int,input().split())) ans='No' if 2*max(a)==sum(a): ans='Yes' print(ans)
s430278593
p02385
u073709667
1,000
131,072
Wrong Answer
40
11,828
959
Write a program which reads the two dices constructed in the same way as [Dice I](description.jsp?id=ITP1_11_A), and determines whether these two dices are identical. You can roll a dice in the same way as [Dice I](description.jsp?id=ITP1_11_A), and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical.
import random def N(): num=Dice[0] Dice[0]=Dice[1] Dice[1]=Dice[5] Dice[5]=Dice[4] Dice[4]=num def E(): num=Dice[0] Dice[0]=Dice[3] Dice[3]=Dice[5] Dice[5]=Dice[2] Dice[2]=num def W(): num=Dice[0] Dice[0]=Dice[2] Dice[2]=Dice[5] Dice[5]=Dice[3] Dice[3]=num def S(): num=Dice[0] Dice[0]=Dice[4] Dice[4]=Dice[5] Dice[5]=Dice[1] Dice[1]=num Dice=[int(i) for i in input().split()] Dice2=[int(i) for i in input().split()] if (Dice[0] in Dice2)==False: print('No') else: while True: rand=random.randint(1,4) if rand==1: N() elif rand==2: E() elif rand==3: W() else: S() if Dice[0]==Dice2[0]: break for i in range(3): N() W() S() if Dice==Dice2: break if Dice==Dice2: print('Yes') else: print('No')
s309460822
Accepted
50
7,800
861
def N(): num=Dice[0] Dice[0]=Dice[1] Dice[1]=Dice[5] Dice[5]=Dice[4] Dice[4]=num def E(): num=Dice[0] Dice[0]=Dice[3] Dice[3]=Dice[5] Dice[5]=Dice[2] Dice[2]=num def W(): num=Dice[0] Dice[0]=Dice[2] Dice[2]=Dice[5] Dice[5]=Dice[3] Dice[3]=num def S(): num=Dice[0] Dice[0]=Dice[4] Dice[4]=Dice[5] Dice[5]=Dice[1] Dice[1]=num Dice=[int(i) for i in input().split()] Dice2=[int(i) for i in input().split()] if (Dice[0] in Dice2)==False: print('No') else: for j in range(6): if j%2==0: N() else: W() for i in range(4): N() W() S() if Dice==Dice2: break if Dice==Dice2: break if Dice==Dice2: print('Yes') else: print('No')
s869239068
p03836
u680851063
2,000
262,144
Wrong Answer
18
3,188
246
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.
a, b, c, d = map(int,input().split()) x = c - a y = d - b z = [] z += y * 'U' z += x * 'R' z += y * 'D' z += (x + 1) * 'L' z += (y + 1) * 'U' z += (1 + x) * 'R' z += 'U' z += 'R' z += (y + 1) * 'U' z += (1 + x) *'L' z += 'U' print(''.join(z))
s635400595
Accepted
18
3,188
245
a, b, c, d = map(int,input().split()) x = c - a y = d - b z = [] z += y * 'U' z += x * 'R' z += y * 'D' z += (x + 1) * 'L' z += (y + 1) * 'U' z += (1 + x) * 'R' z += 'D' z += 'R' z += (y + 1) * 'D' z += (1 + x) *'L' z += 'U' print(''.join(z))
s628400545
p02255
u672443148
1,000
131,072
Wrong Answer
20
5,592
212
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.
N=int(input()) arr=list(map(int,input().split())) for key in range(1,len(arr)): temp=arr[key] i=key-1 while i>=0 and arr[i]>temp: arr[i+1]=arr[i] i-=1 arr[i+1]=temp print(*arr)
s580120172
Accepted
30
5,980
242
N=int(input()) arr=list(map(int,input().split())) print(' '.join(map(str,arr))) for key in range(1,len(arr)): temp=arr[key] i=key-1 while i>=0 and arr[i]>temp: arr[i+1]=arr[i] i-=1 arr[i+1]=temp print(*arr)
s231161493
p03605
u626228246
2,000
262,144
Wrong Answer
18
2,940
66
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
N = list(input()) print("Yes" if N[0] == 9 or N[1] == 9 else "No")
s572290902
Accepted
17
2,940
71
N = list(input()) print("Yes" if N[0] == "9" or N[1] == "9" else "No")
s179802832
p03047
u273006189
2,000
1,048,576
Wrong Answer
17
2,940
34
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 = input().split(" ") print(N)
s152221574
Accepted
30
3,060
218
line = input().split(" ") N = int(line[0]) M = int(line[1]) count = 0 for i in range(1, N+1): for j in range(M): if i+j > N: break if j == M-1: count += 1 print(count)
s751556367
p03139
u497883442
2,000
1,048,576
Wrong Answer
17
2,940
69
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question.
n,a,b = list(map(int, input().split())) print(max(a,b), max(a+b-n,0))
s352748436
Accepted
17
2,940
69
n,a,b = list(map(int, input().split())) print(min(a,b), max(a+b-n,0))
s734073608
p03067
u167307651
2,000
1,048,576
Wrong Answer
17
2,940
101
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.
a,b,c = map(int, input().split()) if ((a<b)&(b<c))|((a>b)&(b>c)): print ("Yes") else: print("No")
s712353416
Accepted
17
2,940
101
a,b,c = map(int, input().split()) if ((a<c)&(c<b))|((a>c)&(c>b)): print ("Yes") else: print("No")
s187813940
p03567
u814986259
2,000
262,144
Wrong Answer
28
8,992
59
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() if 'AC' in S: print("AC") else: print("NO")
s578574767
Accepted
29
9,024
61
S = input() if 'AC' in S: print("Yes") else: print("No")
s331701529
p03478
u931462344
2,000
262,144
Wrong Answer
32
2,940
188
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()) sum = 0 for i in range(1, n+1): tmpi = 0 for c in str(i): tmpi += int(c) if tmpi >= a and b >= tmpi: sum += tmpi print(sum)
s429324412
Accepted
32
2,940
185
n, a, b = map(int, input().split()) sum = 0 for i in range(1, n+1): tmpi = 0 for c in str(i): tmpi += int(c) if tmpi >= a and b >= tmpi: sum += i print(sum)
s767832266
p03623
u059262067
2,000
262,144
Wrong Answer
17
2,940
103
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 = 0 a, b, c = (abs(int(i) - a) for i in input().split()) if b > c: print("B") else: print("A")
s025000218
Accepted
18
2,940
100
x, a, b = (int(i) for i in input().split()) if abs(a-x) > abs(b-x): print("B") else: print("A")
s117752560
p03149
u657454538
2,000
1,048,576
Wrong Answer
17
2,940
215
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".
s=input() n = len(s) for i in range(n): for j in range(i,n): # tmp = s[:i]+s[j:] if tmp == "keyence": print("YES") quit() print("NO")
s397515221
Accepted
17
2,940
286
a = list(map(int,input().split())) if 1 in a: if 9 in a: if 7 in a: if 4 in a: print("YES") else : print("NO") else : print("NO") else : print("NO") else : print("NO")
s181753340
p03433
u819663617
2,000
262,144
Wrong Answer
25
9,124
104
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
N = int(input()) A = int(input()) amari = N % 500 if amari <= A: print("YES") else: print("NO")
s529536184
Accepted
25
9,072
101
N = int(input()) A = int(input()) amari = N % 500 if amari <= A: print("Yes") else: print("No")
s532134926
p02406
u602702913
1,000
131,072
Wrong Answer
20
7,560
97
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
a=int(input()) for i in range(3,a+1): if i% 3==0: print(" "+str(i),end=" ")
s770304647
Accepted
30
7,948
197
n = int(input()) for i in range(1, n + 1): if i % 3 == 0: print(' ' + str(i), end='') else: s = str(i) if '3' in s: print(' ' + str(i), end='') print('')
s660319596
p03795
u458608788
2,000
262,144
Wrong Answer
18
2,940
37
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.
a=int(input()) print(a*800-200*a//15)
s752952835
Accepted
17
2,940
40
a=int(input()) print(a*800-200*(a//15))
s837584360
p03659
u970197315
2,000
262,144
Wrong Answer
233
24,832
196
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]*N S = sum(A) ans = 10**11 for i in range(1,N): X[i] = X[i-1] + A[i] t = abs(X[i]+X[i]-S) ans = min(ans,t) print(ans)
s354074473
Accepted
190
24,636
252
n=int(input()) a=list(map(int,input().split())) from itertools import accumulate s=list(accumulate(a)) a_sum=sum(a) ans=10**18 if n==2: print(abs(a[0]-a[1])) exit(0) for i in range(1,n-1): x=s[i] y=a_sum-x ans=min(ans,abs(x-y)) print(ans)
s875668735
p03568
u432042540
2,000
262,144
Wrong Answer
17
2,940
163
We will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are _similar_ when |x_i - y_i| \leq 1 holds for all i (1 \leq i \leq N). In particular, any integer sequence is similar to itself. You are given an integer N and an integer sequence of length N, A_1, A_2, ..., A_N. How many integer sequences b_1, b_2, ..., b_N are there such that b_1, b_2, ..., b_N is similar to A and the product of all elements, b_1 b_2 ... b_N, is even?
n = int(input()) a = [int(i) for i in input().split()] print(a) cnt = 0 for i in range(n): if a[i] % 2 == 0: cnt += 1 x = 3 ** n - 2 ** cnt print(x)
s424470166
Accepted
17
2,940
155
n = int(input()) a = [int(i) for i in input().split()] cnt = 0 for i in range(n): if a[i] % 2 == 0: cnt += 1 x = 3 ** n - 2 ** cnt print(x)
s302758286
p03828
u521992338
2,000
262,144
Wrong Answer
44
3,064
265
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.
n = int(input()) ps = [0] * (n + 1) for i in range(2, n + 1): x = i p = 2 while x > 1: while x % p == 0: ps[p] += 1 x //= p p += 1 print (ps) ans = 1 for c in ps: ans = (ans * (c + 1)) % 1000000007 print (ans)
s669180090
Accepted
45
3,060
254
n = int(input()) ps = [0] * (n + 1) for i in range(2, n + 1): x = i p = 2 while x > 1: while x % p == 0: ps[p] += 1 x //= p p += 1 ans = 1 for c in ps: ans = (ans * (c + 1)) % 1000000007 print (ans)
s503034009
p03852
u063052907
2,000
262,144
Wrong Answer
17
2,940
64
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
#coding: utf-8 print(["vowel", "consonant"][input() in "aiueo"])
s138403976
Accepted
17
2,940
63
#coding: utf-8 print(["consonant","vowel"][input() in "aiueo"])
s826165820
p02678
u461454424
2,000
1,048,576
Wrong Answer
1,008
104,580
940
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.
#atcoder template def main(): import sys imput = sys.stdin.readline #input N, M = map(int, input().split()) AB = [map(int, input().split()) for _ in range(M)] C = [[] for _ in range(N+1)] for a, b in AB: C[a].append(b) C[b].append(a) #output from collections import deque search_stack = deque([1]) signpost = [-1] * (N+1) while search_stack: next_position = search_stack.popleft() for node in C[next_position]: if signpost[node] == -1: signpost[node] = next_position search_stack.append(node) print("Yes") for i in range(2, N): print(signpost[i]) if __name__ == "__main__": main()
s869842255
Accepted
941
104,484
942
#atcoder template def main(): import sys imput = sys.stdin.readline #input N, M = map(int, input().split()) AB = [map(int, input().split()) for _ in range(M)] C = [[] for _ in range(N+1)] for a, b in AB: C[a].append(b) C[b].append(a) #output from collections import deque search_stack = deque([1]) signpost = [-1] * (N+1) while search_stack: next_position = search_stack.popleft() for node in C[next_position]: if signpost[node] == -1: signpost[node] = next_position search_stack.append(node) print("Yes") for i in range(2, N+1): print(signpost[i]) if __name__ == "__main__": main()
s022013178
p04044
u843768197
2,000
262,144
Wrong Answer
27
9,088
85
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
n, l = map(int, input().split()) a = list(input() for i in range(n)) print(sorted(a))
s035717837
Accepted
27
9,112
119
n, l = map(int, input().split()) a = list(input() for i in range(n)) ans = '' for i in sorted(a): ans += i print(ans)
s907511674
p01137
u124909914
8,000
131,072
Wrong Answer
210
6,724
494
English text is not available in this practice contest. ケン・マリンブルーは,宇宙ヤシガニを求めて全銀河を旅するスペースハンターである.宇宙ヤシガニは,宇宙最大とされる甲殻類であり,成長後の体長は 400 メートル以上,足を広げれば 1,000 メートル以上にもなると言われている.既に多数の人々が宇宙ヤシガニを目撃しているが,誰一人として捕らえることに成功していない. ケンは,長期間の調査によって,宇宙ヤシガニの生態に関する重要な事実を解明した.宇宙ヤシガニは,驚くべきことに,相転移航法と呼ばれる最新のワープ技術と同等のことを行い,通常空間と超空間の間を往来しながら生きていた.さらに,宇宙ヤシガニが超空間から通常空間にワープアウトするまでには長い時間がかかり,またワープアウトしてからしばらくは超空間に移動できないことも突き止めた. そこで,ケンはついに宇宙ヤシガニの捕獲に乗り出すことにした.戦略は次のとおりである.はじめに,宇宙ヤシガニが通常空間から超空間に突入する際のエネルギーを観測する.このエネルギーを _e_ とするとき,宇宙ヤシガニが超空間からワープアウトする座標 ( _x_ , _y_ , _z_ ) は以下の条件を満たすことがわかっている. * _x_ , _y_ , _z_ はいずれも非負の整数である. * _x_ \+ _y_ 2 \+ _z_ 3 = _e_ である. * 上記の条件の下で _x_ \+ _y_ \+ _z_ の値を最小にする. これらの条件だけでは座標が一意に決まるとは限らないが, _x_ \+ _y_ \+ _z_ の最小値を _m_ としたときに,ワープアウトする座標が平面 _x_ \+ _y_ \+ _z_ = _m_ 上にあることは確かである.そこで,この平面上に十分な大きさのバリアを張る.すると,宇宙ヤシガニはバリアの張られたところにワープアウトすることになる.バリアの影響を受けた宇宙ヤシガニは身動きがとれなくなる.そこをケンの操作する最新鋭宇宙船であるウェポン・ブレーカー号で捕獲しようという段取りである. バリアは一度しか張ることができないため,失敗するわけにはいかない.そこでケンは,任務の遂行にあたって計算機の助けを借りることにした.あなたの仕事は,宇宙ヤシガニが超空間に突入する際のエネルギーが与えられたときに,バリアを張るべき平面 _x_ \+ _y_ \+ _z_ = _m_ を求めるプログラムを書くことである.用意されたテストケースの全てに対して正しい結果を出力したとき,あなたのプログラムは受け入れられるであろう.
cubics = [ x * x * x for x in range(0, 100)] squares = [ x * x for x in range(0, 1000) if x * x < 100 ** 3 - 99 ** 3] while True: x, y, z = 0, 0, 0 e = int(input()) if e == 0: break for i in range(len(cubics)): if e - cubics[i] < 0: e -= cubics[i - 1] z = i - 1 break for i in range(len(squares)): if e - squares[i] < 0: e -= squares[i -1] y = i - 1 break x = e print(x + y + z)
s062249509
Accepted
540
6,816
371
from math import floor, sqrt cubics = [ x * x * x for x in range(101)] squares = [ x * x for x in range(1000)] while True: m = 1000000 e = int(input()) if e == 0: break for z in range(len(cubics)): if e < cubics[z]: break tmp = e - cubics[z] y = floor(sqrt(tmp)) x = tmp - y ** 2 m = min(m, x + y + z) print(m)
s685719575
p03557
u790710233
2,000
262,144
Wrong Answer
536
23,360
300
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower. He has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i. To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar. How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.
import bisect n = int(input()) A = sorted(map(int, input().split())) B = sorted(map(int, input().split())) C = sorted(map(int, input().split())) ans = 0 for i in range(n): b = B[i] a = bisect.bisect_left(A, b) c = n-bisect.bisect_right(C, b) print(a, b, c) ans += a*c print(ans)
s138808544
Accepted
332
23,232
280
import bisect n = int(input()) A = sorted(map(int, input().split())) B = sorted(map(int, input().split())) C = sorted(map(int, input().split())) ans = 0 for i in range(n): b = B[i] a = bisect.bisect_left(A, b) c = n-bisect.bisect_right(C, b) ans += a*c print(ans)
s807969227
p03759
u278143034
2,000
262,144
Wrong Answer
26
9,024
166
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
a,b,c = map(int,input().split()) if b - a == b - c: print("YES") else: print("NO")
s077426944
Accepted
31
9,160
166
a,b,c = map(int,input().split()) if b - a == c - b: print("YES") else: print("NO")
s543982215
p02613
u975243484
2,000
1,048,576
Wrong Answer
150
16,300
224
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.
n = int(input()) s = [] for _ in range(n): s1 = input() s.append(s1) print('AC × ' + str(s.count('AC'))) print('WA × ' + str(s.count('WA'))) print('TLE × ' + str(s.count('TLE'))) print('RE × ' + str(s.count('RE')))
s727058582
Accepted
151
16,220
220
n = int(input()) s = [] for _ in range(n): s1 = input() s.append(s1) print('AC x ' + str(s.count('AC'))) print('WA x ' + str(s.count('WA'))) print('TLE x ' + str(s.count('TLE'))) print('RE x ' + str(s.count('RE')))
s594799882
p03377
u505420467
2,000
262,144
Wrong Answer
17
2,940
53
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("YNEOS"[a+b<=x])
s334559959
Accepted
18
2,940
63
a,b,x=map(int,input().split());print("YNEOS"[a+b<x or a>x::2])
s095770283
p02613
u635252313
2,000
1,048,576
Wrong Answer
151
16,120
144
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.
n=int(input()) lst=[] all=["AC","WA","TLE","RE"] for _ in range(n): a=input() lst.append(a) for i in all: print(i,"×",lst.count(i))
s658535596
Accepted
139
16,224
132
N = int(input()) lst = [input() for _ in range(N)] V=["AC","WA","TLE","RE"] for v in V: print("{} x {}".format(v, lst.count(v)))
s322121717
p03796
u248670337
2,000
262,144
Wrong Answer
32
2,940
74
Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
n=int(input()) ans=1 for i in range(n): ans*=i ans%=10**9+7 print(ans)
s861060077
Accepted
44
2,940
78
n=int(input()) ans=1 for i in range(1,n+1): ans*=i ans%=10**9+7 print(ans)
s177170439
p03473
u477696265
2,000
262,144
Wrong Answer
25
9,060
37
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
a = input() b = int(a) + 24 print(b)
s319977549
Accepted
27
9,040
49
a = input() b = 24 - int(a) c = 24 + b print(c)
s310850676
p04011
u502149531
2,000
262,144
Wrong Answer
17
2,940
127
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
a = int(input()) b = int(input()) c = int(input()) d = int(input()) if a >= b : print(c*a) else : print((a-b)*c + b*d)
s010712724
Accepted
17
2,940
128
a = int(input()) b = int(input()) c = int(input()) d = int(input()) if a <= b : print(c*a) else : print(b*c + (a-b)*d)
s458261638
p03089
u987164499
2,000
1,048,576
Wrong Answer
17
3,060
256
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
from sys import stdin n = int(stdin.readline().rstrip()) li = list(map(int,stdin.readline().rstrip().split())) lin = [] for i in range(n): if i+1 >= li[i]: lin.append(li[i]) else: print(-1) exit() for i in lin: print(i)
s070701489
Accepted
18
3,064
376
from sys import stdin from itertools import groupby n = int(stdin.readline().rstrip()) li = list(map(int,stdin.readline().rstrip().split())) lin = [] while li: now = 10**10 for i,j in enumerate(li,1): if i == j: now = i if now == 10**10: print(-1) exit() lin.append(now) li.pop(now-1) for i in lin[::-1]: print(i)
s737846063
p03623
u953379577
2,000
262,144
Wrong Answer
17
2,940
62
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|.
x,a,b = map(int,input().split()) print(min(abs(a-x),abs(b-x)))
s801055822
Accepted
17
2,940
91
x,a,b = map(int,input().split()) if abs(a-x)<abs(b-x): print("A") else: print("B")
s472806071
p03860
u425448230
2,000
262,144
Wrong Answer
21
3,064
37
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
# A s = input() print("A", s[8], "C")
s299841647
Accepted
22
3,064
37
# A s = input() print("A"+ s[8]+ "C")
s717487102
p03693
u626467464
2,000
262,144
Wrong Answer
17
2,940
107
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?
r,g,b = map(int,input().split()) num = 100*r + 10*g + b if num % 4 == 0: print("Yes") else: print("No")
s205911693
Accepted
18
2,940
107
r,g,b = map(int,input().split()) num = 100*r + 10*g + b if num % 4 == 0: print("YES") else: print("NO")
s215503984
p00101
u555040407
1,000
131,072
Wrong Answer
70
5,780
906
An English booklet has been created for publicizing Aizu to the world. When you read it carefully, you found a misnomer (an error in writing) on the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet says "Hoshino" not "Hoshina". Your task is to write a program which replace all the words "Hoshino" with "Hoshina". You can assume that the number of characters in a text is less than or equal to 1000.
n = int(input()) for __ in range(n): sentence = input() length = 0 after = "" while True: try: sentence[length] length += 1 except: break for i in range(length-6): if sentence[i] == "H": if sentence[i+1] == "o": if sentence[i+2] == "s": if sentence[i+3] == "h": if sentence[i+4] == "i": if sentence[i+5] == "n": if sentence[i+6] == "o": for j in range(i+6): after += sentence[j] after += "a" for j in range(i+7,length): after += sentence[j] print(after)
s395848632
Accepted
70
5,604
869
def get_length(sentence): length = 0 while True: try: if sentence[length] is not None: length += 1 except: break return length n = int(input()) target = "Hoshino" target_right = "Hoshina" length_target = get_length(target) for __ in range(n): sentence = input() length = get_length(sentence) for i in range(length - length_target +1): correct = True for j in range(length_target): if sentence[i+j] != target[j]: correct = False break if correct: after = "" for j in range(i): after += sentence[j] after += target_right for j in range(i+length_target, length): after += sentence[j] sentence = after print(sentence)
s010916811
p03110
u616025987
2,000
1,048,576
Wrong Answer
19
3,188
202
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
import re otoshidama = 0 N = int(input()) for i in range(0,N): ni = re.split('\s+', input()) if(ni[1] == 'BTC'): ni[0] = float(ni[0]) * 38000 otoshidama += float(ni[0]) print(otoshidama)
s254547533
Accepted
19
3,188
222
import re otoshidama = 0 N = int(input()) for i in range(0,N): ni = re.split('\s+', input()) if(ni[1] == 'BTC'): otoshidama += (float(ni[0]) * 380000.00) else: otoshidama += int(ni[0]) print(otoshidama)
s627540413
p03815
u095969144
2,000
262,144
Wrong Answer
17
2,940
54
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7. Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation: * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward. For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back. Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
import math i = int(input()) print(math.ceil(i / 11))
s186175014
Accepted
17
2,940
120
i = int(input()) x = i // 11 a = x * 2 b = i % 11 if b == 0: pass elif b <= 6: a += 1 else: a += 2 print(a)
s030154348
p03455
u393558653
2,000
262,144
Wrong Answer
17
2,940
168
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()) c = a * b % 2 if (c == 0): print("even") else: print("odd")
s849458843
Accepted
17
2,940
168
a,b = map(int,input().split()) c = a * b % 2 if (c == 0): print("Even") else: print("Odd")
s097539616
p03456
u371763408
2,000
262,144
Wrong Answer
18
3,060
121
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 a,b = map(int,input().split()) num = int(a+b) if math.sqrt(num) % 1 == 0: print('Yes') else: print('No')
s792658509
Accepted
20
3,316
113
import math a,b = input().split() num = int(a+b) if math.sqrt(num) % 1 == 0: print('Yes') else: print('No')
s547418674
p02613
u498531348
2,000
1,048,576
Wrong Answer
165
16,324
479
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.
IN = [input() for i in range(1)] N = int(IN[0]) INP = [input() for i in range(int(N))] AC = 0 WA = 0 TLE = 0 RE = 0 i = 0 while i < N: if INP[i] == "AC": AC = AC + 1 i = i + 1 elif INP[i] == "WA": WA = WA + 1 i = i + 1 elif INP[i] == "TLE": TLE = TLE + 1 i = i + 1 elif INP[i] == "RE": RE = RE + 1 i = i + 1 else: i = i + 1 print("AC × " + str(AC)) print("WA × " + str(WA)) print("TLE × " + str(TLE)) print("RE × " + str(RE))
s945963443
Accepted
160
15,964
475
IN = [input() for i in range(1)] N = int(IN[0]) INP = [input() for i in range(int(N))] AC = 0 WA = 0 TLE = 0 RE = 0 i = 0 while i < N: if INP[i] == "AC": AC = AC + 1 i = i + 1 elif INP[i] == "WA": WA = WA + 1 i = i + 1 elif INP[i] == "TLE": TLE = TLE + 1 i = i + 1 elif INP[i] == "RE": RE = RE + 1 i = i + 1 else: i = i + 1 print("AC x " + str(AC)) print("WA x " + str(WA)) print("TLE x " + str(TLE)) print("RE x " + str(RE))
s061673970
p03448
u078944864
2,000
262,144
Wrong Answer
984
3,064
319
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
a = int(input()) b = int(input()) c = int(input()) total = int(input()) max_a = total // 500 max_b = total // 100 max_c = total // 50 ans = 0 for i in range(0, max_a): for j in range(0, max_b): for k in range(0, max_c): sum = 500 * i + 100 * j + 50 * k if (sum == total) : ans += 1 print(ans)
s290601951
Accepted
48
3,064
411
a = int(input()) b = int(input()) c = int(input()) total = int(input()) max_a = a if total // 500 > a else total // 500 max_b = b if total // 100 > b else total // 100 max_c = c if total // 50 > c else total // 50 ans = 0 for i in range(0, max_a + 1): for j in range(0, max_b + 1): for k in range(0, max_c + 1): sum = 500 * i + 100 * j + 50 * k if (sum == total) : ans += 1 print(ans)
s846288686
p03470
u922449550
2,000
262,144
Wrong Answer
17
2,940
169
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
N = int(input()) D = list(map(int, input().split())) D.sort(reverse=True) ans = 0 pre_d = float('inf') for d in D: if d < pre_d: ans += 1 pre_d = d print(ans)
s638810674
Accepted
18
3,060
170
N = int(input()) D = [int(input()) for i in range(N)] D.sort(reverse=True) ans = 0 pre_d = float('inf') for d in D: if d < pre_d: ans += 1 pre_d = d print(ans)
s369128155
p03624
u432226259
2,000
262,144
Wrong Answer
81
6,376
255
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
S = list(map(str,input())) S_new = sorted(S) a = [] index = 0 print(S_new) for i in range(0, len(S_new) - 1): if ord(S_new[i + 1]) - ord(S_new[i]) > 1: index = i break if index == 0: print('None') else: ans = ord(S_new[index]) + 1 print(chr(ans))
s149736471
Accepted
73
5,092
387
def cal_word(n): return n - 97 def cal_word_rev(n): return n + 97 S = list(map(str,input())) S_new = sorted(S) index = -1 S_ans = [] for i in range(0, 26): S_ans.append('false') for i in range(0, len(S)): S_ans[cal_word(ord(S[i]))] = 'true' for i in range(0, 26): if S_ans[i] == 'false': index = i break if index == -1: print('None') else: print(chr(cal_word_rev(index)))
s552491702
p04043
u874303957
2,000
262,144
Wrong Answer
17
2,940
96
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.
ABC = list(map(int, input().split())) print('Yes' if ABC[0] * ABC[1] * ABC[2] == 175 else 'No')
s320386710
Accepted
17
2,940
97
ABC = list(map(int, input().split())) print('YES' if ABC[0] * ABC[1] * ABC[2] == 175 else 'NO')
s816379687
p03778
u451017206
2,000
262,144
Wrong Answer
17
2,940
107
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
W, a, b = map(int, input().split()) if b > a + W:print(b - a + W) elif b + W > a:print(b+W-a) else:print(0)
s445790764
Accepted
17
2,940
107
W, a, b = map(int, input().split()) if b > a + W:print(b - a - W) elif b + W < a:print(a-b-W) else:print(0)
s829792448
p03645
u986254798
2,000
262,144
Wrong Answer
865
49,748
574
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services. Help him.
from queue import Queue n, m = map(int, input().split()) adj = [[] for i in range(n+1)] for i in range(m): a, b = map(int, input().split()) adj[a].append(b) adj[b].append(a) def bfs(): queue = Queue() queue.put((1, 0)) visited = [False]*(n+1) while not queue.empty(): u, step = queue.get() for a in adj[u]: if a == n: print ("Possible") return if step + 1 < 2 and not visited[a]: queue.put((a, step+1)) print ("IMPOSSIBLE") return bfs()
s151488085
Accepted
838
43,676
638
from queue import Queue n, m = map(int, input().split()) adj = [[] for i in range(n+1)] for i in range(m): a, b = map(int, input().split()) adj[a].append(b) adj[b].append(a) def bfs(): queue = Queue() queue.put(1) distance = [10**6]*(n+1) distance[1] = 0 while not queue.empty(): u = queue.get() if u == n and distance[u] == 2: print ("POSSIBLE") return for a in adj[u]: if distance[u] + 1 <= 2 and distance[a] > distance[u] + 1: distance[a] = distance[u] + 1 queue.put(a) print ("IMPOSSIBLE") return bfs()
s346988796
p02612
u104005543
2,000
1,048,576
Wrong Answer
22
9,140
32
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)
s871540356
Accepted
29
9,056
34
n = int(input()) print(-n % 1000)
s144377275
p03697
u163320134
2,000
262,144
Wrong Answer
17
2,940
78
You are given two integers A and B as the input. Output the value of A + B. However, if A + B is 10 or greater, output `error` instead.
a,b=map(int,input().split()) if a+b>=10: print('error') else: print('a+b')
s186044049
Accepted
18
2,940
76
a,b=map(int,input().split()) if a+b>=10: print('error') else: print(a+b)
s653910509
p02407
u426534722
1,000
131,072
Wrong Answer
20
5,572
42
Write a program which reads a sequence and prints it in the reverse order.
print(*sorted(map(int, input().split())))
s093010712
Accepted
20
5,560
38
input() print(*input().split()[::-1])
s829238966
p03993
u953379577
2,000
262,144
Wrong Answer
72
20,548
131
There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a _friendly pair_ if the following condition is met. * Rabbit i likes rabbit j and rabbit j likes rabbit i. Calculate the number of the friendly pairs.
n = int(input()) s = list(map(int,input().split())) ans = 0 for i in range(n): if s[s[i]-1] == i+1: ans += 1 print(ans)
s070471860
Accepted
70
20,508
135
n = int(input()) s = list(map(int,input().split())) ans = 0 for i in range(n): if s[s[i]-1] == i+1: ans += 1 print(ans//2)
s443448327
p03494
u360842608
2,000
262,144
Wrong Answer
18
3,060
335
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.
def answer(in0, in1): N = int(in0) A = [int(a) for a in in1.split()] print(N) print(A) cnt = 0 while (True): for i in range(N): a = A[i] if a % 2 != 0: print(cnt) return A[i] = int(a / 2) cnt += 1 answer(input(), input())
s058505069
Accepted
18
2,940
309
def answer(in0, in1): N = int(in0) A = [int(a) for a in in1.split()] cnt = 0 while (True): for i in range(N): a = A[i] if a % 2 != 0: print(cnt) return A[i] = int(a / 2) cnt += 1 answer(input(), input())
s132033728
p03543
u897436032
2,000
262,144
Wrong Answer
17
2,940
51
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**?
input_ = input().split(",") print(" ".join(input_))
s439821954
Accepted
17
2,940
75
a,b,c,d = input() if a==b==c or b==c==d: print("Yes") else: print("No")
s743114213
p04012
u053856575
2,000
262,144
Wrong Answer
17
3,060
233
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
W=input() count=1 w=[] for j in range(len(W)): w.append(W[j]) w.sort() for i in range(len(w)-1): if w[i]==w[i+1]: count+=1 else: if count %2 !=0: print("No") exit() print("Yes")
s678045949
Accepted
18
3,064
281
W=input() count=1 w=[] for j in range(len(W)): w.append(W[j]) w.sort() w.append("") for i in range(len(w)-1): if w[i]==w[i+1]: count+=1 else: if count %2 !=0: print("No") exit() else: count=1 print("Yes")
s095017030
p02748
u857070771
2,000
1,048,576
Wrong Answer
354
18,608
267
You are visiting a large electronics store to buy a refrigerator and a microwave. The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen. You have M discount tickets. With the i-th ticket ( 1 \le i \le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time. You are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.
a,b,m=map(int,input().split()) *a,=map(int,input().split()) *b,=map(int,input().split()) mi=10**9 for i in range(m): x,y,c=map(int,input().split()) if len(a)<=x and len(b)<=y: res=a[x-1]+b[y-1]-c mi=min(mi,res) l=min(a)+min(b) print(min(mi,l))
s115929483
Accepted
467
18,648
271
a,b,m=map(int,input().split()) *a,=map(int,input().split()) *b,=map(int,input().split()) ans=10**9 for i in range(m): x,y,c=map(int,input().split()) if len(a)>=x and len(b)>=y: res=a[x-1]+b[y-1]-c ans=min(ans,res) l=min(a)+min(b) print(min(ans,l))
s296801527
p03680
u870297120
2,000
262,144
Wrong Answer
192
7,072
172
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.
n = int(input()) l = list(int(input()) for _ in range(n)) num = 1 ans = -1 for i in range(n): num = l[num-1] if num == 2: ans = i break print(ans)
s310318142
Accepted
195
7,072
172
n = int(input()) l = list(int(input()) for _ in range(n)) num = 1 ans = -1 for i in range(n): if num == 2: ans = i break num = l[num-1] print(ans)
s702667021
p03827
u111365959
2,000
262,144
Wrong Answer
17
2,940
104
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
n = int(input()) a = input() x = 0 for b in a: x += int(b.replace('I','1').replace('D','-1')) print(x)
s392478253
Accepted
17
2,940
134
input() tmp = x = 0 for a in input(): x += int(a.replace('I','1').replace('D','-1')) if tmp < x: tmp = x print(max([0,tmp]))
s055716435
p03448
u633914031
2,000
262,144
Wrong Answer
161
4,080
260
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
A=int(input()) B=int(input()) C=int(input()) X=int(input()) cnt=0 i=0 j=0 k=0 while i <= A: while j <= B: while k <= C: sum=500*i+100*j+50*k print(sum) if sum== X: cnt+=1 k+=1 j+=1 k=0 i+=1 j=0 k=0 print(cnt)
s648930712
Accepted
65
3,064
243
A=int(input()) B=int(input()) C=int(input()) X=int(input()) cnt=0 i=0 j=0 k=0 while i <= A: while j <= B: while k <= C: sum=500*i+100*j+50*k if sum== X: cnt+=1 k+=1 j+=1 k=0 i+=1 j=0 k=0 print(cnt)
s905156835
p03605
u952130512
2,000
262,144
Wrong Answer
17
2,940
73
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
s=input() if s[:1]==9 or s[-1:]==9: print("Yes") else: print("No")
s453901488
Accepted
17
2,940
74
s=input() if s[0]=="9" or s[1]=="9": print("Yes") else: print("No")
s668086654
p03079
u233729690
2,000
1,048,576
Wrong Answer
17
2,940
105
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
A,B,C = map(int, input().split()) print(A,B,C) if A == B and B == C: print('Yes') else: print('No')
s415824197
Accepted
17
2,940
91
A,B,C = map(int, input().split()) if A == B and B == C: print('Yes') else: print('No')
s461366973
p03399
u182249053
2,000
262,144
Wrong Answer
17
3,064
316
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
A = int(input("A = ")) B = int(input("B = ")) C = int(input("C = ")) D = int(input("D = ")) if A > B: if C > D: print("最小値 = %d" % (B+D)) else: print("最小値 = %d" % (B+C)) else: if C > D: print("最小値 = %d" % (A+D)) else: print("最小値 = %d" % (A+C))
s201104538
Accepted
17
3,060
244
A = int(input()) B = int(input()) C = int(input()) D = int(input()) if A > B: if C > D: print("%d" % (B+D)) else: print("%d" % (B+C)) else: if C > D: print("%d" % (A+D)) else: print("%d" % (A+C))
s661746804
p03371
u863044225
2,000
262,144
Wrong Answer
17
3,060
127
"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()) c=min(c*2,a+b) ans=min(x,y)*c if x>y:ans+=min(a,c)*(y-x) else:ans+=min(b,c)*(x-y) print(ans)
s781513678
Accepted
18
3,060
127
a,b,c,x,y=map(int,input().split()) c=min(c*2,a+b) ans=min(x,y)*c if x>y:ans+=min(a,c)*(x-y) else:ans+=min(b,c)*(y-x) print(ans)
s834367046
p02612
u274615057
2,000
1,048,576
Wrong Answer
29
9,084
94
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.
def main(): n = int(input()) print(n % 1000) if __name__ == "__main__": main()
s968005646
Accepted
27
9,164
154
def main(): n = int(input()) if n % 1000 != 0: print(1000 - n % 1000) else: print(0) if __name__ == "__main__": main()
s882482375
p03369
u811730180
2,000
262,144
Wrong Answer
17
2,940
97
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() Ss = [S[0],S[1],S[2]] Ss_extract = [x for x in Ss if x == "o"] print(len(Ss_extract))
s770127936
Accepted
17
2,940
107
S = input() Ss = [S[0],S[1],S[2]] Ss_extract = [x for x in Ss if x == "o"] print(700 + len(Ss_extract)*100)
s359500723
p02259
u825178626
1,000
131,072
Wrong Answer
30
7,484
404
Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 4 of the pseudocode.
# coding: utf-8 # Here your code ! S = int(input()) N = list(map(int,input().split())) count=0 def bubblesort(n,s): global count flag = 1 while flag: flag = 0 for i in range(s-1,0,-1): key = n[i] if n[i]<n[i-1]: n[i]=n[i-1] n[i-1]=key count+=1 flag=1 bubblesort(N,S) print(count)
s398659786
Accepted
20
7,636
446
# coding: utf-8 # Here your code ! S = int(input()) N = list(map(int,input().split())) count=0 def bubblesort(n,s): global count flag = 1 while flag: flag = 0 for i in range(s-1,0,-1): key = n[i] if n[i]<n[i-1]: n[i]=n[i-1] n[i-1]=key count+=1 flag=1 print(" ".join(list(map(str,n)))) print(count) bubblesort(N,S)
s532059283
p03861
u854093727
2,000
262,144
Wrong Answer
17
2,940
61
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
a,b,c = map(int,input().split()) print(int(b/c - ((a-1)/c)))
s443981473
Accepted
17
2,940
63
a,b,c = map(int,input().split()) print(int(b//c - ((a-1)//c)))
s863313216
p03573
u550535134
2,000
262,144
Wrong Answer
17
2,940
84
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
A, B, C = map(int, input().split()) print("A" if B == C else "B" if A == C else "C")
s926205984
Accepted
18
2,940
79
A, B, C = map(int, input().split()) print(A if B == C else B if A == C else C)
s303395059
p02458
u847467233
4,000
262,144
Wrong Answer
30
5,628
628
For a set $S$ of integers, perform a sequence of the following operations. Note that _multiple elements can have equivalent values in $S$_. * insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation. * find($x$): Report the number of $x$ in $S$. * delete($x$): Delete all $x$ from $S$. * dump($L$, $R$): Print elements $x$ in $S$ such that $L \leq x \leq R$.
# AOJ ITP2_7_D: Multi-Set # Python3 2018.6.24 bal4u from bisect import bisect_left, bisect_right, insort_left dict = {} keytbl = [] cnt = 0 q = int(input()) for i in range(q): a = list(input().split()) ki = int(a[1]) if a[0] == '0': if ki not in dict: dict[ki] = 1 insort_left(keytbl, ki) else: dict[ki] += 1 cnt += 1 print(cnt) elif a[0] == '1': print(dict[ki] if ki in dict else 0) elif a[0] == '2': if ki in dict: cnt -= dict[ki] dict[ki] = 0 else: L = bisect_left (keytbl, int(a[1])) R = bisect_right(keytbl, int(a[2]), L) for j in range(L, R): if dict[keytbl[j]] > 0: print(keytbl[j])
s921684839
Accepted
3,420
17,908
660
# AOJ ITP2_7_D: Multi-Set # Python3 2018.6.24 bal4u from bisect import bisect_left, bisect_right, insort_left dict = {} keytbl = [] cnt = 0 q = int(input()) for i in range(q): a = list(input().split()) ki = int(a[1]) if a[0] == '0': if ki not in dict: dict[ki] = 1 insort_left(keytbl, ki) else: dict[ki] += 1 cnt += 1 print(cnt) elif a[0] == '1': print(dict[ki] if ki in dict else 0) elif a[0] == '2': if ki in dict: cnt -= dict[ki] dict[ki] = 0 else: L = bisect_left (keytbl, int(a[1])) R = bisect_right(keytbl, int(a[2]), L) r = [] for j in range(L, R): r += [keytbl[j]]*dict[keytbl[j]] if r != []: print(*r, sep='\n')
s116682179
p03089
u797664206
2,000
1,048,576
Wrong Answer
17
3,060
311
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
n = int(input()) l = [int(i) for i in input().split()] a = [0]*n o = 0 for i in l: o+=1 if(i<=o): if(i<=len(a)): if(a[i-1]!=0): a[a.index(0)] = i else: a[i-1] = i if(a == l): print("\n".join([str(i) for i in a])) else: print(-1)
s376249742
Accepted
18
3,060
299
n = int(input()) l = input().split() res = [] for i in range(n): for j in range(len(l)-1,-1,-1): if(l[j] == str(j+1)): res.append(l[j]) del(l[j]) break if(l != []): print(-1) else: print("\n".join(res[::-1]))
s087120649
p02600
u961683878
2,000
1,048,576
Time Limit Exceeded
2,222
520,056
1,123
M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a _kyu_ (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have?
#! /usr/bin/env python3 import sys int1 = lambda x: int(x) - 1 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(500000) N = int(readline()) XYP = [list(map(int, readline().split())) for _ in range(N)] x_cost = [[0 for _ in range(N)] for _ in range(1 << N)] y_cost = [[0 for _ in range(N)] for _ in range(1 << N)] for bit in range(1 << N): for i in range(N): x_cost[bit][i] = abs(XYP[i][0]) y_cost[bit][i] = abs(XYP[i][1]) for k in range(N): if bit & (1 << k): x_cost[bit][i] = min(x_cost[bit][i], abs(XYP[i][0] - XYP[k][0])) y_cost[bit][i] = min(y_cost[bit][i], abs(XYP[i][1] - XYP[k][1])) ans = [sys.maxsize for _ in range(N + 1)] for bit in range(1 << N): cnt = bin(bit).count('1') bit_ = bit while bit_ >= 0: bit_ &= bit cost = 0 for k in range(N): cost += 1 * XYP[k][2] * min(x_cost[bit_][k], y_cost[bit - bit_][k]) ans[cnt] = min(ans[cnt], cost) bit_ -= 1 for i in range(N + 1): print(ans[i])
s258713616
Accepted
126
27,148
467
#! /usr/bin/env python3 import sys import numpy as np int1 = lambda x: int(x) - 1 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(500000) X = int(readline()) if X <= 599: print(8) elif X <= 799: print(7) elif X <= 999: print(6) elif X <= 1199: print(5) elif X <= 1399: print(4) elif X <= 1599: print(3) elif X <= 1799: print(2) elif X <= 1999: print(1)
s607780934
p02613
u202145645
2,000
1,048,576
Wrong Answer
155
16,640
266
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.
from collections import Counter N = int(input()) list_s = [] for i in range(N): S = input() list_s.append(S) D = Counter(list_s) print("AC x " + str(D["AC"])) print("WA x " + str(D["WA"])) print("TLE x " + str(D["TLE"])) print("RE x " + str(D["RE"]))
s618203079
Accepted
152
16,624
262
from collections import Counter N = int(input()) list_s = [] for i in range(N): S = input() list_s.append(S) D = Counter(list_s) print("AC x " + str(D["AC"])) print("WA x " + str(D["WA"])) print("TLE x " + str(D["TLE"])) print("RE x " + str(D["RE"]))
s911520655
p02972
u726615467
2,000
1,048,576
Wrong Answer
1,269
10,936
448
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 sys # input = sys.stdin.readline inf = 10 ** 18 P = 10 ** 9 + 7 N = int(input()) a = list(map(int, input().split())) x = [None] * N for i_inv in range(N): i = (N - 1) - i_inv j = 2 xi = a[i] % 2 while (i + 1) * j < N: xi ^= x[(i + 1) * j - 1] j += 1 x[i] = xi print(sum(x)) ans = [] for i, xi in enumerate(x): if xi == 1: ans.append(i + 1) if sum(x) < 0: print(' '.join(map(str, ans)))
s344683596
Accepted
1,349
19,892
543
import sys # input = sys.stdin.readline inf = 10 ** 18 P = 10 ** 9 + 7 N = int(input()) a = list(map(int, input().split())) x = [ai % 2 for ai in a] for i_inv in range(N): i = (N - 1) - i_inv j = 2 xi = x[i] # print("#", i, a[i]) while (i + 1) * j - 1 < N: # print("##", (i + 1) * j - 1, x[(i + 1) * j - 1]) xi ^= x[(i + 1) * j - 1] j += 1 x[i] = xi print(sum(x)) ans = [] for i, xi in enumerate(x): if xi == 1: ans.append(i + 1) if sum(x) > 0: print(' '.join(map(str, ans)))
s557942492
p03698
u035210736
2,000
262,144
Wrong Answer
29
9,024
78
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
s = list(input()) if len(s) == len(set(s)): print("YES") else: print("NO")
s446185683
Accepted
30
8,988
79
s = list(input()) if len(s) == len(set(s)): print("yes") else: print("no")
s824053922
p02615
u616382321
2,000
1,048,576
Wrong Answer
131
31,432
110
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?
N = int(input()) A = list(map(int, input().split())) A.sort(reverse=True) print(A) B = A[:-1] print(sum(B))
s872179188
Accepted
106
31,428
180
N = int(input()) A = list(map(int, input().split())) A.sort(reverse=True) if N%2 == 0: print(sum(A[:int(N/2)])*2 - A[0]) else: print(sum(A[:N//2+1])*2 - A[0] - A[N//2])
s752391113
p03485
u923010184
2,000
262,144
Wrong Answer
17
2,940
58
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()) print(int(a / 2 + b /2) +1)
s540811484
Accepted
17
2,940
55
a,b = map(int,input().split()) print(((a + b +1) // 2))
s686654952
p03657
u241159583
2,000
262,144
Wrong Answer
17
2,940
127
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
a, b = map(int, input().split()) if a + b % 3 == 0 or a % 3 == 0 or b % 3 == 0: print("Possible") else: print("Impossible")
s898167401
Accepted
18
2,940
101
a,b = map(int, input().split()) print("Possible" if a%3==0 or b%3==0 or (a+b)%3==0 else "Impossible")
s039914955
p03994
u100927237
2,000
262,144
Wrong Answer
2,104
109,836
363
Mr. Takahashi has a string s consisting of lowercase English letters. He repeats the following operation on s exactly K times. * Choose an arbitrary letter on s and change that letter to the next alphabet. Note that the next letter of `z` is `a`. For example, if you perform an operation for the second letter on `aaz`, `aaz` becomes `abz`. If you then perform an operation for the third letter on `abz`, `abz` becomes `aba`. Mr. Takahashi wants to have the lexicographically smallest string after performing exactly K operations on s. Find the such string.
makeA = lambda c: (ord('z')-ord(c)+1) % 26 s = list(map(makeA,list(input()))) print(s) K = int(input()) len_s = len(s) print(len_s) for i in range(len_s-1): if s[i] <= K: K -= s[i] s[i] = 0 print(s) if K > 0: s[-1] = (s[-1] + 26 - (K % 26)) % 26 print(s) makeS = lambda n: chr((26-n)%26+ord('a')) print(''.join(list(map(makeS,s))))
s033365469
Accepted
97
4,836
369
makeA = lambda c: (ord('z')-ord(c)+1) % 26 s = list(map(makeA,list(input()))) #print(s) K = int(input()) len_s = len(s) #print(len_s) for i in range(len_s-1): if s[i] <= K: K -= s[i] s[i] = 0 #print(s) if K > 0: s[-1] = (s[-1] + 26 - (K % 26)) % 26 #print(s) makeS = lambda n: chr((26-n)%26+ord('a')) print(''.join(list(map(makeS,s))))