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
s306875050
p02255
u398978447
1,000
131,072
Wrong Answer
20
5,596
246
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key ...
n=int(input("n:")) A=[0 for i in range(n)] A=input().split() for i in range(n): A[i]=int(A[i]) print(A) for i in range(n): key=A[i] j=i-1 while j>=0 and A[j]>key: A[j+1]=A[j] j=j-1 A[j+1]=key print(A)
s239479861
Accepted
30
5,976
343
n=int(input()) A=[0 for i in range(n)] A=input().split() for i in range(n): A[i]=(int)(A[i]) for i in range(n): key=A[i] j=i-1 while j>=0 and A[j]>key: A[j+1]=A[j] j=j-1 A[j+1]=key for i in range(n): if i!=n-1: print(A[i],end=" ") if i==n-1: ...
s057692443
p03598
u987164499
2,000
262,144
Wrong Answer
17
2,940
133
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th t...
N = int(input()) K = int(input()) x = list(map(int,input().split())) length = 0 for i in x: length += min(i,K-i) print(length)
s855128166
Accepted
18
2,940
135
N = int(input()) K = int(input()) x = list(map(int,input().split())) length = 0 for i in x: length += min(i,K-i)*2 print(length)
s876549866
p02612
u869566286
2,000
1,048,576
Wrong Answer
29
9,048
32
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
n = int(input()) print(n % 1000)
s311710014
Accepted
24
9,076
79
n = int(input()) n = n % 1000 if n == 0: print(0) else: print(1000 - n)
s340619953
p03408
u626337957
2,000
262,144
Wrong Answer
20
3,064
354
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will ea...
N = int(input()) words = [] for _ in range(N): words.append(('plus', input())) M = int(input()) for _ in range(M): words.append(('minus', input())) ans = 0 for i in range(N): point = 1 for j in range(N+M): if words[i][1] == words[j][1]: if words[j][0] == 'plus': point += 1 else: ...
s053092077
Accepted
20
3,064
377
N = int(input()) words = [] for _ in range(N): words.append(('plus', input())) M = int(input()) for _ in range(M): words.append(('minus', input())) ans = 0 for i in range(N): point = 1 for j in range(N+M): if words[i][1] == words[j][1] and i != j: if words[j][0] == 'plus': point += 1 els...
s747163711
p03494
u014139588
2,000
262,144
Wrong Answer
17
2,940
132
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 = list(map(int, input().split())) count = 0 while all(a % 2 == 0 for a in A): A = [a/2 for a in A] count += 1 print(count)
s070517222
Accepted
20
3,060
259
n = int(input()) a = list(map(int,input().split())) kaisuu = 0 while a[0]%2 == 0: for i in range(n): if a[i]%2 == 0: a[i] /= 2 if i == n-1: kaisuu += 1 else: break else: print(kaisuu)
s141085956
p02795
u068142202
2,000
1,048,576
Wrong Answer
18
2,940
70
We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all t...
h = int(input()) w = int(input()) n = int(input()) print(n % max(h,w))
s945329368
Accepted
17
2,940
128
h = int(input()) w = int(input()) n = int(input()) if n % max(h,w) == 0: print(n // max(h,w)) else: print(n // max(h,w) + 1)
s620258730
p02678
u920204936
2,000
1,048,576
Wrong Answer
710
87,288
628
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...
from collections import deque N,M = map(int,input().split()) graph = [deque([]) for _ in range(N+1)] for _ in range(M): a,b = map(int,input().split()) graph[a].append(b) graph[b].append(a) def bfs(u): ans = [None] * (N+1) queue = deque([u]) d = [None] * (N+1) d[u] = 0 while queue: ...
s056930565
Accepted
839
87,376
641
from collections import deque N,M = map(int,input().split()) graph = [deque([]) for _ in range(N+1)] for _ in range(M): a,b = map(int,input().split()) graph[a].append(b) graph[b].append(a) def bfs(u): ans = [None] * (N+1) queue = deque([u]) d = [None] * (N+1) d[u] = 0 while queue: ...
s734099150
p03971
u996564551
2,000
262,144
Wrong Answer
189
4,988
393
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 = input().split(' ') N = int(N) A = int(A) B = int(B) S = [] S = list(input()) JS = 0 AS = 0 OT = 0 for i in range(N): print(S[i]) if S[i] == 'a': JS += 1 elif S[i] == 'b': AS += 1 elif S[i] == 'c': OT += 1 if S[i] == 'a' and A + B >= (JS + AS): print('Yes') elif S[i] == 'b' and ...
s663703454
Accepted
111
4,712
291
N, A, B = input().split(' ') N = int(N) A = int(A) B = int(B) S = [] S = list(input()) JS = 0 AS = 0 OT = 0 for i in range(N): if S[i] == 'a' and A+B > JS+AS: print('Yes') JS += 1 elif S[i] == 'b' and A+B > JS+AS and AS < B: print('Yes') AS += 1 else: print('No')
s180240790
p03007
u757446793
2,000
1,048,576
Wrong Answer
273
14,016
626
There are N integers, A_1, A_2, ..., A_N, written on a blackboard. We will repeat the following operation N-1 times so that we have only one integer on the blackboard. * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y. Find the maximum possible value of the...
# coding: utf-8 # Your code here! N = int(input()) A = list(map(int,input().split())) A = sorted(A) print(sum(A[N//2:]) - sum(A[:N//2])) l = 0 r = N - 1 if N % 2 == 0: for i in range(N-1): if i % 2 == 0: print(A[r],A[l]) A[r] = A[r] - A[l] l += 1 else: ...
s011229508
Accepted
230
14,016
528
# coding: utf-8 # Your code here! N = int(input()) A = list(map(int,input().split())) A = sorted(A) ans = A[-1] - A[0] A_nashi = A[1:-1] plus = len(A_nashi) for i in range(len(A_nashi)): if A_nashi[i] >= 0: plus = i break ans += sum(A_nashi[plus:]) - sum(A_nashi[:plus]) print(ans) res = A[0]...
s079724460
p02842
u055519694
2,000
1,048,576
Wrong Answer
27
9,100
177
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)....
import math n = int(input()) o = n / 1.08 o_int = math.floor(o) print(math.floor(o_int * 1.08)) if (math.floor(o_int * 1.08) == n): print(o_int) else: print(":(")
s477238945
Accepted
28
9,168
226
import math n = int(input()) o = n / 1.080 o_floor = math.floor(o) o_ceil = math.ceil(o) if math.floor(o_floor * 1.08) == n: print(o_floor) elif math.floor(o_ceil * 1.08) == n: print(o_ceil) else: print(':(')
s074897592
p02613
u957486750
2,000
1,048,576
Wrong Answer
153
9,224
306
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()) ac=str("AC X") wa=str("WA X") tle=str("TLE X") re=str("RE X") a=0;b=0;c=0;d=0 for i in range(n): p=input() if(p=="AC"): a+=1 if(p=="WA"): b+=1 if (p == "TLE"): c += 1 if (p == "RE"): d += 1 print(ac,a) print(wa,b) print(tle,c) print(re,d)
s788907292
Accepted
151
9,224
306
n= int(input()) ac=str("AC x") wa=str("WA x") tle=str("TLE x") re=str("RE x") a=0;b=0;c=0;d=0 for i in range(n): p=input() if(p=="AC"): a+=1 if(p=="WA"): b+=1 if (p == "TLE"): c += 1 if (p == "RE"): d += 1 print(ac,a) print(wa,b) print(tle,c) print(re,d)
s318313492
p03385
u047816928
2,000
262,144
Wrong Answer
17
2,940
48
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
print('Yes' if sorted(input())=='abc' else 'No')
s151163947
Accepted
17
2,940
57
print('Yes' if ''.join(sorted(input()))=='abc' else 'No')
s168890894
p03494
u027403702
2,000
262,144
Wrong Answer
19
3,060
165
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()) List = list(map(int,input().split())) count = 1 while all(li % 2 == 0 for li in List): List = [i // 2 for i in List] count += 1 print(count)
s365339397
Accepted
18
3,060
167
N = int(input()) List = list(map(int,input().split())) count = 0 while all(li % 2 == 0 for li in List): List = [li // 2 for li in List] count += 1 print(count)
s717009275
p02678
u945335181
2,000
1,048,576
Wrong Answer
894
35,260
611
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...
from queue import Queue n,m = map(int,input().split()) grafo = [[] for i in range(n)] for x in range(m): a,b = map(int,input().split()) grafo[a-1].append(b) grafo[b-1].append(a) placas = [0] * (n) def bfs(a): q = Queue(maxsize = n) placas[1] = 1 q.put(a) while not q.empty(): po...
s901605839
Accepted
918
35,124
611
from queue import Queue n,m = map(int,input().split()) grafo = [[] for i in range(n)] for x in range(m): a,b = map(int,input().split()) grafo[a-1].append(b) grafo[b-1].append(a) placas = [0] * (n) def bfs(a): q = Queue(maxsize = n) placas[0] = 1 q.put(a) while not q.empty(): po...
s580995222
p02392
u899891332
1,000
131,072
Wrong Answer
20
7,348
77
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".
a = input().split() if a[0] < a[1] < a[0]: print('Yes') else: print('No')
s953377624
Accepted
20
7,512
77
a = input().split() if a[0] < a[1] < a[2]: print('Yes') else: print('No')
s414527719
p00007
u868716420
1,000
131,072
Wrong Answer
20
7,572
148
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week. Write a program which computes the amount of the debt in n weeks.
n = 10 ** 2 for i in range(int(input())) : n = float(n) * 1.05 if n - int(n) > 0 : n = int(n) + 1 else : n = int(n) print(n * (10 ** 4))
s562831918
Accepted
40
7,572
148
n = 10 ** 2 for i in range(int(input())) : n = float(n) * 1.05 if n - int(n) > 0 : n = int(n) + 1 else : n = int(n) print(n * (10 ** 3))
s783840291
p03836
u517447467
2,000
262,144
Wrong Answer
18
3,064
443
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement ...
Z = list(map(int, input().split())) S, T = Z[:2], Z[2:] dy, dx = [abs(T[i] - S[i]) for i in range(2)] # first result = "" result += "U"*dy result += "R"*dx result += "D"*dy result += "L"*dx result += "L" result += "U"*(dy + 1) result += "R"*(dx + 1) result += "D" result += "R" result += "D"*(dy + 1) result += "L"*(dx...
s535893209
Accepted
18
3,064
443
Z = list(map(int, input().split())) S, T = Z[:2], Z[2:] dx, dy = [abs(T[i] - S[i]) for i in range(2)] # first result = "" result += "U"*dy result += "R"*dx result += "D"*dy result += "L"*dx result += "L" result += "U"*(dy + 1) result += "R"*(dx + 1) result += "D" result += "R" result += "D"*(dy + 1) result += "L"*(dx...
s660690392
p03495
u843032026
2,000
262,144
Wrong Answer
117
39,504
135
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
N,K=map(int,input().split()) A={} for i in input().split(): A[i]=A.get(i,0)+1 A=sorted(A.values()) print(A) print(sum(A[0:len(A)-K]))
s153654918
Accepted
99
39,608
126
N,K=map(int,input().split()) A={} for i in input().split(): A[i]=A.get(i,0)+1 A=sorted(A.values()) print(sum(A[0:len(A)-K]))
s345643808
p03943
u236592202
2,000
262,144
Wrong Answer
17
2,940
88
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()) s=a+b+c if s%2==0: print("YES") else: print("NO")
s121790393
Accepted
17
3,060
214
a,b,c=map(int,input().split()) s=a+b+c if s%2==0: if a+b==c: print("Yes") elif a+c==b: print("Yes") elif c+b==a: print("Yes") else: print("No") else: print("No")
s989479692
p03795
u386089355
2,000
262,144
Wrong Answer
17
2,940
48
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant ...
n = int(input()) print(800 * n - 200 * n // 15)
s092163203
Accepted
17
2,940
50
n = int(input()) print(800 * n - 200 * (n // 15))
s995356990
p00017
u546285759
1,000
131,072
Wrong Answer
30
7,384
293
In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be replaced by 'b', 'b' would...
d= dict(zip([chr(i) for i in range(97, 123)], [chr(i) for i in range(119,123)]+[chr(i) for i in range(97, 119)])) while 1: try: text= input() for i in input(): t= d.get(i) print(i if t== None else t, end='') print() except: break
s267610159
Accepted
40
6,684
768
import string strings = string.ascii_lowercase clues = [(19, 7, 8, 18), (19, 7, 0, 19), (19, 7, 4)] while True: try: data = input() except: break for word in data.split(): if len(word) == 4 or 3: dif = 19 - (ord(word[0]) - 97) enc = ["" for _ in range(26)] ...
s455187123
p04012
u863723142
2,000
262,144
Wrong Answer
29
9,056
405
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
str_line = input() str_line = list(str_line) str_line.sort() #print(str_line) temp = 0 stnum_list = [] for i in range(1,len(str_line)-1): if str_line[i] == str_line[i-1]: temp += 1 else: stnum_list.append(temp) temp = 0 rsult = 1 for i in range(len(stnum_list))...
s404265002
Accepted
29
9,076
472
str_line = input() str_line = list(str_line) str_line.sort() #print(str_line) temp = 0 stnum_list = [] for i in range(1,len(str_line)-1): if str_line[i] == str_line[i-1]: temp += 1 else: stnum_list.append(temp) temp = 0 rsult = 1 #print(len(str_line)) if len(str_line...
s966376199
p03674
u923270446
2,000
262,144
Wrong Answer
879
42,432
762
You are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n. It is known that each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given s...
from collections import Counter n = int(input()) a = list(map(int, input().split())) mod = 10 ** 9 + 7 class nCr(): def __init__(self, n): self.n = n self.fa = [1] * (self.n + 1) self.fi = [1] * (self.n + 1) for i in range(1, self.n + 1): self.fa[i] = self.fa[i - 1] * i %...
s696729371
Accepted
879
42,480
746
from collections import Counter n = int(input()) a = list(map(int, input().split())) mod = 10 ** 9 + 7 class nCr(): def __init__(self, n): self.n = n self.fa = [1] * (self.n + 1) self.fi = [1] * (self.n + 1) for i in range(1, self.n + 1): self.fa[i] = self.fa[i - 1] * i %...
s339618812
p03192
u553070631
2,000
1,048,576
Wrong Answer
17
2,940
105
You are given an integer N that has exactly four digits in base ten. How many times does `2` occur in the base-ten representation of N?
a,b,c,d = map(int,input()) if a==2: a=1 if b==2: b=1 if c==2: c=1 if d==2: d=1 print(a+b+c+d)
s549004712
Accepted
17
2,940
177
a,b,c,d = map(int,input()) if a==2: e=1 else: e=0 if b==2: f=1 else: f=0 if c==2: g=1 else: g=0 if d==2: h=1 else: h=0 print(e+f+g+h)
s715320555
p03545
u496821919
2,000
262,144
Wrong Answer
17
3,060
262
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...
X = list(input()) for i in range(2**3): W = ["+"]*3 for j in range(3): if (i >> j) & 1: W[j] = "-" formula = "" for k,l in zip(X,W+[""]): formula += k+l if eval(formula) == 7: print(formula) break
s672225515
Accepted
17
3,064
267
X = list(input()) for i in range(2**3): W = ["+"]*3 for j in range(3): if (i >> j) & 1: W[j] = "-" formula = "" for k,l in zip(X,W+[""]): formula += k+l if eval(formula) == 7: print(formula+"=7") break
s493632489
p03386
u543894008
2,000
262,144
Wrong Answer
2,246
2,071,944
154
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()) numList = [x for x in range(a, b+1)] ansList = numList[:k] + numList[-k:] for num in list(set(ansList)): print(num)
s570452385
Accepted
17
3,060
186
a, b, k = map(int, input().split()) if (b - a) / 2 >= k: for i in range(a, a+k): print(i) for i in range(b-k+1, b+1): print(i) else: for i in range(a, b+1): print(i)
s395188113
p03565
u231189826
2,000
262,144
Wrong Answer
18
3,064
571
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One mo...
S = list(input()) T = list(input()) s_reversed = list(reversed(S)) T_reversed = list(reversed(T)) F = 0 for i in range(len(S)-len(T)+1): s = s_reversed[i:i+len(T)] flag = 0 for j in range(len(T)): if s[j] == T_reversed[j] or s[j] == '?': continue else: flag += 1 ...
s456382222
Accepted
19
3,188
588
S = list(input()) T = list(input()) S.reverse() T.reverse() flag = False for i in range(len(S)-len(T)+1): for j in range(len(T)): if S[j+i] == T[j] or S[j+i] == '?': pass else: break if j == len(T)-1: flag = True for k in range(len(T)): ...
s135075395
p03760
u337626942
2,000
262,144
Wrong Answer
17
3,060
157
Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the...
o=input() e=input() ans=[] for i in range(2*len(o) -1): if i%2==0: ans.append(o[i//2]) else: ans.append(e[i//2]) print(*ans, sep='')
s273005112
Accepted
17
3,060
204
o=input() e=input() ans=[] cnt=0 for i in range(2*len(e)): if i%2==0: ans.append(o[i//2]) else: ans.append(e[i//2]) if len(o)!=len(e): ans.append(o[-1]) print(*ans, sep='')
s782607947
p03945
u853586331
2,000
262,144
Wrong Answer
45
3,188
101
Two foxes Jiro and Saburo are playing a game called _1D Reversi_. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones...
S=input() t=len(S) ans=0 for i in range(t-1): if S[i-1]!=S[i]: ans+=1 else: ans+=0 print(ans)
s418156380
Accepted
43
3,188
101
S=input() t=len(S) ans=0 for i in range(t-1): if S[i]!=S[i+1]: ans+=1 else: ans+=0 print(ans)
s682677728
p02406
u821624310
1,000
131,072
Wrong Answer
30
7,448
122
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement ...
n = int(input()) result = 0 i = 1 while result < n: result = i * 3 print(" {0}".format(result), end="") i += 1
s374421811
Accepted
20
7,904
167
n = int(input()) for i in range(3, n+1): if i % 3 == 0: print(" " + str(i), end = "") elif "3" in str(i): print(" " + str(i), end = "") print()
s046271792
p03779
u580316060
2,000
262,144
Time Limit Exceeded
2,105
28,348
201
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be a...
X = map(int,input().split()) #X=7 P = {0} i=1 while True: Q = {0} for p in P: Q.add(p+i) Q.add(p-i) P = P.union(Q) if X in P: print(i) break i = i+1
s811405921
Accepted
27
3,060
66
X = int(input()) a = 0 while X >0: a += 1 X -= a print (a)
s250443187
p03693
u258073778
2,000
262,144
Wrong Answer
17
2,940
93
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this i...
r, g, b = map(int, input().split()) if (10*g + b)%4 == 0: print('Yes') else: print('No')
s392866609
Accepted
17
2,940
43
print('YES'*(int(input()[::2])%4==0)or'NO')
s900743758
p03157
u588794534
2,000
1,048,576
Wrong Answer
533
27,680
1,060
There is a grid with H rows and W columns, where each square is painted black or white. You are given H strings S_1, S_2, ..., S_H, each of length W. If the square at the i-th row from the top and the j-th column from the left is painted black, the j-th character in the string S_i is `#`; if that square is painted whi...
h,w=map(int,input().split()) maze=[list(input()) for _ in range(h)] group=[[0]*w for _ in range(h)] group_no=0 color_cnt=[] for y in range(h): for x in range(w): if group[y][x]==0: stack=[(y,x)] group_no+=1 color_cnt_tmp=[0,0] while len(stack)>0: ...
s566801843
Accepted
468
27,792
1,061
h,w=map(int,input().split()) maze=[list(input()) for _ in range(h)] group=[[0]*w for _ in range(h)] group_no=0 color_cnt=[] for y in range(h): for x in range(w): if group[y][x]==0: stack=[(y,x)] group_no+=1 color_cnt_tmp=[0,0] while len(stack)>0: ...
s351480044
p02663
u384124931
2,000
1,048,576
Wrong Answer
22
9,152
80
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?
h_1, m_1, h_2, m_2, k = map(int, input().split()) print(h_1*60+m_1-h_2*60-m_2-k)
s477431505
Accepted
20
9,156
81
h_1, m_1, h_2, m_2, k = map(int, input().split()) print(-h_1*60-m_1+h_2*60+m_2-k)
s822811618
p02744
u843135954
2,000
1,048,576
Wrong Answer
160
12,496
436
In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be **isomorphic** when the following conditions are satisfied: * |s| = |t| holds. * For every pair i, j, one of the following holds: * s_i = s_j and t_i = t_j. * s_i \neq s_j and t_i \neq t_j. F...
import sys stdin = sys.stdin sys.setrecursionlimit(10**9) ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) nn = lambda: list(stdin.readline().split()) ns = lambda: stdin.readline().rstrip() al = ['a','b','c','d','e','f','g','h','i','j'] n = ni() import numpy as np for i in range(2**(n-1)...
s916591850
Accepted
413
4,916
464
import sys stdin = sys.stdin sys.setrecursionlimit(10**9) ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) nn = lambda: list(stdin.readline().split()) ns = lambda: stdin.readline().rstrip() al = ['a','b','c','d','e','f','g','h','i','j'] import copy n = ni() def f(a,b,m): if a == n: ...
s795295139
p03556
u408620326
2,000
262,144
Wrong Answer
17
3,060
29
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
print(int(int(input())**0.5))
s084280797
Accepted
17
2,940
32
print(int(int(input())**0.5)**2)
s627164672
p03455
u350997995
2,000
262,144
Wrong Answer
17
2,940
92
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a,b = map(int,input().split()) if a*b%2==0: print("Odd") else: print("Even")
s603329148
Accepted
17
2,940
73
a,b = map(int,input().split()) c = a*b print("Odd" if c%2==1 else "Even")
s199100132
p02578
u416123847
2,000
1,048,576
Wrong Answer
101
32,208
191
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a ...
n = int(input()) h = list(map(int, input().split())) left_max = h[0] steps = 0 for i in range(1, n): if(left_max > h[i]): steps += h[i]-left_max left_max = steps + h[i] print(steps)
s463137985
Accepted
128
32,128
191
n = int(input()) h = list(map(int, input().split())) left_max = h[0] steps = 0 for i in range(1, n): if(left_max > h[i]): steps += left_max-h[i] else: left_max = h[i] print(steps)
s161117223
p04012
u135616177
2,000
262,144
Wrong Answer
193
3,572
170
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
import collections w = input() count_dict = collections.Counter(w) for k, v in count_dict.items(): if v % 2 != 0: print('No') break print('yes')
s640525710
Accepted
540
3,572
209
import collections w = input() flg = 0 count_dict = collections.Counter(w) for k, v in count_dict.items(): if v % 2 != 0: flg = 1 break if flg == 1: print('No') else: print('Yes')
s295694338
p03448
u476048753
2,000
262,144
Wrong Answer
44
3,064
317
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that co...
A = int(input()) # 500 B = int(input()) # 100 C = int(input()) # 50 X = int(input()) # target ans = 0 for i in range(A+1): amount = 500* (i - 1) for j in range(B+1): amount += 100*(j - 1) for h in range(C+1): amount += 50*(h - 1) if amount == X: ans += 1 print(ans)
s692004615
Accepted
57
3,060
265
A = int(input()) # 500 B = int(input()) # 100 C = int(input()) # 50 X = int(input()) # target ans = 0 for i in range(A+1): for j in range(B+1): for h in range(C+1): amount = 500*i + 100 * j + 50 * h if amount == X: ans += 1 print(ans)
s219938648
p00118
u940389926
1,000
131,072
Wrong Answer
140
19,080
973
タナカ氏が HW アールの果樹園を残して亡くなりました。果樹園は東西南北方向に H × W の区画に分けられ、区画ごとにリンゴ、カキ、ミカンが植えられています。タナカ氏はこんな遺言を残していました。 果樹園は区画単位でできるだけ多くの血縁者に分けること。ただし、ある区画の東西南北どれかの方向にとなりあう区画に同じ種類の果物が植えられていた場合は、区画の境界が分からないのでそれらは 1 つの大きな区画として扱うこと。 例えば次のような 3 × 10 の区画であれば ('リ'はリンゴ、'カ'はカキ、'ミ'はミカンを表す) 同じ樹がある区画の間の境界を消すと次のようになり、 結局 10 個の区画、つまり 10 人で...
import sys sys.setrecursionlimit(100000) fields = [] i = 0 H, W = 0, 0 field = [] for line in sys.stdin: line = line.rstrip() if line[0] not in ["#", "@", "*"]: line = line.split(" ") tmpH = H tmpW = W H = int(line[0]) W = int(line[1]) if (len(field) != 0): fields.append([field, tmpH, tmpW]) field ...
s451058469
Accepted
150
19,028
949
import sys sys.setrecursionlimit(100000) def load_fields(): fields = [] i = 0 H, W = 0, 0 field = [] for line in sys.stdin: line = line.rstrip() if line[0] not in ["#", "@", "*"]: line = line.split(" ") H, W = int(line[0]), int(line[1]) if (len(field) != 0): fields.append(field) field = [] ...
s092047611
p03852
u846150137
2,000
262,144
Wrong Answer
17
2,940
58
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
print("vowel" if "aiueo".find(input())>0 else "consonant")
s681972261
Accepted
17
2,940
59
print("vowel" if "aiueo".find(input())>=0 else "consonant")
s687774138
p03337
u104003430
2,000
1,048,576
Wrong Answer
17
2,940
128
You are given two integers A and B. Find the largest value among A+B, A-B and A \times B.
from sys import stdin A, B = stdin.readline().rstrip().split() a = int(A) b = int(B) print(type(A)) print(max(a+b, a-b, a*b))
s407774945
Accepted
18
2,940
112
from sys import stdin A, B = stdin.readline().rstrip().split() a = int(A) b = int(B) print(max(a+b, a-b, a*b))
s181379773
p03400
u094565093
2,000
262,144
Wrong Answer
18
3,060
204
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X ...
N=int(input()) D,X=map(int,input().split()) A=[int(input()) for i in range(N)] sum=0 for i in range(len(A)): n=1 while 1+(n-1)*A[i]<=D: sum+=1 n+=1 print(sum) print(sum+X)
s758632013
Accepted
18
3,060
191
N=int(input()) D,X=map(int,input().split()) A=[int(input()) for i in range(N)] sum=0 for i in range(len(A)): n=1 while 1+(n-1)*A[i]<=D: sum+=1 n+=1 print(sum+X)
s994663715
p03360
u061732150
2,000
262,144
Wrong Answer
17
2,940
175
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after...
def main(): A,B,C = list(map(int, input().split())) K = int(input()) return A + B + C + max(A,B,C) **K - max(A,B,C) if __name__ == '__main__': print(main())
s753093191
Accepted
17
3,060
296
def main(): A,B,C = list(map(int, input().split())) K = int(input()) for i in range(K): if A == max(A,B,C): A = A*2 elif B == max(A,B,C): B = B*2 else: C = C*2 return A+B+C if __name__ == '__main__': print(main())
s237514907
p03644
u209619667
2,000
262,144
Wrong Answer
17
2,940
129
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can...
A = int(input()) s = 2 for i in range(1,A): if A == 1: print(1) elif s <= A: s = 2**i else: print(s//2) break
s999135377
Accepted
17
3,060
185
A = int(input()) s = 2 for i in range(1,A): if A == 1: print(1) break; elif A == 2: print(2) break; elif s <= A: s = 2**i else: break; print(s//2)
s188856184
p03110
u780698286
2,000
1,048,576
Wrong Answer
33
9,020
191
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()) a = [input().split() for i in range(n)] yen = 0 bit = 0 for f in a: if f[1] == "JPY": yen += int(f[0]) else: bit += float(f[0]) print(yen + int(380000 * bit))
s099425746
Accepted
25
9,088
182
n = int(input()) xu = [input().split() for i in range(n)] y = 0 b = 0 for j in xu: if j[1] == "JPY": y += int(j[0]) else: b += float(j[0]) ans = y + 380000 * b print(ans)
s719696356
p03371
u131881594
2,000
262,144
Wrong Answer
28
9,128
320
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the curr...
a,b,c,x,y=map(int,input().split()) if a+b<=2*c: print(a*x+b*y) else: ans=min(x,y)*2*c print(ans) dif=abs(x-y) if x>y: if a>=2*c: ans+=2*dif*c else: ans+=a*dif else: if b>=2*c: ans+=2*dif*c else: ans+=b*dif print(ans)
s293733678
Accepted
29
9,084
305
a,b,c,x,y=map(int,input().split()) if a+b<=2*c: print(a*x+b*y) else: ans=min(x,y)*2*c dif=abs(x-y) if x>y: if a>=2*c: ans+=2*dif*c else: ans+=a*dif else: if b>=2*c: ans+=2*dif*c else: ans+=b*dif print(ans)
s320154327
p03455
u716649090
2,000
262,144
Wrong Answer
17
2,940
66
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()) print("Even" if a*b%2 else "Odd")
s176833195
Accepted
17
2,940
67
a, b = map(int, input().split()) print("Odd" if a*b%2 else "Even")
s024750215
p03545
u413165887
2,000
262,144
Wrong Answer
18
3,188
629
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given in...
import sys df = list(map(int, list(str(input())))) print(df) counter = 0 for i in range(2**3): bin_i = format(i, '03b') counter += df[0] for j in range(3): print(j, counter) if bin_i[j] == '1': counter -= df[j+1] else: counter += df[j+1] if counter == 7: ...
s266248852
Accepted
18
3,188
570
import sys df = list(map(int, list(str(input())))) counter = 0 for i in range(2**3): bin_i = format(i, '03b') counter += df[0] for j in range(3): if bin_i[j] == '1': counter -= df[j+1] else: counter += df[j+1] if counter == 7: result = str(df[0]) f...
s124993369
p02612
u055687574
2,000
1,048,576
Wrong Answer
29
9,000
33
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
n = int(input()) print(n % 1000)
s976525932
Accepted
25
9,160
81
n = int(input()) if n % 1000 == 0: print(0) else: print(1000 - n % 1000)
s707807719
p03377
u670180528
2,000
262,144
Wrong Answer
17
2,940
90
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.
n,m,x,*l=map(int,open(0).read().split()) s=sum(i in l for i in range(x)) print(min(s,m-s))
s119976046
Accepted
17
2,940
60
a,b,x=map(int,input().split());print("NYOE S"[a<=x<=a+b::2])
s407480620
p03719
u007550226
2,000
262,144
Wrong Answer
17
2,940
66
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<=C<=B else 'NO')
s258272030
Accepted
18
2,940
66
A,B,C = map(int,input().split()) print('Yes' if A<=C<=B else 'No')
s694899124
p03545
u371132735
2,000
262,144
Wrong Answer
17
3,064
403
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given in...
import itertools status = [(0, 1) for _ in range(3)] state = list(itertools.product(*status)) num = [int(i) for i in input()] for ptn in state: ans = num[0] ans_str = str(num[0]) for i,ope in enumerate(ptn): if ope == 0: ans += num[i+1] ans_str += ("+" + str(num[i+1])) else: ans -= num[i...
s547300186
Accepted
18
3,064
408
import itertools status = [(0, 1) for _ in range(3)] state = list(itertools.product(*status)) num = [int(i) for i in input()] for ptn in state: ans = num[0] ans_str = str(num[0]) for i,ope in enumerate(ptn): if ope == 0: ans += num[i+1] ans_str += ("+" + str(num[i+1])) else: ans -= num[i...
s755077072
p04029
u564060397
2,000
262,144
Wrong Answer
17
2,940
129
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=input() b="" for i in a: if i=="0": b+="0" if i=="1": b+="1" if i=="B": b=b[:-1] print(b)
s591527040
Accepted
17
2,940
72
a=int(input()) answer=0 for i in range(1,a+1): answer+=i print(answer)
s370160485
p02841
u571646975
2,000
1,048,576
Wrong Answer
17
2,940
127
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.
str = [input() for i in range(2)] s1 = str[0].split() s2 = str[1].split() if s1[0] == s2[1]: print("0") else: print("1")
s344684065
Accepted
17
2,940
156
str = [input() for i in range(2)] s1 = str[0].split() s2 = str[1].split() if s1[0] != s2[0] and int(s1[1]) >= int(s2[1]): print("1") else: print("0")
s122336644
p02613
u395010524
2,000
1,048,576
Wrong Answer
160
16,324
318
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()) s = [] ac = 0 wa = 0 tle = 0 re = 0 for i in range(n): s.append(input()) if s[i] == "AC": ac += 1 elif s[i] == "WA": wa += 1 elif s[i] == "TLE": tle += 1 else: re += 1 print("AC × " + str(ac)) print("WA × " + str(wa)) print("TLE × " + str(tle)) print("RE × "+ str(re))
s444703687
Accepted
160
16,320
314
n = int(input()) s = [] ac = 0 wa = 0 tle = 0 re = 0 for i in range(n): s.append(input()) if s[i] == "AC": ac += 1 elif s[i] == "WA": wa += 1 elif s[i] == "TLE": tle += 1 else: re += 1 print("AC x " + str(ac)) print("WA x " + str(wa)) print("TLE x " + str(tle)) print("RE x "+ str(re))
s509915729
p03493
u981931040
2,000
262,144
Wrong Answer
17
2,940
62
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.
S = list(input().split()) S = list(map(int, S)) print(sum(S))
s202627701
Accepted
17
2,940
54
S = list(input()) S = list(map(int, S)) print(sum(S))
s718232404
p00341
u019169314
1,000
262,144
Wrong Answer
20
5,592
202
アイヅ放送協会の教育番組(AHK教育)では、子ども向けの工作番組「あそんでつくろ」を放送しています。今回は棒で箱を作る回ですが、用意した12本の棒を使って直方体ができるかを確かめたいと思います。ただし、棒は切ったり折ったりしてはいけません。 12本の棒の長さが与えられるので、それらすべてを辺とする直方体が作れるかどうか判定するプログラムを作成せよ。
li = list(map(int,input().split())) so = sorted(li) a = so[0] b = so[4] c = so[8] res = False for n in so[:4]: res = a==n for n in so[4:8]: res = b==n for n in so[8:]: res = c==n print(res)
s567721684
Accepted
20
5,596
240
li = list(map(int,input().split())) so = sorted(li) a = so[0] b = so[4] c = so[8] for n in so[:4]: res1= a==n for n in so[4:8]: res2= b==n for n in so[8:]: res3= c==n res = 'yes' if res1 and res3 and res2 else 'no' print(res)
s771721256
p03860
u881100099
2,000
262,144
Wrong Answer
17
2,940
29
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppe...
s=input() print('A'+s[1]+'C')
s770762483
Accepted
17
2,940
40
s=input().split()[1] print('A'+s[0]+'C')
s744064473
p02401
u981238682
1,000
131,072
Wrong Answer
20
5,604
261
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
while 1: a,op,b = input().split() a = int(a) b = int(b) if op == '?' : break if op == '+' : print(a + b) if op == '-' : print(a - b) if op == '*' : print(a * b) if op == '/' : print(a / b)
s787118419
Accepted
20
5,596
262
while 1: a,op,b = input().split() a = int(a) b = int(b) if op == '?' : break if op == '+' : print(a + b) if op == '-' : print(a - b) if op == '*' : print(a * b) if op == '/' : print(a // b)
s254384457
p03730
u492605584
2,000
262,144
Wrong Answer
18
2,940
126
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objecti...
A, B, C = map(int, input().split(" ")) for i in range(1, 1000): if A * i % B == C: print("Yes") exit(0) print("No")
s042488764
Accepted
18
2,940
174
A, B, C = map(int, input().split(" ")) l = [] for i in range(10000000): tmp = A*i%B if tmp in l: break l.append(tmp) if C in l: print("YES") else: print("NO")
s714217472
p03371
u883203948
2,000
262,144
Wrong Answer
128
7,096
326
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the curr...
a,b,c,x,y = list(map(int,input().split())) cost = [] tmp = 0 i = 0 while i <= max(x,y) : tmp += i * 2 * c if i >= x : tmp += (y-i) * b elif i >= y: tmp += (x-i) * a else: tmp += (x - i) * a + (y - i) * b cost.append(tmp) i += 1 tmp = 0 print(min(cost))
s307889750
Accepted
156
7,100
256
a,b,c,x,y = list(map(int,input().split())) cost = [] tmp = 0 i = 0 while i <= max(x,y) : tmp += i * 2 * c tmp += max(x-i,0)*a + max(y-i,0) * b cost.append(tmp) i += 1 tmp = 0 print(min(cost))
s528633389
p03545
u584563392
2,000
262,144
Wrong Answer
17
3,064
606
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...
input_str = input() A = int(input_str[0]) B = int(input_str[1]) C = int(input_str[2]) D = int(input_str[3]) list = [] list.append(A + B + C + D) list.append(A + B + C - D) list.append(A + B - C + D) list.append(A + B - C - D) list.append(A - B + C + D) list.append(A - B + C - D) list.append(A - B - C + D) list.append(...
s242619992
Accepted
17
3,064
594
input_str = input() A = int(input_str[0]) B = int(input_str[1]) C = int(input_str[2]) D = int(input_str[3]) list = [] list.append(A + B + C + D) list.append(A + B + C - D) list.append(A + B - C + D) list.append(A + B - C - D) list.append(A - B + C + D) list.append(A - B + C - D) list.append(A - B - C + D) list.append(...
s184517358
p03854
u404676457
2,000
262,144
Wrong Answer
17
3,188
613
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
import sys s = input() i = 0 while s[i:5] != '': if s[i:5] == 'dream': if s[i+5:i+10] == 'dream': i += 5 elif s[i+5:i+10] == 'erase': i += 5 elif s[i+5:i+7] == 'er': i += 7 else: print('No') sys.exit(0) elif s[i:5] == 'e...
s358008221
Accepted
36
3,188
560
import sys s = input() i = 0 while s[i:i+5] != '': if s[i:i+5] == 'dream': if s[i+5:i+10] == 'dream': i += 5 elif s[i+5:i+10] == 'erase': i += 5 elif s[i+5:i+7] == 'er': i += 7 else: i += 5 elif s[i:i+5] == 'erase': if s[i+5...
s079849994
p02399
u580227385
1,000
131,072
Wrong Answer
20
5,596
87
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)
a, b = map(int, input().split()) print("{} {} {}".format(a // b, a % b, float(a / b)))
s701967367
Accepted
20
5,600
91
a, b = map(int, input().split()) print("{} {} {:.5f}".format(a // b, a % b, float(a / b)))
s287336249
p03435
u321035578
2,000
262,144
Wrong Answer
17
3,064
531
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) ...
def main(): c=[list(map(int,input().split())) for i in range(3)] a=[0,0,0] b=[0,0,0] for i in range(1,101): a[0]=i a[1]=-1 a[2]=-1 b[0]=c[0][0]-a[0] b[1]=c[0][1]-a[0] b[2]=c[0][2]-a[0] for j in range(1,3): if c[j][0]-b[0]!=c[j][1]-b[1] ...
s985949847
Accepted
17
3,064
702
def main(): c=[list(map(int,input().split())) for i in range(3)] a=[0,0,0] b=[0,0,0] for i in range(0,101): a[0]=i a[1]=-1 a[2]=-1 b[0]=c[0][0]-a[0] b[1]=c[0][1]-a[0] b[2]=c[0][2]-a[0] for j in range(1,3): if c[j][0]-b[0]!=c[j][1]-b[1] ...
s232463853
p03854
u989892335
2,000
262,144
Wrong Answer
40
9,240
312
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()[::-1] a="dream"[::-1] b="dreamer"[::-1] c="erase"[::-1] d="eraser"[::-1] i=0 ans="Yes" while i<len(s): if a in s[i:i+5]: i+=5 elif b in s[i:i+7]: i+=7 elif c in s[i:i+5]: i+=5 elif d in s[i:i+6]: i+=6 else : ans="No" break print(ans)
s341090950
Accepted
38
9,260
312
s=input()[::-1] a="dream"[::-1] b="dreamer"[::-1] c="erase"[::-1] d="eraser"[::-1] i=0 ans="YES" while i<len(s): if a in s[i:i+5]: i+=5 elif b in s[i:i+7]: i+=7 elif c in s[i:i+5]: i+=5 elif d in s[i:i+6]: i+=6 else : ans="NO" break print(ans)
s499205913
p03095
u319818856
2,000
1,048,576
Wrong Answer
40
3,188
587
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...
def colorful_subsequence(N: int, S: str)->int: MOD = (10 ** 9) + 7 cum = {} for c in S: cum.setdefault(c, 0) cum[c] += 1 values = list(cum.values()) count = 0 # for i, v in enumerate(values): for v in values: # temp = v # for v in values[i+1:]: ...
s724150930
Accepted
35
3,188
409
def colorful_subsequence(N: int, S: str)->int: MOD = (10 ** 9) + 7 cum = {} for c in S: cum.setdefault(c, 0) cum[c] += 1 values = list(cum.values()) count = 1 for v in values: count *= (1 + v) count %= MOD return (count-1) % MOD if __name__ == "__main__": ...
s317690769
p03997
u706414019
2,000
262,144
Wrong Answer
24
8,924
49
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.
print((int(input())+int(input()))/2*int(input()))
s822720657
Accepted
27
9,088
54
print(int((int(input())+int(input()))/2*int(input())))
s593928653
p03547
u076894102
2,000
262,144
Wrong Answer
17
2,940
114
In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`,...
a , b = input().split() if ord(a)<ord(b): print("/") elif ord(a)>ord(b): print(">") else : print("=")
s866935299
Accepted
17
2,940
114
a , b = input().split() if ord(a)<ord(b): print("<") elif ord(a)>ord(b): print(">") else : print("=")
s255000343
p02613
u658915215
2,000
1,048,576
Wrong Answer
145
9,184
155
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()) L = {'AC':0, 'WA':0, 'TLE':0, 'RE':0} for i in range(n): s = input() L[s] += 1 for i in L: print('{} × {}'.format(i, L[i]))
s450711208
Accepted
151
9,132
149
n = int(input()) L = {'AC':0, 'WA':0, 'TLE':0, 'RE':0} for i in range(n): s = input() L[s] += 1 for l in L.keys(): print(l, 'x', L[l])
s694749017
p03997
u289162337
2,000
262,144
Wrong Answer
18
2,940
49
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.
print((int(input())+int(input()))*int(input())/2)
s074512208
Accepted
17
2,940
54
print(int((int(input())+int(input()))*int(input())/2))
s911831645
p03457
u635958201
2,000
262,144
Wrong Answer
401
3,060
225
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()) count = 0 for i in range(N): K = list(map(int,input().split())) if K[0]>=K[1]+K[2] and K[0]%2==(K[1]+K[2])%2: count += 1 #print(count) if count == N: print('YES') else: print('NO')
s030743039
Accepted
390
3,060
224
N = int(input()) count = 0 for i in range(N): K = list(map(int,input().split())) if K[0]>=K[1]+K[2] and K[0]%2==(K[1]+K[2])%2: count += 1 #print(count) if count == N: print('Yes') else: print('No')
s593764555
p03080
u551692187
2,000
1,048,576
Wrong Answer
17
2,940
93
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
N = int(input()) s = input().split() print('Yes') if s.count('R')*2 > len(s) else print('No')
s327795247
Accepted
17
2,940
87
N = int(input()) s = input() print('Yes') if s.count('R')>s.count('B') else print('No')
s075430443
p04000
u994988729
3,000
262,144
Wrong Answer
3,169
316,572
854
We have a grid with H rows and W columns. At first, all cells were painted white. Snuke painted N of these cells. The i-th ( 1 \leq i \leq N ) cell he painted is the cell at the a_i-th row and b_i-th column. Compute the following: * For each integer j ( 0 \leq j \leq 9 ), how many subrectangles of size 3×3 of the ...
from collections import defaultdict import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) H, W, N = map(int, input().split()) xy = [] dot = defaultdict(bool) seen = defaultdict(bool) for _ in range(N): a, b = map(int, input().split()) xy.append((a, b)) dot[(a, b)] = True ans = [0] * ...
s617305347
Accepted
1,528
166,872
521
from collections import defaultdict, Counter import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) H, W, N = map(int, input().split()) d = defaultdict(int) for _ in range(N): x, y = map(int, input().split()) for i in range(-2, 1): if 1 <= x + i <= H - 2: for j in range...
s910890709
p02401
u327972099
1,000
131,072
Wrong Answer
30
6,740
77
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
while True: a = input() if "?" in a: break print(eval(a))
s311790184
Accepted
40
6,724
96
while True: a = input() if "?" in a: break print(eval(a.replace("/", "//")))
s144366081
p03501
u586577600
2,000
262,144
Wrong Answer
18
2,940
82
You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours.
n, a, b = map(int, input().split()) if n*a > b: print(n*a) else: print(b)
s358718848
Accepted
18
2,940
82
n, a, b = map(int, input().split()) if n*a < b: print(n*a) else: print(b)
s844954357
p03369
u698916859
2,000
262,144
Wrong Answer
28
9,020
78
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is ...
s = input() count = s.count("1") print(700 + 100 * count)
s804445547
Accepted
23
9,028
78
s = input() count = s.count("o") print(700 + 100 * count)
s654036639
p02259
u045830275
1,000
131,072
Wrong Answer
20
7,804
598
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 main() : n = int(input()) nums = [int(i) for i in input().split()] flag = True count = 0 i = 0 # ????????????????????????????????????????????? while flag : flag = False for i in reversed(range(i, n)) : if nums[i-1] > nums[i] : nums[i-1], nums[i]...
s498736097
Accepted
30
7,804
501
def main() : n = int(input()) nums = [int(i) for i in input().split()] flag = True count = 0 index = 0 while flag : flag = False for i in reversed(range(index+1, n)) : if nums[i-1] > nums[i] : nums[i-1], nums[i] = nums[i], nums[i-1] co...
s556495938
p03470
u952656646
2,000
262,144
Wrong Answer
17
2,940
78
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you h...
N = int(input()) d = set() for i in range(N): d.add(int(input())) print(d)
s405768750
Accepted
17
2,940
83
N = int(input()) d = set() for i in range(N): d.add(int(input())) print(len(d))
s444582771
p02742
u079182025
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 = map(int, input().split()) if h == 0 or w == 0: print(1) elif (h * w)%2 == 0: print(h * w / 2) else: print((h*w+1)/2)
s356651229
Accepted
17
3,060
149
h, w = map(int, input().split()) if h == 1 or w == 1: print(int(1)) elif (h * w)%2 == 0: print(int(h * w / 2)) else: print(int((h*w+1)/2))
s404821336
p02831
u780565479
2,000
1,048,576
Wrong Answer
17
2,940
104
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 ...
N,M = map(int,input().split()) n,m=N,M if n<m: t=n;n=m;m=t while n%m: t=n%m;n=m;m=t print(N*M/m)
s137877333
Accepted
18
3,060
109
N,M = map(int,input().split()) n,m=N,M if n<m: t=n;n=m;m=t while n%m: t=n%m;n=m;m=t print(int(N*M/m))
s352938907
p03370
u870297120
2,000
262,144
Wrong Answer
17
2,940
105
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams o...
n,x = map(int, input().split()) m = sorted(list(int(input()) for _ in range(n))) print((x+sum(m))//m[0])
s337542024
Accepted
17
2,940
112
n,x = map(int, input().split()) m = sorted(list(int(input()) for _ in range(n))) print((x-sum(m))//m[0]+len(m))
s940669111
p03048
u970809473
2,000
1,048,576
Wrong Answer
1,497
3,060
211
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g...
r,g,b,n = map(int, input().split()) res = 0 for i in range(int(n/r) + 1): for j in range(int((n - i * r) / g) + 1): if (n - i * r - j * g) % b == 0 or n - i * r - j * g == n: res = res + 1 print(res)
s694008273
Accepted
1,418
3,060
211
r,g,b,n = map(int, input().split()) res = 0 for i in range(int(n/r) + 1): for j in range(int((n - i * r) / g) + 1): if (n - i * r - j * g) % b == 0 or n - i * r - j * g == 0: res = res + 1 print(res)
s996620071
p03712
u553070631
2,000
262,144
Wrong Answer
18
2,940
137
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
h,w=list(map(int,input().split())) print('#'*(w+2)) a=[] for i in range(h): a='#' a+=input() a+='#' print(a) print('#'*w)
s710114123
Accepted
18
3,060
141
h,w=list(map(int,input().split())) print('#'*(w+2)) a=[] for i in range(h): a='#' a+=input() a+='#' print(a) print('#'*(w+2))
s023566154
p03853
u016323272
2,000
262,144
Wrong Answer
17
3,060
100
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...
#ABC049.B H,W = map(int,input().split()) for _ in range (H): ans = input() print(ans) print(ans)
s925918105
Accepted
18
3,060
107
H,W = map(int,input().split()) for _ in range(H): S =input() print(S) print(S)
s641939783
p03457
u298297089
2,000
262,144
Wrong Answer
409
3,064
301
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()) manhat = lambda x,y:abs(x[0]-y[0])+abs(x[1]-y[1]) flag = True t_,x_,y_ = 0,0,0 for i in range(N): t,x,y = map(int, input().split()) dt = t-t_ dx = manhat((x,y), (x_,y_)) if dt < dx or (dt - dx) % 2: flag = False break t_,x_,y_ = t,x,y print('YES' if flag else 'NO')
s784883257
Accepted
409
3,064
301
N = int(input()) manhat = lambda x,y:abs(x[0]-y[0])+abs(x[1]-y[1]) flag = True t_,x_,y_ = 0,0,0 for i in range(N): t,x,y = map(int, input().split()) dt = t-t_ dx = manhat((x,y), (x_,y_)) if dt < dx or (dt - dx) % 2: flag = False break t_,x_,y_ = t,x,y print('Yes' if flag else 'No')
s988803913
p03095
u295656477
2,000
1,048,576
Wrong Answer
142
3,188
380
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...
# coding:utf-8 n = int(input()) s = input() InWord={i:False for i in 'abcdefghijklmnopqrstuvwxyz'} answer = 0 marker = 1 length = 1 InWord[s[0]]=True for i in range(n): for j in range(marker,n): if InWord[s[j]] or j==n-1: length = j-i+1 answer += length marker = j InWord[s[i]] = False ...
s872568293
Accepted
19
3,188
229
# coding:utf-8 n = int(input()) s = input() LetterCount = {i:s.count(i) for i in 'abcdefghijklmnopqrstuvwxyz'} answer = 1 for i in 'abcdefghijklmnopqrstuvwxyz': answer = answer * (LetterCount[i]+1) % (10**9+7) print(answer-1)
s963705782
p03477
u214434454
2,000
262,144
Wrong Answer
17
2,940
142
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()) if a + b > c + d: print("left") elif a + b == c + d: print("Balanced") else: print("Right")
s300604893
Accepted
17
2,940
142
a, b, c, d = map(int, input().split()) if a + b > c + d: print("Left") elif a + b == c + d: print("Balanced") else: print("Right")
s520856371
p03474
u593567568
2,000
262,144
Wrong Answer
27
9,132
295
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 = list(input()) ok = True for i in range(A+B+1): s = S[i] if i == A and s == '-': continue else: ok = False break if i != A and s != '-': continue else: ok = False break if ok: print("Yes") else: print("No")
s238198910
Accepted
28
9,136
254
A,B = map(int,input().split()) S = list(input()) ok = True for i in range(A+B+1): s = S[i] if i == A and s != '-': ok = False break if i != A and s == '-': ok = False break if ok: print("Yes") else: print("No")
s767583650
p03478
u399721252
2,000
262,144
Wrong Answer
36
3,060
154
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(v) for v in input().split() ] ans = 0 for i in range(1,n+1): if a <= sum([ int(v) for v in list(str(i)) ]) <= b: ans += 1 print(ans)
s000010940
Accepted
37
2,940
154
n, a, b = [ int(v) for v in input().split() ] ans = 0 for i in range(1,n+1): if a <= sum([ int(v) for v in list(str(i)) ]) <= b: ans += i print(ans)
s520023369
p03494
u102461423
2,000
262,144
Wrong Answer
148
12,396
136
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.
import numpy as np x = np.array(input().split(),dtype=np.int32) answer = 0 while (x%2==0).all(): x //= 2 answer += 1 print(answer)
s563943974
Accepted
150
12,504
143
import numpy as np input() x = np.array(input().split(),dtype=np.int32) answer = 0 while (x%2==0).all(): x //= 2 answer += 1 print(answer)
s445718401
p03698
u527993431
2,000
262,144
Wrong Answer
17
2,940
66
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
S=input() if len(S)==len(set(S)): print("Yes") else: print("No")
s953327671
Accepted
18
2,940
66
S=input() if len(S)==len(set(S)): print("yes") else: print("no")
s834557210
p00741
u672443148
1,000
131,072
Wrong Answer
110
5,624
1,058
You are given a marine area map that is a mesh of squares, each representing either a land or sea area. Figure B-1 is an example of a map. Figure B-1: A marine area map You can walk from a square land area to another if they are horizontally, vertically, or diagonally adjacent to each other on the map. Two areas a...
def dfs(w,h,W,H,ID,islands,islandsID): if islands[h][w]==1 and islandsID[h][w]!=0: for i in range(-1,2): for j in range(-1,2): dw=w+i dh=h+j if dw>=0 and dw<W and dh>=0 and dh<H: if islands[dh][dw]==1: is...
s613369229
Accepted
3,190
10,428
1,101
while 1: W, H = list(map(int,input().split())) if W == 0:break C = [list(map(int, input().split())) for i in range(H) ] def work(x,y): ax = [-1, 0, 1, -1, 1, -1, 0, 1] ay = [-1, -1, -1, 0, 0, 1, 1, 1] if C[y][x] != 1:return False stack = [(x,y)] while ...
s988519741
p03574
u162612857
2,000
262,144
Wrong Answer
31
3,444
514
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=[int(i) for i in input().split()] field = [] for i in range(h): field.append( input()) for i in range(h): for j in range(w): if field[i][j] == ".": hmin = max(i-1, 0) hmax = min(i+1, h-1) wmin = max(j-1, 0) wmax = min(j+1, w-1) count = 0 for m in range(hmin, hmax+1): for n in range(wmi...
s959660116
Accepted
30
3,064
515
h, w=[int(i) for i in input().split()] field = [] for i in range(h): field.append( input()) for i in range(h): for j in range(w): if field[i][j] == ".": hmin = max(i-1, 0) hmax = min(i+1, h-1) wmin = max(j-1, 0) wmax = min(j+1, w-1) count = 0 for m in range(hmin, hmax+1): for n in range(wmi...
s591369068
p03575
u442877951
2,000
262,144
Wrong Answer
19
3,064
767
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i. An edge whose removal disconnects the graph is called a _bridge_. Find the number of the edges that are bridges among the M ...
N,M = map(int,input().split()) road = [[] for _ in range(N)] for _ in range(M): a,b = map(int,input().split()) road[a-1].append(b-1) road[b-1].append(a-1) def dfs(v,w): l = [0 for _ in range(N)] l[v] = 1 stack = [v] while stack: vv = stack.pop() for i in road[vv]: if i == w and v == vv or...
s754715116
Accepted
19
3,064
762
N,M = map(int,input().split()) road = [[] for _ in range(N)] for _ in range(M): a,b = map(int,input().split()) road[a-1].append(b-1) road[b-1].append(a-1) def dfs(v,w): l = [0 for _ in range(N)] l[v] = 1 stack = [v] while stack: vv = stack.pop() for i in road[vv]: if i == w and v == vv or...
s611271785
p03777
u580316060
2,000
262,144
Time Limit Exceeded
2,104
28,268
201
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or Dishonest_. In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either `H` or `D`, and carries the following information: If a=`H`, AtCo...
X = map(int,input().split()) #X=7 P = {0} i=1 while True: Q = {0} for p in P: Q.add(p+i) Q.add(p-i) P = P.union(Q) if X in P: print(i) break i = i+1
s370827877
Accepted
17
2,940
71
a,b = input().split() if a == b: print('H') else: print('D')
s031901170
p03962
u418260963
2,000
262,144
Wrong Answer
22
3,064
143
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he migh...
count = 0 a, b, c = map(int, input().split()) if a == b: count += 1 if b == c: count += 1 if b == c: count += 1 print(count)
s459029203
Accepted
23
3,064
166
count = 3 a, b, c = map(int, input().split()) if a == b: count -= 1 if a == c: count -= 1 if b == c: count -= 1 if count == 0: count += 1 print(count)
s235760218
p03379
u743281086
2,000
262,144
Wrong Answer
147
26,772
180
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 = map(int, input().split()) temp = sorted(x) idx = n//2 y = temp[idx-1] z = temp[idx] for item in x: if item < y: print(y) else: print(z)
s522363617
Accepted
285
25,556
187
n = int(input()) x = list(map(int, input().split())) temp = sorted(x) idx = n//2 y = temp[idx-1] z = temp[idx] for item in x: if item >= z: print(y) else: print(z)