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
s267910497
p02390
u058933891
1,000
131,072
Wrong Answer
20
7,540
104
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 - s % 3600 m = s% 3600 - (s % 3600) % 60 s = (s % 3600) % 60 print ( "h:m:s")
s904451058
Accepted
30
7,664
166
s = int(input()) h = str(int((s - s % 3600 ) / 3600 )) m = str(int((s% 3600 - (s % 3600) % 60) /60 )) s = str(int((s % 3600) % 60 )) print ( h + ":" + m + ":" + s)
s275942900
p03480
u762557532
2,000
262,144
Wrong Answer
2,104
6,264
543
You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times. * Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satis...
from collections import Counter S = input() boundary = [] pre_state = '0' for i in range(len(S)): if S[i] != pre_state: boundary.append(i) pre_state = S[i] else: if S[-1] == '1': boundary.append(len(S)) k = 2 while True: lst_mod = list(map(lambda x: x % k, boundary)) count_mod = list(Counter...
s850012745
Accepted
63
6,388
458
S = input() boundary = [] pre_state = '0' for i in range(len(S)): if S[i] != pre_state: boundary.append(i) pre_state = S[i] else: if S[-1] == '1': boundary.append(len(S)) if len(boundary) == 0: print(len(S)) exit() lst = [] for i in range(len(boundary)): lst.append(max(boundary[i], le...
s013557974
p03623
u500297289
2,000
262,144
Wrong Answer
17
2,940
91
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and...
x, a, b = map(int, input().split()) if abs(x - a) < abs(x - b): print(a) else: print(b)
s756575343
Accepted
18
2,940
95
x, a, b = map(int, input().split()) if abs(x - a) < abs(x - b): print('A') else: print('B')
s241978660
p02600
u347600233
2,000
1,048,576
Wrong Answer
25
9,152
47
M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a _kyu_ (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * Fr...
x = int(input()) print(8 - (1800 - 400) // 200)
s752289484
Accepted
26
9,152
44
x = int(input()) print(8 - (x - 400) // 200)
s036946679
p02865
u343850880
2,000
1,048,576
Wrong Answer
17
2,940
70
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
n = int(input()) if n%2==0: print(n/2-1) else: print((n-1)/2)
s255798094
Accepted
17
2,940
80
n = int(input()) if n%2==0: print(int(n/2-1)) else: print(int((n-1)/2))
s220983464
p02690
u042113240
2,000
1,048,576
Wrong Answer
21
9,188
154
Give a pair of integers (A, B) such that A^5-B^5 = X. It is guaranteed that there exists such a pair for the given integer X.
X = int(input()) x = 1 while ((x-1)**4)*5 > X: x += 1 for i in range(x): for j in range(-x, i): if i**5-j**5 == X: a = [i,j] print(*a)
s887421935
Accepted
33
9,116
182
X = int(input()) x = 1 while ((x-1)**4)*5 < X: x += 1 for i in range(x): for j in range(-x, i): if i**5-j**5 == X: a = [i,j] break print(*a)
s622091212
p03943
u894694822
2,000
262,144
Wrong Answer
20
3,060
105
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Not...
a, b, c =map(int,input().split()) if a+b == c or a+c == b or b+c == a: print("YES") else: print("NO")
s106399646
Accepted
20
2,940
105
a, b, c =map(int,input().split()) if a+b == c or a+c == b or b+c == a: print("Yes") else: print("No")
s521404114
p02743
u692687119
2,000
1,048,576
Wrong Answer
18
2,940
144
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
a, b, c = map(int, input().split()) A = a * a B = b * b C = c * c X = ((C - A - B))-(4 * a * b) if X > 0: print('Yes') else: print('No')
s183578998
Accepted
32
2,940
164
a, b, c = map(int, input().split()) m = c - a - b if m <= 0: print('No') else: X = (m * m) - (4 * a * b) if X > 0: print('Yes') else: print('No')
s911398510
p03944
u143278390
2,000
262,144
Wrong Answer
342
12,540
816
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) po...
import numpy as np W,H,N=[int(i) for i in input().split()] lst=[] for j in range(N): lst.append([int(i) for i in input().split()]) print(lst) square=np.zeros(H*W,dtype=np.int64).reshape(H,W) print(square) for i in lst: x=i[0] y=i[1] a=i[2] if(a==1): for j in range(x): for k in...
s349237183
Accepted
341
12,512
818
import numpy as np W,H,N=[int(i) for i in input().split()] lst=[] for j in range(N): lst.append([int(i) for i in input().split()]) #print(lst) square=np.zeros(H*W,dtype=np.int64).reshape(H,W) #print(square) for i in lst: x=i[0] y=i[1] a=i[2] if(a==1): for j in range(x): for k ...
s334394245
p02396
u566311709
1,000
131,072
Wrong Answer
80
5,904
153
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are give...
a = [] while True: n = int(input()) if n == 0: break a.append(n) for i in range(len(a)): print("Case {0}: {1}".format(i, a[i]))
s149474044
Accepted
80
5,908
144
a = [] while True: n = int(input()) if n == 0: break a.append(n) for i in range(len(a)): print("Case {0}: {1}".format(i + 1, a[i]))
s689085092
p03605
u629540524
2,000
262,144
Wrong Answer
17
2,940
63
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 = input() if n in '9': print('Yes') else: print('No')
s671245202
Accepted
17
2,940
63
n = input() if '9' in n: print('Yes') else: print('No')
s843771964
p00007
u350804311
1,000
131,072
Wrong Answer
40
7,620
126
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week. Write a program which computes the amount of the debt in n weeks.
import math n = int(input()) debt = 100 for i in range(n): debt = math.ceil(debt * 1.05) print(str(debt * 1000))
s995242092
Accepted
40
7,648
122
import math n = int(input()) debt = 100 for i in range(n): debt = math.ceil(debt * 1.05) print(str(debt * 1000))
s336378846
p03574
u240793404
2,000
262,144
Wrong Answer
27
3,188
543
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square con...
h,w = map(int,input().split()) mine = [] for i in range(h): mine.append([]) inp = input() for j in range(w): mine[i].append(inp[j]) print(mine) for i in range(h): for j in range(w): if mine[i][j] == '.': cnt = 0 for k in range(3): for l in range(3)...
s412259539
Accepted
29
3,188
467
import itertools h,w=map(int,input().split()) s=[list(input()) for i in range(h)] l=list(itertools.product([-1,0,1],repeat=2)) for i in range(h): for j in range(w): if s[i][j]=='.': cnt = 0 for k in l: x = i+k[0] y = j+k[1] if 0<=x<=h-...
s830292021
p03478
u687044304
2,000
262,144
Wrong Answer
19
2,940
309
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).
# -*- coding:utf-8 -*- def solve(): N, A, B = list(map(int, input().split())) ans = 0 for i in range(N): bit0 = i%10 bit1 = i//10 total = (bit0 + bit1) if total >= A and total <= B: ans += 1 print(ans) if __name__ == "__main__": solve()
s673789735
Accepted
23
3,060
411
# -*- coding:utf-8 -*- def solve(): N, A, B = list(map(int, input().split())) ans = 0 for i in range(1, N+1): keta_sum = 0 num = i while True: if num == 0: break keta_sum += num%10 num = num//10 if keta_sum >= A and keta_...
s374628866
p02749
u023229441
2,000
1,048,576
Wrong Answer
1,046
167,732
1,422
We have a tree with N vertices. The vertices are numbered 1 to N, and the i-th edge connects Vertex a_i and Vertex b_i. Takahashi loves the number 3. He is seeking a permutation p_1, p_2, \ldots , p_N of integers from 1 to N satisfying the following condition: * For every pair of vertices (i, j), if the distance be...
import sys import math mod=10**9+7 inf=float("inf") from math import sqrt from collections import deque from collections import Counter input=lambda: sys.stdin.readline().strip() sys.setrecursionlimit(11451419) from functools import lru_cache n=int(input()) G=[[] for i in range(n)] for i in range(n-1): a,b=map(...
s912147142
Accepted
940
62,152
1,447
n=int(input()) dist=[-1]*n G=[[] for i in range(n)] for i in range(n-1): a,b=map(int,input().split()) a-=1;b-=1 G[a].append(b) G[b].append(a) from collections import deque queue=deque([[0,i] for i in G[0]]) dist[0]=0 while queue: now,to=queue.pop() # print(now,to) if dist[to]!=-1:continue ...
s733883849
p03351
u636162168
2,000
1,048,576
Wrong Answer
17
2,940
156
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either ...
a,b,c,d=map(int,input().split()) if abs(a-c)<d: print("Yes") else: if abs(a-b)<d and abs(b-c)<d: print("Yes") else: print("No")
s522320648
Accepted
17
2,940
159
a,b,c,d=map(int,input().split()) if abs(a-c)<=d: print("Yes") else: if abs(a-b)<=d and abs(b-c)<=d: print("Yes") else: print("No")
s915962113
p03719
u346308892
2,000
262,144
Wrong Answer
26
2,940
102
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(" "))) if c>=a and c<=b: print("yes") else: print("no")
s526063043
Accepted
18
3,064
98
a,b,c=list(map(int,input().split(" "))) if c>=a and c<=b: print("Yes") else: print("No")
s939502995
p03853
u781288689
2,000
262,144
Wrong Answer
23
3,064
127
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, p...
m,n=input().split() a=[] for i in range(int(m)) : a.append(input()) for i in a : print(i) for i in a : print(i)
s583297587
Accepted
23
3,192
111
m,n=input().split() a=[] for i in range(int(m)) : a.append(input()) for i in a : print(i) print(i)
s213047052
p03487
u729133443
2,000
262,144
Wrong Answer
42
14,692
47
You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly ...
n=int(input()) a=list(map(int,input().split()))
s658212626
Accepted
94
17,704
109
n,*a=map(int,open(0).read().split()) d={} for i in a:d[i]=d.get(i,0)+1 print(sum(d[i]-i*(d[i]>=i)for i in d))
s686283952
p03447
u117193815
2,000
262,144
Wrong Answer
17
2,940
71
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
a = int(input()) if a%2==0: print(int(a/2)) else: print(a//2+1)
s129180405
Accepted
17
2,940
77
x = int(input()) a = int(input()) b = int(input()) print((x-a)%b)
s841873637
p03698
u856232850
2,000
262,144
Wrong Answer
17
2,940
89
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
a = input() ans = 'no' for i in a: if a.count(i) >= 2: ans = 'yes' print(ans)
s476396770
Accepted
17
2,940
89
a = input() ans = 'yes' for i in a: if a.count(i) >= 2: ans = 'no' print(ans)
s363062533
p03862
u923659712
2,000
262,144
Wrong Answer
92
14,252
146
There are N boxes arranged in a row. Initially, the i-th box from the left contains a_i candies. Snuke can perform the following operation any number of times: * Choose a box containing at least one candy, and eat one of the candies in the chosen box. His objective is as follows: * Any two neighboring boxes con...
n,x=map(int,input().split()) a=list(map(int,input().split())) c=0 for i in range(n-1): if a[i]+a[i+1]>x: c+=(a[i]+a[i+1]-x) print(c)
s816180957
Accepted
124
14,060
212
n,x=map(int,input().split()) a=list(map(int,input().split())) c=0 if a[0] > x: c= a[0] - x a[0] = x for i in range(0,n-1): if a[i]+a[i+1]>x: c+=(a[i]+a[i+1]-x) a[i+1]-=(a[i]+a[i+1]-x) print(c)
s973841587
p03644
u706414019
2,000
262,144
Wrong Answer
30
9,028
105
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can...
N = int(input()) a = 0 for i in range(N): a = max(a,len(bin(64))-(bin(64)).rfind('1')-1) print(2**a)
s818039581
Accepted
29
9,052
108
N = int(input()) counter = 0 for i in range(8): if N // 2**i ==0: print(2**(i-1)) break
s248132735
p03007
u201234972
2,000
1,048,576
Wrong Answer
247
14,092
1,126
There are N integers, A_1, A_2, ..., A_N, written on a blackboard. We will repeat the following operation N-1 times so that we have only one integer on the blackboard. * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y. Find the maximum possible value of the...
N = int( input()) A = list( map( int, input().split())) A.sort(reverse=True) if N%2 == 0: print( sum(A[:N//2]) - sum(A[N//2:])) now = A[0] print(now, A[N-1]) now -= A[N-1] for i in range(2,N): if i%2 == 0: print(A[N-1-i//2], now) now = A[N-1-i//2] - now else: ...
s391954554
Accepted
262
14,260
1,001
N = int( input()) A = list( map( int, input().split())) A.sort(reverse = True) plus = 0 zero = 0 for i in range(N): if A[i] > 0: plus += 1 elif A[i] == 0: zero += 1 minus = N - plus - zero if plus + zero== N: print(sum(A)-A[-1]*2) now = A[-1] for i in range(N-2): print(now, A...
s587759720
p03599
u382303205
3,000
262,144
Wrong Answer
3,156
3,444
1,144
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the bea...
a,b,c,d,e,f=map(int,input().split()) ans1 = 100 ans2 = 0 if a>b: a, b = b, a for _a in range(f//(a*100) + 1): for _b in range((f - _a*100)//(b*100) + 1): for _c in range((f - _a*100 - _b*100)//c + 1): for _d in range((f - _a*100 - _b*100 - _c * c)//d + 1): if a*100*_a+b*10...
s288696508
Accepted
468
3,064
1,062
import sys a,b,c,d,e,f=map(int,input().split()) if a>b: a, b = b, a ans1 = a*100 ans2 = 0 for _a in range(f//(a*100) + 1): for _b in range((f - _a*100)//(b*100) + 1): max_sugar = min(f-(_a+_b)*100, (f-(_a+_b)*100)//100*e) for _c in range(max_sugar//c + 1): for _d...
s283435884
p03672
u223904637
2,000
262,144
Wrong Answer
17
3,060
305
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by del...
s=list(input()) def ans(s): n=len(s)//2 f=0 for i in range(n): if s[i]!=s[i+n]: f+=1 break if f==0: return True else: return False s.pop(-1) s.pop(-1) kai=2 while not ans(s): s.pop(-1) s.pop(-1) kai+=2 print(kai)
s944123057
Accepted
17
3,064
310
s=list(input()) h=len(s) def ans(s): n=len(s)//2 f=0 for i in range(n): if s[i]!=s[i+n]: f+=1 break if f==0: return True else: return False s.pop(-1) s.pop(-1) kai=2 while not ans(s): s.pop(-1) s.pop(-1) kai+=2 print(h-kai)
s994600985
p03149
u505547600
2,000
1,048,576
Wrong Answer
18
2,940
120
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".
list = input().split() # if 1 in list and 9 in list and 7 in list and 4 in list: print("YES") else: print("NO")
s605732601
Accepted
17
2,940
240
list =input().split() # var=[] for a in list: a = int(a) var.append(a) flg = False if 1 in var: if 9 in var: if 7 in var: if 4 in var: flg = True if flg: print("YES") else: print("NO")
s369845362
p03860
u401183062
2,000
262,144
Wrong Answer
27
8,972
130
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppe...
def iroha(): string = input() Capital = string[0] print("A" + Capital + "C") if __name__ == "__main__": iroha()
s558269628
Accepted
25
9,072
204
def iroha(): head, string, heel = map(str, input().split()) headC = head[0] Capital = string[0] heelC = heel[0] print(headC + Capital + heelC) if __name__ == "__main__": iroha()
s108551719
p03730
u924182136
2,000
262,144
Wrong Answer
17
2,940
166
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 objecti...
A,B,C = map(int,input().split()) flag = False for i in range(B): tmp = i*A%B if tmp == C: flag = True if flag: print("Yes") else: print("No")
s299967916
Accepted
17
2,940
168
A,B,C = map(int,input().split()) flag = False for i in range(B): tmp = i*A%B if tmp == C: flag = True if flag: print("YES") else: print("NO")
s373176128
p03760
u310381103
2,000
262,144
Wrong Answer
24
9,128
135
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...
o=input() e=input() print("".join([o[i]+e[i] for i in range(len(o)-1)]),end="") print(o[-1],end="") if len(o) != len(e): print(e[-1])
s399684453
Accepted
29
9,128
135
o=input() e=input() print("".join([o[i]+e[i] for i in range(len(o)-1)]),end="") print(o[-1],end="") if len(o) == len(e): print(e[-1])
s976515966
p03860
u023077142
2,000
262,144
Wrong Answer
17
2,940
38
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppe...
S = input() print("A{}C".format(S[0]))
s591963558
Accepted
17
2,940
52
_, S, _ = input().split() print("A{}C".format(S[0]))
s656509168
p02744
u007627455
2,000
1,048,576
Wrong Answer
17
2,940
335
In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be **isomorphic** when the following conditions are satisfied: * |s| = |t| holds. * For every pair i, j, one of the following holds: * s_i = s_j and t_i = t_j. * s_i \neq s_j and t_i \neq t_j. F...
# coding: utf-8 n = int(input()) alphas = "abcdefghij" init_str = "" def standard(moji, x): if len(moji) == n: print(moji) else: for j in range(x): if j == x: standard(moji + alphas[j], i + 1) else: standard(moji + alphas[j], i) standar...
s031186915
Accepted
121
4,340
451
# coding: utf-8 n = int(input()) alphas = "abcdefghij" init_str = "" def standard(moji, x): if len(moji) == n: print(moji) else: for j in range(x+1): if j == x: # print("j == x") standard(moji + alphas[j], x + 1) else: ...
s326081303
p00012
u957840591
1,000
131,072
Wrong Answer
30
7,784
2,477
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. Write a program which prints "YES" if a point $P$ $(x_p, y_p)$ is in the triangle and "NO" if not.
class vector(object): def __init__(self,a,b): self.x=b.x-a.x self.y=b.y-a.y @staticmethod def cross_product(a,b): return a.x*b.y-a.y*b.x class vertex(object): def __init__(self,a): self.x=a[0] self.y=a[1] class circle(object): def __init__(self,p,r): s...
s732955672
Accepted
30
7,744
2,477
class vector(object): def __init__(self,a,b): self.x=b.x-a.x self.y=b.y-a.y @staticmethod def cross_product(a,b): return a.x*b.y-a.y*b.x class vertex(object): def __init__(self,a): self.x=a[0] self.y=a[1] class circle(object): def __init__(self,p,r): s...
s277513023
p02936
u591503175
2,000
1,048,576
Wrong Answer
2,115
190,244
1,030
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operati...
N, Q = [int(item) for item in input().split()] tree_list = [input() for _ in range(1,N)] tree_list_int = [list(map(int,i.split())) for i in tree_list] action_list = [input() for _ in range(Q)] action_list_int = [list(map(int, i.split())) for i in action_list] print('tree', tree_list_int) print('act', action_list_int)...
s473717662
Accepted
1,919
208,132
762
N, Q = [int(item) for item in input().split()] tree_list = [input().split() for j in range(1, N)] query_list = [input().split() for k in range(Q)] query_list_int = [[int(k) for k in i] for i in query_list] val_list = [0 for _ in range(N)] linked_node_list = [[] for _ in range(N)] for a, b in tree_list: a, b = ...
s822364099
p00050
u868716420
1,000
131,072
Wrong Answer
30
7,716
210
福島県は果物の産地としても有名で、その中でも特に桃とりんごは全国でも指折りの生産量を誇っています。ところで、ある販売用の英文パンフレットの印刷原稿を作ったところ、手違いでりんごに関する記述と桃に関する記述を逆に書いてしまいました。 あなたは、apple と peach を修正する仕事を任されましたが、なにぶん面倒です。1行の英文を入力して、そのなかの apple という文字列を全て peach に、peach という文字列を全てapple に交換した英文を出力するプログラムを作成してください。
from collections import deque result = deque() for _ in input().split(): if 'apple' in _ : result.append('peach') elif 'peach' in _ : result.append('apple') else : result.append(_) print(*result)
s851499367
Accepted
30
7,804
379
from collections import deque result = deque() for _ in input().split(): if 'apple' in _ : if _ == 'apple' : result.append('peach') else : result.append(_.replace('apple', 'peach')) elif 'peach' in _ : if _ == 'peach' : result.append('apple') else : result.append(_.replace('p...
s794765007
p02646
u180704972
2,000
1,048,576
Wrong Answer
2,206
9,144
295
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 ...
AV = list(map(int,input().split())) BW = list(map(int,input().split())) T = int(input()) A = AV[0] V = AV[1] B = BW[0] W = BW[1] for i in range(T): if A <= B: B += W A += V else: B -= W A -= V if abs(A) >= abs(B): print('Yes') else: print('No')
s224622249
Accepted
23
9,216
396
AV = list(map(int,input().split())) BW = list(map(int,input().split())) T = int(input()) A = AV[0] V = AV[1] B = BW[0] W = BW[1] pos_A = A pos_B = B if A <= B: pos_B = B + T*W pos_A = A + T*V if pos_A >= pos_B: print('YES') else: print('NO') else: pos_B = B - T*W pos_A = A - T...
s033333439
p03694
u690536347
2,000
262,144
Wrong Answer
17
2,940
52
It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts. There are N houses along _TopCoDeer street_. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses. Find the minimum distance to be traveled when AtCoDeer can star...
l=sorted(map(int,input().split())) print(l[-1]-l[0])
s507346682
Accepted
17
2,940
68
N=int(input()) l=sorted(map(int,input().split())) print(l[-1]-l[0])
s688451157
p02614
u562662744
1,000
1,048,576
Wrong Answer
238
27,244
710
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation...
import numpy as np import itertools h,w,k=map(int,input().split()) g=np.ones((h,w)) l=['' for _ in range(h)] for i in range(h): l[i]=str(input()) for i in range(h): for j in range(w): if l[i][j]=='.': g[i][j]=0 s=np.sum(g) ans=0 for i in range(h): for j in range(w): u=list(itertools.combinations(range(h),...
s656623737
Accepted
225
26,984
653
import numpy as np import itertools h,w,k=map(int,input().split()) g=np.ones((h,w)) l=['' for _ in range(h)] for i in range(h): l[i]=str(input()) for i in range(h): for j in range(w): if l[i][j]=='.': g[i][j]=0 s=np.sum(g) ans=0 for i in range(h): for j in range(w): u=list(itertools.combinations(range(h),...
s277982275
p03478
u881116515
2,000
262,144
Wrong Answer
28
3,060
262
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()) ans = 0 for i in range(2): for j in range(10): for k in range(10): for l in range(10): for m in range(10): if i*10000+j*1000+k*100+l*10+m <= n and a <= i+j+k+l+m <= b: ans += 1 print(ans)
s071081707
Accepted
30
3,060
288
n,a,b = map(int,input().split()) ans = 0 for i in range(2): for j in range(10): for k in range(10): for l in range(10): for m in range(10): if i*10000+j*1000+k*100+l*10+m <= n and a <= i+j+k+l+m <= b: ans += i*10000+j*1000+k*100+l*10+m print(ans)
s865062059
p02578
u304593245
2,000
1,048,576
Wrong Answer
174
32,188
190
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a ...
N = int(input()) A = list(map(int, input().split())) ans = 0 for i in range(1,N): tmp = A[i-1] - A[i] if A[i-1] > A[i]: A[i] += tmp ans += tmp print(A) print(ans)
s942886207
Accepted
159
32,372
191
N = int(input()) A = list(map(int, input().split())) ans = 0 for i in range(1,N): tmp = A[i-1] - A[i] if A[i-1] > A[i]: A[i] += tmp ans += tmp #print(A) print(ans)
s748307212
p03455
u834157170
2,000
262,144
Wrong Answer
17
2,940
87
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a, b = map(int, input().split()) if (a*b)//2 == 0: print('Even') else: print('Odd')
s711797023
Accepted
17
2,940
88
a, b = map(int, input().split()) if (a*b) % 2 == 0: print('Even') else: print('Odd')
s602427267
p03698
u684305751
2,000
262,144
Wrong Answer
17
2,940
55
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
s=input() print("Yes" if len(s)==len(set(s)) else "No")
s888973108
Accepted
17
2,940
55
s=input() print("yes" if len(s)==len(set(s)) else "no")
s082893182
p03998
u278356323
2,000
262,144
Wrong Answer
17
3,064
522
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. * ...
#ABC045a import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) a = input()[:-1] b = input()[:-1] c = input()[:-1] nextPerson = "a" while (True): if (nextPerson == "a"): if (len(a) == 1): break nextPerson = a[0] a = a[1:] elif (nextPerson == "b"): if (l...
s521763637
Accepted
17
3,064
580
#ABC045a import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) a = input()[:-1] b = input()[:-1] c = input()[:-1] aa = 0 bb = 0 cc = 0 nextPerson = "a" while (True): #print(nextPerson) if (nextPerson == "a"): if (len(a) - aa == 0): break nextPerson = a[aa] aa...
s022447860
p03369
u226779434
2,000
262,144
Wrong Answer
24
9,024
43
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 ...
s = input() print(700 + s.count("○")*100)
s267103814
Accepted
27
8,984
41
s = input() print(700 + s.count("o")*100)
s761461202
p03486
u595375942
2,000
262,144
Wrong Answer
18
2,940
145
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
s = input() t = input() ss = ''.join(sorted(s)) tt = ''.join(sorted(t, reverse=True)) if ss > tt: ans = 'Yes' else: ans = 'No' print(ans)
s264594899
Accepted
18
2,940
129
S = ''.join(sorted(list(input()))) T = ''.join(reversed(sorted(list(input())))) if S < T: print('Yes') else: print('No')
s573553173
p03477
u494748969
2,000
262,144
Wrong Answer
17
3,064
150
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and pl...
a, b, c, d = list(map(int, input().split())) if a + b > c + d: print("left") elif a + b == c + d: print("Balanced") else: print("Right")
s093269424
Accepted
17
2,940
150
a, b, c, d = list(map(int, input().split())) if a + b > c + d: print("Left") elif a + b == c + d: print("Balanced") else: print("Right")
s653002147
p03854
u588526762
2,000
262,144
Wrong Answer
72
3,188
226
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 1: for x in ('dream', 'dreamer', 'erase', 'eraser'): if s.endswith(x): s = s[:-len(x)] break else: print('NO') break if not s: print('YES')
s271078865
Accepted
71
3,316
240
s = input() while 1: for x in ('dream', 'dreamer', 'erase', 'eraser'): if s.endswith(x): s = s[:-len(x)] break else: print('NO') break if not s: print('YES') break
s356393071
p03997
u432805419
2,000
262,144
Wrong Answer
17
2,940
62
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a = [int(input()) for i in range(3)] print((a[0]+a[1])*a[2]/2)
s964037557
Accepted
18
2,940
67
a = [int(input()) for _ in range(3)] print(int((a[0]+a[1])*a[2]/2))
s909905497
p04043
u457901067
2,000
262,144
Wrong Answer
16
2,940
84
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 ...
X = list(map(int, input().split())).sort() print("YES" if X == [5, 5, 7] else "NO")
s800731055
Accepted
17
2,940
85
X = sorted(list(map(int, input().split()))) print("YES" if X == [5, 5, 7] else "NO")
s746391181
p02411
u777299405
1,000
131,072
Wrong Answer
40
6,724
435
Write a program which reads a list of student test scores and evaluates the performance for each student. The test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, t...
while True: m, f, r = map(int, (input().split())) score = m + f if m == f == r == -1: break else: if m == -1 or f == -1: print("F") elif score >= 80: print("A") elif 80 > score >= 65: print("B") elif 65 > score >= 50: ...
s090028462
Accepted
30
6,724
500
while True: m, f, r = map(int, (input().split())) score = m + f if m == f == r == -1: break else: if m == -1 or f == -1: print("F") elif score >= 80: print("A") elif 80 > score >= 65: print("B") elif 65 > score >= 50: ...
s352624787
p02669
u189479417
2,000
1,048,576
Wrong Answer
441
14,016
1,201
You start with the number 0 and you want to reach the number N. You can change the number, paying a certain amount of coins, with the following operations: * Multiply the number by 2, paying A coins. * Multiply the number by 3, paying B coins. * Multiply the number by 5, paying C coins. * Increase or decrease...
def solve(N, A, B, C, D): d = {0:0, 1:D} s = set() return dfs(N, A, B, C, D, d, s) def dfs(n, A, B, C, D, d, s): if n in d: return d[n] if n in s: return float('inf') s.add(n) ans = float('inf') p = n % 2 if p == 0: ans = min(ans, dfs(n // 2, A, B, ...
s783722762
Accepted
315
11,712
1,208
def solve(N, A, B, C, D): d = {0:0, 1:D} s = set() return dfs(N, A, B, C, D, d, s) def dfs(n, A, B, C, D, d, s): if n in d: return d[n] if n in s: return float('inf') s.add(n) ans = float('inf') p = n % 2 if p == 0: ans = min(ans, dfs(n // 2, A, B, ...
s484070762
p02694
u373703188
2,000
1,048,576
Wrong Answer
22
9,012
590
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or abo...
# import math x = int(input()) cnt = 0 answer = 100 # fv = 100 (1 + 1) # x = x / 100 # print(math.log(2, x)) # # ans += 100 * 0.01 # if x <= ans: # break # print(answer) while answer <= x: cnt += 1 answer += answer // 100 print(cnt)
s980863784
Accepted
20
9,168
679
# import math x = int(input()) cnt = 0 answer = 100 # fv = 100 (1 + 1) # x = x / 100 # print(math.log(2, x)) # # ans += 100 * 0.01 # if x <= ans: # break # print(answer) while answer < x: cnt += 1 answer += answer // 100 # print(answer) # print(x) print(cnt)
s448280371
p03609
u617010143
2,000
262,144
Wrong Answer
17
2,940
134
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
s = input() hoge =list(s) moji = '' for num in range(len(s)): if num%2 == 0: moji += hoge[num] continue print(moji)
s999635759
Accepted
17
2,940
74
X,t =map(int,input().split()) if X >= t: print(X-t) else: print(0)
s798556006
p03067
u864650257
2,000
1,048,576
Wrong Answer
17
2,940
119
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
A,B,C = map (int,input().split()) if A < C < B: print("YES") elif A > C > B: print("YES") else: print("NO")
s906704671
Accepted
17
2,940
119
A,B,C = map (int,input().split()) if A < C < B: print("Yes") elif A > C > B: print("Yes") else: print("No")
s501030841
p03636
u750651325
2,000
262,144
Wrong Answer
17
2,940
46
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
S = input() l = len(S)-2 print(S[0]+"l"+S[-1])
s595418048
Accepted
17
2,940
49
S = input() l = str(len(S)-2) print(S[0]+l+S[-1])
s897538989
p03068
u254745082
2,000
1,048,576
Wrong Answer
17
3,064
224
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 `*`.
n = int(input()) s = input() k = int(input()) str_list = list(s) x = str_list[k-1] print(n,s,k,x) for i in range(len(s)): if str_list[i] != x: str_list[i] = "*" str_changed = "".join(str_list) print(str_changed)
s221606455
Accepted
18
3,060
209
n = int(input()) s = input() k = int(input()) str_list = list(s) x = str_list[k-1] for i in range(len(s)): if str_list[i] != x: str_list[i] = "*" str_changed = "".join(str_list) print(str_changed)
s867253601
p02239
u255317651
1,000
131,072
Wrong Answer
30
5,624
752
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by IDs $1, 2, ... n$.
# -*- coding: utf-8 -*- """ Created on Sun Jul 8 10:56:33 2018 @author: maezawa """ n = int(input()) adj = [[] for _ in range(n)] d = [-1 for _ in range(n)] d[0] = 0 for j in range(n): ain = list(map(int, input().split())) u = ain[0] k = ain[1] for i in range(k): adj[u-1].append(ain[i+2]-1) ...
s603417613
Accepted
20
5,632
867
# -*- coding: utf-8 -*- """ Created on Sun Jul 8 10:56:33 2018 @author: maezawa """ n = int(input()) adj = [[] for _ in range(n)] d = [-1 for _ in range(n)] d[0] = 0 for j in range(n): ain = list(map(int, input().split())) u = ain[0] k = ain[1] for i in range(k): adj[u-1].append(ain[i+2]-1) ...
s737619085
p02748
u690184681
2,000
1,048,576
Wrong Answer
506
39,340
335
You are visiting a large electronics store to buy a refrigerator and a microwave. The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen. You have M discount tic...
A,B,M = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) discount = [] for i in [0]*M: discount.append(list(map(int,input().split()))) min_comb = min(a)+min(b) for i in range(M): min_comb = min(min_comb,a[discount[i][0]-1]+b[discount[i][1]-1]-discount[i][2]) ans...
s203860012
Accepted
521
39,268
342
A,B,M = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) discount = [] for i in [0]*M: discount.append(list(map(int,input().split()))) min_comb = min(a)+min(b) for i in range(M): min_comb = min(min_comb,a[discount[i][0]-1]+b[discount[i][1]-1]-discount[i][2]) ans...
s210762201
p03369
u247211039
2,000
262,144
Wrong Answer
17
2,940
41
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 ...
S = input() print(700 + S.count("o")*300)
s640928612
Accepted
17
2,940
41
S = input() print(700 + S.count("o")*100)
s611510042
p03456
u320098990
2,000
262,144
Wrong Answer
27
9,184
189
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.
import math input_list = input().split(' ') a = input_list[0] b = input_list[1] N = math.sqrt(int(a+b)) print(a+b) print(N) if isinstance(N, float): print('Yes') else: print('No')
s683397888
Accepted
25
9,092
165
import math input_list = input().split(' ') a = input_list[0] b = input_list[1] N = math.sqrt(int(a+b)) if N.is_integer(): print('Yes') else: print('No')
s213681292
p03433
u280552586
2,000
262,144
Wrong Answer
17
2,940
91
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()) if n % 500 <= a: print('YES') else: print('NO')
s561362923
Accepted
17
3,064
79
n, a = [int(input()) for _ in range(2)] print('Yes' if n % 500 <= a else 'No')
s617429148
p03657
u841153348
2,000
262,144
Wrong Answer
17
2,940
300
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them ca...
def yagi(cookie_1,cookie_2): if cookie_1 % 3 == 0: return "possible" elif cookie_2 % 3 == 0: return "possible" elif cookie_1 + cookie_2 % 3 == 0: return "possible" else: return "impossible" cookie = (input()) unti = cookie.split() print(yagi(int(unti[0]),int(unti[1])))
s332081942
Accepted
18
2,940
272
cookie = (input()) unti = cookie.split() cookie_1 = int(unti[0]) cookie_2 = int(unti[1]) if cookie_1 % 3 == 0: print( "Possible") elif cookie_2 % 3 == 0: print( "Possible") elif ((cookie_1 + cookie_2) % 3 == 0): print( "Possible") else : print( "Impossible")
s009154663
p03997
u387456967
2,000
262,144
Wrong Answer
17
2,940
67
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a,b,h = [int(input()) for i in range(3)] ans = (a+b)*h/2 print(ans)
s230689261
Accepted
17
2,940
72
a,b,h = [int(input()) for i in range(3)] ans = int((a+b)*h/2) print(ans)
s875333981
p00135
u032662562
1,000
131,072
Wrong Answer
40
7,644
386
原始スローライフ主義組織「アカルイダ」から、いたずらの予告状が届きました。アカルイダといえば、要人の顔面にパイを投げつけたりするいたずらで有名ですが、最近では火薬を用いてレセプション会場にネズミ花火をまき散らすなど、より過激化してきました。予告状は次の文面です。 ---パソコン ヒトの時間を奪う。良くない。 時計の短い針と長い針 出会うころ、アカルイダ 正義行う。 スローライフ 偉大なり。 たどたどしくてよく解らないのですが、時計の短針と長針とが重なったころにいたずらを決行するという意味のようです。 このいたずらを警戒するため、時刻を入力として、短針と長針が近い場合は "alert"、遠い場合は...
def solve(h,m): dm = m / 60.0 * 360.0 dh = h / 12.0 * 360.0 + 360.0/ 12.0 * m / 60.0 print(dh, dm) if 0 <= abs(dh-dm) < 30.0: return("alert") elif 90.0 <= abs(dh-dm) < 180.0: return("safe") else: return("warning") n = int(input().strip()) for i in range(n): v = list(...
s729476031
Accepted
40
7,628
406
def solve(h,m): dh = h / 12.0 * 360.0 + 360.0/ 12.0 * m / 60.0 dm = m / 60.0 * 360.0 x = abs(dh-dm) if x > 180: x = 360 - x if 0 <= x < 30.0: return("alert") elif 90.0 <= x <= 180.0: return("safe") else: return("warning") n = int(input().strip()) for i in ran...
s166179612
p02748
u371409687
2,000
1,048,576
Wrong Answer
419
18,608
224
You are visiting a large electronics store to buy a refrigerator and a microwave. The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen. You have M discount tic...
a,b,m=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) ans=min(A)+min(B) for i in range(m): x,y,c=map(int,input().split()) tmp=A[x-1]+B[y-1]+c ans=min(ans,tmp) print(ans)
s780526058
Accepted
417
18,608
224
a,b,m=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) ans=min(A)+min(B) for i in range(m): x,y,c=map(int,input().split()) tmp=A[x-1]+B[y-1]-c ans=min(ans,tmp) print(ans)
s505936604
p03779
u145600939
2,000
262,144
Wrong Answer
30
2,940
64
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be a...
x = int(input()) i = 0 while i*(i-1)//2 < x: i += 1 print(i)
s713496410
Accepted
31
2,940
64
x = int(input()) i = 0 while i*(i+1)//2 < x: i += 1 print(i)
s616666751
p02846
u918714262
2,000
1,048,576
Wrong Answer
17
3,064
404
Takahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east. They start simultaneously at the same point and moves as follows **towards the east** : * Takahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for th...
t1, t2 = map(int, input().split()) a1, a2 = map(int, input().split()) b1, b2 = map(int, input().split()) a1 -= b1 a2 -= b2 if a1*t1+a2*t2 == 0: print("infinity") quit() if a1 < 0: a1 = -a1 a2 = -a2 if a2 > 0: print(0) quit() d = a1*t1+a2*t2 if d > 0: print(0) quit() print(a1*t1, -d) ans = ((a1*t1-1)/...
s167453708
Accepted
17
3,064
386
t1, t2 = map(int, input().split()) a1, a2 = map(int, input().split()) b1, b2 = map(int, input().split()) a1 -= b1 a2 -= b2 if a1*t1+a2*t2 == 0: print("infinity") quit() if a1 < 0: a1 = -a1 a2 = -a2 if a2 > 0: print(0) quit() d = a1*t1+a2*t2 if d > 0: print(0) quit() ans = ((a1*t1-1)//(-d)+1)*2-1 if a1...
s273088685
p03024
u826557401
2,000
1,048,576
Wrong Answer
17
2,940
78
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S cons...
s = str(input()) if s.count('x') >= 8: print("No") else: print("Yes")
s551667460
Accepted
17
2,940
78
s = str(input()) if s.count('x') >= 8: print("NO") else: print("YES")
s989496552
p02841
u539805724
2,000
1,048,576
Wrong Answer
17
2,940
220
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month.
def main(): M = [] D = [] for i in range(2): m, d = [int(i) for i in input().split()] M.append(m) D.append(d) if (M[0] != M[1]): print(0) else: print(1) if __name__ == "__main__": main()
s667705009
Accepted
17
3,060
191
def main(): M = [] D = [] for i in range(2): m, d = [int(i) for i in input().split()] M.append(m) D.append(d) if (M[0] != M[1]): print(1) else: print(0) main()
s948579143
p03150
u854685063
2,000
1,048,576
Wrong Answer
28
9,016
688
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
import sys import math import itertools as it def I():return int(sys.stdin.readline().replace("\n","")) def I2():return map(int,sys.stdin.readline().replace("\n","").split()) def S():return str(sys.stdin.readline().replace("\n","")) def L():return list(sys.stdin.readline().replace("\n","")) def Intl():return [int(k) fo...
s712379482
Accepted
26
9,068
663
import sys import math import itertools as it def I():return int(sys.stdin.readline().replace("\n","")) def I2():return map(int,sys.stdin.readline().replace("\n","").split()) def S():return str(sys.stdin.readline().replace("\n","")) def L():return list(sys.stdin.readline().replace("\n","")) def Intl():return [int(k) fo...
s900811798
p03472
u454760747
2,000
262,144
Wrong Answer
1,202
23,216
884
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 d...
N, H = map(int, input().split()) alist = [] blist = [] for i in range(N): A, B = map(int, input().split()) alist.append(A) blist.append(B) maxa = max(alist) blist = list(filter(lambda el: el > maxa, blist)) def mergesort(l): def merge(left, right): result = [] while left and right: ...
s407873069
Accepted
1,179
22,244
919
N, H = map(int, input().split()) alist = [] blist = [] for i in range(N): A, B = map(int, input().split()) alist.append(A) blist.append(B) maxa = max(alist) blist = list(filter(lambda el: el > maxa, blist)) def mergesort(l): def merge(left, right): result = [] while left and right: ...
s845440753
p02388
u040556632
1,000
131,072
Wrong Answer
20
7,320
14
Write a program which calculates the cube of a given integer x.
print(input())
s125914556
Accepted
30
7,580
34
x = int(input()) x = x**3 print(x)
s823521628
p02390
u527389300
1,000
131,072
Wrong Answer
20
5,608
137
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()) temp = s % 60 m = (s - temp) / 60 temp = m % 60 h = (m - temp) / 60 print(str(h) + ':' + str(m) + ':' + str(s))
s981398719
Accepted
20
5,588
163
time = int(input()) h = time - (time % 3600) time = time - h m = time - (time % 60) s = time - m print(str(int(h / 3600))+':'+str(int(m / 60))+':'+str(s))
s236186552
p02972
u278864208
2,000
1,048,576
Wrong Answer
478
18,852
242
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 con...
#D N = int(input()) box = [0] * N for i in range(N-1, 0, -1): aisum = 0 for j in range(i, N, i): aisum += box[j] if aisum%2 == 0: box[i] = 1 else: box[i] = 0 print(' '.join(map(str, box[::-1])))
s701910568
Accepted
611
19,856
366
#D N = int(input()) a = list(map(int,input().split())) box = [0] * N result = [] for i in range(N-1, -1, -1): aisum = 0 for j in range(i, N, i+1): aisum += box[j] if aisum%2 != a[i]%2: box[i] = 1 result.append(i+1) else: box[i] = 0 print(len(result)) if len(resul...
s940301763
p03623
u752552310
2,000
262,144
Wrong Answer
17
2,940
91
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and...
x, a, b = map(int, input().split()) if abs(x-a) > abs(x-b): print('A') else: print('B')
s581326484
Accepted
17
2,940
91
x, a, b = map(int, input().split()) if abs(x-a) > abs(x-b): print('B') else: print('A')
s609845812
p03693
u982594421
2,000
262,144
Wrong Answer
17
2,940
89
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this i...
r, g, b = map(int, input().split()) if g * b % 4 == 0: print('YES') else: print('NO')
s104405679
Accepted
19
2,940
96
r, g, b = map(int, input().split()) if (g * 10 + b) % 4 == 0: print('YES') else: print('NO')
s829765549
p02697
u945228737
2,000
1,048,576
Wrong Answer
72
9,276
145
You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing fi...
def solve(): N, M = map(int, input().split()) for i in range(M): print(i + 1, N - i) if __name__ == '__main__': solve()
s113569289
Accepted
75
9,232
449
def solve(): N, M = map(int, input().split()) m = 0 oddN = M oddN += (oddN + 1) % 2 for i in range(oddN // 2): print(i + 1, oddN - i) m += 1 if m == M: return for i in range(M): print(oddN + i + 1, M * 2 + 1 - i) m += 1 if...
s140659710
p03047
u801512570
2,000
1,048,576
Wrong Answer
18
3,064
67
Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers?
N,K=map(int, input().split()) print(sum([i for i in range(1,N+1)]))
s583063684
Accepted
17
2,940
44
N,K=map(int,input().split()) print(N-(K-1))
s893473076
p03469
u347600233
2,000
262,144
Wrong Answer
17
2,940
33
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date col...
s = input() print('2017' + s[4:])
s442861466
Accepted
17
2,940
33
s = input() print('2018' + s[4:])
s547493816
p03713
u557494880
2,000
262,144
Wrong Answer
328
3,064
349
There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying...
W,H = map(int,input().split()) ans = 10**100 for i in range(1,W): a = H*i w = W - i b = min((w//2)*H,w*(H//2)) c = w*H - b x = max(a,b,c) - min(a,b,c) ans = min(ans,x) for i in range(1,H): a = W*i h = H - i b = min((W//2)*h,W*(h//2)) c = h*W - b x = max(a,b,c) - min(a,b,c) ...
s738827403
Accepted
324
3,064
349
W,H = map(int,input().split()) ans = 10**30 for i in range(1,W): a = H*i w = W - i b = max((w//2)*H,w*(H//2)) c = w*H - b x = max(a,b,c) - min(a,b,c) ans = min(ans,x) for i in range(1,H): a = W*i h = H - i b = max((W//2)*h,W*(h//2)) c = h*W - b x = max(a,b,c) - min(a,b,c) ...
s215446545
p03992
u374802266
2,000
262,144
Wrong Answer
17
2,940
113
This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the fi...
a=input() for i in range(4): print(a[i],end='') print(' ',end='') for i in range(8): print(a[i+4],end='')
s290482999
Accepted
31
8,940
28
s=input() print(s[:4],s[4:])
s943499674
p04029
u989326345
2,000
262,144
Wrong Answer
17
2,940
42
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
N=int(input()) ans=(N*(N-1))//2 print(ans)
s450609312
Accepted
17
2,940
43
N=int(input()) ans=(N*(N+1))//2 print(ans)
s072656772
p02262
u630566146
6,000
131,072
Wrong Answer
20
5,616
882
Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+...
def insertion_sort(l, g): cnt = 0 for i in range(g, len(l)): tmp = l[i] j = i - g while j >= 0 and l[j] > tmp: l[j+g] = l[j] cnt += 1 j -= g l[j+g] = tmp return l, cnt def shell_sort(l, lg): tot = 0 for g in lg: sl, cnt =...
s408084529
Accepted
19,330
45,504
767
def insertion_sort(l, g): cnt = 0 for i in range(g, len(l)): tmp = l[i] j = i - g while j >= 0 and l[j] > tmp: l[j+g] = l[j] cnt += 1 j -= g l[j+g] = tmp return l, cnt def shell_sort(l, lg): tot = 0 for g in lg: sl, cnt =...
s146228229
p02406
u261533743
1,000
131,072
Wrong Answer
20
7,720
121
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement ...
N = int(input()) result = ' '.join([str(c) for c in range(1, N + 1) if c == 3 or '3' in str(c)]) print(' ' + result)
s896282108
Accepted
20
7,772
116
N = int(input()) print(' {}'.format(' '.join([str(c) for c in range(1, N + 1) if c % 3 == 0 or '3' in str(c)])))
s192838173
p04043
u039002256
2,000
262,144
Wrong Answer
22
8,968
212
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 ...
l = list(map(int, input().split())) flag_5 = flag_7 = 0 for i in l: if i == 5: flag_5 += 1 if i == 7: flag_7 += 1 if flag_5 == 2 and flag_7 == 1: print("Yes") else: print("No")
s763732082
Accepted
28
8,964
212
l = list(map(int, input().split())) flag_5 = flag_7 = 0 for i in l: if i == 5: flag_5 += 1 if i == 7: flag_7 += 1 if flag_5 == 2 and flag_7 == 1: print("YES") else: print("NO")
s456224943
p04029
u263824932
2,000
262,144
Wrong Answer
17
2,940
303
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
S=input() words=[a for a in S] answers=[] for n in words: if n=='1': answers.append('1') elif n=='0': answers.append('0') else: if not answers: continue else: answers.pop() mojiretu='' for x in answers: mojiretu+=x print(mojiretu)
s037828491
Accepted
17
2,940
70
N=int(input()) C=[] for n in range(N+1): C.append(n) print(sum(C))
s041749251
p03944
u530786533
2,000
262,144
Wrong Answer
18
3,060
299
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) po...
w, h, n = map(int, input().split()) p, q, r, s = 0, 0, w, h for i in range(n): x, y, a = map(int, input().split()) if (a == 1): p = x elif (a == 2): r = x elif (a == 3): q = y else: s = y if (r - p < 0): r = p if (s - q < 0): s = q print(r - p, s - q)
s504490158
Accepted
18
3,064
389
w, h, n = map(int, input().split()) p, q, r, s = 0, 0, w, h for i in range(n): x, y, a = map(int, input().split()) if (a == 1): if (x > p): p = x elif (a == 2): if (x < r): r = x elif (a == 3): if (y > q): q = y else: if (y < s): s = y if (r <...
s555736482
p04029
u461954362
2,000
262,144
Wrong Answer
40
3,064
63
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
#!/usr/bin/env python N = int(input()) print(N * (N + 1) / 2)
s479802725
Accepted
38
3,064
64
#!/usr/bin/env python N = int(input()) print(N * (N + 1) // 2)
s800605725
p02612
u731362892
2,000
1,048,576
Wrong Answer
28
9,148
50
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
n=int(input()) while n<=0: n-=1000 print(abs(n))
s347276810
Accepted
28
9,152
49
n=int(input()) while n>0: n-=1000 print(abs(n))
s431086340
p03549
u333945892
2,000
262,144
Wrong Answer
29
4,212
332
Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of th...
from collections import defaultdict import sys,heapq,bisect,math,itertools,string,queue,datetime sys.setrecursionlimit(10**8) INF = float('inf') mod = 10**9+7 eps = 10**-7 def inpl(): return list(map(int, input().split())) def inpl_s(): return list(input().split()) N,M = inpl() T = (N-M)*100 + 1900*M print(T) k = 2**M...
s831234825
Accepted
29
4,204
323
from collections import defaultdict import sys,heapq,bisect,math,itertools,string,queue,datetime sys.setrecursionlimit(10**8) INF = float('inf') mod = 10**9+7 eps = 10**-7 def inpl(): return list(map(int, input().split())) def inpl_s(): return list(input().split()) N,M = inpl() T = (N-M)*100 + 1900*M k = 2**M print(k*...
s718850549
p02694
u434609232
2,000
1,048,576
Wrong Answer
26
9,164
107
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or abo...
X = int(input()) money = 100 year = 0 while money <= X: money += money // 100 year += 1 print(year)
s012041762
Accepted
27
9,100
106
X = int(input()) money = 100 year = 0 while money < X: money += money // 100 year += 1 print(year)
s880205653
p02422
u957840591
1,000
131,072
Wrong Answer
30
7,680
615
Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-t...
str=input() q=eval(input()) command=[] replace=[] numdata=[] for i in range(q): x=input() if 'replace' in x: a,b,c,d=x.split() replace.append(d) numdata.append((int(b),int(c))) else: a,b,c=x.split() numdata.append((int(b),int(c))) command.append(a) Re=iter(replace...
s958571872
Accepted
30
7,708
636
str=input() q=eval(input()) command=[] replace=[] numdata=[] for i in range(q): x=input() if 'replace' in x: a,b,c,d=x.split() replace.append(d) numdata.append((int(b),int(c))) else: a,b,c=x.split() numdata.append((int(b),int(c))) command.append(a) Re=iter(replace...
s796173869
p03401
u806855121
2,000
262,144
Wrong Answer
194
14,048
420
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from...
N = int(input()) A = list(map(int, input().split())) s = 0 p = 0 for i in range(N): s += abs(p - A[i]) p = A[i] if p != 0: s += abs(p) A.append(0) A.insert(0, 0) for i in range(1, N+1): if A[i] < 0: if A[i] < A[i+1]: print(s - abs(A[i-1] - A[i])*2) continue else: ...
s155100734
Accepted
1,346
13,536
262
from collections import deque N = int(input()) A = deque(map(int, input().split())) A.appendleft(0) A.append(0) S = 0 for i in range(1, N+2): S += abs(A[i-1] - A[i]) for i in range(1, N+1): print(S+abs(A[i-1]-A[i+1])-(abs(A[i-1]-A[i])+abs(A[i]-A[i+1])))
s125906715
p03827
u324549724
2,000
262,144
Wrong Answer
18
2,940
134
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x duri...
a = input() maxi = 0 now = 0 for c in a: if c == 'I': now += 1 else: now -= 1 if now > maxi: maxi = now print(maxi)
s801676084
Accepted
17
2,940
134
input() a = input() maxi = 0 now = 0 for c in a: if c == 'I': now += 1 else: now -= 1 maxi = max(now, maxi) print(maxi)
s377827443
p02612
u220560107
2,000
1,048,576
Wrong Answer
32
9,148
28
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
N=int(input()) print(1000-N)
s366845115
Accepted
28
9,120
40
N=int(input()) print((1000-N%1000)%1000)
s009034441
p03369
u737508101
2,000
262,144
Wrong Answer
17
2,940
38
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 ...
s = input() print(s.count("o") * 100)
s159366523
Accepted
17
2,940
43
s = input() print(s.count("o") * 100 + 700)
s001705377
p04012
u594956556
2,000
262,144
Wrong Answer
18
3,060
172
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
w = input() cdict = {} for c in w: if c in cdict: cdict[c] += 1 else: cdict[c] = 0 if all(cdict[c]%2==0 for c in cdict): print('Yes') else: print('No')
s979712926
Accepted
17
2,940
173
w = input() cdict = {} for c in w: if c in cdict: cdict[c] += 1 else: cdict[c] = 1 if all(cdict[c]%2==0 for c in cdict): print('Yes') else: print('No')
s531864276
p03044
u652057333
2,000
1,048,576
Wrong Answer
2,104
16,432
959
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices...
n = int(input()) u = [0] * (n-1) v = [0] * (n-1) w = [0] * (n-1) node = [i for i in range(n)] group1 = [] group2 = [] for i in range(n-1): u[i], v[i], w[i] = map(int, input().split()) u[i] -= 1 v[i] -= 1 w[i] = w[i] % 2 if w[i] == 0: if node[u[i]] == u[i]: node[u[i]] = n...
s488447670
Accepted
1,304
51,348
480
import queue n = int(input()) links = [set() for _ in [0] * n] for i in range(n-1): u, v, w = map(int, input().split()) u -= 1 v -= 1 links[u].add((v, w)) links[v].add((u, w)) ans = [-1] * n q = queue.Queue() q.put((0, 0, -1)) while not q.empty(): v, d, p = q.get() if d % 2 == 0: an...
s640649260
p03145
u675918663
2,000
1,048,576
Wrong Answer
19
2,940
97
There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
import sys for line in sys.stdin: nbs = line.split(' ') print(int(nbs[0]) * int(nbs[1]) / 2)
s337716392
Accepted
18
2,940
99
import sys for line in sys.stdin: nbs = line.split(' ') print(int(nbs[0]) * int(nbs[1]) // 2)
s477727503
p02742
u767995501
2,000
1,048,576
Wrong Answer
17
2,940
56
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the to...
H, W = map(int, input().split()) print((H / 2)*(W / 2))
s647403902
Accepted
17
2,940
122
H,W = map(int, input().split()) if H > W: H,W = W,H if H == 1: print(1) else: N = H * W print((N+1)//2)