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
s605068439
p03149
u744517446
2,000
1,048,576
Wrong Answer
17
3,060
245
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".
clist = list(map(int,input().split())) clist.sort() ans = "No" if min(clist) == 1 and max(clist) == 9 : clist.pop(0) clist.pop() if min(clist) == 4 and max(clist) == 7 : ans = "Yes" else: ans = "No" else: ans = "No" print(ans)
s665386036
Accepted
17
3,064
110
clist = list(map(int,input().split())) clist.sort() if clist == [1,4,7,9] : print("YES") else: print("NO")
s584616087
p03636
u699944218
2,000
262,144
Wrong Answer
17
2,940
33
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() a = len(s)-2 print(a)
s769184472
Accepted
17
2,940
61
s = input() a = len(s)-2 print(s[0] + str(a) + s[len(s) - 1])
s631275499
p00219
u546285759
1,000
131,072
Wrong Answer
150
9,580
233
テンアイスクリームという名前のアイスクリーム屋さんがあります。このお店では常に 10 種類のアイスクリームが店頭に並ぶようにしています。お店の店長は商品開発の参考にするために、アイスクリームの売れ具合を表すグラフを毎日作成しています。 そんな店長のために、あなたは各アイスクリームの販売数をグラフで表示するプログラムを作成することになりました。 一日に販売されるアイスクリームの総数と売れたアイスクリームの番号を入力とし、アイスクリームの種類ごとに販売した数だけ * (半角アスタリスク) を出力するプログラムを作成してください。ただし、アイスクリームの種類を 0 から 9 までの整数で表わします。また、販売個数がゼロのアイスクリームは、- (半角ハイフン) をひとつ出力します。
while True: n = int(input()) if n == 0: break d = {k: 0 for k in range(n)} for _ in range(n): x = int(input()) d[x] += 1 for k in range(n): print("*"*d[k] + "-"*(d[k]==0))
s845608423
Accepted
110
7,712
197
while True: n = int(input()) if n == 0: break ice = [int(input()) for _ in range(n)] for i in range(10): nums = ice.count(i) print("*"*nums + "-"*(nums==0))
s986812704
p02678
u811436126
2,000
1,048,576
Wrong Answer
935
65,944
651
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.
from collections import deque n, m = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(m)] graph = [[] for _ in range(n + 1)] for i in range(m): a = ab[i][0] b = ab[i][1] graph[a].append(b) graph[b].append(a) inf = 100100100 ans = [[inf, inf] for _ in range(n + 1)] ans[0] = [0, 0] ans[1] = [0, 0] q = deque([1]) while q: now = q.popleft() depth = ans[now][1] for x in graph[now]: if ans[x][0] == inf: q.append(x) if ans[x][1] > depth + 1: ans[x][0] = now ans[x][1] = depth + 1 for i in range(2, n + 1): print(ans[i][0])
s258709824
Accepted
838
65,776
664
from collections import deque n, m = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(m)] graph = [[] for _ in range(n + 1)] for i in range(m): a = ab[i][0] b = ab[i][1] graph[a].append(b) graph[b].append(a) inf = 100100100 ans = [[inf, inf] for _ in range(n + 1)] ans[0] = [0, 0] ans[1] = [0, 0] q = deque([1]) while q: now = q.popleft() depth = ans[now][1] for x in graph[now]: if ans[x][0] == inf: q.append(x) if ans[x][1] > depth + 1: ans[x][0] = now ans[x][1] = depth + 1 print('Yes') for i in range(2, n + 1): print(ans[i][0])
s132710025
p03565
u565149926
2,000
262,144
Wrong Answer
19
3,188
362
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 = input() T = input() ans = [] for i in range(len(S) - len(T) + 1): c = "" for j in range(len(T)): if S[i+j] != "?" and S[i+j] != T[j]: break c += T[j] if len(c) == len(T): print(S[:i], c, S[i+len(T):]) ans.append((S[:i] + c + S[i+len(T):]).replace("?", "a")) print(min(ans) if ans else "UNRESTORABLE")
s191182297
Accepted
18
3,060
324
S = input() T = input() ans = [] for i in range(len(S) - len(T) + 1): c = "" for j in range(len(T)): if S[i+j] != "?" and S[i+j] != T[j]: break c += T[j] if len(c) == len(T): ans.append((S[:i] + c + S[i+len(T):]).replace("?", "a")) print(min(ans) if ans else "UNRESTORABLE")
s751276825
p03854
u122231433
2,000
262,144
Wrong Answer
18
3,188
517
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`.
# coding: utf-8 # Your code here! S = input() flag = False st_match = ["erase",'dream'] while len(S)>0: for st in st_match: if(S.startswith(st)): S=S[len(st):] if(S.startswith('er') and S.startswith('era')==False): S=S[2:] elif(S.startswith('r')): S=S[2:] flag=True break if(flag): flag=False continue else: break if(len(S)==0): print('Yes') else: print('NO')
s400281855
Accepted
214
4,084
477
def rev (s): _re=''.join(list(reversed(s))) return _re name = ['dream','dreamer','eraser','erase'] S = input() S_re = rev(S) i=0 can = True while i < len(S_re): for div in name: can2 = False if len(S_re[i:]) >= len(div): if S_re[i:i+len(div)]==rev(div) : i+=len(div) can2 = True break if not can2 : can = False break if can : print('YES') else : print('NO')
s109936800
p03712
u813387707
2,000
262,144
Wrong Answer
26
8,976
126
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
h, w = [int(x) for x in input().split()] s = "*" * (w + 2) print(s) for _ in range(h): print("*" + input() + "*") print(s)
s330993110
Accepted
24
9,060
128
h, w = [int(x) for x in input().split()] c = "#" s = c * (w + 2) print(s) for _ in range(h): print(c + input() + c) print(s)
s611973251
p03371
u419535209
2,000
262,144
Wrong Answer
17
3,064
306
"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.
def C(): A, B, C, nA, nB = map(int, input().split()) minAB = min(nA, nB) # 3, 2 --> 1, 0 ns = [nA - minAB, nB - minAB] print(ns) amounts = [ A * nA + B * nB, minAB * 2 * C + ns[0] * A + ns[1] * B, max(nA, nB) * 2 * C ] return min(amounts) print(C())
s185613378
Accepted
17
3,060
293
def C(): A, B, C, nA, nB = map(int, input().split()) minAB = min(nA, nB) # 3, 2 --> 1, 0 ns = [nA - minAB, nB - minAB] amounts = [ A * nA + B * nB, minAB * 2 * C + ns[0] * A + ns[1] * B, max(nA, nB) * 2 * C ] return min(amounts) print(C())
s677743610
p04030
u288087195
2,000
262,144
Wrong Answer
17
3,060
353
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
s = input() data =[] for i in range(len(s)): data.append(s[i]) array = [] for i in range(1, len(data)): if data[i] == "0": array.append("0") elif data[i] == "1": array.append("1") elif (len(array) != 0 and data[i]== "B"): array.pop(-1) else: pass mojiretu = '' for x in array: mojiretu += x print(mojiretu)
s406642147
Accepted
17
3,064
336
s = input() data =[] for i in range(len(s)): data.append(s[i]) array = [] for i in range(len(data)): if data[i] == "0": array.append("0") elif data[i] == "1": array.append("1") elif (len(array) != 0 and data[i]== "B"): array.pop(-1) else: pass mojiretu = '' for x in array: mojiretu += x print(mojiretu)
s895264113
p02268
u548155360
1,000
131,072
Wrong Answer
20
7,632
429
You are given a sequence of _n_ integers S and a sequence of different _q_ integers T. Write a program which outputs C, the number of integers in T which are also in the set S.
def BinarySearch(A, c): left = 0 right = len(A)-1 while(left < right): mid = (left + right) // 2 print(mid) if A[mid] == c: return mid elif (A[mid] < c): left = mid + 1 else: right = mid else: return 0 N = int(input()) S = list(map(int, input().split())) Q = int(input()) T = list(map(int, input().split())) ctr = 0 n = N for i in range(Q): if BinarySearch(S, T[i]): ctr += 1 print(ctr)
s446932353
Accepted
280
18,800
411
def BinarySearch(A, c): left = 0 right = len(A) while(left < right): mid = (left + right) // 2 if A[mid] == c: return True elif (A[mid] < c): left = mid + 1 else: right = mid else: return False N = int(input()) S = list(map(int, input().split())) Q = int(input()) T = list(map(int, input().split())) ctr = 0 for i in range(Q): if BinarySearch(S, T[i]): ctr += 1 print(ctr)
s930267267
p03448
u248670337
2,000
262,144
Wrong Answer
45
8,016
129
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,b,c,x=[int(input()) for _ in range(4)] print([500*i+100*j+50*k for i in range(a) for j in range(b) for k in range(c)].count(x))
s968063318
Accepted
46
8,276
135
a,b,c,x=[int(input()) for _ in range(4)] print([500*i+100*j+50*k for i in range(a+1) for j in range(b+1) for k in range(c+1)].count(x))
s964302451
p03605
u392319141
2,000
262,144
Wrong Answer
17
2,940
39
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?
print('YNeos'[input().count('9')>0::2])
s374723616
Accepted
20
2,940
41
print('YNeos'[input().count('9')==0::2])
s667949802
p03836
u898967808
2,000
262,144
Wrong Answer
17
3,064
238
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()) yl = ty - sy xl = tx - sx ans = '' ans += 'U'*yl ans += 'R'*xl ans += 'D'*yl ans += 'L'*xl ans += 'R'*(yl+1) ans += 'R'*(xl+1) ans += 'DR' ans += 'D'*(yl+1) ans += 'L'*(xl+1) ans += 'U' print(ans)
s210896720
Accepted
17
3,064
242
sx,sy,tx,ty = map(int,input().split()) yl = ty - sy xl = tx - sx ans = '' ans += 'U'*yl ans += 'R'*xl ans += 'D'*yl ans += 'L'*(xl+1) ans += 'U'*(yl+1) ans += 'R'*(xl+1) ans += 'DR' ans += 'D'*(yl+1) ans += 'L'*(xl+1) ans += 'U' print(ans)
s233787884
p02795
u455533363
2,000
1,048,576
Wrong Answer
2,104
2,940
158
We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all the squares in that column black. At least how many operations do you need in order to have N or more black squares in the grid? It is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.
h = int(input()) w = int(input()) n = int(input()) count = n//h bit = w - count while count<n: if count>=n: print(count) break count += bit
s377139378
Accepted
18
3,060
187
h = int(input()) w = int(input()) n = int(input()) num = n//max(h,w) if (n//max(h,w)+1)==n else (n//max(h,w)+1) if (n%max(h,w)==0): print((n//max(h,w))) else: print((n//max(h,w)+1))
s721201517
p03962
u296150111
2,000
262,144
Wrong Answer
17
2,940
117
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.
a,b,c=map(int,input().split()) ans=1 if a==b: ans+=1 if b==c: ans+=1 if a==c: ans+=1 if ans==4: ans=3 print(ans)
s614129133
Accepted
17
2,940
111
a,b,c=input().split() if a!=b and b!=c and c!=a: print(3) elif a!=b or b!=c or c!=a: print(2) else: print(1)
s721914966
p02288
u207394722
2,000
131,072
Wrong Answer
40
6,556
1,089
A binary heap which satisfies max-heap property is called max-heap. In a max- heap, for every node $i$ other than the root, $A Write a program which reads an array and constructs a max-heap from the array based on the following pseudo code. $maxHeapify(A, i)$ move the value of $A[i]$ down to leaves to make a sub-tree of node $i$ a max-heap. Here, $H$ is the size of the heap. 1 maxHeapify(A, i) 2 l = left(i) 3 r = right(i) 4 // select the node which has the maximum value 5 if l ≤ H and A[l] > A[i] 6 largest = l 7 else 8 largest = i 9 if r ≤ H and A[r] > A[largest] 10 largest = r 11 12 if largest ≠ i // value of children is larger than that of i 13 swap A[i] and A[largest] 14 maxHeapify(A, largest) // call recursively The following procedure buildMaxHeap(A) makes $A$ a max-heap by performing maxHeapify in a bottom-up manner. 1 buildMaxHeap(A) 2 for i = H/2 downto 1 3 maxHeapify(A, i)
import pprint as pp class Main(): def exchange(self, n1, n2): tmp = self.A[n1] self.A[n1] = self.A[n2] self.A[n2] = tmp def left(self, i): return i * 2 def right(self, i): return i * 2 + 1 def maxHeapify(self, i): l = self.left(i) r = self.right(i) if l <= self.H and self.A[l] > self.A[i]: largest = l else : largest = i if r <= self.H and self.A[r] > self.A[largest]: largest = r if largest != i: self.exchange(i, largest) self.maxHeapify(largest) def buildMaxHeap(self): for i in reversed( range(1, self.H//2) ): self.maxHeapify(i) def main(self): self.H = int( input() ) self.A = [0] inputData = [int(x) for x in input().split()] self.A.extend(inputData) self.buildMaxHeap() for i in range(1, self.H+1): print(" " + str(self.A[i]), end = "" ) if __name__ == '__main__': M = Main() M.main()
s159633791
Accepted
1,830
62,628
1,109
import pprint as pp class Main(): def exchange(self, n1, n2): tmp = self.A[n1] self.A[n1] = self.A[n2] self.A[n2] = tmp def left(self, i): return i * 2 def right(self, i): return i * 2 + 1 def maxHeapify(self, i): l = self.left(i) r = self.right(i) if l <= self.H and self.A[l] > self.A[i]: largest = l else : largest = i if r <= self.H and self.A[r] > self.A[largest]: largest = r if largest != i: self.exchange(i, largest) self.maxHeapify(largest) def buildMaxHeap(self): for i in reversed( range(1, self.H//2 + 1) ): self.maxHeapify(i) def main(self): self.H = int( input() ) self.A = [0] inputData = [int(x) for x in input().split()] self.A.extend(inputData) self.buildMaxHeap() for i in range(1, self.H+1): print(" " + str(self.A[i]), end = "" ) print() if __name__ == '__main__': M = Main() M.main()
s712651017
p02415
u506705885
1,000
131,072
Wrong Answer
20
5,540
40
Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.
sentence=input() print(sentence.upper())
s231953290
Accepted
20
5,540
25
print(input().swapcase())
s220845882
p03151
u983918956
2,000
1,048,576
Wrong Answer
143
19,560
381
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his _readiness_ for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination. Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness. For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions: * The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal. * For every i, B_i \leq C_i holds. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) if sum(A) < sum(B): print(-1) exit() d = [A[i]-B[i] for i in range(N)] print(d) d.sort() neg = 0 count = 0 for e in d: if e < 0: neg += e count += 1 continue break for e in d[::-1]: if neg >= 0: break neg += e count += 1 print(count)
s306898172
Accepted
133
19,496
372
N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) if sum(A) < sum(B): print(-1) exit() d = [A[i]-B[i] for i in range(N)] d.sort() neg = 0 count = 0 for e in d: if e < 0: neg += e count += 1 continue break for e in d[::-1]: if neg >= 0: break neg += e count += 1 print(count)
s936829087
p03378
u264508862
2,000
262,144
Wrong Answer
17
3,064
123
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N. Find the minimum cost incurred before reaching the goal.
n,m,x=map(int,input().split()) a=map(int,input().split()) print(min(len([i for i in a if x<i]),len([i for i in a if x>i])))
s269386909
Accepted
17
3,060
155
n,m,x=map(int,input().split()) a=map(int,input().split()) b,c=[],[] for i in a: if i>x: b.append(i) else: c.append(i) print(min(len(b),len(c)))
s615081023
p03997
u196182810
2,000
262,144
Wrong Answer
20
2,940
150
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.
string_list = [input() for i in range(3)] a = int(string_list[0]) b = int(string_list[1]) h = int(string_list[2]) answer = (a+b)*h/2 print(answer)
s483182828
Accepted
17
2,940
151
string_list = [input() for i in range(3)] a = int(string_list[0]) b = int(string_list[1]) h = int(string_list[2]) answer = (a+b)*h//2 print(answer)
s980523028
p02390
u980683323
1,000
131,072
Wrong Answer
20
7,472
75
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
S=int(input()) s=S%60 S/=60 m=S%60 h=S/60 print("{}:{}:{}".format(h, m, s))
s118707084
Accepted
50
7,660
66
S=int(input()) print("{}:{}:{}".format(S//3600, (S//60)%60, S%60))
s467125239
p02659
u776134564
2,000
1,048,576
Wrong Answer
24
9,092
74
Compute A \times B, truncate its fractional part, and print the result as an integer.
import math a,b=map(float,input().split()) z=int(math.ceil(a*b)) print(z)
s381622738
Accepted
25
9,104
92
import math x,y=input().split() a=int(x) y=y.replace('.','') b=int(y) z=(a*b)//100 print(z)
s456881686
p03067
u849433300
2,000
1,048,576
Wrong Answer
17
2,940
83
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 abs(a-b)> c: print("yes") else: print("no")
s373096137
Accepted
17
2,940
112
a,b,c=map(int, input().split()) if a > c > b: print("Yes") elif a < c < b: print("Yes") else: print("No")
s702720517
p03548
u244836567
2,000
262,144
Wrong Answer
31
9,092
64
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person. At most how many people can sit on the seat?
a,b,c=input().split() a=int(a) b=int(b) c=int(c) print((a-c)//b)
s401432463
Accepted
29
9,032
68
a,b,c=input().split() a=int(a) b=int(b) c=int(c) print((a-c)//(b+c))
s002229161
p03457
u572122511
2,000
262,144
Wrong Answer
373
3,060
183
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
N = int(input()) can = True for i in range(N): t, x, y = list(map(int, input().split())) if not t%2 == (x+y)%2 or (x+y) > t: can = False break print(can)
s543964714
Accepted
370
3,060
231
N = int(input()) can = True for i in range(N): t, x, y = list(map(int, input().split())) if not t%2 == (x+y)%2 or (x+y) > t: can = False break if can: s = "Yes" else: s = "No" print(s)
s926359921
p03471
u956836108
2,000
262,144
Wrong Answer
1,058
9,096
463
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
# -*- coding: utf-8 -*- n, y = map(int, input().split()) judge = "no value" for i in range(n+1): if judge == "Found it!": break for j in range(n+1): value = i * 1000 + j * 5000 + (n - i - j) *10000 if value == y: print(i, j, n - i - j) judge = "Found it!" break if judge == "no value": print(-1, -1, -1)
s956561196
Accepted
1,239
9,184
308
n, y = map(int, input().split()) for i in range(n+1): for j in range(n+1): z = n - i - j value = z * 10000 + i * 5000 + j *1000 if value == y and z >= 0: print(z, i , j) break else: continue break else: print(-1, -1, -1)
s779177571
p02601
u589361760
2,000
1,048,576
Wrong Answer
31
9,200
308
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
a, b, c = map(int, input().split()) k = int(input()) c = c * 2 ** k i = 1 if a < b: if b < c: print("Yes") else: print("No") else: while i <= k: if a < i * b and i * b < c: print("Yes") break else: b = b * 2 i += 1 if i > k: print("No") print(a, b, c, i)
s158651788
Accepted
26
9,192
302
a, b, c = map(int, input().split()) k = int(input()) c = c * 2 ** k i = 1 if a < b: if b < c: print("Yes") else: print("No") else: while i <= k: if a < b and b < c: print("Yes") break else: b = b * 2 c = int(c / 2) i += 1 if i > k: print("No")
s758087927
p02844
u493520238
2,000
1,048,576
Wrong Answer
20
3,188
452
AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code. The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code. How many different PIN codes can he set this way? Both the lucky number and the PIN code may begin with a 0.
n = int(input()) s = input() print(s) cnt = 0 for s1 in range(10): s1_ind = s.find(str(s1)) if s1_ind == -1 or s1_ind >= len(s)-2 : continue for s2 in range(10): s2_ind = s[s1_ind+1: ].find(str(s2)) + s1_ind + 1 if s2_ind <= s1_ind or s2_ind >= len(s)-1: continue for s3 in range(10): s3_ind = s[s2_ind+1: ].find(str(s3)) + s2_ind + 1 if s3_ind > s2_ind: cnt+=1 print(cnt)
s323596788
Accepted
20
3,064
443
n = int(input()) s = input() cnt = 0 for s1 in range(10): s1_ind = s.find(str(s1)) if s1_ind == -1 or s1_ind >= len(s)-2 : continue for s2 in range(10): s2_ind = s[s1_ind+1: ].find(str(s2)) + s1_ind + 1 if s2_ind <= s1_ind or s2_ind >= len(s)-1: continue for s3 in range(10): s3_ind = s[s2_ind+1: ].find(str(s3)) + s2_ind + 1 if s3_ind > s2_ind: cnt+=1 print(cnt)
s187951870
p02613
u606374450
2,000
1,048,576
Wrong Answer
138
16,296
212
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()) A = [input() for i in range(N)] print('AC × {}'.format(A.count('AC'))) print('WA × {}'.format(A.count('WA'))) print('TLE × {}'.format(A.count('TLE'))) print('RE × {}'.format(A.count('RE')))
s249133975
Accepted
143
16,276
168
N = int(input()) A = [input() for i in range(N)] print('AC x', A.count('AC')) print('WA x', A.count('WA')) print('TLE x', A.count('TLE')) print('RE x', A.count('RE'))
s892966111
p03380
u026155812
2,000
262,144
Wrong Answer
2,105
14,920
558
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.
from bisect import bisect_left, bisect_right import math def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) n = int(input()) a = [int(i) for i in input().split()] a.sort() lim = len(a)//2 ans = [] for i, x in enumerate(a[::-1]): if i == lim: break if x != bisect_left(a, x//2): ans.append(combinations_count(x, bisect_left(a, x//2))) if x != bisect_right(a, x//2): ans.append(combinations_count(x, bisect_right(a, x//2))) print(max(ans))
s305662509
Accepted
127
14,348
214
from itertools import combinations n = int(input()) a = [int(i) for i in input().split()] a.sort() ai = a[-1] aj = -1 for i in range(n-1): if abs(a[i] - ai/2) <= abs(aj - ai/2): aj = a[i] print(ai, aj)
s924981184
p02646
u966891144
2,000
1,048,576
Wrong Answer
19
9,184
224
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()) kyori = abs(a - b) sokudo = abs(v-w) if (a > b and v < w) and (a < b and v > w) and kyori < t * sokudo: print('YES') else: print('NO')
s149406778
Accepted
24
9,168
172
a, v = map(int, input().split()) b, w = map(int, input().split()) t = int(input()) kyori = abs(a - b) sokudo = v-w if kyori<=t*sokudo: print('YES') else: print('NO')
s567408826
p03140
u021548497
2,000
1,048,576
Wrong Answer
29
9,096
101
You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters. Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation: * Operation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter. What is the minimum number of operations required to achieve the objective?
n=open(0).read() p=int(n[0]) ans=0 for i in range(p): ans+=len({n[i],n[p+i],n[p*2+i]})-1 print(ans)
s857115692
Accepted
28
9,156
215
n = int(input()) a = input() b = input() c = input() ans = 0 for i in range(n): if a[i] == b[i] == c[i]: continue if a[i] == b[i] or b[i] == c[i] or c[i] == a[i]: ans += 1 else: ans += 2 print(ans)
s127031473
p02261
u603049633
1,000
131,072
Wrong Answer
20
7,592
716
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
N = int(input()) A1 = list(map(str,input().split())) A2 = A1[:] def bubbleSort(A, N): flag = 0 i = 0 while flag == 0: flag = 1 for j in range(N-1, i, -1): if A[j][1] < A[j-1][1]: A[j], A[j-1] = A[j-1], A[j] flag = 0 i += 1 return A def selectSort(A, N): for i in range(N): minj = i for j in range(i, N): if A[j][1] < A[minj][1]: minj = j if A[i][1] != A[minj][1]: A[i], A[minj] = A[minj], A[i] return A def stable(Ab, As, N): for i in range(N): if Ab[i] != As[i]: return False return True bubbleSort(A1, N) selectSort(A2, N) print(" ".join(map(str, A1))) print("Stable") print(" ".join(map(str, A2))) if stable(A1, A2, N): print("Stable") else: print("Not Stable")
s119974412
Accepted
30
7,764
716
N = int(input()) A1 = list(map(str,input().split())) A2 = A1[:] def bubbleSort(A, N): flag = 0 i = 0 while flag == 0: flag = 1 for j in range(N-1, i, -1): if A[j][1] < A[j-1][1]: A[j], A[j-1] = A[j-1], A[j] flag = 0 i += 1 return A def selectSort(A, N): for i in range(N): minj = i for j in range(i, N): if A[j][1] < A[minj][1]: minj = j if A[i][1] != A[minj][1]: A[i], A[minj] = A[minj], A[i] return A def stable(Ab, As, N): for i in range(N): if Ab[i] != As[i]: return False return True bubbleSort(A1, N) selectSort(A2, N) print(" ".join(map(str, A1))) print("Stable") print(" ".join(map(str, A2))) if stable(A1, A2, N): print("Stable") else: print("Not stable")
s736295679
p03385
u456879806
2,000
262,144
Wrong Answer
30
8,972
66
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
S = input() if S == "abc": print("Yes") else: print("No")
s769224022
Accepted
27
9,080
90
S = list(input()) S.sort() if S == ['a', 'b', 'c']: print("Yes") else: print("No")
s155438649
p03469
u727067903
2,000
262,144
Wrong Answer
17
2,940
46
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
str = input() ans = '2018'+str[4:7] print(ans)
s622488496
Accepted
18
3,064
47
str = input() ans = '2018'+str[4:10] print(ans)
s776016752
p02613
u511824539
2,000
1,048,576
Wrong Answer
144
9,116
209
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()) n_apperances = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0} for i in range(n): s = input() n_apperances[s] += 1 for key in n_apperances: print('{} × {}'.format(key, n_apperances[key]))
s890766293
Accepted
148
9,060
208
n = int(input()) n_apperances = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0} for i in range(n): s = input() n_apperances[s] += 1 for key in n_apperances: print('{} x {}'.format(key, n_apperances[key]))
s851672607
p03450
u189023301
2,000
262,144
Wrong Answer
1,048
76,596
780
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.
from collections import deque n, m = map(int, input().split()) g = [[] for _ in range(n + 1)] q = deque([]) visited = set() dist = [None] * (n + 1) for i in range(m): a, b, k = map(int, input().split()) g[a].append((b, k)) g[b].append((a, -k)) def dfs(u): q.append(u) while q: v = q.pop() visited.add(v) for x, d in g[v]: if x not in visited: if dist[x] is None: dist[x] = dist[v] + d elif dist[x] != dist[v] + d: return False q.append(x) return True for i in range(1, n + 1): if i not in visited: print(len(visited)) dist[i] = 1 if not dfs(i): print("No") exit() print("Yes")
s585034809
Accepted
1,058
76,512
752
from collections import deque n, m = map(int, input().split()) g = [[] for _ in range(n + 1)] q = deque([]) visited = set() dist = [None] * (n + 1) for i in range(m): a, b, k = map(int, input().split()) g[a].append((b, k)) g[b].append((a, -k)) def dfs(u): q.append(u) while q: v = q.pop() visited.add(v) for x, d in g[v]: if x not in visited: if dist[x] is None: dist[x] = dist[v] + d elif dist[x] != dist[v] + d: return False q.append(x) return True for i in range(1, n + 1): if i not in visited: dist[i] = 1 if not dfs(i): print("No") exit() print("Yes")
s269757353
p02534
u883983516
2,000
1,048,576
Wrong Answer
28
9,072
18
You are given an integer K. Print the string obtained by repeating the string `ACL` K times and concatenating them. For example, if K = 3, print `ACLACLACL`.
"ACL"*int(input())
s946404346
Accepted
24
9,108
25
print("ACL"*int(input()))
s473344107
p03700
u203900263
2,000
262,144
Wrong Answer
2,109
55,704
506
You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called _health_ , and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below. Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows: * Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds. At least how many explosions do you need to cause in order to vanish all the monsters?
import math import numpy as np N, A, B = map(int, input().split()) h = [] for i in range(N): h.append(int(input())) def enough(T): h2 = list(map(lambda x: x - B * T, h)) print(h2) return sum(map(lambda x: max(0, math.ceil(x / (A - B))), h2)) <= T def solver(mi, ma): print(mi, ma) mid = (mi + ma) // 2 if mi == ma: return mid elif enough(mid): return solver(mi, mid) else: return solver(mid + 1, ma) t = max(h) // B print(solver(0, t))
s936016396
Accepted
1,939
11,036
457
import math N, A, B = map(int, input().split()) h = [] for i in range(N): h.append(int(input())) def enough(T): h2 = list(map(lambda x: x - B * T, h)) return sum(map(lambda x: max(0, math.ceil(x / (A - B))), h2)) <= T def solver(inf, sup): mid = (inf + sup) // 2 if inf == sup: return mid elif enough(mid): return solver(inf, mid) else: return solver(mid + 1, sup) t = 10 ** 9 print(solver(0, t))
s791280556
p03577
u331464808
2,000
262,144
Wrong Answer
17
2,940
24
Rng is going to a festival. The name of the festival is given to you as a string S, which ends with `FESTIVAL`, from input. Answer the question: "Rng is going to a festival of what?" Output the answer. Here, assume that the name of "a festival of s" is a string obtained by appending `FESTIVAL` to the end of s. For example, `CODEFESTIVAL` is a festival of `CODE`.
s= input() print(s[:-6])
s301607721
Accepted
17
2,940
24
s= input() print(s[:-8])
s144068895
p03228
u948416555
2,000
1,048,576
Wrong Answer
17
3,060
190
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person. Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.
a,b,k = map(int,input().split()) for i in range(k): if i%2 == 0: if a%2 != 0 : a -=1 a /= 2 b += a else : if b%2 != 0: b -= 1 b /= 2 a += b print(a,b)
s914706410
Accepted
17
3,060
200
a,b,k = map(int,input().split()) for i in range(k): if i%2 == 0: if a%2 != 0 : a -=1 a /= 2 b += a else : if b%2 != 0: b -= 1 b /= 2 a += b print(int(a),int(b))
s051923285
p02972
u549383771
2,000
1,048,576
Wrong Answer
841
14,124
524
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.
m = int(input()) num_list = list(map(int,input().split())) ans_list = [0]*m print_list = [] for i in range(m): if num_list[m-i-1] == 0: continue elif num_list[m-i-1] == 1: cnt = 0 for j in range(2**10): if (j+1)*(m-i) > m: break else: cnt += ans_list[(m-i)*(j+1)-1] if cnt % 2 == 0: ans_list[m-i-1] = 1 print_list.append(m-i) if not print_list: print(0) else: print(*print_list)
s983747796
Accepted
691
14,460
621
m = int(input()) num_list = list(map(int,input().split())) ans_list = [0]*m print_list = [] for i in range(m,0,-1): if num_list[i-1] == 0: cnt = 0 for j in range(2,m//i+1): cnt += ans_list[i*j-1] if cnt % 2 == 1: ans_list[i-1] = 1 print_list.append(i) elif num_list[i-1] == 1: cnt = 0 for j in range(2,m//i+1): cnt += ans_list[i*j-1] if cnt % 2 == 0: ans_list[i-1] = 1 print_list.append(i) if not print_list: print(0) else: print(sum(ans_list)) print(*print_list)
s157946404
p03672
u969708690
2,000
262,144
Wrong Answer
18
3,060
191
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
import sys S=input() for i in range(1,len(S)): S=S[:-1] if len(S)%2==0: c=len(S) print(S[c//2+1:]) print(S[:c//2]) if S[:c//2]==S[c//2+1:]: print(i) sys.exit()
s919135136
Accepted
17
3,060
147
import sys S=input() for i in range(1,len(S)): S=S[:-1] if len(S)%2==0: c=len(S) if S[:c//2]==S[c//2:]: print(c) sys.exit()
s795726977
p03679
u160659351
2,000
262,144
Wrong Answer
17
2,940
163
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
#65 X, A, B = map(int, input().rstrip().split()) if A-B >= 0: print("delicious") elif X+A-B >= 0: print("Safe") elif X+1+A-B <= 0: print("dangerous")
s895727231
Accepted
17
2,940
163
#65 X, A, B = map(int, input().rstrip().split()) if A-B >= 0: print("delicious") elif X+A-B >= 0: print("safe") elif X+1+A-B <= 0: print("dangerous")
s079687132
p03140
u936985471
2,000
1,048,576
Wrong Answer
18
2,940
163
You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters. Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation: * Operation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter. What is the minimum number of operations required to achieve the objective?
n=int(input()) a=input() b=input() c=input() ans=0 for i in range(n): if len(set([a,b,c]))==3: ans+=2 elif len(set([a,b,c]))==2: ans+=1 print(ans)
s160634913
Accepted
17
2,940
122
n=int(input()) a=input() b=input() c=input() ans=0 for i in range(n): ans+=len(set([a[i],b[i],c[i]]))-1 print(ans)
s869217810
p03971
u703890795
2,000
262,144
Wrong Answer
84
4,016
191
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 = input() for s in S: if s == "a" and A > 0: print("Yes") A -= 1 elif s == "b" and B > 0: print("Yes") B -= 1 else: print("No")
s706202581
Accepted
91
4,016
246
N, A, B = map(int, input().split()) S = input() for s in S: if s == "a" and A > 0: print("Yes") A -= 1 elif s == "a" and B > 0: print("Yes") B -= 1 elif s == "b" and B > 0: print("Yes") B -= 1 else: print("No")
s917772970
p03796
u414877092
2,000
262,144
Wrong Answer
17
2,940
36
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.
import math print(math.factorial(5))
s417709928
Accepted
230
3,984
61
import math N=int(input()) print(math.factorial(N)%(10**9+7))
s878632554
p03693
u275861030
2,000
262,144
Wrong Answer
17
2,940
98
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
a, b, c = map(int, input().split()) if int(a + b + c) % 4 == 0: print('YES') else: print('NO')
s211618930
Accepted
17
2,940
89
a, b, c = input().split() if int(a + b + c) % 4 == 0: print('YES') else: print('NO')
s711297843
p02841
u007263493
2,000
1,048,576
Wrong Answer
17
2,940
102
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month.
a, b = map(int,input().split()) c, d = map(int,input().split()) if a == b: print(0) else: print(1)
s141250007
Accepted
18
2,940
102
a, b = map(int,input().split()) c, d = map(int,input().split()) if a == c: print(0) else: print(1)
s571516450
p03759
u060505280
2,000
262,144
Wrong Answer
17
2,940
76
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()) print('Yes' if b - a == c - a else 'No')
s417029104
Accepted
17
2,940
80
a, b, c = map(int, input().split()) print('YES' if (b - a) == (c - b) else 'NO')
s460784840
p02409
u256874901
1,000
131,072
Wrong Answer
20
7,640
359
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
#coding:utf-8 apartment = [[[0 for z in range(10)] for y in range(3)] for x in range(4)] N = int(input()) for i in range(N): data = [int(x) - 1 for x in input().split()] apartment[data[0]][data[1]][data[2]] = data[3] + 1 for x in range(4): for y in range(3): for z in range(10): print(apartment[x][y][z], end="") print() if x != 3: print("#"*10)
s508537228
Accepted
20
7,796
520
#coding:utf-8 apartment = [[[0 for z in range(10)] for y in range(3)] for x in range(4)] N = int(input()) data = [[int(x) - 1 for x in input().split()] for y in range(N)] for x in data: apartment[x[0]][x[1]][x[2]] += x[3] + 1 if apartment[x[0]][x[1]][x[2]] > 9: apartment[x[0]][x[1]][x[2]] = 9 elif apartment[x[0]][x[1]][x[2]] < 0: apartment[x[0]][x[1]][x[2]] = 0 for x in range(4): for y in range(3): for z in range(10): print(" " + str(apartment[x][y][z]), end="") print() if x != 3: print(("#"*20))
s560693745
p03545
u995062424
2,000
262,144
Wrong Answer
17
3,064
496
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.
Num = input() op = -1 A = int(Num[0]) B = int(Num[1]) C = int(Num[2]) D = int(Num[3]) sign = [0]*3 for i in range(2): for j in range(2): for k in range(2): if(A+B*op**(i+1)+C*op**(j+1)+D*op**(k+1) == 7): sign[0] = i sign[1] = j sign[2] = k quit() for n in range(3): if(sign[n] == 0): sign[n] = "-" else: sign[n] = "+" print(str(A)+sign[0]+str(B)+sign[1]+str(C)+sign[2]+str(D)+"=7")
s481942109
Accepted
17
3,188
467
Num = input() op = -1 A = int(Num[0]) B = int(Num[1]) C = int(Num[2]) D = int(Num[3]) sign = [] for i in range(2): for j in range(2): for k in range(2): if(A+B*op**i+C*op**j+D*op**k == 7): sign.append(i) sign.append(j) sign.append(k) for n in range(3): if(sign[n] == 0): sign[n] = "+" else: sign[n] = "-" print(Num[0]+sign[0]+Num[1]+sign[1]+Num[2]+sign[2]+Num[3]+"=7")
s689318354
p03044
u392029857
2,000
1,048,576
Wrong Answer
928
115,972
761
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices painted in the same color, the distance between them is an even number. Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.
import sys sys.setrecursionlimit(4100000) input = sys.stdin.readline def main(): def Dfs(G, v, cur=0): color[v] = cur % 2 for next_v in G[v]: if color[next_v[0]] != -1: continue Dfs(G, next_v[0], cur+next_v[1]) n = int(input()) e = [[0, 0, 0]] + [list(map(int, input().split())) for i in range(n-1)] g = [[] for i in range(n+1)] print(n, e); for i in range(1, n): g[e[i][0]].append([e[i][1], e[i][2]]) g[e[i][1]].append([e[i][0], e[i][2]]) color = [-1 for i in range(n+1)] for v in range(1, n+1): if color[v] != -1: continue Dfs(g, v) for i in range(1, n+1): print(color[i]) if __name__ == '__main__': main()
s475339280
Accepted
806
113,444
745
import sys sys.setrecursionlimit(4100000) input = sys.stdin.readline def main(): def Dfs(G, v, cur=0): color[v] = cur % 2 for next_v in G[v]: if color[next_v[0]] != -1: continue Dfs(G, next_v[0], cur+next_v[1]) n = int(input()) e = [[0, 0, 0]] + [list(map(int, input().split())) for i in range(n-1)] g = [[] for i in range(n+1)] for i in range(1, n): g[e[i][0]].append([e[i][1], e[i][2]]) g[e[i][1]].append([e[i][0], e[i][2]]) color = [-1 for i in range(n+1)] for v in range(1, n+1): if color[v] != -1: continue Dfs(g, v) for i in range(1, n+1): print(color[i]) if __name__ == '__main__': main()
s513177973
p03792
u271539660
2,000
262,144
Wrong Answer
502
11,380
1,670
There is a square-shaped grid with N vertical rows and N horizontal columns. We will denote the square at the i-th row from the top and the j-th column from the left as (i,\ j). Initially, each square is either white or black. The initial color of the grid is given to you as characters a_{ij}, arranged in a square shape. If the square (i,\ j) is white, a_{ij} is `.`. If it is black, a_{ij} is `#`. You are developing a robot that repaints the grid. It can repeatedly perform the following operation: * Select two integers i, j (1 ≤ i,\ j ≤ N). Memorize the colors of the squares (i,\ 1), (i,\ 2), ..., (i,\ N) as c_1, c_2, ..., c_N, respectively. Then, repaint the squares (1,\ j), (2,\ j), ..., (N,\ j) with the colors c_1, c_2, ..., c_N, respectively. Your objective is to turn all the squares black. Determine whether it is possible, and find the minimum necessary number of operations to achieve it if the answer is positive.
def paint(row,col): #print("--> paint:",row, col) temp = list(ar[row]) for i in range(N): ar[i][col] = temp[i] def paintsCompletely(row,col): for i in range(N): if ar[i][col] == '.' and ar[row][i] == '.': return False return True N = int(input().strip()) ar = [N*[] for _ in range(N)] for row in range(N): ar[row] = list(input().strip()) #print(ar) count = N*[0] missing = [N*[] for _ in range(N)] fullestRow = -1 maxCount = 0 for row in range(N): for col in range(N): if ar[row][col] == '#': count[row] += 1 else: missing[row].append(col) if count[row] > maxCount: maxCount = count[row] fullestRow = row #print(fullestRow) if maxCount == 0: print(-1) else: req = 0 for emptyCol in missing[fullestRow]: #print(ar) #print("empty:",emptyCol) req += 1 found = False oneRow = -1 for row in range(N): if ar[row][fullestRow] == '#': found = True oneRow = row #ar[fullestRow][emptyCol] = '#' if paintsCompletely(row,emptyCol): #print("completely?") paint(row,emptyCol) break if not found: #print("Not found") paint(fullestRow,emptyCol) req += 1 #ar[fullestRow][emptyCol] = '#' for row in range(N): if ar[row][fullestRow] == '#': oneRow = row #ar[fullestRow][emptyCol] = '#' if paintsCompletely(row,emptyCol): paint(row,emptyCol) break paint(oneRow, emptyCol) #print(ar) for col in range(N): for row in range(N): if ar[row][col] == '.': req+=1 break print(req)
s111284040
Accepted
99
3,316
734
N = int(input().strip()) ar = [N*[] for _ in range(N)] for row in range(N): ar[row] = input().strip() fullestRows = [] maxCount = 0 for row in range(N): count = 0 for col in range(N): if ar[row][col] == '#': count += 1 if count > maxCount: maxCount = count fullestRows = [row] elif count == maxCount: fullestRows.append(row) if maxCount == 0: print(-1) else: found = False req = 0 for fr in fullestRows: for row in range(N): if ar[row][fr] == '#': found = True break if found: break if not found: req += 1 req += N - maxCount for col in range(N): for row in range(N): if ar[row][col] == '.': req+=1 break print(req)
s977007354
p03485
u570612423
2,000
262,144
Wrong Answer
21
3,316
49
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(-(-a+b//2))
s360092378
Accepted
17
2,940
51
a,b = map(int,input().split()) print(-(-(a+b)//2))
s609263456
p03494
u964665290
2,000
262,144
Wrong Answer
29
9,156
284
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()) li = list(map(int, input().split())) count = 0 def calc_half(n): return n/2 for i in range(N): for i in li: if i%2 == 0: flag = True else: flag = False break if flag == True: li = map(calc_half, li) count += 1 print(count)
s379297718
Accepted
29
9,068
186
N = int(input()) A = list(map(int, input().split())) count = 0 while all(a % 2 == 0 for a in A): A = [a/2 for a in A] count += 1 print(count)
s704157460
p03196
u519968172
2,000
1,048,576
Wrong Answer
2,206
9,336
258
There are N integers a_1, a_2, ..., a_N not less than 1. The values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \times a_2 \times ... \times a_N = P. Find the maximum possible greatest common divisor of a_1, a_2, ..., a_N.
n,p=map(int,input().split()) from collections import Counter a=[] while p%2==0: a.append(2) p//=2 f=3 while f<=p: if p%f==0: a.append(f) p//=f else: f+=2 c=Counter(a) ans=1 print(c) for k,v in c.items(): if v>=n: ans*=k print(ans)
s866555092
Accepted
88
9,436
297
n,p=map(int,input().split()) from collections import Counter a=[] while p%2==0: a.append(2) p//=2 f=3 while f<=p: if p%f==0: a.append(f) p//=f elif f*f>p: a.append(p) break else: f+=2 c=Counter(a) ans=1 for k,v in c.items(): if v>=n: ans*=k**(v//n) print(ans)
s278522306
p03739
u489108157
2,000
262,144
Wrong Answer
173
14,468
837
You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
n=int(input()) a=list(map(lambda x: int(x), input().split())) a.sort() cnt=[] val=[] last=-1 for i in a: if i == last: cnt[-1]+=1 else: cnt.append(1) val.append(i) last = i low_val=-10 low_cnt=0 mid_val=0 mid_cnt=0 ans=0 for i, v in enumerate(val): if v>=low_val+3: ans=max(ans, low_cnt+mid_cnt+cnt[i]) low_val=v low_cnt=cnt[i] mid_val=0 mid_cnt=0 elif v==low_val+2: ans=max(ans, low_cnt+mid_cnt+cnt[i]) if mid_val>0: low_val=mid_val low_cnt=mid_cnt mid_val=v mid_cnt=cnt[i] else: low_val=v low_cnt=cnt[i] mid_val=0 mid_cnt=0 if v==low_val+1: mid_val=v mid_cnt=cnt[i] ans=max(ans, low_cnt+mid_cnt) print(ans)
s497193193
Accepted
140
14,332
930
n=int(input()) a=list(map(lambda x: int(x), input().split())) ans_plus=0 tmp=0 if a[0]<=0: ans_plus=1-a[0] tmp=1 else: tmp=a[0] plus_flag=False for i in a[1:]: tmp+=i if plus_flag==True and tmp>0: pass elif plus_flag==True and tmp<=0: ans_plus+=1-tmp tmp=1 elif plus_flag==False and tmp<0: pass elif plus_flag==False and tmp>=0: ans_plus+=1+tmp tmp=-1 plus_flag=not plus_flag ans_minus=0 tmp=0 if a[0]>=0: ans_minus=1+a[0] tmp=-1 else: tmp=a[0] plus_flag=True for i in a[1:]: tmp+=i if plus_flag==True and tmp>0: pass elif plus_flag==True and tmp<=0: ans_minus+=1-tmp tmp=1 elif plus_flag==False and tmp<0: pass elif plus_flag==False and tmp>=0: ans_minus+=1+tmp tmp=-1 plus_flag=not plus_flag #print(ans_minus) print(min(ans_plus, ans_minus))
s789433118
p03863
u733321071
2,000
262,144
Wrong Answer
18
3,316
118
There is a string s of length 3 or greater. No two neighboring characters in s are equal. Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first: * Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s. The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
# -*- coding: utf-8 s = input() if (s[0] == s[-1]) ^ (len(s) % 2 == 0): print('First') else: print('Second')
s878495982
Accepted
18
3,316
118
# -*- coding: utf-8 s = input() if (s[0] == s[-1]) ^ (len(s) % 2 == 0): print('Second') else: print('First')
s785668968
p03964
u030726788
2,000
262,144
Wrong Answer
20
3,060
195
AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.
n=int(input()) t,a=map(int,input().split()) for i in range(1,n): c,d=map(int,input().split()) e,f=c,d times=1 while(e<t and f<a): times+=1 e,f=c*times,d*times t,a=e,f print(t+a)
s627126888
Accepted
21
3,060
278
n=int(input()) t,a=map(int,input().split()) for i in range(1,n): c,d=map(int,input().split()) if(t/c>a/d): if(t%c==0):times=t//c else:times=t//c+1 else: if(a%d==0):times=a//d else:times=a//d+1 #print(times) t,a=c*times,d*times #print(t,a) print(t+a)
s601035109
p03455
u607680583
2,000
262,144
Wrong Answer
29
9,156
96
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a,b = [int(x) for x in input().split()] if (a+b) % 2 == 0: print("Even") else: print("Odd")
s244369196
Accepted
24
9,096
96
a,b = [int(x) for x in input().split()] if (a*b) % 2 == 0: print("Even") else: print("Odd")
s056331140
p03637
u595633284
2,000
262,144
Wrong Answer
54
11,096
572
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
import sys def main(): args = sys.stdin.readline().split() N = int(args[0]) A = map(int, input().split()) non_factor_cnt = 0 factor_of_two_cnt = 0 factor_of_four_cnt = 0 for num in A: remainder = num % 4 if remainder != 0: if remainder == 2: factor_of_two_cnt += 1 else: non_factor_cnt += 1 else: factor_of_four_cnt += 1 if factor_of_four_cnt >= non_factor_cnt + factor_of_two_cnt % 2: print('Yes') else: print('No') main()
s798219175
Accepted
55
11,096
712
import sys def main(): args = sys.stdin.readline().split() N = int(args[0]) A = map(int, input().split()) non_factor_cnt = 0 factor_of_two_cnt = 0 factor_of_four_cnt = 0 for num in A: remainder = num % 4 if remainder != 0: if remainder == 2: factor_of_two_cnt += 1 else: non_factor_cnt += 1 else: factor_of_four_cnt += 1 if factor_of_two_cnt == 0: if factor_of_four_cnt >= non_factor_cnt - 1: print('Yes') sys.exit() if factor_of_four_cnt >= non_factor_cnt: # + factor_of_two_cnt % 2: print('Yes') sys.exit() print('No') main()
s692658944
p02276
u940395729
1,000
131,072
Wrong Answer
20
5,596
361
Quick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, inturn, less than or equal to each element of A[q+1..r]. It also computes the index q. In the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r). Your task is to read a sequence A and perform the Partition based on the following pseudocode: Partition(A, p, r) 1 x = A[r] 2 i = p-1 3 for j = p to r-1 4 do if A[j] <= x 5 then i = i+1 6 exchange A[i] and A[j] 7 exchange A[i+1] and A[r] 8 return i+1 Note that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].
def partition(A, p, r): x = A[r] i = p-1 for j in range(p, r): if A[j] <= x: i = i+1 tmpA = A[i] A[i] = A[j] A[j] = tmpA tmpB = A[i+1] A[i+1] = A[r] A[r] = tmpB return i+1 n = int(input()) A = list(map(int, input().split())) r = len(A)-1 p = 0 partition(A, p, r) print(A)
s855980945
Accepted
80
16,388
306
def partition(A, p, r): x = A[r] i = p-1 for j in range(p, r): if A[j] <= x: i += 1 A[i], A[j] = A[j], A[i] A[i+1], A[r] = A[r], A[i+1] A[i+1] = "[{}]".format(A[i+1]) n = int(input()) A = list(map(int, input().split())) partition(A, 0, n-1) print(*A)
s295733072
p03636
u696449926
2,000
262,144
Wrong Answer
17
2,940
131
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.
chr = input() chr_list = list(chr) length = len(chr_list) a, z = chr_list[0], chr_list[length - 1] print(a, length, z, sep = '')
s316971395
Accepted
17
2,940
135
chr = input() chr_list = list(chr) length = len(chr_list) a, z = chr_list[0], chr_list[length - 1] print(a, length - 2, z, sep = '')
s187338438
p03971
u566968132
2,000
262,144
Wrong Answer
137
4,708
608
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.
l=list(map(int,input().split())) participant=list(input()) passnum=l[1]+l[2] b=0 for i in range(l[0]): if participant[i]=='a' and passnum>0: participant[i]='Yes' passnum-=1 elif passnum==0: break if passnum>0: for i in range(l[0]): if participant[i]=='b' and passnum>0 and b<l[2]: participant[i]='Yes' passnum-=1 b+=1 elif b==l[2]: break elif passnum==0: break for i in range(l[0]): if participant[i]!='Yes': participant[i]='No' for i in range(l[0]): print(participant[i])
s398901938
Accepted
123
4,712
483
l=list(map(int,input().split())) participant=list(input()) passnum=l[1]+l[2] b=0 for i in range(l[0]): if participant[i]=='a' and passnum>0: participant[i]='Yes' passnum-=1 elif participant[i]=='b' and passnum>0 and b<l[2]: participant[i]='Yes' passnum-=1 b+=1 elif passnum==0: break for i in range(l[0]): if participant[i]!='Yes': participant[i]='No' for i in range(l[0]): print(participant[i])
s285766341
p04029
u989851123
2,000
262,144
Wrong Answer
27
8,988
34
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?
print(sum(range(1, int(input()))))
s310404824
Accepted
27
9,072
36
print(sum(range(1, int(input())+1)))
s779126614
p02842
u932368968
2,000
1,048,576
Wrong Answer
17
2,940
155
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.
IN = list(map(int, input().split())) N = IN[0] price = round(N/1.08) price1 = (int)(1.08 * price) if N == price1: print(price1) else: print(":(")
s341560388
Accepted
31
2,940
171
import math N = int(input()) ans = -1 for x in range(N+1): if math.floor(x * 1.08) == N: ans = x break if ans == -1: print(":(") else: print(ans)
s030504986
p04030
u556161636
2,000
262,144
Wrong Answer
17
2,940
189
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
arg=input() ans=[] for char in arg: if char=='1' or char=='0': ans.append(char) print(ans) elif char=='B': if ans!=[]: del ans[-1] print(ans) print(''.join(ans))
s370638626
Accepted
17
2,940
157
arg=input() ans=[] for char in arg: if char=='1' or char=='0': ans.append(char) elif char=='B': if ans!=[]: del ans[-1] print(''.join(ans))
s545932754
p02393
u009101629
1,000
131,072
Wrong Answer
20
5,592
76
Write a program which reads three integers, and prints them in ascending order.
lis = [int(x) for x in input().split()] lis.sort() lis.reverse() print(lis)
s904379736
Accepted
20
5,604
113
lis = [int(x) for x in input().split()] lis.sort() for i in range(2): print(lis[i],end = " ") print(lis[-1])
s339205553
p03455
u291766461
2,000
262,144
Wrong Answer
17
3,060
447
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
def is_even(int_num): if int_num % 2 == 0: return True else: return False def main(): inputs = input("input two integers for this problem: ") temp = inputs.split() if len(temp) != 2: print("input is invalid. input two integers.") exit(1) a, b = int(temp[0]), int(temp[1]) if is_even(a * b): print("Even") else: print("Odd") if __name__ == "__main__": main()
s024228955
Accepted
17
3,060
368
def is_even(int_num): if int_num % 2 == 0: return True else: return False def main(): # start = time.time() inputs = input().split() a, b = int(inputs[0]), int(inputs[1]) if is_even(a * b): print("Even") else: print("Odd") # print((time.time() - start) * 1000.0) if __name__ == "__main__": main()
s761822514
p03845
u888512581
2,000
262,144
Wrong Answer
18
3,060
162
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()) for i in range(M): P, X = map(int, input().split()) print(sum(T) - (T[P-1] - X) + X)
s010365174
Accepted
18
3,060
158
N = int(input()) T = list(map(int, input().split())) M = int(input()) for i in range(M): P, X = map(int, input().split()) print(sum(T) - (T[P-1] - X))
s280559859
p02927
u620755587
2,000
1,048,576
Wrong Answer
19
3,060
239
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()) cnt = 0 for i in range(1, m + 1): for j in range(1, d + 1): if (j % 10) * (j // 10) == i and j % 10 >= 2 and j // 10 >= 2: print(i, j, j % 10, j // 10) cnt += 1 print(cnt)
s299374438
Accepted
18
2,940
198
m, d = map(int,input().split()) cnt = 0 for i in range(1, m + 1): for j in range(1, d + 1): if (j % 10) * (j // 10) == i and j % 10 >= 2 and j // 10 >= 2: cnt += 1 print(cnt)
s082842885
p03943
u996307903
2,000
262,144
Wrong Answer
17
2,940
137
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 = input().split() b = max(a) c =0 for i in a: if int(i) < int(b): c += int(i) if c == int(b): print('YES') else: print('NO')
s623682962
Accepted
17
2,940
90
a, b, c= sorted(map(int, input().split())) if a+b == c: print('Yes') else: print('No')
s199790053
p02669
u521866787
2,000
1,048,576
Wrong Answer
233
13,212
1,132
You start with the number 0 and you want to reach the number N. You can change the number, paying a certain amount of coins, with the following operations: * Multiply the number by 2, paying A coins. * Multiply the number by 3, paying B coins. * Multiply the number by 5, paying C coins. * Increase or decrease the number by 1, paying D coins. You can perform these operations in arbitrary order and an arbitrary number of times. What is the minimum number of coins you need to reach N? **You have to solve T testcases.**
import heapq from collections import deque T = int(input()) for t in range(T): N,A,B,C,D = map(int,input().split()) q = [(0,N)] heapq.heapify(q) seen = set() while q: cost, n = heapq.heappop(q) if n in seen: continue seen.add(n) if n == 0: print(cost) break heapq.heappush(q, (cost + N * D, 0)) if n % 2 ==0: heapq.heappush(q, (cost + A, n // 2)) else: heapq.heappush(q, (cost + D + A, (n + 1) // 2)) heapq.heappush(q, (cost + D + A, (n - 1) // 2)) if n % 3 ==0: heapq.heappush(q, (cost + B, n // 3)) else: rest = n % 3 heapq.heappush(q, (cost + rest * D + B, (n - rest) // 3)) heapq.heappush(q, (cost + (3-rest) * D + B, (n - rest + 3) // 3)) if n % 5 ==0: heapq.heappush(q, (cost + C, n // 5)) else: rest = n % 5 heapq.heappush(q, (cost + rest * D + C, (n - rest) // 5)) heapq.heappush(q, (cost + (5-rest) * D + C, (n - rest + 5) // 5))
s625491470
Accepted
177
12,868
1,103
import heapq T = int(input()) for t in range(T): N,A,B,C,D = map(int,input().split()) q = [(0,N)] heapq.heapify(q) seen = set() while q: cost, n = heapq.heappop(q) if n in seen: continue seen.add(n) if n == 0: print(cost) break heapq.heappush(q, (cost + n * D, 0)) if n % 2 ==0: heapq.heappush(q, (cost + A, n // 2)) else: heapq.heappush(q, (cost + D + A, (n + 1) // 2)) heapq.heappush(q, (cost + D + A, (n - 1) // 2)) if n % 3 ==0: heapq.heappush(q, (cost + B, n // 3)) else: rest = n % 3 heapq.heappush(q, (cost + rest * D + B, (n - rest) // 3)) heapq.heappush(q, (cost + (3-rest) * D + B, (n - rest + 3) // 3)) if n % 5 ==0: heapq.heappush(q, (cost + C, n // 5)) else: rest = n % 5 heapq.heappush(q, (cost + rest * D + C, (n - rest) // 5)) heapq.heappush(q, (cost + (5-rest) * D + C, (n - rest + 5) // 5))
s376989878
p01416
u509278866
2,000
131,072
Wrong Answer
60
9,044
3,091
ICPC で良い成績を収めるには修行が欠かせない.うさぎは ICPC で勝ちたいので,今日も修行をすることにした. 今日の修行は,流行りのパズルをすばやく解いて,瞬発力を鍛えようというものである.今日挑戦するのは,色とりどりのタイルが並んでいてそれらを上手く消していくパズルだ 初期状態では,グリッド上のいくつかのマスにタイルが置かれている.各タイルには色がついている.プレイヤーはゲーム開始後,以下の手順で示される操作を何回も行うことができる. 1. タイルが置かれていないマスを 1 つ選択し,そのマスを叩く. 2. 叩いたマスから上に順に辿っていき,タイルが置かれているマスに至ったところでそのタイルに着目する.タイルが置かれているマスがないまま盤面の端に辿り着いたら何にも着目しない. 3. 同様の操作を叩いたマスから下・左・右方向に対して行う.最大 4 枚のタイルが着目されることになる. 4. 着目したタイルの中で同じ色のものがあれば,それらのタイルを盤面から取り除く.同じ色のタイルの組が 2 組あれば,それら両方を取り除く. 5. タイルを取り除いた枚数と同じ値の得点が入る. 6. 着目をやめる. たとえば,以下のような状況を考えよう.タイルが置かれていないマスはピリオドで,タイルの色はアルファベット大文字で表されている. ..A....... .......B.. .......... ..B....... ..A.CC.... ここで上から 2 行目,左から 3 列目のマスを叩く操作を考える.着目することになるタイルは `A` , `B` , `B` の 3 枚であるから,`B` の 2 枚が消えて盤面は以下のようになり,2 点を得る. ..A....... .......... .......... .......... ..A.CC.... このパズルはゆっくりしていると時間切れになってしまい,盤面の一部が見えなくなりどのくらい修行が足りなかったのかがわからなくなってしまう. 各色のタイルは 2 枚ずつ置かれているが,それらをすべて消せるとは限らないので,予めプログラムに得点の最大値を計算させておきたい.
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def I(): return int(sys.stdin.readline()) def F(): return float(sys.stdin.readline()) def S(): return input() def pf(s): return print(s, flush=True) def main(): m,n = LI() a = [[c for c in S()] for _ in range(m)] ad = collections.defaultdict(list) for i in range(m): for j in range(n): if a[i][j] != '.': ad[a[i][j]].append((i,j)) ps = set(map(tuple,ad.values())) f = True r = 0 while f: f = False for pa,pb in list(ps): i1,j1 = pa i2,j2 = pb if i1 == i2: ff = True for j in range(min(j1,j2)+1,max(j1,j2)): if a[i1][j] != '.': ff = False break if ff: f = True a[i1][j1] = '.' a[i2][j2] = '.' ps.remove((pa,pb)) r += 2 elif j1 == j2: ff = True for i in range(min(i1,i2)+1,max(i1,i2)): if a[i][j1] != '.': ff = False break if ff: f = True a[i1][j1] = '.' a[i2][j2] = '.' ps.remove((pa,pb)) r += 2 else: i,j = i1,j2 ff = True for j3 in range(min(j,j2)+1,max(j,j2)): if a[i][j3] != '.': ff = False break for i3 in range(min(i,i2)+1,max(i,i2)): if a[i3][j] != '.': ff = False break if ff: f = True a[i1][j1] = '.' a[i2][j2] = '.' ps.remove((pa,pb)) r += 2 continue i,j = i2,j1 ff = True for j3 in range(min(j,j1)+1,max(j,j1)): if a[i][j3] != '.': ff = False break for i3 in range(min(i,i1)+1,max(i,i1)): if a[i3][j] != '.': ff = False break if ff: f = True a[i1][j1] = '.' a[i2][j2] = '.' ps.remove((pa,pb)) r += 2 return r print(main())
s000886069
Accepted
90
11,204
3,132
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def I(): return int(sys.stdin.readline()) def F(): return float(sys.stdin.readline()) def S(): return input() def pf(s): return print(s, flush=True) def main(): m,n = LI() a = [[c for c in S()] for _ in range(m)] ad = collections.defaultdict(list) for i in range(m): for j in range(n): if a[i][j] != '.': ad[a[i][j]].append((i,j)) ps = set(map(tuple,ad.values())) f = True r = 0 while f: f = False for pa,pb in list(ps): i1,j1 = pa i2,j2 = pb if i1 == i2: ff = abs(j1-j2) > 1 for j in range(min(j1,j2)+1,max(j1,j2)): if a[i1][j] != '.': ff = False break if ff: f = True a[i1][j1] = '.' a[i2][j2] = '.' ps.remove((pa,pb)) r += 2 elif j1 == j2: ff = abs(i1-i2) > 1 for i in range(min(i1,i2)+1,max(i1,i2)): if a[i][j1] != '.': ff = False break if ff: f = True a[i1][j1] = '.' a[i2][j2] = '.' ps.remove((pa,pb)) r += 2 else: i,j = i1,j2 ff = a[i][j] == '.' for j3 in range(min(j,j1)+1,max(j,j1)): if a[i][j3] != '.': ff = False break for i3 in range(min(i,i2)+1,max(i,i2)): if a[i3][j] != '.': ff = False break if ff: f = True a[i1][j1] = '.' a[i2][j2] = '.' ps.remove((pa,pb)) r += 2 continue i,j = i2,j1 ff = a[i][j] == '.' for j3 in range(min(j,j2)+1,max(j,j2)): if a[i][j3] != '.': ff = False break for i3 in range(min(i,i1)+1,max(i,i1)): if a[i3][j] != '.': ff = False break if ff: f = True a[i1][j1] = '.' a[i2][j2] = '.' ps.remove((pa,pb)) r += 2 return r print(main())
s045904254
p03548
u703890795
2,000
262,144
Wrong Answer
17
2,940
55
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person. At most how many people can sit on the seat?
X, Y, Z = map(int, input().split()) print((X-Y)//(Y+Z))
s056208297
Accepted
17
3,064
55
X, Y, Z = map(int, input().split()) print((X-Z)//(Y+Z))
s018224568
p03477
u964665290
2,000
262,144
Wrong Answer
25
9,044
136
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.
a, b, c, d = map(int, input().split()) R = a+b L = c+d if R > L: print('Right') elif R < L: print('Left') else: print('Balanced')
s335190655
Accepted
26
9,072
135
a, b, c, d = map(int, input().split()) L = a+b R = c+d if R > L: print('Right') elif R < L: print('Left') else: print('Balanced')
s075898236
p02472
u536089081
1,000
262,144
Wrong Answer
20
5,588
39
Given two integers $A$ and $B$, compute the sum, $A + B$.
sum([int(i) for i in input().split()])
s864019487
Accepted
230
5,936
46
print(sum([int(i) for i in input().split()]))
s505658918
p03378
u284848973
2,000
262,144
Wrong Answer
18
3,064
287
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N. Find the minimum cost incurred before reaching the goal.
N, M, X = map(int, input('N M X = ').split()) A = map(int, input('A_{i}(i=1,2,…,M)= ').split()) setA = set(A) s1 = range(0, X) s2 = range(X, N+1) a1 = set(s1) & (setA) a2 = set(s2) & (setA) cost1 = len(a1) cost2 = len(a2) if cost1 >= cost2: print(cost2) else: print(cost1)
s241981820
Accepted
17
3,064
254
N, M, X = map(int, input().split()) A = map(int, input().split()) setA = set(A) s1 = range(0, X) s2 = range(X, N+1) a1 = set(s1) & (setA) a2 = set(s2) & (setA) cost1 = len(a1) cost2 = len(a2) if cost1 >= cost2: print(cost2) else: print(cost1)
s236595454
p02742
u948233576
2,000
1,048,576
Wrong Answer
17
2,940
94
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
H,W=list(map(int,input().split())) c=H*W/2 if H%2==1 and W%2==1: print(c+1) else: print(c)
s161556537
Accepted
17
3,060
131
H,W=list(map(int,input().split())) c=int(H*W/2) if H==1 or W==1: print("1") elif H%2==1 and W%2==1: print(c+1) else: print(c)
s432496779
p03494
u443630646
2,000
262,144
Wrong Answer
17
2,940
73
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
N = int(input()) a = input().split(' ') print(min(int(i) for i in a)//2)
s656257950
Accepted
31
3,060
295
N = int(input()) a = input().split(' ') c = 0 def check(a): global c for i in a: if int(i) % 2 == 1: return for i in a: a[a.index(i)] = int(i)/2 if int(i)/2 == 1: c += 1 return c += 1 check(a) check(a) print(c)
s745357280
p03150
u673101577
2,000
1,048,576
Wrong Answer
26
8,944
360
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
# from pprint import pprint # import math # import collections # n = int(input()) s = input() # a = list(map(int, input().split(' '))) K = 'keyence' if K in s: splitted = s.split(K) if len([spl for spl in splitted if len(spl) > 0]) > 1: print('NO') else: print('YES') else: print('NO')
s922070771
Accepted
32
9,068
509
# from pprint import pprint # import math # import collections # n = int(input()) s = input() # a = list(map(int, input().split(' '))) K = 'keyence' for i in range(len(s)): for j in range(len(s)): s1 = s[0:i] s2 = s[i:i + j] s3 = s[i + j:] # print(s1,s2,s3) if s1 == K or s2 == K or s3 == K or s1 + s2 == K or s1 + s3 == K or s2 + s3 == K: print('YES') exit() print('NO')
s024000326
p02388
u564707955
1,000
131,072
Wrong Answer
20
7,648
74
Write a program which calculates the cube of a given integer x.
print("????????°????????\?????????????????????>",) print(int(input())**3)
s448605277
Accepted
20
7,576
22
print(int(input())**3)
s404091359
p03563
u237702300
2,000
262,144
Wrong Answer
17
2,940
57
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
i1 = int(input()) i2 = int(input()) print(int((i1+i2)/2))
s816224297
Accepted
17
2,940
50
i1 = int(input()) i2 = int(input()) print(i2*2-i1)
s098059877
p03377
u802772880
2,000
262,144
Wrong Answer
17
2,940
85
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()) if A<=X<=(A+B): print('Yes') else: print('No')
s644079572
Accepted
17
2,940
85
A,B,X=map(int,input().split()) if A<=X<=(A+B): print('YES') else: print('NO')
s450799493
p02742
u745812846
2,000
1,048,576
Wrong Answer
18
3,060
263
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
h, w = map(int, input().split()) ans = [] if h % 2 == 0: ans = h / 2 * w else: if w % 2 == 0: h_a = h//2 + 1 ans = (h_a * 2 - 1) * w/2 else: h_a = h // 2 + 1 ans = (h_a * 2 - 1) * (w//2) + h_a print(ans)
s856251145
Accepted
17
3,060
292
h, w = map(int, input().split()) if h == 1 or w == 1: ans = 1 elif h % 2 == 0: ans = h // 2 * w else: if w % 2 == 0: h_a = h//2 + 1 ans = (h_a * 2 - 1) * w//2 else: h_a = h // 2 + 1 ans = (h_a * 2 - 1) * (w//2) + h_a print(ans)
s246709130
p02388
u286033857
1,000
131,072
Wrong Answer
20
7,612
33
Write a program which calculates the cube of a given integer x.
x = int(input("num")) print(x**3)
s567522725
Accepted
30
7,536
28
x = int(input()) print(x**3)
s337780768
p02402
u725841747
1,000
131,072
Wrong Answer
30
7,648
105
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.
n = input() a = list(map(int,input().split(" "))) del(a[0]) print("{0} {1}".format(min(a),max(a),sum(a)))
s077285241
Accepted
30
8,628
99
n = input() a = list(map(int,input().split(" "))) print("{0} {1} {2}".format(min(a),max(a),sum(a)))
s894711372
p03567
u525117558
2,000
262,144
Wrong Answer
17
2,940
57
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(S in 'AC'): print('Yes') else: print('No')
s155184645
Accepted
17
2,940
56
S=input() if 'AC' in S: print('Yes') else: print('No')
s719977352
p03495
u408375121
2,000
262,144
Wrong Answer
133
32,184
249
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.
N, K = map(int, input().split()) A = list(map(int, input().split())) dic = {} B = [] for a in A: if a in dic: dic[a] += 1 else: dic[a] = 1 for v in dic.values(): B.append(v) B.sort() if len(B) <= K: print(0) else: print(sum(B[K:]))
s631293806
Accepted
132
33,312
251
N, K = map(int, input().split()) A = list(map(int, input().split())) dic = {} B = [] for a in A: if a in dic: dic[a] += 1 else: dic[a] = 1 for v in dic.values(): B.append(v) B.sort() if len(B) <= K: print(0) else: print(sum(B[:-K]))
s754838203
p03759
u779830746
2,000
262,144
Wrong Answer
28
9,000
115
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 == c-b: print('Yes') else: print('No')
s334758680
Accepted
28
9,132
115
a, b, c = map(int, input().split()) if b-a == c-b: print('YES') else: print('NO')
s544192860
p04030
u417014669
2,000
262,144
Wrong Answer
17
2,940
107
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
words="010B" s="" for word in words: if word=="B": s=s[:-1] else: s=s+word print(s)
s035871247
Accepted
19
2,940
108
words=input() s="" for word in words: if word=="B": s=s[:-1] else: s=s+word print(s)
s313181201
p02936
u504836877
2,000
1,048,576
Wrong Answer
2,116
143,192
653
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 = map(int, input().split()) edge = [[int(e) for e in input().split()] for _ in range(N-1)] question = [[int(q) for q in input().split()] for _ in range(Q)] L = [[] for _ in range(N)] for i in range(N-1): L[edge[i][0]-1].append(edge[i][1]-1) L[edge[i][1]-1].append(edge[i][0]-1) qlist = [0]*N for i in range(Q): qlist[question[i][0]-1] += question[i][1] cnt = [0]*N q = [[0, qlist[0]]] cnt[0] = qlist[0] while q: temp = q.pop(0) v = temp[0] c = temp[1] for i in L[v]: if cnt[i] == 0: q.append([i, c+qlist[i]]) cnt[i] = c+qlist[i] for i in range(N): print(cnt[i])
s726462531
Accepted
1,735
75,340
511
N,Q = map(int, input().split()) E = [[] for _ in range(N)] for _ in range(N-1): a,b = map(int, input().split()) E[a-1].append(b-1) E[b-1].append(a-1) C = [0]*N for _ in range(Q): p,x = map(int, input().split()) C[p-1] += x from collections import deque q = deque() q.append((0, C[0])) ans = [-1]*N ans[0] = C[0] while q: temp = q.pop() u = temp[0] c = temp[1] for v in E[u]: if ans[v] == -1: ans[v] = c+C[v] q.append((v, c+C[v])) print(*ans)
s560830797
p03434
u584317622
2,000
262,144
Wrong Answer
17
2,940
82
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
N = input() a = sorted(map(int,input().split())) print(sum(a[::2]) - sum(a[1::2]))
s504269124
Accepted
17
2,940
96
N = input() a = sorted(map(int,input().split()),reverse=True) print(sum(a[0::2]) - sum(a[1::2]))
s945858561
p02927
u338929851
2,000
1,048,576
Wrong Answer
25
3,064
527
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?
# -*- coding: utf-8 -*- if __name__ == '__main__': M, D = map(int, input().split()) #D10 = int(D[0]) #D1 = int(D[1]) count = 0 for m in range(1,M+1): for d in range(1,D+1): if d>=10: d_ = str(d) D10 = int(d_[0]) D1 = int(d_[1]) D_ = D10 * D1 if m == D_ and D10>=2 and D1>=2: print(d_,m) count += 1 else: D_ = 0 print(count)
s843895387
Accepted
24
3,060
495
# -*- coding: utf-8 -*- if __name__ == '__main__': M, D = map(int, input().split()) #D10 = int(D[0]) #D1 = int(D[1]) count = 0 for m in range(1,M+1): for d in range(1,D+1): if d>=10: d_ = str(d) D10 = int(d_[0]) D1 = int(d_[1]) D_ = D10 * D1 if m == D_ and D10>=2 and D1>=2: count += 1 else: D_ = 0 print(count)
s935486531
p03415
u944209426
2,000
262,144
Wrong Answer
17
2,940
57
We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.
a = input() b = input() c = input() print(a[0],b[1],c[2])
s437397393
Accepted
17
2,940
57
a = input() b = input() c = input() print(a[0]+b[1]+c[2])
s126549436
p03385
u360515075
2,000
262,144
Wrong Answer
17
2,940
50
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
print ("YES" if len(set(input())) == 3 else "NO")
s880462605
Accepted
17
2,940
50
print ("Yes" if len(set(input())) == 3 else "No")
s075749706
p02742
u608493167
2,000
1,048,576
Wrong Answer
17
2,940
99
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
a,b = map(int,input().split()) if (a*b)%2 == 1: print(int(a*b)/2+1) else: print(int(a*b)/2)
s718111863
Accepted
17
2,940
139
a,b = map(int,input().split()) if a == 1 or b == 1: print(1) elif (a*b)%2 == 1: print(int((a*b)/2+1)) else: print(int((a*b)/2))
s466075867
p02600
u252016853
2,000
1,048,576
Wrong Answer
28
9,056
113
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?
x = int(input()) sum = 600 for i in range(8, 0, -1): if x < sum: print(i) break sum += 20
s743300201
Accepted
29
8,972
114
x = int(input()) sum = 600 for i in range(8, 0, -1): if x < sum: print(i) break sum += 200
s196724274
p03386
u306142032
2,000
262,144
Wrong Answer
17
3,060
159
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()) list = [] for i in range(k): print(i+a) for i in range(k): list.append(b-i) for x in list: print(x)
s412368356
Accepted
17
3,060
214
a, b, k = map(int, input().split()) t = [] for i in range(k): if i+a <= b: t.append(i+a) for i in range(k): if b-i >= a: t.append(b-i) y = list(set(t)) for x in sorted(y): print(x)