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
s246605963
p03469
u462214100
2,000
262,144
Wrong Answer
17
2,940
33
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.
s = input() print('2018' + s[:4])
s180620982
Accepted
17
2,940
38
s = input() print('2018/01/' + s[-2:])
s028590881
p02608
u699944218
2,000
1,048,576
Wrong Answer
2,206
8,796
307
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
import math N = int(input()) n = int(math.sqrt(N)) ans = [0 for _ in range(N)] for i in range(N): for x in range(n): for y in range(n): for z in range(n): if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * y == N: ans[i] += 1 for i in range(N): print(ans[i])
s494238630
Accepted
800
9,244
279
N = int(input()) ans = [0 for i in range(10100)] for x in range(1,100): for y in range(1,100): for z in range(1,100): n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x if n < 10100: ans[n] += 1 for n in range(N): print(ans[n+1])
s069904330
p02612
u854294899
2,000
1,048,576
Wrong Answer
27
9,128
32
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
n = int(input()) print(n % 1000)
s956955132
Accepted
31
9,148
75
n = int(input()) res = n % 1000 if (res > 0): res = 1000 - res print(res)
s037953869
p03377
u439392790
2,000
262,144
Wrong Answer
17
2,940
80
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 X-A<=B: print('Yes') else: print('No')
s815269560
Accepted
17
2,940
90
A,B,X=map(int,input().split()) if X-A<=B and A<=X: print('YES') else: print('NO')
s527550948
p03369
u486302338
2,000
262,144
Wrong Answer
18
2,940
68
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
S = input() cnt = 0 for s in S: cnt += 1 print(700 + 100 * cnt)
s572596373
Accepted
17
2,940
83
S = input() cnt = 0 for s in S: if s == 'o': cnt += 1 print(700 + 100 * cnt)
s753290467
p03469
u735008991
2,000
262,144
Wrong Answer
17
2,940
28
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.
print('2018' + input()[:4])
s723290732
Accepted
17
2,940
28
print('2018' + input()[4:])
s499864404
p03657
u674934587
2,000
262,144
Wrong Answer
28
9,016
95
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
a,b=map(int,input().split()) if (a+b)%2==0: print("Possible") else: print("Impossible")
s203520606
Accepted
27
9,076
111
a,b=map(int,input().split()) if a%3==0 or b%3==0 or (a+b)%3==0: print("Possible") else: print("Impossible")
s622538910
p03845
u617515020
2,000
262,144
Wrong Answer
24
9,200
266
Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.
n=int(input()) t=list(map(int,input().split())) m=int(input()) px=[] for _ in range(m): p,x=map(int,input().split()) px.append((p-1,x-1)) for i in range(m): ans=0 p,x=px[i] for j in range(n): if j==p: ans+=x else: ans+=t[j] print(ans)
s451315039
Accepted
23
9,148
264
n=int(input()) t=list(map(int,input().split())) m=int(input()) px=[] for _ in range(m): p,x=map(int,input().split()) px.append((p-1,x)) for i in range(m): ans=0 p,x=px[i] for j in range(n): if j==p: ans+=x else: ans+=t[j] print(ans)
s939907523
p03080
u482157295
2,000
1,048,576
Wrong Answer
18
3,060
187
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
import math N = int(input()) s = input() count = 0 for i in s: if i == "R": count = count + 1 if count > math.floor(N//2): print("yes") else: print("No")
s444420214
Accepted
17
2,940
175
import math N = int(input()) s = input() count = 0 for i in s: if i == "R": count = count + 1 if count > N//2: print("Yes") else: print("No")
s570408474
p03854
u448659077
2,000
262,144
Wrong Answer
82
3,672
295
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`.
#ABC049 s = input() while len(s) != 0: if s[-5:] == "dream": s = s[:-5] elif s[-7:] == "dreamer": s = s[:-7] elif s[-5:] == "erase": s = s[:-5] elif s[-6:] == "eraser": s = s[:-6] else: print("NO") break print("YES")
s284831868
Accepted
68
3,188
301
#ABC049 s = input() while len(s) != 0: if s[-5:] == "dream": s = s[:-5] elif s[-7:] == "dreamer": s = s[:-7] elif s[-5:] == "erase": s = s[:-5] elif s[-6:] == "eraser": s = s[:-6] else: print("NO") break else: print("YES")
s725559517
p03474
u977389981
2,000
262,144
Wrong Answer
21
2,940
217
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
a, b = map(int, input().split()) S = input() ans = 'Yes' if S[a + 1] == '-': S = S.replace('-', '', 1) for i in S: if not i in '1234567890': ans = 'No' else: ans = 'No' print(ans)
s613266311
Accepted
17
3,064
166
a, b = map(int, input().split()) s = input() ans = 'No' if s[a] == '-': if s[: a].isdecimal() and s[a + 1 :].isdecimal(): ans = 'Yes' print(ans)
s645778926
p03693
u253011685
2,000
262,144
Wrong Answer
17
2,940
85
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
r,g,b=(input().split()) N=int(r+g+b) if(N%4==0): print('Yes') else: print('No')
s253159569
Accepted
17
2,940
85
r,g,b=(input().split()) N=int(r+g+b) if(N%4==0): print('YES') else: print('NO')
s487232506
p03909
u021916304
2,000
262,144
Wrong Answer
17
3,060
230
There is a grid with H rows and W columns. The square at the i-th row and j-th column contains a string S_{i,j} of length 5. The rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from `A` through the W-th letter of the alphabet. Exactly one of the squares in the grid contains the string `snuke`. Find this square and report its location. For example, the square at the 6-th row and 8-th column should be reported as `H6`.
alpha = 'abcdefghijklmnopqrstuvwxyz' h,w = map(int,input().split()) for i in range(h): A = list(map(str,input().split())) for j in range(w): if A[j] == 'snuke': print(alpha[j]+str(i)) exit()
s080426480
Accepted
17
2,940
223
alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' h,w = map(int,input().split()) for i in range(h): A = list(map(str,input().split())) for j in range(w): if A[j] == 'snuke': ans = alpha[j]+str(i+1) print(ans)
s726621717
p03611
u686036872
2,000
262,144
Wrong Answer
2,104
13,964
153
You are given an integer sequence of length N, a_1,a_2,...,a_N. For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices.
N = input() A = list(map(int, input().split())) ans = 0 for i in range(min(A), max(A)+1): ans = A.count(i-1) + A.count(i) + A.count(i+1) print(ans)
s351934367
Accepted
161
14,564
192
import collections N = input() A = list(map(int, input().split())) c = collections.Counter(A) ans = 0 for i in range(min(A), max(A)+1): ans = max(c[i-1] + c[i] + c[i+1], ans) print(ans)
s218838958
p03644
u189397279
2,000
262,144
Wrong Answer
17
3,060
200
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
N = int(input()) if 1 <= N <2: print(0) if 2 <= N <4: print(1) if 4 <= N <8: print(2) if 8 <= N <16: print(3) if 16 <= N <32: print(4) if 32 <= N <64: print(5) if 64 <= N <100: print(6)
s746916741
Accepted
17
3,060
204
N = int(input()) if 1 <= N <2: print(1) if 2 <= N <4: print(2) if 4 <= N <8: print(4) if 8 <= N <16: print(8) if 16 <= N <32: print(16) if 32 <= N <64: print(32) if 64 <= N <= 100: print(64)
s448971574
p03997
u453500284
2,000
262,144
Wrong Answer
17
2,940
57
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a, b, h = [int(input()) for i in range(3)] print(a*b*h/2)
s656603039
Accepted
17
2,940
48
x = lambda:int(input()) print((x()+x())*x()//2)
s685076989
p03730
u640603056
2,000
262,144
Wrong Answer
17
3,064
449
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
import sys def ILI(): return list(map(int, sys.stdin.readline().rstrip().split())) def ISI(): return map(int, sys.stdin.readline().rstrip().split()) def II(): return int(sys.stdin.readline().rstrip()) def ISS(): return sys.stdin.readline().rstrip().split() def IS(): return sys.stdin.readline().rstrip() A, B, C = ISI() for i in range(1, B+1): if A*i%B == C: print("Yes") break else: print("No")
s889426149
Accepted
18
3,064
449
import sys def ILI(): return list(map(int, sys.stdin.readline().rstrip().split())) def ISI(): return map(int, sys.stdin.readline().rstrip().split()) def II(): return int(sys.stdin.readline().rstrip()) def ISS(): return sys.stdin.readline().rstrip().split() def IS(): return sys.stdin.readline().rstrip() A, B, C = ISI() for i in range(1, B+1): if A*i%B == C: print("YES") break else: print("NO")
s076207287
p02833
u487594898
2,000
1,048,576
Wrong Answer
17
2,940
155
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()) cnt = 0 if N%2==1: print(0) else : for i in range(30): cnt +=N//5**i if N < 5**i: break print(cnt)
s446105776
Accepted
17
3,060
159
import math N = int(input()) cnt = 0 if N%2==1: print(0) else : for i in range(1,30): n = N//2 cnt +=math.floor(n//5**i) print(cnt)
s216590920
p04043
u088974156
2,000
262,144
Wrong Answer
18
2,940
71
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
n=input().split() print("YES" if n.count("5")==2 and ("7")==1 else"NO")
s757693433
Accepted
17
2,940
79
a=input().split() print("YES" if a.count("5")==2 and a.count("7")==1 else "NO")
s885495423
p02613
u439370642
2,000
1,048,576
Wrong Answer
139
16,260
387
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
def main(): n = int(input()) mylist = [] for i in range(1, n+1): s = input() mylist.append(s) ac=mylist.count('AC') wa=mylist.count('WA') tle=mylist.count('TLE') re=mylist.count('RE') print('AC × ' + str(ac)) print('WA × ' + str(wa)) print('TLE × ' + str(tle)) print('RE × ' + str(re)) if __name__ == "__main__": main()
s736979450
Accepted
152
16,548
351
def main(): import collections n = int(input()) mylist = [] for i in range(n): s = input() mylist.append(s) c = collections.Counter(mylist) print('AC x ' + str(c['AC'])) print('WA x ' + str(c['WA'])) print('TLE x ' + str(c['TLE'])) print('RE x ' + str(c['RE'])) if __name__ == "__main__": main()
s234343526
p03997
u296150111
2,000
262,144
Wrong Answer
17
2,940
62
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)//2*h)
s277397240
Accepted
17
2,940
66
a=int(input()) b=int(input()) h=int(input()) print(int((a+b)/2*h))
s422888436
p03494
u364642100
2,000
262,144
Time Limit Exceeded
2,104
2,940
140
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 = input() a = list(map(int, input().split())) cnt = 0 while all(i%2 == 0 for i in a): a = [i % 2 for i in a] cnt += 1 print(cnt)
s341613361
Accepted
17
3,060
164
import math n = input() a = list(map(int, input().split())) ans = float("inf") for i in a: ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1) print(round(ans))
s330465746
p02694
u578093902
2,000
1,048,576
Wrong Answer
24
9,432
164
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
import math x = int(input()) n = int((math.log10(x)-2)/math.log10(1.01)) total = 100*(1.01**n) while total < x: n += 1 total = 100*(1.01**n) print(total,n)
s082477085
Accepted
63
9,300
196
import math x = int(input()) n = int((math.log10(x)-2)/math.log10(1.01))-1 total = 100 while total < x: n += 1 total = 100 for _ in range(n): total += int(total*0.01) print(n)
s976696154
p03352
u893063840
2,000
1,048,576
Wrong Answer
18
3,060
141
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
x = int(input()) ans = 1 for i in range(2, x + 1): tmp = i while tmp <= x: tmp *= i ans = max(ans, tmp / i) print(ans)
s326539711
Accepted
18
2,940
176
x = int(input()) import math ans = 1 for i in range(2, math.ceil(math.sqrt(x)) + 1): tmp = i while tmp <= x: tmp *= i ans = max(ans, tmp // i) print(ans)
s332357804
p02407
u613534067
1,000
131,072
Wrong Answer
20
5,572
68
Write a program which reads a sequence and prints it in the reverse order.
a = list(map(int, input().split())) a.sort(reverse = True) print(a)
s769170094
Accepted
20
5,584
85
input() a = list(map(int, input().split())) a.reverse() print(" ".join(map(str, a)))
s988565866
p03852
u064246852
2,000
262,144
Wrong Answer
18
3,060
282
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`.
s = input()[::-1] flag = 1 i = 0 while i < len(s): if s[i:i+5] == "maerd" or s[i:i+5] == "esare": i += 5 elif s[i:i+6] == "resare": i += 6 elif s[i:i+7] == "remaerd": i += 7 else: flag = 0 break print("YES" if flag else "NO")
s879820437
Accepted
17
2,940
46
print(input()in"aeiou"and"vowel"or"consonant")
s733336970
p02390
u229478139
1,000
131,072
Wrong Answer
20
5,588
160
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.
temp = int(input("Your number:")) hour = temp//3600 min = (temp%3600)//60 sec = (temp%3600)%60 answer = str(hour)+":"+str(min)+":"+str(sec) print(answer)
s802571414
Accepted
20
5,588
117
s = int(input()) h = str(s // 3600) m = str((s % 3600) // 60) s = str((s % 3600) % 60) print(h + ':' + m + ':' + s)
s023682111
p03399
u695079172
2,000
262,144
Wrong Answer
17
2,940
101
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
s = int(input()) sm = sum([int(c) for c in str(s)]) if s%sm == 0: print("Yes") else: print("No")
s623224253
Accepted
17
2,940
114
a,b,c,d = [int(input()) for _ in range(4)] train = a if a <= b else b bus = c if c <= d else d print(train + bus)
s137762267
p02975
u861141787
2,000
1,048,576
Wrong Answer
72
14,116
194
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`. * The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself. What is XOR? The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non- negative integers x_1, x_2, \ldots, x_n is defined as follows: - When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3 \oplus 5 = 6.
n = int(input()) a = list(map(int, input().split())) a = [a[-1]] + a + [a[0]] print(a) for i in range(1, n-2): if a[i] != a[i-1] ^ a[i+1]: print("No") exit() print("Yes")
s403483774
Accepted
49
14,212
316
n = int(input()) a = list(map(int, input().split())) b = list(set(a)) if a.count(0) == n: print("Yes") elif len(b) == 2 and a.count(0) == n / 3: print("Yes") elif len(b) == 3 and b[0] ^ b[1] ^ b[2] == 0 and a.count(b[0]) == n / 3 and a.count(b[0]) == n / 3: print("Yes") else: print("No")
s511728715
p02259
u150984829
1,000
131,072
Wrong Answer
20
5,596
166
Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 4 of the pseudocode.
n=int(input()) a=list(map(int,input().split())) c=0 for i in range(n-2): for j in range(n-1,i,-1): if a[j-1]>a[j]:a[j-1],a[j]=a[j],a[j-1] c+=1 print(*a) print(c)
s613778855
Accepted
20
5,604
159
n=int(input()) a=list(map(int,input().split())) c=0 for i in range(n-1): for j in range(n-i-1): if a[j]>a[j+1]:a[j:j+2]=a[j+1],a[j];c+=1 print(*a) print(c)
s426715306
p03944
u148471096
2,000
262,144
Wrong Answer
19
3,064
381
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
w, h, n = map(int, input().split()) wmin = 0 hmin = 0 wmax = w hmax = h for i in range(n): x, y, a = map(int, input().split()) if a==1: wmax = max(wmax,x) elif a==2: wmin = min(wmin,x) elif a==3: hmax = max(hmax,y) elif a==4: hmin = min(hmin,y) if wmax-wmin<0 or hmax-hmin<0: print(0) else: print((wmax-wmin)*(hmax-hmin))
s590709969
Accepted
17
3,064
386
w, h, n = map(int, input().split()) wmin = w hmin = h wmax = 0 hmax = 0 for i in range(n): x, y, a = map(int, input().split()) if a==1: wmax = max(wmax,x) elif a==2: wmin = min(wmin,x) elif a==3: hmax = max(hmax,y) elif a==4: hmin = min(hmin,y) if wmin-wmax<0 or hmin-hmax<0: print(0) else: print((wmin-wmax)*(hmin-hmax))
s786253088
p03565
u519130434
2,000
262,144
Wrong Answer
17
3,064
779
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 = list(input()) T = list(input()) if len(S) < len(T): print("UNRESTORABLE") else: solved = False ind = -1 for i in reversed(range(len(S) - len(T) + 1)): s = S[i:i+len(T)] yes = True for j in range(len(s)): print(T[j], s[j]) if s[j] == '?' or s[j] == T[j]: continue else: yes = False break if yes: ind = i solved = True break if not solved: print("UNRESTORABLE") else: for i in range(len(S)): if i < ind: if S[i] == '?': S[i] = 'a' elif ind<= i < ind+len(T): S[i] = T[i-ind] print(''.join(S))
s133622653
Accepted
17
3,064
960
S = list(input()) T = list(input()) def solve(): global S, T if len(S) < len(T): print("UNRESTORABLE") return inds = [] for i in reversed(range(len(S) - len(T) + 1)): s = S[i:i+len(T)] # print(i, S[i], S[i:i+len(T)]) yes = True for j in range(len(s)): # print(T[j], s[j]) if s[j] == '?' or s[j] == T[j]: continue else: yes = False break if yes: inds.append(i) # print(inds) if len(inds) == 0: print("UNRESTORABLE") return ans = [] for ind in inds: ss = S[:] for i in range(len(S)): if ind<= i < ind+len(T): ss[i] = T[i-ind] elif ss[i] == '?': ss[i] = 'a' ans.append(ss) # print(ans) ans = list(map(lambda x: ''.join(x), ans)) print(min(ans)) solve()
s538107098
p03679
u391675400
2,000
262,144
Wrong Answer
18
2,940
215
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.
x,a,b = map(int,(input().split())) hantei = b - a if hantei < 0: print("delicious") elif x > hantei: print("sefe") else: print("dangerous")
s462809695
Accepted
17
3,068
174
x,a,b = map(int,(input().split())) hantei = b - a if hantei <= 0: print("delicious") elif x >= hantei: print("safe") elif (x + 1) <= hantei: print("dangerous")
s149757621
p03494
u769538311
2,000
262,144
Wrong Answer
21
3,060
249
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())) c = 0 bool = True while (bool): for i in range(N): if a[i] % 2 == 0: a[i] = a[i] / 2 else: bool = False break else: c += 1
s221218887
Accepted
23
9,188
223
N=int(input()) A=list(map(int,input().split())) ans_list = [] for n in A: temp = n count = 0 while temp % 2 == 0: temp /= 2 count = count + 1 ans_list.append(count) print(min(ans_list))
s033010983
p03624
u941753895
2,000
262,144
Wrong Answer
17
3,188
200
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
S=input() l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] for x in l: if x in S: print(x) exit() print('None')
s000185918
Accepted
17
3,188
204
S=input() l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] for x in l: if x not in S: print(x) exit() print('None')
s348250039
p03699
u416773418
2,000
262,144
Wrong Answer
17
3,060
213
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
n = int(input()) s=[int(input()) for i in range(n)] ans=sum(s) if ans % 10 != 0: print(ans) else: for i in range(len(s)): if s[i] % 10 != 0: print(ans-s[i]) else: print(0)
s096247032
Accepted
18
3,060
239
n = int(input()) s=[int(input()) for i in range(n)] s.sort() ans=sum(s) if ans % 10 != 0: print(ans) else: for i in range(len(s)): if s[i] % 10 != 0: print(ans-s[i]) break else: print(0)
s804483959
p04043
u343977188
2,000
262,144
Wrong Answer
17
2,940
101
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
S=list(map(int,input().split())) if S.count(5)==2 and S.count(7)==1: print("Yes") else:print("No")
s990479910
Accepted
17
2,940
101
S=list(map(int,input().split())) if S.count(5)==2 and S.count(7)==1: print("YES") else:print("NO")
s492180851
p00007
u885889402
1,000
131,072
Wrong Answer
20
6,748
162
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week. Write a program which computes the amount of the debt in n weeks.
n = input() a = 100000 for i in range(1,int(n)+1): a = int(a*1.05) print(a) if(a%1000 > 0): a = 1000*int(a/1000) + 1000 print(a) print(a)
s951388262
Accepted
30
6,748
136
n = input() a = 100000 for i in range(1,int(n)+1): a = int(a*1.05) if(a%1000 > 0): a = 1000*int(a/1000) + 1000 print(a)
s676347162
p03351
u103657515
2,000
1,048,576
Wrong Answer
21
2,940
167
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
A,B,C,D = map(int, input().split()) AB = abs(A-B) BC = abs(B-C) ans = 0 if AB <= D and BC <= D: ans = "yes" else: ans = "no" print(ans)
s532720236
Accepted
17
2,940
185
A,B,C,D = map(int, input().split()) AB = abs(A-B) BC = abs(B-C) AC = abs(A-C) ans = 0 if AB <= D and BC <= D or AC <= D: ans = "Yes" else: ans = "No" print(ans)
s619893848
p03377
u304630225
2,000
262,144
Wrong Answer
18
2,940
109
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,C=input().split() A=int(A) B=int(B) C=int(C) if C>=A and C<=A+B : print("Yes") else : print("No")
s586260084
Accepted
17
3,060
109
A,B,C=input().split() A=int(A) B=int(B) C=int(C) if C>=A and C<=A+B : print("YES") else : print("NO")
s807894658
p03007
u305422591
2,000
1,048,576
Wrong Answer
402
21,532
453
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 final integer on the blackboard and a sequence of operations that maximizes the final integer.
import heapq N = int(input()) A = [int(item) for item in input().split()] # N = 10**5 # A = [item for item in range(N)] heapq.heapify(A) res = [] while len(A) > 2: min_ = A[0] heapq.heappop(A) min_2 = A[0] heapq.heappop(A) new = min_ - min_2 res.append([min_, min_2]) heapq.heappush(A, new) min_ = A[0] heapq.heappop(A) min_2 = A[0] heapq.heappop(A) res.append([min_, min_2]) print(min_2 - min_) for item in res: print (item[0], item[1])
s496226942
Accepted
308
18,760
361
import heapq N = int(input()) A = [int(item) for item in input().split()] # N = 10**5 # A = [item for item in range(N)] A.sort() M = A.pop() heapq.heapify(A) m = heapq.heappop(A) res = [] while A: a = heapq.heappop(A) if a < 0: res.append((M, a)) M -= a else: res.append((m, a)) m -= a print(M-m) for x, y in res: print(x, y) print(M, m)
s761488839
p03385
u357050210
2,000
262,144
Wrong Answer
17
2,940
84
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() s = sorted(s) if s == "abc": print("Yes") else: print("No")
s388198839
Accepted
20
2,940
90
s = input() s = "".join(sorted(s)) if s == "abc": print("Yes") else: print("No")
s117181265
p02608
u992541367
2,000
1,048,576
Wrong Answer
60
9,436
546
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
N = int(input()) answers = [0 for i in range(10**4+1)] for x in range(1,50): for y in range(x,50): for z in range(y,50): n = x**2+y**2+z**2+x*y+y*z+z*x if 0 <= n <= 10000: #print(x,y,z,n) c = len(set([x,y,z])) if c == 1: answers[n] += 1 elif c == 2: answers[n] += 3 else: answers[n] += 6 #print(answers[:30]) for ans in answers[1:]: print(ans)
s984590958
Accepted
154
9,092
589
N = int(input()) answers = [0 for i in range(10**4+1)] for x in range(1,42): for y in range(x,100): for z in range(y,100): n = x**2+y**2+z**2+x*y+y*z+z*x if 0 <= n <= 10000: #if n == 9803: # print(x,y,z,n) c = len(set([x,y,z])) if c == 1: answers[n] += 1 elif c == 2: answers[n] += 3 else: answers[n] += 6 #print(answers[-100:]) for ans in answers[1:N+1]: print(ans)
s001940341
p02612
u023762741
2,000
1,048,576
Wrong Answer
26
9,140
33
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
s = int(input()) print(s % 1000)
s747515341
Accepted
28
9,144
76
s = int(input()) % 1000 if s == 0: print(0) else: print(1000 - s )
s187635615
p03730
u532087742
2,000
262,144
Wrong Answer
18
2,940
191
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
# -*- coding: utf-8 -*- import sys (A,B,C) = map(int,input().split(" ")) x = A % B print(C,x) for i in range(B): if (A*i) % B == C: print('YES') sys.exit() print('NO')
s445791277
Accepted
17
2,940
168
# -*- coding: utf-8 -*- import sys (A,B,C) = map(int,input().split(" ")) for i in range(B): if (A*i) % B == C: print('YES') sys.exit() print('NO')
s782105938
p03168
u686230543
2,000
1,048,576
Wrong Answer
202
13,048
192
Let N be a positive odd number. There are N coins, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), when Coin i is tossed, it comes up heads with probability p_i and tails with probability 1 - p_i. Taro has tossed all the N coins. Find the probability of having more heads than tails.
import numpy as np n = int(input()) dp = np.zeros(n) dp[0] = 1. for p in map(float, input().split()): tmp = (1. - p) * dp tmp[1:] += p * dp[:-1] dp = tmp print(dp[n // 2 + 1:].sum())
s902694024
Accepted
202
12,468
196
import numpy as np n = int(input()) dp = np.zeros(n + 1) dp[0] = 1. for p in map(float, input().split()): tmp = (1. - p) * dp tmp[1:] += p * dp[:-1] dp = tmp print(dp[n // 2 + 1:].sum())
s966435054
p02742
u996564551
2,000
1,048,576
Wrong Answer
26
9,136
238
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 = input().split(' ') H = int(H) W = int(W) if (H//2)==0 and (W//2)==0: print(int((H/2) * W)) elif (H//2)==1 and (W//2)==0: print(int((W/2) * H)) elif (H//2)==0 and (W//2)==1: print(int((H/2) * W)) else: print(int((H*W/2)+1))
s154356596
Accepted
25
8,984
286
H, W = input().split(' ') H = int(H) W = int(W) if H==1 or W ==1: print(1) elif (H%2)==0 and (W%2)==0: print(int((H/2) * W)) elif (H%2)==1 and (W%2)==0: print(int((W/2) * H)) elif (H%2)==0 and (W%2)==1: print(int((H/2) * W)) elif (H%2)==1 and (W%2)==1: print(int((H*W//2)+1))
s060288280
p02394
u386861275
1,000
131,072
Wrong Answer
30
7,528
105
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.
W,H,x,y,r= map(int, input().split()) if W>=x+r & r<=x & r<=y & H>=y+r: print ("Yes") else: print ("No")
s302704652
Accepted
20
7,668
111
W,H,x,y,r= map(int, input().split()) if W>=x+r and r<=x and r<=y and H>=y+r: print ("Yes") else: print ("No")
s388734798
p03853
u533084327
2,000
262,144
Wrong Answer
148
12,424
189
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
import numpy as np H,W = list(map(int, input().split())) print (H) C = [] for i in range(H): C.append(input()) print (C) for i in range(H): print (str(C[i])) print (str(C[i]))
s885561666
Accepted
148
12,424
191
import numpy as np H,W = list(map(int, input().split())) #print (H) C = [] for i in range(H): C.append(input()) #print (C) for i in range(H): print (str(C[i])) print (str(C[i]))
s243236906
p04044
u506858457
2,000
262,144
Wrong Answer
17
3,060
88
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
N,L=map(int,input().split()) for i in range(N): s=input() s=sorted(s) print(*s,sep='')
s655592652
Accepted
17
3,060
93
n,l=map(int,input().split()) s=sorted([input() for i in range(n)]) #print(s) print(*s,sep="")
s905897742
p04011
u011872685
2,000
262,144
Wrong Answer
26
9,004
75
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
N=int(input()) K=int(input()) X=int(input()) Y=int(input()) a=X*K+Y*(N-K) a
s486032863
Accepted
27
9,016
113
N=int(input()) K=int(input()) X=int(input()) Y=int(input()) if K<N: print(X*K+Y*(N-K)) else: print(X*N)
s545660124
p00060
u546285759
1,000
131,072
Wrong Answer
20
7,612
415
「1」から「10」までの数字が書かれたカードが各 1 枚、全部で 10 枚あります。このカードは、表側には数字が書かれ、裏側には何も書かれていません。このカードを使って、あなたと相手の 2 名で以下のルールでゲー ムを行います。 1. あなたと相手には、表を上にして 1 枚、裏を上にして 1 枚、計 2 枚のカードが配られています。あなたは相手の表のカードの数字を見ることができますが、裏のカードの数字は見えません。 2. 配られたカードの数字の合計が 20 以下で、かつ相手の数字の合計より大きいときに勝ちとなります。 例えば、あなたのカードが「7」「8」 (合計 15) 、相手のカードが「9」「10」 (合計 19) のときは、相手の勝ちです。 3. あなたと相手は最大であと 1 枚カードを引くことができます。それを引かなくても構いません。 ここで、あと 1 枚のカードを引くかどうかを決定する目安として、カードを引いたときに合計が 20 以下に なる確率を考え、その確率が 50% 以上のときはカードを引くこととしましょう。この確率を計算するときには、あなたの 2 枚のカードと相手の表のカードの計3枚のカードの情報を利用することができます。つまり、各カードは 1 枚ずつしかないので、それらのカードを引くことはないことになります。 あなたの 2 枚のカードと相手の表のカードを読み込んで、それぞれについて、あと 1 枚引いたときに合計が 20 以下になる確率が 50% 以上のときは YES、そうでないなら NO を出力するプログラムを作成してください。
while True: try: C1, C2, C3 = map(int, input().split()) except: break cards = [v for v in range(1, 11)] p = [] for v in [C1, C2, C3]: cards.remove(v) for i in cards: _card = cards[:] _card.remove(i) for j in _card: if C1+C2+j <= 20: p.append(1) else: p.append(0) print(sum(p)/len(p))
s064093273
Accepted
30
7,700
441
while True: try: C1, C2, C3 = map(int, input().split()) except: break cards = [v for v in range(1, 11)] p = [] for v in [C1, C2, C3]: cards.remove(v) for i in cards: _card = cards[:] _card.remove(i) for j in _card: if C1+C2+j <= 20: p.append(1) else: p.append(0) print("YES" if sum(p)/len(p) >= 0.5 else "NO")
s593984774
p03997
u941277791
2,000
262,144
Wrong Answer
17
2,940
107
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.
top=int(input()) bottom=int(input()) height=int(input()) num=top+bottom ans=num*height/2 print(str(ans))
s586483263
Accepted
17
2,940
115
top=int(input()) bottom=int(input()) height=int(input()) num=top+bottom ans=int(num*height/2) print(str(ans))
s440041195
p03563
u945419374
2,000
262,144
Wrong Answer
19
2,940
97
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.
N=int(input()) K=int(input()) x=1 for i in range(N): if x<=K: x=x*2 else: x=x+K print(x)
s174452985
Accepted
17
2,940
51
R=int(input()) G=int(input()) print(2*G-R)
s691722777
p02613
u316055872
2,000
1,048,576
Wrong Answer
144
16,272
236
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
N = int(input()) S = [] for _ in range(N): S.append(input()) a = S.count('AC') b = S.count('WA') c = S.count('TLE') d = S.count('RE') print ('AC ×' + str(a)) print('WA ×' + str(b)) print('TLE ×' + str(c)) print('RE ×' + str(d))
s974832859
Accepted
147
16,224
252
N = int(input()) S = [] for _ in range(N): S.append(input()) a = S.count('AC') b = S.count('WA') c = S.count('TLE') d = S.count('RE') print ('AC x' +' ' + str(a)) print('WA x' + ' '+ str(b)) print('TLE x' +' ' + str(c)) print('RE x' + ' '+ str(d))
s555646320
p03434
u375695365
2,000
262,144
Wrong Answer
17
3,060
134
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=int(input()) a=list(map(int,input().split())) a.sort() ab=list(a[::2]) ac=list(a[1::2]) print(sum(ab)-sum(ac)) #print(ab) #print(ac)
s774912095
Accepted
17
3,060
146
n=int(input()) a=list(map(int,input().split())) a.sort(reverse=True) ab=list(a[::2]) ac=list(a[1::2]) print(sum(ab)-sum(ac)) #print(ab) #print(ac)
s035667541
p03455
u559313689
2,000
262,144
Wrong Answer
25
9,088
109
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a, b = map(int, input().split()) answer = (a * b)% 2 if answer == 0: print('even') else: print('odd')
s109490959
Accepted
31
9,024
109
a, b = map(int, input().split()) answer = (a * b)% 2 if answer == 0: print('Even') else: print('Odd')
s158771199
p02421
u395334793
1,000
131,072
Wrong Answer
20
7,500
328
Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card. The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner obtains 3 points. In the case of a draw, they obtain 1 point each. Write a program which reads a sequence of cards Taro and Hanako have and reports the final scores of the game.
count = int(input()) Taro_an = [] Hanako_an = [] Ts = 0 Hs = 0 for i in range(count) : animal = input().split(" ") Taro_an = animal[0] Hanako_an = animal[1] if Taro_an > Hanako_an : Ts += 3 else : if Hanako_an > Taro_an : Hs += 3 else : ++Ts, ++Hs print(Ts,Hs)
s840082101
Accepted
20
7,488
334
count = int(input()) Taro_an = [] Hanako_an = [] Ts = 0 Hs = 0 for i in range(count) : animal = input().split(" ") Taro_an = animal[0] Hanako_an = animal[1] if Taro_an > Hanako_an : Ts += 3 else : if Hanako_an > Taro_an : Hs += 3 else : Ts += 1; Hs += 1 print(Ts,Hs)
s631277623
p03167
u954774382
2,000
1,048,576
Wrong Answer
600
51,968
1,576
There is a grid 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. For each i and j (1 \leq i \leq H, 1 \leq j \leq W), Square (i, j) is described by a character a_{i, j}. If a_{i, j} is `.`, Square (i, j) is an empty square; if a_{i, j} is `#`, Square (i, j) is a wall square. It is guaranteed that Squares (1, 1) and (H, W) are empty squares. Taro will start from Square (1, 1) and reach (H, W) by repeatedly moving right or down to an adjacent empty square. Find the number of Taro's paths from Square (1, 1) to (H, W). As the answer can be extremely large, find the count modulo 10^9 + 7.
import sys from functools import lru_cache, cmp_to_key from heapq import merge, heapify, heappop, heappush from math import * from collections import defaultdict as dd, deque, Counter as C from itertools import combinations as comb, permutations as perm from bisect import bisect_left as bl, bisect_right as br, bisect from time import perf_counter from fractions import Fraction import copy import time # import numpy as np starttime = time.time() # import numpy as np mod = int(pow(10, 9) + 7) mod2 = 998244353 def data(): return sys.stdin.readline().strip() def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end) def L(): return list(sp()) def sl(): return list(ssp()) def sp(): return map(int, data().split()) def ssp(): return map(str, data().split()) def l1d(n, val=0): return [val for i in range(n)] def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)] try: sys.setrecursionlimit(int(pow(10,6))) sys.stdin = open("input.txt", "r") # sys.stdout = open("../output.txt", "w") except: pass n,m=L() A=[input() for i in range(n)] dp=[[0 for i in range(m)] for j in range(n)] for i in range(n): for j in range(m): if i==0 and j==0: dp[i][j]=1 continue if i==0: dp[i][j]=dp[i][j-1] elif j==0: dp[i][j]=dp[i-1][j] else: if A[i][j]==".": dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod else: dp[i][j]=0 print(dp[-1][-1]) endtime = time.time() # print(f"Runtime of the program is {endtime - starttime}")
s900921109
Accepted
609
52,164
1,662
import sys from functools import lru_cache, cmp_to_key from heapq import merge, heapify, heappop, heappush from math import * from collections import defaultdict as dd, deque, Counter as C from itertools import combinations as comb, permutations as perm from bisect import bisect_left as bl, bisect_right as br, bisect from time import perf_counter from fractions import Fraction import copy import time # import numpy as np starttime = time.time() # import numpy as np mod = int(pow(10, 9) + 7) mod2 = 998244353 def data(): return sys.stdin.readline().strip() def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end) def L(): return list(sp()) def sl(): return list(ssp()) def sp(): return map(int, data().split()) def ssp(): return map(str, data().split()) def l1d(n, val=0): return [val for i in range(n)] def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)] try: sys.setrecursionlimit(int(pow(10,6))) sys.stdin = open("input.txt", "r") # sys.stdout = open("../output.txt", "w") except: pass n,m=L() A=[input() for i in range(n)] dp=[[0 for i in range(m)] for j in range(n)] for i in range(n): for j in range(m): if i==0 and j==0: dp[i][j]=1 continue if i==0: if A[i][j]==".": dp[i][j]=dp[i][j-1] elif j==0: if A[i][j]==".": dp[i][j]=dp[i-1][j] else: if A[i][j]==".": dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod else: dp[i][j]=0 # print(*dp[i]) print(dp[-1][-1]) endtime = time.time() # print(f"Runtime of the program is {endtime - starttime}")
s383481435
p02239
u797673668
1,000
131,072
Wrong Answer
30
8,012
524
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by IDs $1, 2, ... n$.
from collections import deque n = int(input()) g = [None] * n visited = [0] * n dist = [-1] * n queue = deque() while n: l = list(map(int, input().split())) connected = [i - 1 for i in l[2:]] g[l[0] - 1] = [i - 1 for i in l[2:]] n -= 1 queue.append((0, 0)) visited[0] = 1 while queue: print(queue) i, d = queue.popleft() dist[i] = d for c in g[i]: if not visited[c]: visited[c] = 1 queue.append((c, d + 1)) for i, d in enumerate(dist): print(i + 1, d)
s839252610
Accepted
40
8,068
507
from collections import deque n = int(input()) g = [None] * n visited = [0] * n dist = [-1] * n queue = deque() while n: l = list(map(int, input().split())) connected = [i - 1 for i in l[2:]] g[l[0] - 1] = [i - 1 for i in l[2:]] n -= 1 queue.append((0, 0)) visited[0] = 1 while queue: i, d = queue.popleft() dist[i] = d for c in g[i]: if not visited[c]: visited[c] = 1 queue.append((c, d + 1)) for i, d in enumerate(dist): print(i + 1, d)
s913878293
p04030
u637918426
2,000
262,144
Wrong Answer
17
2,940
222
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?
l = list(input()) print(l) list = [] for i in range(len(l)): if l[i] == 'B': if not list: continue else: del list[-1] else: list.append(l[i]) print(''.join(list))
s084368643
Accepted
17
2,940
213
l = list(input()) list = [] for i in range(len(l)): if l[i] == 'B': if not list: continue else: del list[-1] else: list.append(l[i]) print(''.join(list))
s138798006
p03672
u585819925
2,000
262,144
Wrong Answer
17
2,940
223
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.
s=input() while True: if len(s) % 2 == 0: if s[:len(s)//2] == s[len(s)//2:]: print(len(s)) break s = s[:-1]
s880522154
Accepted
17
2,940
228
s=input()[:-1] while True: if len(s) % 2 == 0: if s[:len(s)//2] == s[len(s)//2:]: print(len(s)) break s = s[:-1]
s502129929
p03861
u525423408
2,000
262,144
Wrong Answer
17
2,940
87
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
a,b,x=map(int,input().split()) if a==0: print(b//x +1) else: print(b//x - a//x)
s399466686
Accepted
17
3,064
93
a,b,x=map(int,input().split()) if a % x == 0: print(b//x - a//x +1) else:print(b//x-a//x)
s106703183
p02936
u869919400
2,000
1,048,576
Wrong Answer
2,118
236,564
390
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()) rs = [map(int, input().split()) for _ in range(N-1)] ps = [map(int, input().split()) for _ in range(Q)] cs = [0] * N nodes = [set() for _ in range(N)] for n1, n2 in rs: nodes[n1-1].add(n2-1) def f(n, p): cs[n] += p if not nodes[n]: return for _n in nodes[n]: f(_n, p) while ps: n, p = ps.pop() f(n-1, p) print(cs)
s885451193
Accepted
1,419
234,516
532
import sys sys.setrecursionlimit(500000) N, Q = map(int, input().split()) tree = [[] for _ in range(N)] for _ in range(N-1): a, b = map(int, input().split()) tree[a-1].append(b-1) tree[b-1].append(a-1) scores = [0] * N for _ in range(Q): p, x = map(int, input().split()) scores[p-1] += x ans = [0] * N visited = set() def dfs(n: int, score: int): score += scores[n] ans[n] = score visited.add(n) for v in tree[n]: if v not in visited: dfs(v, score) dfs(0, 0) print(*ans)
s205067731
p03149
u732963817
2,000
1,048,576
Wrong Answer
17
2,940
101
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())) print("Yes" if 1 in N and 9 in N and 7 in N and 4 in N else "No")
s173583795
Accepted
17
2,940
122
N = list(map(int, input().split())) print("YES" if len(set(N)) == 4 and 1 in N and 9 in N and 7 in N and 4 in N else "NO")
s490254191
p04030
u306412379
2,000
262,144
Wrong Answer
29
9,016
219
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 = list(input()) x = len(s) a = [] for i in range(x): if s[i] == '0': a.append(0) elif s[i] == '1': a.append(1) elif s[i] == 'B': if a != []: a.remove(a[-1]) else: continue print(*a)
s326913698
Accepted
30
8,932
230
s = list(input()) x = len(s) a = [] for i in range(x): if s[i] == '0': a.append('0') elif s[i] == '1': a.append('1') elif s[i] == 'B': if a == []: continue else: a.pop(-1) b = ''.join(a) print(b)
s140832590
p03943
u402629484
2,000
262,144
Wrong Answer
22
3,064
48
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.
s = input() print(s.count('WB') + s.count('BW'))
s330970007
Accepted
22
3,064
92
a,b,c = list(map(int, input().split())) print("Yes" if a+b==c or b+c==a or c+a==b else "No")
s587889538
p02261
u760369990
1,000
131,072
Wrong Answer
30
7,728
1,571
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).
def isStable(before_sort, after_sort): num = len(before_sort) for i in range(0, num-1): for j in range(i+1, num): for a in range(0, num-1): for b in range(a+1, num): if before_sort[i][1] == after_sort[j][1] and \ before_sort[i] == after_sort[b] and \ before_sort[j] == after_sort[a]: print("i=%d / j=%d / a=%d / b=%d /before=%s / after=%s" % \ (i, j, a, b, before_sort[i][1], after_sort[j][1])) return False return True def isStable2(sorted_data, bubble_sort_data): for i in range(0, len(sorted_data)): if sorted_data[i] != bubble_sort_data[i]: return False return True def BubbleSort(c, n): for i in range(0, n): for j in range(n-1, i, -1): if int(c[j][1]) < int(c[j-1][1]): c[j], c[j-1] = c[j-1], c[j] def SelectionSort(c, n): for i in range(0, n): minj = i for j in range(i, n): if int(c[j][1]) < int(c[minj][1]): minj = j c[i], c[minj] = c[minj], c[i] num = int(input()) data = input().split(' ') copy_data = data.copy() BubbleSort(copy_data, num) print(copy_data) if isStable(copy_data, copy_data): print("Stable") else: print("Not stable") bubble_sort_data = data.copy() SelectionSort(bubble_sort_data, num) print(bubble_sort_data) if isStable(bubble_sort_data, copy_data): print("Stable") else: print("Not stable")
s843366925
Accepted
150
7,844
1,427
def isStable(before_sort, after_sort): num = len(before_sort) for i in range(0, num-1): for j in range(i+1, num): for a in range(0, num-1): for b in range(a+1, num): if before_sort[i][1] == after_sort[j][1] and \ before_sort[i] == after_sort[b] and \ before_sort[j] == after_sort[a]: return False return True def isStable2(sorted_data, bubble_sort_data): for i in range(0, len(sorted_data)): if sorted_data[i] != bubble_sort_data[i]: return False return True def BubbleSort(c, n): for i in range(0, n): for j in range(n-1, i, -1): if int(c[j][1]) < int(c[j-1][1]): c[j], c[j-1] = c[j-1], c[j] def SelectionSort(c, n): for i in range(0, n): minj = i for j in range(i, n): if int(c[j][1]) < int(c[minj][1]): minj = j c[i], c[minj] = c[minj], c[i] num = int(input()) data = input().split(' ') copy_data = data.copy() BubbleSort(copy_data, num) print(' '.join(copy_data)) if isStable(copy_data, copy_data): print("Stable") else: print("Not stable") bubble_sort_data = data.copy() SelectionSort(bubble_sort_data, num) print(' '.join(bubble_sort_data)) if isStable(bubble_sort_data, copy_data): print("Stable") else: print("Not stable")
s297105978
p02388
u538972897
1,000
131,072
Wrong Answer
20
5,572
28
Write a program which calculates the cube of a given integer x.
x = int(input()) print(x**x)
s335872983
Accepted
20
5,576
28
x = int(input()) print(x**3)
s651639743
p03044
u518042385
2,000
1,048,576
Wrong Answer
2,106
108,104
607
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(1000000) n=int(input()) l=[[] for i in range(n+1)] for i in range(n-1): a,b,c=map(int,input().split()) l[a].append([b,c]) l[b].append([a,c]) color=[-1 for i in range(n+1)] def dfs(s,c): color[s]=c for i in range(len(l[s])): index=l[s][i][0] dis=l[s][i][1] if color[index]!=-1: if dis%2==1: if color[index]==c: color[index]=1-c dfs(index,1-c) else: if dis%2==1: color[s]=1-c dfs(index,1-c) else: color[s]=c dfs(index,1-c) dfs(1,1) for i in range(1,n+1): print(color[i])
s937372880
Accepted
857
42,228
499
from collections import deque q=deque([1]) n=int(input()) l=[[] for i in range(n+1)] for i in range(n-1): a,b,c=map(int,input().split()) c=c%2 l[a].append([b,c]) l[b].append([a,c]) inf=10**10 d=[inf for i in range(n+1)] d[1]=0 def dik(s): q=deque([s]) while q: a=q.popleft() for i in l[a]: index=i[0] dis=i[1] if d[index]>dis+d[a]: d[index]=dis+d[a] q.append(index) dik(1) for i in range(1,n+1): if d[i]%2==0: print(0) else: print(1)
s376503054
p02614
u137226361
1,000
1,048,576
Wrong Answer
128
9,348
969
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
import sys, copy input = sys.stdin.readline def main(): h, w , k = map(int, input().split()) ls = [] for _ in range(h): ms = [] t=str(input().rstrip()) for i in range(len(t)): if t[i] =='.': ms.append(0) else: ms.append(1) ls.append(ms) def num(x, y): lt = copy.deepcopy(ls) x2 = format(x, 'b') y2 = format(y, 'b') for i in range(len(x2)): if x2[i]=='0': lt[i]= [0]*len(y2) for j in range(len(y2)): if y2[j]=='0': for t in range(len(x2)): lt[t][j]= 0 re = 0 for i in lt: re += sum(i) return re ans = 0 for i in range(2**h): for j in range(2**w): if num(i,j) == k: ans +=1 print(i, j) print(ans) print(ls) if __name__ == '__main__': main()
s590259860
Accepted
130
9,168
957
import sys, copy input = sys.stdin.readline def main(): h, w , k = map(int, input().split()) ls = [] for _ in range(h): ms = [] t=str(input().rstrip()) for i in range(len(t)): if t[i] =='.': ms.append(0) else: ms.append(1) ls.append(ms) def num(x, y): lt = copy.deepcopy(ls) x2 = format(x, 'b').rjust(h, '0') y2 = format(y, 'b').rjust(w, '0') for i in range(len(x2)): if x2[i]=='0': lt[i]= [0]*len(y2) for j in range(len(y2)): if y2[j]=='0': for t in range(len(x2)): lt[t][j]= 0 re = 0 for i in lt: re += sum(i) return re ans = 0 for i in range(2**h): for j in range(2**w): if num(i,j) == k: ans +=1 print(ans) if __name__ == '__main__': main()
s515501416
p02613
u047116039
2,000
1,048,576
Wrong Answer
161
9,220
314
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.
ac,wa,tle,re = 0,0,0,0 N=int(input()) for _ in range(N): s=str(input()) if(s=="AC"): ac+=1 elif(s=="WA"): wa+=1 elif(s=="TLE"): tle+=1 elif(s=="RE"): re+=1 print("AC × "+str(ac)+"\n") print("WA × "+str(wa)+"\n") print("TLE × "+str(tle)+"\n") print("RE × "+str(re)+"\n")
s292464654
Accepted
162
9,212
272
ac,wa,tle,re = 0,0,0,0 N=int(input()) for _ in range(N): s=str(input()) if(s=="AC"): ac+=1 elif(s=="WA"): wa+=1 elif(s=="TLE"): tle+=1 elif(s=="RE"): re+=1 print("AC x "+str(ac)) print("WA x "+str(wa)) print("TLE x "+str(tle)) print("RE x "+str(re))
s363152954
p03379
u503901534
2,000
262,144
Wrong Answer
371
25,220
184
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
n = int(input()) x = list(map(int,input().split())) xs = list(sorted(x)) for i in range(n): if x[i] <= xs[n // 2]: print(xs[n // 2]) else: print(xs[n // 2 -1])
s776934597
Accepted
340
25,620
183
n = int(input()) x = list(map(int,input().split())) xs = list(sorted(x)) for i in range(n): if x[i] < xs[n // 2]: print(xs[n // 2]) else: print(xs[n // 2 -1])
s761590286
p03351
u077019541
2,000
1,048,576
Wrong Answer
17
2,940
92
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
a,b,c,d = map(int,input().split()) if (b-a)+(c-b)<=d: print("Yes") else: print("No")
s902724379
Accepted
17
2,940
140
a,b,c,d = map(int,input().split()) if abs(b-a)<=d and abs(c-b)<=d: print("Yes") elif abs(c-a)<=d: print("Yes") else: print("No")
s260406227
p03493
u181769094
2,000
262,144
Wrong Answer
17
2,940
61
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
list=list(map(int,input().split())) a=list.count(1) print(a)
s175006129
Accepted
18
2,940
52
list=list(map(int,input())) a=list.count(1) print(a)
s530095893
p04043
u594956556
2,000
262,144
Wrong Answer
17
2,940
131
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
abc = list(map(int, input().split())) abc.sort() if (abc[0]==5) and (abc[0]==5) and (abc[0]==7): print('YES') else: print('NO')
s157171132
Accepted
17
2,940
132
abc = list(map(int, input().split())) abc.sort() if (abc[0]==5) and (abc[1]==5) and (abc[2]==7): print('YES') else: print('NO')
s095183229
p02694
u597626771
2,000
1,048,576
Wrong Answer
21
9,092
110
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
X = int(input()) money = 100 year = 0 while money <= X: year += 1 money = int(money*1.01) print(year)
s081712988
Accepted
24
9,084
108
X = int(input()) money = 100 year = 0 while money < X: year += 1 money = int(money*1.01) print(year)
s139992261
p03385
u569272329
2,000
262,144
Wrong Answer
17
2,940
85
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 = str(input()) S = sorted(S) if "abc" == S: print("Yes") else: print("No")
s352562186
Accepted
17
2,940
122
S = str(input()) if not(S[0] == S[1]) and not(S[1] == S[2]) and not(S[0] == S[2]): print("Yes") else: print("No")
s127137317
p03730
u739843002
2,000
262,144
Wrong Answer
28
9,124
126
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
import math A, B, C = list(map(lambda n: int(n), input().split(" "))) print("Yes") if C % math.gcd(A,B) == 0 else print("No")
s186275939
Accepted
25
9,200
127
import math A, B, C = list(map(lambda n: int(n), input().split(" "))) print("YES") if C % math.gcd(A,B) == 0 else print("NO")
s349994264
p03007
u583276018
2,000
1,048,576
Wrong Answer
2,104
13,964
386
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 final integer on the blackboard and a sequence of operations that maximizes the final integer.
n = int(input()) num = [int(i) for i in input().split()] anslist = [] for i in range(n-2): anslist.append([min(num), max(num)]) a = min(num) - max(num) num.remove(min(num)) num.remove(max(num)) num.append(a) ans = max(num) - min(num) print(ans) for i in range(n-2): print(str(anslist[i][0]) + " " + str(anslist[i][1])) print(str(max(num)) + " " + str(min(num)))
s968275740
Accepted
1,800
23,240
1,469
n = int(input()) num = [int(i) for i in input().split()] plus = [] minus = [] sumlist = [] for i in range(n): if(num[i] >= 0): plus.append(num[i]) else: minus.append(num[i]) ans = [] if(len(plus) >= len(minus)): last = min(num) if(last >= 0): plus.remove(min(plus)) else: minus.remove(min(minus)) while(len(minus) > 0): sumlist.append(plus[0] - minus[0]) ans.append([plus.pop(0), minus.pop(0)]) for i in range(len(plus)): sumlist.append(plus[i]) for i in range(len(sumlist)-1): tmp = last last -= sumlist[0] ans.append([tmp, sumlist.pop(0)]) ans.append([sumlist[0], last]) score = sumlist[0] - last print(score) for i in range(len(ans)): print(str(ans[i][0]) + " " + str(ans[i][1])) else: last = max(num) if(last >= 0): plus.remove(max(plus)) else: minus.remove(max(minus)) while(len(plus) > 0): sumlist.append(minus[0] - plus[0]) ans.append([minus.pop(0), plus.pop(0)]) for i in range(len(minus)): sumlist.append(minus[i]) for i in range(len(sumlist)-1): tmp = last last -= sumlist[0] ans.append([tmp, sumlist.pop(0)]) ans.append([last, sumlist[0]]) score = last - sumlist[0] print(score) for i in range(len(ans)): print(str(ans[i][0]) + " " + str(ans[i][1]))
s027355593
p03494
u727801592
2,000
262,144
Wrong Answer
23
3,064
140
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=input() div=30 count=0 for i in input().split(): while int(i)%2==0: i=int(i)/2 count+=1 if count<div: div=count print(div)
s602536398
Accepted
23
2,940
150
n=input() div=30 count=0 for i in input().split(): while int(i)%2==0: i=int(i)/2 count+=1 if count<div: div=count count=0 print(div)
s702531526
p04029
u733321071
2,000
262,144
Wrong Answer
17
2,940
37
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((1 + n) / 2)
s970750236
Accepted
17
2,940
38
n = int(input()) print(int((n+1)*n/2))
s895715845
p03369
u010437136
2,000
262,144
Wrong Answer
17
2,940
191
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
import sys s = sys.stdin.readline() l = [0,0,0] for i in range(2): if s[i] == "o": l[i] = 100 elif s[i] == "x": l[i] = 0 goukei = 700+l[0]+l[1]+l[2] print(goukei)
s638812136
Accepted
17
2,940
191
import sys s = sys.stdin.readline() l = [0,0,0] for i in range(3): if s[i] == "o": l[i] = 100 elif s[i] == "x": l[i] = 0 goukei = 700+l[0]+l[1]+l[2] print(goukei)
s568956910
p02608
u933129390
2,000
1,048,576
Wrong Answer
467
18,232
401
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
n = int(input()) xyz = [[[0 for i in range(101)] for j in range(101)] for k in range(101)] ans = [0 for i in range(n+1)] def gen_n(x, y, z): return x*2 + y*2 + z*2 + x*y + y*z + z*x for i in range(1, 101): for j in range(1, 101): for k in range(1, 101): num = gen_n(i, j, k) if n >= num: ans[num] += 1 for i in range(1, n+1): print(ans[i])
s743498723
Accepted
954
18,416
404
n = int(input()) xyz = [[[0 for i in range(101)] for j in range(101)] for k in range(101)] ans = [0 for i in range(n+1)] def gen_n(x, y, z): return x**2 + y**2 + z**2 + x*y + y*z + z*x for i in range(1, 101): for j in range(1, 101): for k in range(1, 101): num = gen_n(i, j, k) if n >= num: ans[num] += 1 for i in range(1, n+1): print(ans[i])
s052175139
p03385
u580362735
2,000
262,144
Wrong Answer
17
2,940
63
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() print('Yes') if sorted(S) == 'abc' else print('No')
s476651953
Accepted
18
2,940
77
S = list(input()) print('Yes') if sorted(S) == ['a','b','c'] else print('No')
s483654110
p03544
u170324846
2,000
262,144
Wrong Answer
18
2,940
108
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
N = int(input()) L = [0] * (N + 1) L[0] = 2 L[1] = 1 for i in range(2,N): L[i] = L[i-1]+L[i-2] print(L[N])
s534582760
Accepted
17
2,940
111
N = int(input()) L = [0] * (N + 1) L[0] = 2 L[1] = 1 for i in range(2,N+1): L[i] = L[i-1]+L[i-2] print(L[N])
s735063433
p03351
u468940068
2,000
1,048,576
Wrong Answer
21
3,316
167
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
# coding: utf-8 a, b, c, d = map(int, input().split()) if abs(a-c) <= d: print('YES') elif abs(a-b) <= d and abs(b-c) <= d: print('YES') else: print('NO')
s970456600
Accepted
22
3,316
167
# coding: utf-8 a, b, c, d = map(int, input().split()) if abs(a-c) <= d: print('Yes') elif abs(a-b) <= d and abs(b-c) <= d: print('Yes') else: print('No')
s658791342
p03160
u041401317
2,000
1,048,576
Wrong Answer
99
13,980
408
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
def main(): n = int(input()) hts = list(map(int,input().split())) if n == 2: print(abs(hts[0]-hts[1])) return dp = [float('inf')]*n dp[0] = 0 dp[1] = abs(dp[1]-dp[0]) ## dp[i] for i in range(2,n): dp[i] = min(dp[i-1]+abs(hts[i]-hts[i-1]), dp[i-2]+abs(hts[i]-hts[i-2])) print(dp[-1]) main()
s247054559
Accepted
102
13,928
426
def main(): n = int(input()) hts = list(map(int,input().split())) if n == 2: print(abs(hts[0]-hts[1])) return dp = [float('inf')]*n dp[0] = 0 dp[1] = abs(hts[1]-hts[0]) ## dp[i] for i in range(2,n): dp[i] = min(dp[i-1]+abs(hts[i]-hts[i-1]), dp[i-2]+abs(hts[i]-hts[i-2])) #print(dp) print(dp[-1]) main()
s336333507
p02613
u950847221
2,000
1,048,576
Wrong Answer
29
9,068
267
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.
tr=int(input()) word=input() a=0 w=0 t=0 r=0 i=0 for i in range(1<=tr<=10*5): i+=1 if word=='AC': a+=1 elif word=='WA': w+=1 elif word=='TLE': t+=1 else: r+=1 print('AC*a') print('WA*w') print('TLE*t') print('RE*r')
s697658370
Accepted
145
9,156
288
tr=int(input()) a=0 w=0 t=0 r=0 for i in range(tr): word=input() if word=='AC': a+=1 elif word=='WA': w+=1 elif word=='TLE': t+=1 else: r+=1 print('AC x '+str(a)) print('WA x '+str(w)) print('TLE x '+str(t)) print('RE x '+str(r))
s689571325
p02612
u297089927
2,000
1,048,576
Wrong Answer
28
9,148
48
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 n=int(input()) print(math.ceil(n)-n)
s132134268
Accepted
30
8,960
29
n=int(input()) print(-n%1000)
s246371719
p03852
u960570220
2,000
262,144
Wrong Answer
29
9,100
121
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`.
c = str(input()) if c == 'a' and c == 'e' and c == 'i' and c == 'o' and c == 'u': print('Yes') else: print('No')
s381211625
Accepted
26
9,028
126
c = str(input()) if c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u': print('vowel') else: print('consonant')
s501318799
p03493
u497326082
2,000
262,144
Wrong Answer
20
3,316
110
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
a = input() b = 1 c = 0 print(a) print(a[b]) for b in range(3): if int(a[b]) == 1: c += 1 print(c)
s394313872
Accepted
17
2,940
86
s=input() ans=0 if s[0]=="1":ans+=1 if s[1]=="1":ans+=1 if s[2]=="1":ans+=1 print(ans)
s993720128
p02293
u279605379
1,000
131,072
Wrong Answer
20
7,652
318
For given two lines s1 and s2, print "2" if they are parallel, "1" if they are orthogonal, or "0" otherwise. s1 crosses points p0 and p1, and s2 crosses points p2 and p3.
def dot(a,b):return a[0]*b[0] + a[1]*b[1] def cross(a,b):return a[0]*b[1] - a[1]*b[0] q = int(input()) for i in range(q): x0,y0,x1,y1,x2,y2,x3,y3 = [int(i) for i in input().split()] a = [x1-x0,y1-y0] b = [x3-x2,y3-y1] if dot(a,b) == 0 : print(1) elif cross(a,b) == 0 : print(2) else : print(0)
s033306097
Accepted
30
7,748
318
def dot(a,b):return a[0]*b[0] + a[1]*b[1] def cross(a,b):return a[0]*b[1] - a[1]*b[0] q = int(input()) for i in range(q): x0,y0,x1,y1,x2,y2,x3,y3 = [int(i) for i in input().split()] a = [x1-x0,y1-y0] b = [x3-x2,y3-y2] if dot(a,b) == 0 : print(1) elif cross(a,b) == 0 : print(2) else : print(0)
s925451197
p02233
u869924057
1,000
131,072
Wrong Answer
20
5,596
168
Write a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th fibonacci number is defined by the following recursive formula: \begin{equation*} fib(n)= \left \\{ \begin{array}{ll} 1 & (n = 0) \\\ 1 & (n = 1) \\\ fib(n - 1) + fib(n - 2) & \\\ \end{array} \right. \end{equation*}
memo = [0, 1] def fib(n): if (n in memo): return memo[n] ans = fib(n-1) + fib(n-2) memo.append(ans) return ans n = int(input()) print(fib(n))
s391124287
Accepted
20
5,600
163
memo = [1, 1] def fib(n): if (n < len(memo)): return memo[n] memo.append(fib(n-1) + fib(n-2)) return memo[n] N = int(input()) print(fib(N))
s084994995
p03777
u407106303
2,000
262,144
Wrong Answer
17
2,940
60
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or Dishonest_. In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either `H` or `D`, and carries the following information: If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`, AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that TopCoDeer is dishonest. Given this information, determine whether TopCoDeer is honest.
a,b=input().split() print('H' if (a=='D')^(b=='D') else 'D')
s743618191
Accepted
17
2,940
60
a,b=input().split() print('D' if (a=='H')^(b=='H') else 'H')
s676893764
p03643
u473023730
2,000
262,144
Wrong Answer
17
2,940
33
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=str(input()) a="ABC" print(n+a)
s511171602
Accepted
17
2,940
33
n=str(input()) a="ABC" print(a+n)
s731663155
p02975
u377989038
2,000
1,048,576
Wrong Answer
86
22,976
311
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`. * The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself. What is XOR? The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non- negative integers x_1, x_2, \ldots, x_n is defined as follows: - When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3 \oplus 5 = 6.
from collections import Counter as ct import sys input = sys.stdin.readline n = int(input()) a = input().split() c = ct(a) print(c) if c["0"] == n: print("Yes") elif len(c) == 2 and c["0"] * 3 == n: print("Yes") elif len(c) == 3 and c[0] == c[1] and c[1] == c[2]: print("Yes") else: print("No")
s783736507
Accepted
53
14,468
393
from collections import Counter as ct import sys input = sys.stdin.readline n = int(input()) a = list(map(int, input().split())) c = ct(a) if c[0] == n: print("Yes") elif len(c) == 2 and c[0] * 3 == n: print("Yes") elif len(c) == 3 and len(set(c.values())) == 1: a, b, c = c.keys() if (a ^ b ^ c) == 0: print("Yes") else: print("No") else: print("No")
s380249676
p03998
u017719431
2,000
262,144
Wrong Answer
18
2,940
58
Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game.
cards_list = [input() for _ in range(3)] print(cards_list)
s111174100
Accepted
17
3,064
447
cards_list = [input() for _ in range(3)] def battle(cards_list): dict = {"a": 0, "b": 1, "c": 2} current = "a" while True: index = dict[current] #0 current = cards_list[index][0] #b if len(cards_list[index]) > 1: cards_list[index] = cards_list[index][1:] else: cards_list[index] = [] index = dict[current] if len(cards_list[index]) == 0: return current.upper() print(battle(cards_list))
s417725862
p03448
u502028059
2,000
262,144
Wrong Answer
49
3,060
234
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
a = int(input()) b = int(input()) c = int(input()) x = int(input()) ans = 0 for i in range(a+1): for x in range(b+1): for z in range(c+1): if 500 * i + 100 * x + 10 * z == x: ans += 1 print(ans)
s327717570
Accepted
51
3,060
251
a = int(input()) b = int(input()) c = int(input()) x = int(input()) ans = 0 for i in range(a+1): for y in range(b+1): for z in range(c+1): if 500 * i + 100 * y + 50 * z == x: ans += 1 print(ans)
s041869300
p03813
u117629640
2,000
262,144
Wrong Answer
23
3,192
237
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise. You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise.
# -*- coding: utf-8 -*- def main(): x = int(input()) ans = (x // 11) * 2 x %= 11 if x > 0: if x > 6: ans += 2 else: ans += 1 print(ans) if __name__ == '__main__': main()
s756192451
Accepted
24
3,064
144
# -*- coding: utf-8 -*- def main(): a = int(input()) print('ABC') if a < 1200 else print('ARC') if __name__ == '__main__': main()