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
s630740745
p02273
u358919705
2,000
131,072
Wrong Answer
20
7,636
679
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.
from math import sin, cos, pi def koch(px, py, qx, qy, n): if n == 0: return True sx = (2 * px + qx) / 3 sy = (2 * py + qy) / 3 tx = (px + 2 * qx) / 3 ty = (py + 2 * qy) / 3 ux = sx + (tx - sx) * cos(pi / 3) - (ty - sy) * sin(pi / 3) uy = sy + (tx - sx) * sin(pi / 3) - (ty - sy) * co...
s096063314
Accepted
40
7,976
696
from math import sin, cos, pi def koch(px, py, qx, qy, n): if n == 0: return True sx = (2 * px + qx) / 3 sy = (2 * py + qy) / 3 tx = (px + 2 * qx) / 3 ty = (py + 2 * qy) / 3 ux = sx + (tx - sx) * cos(pi / 3) - (ty - sy) * sin(pi / 3) uy = sy + (tx - sx) * sin(pi / 3) + (ty - sy) * co...
s017219674
p04043
u552502395
2,000
262,144
Wrong Answer
17
2,940
123
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each ...
L = list(map(int, input().split())) L.sort() if L[0] == 5 and L[1]==5 and L[2]==7: print("Yes"); else: print("No");
s504223148
Accepted
18
2,940
124
L = list(map(int, input().split())) L.sort() if L[0] == 5 and L[1]==5 and L[2]==7: print("YES"); else: print("NO");
s543550692
p02408
u874395007
1,000
131,072
Wrong Answer
20
5,596
409
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): line = input().split() a = line[0] num = int(line[1]) cards.append((a, num)) tarinai_list = [] for a in ['S', 'H', 'C', 'D']: for num in range(1, 14): for card in cards: if a == card[0] and num == card[1]: break ...
s346468231
Accepted
20
5,616
468
suits = ['S', 'H', 'C', 'D'] table = [[False] * 14 for i in range(4)] N = int(input()) for _i in range(N): mark, num = input().split() num = int(num) if mark == 'S': table[0][num] = True if mark == 'H': table[1][num] = True if mark == 'C': table[2][num] = True if mark =...
s002544504
p02613
u223215060
2,000
1,048,576
Wrong Answer
164
9,212
323
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()) a = 0 b = 0 c = 0 d = 0 for i in range(n): s = str(input()) if s == 'AC' : a += 1 elif s == 'WA': b += 1 elif s == 'TLE': c += 1 else: d += 1 print('AC ร— {}'.format(a)) print('WA ร— {}'.format(b)) print('TLE ร— {}'.format(c)) print('RE ร— {}'.format(d))
s150371612
Accepted
159
9,220
319
n = int(input()) a = 0 b = 0 c = 0 d = 0 for i in range(n): s = str(input()) if s == 'AC' : a += 1 elif s == 'WA': b += 1 elif s == 'TLE': c += 1 else: d += 1 print('AC x {}'.format(a)) print('WA x {}'.format(b)) print('TLE x {}'.format(c)) print('RE x {}'.format(d))
s624914821
p02612
u688375653
2,000
1,048,576
Wrong Answer
35
9,164
216
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.
def input_int(): return map(int, input().split()) def one_int(): return int(input()) def one_str(): return input() def many_int(): return list(map(int, input().split())) a=one_int() print(a%1000)
s918721163
Accepted
30
9,168
257
def input_int(): return map(int, input().split()) def one_int(): return int(input()) def one_str(): return input() def many_int(): return list(map(int, input().split())) a=one_int() if a%1000>0: print(1000-a%1000) else: print(0)
s029074857
p04043
u054412614
2,000
262,144
Wrong Answer
17
2,940
100
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 ...
a,b,c=map(int,input().split()) if a+b+c==17: if a==7 or b==7 or c==7: print("YES") print("NO")
s716340605
Accepted
17
3,060
206
a,b,c=map(int,input().split()) if a+b+c==17: if a==5 and b==5: print("YES") elif a==5 and c==5: print("YES") elif b==5 and c==5: print("YES") else: print("NO") else: print("NO")
s295197457
p03214
u374171306
2,525
1,048,576
Wrong Answer
17
3,064
289
Niwango-kun is an employee of Dwango Co., Ltd. One day, he is asked to generate a thumbnail from a video a user submitted. To generate a thumbnail, he needs to select a frame of the video according to the following procedure: * Get an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the numbe...
N = int(input()) a = list(map(int,input().split())) sum = 0 for i in a: sum += i avg = sum/N result = 0 tmp = 0 for i in range(len(a)): ans = avg - a[i] ans = ans if ans < 0 else ans * -1 if i == 0: result = i tmp = ans elif tmp > ans: result = i print(result)
s036552831
Accepted
17
3,064
282
N = int(input()) a = list(map(int,input().split())) sum = sum(a) avg = sum/N result = 0 tmp = 0 for i in range(len(a)): ans = avg - a[i] ans = ans if ans > 0 else ans * -1 if i == 0: result = i tmp = ans elif tmp > ans: result = i tmp = ans print(result)
s941393182
p03386
u433380437
2,000
262,144
Wrong Answer
27
9,196
213
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()) A=[] for i in range(a,min(a+k+1,b+1)): A.append(i) for j in range(b,max(b-k,a),-1): A.append(j) A.sort(reverse=False) B=list(set(A)) for p in range(len(B)): print(B[p])
s813008554
Accepted
26
9,196
218
a,b,k = map(int,input().split()) A=[] B=[] for i in range(a,min(a+k,b+1)): A.append(i) for j in range(b,max(b-k,a-1),-1): A.append(j) B=list(set(A)) B.sort(reverse=False) for p in range(len(B)): print(B[p])
s028786285
p03673
u368796742
2,000
262,144
Wrong Answer
2,104
26,016
117
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.
n = int(input()) l = list(map(int,input().split())) ans = [] for i in l: ans.append(i) ans = ans[::-1] print(ans)
s893002989
Accepted
176
26,180
256
n = int(input()) l = list(map(int,input().split())) if n % 2 == 0: ans = [l[i] for i in range(n-1,-1,-2)] + [l[i] for i in range(0,n-1,2)] print(*ans) else: ans = [l[i] for i in range(n-1,-1,-2)] + [l[i] for i in range(1,n-1,2)] print(*ans)
s452476073
p03449
u224050758
2,000
262,144
Wrong Answer
17
3,064
720
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 ...
N = int(input()) HIGH = [int(x) for x in input().split()] LOW = [int(x) for x in input().split()] def get_sum(diff_list): max_abs_value = max(diff_list, key=abs) max_abs_index = diff_list.index(max_abs_value) corrects = [HIGH[i] if i <= max_abs_index else LOW[i] for i, _ in enumerate(diff_list)] print(...
s021480213
Accepted
17
3,064
439
N = int(input()) HIGH = [int(x) for x in input().split()] LOW = [int(x) for x in input().split()] def main(): first = HIGH.pop(0) last = LOW.pop() mid_len = len(HIGH) mid_sum = 0 for i in range(mid_len)[::-1]: # reversed mid_sum = max(mid_sum, sum(HIGH)) HIGH[i] = LOW[i] mid_su...
s084613857
p03679
u396391104
2,000
262,144
Wrong Answer
17
2,940
117
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 (b-a)<=x: print("safe") else: print("dangerous")
s528166273
Accepted
17
3,060
118
x,a,b=map(int,input().split()) if a>=b: print("delicious") elif (b-a)<=x: print("safe") else: print("dangerous")
s214125881
p02389
u681232780
1,000
131,072
Wrong Answer
20
5,580
74
Write a program which calculates the area and perimeter of a given rectangle.
a,b=map(int,input().split()) print('้ข็ฉ',a*b,'ๅ‘จใฎ้•ทใ•',2*a+2*b)
s984654957
Accepted
20
5,580
49
a,b=map(int,input().split()) print(a*b,2*a+2*b)
s229107576
p02614
u396472025
1,000
1,048,576
Wrong Answer
29
8,988
8
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation...
print(0)
s753061871
Accepted
65
9,064
426
H, W, K = map(int, input().split()) C = [list(input()) for _ in range(H)] ans = 0 for h_ptn in range(2 ** H): for w_ptn in range(2 ** W): cnt = 0 for h in range(H): for w in range(W): if (h_ptn >> h) & 1 == 0 and (w_ptn >> w) & 1 == 0: if C[h][w] == '#': cnt += 1 ...
s886539732
p02697
u069125420
2,000
1,048,576
Wrong Answer
74
9,216
79
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(0, M): print(i + 1, N - i)
s428959221
Accepted
74
9,188
330
N, M = map(int, input().split()) M_f = M * 2 + 1 if M % 2 != 0: for i in range(0, M // 2): print(i + 1, (M) - i) for i in range(0, M // 2 + 1): print(M + 1 + i, M_f - i) else: for i in range(0, M // 2): print(i + 1, (M + 1) - i) for i in range(0, M // 2): print(M + 2 + i...
s170492670
p03579
u830592648
2,000
262,144
Wrong Answer
2,105
107,600
495
Rng has a connected undirected graph with N vertices. Currently, there are M edges in the graph, and the i-th edge connects Vertices A_i and B_i. Rng will add new edges to the graph by repeating the following operation: * Operation: Choose u and v (u \neq v) such that Vertex v can be reached by traversing exactly t...
import sys sys.setrecursionlimit(10**6) n,m=map(int,input().split()) s=[[]for i in range(n+1)] c=[0]*(n+1) for i in range(m): a,b=map(int,input().split()) s[a].append(b) s[b].append(a) def dfs(v,t): c[v]=t print('start :'+str(c)) for i in s[v]: if c[i]==t: return False ...
s216070048
Accepted
541
31,156
491
import sys sys.setrecursionlimit(10**6) n,m=map(int,input().split()) s=[[]for i in range(n+1)] c=[0]*(n+1) for i in range(m): a,b=map(int,input().split()) s[a].append(b) s[b].append(a) def dfs(v,t): c[v]=t # print('start :'+str(c)) for i in s[v]: if c[i]==t: return False ...
s193988837
p02663
u921352252
2,000
1,048,576
Wrong Answer
22
9,404
300
In this problem, we use the 24-hour clock. Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying?
import time import datetime from datetime import timedelta H1,M1,H2,M2,K=map(int,input().split()) delta1=timedelta(minutes=M1,hours=H1) delta2=timedelta(minutes=M2,hours=H2) delta=delta2-delta1 delta_minutes=delta.total_seconds()/60 if delta_minutes>30: print(delta_minutes-30) else: print(0)
s340040007
Accepted
22
9,400
293
import datetime from datetime import timedelta H1,M1,H2,M2,K=map(int,input().split()) delta1=timedelta(minutes=M1,hours=H1) delta2=timedelta(minutes=M2,hours=H2) delta=delta2-delta1 delta_minutes=delta.total_seconds()/60 if delta_minutes>=K: print(round(delta_minutes-K)) else: print(0)
s365171171
p03472
u648212584
2,000
262,144
Wrong Answer
542
32,880
341
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, โ€ฆ, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 โ‰ค i โ‰ค N), the monster receives a_i points of d...
N,M = map(int,input().split()) X = [list(map(int,input().split())) for _ in range(N)] X = sorted(X,key=lambda X:-X[0]) a = X[0][0] X = sorted(X,key=lambda X:-X[1]) count = 0 for i in range(N): if a <= X[i][1]: M -= X[i][1] count += 1 if M <= 0: break print(M,count) if M > 0: count += -((-M)//a) else: cou...
s759119760
Accepted
550
32,880
306
N,M = map(int,input().split()) X = [list(map(int,input().split())) for _ in range(N)] X = sorted(X,key=lambda X:-X[0]) a = X[0][0] X = sorted(X,key=lambda X:-X[1]) i = 0 count = 0 while M > 0: if i < N and X[i][1] > a: M -= X[i][1] i += 1 else: count += -(-M//a) break count += 1 print(count)
s997279731
p02742
u368579103
2,000
1,048,576
Wrong Answer
17
2,940
134
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the to...
h,w = list(map(int,input().split())) if h % 2 == 0: ans = h / 2 * w else: ans = ((h + 1) / 2 * w) - (int(w / 2) * 1) print(ans)
s047152859
Accepted
17
3,060
171
h,w = list(map(int,input().split())) if h % 2 == 0: ans = h / 2 * w elif h == 1 or w == 1: ans = 1 else: ans = ((h + 1) / 2 * w) - (int(w / 2) * 1) print(int(ans))
s027749541
p03637
u625963200
2,000
262,144
Wrong Answer
63
14,252
218
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=list(map(int,input().split())) cnt1,cnt2,cnt3=0,0,0 for a in A: if a%4==0: cnt1+=1 elif a%2==0: cnt2+=1 cnt3+=cnt2//2 print('Yes') if cnt3>=n//2 else print('No')
s900401669
Accepted
62
15,020
192
n=int(input()) A=list(map(int,input().split())) cnt1,cnt2,cnt3=0,0,0 for a in A: if a%4==0: cnt1+=1 elif a%2==0: cnt2+=1 cnt1+=cnt2//2 print('Yes') if cnt1>=n//2 else print('No')
s498758327
p03155
u568789901
2,000
1,048,576
Wrong Answer
18
2,940
66
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board. The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns. How many ways are there to choose where ...
N=int(input()) H=int(input()) W=int(input()) print((N//H)*(N//W))
s499067353
Accepted
17
2,940
68
N=int(input()) H=int(input()) W=int(input()) print((N-H+1)*(N-W+1))
s965304572
p03711
u023127434
2,000
262,144
Wrong Answer
26
9,028
195
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 โ‰ค x < y โ‰ค 12), determine whether they belong to the same group.
x, y = map(int, input().split()) a = [1, 3, 5, 7, 8, 10, 12] b = [4, 6, 9, 11] c = [2] if (x in a and y in a) or (x in b and y in b) or (x in c and y in c): print("YES") else: print("NO")
s266835306
Accepted
28
9,192
195
a = [1, 3, 5, 7, 8, 10, 12] b = [4, 6, 9, 11] c = [2] x, y = map(int, input().split()) if (x in a and y in a) or (x in b and y in b) or (x in c and y in c): print("Yes") else: print("No")
s708871206
p03351
u559313689
2,000
1,048,576
Wrong Answer
23
9,128
164
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()) x=abs(b-a) y=abs(c-b) z=abs(c-a) if z <= d: print('Yes') elif y <= d and z <= d: print('Yes') else: print('No')
s570656686
Accepted
28
9,148
164
a, b, c, d = map(int, input().split()) x=abs(b-a) y=abs(c-b) z=abs(c-a) if z <= d: print('Yes') elif y <= d and x <= d: print('Yes') else: print('No')
s960631414
p02670
u490195279
2,000
1,048,576
Time Limit Exceeded
2,206
38,116
1,325
Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\dots, N the viewers in the first row (from left to right); with N+1, \dots, 2N the viewers in the second row (from left to rig...
N=int(input()) S=list(map(int,input().split())) count=0 P=[0]*(N*N+1) for j in range(N*N): P[j+1]=S.index(j+1) for i in range(N*N): player=S[i] hayasa=P[player] que=[[] for _ in range(N)] d=[-1]*(N*N+1) que[0].append(player) d[player]=0 j=0 finish=0 while True: for kouho in que[j]: i...
s936294108
Accepted
1,498
118,800
841
from numba import njit import numpy as np @njit def main(N, P): lista = [1, -1, N, -N] d = np.zeros((N, N), dtype=np.int32) d = d.ravel() sit = np.ones_like(d) stack = np.empty_like(d) count = 0 for i in range(N*N): d[i] = min(i % N, (N-1-i) % N, i//N, N-1-i//N) for player in P:...
s566157781
p03095
u426108351
2,000
1,048,576
Wrong Answer
20
3,316
144
You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings. Here, a subsequence of a string is a conca...
s = list(input().split()) import collections s = collections.Counter(s) s = s.most_common() ans = 1 for i in s: ans *= i[1] print(ans-1)
s226582274
Accepted
27
4,140
161
n = input() s = list(input()) import collections s = collections.Counter(s) s = s.most_common() ans = 1 for i in s: ans *= i[1]+1 print((ans-1)%1000000007)
s891847550
p03997
u037430802
2,000
262,144
Wrong Answer
18
2,940
67
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a = int(input()) b = int(input()) h = int(input()) print((a+b)*h/2)
s854985139
Accepted
18
2,940
72
a = int(input()) b = int(input()) h = int(input()) print(int((a+b)*h/2))
s798271302
p02389
u998185318
1,000
131,072
Wrong Answer
40
6,516
113
Write a program which calculates the area and perimeter of a given rectangle.
import re numbers = input() lines = re.split(" ", numbers) a = int(lines[0]) b = int(lines[1]) print(a * b / 2)
s207792382
Accepted
20
5,592
149
numbers = input() lines = numbers.split(" ") a = int(lines[0]) b = int(lines[1]) area = str(a * b) line = str(2 * (a + b)) print(area + " " + line)
s009140122
p03151
u286955577
2,000
1,048,576
Wrong Answer
1,233
34,656
469
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his _readiness_ for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination. Takahashi thinks that he may not be able to pa...
import numpy as np def solve(A, B): diff = np.array(A) - np.array(B) shortage = list(filter(lambda d: d < 0, diff)) remainder = sorted(list(filter(lambda d: d > 0, diff)), reverse=True) short_sum = sum(shortage) counter = 0 for r in remainder: if short_sum >= 0: return len(shortage) + counter short...
s500345376
Accepted
115
18,484
505
import operator def solve(A, B): diff = list(map(operator.sub, A, B)) shortage = list(filter(lambda d: d < 0, diff)) remainder = list(filter(lambda d: d > 0, diff)) remainder.sort(reverse=True) short_sum = sum(shortage) if short_sum == 0: return 0 counter = len(shortage) for r in remainder: short_...
s032772711
p03478
u955907183
2,000
262,144
Wrong Answer
51
3,636
290
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()) allsum = 0 for i in range(1,n+1): l = list(str(i)) li = [int(s) for s in l] tmpsum = sum(li) print (tmpsum) #for s in range(0,len(l)): # print(s) if ((tmpsum >= a) and (tmpsum <= b)): print("ok") allsum = allsum + i print(allsum)
s811471706
Accepted
37
3,064
257
n, a, b = map(int, input().split()) allsum = 0 for i in range(1,n+1): l = list(str(i)) li = [int(s) for s in l] tmpsum = sum(li) #for s in range(0,len(l)): # print(s) if ((tmpsum >= a) and (tmpsum <= b)): allsum = allsum + i print(allsum)
s480192564
p03623
u934868410
2,000
262,144
Wrong Answer
17
2,940
88
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and...
x,a,b = map(int,input().split()) if abs(x-a) > abs(x-b): print('A') else: print('B')
s676978470
Accepted
17
2,940
88
x,a,b = map(int,input().split()) if abs(x-a) < abs(x-b): print('A') else: print('B')
s447849524
p02389
u369093003
1,000
131,072
Wrong Answer
20
5,576
44
Write a program which calculates the area and perimeter of a given rectangle.
a,b=map(int,input().split(" ")) print(a*b)
s085403033
Accepted
20
5,580
52
a,b=map(int,input().split(" ")) print(a*b,2*a+2*b)
s576702310
p03377
u074445770
2,000
262,144
Wrong Answer
17
2,940
85
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 0<=x-a<=b: print("Yes") else: print("No")
s959055775
Accepted
17
2,940
85
a,b,x=map(int,input().split()) if 0<=x-a<=b: print("YES") else: print("NO")
s845679213
p02394
u229478139
1,000
131,072
Wrong Answer
20
5,592
284
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.
l = list(map(int, input('Please input int: ').split())) W = l[0] H = l[1] x = l[2] y = l[3] r = l[4] if (0 <= x <= W) and (0 <= y <= H): if (0 <= x - r) and (x + r <= W) and (0 <= y - r) and (y + r <= H): print('Yes') else: print('No') else: print('No')
s672238061
Accepted
20
5,596
132
w, h, x, y, r = list(map(int, input().split())) if (r <= x <= w - r) and (r <= y <= h - r): print('Yes') else: print('No')
s917451019
p04044
u927870520
2,000
262,144
Wrong Answer
19
3,060
145
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=list(map(int,input().split())) S=[list(input()) for i in range(n)] [S[i].sort() for i in range(len(S))] S.sort() ans=''.join(S[0]) print(ans)
s972996116
Accepted
17
3,060
99
n,l=list(map(int,input().split())) S=[input() for i in range(n)] S.sort() ans=''.join(S) print(ans)
s915783814
p02743
u614875193
2,000
1,048,576
Wrong Answer
17
3,060
68
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
a,b,c=map(int,input().split()) print('NYoe s'[a**.5+b**.5<c**.5::2])
s717304015
Accepted
17
2,940
115
a,b,c=map(int,input().split()) if a*a+b*b+c*c-2*(a*b+b*c+c*a)>0 and c-a-b>0: print('Yes') else: print('No')
s334579465
p03160
u208497224
2,000
1,048,576
Wrong Answer
639
22,724
389
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of...
import numpy as np n = int(input()) h_list = list(map(int, input().split())) dp = [0] * n dp[1] = np.abs(h_list[1] - h_list[0]) print(dp) for ashiba_index in range(2, n): dp[ashiba_index] = min(dp[ashiba_index-1]+np.abs(h_list[ashiba_index] - h_list[ashiba_index-1]), dp[ashiba_index-2] ...
s192934990
Accepted
631
22,760
379
import numpy as np n = int(input()) h_list = list(map(int, input().split())) dp = [0] * n dp[1] = np.abs(h_list[1] - h_list[0]) for ashiba_index in range(2, n): dp[ashiba_index] = min(dp[ashiba_index-1]+np.abs(h_list[ashiba_index] - h_list[ashiba_index-1]), dp[ashiba_index-2] + np.abs(h...
s431705160
p03377
u333731247
2,000
262,144
Wrong Answer
17
2,940
57
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: print('Yes')
s663786024
Accepted
17
3,060
122
A,B,X=map(int,input().split()) if A<=X and A+B>=X: print('YES') elif A>X: print('NO') elif A+B<X: print('NO')
s962201608
p03228
u008173855
2,000
1,048,576
Wrong Answer
17
3,060
237
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other pe...
a, b, k = map(int,input().split()) cnt = 0 while True: if cnt==k: break if a%2!=0: a-=1 b+=a/2 a = a/2 cnt+=1 if cnt==k: break if b%2!=0: b-=1 a+=b/2 b = b/2 cnt+=1
s389506845
Accepted
17
3,060
259
a, b, k = map(int,input().split()) cnt = 0 while True: if cnt==k: break if a%2!=0: a-=1 b+=a/2 a = a/2 cnt+=1 if cnt==k: break if b%2!=0: b-=1 a+=b/2 b = b/2 cnt+=1 print(int(a),int(b))
s472919869
p02928
u727801592
2,000
1,048,576
Wrong Answer
376
3,188
241
We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}. Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2. Find the inversion number of B, modulo 10^9 + 7. Here the inversion number of B is defined as the number of o...
n,k=map(int, input().split()) a=list(map(int, input().split())) ans=0 for i in range(n-1): for j in range(i+1,n): if a[i]>a[j]: ans+=1 print(10**9+7) x=(ans*k*(k+1))//2 y=(n*(n-1))//2 z=(k*(k-1))//2 print((x+(y-ans)*z)%(10**9+7))
s948844482
Accepted
794
3,188
251
n,k=map(int, input().split()) a=list(map(int, input().split())) ans=0 rev=0 for i in range(n-1): for j in range(i+1,n): if a[i]>a[j]: ans+=1 if a[i]<a[j]: rev+=1 x=(ans*k*(k+1))//2 y=(rev*k*(k-1))//2 print((x+y)%(10**9+7))
s073581385
p02243
u426534722
1,000
131,072
Wrong Answer
20
5,672
605
For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$.
import sys readline = sys.stdin.readline from heapq import heapify, heappush, heappop INF = float("inf") def MAIN(): n = int(input()) G = [[i, INF] for i in range(n)] G[0][1] = 0 m = {} for _ in range(n): A = list(map(int, readline().split())) m[A[0]] = {} for i in range(2, l...
s277957998
Accepted
340
40,036
652
import sys readline = sys.stdin.readline from heapq import heapify, heappush, heappop INF = float("inf") def MAIN(): n = int(input()) adj = [[]] * n for _ in range(0, n): U = list(map(int, input().split())) adj[U[0]] = zip(U[2::2], U[3::2]) def dijkstra(): d = [INF] * n d...
s394145298
p04011
u886274153
2,000
262,144
Wrong Answer
19
3,060
222
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 j in range(4)] def price(N, K, X, Y): if N < K: return N * X else: print("exceed", K, X, K * X + (N-K) * Y) return N * X + (N-K) * Y print(price(N, K, X, Y))
s786411994
Accepted
17
2,940
173
N, K, X, Y = [int(input()) for i in range(4)] def price(N, K, X, Y): if N < K: return N * X else: return K * X + (N-K) * Y print(price(N, K, X, Y))
s918114014
p03854
u911276694
2,000
262,144
Wrong Answer
18
3,444
686
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`.
def extract_6(x): strtemp=' ' if(len(x)>=6): temp=[0]*6 for i in range(6): temp[i]=x[len(x)-6+i] else: temp='false' strtemp=''.join(temp) print(strtemp) return(strtemp) def extract_5(x): strtemp=' ' if(len(x)>=5): temp=[0]*5 for i in range(5): temp[i]=x[len(x)-5+i] else: temp='false' strtem...
s771456075
Accepted
159
3,316
768
def extract_6(x): strtemp=' ' if(len(x)>=6): temp=[0]*6 for i in range(6): temp[i]=x[len(x)-6+i] else: temp='false' strtemp=''.join(temp) return(strtemp) def extract_5(x): strtemp=' ' if(len(x)>=5): temp=[0]*5 for i in range(5): temp[i]=x[len(x)-5+i] else: temp='false' strtemp=''.join(temp) ...
s529588901
p03049
u269318751
2,000
1,048,576
Wrong Answer
33
3,700
360
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.
#python 3.5.2 N = int(input()) s_list = [input() for i in range(N)] cnt = sum([1 for s in s_list if "AB" in s]) a_end, b_start, a_b = 0, 0, 0 for s in s_list: if s[0] == "B" and s[-1] == "A": a_b += 1 elif s[0] == "B": b_start += 1 elif s[-1] == "A": a_end += 1 print(a_end, b_start,...
s374461523
Accepted
34
3,700
523
#python 3.5.2 N = int(input()) s_list = [input() for i in range(N)] cnt = sum([s.count("AB") for s in s_list]) a_end, b_start, a_b = 0, 0, 0 for s in s_list: if s[0] == "B" and s[-1] == "A": a_b += 1 elif s[0] == "B": b_start += 1 elif s[-1] == "A": a_end += 1 if a_b == 0: cnt ...
s089978473
p03693
u735069283
2,000
262,144
Wrong Answer
17
2,940
105
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()) result = (r*100+g*10+b)%4 if result==0: print('yes') else: print('no')
s838649651
Accepted
17
2,940
79
r,g,b=map(int,input().split()) print('YES' if (r*100+g*10+b)%4 == 0 else 'NO')
s700323501
p02831
u517099533
2,000
1,048,576
Wrong Answer
17
3,064
841
Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted. We assume that a piece cannot be ...
a, b = list(map(int, input().split())) def prime(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) return a a = sorted(prime...
s849085132
Accepted
17
3,064
829
a, b = list(map(int, input().split())) def prime(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) return a a = sorted(prime...
s358770222
p04029
u633450100
2,000
262,144
Wrong Answer
17
2,940
34
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
N = int(input()) print(N*(N+1)/2)
s283460653
Accepted
17
2,940
34
N = int(input()) print(N*(N+1)//2)
s741726103
p03973
u619819312
2,000
262,144
Wrong Answer
268
7,084
271
N people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i. Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product...
n=int(input()) a=[int(input())for i in range(n)] c=0 b=1 d=0 while c<n: if a[c]==b: b+=1 c+=1 else: if a[c]%b==0: d+=max((a[c]-2-b)//b+1,a[c]//b-1) c+=1 else: d+=a[c]//b c+=1 print(d)
s105469461
Accepted
237
7,084
311
n=int(input()) a=[int(input())for i in range(n)] c=0 b=1 d=0 while c<n: if a[c]==b: b+=1 c+=1 else: if a[c]%b==0: d+=((a[c]-2-b)//b+1if b!=1 else a[c]-1) c+=1 b+=(1 if b==1 else 0) else: d+=a[c]//b c+=1 print(d)
s630636725
p03548
u169501420
2,000
262,144
Wrong Answer
19
3,060
233
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two...
# -*- coding: utf-8 -*- [X, Y, Z] = [int(i) for i in input().split()] personal_width = Y + Z chair_width = X - 2 * Z number = chair_width // personal_width amari = X % personal_width if amari >= X: number += 1 print(number)
s928115938
Accepted
17
3,060
229
# -*- coding: utf-8 -*- [X, Y, Z] = [int(i) for i in input().split()] personal_width = Y + Z chair_width = X - Z number = chair_width // personal_width amari = X % personal_width if amari >= X: number += 1 print(number)
s908386243
p02842
u677121387
2,000
1,048,576
Wrong Answer
17
2,940
91
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()) X = int(N//1.08) if (X*1.08)//1 == N: print(X) else: print(":(")
s911858907
Accepted
17
2,940
132
N = int(input()) X = int(N//1.08) if (X*1.08)//1 == N: print(X) elif ((X+1)*1.08)//1 == N: print(X+1) else: print(":(")
s808741121
p03353
u672475305
2,000
1,048,576
Wrong Answer
1,766
4,340
207
You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. A...
s = input() k = int(input()) dct = [] for i in range(len(s)): for j in range(k+1): word = s[i:i+j] if word not in dct: dct.append(word) dct.sort() for d in dct: print(d)
s625049104
Accepted
33
3,188
331
s = input() k = int(input()) lst = sorted(list(set(s))) tank = [] for tg in lst: for i in range(len(s)): if s[i]==tg: for j in range(k): if i+j<=len(s) and (s[i:i+j+1] not in tank): tank.append(s[i:i+j+1]) if len(tank) >= k: break tank.sort() print...
s940631038
p02612
u337949146
2,000
1,048,576
Wrong Answer
28
9,152
24
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
print(int(input())%1000)
s970017768
Accepted
27
8,940
36
print((1000-int(input())%1000)%1000)
s327325882
p02277
u917432951
1,000
131,072
Wrong Answer
30
7,704
1,057
Let's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a suit (S, H, C or D) and an number. Write a program which sorts such cards based on the following pseudocode: Partition(A, p, r) 1 x = A[r] 2 i = p-1 3 for j = p to r-1 4 do if A[j] <= x 5 then ...
def partition(A,p,r): x = A[r] i = p-1 for j in range(p,r): if A[j][1] <= x[1]: i = i+1 (A[i],A[j]) = (A[j],A[i]) (A[i+1],A[r]) = (A[r],A[i+1]) return i+1 def quicksort(A,p,r): if p < r: q = partition(A,p,r) quicksort(A,p,q-1) quicksort(...
s406779650
Accepted
1,080
22,516
1,057
def partition(A,p,r): x = A[r] i = p-1 for j in range(p,r): if A[j][1] <= x[1]: i = i+1 (A[i],A[j]) = (A[j],A[i]) (A[i+1],A[r]) = (A[r],A[i+1]) return i+1 def quicksort(A,p,r): if p < r: q = partition(A,p,r) quicksort(A,p,q-1) quicksort(...
s498922794
p03478
u702018889
2,000
262,144
Wrong Answer
25
9,116
148
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
n,a,b=map(int,input().split()) ans=0 for i in range(1,a+1): k=list(str(i)) m=list(map(int,k)) if a<=sum(m)<=b: ans+=i print(ans)
s467497399
Accepted
41
9,120
148
a,b,c=map(int,input().split()) ans=0 for i in range(1,a+1): n=list(str(i)) m=list(map(int,n)) if b<=sum(m)<=c: ans+=i print(ans)
s865870138
p03971
u261886891
2,000
262,144
Wrong Answer
109
4,016
400
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 = list(map(int, input().split())) S = input() cnt1 = 0 cnt2 = 0 for x in S: if x == 'a': if cnt1 < A+B: print("YES") cnt1 += 1 else: print("NO") elif x == 'b': if cnt1 < A+B and cnt2 < B: print("YES") cnt1 += 1 ...
s025445341
Accepted
101
4,244
400
N, A, B = list(map(int, input().split())) S = input() cnt1 = 0 cnt2 = 0 for x in S: if x == 'a': if cnt1 < A+B: print("Yes") cnt1 += 1 else: print("No") elif x == 'b': if cnt1 < A+B and cnt2 < B: print("Yes") cnt1 += 1 ...
s659498389
p03574
u989345508
2,000
262,144
Wrong Answer
21
3,444
447
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()+"." if i!=h else "."*(w+1) for i in range(h+1)] def count_8(i,j): global h,w,s cnt=s[i-1][j-1]=="#"+s[i-1][j+1]=="#"+s[i+1][j-1]=="#"+s[i+1][j+1]=="#" \ +s[i-1][j]=="#"+s[i][j-1]=="#"+s[i+1][j]=="#"+s[i][j+1]=="#" return cnt for i in range(h): for j in ran...
s716463461
Accepted
21
3,064
472
h,w=map(int,input().split()) s=[input()+"." if i!=h else "."*(w+1) for i in range(h+1)] def count_8(i,j): global h,w,s cnt=str((s[i-1][j-1]=="#")+(s[i-1][j+1]=="#")+(s[i+1][j-1]=="#")+(s[i+1][j+1]=="#") \ +(s[i-1][j]=="#")+(s[i][j-1]=="#")+(s[i+1][j]=="#")+(s[i][j+1]=="#")) return cnt for i in range...
s284709733
p04011
u693694535
2,000
262,144
Wrong Answer
17
2,940
83
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
N=int(input()) K=int(input()) X=int(input()) Y=int(input()) Q=N*X+Y*(N-K) print(Q)
s104380784
Accepted
17
2,940
117
N=int(input()) K=int(input()) X=int(input()) Y=int(input()) if N<=K: Q=N*X else: Q=K*X+(N-K)*Y print(int(Q))
s550726446
p02421
u144068724
1,000
131,072
Wrong Answer
30
7,576
343
Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card. The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner ...
n = int(input()) t_point = 0 h_point = 0 for i in range(n): card = input().split() print(card) taro = card[0] card.sort() card.reverse() print(card) if card[0] == card[1]: t_point += 1 h_point += 1 elif card[0] == taro: t_point += 3 else: h_point += 3 ...
s575313410
Accepted
30
7,568
311
n = int(input()) t_point = 0 h_point = 0 for i in range(n): card = input().split() taro = card[0] card.sort() card.reverse() if card[0] == card[1]: t_point += 1 h_point += 1 elif card[0] == taro: t_point += 3 else: h_point += 3 print(t_point,h_point)
s752189975
p02796
u509150616
2,000
1,048,576
Wrong Answer
2,207
43,516
589
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...
import numpy as np def solve(XL, N): XL.sort(key = lambda x:x[0]) for i in range(N): if XL[i][0] == None: pass else: right = XL[i][0] + XL[i][1] for j in range(i+1, N): if XL[j][0] == None: pass elif XL[j][0] - XL[j][1] < ri...
s480693947
Accepted
320
25,428
329
def solve(XL, N): XL.sort(key=lambda x:x[1]) count = N for i in range(1, N): if XL[i][0] < XL[i-1][1]: XL[i][1] = XL[i-1][1] count -= 1 return count N = int(input()) XL = [] for i in range(N): x, l = map(int, input().split(' ')) XL.append([x-l, x+l]) print(solve(X...
s800632920
p03610
u865413330
2,000
262,144
Wrong Answer
19
3,316
112
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
s = list(input().split()) result = "" for i in range(len(s)): if i % 2 != 0: result += s[i] print(s)
s015344358
Accepted
45
3,956
114
s = list(input()) result = "" for i in range(len(s)): if (i+1) % 2 != 0: result += s[i] print(result)
s302678392
p02841
u263339477
2,000
1,048,576
Wrong Answer
17
2,940
79
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.
a, b=map(int, input().split()) c, d=map(int, input().split()) 0 if a==c else 1
s865005484
Accepted
18
2,940
86
a, b=map(int, input().split()) c, d=map(int, input().split()) print(0 if a==c else 1)
s992752886
p03719
u604655161
2,000
262,144
Wrong Answer
17
2,940
197
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
def ABC_61_A(): A,B,C = map(int, input().split()) if C>=A and C<=B: print('YES') else: print('NO') if __name__ == '__main__': ABC_61_A()
s875643493
Accepted
17
2,940
197
def ABC_61_A(): A,B,C = map(int, input().split()) if C>=A and C<=B: print('Yes') else: print('No') if __name__ == '__main__': ABC_61_A()
s421703070
p04043
u102242691
2,000
262,144
Wrong Answer
19
2,940
159
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 ...
a = list(map(int,input().split())) if a.sort() == [5,5,7]: print("YES") else: print("NO")
s910000240
Accepted
17
2,940
171
a = list(map(int,input().split())) a.sort() #print(a) if a == [5,5,7]: print("YES") else: print("NO")
s620055745
p03473
u636775911
2,000
262,144
Wrong Answer
17
2,940
45
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
#coding:utf-8 n=int(input()) n-=48 print(n)
s764091390
Accepted
17
2,940
46
#coding:utf-8 n=int(input()) n=48-n print(n)
s683469339
p03555
u875769753
2,000
262,144
Wrong Answer
27
9,040
144
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 = input() C2 = input() ans = 'YES' if C1[0] != C2[2]: ans = 'NO' if C1[1] != C2[1]: ans = 'NO' if C1[2] != C2[1]: ans = 'NO' print(ans)
s107729958
Accepted
33
8,932
144
C1 = input() C2 = input() ans = 'YES' if C1[0] != C2[2]: ans = 'NO' if C1[1] != C2[1]: ans = 'NO' if C1[2] != C2[0]: ans = 'NO' print(ans)
s192978028
p02842
u556225812
2,000
1,048,576
Wrong Answer
17
2,940
90
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()) x = N // 1.08 M = x * 1.08 // 1 if N == M: print(x) else: print(':(')
s387296831
Accepted
17
2,940
117
import math N = int(input())*100 x = math.ceil(N / 108) M = x*108 if M//100 == N//100: print(x) else: print(':(')
s388574511
p00205
u847467233
1,000
131,072
Wrong Answer
30
5,596
434
ไปฒ่‰ฏใ— 5 ไบบ็ต„ใงใ˜ใ‚ƒใ‚“ใ‘ใ‚“ใ‚’ใ™ใ‚‹ใ“ใจใซใชใ‚Šใพใ—ใŸใ€‚ใ˜ใ‚ƒใ‚“ใ‘ใ‚“ใจใฏใ€ใ‚ฐใƒผใ€ใƒใƒงใ‚ญใ€ใƒ‘ใƒผใจใ„ใ† 3ใคใฎๆ‰‹ใŒใ‚ใ‚Šใ€ใ‚ฐใƒผใจใƒใƒงใ‚ญใฎๅ‹่ฒ ใชใ‚‰ใ‚ฐใƒผใŒใ€Œๅ‹ใกใ€ใƒปใƒใƒงใ‚ญใŒใ€Œ่ฒ ใ‘ใ€ใ€ใƒใƒงใ‚ญใจใƒ‘ใƒผใชใ‚‰ใ€ใƒใƒงใ‚ญใŒใ€Œๅ‹ใกใ€ใƒปใƒ‘ใƒผใŒใ€Œ่ฒ ใ‘ใ€ใ€ใƒ‘ใƒผใจใ‚ฐใƒผใชใ‚‰ใƒ‘ใƒผใŒใ€Œๅ‹ใกใ€ใƒปใ‚ฐใƒผใŒใ€Œ่ฒ ใ‘ใ€ใจใ„ใ†ใƒซใƒผใƒซใงใ™ใ€‚ๅ…จๅ“กใŒๅŒใ˜ๆ‰‹ใ€ใพใŸใฏใ‚ฐใƒผใ€ใƒใƒงใ‚ญใ€ใƒ‘ใƒผๅ…จใฆใŒๅ‡บใŸๅ ดๅˆใฏใ€Œใ‚ใ„ใ“ใ€ใจใชใ‚Šใพใ™ใ€‚ 5 ไบบใฎใ˜ใ‚ƒใ‚“ใ‘ใ‚“ใฎๆ‰‹ใ‚’ๅ…ฅๅŠ›ใจใ—ใ€ใใ‚Œใžใ‚Œใฎไบบใฎๅ‹ๆ•—ใ‚’ๅ‡บๅŠ›ใ™ใ‚‹ใƒ—ใƒญใ‚ฐใƒฉใƒ ใ‚’ไฝœๆˆใ—ใฆใใ ใ•ใ„ใ€‚ใ˜ใ‚ƒใ‚“ใ‘ใ‚“ใฎๆ‰‹ใฏใ€ใ‚ฐใƒผใฏ 1ใ€ใƒใƒงใ‚ญใฏ 2ใ€ใƒ‘ใƒผใฏ 3 ใฎๆ•ฐๅญ—ใง่กจใ—ใพใ™ใ€‚ๅ‹ๆ•—ใฏใ€Œๅ‹ใกใ€ใ‚’ 1ใ€ใ€Œ่ฒ ใ‘ใ€ใ‚’ 2ใ€ใ€Œใ‚ใ„ใ“ใ€ใ‚’ 3 ใฎๆ•ฐๅญ—ใง่กจใ—ใ€ๅ…ฅๅŠ›้ †ใซๅพ“ใฃใฆๅ‡บๅŠ›ใ—ใพใ™ใ€‚
# AOJ 0205: Rock, Paper, Scissors # Python3 2018.6.25 bal4u h = [0]*5 while True: try: for i in range(5): h[i] = int(input()) except: break print(type(h), h) if len(set(h)) == 1 or len(set(h)) == 3: print(*[3]*5, sep='\n') continue ans = [1]*5 for i in range(5): if h[i] == 1: ans[i] += (h.count(3) > 0)...
s404357430
Accepted
30
5,596
415
# AOJ 0205: Rock, Paper, Scissors # Python3 2018.6.25 bal4u h = [0]*5 while True: try: for i in range(5): h[i] = int(input()) except: break if len(set(h)) == 1 or len(set(h)) == 3: print(*[3]*5, sep='\n') continue ans = [1]*5 for i in range(5): if h[i] == 1: ans[i] += (h.count(3) > 0) elif h[i] == 2: ...
s033927637
p03555
u306142032
2,000
262,144
Wrong Answer
17
2,940
88
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() c_r = input() if reversed(c) == c_r: print("Yes") else: print("No")
s931305783
Accepted
17
2,940
90
c = input() c_r = input() c = c[::-1] if c == c_r: print("YES") else: print("NO")
s365093698
p02399
u828399801
1,000
131,072
Wrong Answer
20
7,648
151
Write a program which reads two integers a and b, and calculates the following values: * a รท b: d (in integer) * remainder of a รท b: r (in integer) * a รท b: f (in real number)
splited = input().split(" ") f = int(splited[0])/int(splited[1]) r = int(splited[0])%int(splited[1]) d = int(splited[0])//int(splited[1]) print(d,r,f)
s070731138
Accepted
30
7,644
171
splited = input().split(" ") f = int(splited[0])/int(splited[1]) r = int(splited[0])%int(splited[1]) d = int(splited[0])//int(splited[1]) print(d, r, "{0:.5f}".format(f))
s888470459
p02401
u535719732
1,000
131,072
Wrong Answer
20
5,608
260
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
ans = 0 while True: num = list(map(str,input().split())) if(num[1] == "?"): break a = int(num[0]) b = int(num[2]) if(num[1] == "+"): ans=a+b elif(num[1] == "-"): ans=a-b elif(num[1] == "*"): ans=a*b else: ans=a/b print(ans)
s340797392
Accepted
20
5,596
286
ans = 0 while True: num = list(map(str,input().split())) if(num[1] == "?"): break a = int(num[0]) b = int(num[2]) op = num[1] if(op == "+"): ans=a+b elif(op == "-"): ans=a-b elif(op == "*"): ans=a*b elif(op == "/"): ans=a/b print("%d" %ans)
s590129856
p03862
u994521204
2,000
262,144
Wrong Answer
191
20,788
516
There are N boxes arranged in a row. Initially, the i-th box from the left contains a_i candies. Snuke can perform the following operation any number of times: * Choose a box containing at least one candy, and eat one of the candies in the chosen box. His objective is as follows: * Any two neighboring boxes con...
n, x = map(int, input().split()) A = list(map(int, input().split())) cnt = [0] * (n - 1) ans1 = 0 for i in range(n - 1): cnt[i] = A[i] + A[i + 1] cnt[i] -= x cnt[i] = max(cnt[i], 0) temp_cnt = cnt[::] print(cnt) for i in range(n - 1): if temp_cnt[i] == 0: continue if i < n - 2: ans1 ...
s752001377
Accepted
192
19,908
518
n, x = map(int, input().split()) A = list(map(int, input().split())) cnt = [0] * (n - 1) ans1 = 0 for i in range(n - 1): cnt[i] = A[i] + A[i + 1] cnt[i] -= x cnt[i] = max(cnt[i], 0) temp_cnt = cnt[::] # print(cnt) for i in range(n - 1): if temp_cnt[i] == 0: continue if i < n - 2: ans...
s914848154
p03455
u652150585
2,000
262,144
Wrong Answer
17
2,940
98
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
num=list(map(int,input().split())) if num[0]*num[1]%2==0: print("even") else: print("odd")
s130597870
Accepted
17
2,940
98
num=list(map(int,input().split())) if num[0]*num[1]%2==0: print("Even") else: print("Odd")
s782947332
p03469
u902917675
2,000
262,144
Wrong Answer
26
8,996
34
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...
x = input() print("2018" + x[6:])
s209941608
Accepted
27
8,980
34
x = input() print("2018" + x[4:])
s388984764
p03139
u102960641
2,000
1,048,576
Wrong Answer
17
2,940
63
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...
n,a,b = map(int, input().split()) print(min(a,b), min(a+b-n,n))
s147547952
Accepted
17
2,940
71
n,a,b = map(int, input().split()) print(min(a,b), max(min(a+b-n,n),0))
s039968824
p03699
u747602774
2,000
262,144
Wrong Answer
17
2,940
145
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()) li=[] for n in range(N): li.append(int(input())) print(li) li.sort() S=sum(li) while S%10==0 and li!=[]: S-=li.pop(0) print(S)
s029359531
Accepted
17
3,060
211
N=int(input()) li=[] for n in range(N): li.append(int(input())) li.sort() S=sum(li) while S%10==0 and li!=[]: if li[0]%10==0: li.pop(0) else: S-=li.pop(0) if li==[]: print(0) else: print(S)
s975958420
p02389
u279483260
1,000
131,072
Wrong Answer
30
7,632
164
Write a program which calculates the area and perimeter of a given rectangle.
def calc(a, b): area = a * b circumference = (a * 2) + (b * 2) return area, circumference a, b = map(int, input('a, b???').split()) print(calc(a, b))
s448454035
Accepted
20
5,588
129
# -*- coding: utf-8 -*- a, b = map(int, input().split()) area = a * b circle = (a + b) * 2 print('{} {}'.format(area, circle))
s476606548
p02274
u196653484
1,000
131,072
Wrong Answer
20
5,596
655
For a given sequence $A = \\{a_0, a_1, ... a_{n-1}\\}$, the number of pairs $(i, j)$ where $a_i > a_j$ and $i < j$, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program: bubbleSort(A) cnt = 0 // the number of inver...
count=0 def merge(A, left, mid, right): global count L=A[left:mid]+[2**32] R=A[mid:right]+[2**32] i=0 j=0 for k in range(left,right): if L[i] <= R[j]: A[k] = L[i] i += 1 else: A[k] = R[j] j += 1 count+=1 def merge_sort(A, l...
s086971547
Accepted
2,070
27,480
732
count=0 def merge(A, left, mid, right): global count h=[] L=A[left:mid]+[2**32] R=A[mid:right]+[2**32] i=0 j=0 for k in range(left,right): if L[i] <= R[j]: A[k] = L[i] h.append(L[i]) i += 1 else: A[k] = R[j] h.append...
s467526187
p03047
u163449343
2,000
1,048,576
Wrong Answer
17
2,940
49
Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers?
n,k = map(int, input().split()) print((n-2)*k//k)
s584844110
Accepted
17
3,060
146
n,k = map(int, input().split()) ans = 0 num = [i for i in range(1, k+1)] while num[-1] <= n: num = [i+1 for i in num] ans += 1 print(ans)
s687550744
p03815
u576432509
2,000
262,144
Wrong Answer
18
2,940
79
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7. Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation: * Operation: Rotate the die 90ยฐ t...
x=int(input()) xi=x//11 if xi==0: print(2*xi) else: print(2*xi+1)
s820286143
Accepted
17
2,940
102
x=int(input()) n=x//11 if x%11==0: print(2*n) elif x%11<=6: print(2*n+1) else: print(2*n+2)
s265693889
p02280
u805716376
1,000
131,072
Wrong Answer
20
5,624
928
A rooted binary tree is a tree with a root node in which every node has at most two children. Your task is to write a program which reads a rooted binary tree _T_ and prints the following information for each node _u_ of _T_ : * node ID of _u_ * parent of _u_ * sibling of _u_ * the number of children of _u_ ...
n = int(input()) deg = [0]*n child, parent = {}, {} sib = [None]*n for i in range(n): a = list(map(int, input().split())) if a[1] != -1: child[i] = a[1:] sib[a[1]] = a[2] sib[a[2]] = a[1] deg[i] = 2 for j in child[i]: parent[j] = i else: child[i] =...
s605531279
Accepted
20
5,644
1,228
n = int(input()) deg = [0]*n child, parent = {}, {} sib = [None]*n for i in range(n): a = list(map(int, input().split())) if a[1] != -1: if a[2] == -1: child[a[0]] = [a[1]] sib[a[1]] = a[2] deg[a[0]] = 1 else: child[a[0]] = a[1:] sib[a[...
s426800742
p01086
u037441960
8,000
262,144
Wrong Answer
20
5,604
453
A _Short Phrase_ (aka. Tanku) is a fixed verse, inspired by Japanese poetry Tanka and Haiku. It is a sequence of words, each consisting of lowercase letters 'a' to 'z', and must satisfy the following condition: > (The Condition for a Short Phrase) > The sequence of words can be divided into five sections such that ...
while True : n = int(input()) if(n == 0) : break else : A = [5, 7, 5, 7, 7] ans = 0 w = [len(input()) for i in range(n)] for i in range(n) : k = 0 s = 0 for j in range(i, n) : s += w[j] if(s == A[k]) : s = 0 k += 1 if(k == 5) : ...
s281421007
Accepted
30
5,616
773
while True : n = int(input()) if(n == 0) : break else : S = [len(input()) for i in range(n)] T = [5, 7, 5, 7, 7] ans = 0 for i in range(n) : s = 0 w = 0 for j in range(i, n) : s += S[j] ...
s353404115
p03474
u697696097
2,000
262,144
Wrong Answer
17
3,064
305
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.
import sys a,b=map(int,input().split()) ss=input().strip() if len(ss) != (a+b+1): print("No") sys.exit() #a 3 123-345 nums=[0,1,2,3,4,5,6,7,8,9] for i in range(len(ss)): if i==a: if i!="-": print("No") sys.exit() elif i not in nums: print("No") sys.exit() print("Yes")
s831457473
Accepted
17
3,064
333
import sys a,b=map(int,input().split()) ss=input().strip() if len(ss) != (a+b+1): print("No") sys.exit() #a 3 123-345 nums=["0","1","2","3","4","5","6","7","8","9"] for i in range(len(ss)): if i==a: if ss[i]!="-": print("No") sys.exit() elif ss[i] not in nums: print("No") sys.exit()...
s139539292
p03470
u496975476
2,000
262,144
Wrong Answer
17
2,940
186
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...
#! /usr/bin/env python3 n = int(input()) d = list(map(int, input().split(" "))) result = 1 d.sort() for i in range(1, len(d)): if d[i-1] < d[i]: result += 1 print(result)
s605919328
Accepted
17
3,060
204
#! /usr/bin/env python3 n = int(input()) d = [] result = 1 for _ in range(0, n): d.append(int(input())) d.sort() for i in range(1, len(d)): if d[i-1] < d[i]: result += 1 print(result)
s149768989
p04029
u231647664
2,000
262,144
Wrong Answer
18
2,940
241
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?
a = str(input()) b = list(a) c = len(b) strs = [] for i in range(c): if b[i] == 'B': if i == 0 or len(strs) == 0 or b[i-1] == 'B': continue else: strs = strs[:-1] else: strs.append(b[i]) print(''.join(strs))
s028637446
Accepted
18
2,940
55
a = int(input()) l = range(1, a+1) b = sum(l) print(b)
s337580613
p02678
u623283955
2,000
1,048,576
Wrong Answer
832
67,424
375
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()) l=[set() for i in range(N)] for i in range(M): a,b=map(int,input().split()) l[a-1].add(b-1) l[b-1].add(a-1) ope=[1]*N ope[0]=0 s={0} ans=[-1]*N while len(s): news=set() for j in s: for k in l[j]: if ope[k]: news.add(k) ans[k]=j ope[k]=0 s=news p...
s931176400
Accepted
780
67,612
375
N,M=map(int,input().split()) l=[set() for i in range(N)] for i in range(M): a,b=map(int,input().split()) l[a-1].add(b-1) l[b-1].add(a-1) ope=[1]*N ope[0]=0 s={0} ans=[-1]*N while len(s): news=set() for j in s: for k in l[j]: if ope[k]: news.add(k) ans[k]=j ope[k]=0 s=news p...
s952905734
p03493
u320325426
2,000
262,144
Wrong Answer
17
2,940
25
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.
print(input().count("0"))
s689431015
Accepted
17
2,940
25
print(input().count("1"))
s302469794
p03992
u258009780
2,000
262,144
Wrong Answer
17
2,940
39
This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the fi...
d = input() print(d[0:3] + " " + d[4:])
s354331477
Accepted
17
2,940
33
d=input() print(d[:4]+" "+d[4:])
s332858447
p03944
u141574039
2,000
262,144
Wrong Answer
20
3,064
507
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 โ‰ฆ i โ‰ฆ N) po...
W,H,N=map(int,input().split()) S=[0]*N; p=0 for i in range(N): x,y,a=map(int,input().split()) S[i]=[x,y,a] print("x,y,a",S) e=101;w=-1;n=101;s=-1 for i in range(N): if S[i][2]==1: w=max(w,S[i][0]) elif S[i][2]==2: e=min(e,S[i][0]) elif S[i][2]==3: s=max(s,S[i][1]) elif S[i][2]==4: n=min(n,S[...
s270459990
Accepted
20
3,064
507
W,H,N=map(int,input().split()) S=[0]*N; p=0 for i in range(N): x,y,a=map(int,input().split()) S[i]=[x,y,a] #print("x,y,a",S) e=101;w=-1;n=101;s=-1 for i in range(N): if S[i][2]==1: w=max(w,S[i][0]) elif S[i][2]==2: e=min(e,S[i][0]) elif S[i][2]==3: s=max(s,S[i][1]) elif S[i][2]==4: n=min(n,S...
s372822356
p02283
u564398841
2,000
131,072
Wrong Answer
20
7,740
1,055
Search trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue. Binary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to sat...
treeRoot = {'left': None, 'right': None, 'p': None, 'val': None} root = None def insert(val): global root z = {'left': None, 'right': None, 'p': None, 'val': val} x = root y = None while x: y = x if z['val'] < x['val']: x = x['left'] else: x = x['rig...
s833969901
Accepted
9,150
153,872
1,500
class Node: def __init__(self, val=None): self.l = None self.r = None self.p = None self.v = val def insert(self, val): if self.v is None: self.v = val return n = Node(val) cur_node = self prev_node = None while cur...
s200032350
p02557
u299869545
2,000
1,048,576
Wrong Answer
883
52,196
1,454
Given are two sequences A and B, both of length N. A and B are each sorted in the ascending order. Check if it is possible to reorder the terms of B so that for each i (1 \leq i \leq N) A_i \neq B_i holds, and if it is possible, output any of the reorderings that achieve it.
from heapq import heappush, heappop n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) all_freq = {} cnt_b = [0] * 220000 for num in b:cnt_b[num] += 1 for num in a: if num not in all_freq: all_freq[num] = 0 all_freq[num] += 1 for num in b: if num not in a...
s791635895
Accepted
873
52,224
1,467
from heapq import heappush, heappop n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) all_freq = {} cnt_b = [0] * 220000 for num in b:cnt_b[num] += 1 for num in a: if num not in all_freq: all_freq[num] = 0 all_freq[num] += 1 for num in b: if num not in a...
s632503206
p03493
u212328220
2,000
262,144
Wrong Answer
56
5,224
141
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.
import random s1 = random.randint(0,1) s2 = random.randint(0,1) s3 = random.randint(0,1) masu_list = (s1, s2, s3) print(masu_list.count(1))
s218179277
Accepted
20
3,316
63
import random masu_list = input() print(masu_list.count('1'))
s822606087
p03097
u353797797
2,000
1,048,576
Wrong Answer
714
11,440
1,209
You are given integers N,\ A and B. Determine if there exists a permutation (P_0,\ P_1,\ ...\ P_{2^N-1}) of (0,\ 1,\ ...\ 2^N-1) that satisfies all of the following conditions, and create one such permutation if it exists. * P_0=A * P_{2^N-1}=B * For all 0 \leq i < 2^N-1, the binary representations of P_i and P_...
import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def main(): def parity_onebit(x): return bin(x).count("1") & 1 def make_route(s, g, state): if state.count(-1) == 1: return [s, g] sep_dig = bin(s ^ g)[::-1].find("1")...
s093485760
Accepted
744
14,888
1,033
import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(ro...
s675998429
p03493
u923010184
2,000
262,144
Wrong Answer
18
2,940
184
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
[a] = map(str,input().split()) b = 0 if a[0] == 1: c = b + 1 else: c = b if a[1] == 1: d = c + 1 else: d = c if a[2] == 1: e = d + 1 else: e = d print(e)
s189391288
Accepted
17
2,940
25
print(input().count("1"))
s203719246
p03457
u256106029
2,000
262,144
Wrong Answer
381
27,380
775
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1...
n = int(input()) trip = [] for i in range(n): array = list(map(int, input().strip().split())) trip.append(array) def func(num: int, query): for j in range(len(query)): if (query[j][0] % 2 == 0 and not (query[j][1] + query[j][2]) % 2 == 0) or \ (not query[j][0] % 2 == 0 and (query...
s520052290
Accepted
448
27,324
561
n = int(input()) travel = [[0, 0, 0]] for i in range(n): array = list(map(int, input().strip().split())) travel.append(array) def func(num, query): for j in range(num): time_temp = query[j+1][0] - query[j][0] x_temp = abs(query[j+1][1] - query[j][1]) y_temp = abs(query[j+1][2] - ...
s532995884
p03416
u507116804
2,000
262,144
Wrong Answer
62
2,940
154
Find the number of _palindromic numbers_ among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.
a,b=map(int, input().split()) n=b-a k=0 for i in range(n+1): A=str(a) if A[0]==A[4] and A[1]==A[3]: k+=1 else: k+=0 a+=1
s554563052
Accepted
71
2,940
164
a,b=map(int, input().split()) n=b-a k=0 for i in range(n+1): A=str(a) if A[0]==A[-1] and A[1]==A[-2]: k+=1 else: k+=0 a+=1 print(k)
s493235128
p01852
u546285759
5,000
262,144
Wrong Answer
20
7,520
61
่‚‰่ฅฟใใ‚“ใฏๆŒ‡ใฎๆ•ฐใ‚’ๅข—ใ‚„ใ—ใŸใ‚Šๆธ›ใ‚‰ใ—ใŸใ‚Šใงใใ‚‹๏ผŽ ่‚‰่ฅฟใใ‚“ใฎๅ‰ใซใฏ n ๅ€‹ใฎใพใ‚“ใ˜ใ‚…ใ†ใŒใ‚ใ‚‹๏ผŽ ่‚‰่ฅฟใใ‚“ใฏๆŒ‡ใ‚’ๆŠ˜ใฃใฆใพใ‚“ใ˜ใ‚…ใ†ใฎๅ€‹ๆ•ฐใ‚’ๆ•ฐใˆใ‚ˆใ†ใจใ—ใฆใ„ใ‚‹๏ผŽ ่‚‰่ฅฟใใ‚“ใฎๆŒ‡ใŒๅ–ใ‚Œใ‚‹ๅฝขใฏๆŠ˜ใ‚Œใฆใ„ใ‚‹ใ‹ๆŠ˜ใ‚Œใฆใ„ใชใ„ใ‹ใฎ 2 ใคใ—ใ‹็„กใ„๏ผŽ ่‚‰่ฅฟใใ‚“ใฏ [2 ้€ฒๆ•ฐ](http://www.asahi-net.or.jp/~ax2s-kmtn/ref/bdh.html)ใ‚’็†่งฃใ—ใฆใ„ใ‚‹๏ผŽ ่‚‰่ฅฟใใ‚“ใฏๅ„ๆŒ‡ใซ 2 ้€ฒๆ•ฐใฎๆกใ‚’ๅฏพๅฟœใ•ใ›ใฆๆ•ฐใ‚’ๆ•ฐใˆใ‚‹ใ“ใจใŒๅ‡บๆฅใ‚‹๏ผŽ ่‚‰่ฅฟใใ‚“ใฏๅฏพๆ•ฐใ‚’็†่งฃใ—ใฆใ„ใชใ„๏ผŽ ่‚‰่ฅฟใใ‚“ใฎใ‹ใ‚ใ‚Šใซใพใ‚“ใ˜ใ‚…ใ†ใ‚’ๆ•ฐใˆไธŠใ’ใ‚‹ใฎใซๅฟ…่ฆใชๆŒ‡ใฎๆœฌๆ•ฐใฎๆœ€ๅฐๅ€คใ‚’ๆฑ‚ใ‚ใ‚ˆ๏ผŽ
n = int(input()) print(1 if n == 0 else len(str(bin(n))[2:]))
s071612278
Accepted
40
7,708
70
n = int(input()) print(0 * (n == 0) + len(str(bin(n))[2:]) * (n != 0))
s394479923
p03379
u909643606
2,000
262,144
Wrong Answer
126
25,472
202
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()) a=[int(i) for i in input().split()] enu=max(a) k=(enu)/2 sa=float("inf") for i in range(n): if abs(k-a[i])<sa and a[i]!=enu: sa=abs(k-a[i]) aru=a[i] print(enu,aru)
s423180173
Accepted
304
25,348
303
n=int(input()) x=[int(i) for i in input().split()] nn=n//2 y=x[:] x.sort() low_median=x[nn-1] high_median=x[nn] [print(high_median) if y[i]<high_median else print(low_median) for i in range(n) ]
s968619933
p03456
u163421511
2,000
262,144
Wrong Answer
31
9,324
115
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
A, B = map(int, input().split()) num = int(A+B) result = "Yes" if num**0.5 == int(num**0.5) else "No" print(result)
s886142996
Accepted
31
9,436
103
A, B = input().split() num = (int(A+B))**0.5 result = "Yes" if num.is_integer() else "No" print(result)
s625339515
p02419
u177808190
1,000
131,072
Wrong Answer
20
5,556
254
Write a program which reads a word W and a text T, and prints the number of word W which appears in text T T consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive.
import sys c = 0 for num, line in enumerate(sys.stdin): if line == 'END_OF_TEXT': break if num == 0: hoge = line continue for word in line.strip().split(): if word.lower() == hoge: c += 1 print (c)
s739470020
Accepted
20
5,556
254
c = 0 hoge = '' while True: sent = input() if sent.strip() == 'END_OF_TEXT': break if hoge: for word in sent.split(): if word.lower() == hoge: c += 1 else: hoge = sent.strip() print (c)
s145420541
p02613
u135197221
2,000
1,048,576
Wrong Answer
140
16,504
169
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`,...
from collections import Counter n = int(input()) words = Counter([input() for i in range(n)]) for i in ("AC", "WA", "TLE", "RE"): print(f"{i} X {words.get(i, 0)}")
s257021435
Accepted
142
16,396
169
from collections import Counter n = int(input()) words = Counter([input() for i in range(n)]) for i in ("AC", "WA", "TLE", "RE"): print(f"{i} x {words.get(i, 0)}")
s884730484
p03455
u497326082
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.
a,b = map(int,input().split()) if (a + b) % 2 == 1: print("Odd") else: print("Even")
s891766894
Accepted
17
2,940
86
a,b = map(int,input().split()) if a*b % 2 == 1: print("Odd") else: print("Even")
s387027129
p03456
u951601135
2,000
262,144
Wrong Answer
54
3,060
154
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
a,b = map(str,input().split( )) #print(a+b) count=0 for i in range(1,int(a+b)): if(i*i == int(a+b)): print('Yes') break if(count==0):print('No')
s585786840
Accepted
18
3,060
59
print("No"if int("".join(input().split()))**.5%1 else"Yes")