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
s097240592
p02694
u464912173
2,000
1,048,576
Wrong Answer
20
9,160
67
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()) a=100 b=0 while a>x: a +=a//100 b+=1 print(b)
s586509448
Accepted
22
9,156
72
x = int(input()) a=100 b=0 while a<x: a =int(a*1.01) b+=1 print(b)
s104152947
p03369
u013605408
2,000
262,144
Wrong Answer
17
2,940
29
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.
print(700+input().count("o"))
s576964705
Accepted
17
2,940
35
print(700+(input().count("o")*100))
s452905825
p03450
u785578220
2,000
262,144
Wrong Answer
2,108
9,012
1,785
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
class WeightedUnionFind: def __init__(self, n): self.par = [i for i in range(n+1)] self.rank = [0] * (n+1) self.weight = [0] * (n+1) def find(self, x): if self.par[x] == x: return x else: y = self.find(self.par[x]) self.weight[x] += self.weight[self.par[x]] self.par[x] = y return y def union(self, x, y, w): rx = self.find(x) ry = self.find(y) if self.rank[rx] < self.rank[ry]: self.par[rx] = ry self.weight[rx] = w - self.weight[x] + self.weight[y] else: self.par[ry] = rx self.weight[ry] = -w - self.weight[y] + self.weight[x] if self.rank[rx] == self.rank[ry]: self.rank[rx] += 1 def same(self, x, y): return self.find(x) == self.find(y) def diff(self, x, y): return self.weight[x] - self.weight[y] def main(): max_v, max_e = map(int, input().split()) uf = WeightedUnionFind(max_v) k = [] s = 0 for i in range(max_e): a,b,w= map(int, input().split()) if a not in k: k.append(a) if b not in k: k.append(b) if a in k and b in k: uf.diff(a,b) == w s =1 else:uf.union(a,b,w) if s == 0: print("Yes") else: print("No") if __name__ == '__main__': main()
s156701291
Accepted
737
8,948
1,164
def main(): import sys input = sys.stdin.readline def find(x): if par[x] < 0: return x else: px = find(par[x]) wei[x] += wei[par[x]] par[x] = px return px def weight(x): find(x) return wei[x] def unite(x,y,w): w += wei[x]-wei[y] x = find(x) y = find(y) if x == y: return False else: if par[x] > par[y]: x,y = y,x w = -w par[x] += par[y] par[y] = x wei[y] = w return True def same(x,y): return find(x) == find(y) def size(x): return -par[find(x)] def diff(x,y): return weight(y)-weight(x) n,m = map(int,input().split()) par = [-1]*n wei = [0]*n for i in range(m): l,r,d = map(int,input().split()) l,r = l-1,r-1 if same(l,r): if d != diff(l,r): print('No') exit() else: unite(l,r,d) print('Yes') if __name__ == '__main__': main()
s793780446
p02936
u918601425
2,000
1,048,576
Wrong Answer
2,110
110,256
2,012
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.
N,Q=[int(s) for s in input().split()] e_list=[[int(s) for s in input().split()] for i in range(N-1)] q_list=[[int(s) for s in input().split()] for i in range(Q)] def euler_tour(edge_list,start): reach=[[start,1,0]] ans=[start] path=[start] e_list=[[e[0],e[1],0] for e in edge_list] vertex=start endflag=0 depth=1 while True : for e in e_list: if (e[0]==vertex and e[2]==0): reach.append([e[1],0,depth]) e[2]=1 elif (e[1]==vertex and e[2]==0): reach.append([e[0],0,depth]) e[2]=1 for i in range(len(reach)+1): if reach[-i][1]==0 : vertex=reach[-i][0] if reach[-i][2]<depth: for j in range(1,depth-reach[-i][2]+1): path.remove(path[-1]) ans.append(path[-1]) ans.append(vertex) path.append(vertex) depth=reach[-i][2]+1 reach[-i][1]=1 break if i==len(reach): for j in range(len(path)-1): path.remove(path[-1]) ans.append(path[-1]) return ans break euler=euler_tour(e_list,1) def eu(num): if num==1: return [i+1 for i in range(N)] ans=[] i=-1 while True : i+=1 if euler[i]==num: ii=euler[i-1] break while True: if euler[i]==ii: break ans.append(euler[i]) i+=1 return list(set(ans)) answer=[0 for i in range(N)] for q in q_list: for v in eu(q[0]): answer[v-1]+=q[1] print(answer)
s212881083
Accepted
1,860
68,952
553
n,q=[int(s) for s in input().split()] graph=[[] for _ in range(n)] for i in range(n-1): a,b=[int(s) for s in input().split()] a-=1 b-=1 graph[a].append(b) graph[b].append(a) ct=[0 for _ in range(n)] for i in range(q): p,x=[int(s) for s in input().split()] p-=1 ct[p]+=x stack=[(0, ct[0], -1)] ans=[0 for _ in range(n)] while stack: vrt, cost, _from = stack.pop(-1) ans[vrt] = cost for _to in graph[vrt]: if _to ==_from: continue stack.append((_to, cost+ct[_to],vrt)) print(*ans)
s083625426
p03611
u652150585
2,000
262,144
Wrong Answer
131
16,096
331
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()) l=list(map(int,input().split())) s=collections.Counter(l) s=s.most_common() #print(s) f=[0]*len(s) for i in range(len(s)): f[i]=s[i][1] if s[i-1][0]==s[i][0]-1 and i>=1: f[i]+=s[i-1][1] if i<=len(s)-2: if s[i+1][0]==s[i][0]+1: f[i]+=s[i+1][1] print(max(f))
s817942745
Accepted
150
16,096
373
import collections n=int(input()) l=list(map(int,input().split())) s=collections.Counter(l) s=list(s.items()) s=sorted(s,key=lambda x:x[0]) #print(s) f=[0]*len(s) for i in range(len(s)): f[i]=s[i][1] if i>=1: if s[i-1][0]==s[i][0]-1: f[i]+=s[i-1][1] if i<=len(s)-2: if s[i+1][0]==s[i][0]+1: f[i]+=s[i+1][1] print(max(f))
s466386587
p03024
u675757825
2,000
1,048,576
Wrong Answer
18
2,940
113
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
s = input() cnt = 0 for i in s: if (i == 'o'): cnt += 1 print('Yes' if len(s) - cnt <= 7 else 'No')
s241931892
Accepted
17
2,940
113
s = input() cnt = 0 for i in s: if (i == 'o'): cnt += 1 print('YES' if len(s) - cnt <= 7 else 'NO')
s286123341
p03854
u457554982
2,000
262,144
Wrong Answer
19
3,956
385
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`.
s=list(input()) s.reverse() judge=True i=0 while i<=len(s)-5: box=[] for j in range(5): box+=s[i+j] if box==["m","a","e","r","d"] or box==["e","s","a","r","e"]: print(box) i+=5 else: box+=s[i+5]+s[i+6] print(box) if box==["r","e","m","a","e","r","d"] or box==["r","e","s","a","r","e"]: i+=7 else: judge=False break if judge: print("YES") else: print("NO")
s076494926
Accepted
68
3,956
419
s=list(input()) s.reverse() judge=True i=0 while i<=len(s)-5: box=[] for j in range(5): box+=s[i+j] if box==["m","a","e","r","d"] or box==["e","s","a","r","e"]: i+=5 #print(box) else: box+=s[i+5] #print(box) if box==["r","e","s","a","r","e"]: i+=6 else: box+=s[i+6] if box==["r","e","m","a","e","r","d"]: i+=7 else: judge=False break if judge: print("YES") else: print("NO")
s566803198
p03778
u399721252
2,000
262,144
Wrong Answer
17
2,940
74
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 = [ int(v) for v in input().split() ] print(max(abs(a-b) - 5, 0))
s893015695
Accepted
17
2,940
74
w, a, b = [ int(v) for v in input().split() ] print(max(abs(a-b) - w, 0))
s840307198
p03386
u239342230
2,000
262,144
Wrong Answer
2,104
3,060
95
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()) for i in range(A,B+1): if i<=A+K or i>=B-K: print(i)
s850849283
Accepted
17
3,060
106
A,B,K=map(int,input().split());r=range(A,B+1) for i in sorted(set(list(r[:K])+list(r[-K:]))): print(i)
s854080803
p03861
u541610817
2,000
262,144
Wrong Answer
17
2,940
72
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, x = [int(x) for x in input().split()] a //= x b //= x print(b - a)
s296980996
Accepted
17
2,940
88
a, b, x = [int(x) for x in input().split()] a = (a + x - 1)//x b //= x print(b - a + 1)
s541068493
p02258
u424457654
1,000
131,072
Wrong Answer
30
7,568
173
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen. Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
n = int(input()) max = -1000000000 min = int(input()) for i in range(1, n): r = int(input()) if max < (r - min): max = r - min if min > r: max = min print(max)
s263886615
Accepted
430
7,724
171
n = int(input()) max = -1000000000 min = int(input()) for i in range(1, n): r = int(input()) if max < (r - min): max = r - min if min > r: min = r print(max)
s240485471
p03545
u632369368
2,000
262,144
Wrong Answer
17
3,064
422
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
import itertools A, B, C, D = [int(s) for s in list(input())] print('A:{}, B:{}, C:{}, D:{}'.format(A, B, C, D)) symbols = ['+', '-'] for s1, s2, s3 in itertools.product(symbols, symbols, symbols): N = 0 N = A + B if s1 == '+' else A - B N = N + C if s2 == '+' else N - C N = N + D if s3 == '+' else N - D if N == 7: print('{}{}{}{}{}{}{}={}'.format(A, s1, B, s2, C, s3, D, N)) break
s992710064
Accepted
17
3,064
371
import itertools A, B, C, D = [int(s) for s in list(input())] symbols = ['+', '-'] for s1, s2, s3 in itertools.product(symbols, symbols, symbols): N = 0 N = A + B if s1 == '+' else A - B N = N + C if s2 == '+' else N - C N = N + D if s3 == '+' else N - D if N == 7: print('{}{}{}{}{}{}{}={}'.format(A, s1, B, s2, C, s3, D, N)) break
s013726093
p03730
u809670194
2,000
262,144
Wrong Answer
17
2,940
183
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
i = input().split() a = int(i[0]) b = int(i[1]) c = int(i[2]) d =a*b answer = "NO" while a <= d: if a%b==c: answer = "YES" break a += a print(answer)
s410813344
Accepted
17
2,940
174
i = input().split() a = int(i[0]) b = int(i[1]) c = int(i[2]) answer = "NO" count = a for i in range(1,b+1): if (i*a)%b==c: answer = "YES" print(answer)
s459087237
p04029
u369338402
2,000
262,144
Wrong Answer
17
2,940
67
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?
n=int(input()) result=0 for i in range(1,n+1): result+=i print(i)
s529836879
Accepted
17
2,940
38
n=int(input()) print(int((n*(1+n))/2))
s551276470
p03386
u552822163
2,000
262,144
Wrong Answer
18
3,064
873
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.
# coding=utf-8 def from_down(base, number, upper): return_list = [] range_upper = min(upper+1, base+number) for i in range(base, range_upper): return_list.append(i) return return_list def from_up(base, number, down): return_list = [] range_down = max(base-number+1, down) for i in range(range_down, base+1): return_list.append(i) return return_list def remove_double(object_list): list_unique = [] for x in object_list: if x not in list_unique: list_unique.append(x) return list_unique if __name__ == '__main__': A, B, K = map(int, input().split()) down_list = from_down(A, K, B) upper_list = from_up(B, K, A) print(down_list) print(upper_list) down_list.extend(upper_list) print(down_list) unique_list = remove_double(down_list) print(unique_list)
s039348185
Accepted
18
3,064
843
# coding=utf-8 def from_down(base, number, upper): return_list = [] range_upper = min(upper+1, base+number) for i in range(base, range_upper): return_list.append(i) return return_list def from_up(base, number, down): return_list = [] range_down = max(base-number+1, down) for i in range(range_down, base+1): return_list.append(i) return return_list def remove_double(object_list): list_unique = [] for x in object_list: if x not in list_unique: list_unique.append(x) return list_unique if __name__ == '__main__': A, B, K = map(int, input().split()) down_list = from_down(A, K, B) upper_list = from_up(B, K, A) down_list.extend(upper_list) unique_list = remove_double(down_list) output = [print(element) for element in unique_list]
s309716532
p03814
u095969144
2,000
262,144
Wrong Answer
17
3,500
56
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
s = input() a = s.find("a") z = s.find("z") print(z - a)
s184331512
Accepted
17
3,500
62
s = input() a = s.find("A") b = s.rfind("Z") print(b - a + 1)
s700865459
p04044
u399721252
2,000
262,144
Wrong Answer
18
2,940
118
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 = [ v for v in input().split() ] string_list = sorted([ v for v in input().split() ]) print("".join(string_list))
s954455106
Accepted
17
3,060
122
n, l = [ int(v) for v in input().split() ] string_list = sorted([ input() for v in range(n) ]) print("".join(string_list))
s840198232
p03737
u612975321
2,000
262,144
Wrong Answer
23
9,028
66
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
a, b, c = input().split() print(a.upper() + b.upper() + c.upper())
s610154586
Accepted
24
9,088
75
a, b, c = input().split() print(a[0].upper() + b[0].upper() + c[0].upper())
s187995638
p03971
u921773161
2,000
262,144
Wrong Answer
112
4,708
474
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.
#%% n, a, b = map(int, input().split()) s = list(input()) c = 0 d = 0 for i in range(n): if s[i] == 'a': if c < a+b: c += 1 print('Yes') else: print('no') elif s[i] == 'b': if c < a+b: if d < b: print('Yes') c += 1 d += 1 else: print('No') else: print('No') else: print('No') #%%
s942652340
Accepted
116
4,712
475
#%% n, a, b = map(int, input().split()) s = list(input()) c = 0 d = 0 for i in range(n): if s[i] == 'a': if c < a+b: c += 1 print('Yes') else: print('No') elif s[i] == 'b': if c < a+b: if d < b: print('Yes') c += 1 d += 1 else: print('No') else: print('No') else: print('No') #%%
s100909731
p03971
u844895214
2,000
262,144
Wrong Answer
62
9,208
629
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.
import sys def S(): return sys.stdin.readline().rstrip() def IL(): return map(int,sys.stdin.readline().rstrip().split()) def solve(): n,a,b = IL() s = S() count = 0 fs = 1 for rep in s: if rep=='a': if count < a+b: count += 1 print('Yes') else: print('No') elif rep=='b': if count<a+b and fs<=b: count += 1 fs += 1 print('yes') else: print('No') else: print('No') return if __name__=='__main__': solve()
s188706854
Accepted
59
9,244
629
import sys def S(): return sys.stdin.readline().rstrip() def IL(): return map(int,sys.stdin.readline().rstrip().split()) def solve(): n,a,b = IL() s = S() count = 0 fs = 1 for rep in s: if rep=='a': if count < a+b: count += 1 print('Yes') else: print('No') elif rep=='b': if count<a+b and fs<=b: count += 1 fs += 1 print('Yes') else: print('No') else: print('No') return if __name__=='__main__': solve()
s203297551
p04011
u900109664
2,000
262,144
Wrong Answer
17
2,940
145
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.
N = int(input('N>')) K = int(input('K>')) X = int(input('X>')) Y = int(input('Y>')) if N >= K: print( K*X + (N-K)*Y ) else: print( N*X )
s962872565
Accepted
17
2,940
131
N = int(input()) K = int(input()) X = int(input()) Y = int(input()) if N >= K: print( K*X + (N-K)*Y ) else: print( N*X )
s006073879
p00015
u648595404
1,000
131,072
Wrong Answer
20
7,596
92
A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647. Your task is to write a program which reads two integers (more than or equal to zero), and prints a sum of these integers. If given integers or the sum have more than 80 digits, print "overflow".
n = int(input()) for i in range(n): a = int(input()) b = int(input()) print(a+b)
s285971172
Accepted
20
7,540
168
n = int(input()) for i in range(n): a = int(input()) b = int(input()) c = str(a+b) if len(c) > 80: print("overflow") else: print(c)
s623711069
p02257
u665238221
1,000
131,072
Wrong Answer
20
5,664
265
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.
def is_prime(x): if x == 2: return True if x < 2: return False for i in range(3, int(x ** .5) + 1, 2): if x % i == 0: return False return True n = int(input()) print(sum(is_prime(int(input())) for _ in range(n)))
s981939432
Accepted
220
5,688
279
def is_prime(x): if x == 2: return True if x < 2 or x % 2 == 0: return False for i in range(3, int(x ** .5) + 1, 2): if x % i == 0: return False return True n = int(input()) print(sum(is_prime(int(input())) for _ in range(n)))
s298746053
p02646
u306142032
2,000
1,048,576
Wrong Answer
21
9,040
137
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 = map(int, input().split()) b, w = map(int, input().split()) t = int(input()) if (b-a) < t*(w-v): print('YES') else: print('NO')
s516833478
Accepted
22
9,176
141
a, v = map(int, input().split()) b, w = map(int, input().split()) t = int(input()) if abs(a-b) <= t*(v-w): print('YES') else: print('NO')
s391146026
p03448
u884323674
2,000
262,144
Wrong Answer
33
5,656
356
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 = 30 B = 40 C = 50 X = 6000 A_list = [500*i for i in range(A+1)] B_list = [100*i for i in range(B+1)] C_list = [50*i for i in range(C+1)] sum_list = [] for i in A_list: for j in B_list: i_j = i + j for k in C_list: sum_list.append(i_j + k) result = 0 for i in sum_list: if i == X: result += 1 print(result)
s622595408
Accepted
35
3,060
258
A = int(input()) B = int(input()) C = int(input()) X = int(input()) result = 0 for i in range(A+1): for j in range(B+1): i_j = 500*i + 100*j for k in range(C+1): if i_j + 50*k == X: result += 1 print(result)
s045593622
p03485
u485716382
2,000
262,144
Wrong Answer
17
2,940
99
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.
def solve(): a, b = map(int, input().split()) x = ((a + b) // 2) + 1 print(x) solve()
s090404358
Accepted
17
2,940
109
from math import ceil def solve(): a, b = map(int, input().split()) print(ceil((a + b) / 2)) solve()
s995959785
p03997
u566321790
2,000
262,144
Wrong Answer
17
3,060
146
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()) if a>b: print((((a-b)*h)/2)+(b*h)) elif b>a: print((((b-a)*h)/2)+(a*h)) else: print(a*h)
s940821282
Accepted
17
3,060
161
a = int(input()) b = int(input()) h = int(input()) if a>b: print(int((((a-b)*h)/2)+(b*h))) elif b>a: print(int((((b-a)*h)/2)+(a*h))) else: print(int(a*h))
s797559101
p03555
u484856305
2,000
262,144
Wrong Answer
17
2,940
81
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
a=input() b=input() c=b[::-1] if a == c[::-1]: print("YES") else: print("NO")
s272899166
Accepted
18
2,940
76
a=input() b=input() c=b[::-1] if a == c: print("YES") else: print("NO")
s845540191
p03854
u545368057
2,000
262,144
Wrong Answer
17
3,316
1,371
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`.
S = input() strs = ["dream","dreamer","erase","eraser"] ind = 0 while True: # print(ind,S[ind]) if S[ind] == "e": if S[ind:ind+5] == "erase": if ind+5 == len(S): print("YES") exit() if S[ind+5] == "r": if ind + 6 ==len(S): print("YES") exit() ind+=6 elif S[ind+5] == "d" or S[ind+5]=="e": ind+=5 else: print("NO") exit() else: print("NO") exit() elif S[ind] == "d": if S[ind:ind+5] == "dream": if ind + 5 == len(S): print("YES") exit() if S[ind+5] == "d" :ind += 5 if S[ind+5] == "e": if S[ind+6] == "r": if ind + 7 == len(S): print("YES") exit() if S[ind+7] == "e" or S[ind+7] =="d": ind += 6 elif S[ind+7] == "a": ind += 5 else: print("NO") exit() else: print("NO") exit() else: print("NO") exit() print(ind)
s148727040
Accepted
29
3,188
389
S = input() strs = ["erase", "eraser", "dreamer","dream"] rtss = [s[::-1] for s in strs] S = S[::-1] ind = 0 while True: # print(ind,S[ind]) if S[ind:ind+5] in rtss: ind += 5 elif S[ind:ind+6] in rtss: ind += 6 elif S[ind:ind+7] in rtss: ind +=7 else: print("NO") exit() if ind == len(S): print("YES") exit()
s190885071
p03338
u945418216
2,000
1,048,576
Wrong Answer
18
3,060
232
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.
#ABC098B n = int(input()) s = input() ans = 0 for i in range(1,n): s1 = list(set(s[:i])) s2 = list(set(s[i:])) cnt = [s2.count(x) for x in s1] count=0 for c in cnt: count+=c ans=max(ans,count) print()
s196636677
Accepted
20
3,060
200
n=int(input()) s=input() ans=0 for i in range(n): l = list(set(s[:i])) r = list(set(s[i:])) count=0 for x in l: count+=r.count(x) if ans<count: ans=count print(ans)
s309330055
p03455
u027208253
2,000
262,144
Wrong Answer
17
2,940
107
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a, b = input().split() result = int(a) * int(b) if result % 2 == 0: print("even") else : print("odd")
s007882599
Accepted
17
2,940
108
a,b = input().split() result = int(a) * int(b) if result % 2 == 0: print("Even") else : print("Odd")
s867551933
p03598
u586639900
2,000
262,144
Wrong Answer
32
9,180
189
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()) X = list(map(int, input().split())) res = 0 for i in range(N): if X[i] >= (K - X[i]): res += 2 * X[i] else: res += 2 * (K - X[i]) print(res)
s683128610
Accepted
28
9,180
189
N = int(input()) K = int(input()) X = list(map(int, input().split())) res = 0 for i in range(N): if X[i] <= (K - X[i]): res += 2 * X[i] else: res += 2 * (K - X[i]) print(res)
s626417296
p03433
u215643129
2,000
262,144
Wrong Answer
27
9,112
109
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 = list(map(int, input().split())) a.sort(reverse=True) print(sum(a[::2])-sum(a[1::2]))
s959225501
Accepted
29
9,120
83
n = int(input()) a = int(input()) if n%500 <= a: print("Yes") else: print("No")
s018254056
p03485
u144242534
2,000
262,144
Wrong Answer
32
9,040
95
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()) x = a + b if x % 2 == 0: print(x/2) else: print((x + 1)/2)
s359076722
Accepted
23
8,940
105
a, b = map(int, input().split()) x = a + b if x % 2 == 0: print(int(x/2)) else: print(int((x + 1)/2))
s575509349
p03854
u390958150
2,000
262,144
Wrong Answer
2,104
3,188
271
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`.
s = input() ans = 'YES' while len(s) > 0: if s.endswith('dreamer'): s = s[:-7] elif s.endswith('dream'): s = s[:-5] elif s.endswith('eraser'): s = s[:-6] elif s.endswith('erase'): s = s[:-5] else: ans = 'NO'
s496846193
Accepted
68
3,188
298
s = input() ans = 'YES' while len(s) > 0: if s.endswith('dreamer'): s = s[:-7] elif s.endswith('dream'): s = s[:-5] elif s.endswith('eraser'): s = s[:-6] elif s.endswith('erase'): s = s[:-5] else: ans = 'NO' break print(ans)
s784034555
p03659
u507456172
2,000
262,144
Wrong Answer
165
30,656
180
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())) S1 = A[0] S2 = sum(A)-A[0] B = [S1-S2] for i in range(N-2): S1 += A[i+1] S2 -= A[i+1] B.append(abs(S1-S2)) print(min(B))
s685515129
Accepted
165
30,468
185
N = int(input()) A = list(map(int,input().split())) S1 = A[0] S2 = sum(A)-A[0] B = [abs(S1-S2)] for i in range(N-2): S1 += A[i+1] S2 -= A[i+1] B.append(abs(S1-S2)) print(min(B))
s551946561
p03545
u953868469
2,000
262,144
Wrong Answer
18
3,064
771
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
n = list(map(int,input())) if n[0] + n[1] + n[2] + n[3] == 7: print("{}+{}+{}+{}".format(n[0],n[1],n[2],n[3])) elif n[0] + n[1] + n[2] - n[3] == 7: print("{}+{}+{}+{}".format(n[0],n[1],n[2],n[3])) elif n[0] + n[1] - n[2] + n[3] == 7: print("{}+{}+{}+{}".format(n[0],n[1],n[2],n[3])) elif n[0] + n[1] - n[2] - n[3] == 7: print("{}+{}+{}+{}".format(n[0],n[1],n[2],n[3])) elif n[0] - n[1] + n[2] + n[3] == 7: print("{}+{}+{}+{}".format(n[0],n[1],n[2],n[3])) elif n[0] - n[1] + n[2] - n[3] == 7: print("{}+{}+{}+{}".format(n[0],n[1],n[2],n[3])) elif n[0] - n[1] - n[2] + n[3] == 7: print("{}+{}+{}+{}".format(n[0],n[1],n[2],n[3])) elif n[0] - n[1] - n[2] - n[3] == 7: print("{}+{}+{}+{}".format(n[0],n[1],n[2],n[3])) else: print("error")
s964925332
Accepted
18
3,188
786
n = list(map(int,input())) if n[0] + n[1] + n[2] + n[3] == 7: print("{}+{}+{}+{}=7".format(n[0],n[1],n[2],n[3])) elif n[0] + n[1] + n[2] - n[3] == 7: print("{}+{}+{}-{}=7".format(n[0],n[1],n[2],n[3])) elif n[0] + n[1] - n[2] + n[3] == 7: print("{}+{}-{}+{}=7".format(n[0],n[1],n[2],n[3])) elif n[0] + n[1] - n[2] - n[3] == 7: print("{}+{}-{}-{}=7".format(n[0],n[1],n[2],n[3])) elif n[0] - n[1] + n[2] + n[3] == 7: print("{}-{}+{}+{}=7".format(n[0],n[1],n[2],n[3])) elif n[0] - n[1] + n[2] - n[3] == 7: print("{}-{}+{}-{}=7".format(n[0],n[1],n[2],n[3])) elif n[0] - n[1] - n[2] + n[3] == 7: print("{}-{}-{}+{}=7".format(n[0],n[1],n[2],n[3])) elif n[0] - n[1] - n[2] - n[3] == 7: print("{}-{}-{}-{}=7".format(n[0],n[1],n[2],n[3])) else: print("error")
s925372873
p02612
u617037231
2,000
1,048,576
Wrong Answer
30
9,132
33
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)
s794703458
Accepted
27
9,152
99
N = int(input()) if N%1000 == 0: print(0) else: while N>=1000: N-=1000 print(abs(N-1000))
s814839697
p02406
u589886885
1,000
131,072
Wrong Answer
20
7,480
126
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; }
n = int(input()) for i in range(3, n + 1): if i % 3 == 0: print(i) elif '3' in list(str(i)): print(i)
s962766238
Accepted
20
8,112
172
n = int(input()) result = [''] for i in range(3, n + 1): if i % 3 == 0: result.append(i) elif '3' in list(str(i)): result.append(i) print(*result)
s748050805
p03494
u871867619
2,000
262,144
Wrong Answer
18
2,940
300
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.
arr = [int(i) for i in input().split()] count = 0 while(True): for i, j in enumerate(arr): if j % 2 == 0: arr[i] = j / 2 if i == 2: count += 1 else: break else: continue break print(count)
s020446284
Accepted
160
12,420
347
import numpy as np N = int(input()) arr = np.array([int(i) for i in input().split()]) count = 0 while(True): exits_odd = False for i in range(N): if arr[i] % 2 != 0: exits_odd = True else: continue if exits_odd: break else: count += 1 arr = arr / 2 print(count)
s248992789
p03814
u663101675
2,000
262,144
Wrong Answer
46
3,560
187
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
A = input() N = len(A) print(A) for i in range(N): if A[i] == 'A': S = i break for i in range(N): if A[N-i-1] == 'Z': E = i break print(N - S - E)
s677463445
Accepted
45
3,516
188
A = input() N = len(A) #print(A) for i in range(N): if A[i] == 'A': S = i break for i in range(N): if A[N-i-1] == 'Z': E = i break print(N - S - E)
s451730786
p03494
u009219947
2,000
262,144
Wrong Answer
2,104
3,064
236
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.
_ = input() num_list = input().split(" ") num_list = list(map(lambda x:int(x), num_list)) min_num = min(num_list) shift_counter = 0 while(True): if min_num == 1: break min_num /= 2 shift_counter += 1 print(shift_counter)
s600349580
Accepted
18
3,064
352
_ = input() num_list = input().split(" ") num_list = list(map(lambda x:int(x), num_list)) shift_counter = 0 def checker(num_list): for n in num_list: if n % 2 != 0: return True return False while(True): if checker(num_list): print(shift_counter) break else: num_list = [int(n/2) for n in num_list] shift_counter += 1
s169595696
p03567
u476044037
2,000
262,144
Wrong Answer
17
2,940
22
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.
print("AC" in input())
s395716624
Accepted
19
2,940
83
answer = "AC" in input() if answer == False: print("No") else: print("Yes")
s171927806
p02806
u000840710
2,525
1,048,576
Wrong Answer
18
3,064
224
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct. Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X. Find the duration of time when some song was played while Niwango was asleep.
N = int(input().rstrip()) src = [list(input().split()) for _ in range(N)] for row in src: row[1] = int(row[1]) X = input() ans = 0 for row in src: if row[0] == X: break else: ans += row[1] print(ans)
s707147116
Accepted
18
3,064
315
N = int(input().rstrip()) src = [list(input().split()) for _ in range(N)] for row in src: row[1] = int(row[1]) X = input() total = 0 for row in src: total += row[1] awake = 0 for row in src: if row[0] != X: awake += row[1] else: awake += row[1] break ans = total - awake print(ans)
s028630182
p02694
u321881571
2,000
1,048,576
Wrong Answer
2,205
9,076
129
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()) i=1 Y=100 while True: Z=Y+0.01 if Z>=X: print(i) break else: i=i+1 Y=Z
s553853438
Accepted
21
9,172
130
X=int(input()) i=0 Y=100 while True: Z=int(Y*1.01) i=i+1 if Z>=X: print(i) break else: Y=Z
s875074237
p02612
u364363327
2,000
1,048,576
Wrong Answer
124
27,136
52
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.
import numpy as np N = int(input()) print(N%1000)
s379521382
Accepted
115
27,124
124
import numpy as np N = int(input()) for i in range(10000): if ( N <= 1000*i ): print(1000*i - N) break
s864604382
p03385
u662449766
2,000
262,144
Wrong Answer
17
2,940
203
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
import sys input = sys.stdin.readline def main(): s = input() if "a" in s and "b" in s and "c" in s: print("YES") else: print("NO") if __name__ == "__main__": main()
s040299259
Accepted
17
2,940
203
import sys input = sys.stdin.readline def main(): s = input() if "a" in s and "b" in s and "c" in s: print("Yes") else: print("No") if __name__ == "__main__": main()
s015579499
p03836
u462703607
2,000
262,144
Wrong Answer
17
3,060
164
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()) x=tx-sx y=ty-sy path="" path+="U"*x+"R"*y+"D"*x+"L"*y path+="L"+"R"*(x+1)+"U"*(y+1)+"L"+"U"+"L"*(x+1)+"D"*(y+1)+"R" print(path)
s620613556
Accepted
18
3,060
164
sx,sy,tx,ty=map(int,input().split()) y=tx-sx x=ty-sy path="" path+="U"*x+"R"*y+"D"*x+"L"*y path+="L"+"U"*(x+1)+"R"*(y+1)+"D"+"R"+"D"*(x+1)+"L"*(y+1)+"U" print(path)
s116068109
p03547
u379692329
2,000
262,144
Wrong Answer
17
2,940
38
In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`, `D`, `E` or `F`. When X and Y are seen as hexadecimal numbers, which is larger?
X, Y = input().split() print(max(X,Y))
s146053614
Accepted
19
3,060
89
X, Y = input().split() if X > Y: print(">") elif X < Y: print("<") else: print("=")
s719119572
p03699
u185034753
2,000
262,144
Wrong Answer
19
3,060
311
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
def solve(): N = int(input()) a = sorted([int(input()) for _ in range(N)]) s = sum(a) if s % 10 != 0: return s for x in a: if (s-x)%10 != 0: print(x) return s - x return 0 def main(): print(solve()) if __name__ == '__main__': main()
s458640191
Accepted
17
3,064
290
def solve(): N = int(input()) a = sorted([int(input()) for _ in range(N)]) s = sum(a) if s % 10 != 0: return s for x in a: if (s-x)%10 != 0: return s - x return 0 def main(): print(solve()) if __name__ == '__main__': main()
s823970929
p03623
u561828236
2,000
262,144
Wrong Answer
18
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|.
x,a,b = map(int,input().split()) if abs(x-a) >= abs(x-b): print(abs(x-b)) else: print(abs(x-a))
s990932462
Accepted
18
2,940
94
x,a,b = map(int,input().split()) if abs(x-a) >= abs(x-b): print("B") else: print("A")
s979101755
p02263
u404682284
1,000
131,072
Wrong Answer
20
5,592
341
An expression is given in a line. Two consequtive symbols (operand or operator) are separated by a space character. You can assume that +, - and * are given as the operator and an operand is a positive integer less than 106
input_line = input().split() stack = [] for i in input_line: if i == '+': stack.append(stack.pop() + stack.pop()) elif i == '-': a = stack.pop() b = stack.pop() stack.append(b - a) elif i =='*': stack.append(stack.pop() * stack.pop()) else: stack.append(int(i)) print(stack)
s388582645
Accepted
20
5,600
344
input_line = input().split() stack = [] for i in input_line: if i == '+': stack.append(stack.pop() + stack.pop()) elif i == '-': a = stack.pop() b = stack.pop() stack.append(b - a) elif i =='*': stack.append(stack.pop() * stack.pop()) else: stack.append(int(i)) print(stack[0])
s001119532
p04029
u149752754
2,000
262,144
Wrong Answer
17
2,940
233
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?
c = list(input()) ans = [] for i in range(len(c)): if c[i] == '0': ans.append('0') elif c[i] == '1': ans.append('1') elif len(ans) != 0: del ans[-1] else: continue print (''.join(ans))
s658610180
Accepted
18
2,940
37
N = int(input()) print((N*(N+1))//2)
s941881176
p03623
u287431190
2,000
262,144
Wrong Answer
17
2,940
90
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()) if abs(x-a) > abs(x-b): print('A') else: print('B')
s603692768
Accepted
17
2,940
90
x,a,b = map(int, input().split()) if abs(x-a) < abs(x-b): print('A') else: print('B')
s828216874
p03079
u503228842
2,000
1,048,576
Wrong Answer
17
2,940
95
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()) if a==b: if b==c: print("yes") else: print("No")
s400452417
Accepted
17
2,940
91
a,b,c = map(int,input().split()) if (a==b) and b==c: print("Yes") else: print("No")
s059331451
p03815
u641406334
2,000
262,144
Wrong Answer
17
2,940
32
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.
n = int(input()) print(n//5.5+1)
s078497324
Accepted
17
2,940
81
n = int(input()) a = n//11 print(2*a if n%11==0 else 2*a+1 if n%11<=6 else 2*a+2)
s338369648
p03673
u776237437
2,000
262,144
Wrong Answer
2,104
26,180
117
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
N = int(input()) A = list(map(int, input().split())) L = [] for a in A: L.append(a) L.reverse() print(L)
s977197782
Accepted
219
25,416
364
from collections import deque N = int(input()) A = list(map(int, input().split())) B = deque() if N % 2 == 0: for i in range(N): if i % 2 == 0: B.append(A[i]) else: B.appendleft(A[i]) else: for i in range(N): if i % 2 == 0: B.appendleft(A[i]) else: B.append(A[i]) print(*B)
s290731156
p02842
u994502918
2,000
1,048,576
Wrong Answer
18
2,940
142
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
import math n = int(input()) x = math.ceil(n / 1.08) result = math.floor(x * 1.08) if (result == n): print(result) else: print(":(")
s469316875
Accepted
18
2,940
137
import math n = int(input()) x = math.ceil(n / 1.08) result = math.floor(x * 1.08) if (result == n): print(x) else: print(":(")
s372996343
p02612
u576320075
2,000
1,048,576
Wrong Answer
30
9,084
59
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()) while n >= 1000: n -= 1000 print(n)
s295317788
Accepted
31
9,116
118
n = int(input()) # while n >= 1000: # n -= 1000 # n = max(n, 0) print((1000 - n % 1000) % 1000) # print(n)
s272233525
p00251
u766477342
1,000
131,072
Wrong Answer
30
6,724
61
選手の皆さん、パソコン甲子園にようこそ。パソコン甲子園は今年で10周年になりますが、出題される問題数や合計得点は年によって異なります。各問題には難易度に応じて得点が決められています。問題数が10問で、それぞれの問題の得点が与えられるとき、それらの合計を出力するプログラムを作成して下さい。
sum = 0 for i in range(10):sum = int(input()); print(sum)
s980515083
Accepted
30
6,724
56
s = 0 for i in range(10):s += int(input()); print(s)
s493964843
p03636
u492447501
2,000
262,144
Wrong Answer
17
2,940
45
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
S = input() print(S[0]+S[1:-1]+S[len(S)-1])
s902118848
Accepted
17
2,940
55
S = input() print(S[0]+str(len(S[1:-1]))+S[len(S)-1])
s975316846
p03730
u588081069
2,000
262,144
Wrong Answer
17
2,940
127
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
A, B, C = list(map(int, input().split())) if A == 1: print("YES") elif A % B == C: print("YES") else: print("NO")
s761892691
Accepted
17
2,940
137
A, B, C = list(map(int, input().split())) for i in range(100): if (A * i) % B == C: print("YES") exit() print("NO")
s706438608
p03945
u699699071
2,000
262,144
Wrong Answer
52
3,316
130
Two foxes Jiro and Saburo are playing a game called _1D Reversi_. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones between the new white stone and another white stone, turn into white stones, and vice versa. In the middle of a game, something came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is `B`, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is `W`, it means that the color of the corresponding stone is white. Jiro wants all stones on the board to be of the same color. For this purpose, he will place new stones on the board according to the rules. Find the minimum number of new stones that he needs to place.
S=input() print(S) result=0 for i in range(len(S)-1): state=S[i] if S[i]!=S[i+1]: result+=1 else: pass print(result)
s621995349
Accepted
50
3,188
121
S=input() result=0 for i in range(len(S)-1): state=S[i] if S[i]!=S[i+1]: result+=1 else: pass print(result)
s664046628
p03997
u028014940
2,000
262,144
Wrong Answer
17
2,940
63
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)
s934203221
Accepted
17
2,940
68
a=int(input()) b=int(input()) h=int(input()) print(int((a+b)*h/2))
s216062776
p03495
u050708958
2,000
262,144
Wrong Answer
115
35,996
147
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
from collections import Counter n, k = map(int, input().split()) c = sum(map(lambda x: x[1], Counter(input().split()).most_common(k))) print(k - c)
s280777155
Accepted
131
35,996
147
from collections import Counter n, k = map(int, input().split()) c = sum(map(lambda x: x[1], Counter(input().split()).most_common(k))) print(n - c)
s977693308
p02417
u340503368
1,000
131,072
Wrong Answer
20
5,560
350
Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.
sentence = input() count = [0 for i in range(26)] alpha = "abcdefghijklmnopqrstuvwxyz" for letter in sentence: letter.lower() num = 0 for j in alpha: if letter == j: count[num] += 1 break else: num += 1 num = 0 for k in alpha: print(k + " : " + str(count[num])) num += 1
s489374011
Accepted
20
5,568
233
import sys s = sys.stdin.read().lower() count = [0 for i in range(26)] for j in s: num = ord(j) - ord('a') if num >= 0 and num <= 25: count[num] += 1 for k in range(26): print(chr(k + 97) + " : " + str(count[k]))
s639176991
p02408
u737311644
1,000
131,072
Wrong Answer
20
5,576
64
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.
n=int(input()) a=input().split() a.reverse() print(" ".join(a))
s603887861
Accepted
20
5,608
471
n=int(input()) spade=set(range(1,14,1)) heart=set(range(1,14,1)) club=set(range(1,14,1)) diamond=set(range(1,14,1)) for a in range(n): e,b=input().split() if e=="S": spade.remove(int(b)) if e=="H": heart.remove(int(b)) if e=="C": club.remove(int(b)) if e=="D": diamond.remove(int(b)) for i in spade: print("S",i) for i in heart: print("H",i) for i in club: print("C", i) for i in diamond: print("D",i)
s567393879
p03455
u652109955
2,000
262,144
Wrong Answer
28
9,168
119
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
# coding: utf-8 # Your code here! a,b=(map(int,input().split())) if a*b/2==0: print("Even") else: print("Odd")
s793936768
Accepted
22
9,148
119
# coding: utf-8 # Your code here! a,b=(map(int,input().split())) if a*b%2==0: print("Even") else: print("Odd")
s780354652
p00032
u647694976
1,000
131,072
Time Limit Exceeded
10,000
5,588
218
機械に辺・対角線の長さのデータを入力し、プラスティック板の型抜きをしている工場があります。この工場では、サイズは様々ですが、平行四辺形の型のみを切り出しています。あなたは、切り出される平行四辺形のうち、長方形とひし形の製造個数を数えるように上司から命じられました。 「機械に入力するデータ」を読み込んで、長方形とひし形の製造個数を出力するプログラムを作成してください。
hisi=0 tyou=0 while True: try: a,b,c=map(int,input().split(",")) if a**2+b**2==c**2: tyou +=1 elif a==b: hisi +=1 except: print(tyou) print(hisi)
s623724001
Accepted
20
5,592
233
hisi=0 tyou=0 while True: try: a,b,c=map(int,input().split(",")) if a**2+b**2==c**2: tyou +=1 elif a==b: hisi +=1 except: print(tyou) print(hisi) break
s616146740
p02414
u628732336
1,000
131,072
Wrong Answer
30
7,628
208
Write a program which reads a $n \times m$ matrix $A$ and a $m \times l$ matrix $B$, and prints their product, a $n \times l$ matrix $C$. An element of matrix $C$ is obtained by the following formula: \\[ c_{ij} = \sum_{k=1}^m a_{ik}b_{kj} \\] where $a_{ij}$, $b_{ij}$ and $c_{ij}$ are elements of $A$, $B$ and $C$ respectively.
n, m, l = [int(i) for i in input().split()] A = [] B = [] C = [] for ni in range(n): A.append([int(i) for i in input().split()]) for mi in range(m): B.append([int(i) for i in input().split()])
s994596180
Accepted
490
8,980
420
n, m, l = [int(i) for i in input().split()] A = [] B = [] C = [] for ni in range(n): A.append([int(i) for i in input().split()]) for mi in range(m): B.append([int(i) for i in input().split()]) for i in range(n): C.append([]) for j in range(l): C[i].append(0) for k in range(m): C[i][j] += A[i][k] * B[k][j] for ni in range(n): print(" ".join([str(s) for s in C[ni]]))
s388021952
p03470
u729133443
2,000
262,144
Wrong Answer
17
2,940
42
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?
print(len(set(open(0).readlines()[1:]))-1)
s113273036
Accepted
17
2,940
31
_,*s=open(0);print(len(set(s)))
s782858704
p03814
u782330257
2,000
262,144
Wrong Answer
18
3,516
75
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
s=input() rev=s[::-1] n=len(s) print((n-rev.find('Z')) - (s.find('A') + 1))
s315236067
Accepted
18
3,512
89
s=input().strip() rev=s[::-1] n=len(s) #print(n) print((n-rev.find('Z')) - (s.find('A')))
s339767885
p02743
u395202850
2,000
1,048,576
Wrong Answer
18
2,940
83
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
a, b, c = map(int, input().split()) print("YNeos"[(a * b) >= (c - a - b) ** 2::2])
s131838252
Accepted
17
2,940
112
a, b, c = map(int, input().split()) print("Yes" if 4 * (a * b) < (c - a - b) ** 2 and c - a - b > 0 else "No")
s081143891
p02665
u761529120
2,000
1,048,576
Wrong Answer
921
674,256
883
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.
def main(): N = int(input()) A = list(map(int, input().split())) B = [0] * (N + 1) if A[0] >= 2: print(-1) exit() if A[0] == 1: if len(A) == 1: print(1) exit() else: print(-1) exit() B[0] = 1 ans = 1 for i in range(1,N+1): tmp = 2 * B[i-1] if tmp < A[i]: print(-1) exit() elif tmp == A[i]: if i != N: print(-1) exit() B[i] = tmp - A[i] ans += A[N] C = [0] * (N+1) C[N] += A[N] for i in range(N-1,0,-1): if C[i+1] <= B[i] + A[i]: ans += A[i] + C[i+1] C[i] = A[i] + C[i+1] else: ans += B[i] + A[i] C[i] = B[i] print(ans) if __name__ == "__main__": main()
s740155500
Accepted
770
679,908
892
def main(): N = int(input()) A = list(map(int, input().split())) B = [0] * (N + 1) if A[0] >= 2: print(-1) exit() if A[0] == 1: if len(A) == 1: print(1) exit() else: print(-1) exit() B[0] = 1 ans = 1 for i in range(1,N+1): tmp = 2 * (B[i-1] - A[i-1]) if tmp < A[i]: print(-1) exit() elif tmp == A[i]: if i != N: print(-1) exit() B[i] = tmp ans += A[N] C = [0] * (N+1) C[N] += A[N] for i in range(N-1,0,-1): if C[i+1] + A[i] <= B[i]: ans += A[i] + C[i+1] C[i] = A[i] + C[i+1] else: ans += B[i] C[i] = B[i] print(ans) if __name__ == "__main__": main()
s551082571
p00010
u659302741
1,000
131,072
Wrong Answer
20
7,640
707
Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface.
def simultaneous_equasion(a, b, c, d, e, f): "??£???????¨????" det = a * d - b * c a11 = d / det a12 = - b / det a21 = - c / det a22 = a / det return a11 * e + a12 * f, a21 * e + a22 * f n = int(input()) for i in range(n): x1, y1, x2, y2, x3, y3 = map(float, input().split()) a = 2 * (x2 - x1) b = 2 * (y2 - y1) c = 2 * (x3 - x1) d = 2 * (y3 - y1) e = (y2 - y1) ** 2 + (x2 - x1) ** 2 f = (y3 - y1) ** 2 + (x3 - x1) ** 2 px, py = simultaneous_equasion(a, b, c, d, e, f) print("%.3f %3f" % (round(px, 3), round(py, 3)))
s466402039
Accepted
30
7,776
970
import math def simultaneous_equasion(a, b, c, d, e, f): "??£???????¨????" det = a * d - b * c a11 = d / det a12 = - b / det a21 = - c / det a22 = a / det return a11 * e + a12 * f, a21 * e + a22 * f n = int(input()) for i in range(n): x1, y1, x2, y2, x3, y3 = map(float, input().split()) # (x - x1) ^ 2 + (y - y1) ^ 2 = (x - x2) ^ 2 + (y - y2) ^ 2 a = 2 * (x1 - x2) b = 2 * (y1 - y2) c = 2 * (x1 - x3) d = 2 * (y1 - y3) e = x1 ** 2 + y1 ** 2 - x2 ** 2 - y2 ** 2 f = x1 ** 2 + y1 ** 2 - x3 ** 2 - y3 ** 2 px, py = simultaneous_equasion(a, b, c, d, e, f) r = math.sqrt((px - x1) ** 2 + (py - y1) ** 2) print("%.3f %.3f %.3f" % (round(px, 3), round(py, 3), round(r, 3)))
s010372607
p03478
u578501242
2,000
262,144
Wrong Answer
26
3,060
195
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).
a =list(map(int,input().split())) x=a[0] y=a[1] z=a[2] t=0 for i in range(1,x): if i//1000+((i//100)%10)+((i//10)%10)+(i%10)>=y and i//1000+((i//100)%10)+((i//10)%10)+(i%10)<=z: t=t+i print(t)
s933155068
Accepted
26
3,064
229
a =list(map(int,input().split())) x=a[0] y=a[1] z=a[2] t=0 for i in range(1,x+1): if i//10000+((i//1000)%10)+((i//100)%10)+((i//10)%10)+(i%10)>=y and i//10000+((i//1000)%10)+((i//100)%10)+((i//10)%10)+(i%10)<=z: t=t+i print(t)
s044255484
p02613
u691576679
2,000
1,048,576
Wrong Answer
137
16,268
165
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.
a=int(input()) s=[input() for i in range(a)] print("AC ×",s.count("AC")) print("WA ×",s.count("WA")) print("TLE ×",s.count("TLE")) print("RE ×",s.count("RE"))
s812164493
Accepted
141
16,160
213
a=int(input()) s=[input() for i in range(a)] print("AC x {:d}".format(s.count("AC"))) print("WA x {:d}".format(s.count("WA"))) print("TLE x {:d}".format(s.count("TLE"))) print("RE x {:d}".format(s.count("RE")))
s015063033
p03448
u587213169
2,000
262,144
Wrong Answer
50
3,060
235
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()) count=0 for i in range(a+1): for i in range(b+1): for i in range(c+1): if x == 500*a + 100*b + 50*c: count+=1 print(count)
s063934338
Accepted
50
3,064
237
a=int(input()) b=int(input()) c=int(input()) x=int(input()) count=0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if x == (i*500 + j*100 + k*50): count+=1 print(count)
s000611537
p03997
u620238824
2,000
262,144
Wrong Answer
18
2,940
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)
s757453831
Accepted
16
2,940
73
a = int(input()) b = int(input()) h = int(input()) print(int((a+b)*h/2))
s769321803
p02613
u466916194
2,000
1,048,576
Wrong Answer
162
16,152
340
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.
numberotestcase = int(input()) verdicat=[] for step in range(numberotestcase): exp = input().upper() verdicat.append(exp) first = verdicat.count('AC') sec = verdicat.count('WA') thir = verdicat.count('TLE') fou = verdicat.count('RE') print('AC * '+str(first)) print('WA * '+str(sec)) print('TLE * '+str(thir)) print('RE * '+str(fou))
s842650365
Accepted
156
16,276
341
numberotestcase = int(input()) verdicat=[] for step in range(numberotestcase): exp = input().upper() verdicat.append(exp) first = verdicat.count('AC') sec = verdicat.count('WA') thir = verdicat.count('TLE') fou = verdicat.count('RE') print('AC x '+str(first)) print('WA x '+str(sec)) print('TLE x '+str(thir)) print('RE x '+str(fou))
s332000296
p03673
u519923151
2,000
262,144
Wrong Answer
130
26,184
353
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
n = int(input()) al = list(map(int, input().split())) res = [0]*n m = n //2 if n % 2 ==0: for i in range(m): res[i] = al[-1-i*2] for j in range(m): res[m+j]= al[j*2] print(res) else: for i in range(m+1): res[i] = al[-1-i*2] for j in range(m): res[m+1+j] = al[1+j*2] print(res)
s848459003
Accepted
231
26,180
405
n = int(input()) al = list(map(int, input().split())) res = [0]*n m = n //2 if n % 2 ==0: for i in range(m): res[i] = al[-1-i*2] for j in range(m): res[m+j]= al[j*2] else: for i in range(m+1): res[i] = al[-1-i*2] for j in range(m): res[m+1+j] = al[1+j*2] ress="" for k in range(n): ress +=str(res[k]) ress +=" " print(ress[:-1])
s467707077
p03369
u855985627
2,000
262,144
Wrong Answer
17
2,940
31
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.
print(100*input().count('○'))
s086526467
Accepted
17
2,940
33
print(700+100*input().count('o'))
s229289554
p03416
u627147604
2,000
262,144
Wrong Answer
70
2,940
188
Find the number of _palindromic numbers_ among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.
def is_palindromic(n): if str(n) == str(n)[::-1]: True else: False A,B = map(int, input().split()) for i in range(A, B): if is_palindromic(i): print(i)
s857863525
Accepted
69
2,940
223
def is_palindromic(n): if str(n) == str(n)[::-1]: return True else: return False res = 0 A,B = map(int, input().split()) for i in range(A, B+1): if is_palindromic(i): res += 1 print(res)
s634841195
p03827
u517309493
2,000
262,144
Wrong Answer
28
8,752
308
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).
import os import sys import math if os.environ.get("DEBUG") is not None: sys.stdin = open("in.txt", "r") rl = sys.stdin.readline n, s = [rl().rstrip("\n") for _ in range(2)] print(n, s) x = 0 ans = 0 for it in s: if it == "I": x += 1 else: x -= 1 ans = max(ans, x) print(ans)
s675944553
Accepted
26
9,060
296
import os import sys import math if os.environ.get("DEBUG") is not None: sys.stdin = open("in.txt", "r") rl = sys.stdin.readline n, s = [rl().rstrip("\n") for _ in range(2)] x = 0 ans = 0 for it in s: if it == "I": x += 1 else: x -= 1 ans = max(ans, x) print(ans)
s870444628
p03795
u174536291
2,000
262,144
Wrong Answer
31
9,132
84
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()) a = n % 15 my_result = n * 800 - (n - a) / 15 print(int(my_result))
s769905368
Accepted
23
9,088
90
n = int(input()) a = n % 15 my_result = n * 800 - (n - a) * 200 / 15 print(int(my_result))
s444117206
p03069
u130900604
2,000
1,048,576
Wrong Answer
2,104
3,620
169
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 for i in range(n): a=s.count(".#") if a==0: break cnt+=a s=s.replace(".#","..") print(s,cnt)
s897060519
Accepted
81
11,260
170
n=int(input()) s=input() w_cnt=s.count(".") ans=[w_cnt] b=0 w=w_cnt for i in s: if i=="#": b+=1 else: w-=1 ans.append(b+w) print(min(ans))
s596749782
p03409
u882359130
2,000
262,144
Wrong Answer
19
3,064
466
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, Blue = [], [] for n in range(N): Red.append([int(ab) for ab in input().split()]) Red.sort(key=lambda x: x[1], reverse=True) for n in range(N): Blue.append([int(cd) for cd in input().split()]) Blue.sort(key=lambda x: x[0]) pairs = 0 for B in Blue: c, d = B for R in Red: a, b = R inclination = (d-b) / abs(c-a) if inclination > 0: pairs += 1 print([R, B]) Red.remove(R) break print(pairs)
s336905705
Accepted
19
3,064
411
N = int(input()) Red, Blue = [], [] for n in range(N): Red.append([int(ab) for ab in input().split()]) Red.sort(key=lambda x: x[1], reverse=True) for n in range(N): Blue.append([int(cd) for cd in input().split()]) Blue.sort(key=lambda x: x[0]) pairs = 0 for B in Blue: c, d = B for R in Red: a, b = R if a < c and b < d: pairs += 1 Red.remove(R) break print(pairs)
s844510708
p03155
u752898745
2,000
1,048,576
Wrong Answer
17
2,940
61
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board. The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns. How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?
n,h,w=[int(input()) for _ in range(3)];print((n-1+h)*(n-1+w))
s882342635
Accepted
17
2,940
61
n,h,w=[int(input()) for _ in range(3)];print((n+1-h)*(n+1-w))
s207917933
p03494
u320098990
2,000
262,144
Wrong Answer
28
9,176
330
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()) in_list = input().split(' ') judge_list = max([int(s)%2 for s in in_list]) if judge_list==1: print(0) else: min_num = min([int(s) for s in in_list]) amari = min_num%2 counter = 0 while amari == 0 : min_num = min_num/2 amari = min_num%2 counter += 1 print(counter)
s812781556
Accepted
27
9,188
288
N = int(input()) in_list = input().split(' ') target_list = [int(s) for s in in_list] max_num = max([s%2 for s in target_list]) counter = 0 while max_num==0: target_list = [int(s)/2 for s in target_list] max_num = max([s%2 for s in target_list]) counter += 1 print(counter)
s233403887
p03659
u038408819
2,000
262,144
Wrong Answer
404
30,604
361
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())) s_right = [0] * (N + 1) s_left = [0] * (N + 1) for i in range(N): s_left[i + 1] = s_left[i] + a[i] s_right[i + 1] = s_right[i] + a[N - 1 - i] ans = float('Inf') for i in range(1, N): print(ans) if ans > abs(s_left[i] - s_right[N - i]): ans = abs(s_left[i] - s_right[N - i]) print(ans)
s183137696
Accepted
191
24,832
293
N = int(input()) a = list(map(int, input().split())) s = [0] * (N + 1) for i in range(N): s[i + 1] = s[i] + a[i] ans = float('Inf') for i in range(1, N): #print(ans) kouho = abs(s[i] - ((s[-1]) - s[i])) if ans > kouho: ans = kouho #ans = min(ans, kouho) print(ans)
s728358186
p03380
u320567105
2,000
262,144
Wrong Answer
670
19,884
314
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
n = int(input()) a = list(map(int,input().split())) a.sort() a_i = a[-1] a_i_2 = a_i / 2.0 b = a[0] for i in a: if i < a_i_2: b = i else: c = i break from scipy.misc import comb if comb(a_i, b) > comb(a_i,c): print("{} {}".format(a_i, b)) else: print("{} {}".format(a_i, c))
s788052902
Accepted
80
14,648
465
ri = lambda: int(input()) rl = lambda: list(map(int,input().split())) rr = lambda N: [ri() for _ in range(N)] YN = lambda b: print('YES') if b else print('NO') yn = lambda b: print('Yes') if b else print('No') OE = lambda x: print('Odd') if x%2 else print('Even') INF = 10**18 n=ri() a=rl() a.sort() import bisect p = a[-1] p2 = p/2 q_i = bisect.bisect_left(a,p2) if ((a[q_i]-p2) > (p2 - a[q_i-1]) or p==a[q_i]) and q_i != 0: q_i -= 1 q = a[q_i] print(p,q)
s790299717
p02927
u382176416
2,000
1,048,576
Wrong Answer
28
3,064
288
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?
m,d=map(int, input().split()) count=0 if d <= 10: print(0) else: for i in range(1,m+1): for j in range(11,d+1): dl = list(str(j)) if int(dl[0]) >=2 and int(dl[1]) >= 2 and int(dl[0])*int(dl[1]) == i: print(str(i)+ ' ' + str(j)) count+=1 print(count)
s420735400
Accepted
29
3,064
252
m,d=map(int, input().split()) count=0 if d <= 10: print(0) else: for i in range(1,m+1): for j in range(11,d+1): dl = list(str(j)) if int(dl[0]) >=2 and int(dl[1]) >= 2 and int(dl[0])*int(dl[1]) == i: count+=1 print(count)
s629082072
p03845
u167647458
2,000
262,144
Wrong Answer
18
3,060
220
Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.
n = int(input()) t = list(map(int, input().split())) m = int(input()) px = [list(map(int, input().split())) for _ in range(m)] sum_t = sum(t) for i in range(m): print(min(sum_t, sum_t - t[px[i][0] - 1] + px[i][1]))
s912717749
Accepted
18
3,060
208
n = int(input()) t = list(map(int, input().split())) m = int(input()) px = [list(map(int, input().split())) for _ in range(m)] sum_t = sum(t) for i in range(m): print(sum_t - t[px[i][0] - 1] + px[i][1])
s915653401
p00423
u900033552
1,000
131,072
Wrong Answer
20
7,672
187
A と B の 2 人のプレーヤーが, 0 から 9 までの数字が書かれたカードを使ってゲームを行う.最初に, 2 人は与えられた n 枚ずつのカードを,裏向きにして横一列に並べる.その後, 2 人は各自の左から 1 枚ずつカードを表向きにしていき,書かれた数字が大きい方のカードの持ち主が,その 2 枚のカードを取る.このとき,その 2 枚のカードに書かれた数字の合計が,カードを取ったプレーヤーの得点となるものとする.ただし,開いた 2 枚のカードに同じ数字が書かれているときには,引き分けとし,各プレーヤーが自分のカードを 1 枚ずつ取るものとする. 例えば, A,B の持ち札が,以下の入力例 1 から 3 のように並べられている場合を考えよう.ただし,入力ファイルは n + 1 行からなり, 1 行目には各プレーヤのカード枚数 n が書かれており, i + 1 行目(i = 1,2,... ,n)には A の左から i 枚目のカードの数字と B の左から i 枚目の カードの数字が,空白を区切り文字としてこの順で書かれている.すなわち,入力ファイルの 2 行目以降は,左側の列が A のカードの並びを,右側の列が B のカードの並びを,それぞれ表している.このとき,ゲーム終了後の A と B の得点は,それぞれ,対応する出力例に示したものとなる. 入力ファイルに対応するゲームが終了したときの A の得点と B の得点を,この順に空白を区切り文字として 1 行に出力するプログラムを作成しなさい.ただし, n ≤ 10000 とする. 入力例1 | 入力例2 | 入力例3 ---|---|--- 3| 3| 3 9 1| 9 1| 9 1 5 4| 5 4| 5 5 0 8| 1 0| 1 8 出力例1 | 出力例2 | 出力例3 19 8| 20 0| 15 14
#coding: utf-8 n = int(input()) s = [list(map(int, input().split(' '))) for i in range(n)] win = {True: 0, False: 0} for a, b in s: win[a>b] += (a + b) print(win[True], win[False])
s862680058
Accepted
110
9,436
483
#coding: utf-8 def one_game(): n = int(input()) if n == 0: return False s = [list(map(int, input().split(' '))) for i in range(n)] win = {True: 0, False: 0} for a, b in s: if a == b: win[True] += a win[False] += a continue win[a>b] += (a + b) print(win[True], win[False]) return True while one_game() is True: a = 0
s025601691
p03387
u488127128
2,000
262,144
Wrong Answer
17
3,064
810
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.
def solve(): a,b,c = map(int, input().split()) count = 0 l = (a%2, b%2, c%2) print(l) if l == (0,0,0) or l == (1,1,1): count += abs(a-b) // 2 count += abs(max(a,b) - c) // 2 elif l == (1,0,0) or l == (0,1,1): count += abs(b-c) // 2 if max(b,c) <= a: count += a - max(b,c) else: count += max(b,c) - a elif l == (0,1,0) or l == (1,0,1): count += abs(a-c) // 2 if max(a,c) <= b: count += b - max(a,c) else: count += max(a,c) - b elif l == (0,0,1) or l == (1,1,0): count += abs(a-b) // 2 if max(a,b) <= c: count += c - max(a,b) else: count += max(a,b) - c return count if __name__ == '__main__': print(solve())
s704043263
Accepted
17
3,064
768
def solve(): T = list(map(int, input().split())) l = [t%2 for t in T] count = 0 if sum(l) == 1: odd = T.pop(l.index(1)) count += abs(T[0] - T[1]) // 2 if max(T[0],T[1]) <= odd: count += odd - max(T[0],T[1]) else: count += (max(T[0],T[1]) - odd)//2 + 2 elif sum(l) == 2: even = T.pop(l.index(0)) count += abs(T[0] - T[1]) // 2 if max(T[0],T[1]) <= even: count += even - max(T[0],T[1]) else: count += (max(T[0],T[1]) - even)//2 + 2 else: m = T.pop(T.index(max(T))) count += abs(T[0] - T[1]) // 2 count += abs(m - max(T[0],T[1])) return count if __name__ == '__main__': print(solve())
s625475188
p03680
u658993896
2,000
262,144
Wrong Answer
2,104
7,080
312
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()) buttun=[0] for i in range(N): buttun.append(int(input())) light=1 ans=0 while True: if buttun[light]==2: break elif light==buttun[light]: ans=-1 break else: light=buttun[light] ans+=1 if light==1: ans=-1 break print(ans)
s083943716
Accepted
221
7,080
344
N=int(input()) buttun=[0] for i in range(N): buttun.append(int(input())) light=1 ans=0 while True: if light==2: break elif light==buttun[light]: ans=-1 break else: tmp=light light=buttun[light] ans+=1 buttun[tmp]=1 if light==1: ans=-1 break print(ans)
s178187564
p03680
u750838232
2,000
262,144
Wrong Answer
189
7,084
167
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()) a= [int(input()) for _ in range(n)] count = 0 now = a[0] while now != 2 and count < n: now = a[now-1] count += 1 print(count if count<n else -1)
s826182810
Accepted
193
7,084
167
n = int(input()) a= [int(input()) for _ in range(n)] count = 1 now = a[0] while now != 2 and count < n: now = a[now-1] count += 1 print(count if count<n else -1)
s599859050
p03447
u106342872
2,000
262,144
Wrong Answer
18
2,940
68
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
x = int(input()) a = int(input()) b = int(input()) print((x-a) // b)
s333222619
Accepted
19
2,940
85
x = int(input()) a = int(input()) b = int(input()) k = (x-a) // b print(x-a-b*k)
s921182777
p03699
u371763408
2,000
262,144
Wrong Answer
18
2,940
100
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
n=int(input()) S=[int(input()) for i in range(n)] if sum(S)%10==0: print(0) else: print(sum(S))
s350439369
Accepted
18
3,060
178
n=int(input()) S=sorted([int(input()) for i in range(n)]) not_10=[i for i in S if i%10!=0] sums=sum(S) if sums%10!=0: print(sums) else: print(sums-not_10[0] if not_10 else 0)
s529317723
p03597
u972892985
2,000
262,144
Wrong Answer
17
2,940
49
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
n = int(input()) a = int(input()) print((n**n)-1)
s787218508
Accepted
17
2,940
49
n = int(input()) a = int(input()) print((n**2)-a)