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
s433273055
p02412
u713218261
1,000
131,072
Wrong Answer
30
6,724
307
Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9
while True: (n, x) = [int(i) for i in input().split()] if n == x == 0: break for a in range(1, n + 1): for b in range(2, n + 1): for c in range(3, n + 1): count = 0 if (a + b + c) == x: count += 1 print(count)
s310156226
Accepted
500
6,724
357
while True: (n, x) = [int(i) for i in input().split()] if n == x == 0: break count = 0 for a in range(1, n+1): for b in range(a+1, n+1): for c in range(b+1, n+1): if (a + b + c) == x: count += 1 elif (a + b + c) > x: break print(count)
s435052348
p00005
u847467233
1,000
131,072
Wrong Answer
20
5,620
304
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.
# AOJ 0005 GCD and LCM # Python3 2018.6.9 bal4u def lcm(a, b): return a/gcd(a, b)*b def gcd(a, b): while b != 0: r = a % b a = b b = r return a while True: try: a = list(map(int, input().split())) print(gcd(a[0], a[1]), lcm(a[0], a[1])) except EOFError: break
s469508341
Accepted
20
5,604
309
# AOJ 0005 GCD and LCM # Python3 2018.6.9 bal4u def lcm(a, b): return a // gcd(a, b) * b def gcd(a, b): while b != 0: r = a % b a = b b = r return a while True: try: a = list(map(int, input().split())) print(gcd(a[0], a[1]), lcm(a[0], a[1])) except EOFError: break
s187218672
p02972
u464244643
2,000
1,048,576
Wrong Answer
2,104
8,228
441
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
import sys sys.setrecursionlimit(10 ** 6) def input(): return sys.stdin.readline()[:-1] def main(): N = int(input()) a = [-1]+list(map(int, input().split())) b = [0] * (N+1) for i in reversed(range(1,N+1)): total = 0 for j in range(i,N+1): if i%j==0: total += b[j] if a[i] != (total%2): b[i] = 1 print(*b[1:]) if __name__ == "__main__": main()
s081236137
Accepted
377
14,124
548
import sys sys.setrecursionlimit(10 ** 6) def input(): return sys.stdin.readline()[:-1] def main(): N = int(input()) a = [-1]+list(map(int, input().split())) b = [0] * (N+1) for i in reversed(range(1,N+1)): total = 0 for j in range(i,N+1,i): total += b[j] if a[i] != (total%2): b[i] = 1 ans = [] cnt = 0 for i, n in enumerate(b): if n!=0: ans.append(i) cnt += 1 print(cnt) print(*ans) if __name__ == "__main__": main()
s289575855
p03469
u075303794
2,000
262,144
Wrong Answer
17
2,940
42
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() s.replace('8/', '9/') print(s)
s106566191
Accepted
17
2,940
42
S=str(input()) print(S.replace('7/','8/'))
s727639277
p03457
u377834804
2,000
262,144
Wrong Answer
269
26,988
321
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
N = int(input()) TXY = [list(map(int, input().split())) for _ in range(N)] pre_t, pre_x, pre_y = 0, 0, 0 for t, x, y in TXY: diff_t = t - pre_t diff_pos = abs(x-pre_x) + abs(y-pre_y) if diff_t > diff_pos or diff_pos-diff_t % 2 == 1: print('No') exit() else: pre_t, pre_x, pre_y = t, x, y print('Yes')
s906551144
Accepted
270
26,864
324
N = int(input()) TXY = [list(map(int, input().split())) for _ in range(N)] pre_t, pre_x, pre_y = 0, 0, 0 for t, x, y in TXY: diff_t = t - pre_t diff_pos = abs(x-pre_x) + abs(y-pre_y) if diff_t < diff_pos or (diff_t-diff_pos) % 2 == 1: print('No') exit() else: pre_t, pre_x, pre_y = t, x, y print('Yes')
s066785650
p03854
u607930911
2,000
262,144
Wrong Answer
20
3,188
199
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() judge = "YES" s = s.replace("eraser", "0") s = s.replace("erase", "0") s = s.replace("dreamer", "0") s = s.replace("dream", "0") if not s.isdigit(): judge = "NO" print(s) print(judge)
s135241110
Accepted
20
3,188
190
s = input() judge = "YES" s = s.replace("eraser", "0") s = s.replace("erase", "0") s = s.replace("dreamer", "0") s = s.replace("dream", "0") if not s.isdigit(): judge = "NO" print(judge)
s851731734
p02613
u736443076
2,000
1,048,576
Wrong Answer
144
16,112
199
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 = [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'))))
s392057996
Accepted
136
16,184
125
n = int(input()) s = [input() for i in range(n)] ans = ['AC', 'WA', 'TLE', 'RE'] for i in ans: print(i, 'x', s.count(i))
s205283444
p03737
u977370660
2,000
262,144
Wrong Answer
18
2,940
72
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
a,b,c = input().split() s1 = a[0] s2 = b[0] s3 = c[0] print(s1+s2+s3)
s006048650
Accepted
17
2,940
83
N = input().upper() N = N.split() print("{}{}{}".format(N[0][0],N[1][0],N[2][0]))
s135557790
p03434
u375870553
2,000
262,144
Wrong Answer
18
2,940
317
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.
def main(): n = int(input()) a = [int(i) for i in input().split()] a.sort() sw = 0 alice = 0 bob = 0 for i in a: if sw == 0: alice += i sw = 1 else: bob += i sw = 0 print(alice-bob) if __name__ == '__main__': main()
s019384100
Accepted
17
3,060
330
def main(): n = int(input()) a = [int(i) for i in input().split()] a.sort(reverse=True) sw = 0 alice = 0 bob = 0 for i in a: if sw == 0: alice += i sw = 1 else: bob += i sw = 0 print(alice-bob) if __name__ == '__main__': main()
s356422258
p02613
u598684283
2,000
1,048,576
Wrong Answer
145
9,224
324
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()) ac = 0 wa = 0 tle = 0 re = 0 for i in range(n): tmp = input() if tmp == "AC": ac += 1 elif tmp == "WA": wa += 1 elif tmp == "tle": tle += 1 else: re += 1 print("AC x " + str(ac)) print("WA x " + str(wa)) print("TLE x " + str(tle)) print("RE x " + str(re))
s182256314
Accepted
144
9,044
324
n = int(input()) ac = 0 wa = 0 tle = 0 re = 0 for i in range(n): tmp = input() if tmp == "AC": ac += 1 elif tmp == "WA": wa += 1 elif tmp == "TLE": tle += 1 else: re += 1 print("AC x " + str(ac)) print("WA x " + str(wa)) print("TLE x " + str(tle)) print("RE x " + str(re))
s718196038
p03861
u518042385
2,000
262,144
Wrong Answer
2,104
2,940
149
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?
x,y,z=map(int,input().split()) t1=0 t2=0 for i in range(1,x): if i%z==0: t1+=1 for i in range(1,y): if i%z==0: t2+=1 print(t2-t1)
s775541408
Accepted
17
2,940
88
a,s,d=map(int,input().split()) if a%d==0: print(s//d-a//d+1) else: print(s//d-a//d)
s466715091
p02613
u465423770
2,000
1,048,576
Wrong Answer
145
9,204
264
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.
num = int(input()) count = {"AC":0,"WA":0,"TLE":0,"RE":0} for _ in range(num): s = input() count[s] += 1 print("AC x {}".format(count["AC"])) print("WA x {}".format(count["WA"])) print("TLE x {}".format(count["TLE"])) print("RE {}".format(count["RE"]))
s464682318
Accepted
146
9,212
266
num = int(input()) count = {"AC":0,"WA":0,"TLE":0,"RE":0} for _ in range(num): s = input() count[s] += 1 print("AC x {}".format(count["AC"])) print("WA x {}".format(count["WA"])) print("TLE x {}".format(count["TLE"])) print("RE x {}".format(count["RE"]))
s379080153
p03448
u995861601
2,000
262,144
Wrong Answer
50
3,064
222
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()) pattern = 0 for i in range(c+1): for j in range(b+1): for k in range(a+1): if 500*a - 100*b - 50*c == x: pattern += 1 print(pattern)
s217865645
Accepted
51
3,060
222
a = int(input()) b = int(input()) c = int(input()) x = int(input()) pattern = 0 for i in range(c+1): for j in range(b+1): for k in range(a+1): if 500*k + 100*j + 50*i == x: pattern += 1 print(pattern)
s821358558
p02407
u187646742
1,000
131,072
Wrong Answer
20
7,608
85
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(" ".join(map(str, a)))
s846198358
Accepted
40
7,756
122
_ = input() a = list(map(int, input().split())) a = list(a[i] for i in range(len(a)-1,-1,-1)) print(" ".join(map(str, a)))
s066403644
p03436
u327248573
2,000
262,144
Wrong Answer
32
3,956
740
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares. Before Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game. When the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares. The color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is `.`; if square (i, j) is initially painted by black, s_{i, j} is `#`.
from collections import deque from itertools import chain H, W = map(int, input().split(' ')) Maze = [list(input()) for _ in range(H)] White = list(chain.from_iterable(Maze)).count('.') Maze[0][0] = 1 q = deque([]) current = [0, 0] q.append(current) dir_x = [1, -1, 0, 0] dir_y = [0, 0, 1, -1] while len(q) > 0: now_y, now_x = q.popleft() print(now_y, now_x) if now_y == H-1 and now_x == W-1 : break for (dx, dy) in zip(dir_x, dir_y): if 0 <= now_y + dy <= H-1 and 0 <= now_x + dx <= W-1 and Maze[now_y + dy][now_x + dx] == '.': Maze[now_y + dy][now_x + dx] = Maze[now_y][now_x] + 1 q.append([now_y + dy, now_x + dx]) if Maze[H-1][W-1] == '.': print(-1) else: print(White - Maze[H-1][W-1])
s843218868
Accepted
28
3,316
716
from collections import deque from itertools import chain H, W = map(int, input().split(' ')) Maze = [list(input()) for _ in range(H)] White = list(chain.from_iterable(Maze)).count('.') Maze[0][0] = 1 q = deque([]) current = [0, 0] q.append(current) dir_x = [1, -1, 0, 0] dir_y = [0, 0, 1, -1] while len(q) > 0: now_y, now_x = q.popleft() if now_y == H-1 and now_x == W-1 : break for (dx, dy) in zip(dir_x, dir_y): if 0 <= now_y + dy <= H-1 and 0 <= now_x + dx <= W-1 and Maze[now_y + dy][now_x + dx] == '.': Maze[now_y + dy][now_x + dx] = Maze[now_y][now_x] + 1 q.append([now_y + dy, now_x + dx]) if Maze[H-1][W-1] == '.': print(-1) else: print(White - Maze[H-1][W-1])
s288642320
p03359
u806855121
2,000
262,144
Wrong Answer
17
2,940
95
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 example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
a, b = map(int, input().split()) ans = a - 1 if b > a: print(ans+1) else: print(ans)
s245146425
Accepted
17
2,940
80
a, b = map(int, input().split()) if b >= a: print(a) else: print(a-1)
s096703893
p03853
u652656291
2,000
262,144
Wrong Answer
17
3,060
117
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).
h,w = map(int,input().split()) l = list(map(str,input().split())) for i in range(len(l)): print(l[i]) print(l[i])
s391484721
Accepted
17
3,060
112
h, w = list(map(int, input().split())) c = [input() for i in range(h)] for i in range(h*2): print(c[i // 2])
s099884099
p03160
u715107458
2,000
1,048,576
Wrong Answer
50
14,476
432
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.
from functools import lru_cache N = int(input()) heights = [int(h) for h in input().split()] @lru_cache(None) def dfs(i): if i == len(heights) - 1: return 0 if i >= len(heights): return float("inf") return min(abs(heights[i] - heights[i + 1]) + dfs(i + 1) if i + 1 < len(heights) else float("inf"), abs(heights[i] - heights[i + 2]) + dfs(i + 2) if i + 2 < len(heights) else float("inf"))
s780255115
Accepted
137
14,976
849
import sys from functools import lru_cache sys.setrecursionlimit(20000000) N = int(input()) heights = [int(h) for h in input().split()] # heights = [10, 30, 40, 20] # heights = [10, 10] # heights = [30, 10, 60, 10, 60, 50] @lru_cache(None) def dfs(i): if i == len(heights) - 1: return 0 return min(abs(heights[i] - heights[i + 1]) + dfs(i + 1) if i + 1 < len(heights) else float("inf"), abs(heights[i] - heights[i + 2]) + dfs(i + 2) if i + 2 < len(heights) else float("inf")) def helper(): dp = [float("inf")] * len(heights) dp[0] = 0 for i in range(1, len(heights)): dp[i] = min(dp[i], dp[i - 1] + abs(heights[i] - heights[i - 1])) if i > 1: dp[i] = min(dp[i], dp[i - 2] + abs(heights[i] - heights[i - 2])) return dp[-1] # print(dfs(0)) print(helper())
s305601350
p03471
u117193815
2,000
262,144
Wrong Answer
2,104
3,060
220
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
n,y=map(int, input().split()) a=10000 b=5000 c=1000 for i in range(n+1): for j in range(n-i): for k in range(n-i-j): if (i*a)+(j*b)+(k*c)==y: print(i,j,k) exit() print(-1,-1,-1)
s608795299
Accepted
782
3,060
184
n,y=map(int, input().split()) a=-1 b=-1 c=-1 for i in range(n+1): for j in range(n-i+1): k=n-i-j if (i*10000)+(j*5000)+(k*1000)==y: a=i b=j c=k print(a,b,c)
s337371739
p03478
u524765246
2,000
262,144
Wrong Answer
33
3,064
390
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
lst = list(map(int, input().split())) ans = 0 tot = 0 cnt = 0 for i in range(1,lst[0]+1): flg = True val = i while flg: cnt += 1 tot = tot + val%10 val = val//10 if val==0: if ( lst[1] <= tot and tot <= lst[2] ): ans = ans + i tot = 0 flg = False print("Sum: " + str(ans))
s570567792
Accepted
34
3,064
379
lst = list(map(int, input().split())) ans = 0 tot = 0 cnt = 0 for i in range(1,lst[0]+1): flg = True val = i while flg: cnt += 1 tot = tot + val%10 val = val//10 if val==0: if ( lst[1] <= tot and tot <= lst[2] ): ans = ans + i tot = 0 flg = False print(ans)
s843203510
p03854
u143492911
2,000
262,144
Wrong Answer
19
3,188
146
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().replace("eraser",",").replace("eraser",",").replace("dreamer",",").replace("dream",",").replace(",","") print("YES" if s=="" else "NO")
s488050412
Accepted
23
6,516
99
import re s=input() print("YES") if re.match("^(dream|dreamer|erase|eraser)+$",s) else print("NO")
s789296413
p03563
u209951743
2,000
262,144
Wrong Answer
18
2,940
128
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()) S = 1 for i in range(N): if S < K: S = S*2 else: S = S + K print(S)
s732375729
Accepted
17
2,940
57
R = int(input()) G = int(input()) A =G * 2 - R print(A)
s199527831
p03556
u763881112
2,000
262,144
Time Limit Exceeded
2,108
36,824
98
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
import numpy as np n=int(input()) for i in range(10**9): if(i*i>n): print((i-1)**2)
s438010668
Accepted
17
3,060
32
print(int(int(input())**0.5)**2)
s142545992
p02612
u809819902
2,000
1,048,576
Wrong Answer
27
9,140
24
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.
print(int(input())%1000)
s217177993
Accepted
29
9,156
53
n=int(input()) print(0 if n%1000==0 else 1000-n%1000)
s318546299
p03998
u135521563
2,000
262,144
Wrong Answer
24
3,316
527
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.
a = input() b = input() c = input() a_pos = 0 b_pos = 0 c_pos = 0 now = 'a' while True: print(a_pos, b_pos, c_pos, now) if now == 'a': if len(a) < a_pos + 1: print('A') break now = a[a_pos] a_pos += 1 elif now == 'b': if len(b) < b_pos + 1: print('B') break now = b[b_pos] b_pos += 1 elif now == 'c': if len(c) < c_pos + 1: print('C') break now = c[c_pos] c_pos += 1
s525955205
Accepted
23
3,064
491
a = input() b = input() c = input() a_pos = 0 b_pos = 0 c_pos = 0 now = 'a' while True: if now == 'a': if len(a) < a_pos + 1: print('A') break now = a[a_pos] a_pos += 1 elif now == 'b': if len(b) < b_pos + 1: print('B') break now = b[b_pos] b_pos += 1 elif now == 'c': if len(c) < c_pos + 1: print('C') break now = c[c_pos] c_pos += 1
s599651206
p03719
u153729035
2,000
262,144
Wrong Answer
19
2,940
65
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
A,B,C=list(map(int,input().split())) print(['NO','YES'][A<=C<=B])
s269536126
Accepted
17
2,940
65
A,B,C=list(map(int,input().split())) print(['No','Yes'][A<=C<=B])
s373560531
p02613
u954153335
2,000
1,048,576
Wrong Answer
156
16,616
278
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.
import collections n=int(input()) data=[] for i in range(n): num=input() data.append(num) data=collections.Counter(data) print("AC × {}".format(data["AC"])) print("WA × {}".format(data["WA"])) print("TLE × {}".format(data["TLE"])) print("RE × {}".format(data["RE"]))
s461168501
Accepted
159
16,620
274
import collections n=int(input()) data=[] for i in range(n): num=input() data.append(num) data=collections.Counter(data) print("AC x {}".format(data["AC"])) print("WA x {}".format(data["WA"])) print("TLE x {}".format(data["TLE"])) print("RE x {}".format(data["RE"]))
s217238147
p03826
u060793972
2,000
262,144
Wrong Answer
17
2,940
52
There are two rectangles. The lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B. The lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D. Print the area of the rectangle with the larger area. If the two rectangles have equal areas, print that area.
a,b,c,d=map(int,input().split()) print(min(a*b,c*d))
s636534461
Accepted
17
2,940
52
a,b,c,d=map(int,input().split()) print(max(a*b,c*d))
s486634704
p03386
u773246942
2,000
262,144
Wrong Answer
20
3,316
164
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
A, B, K =map(int,input().split()) C = [] for i in range(A, A+K): C.append(i) D = [] for i in range(B, B-K, -1) : D.append(i) E = set(C) | set(D) print(E)
s252736684
Accepted
17
3,060
295
A, B, K =map(int,input().split()) if B-A <= K: for i in range(A, B+1): print(i) else: C = [] for i in range(A, A+K): C.append(i) D = [] for i in range(B, B-K, -1) : D.append(i) E = set(C) | set(D) F = sorted(E) for i in range(len(F)): print(F[i])
s640978200
p03548
u580362735
2,000
262,144
Wrong Answer
17
2,940
62
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person. At most how many people can sit on the seat?
X,Y,Z = map(int,input().split()) print((X - (Y + 2*Z))//(Y+Z))
s804043424
Accepted
17
2,940
65
X,Y,Z = map(int,input().split()) print((X - (Y + 2*Z))//(Y+Z)+1)
s006365623
p03409
u419686324
2,000
262,144
Wrong Answer
2,104
4,596
777
On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.
N = int(input()) R = [tuple([int(x) for x in input().split()]) for _ in range(N)] B = [tuple([int(x) for x in input().split()]) for _ in range(N)] xl = [set() for _ in range(2 * N + 1)] yl = [set() for _ in range(2 * N + 1)] for b in B: x, y = b for i in range(x): xl[i].add(b) for j in range(y): yl[j].add(b) cands = [] for r in R: x, y = r s = xl[x] and yl[y] cands.append([r, len(s), s]) def f(cands, used, n): if not cands: return n ret = 0 hd, tl = cands[0], cands[1:] r, _, s = hd for t in s - used: u = used.union({t}) ret = max(ret, f(tl, u, n + 1)) ret = max(ret, f(tl, used, n)) return ret import operator cands.sort(key=operator.itemgetter(1)) print(f(cands, set(), 0))
s280731441
Accepted
19
3,188
384
N = int(input()) R = [[int(x) for x in input().split()] for _ in range(N)] B = [[int(x) for x in input().split()] for _ in range(N)] import operator R.sort(key=operator.itemgetter(1), reverse=True) B.sort() ans = 0 for b in B: xb, yb = b for r in R: xr, yr = r if xr < xb and yr < yb: ans += 1 R.remove(r) break print(ans)
s022894239
p02692
u961674365
2,000
1,048,576
Wrong Answer
313
17,328
5,248
There is a game that involves three variables, denoted A, B, and C. As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `AB`, you must add 1 to A or B then subtract 1 from the other; if s_i is `AC`, you must add 1 to A or C then subtract 1 from the other; if s_i is `BC`, you must add 1 to B or C then subtract 1 from the other. After each choice, none of A, B, and C should be negative. Determine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.
n,a,b,c = map(int,input().split()) ss=['' for _ in range(n)] ans=['' for _ in range(n)] wa=a+b+c for i in range(n): s=input() ss[i]=s i=0 if wa==0: print('No') exit() elif wa==1: for s in ss: if s=='AB': if c: print('No') exit() elif b: a+=1 b-=1 ans[i]='A' elif a: b+=1 a-=1 ans[i]='B' elif s=='AC': if b: print('No') exit() elif a: c+=1 a-=1 ans[i]='C' elif c: a+=1 c-=1 ans[i]='A' elif s=='BC': if a: print('No') exit() elif b: c+=1 b-=1 ans[i]='C' elif c: b+=1 c-=1 ans[i]='B' i+=1 elif wa==2: for s in ss: if s=='AB': if a==0 and b==0: print('No') exit() elif a==0: a+=1 b-=1 ans[i]='A' elif b==0: b+=1 a-=1 ans[i]='B' elif a==1 and b==1: if i==n-1: ans[i]='A' else: if ss[i+1]=='AC' or ss[i+1]=='AB': a+=1 b-=1 ans[i]='A' elif ss[i+1]=='BC': b+=1 a-=1 ans[i]='B' elif s=='AC': if a==0 and c==0: print('No') exit() elif a==0: a+=1 c-=1 ans[i]='A' elif c==0: c+=1 a-=1 ans[i]='C' elif a==1 and c==1: if i==n-1: ans[i]='A' else: if ss[i+1]=='AC' or ss[i+1]=='AB': a+=1 c-=1 ans[i]='A' elif ss[i+1]=='BC': c+=1 a-=1 ans[i]='C' elif s=='BC': if b==0 and c==0: print('No') exit() elif b==0: b+=1 c-=1 ans[i]='B' elif c==0: c+=1 b-=1 ans[i]='C' elif b==1 and c==1: if i==n-1: ans[i]='B' else: if ss[i+1]=='BC' or ss[i+1]=='AB': b+=1 c-=1 ans[i]='B' elif ss[i+1]=='AC': c+=1 b-=1 ans[i]='C' i+=1 elif wa>2: for i in range(n): s=ss[i] if s=='AB': if a==0 and b==0: print('No') exit() elif a==0: a+=1 b-=1 ans[i]='A' elif b==0: b+=1 a-=1 ans[i]='B' else: if i==n-1: ans[i]='A' a+=1 b-=1 else: if b>=a: a+=1 b-=1 ans[i]='A' else: b+=1 a-=1 ans[i]='B' elif s=='AC': if a==0 and c==0: print('No') exit() elif a==0: a+=1 c-=1 ans[i]='A' elif c==0: c+=1 a-=1 ans[i]='C' else: if i==n-1: ans[i]='A' a+=1 c-=1 else: if c>=a: a+=1 c-=1 ans[i]='A' else: c+=1 a-=1 ans[i]='C' elif s=='BC': if b==0 and c==0: print('No') exit() elif b==0: b+=1 c-=1 ans[i]='B' elif c==0: c+=1 b-=1 ans[i]='C' else: if i==n-1: ans[i]='B' b+=1 c-=1 else: if c>=b: b+=1 c-=1 ans[i]='B' else: c+=1 b-=1 ans[i]='C' print(i,a,b,c) print('Yes') for x in ans: print(x)
s091019027
Accepted
225
16,988
5,249
n,a,b,c = map(int,input().split()) ss=['' for _ in range(n)] ans=['' for _ in range(n)] wa=a+b+c for i in range(n): s=input() ss[i]=s i=0 if wa==0: print('No') exit() elif wa==1: for s in ss: if s=='AB': if c: print('No') exit() elif b: a+=1 b-=1 ans[i]='A' elif a: b+=1 a-=1 ans[i]='B' elif s=='AC': if b: print('No') exit() elif a: c+=1 a-=1 ans[i]='C' elif c: a+=1 c-=1 ans[i]='A' elif s=='BC': if a: print('No') exit() elif b: c+=1 b-=1 ans[i]='C' elif c: b+=1 c-=1 ans[i]='B' i+=1 elif wa==2: for s in ss: if s=='AB': if a==0 and b==0: print('No') exit() elif a==0: a+=1 b-=1 ans[i]='A' elif b==0: b+=1 a-=1 ans[i]='B' elif a==1 and b==1: if i==n-1: ans[i]='A' else: if ss[i+1]=='AC' or ss[i+1]=='AB': a+=1 b-=1 ans[i]='A' elif ss[i+1]=='BC': b+=1 a-=1 ans[i]='B' elif s=='AC': if a==0 and c==0: print('No') exit() elif a==0: a+=1 c-=1 ans[i]='A' elif c==0: c+=1 a-=1 ans[i]='C' elif a==1 and c==1: if i==n-1: ans[i]='A' else: if ss[i+1]=='AC' or ss[i+1]=='AB': a+=1 c-=1 ans[i]='A' elif ss[i+1]=='BC': c+=1 a-=1 ans[i]='C' elif s=='BC': if b==0 and c==0: print('No') exit() elif b==0: b+=1 c-=1 ans[i]='B' elif c==0: c+=1 b-=1 ans[i]='C' elif b==1 and c==1: if i==n-1: ans[i]='B' else: if ss[i+1]=='BC' or ss[i+1]=='AB': b+=1 c-=1 ans[i]='B' elif ss[i+1]=='AC': c+=1 b-=1 ans[i]='C' i+=1 elif wa>2: for i in range(n): s=ss[i] if s=='AB': if a==0 and b==0: print('No') exit() elif a==0: a+=1 b-=1 ans[i]='A' elif b==0: b+=1 a-=1 ans[i]='B' else: if i==n-1: ans[i]='A' a+=1 b-=1 else: if b>=a: a+=1 b-=1 ans[i]='A' else: b+=1 a-=1 ans[i]='B' elif s=='AC': if a==0 and c==0: print('No') exit() elif a==0: a+=1 c-=1 ans[i]='A' elif c==0: c+=1 a-=1 ans[i]='C' else: if i==n-1: ans[i]='A' a+=1 c-=1 else: if c>=a: a+=1 c-=1 ans[i]='A' else: c+=1 a-=1 ans[i]='C' elif s=='BC': if b==0 and c==0: print('No') exit() elif b==0: b+=1 c-=1 ans[i]='B' elif c==0: c+=1 b-=1 ans[i]='C' else: if i==n-1: ans[i]='B' b+=1 c-=1 else: if c>=b: b+=1 c-=1 ans[i]='B' else: c+=1 b-=1 ans[i]='C' #print(i,a,b,c) print('Yes') for x in ans: print(x)
s609726561
p03605
u705418271
2,000
262,144
Wrong Answer
27
9,080
72
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
n=str(input()) if n[0]==9 or n[1]==9: print("Yes") else: print("No")
s894063718
Accepted
31
9,080
57
n=input() if "9" in n: print("Yes") else: print("No")
s702768042
p03476
u102126195
2,000
262,144
Wrong Answer
2,104
7,960
663
We say that a odd number N is _similar to 2017_ when both N and (N+1)/2 are prime. You are given Q queries. In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.
PN = [i for i in range(100001)] i = 2 print(PN[1:20]) while True: if i >= len(PN): break j = i * 2 while True: if j >= len(PN): break PN[j] = 0 j += i while True: i += 1 if i >= len(PN): break if PN[i] != 0: break PN[1] = 0 PN_2 = [] for i in range(100001): if PN[i] != 0 and PN[int((PN[i] + 1) / 2)] != 0: PN_2.append(PN[i]) else: PN_2.append(0) Q = int(input()) lr = [] for i in range(Q): cnt = 0 l, r = map(int, input().split()) for j in range(l, r + 1): if PN_2[j] != 0: cnt += 1 print(cnt)
s302808556
Accepted
969
9,068
727
PN = [i for i in range(100001)] i = 2 while True: if i >= len(PN): break j = i * 2 while True: if j >= len(PN): break PN[j] = 0 j += i while True: i += 1 if i >= len(PN): break if PN[i] != 0: break PN[1] = 0 PN_2 = [0] DPN = [0] for i in range(1, 100001): if PN[i] != 0 and PN[int((PN[i] + 1) / 2)] != 0: PN_2.append(PN[i]) DPN.append(DPN[i - 1] + 1) else: PN_2.append(0) DPN.append(DPN[i - 1]) #print(PN[1:30]) #print(PN_2[1:30]) #print(DPN[1:30]) Q = int(input()) lr = [] for i in range(Q): cnt = 0 l, r = map(int, input().split()) print(DPN[r] - DPN[l - 1])
s656547169
p03730
u906017074
2,000
262,144
Wrong Answer
17
2,940
119
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
a,b,c = input().split() ans = 'NO' if a[len(a)-1] == b[0]: if b[len(b)-1 == c[0]]: ans = 'YES' print(ans)
s058851497
Accepted
17
2,940
235
a, b, c = [int(i) for i in input().split()] ans='NO' i = 1 f = a % b while(1): tmp = a * i mod = tmp % b if mod == c: ans = 'YES' break if i != 1 and mod == f: break i += 1 print(ans)
s996615869
p00002
u506705885
1,000
131,072
Wrong Answer
20
7,372
189
Write a program which computes the digit number of sum of two integers a and b.
answers=[] while True: try: nums=input().split() answers.append(len(nums[0])+len(nums[1])) except: break for i in range(len(answers)): print(answers[i])
s792266806
Accepted
20
7,656
199
answers=[] while True: try: nums=input().split() answers.append(len(str(int(nums[0])+int(nums[1])))) except : break for i in range(len(answers)): print(answers[i])
s059173884
p03494
u750651325
2,000
262,144
Wrong Answer
26
8,996
166
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())) a = 0 count = 0 N = [0]*len(A) for i in range(len(A)): if A[i] % 2 == 0: N[i] += 1 print(min(N))
s973312912
Accepted
31
9,084
203
a = int(input()) A = list(map(int, input().split())) N = [0]*len(A) for i in range(a): n = A[i] while n % 2 == 0: if n % 2 == 0: n /= 2 N[i] += 1 print(min(N))
s363979159
p03433
u939552576
2,000
262,144
Wrong Answer
17
2,940
72
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
N = int(input()) A = int(input()) print('YES' if N % 500 <= A else 'NO')
s181797789
Accepted
17
2,940
72
N = int(input()) A = int(input()) print('Yes' if N % 500 <= A else 'No')
s966829146
p03485
u341736906
2,000
262,144
Wrong Answer
19
2,940
89
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()) if (a+b) % 2==0: print((a+b)/2) else: print((a+b+1)/2)
s373667792
Accepted
17
2,940
73
from math import ceil a,b = map(int,input().split()) print(ceil((a+b)/2))
s992819015
p03129
u657221245
2,000
1,048,576
Wrong Answer
17
2,940
119
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
a = list(map(int, input().split())) b = - ( -a[0] // 2 ) if b >= a[1]: print('yes') else: print('no')
s815107519
Accepted
17
2,940
119
a = list(map(int, input().split())) b = - ( -a[0] // 2 ) if b >= a[1]: print('YES') else: print('NO')
s507318326
p03493
u278379520
2,000
262,144
Wrong Answer
17
2,940
43
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=list(input().split()) print(a.count('1'))
s873363162
Accepted
17
2,940
91
a=input() b=0 if a[0]=='1': b+=1 if a[1]=='1': b+=1 if a[2]=='1': b+=1 print(b)
s879201961
p03737
u820351940
2,000
262,144
Wrong Answer
17
2,940
53
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.
"".join(map(lambda x: x[0].upper(), input().split()))
s340178019
Accepted
17
2,940
60
print("".join(map(lambda x: x[0].upper(), input().split())))
s127002180
p04043
u873715358
2,000
262,144
Wrong Answer
17
2,940
81
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.
a = input().split().sort() if a == [5, 5, 7]: print('YES') else: print('NO')
s260305469
Accepted
17
2,940
100
a = [int(n) for n in input().split()] a.sort() if a == [5, 5, 7]: print('YES') else: print('NO')
s124947540
p03712
u137228327
2,000
262,144
Wrong Answer
27
9,456
254
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
from collections import deque H,W = map(int,input().split()) st = [str(input()) for _ in range(H)] print(st) st = deque(st) for i in range(H): st[i] = '#'+st[i]+'#' st.appendleft('#'*(W+2)) st.append('#'*(W+2)) for i in range(H+2): print(st[i])
s113401206
Accepted
28
9,180
136
H,W = map(int,input().split()) st = ['#' + str(input()) +'#' for _ in range(H)] st = ['#'*(W+2)] + st + ['#'*(W+2)] print(*st,sep='\n')
s512260119
p02401
u215335591
1,000
131,072
Wrong Answer
20
5,612
294
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
while True: x = [i for i in input().split()] if x[1] == '?': break a = int(x[0]) b = int(x[2]) if x[1] == '+': print (a + b) elif x[1] == '-': print (a - b) elif x[1] == '*': print (a * b) elif x[1] == '/': print (a / b)
s457278313
Accepted
20
5,604
295
while True: x = [i for i in input().split()] if x[1] == '?': break a = int(x[0]) b = int(x[2]) if x[1] == '+': print (a + b) elif x[1] == '-': print (a - b) elif x[1] == '*': print (a * b) elif x[1] == '/': print (a // b)
s811446917
p03415
u994988729
2,000
262,144
Wrong Answer
17
2,940
48
We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.
print([input()[0],input()[1],input()[2]],sep="")
s348173777
Accepted
18
2,940
50
print("".join([input()[0],input()[1],input()[2]]))
s489206792
p02831
u056830573
2,000
1,048,576
Wrong Answer
51
3,064
1,081
Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted. We assume that a piece cannot be divided and distributed to multiple guests.
number_of_guests = input().split() A = int(number_of_guests[0]) B = int(number_of_guests[1]) A_divisors = [] x = 2 while True: if (A % x == 0): A /= x A_divisors.append(x) else: x += 1 if (A <= 1): break y = 2 B_divisors = [] while True: if (B % y == 0): B /= y B_divisors.append(y) else: y += 1 if (B <= 1): break A_only = [x for x in A_divisors if (x not in B_divisors)] B_only = [y for y in A_divisors if (y not in A_divisors)] common_divisors = [] A_divisors = [3, 3, 2] B_divisors = [3, 3, 4, 2, 3] for z in (A_divisors + B_divisors): if z in A_divisors and z in B_divisors: if (A_divisors.count(z) >= B_divisors.count(z)): common_divisors.append(z**A_divisors.count(z)) else: common_divisors.append(z**B_divisors.count(z)) A_divisors = list(filter(lambda x: x != z, A_divisors)) B_divisors = list(filter(lambda x: x != z, B_divisors)) result = 1 for x in A_only + B_only + common_divisors: result *= x print(x)
s099878125
Accepted
51
3,064
1,034
number_of_guests = input().split() A = int(number_of_guests[0]) B = int(number_of_guests[1]) A_divisors = [] x = 2 while True: if (A % x == 0): A /= x A_divisors.append(x) else: x += 1 if (A <= 1): break y = 2 B_divisors = [] while True: if (B % y == 0): B /= y B_divisors.append(y) else: y += 1 if (B <= 1): break A_only = [x for x in A_divisors if (x not in B_divisors)] B_only = [y for y in B_divisors if (y not in A_divisors)] common_divisors = [] for z in (A_divisors + B_divisors): if z in A_divisors and z in B_divisors: if (A_divisors.count(z) >= B_divisors.count(z)): common_divisors.append(z**A_divisors.count(z)) else: common_divisors.append(z**B_divisors.count(z)) A_divisors = list(filter(lambda x: x != z, A_divisors)) B_divisors = list(filter(lambda x: x != z, B_divisors)) result = 1 for x in A_only + B_only + common_divisors: result *= x print(result)
s651916007
p00003
u804558166
1,000
131,072
Wrong Answer
50
5,596
193
Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so.
n = int(input()) for i in range(n): x, y, z =map(int, input().split()) if x*x + y*y == z*z or y*y + z*z == x*x or x*x + z*z == y*y : print("Yes") else: print("No")
s255965765
Accepted
30
5,592
193
n = int(input()) for i in range(n): x, y, z =map(int, input().split()) if x*x + y*y == z*z or y*y + z*z == x*x or x*x + z*z == y*y : print("YES") else: print("NO")
s818523528
p02747
u568576853
2,000
1,048,576
Wrong Answer
17
2,940
123
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=input() while len(S)>=2: if S[:2]=='hi': S=S[2:] else: break if len(S)==0: print('YES') else: print('NO')
s973378993
Accepted
17
2,940
124
S=input() while len(S)>=2: if S[0:2]=='hi': S=S[2:] else: break if len(S)==0: print('Yes') else: print('No')
s693851097
p02255
u162598098
1,000
131,072
Wrong Answer
20
7,404
197
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
def insertionSort(lis,leng): for i in range(leng): v = lis[i] j = i - 1 while j >= 0 and lis[j] > v: lis[j+1] = lis[j] j = j-1 lis[j+1]=v
s376649947
Accepted
30
8,000
348
def insertionSort(lis,leng): for i in range(leng): v = lis[i] j = i - 1 while j >= 0 and lis[j] > v: lis[j+1] = lis[j] j = j-1 lis[j+1]=v print(*lis) if __name__ == "__main__": lengg=int(input()) liss=list(map(int, input().split())) insertionSort(liss,lengg)
s777393455
p03635
u851704997
2,000
262,144
Wrong Answer
17
2,940
55
In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?
s = input() x = len(s) - 2 print(s[0] + str(x) + s[-1])
s000298012
Accepted
17
2,940
58
n,m = map(int,input().split()) print(str((n - 1)*(m - 1)))
s281360950
p03606
u072717685
2,000
262,144
Wrong Answer
17
2,940
131
Joisino is working as a receptionist at a theater. The theater has 100000 seats, numbered from 1 to 100000. According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive). How many people are sitting at the theater now?
n = int() seats = [list(map(int,input().split())) for _ in range(n)] nop = [s[-1] - s[0] + 1 for s in seats] r = sum(nop) print(r)
s364473891
Accepted
20
3,188
141
n = int(input()) seats = [list(map(int, input().split())) for _ in range(n)] nop = [s[-1] - s[0] + 1 for s in seats] r = sum(nop) print(r)
s075021074
p03037
u881141729
2,000
1,048,576
Wrong Answer
589
3,064
386
We have N ID cards, and there are M gates. We can pass the i-th gate if we have one of the following ID cards: the L_i- th, (L_i+1)-th, ..., and R_i-th ID cards. How many of the ID cards allow us to pass all the gates alone?
while True: try: n, m = map(int, input().split()) start = 1 end = n for i in range(m): a, b = map(int, input().split()) if a > end or b < start: print(0) break start = max(start, a) end = min(end, b) else: print(end-start+1) except: break
s986104769
Accepted
331
3,064
456
while True: try: n, m = map(int, input().split()) start = 1 end = n for i in range(m): a, b = map(int, input().split()) if a > end or b < start: print(0) for j in range(m-i-1): input() break start = max(start, a) end = min(end, b) else: print(end-start+1) except: break
s408917115
p03369
u048945791
2,000
262,144
Wrong Answer
17
2,940
37
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() print(s.count("o") * 100)
s140104617
Accepted
17
2,940
43
s = input() print(700 + s.count("o") * 100)
s103397239
p03854
u021916304
2,000
262,144
Wrong Answer
26
3,804
159
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`.
import re s = input() re.sub('eraser','0',s) re.sub('erase','0',s) re.sub('dreamer','0',s) re.sub('dream','0',s) print('YES' if set(s) == set('0') else 'NO')
s447491806
Accepted
23
3,656
215
import re s = input() s = re.sub('eraser','0',s) #print(s) s = re.sub('erase','0',s) #print(s) s = re.sub('dreamer','0',s) #print(s) s = re.sub('dream','0',s) #print(s) print('YES' if set(s) == set('0') else 'NO')
s731968094
p02747
u223904637
2,000
1,048,576
Wrong Answer
17
2,940
103
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.
a='hi' b='' p=[] for i in range(6): b+=a p.append(a) s=input() print('Yes' if s in p else 'No')
s631886643
Accepted
18
3,188
104
a='hi' b='' p=[] for i in range(6): b+=a p.append(b) s=input() print('Yes' if s in p else 'No')
s569337669
p03816
u072717685
2,000
262,144
Wrong Answer
61
22,144
306
Snuke has decided to play a game using cards. He has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written. He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept. Operation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.
import sys from collections import Counter read = sys.stdin.read readlines = sys.stdin.readlines def main(): n, *a = map(int, read().split()) ac = Counter(a) acl = ac.values() r = len(acl) t = (sum(ac.keys()) - r)&1 r -= t ^ 1 print(r) if __name__ == '__main__': main()
s834406205
Accepted
55
20,572
204
import sys read = sys.stdin.read readlines = sys.stdin.readlines def main(): n, *a = map(int, read().split()) r = len(set(a)) r -= (n - r)&1 print(r) if __name__ == '__main__': main()
s621817436
p03049
u539517139
2,000
1,048,576
Wrong Answer
37
3,064
238
Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
n=int(input()) a=0 b=0 ab=0 x=0 for i in range(n): s=input() l=len(s)-1 if s[0]=='B': if s[l]=='A': ab+=1 else: b+=1 elif s[l]=='A': a+=1 x+=s.count('AB') if ab>0: x+=(a>0)+(b>0) x+=max(0,ab-1) print(x)
s791823686
Accepted
36
3,064
279
n=int(input()) a=0 b=0 ab=0 x=0 for i in range(n): s=input() l=len(s)-1 if s[0]=='B': if s[l]=='A': ab+=1 else: b+=1 elif s[l]=='A': a+=1 x+=s.count('AB') if ab>0: x+=ab-1 x+=(a>0)+(b>0) a-=1;b-=1 a=max(0,a);b=max(0,b) x+=min(a,b) print(x)
s066982958
p03591
u066337396
2,000
262,144
Wrong Answer
17
2,940
69
Ringo is giving a present to Snuke. Ringo has found out that Snuke loves _yakiniku_ (a Japanese term meaning grilled meat. _yaki_ : grilled, _niku_ : meat). He supposes that Snuke likes grilled things starting with `YAKI` in Japanese, and does not like other things. You are given a string S representing the Japanese name of Ringo's present to Snuke. Determine whether S starts with `YAKI`.
if input().startswith('YAKi'): print('Yes') else: print('No')
s536577928
Accepted
17
2,940
69
if input().startswith('YAKI'): print('Yes') else: print('No')
s312500637
p03760
u440975163
2,000
262,144
Wrong Answer
27
9,032
142
Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions. You are given two strings O and E. O contains the characters at the odd- numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order. Restore the original password.
o = list(str(input())) x = list(str(input())) ln = [] for i in o: for j in x: ln.append(i) ln.append(j) print(''.join(ln))
s671653183
Accepted
28
8,952
159
o = list(str(input())) x = list(str(input())) ln = [] for i in range(len(o)): ln.append(o[i]) if len(x) > i: ln.append(x[i]) print(''.join(ln))
s931662071
p03457
u404561212
2,000
262,144
Wrong Answer
429
11,752
570
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
N = int(input()) t = [] x = [] y = [] for i in range(N): a_list = list(map(int, input().split())) t.append(a_list[0]) x.append(a_list[1]) y.append(a_list[2]) for n in range(N): if n == 0: offset_x = abs(x[n]) offset_y = abs(y[n]) else: offset_x = abs (x[n] - x[n-1]) offset_y = abs (y[n] - y[n-1]) offset_total = offset_x + offset_y time_offset = 1 if n==0 else t[n] - t[n-1] if offset_total != time_offset: print("No") break else: print("Yes")
s459552232
Accepted
433
11,872
1,175
def create_decrement_list(num): decrement_list = [] while(num >= 0): decrement_list.append(num) num -=2 return decrement_list def check_route(num_list, offset): is_path_possible = False for num in num_list: if offset == num: is_path_possible = True break return is_path_possible def route_checker(N, list_t, list_x, list_y): for n in range(N): if n == 0: offset_x = abs(list_x[n]) offset_y = abs(list_y[n]) else: offset_x = abs (list_x[n] - list_x[n-1]) offset_y = abs (list_y[n] - list_y[n-1]) offset_total = offset_x + offset_y time_offset = list_t[n] if n==0 else list_t[n] - list_t[n-1] time_offset_list = create_decrement_list(time_offset) if check_route(time_offset_list, offset_total)==False: print("No") break else: print("Yes") N = int(input()) t = [] x = [] y = [] for i in range(N): a_list = list(map(int, input().split())) t.append(a_list[0]) x.append(a_list[1]) y.append(a_list[2]) route_checker(N, t, x, y)
s537194451
p00024
u553148578
1,000
131,072
Wrong Answer
20
5,628
75
Ignoring the air resistance, velocity of a freely falling object $v$ after $t$ seconds and its drop $y$ in $t$ seconds are represented by the following formulas: $ v = 9.8 t $ $ y = 4.9 t^2 $ A person is trying to drop down a glass ball and check whether it will crack. Your task is to write a program to help this experiment. You are given the minimum velocity to crack the ball. Your program should print the lowest possible floor of a building to crack the ball. The height of the $N$ floor of the building is defined by $5 \times N - 5$.
import math print(math.ceil((math.ceil(4.9*(float(input())/9.8)**2)+5)/5))
s944249273
Accepted
20
5,640
105
import math while 1: try: print(math.ceil((math.ceil(4.9*(float(input())/9.8)**2)+5)/5)) except: break
s675076705
p03854
u309120194
2,000
262,144
Wrong Answer
55
9,240
358
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() while True: if S[-5:] == 'erase': S = S[:-5] else: if S[-6:] == 'eraser': S = S[:-6] else: if S[-5:] == 'dream': S = S[:-5] else: if S[-7:] == 'dreamer': S = S[:-7] else: break if len(S) == 0: print('Yes') else: print('No')
s319460102
Accepted
61
9,164
324
S = input() S = S[::-1] words = {'maerd', 'remaerd', 'esare', 'resare'} while len(S) > 0: orig = S for w in words: if S.startswith(w): S = S[len(w):] break if orig == S: break if len(S) == 0: print('YES') else: print('NO')
s341670864
p03598
u244466744
2,000
262,144
Wrong Answer
26
9,088
180
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N. When activated, each type of robot will operate as follows. * When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. * When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.
N = int(input()) K = int(input()) x = list(map(int, input().split())) sum = 0 for i in range(N): if x[i] >= K - x[i]: sum += K - x[i] else: sum += x[i] print(sum)
s921187955
Accepted
25
9,004
190
N = int(input()) K = int(input()) x = list(map(int, input().split())) sum = 0 for i in range(N): if x[i] >= K - x[i]: sum += 2 * (K - x[i]) else: sum += 2 * x[i] print(sum)
s207895226
p03545
u381282312
2,000
262,144
Wrong Answer
30
9,052
309
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
n=list(map(str,input())) cnt = len(n) - 1 for i in range(2**cnt): op = ['-'] * cnt for j in range(cnt): if((i>>j) & 1): op[cnt - 1 - j] = '+' formula = '' for p_n, p_o in zip(n, op+['']): formula += (p_n + p_o) if eval(formula) == 7: print(formula + '==7') break
s838064967
Accepted
28
8,964
356
n=list(map(str,input())) cnt = len(n) - 1 for i in range(2**cnt): op = ['-'] * cnt for j in range(cnt): if((i>>j) & 1): op[cnt - 1 - j] = '+' formula = '' for p_n, p_o in zip(n, op+['']): # n->p_n: 1 # op+['']->p_o: +, +, +, '' formula += (p_n + p_o) if eval(formula) == 7: print(formula + '=7') break
s250939132
p03795
u616522759
2,000
262,144
Wrong Answer
18
2,940
53
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
N = int(input()) x = 800 * N y = N // 15 print(x - y)
s232372548
Accepted
17
2,940
59
N = int(input()) x = 800 * N y = N // 15 * 200 print(x - y)
s187918772
p03456
u616413858
2,000
262,144
Wrong Answer
17
2,940
92
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
joint = input().replace(" ", "") num = int(joint) root = num**(1/2) print(root.is_integer())
s516526414
Accepted
17
2,940
152
joint = input().replace(" ", "") num = int(joint) root = num**(1/2) # print(root) print("Yes" if root.is_integer() else "No")
s842017649
p03478
u815666840
2,000
262,144
Wrong Answer
35
3,060
147
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
n,a,b = map(int,input().split()) num = 0 for i in range(n+1): if a <= sum(list(map(int,list(str(i))))) <= b: num = num + 1 print(num)
s145385429
Accepted
37
3,060
148
n,a,b = map(int,input().split()) num = 0 for i in range(n+1): if a <= sum(list(map(int,list(str(i))))) <= b: num = num + i print(num)
s310003157
p03472
u589381719
2,000
262,144
Wrong Answer
393
11,640
361
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times. * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana. The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?
from collections import deque N,H = map(int,input().split()) A=[] B=[] d=deque() max_axe = 0 max_throw = 0 ans=0 for i in range(N): a,b = map(int,input().split()) A.append(a) B.append(b) A.sort(reverse=True) B.sort(reverse=True) for i in B: if i>=A[0]: H-=i ans+=1 else: break ans+=int(-(-H/A[0])) print(ans)
s806824620
Accepted
397
11,580
390
from collections import deque N,H = map(int,input().split()) A=[] B=[] d=deque() max_axe = 0 max_throw = 0 ans=0 for i in range(N): a,b = map(int,input().split()) A.append(a) B.append(b) A.sort(reverse=True) B.sort(reverse=True) for i in B: if i>=A[0]: H-=i ans+=1 if H<=0:break else: break if H>0:ans+=int(-(-H//A[0])) print(ans)
s095603166
p03779
u140251125
2,000
262,144
Wrong Answer
17
3,064
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 at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.
# input X = int(input()) i = 1 while 2 * X <= i * (i - 1): i += 1 print(i)
s178052777
Accepted
30
2,940
84
# input X = int(input()) i = 1 while 2 * X > i * (i + 1): i += 1 print(i)
s621993290
p03836
u059210959
2,000
262,144
Wrong Answer
40
5,968
598
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
# encoding:utf-8 import copy import random import bisect import fractions import math import sys mod = 10**9+7 sys.setrecursionlimit(mod) sx,sy,gx,gy = map(int,input().split()) ans = [] # go way1 = ["U"] * (gy-sy) + ["R"] * (gx-sx) #return way2 = ["D"] * (gx-sx) + ["L"] * (gy-sy) way3 = ["L"] + ["U"] * (gy-sy+1) + ["R"] * (gx-sx+1) + ["D"] way4 = ["R"] + ["D"] * (gx-sx+1) + ["L"] * (gy-sy+1) + ["U"] ans += way1 + way2 + way3 + way4 print("".join(ans))
s479515533
Accepted
40
5,964
616
# encoding:utf-8 import copy import random import bisect import fractions import math import sys mod = 10**9+7 sys.setrecursionlimit(mod) sx,sy,gx,gy = map(int,input().split()) ans = [] # go way1 = ["U"] * (gy-sy) + ["R"] * (gx-sx) #return way2 = ["D"] * (gy-sy) + ["L"] * (gx-sx) way3 = ["L"] + ["U"] * (gy-sy+1) + ["R"] * (gx-sx+1) + ["D"] way4 = ["R"] + ["D"] * (gy-sy+1) + ["L"] * (gx-sx+1) + ["U"] ans += way1 + way2 + way3 + way4 print("".join(ans)) # print(len(ans))
s312948289
p02388
u316584871
1,000
131,072
Wrong Answer
20
5,560
31
Write a program which calculates the cube of a given integer x.
s = float(input()) print(s**3)
s678403235
Accepted
20
5,576
29
s = int(input()) print(s**3)
s412434885
p02255
u387731924
1,000
131,072
Wrong Answer
20
5,592
287
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
n = int(input()) nums = [] nums = input().split() def insertationSort(A,N): 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 = j - 1 A[j+1] = v print(' '.join(A)) insertationSort(nums,n)
s480226412
Accepted
20
5,600
437
n = int(input()) nums = [] nums = input().split() intNums = list(map(int,nums)) def insertationSort(nums,intNums): print(' '.join(nums)) for i in range(1,len(nums)): v = intNums[i] j = i - 1 while j>=0 and intNums[j]>v: intNums[j+1] = intNums[j] j = j - 1 intNums[j+1] = v nums = list(map(str,intNums)) print(' '.join(nums)) insertationSort(nums,intNums)
s861327258
p02833
u667024514
2,000
1,048,576
Wrong Answer
17
2,940
123
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()) if n % 2 == 1: print(0) exit() ans = 0 for i in range(1,50): ans += (n // (5 ** i)) print(ans)
s470646868
Accepted
17
2,940
132
n = int(input()) if n % 2 == 1: print(0) exit() n = n//2 ans = 0 for i in range(1,50): ans += (n // (5 ** i)) print(ans)
s556249304
p02412
u957680575
1,000
131,072
Wrong Answer
20
7,600
254
Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9
while True: n,x=map(int,input().split()) if n==0 and x==0: break sum=0 for i in range(x//3,n+1): if (x-i)%2==0: sum+=((x-i)/2)-1 else: sum+=(x-i-1)/2 print(sum)
s418941927
Accepted
30
7,516
233
while True: n,x=map(int,input().split()) if n==0 and x==0: break sum=0 for i in range(x//3+1,n+1): for j in range((x-i)//2+1,i): if 0<x-i-j<j : sum+=1 print(int(sum))
s260955991
p03607
u798129018
2,000
262,144
Wrong Answer
197
11,884
98
You are playing the following game with Joisino. * Initially, you have a blank sheet of paper. * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. * Then, you are asked a question: How many numbers are written on the sheet now? The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?
N = int(input()) a = set() for i in range(N): ai = int(input()) a.add(ai) print(len(list(a)))
s038211027
Accepted
186
17,884
238
n = int(input()) d = {} for i in range(n): a = input() if a not in d: d[a] = 1 else: d[a] = d[a] + 1 ans = 0 for val in d.values(): if val % 2 == 1: ans += 1 else: continue print(ans)
s871197016
p02390
u636711749
1,000
131,072
Wrong Answer
30
6,720
82
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()) h = S // 3600 m = S % 3600 // 60 s = S // 60 print(h,m,s, sep=':')
s335484720
Accepted
40
6,724
84
S = int(input()) h = S // 3600 m = S % 3600 // 60 s = S % 60 print(h, m, s, sep=':')
s954141546
p03610
u332331919
2,000
262,144
Wrong Answer
47
9,368
225
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.
#072_b s = input() a = [] if s.islower() and 1 <= len(s) and len(s) <= 10 ** 5: b="" for n in range(len(s)): if n % 2 != 0: a.append(s[n]) for m in range(len(a)): b=b+a[m] print(b)
s481165470
Accepted
49
9,388
225
#072_b s = input() a = [] if s.islower() and 1 <= len(s) and len(s) <= 10 ** 5: b="" for n in range(len(s)): if n % 2 == 0: a.append(s[n]) for m in range(len(a)): b=b+a[m] print(b)
s365243237
p02261
u535719732
1,000
131,072
Wrong Answer
30
5,604
614
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
n = int(input()) a = list(map(str,input().split())) data1 = a[:] data2 = a[:] def bubble_sort(data): for i in range(len(data)): for j in range(len(data)-1,i,-1): if(data[j][1] < data[j-1][1]): data[j],data[j-1] = data[j-1],data[j] return(data) def selection_sort(data): for i in range(len(data)): minj = i for j in range(i,len(data)): if(data[j][1] < data[minj][1]): minj = j data[i],data[minj] = data[minj],data[i] return(data) data1 = bubble_sort(data1) data2 = selection_sort(data2) print(*data1) print("Stable") print(*data2) print("Stable" if data1 == data2 else "NotStable")
s863110627
Accepted
20
5,616
615
n = int(input()) a = list(map(str,input().split())) data1 = a[:] data2 = a[:] def bubble_sort(data): for i in range(len(data)): for j in range(len(data)-1,i,-1): if(data[j][1] < data[j-1][1]): data[j],data[j-1] = data[j-1],data[j] return(data) def selection_sort(data): for i in range(len(data)): minj = i for j in range(i,len(data)): if(data[j][1] < data[minj][1]): minj = j data[i],data[minj] = data[minj],data[i] return(data) data1 = bubble_sort(data1) data2 = selection_sort(data2) print(*data1) print("Stable") print(*data2) print("Stable" if data1 == data2 else "Not stable")
s394287283
p03997
u276785896
2,000
262,144
Wrong Answer
17
2,940
76
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(1/2 * (a + b) * h)
s434152309
Accepted
17
2,940
68
a = int(input()) b = int(input()) h = int(input()) print((a+b)*h//2)
s791932470
p03779
u067986021
2,000
262,144
Wrong Answer
159
4,408
220
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 at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.
X = int(input()) i = 1 x = X while(True): if x == i: print(i) break elif x >= (i * 2 + 1): x = x - i i += 1 elif x < i: break else: i += 1 print(i, x)
s887124060
Accepted
27
3,060
79
X = int(input()) i = 1 x = 1 while(x <= X): x += i i += 1 print(i - 1)
s008143701
p03068
u829356061
2,000
1,048,576
Wrong Answer
17
2,940
153
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.
A = int(input()) B = input() C = int(input()) mark = B[C-1] for i in range(A): if B[i] != mark: B = B.replace(B[i], '*', 1) print(1) print(B)
s736320080
Accepted
18
3,068
145
A = int(input()) B = input() C = int(input()) mark = B[C-1] for i in range(A): if B[i] != mark: B = B.replace(B[i], '*', 1) print(B)
s354324717
p02646
u587518324
2,000
1,048,576
Wrong Answer
22
9,220
506
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
#!/usr/bin/env python def run(a, v, b, w, t): if a == b: return 'Yes' elif b < a: if a - (v * t) <= b - (w * t): return 'Yes' else: return 'No' else: if b + (w * t) <= a + (v * t): return 'Yes' else: return 'No' def main(): A, V = list(map(int, input().split())) B, W = list(map(int, input().split())) T = int(input()) print(run(A, V, B, W, T)) if __name__ == '__main__': main()
s951678619
Accepted
25
9,200
594
#!/usr/bin/env python def run(a, vt, b, wt): if a < b: if b + wt <= a + vt: return 'YES' else: return 'NO' else: if a - vt <= b - wt: return 'YES' else: return 'NO' def main(): A, V = list(map(int, input().split())) B, W = list(map(int, input().split())) T = int(input()) print(run(A, V*T, B, W*T)) if __name__ == '__main__': main()
s915348025
p03050
u010090035
2,000
1,048,576
Wrong Answer
144
3,936
412
Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied: * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds. Find all favorite numbers and print the sum of those.
n=int(input()) div=[] for i in range(1,int((n**0.5)//1)+1): if(n%i==0): div.append(i) div.append(n//i) div=sorted(list(set(div))) ans=[0] #i//m + i%m #m*x + x = i #x = i/(m+1) for divi in div: m=divi-1 if(n//divi < m): ans.append(m) print(ans) print(sum(ans))
s918179685
Accepted
156
3,936
401
n=int(input()) div=[] for i in range(1,int((n**0.5)//1)+1): if(n%i==0): div.append(i) div.append(n//i) div=sorted(list(set(div))) ans=[0] #i//m + i%m #m*x + x = i #x = i/(m+1) for divi in div: m=divi-1 if(n//divi < m): ans.append(m) print(sum(ans))
s522352349
p02567
u368796742
5,000
1,048,576
Wrong Answer
2,075
31,536
1,895
You are given an array a_0, a_1, ..., a_{N-1} of length N. Process Q queries of the following types. The type of i-th query is represented by T_i. * T_i=1: You are given two integers X_i,V_i. Replace the value of A_{X_i} with V_i. * T_i=2: You are given two integers L_i,R_i. Calculate the maximum value among A_{L_i},A_{L_i+1},\cdots,A_{R_i}. * T_i=3: You are given two integers X_i,V_i. Calculate the minimum j such that X_i \leq j \leq N, V_i \leq A_j. If there is no such j, answer j=N+1 instead.
class segtree: ## define what you want to do ,(min, max) sta = -1 func = max def __init__(self,n): self.size = n self.tree = [self.sta]*(2*n) def build(self, list): for i,x in enumerate(list,self.size): self.tree[i] = x for i in range(self.size-1,0,-1): self.tree[i] = self.func(self.tree[i<<1],self.tree[i<<1 | 1]) def set(self,i,x): i += self.size self.tree[i] = x while i > 1: i >>= 1 self.tree[i] = self.func(self.tree[i<<1],self.tree[i<<1 | 1]) ## take the value of [l,r) def get(self,l,r): l += self.size r += self.size res = self.sta while l < r: if l & 1: res = self.func(self.tree[l],res) l += 1 if r & 1: res = self.func(self.tree[r-1],res) l >>= 1 r >>= 1 return res def max_right(self, l, x): if l == self.size: return l l += self.size res = self.sta check = True while check or (l & -l) != l: check = False while l%2 == 0: l >>= 1 if x < self.func(res,self.tree[l]): while l < self.size: l <<= 1 if not x < self.func(res,self.tree[l]): res = self.func(res,self.tree[l]) l += 1 return l - self.size res = self.func(res,self.tree[l]) l += 1 return self.size n,q = map(int,input().split()) a = list(map(int,input().split())) seg = segtree(n) seg.build(a) for _ in range(q): t,x,v = map(int,input().split()) if t == 1: seg.set(x-1,v) elif t == 2: print(seg.get(x-1,v)) else: print(seg.max_right(x-1,v)+1)
s626843221
Accepted
2,164
31,388
2,906
class SegTree: """ define what you want to do with 0 index, ex) size = tree_size, func = min or max, sta = default_value """ def __init__(self,size,func,sta): self.n = size self.size = 1 << size.bit_length() self.func = func self.sta = sta self.tree = [sta]*(2*self.size) def build(self, list): """ set list and update tree""" for i,x in enumerate(list,self.size): self.tree[i] = x for i in range(self.size-1,0,-1): self.tree[i] = self.func(self.tree[i<<1],self.tree[i<<1 | 1]) def set(self,i,x): i += self.size self.tree[i] = x while i > 1: i >>= 1 self.tree[i] = self.func(self.tree[i<<1],self.tree[i<<1 | 1]) def get(self,l,r): """ take the value of [l r) with func (min or max)""" l += self.size r += self.size res = self.sta while l < r: if l & 1: res = self.func(self.tree[l],res) l += 1 if r & 1: res = self.func(self.tree[r-1],res) l >>= 1 r >>= 1 return res def max_right(self, l, x): if l == self.n: return l l += self.size res = self.sta check = True while check or (l & -l) != l: check = False while l%2 == 0: l >>= 1 if not self.func(res,self.tree[l]) < x: while l < self.size: l <<= 1 if self.func(res,self.tree[l]) < x: res = self.func(res,self.tree[l]) l += 1 return l - self.size res = self.func(res,self.tree[l]) l += 1 return self.n def min_left(self, r, x): if r == 0: return 0 r += self.size res = self.sta check = True while check and (r & -r) != r: check = False r -= 1 while (r > 1 and r%2): r >>= 1 if not self.func(res, self.tree[r]) < x: while r < self.size: r = 2*r + 1 if self.func(res, self.tree[r]) < x: res = self.func(res, self.tree[r]) r -= 1 return r + 1 - self.size res = self.func(self.tree[r],res) return 0 n,q = map(int,input().split()) a = list(map(int,input().split())) seg = SegTree(n,max,-1) seg.build(a) for _ in range(q): t,x,v = map(int,input().split()) if t == 1: seg.set(x-1,v) elif t == 2: print(seg.get(x-1,v)) else: print(seg.max_right(x-1,v)+1)
s365964394
p03544
u103902792
2,000
262,144
Wrong Answer
17
2,940
130
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()) ans = [2,1] if n == 1: print(2) exit() for _ in range(n-2): ans.append(ans[-1]+ans[-2]) print(ans[-1])
s382331237
Accepted
17
2,940
133
n = int(input()) ans = [2,1] if n == 1: print(1) exit() for _ in range(n-1): ans.append(ans[-1]+ans[-2]) print(ans[-1])
s483027338
p03693
u075520262
2,000
262,144
Wrong Answer
17
2,940
181
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
a,b,c=map(int, input().split()) d = int(a+b+c) % 4 if d != 0: print('NO') else: print('YES')
s791569769
Accepted
17
2,940
196
a,b,c=map(int, input().split()) d = int(str(a)+str(b)+str(c)) % 4 if d != 0: print('NO') else: print('YES')
s336913655
p03993
u664481257
2,000
262,144
Wrong Answer
99
14,516
843
There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a _friendly pair_ if the following condition is met. * Rabbit i likes rabbit j and rabbit j likes rabbit i. Calculate the number of the friendly pairs.
# -*- coding: utf-8 -*- # !/usr/bin/env python # vim: set fileencoding=utf-8 : """ # # Author: Noname # URL: https://github.com/pettan0818 # License: MIT License # Created: 2016-09-28 # # Usage # """ import sys def input_single_line(): return input() def input_two_line(): """Receive Two Lined Inputs. Like this. N 1 2 3 4 5 """ sys.stdin.readline() target = sys.stdin.readline() target = target.rstrip("\n") target = target.split(" ") return target def search_lovers(target_list: list) -> None: """Search Simple.""" lovers = [] for i in target_list: if target_list[i-1] == i-1: lovers.append(i-1) print(len(lovers)) if __name__ == "__main__": import doctest doctest.testmod() target = input_two_line()
s607305419
Accepted
121
17,908
1,171
# -*- coding: utf-8 -*- # !/usr/bin/env python # vim: set fileencoding=utf-8 : """ # # Author: Noname # URL: https://github.com/pettan0818 # License: MIT License # Created: 2016-09-28 # # Usage # """ import sys def input_single_line(): return input() def input_two_line(): """Receive Two Lined Inputs. Like this. N 1 2 3 4 5 """ sys.stdin.readline() target = sys.stdin.readline() target = target.rstrip("\n") target = target.split(" ") return target def search_lovers(target_list: list) -> None: """Search Simple. >>> target_list = [2, 3, 1] >>> search_lovers(target_list) 0 >>> target_list = [2, 1, 4, 3] >>> search_lovers(target_list) 2 >>> target_list = [5, 5, 5, 5, 1] >>> search_lovers(target_list) 1 """ target_list = [int(i) - 1 for i in target_list] lovers = [] ans = 0 for i, n in enumerate(target_list): if target_list[n] == i: ans = ans + 1 print(int(ans/2)) if __name__ == "__main__": import doctest doctest.testmod() target = input_two_line() search_lovers(target)
s843029651
p03993
u393971002
2,000
262,144
Wrong Answer
146
14,008
180
There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a _friendly pair_ if the following condition is met. * Rabbit i likes rabbit j and rabbit j likes rabbit i. Calculate the number of the friendly pairs.
N = int(input()) a = list(map(int, input().split())) a = [i - 1 for i in a] count = 0 for i in range(N): print(a[i]) if i == a[a[i]]: count += 1 print(count // 2)
s007828243
Accepted
85
14,008
164
N = int(input()) a = list(map(int, input().split())) a = [i - 1 for i in a] count = 0 for i in range(N): if i == a[a[i]]: count += 1 print(count // 2)
s443317291
p03657
u616188005
2,000
262,144
Wrong Answer
17
2,940
165
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%3==0: print("Possible") elif b%3==0: print("Possible") elif a+b%3==0: print("Possible") else: print("Impossible")
s548160336
Accepted
17
2,940
167
a,b = map(int,input().split()) if a%3==0: print("Possible") elif b%3==0: print("Possible") elif (a+b)%3==0: print("Possible") else: print("Impossible")
s860829045
p03408
u951601135
2,000
262,144
Wrong Answer
18
3,064
354
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
N=int(input()) s=[input() for i in range(N)] M=int(input()) l=[input() for i in range(M)] list_str=list(dict.fromkeys(s+l)) s_l=[] for i in range(len(list_str)): s_l.append(s.count(list_str[i])-l.count(list_str[i])) print(all([i < 0 for i in s_l])) if(all([i < 0 for i in s_l])): t='a' while(t==any(s_l)): t+='a' print(t) else:print(max(s_l))
s870087455
Accepted
18
3,064
314
N=int(input()) s=[input() for i in range(N)] M=int(input()) l=[input() for i in range(M)] list_str=list(dict.fromkeys(s+l)) s_l=[] for i in range(len(list_str)): s_l.append(s.count(list_str[i])-l.count(list_str[i])) if(all([i < 0 for i in s_l])): print(0) else:print(max(s_l))
s409769705
p04039
u729133443
2,000
262,144
Wrong Answer
20
2,940
71
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier.
n,k,*a=open(0).read().split() while set(a)&{n}:n=str(int(n)+1) print(n)
s924124047
Accepted
137
2,940
70
n,a=open(0) n=int(n.split()[0]) while set(a)&set(str(n)):n+=1 print(n)
s163264106
p03456
u127856129
2,000
262,144
Wrong Answer
17
3,060
108
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
a,b=input().split() c=(int(a+b)) for i in range(350): if c==i*i: print("Yes") else: print("No")
s240821418
Accepted
17
2,940
107
from math import sqrt a,b=input().split() c=sqrt(int(a+b)) if c==int(c): print("Yes") else: print("No")
s228125423
p03408
u103902792
2,000
262,144
Wrong Answer
18
3,064
250
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
n = int(input()) d = {} for _ in range(n): s = input() if s not in d: d[s] = 0 d[s] += 1 m =int(input()) for _ in range(m): s = input() if s not in d: d[s] = 0 d[s] -= 1 ans = 0 for key in d: ans += max(d[key], 0) print(ans)
s690395570
Accepted
17
3,060
253
n = int(input()) d = {} for _ in range(n): s = input() if s not in d: d[s] = 0 d[s] += 1 m =int(input()) for _ in range(m): s = input() if s not in d: d[s] = 0 d[s] -= 1 ans = 0 for key in d: ans = max(d[key], ans) print(ans)
s696501168
p03161
u336011173
2,000
1,048,576
Wrong Answer
2,206
38,524
398
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 one of the following: Stone i + 1, i + 2, \ldots, i + K. 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.
import numpy as np N, K = map(int, input().split()) hs = np.array(list(map(int, input().split()))) i = 0 total_cost = 0 a = np.zeros(N, int) a[0] = 0 a[1] = abs(hs[1] - hs[0]) for i in range(2, N): bmin = float('inf') for j in range(K): if i-j+1 >= 0: a[i] = min(a[i], a[max(i-(j+1),0)] + abs(hs[i] - hs[max(i-(j+1),0)])) else: break print(a[-1])
s252370260
Accepted
796
38,696
304
import numpy as np N, K = map(int, input().split()) hs = np.array(list(map(int, input().split()))) i = 0 total_cost = 0 a = np.zeros(N, dtype=np.int64) a[0] = 0 a[1] = abs(hs[1] - hs[0]) for i in range(2, N): k = min(K,i) a[i] = np.min(a[i-k:i] + np.abs(hs[i] - hs[i-k:i])) print(a[-1])
s541752747
p03407
u389910364
2,000
262,144
Wrong Answer
23
3,572
835
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
import functools import os INF = float('inf') def inp(): return int(input()) def inpf(): return float(input()) def inps(): return input() def inl(): return list(map(int, input().split())) def inlf(): return list(map(float, input().split())) def inls(): return input().split() def debug(fn): if not os.getenv('LOCAL'): return fn @functools.wraps(fn) def wrapper(*args, **kwargs): print('DEBUG: {}({}) -> '.format( fn.__name__, ', '.join( list(map(str, args)) + ['{}={}'.format(k, str(v)) for k, v in kwargs.items()] ) ), end='') ret = fn(*args, **kwargs) print(ret) return ret return wrapper a, b, c = inl() if a + b == c: print('Yes') else: print('No')
s914008968
Accepted
22
3,572
836
import functools import os INF = float('inf') def inp(): return int(input()) def inpf(): return float(input()) def inps(): return input() def inl(): return list(map(int, input().split())) def inlf(): return list(map(float, input().split())) def inls(): return input().split() def debug(fn): if not os.getenv('LOCAL'): return fn @functools.wraps(fn) def wrapper(*args, **kwargs): print('DEBUG: {}({}) -> '.format( fn.__name__, ', '.join( list(map(str, args)) + ['{}={}'.format(k, str(v)) for k, v in kwargs.items()] ) ), end='') ret = fn(*args, **kwargs) print(ret) return ret return wrapper a, b, c = inl() if a + b >= c: print('Yes') else: print('No')
s001510024
p03380
u325956328
2,000
262,144
Wrong Answer
249
24,140
599
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
from scipy.misc import comb #from scipy.special import comb n = int(input()) A = sorted(list(map(int, input().split()))) ans = 0 out = [] if n % 2 == 1: middle = A[n // 2] last = A[-1] print(last, middle) # print(ans) elif n == 2: print(*A[::-1]) else: cand = [A[n // 2 - 1], A[n // 2]] last = A[-1] for i in range(2): middle = cand[i] comb_last_middle = comb(last, middle) if ans < comb_last_middle: out.append([last, middle]) ans = comb_last_middle print(last, middle)
s695861194
Accepted
157
38,388
553
import numpy as np n = int(input()) a = list(map(int, input().split())) a.sort() def get_nearest_value(arr, num): idx = np.abs(np.asarray(arr) - num).argmin() return arr[idx] first = a[-1] second = get_nearest_value(a, first / 2) print(first, second)
s990780840
p02397
u300641790
1,000
131,072
Wrong Answer
60
7,476
123
Write a program which reads two integers x and y, and prints them in ascending order.
while 1: x,y = [int(i) for i in input().split()] if (x == 0 and y == 0): break print(str(x)+" "+str(y))
s204665480
Accepted
60
7,480
140
while 1: l = list(map(int,input().split())) if (l[0] == 0 and l[1] == 0): break l.sort() print(" ".join(map(str,l)))
s898215114
p03719
u859897687
2,000
262,144
Wrong Answer
17
2,940
77
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
a,b,c=map(int,input().split()) if a<=c<=b: print("YES") else: print("NO")
s738902677
Accepted
17
2,940
77
a,b,c=map(int,input().split()) if a<=c<=b: print("Yes") else: print("No")
s305751581
p02865
u217303170
2,000
1,048,576
Wrong Answer
25
9,060
30
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
n=int(input()) print((n+1)//2)
s995789898
Accepted
29
9,080
68
n = int(input()) if n%2==0: print(n//2-1) else: print(n//2)