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
s103155874
p03860
u346629192
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().split()[1] print("A"+s+"C")
s691108551
Accepted
18
2,940
42
s =input().split()[1] print("A"+s[0]+"C")
s019988459
p03943
u616040357
2,000
262,144
Wrong Answer
17
2,940
257
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...
def solve(): a, b, c = map(int, input().split()) if a == b + c: ans = "YES" elif b == a + c: ans = "YES" elif c == a + b: ans = "YES" else: ans = "NO" print(ans) if __name__ == '__main__': solve()
s156947766
Accepted
17
2,940
257
def solve(): a, b, c = map(int, input().split()) if a == b + c: ans = "Yes" elif b == a + c: ans = "Yes" elif c == a + b: ans = "Yes" else: ans = "No" print(ans) if __name__ == '__main__': solve()
s527867304
p03624
u130900604
2,000
262,144
Wrong Answer
20
3,956
103
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
string=input() s=set(list(string)) full=set(list("abcdefghijklmnopqrstuvwxyz")) tmp=full-s print(tmp)
s171328451
Accepted
20
3,956
153
string=input() s=set(list(string)) full=set(list("abcdefghijklmnopqrstuvwxyz")) tmp=full-s if len(tmp)==0: print("None") exit() print(min(tmp))
s782218236
p03583
u761989513
2,000
262,144
Wrong Answer
572
2,940
223
You are given an integer N. Find a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w. If there are multiple solutions, any of them will be accepted.
N = int(input()) if N > 0: for i in range(2, 3501, 3): for n in range(1, 1751): w = i * n if 3 * w == N * (i + 1): print("{} {} {}".format(N, n, w)) exit()
s013910927
Accepted
1,671
2,940
244
N = int(input()) for h in range(1, 3501): for n in range(h, 3501): bunbo = 4 * h * n - N * n - N * h if bunbo > 0 and N * h * n % bunbo == 0: print("{} {} {}".format(h, n, N * h * n // bunbo)) exit()
s928378301
p03149
u532966492
2,000
1,048,576
Wrong Answer
17
2,940
57
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".
print("YNeos"["".join(sorted(list(input())))!="1479"::2])
s143421345
Accepted
17
2,940
65
print("YNEOS"["".join(sorted(list(input().split())))!="1479"::2])
s425594823
p03777
u672475305
2,000
262,144
Wrong Answer
17
2,940
78
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or Dishonest_. In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either `H` or `D`, and carries the following information: If a=`H`, AtCo...
a,b = map(str,input().split()) if a==b: print('Yes') else: print('No')
s501898889
Accepted
17
2,940
75
a,b = map(str,input().split()) if a==b: print('H') else: print('D')
s337619496
p03644
u820351940
2,000
262,144
Wrong Answer
17
2,940
67
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...
a = int(input()) cnt = 0 while a: cnt += 1 a >>= 1 print(cnt - 1)
s622933073
Accepted
17
2,940
81
a = int(input()) cnt = 0 while a: cnt += 1 a >>= 1 print(1 << (cnt - 1))
s481082804
p03049
u037074041
2,000
1,048,576
Wrong Answer
40
4,724
1,563
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.
from sys import stdin import math import itertools def makeIntMatrix(lines): intMatrix = [] for a in makeStringMatrix(lines): intMatrix.append([int(b) for b in a]) return intMatrix def makeStringMatrix(lines): stringMatrix = [line.rstrip() for line in lines] return stringMatrix def...
s272327643
Accepted
36
4,596
1,877
from sys import stdin import math import itertools def makeIntMatrix(lines): intMatrix = [] for a in makeStringMatrix(lines): intMatrix.append([int(b) for b in a]) return intMatrix def makeStringMatrix(lines): stringMatrix = [line.rstrip() for line in lines] return stringMatrix def...
s764047388
p03131
u597455618
2,000
1,048,576
Wrong Answer
17
3,060
149
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the ...
k, a, b = map(int, input().split()) if 2 >= b - a or k+1 <= a: print(k+1) else: i = (k-a+1)//2+1 ans = k+1 -a*i + b*i -2*i print(ans)
s929347083
Accepted
18
3,060
148
k, a, b = map(int, input().split()) if 2 >= b - a or k+1 <= a: print(k+1) else: i = -(a-k-1)//2 ans = k+1 -a*i + b*i -2*i print(ans)
s964944875
p03962
u319612498
2,000
262,144
Wrong Answer
17
3,060
176
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he migh...
a,b,c=map(int, input().split()) list=[a,b,c] list.sort() if list[0]==list[1]==list[2]: print(3) elif list[1]==list[0] or list[1]==list[2]: print(2) else: print(1)
s663823200
Accepted
17
3,060
177
a,b,c=map(int, input().split()) list=[a,b,c] list.sort() if list[0]==list[1]==list[2]: print(1) elif list[1]==list[0] or list[1]==list[2]: print(2) else: print(3)
s410416786
p02260
u424041287
1,000
131,072
Wrong Answer
20
5,604
402
Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 if A[j] < A[mini] 5 mini = j 6 swap A[...
def bubbleSort(A, N): s = 0 for i in range(N): minj = i for j in range(i,N): if A[j] < A[minj]: minj = j A[j], A[j - 1] = A[j - 1], A[j] s += 1 t = str(A[0]) for i in range(1,N): t = t + " " + str(A[i]) print(t) ...
s738175576
Accepted
30
5,600
416
def selectionSort(A, N): s = 0 for i in range(N): minj = i for j in range(i,N): if A[j] < A[minj]: minj = j A[i], A[minj] = A[minj], A[i] if i != minj: s += 1 t = str(A[0]) for i in range(1,N): t = t + " " + str(A[i]) pr...
s842440767
p03943
u209918867
2,000
262,144
Wrong Answer
17
2,940
75
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());print('YNeos'[a+b!=c and a+c!=b and b+c!=a])
s462398620
Accepted
17
2,940
78
a,b,c=map(int,input().split());print('YNeos'[a+b!=c and a+c!=b and b+c!=a::2])
s901942335
p02936
u047668580
2,000
1,048,576
Wrong Answer
2,111
60,396
957
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...
import sys input = sys.stdin.readline import numpy as np N, Q = list(map(int, input().split())) graph = [[] for i in range(N)] for i in range(N-1): a, b = list(map(int, input().split())) graph[a-1].append(b-1) points = np.zeros(N, dtype=int) for _ in range(Q): p, x = list(map(int, input().split())) ...
s136273131
Accepted
1,088
65,320
827
import sys from queue import deque input = sys.stdin.readline def main(): N, Q = list(map(int, input().split())) graph = [[] for i in range(N)] for i in range(N-1): a, b = list(map(int, input().split())) graph[a-1].append(b-1) graph[b-1].append(a-1) points = [0] *...
s696800556
p03693
u464603191
2,000
262,144
Wrong Answer
21
3,316
115
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()) s = int(100*r + 10*g + b) t = s%4 if t == 0 : print('yes') else : print('no')
s603842610
Accepted
29
3,064
115
r, g, b = map(int, input().split()) s = int(100*r + 10*g + b) t = s%4 if t == 0 : print('YES') else : print('NO')
s869215881
p03601
u777923818
3,000
262,144
Wrong Answer
71
3,968
600
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...
# -*- coding: utf-8 -*- A, B, C, D, E, F = tuple(map(int, input().split())) A, B = 100*A, 100*B waters = set([a+b for b in range(0, F+1, B) for a in range(b, F-b+1, A)]) res_water = 0 res_sugar = 0 max_ratio = 0 for w in sorted(waters): sugar = max([c+d for c in range(0, int(w/100)*E+1, C) ...
s027183652
Accepted
298
6,160
714
# -*- coding: utf-8 -*- A, B, C, D, E, F = tuple(map(int, input().split())) A, B = 100*A, 100*B waters = set([a+b for b in range(0, F+1, B) for a in range(0, F+1, A) if a+b <= F]) res_water = min(A, B) res_sugar = 0 max_ratio = 0 for w in sorted(waters): sugars = [c+d for c in range(0, int(w//100)*E+1, C) ...
s997755401
p04043
u165388538
2,000
262,144
Wrong Answer
22
9,024
88
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each ...
abc = input().split() print("YES" if abc.count(5) == 2 and abc.count(7) == 1 else "NO")
s689875645
Accepted
29
9,024
92
abc = input().split() print("YES" if abc.count("5") == 2 and abc.count("7") == 1 else "NO")
s020589925
p04044
u614181788
2,000
262,144
Wrong Answer
18
3,188
152
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically sm...
n,l = map(int,input().split()) s = [0]*n for i in range(n): s[i] = input() s = sorted(s) ans = [] for i in range(n): ans.extend(s[i]) print(ans)
s535660481
Accepted
18
3,060
153
n,l = map(int,input().split()) s = [0]*n for i in range(n): s[i] = input() s = sorted(s) ans = [] for i in range(n): print(s[i],end="") print("")
s985513710
p03455
u363466395
2,000
262,144
Wrong Answer
17
2,940
100
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a, b = [int(x) for x in input().split()] if a * b % 2 == 0: print("even") else: print("odd")
s741772721
Accepted
18
2,940
100
a, b = [int(x) for x in input().split()] if a * b % 2 == 0: print("Even") else: print("Odd")
s034698655
p03644
u762420987
2,000
262,144
Wrong Answer
17
2,940
158
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()) def two(n): ans = 0 while n % 2 == 0: n //= 2 ans += 1 return ans print(max([two(i + 1) for i in range(N)]))
s785426336
Accepted
17
2,940
183
N = int(input()) def two(n): ans = 0 while n % 2 == 0: n //= 2 ans += 1 return ans ans = [two(i + 1) for i in range(N)] print(ans.index(max(ans)) + 1)
s149276689
p02646
u736981539
2,000
1,048,576
Wrong Answer
25
9,180
160
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch ...
A,V=map(int,input().split()) B,W=map(int,input().split()) T=int(input()) if V==W: print("NO") elif (B-A)/(V-W) >= T: print("YES") else: print("NO")
s079002341
Accepted
20
9,184
167
A,V=map(int,input().split()) B,W=map(int,input().split()) T=int(input()) if V <= W: print("NO") elif abs((B-A))/(V-W) <= T: print("YES") else: print("NO")
s483686042
p03699
u021877437
2,000
262,144
Wrong Answer
18
3,060
280
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When...
N = int(input().rstrip()) a = [] for i in range(N): a.append(int(input().rstrip())) a.sort() total = sum(a) if (a[i] % 10) == 0: for i in range(N): if (a[i] % 10) != 0: total = total - a[i] break print(0 if (total % 10) == 0 else total)
s036291309
Accepted
18
3,060
281
N = int(input().rstrip()) a = [] for i in range(N): a.append(int(input().rstrip())) a.sort() total = sum(a) if (total % 10) == 0: for i in range(N): if (a[i] % 10) != 0: total = total - a[i] break print(0 if (total % 10) == 0 else total)
s740232071
p03854
u360061665
2,000
262,144
Wrong Answer
17
3,316
252
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() temp = ['dream', 'dreamer', 'erase', 'eraser'] while(1): for i in temp: if S.startswith(i): S = S.lstrip(i) break else: break print(S) if len(S) == 0: print('YES') else: print('NO')
s309166738
Accepted
18
3,188
150
S = input().replace('eraser', '').replace( 'erase', '').replace('dreamer', '').replace('dream', '') if S: print('NO') else: print('YES')
s992263888
p02272
u918457647
1,000
131,072
Wrong Answer
30
7,684
610
Write a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function. Merge(A, left, mid, right) n1 = mid - left; n2 = right - mid; create array L[0...n1], R[0...n2] for i = 0 to n1-1 do L[i] = A[left + i] ...
def merge(a, left, mid, right): global cnt l = a[left:mid] + [10**9 + 1] r = a[mid:right] + [10**9 + 1] i = 0 j = 0 for k in range(left, right): cnt += 1 if l[i] <= r[j]: a[k] = l[i] i += 1 else: a[k] = r[j] j += 1 def me...
s945920020
Accepted
4,350
63,764
611
def merge(a, left, mid, right): global cnt l = a[left:mid] + [10**9 + 1] r = a[mid:right] + [10**9 + 1] i = 0 j = 0 for k in range(left, right): cnt += 1 if l[i] <= r[j]: a[k] = l[i] i += 1 else: a[k] = r[j] j += 1 def me...
s041265265
p02850
u202570162
2,000
1,048,576
Wrong Answer
2,106
39,492
814
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colo...
# TLE? N = int(input()) T = [[]for i in range(N)] Eo = [] for i in range(N-1): a,b = map(int,input().split()) T[a-1].append(b-1) T[b-1].append(a-1) Eo.append((a-1,b-1)) Eo = tuple(Eo) K = 0 for i in range(N): K = max(len(T[i]),K) P = [-1 for i in range(N)] for i in range(N): for j in T[i]: ...
s153679487
Accepted
790
50,840
628
N = int(input()) AB =[] V = [[] for _ in range(N)] Edict = dict() for _ in range(N-1): a,b = map(int,input().split()) AB.append((a-1,b-1)) V[a-1].append(b-1) V[b-1].append(a-1) K = max(len(V[i]) for i in range(N)) for i in V: i.sort() for i,v in enumerate(V[0]): Edict[(0,v)] = i for i in range(1...
s204380237
p03737
u652656291
2,000
262,144
Wrong Answer
17
2,940
84
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
a,b,c = map(str,input().split()) a.upper() b.upper() c.upper() print(a[0]+b[0]+c[0])
s264688288
Accepted
17
2,940
97
a,b,c = map(str,input().split()) a = a.upper() b = b.upper() c = c.upper() print(a[0]+b[0]+c[0])
s134756392
p03861
u962819039
2,000
262,144
Wrong Answer
18
2,940
54
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
a, b, x = map(int, input().split()) print(b//x - a//x)
s989693338
Accepted
20
2,940
92
a, b, x = map(int, input().split()) c = 0 if a % x == 0: c += 1 print(b // x - a // x + c)
s595789261
p03637
u140672616
2,000
262,144
Wrong Answer
63
11,100
322
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
n = int(input()) a = map(int, input().split(" ")) point = 0 for i in a: if i % 4 == 0: point += 2 elif i % 2 == 0: point += 1 if n % 2 == 1: if n <= point + 1: print("YES") else: print("NO") else: if n <= point: print("YES") else: print("NO") ...
s773627644
Accepted
64
11,100
319
n = int(input()) a = map(int, input().split(" ")) point = 0 for i in a: if i % 4 == 0: point += 2 elif i % 2 == 0: point += 1 if n % 2 == 1: if n <= point + 1: print("Yes") else: print("No") else: if n <= point: print("Yes") else: print("No")
s963812331
p04011
u183840468
2,000
262,144
Wrong Answer
19
3,060
168
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
n,k = [int(input()) for _ in range(2)] x,y = [int(input()) for _ in range(2)] ans = 0 for i in range(n): if i <= k: ans += x else: ans += y print(ans)
s210097554
Accepted
19
2,940
172
n,k = [int(input()) for _ in range(2)] x,y = [int(input()) for _ in range(2)] ans = 0 for i in range(1,n+1): if i <= k: ans += x else: ans += y print(ans)
s868024824
p03658
u371530330
2,000
262,144
Wrong Answer
17
2,940
94
Snuke has N sticks. The length of the i-th stick is l_i. Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy.
n,k = map(int, input().split()) l = map(int, input().split()) x = sorted(l) print(sum(x[k:]))
s559924715
Accepted
17
2,940
101
n,k = map(int, input().split()) l = list(map(int, input().split())) x = sorted(l) print(sum(x[n-k:]))
s417684624
p03860
u546853743
2,000
262,144
Wrong Answer
18
2,940
33
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppe...
s=input("") print("A","s[0]","C")
s225771100
Accepted
17
2,940
24
print("A%sC"%input()[8])
s028943061
p03449
u007886915
2,000
262,144
Wrong Answer
159
13,892
10,015
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You ...
# -*- coding: utf-8 -*- import sys import fractions import copy import bisect import math import numpy as np import itertools from itertools import combinations_with_replacement #w=input() from operator import itemgetter from sys import stdin from operator import mul from functools import reduce from collections imp...
s981489976
Accepted
157
13,640
10,142
# -*- coding: utf-8 -*- import sys import fractions import copy import bisect import math import numpy as np import itertools from itertools import combinations_with_replacement #w=input() from operator import itemgetter from sys import stdin from operator import mul from functools import reduce from collections imp...
s597133758
p02697
u948911484
2,000
1,048,576
Wrong Answer
71
9,280
68
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...
n,m = map(int,input().split()) for i in range(m): print(i+1,2*m-i)
s037779867
Accepted
74
9,144
242
n,m = map(int,input().split()) ans=[] if m%2==1: for i in range(m//2): print(i+1,m-i) for i in range(m//2+1): print(m+1+i,2*m+1-i) else: for i in range(m//2): print(i+1,m-i+1) for i in range(m//2): print(m+2+i,2*m+1-i)
s247865710
p03555
u749770850
2,000
262,144
Wrong Answer
17
2,940
122
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
c = [input() for _ in range(2)] if c[0][1] == c[1][1] and sorted(c[0]) == sorted(c[1]): print("Yes") else: print("No")
s277176075
Accepted
17
2,940
150
c = [input() for _ in range(2)] if c[0][1] == c[1][1] and c[0][0] == c[1][2] and c[0][2] == c[1][0]: print("YES") exit() else: print("NO") exit()
s073091862
p03609
u301302814
2,000
262,144
Wrong Answer
17
2,940
67
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?
# coding: utf-8 x, t = map(int, input().split()) print(min(x-t, 0))
s240163165
Accepted
17
2,940
67
# coding: utf-8 x, t = map(int, input().split()) print(max(x-t, 0))
s994445654
p03943
u475966842
2,000
262,144
Wrong Answer
17
2,940
92
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=input().split() if a+b==c or a+c==b or b+c==a : print("Yes") else: print("No")
s184227431
Accepted
18
2,940
120
a,b,c=input().split() a=int(a) b=int(b) c=int(c) if a+b==c or a+c==b or b+c==a : print("Yes") else: print("No")
s391190831
p03556
u785989355
2,000
262,144
Wrong Answer
338
20,380
60
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()) print(int(np.sqrt(N)))
s203151215
Accepted
28
2,940
87
N=int(input()) for i in range(1,10**5): if i**2>N: break print((i-1)**2)
s807140647
p03563
u395287676
2,000
262,144
Wrong Answer
17
3,064
3,286
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the cont...
import sys def main(): # Get Args args = _input_args() # get arguments as an array from console/script parameters. # Call main Logic result = _main(args) # Output a result in a correct way. _output_result(result) def _main(args): """Write Main Logic here for the contest. :param ...
s812405423
Accepted
17
3,064
2,449
import sys def main(): # Get Args args = _input_args() # get arguments as an array from console/script parameters. # Call main Logic result = _main(args) # Export a result in a correct way. _export_result(result) def _main(args): """Write Main Logic here for the contest. :param ...
s518260211
p03370
u538956308
2,000
262,144
Wrong Answer
17
2,940
139
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams o...
N,X = map(int,input().split()) D = [] for i in range(N): d = int(input()) D.append(d) a = X//sum(D) b = X%sum(D)//min(D) print(a+b)
s830524817
Accepted
17
2,940
142
N,X = map(int,input().split()) D = [] for i in range(N): d = int(input()) D.append(d) a = X-sum(D) b = len(D) c = a//min(D) print(b+c)
s684139700
p03556
u994521204
2,000
262,144
Wrong Answer
17
2,940
52
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 math a=int(input()) print(math.floor(a**0.5))
s499877533
Accepted
17
2,940
57
import math a=int(input()) print((math.floor(a**0.5))**2)
s304899238
p02417
u395334793
1,000
131,072
Wrong Answer
20
7,408
246
Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.
import sys cs = { c : 0 for c in list("abcdefghijklmnopqrstuvwxyz")} for c in list(sys.stdin.read()): c = c.lower() if c in cs.keys(): cs[c] = cs[c] + 1 for (c,cnt) in sorted(list(cs.items())): print('[0] : [1]'.format(c,cnt))
s548897686
Accepted
30
7,432
246
import sys cs = { c : 0 for c in list("abcdefghijklmnopqrstuvwxyz")} for c in list(sys.stdin.read()): c = c.lower() if c in cs.keys(): cs[c] = cs[c] + 1 for (c,cnt) in sorted(list(cs.items())): print('{0} : {1}'.format(c,cnt))
s411765193
p03761
u232733545
2,000
262,144
Wrong Answer
23
3,444
257
Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headlin...
from collections import Counter as cn d=int(input()) l = [] for k in range(d): p = cn(input()) l.append(p) oi = l[0] for g in range(len(l)): oi = oi & l[g] print(oi) print("".join(sorted(oi.elements())))
s313422014
Accepted
22
3,444
236
from collections import Counter d = int(input()) l = [] for k in range(d): r = input() l.append(Counter(r)) oi = l[0] for g in range(1,d): oi = oi & l[g] print("".join(sorted(oi.elements())))
s330672591
p02260
u058433718
1,000
131,072
Wrong Answer
20
7,636
519
Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 if A[j] < A[mini] 5 mini = j 6 swap A[...
import sys def selection_sort(nums, n): cnt = 0 for i in range(n): minj = i for j in range(i, n): if nums[j] < nums[minj]: minj = j if i != minj: nums[i], nums[minj] = nums[minj], nums[i] cnt += 1 print(cnt) def main():...
s023515229
Accepted
20
7,772
559
import sys def selection_sort(nums, n): cnt = 0 for i in range(n): minj = i for j in range(i, n): if nums[j] < nums[minj]: minj = j nums[i], nums[minj] = nums[minj], nums[i] if i != minj: cnt += 1 print(' '.join([str(i) for i in...
s502682278
p03997
u457957084
2,000
262,144
Wrong Answer
17
2,940
75
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a = int(input()) b = int(input()) h = int(input()) print((a + b) * h / 2)
s634711218
Accepted
17
2,940
81
a = int(input()) b = int(input()) h = int(input()) print(int((a + b) * h / 2))
s589496022
p02646
u609176437
2,000
1,048,576
Wrong Answer
21
9,184
180
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch ...
a,v = map(int,input().split()) b,w = map(int,input().split()) t = int(input()) coordinate_ab = b-a speed_ab = w-v if coordinate_ab < speed_ab * t: print("YES") else:print("NO")
s906982222
Accepted
21
9,168
141
a,v = map(int,input().split()) b,w = map(int,input().split()) t = int(input()) if (v-w)*t >= abs(b-a): print("YES") else: print("NO")
s921307695
p03494
u085334230
2,000
262,144
Wrong Answer
32
2,940
247
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())) j = True count = 0 while j: for i in A: if i % 2 == 0: A[A.index(i)] = i / 2 else: j = False count += 1 print(count)
s171545440
Accepted
32
3,060
290
N = int(input()) A = list(map(int,input().split())) j = True count = 0 while j : for i in A: if i % 2 == 0 or i == 0: A[A.index(i)] = i / 2 else: j = False if j == True: count += 1 print(count)
s499864871
p02743
u732870425
2,000
1,048,576
Wrong Answer
17
2,940
120
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
a, b, c = map(int, input().split()) if a ** 0.5 + b ** 0.5 > c ** 0.5: ans = "Yes" else: ans = "No" print(ans)
s685016167
Accepted
17
3,068
174
a, b, c = map(int, input().split()) if c - a - b > 0: if 4 * a * b < (c - a - b) ** 2: ans = "Yes" else: ans = "No" else: ans = "No" print(ans)
s301709358
p03854
u816428863
2,000
262,144
Wrong Answer
19
3,188
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`.
S=input() S=S.replace("eraser","") S=S.replace("erase","") S=S.replace("dreamer","") S=S.replace("dream","") if S=="": print("Yes") else: print("No")
s959798379
Accepted
18
3,188
159
S=input() S=S.replace("eraser","") S=S.replace("erase","") S=S.replace("dreamer","") S=S.replace("dream","") if S=="": print("YES") else: print("NO")
s798044546
p00001
u897625141
1,000
131,072
Wrong Answer
30
7,500
135
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
Array = [] for i in range(10): Array.append(int(input())) Anum = len(Array) for i in range(Anum-1,Anum-4,-1): print(Array[i])
s224429001
Accepted
30
7,636
98
array = [int(input()) for i in range(10)] array.sort() for i in range(9,6,-1): print(array[i])
s446888606
p03474
u077019541
2,000
262,144
Wrong Answer
17
2,940
137
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
A,B = map(int,input().split()) S = [i for i in input().split()] if len(S[0])==A and len(S[1])==B: print("Yes") else: print("No")
s421794753
Accepted
17
2,940
140
A,B = map(int,input().split()) S = [i for i in input().split("-")] if len(S[0])==A and len(S[1])==B: print("Yes") else: print("No")
s037931982
p03860
u821251381
2,000
262,144
Wrong Answer
17
2,940
25
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...
print("A"+input()[0]+"C")
s320687500
Accepted
17
2,940
36
print("A"+input().split()[1][0]+"C")
s438348558
p03455
u863478942
2,000
262,144
Wrong Answer
17
2,940
88
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("Odd") else: print("Even")
s006452711
Accepted
17
2,940
88
a, b = map(int, input().split()) if a * b % 2 == 0: print("Even") else: print("Odd")
s793972981
p02796
u960080897
2,000
1,048,576
Wrong Answer
491
20,104
253
In a factory, there are N robots placed on a number line. Robot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative. We want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect. Here, for each i (1 \leq i \leq N...
N = int(input()) robot = [] ans = 0 for i in range(N): x,l = map(int,input().split()) robot.append([x-l,x+l]) robot.sort() cur = -float('inf') for i in range(N): if cur <= robot[i][1]: ans += 1 cur = robot[i][0] print(ans)
s193395569
Accepted
519
20,104
253
N = int(input()) robot = [] ans = 0 for i in range(N): x,l = map(int,input().split()) robot.append([x+l,x-l]) robot.sort() cur = -float('inf') for i in range(N): if cur <= robot[i][1]: ans += 1 cur = robot[i][0] print(ans)
s184813134
p03698
u044746696
2,000
262,144
Wrong Answer
17
2,940
50
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)==set(s) else 'no')
s714871905
Accepted
17
2,940
55
s=input() print('yes' if len(s)==len(set(s)) else 'no')
s133290491
p03386
u916806287
2,000
262,144
Wrong Answer
2,104
2,940
118
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()) result = [i for i in range(a, b+1) if i <= (a + k) or (b - k) <= i] print(result)
s061312669
Accepted
17
3,064
293
a, b, k = map(int, input().split()) if a + k > b: a_k = b else: a_k = a + k if b - k < a: b_k = a else: b_k = b - k if a == b: a_k = a + 1 b_k = b + 1 result = list(set([i for i in range(a, a_k)] + [i for i in range(b_k + 1, b + 1)])) result.sort() for n in result: print(n)
s897238053
p02394
u533681846
1,000
131,072
Wrong Answer
20
5,596
106
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.
W,H,x,y,r = map(int,input().split()) if r<x & r<y & x<W-r & y<H-r: print("Yes") else: print("No")
s686380040
Accepted
20
5,596
120
W,H,x,y,r = map(int,input().split()) if r<=x and r<=y and x<=(W-r) and y<=(H-r): print("Yes") else: print("No")
s066663804
p02678
u952773501
2,000
1,048,576
Wrong Answer
2,213
227,700
662
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in th...
n, m = map(int, input().split()) abj = [set() for _ in range(n)] for _ in range(m): a, b = map(int, input().split()) a, b = a-1, b-1 abj[a].add(b) abj[b].add(a) def bfs_paths(graph, start, goal): queue = [(start, [start])] result = [] while queue: n, path = queue.pop(0) ...
s529331168
Accepted
707
37,744
501
from collections import deque n, m = map(int, input().split()) g = [[] for _ in range(n)] for _ in range(m): a, b = map(int, input().split()) g[a-1].append(b-1) g[b-1].append(a-1) queue = deque([0]) d = [None]*n d[0] = 0 while queue: v = queue.popleft() for i in g[v]: if d[i] == No...
s239508556
p03827
u599547273
2,000
262,144
Wrong Answer
17
2,940
77
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...
n,s=map(input,"aa");print(max(s[:i].count("I")*2-i for i in range(int(n)+1)))
s343573766
Accepted
17
2,940
77
n,s=input(),input();print(max(s[:i].count("I")*2-i for i in range(int(n)+1)))
s708169315
p03493
u626468554
2,000
262,144
Wrong Answer
17
2,940
176
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.
#n = int(input()) #n,k = map(int,input().split()) #x = list(map(int,input().split())) n = list(input()) cnt =0 for i in range(3): if n[i]==1: cnt += 1 print(cnt)
s367183182
Accepted
17
2,940
178
#n = int(input()) #n,k = map(int,input().split()) #x = list(map(int,input().split())) n = list(input()) cnt =0 for i in range(3): if n[i]=="1": cnt += 1 print(cnt)
s304775806
p01085
u546285759
8,000
262,144
Wrong Answer
110
7,584
216
The International Competitive Programming College (ICPC) is famous for its research on competitive programming. Applicants to the college are required to take its entrance examination. The successful applicants of the examination are chosen as follows. * The score of any successful applicant is higher than that of ...
while 1: m,nn,nx= map(int,input().split()) if m==0: break s=[int(input()) for _ in range(m)] v=k=0 for i in range(nn-1,nx): t=s[i]-s[i+1] if v<t: k,v=i+1,t print(k)
s173878269
Accepted
130
5,624
294
while True: m, n_min, n_max = map(int, input().split()) if m == 0: break p = [int(input()) for _ in range(m)] ans = tmp = 0 for i in range(n_min, n_max+1): hoge = p[i-1] - p[i] if tmp <= hoge: tmp = hoge ans = i print(ans)
s750851909
p03609
u346629192
2,000
262,144
Wrong Answer
17
2,940
48
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?
X,t = map(int,input().split()) print(min(0,X-t))
s781290388
Accepted
17
3,064
48
X,t = map(int,input().split()) print(max(0,X-t))
s500945177
p03455
u756464404
2,000
262,144
Wrong Answer
18
2,940
93
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
def product_judge(a,b): c = a*b if c % 2 == 0: print("Even") else: print("Odd")
s318850180
Accepted
17
2,940
84
a,b = map(int,input().split()) if a*b % 2 == 0: print("Even") else: print("Odd")
s179293903
p03495
u710921979
2,000
262,144
Wrong Answer
54
20,228
148
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
import collections N,K=map(int,input().split()) c=sorted(collections.Counter(ball=list(map(str,input().split()))).values()) print(sum(c[:len(c)-K]))
s393128412
Accepted
102
35,996
137
import collections N,K=map(int,input().split()) c=sorted(collections.Counter(list(map(str,input().split()))).values()) print(sum(c[:-K]))
s895880476
p02412
u634490486
1,000
131,072
Wrong Answer
20
5,600
341
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
from sys import stdin while True: n, x = [int(x) for x in stdin.readline().rstrip().split()] if n == 0 and x == 0: break else: count = 0 for i in range(1, n-1): for j in range(i+1, n-2): if j < x-i-j <= n: count += 1 else: ...
s009559354
Accepted
40
5,608
339
from sys import stdin while True: n, x = [int(x) for x in stdin.readline().rstrip().split()] if n == 0 and x == 0: break else: count = 0 for i in range(1, n-1): for j in range(i+1, n): if j < x-i-j <= n: count += 1 else: ...
s503922479
p03502
u928385607
2,000
262,144
Wrong Answer
17
2,940
237
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
n= int(input()) nn = n f = 0 while nn != 0: f = f + nn % 10 nn = int( nn / 10) if n%f == 0: print('YES') else: print('NO')
s173582844
Accepted
17
3,060
237
n= int(input()) nn = n f = 0 while nn != 0: f += int(nn % 10) nn = int(nn/10) if n%f == 0: print('Yes') else: print('No')
s807160580
p03962
u451017206
2,000
262,144
Wrong Answer
17
2,940
37
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he migh...
print(len(set([i for i in input()])))
s202798219
Accepted
17
2,940
45
print(len(set([i for i in input().split()])))
s720303279
p02413
u510829608
1,000
131,072
Wrong Answer
20
7,504
117
Your task is to perform a simple table calculation. Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.
n, m = map(int, input().split()) for i in range(n): a = list(map(int, input().split())) a.append(sum(a)) print(*a)
s208890749
Accepted
30
8,356
269
n, m = map(int, input().split()) li = [list(map(int,input().split())) for i in range(n)] c = [] for i in range(n): li[i].append(sum(li[i])) for j in range(m+1): t = 0 for i in range(n): t += li[i][j] c.append(t) li.append(c) for i in range(n+1): print(*li[i])
s584537198
p02413
u711765449
1,000
131,072
Wrong Answer
30
7,772
499
Your task is to perform a simple table calculation. Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.
r,c = map(int,input().split(' ')) arr = [[0 for i in range(c+1)] for i in range(r+1)] for i in range(r): row = list(map(int,input().split(' '))) for j in range(c): arr[i][j] = row[j] for i in range(r): for j in range(c): arr[i][-1] += arr[i][j] for i in range(c): for j in range(r): ...
s597119797
Accepted
40
8,428
662
r,c = map(int,input().split(' ')) arr = [[0 for i in range(c+1)] for i in range(r+1)] for i in range(r): row = list(map(int,input().split(' '))) for j in range(c): arr[i][j] = row[j] for i in range(r): for j in range(c): arr[i][-1] += arr[i][j] for i in range(c): for j in range(r): ...
s683024417
p03693
u024442309
2,000
262,144
Wrong Answer
17
2,940
91
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 (r*100+g*10+b)%4: print('No') else: print('Yes')
s287527601
Accepted
17
2,940
91
r, g, b = map(int, input().split()) if (r*100+g*10+b)%4: print('NO') else: print('YES')
s163736084
p03435
u506858457
2,000
262,144
Wrong Answer
29
9,112
189
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) ...
a,b,c=map(int,input().split()) d,e,f=map(int,input().split()) g,h,i=map(int,input().split()) if a+e==b+d: if b+f==c+e: if d+h==e+g: if e+i==f+h: print('Yes') print('No')
s365766587
Accepted
31
9,072
204
a,b,c=map(int,input().split()) d,e,f=map(int,input().split()) g,h,i=map(int,input().split()) if a+e==b+d: if b+f==c+e: if d+h==e+g: if e+i==f+h: print('Yes') exit() print('No')
s036959410
p03557
u706330549
2,000
262,144
Wrong Answer
243
20,064
466
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower. He has N parts for each of the three categories. The size of the i-th upper ...
import numpy as np import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines n = int(readline()) a = np.array(readline().split(), dtype=np.int32) b = np.array(readline().split(), dtype=np.int32) c = np.array(readline().split(), dtype=np.int32) a.sort() b.sort(...
s247581566
Accepted
242
20,064
468
import numpy as np import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines n = int(readline()) a = np.array(readline().split(), dtype=np.int32) b = np.array(readline().split(), dtype=np.int32) c = - np.array(readline().split(), dtype=np.int32) a.sort() b.sor...
s265714323
p02255
u508054630
1,000
131,072
Wrong Answer
20
5,596
376
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key ...
def InsertionSort(A, N): ans = '' i = 1 while i < N: v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j + 1] = v ans += ' '.join(map(str, A)) + '\n' i += 1 return ans[:-1] n = int(input()) A = list(map(int, in...
s245754284
Accepted
20
5,644
402
def InsertionSort(A, N): ans = ' '.join(map(str, A)) + '\n' i = 1 while i < N: v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j + 1] = v ans += ' '.join(map(str, A)) + '\n' i += 1 return ans[:-1] n = int(inp...
s702805840
p03759
u794753968
2,000
262,144
Wrong Answer
17
3,060
70
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
a,b,c = map(int, input().split()) print("Yes" if b-a == c-b else "No")
s349079369
Accepted
17
2,940
70
a,b,c = map(int, input().split()) print("YES" if b-a == c-b else "NO")
s340017120
p02259
u749243807
1,000
131,072
Wrong Answer
20
5,604
444
Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, in...
count = int(input()); data = [int(n) for n in input().split(" ")]; def bubble_sort(data): show(data); count = len(data); for i in range(count): for j in range(count - 1, i, -1): if data[j] < data[j - 1]: temp = data[j]; data[j] = data[j - 1]; ...
s680910922
Accepted
20
5,604
473
count = int(input()); data = [int(n) for n in input().split(" ")]; def bubble_sort(data): count = len(data); o = 0; for i in range(count): for j in range(count - 1, i, -1): if data[j] < data[j - 1]: o += 1; temp = data[j]; data[j] = data[j...
s210123905
p03388
u631277801
2,000
262,144
Wrong Answer
17
3,060
213
10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th. The _score_ of a participant is the product of his/her ranks in the two contests. Process the following Q queries: * In the i-th query, you ...
from math import sqrt, floor import sys sdin = sys.stdin.readline q = int(sdin()) ab = [] for i in range(q): ab.append(tuple(map(int, sdin().split()))) for a, b in ab: print(floor(2 * sqrt(a*b)) - 2)
s420806605
Accepted
18
3,064
862
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return map(int, stdin.readline().split()) def li_(): return map(lambda x: int(x)-1, stdin.readline().split()) def lf(): return map(float, stdin.readline().split()) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() ...
s208474498
p03377
u655975843
2,000
262,144
Wrong Answer
17
2,940
94
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
a, b, x = map(int, input().split()) if a <= x and x <= a + b: print('Yes') else: print('No')
s006376784
Accepted
20
3,060
94
a, b, x = map(int, input().split()) if a <= x and x <= a + b: print('YES') else: print('NO')
s184327059
p03997
u610143410
2,000
262,144
Wrong Answer
23
3,064
84
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()) s = ((a + b) * h ) / 2 print(s)
s778322622
Accepted
23
3,064
89
a = int(input()) b = int(input()) h = int(input()) s = ((a + b) * h ) / 2 print(int(s))
s527663521
p03998
u473291366
2,000
262,144
Wrong Answer
17
3,064
350
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. * ...
A = input() B = input() C = input() a = list(A) b = list(B) c = list(C) state = [a, b, c] player = 0 player_name = ["a", "b", "c"] get_player = {"a": 0, "b":1, "c": 2} while True: if len(state[player]) == 0: print(player_name[player]) exit() next_player_name = state[player].pop(0) player =...
s437133313
Accepted
17
3,060
331
A = input() B = input() C = input() state = [list(A), list(B), list(C)] player = 0 player_name = ["A", "B", "C"] get_player = {"a": 0, "b":1, "c": 2} while True: if len(state[player]) == 0: print(player_name[player]) exit() next_player_name = state[player].pop(0) player = get_player[next_pl...
s111260720
p02972
u771007149
2,000
1,048,576
Wrong Answer
995
22,796
675
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()) a = list(map(int,input().split())) box = [0 for _ in range(n)] result = [] def baisu(n,max_n): ans = [] cnt = 1 while n*cnt <= max_n: ans.append(n*cnt) cnt += 1 return ans for i in range(n-1,-1,-1): if i+1 > n//2: box[i] = a[i] else: ...
s775321783
Accepted
1,002
21,684
677
#D n = int(input()) a = list(map(int,input().split())) box = [0 for _ in range(n)] result = [] def baisu(n,max_n): ans = [] cnt = 1 while n*cnt <= max_n: ans.append(n*cnt) cnt += 1 return ans for i in range(n-1,-1,-1): if i+1 > n//2: box[i] = a[i] else: ...
s592792121
p03827
u609061751
2,000
262,144
Wrong Answer
17
2,940
217
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...
import sys input = sys.stdin.readline N = int(input()) S = list(input().rstrip()) maxx = -(10 ** 9) x = 0 for i in S: if i == "I": x += 1 else: x -= 1 if x > maxx: maxx = x print(x)
s297315000
Accepted
17
3,060
200
import sys input = sys.stdin.readline N = int(input()) S = list(input().rstrip()) ans = [0] x = 0 for i in S: if i == "I": x += 1 else: x -= 1 ans.append(x) print(max(ans))
s374112321
p02397
u782850499
1,000
131,072
Wrong Answer
40
8,028
202
Write a program which reads two integers x and y, and prints them in ascending order.
a=[] while True: m,n=input().split() if m==n=="0": break else: a.append(sorted([int(m),int(n)])) print(a) for i in range(len(a)): print("{0} {1}".format(a[i][0],a[i][1]))
s321470688
Accepted
50
8,024
193
a=[] while True: m,n=input().split() if m==n=="0": break else: a.append(sorted([int(m),int(n)])) for i in range(len(a)): print("{0} {1}".format(a[i][0],a[i][1]))
s160876996
p02612
u662396511
2,000
1,048,576
Wrong Answer
28
9,144
58
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 >= 1000: n -= 1000 print(n)
s612844840
Accepted
29
9,156
77
n = int(input()) if n%1000 == 0: print(0) else: print(1000-(n%1000))
s040279139
p03546
u677121387
2,000
262,144
Time Limit Exceeded
2,108
3,444
699
Joisino the magical girl has decided to turn every single digit that exists on this world into 1. Rewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points). She is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and...
from itertools import permutations h,w = map(int,input().split()) c = [[int(i) for i in input().split()] for _ in range(10)] a = [[int(i) for i in input().split()] for _ in range(h)] ans = 0 lst = [int(i) for i in range(10) if i != 1] mp = [0]*10 for i in lst: mp[i] = c[i][1] for j in range(1,9): for ...
s234074289
Accepted
35
3,316
402
h,w = map(int,input().split()) c = [[int(i) for i in input().split()] for _ in range(10)] a = [[int(i) for i in input().split()] for _ in range(h)] for k in range(10): for i in range(10): for j in range(10): c[i][j] = min(c[i][j], c[i][k] + c[k][j]) ans = 0 mp = [c[i][1] for i in range(10)] mp...
s950527047
p02731
u067694718
2,000
1,048,576
Wrong Answer
17
2,940
49
Given is a positive integer L. Find the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.
a = int(input()) b = a // 3 print(float(b ** 3))
s957531867
Accepted
17
2,940
58
a = int(input()) b = a / 3 print('{:.12f}'.format(b ** 3))
s957688638
p03371
u857673087
2,000
262,144
Wrong Answer
17
3,064
222
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the curr...
A,B,C,X,Y = map(int,input().split()) plan1 = (A*X) + (B*Y) plan2 = (C*2) * max(X,Y) plan3 = (C*2) * X + B*(Y-X) plan4 = (C*2) * Y + A*(Y-X) if X <= Y: print(min(plan1,plan2,plan3)) else: print(min(plan1,plan2,plan4))
s049085731
Accepted
18
3,060
223
A,B,C,X,Y = map(int,input().split()) plan1 = (A*X) + (B*Y) plan2 = (C*2) * max(X,Y) plan3 = (C*2) * X + B*(Y-X) plan4 = (C*2) * Y + A*(X-Y) if X <= Y: print(min(plan1,plan2,plan3)) else: print(min(plan1,plan2,plan4))
s322472040
p03971
u282228874
2,000
262,144
Wrong Answer
106
4,016
370
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from t...
N,A,B = map(int,input().split()) S = input() a = 0 b = 0 for s in S: if s == 'a': if a+b <= A+B: print("Yes") a += 1 else: a += 1 elif s == 'b': if a+b <= A+B and b <= B: print("Yes") b += 1 else: print("No")...
s631336243
Accepted
133
4,016
287
N,A,B = map(int,input().split()) S = input() a = 0 b = 0 for s in S: if s == 'a': a += 1 print("Yes" if a+b <= A+B else "No") elif s == 'b': b += 1 print("Yes" if a+b <= A+B and b <= B else "No" ) b = min(b,B) else: print("No")
s698481658
p03485
u456033454
2,000
262,144
Wrong Answer
17
2,940
50
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
a, b = map(int, input().split()) print((a+b)//2+1)
s165281368
Accepted
19
3,060
52
a, b = map(int, input().split()) print(-(-(a+b)//2))
s468166541
p02833
u075739430
2,000
1,048,576
Wrong Answer
17
2,940
120
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() n //= 1 res = 0 while n > 0: n //= 5 res += n print(res)
s987298545
Accepted
17
2,940
120
n = int(input()) if n % 2 == 1: print(0) exit() n //= 2 res = 0 while n > 0: n //= 5 res += n print(res)
s648091403
p02612
u314079346
2,000
1,048,576
Wrong Answer
24
8,992
76
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()) for i in range(0,11000,1000): if N<=i: print(int(i-N))
s855663103
Accepted
27
9,084
31
print((1000-int(input()))%1000)
s822317816
p02408
u786891610
1,000
131,072
Wrong Answer
20
5,596
253
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.
n = int(input()) cards = {} for i in range(n): card = input() cards[card] = 1 #print(cards) for c in ['S','H','C','D']: for n in range(1,13): key = c + '' + str(n) if not key in cards: print(key)
s779137958
Accepted
20
5,600
256
n = int(input()) cards = {} for i in range(n): card = input() cards[card] = 1 # print(cards) for c in ['S','H','C','D']: for n in range(1, 14): key = c + ' ' + str(n) if not key in cards: print(key)
s502479734
p02981
u094932051
2,000
1,048,576
Wrong Answer
17
2,940
169
N of us are going on a trip, by train or taxi. The train will cost each of us A yen (the currency of Japan). The taxi will cost us a total of B yen. How much is our minimum total travel expense?
while True: try: N, A, B = map(int, input().split()) if A >= B: print(N*B) else: print(N*A) except: break
s082488143
Accepted
17
2,940
169
while True: try: N, A, B = map(int, input().split()) if N*A >= B: print(B) else: print(N*A) except: break
s109690466
p03007
u306950978
2,000
1,048,576
Wrong Answer
162
21,228
593
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...
from collections import deque n = int(input()) a = list(map(int,input().split())) a.sort() d = deque(a) print(sum(a)-2*sum(a[:n//2])) if n % 2 == 1: now = d.pop() for i in range(n-1): if i % 2 == 0: nex = d.popleft() elif i % 2 == 1: nex = d.pop() print(str(nex) +...
s636890139
Accepted
190
24,792
883
n = int(input()) a = list(map(int,input().split())) a.sort() aminus = [] aplus = [] p = 0 q = 0 for i in a: if i >= 0: aplus.append(i) p += 1 elif i < 0: aminus.append(i) q += 1 ans = [] cou = 0 if aplus and aminus: now = aminus[0] for i in range(p-1): ans.append(...
s164342027
p02617
u571331348
2,000
1,048,576
Wrong Answer
934
9,600
395
We have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\cdots, N and 1, 2, \cdots, N-1. Edge i connects Vertex u_i and v_i. For integers L, R (1 \leq L \leq R \leq N), let us define a function f(L, R) as follows: * Let S be the set of the vertices numbered L through R. f(L, R) represents the numbe...
n = int(input()) ans = 0 for i in range(1,n+1): ans += i*(n-i+1) print(ans) for _ in range(n-1): u,v = map(int, input().split()) if u > v: u,v = v,u ans -= u*(n-v+1) print(ans) print(ans)
s948257313
Accepted
416
9,184
414
# coding: utf-8 n = int(input()) ans = 0 for i in range(1,n+1): ans += i*(n-i+1) #print(ans) for _ in range(n-1): u,v = map(int, input().split()) if u > v: u,v = v,u ans -= u*(n-v+1) #print(ans) print(ans)
s627433988
p03720
u440129511
2,000
262,144
Wrong Answer
18
3,060
172
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
import itertools n,m=map(int,input().split()) ab= [list(input()) for _ in range(m)] ab=list(itertools.chain.from_iterable(ab)) for i in range(1,n+1): print(ab.count(i))
s873341326
Accepted
17
3,060
189
import itertools n,m=map(int,input().split()) ab= [list(map(int,input().split())) for _ in range(m)] ab=list(itertools.chain.from_iterable(ab)) for i in range(1,n+1): print(ab.count(i))
s054608097
p03524
u548624367
2,000
262,144
Wrong Answer
31
9,740
104
Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.
s = list(input()) a = [s.count('a'),s.count('b'),s.count('c')] print("No" if max(a)-min(a)>1 else "Yes")
s646786301
Accepted
38
9,836
104
s = list(input()) a = [s.count('a'),s.count('b'),s.count('c')] print("NO" if max(a)-min(a)>1 else "YES")
s884414431
p03543
u823885866
2,000
262,144
Wrong Answer
117
27,072
459
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
import sys import math import itertools import collections import heapq import re import numpy as np rr = lambda: sys.stdin.readline().rstrip() rs = lambda: sys.stdin.readline().split() ri = lambda: int(sys.stdin.readline()) rm = lambda: map(int, sys.stdin.readline().split()) rl = lambda: list(map(int, sys.stdin.readl...
s059873148
Accepted
120
26,912
464
import sys import math import itertools import collections import heapq import re import numpy as np rr = lambda: sys.stdin.readline().rstrip() rs = lambda: sys.stdin.readline().split() ri = lambda: int(sys.stdin.readline()) rm = lambda: map(int, sys.stdin.readline().split()) rl = lambda: list(map(int, sys.stdin.readl...
s058939207
p03470
u493491792
2,000
262,144
Wrong Answer
17
2,940
127
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you h...
n=int(input()) lista=[] for i in range(n): lista.append(int(input())) lista=set(lista) print(lista) print(len(lista))
s052171409
Accepted
17
2,940
77
n=int(input()) a=[int(input()) for i in range(n)] print(len(set(a)))
s839320410
p03574
u161703388
2,000
262,144
Wrong Answer
32
3,444
444
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square con...
H, W = map(int, input().split()) S = [input() for i in range(H)] offset_h = (-1,-1,-1,0,0,1,1,1) offset_w = (-1,0,1,-1,1,-1,0,1) for h in range(H): for w in range(W): if S[h][w] == "#": print("#", end="") else: bomb = 0 for i,j in zip(offset_h, offset_w): if h+i >= 0 and h+i < H and...
s897716621
Accepted
32
3,444
444
H, W = map(int, input().split()) S = [input() for i in range(H)] offset_h = (-1,-1,-1,0,0,1,1,1) offset_w = (-1,0,1,-1,1,-1,0,1) for h in range(H): for w in range(W): if S[h][w] == "#": print("#", end="") else: bomb = 0 for i,j in zip(offset_h, offset_w): if h+i >= 0 and h+i < H and...
s904075421
p03474
u629350026
2,000
262,144
Wrong Answer
17
3,064
217
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
a,b=map(int,input().split()) s=str(input()) slist=list(s) temp=slist.count("-") if temp==1 and slist[a]=="-": s.replace("","-") if s.isdecimal()==True: print("Yes") else: print("No") else: print("No")
s943549794
Accepted
18
3,060
219
a,b=map(int,input().split()) s=str(input()) slist=list(s) temp=slist.count("-") if temp==1 and slist[a]=="-": s=s.replace("-","") if s.isdecimal()==True: print("Yes") else: print("No") else: print("No")
s427989068
p03545
u562016607
2,000
262,144
Wrong Answer
18
3,060
173
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given in...
import itertools S=input() TT=itertools.product(["+","-"],repeat=3) for T in TT: A=S[0]+T[0]+S[1]+T[1]+S[2]+T[2]+S[3] if eval(A)==7: print(A) exit()
s722904031
Accepted
18
3,060
178
import itertools S=input() TT=itertools.product(["+","-"],repeat=3) for T in TT: A=S[0]+T[0]+S[1]+T[1]+S[2]+T[2]+S[3] if eval(A)==7: print(A+"=7") exit()
s670023034
p03470
u426108351
2,000
262,144
Wrong Answer
17
3,060
116
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you h...
N = int(input()) mochi = [] for i in range(N): mochi.append(int(input())) print(list(set(mochi)))
s609243016
Accepted
18
2,940
121
N = int(input()) mochi = [] for i in range(N): mochi.append(int(input())) print(len(list(set(mochi))))