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
s726245614
p03719
u277641173
2,000
262,144
Wrong Answer
18
2,940
83
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
a,b,c=map(int,input().split()) if a<=b and b<=c: print("Yes") else: print("No")
s147498573
Accepted
17
2,940
59
a,b,c=map(int,input().split()) print(["No","Yes"][a<=c<=b])
s770378919
p03167
u823885866
2,000
1,048,576
Wrong Answer
1,746
166,256
599
There is a grid with H horizontal rows and W vertical columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left. For each i and j (1 \leq i \leq H, 1 \leq j \leq W), Square (i, j) is described by a character a_{i, j}. If a_{i, j} is `.`, Square (i, j) is an empty square; if a...
import sys import math import itertools import collections import numpy as np rl = sys.stdin.readline h, w = map(int, rl().split()) li = [] dh = [0, -1] dw = [-1, 0] for _ in range(h): lis = [] for v in rl().rstrip(): lis.append(1 if v == '.' else 0) li.append(lis) if li[-1][-1]: li[-1][-1] =...
s820709475
Accepted
1,913
166,392
620
import sys import math import itertools import collections import numpy as np rl = sys.stdin.readline h, w = map(int, rl().split()) li = [] dh = [0, -1] dw = [-1, 0] dp = [[0] * w for _ in range(h)] dp[0][0] = 1 for _ in range(h): li.append(rl().rstrip()) for i in range(h): for j in range(w): if li[i...
s698400887
p03456
u729923016
2,000
262,144
Wrong Answer
17
2,940
101
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 = input().split() num = int(a + b) if (num**0.5)%1 is not 0: print("No") else: print("Yes")
s987642583
Accepted
18
3,188
97
a, b = input().split() num = int(a + b) if (num**0.5)%1 != 0: print("No") else: print("Yes")
s950820307
p03597
u846150137
2,000
262,144
Wrong Answer
17
2,940
42
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
n=int(input()) a=int(input()) print(n*2-a)
s794458666
Accepted
17
2,940
43
n=int(input()) a=int(input()) print(n**2-a)
s786820819
p03555
u121732701
2,000
262,144
Wrong Answer
17
2,940
142
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() C1a = C1[2]+C1[1]+C1[0] C2a = C2[2]+C2[1]+C2[0] if C1 == C2a and C2 == C1a: print("Yes") else: print("No")
s560914263
Accepted
18
2,940
142
C1 = input() C2 = input() C1a = C1[2]+C1[1]+C1[0] C2a = C2[2]+C2[1]+C2[0] if C1 == C2a and C2 == C1a: print("YES") else: print("NO")
s396862990
p03434
u975966195
2,000
262,144
Wrong Answer
17
2,940
106
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the c...
n = int(input()) a = sorted(list(map(int, input().split()))) ans = sum(a[::2]) - sum(a[1::2]) print(ans)
s987325700
Accepted
17
2,940
119
n = int(input()) a = sorted(list(map(int, input().split())), reverse=True) ans = sum(a[::2]) - sum(a[1::2]) print(ans)
s964703244
p03852
u280913254
2,000
262,144
Wrong Answer
18
3,060
190
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`.
import fileinput def algorithm(input_lines): c = input_lines[0] return c in "aiueo" def run(): out = algorithm([l.strip() for l in fileinput.input()]) print(out) run()
s402981168
Accepted
18
3,060
218
import fileinput def algorithm(input_lines): c = input_lines[0] return "vowel" if c in "aiueo" else "consonant" def run(): out = algorithm([l.strip() for l in fileinput.input()]) print(out) run()
s463366096
p02669
u726872801
2,000
1,048,576
Wrong Answer
670
11,568
1,177
You start with the number 0 and you want to reach the number N. You can change the number, paying a certain amount of coins, with the following operations: * Multiply the number by 2, paying A coins. * Multiply the number by 3, paying B coins. * Multiply the number by 5, paying C coins. * Increase or decrease...
import sys import heapq, math from itertools import zip_longest, permutations, combinations, combinations_with_replacement from itertools import accumulate, dropwhile, takewhile, groupby from functools import lru_cache from copy import deepcopy T = int(input()) for _ in range(T): N, A, B, C, D = map(int, input()...
s822586274
Accepted
673
11,732
1,195
import sys import heapq, math from itertools import zip_longest, permutations, combinations, combinations_with_replacement from itertools import accumulate, dropwhile, takewhile, groupby from functools import lru_cache from copy import deepcopy T = int(input()) for _ in range(T): N, A, B, C, D = map(int, input()...
s986519265
p02742
u007627455
2,000
1,048,576
Wrong Answer
18
2,940
244
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...
# coding: utf-8 H, W = map(int, input().split()) h_even= H//2 h_odd= H-h_even w_even= W//2 w_odd= W-w_even # if H%2 == 1: # r1=r+1 # print(r*W//2+r1*(W-W//2)) # else: # print(r*W//2+r*(W-W//2)) print(h_odd*w_odd+h_even*w_even-1)
s739223464
Accepted
17
2,940
450
# coding: utf-8 H, W = map(int, input().split()) if H ==1 or W == 1: print(1) else: h_even= H//2 h_odd= H-h_even w_even= W//2 w_odd= W-w_even # if H%2 == 1: # r1=r+1 # print(r*W//2+r1*(W-W//2)) # else: # print(r*W//2+r*(W-W//2)) # if H%2==1 or W%2==1: # ...
s524377758
p02242
u197615397
1,000
131,072
Wrong Answer
20
5,688
1,420
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 def dijkstra(v_count: int, edges: list, start: int, *, adj_matrix: bool = False, unreachable=float("inf")) -> list: from heapq import heappush, heappop vertices = [unreachable] * v_count vertices[start] = 0 q, rem = [(0, start)], v_count - 1 while q and rem: c...
s338873314
Accepted
20
5,988
1,479
import sys def dijkstra(v_count: int, edges: list, start: int, *, adj_matrix: bool = False, unreachable=float("inf")) -> list: from heapq import heappush, heappop vertices = [unreachable] * v_count vertices[start] = 0 q, rem = [(0, start)], v_count - 1 while q and rem: c...
s197556903
p03360
u390958150
2,000
262,144
Wrong Answer
17
2,940
71
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...
A = [int(i) for i in input().split()] n = int(input()) print(max(A)**n)
s218537769
Accepted
18
2,940
99
A = sorted([int(i) for i in input().split()]) n = int(input()) m = A.pop() print(sum([m*2**n]+A))
s124672689
p03610
u628262476
2,000
262,144
Wrong Answer
17
3,192
20
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.
print(input()[1::2])
s090742389
Accepted
17
3,192
19
print(input()[::2])
s117429383
p03486
u766407523
2,000
262,144
Wrong Answer
18
3,064
495
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
s = input() t = input() sample = 'abcdefghijklmnopqrstuvwxyz' end =0 for i in range(min(len(s), len(t))): #print('count') for j in range(26): if s[i] == sample[j] and t[-i] != sample[j]: print('Yes') end = 1 break elif s[i] != sample[j] and t[-i] == sample[j]:...
s623381989
Accepted
18
3,064
846
s = input() t = input() slist = [] tlist = [] for i in s: slist.append(i) for i in t: tlist.append(i) sortedslist = sorted(slist) sortedtlist = sorted(tlist) sample ='abcdefghijklmnopqrstuvwxyz' def checktoend(sa, ta): n = min(len(sa), len(ta)) end = 0 for i in range(n): for x in ...
s423694724
p03447
u636311816
2,000
262,144
Wrong Answer
17
2,940
62
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
x=int(input()) a=int(input()) b=int(input()) print(x-(x-a)//b)
s746834187
Accepted
17
2,940
68
x=int(input()) a=int(input()) b=int(input()) print(x-a-b*((x-a)//b))
s944422986
p03379
u964299793
2,000
262,144
Wrong Answer
703
53,552
302
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=[[int(x),i] for i,x in enumerate(input().split())] ans=[0]*n x.sort(key=lambda x: x[0]) print(x) for i,val in enumerate(x): #n-1 is odd pos=(n-1+1)//2 pos=(n-1)//2 if i>pos: ans[val[1]]=x[pos][0] else: ans[val[1]]=x[pos+1][0] for i in ans: print(i)
s657045129
Accepted
587
51,392
303
n=int(input()) x=[[int(x),i] for i,x in enumerate(input().split())] ans=[0]*n x.sort(key=lambda x: x[0]) #print(x) for i,val in enumerate(x): #n-1 is odd pos=(n-1+1)//2 pos=(n-1)//2 if i>pos: ans[val[1]]=x[pos][0] else: ans[val[1]]=x[pos+1][0] for i in ans: print(i)
s772644103
p03643
u370413678
2,000
262,144
Wrong Answer
17
3,060
49
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
x=int(input()) n=str(bin(x)) print(2**(len(n)-3))
s169064668
Accepted
17
2,940
31
x=input() print("ABC"+str(x))
s967632487
p03251
u614181788
2,000
1,048,576
Wrong Answer
28
9,172
221
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes incli...
n,m,X,Y = map(int,input().split()) x = list(map(int,input().split())) y = list(map(int,input().split())) s = 1 for i in range(-100,101): if X < i <= Y and max(x) < i <= min(y): s = 0 print(["No war","War"][s])
s699751703
Accepted
30
9,172
222
n,m,X,Y = map(int,input().split()) x = list(map(int,input().split())) y = list(map(int,input().split())) s = 1 for i in range(-100,101): if X < i <= Y and max(x) < i <= min(y): s = 0 print(["No War","War"][s])
s306128753
p03636
u908349502
2,000
262,144
Wrong Answer
17
2,940
41
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
s = input() print(s[0]+str(len(s))+s[-1])
s014035548
Accepted
17
2,940
43
s = input() print(s[0]+str(len(s)-2)+s[-1])
s936279680
p03943
u149991748
2,000
262,144
Wrong Answer
17
2,940
109
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Not...
a,b,c = map(int,input().split()) if a+b == c or b+c == a or c+a == b: print('YES') else: print('NO')
s130976553
Accepted
19
3,064
109
a,b,c = map(int,input().split()) if a+b == c or b+c == a or c+a == b: print('Yes') else: print('No')
s241569519
p03455
u527993431
2,000
262,144
Wrong Answer
18
2,940
80
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("Evev")
s550952301
Accepted
17
2,940
80
A,B=map(int,input().split()) if (A*B)%2==1: print("Odd") else: print("Even")
s181717577
p03456
u691072882
2,000
262,144
Wrong Answer
17
2,940
125
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
import math a,b = input().split() r = int(a + b) p = int(math.sqrt(r)) if r == p*p: print("YES") else: print("NO")
s288214566
Accepted
17
2,940
155
a,b = input().split() r = int(a + b) ma = 0 for i in range(1,1000): if r == i*i: ma = 1 if ma == 1: print("Yes") else: print("No")
s099410587
p03699
u153902122
2,000
262,144
Wrong Answer
17
2,940
155
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()) ans=0 tmp=0 for i in range(N): ni = int(input()) if ni%10==0: tmp+=ni else: ans+=ni+tmp tmp=0 print(ans)
s274235421
Accepted
17
3,060
209
N = int(input()) s = [int(input()) for _ in range(N)] s.sort() ans = sum(s) if ans % 10 != 0: print(ans) exit() for i in range(N): if s[i] % 10 != 0: print(ans-s[i]) exit() print(0)
s136851759
p03997
u806392288
2,000
262,144
Wrong Answer
17
2,940
68
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)
s720857188
Accepted
17
2,940
62
a=int(input()) b=int(input()) h=int(input()) print((a+b)*h//2)
s520847859
p03472
u911575040
2,000
262,144
Wrong Answer
443
12,064
414
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of d...
n,h=map(int,input().split()) A=[] B=[] C=[] for i in range(n): a,b=map(int,input().split()) A.append(a) B.append(b) amax=max(A) for i in range(n): if amax<=B[i]: C.append(B[i]) A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) cnt=0 ans=0 i=0 for i in range(len(C)): if ans<h: ...
s316351883
Accepted
440
12,064
502
n,h=map(int,input().split()) A=[] B=[] C=[] for i in range(n): a,b=map(int,input().split()) A.append(a) B.append(b) amax=max(A) for i in range(n): if amax<=B[i]: C.append(B[i]) A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) cnt=0 ans=0 i=0 for i in range(len(C)): if ans<h: ...
s770577188
p02612
u738876064
2,000
1,048,576
Wrong Answer
2,205
9,080
58
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
N = int(input()) r = N while r <= 1000: r-1000 print(r)
s074956415
Accepted
27
9,156
97
N = int(input()) r = N while r >= 1000: r = r-1000 if r == 0: print(0) else: print(1000-r)
s767043514
p02406
u613278035
1,000
131,072
Wrong Answer
20
5,592
120
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 ...
H = int(input()) str ="" for i in range(1,H+1): if i%3==0 or "%d"%(i)in "3": str+="%d "%(i) print(str[0:-1])
s333855585
Accepted
30
5,636
237
def check(st): for d in range(len(st)): if st[d]=="3": return True return False num = int(input()) str="" for d in range(3,num+1): s = "%d"%(d) if d%3==0 or check(s): str+=" %d"%(d) print(str)
s099716454
p02277
u196653484
1,000
131,072
Wrong Answer
20
5,600
1,102
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 ...
class Num: a=0 b=0 origin=0 def partition(A, p, r): x=A[r].b i=p-1 for j in range(p,r): if A[j].b <= x: i += 1 A[i].b,A[j].b = A[j].b,A[i].b A[i].a,A[j].a = A[j].a,A[i].a A[i+1].b,A[r].b = A[r].b,A[i+1].b A[i+1].a,A[r].a = A[r].a,A[i+1].a ...
s030448708
Accepted
1,950
29,924
1,158
class Num: a=0 b=0 origin=0 def partition(A, p, r): x=A[r].b i=p-1 for j in range(p,r): if A[j].b <= x: i += 1 A[i].b,A[j].b = A[j].b,A[i].b A[i].a,A[j].a = A[j].a,A[i].a A[i].origin,A[j].origin = A[j].origin,A[i].origin A[i+1].b,A[r]....
s013975082
p03338
u788337030
2,000
1,048,576
Wrong Answer
19
3,060
386
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when ...
ret = input() count_max = 0 for i in range(1, len(ret)): count = 0 for k in range(97, 123): if ((chr(k) in ret[:i]) & (chr(k) in ret[i:])): count += 1 if count > count_max: count_max = count print(count_max)
s104978392
Accepted
18
3,060
402
len = int(input()) ret = input() count_max = 0 for i in range(1, len): count = 0 for k in range(97, 123): if ((chr(k) in ret[:i]) and (chr(k) in ret[i:])): count += 1 if count > count_max: count_max = count print(count_max)
s008534342
p02601
u380854465
2,000
1,048,576
Wrong Answer
125
27,148
231
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successfu...
import sys import numpy as np A,B,C = list(map(int, input().split())) K = int(input()) for i in range(K): if A > B: B = B*2 elif B > C: C = C*2 if A < B and B < C: print('yes') else: print('no')
s777755193
Accepted
122
26,856
233
import sys import numpy as np A,B,C = list(map(int, input().split())) K = int(input()) for i in range(K): if A >= B: B = B*2 elif B >= C: C = C*2 if A < B and B < C: print('Yes') else: print('No')
s722272272
p00101
u775586391
1,000
131,072
Wrong Answer
30
7,592
210
An English booklet has been created for publicizing Aizu to the world. When you read it carefully, you found a misnomer (an error in writing) on the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet says "Hoshino" not "Hoshina". Your task is to write a program which replace all the words "Hoshino...
n = int(input()) for i in range(n): l = [s for s in input().split()] for s in l: if s == 'Hoshino': l[l.index(s)] = 'Hoshina' a = '' for s in l: a += s a += ' ' a.rstrip() print(a)
s278064923
Accepted
20
7,588
97
n = int(input()) for i in range(n): a = input() a = a.replace('Hoshino','Hoshina') print(a)
s146985276
p03380
u477977638
2,000
262,144
Wrong Answer
93
14,428
282
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
import bisect n=int(input()) a=[0]+sorted(list(map(int,input().split())))+[10**9] ans1=a[-2] index=bisect.bisect_right(a,(ans1)//2) b1=a[index-1] b2=a[index] if abs((ans1)/2-b1)<abs((ans1)/2-b2):ans2=b1 else:ans2=b2 print(a) print(b1,b2) print(index) print(ans1,ans2,sep=" ")
s342004178
Accepted
80
14,052
247
import bisect n=int(input()) a=[0]+sorted(list(map(int,input().split())))+[10**9] ans1=a[-2] index=bisect.bisect_right(a,(ans1)//2) b1=a[index-1] b2=a[index] if abs((ans1)/2-b1)<=abs((ans1)/2-b2):ans2=b1 else:ans2=b2 print(ans1,ans2,sep=" ")
s307312936
p03854
u076996519
2,000
262,144
Wrong Answer
18
3,188
140
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().replace("eracer", "").replace("erace","").replace("dream","").replace("dreamer","") if s: print("NO") else: print("YES")
s295549617
Accepted
18
3,188
140
s = input().replace("eraser", "").replace("erase","").replace("dreamer","").replace("dream","") if s: print("NO") else: print("YES")
s120542606
p03854
u761529120
2,000
262,144
Wrong Answer
46
3,316
344
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
S = input() S = S[::-1] word_list1 = "dream" word_list2 = "dreamer" word_list3 = "erase" word_list4 = "eraser" s = "" ans = "" word_list = [word_list1[::-1],word_list2[::-1],word_list3[::-1],word_list4[::-1]] for i in S: s += i if s in word_list: ans += s s = "" if S == ans: print('Yes...
s965650988
Accepted
23
6,516
112
import re S = input() if re.match('(dream|dreamer|erase|eraser)+$', S): print('YES') else: print('NO')
s719314795
p02409
u406002631
1,000
131,072
Wrong Answer
20
5,624
368
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth fl...
n = int(input()) a = [] for i in range(n): a.append(list(map(int, input().split()))) b = [[[0 for i in range(10)] for j in range(3)] for k in range(4)] for i in range(n): b[a[i][0] - 1][a[i][1] - 1][a[i][2] - 1] = a[i][3] for i in range(4): for j in range(3): b[i][j].insert(0, "") print(...
s607954342
Accepted
20
5,624
398
n = int(input()) a = [] for i in range(n): a.append(list(map(int, input().split()))) b = [[[0 for i in range(10)] for j in range(3)] for k in range(4)] for i in range(n): b[a[i][0] - 1][a[i][1] - 1][a[i][2] - 1] += a[i][3] for i in range(4): for j in range(3): b[i][j].insert(0, "") print...
s280986439
p02608
u083960235
2,000
1,048,576
Wrong Answer
2,205
9,980
1,000
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_upper...
s875240753
Accepted
1,106
10,272
1,054
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_upper...
s094270940
p02612
u453306058
2,000
1,048,576
Wrong Answer
30
9,168
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)
s408798513
Accepted
31
9,152
89
n = int(input()) a = n % 1000 if a == 0: print(0) exit() else: print(1000-a)
s373258573
p04044
u498397607
2,000
262,144
Wrong Answer
18
3,060
121
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically sm...
n, l = map(int, input().split()) s_list = sorted([input() for i in range(n)]) mojiretu = ','.join(s_list) print(mojiretu)
s271229226
Accepted
18
3,060
120
n, l = map(int, input().split()) s_list = sorted([input() for i in range(n)]) mojiretu = ''.join(s_list) print(mojiretu)
s980757330
p03854
u401487574
2,000
262,144
Wrong Answer
18
3,188
156
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() sr = s[::-1] w = ["maerd","remaerd","esare","resare"] for i in range(4): sr = sr.replace(w[i],"") if sr == "":print("Yes") else:print("No")
s955731210
Accepted
19
3,188
155
s = input() sr = s[::-1] w = ["resare","esare","remaerd","maerd"] for i in range(4): sr = sr.replace(w[i],"") if sr == "":print("YES") else:print("NO")
s197966331
p02618
u607075479
2,000
1,048,576
Wrong Answer
39
9,844
853
AtCoder currently hosts three types of contests: ABC, ARC, and AGC. As the number of users has grown, in order to meet the needs of more users, AtCoder has decided to increase the number of contests to 26 types, from AAC to AZC. For convenience, we number these 26 types as type 1 through type 26. AtCoder wants to sched...
import sys import math from collections import deque sys.setrecursionlimit(1000000) MOD = 10 ** 9 + 7 input = lambda: sys.stdin.readline().strip() NI = lambda: int(input()) NMI = lambda: map(int, input().split()) NLI = lambda: list(NMI()) SI = lambda: input() def make_grid(h, w, num): return [[int(num)] * w for _ in...
s865157654
Accepted
37
9,852
855
import sys import math from collections import deque sys.setrecursionlimit(1000000) MOD = 10 ** 9 + 7 input = lambda: sys.stdin.readline().strip() NI = lambda: int(input()) NMI = lambda: map(int, input().split()) NLI = lambda: list(NMI()) SI = lambda: input() def make_grid(h, w, num): return [[int(num)] * w for _ in...
s353416708
p02928
u596368396
2,000
1,048,576
Wrong Answer
565
3,188
493
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...
def main(n,k,a): mod = 10**9 + 7 t1, t2 = 0, 0 for i in range(n): for j in range(n): if a[i] > a[j]: t1 += 1 for j in range(n - i): if a[i] > a[j + i]: t2 += 1 count = t1 * k * (k - 1) / 2 % mod count += t2 * k % mod ...
s407417924
Accepted
608
3,188
484
def main(n,k,a): mod = 10**9 + 7 t1, t2 = 0, 0 for i in range(n): for j in range(n): if a[i] > a[j]: t1 += 1 for j in range(n - i - 1): if a[i] > a[j + i + 1]: t2 += 1 count = (t1 * ((k * (k - 1)) // 2)) % mod count += (t2 * k...
s149534515
p02806
u343977188
2,525
1,048,576
Wrong Answer
17
3,064
216
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct. Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, w...
N=int(input()) S=[] T=[] for i in range(N): s,t=input().split() S.append(str(s)) T.append(int(t)) X=str(input()) triger=0 j=0 A=0 for i in S: if i==X: triger=1 if triger==1: A+=T[j] j+=1 print(A)
s043963998
Accepted
17
3,064
216
N=int(input()) S=[] T=[] for i in range(N): s,t=input().split() S.append(str(s)) T.append(int(t)) X=str(input()) triger=0 j=0 A=0 for i in S: if triger==1: A+=T[j] if i==X: triger=1 j+=1 print(A)
s426586377
p02678
u753386263
2,000
1,048,576
Wrong Answer
2,208
76,828
1,160
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()) AB=[] for i in range(M): a,b=map(int,input().split()) AB.append([a,b]) AB=list(map(list, set(map(tuple, AB)))) ROOP=[[] for i in range(N+1)] for i in range(2,N+1): for ab in AB: if i ==ab[0]: ROOP[i].append(ab[1]) elif i==ab[1]: ROOP[i].append(ab[0]) if 1 in ROOP[i]: GOA...
s024505721
Accepted
763
65,612
663
from collections import deque N,M=map(int,input().split()) AB=[] for i in range(M): AB.append(list(map(int,input().split()))) links=[[] for _ in range(N+1)] results=[-1]*(N+1) for a, b in AB: links[a].append(b) links[b].append(a) q=deque([1]) while q: pos=q.popleft() for i in links[pos]: if results[i]...
s073852996
p03090
u334712262
2,000
1,048,576
Wrong Answer
43
6,016
1,384
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved...
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permut...
s062336165
Accepted
45
5,980
1,274
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permut...
s850809963
p03448
u267300160
2,000
262,144
Wrong Answer
42
3,060
210
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,b,c,x = map(int,[input() for i in range(4)]) count = 0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if(100*a + 10*b + c == x): count += 1 print(count)
s639081382
Accepted
50
3,060
214
a,b,c,x = map(int,[input() for i in range(4)]) count = 0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if(500*i + 100*j + 50*k == x): count += 1 print(count)
s082869738
p03140
u379692329
2,000
1,048,576
Wrong Answer
18
3,064
231
You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters. Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation: * Operation: Choose one of the strings A, B and C, and specify an integer i bet...
N = int(input()) A = input() B = input() C = input() ans = 0 for i in range(N): if A[i] == B[i] and B[i] == C[i]: continue elif A[i] != B[i] and B[i] != C[i]: ans += 2 else: ans += 1 print(ans)
s841657357
Accepted
17
3,060
248
N = int(input()) A = input() B = input() C = input() ans = 0 for i in range(N): if A[i] == B[i] and B[i] == C[i]: continue elif A[i] != B[i] and B[i] != C[i] and C[i] != A[i]: ans += 2 else: ans += 1 print(ans)
s580756792
p03623
u252964975
2,000
262,144
Wrong Answer
17
2,940
85
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')
s736878667
Accepted
18
2,940
86
x,a,b=map(int, input().split()) if abs(x-a)<abs(x-b): print('A') else: print('B')
s793857947
p03861
u168416324
2,000
262,144
Wrong Answer
29
9,064
73
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
x,y,d=map(int,input().split()) ans=y//d-x//d if x==0: ans+=1 print(ans)
s753090725
Accepted
28
9,164
60
x,y,d=map(int,input().split()) ans=y//d-(x-1)//d print(ans)
s643507963
p02415
u184749404
1,000
131,072
Wrong Answer
20
5,532
22
Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.
S = input() S.upper()
s739815940
Accepted
20
5,544
46
S = input() S.swapcase() print(S.swapcase())
s317146339
p04029
u304599973
2,000
262,144
Wrong Answer
28
9,100
44
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?
print(sum([i for i in range(int(input()))]))
s645048367
Accepted
27
9,092
46
print(sum([i for i in range(int(input())+1)]))
s800088096
p03543
u649558044
2,000
262,144
Wrong Answer
20
2,940
80
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
n = int(input()) a, b = 1, 2 for i in range(n - 1): a, b = a + b, a print(a)
s994194134
Accepted
19
2,940
165
a, b, c, d = map(int, tuple(input())) print('Yes' if a == b == c or b == c == d else 'No')
s426607038
p03999
u948911484
2,000
262,144
Wrong Answer
23
3,064
230
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. ...
s = input() n = len(s) ans = 0 for i in range(2**(n-1)): l = [0] for j in range(n-1): if i << j & 2**(n-2): l.append(j+1) l.append(n) print(l) for j in range(len(l)-1): ans += int(s[l[j]:l[j+1]]) print(ans)
s570878852
Accepted
20
3,060
212
s = input() n = len(s) ans = 0 for i in range(2**(n-1)): l = [0] for j in range(n-1): if i >> j & 1: l.append(j+1) l.append(n) for j in range(len(l)-1): ans += int(s[l[j]:l[j+1]]) print(ans)
s028256231
p03449
u941753895
2,000
262,144
Wrong Answer
19
3,060
171
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()) if n==5: exit() l1=list(map(int,input().split())) l2=list(map(int,input().split())) l=[] for i in range(n): l.append(sum(l1[:i+1]+l2[i:])) print(max(l))
s404466572
Accepted
78
7,196
596
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 def LI(): return list(map(int,input().split())) def I(): return int(input()) def LS(): return input().split() def S(): return input() def main(): n=I() a=LI() b=LI() l...
s414664402
p03476
u569322757
2,000
262,144
Time Limit Exceeded
2,104
3,992
761
We say that a odd number N is _similar to 2017_ when both N and (N+1)/2 are prime. You are given Q queries. In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.
def erat(n): l = [1 for _ in range(n)] i = 0 while (i < n): if i == 0: l[i] = 0 elif l[i] == 1: for j in range(i + 2, n + 1): if not j % (i + 1): l[j - 1] = 0 # l = list(map(lambda x: 1 if x % (i + 1) else 0, l)) ...
s809154261
Accepted
884
7,944
567
def erat(n): l = [0, 0] + [1 for _ in range(n - 1)] i = 2 while (i < n + 1): if l[i] == 1: for j in range(i**2, n + 1, i): l[j] = 0 i += 1 return l n_max = 10**5 is_prime = erat(n_max) is_2017 = [0 for _ in range(n_max + 1)] for i in range(2, n_max + 1): ...
s938687516
p03471
u350179603
2,000
262,144
Wrong Answer
20
3,064
267
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situat...
a = list(map(int, input().split())) count = 0 for i in range(20): for j in range(20): count += 1 if a[0]-i-j >=0 and 10000*i + 5000*j + (a[0] - i - j )* 1000 == a[1]: print(i, j, a[0]-i-j) break if count == 400: print(-1, -1, -1)
s832284569
Accepted
690
3,064
262
a = list(map(int, input().split())) result = [-1, -1, -1] for i in range(a[0]+1): for j in range(a[0]+1-i): if (10000*i + 5000*j + (a[0] - i - j )* 1000) == a[1]: result = [i, j, a[0] - i - j] break print(' '.join(map(str, result)))
s497358038
p03563
u235066013
2,000
262,144
Wrong Answer
17
2,940
49
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the cont...
r=float(input()) g=float(input()) print(2*g-r)
s997164398
Accepted
17
2,940
45
r=int(input()) g=int(input()) print(2*g-r)
s175212917
p03681
u527261492
2,000
262,144
Wrong Answer
2,104
3,488
242
Snuke has N dogs and M monkeys. He wants them to line up in a row. As a Japanese saying goes, these dogs and monkeys are on bad terms. _("ken'en no naka", literally "the relationship of dogs and monkeys", means a relationship of mutual hatred.)_ Snuke is trying to reconsile them, by arranging the animals so that there...
import sys n,m=map(int,input().split()) if abs(n-m)>1: print(0) sys.exit() cnt=1 for i in range(1,n+1): cnt*=i if n==m: print((cnt**2)%((10**9)+7)) if n-m==1: print(cnt*(cnt//m)%(10**9)+7) if m-n==1: print(cnt*cnt*(n+1)%(10**9)+7)
s226722335
Accepted
77
3,064
403
import sys n,m=map(int,input().split()) num=n mum=m if 2<=abs(n-m): print(0) sys.exit() if abs(n-m)==1: while n>1: num*=n-1 n-=1 num=num%((10**9)+7) while m>1: mum*=m-1 m-=1 mum=mum%((10**9)+7) print((num*mum)%((10**9)+7)) sys.exit() if abs(n-m)==0: while n>1: num*=n-1 n-=1...
s177055871
p03548
u798129018
2,000
262,144
Wrong Answer
27
2,940
114
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...
x,y,z = map(int,input().split()) ans = 1 while True: if ans*(y+z)+z>x: break else: ans += 1 print(ans)
s812863865
Accepted
26
2,940
118
x,y,z = map(int,input().split()) ans = 1 while True: if ans*(y+z)+z>x: break else: ans += 1 print(ans-1)
s145557624
p02336
u011621222
1,000
262,144
Wrong Answer
40
6,512
568
Balls| Boxes| Any way| At most one ball| At least one ball ---|---|---|---|--- Distinguishable| Distinguishable| 1| 2| 3 Indistinguishable| Distinguishable| 4| 5| 6 Distinguishable| Indistinguishable| 7| 8| 9 Indistinguishable| Indistinguishable| 10| 11| 12
# -*- coding: utf-8 -*- n,k = map(int, input().split()) def cmb(n, r, mod): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod mod = 10**7+7 N = 10**4 g1 = [1, 1] g2 = [1, 1] inverse = [0, 1] 計算用テーブル for i in range( 2, N + 1 ): g1.append( ( g1[-1] * i ) % m...
s706564298
Accepted
20
5,596
153
n,k = map(int, input().split()) if k > n: print(0) quit() ans = 1 for i in range(1,k): ans *= n-i ans //= i ans %= 1000000007 print(ans)
s112899634
p03448
u314350544
2,000
262,144
Wrong Answer
60
13,800
285
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()) b = int(input()) c = int(input()) x = int(input()) answer_values = [] for c_value in range(c): for b_value in range(b): for a_value in range(a): answer_values.append(c_value * 500 + b_value * 100 + a_value * 50) print(answer_values.count(x))
s717848380
Accepted
59
13,996
292
a = int(input()) b = int(input()) c = int(input()) x = int(input()) answer_values = [] for a_value in range(a + 1): for b_value in range(b+1): for c_value in range(c+1): answer_values.append(a_value * 500 + b_value * 100 + c_value * 50) print(answer_values.count(x))
s769947455
p03130
u667024514
2,000
1,048,576
Wrong Answer
89
3,444
205
There are four towns, numbered 1,2,3 and 4. Also, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally. No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roa...
from collections import Counter lis = [0 for i in range(4)] for i in range(3): a,b = map(int,input().split()) lis[a-1] += 1 lis[b-1] += 1 if lis.count(2) == 4: print("YES") else:print("NO")
s671464712
Accepted
17
2,940
97
print("YES") if sum([sum(list(map(int,input().split()))) for i in range(3)])==15 else print("NO")
s590088190
p04043
u053677958
2,000
262,144
Wrong Answer
153
12,420
291
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 ...
# coding: utf-8 import numpy as np if __name__ == "__main__": input_str = input("input >>> ") length_str = np.array([int(f) for f in input_str.split(" ")]) if np.sum(length_str == 5) and np.sum(length_str == 7): print("YES") else: print("NO")
s433002836
Accepted
155
12,512
291
# coding: utf-8 import numpy as np if __name__ == "__main__": input_str = input("") length_str = np.array([int(f) for f in input_str.split(" ")]) if np.sum(length_str == 5) == 2 and np.sum(length_str == 7) == 1: print("YES") else: print("NO")
s352649045
p03739
u597455618
2,000
262,144
Wrong Answer
112
14,464
433
You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through ...
n = int(input()) a = list(map(int, input().split())) check = '' if a[0] > 0: check = '+' else: check = '-' ans = 0 for i in range(1, n): a[i] += a[i-1] if check == '+': if a[i] >= 0: ans += abs(a[i]) + 1 a[i] -= abs(a[i]) + 1 check = '-' else: if a[i]...
s147000574
Accepted
88
14,332
323
N = int(input()) A = [int(x) for x in input().split()] def F(A, sgn): cnt = 0 cum = 0 for a in A: sgn *= -1 cum += a if cum * sgn > 0: continue if sgn > 0: cnt += 1 - cum cum = 1 else: cnt += cum + 1 cum = -1 return cnt answer = min(F(A,1), F(A,-1)) print(answ...
s360865491
p02936
u744920373
2,000
1,048,576
Wrong Answer
2,116
183,028
1,001
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operati...
import sys sys.setrecursionlimit(10**8) 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 li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] def dp2(ini, i, j): return [[ini]*i...
s814201599
Accepted
1,247
104,624
1,200
import sys 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 li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] def dp2(ini, i, j): return [[ini]*i for i2 in range(j)] def dp3(...
s758984599
p03493
u340947941
2,000
262,144
Wrong Answer
18
2,940
49
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(map(int,input().split(" "))) print(sum(S))
s238281975
Accepted
17
2,940
67
S=list(map(int,list(input()))) print(sum(S))
s763084714
p03605
u010110540
2,000
262,144
Wrong Answer
17
2,940
46
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
N = input() print('YES' if '9' in N else 'NO')
s494811713
Accepted
17
2,940
46
N = input() print('Yes' if '9' in N else 'No')
s489526985
p03371
u757919796
2,000
262,144
Wrong Answer
18
3,060
292
"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 = tuple(map(lambda i: int(i), input().split())) print(a+b,c*2) if a + b > c * 2: if a > c or b > c: print(c*y*2 if x<y else c*x*2) else: num_c = (x if x < y else y) * 2 print((b*(y-x) if x < y else a*(x-y)) + c*num_c) else: print(a*x + b*y)
s704850294
Accepted
17
3,060
254
a, b, c, x, y = tuple(map(lambda i: int(i), input().split())) p1 = a * x + b * y p2 = c * min(x, y) * 2 + (a * (x - y) if x > y else b * (y - x)) p3 = c*max(x, y)*2 print(min(p1, p2, p3))
s707811663
p03434
u245870380
2,000
262,144
Wrong Answer
17
2,940
91
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the c...
N = int(input()) a = list(map(int, input().split()))[::-1] print(sum(a[0::2])-sum(a[1::2]))
s632947721
Accepted
17
3,064
99
N = int(input()) a = sorted(list(map(int, input().split())))[::-1] print(sum(a[0::2])-sum(a[1::2]))
s867427921
p02601
u893178798
2,000
1,048,576
Wrong Answer
32
9,180
211
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successfu...
A, B, C = map(int, input().split()) K = int(input()) i = 0 while(not(A < B)): B = B * 2 i = i + 1 while(not(B < C)): C = C * 2 i = i + 1 print(i) if i <= K: print('Yes') else: print('No')
s661468951
Accepted
30
9,052
194
A, B, C = map(int, input().split()) K = int(input()) i = 0 while(A >= B): B = B * 2 i = i + 1 while(B >= C): C = C * 2 i = i + 1 if i <= K: print('Yes') else: print('No')
s445324966
p03971
u094999522
2,000
262,144
Wrong Answer
76
10,612
204
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from t...
n, a, b = map(int, input().split()) s = input() q = [1] * n for i,l in enumerate(s): q[i] *= (l == "b" and b > 0) or (l == "a" and a + b > 0) b -= q[i] print("".join(["YNeos"[1-i::2] for i in q]))
s944167198
Accepted
99
10,740
242
n, a, b = map(int, input().split()) s = input() q = [1] * n for i,l in enumerate(s): q[i] *= ((l == "b" and b > 0) or l == "a") and a + b > 0 b -= q[i]*(l == "b") a -= q[i]*(l == "a") print("\n".join(["YNeos"[1-i::2] for i in q]))
s561390358
p03359
u370867568
2,000
262,144
Wrong Answer
17
2,940
76
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For ...
a, b = map(int, input().split()) ans = a if b <= a: ans += 1 print(ans)
s182516853
Accepted
17
2,940
75
a, b = map(int, input().split()) ans = a if a > b: ans -= 1 print(ans)
s556060949
p03502
u945427450
2,000
262,144
Wrong Answer
18
2,940
73
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
n=input() s=0 for i in n: s+=int(i) print(['NO','YES'][int(n)%s==0])
s872144497
Accepted
17
2,940
73
n=input() s=0 for i in n: s+=int(i) print(['No','Yes'][int(n)%s==0])
s249849855
p03251
u188244611
2,000
1,048,576
Wrong Answer
18
3,064
330
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes incli...
# ABC 110 , B tmp = [int(el) for el in input().split(' ')] n = tmp[0] m = tmp[1] x = tmp[2] y = tmp[3] X = [int(el) for el in input().split(' ')] Y = [int(el) for el in input().split(' ')] for z in range(x+1, y+1): if max(X) < z and min(Y) >= z: print(z) print('No War') break else: pri...
s785176420
Accepted
18
3,064
313
# ABC 110 , B tmp = [int(el) for el in input().split(' ')] n = tmp[0] m = tmp[1] x = tmp[2] y = tmp[3] X = [int(el) for el in input().split(' ')] Y = [int(el) for el in input().split(' ')] for z in range(x+1, y+1): if max(X) < z and min(Y) >= z: print('No War') break else: print('War')
s434646128
p03024
u488178971
2,000
1,048,576
Wrong Answer
17
2,940
79
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S cons...
N=input() if N.count('o')+15-len(N) >=8: print('Yes') else: print('No')
s207010612
Accepted
17
2,940
79
N=input() if N.count('o')+15-len(N) >=8: print('YES') else: print('NO')
s470823573
p02401
u806005289
1,000
131,072
Wrong Answer
20
5,616
357
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.
x=[] i=0 while 1: l=input().split() a=int(l[0]) b=int(l[2]) op=str(l[1]) if op=="?": break elif op=="/": if b==0: pass else: x.append(eval(str(a)+op+str(b))) i=i+1 else: x.append(eval(str(a)+op+str(b))) i=i+1 m=0 w...
s451015991
Accepted
20
5,668
380
import math x=[] i=0 while 1: l=input().split() a=int(l[0]) b=int(l[2]) op=str(l[1]) if op=="?": break elif op=="/": if b==0: pass else: x.append(math.floor(eval(str(a)+op+str(b)))) i=i+1 else: x.append(eval(str(a)+op+str(b...
s834364864
p02742
u133527491
2,000
1,048,576
Wrong Answer
17
2,940
91
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*w/2!=h*w//2: print(h*w//2+1) exit() print(h*w/2)
s934530352
Accepted
17
2,940
133
h,w=map(int,input().split()) if h==1 or w==1: print(1) exit() if h*w/2!=h*w//2: print(h*w//2+1) exit() print(h*w//2)
s384430709
p02747
u143683072
2,000
1,048,576
Wrong Answer
17
2,940
84
A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string.
s = input() s.replace('hi', '') if len(s) == 0: print('Yes') else: print('No')
s329779414
Accepted
17
2,940
81
s = input() if len(s.replace('hi', '')) == 0: print('Yes') else: print('No')
s754421329
p03049
u970899068
2,000
1,048,576
Wrong Answer
55
4,716
506
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.
n=int(input()) s=[list(input()) for i in range(n)] count=0 countA=0 countB=0 countBA=0 for i in range(n): for j in range(len(s[i])-1): if s[i][j]=='A' and s[i][j+1]=='B': count+=1 for i in range(n): if s[i][0]=='B' and s[i][-1]=='A': countBA+=1 elif s[i][0]=='B': ...
s692304297
Accepted
52
4,596
604
n=int(input()) s=[list(input()) for i in range(n)] count=0 countA=0 countB=0 countBA=0 for i in range(n): for j in range(len(s[i])-1): if s[i][j]=='A' and s[i][j+1]=='B': count+=1 for i in range(n): if s[i][0]=='B' and s[i][-1]=='A': countBA+=1 elif s[i][0]=='B': ...
s065295951
p03150
u624696727
2,000
1,048,576
Wrong Answer
17
3,064
856
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
import sys 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 LI1(): return list(map(int1, sys.stdin.readline(...
s740269226
Accepted
18
3,064
919
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 LI1(): return list(map(int1, sys.stdin.readline(...
s542499814
p02261
u995990363
1,000
131,072
Wrong Answer
20
5,612
1,764
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubbl...
def bubbleSort(cards, N): flag = True while flag: flag = False for j in range(N-1, 0, -1): if cards.numbers[j] < cards.numbers[j - 1]: cards.swap(j, j-1) flag = True return cards def selectionSort(cards,N): for i in range(N): minj = i ...
s327336738
Accepted
20
5,616
1,746
def bubbleSort(cards, N): flag = True while flag: flag = False for j in range(N-1, 0, -1): if cards.numbers[j] < cards.numbers[j - 1]: cards.swap(j, j-1) flag = True return cards def selectionSort(cards,N): for i in range(N): minj = i ...
s695631096
p02261
u630566146
1,000
131,072
Wrong Answer
20
7,688
950
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubbl...
def is_stable(oline, line): for i in range(N): for j in range(i+1, N): for a in range(N): for b in range(a+1, N): if (oline[i][1] == oline[j][1]) & (oline[i] == line[b]) & (oline[j] == line[a]): return False return True N = int(inp...
s421497204
Accepted
210
7,828
952
def is_stable(oline, line): for i in range(N): for j in range(i+1, N): for a in range(N): for b in range(a+1, N): if (oline[i][1] == oline[j][1]) & (oline[i] == line[b]) & (oline[j] == line[a]): return False return True N = int(inp...
s319348491
p03449
u353895424
2,000
262,144
Wrong Answer
18
3,064
498
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 ...
def genSumList(l): n = len(l) ret = [] for i in range(1,n+1): tmp = 0 for j in range(i): tmp += l[j] ret.append(tmp) return ret n = int(input()) a = [] ans = [] for i in range(2): a.append(list(map(int, inp...
s691169051
Accepted
17
3,064
235
n = int(input()) a = [] for i in range(2): a.append(list(map(int, input().split()))) l = [] for i in range(1,n): l.append(sum(a[0][:i]) + sum(a[1][i-1:])) if len(l) == 0: print(a[0][0] + a[1][0]) exit() print(max(l))
s254156792
p02389
u715278210
1,000
131,072
Wrong Answer
20
5,576
76
Write a program which calculates the area and perimeter of a given rectangle.
a,b = map(int, input().split()) hirosa = a*b nagasa = 2*(a+b) hirosa,nagasa
s766474937
Accepted
20
5,576
63
a,b = map(int, input().split()) x = a*b y = 2*(a+b) print(x,y)
s169071007
p03610
u733167185
2,000
262,144
Wrong Answer
55
3,828
87
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 = input() for i in range(len(s)): if i % 2 == 0: print(s[i])
s441144126
Accepted
18
3,188
46
s = input() s = s[::2] print(s)
s482388409
p02694
u003505857
2,000
1,048,576
Wrong Answer
30
9,160
92
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or abo...
x = int(input()) a = 100 ans = 0 while a <= x: a = int(a * 1.01) ans += 1 print(ans)
s109871595
Accepted
29
9,056
117
x = int(input()) money = 100 count = 0 while money < x: money = (money * 101) // 100 count += 1 print(count)
s645495809
p03447
u798316285
2,000
262,144
Wrong Answer
17
2,940
54
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
x,a,b=[int(input()) for i in range(3)] print((x-a)//b)
s309315284
Accepted
17
2,940
53
x,a,b=[int(input()) for i in range(3)] print((x-a)%b)
s012896576
p02659
u127981515
2,000
1,048,576
Wrong Answer
21
9,164
58
Compute A \times B, truncate its fractional part, and print the result as an integer.
A,B=input().split() a=int(A) b=float(B) print(int(a*b/10))
s344144752
Accepted
26
10,068
87
from decimal import Decimal A,B=input().split() a=int(A) b=Decimal(B) print(int(a*b))
s595473668
p03408
u649558044
2,000
262,144
Wrong Answer
17
3,064
338
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()) s = [input() for _ in range(n)] m = int(input()) t = [input() for _ in range(m)] cnt_dict = {} for si in s: cnt_dict[si] = 0 for ti in t: cnt_dict[ti] = 0 for si in s: cnt_dict[si] += 1 for ti in t: cnt_dict[ti] -= 1 score = 0 for cnt in cnt_dict.values(): if cnt > 0: score +...
s690558777
Accepted
18
3,064
286
n = int(input()) s = [input() for _ in range(n)] m = int(input()) t = [input() for _ in range(m)] cnt_dict = {} for si in s: cnt_dict[si] = 0 for ti in t: cnt_dict[ti] = 0 for si in s: cnt_dict[si] += 1 for ti in t: cnt_dict[ti] -= 1 print(max(max(cnt_dict.values()), 0))
s373578057
p03997
u984730891
2,000
262,144
Wrong Answer
20
3,316
73
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)
s154911810
Accepted
17
2,940
78
a = int(input()) b = int(input()) h = int(input()) print(int((a + b) * h / 2))
s201420183
p03607
u921168761
2,000
262,144
Time Limit Exceeded
2,104
7,388
249
You are playing the following game with Joisino. * Initially, you have a blank sheet of paper. * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. * Then, you are asked a question: How many...
N = int(input()) A = [] for _ in range(N): A.append(int(input())) A.sort() ans = 0 idx = 0 while idx < N: sub = 0 while idx + sub < N and A[idx] == A[idx + sub]: sub = sub + 1 if sub % 2 == 1: ans = ans + 1 print(ans)
s769857950
Accepted
300
7,388
269
N = int(input()) A = [] for _ in range(N): A.append(int(input())) A.sort() ans = 0 idx = 0 while idx < N: sub = 0 while idx + sub < N and A[idx] == A[idx + sub]: sub = sub + 1 if sub % 2 == 1: ans = ans + 1 idx = idx + sub print(ans)
s049923818
p04030
u126844573
2,000
262,144
Wrong Answer
17
2,940
87
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this stri...
s = input() print(*[s[q] if s[q] != "B" else chr(0x08) for q in range(len(s))], sep="")
s864358678
Accepted
17
2,940
160
s, s_back = input(), "" while "B" in s: s = s.replace("1B", "").replace("0B", "") if s_back == s: break s_back = s print(s.replace("B", ""))
s801762751
p03713
u830054172
2,000
262,144
Wrong Answer
439
18,968
638
There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying...
H, W = list(map(int, input().split())) ans = [] for i in range(1, H+1): area1 = W*i area2 = (H-i)//2*W area3 = (H-(H-i)//2)*W area4 = (H-i)*(W//2) area5 = (H-i)*(W-(W//2)) ans.append(max(area1, area2, area3)-min(area1, area2, area3)) ans.append(max(area1, area4, area5)-min(area1, area4, ar...
s268663730
Accepted
477
18,928
842
H, W = list(map(int, input().split())) ans = [] for i in range(1, H): area1 = W*i area2 = (H-i)//2*W area3 = (H-(H-i)//2-i)*W area4 = (H-i)*(W//2) area5 = (H-i)*(W-(W//2)) if area1 != 0 or area2 != 0 or area3 !=0: ans.append(max(area1, area2, area3)-min(area1, area2, area3)) if are...
s434403955
p02841
u311636831
2,000
1,048,576
Wrong Answer
19
2,940
100
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()) if(A==B): print(0) else: print(1)
s020502698
Accepted
20
3,060
100
A,B=map(int,input().split()) C,D=map(int,input().split()) if(A==C): print(0) else: print(1)
s106706628
p03943
u911575040
2,000
262,144
Wrong Answer
17
2,940
125
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=[] a=list(map(int,input().split(' '))) a.sort() if a[0]+a[1]==a[2]: print('YES') elif a[0]+a[1]!=a[2]: print('NO')
s262858794
Accepted
17
2,940
111
a, b, c = map(int, input().split()) if a == b + c or a + b == c or a + c == b: print('Yes') else: print('No')
s957637120
p03693
u538956308
2,000
262,144
Wrong Answer
17
3,064
99
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()) ans = r*100+g*10+b if ans%4==0: print("Yes") else: print("No")
s365784740
Accepted
17
2,940
105
r, g, b = map(int,input().split()) n = r*100+g*10+b if n % 4 == 0: print('YES') else: print('NO')
s136810538
p03814
u319690708
2,000
262,144
Wrong Answer
17
3,512
63
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends w...
N = str(input()) a = N.find("a") z = N.rfind("z") print(z-a+1)
s145733891
Accepted
17
3,500
62
N = str(input()) a = N.find("A") z = N.rfind("Z") print(z-a+1)
s247762122
p03407
u693105608
2,000
262,144
Wrong Answer
28
9,020
96
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
a, b, c = list(map(int, input().split())) if (a+b) <= c: print("Yes") else: print("No")
s689399355
Accepted
30
9,100
97
a, b, c = list(map(int, input().split())) if c <= (a+b): print("Yes") else: print("No")
s017548721
p03712
u787562674
2,000
262,144
Wrong Answer
19
3,316
309
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 = map(int, input().split()) input_list = [[i for i in input()] for j in range(H)] option = ["#"]*(W+2) input_list.insert(0, option) input_list.append(option) for i in range(1, H+1): input_list[i].insert(0, "#") input_list[i].append("#") for i in range(H+2): print(" ".join(input_list[i]))
s262695589
Accepted
18
3,060
308
H, W = map(int, input().split()) input_list = [[i for i in input()] for j in range(H)] option = ["#"]*(W+2) input_list.insert(0, option) input_list.append(option) for i in range(1, H+1): input_list[i].insert(0, "#") input_list[i].append("#") for i in range(H+2): print("".join(input_list[i]))
s173315332
p03493
u004025573
2,000
262,144
Wrong Answer
17
2,940
47
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=list(map(int,input().split())) print(sum(A))
s777902879
Accepted
17
2,940
53
A=int(input()) print(A//100+(A%100)//10+(A%100)%10)
s603102338
p03095
u537782349
2,000
1,048,576
Wrong Answer
31
3,956
102
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...
a = int(input()) b = list(input()) c = {} for i in range(a): if b[i] not in c: c[b[i]] = 1
s959871878
Accepted
43
3,188
207
a = int(input()) b = input() c = {} for i in range(a): if b[i] not in c: c[b[i]] = 1 else: c[b[i]] += 1 d = 1 for k in c.keys(): d = (d * (c[k] + 1)) % (10 ** 9 + 7) print(d - 1)
s757377220
p03408
u265608204
2,000
262,144
Wrong Answer
247
12,624
449
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...
from collections import Counter import numpy as np a = int(input()) a_list = [] b_list = [] for i in range(a): a_list.append(input()) a_list.append('null') b = int(input()) for i in range(b): b_list.append(input()) a_count = Counter(a_list) b_count = Counter(b_list) a_list_no_overlap = set(a_list) print(a_count...
s883246819
Accepted
147
12,504
441
from collections import Counter import numpy as np a = int(input()) a_list = [] b_list = [] for i in range(a): a_list.append(input()) b = int(input()) for i in range(b): b_list.append(input()) a_count = Counter(a_list) b_count = Counter(b_list) a_list_no_overlap = set(a_list) point = [] for i in a_list_no_over...