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
s692689161
p03385
u219369949
2,000
262,144
Wrong Answer
17
2,940
106
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() set1 = set(s) print(set1) if set1 == {'c', 'b', 'a'}: print("Yes") else: print("No")
s331820715
Accepted
17
2,940
93
s = input() set1 = set(s) if set1 == {'c', 'b', 'a'}: print("Yes") else: print("No")
s162239178
p03494
u278670845
2,000
262,144
Time Limit Exceeded
2,104
2,940
178
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.
import sys n = int(input()) a = list(map(int, input().split())) i = 0 while(True): for x in a: if x%2!=0: print(i) sys.exit() else: x = x//2 i += 1
s155023203
Accepted
18
3,060
288
import sys def main(): n = int(input()) a = list(map(int, input().split())) i = 0 while(True): for x in a: if x%2!=0: print(i) sys.exit() a = [x//2 for x in a] i += 1 if __name__=="__main__": main()
s839016226
p03610
u773686010
2,000
262,144
Wrong Answer
28
8,980
25
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
print(str(input())[1::2])
s839059163
Accepted
23
9,056
24
print(str(input())[::2])
s746775019
p03545
u917558625
2,000
262,144
Wrong Answer
30
9,116
282
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 in...
import itertools A=input() for i in list(itertools.product(range(2),repeat=3)): c='' c+=A[0] bns=int(A[0]) for j in range(3): if i[j]==0: bns+=int(A[j+1]) c+='+'+A[j+1] else: bns-=int(A[j+1]) c+='-'+A[j+1] if bns==7: print(c) exit()
s483975321
Accepted
29
9,084
287
import itertools A=input() for i in list(itertools.product(range(2),repeat=3)): c='' c+=A[0] bns=int(A[0]) for j in range(3): if i[j]==0: bns+=int(A[j+1]) c+='+'+A[j+1] else: bns-=int(A[j+1]) c+='-'+A[j+1] if bns==7: print(c+'=7') exit()
s888305182
p03360
u202826462
2,000
262,144
Wrong Answer
17
2,940
155
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after...
a, b, c = map(int, input().split()) k = int(input()) ans = 0 sub = a + b + c ans = max(a * (2 * k) + sub, b * (2 * k) + sub, c * (2 * k) + sub) print(ans)
s768269780
Accepted
17
2,940
100
a, b, c = map(int, input().split()) k = int(input()) print(a + b + c + max(a, b, c) * (2 ** k - 1))
s105247685
p03729
u854627522
2,000
262,144
Wrong Answer
17
2,940
121
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `Y...
nums = input().split() if nums[0][-1] == nums[1][0] and nums[1][-1] == nums[2][0]: print('Yes') else: print('No')
s365440272
Accepted
18
2,940
121
nums = input().split() if nums[0][-1] == nums[1][0] and nums[1][-1] == nums[2][0]: print('YES') else: print('NO')
s655762256
p03644
u419963262
2,000
262,144
Wrong Answer
28
9,132
170
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can...
n = int(input()) ANS = 0 for i in range(1,n+1): check = i ans = 0 while check % 2 == 0: check = check // 2 ans += 1 if ANS < ans: ANS = ans print(ANS)
s275045039
Accepted
26
9,140
194
n = int(input()) ANS = 1 keep = 0 for i in range(1,n+1): check = i ans = 0 while check % 2 == 0: check = check // 2 ans += 1 if keep < ans: keep = ans ANS = i print(ANS)
s421599625
p03796
u858670323
2,000
262,144
Wrong Answer
51
2,940
76
Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
N=int(input()) a=1 mod=1e9+7 for i in range(1,N+1): a*=i a%=mod print(a)
s622081570
Accepted
56
2,940
91
N=int(input().rstrip()) a=1 mod=1e9+7 for i in range(1,N+1): a*=i a%=mod print(int(a))
s635893573
p03359
u129978636
2,000
262,144
Wrong Answer
17
2,940
144
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For ...
a, b = map( int, input().split()) count = 0 for i in range(1, a + 1): if( i < b): count += 1 else: continue print(count)
s209349238
Accepted
17
2,940
104
a, b = map( int, input().split()) if( b < a): count = a - 1 else: count = a print(count)
s827556022
p03836
u667472448
2,000
262,144
Wrong Answer
33
4,468
606
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 ...
sx, sy, tx, ty = map(int, input().split()) distance_x, distance_y = tx-sx, ty-sy x_now, y_now = sx, sy #path1 for i in range(distance_y): print("U",end="") for i in range(distance_x): print("R",end="") #path2 for i in range(distance_y): print("D",end="") for i in range(distance_x): print("L",end="") ...
s047670893
Accepted
17
3,064
405
sx, sy, tx, ty = map(int, input().split()) distance_x, distance_y = tx-sx, ty-sy x_now, y_now = sx, sy up, down, right, left = 'U', 'D', 'R', 'L' #path1 print(up*distance_y+""+right*distance_x,end="") #path2 print(down*distance_y+""+left*distance_x,end="") #path3 print("L"+""+up*(distance_y+1)+""+right*(distance_x+1)+...
s754021977
p02975
u754022296
2,000
1,048,576
Wrong Answer
56
14,708
237
Snuke has N hats. The i-th hat has an integer a_i written on it. There are N camels standing in a circle. Snuke will put one of his hats on each of these camels. If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `Yes`; otherwise, print `No...
from functools import reduce n = int(input()) l = list(map(int, input().split())) if n%3: if max(l) == 0: print("YES") else: print("NO") else: if reduce((lambda x, y:x ^ y), l) == 0: print("YES") else: print("NO")
s721916317
Accepted
55
11,508
105
from functools import reduce as f;input();print("YNeos"[f(lambda x,y:x^y,map(int,input().split()))>0::2])
s356812139
p03485
u623687794
2,000
262,144
Wrong Answer
17
2,940
46
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+1)
s190652104
Accepted
17
2,940
90
a,b=map(int,input().split()) if (a+b) % 2==1: print((a+b+1)//2) else: print((a+b)//2)
s272939477
p03672
u445511055
2,000
262,144
Wrong Answer
19
3,064
291
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 del...
# -*- coding: utf-8 -*- def main(): """Function.""" s = str(input()) max_len = 0 for i in range((len(s)-1)//2): if s[:i+1] * 2 == s[:(i+1)*2]: print(s[:i+1]) max_len = (i + 1) * 2 print(max_len) if __name__ == "__main__": main()
s849266252
Accepted
18
2,940
264
# -*- coding: utf-8 -*- def main(): """Function.""" s = str(input()) max_len = 0 for i in range((len(s)-1)//2): if s[:i+1] * 2 == s[:(i+1)*2]: max_len = (i + 1) * 2 print(max_len) if __name__ == "__main__": main()
s625283958
p02747
u821237744
2,000
1,048,576
Wrong Answer
18
3,060
244
A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string.
S = list(input()) flug = True for i in range(0,len(S),2): if i+1 < len(S): st = S[i] + S[i + 1] if st != "hi": flug = False else: flug = False if flug == True: print("YES") else: print("NO")
s562702939
Accepted
17
3,060
244
S = list(input()) flug = True for i in range(0,len(S),2): if i+1 < len(S): st = S[i] + S[i + 1] if st != "hi": flug = False else: flug = False if flug == True: print("Yes") else: print("No")
s979926608
p03636
u305732215
2,000
262,144
Wrong Answer
18
2,940
57
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() aida = str(len(s)) print(s[0] + aida + s[-1])
s779714879
Accepted
17
2,940
60
s = input() aida = str(len(s)-2) print(s[0] + aida + s[-1])
s583202266
p03007
u162612857
2,000
1,048,576
Wrong Answer
232
14,260
950
There are N integers, A_1, A_2, ..., A_N, written on a blackboard. We will repeat the following operation N-1 times so that we have only one integer on the blackboard. * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y. Find the maximum possible value of the...
n = int(input()) nums = list(map(int, input().split() )) nums.sort() print(nums) if nums[0] >= 0: print(sum(list(map(abs, nums))) - 2 * nums[0]) hikareru = nums[0] for idx in range(2,n): print("{} {}".format(hikareru, nums[idx]) ) hikareru -= nums[idx] print("{} {}".format(nums[1], hikareru) ) elif nums...
s051288345
Accepted
230
14,088
936
n = int(input()) nums = list(map(int, input().split() )) nums.sort() if nums[0] >= 0: print(sum(list(map(abs, nums))) - 2 * nums[0]) hikareru = nums[0] for idx in range(2,n): print("{} {}".format(hikareru, nums[idx]) ) hikareru -= nums[idx] print("{} {}".format(nums[1], hikareru) ) elif nums[-1] <= 0: ...
s233290249
p02612
u284679563
2,000
1,048,576
Wrong Answer
35
9,132
151
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
import sys #DEBUG = True DEBUG = False if DEBUG: f=open("202007_1st/A_input.txt") else: f=sys.stdin N=int(f.readline()) print(N%1000) f.close()
s672723920
Accepted
33
9,172
207
import sys #DEBUG = True DEBUG = False if DEBUG: f=open("202007_1st/A_input.txt") else: f=sys.stdin N=int(f.readline().strip()) R=N%1000 if R==0: print(R) else: print(1000-(N%1000)) f.close()
s292072645
p00001
u247705495
1,000
131,072
Wrong Answer
20
5,596
143
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
mountains = [] for i in range(10): m = int(input()) mountains.append(m) mountains.sort() for i in range(3): print(mountains[i])
s091036030
Accepted
20
5,596
155
mountains = [] for i in range(10): m = int(input()) mountains.append(m) mountains.sort(reverse=True) for i in range(3): print(mountains[i])
s167034018
p03779
u280552586
2,000
262,144
Wrong Answer
17
2,940
85
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be a...
x = int(input()) cnt = 0 i = 1 while cnt >= x: cnt += i i += 1 print(i-1)
s540031649
Accepted
26
2,940
84
x = int(input()) cnt = 0 i = 1 while cnt < x: cnt += i i += 1 print(i-1)
s420007768
p03693
u056599756
2,000
262,144
Wrong Answer
17
2,940
137
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 i...
r,g,b=map(int,input().split()) n=r*100000000+r*10000000+r*1000000+g*100000+g*10000+g*1000+b*100+b*10+b print("Yes" if n%4==0 else "No")
s429341611
Accepted
17
2,940
80
r,g,b=map(int,input().split()) n=r*100+g*10+b print("YES" if n%4==0 else "NO")
s030943225
p02842
u755545520
2,000
1,048,576
Wrong Answer
17
2,940
107
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)....
n=int(input()) for i in range(50000): if int(i*1.08)== n: print(i) break else: print(':(') break
s070754615
Accepted
31
2,940
94
n=int(input()) for i in range(50000): if int(i*1.08)== n: print(i) exit() print(':(')
s802685499
p03853
u167681750
2,000
262,144
Wrong Answer
17
3,060
92
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, p...
h, w = map(int, input().split()) c = [input() for i in range(h)] for i in c*2: print(i)
s822888614
Accepted
18
3,060
92
h, w = map(int, input().split()) for i in range(h): c = input() print(c + "\n" + c)
s938159702
p03547
u620945921
2,000
262,144
Wrong Answer
17
2,940
49
In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`,...
x,y=input().split() print('>' if x < y else '=')
s006421064
Accepted
17
2,940
87
x,y=input().split() if x < y: print('<') elif x > y: print('>') else: print('=')
s750997352
p03643
u104888971
2,000
262,144
Wrong Answer
17
2,940
27
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
N = input() print('ABC',N)
s057229579
Accepted
17
2,940
27
N = input() print("ABC"+N)
s438504928
p04046
u474423089
2,000
262,144
Wrong Answer
138
14,836
499
We have a large square grid with H rows and W columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell. However, she cannot enter the cells in the intersection of the bottom A rows and the leftmost B columns. (That is, there ...
def main(): h,w,a,b=map(int,input().split(' ')) mod = 10**9+7 mx=max(h,w) fac=[1]*(h+w+1) for i in range(1,h+w+1): fac[i]=fac[i-1]*i%mod rev=[1]*(mx+1) rev[-1]=pow(fac[mx],mod-2,mod) for i in range(mx-1,-1,-1): rev[i+1]=rev[i+1]*(i+1)%mod const=rev[h-a-1]*rev[a-1]%mod...
s646453543
Accepted
138
14,836
497
def main(): h,w,a,b=map(int,input().split(' ')) mod = 10**9+7 mx=max(h,w) fac=[1]*(h+w+1) for i in range(1,h+w+1): fac[i]=fac[i-1]*i%mod rev=[1]*(mx+1) rev[-1]=pow(fac[mx],mod-2,mod) for i in range(mx-1,-1,-1): rev[i]=rev[i+1]*(i+1)%mod const=rev[h-a-1]*rev[a-1]%mod ...
s312784576
p02255
u972731768
1,000
131,072
Wrong Answer
20
5,592
355
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key ...
def insertionSort(A,N): for i in range(1,len(A)): v = A[i] j=i-1 while(j>=0 and A[j] > v): A[j+1] = A[j] j-=1 A[j+1]=v print(*A) def main(): print("??°????????\???") A = list(map(int,input().split())) N = len(A) insertionSort(A,N) if ...
s502708898
Accepted
20
5,976
216
N = int(input()) A = list(map(int,input().split())) print( *A ) for i in range(1,N): v = A[i] j = i - 1 while j >= 0 and A [j] > v : A[j + 1] = A[j] j -= 1 A[j + 1] = v print( *A )
s690734465
p02833
u620464724
2,000
1,048,576
Wrong Answer
17
2,940
203
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
n=int(input()) ans=0 if n % 2==1: for i in range(1,19): waru = 2*5**i if n < waru: break else: tmp = n/waru ans += int(tmp) print(str(ans))
s640641741
Accepted
17
2,940
202
n=int(input()) ans=0 if n % 2==0: for i in range(1,10000): waru = 2*5**i if n < waru: break else: tmp = n//waru ans += tmp print(str(ans))
s048539591
p03795
u706414019
2,000
262,144
Wrong Answer
26
9,148
39
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant ...
N = int(input()) print(N*800-200*N//15)
s863599048
Accepted
23
9,116
42
N = int(input()) print(N*800-200*(N//15))
s824968641
p03759
u912862653
2,000
262,144
Wrong Answer
18
2,940
88
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 = list(map(int, input().split())) if a-b==c-b: print('YES') else: print('NO')
s994993029
Accepted
18
2,940
88
a, b, c = list(map(int, input().split())) if b-a==c-b: print('YES') else: print('NO')
s895009774
p03048
u463655976
2,000
1,048,576
Wrong Answer
1,006
2,940
178
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g...
R, G, B, N = map(int, input().split()) ans = 0 for i in range(R): cntR = N - i for j in range(min(cntR, G)): cntG = cntR - j if cntG <= B: ans += 1 print(ans)
s828024798
Accepted
1,353
2,940
192
R, G, B, N = map(int, input().split()) ans = 0 for i in range(N//R+1): cntR = N - i * R for j in range(cntR//G+1): cntG = cntR - j * G if cntG % B == 0: ans += 1 print(ans)
s897210552
p02418
u742505495
1,000
131,072
Wrong Answer
20
5,540
102
Write a program which finds a pattern $p$ in a ring shaped text $s$.
s = str(input()) p = str(input()) case = s + s if p in case == True: print('yes') else: print('no')
s183465759
Accepted
20
5,552
94
s = str(input()) p = str(input()) case = s + s if p in case: print('Yes') else: print('No')
s157853127
p03853
u045953894
2,000
262,144
Wrong Answer
33
9,108
138
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, p...
h,w = map(int,input().split()) c = [] for _ in range(h): c.append(list(input())) for i in range(h): print(*c[i]) print(*c[i])
s671222391
Accepted
38
9,112
154
h,w = map(int,input().split()) c = [] for _ in range(h): c.append(list(input())) for i in range(h): print("".join(c[i])) print("".join(c[i]))
s691088876
p03495
u559367141
2,000
262,144
Wrong Answer
2,206
32,208
296
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 = list(map(int, input().split())) a_list.sort() counter_list = [] for i in range(N): if a_list.count(i) > 0: counter_list.append(a_list.count(i)) counter_list.sort() count = 0 for i in range(len(counter_list) - K): count += i print(count)
s056749895
Accepted
99
32,320
219
N,K = map(int, input().split()) a_list = list(map(int, input().split())) counter_list = [0]*N for i in a_list: counter_list[i-1] += 1 counter_list.sort(reverse=True) ans = N - sum(counter_list[:K]) print(ans)
s392621044
p02612
u696684809
2,000
1,048,576
Wrong Answer
29
9,092
30
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
N = int(input()) print(N%1000)
s473936198
Accepted
30
9,156
70
N = int(input()) a = N%1000 if(a==0): print(a) else: print(1000-a)
s391590161
p03494
u309120194
2,000
262,144
Wrong Answer
26
9,248
226
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
N = int(input()) A = list(map(int, input().split())) count = 0 flag = False while True: for n in range(N): if A[n] % 2 == 0: A[n] = A[n] / 2 else: flag = True break count += 1 if flag: break
s989626766
Accepted
25
9,176
245
N = int(input()) A = list(map(int, input().split())) count = 0 flag = False while True: for n in range(N): if A[n] % 2 != 0: flag = True break if flag: break for n in range(N): A[n] //= 2 count += 1 print(count)
s435029038
p03637
u075303794
2,000
262,144
Wrong Answer
143
38,160
323
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 numpy as np N=int(input()) A=np.array(list(map(int,input().split()))) odd=np.count_nonzero(A%2!=0) four=np.count_nonzero(A%4==0) if odd+four==N: if odd-1<=four: print('Yes') else: print('No') else: if odd==2 and four==2: print('Yes') elif odd+1<=four: print('Yes') else: print('No...
s329984182
Accepted
140
38,044
318
import numpy as np N=int(input()) A=np.array(list(map(int,input().split()))) odd=np.count_nonzero(A%2!=0) four=np.count_nonzero(A%4==0) ans='No' if odd==1 and four>=1: ans='Yes' elif odd==2 and four>=2: ans='Yes' else: if odd+four==N and odd-1<=four: ans='Yes' elif odd<=four: ans='Yes' print(ans)
s817453832
p03779
u547167033
2,000
262,144
Wrong Answer
27
2,940
86
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be a...
x=int(input()) for t in range(1,10**5+1): if t*(t-1)//2>x: print(t-1) exit()
s100250690
Accepted
26
2,940
88
x=int(input()) for t in range(1,10**5+1): if t*(t-1)//2>=x: print(t-1) exit()
s114350233
p03543
u626468554
2,000
262,144
Wrong Answer
17
3,064
351
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
#n = int(input()) #n,k = map(int,input().split()) #x = list(map(int,input().split())) a = list(input()) print(a) if a[0] == a[1] and a[1] == a[2]: print("Yes") elif a[0] == a[1] and a[1] == a[3]: print("Yes") elif a[0] == a[2] and a[2] == a[3]: print("Yes") elif a[2] == a[1] and a[1] == a[3]: prin...
s466765118
Accepted
17
3,060
243
#n = int(input()) #n,k = map(int,input().split()) #x = list(map(int,input().split())) a = list(input()) if (a[0] == a[1]) and (a[1] == a[2]): print("Yes") elif (a[2] == a[1]) and (a[1] == a[3]): print("Yes") else: print("No")
s764885863
p02409
u498462680
1,000
131,072
Wrong Answer
20
5,640
1,057
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 fl...
sharpNum = 20 roomNum = 10 height = 15 dataNum = int(input()) #building = [[0]*sharpNum] * height building = [[0] * sharpNum for i in range(height)] actRoom = 0 for data in range(dataNum): b,f,r,v = map(int, input().split()) for floor in range(height): if floor%4 == 3: for room in range(shar...
s907332415
Accepted
40
5,648
1,026
sharpNum = 20 roomNum = 10 height = 15 dataNum = int(input()) #building = [[0]*sharpNum] * height building = [[0] * sharpNum for i in range(height)] for data in range(dataNum): actBuilding = 1 actRoom = 0 actFloor = 0 b,f,r,v = map(int, input().split()) for floor in range(height): actRoom =...
s620324329
p03574
u749491107
2,000
262,144
Wrong Answer
40
9,100
566
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square con...
h, w = map(int, input().split()) s = [list(input()) for _ in range(h)] for i in range(h): for j in range(w): if s[i][j] == ".": c = 0 for x in range(-1, 2): for y in range(-1, 2): if x == 0 and y == 0: break ...
s712215528
Accepted
36
9,228
569
h, w = map(int, input().split()) s = [list(input()) for _ in range(h)] for i in range(h): for j in range(w): if s[i][j] == ".": c = 0 for x in range(-1, 2): for y in range(-1, 2): if x == 0 and y == 0: continue ...
s852008887
p02390
u231369830
1,000
131,072
Wrong Answer
20
5,584
139
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()) m = 0 h = 0 if s >= 60: m = int(s / 60) s = s % 60 if m >= 60: h = int(m / 60) m = m % 60 print(h,m,s)
s312152449
Accepted
20
5,592
173
s = int(input()) m = 0 h = 0 if s >= 60: m = int(s / 60) s = s % 60 if m >= 60: h = int(m / 60) m = m % 60 print(h,end = ":") print(m,end = ":") print(s)
s023190347
p03852
u036190609
2,000
262,144
Wrong Answer
17
2,940
94
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
komoji = input() if komoji in "aeiou" == True: print("vowel") else: print("consonant")
s115701842
Accepted
17
2,940
76
s = input() if s in "aeiou": print("vowel") else: print("consonant")
s704436802
p03054
u667084803
2,000
1,048,576
Wrong Answer
1,176
14,640
665
We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, there is a piece, which is initially placed at square (s_r,s_c). Takahashi and Aoki will play a game, where each player has a st...
H, W, N = map(int, input().split()) sr, sc = map(int, input().split()) S = input() T = input() flag = 0 hidari = sc migi = sc ue = sr shita = sr for i in range(N): print(hidari,migi,ue,shita) if S[i] == 'L': hidari -= 1 if S[i] == 'R': migi += 1 if S[i] == 'U': ue -= 1 if S[i] == 'D': shita +...
s745695693
Accepted
230
3,788
606
H, W, N = map(int, input().split()) sr, sc = map(int, input().split()) S = input() T = input() flag = 0 hidari = sc migi = sc ue = sr shita = sr for i in range(N): if S[i] == 'L': hidari -= 1 if S[i] == 'R': migi += 1 if S[i] == 'U': ue -= 1 if S[i] == 'D': shita += 1 if hidari == 0 or migi =...
s865854254
p04029
u393581926
2,000
262,144
Wrong Answer
18
3,060
32
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
n=int(input()) print(n*(n+1)/2)
s620376083
Accepted
18
2,940
33
n=int(input()) print(n*(n+1)//2)
s299126715
p03415
u470286613
2,000
262,144
Wrong Answer
17
2,940
47
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 bot...
for i in range(3): print(input()[i],sep='')
s307571915
Accepted
17
2,940
50
s='' for i in range(3): s+=input()[i] print(s)
s639062368
p03129
u591779169
2,000
1,048,576
Wrong Answer
17
3,060
150
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
n, k = map(int, input().split()) sum = 0 for i in range (1, n-1): sum = sum + i print(sum) if k >= sum: print("YES") else: print("NO")
s153244565
Accepted
17
2,940
100
n, k = map(int, input().split()) num = n/2+ 0.5 if num >= k: print("YES") else: print("NO")
s547808074
p04043
u193657135
2,000
262,144
Wrong Answer
17
2,940
104
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each ...
ABC = list(map(int, input().split())) if sorted(ABC) == [5,5,7]: print("Yes") else: print("No")
s748779358
Accepted
17
2,940
134
A,B,C = map(int, input().split()) ABC = [A,B,C] if sorted(ABC) == [5,5,7]: print("YES") else: print("NO")
s807965056
p03473
u010437136
2,000
262,144
Wrong Answer
17
2,940
47
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
def time(x): return 48-int(x) time(input())
s573605479
Accepted
17
2,940
34
a = input() x = int(a) print(48-x)
s296282477
p03563
u178432859
2,000
262,144
Wrong Answer
17
2,940
44
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 cont...
a = int(input()) b = int(input()) print(b-a)
s286090601
Accepted
21
3,316
46
a = int(input()) b = int(input()) print(2*b-a)
s100178467
p02388
u517275798
1,000
131,072
Wrong Answer
20
5,576
52
Write a program which calculates the cube of a given integer x.
s = input() n = int(s)**3 print('x =', s,'x^3=', n)
s816353805
Accepted
20
5,572
30
x = int(input()) print(x*x*x)
s783237445
p03657
u969848070
2,000
262,144
Wrong Answer
26
9,092
192
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them ca...
a, b = map(int, input().split()) if a + b % 3 == 0: print('Possible') exit() elif a % 3 == 0: print('Possible') exit() elif b % 3 == 0: print('Possible') exit() print('Impossible')
s140262302
Accepted
28
9,172
194
a, b = map(int, input().split()) if (a + b) % 3 == 0: print('Possible') exit() elif a % 3 == 0: print('Possible') exit() elif b % 3 == 0: print('Possible') exit() print('Impossible')
s833359792
p03575
u131634965
2,000
262,144
Wrong Answer
25
3,064
1,234
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i. An edge whose removal disconnects the graph is called a _bridge_. Find the number of the edges that are bridges among the M ...
def dfs(x): if visited[x]: return visited[x] = True for i in range(N): if graph[x][i]: dfs(i) N, M = map(int, input().split()) edge = [] graph = [[False]*N for _ in range(N)] visited = [False]*N for i in range(M): a, b = map(int, input().split()) edge.app...
s588784059
Accepted
26
3,188
1,170
def dfs(x): if visited[x]: return visited[x] = True for i in range(N): if graph[x][i]: dfs(i) N, M = map(int, input().split()) edge = [] graph = [[False]*N for _ in range(N)] visited = [False]*N for i in range(M): a, b = map(int, input().split()) edge.app...
s644503535
p03737
u312078744
2,000
262,144
Wrong Answer
17
2,940
103
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
a, b, c = map(str, input().split()) A = a[0] B = b[0] C = c[0] ans = A.upper() + B.upper() + C.upper()
s107832873
Accepted
17
2,940
114
a, b, c = map(str, input().split()) A = a[0] B = b[0] C = c[0] ans = A.upper() + B.upper() + C.upper() print(ans)
s431690296
p03693
u840310460
2,000
262,144
Wrong Answer
17
2,940
95
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 i...
x = input().split() xx = int("".join(x)) if xx % 4 == 0: print("Yes") else: print("No")
s490072446
Accepted
18
2,940
95
x = input().split() xx = int("".join(x)) if xx % 4 == 0: print("YES") else: print("NO")
s090239443
p00026
u964040941
1,000
131,072
Wrong Answer
30
7,680
711
As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (x, y) coordinate system. We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as sho...
import sys paper = [[0] * 10 for i in range(10)] for line in sys.stdin: x,y,s = map(int,line.split(',')) for i in range(10): for j in range(10): if s == 1: if abs(i - y) + abs(j - x) <= 1: paper [i] [j] += 1 if s == 2: if abs(...
s426531926
Accepted
30
7,728
676
paper = [[0] * 10 for i in range(10)] while True: try: x,y,s = map(int,input().split(',')) except: break if s == 1: for i in range(10): for j in range(10): if abs(x - i) + abs(y - j) <= 1: paper [i] [j] += 1 elif s == 2: fo...
s373366789
p02601
u008464939
2,000
1,048,576
Wrong Answer
127
27,168
328
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 successfu...
import numpy as np A = [int(x) for x in input().split()] src = np.array(A) K = int(input()) flag = 0 for i in range(K): if(src[0] < src[1]): if(src[1] < src[2]): flag = 1 break else: src[2] *= 2 else: src[1] *= 2 if(src[0] < src[1]): if(src[1] < src[2]): print("yes") else: pri...
s423341661
Accepted
121
27,116
355
import numpy as np A = [int(x) for x in input().split()] src = np.array(A) K = int(input()) flag = 0 for i in range(K): if(src[0] < src[1]): if(src[1] < src[2]): flag = 1 break else: src[2] *= 2 else: src[1] *= 2 if(src[0] < src[1]): if(src[1] < src[2]): print("Yes") else: p...
s825981362
p02399
u896025703
1,000
131,072
Wrong Answer
20
7,632
78
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
a, b = map(int, input().split()) d = a // b r = a % b f = a / b print(d, r, f)
s550115892
Accepted
30
7,640
95
a, b = map(int, input().split()) d = a // b r = a % b f = a / b print(d, r, "{:.5f}".format(f))
s919059324
p03997
u483151310
2,000
262,144
Wrong Answer
18
2,940
68
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a = int(input()) b = int(input()) h = int(input()) print((a+b)*h/2)
s117895471
Accepted
19
2,940
86
a = int(input()) b = int(input()) h = int(input()) calc = int((a+b)*h/2) print(calc)
s805658028
p03131
u668503853
2,000
1,048,576
Wrong Answer
17
2,940
87
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the ...
K,A,B=map(int,input().split()) if B-A<=2: print(K+1) else: print(max(0,K-(A-1)//2))
s666642946
Accepted
17
2,940
113
K,A,B=map(int,input().split()) if K+1>=A and A+2<=B: print(((K+1)-A)//2*(B-A)+A+((K+1)-A)%2) else: print(K+1)
s358460458
p03574
u146346223
2,000
262,144
Wrong Answer
31
3,188
577
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square con...
H, W = map(int, input().split()) s = [list(input()) for _ in range(H)] for i in range(H): for j in range(W): if s[i][j] == '.': count = 0 for dx, dy in ( (-1,1), (0,1), (1,0), (-1,0), (0,0), (0,1), (-1,-1),(0,-1),(1,-1) ): ...
s910480131
Accepted
29
3,188
577
H, W = map(int, input().split()) s = [list(input()) for _ in range(H)] for i in range(H): for j in range(W): if s[i][j] == '.': count = 0 for dx, dy in ( (-1,1), (0,1), (1,1), (-1,0), (0,0), (1,0), (-1,-1),(0,-1),(1,-1) ): ...
s201573834
p03545
u483304397
2,000
262,144
Wrong Answer
17
3,064
593
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 in...
S = input() sumS = int(S[0]) + int(S[1]) + int(S[2]) + int(S[3]) def minus(a, sumS): sS = sumS ba = bin(a) for ia,aa in enumerate(ba[::-1]): if aa == 'b': break elif aa == '1': sS -= 2 * int(S[ia+1:ia+2]) if sS == 7: print(ba) T = ['+', '+', '+', ...
s321528548
Accepted
17
3,064
575
S = input() sumS = int(S[0]) + int(S[1]) + int(S[2]) + int(S[3]) def minus(a, sumS): sS = sumS ba = bin(a) for ia,aa in enumerate(ba[::-1]): if aa == 'b': break elif aa == '1': sS -= 2 * int(S[ia+1:ia+2]) if sS == 7: T = ['+', '+', '+', '=7'] for ...
s192514155
p02612
u306412379
2,000
1,048,576
Wrong Answer
27
9,108
40
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
N = int(input()) print(N - N//1000*1000)
s520774799
Accepted
27
9,136
56
N = int(input()) a = (N + 1000 -1)//1000 print(a*1000-N)
s471563716
p02613
u131453093
2,000
1,048,576
Wrong Answer
142
9,140
177
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`,...
N = int(input()) test = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0} for _ in range(N): s = input() test[s] += 1 for i, j in test.items(): print("{} × {}".format(i, j))
s002808377
Accepted
145
9,180
178
N = int(input()) test = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0} for _ in range(N): s = input() test[s] += 1 for i, j in test.items(): print("{} x {}".format(i, j))
s017353267
p03997
u239342230
2,000
262,144
Wrong Answer
18
2,940
61
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a=int(input()) b=int(input()) c=int(input()) print((a+b)*c/2)
s126663784
Accepted
19
2,940
66
a=int(input()) b=int(input()) c=int(input()) print(int((a+b)*c/2))
s357967658
p03089
u918845030
2,000
1,048,576
Wrong Answer
21
3,440
493
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N oper...
def find(n): tn = int(n/2) s = 2 * tn + 1 count = 0 line_list = [] for i in range(1, n+1): for j in range(i+1, n+1): if i + j != s: line_list.append(str(i) + " " + str(j)) count +=1 return count, line_list if __name__ == '__main__': ...
s090357211
Accepted
17
3,064
488
def find(sequence): result_list = [] for i in range(len(sequence)): for j in reversed(list(range(len(sequence)))): if sequence[j] == j + 1: result_list.append(sequence.pop(j)) break if len(sequence) != 0: return [-1] return result_list if __n...
s222847649
p03359
u776871252
2,000
262,144
Wrong Answer
17
2,940
78
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For ...
a, b = map(int, input().split()) ans = a if b <= a: ans -= 1 print(ans)
s289914422
Accepted
17
2,940
77
a, b = map(int, input().split()) ans = a if b < a: ans -= 1 print(ans)
s772294498
p03545
u941884460
2,000
262,144
Wrong Answer
18
3,064
767
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 in...
import sys x = input() A = int(x[0]) B = int(x[1]) C = int(x[2]) D = int(x[3]) work = A op1,op2,op3 = "","","" for i in range(2): for j in range(2): for k in range(2): if i == 1: op1 = "+" work += B else: op1 = "-" wo...
s023417498
Accepted
17
3,064
772
import sys x = input() A = int(x[0]) B = int(x[1]) C = int(x[2]) D = int(x[3]) work = A op1,op2,op3 = "","","" for i in range(2): for j in range(2): for k in range(2): if i == 1: op1 = "+" work += B else: op1 = "-" wo...
s741511927
p03067
u297756089
2,000
1,048,576
Wrong Answer
17
2,940
118
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
a,b,c=map(int,input().split()) if a<=b and b<=c: print("Yes") elif a>=b and b>=c: print("Yes") else: print("No")
s495994573
Accepted
17
2,940
119
a,b,c=map(int,input().split()) if a<=c and c<=b: print("Yes") elif a>=c and c>=b: print("Yes") else: print("No")
s502626931
p02396
u499005012
1,000
131,072
Wrong Answer
110
6,720
109
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are give...
i = 0 while True: v = input() if v == '0': break print('Case %d: %s' % (i, v)) i += 1
s436764588
Accepted
120
6,724
109
i = 0 while True: i += 1 v = input() if v == '0': break print('Case %d: %s' % (i, v))
s083870222
p02393
u389610071
1,000
131,072
Wrong Answer
30
6,724
277
Write a program which reads three integers, and prints them in ascending order.
nums = input().split() a = int(nums[0]) b = int(nums[0]) c = int(nums[0]) if a < b < c: print(a, b, c) elif a < c < b: print(a, c, b) elif b < a < c: print(b, a, c) elif b < c < a: print(b, c, a) elif c < a < b: print(c, a, b) else: print(c, b, a)
s823707254
Accepted
30
6,724
287
nums = input().split() a = int(nums[0]) b = int(nums[1]) c = int(nums[2]) if a <= b <= c: print(a, b, c) elif a <= c <= b: print(a, c, b) elif b <= a <= c: print(b, a, c) elif b <= c <= a: print(b, c, a) elif c <= a <= b: print(c, a, b) else: print(c, b, a)
s741294507
p02742
u190873802
2,000
1,048,576
Wrong Answer
18
2,940
113
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 to...
import math a,b=map(int,input().split()) c=a*b if c%2==0: d = c/2 else: d = math.floor(c/2) + 1 print(d)
s350088122
Accepted
18
2,940
106
import math H,W=map(int, input().split()) if H==1 or W==1: print(1) else: print(math.ceil(H*W/2))
s333804587
p03251
u570121126
2,000
1,048,576
Wrong Answer
17
3,064
229
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes incli...
f=input().split() (n,m,x,y)=(int(f[0]),int(f[1]),int(f[2]),int(f[3])) ax=[int(i) for i in input().split()] ay=[int(i) for i in input().split()] ax.sort() ay.sort() b=ay[0]-ax[-1] if b>1: print("No War") else: print("War")
s223962491
Accepted
17
3,064
370
f=input().split() (n,m,x,y)=(int(f[0]),int(f[1]),int(f[2]),int(f[3])) ax=[int(i) for i in input().split()] ay=[int(i) for i in input().split()] ax.sort() ay.sort() b=ay[0]-ax[-1] c=0 if x<ax[-1] and y>ax[-1]: c=1 elif x>ax[-1] and x<ay[0] and y<ay[0]: c=1 elif x>ax[-1] and y>ay[0] and x<ay[0]: c=1 if b>0 an...
s868447625
p02869
u923270446
2,000
1,048,576
Wrong Answer
136
9,264
571
Given are positive integers N and K. Determine if the 3N integers K, K+1, ..., K+3N-1 can be partitioned into N triples (a_1,b_1,c_1), ..., (a_N,b_N,c_N) so that the condition below is satisfied. Any of the integers K, K+1, ..., K+3N-1 must appear in exactly one of those triples. * For every integer i from 1 to N, ...
n, k = map(int, input().split()) if 2 * k > n + 1: exit(print(-1)) else: if n % 2 == 0: for i in range(n): if i % 2 == 0: print(i // 2 + k, (i + n * 3) // 2, i + n * 2 + k, end=" ") else: print(i // 2 + n // 2 + k, i // 2 + n + k, i + n * 2 + k, en...
s826606168
Accepted
138
9,204
543
n, k = map(int, input().split()) if 2 * k > n + 1: exit(print(-1)) else: if n % 2 == 0: for i in range(n): if i % 2 == 0: print(k + i // 2, k + (i + n * 3) // 2, k + i + n * 2) else: print(k + i // 2 + n // 2, k + i // 2 + n, k + i + n * 2) els...
s398323374
p02613
u137962336
2,000
1,048,576
Wrong Answer
143
16,152
206
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`,...
N = int(input()) S = [input() for i in range(N)] print('AC' + 'x' + str(S.count('AC'))) print('WA' + 'x' + str(S.count('WA'))) print('TLE' + 'x' + str(S.count('TLE'))) print('RE' + 'x' + str(S.count('RE')))
s401964963
Accepted
138
16,276
217
N = int(input()) S = [input() for i in range(N)] print('AC' + ' x ' + str(S.count('AC'))) print('WA' + ' x ' + str(S.count('WA'))) print('TLE' + ' x ' + str(S.count('TLE'))) print('RE' + ' x ' + str(S.count('RE')))
s393104129
p02646
u112629957
2,000
1,048,576
Wrong Answer
25
9,164
129
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 ...
A,V=map(int,input().split()) B,W=map(int,input().split()) T=int(input()) if (V-W)*T>=abs(A-B): print("Yes") else: print("No")
s697056211
Accepted
22
9,164
130
A,V=map(int,input().split()) B,W=map(int,input().split()) T=int(input()) if (V-W)*T>=abs(A-B): print("YES") else: print("NO")
s346624719
p03385
u560135121
2,000
262,144
Wrong Answer
17
2,940
59
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
abc=sorted(input()) print(["NO","YES"][abc==["a","b","c"]])
s283124628
Accepted
17
2,940
59
abc=sorted(input()) print(["No","Yes"][abc==["a","b","c"]])
s776748282
p03599
u658993896
3,000
262,144
Wrong Answer
21
3,064
521
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the bea...
A = list(map(int,input().split())) water = {} for i in range(A[5]//(100*A[0])+1): for j in range((A[5]-i*A[0]*100)//(100*A[1])+1): water[100*(A[0]*i+A[1]*j)]=1 water.pop(0) print(water) ans = [0, 0] max_ = 0 for w in water.keys(): for c in range((w//100*A[4])//A[2]+1): d = ((w//100*A[4])-c*A[2...
s685733750
Accepted
20
3,064
568
A = list(map(int,input().split())) water = {} for i in range(A[5]//(100*A[0])+1): for j in range((A[5]-i*A[0]*100)//(100*A[1])+1): water[100*(A[0]*i+A[1]*j)]=1 water.pop(0) ans = [100*A[0], 0] max_ = -1 for w in water.keys(): for c in range(min((w//100*A[4])//A[2]+1,(A[5]-w)//A[2]+1)): d = mi...
s596417597
p04029
u185331085
2,000
262,144
Wrong Answer
17
2,940
39
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
N = int(input()) S = N*N/2+N/2 print(S)
s788943423
Accepted
20
2,940
44
N = int(input()) S = int(N*N/2+N/2) print(S)
s509574093
p03555
u556371693
2,000
262,144
Wrong Answer
17
2,940
93
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
a,b,c=input() d,e,f=input() if a==f and b==e and c==d: print("Yes") else: print("No")
s248267703
Accepted
17
2,940
93
a,b,c=input() d,e,f=input() if a==f and b==e and c==d: print("YES") else: print("NO")
s592491152
p02663
u518085378
2,000
1,048,576
Wrong Answer
23
9,148
71
In this problem, we use the 24-hour clock. Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying?
h, m, h2, m2, k = map(int, input().split()) print(12*h2+m2-(12*h+m+k))
s555995525
Accepted
24
9,148
71
h, m, h2, m2, k = map(int, input().split()) print(60*h2+m2-(60*h+m+k))
s677080672
p02612
u690833702
2,000
1,048,576
Wrong Answer
27
8,988
80
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
import math def main(): N = int(input()) print(N % 1000) main()
s270329816
Accepted
28
9,136
136
import math def main(): N = int(input()) if N % 1000 == 0: print(0) return print(1000 - (N % 1000)) main()
s276280630
p03485
u266171694
2,000
262,144
Wrong Answer
17
2,940
50
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))
s423839535
Accepted
17
2,940
56
a, b = map(int, input().split()) print((a + b + 1) // 2)
s254728698
p03563
u695079172
2,000
262,144
Wrong Answer
18
2,940
58
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 cont...
r = int(input()) g = int(input()) print((r + (g - r))//2)
s312927786
Accepted
17
2,940
60
r = int(input()) g = int(input()) sa = g - r print(g + sa)
s820174018
p03854
u767797498
2,000
262,144
Wrong Answer
34
9,116
127
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
s=input() lst=["eraser","erase","dreamer","dream",] for e in lst: s=s.replace(e,"") print(s) print("YES" if s=="" else "NO")
s785495804
Accepted
29
9,104
119
s=input() lst=["eraser","erase","dreamer","dream",] for e in lst: s=s.replace(e,"") print("YES" if s=="" else "NO")
s625370013
p03193
u023229441
2,000
1,048,576
Wrong Answer
20
3,060
120
There are N rectangular plate materials made of special metal called AtCoder Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically and B_i horizontally). Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are exactly H \times W. He is trying to obtain such a plate by cho...
n,H,W=map(int,input().split()) p=0 for i in range(n): a,b=map(int,input().split()) if a>=H & b>=W: p+=1 print(p)
s592909625
Accepted
20
3,060
123
n,H,W=map(int,input().split()) p=0 for i in range(n): a,b=map(int,input().split()) if a>=H and b>=W: p+=1 print(p)
s820857877
p03485
u753682919
2,000
262,144
Wrong Answer
17
2,940
54
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
a,b=map(int,input().split()) x=(a+b)/2 print(int(x)+1)
s858075500
Accepted
17
2,940
87
a,b=map(int,input().split()) x=(a+b)/2 if (a+b)%2==0: n=0 else: n=1 print(int(x)+n)
s947195741
p03557
u924406834
2,000
262,144
Wrong Answer
510
23,360
324
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower. He has N parts for each of the three categories. The size of the i-th upper ...
import bisect n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) a.sort() c.sort() ans = 0 for i in range(n): a_num = bisect.bisect_left(a,b[i]) c_num = n - bisect.bisect_right(c,b[i]) print(a_num,c_num) ans += c_num * a_num print(...
s954428854
Accepted
383
23,360
301
import bisect n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) a.sort() c.sort() ans = 0 for i in range(n): a_num = bisect.bisect_left(a,b[i]) c_num = n - bisect.bisect_right(c,b[i]) ans += c_num * a_num print(ans)
s093350155
p02601
u130074358
2,000
1,048,576
Wrong Answer
29
9,196
307
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 successfu...
X = list(map(int,input().split())) A = X[0] B = X[1] C = X[2] K = int(input()) cnt = 0 if A > B: for i in range(K): B = B*2 cnt = cnt + 1 if A < B: break if B > C: for j in range(K): C = C*2 cnt = cnt + 1 if B < C: break if cnt <= K: print('YES') else: print('NO')
s868759364
Accepted
32
9,192
301
X = list(map(int,input().split())) A = X[0] B = X[1] C = X[2] K = int(input()) cnt = 0 if A >= B: for i in range(7): B = B*2 cnt = cnt + 1 if A < B: break if B >= C: for j in range(7): C = C*2 cnt = cnt + 1 if B < C: break if cnt <= K: print('Yes') else: print('No')
s883580902
p03693
u772649753
2,000
262,144
Wrong Answer
17
2,940
93
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 i...
l = list(input().split()) x = int(l[1]+l[2]) if x//4 == 0: print("YES") else: print("NO")
s372613929
Accepted
17
2,940
92
l = list(input().split()) x = int(l[1]+l[2]) if x%4 == 0: print("YES") else: print("NO")
s217230828
p03814
u197300260
2,000
262,144
Wrong Answer
30
3,816
603
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends w...
# _*_ coding:utf-8 _*_ def atozString(dataStr) : rangeFirstToEnd = range(0,len(dataStr),1) rangeEndToFirst = range(len(dataStr)-1,-1,-1) firstA = 0 lastZ = len(dataStr) for i in rangeFirstToEnd: if dataStr[i] == 'A': firstA = i break for i in rangeEndToFirst: if dataStr[i] == 'Z': lastZ = i b...
s575293171
Accepted
23
4,012
459
# Python 3rd Try import copy def solver(givenstring): result = 0 usestrA = copy.copy(givenstring) usestrZ = copy.copy(givenstring) # a position apos = usestrA.index('A')+1 usestrrevZ = usestrZ[::-1] zpos = len(givenstring) - usestrrevZ.index('Z') result = zpos - apos + 1 return result...
s263485260
p02283
u935184340
2,000
131,072
Wrong Answer
30
7,492
1,361
Search trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue. Binary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to sat...
import sys class Node(): def __init__(self,key): self.key = key self.left = None self.right = None def insert(t, z): y = None x = t while x is not None: y = x if z.key < x.key: x = x.left else: x = x.right if y is None: ...
s158143021
Accepted
6,830
152,012
1,368
import sys class Node(): def __init__(self,key): self.key = key self.left = None self.right = None def insert(t, z): y = None x = t while x is not None: y = x if z.key < x.key: x = x.left else: x = x.right if y is None:...
s686687256
p03149
u457460736
2,000
1,048,576
Wrong Answer
25
9,084
140
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".
N=list(map(int,input().split())) if(N.count(1)==1 and N.count(9)==1 and N.count(7)==1 and N.count(4)==1): print("Yes") else: print("No")
s627355475
Accepted
29
9,064
141
N=list(map(int,input().split())) if(N.count(1)==1 and N.count(9)==1 and N.count(7)==1 and N.count(4)==1): print("YES") else: print("NO")
s624663529
p03644
u994767958
2,000
262,144
Wrong Answer
17
2,940
216
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can...
import sys sys.setrecursionlimit(10**6) def f(n): if n == 1: return True elif n%2 == 0: return f(n/2) else: return False n = int(input()) for i in range(n,0,-1): if f(n): print(i) break
s300015948
Accepted
18
2,940
216
import sys sys.setrecursionlimit(10**6) def f(n): if n == 1: return True elif n%2 == 0: return f(n/2) else: return False n = int(input()) for i in range(n,0,-1): if f(i): print(i) break
s110673068
p03796
u409064224
2,000
262,144
Wrong Answer
17
2,940
45
Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
n = int(input()) n *= 6 print(n%1000000007)
s716385014
Accepted
43
3,064
103
n = int(input()) res = 1 for i in range(1,n+1): res *= i res %= (10**9+7) else: print(res)
s577145814
p03721
u698771758
2,000
262,144
Wrong Answer
373
15,072
249
There is an empty array. The following N operations will be performed to insert integers into the array. In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array. Find the K-th smallest integer in the array after the N operations. For example, the 4-th smallest integer in the array \\{1,2...
N,K=map(int,input().split()) ans={} for i in range(N): a,b=map(int,input().split()) if a in ans:ans[a]+=b else :ans[a]=b ans=sorted(ans.items(),key=lambda x:x[0]) print(ans) for key,value in ans: K-=value if K<=0:break print(key)
s988489995
Accepted
344
15,076
238
N,K=map(int,input().split()) ans={} for i in range(N): a,b=map(int,input().split()) if a in ans:ans[a]+=b else :ans[a]=b ans=sorted(ans.items(),key=lambda x:x[0]) for key,value in ans: K-=value if K<=0:break print(key)
s598113521
p02927
u227085629
2,000
1,048,576
Wrong Answer
20
2,940
145
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...
m,d = map(int,input().split()) ans = 0 for i in range(1,d+1): a = i%10 b = i//10 if a >= 2 and b >= 2 and a*b == m: ans += 1 print(ans)
s454438149
Accepted
17
2,940
145
m,d = map(int,input().split()) ans = 0 for i in range(1,d+1): a = i%10 b = i//10 if a >= 2 and b >= 2 and a*b <= m: ans += 1 print(ans)
s053267742
p02833
u771524928
2,000
1,048,576
Wrong Answer
18
3,060
228
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
#import numpy as np def cin(): return map(int, input().split()) n = int(input()) print(n) cnt = 0 if n % 2 == 1: print(0) exit(0) div = 1 n //= 2 for i in range(33): div *= 5 cnt += n // div print(cnt)
s807345211
Accepted
18
2,940
219
#import numpy as np def cin(): return map(int, input().split()) n = int(input()) cnt = 0 if n % 2 == 1: print(0) exit(0) div = 1 n //= 2 for i in range(33): div *= 5 cnt += n // div print(cnt)
s389226772
p03992
u461636820
2,000
262,144
Wrong Answer
17
2,940
45
This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the fi...
s = 'codefextival' print(s[:4] + ' ' + s[4:])
s879406721
Accepted
17
2,940
39
s = input() print(s[0:4] + ' ' + s[4:])
s593942559
p03860
u045408189
2,000
262,144
Wrong Answer
17
2,940
29
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppe...
s=input() print('A'+s[7]+'C')
s623734199
Accepted
17
2,940
30
s=input() print('A'+s[8]+'C')
s177573272
p03637
u787449825
2,000
262,144
Wrong Answer
80
14,636
461
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.
from collections import deque def f(x): return num.count(x) n = int(input()) a = list(map(int, input().split())) num = deque([]) for i in a: if i%4==0: num.append(4) elif i%2==0: num.append(2) else: num.append(0) print(num) if len(a)%2==1: if f(4)>=len(a)//2 or f(2)>=2*(n/...
s731471912
Accepted
71
14,636
451
from collections import deque def f(x): return num.count(x) n = int(input()) a = list(map(int, input().split())) num = deque([]) for i in a: if i%4==0: num.append(4) elif i%2==0: num.append(2) else: num.append(0) if len(a)%2==1: if f(4)>=len(a)//2 or f(2)>=2*(n//2-f(4))+1:...