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
s799721302
p02288
u320446607
2,000
131,072
Wrong Answer
20
7,768
447
A binary heap which satisfies max-heap property is called max-heap. In a max- heap, for every node $i$ other than the root, $A Write a program which reads an array and constructs a max-heap from the array based on the following pseudo code. $maxHeapify(A, i)$ move the value of $A[i]$ down to leaves to make a sub-tr...
H = int(input()) A = [None] + list(map(int, input().split())) def max_heapify(A, i): l = i * 2 r = i * 2 + 1 largest = i if l < H: if A[l] > A[largest]: largest = l if r < H: if A[r] > A[largest]: largest = r if largest != i: A[i], A[largest] = A[largest], A[i] max_heapify(A, largest) def build_m...
s320131823
Accepted
870
65,520
443
H = int(input()) A = [None] + list(map(int, input().split())) def max_heapify(A, i): l = i * 2 r = i * 2 + 1 largest = i if l <= H: if A[l] > A[largest]: largest = l if r <= H: if A[r] > A[largest]: largest = r if largest != i: A[i], A[largest] = A[largest], A[i] max_heapify(A, largest) def build...
s665684049
p02388
u217701374
1,000
131,072
Wrong Answer
20
7,456
36
Write a program which calculates the cube of a given integer x.
X = input() XX = int(X) print(XX**2)
s055602763
Accepted
30
7,436
28
X = int(input()) print(X**3)
s703581102
p03672
u823885866
2,000
262,144
Wrong Answer
123
27,232
571
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...
import sys import math import itertools import collections import heapq import re import numpy as np from functools import reduce 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: ...
s349019523
Accepted
117
27,024
560
import sys import math import itertools import collections import heapq import re import numpy as np from functools import reduce 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: ...
s821724035
p02613
u121698457
2,000
1,048,576
Wrong Answer
159
9,220
329
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`,...
N = int(input()) lis = [0,0,0,0] for i in range(N): s = input() if s == 'AC': lis[0] += 1 elif s == 'WA': lis[1] += 1 elif s == 'TLE': lis[2] += 1 else: lis[3] += 1 print('AC × '+str(lis[0])) print('WA × '+str(lis[1])) print('TLE × '+str(lis[2])) print('RE × '+str(lis...
s817687512
Accepted
150
9,216
325
N = int(input()) lis = [0,0,0,0] for i in range(N): s = input() if s == 'AC': lis[0] += 1 elif s == 'WA': lis[1] += 1 elif s == 'TLE': lis[2] += 1 else: lis[3] += 1 print('AC x '+str(lis[0])) print('WA x '+str(lis[1])) print('TLE x '+str(lis[2])) print('RE x '+str(lis...
s086701566
p03567
u289162337
2,000
262,144
Wrong Answer
19
2,940
110
Snuke built an online judge to hold a programming contest. When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.) Determine whether the judge can return the ...
l = input() for i in range(len(l)-1): if l[i:i+1] == "AC": print("Yes") break else: print("No")
s093320305
Accepted
17
2,940
110
l = input() for i in range(len(l)-1): if l[i:i+2] == "AC": print("Yes") break else: print("No")
s747206541
p03827
u428855582
2,000
262,144
Wrong Answer
17
3,060
165
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 = int(input()) tex=list(input()) print(tex) max=0 cur=0 for i in range(N): if tex[i]=="I": cur+=1 if cur>max: max=cur else: cur-=1 print(max)
s196415922
Accepted
17
2,940
154
N = int(input()) tex=list(input()) max=0 cur=0 for i in range(N): if tex[i]=="I": cur+=1 if cur>max: max=cur else: cur-=1 print(max)
s669016410
p03478
u086051538
2,000
262,144
Wrong Answer
37
3,060
153
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()) counter=0 for m in range(1,n): s=str(m) array=list(map(int,s)) if a<=sum(array)<=b: counter+=m print(counter)
s349476052
Accepted
39
3,060
152
n,a,b=map(int,input().split()) counter=0 for m in range(1,n+1): s=str(m) array=list(map(int,s)) if a<=sum(array)<=b: counter+=m print(counter)
s182840676
p03861
u355137116
2,000
262,144
Wrong Answer
2,108
2,940
114
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()) count = 0 for i in range(a, a+b): if i % x == 0: count += 1 print(count)
s795591470
Accepted
17
2,940
52
a,b,x=map(int,input().split()) print(b//x-(a-1)//x)
s873237740
p03470
u128859393
2,000
262,144
Wrong Answer
18
2,940
56
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...
input();print(len(set(list(map(int, input().split())))))
s210294486
Accepted
18
2,940
78
N = int(input());print(len(set(list(map(int, [input() for _ in range(N)])))))
s306991627
p03673
u073775598
2,000
262,144
Wrong Answer
2,104
26,020
219
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
#ABC066C n=int(input()) a=list(map(int, input().split())) front=[] back=[] for i in range(n//2): front.insert(0, a[2*i-(n%2)+1]) back.append(a[2*i+(n%2)]) if n%2==1: front.insert(0, a[n-1]) print(front+back)
s407702260
Accepted
166
31,296
264
#ABC066C n=int(input()) a=list(map(int, input().split())) flg=n%2 half=n//2 front=[0]*(half+flg) back=[0]*(half) for i in range(half): front[half+flg-1-i]=a[2*i-flg+1] back[i]=a[2*i+flg] if flg==1: front[0]=a[n-1] print(' '.join(map(str, front+back)))
s148626339
p02259
u867503285
1,000
131,072
Wrong Answer
20
7,704
377
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...
def bubble_sort(target): flag = True while flag: flag = False for i in range(len(target)-1, 0, -1): if target[i] < target[i-1]: target[i-1], target[i] = target[i], target[i-1] flag = True return target N = int(input()) A = [int(s) for s in input()...
s234341462
Accepted
30
7,712
436
def bubble_sort(target): global cnt flag = True while flag: flag = False for i in range(len(target)-1, 0, -1): if target[i] < target[i-1]: target[i-1], target[i] = target[i], target[i-1] flag = True cnt += 1 return target N = i...
s417770317
p03997
u583507988
2,000
262,144
Wrong Answer
17
2,940
83
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()) ans = (a + b)*h / 2 print(ans)
s348464550
Accepted
27
8,876
73
a = int(input()) b = int(input()) h = int(input()) print(int((a+b)*h/2))
s053347144
p03436
u390694622
2,000
262,144
Wrong Answer
31
4,972
2,033
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player re...
# coding: UTF-8 #@document_it from collections import deque def document_it(func): def new_function(*args,**kwargs): print('Running function:', func.__name__) print('Positional arguments:', args) print('Kewword arguments:', kwargs) result = func(*args,**kwargs) print('Result:...
s493427038
Accepted
32
4,972
2,035
# coding: UTF-8 #@document_it from collections import deque def document_it(func): def new_function(*args,**kwargs): print('Running function:', func.__name__) print('Positional arguments:', args) print('Kewword arguments:', kwargs) result = func(*args,**kwargs) print('Result:...
s283701514
p03129
u529722835
2,000
1,048,576
Wrong Answer
17
2,940
214
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
N , K = (int(i) for i in input().split()) if N % 2 == 0: if N/2 >= K: print('Yes') else: print('No') elif N % 2 == 1: if N/2 +1 >=K: print('Yes') else: print('No')
s644212455
Accepted
17
2,940
206
N , K = map(int, input().split()) if N % 2 == 0: if N//2 >= K: print('YES') else: print('NO') elif N % 2 == 1: if N//2 +1 >= K: print('YES') else: print('NO')
s167669248
p02382
u175224634
1,000
131,072
Wrong Answer
20
5,640
392
Your task is to calculate the distance between two $n$ dimensional vectors $x = \\{x_1, x_2, ..., x_n\\}$ and $y = \\{y_1, y_2, ..., y_n\\}$. The Minkowski's distance defined below is a metric which is a generalization of both the Manhattan distance and the Euclidean distance. \\[ D_{xy} = (\sum_{i=1}^n |x_i - y_i|^...
num = int(input()) x = list(map(int, input().split())) y = list(map(int, input().split())) first = second = third = inf = 0.00000 for i in range(num): dif = x[i] - y[i] first = first + abs(dif) second = second + dif ** 2 third = third + abs(dif) ** 3 inf = max(inf, abs(dif)) print(float(first)) prin...
s511735875
Accepted
20
5,644
446
num = int(input()) x = list(map(int, input().split())) y = list(map(int, input().split())) first = second = third = inf = 0.00000 for i in range(num): dif = x[i] - y[i] first = first + abs(dif) second = second + dif ** 2 third = third + abs(dif) ** 3 inf = max(inf, abs(dif)) print('{:.6f}'.format(fi...
s360370923
p03485
u058592821
2,000
262,144
Wrong Answer
17
2,940
61
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 = (int(i) for i in input().split()) print((a+b)//2 + 1)
s248305135
Accepted
17
2,940
104
a, b = (int(i) for i in input().split()) if (a+b) % 2 == 0: print((a+b)//2) else: print((a+b)//2+1)
s640976574
p03682
u010110540
2,000
262,144
Wrong Answer
1,775
71,624
916
There are N towns on a plane. The i-th town is located at the coordinates (x_i,y_i). There may be more than one town at the same coordinates. You can build a road between two towns at coordinates (a,b) and (c,d) for a cost of min(|a-c|,|b-d|) yen (the currency of Japan). It is not possible to build other types of road...
from operator import itemgetter from collections import deque N = int(input()) xs, ys = [], [] for _ in range(N): x, y = map(int, input().split()) xs.append(x) ys.append(y) xis = sorted(list(enumerate(xs)), key = itemgetter(1)) yis = sorted(list(enumerate(ys)), key = itemgetter(1)) xds, yds = [], []...
s700004986
Accepted
1,462
71,680
963
from operator import itemgetter from collections import deque N = int(input()) xs, ys = [], [] for _ in range(N): x, y = map(int, input().split()) xs.append(x) ys.append(y) xis = sorted(list(enumerate(xs)), key = itemgetter(1)) yis = sorted(list(enumerate(ys)), key = itemgetter(1)) xds, yds = [], []...
s453147054
p02390
u499005012
1,000
131,072
Wrong Answer
30
6,724
160
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
sec_input = int(input()) hour = sec_input // (60 * 60) remain = sec_input % (60 * 60) min = remain // 60 sec = remain % 60 print('%d %d %d' % (hour, min, sec))
s271598879
Accepted
30
6,724
160
sec_input = int(input()) hour = sec_input // (60 * 60) remain = sec_input % (60 * 60) min = remain // 60 sec = remain % 60 print('%d:%d:%d' % (hour, min, sec))
s062931461
p03369
u268977772
2,000
262,144
Wrong Answer
18
3,064
25
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 ...
print(input().count("o"))
s102310484
Accepted
17
2,940
33
print(700+100*input().count("o"))
s039997399
p03607
u957084285
2,000
262,144
Wrong Answer
2,104
6,244
518
You are playing the following game with Joisino. * Initially, you have a blank sheet of paper. * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. * Then, you are asked a question: How many...
N = int(input()) l = [] for _ in range(N): a = int(input()) if len(l) == 0: l.append(a) continue lo = 0 hi = len(l) mid = (lo+hi) // 2 removed = False p = (1, 0) while not p == (lo, hi): p = (lo, hi) mid = (lo+hi) // 2 if l[mid] == a: ...
s502706855
Accepted
252
15,072
198
N = int(input()) dict = {} for _ in range(N): x = int(input()) if x in dict.keys(): dict[x] += 1 else: dict[x] = 1 print(sum(list(map(lambda x : x%2, dict.values()))))
s076845672
p03494
u877428733
2,000
262,144
Wrong Answer
19
2,940
135
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())) for i in A: p = 0 while i % 2 == 0: i //= 2 p += 1 print(p)
s612139143
Accepted
18
3,060
181
ans = 10**9 N = int(input()) A = list(map(int,input().split())) for i in A: p = 0 while i % 2 == 0: i //= 2 p += 1 if p < ans: ans = p print(ans)
s820901937
p02406
u744506422
1,000
131,072
Wrong Answer
20
5,600
301
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 ...
import sys n=int(input()) a=[] for i in range(1,n+1): if (i%3==0): a.append(i) else: j=str(i) for k in range(len(j)-1): if j[k]=="3": a.append(i) break for i in a: sys.stdout.write(" {0}".format(i)) sys.stdout.write("\n")
s563559353
Accepted
30
5,952
299
import sys n=int(input()) a=[] for i in range(1,n+1): if (i%3==0): a.append(i) else: j=str(i) for k in range(len(j)): if j[k]=="3": a.append(i) break for i in a: sys.stdout.write(" {0}".format(i)) sys.stdout.write("\n")
s313708272
p02612
u583276018
2,000
1,048,576
Wrong Answer
32
9,140
93
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()) a = 0 while(a < n): a += 1000 print(a)
s106221689
Accepted
26
9,148
94
n = int(input()) a = 0 while(a < n): a += 1000 print(a-n)
s387310568
p02536
u168416324
2,000
1,048,576
Wrong Answer
438
26,544
486
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: * Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he...
n,m=map(int,input().split()) global fri fri=[] global tab tab=[0]*n def run(nn): #print(tab) global cnt if tab[nn]: return tab[nn]=1 cnt+=1 for i in fri[nn]: que.append(i) for i in range(n): fri.append([]) for i in range(m): a,b=map(int,input().split()) fri[a-1].append(b-1) fri[b-1].append(...
s806304431
Accepted
413
26,548
488
n,m=map(int,input().split()) global fri fri=[] global tab tab=[0]*n def run(nn): #print(tab) global cnt if tab[nn]: return tab[nn]=1 cnt+=1 for i in fri[nn]: que.append(i) for i in range(n): fri.append([]) for i in range(m): a,b=map(int,input().split()) fri[a-1].append(b-1) fri[b-1].append(...
s728214782
p02612
u321492259
2,000
1,048,576
Wrong Answer
28
9,048
40
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
i = int(input()) a = i-(i%1000) print(a)
s816376708
Accepted
26
9,000
38
print((1000-(int(input())%1000))%1000)
s052000604
p02273
u022407960
2,000
131,072
Wrong Answer
20
7,984
1,216
Write a program which reads an integer _n_ and draws a Koch curve based on recursive calles of depth _n_. The Koch curve is well known as a kind of You should start (0, 0), (100, 0) as the first segment.
# encoding: utf-8 import sys import math _input = sys.stdin.readlines() depth = int(_input[0]) sin_60, cos_60 = math.sin(math.pi / 3), math.cos(math.pi / 3) class Point(object): def __init__(self, x=0.0, y=0.0): """ initialize the point """ self.x = float(x) self.y = flo...
s545016471
Accepted
30
8,044
1,677
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 2 output: 0.00000000 0.00000000 11.11111111 0.00000000 16.66666667 9.62250449 22.22222222 0.00000000 33.33333333 0.00000000 38.88888889 9.62250449 33.33333333 19.24500897 44.44444444 19.24500897 50.00000000 28.86751346 55.55555556 19.24500897 66.66666667 19.245...
s677521189
p02843
u767664985
2,000
1,048,576
Wrong Answer
17
2,940
85
AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi want...
X = int(input()) X %= 105 X %= 104 X %= 103 X %= 102 X %= 101 X %= 100 print(X == 0)
s538338553
Accepted
17
2,940
209
X = int(input()) q, r = X//100, X%100 if r <= 5 * q: print(1) else: print(0)
s665456548
p02841
u912134329
2,000
1,048,576
Wrong Answer
18
2,940
148
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.
xy = [map(int,input().split()) for i in range(2)] x,y = [list(j) for j in zip(*xy)] if (x[1] + 1) == y[1] : ans = 0 else: ans = 1 print(ans)
s324996926
Accepted
17
2,940
148
xy = [map(int,input().split()) for i in range(2)] x,y = [list(j) for j in zip(*xy)] if (y[0] + 1) == y[1] : ans = 0 else: ans = 1 print(ans)
s381772622
p04045
u648452607
2,000
262,144
Wrong Answer
18
2,940
183
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very ...
[n,k]=[int(_) for _ in input().split()] d=[int(_) for _ in input().split()] while True: t=str(n).split() for _t in t: if _t in d: n+=1 continue break print(n)
s655351272
Accepted
69
3,188
246
[n,k]=[int(_) for _ in input().split()] d=[int(_) for _ in input().split()] dt=list({_ for _ in range(10)}-set(d)) def c(n,l): for _c in str(n): if int(_c) not in l: return False return True while True: if c(n,dt): break n+=1 print(n)
s882911837
p02865
u061539997
2,000
1,048,576
Wrong Answer
17
2,940
24
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
print(int(input())-1//2)
s190104738
Accepted
17
2,940
26
print((int(input())-1)//2)
s470153980
p03485
u202877219
2,000
262,144
Wrong Answer
17
2,940
47
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))
s677467082
Accepted
20
3,060
70
import math a,b = map(int, input().split()) print (math.ceil((a+b)/2))
s026888211
p02612
u024609780
2,000
1,048,576
Wrong Answer
27
9,140
29
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.
A =int(input()) print(1000-A)
s134204846
Accepted
34
9,152
73
a=int(input()) if(a%1000!=0): print(1000-(a%1000)) else: print(0)
s651316596
p02975
u648212584
2,000
1,048,576
Wrong Answer
149
18,584
605
Snuke has N hats. The i-th hat has an integer a_i written on it. There are N camels standing in a circle. Snuke will put one of his hats on each of these camels. If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `Yes`; otherwise, print `No...
import collections N = int(input()) a = list(map(int,input().split())) a = collections.Counter(a) a_list = list(a.items()) a_list = sorted(a_list,key = lambda a_list:a_list[0]) print(a_list) if len(a_list) == 1: if a_list[0][0] == 0: print("Yes") else: print("No") elif len(a_list) == 2: if ((a_list[0][0] == 0)...
s630406752
Accepted
106
16,164
648
import collections N = int(input()) a = list(map(int,input().split())) a = collections.Counter(a) a_list = list(a.items()) a_list = sorted(a_list,key = lambda a_list:a_list[0]) if len(a_list) == 1: if a_list[0][0] == 0: print("Yes") else: print("No") elif len(a_list) == 2: if ((a_list[0][0] == 0) and (a_list[0...
s880346686
p03379
u951480280
2,000
262,144
Wrong Answer
290
25,220
132
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, .....
n=int(input()) m=n//2 x=sorted(map(int,input().split())) for i in range(m): print(x[m-1]) for i in range(m,n): print(x[m])
s133309184
Accepted
343
25,472
260
n=int(input()) x=list(map(int,input().split())) x1=sorted(x) mid=n//2 if n>2: for i in range(n): if x[i] < x1[mid]:print(x1[mid]) else:print(x1[mid-1]) else: for i in range(n): x2=x.copy() x2.pop(i) print(x2[0])
s442997465
p03719
u599547273
2,000
262,144
Wrong Answer
17
2,940
87
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 = input().split(" ") print("Yes" if a[-1] == b[0] and b[-1] == c[0] else "No")
s377329033
Accepted
17
2,940
77
a, b, c = map(int, input().split(" ")) print("Yes" if a <= c <= b else "No")
s015158651
p02261
u922112509
1,000
131,072
Wrong Answer
20
5,608
1,256
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubbl...
# Stable Sort length = int(input()) cards = input().rstrip().split() cards1 = [card for card in cards] cards2 = [card for card in cards] def value(n): number = n[1:] return int(number) def char(cards): charSets = [[] for i in range(10)] for i in range(length): char = cards[i][:1] val ...
s230943537
Accepted
20
5,612
1,276
# Stable Sort length = int(input()) cards = input().rstrip().split() cards1 = [card for card in cards] cards2 = [card for card in cards] def value(n): number = n[1:] return int(number) def char(cards): charSets = [[] for i in range(10)] for i in range(length): char = cards[i][:1] val ...
s749413787
p03719
u280512618
2,000
262,144
Wrong Answer
17
2,940
70
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
a,b,c=map(int,input().split()) print('Yes' if a<=b and b<=c else 'No')
s496988763
Accepted
17
2,940
70
a,b,c=map(int,input().split()) print('Yes' if a<=c and c<=b else 'No')
s907738523
p03698
u578501242
2,000
262,144
Wrong Answer
17
3,064
141
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
a=input() b=[str(c) for c in a] b.sort() c=len(b) d=0 for i in range(c-1): if b[i]==b[i+1]: d=d+1 if d>0: print('No') else: print('Yes')
s566512555
Accepted
17
3,060
141
a=input() b=[str(c) for c in a] b.sort() c=len(b) d=0 for i in range(c-1): if b[i]==b[i+1]: d=d+1 if d>0: print('no') else: print('yes')
s483321246
p02613
u699458609
2,000
1,048,576
Wrong Answer
146
9,220
317
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`,...
ans = {"AC": 0, "WA": 0, "TLE": 0, "RE":0} N = int(input()) for i in range(N): inpt = input() if(inpt == "AC"): ans["AC"] += 1 elif(inpt == "WA"): ans["WA"] += 1 elif(inpt == "TLE"): ans["TLE"] += 1 else: ans["RE"] += 1 for key, value in ans.items(): print("{0} × {1}".format(key, value))
s504609997
Accepted
147
9,196
317
ans = {"AC": 0, "WA": 0, "TLE": 0, "RE":0} N = int(input()) for i in range(N): inpt = input() if(inpt == "AC"): ans["AC"] += 1 elif(inpt == "WA"): ans["WA"] += 1 elif(inpt == "TLE"): ans["TLE"] += 1 else: ans["RE"] += 1 for key, value in ans.items(): print("{0} x {1}".format(key, value))
s189088229
p04029
u522266410
2,000
262,144
Wrong Answer
17
2,940
41
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()) x = (N*(N+1)/2) print(x)
s247537123
Accepted
17
2,940
42
N = int(input()) print(round(N*(N+1)/2))
s802654231
p03352
u639592190
2,000
1,048,576
Wrong Answer
19
2,940
120
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
X=int(input()) ans=0 for b in range(1,int(X**(1/2))+1): for p in range(2,int(X/b)+1): ans=max(ans,b**p) print(ans)
s056851537
Accepted
19
2,940
138
X=int(input()) ans=1 for b in range(1,int(X**(1/2))+1): for p in range(2,int(X/b)+1): if b**p<=X: ans=max(ans,b**p) print(ans)
s353504961
p03351
u245641078
2,000
1,048,576
Wrong Answer
17
2,940
105
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-b))>=d and (abs(b-c))>=d: print("Yes") else: print("No")
s057263221
Accepted
17
2,940
107
a,b,c,d = map(int,input().split()) print("Yes" if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d) else 'No')
s457192567
p03379
u198274496
2,000
262,144
Wrong Answer
219
25,620
135
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, .....
N = int(input()) X = list(map(int, input().split())) d = N // 2 a = X[d] b = X[d - 1] for i in range(N): print(a if i < d else b)
s939585290
Accepted
303
25,556
146
N = int(input()) X = list(map(int, input().split())) sX = sorted(X) d = N // 2 a = sX[d] b = sX[d - 1] for c in X: print(a if c < a else b)
s581085867
p03605
u941884460
2,000
262,144
Wrong Answer
17
2,940
73
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[0] != 9 and N[1] !=9: print('No') else: print('Yes')
s406750189
Accepted
17
2,940
83
N = input() if (N[0] != '9') and (N[1] != '9'): print('No') else: print('Yes')
s207367334
p03943
u310394471
2,000
262,144
Wrong Answer
17
2,940
111
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('Yec') else: print('No')
s788674686
Accepted
17
2,940
111
A,B,C = map(int, input().split()) if A+B == C or A+C ==B or B+C == A: print('Yes') else: print('No')
s283013996
p03555
u344959959
2,000
262,144
Wrong Answer
29
8,960
109
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
a=input() b=input() if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]: print("Yes") else: print("No")
s009893011
Accepted
26
8,912
109
a=input() b=input() if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]: print("YES") else: print("NO")
s054543085
p03638
u648315264
2,000
262,144
Wrong Answer
38
9,508
977
We have a grid with H rows and W columns of squares. Snuke is painting these squares in colors 1, 2, ..., N. Here, the following conditions should be satisfied: * For each i (1 ≤ i ≤ N), there are exactly a_i squares painted in Color i. Here, a_1 + a_2 + ... + a_N = H W. * For each i (1 ≤ i ≤ N), the squares paint...
import math from math import gcd,pi,sqrt INF = float("inf") import sys sys.setrecursionlimit(10**6) import itertools from collections import Counter,deque def i_input(): return int(input()) def i_map(): return map(int, input().split()) def i_list(): return list(i_map()) def i_row(N): return [i_input() for _ in range(N...
s125573206
Accepted
37
10,100
1,016
import math from math import gcd,pi,sqrt INF = float("inf") import sys sys.setrecursionlimit(10**6) import itertools from collections import Counter,deque def i_input(): return int(input()) def i_map(): return map(int, input().split()) def i_list(): return list(i_map()) def i_row(N): return [i_input() for _ in range(N...
s542722020
p03545
u532031128
2,000
262,144
Wrong Answer
17
3,064
381
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given in...
s = input() A, B, C, D = int(s[0]), int(s[1]), int(s[2]), int(s[3]) print(A,B,C,D) N = 3 for i in range(2**N): sum = int(s[0]) f = s[0] for j in range(N): if i>>j & 1: sum += int(s[j+1]) f += "+" + s[j+1] else: sum -= int(s[j+1]) f += "-" + s...
s600470236
Accepted
18
3,064
366
s = input() A, B, C, D = int(s[0]), int(s[1]), int(s[2]), int(s[3]) N = 3 for i in range(2**N): sum = int(s[0]) f = s[0] for j in range(N): if i>>j & 1: sum += int(s[j+1]) f += "+" + s[j+1] else: sum -= int(s[j+1]) f += "-" + s[j+1] if s...
s406518721
p03110
u547608423
2,000
1,048,576
Wrong Answer
18
2,940
180
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000`...
N=int(input()) answer=0 for i in range(N): x,u=input().split() print(x,u) if u=="JPY": answer+=int(x) else: answer+=float(x)*380000 print(answer)
s347225772
Accepted
17
2,940
181
N=int(input()) answer=0 for i in range(N): x,u=input().split() #print(x,u) if u=="JPY": answer+=int(x) else: answer+=float(x)*380000 print(answer)
s267494997
p03162
u816631826
2,000
1,048,576
Wrong Answer
370
3,060
128
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain...
a=int(input()) hahaha=0 for i in range(a): r=str(input()).split() m=[int(u) for u in r] hahaha+=max(m) print(hahaha)
s943774572
Accepted
570
24,308
372
if __name__ == '__main__': n = int(input()) res = [[0 for i in range(0, 3)] for i in range(0, n+1)] for i in range(1,n+1): x, y, z = map(int,input().split()) res[i][0] = max(res[i-1][1], res[i-1][2]) res[i][1] = max(res[i-1][0], res[i-1][2]) res[i][2] = max(res[i-1][0], res[i-1][1]) res[i][0]+=x res[i...
s921831180
p03478
u865741247
2,000
262,144
Wrong Answer
35
3,188
196
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).
a,b,c=input().split(" ") nums=[] ans=0 b=int(b) c=int(c) a=int(a) for i in range(a): nums.append(sum(list(map(int,str(i))))) for j,n in enumerate(nums): if b<=n and n<=c: ans+=j print(ans)
s354171412
Accepted
35
3,188
198
a,b,c=input().split(" ") nums=[] ans=0 b=int(b) c=int(c) a=int(a) for i in range(a+1): nums.append(sum(list(map(int,str(i))))) for j,n in enumerate(nums): if b<=n and n<=c: ans+=j print(ans)
s746065987
p02409
u179070318
1,000
131,072
Wrong Answer
20
5,604
418
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth fl...
n = int(input()) info = [] for _ in range(n): temp = [int(x) for x in input().split( )] info.append(temp) state = [[[0 for i in range(10)] for j in range(3)] for k in range(4)] for a in info: state[a[0]-1][a[1]-1][a[2]-1] += a[3] for b in range(4): for f in range(3): string = '' for k in...
s285361301
Accepted
20
5,608
439
n = int(input()) info = [] for _ in range(n): temp = [int(x) for x in input().split( )] info.append(temp) state = [[[0 for i in range(10)] for j in range(3)] for k in range(4)] for a in info: state[a[0]-1][a[1]-1][a[2]-1] += a[3] for b in range(4): for f in range(3): string = '' for k in...
s404858149
p04025
u733337827
2,000
262,144
Wrong Answer
17
3,064
321
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (...
sn = input() xyx = xx = -1 for i in range(1, len(sn)): if (xx == -1) and (sn[i-1] == sn[i]): xx = i-1 if xyx == -1 else i if (xyx == -1) and (i > 2) and (sn[i-2] == sn[i]): xyx = i-2 if xx == -1 else i if (xx == -1) or (xyx == -1): print(-1, -1) else: print(min(xx, xyx)+1, max(xx, xyx)+1...
s307444356
Accepted
18
2,940
172
N = int(input()) an = list(map(int, input().split())) ave = sum(an)/N rep = int(ave + 0.5) if ave > 0 else int(ave - 0.5) ans = sum([(a - rep) ** 2 for a in an]) print(ans)
s181801980
p03943
u366644013
2,000
262,144
Wrong Answer
17
2,940
127
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...
na = lambda: list(map(int, input().split())) a, b, c = na() if a + b == c or b + c == a: print("Yes") else: print("No")
s181489652
Accepted
17
2,940
141
na = lambda: list(map(int, input().split())) a, b, c = na() if a + b == c or b + c == a or c + a == b: print("Yes") else: print("No")
s474250156
p03854
u131464432
2,000
262,144
Wrong Answer
40
9,584
316
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() A = "".join(list(reversed(S))) print(A) i = 0 while i != len(S): if A[i:i+5] == "maerd": i += 5 elif A[i:i+5] == "esare": i += 5 elif A[i:i+7] == "remaerd": i += 7 elif A[i:i+6] == "resare": i += 6 else: print("NO") exit() print("YES")
s127081809
Accepted
41
9,740
307
S = input() A = "".join(list(reversed(S))) i = 0 while i != len(S): if A[i:i+5] == "maerd": i += 5 elif A[i:i+5] == "esare": i += 5 elif A[i:i+7] == "remaerd": i += 7 elif A[i:i+6] == "resare": i += 6 else: print("NO") exit() print("YES")
s038042169
p03502
u655975843
2,000
262,144
Wrong Answer
17
2,940
129
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 = input() N = list(n) n = int(n) ans = 0 for i in N: ans += int(i) if ans % n == 0: print('Yes') else: print('No')
s172231747
Accepted
18
2,940
129
n = input() N = list(n) n = int(n) ans = 0 for i in N: ans += int(i) if n % ans == 0: print('Yes') else: print('No')
s447094102
p03477
u475675023
2,000
262,144
Wrong Answer
18
2,940
93
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=map(int,input().split()) print(["Left" if a+b>c+d else "Right","Balanced"][a+b!=c+d])
s736467779
Accepted
17
2,940
94
a,b,c,d=map(int,input().split()) print(["Left" if a+b>c+d else "Right","Balanced"][a+b==c+d])
s714748220
p03525
u780962115
2,000
262,144
Wrong Answer
21
3,064
1,436
In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the _time gap_ (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if...
#time gap n=int(input()) lists=list(map(int,input().split())) if n>24: print(0) else: timelist=[0 for i in range(13)] for i in lists: timelist[i]+=1 flag=True for j in range(13): if j==0 or j==12: if timelist[j]>1: flag=False else: ...
s256482777
Accepted
23
3,188
1,546
#time gap n=int(input()) lists=list(map(int,input().split())) if n>24: print(0) else: timelist=[0 for i in range(13)] for i in lists: timelist[i]+=1 flag=True for j in range(13): if j==0: if timelist[j]>0: flag=False else: if timel...
s217271451
p03474
u366959492
2,000
262,144
Wrong Answer
18
2,940
168
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
a,b=map(int,input().split()) s=input() f=0 for i in s: if i=="-": f+=1 if len(s)==(a+b+1) and s[a+1]=="-" and f==1: print("Yes") else: print("No")
s271919856
Accepted
18
2,940
165
a,b=map(int,input().split()) s=input() f=0 for i in s: if i=="-": f+=1 if len(s)==(a+b+1) and s[a]=="-" and f==1: print("Yes") else: print("No")
s053741713
p03486
u665038048
2,000
262,144
Wrong Answer
17
3,060
151
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 = list(input().split()) t = list(input().split()) s.sort() t.reverse() s = ''.join(s) t = ''.join(t) if s < t: print('Yes') else: print('No')
s316019867
Accepted
17
2,940
114
s = list(input()) t = list(input()) s.sort() t.sort(reverse=True) if s < t: print('Yes') else: print('No')
s825939856
p02842
u999503965
2,000
1,048,576
Wrong Answer
30
9,112
77
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer)....
n=int(input()) num=n//1.08 if num*1.08==n: print(num) else: print(":(")
s289644465
Accepted
31
9,032
113
import math n=int(input()) num=math.ceil(n/1.08) if math.floor(num*1.08)==n: print(num) else: print(":(")
s385204468
p02972
u281610856
2,000
1,048,576
Wrong Answer
370
23,560
1,005
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...
from heapq import heappush, heappop, heapify from itertools import permutations, accumulate, combinations from math import pi, ceil, floor import numpy as np from collections import defaultdict, deque from operator import itemgetter from bisect import bisect_left, bisect_right, insort_left, insort_right import sys inpu...
s584141168
Accepted
358
23,136
926
from heapq import heappush, heappop, heapify from itertools import permutations, accumulate, combinations from math import pi, ceil, floor import numpy as np from collections import defaultdict, deque from operator import itemgetter from bisect import bisect_left, bisect_right, insort_left, insort_right import sys inpu...
s607750759
p03024
u481605952
2,000
1,048,576
Wrong Answer
18
2,940
83
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 = input() if s.count('x') >= 8: print('No') else: print('Yes')
s441963827
Accepted
18
2,940
74
s = input() if s.count('x') >= 8: print('NO') else: print('YES')
s311883184
p03719
u045953894
2,000
262,144
Wrong Answer
17
2,940
87
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
a,b,c=map(int,input().split()) if c >= a and c <= b: print('YES') else: print('NO')
s641444839
Accepted
17
2,940
77
a,b,c=map(int,input().split()) if a<=c<=b: print('Yes') else: print('No')
s502053571
p02865
u546686251
2,000
1,048,576
Wrong Answer
2,104
2,940
136
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
N = int(input()) count = 0 for i in range(N): for j in range(N): if i + j == N: count = count + 1 print(count/2)
s506778327
Accepted
355
2,940
118
N = int(input()) count = 0 for i in range(1, N): if i != N - i and i < N/2: count = count + 1 print(count)
s659009643
p04029
u389910364
2,000
262,144
Wrong Answer
157
13,556
302
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?
from collections import Counter, deque from fractions import gcd from functools import lru_cache from functools import reduce import functools import heapq import itertools import math import numpy as np import sys sys.setrecursionlimit(10000) INF = float('inf') print(math.factorial(int(input())))
s454514060
Accepted
19
3,060
34
print(sum(range(int(input())+1)))
s096893028
p02393
u587193722
1,000
131,072
Wrong Answer
20
7,564
54
Write a program which reads three integers, and prints them in ascending order.
x = sorted([int(i) for i in input().split()]) print(x)
s264409777
Accepted
30
7,696
89
x = sorted([int(i) for i in input().split()]) print("{0} {1} {2}".format(x[0],x[1],x[2]))
s129427906
p03351
u056599756
2,000
1,048,576
Wrong Answer
17
2,940
100
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()) print("Yes" if abs(a-c)<d or abs(a-b)<d and abs(b-c)<d else "No")
s168471257
Accepted
17
2,940
103
a,b,c,d=map(int, input().split()) print("Yes" if abs(a-c)<=d or abs(a-b)<=d and abs(b-c)<=d else "No")
s103740238
p03377
u304561065
2,000
262,144
Wrong Answer
19
3,060
126
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: if A+B<X: print('No') else: print('Yes') else: print('No')
s962528506
Accepted
17
2,940
127
A,B,X=map(int,input().split()) if A+B>=X: if A<=X: print('YES') else: print('NO') else: print('NO')
s809604206
p02393
u120602885
1,000
131,072
Wrong Answer
20
7,588
127
Write a program which reads three integers, and prints them in ascending order.
tmp = input() tmp = tmp.split(" ") tmp = list(map(int,tmp)) tmp.sort() print(tmp) tmp = list(map(str,tmp)) print(" ".join(tmp))
s855765528
Accepted
30
7,644
116
tmp = input() tmp = tmp.split(" ") tmp = list(map(int,tmp)) tmp.sort() tmp = list(map(str,tmp)) print(" ".join(tmp))
s052982277
p03555
u923270446
2,000
262,144
Wrong Answer
17
2,940
93
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
c1 = list(input()) c2 = list(input()) if c1.reverse == c2: print("YES") else: print("NO")
s716355564
Accepted
17
2,940
45
print("YES"if input()==input()[::-1]else"NO")
s152736568
p03494
u099026234
2,000
262,144
Wrong Answer
26
9,028
277
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.
a = int(input()) b = [int(i) for i in input().split(" ")] count = 0 iti = 1 while iti == 1: for i in range(a): if b[i]%2 == 0: b[i]=b[i]//2 iti = 1 else : print(count) iti = 0 break count = count+1
s646371860
Accepted
30
9,128
281
a = int(input()) b = [int(i) for i in input().split(" ")] count = 0 iti = 1 while iti == 1: for i in range(a): if b[i]%2 == 0: b[i]=b[i]//2 iti = 1 else : print(count) iti = 0 break count = count+1
s248677300
p02841
u698849142
2,000
1,048,576
Wrong Answer
17
2,940
98
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.
m1, d1 = map(int, input().split()) m2, d2 = map(int, input().split()) print(m1 == m2 if 1 else 0)
s022564343
Accepted
17
2,940
98
m1, d1 = map(int, input().split()) m2, d2 = map(int, input().split()) print(0 if m1 == m2 else 1)
s401339636
p03251
u715355213
2,000
1,048,576
Wrong Answer
17
3,064
482
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes incli...
N,M,X,Y = map(int,input().split()) x = list(map(int,input().split())) y = list(map(int,input().split())) flag = 0 Z_max = min(y) Z_min = max(x) print(Z_min,Z_max) Z = X + 1 while Z < Y: if Z_min < Z and Z <= Z_max: break Z += 1 print(Z) for i in range(N): if x[i] >= Z: flag = 1 b...
s966338925
Accepted
17
3,064
454
N,M,X,Y = map(int,input().split()) x = list(map(int,input().split())) y = list(map(int,input().split())) flag = 0 Z_max = min(y) Z_min = max(x) Z = X + 1 while Z < Y: if Z_min < Z and Z <= Z_max: break Z += 1 for i in range(N): if x[i] >= Z: flag = 1 break if flag == 0: for ...
s028125401
p03433
u332420380
2,000
262,144
Wrong Answer
17
2,940
89
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')
s459982635
Accepted
17
2,940
89
n = int(input()) a = int(input()) if n % 500 <= a: print('Yes') else: print('No')
s047178909
p04044
u666964944
2,000
262,144
Wrong Answer
26
9,160
80
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 = [input() for _ in range(n)] print(sorted(s))
s399562488
Accepted
26
9,104
89
n,l = map(int, input().split()) s = [input() for _ in range(n)] print(''.join(sorted(s)))
s354554761
p03351
u672220554
2,000
1,048,576
Wrong Answer
17
2,940
158
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(c-a)<=d: print("Yes") else: if abs(b-a)<=d and abs(c-a)<=d: print("Yes") else: print("No")
s978167593
Accepted
17
2,940
158
a,b,c,d=map(int,input().split()) if abs(c-a)<=d: print("Yes") else: if abs(b-a)<=d and abs(c-b)<=d: print("Yes") else: print("No")
s164186792
p03485
u150641538
2,000
262,144
Wrong Answer
20
2,940
52
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(int((a+b)/2)+1)
s486278643
Accepted
17
2,940
63
a,b = map(int,input().split()) print(int((a+b+((a+b)%2==1))/2))
s577521235
p03658
u257541375
2,000
262,144
Wrong Answer
17
2,940
146
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 = [int(i) for i in input().split()] array = [int(i) for i in input().split()] array.sort() sum = 0 for i in range(k): sum += array[-(i+1)]
s174315140
Accepted
18
2,940
158
n,k = [int(i) for i in input().split()] array = [int(i) for i in input().split()] array.sort() sum = 0 for i in range(k): sum += array[-(i+1)] print(sum)
s488375820
p03385
u273201018
2,000
262,144
Wrong Answer
17
2,940
67
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
S = input() if S == 'abc': print('Yes') else: print('No')
s601841069
Accepted
17
2,940
107
S = input() if 'a' in S and 'b' in S and 'c' in S and len(S) == 3: print('Yes') else: print('No')
s327176041
p02612
u189188797
2,000
1,048,576
Wrong Answer
26
8,976
55
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(abs(n))
s573429178
Accepted
27
9,084
51
n=int(input()) while n>0: n-=1000 print(abs(n))
s839306424
p03478
u770987902
2,000
262,144
Wrong Answer
25
2,940
241
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 = [int(x) for x in input().split()] total = 0 def func(num): r = 0 while num > 0: r = num % 10 num = num // 10 return r for i in range(1, n+1): num = func(i) if num >= a and num <= b: total += num print(total)
s418528776
Accepted
25
2,940
237
n,a,b = [int(x) for x in input().split()] def func(num): r = 0 while num > 0: r += num % 10 num = num // 10 return r total = 0 for i in range(1, n+1): num = func(i) if num >= a and num <= b: total += i print(total)
s135483600
p03494
u428397309
2,000
262,144
Time Limit Exceeded
2,104
2,940
209
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.
# -*- coding: utf-8 -*- N = int(input()) A = list(map(int, input().split())) ans = 0 while 1: new_a = [a // 2 if a % 2 == 0 else -1 for a in A] if -1 in new_a: break ans += 1 print(ans)
s109207327
Accepted
18
2,940
250
# -*- coding: utf-8 -*- N = int(input()) A = list(map(int, input().split())) ans = 0 new_a = A.copy() while 1: new_a = [a // 2 if a % 2 == 0 else -1 for a in new_a] if -1 in new_a: print(ans) exit() ans += 1 print(ans)
s282461841
p04011
u586577600
2,000
262,144
Wrong Answer
17
2,940
101
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, x, y = [int(input()) for i in range(4)] if n <= k: print(x*n) else: print(x*n + max(0, n-k)*y)
s566433652
Accepted
17
2,940
101
n, k, x, y = [int(input()) for i in range(4)] if n <= k: print(x*n) else: print(x*k + max(0, n-k)*y)
s855946267
p03827
u290187182
2,000
262,144
Wrong Answer
17
2,940
197
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...
if __name__ == '__main__': a = int(input()) s = input() count =0 for i in s: if i == "I": count +=1 else: count -=1 print(count)
s498896492
Accepted
17
2,940
248
if __name__ == '__main__': a = int(input()) s = input() count =0 max = 0 for i in s: if i == "I": count +=1 else: count -=1 if max < count: max = count print(max)
s142845827
p03434
u738622346
2,000
262,144
Wrong Answer
17
3,060
385
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the c...
def draw_max_card(card_list): max_card = max(card_list) card_list.remove(max_card) return max_card n = int(input()) card_list = list(map(int, input().split(" "))) points_alice = 0 points_bob = 0 for count in range(1, n + 1): print(count) if count % 2 != 0: points_alice += draw_max_card(car...
s959671425
Accepted
20
3,188
402
def draw_max_card(card_list): max_card = max(card_list) card_list.remove(max_card) return max_card n = int(input()) card_list = list(map(int, input().split(" "))) points_alice = 0 points_bob = 0 for count in range(1, n + 1): if count % 2 != 0: points_alice += draw_max_card(card_list) else:...
s847329877
p03944
u394244719
2,000
262,144
Wrong Answer
30
9,132
694
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 sys import math inint = lambda: int(sys.stdin.readline()) inintm = lambda: map(int, sys.stdin.readline().split()) inintl = lambda: list(inintm()) instrm = lambda: map(str, sys.stdin.readline().split()) instrl = lambda: list(instrm()) w, h, n = inintm() ll = [0,0] lh = [0,h] rl = [w,0] rh = [w,h] for i in r...
s770813613
Accepted
31
9,180
606
import sys import math inint = lambda: int(sys.stdin.readline()) inintm = lambda: map(int, sys.stdin.readline().split()) inintl = lambda: list(inintm()) instrm = lambda: map(str, sys.stdin.readline().split()) instrl = lambda: list(instrm()) w, h, n = inintm() ll = [0,0] rh = [w,h] for i in range(n): x, y, a =...
s757471046
p03435
u393253137
2,000
262,144
Wrong Answer
17
3,064
435
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) ...
c = [list(map(int, input().split())) for _ in range(3)] if c[0][1] - c[0][0] == c[1][1] - c[1][0] == c[2][1] - c[2][0]: if c[0][2] - c[0][1] == c[1][2] - c[1][1] == c[2][2] - c[2][1]: print('Yes') print('No')
s605037695
Accepted
18
2,940
202
a, b, c = map(int, input().split()) d, e, f = map(int, input().split()) g, h, i = map(int, input().split()) if a - b == d - e == g - h and b - c == e - f == h - i: print('Yes') else: print('No')
s954778587
p03853
u290187182
2,000
262,144
Wrong Answer
36
5,144
389
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...
import sys import copy import math import bisect import pprint import bisect from functools import reduce from copy import deepcopy from collections import deque from decimal import * def lcm(x, y): return (x * y) // math.gcd(x, y) if __name__ == '__main__': b, c = map(int, input().split()) for i in ra...
s874752808
Accepted
35
5,144
385
import sys import copy import math import bisect import pprint import bisect from functools import reduce from copy import deepcopy from collections import deque from decimal import * def lcm(x, y): return (x * y) // math.gcd(x, y) if __name__ == '__main__': b, c = map(int, input().split()) for i in ra...
s110317457
p03069
u286955577
2,000
1,048,576
Wrong Answer
41
3,884
364
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so t...
def solve(): N = int(input()) S = input() foundBlack = False black, b, white = 0, 0, 0 for stone in S: if stone == '#': if not foundBlack: foundBlack = True b = b + 1 else: if not foundBlack: continue white = white + 1 black = black + b b = 0 print(white, black)...
s802680111
Accepted
54
5,864
473
def solve(): N = int(input()) S = input() stones = [] look = S[0] cnt = 0 if S[0] == '.': stones.append(0) for s in S: if look == s: cnt += 1 else: stones.append(cnt) cnt = 1 look = s stones.append(cnt) if S[N - 1] == '#': stones.append(0) count = sum(stones[1::2]) ans ...
s123948812
p03139
u303633930
2,000
1,048,576
Wrong Answer
18
3,060
319
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answ...
import sys def r(n, a, b): both_max = min(a, b) if 0 < a + b - n: both_min = a + b - n else: both_min = 0 print(both_max, both_min) def main(): input = sys.stdin.readline n, a, b = list(map(int, input().split())) print(r(n, a, b)) if __name__ == '__main__': main()
s193743880
Accepted
17
3,060
312
import sys def r(n, a, b): both_max = min(a, b) if 0 < a + b - n: both_min = a + b - n else: both_min = 0 print(both_max, both_min) def main(): input = sys.stdin.readline n, a, b = list(map(int, input().split())) r(n, a, b) if __name__ == '__main__': main()
s427312275
p03998
u898967808
2,000
262,144
Wrong Answer
19
3,064
255
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. * ...
dic_s = {x:input() for x in 'abc'} dic_i = {x:i for x,i in zip('abc',[0,0,0])} dic_max = {x:len(dic_s[x]) for x in 'abc'} nt = 'a' while True: dic_i[nt] += 1 if dic_max[nt] == dic_i[nt]: break else: nt = dic_s[nt][dic_i[nt]] print(nt)
s820033458
Accepted
17
3,064
273
dic_s = {x:input() for x in 'abc'} dic_i = {x:i for x,i in zip('abc',[0,0,0])} dic_max = {x:len(dic_s[x]) for x in 'abc'} nt = 'a' while True: if dic_max[nt] == dic_i[nt]: break else: dic_i[nt] += 1 nt = dic_s[nt][dic_i[nt]-1] print(nt.upper())
s437857035
p02534
u922769680
2,000
1,048,576
Wrong Answer
26
9,144
33
You are given an integer K. Print the string obtained by repeating the string `ACL` K times and concatenating them. For example, if K = 3, print `ACLACLACL`.
n=int(input()) w="ALC" print(w*n)
s305986103
Accepted
21
9,148
33
n=int(input()) w="ACL" print(w*n)
s491950617
p03679
u032222383
2,000
262,144
Wrong Answer
17
2,940
119
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Ot...
x, a, b=map(int, input().split()) if a>=b: print("delicious") elif a+x<=b: print("safe") else: print("dangerous")
s992679404
Accepted
18
2,940
120
x, a, b=map(int, input().split()) if a>=b: print("delicious") elif a+x>=b: print("safe") else: print("dangerous")
s758388166
p03401
u089032001
2,000
262,144
Wrong Answer
138
14,048
322
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())) min1 = 0 min2 = 0 max1 = 0 max2 = 0 for a in A: if(a <= min1): min2 = min1 min1 = a elif(a >= max1): max2 = max1 max1 = a for a in A: if(a == min1): print(max1 - min2) elif(a == max1): print(max2 - min1) else: print(max1 - min...
s746566339
Accepted
220
14,048
291
N = int(input()) A = list(map(int, input().split())) A.append(0) all = 0 last = 0 diff = [] for i in range(N): all += abs(A[i] - last) diff.append(abs(A[i+1] - last) - abs(A[i+1] - A[i]) - abs(A[i] - last)) last = A[i] all += abs(A[N-1]) for i in range(N): print(all + diff[i])
s808637621
p03149
u731368968
2,000
1,048,576
Wrong Answer
17
2,940
116
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".
n = list(map(int, input().split())) n.sort() if n[0] + n[1] + n[2] + n[3] == 1479: print('YES') else:print('NO')
s584004112
Accepted
17
2,940
102
n = input().split() n.sort() if n[0] + n[1] + n[2] + n[3] == '1479': print('YES') else:print('NO')
s599837569
p03385
u663438907
2,000
262,144
Wrong Answer
18
3,064
224
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
A = list(input()) l = [0, 0, 0] for i in range(len(A)): if A[i] == 'A': l[0] = 1 elif A[i] == 'B': l[1] = 1 else: l[2] = 1 if l[0] == 1 and l[1] == 1 and l[2] == 1: print('Yes') else: print('No')
s648690714
Accepted
17
3,064
226
A = list(input()) l = [0, 0, 0] for i in range(len(A)): if A[i] == 'a': l[0] = 1 elif A[i] == 'b': l[1] = 1 else: l[2] = 1 if l[0] == 1 and l[1] == 1 and l[2] == 1: print('Yes') else: print('No')
s560320620
p03599
u201234972
3,000
262,144
Wrong Answer
75
3,064
490
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()) ans = 0 ansL = 0 ansM = 0 for i in range(30//a+1): for j in range((30-i)//b+1): L = a*i + b*j M = 0 for k in range(f): if 100*L + k*c <= f: m = min(((e*L-k*c)//d)*d, ((f-100*L-k*c)//d)*d) M = max(M, m+k...
s142685174
Accepted
70
3,064
622
a, b, c, d, e, f = map( int, input().split()) ans = 0 ansL = 0 ansM = 0 for i in range(30//a+1): for j in range((30-i)//b+1): L = a*i + b*j M = 0 for k in range(f): if 100*L + k*c <= f and k*c <= L*e: m = min(((e*L-k*c)//d)*d, ((f-100*L-k*c)//d)*d) ...
s779158159
p02266
u462831976
1,000
131,072
Wrong Answer
30
7,304
679
Your task is to simulate a flood damage. For a given cross-section diagram, reports areas of flooded sections. Assume that rain is falling endlessly in the region and the water overflowing from the region is falling in the sea at the both sides. For example, for the above cross-section diagram, the rain will c...
# -*- coding: utf-8 -*- import sys import os s = input().strip() S1 = [] # sum of pond S2 = [] # each pond area = 0 for i, c in enumerate(s): if c == '\\': S1.append(i) elif c == '_': pass elif c == '/' and S1: j = S1.pop(-1) area += i - j # for each pond ...
s844779441
Accepted
30
7,988
696
# -*- coding: utf-8 -*- import sys import os s = input().strip() S1 = [] # sum of pond S2 = [] # each pond area = 0 for i, c in enumerate(s): if c == '\\': S1.append(i) elif c == '_': pass elif c == '/' and S1: j = S1.pop(-1) area += i - j # for each pond ...
s173523953
p03469
u368796742
2,000
262,144
Wrong Answer
18
2,940
65
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...
a,b,c = map(int,input().split("/")) print("2018/01/{}".format(c))
s991825844
Accepted
17
2,940
69
a,b,c = map(int,input().split("/")) print("2018/01/{:02}".format(c))