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
s003824747
p02936
u111392182
2,000
1,048,576
Wrong Answer
1,471
27,504
261
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: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations.
n,q = list(map(int,input().split())) r = [0]*n ans = [0]*n for i in range(n-1): a,b = list(map(int,input().split())) r[b-1] = a-1 for j in range(q): p,x = list(map(int,input().split())) ans[p-1] += x for k in range(1,n): ans[k] += ans[r[k]] print(ans)
s072675240
Accepted
1,808
55,828
360
n,q = map(int,input().split()) g=[[] for _ in range(n)] ans = [0]*n for i in range(n-1): a,b=map(int,input().split()) g[a-1].append(b-1) g[b-1].append(a-1) for j in range(q): p,x = list(map(int,input().split())) ans[p-1] += x f=[1]*n t=[0] while t: v=t.pop() f[v]=0 for k in g[v]: if f[k]: ans[k]+=ans[v] t.append(k) print(*ans)
s121623413
p03436
u207799478
2,000
262,144
Wrong Answer
30
3,832
1,596
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares. Before Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game. When the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares. The color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is `.`; if square (i, j) is initially painted by black, s_{i, j} is `#`.
import math import string import collections from collections import Counter from collections import deque def readints(): return list(map(int, input().split())) def nCr(n, r): return math.factorial(n)//(math.factorial(n-r)*math.factorial(r)) def has_duplicates2(seq): seen = [] for item in seq: if not(item in seen): seen.append(item) return len(seq) != len(seen) def divisor(n): divisor = [] for i in range(1, n+1): if n % i == 0: divisor.append(i) return divisor # coordinates dx = [-1, -1, -1, 0, 0, 1, 1, 1] dy = [-1, 0, 1, -1, 1, -1, 0, 1] H, W = map(int, input().split()) white = 0 w = [None]*H for i in range(H): w[i] = input() # print(w[i]) for i in range(H): for j in range(W): if w[i][j] == '.': white += 1 #print("white", white) d = deque() d.append((0, 0)) dist = [None]*H for i in range(H): dist[i] = [None]*W dist[0][0] = 0 cost = -1 while(len(d) != 0): g, r = d.popleft() cost = max(cost, dist[g][r]) if w[g][r] == '.': if g != 0 and dist[g-1][r] == None: dist[g-1][r] = dist[g][r]+1 d.append((g-1, r)) if g != H-1 and dist[g+1][r] == None: dist[g+1][r] = dist[g][r]+1 d.append((g+1, r)) if r != 0 and dist[g][r-1] == None: dist[g][r-1] = dist[g][r]+1 d.append((g, r-1)) if r != W-1 and dist[g][r+1] == None: dist[g][r+1] = dist[g][r]+1 d.append((g, r+1)) print(white-(cost-1)) # print(cost)
s748168855
Accepted
29
3,832
1,681
import math import string import collections from collections import Counter from collections import deque def readints(): return list(map(int, input().split())) def nCr(n, r): return math.factorial(n)//(math.factorial(n-r)*math.factorial(r)) def has_duplicates2(seq): seen = [] for item in seq: if not(item in seen): seen.append(item) return len(seq) != len(seen) def divisor(n): divisor = [] for i in range(1, n+1): if n % i == 0: divisor.append(i) return divisor # coordinates dx = [-1, -1, -1, 0, 0, 1, 1, 1] dy = [-1, 0, 1, -1, 1, -1, 0, 1] H, W = map(int, input().split()) white = 0 w = [None]*H for i in range(H): w[i] = input() # print(w[i]) for i in range(H): for j in range(W): if w[i][j] == '.': white += 1 #print("white", white) d = deque() d.append((0, 0)) dist = [None]*H for i in range(H): dist[i] = [None]*W dist[0][0] = 0 cost = 100 while(len(d) != 0): g, r = d.popleft() if w[g][r] == '.': if g != 0 and dist[g-1][r] == None: dist[g-1][r] = dist[g][r]+1 d.append((g-1, r)) if g != H-1 and dist[g+1][r] == None: dist[g+1][r] = dist[g][r]+1 d.append((g+1, r)) if r != 0 and dist[g][r-1] == None: dist[g][r-1] = dist[g][r]+1 d.append((g, r-1)) if r != W-1 and dist[g][r+1] == None: dist[g][r+1] = dist[g][r]+1 d.append((g, r+1)) if H-1 == g and W-1 == r: cost = min(cost, dist[g][r]) print(white-(cost+1)) exit() if dist[H-1][W-1] == None: print(-1)
s848379520
p02678
u076245995
2,000
1,048,576
Wrong Answer
799
69,900
602
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 the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
from collections import defaultdict from collections import deque N, M = map(int,input().split()) sign = defaultdict(set) for i in range(M): A_i, B_i = map(int, input().split()) sign[A_i].add(B_i) sign[B_i].add(A_i) seen = [False for _ in range(N)] cost = [0 for _ in range(N)] ans = [0 for _ in range(N)] q = deque() q.append(1) seen[1 - 1] = True while len(q) > 0: room = q.pop() for j in sign[room]: if not seen[j - 1]: q.append(j) ans[j - 1], seen[j - 1] = room, True if False in seen: print("No") else: ans[0] = "Yes" print(ans)
s704743241
Accepted
845
68,776
535
from collections import defaultdict from collections import deque N, M = map(int, input().split()) route = defaultdict(set) for i in range(M): A_i, B_i = map(int, input().split()) route[A_i].add(B_i) route[B_i].add(A_i) q = deque() q.append(1) seen = [-1] * (N + 1) seen[0], seen[1] = 0, 0 while len(q) > 0: now = q.popleft() for i in route[now]: if seen[i] == -1: q.append(i) seen[i] = now if -1 in seen: print("No") else: seen[1] = "Yes" print(*seen[1:], sep="\n")
s951502026
p03387
u299801457
2,000
262,144
Wrong Answer
21
3,064
217
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
a,b,c=list(map(int,input().split())) mi=min([a,b,c]) ma=max([a,b,c]) mid=a+b+c-mi-ma ans=0 if (mid-mi)%2==1: ans+=1 ma+=1 mi+=1 ans+=(mid-mi)/2 ans+=ma-mid else: ans+=(mid-mi)/2 ans+=ma-mid
s917018202
Accepted
17
3,064
234
a,b,c=list(map(int,input().split())) mi=min([a,b,c]) ma=max([a,b,c]) mid=a+b+c-mi-ma ans=0 if (mid-mi)%2==1: ans+=1 ma+=1 mi+=1 ans+=(mid-mi)/2 ans+=ma-mid else: ans+=(mid-mi)/2 ans+=ma-mid print(int(ans))
s029385662
p03435
u957198490
2,000
262,144
Wrong Answer
17
3,064
252
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) is equal to a_i + b_j. Determine if he is correct.
c = [list(map(int,input().split())) for _ in range(3)] b = c[0] a = [0] for i in range(1,3): a.append(c[i][i]-b[i]) for i in range(3): for j in range(3): if c[i][j] != a[i] + b[j]: print('NO') exit() print('YES')
s119478946
Accepted
18
3,064
252
c = [list(map(int,input().split())) for _ in range(3)] b = c[0] a = [0] for i in range(1,3): a.append(c[i][i]-b[i]) for i in range(3): for j in range(3): if c[i][j] != a[i] + b[j]: print('No') exit() print('Yes')
s409584928
p03545
u441191580
2,000
262,144
Wrong Answer
20
3,188
748
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 input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
x = input().split() x = [int(i) for i in x] xCount = len(x) aaa = 0 for i in range(2**(xCount -1)): binaryNumber = format(i,'b') binaryNumber = binaryNumber.zfill(xCount-1) binaryNumber = list(binaryNumber) binaryNumber = [int(i) for i in binaryNumber] for i in range(xCount-1): if binaryNumber[i] == 1 : binaryNumber[i] = '+' if binaryNumber[i] == 0 : binaryNumber[i] = '-' result = [None]*(len(x)+len(binaryNumber)) result[::2] = x result[1::2] = binaryNumber result = map(str, result) resultStr = ''.join(result) a = eval(resultStr) if (a == 7) : print(resultStr + '=' + str(a)) break
s579845607
Accepted
18
3,064
919
x = input() x = [int(i) for i in x] xCount = len(x) aaa = 0 for i in range(2**(xCount -1)): binaryNumber = format(i,'b') binaryNumber = binaryNumber.zfill(xCount-1) binaryNumber = list(binaryNumber) binaryNumber = [int(i) for i in binaryNumber] for i in range(xCount-1): if binaryNumber[i] == 1 : binaryNumber[i] = '+' if binaryNumber[i] == 0 : binaryNumber[i] = '-' result = [] for i in range(xCount): result.append(x[i]) if i < (xCount -1): result.append(binaryNumber[i]) #result = [None]*(len(x)+len(binaryNumber)) #result[::2] = x #result[1::2] = binaryNumber result = map(str, result) resultStr = ''.join(result) a = eval(resultStr) #print(resultStr) #print(a) if (a == 7) : print(str(resultStr) + '=7') break
s636546129
p02603
u723792785
2,000
1,048,576
Wrong Answer
27
9,140
94
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows: * A_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day. In the i-th day, M-kun can make the following trade **any number of times** (possibly zero), **within the amount of money and stocks that he has at the time**. * Buy stock: Pay A_i yen and receive one stock. * Sell stock: Sell one stock for A_i yen. What is the maximum possible amount of money that M-kun can have in the end by trading optimally?
_,*a=map(int,open(0).read().split());x=1000 for i,j in zip(a,a[1:]): if j>i:x=x//i*j print(x)
s027901247
Accepted
27
9,152
96
_,*a=map(int,open(0).read().split());x=1000 for i,j in zip(a,a[1:]):x+=x//i*(j-i)*(j>i) print(x)
s281368711
p02841
u610387229
2,000
1,048,576
Wrong Answer
17
2,940
185
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.
def mainFunc(): m1, d1 = list(map(int, list(input().split(" ")))) m2, d2 = list(map(int, list(input().split(" ")))) ans = '1' if m1 == m2 else '0' print(ans) mainFunc()
s374621005
Accepted
17
2,940
185
def mainFunc(): m1, d1 = list(map(int, list(input().split(" ")))) m2, d2 = list(map(int, list(input().split(" ")))) ans = '1' if m1 != m2 else '0' print(ans) mainFunc()
s149540796
p02865
u941022948
2,000
1,048,576
Wrong Answer
17
2,940
71
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
a=int(input()) if a%2==0: ans=(a/2)-1 else: ans=a//2 print(ans)
s902749096
Accepted
17
2,940
76
a=int(input()) if a%2==0: ans=(a/2)-1 else: ans=a//2 print(int(ans))
s459625745
p03455
u898042052
2,000
262,144
Wrong Answer
17
2,940
98
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a, b = (int(i) for i in input().split()) if a % b == 0: print("Even") else: print("Odd")
s802538177
Accepted
17
2,940
102
a, b = (int(i) for i in input().split()) if a * b % 2 == 0: print("Even") else: print("Odd")
s026854563
p02578
u512623857
2,000
1,048,576
Wrong Answer
144
32,236
208
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 person includes the stool. Find the minimum total height of the stools needed to meet this goal.
#ABC177 C N = int(input()) A = list(map(int,input().split())) max = A[0] F = [0] for i in range(1,N): if max > A[i]: F.append(max - A[i]) else: max = A[i] F.append(0) print(F) print(sum(F))
s539615331
Accepted
123
32,244
199
#ABC177 C N = int(input()) A = list(map(int,input().split())) max = A[0] F = [0] for i in range(1,N): if max > A[i]: F.append(max - A[i]) else: max = A[i] F.append(0) print(sum(F))
s664500198
p03079
u059210959
2,000
1,048,576
Wrong Answer
170
13,600
243
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
# encoding:utf-8 import copy import numpy as np import random import bisect a,b,c = map(int,input().split()) if (a==b and b ==c): print("Yse") else: print("No")
s509213563
Accepted
176
13,672
236
# encoding:utf-8 import copy import numpy as np import random import bisect a,b,c = map(int,input().split()) if (a==b and b==c): print("Yes") else: print("No")
s269279086
p02414
u017435045
1,000
131,072
Wrong Answer
20
5,600
361
Write a program which reads a $n \times m$ matrix $A$ and a $m \times l$ matrix $B$, and prints their product, a $n \times l$ matrix $C$. An element of matrix $C$ is obtained by the following formula: \\[ c_{ij} = \sum_{k=1}^m a_{ik}b_{kj} \\] where $a_{ij}$, $b_{ij}$ and $c_{ij}$ are elements of $A$, $B$ and $C$ respectively.
n, m, l = map(int, input().split()) a = [] b = [] for i in range(n): a.append(list(map(int, input().split()))) for j in range(m): b.append(list(map(int, input().split()))) c = [[0 for k in range(l)] for i in range(n)] for i in range(n): for k in range(l): c[i][k]=sum([a[i][j]*b[j][k] for j in range(m)]) for i in range(n): print(c[i])
s787398230
Accepted
130
7,008
232
n, m, l = map(int, input().split()) a = [list(map(int, input().split())) for i in range(n)] b = [list(map(int, input().split())) for j in range(m)] [print(*x) for x in [[sum(j*k for j, k in zip(x, y)) for y in zip(*b)] for x in a]]
s060504478
p02394
u628732336
1,000
131,072
Wrong Answer
40
7,468
157
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.
W, H, x, y, r = [int(1) for i in input().split()] if x <= 0 or y <=0: print("No") elif W - x >= r and H - y >= r: print("Yes") else: print("No")
s710374461
Accepted
20
7,716
149
W, H, x, y, r = [int(i) for i in input().split()] if x + r <= W and y - r >= 0 and x - r >= 0 and y + r <= H: print("Yes") else: print("No")
s913266726
p02308
u022407960
1,000
131,072
Wrong Answer
30
7,800
1,710
For given a circle $c$ and a line $l$, print the coordinates of the cross points of them.
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 2 1 1 2 0 1 4 1 3 0 3 3 output: 1.00000000 1.00000000 3.00000000 1.00000000 3.00000000 1.00000000 3.00000000 1.00000000 """ import sys import math class Segment(object): __slots__ = ('source', 'target') def __init__(self, source, target): self.source = complex(source) self.target = complex(target) class Circle(object): __slots__ = ('centre', 'radius') def __init__(self, x, y, r): self.centre = x + y * 1j self.radius = r def dot(a, b): return a.real * b.real + a.imag * b.imag def project(s, p): base_vector = s.target - s.source prj_ratio = dot(p - s.source, base_vector) / pow(abs(base_vector), 2) return s.source + base_vector * prj_ratio def get_cross_point(c, l): prj_vector = project(l, c.centre) line_unit_vector = (l.target - l.source) / (abs(l.target - l.source)) base = math.sqrt(pow(c.radius, 2) - pow(abs(prj_vector - c.centre), 2)) return prj_vector + line_unit_vector * base, prj_vector - line_unit_vector * base def solve(_lines): for line in _lines: line_axis = tuple(map(int, line)) p0, p1 = (x + y * 1j for x, y in zip(line_axis[::2], line_axis[1::2])) l = Segment(p0, p1) cross_pair = get_cross_point(circle, l) cp1, cp2 = cross_pair print('{0:.6f} {1:.6f} {2:.6f} {3:.6f}'.format(cp1.real, cp1.imag, cp2.real, cp2.imag)) return None if __name__ == '__main__': _input = sys.stdin.readlines() cx, cy, radius = map(int, _input[0].split()) q_num = int(_input[1]) lines = map(lambda x: x.split(), _input[2:]) circle = Circle(cx, cy, radius) solve(lines)
s756602147
Accepted
30
8,232
1,615
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 2 1 1 2 0 1 4 1 3 0 3 3 output: 1.00000000 1.00000000 3.00000000 1.00000000 3.00000000 1.00000000 3.00000000 1.00000000 """ import math import sys from operator import attrgetter from collections import namedtuple def dot(a, b): return a.real * b.real + a.imag * b.imag def project(s, p): base_vector = s.target - s.source prj_ratio = dot(p - s.source, base_vector) / pow(abs(base_vector), 2) return s.source + base_vector * prj_ratio def get_cross_point(c, l): prj_vector = project(l, c.centre) line_unit_vector = (l.target - l.source) / (abs(l.target - l.source)) base = math.sqrt(pow(c.radius, 2) - pow(abs(prj_vector - c.centre), 2)) ans = [prj_vector + line_unit_vector * base, prj_vector - line_unit_vector * base] ans.sort(key=attrgetter('real', 'imag')) return ans def solve(_lines): for line in _lines: line_axis = tuple(map(int, line)) p0, p1 = (x + y * 1j for x, y in zip(line_axis[::2], line_axis[1::2])) l = Segment(source=p0, target=p1) cp1, cp2 = get_cross_point(circle, l) print('{0:.8f} {1:.8f} {2:.8f} {3:.8f}'.format(cp1.real, cp1.imag, cp2.real, cp2.imag)) return None if __name__ == '__main__': _input = sys.stdin.readlines() cx, cy, r = map(int, _input[0].split()) q_num = int(_input[1]) lines = map(lambda x: x.split(), _input[2:]) Circle = namedtuple('Circle', ('centre', 'radius')) Segment = namedtuple('Segment', ('source', 'target')) circle = Circle(centre=cx + cy * 1j, radius=r) solve(lines)
s181836373
p03719
u969227451
2,000
262,144
Wrong Answer
26
9,140
90
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=(int(x)for x in input().split()) if a<=c<=b: print("YES") else: print("NO")
s761127517
Accepted
26
8,884
82
a,b,c=map(int,input().split()) if a<=c<=b: print("Yes") else: print("No")
s721122594
p03693
u855665975
2,000
262,144
Wrong Answer
17
2,940
104
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 integer a multiple of 4?
r,g,b = map(int, input().split()) if (r*100) + (g*10) + b % 4 == 0: print("YES") else: print("NO")
s502831634
Accepted
17
2,940
107
r,g,b = map(int, input().split()) if ((r*100) + (g*10) + b) % 4 == 0: print("YES") else: print("NO")
s419110214
p02612
u163874353
2,000
1,048,576
Wrong Answer
29
9,104
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(1000 - n)
s238433689
Accepted
28
9,116
80
n = int(input()) if n % 1000 == 0: print(0) else: print(1000 - n % 1000)
s561430302
p02262
u193453446
6,000
131,072
Wrong Answer
30
7,900
2,132
Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i]) A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$. Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m − 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements: * $1 \leq m \leq 100$ * $0 \leq G_i \leq n$ * cnt does not exceed $\lceil n^{1.5}\rceil$
#!/usr/bin/env python # -*- coding: utf-8 -*- import math def swap(A, x, y): t = A[x] A[x] = A[y] A[y] = t def insertionSort(A, n, g): """ ?????\????????? """ cnt = 0 print(A) for i in range(g, n, g): v = A[i] j = i - g while j >=0 and A[j] > v: A[j+g] = A[j] j = j - g cnt += 1 A[j+g] = v return cnt def shellSort(A, n): cnt = 0 G = [] i = 1 while i < n: G.insert(0,i) i = i * 3 + 1 m = len(G) for i in range(0, m): cnt += insertionSort(A, n, G[i]) print(m) print(" ".join(map(str,G))) print(cnt) for i in A: print(i) # ????????? n = int(input().strip()) a = [] for i in range(n): a.append(int(input().strip())) shellSort(a,n)
s124772451
Accepted
21,000
47,484
1,990
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys def insertionSort(A, n, g): """ ?????\????????? """ c = 0 for i in range(g, n): v = A[i] j = i - g while j >=0 and A[j] > v: A[j+g] = A[j] j = j - g c += 1 A[j+g] = v return c def shellSort(A, n): cnt = 0 G = [] i = 1 while i <= n: G.insert(0,i) i = i * 3 + 1 m = len(G) for i in range(0, m): cnt += insertionSort(A, n, G[i]) # ?????? print(m) print(" ".join(map(str,G))) print(cnt) for i in A: print(i) # ????????? n = int(input().strip()) a = [] for i in range(n): a.append(int(input().strip())) shellSort(a,n)
s009539391
p03455
u915355756
2,000
262,144
Wrong Answer
18
3,064
254
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
N = 1 data = [] for i in range(N): data_input = list(map(int,input().split())) data.append(data_input) M = 1 print(data) if data[0][0]//2 == 0: print('Even') else: if data[0][1]//2 ==0: print('Even') else: print('Odd')
s046594499
Accepted
17
3,060
240
N = 1 data = [] for i in range(N): data_input = list(map(int,input().split())) data.append(data_input) M = 1 if data[0][0]%2 == 0: print('Even') else: if data[0][1]%2 ==0: print('Even') else: print('Odd')
s391767333
p03797
u143278390
2,000
262,144
Wrong Answer
17
2,940
87
Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
n,m=[int(i) for i in input().split()] if(n*2>=m): print(m//n) '''else: m-n*2'''
s999066278
Accepted
17
2,940
65
n,m=[int(i) for i in input().split()] print(min(m//2,(2*n+m)//4))
s327219309
p03473
u248192265
2,000
262,144
Wrong Answer
19
2,940
29
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
M = int(input()) print (24-M)
s756611612
Accepted
17
2,940
32
M = int(input()) print (24-M+24)
s637146649
p03997
u159975271
2,000
262,144
Wrong Answer
17
2,940
77
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()) k = (a + b)* h /2 print(k)
s168124621
Accepted
17
2,940
84
a = int(input()) b = int(input()) h = int(input()) k = (a + b)* h /2 print(round(k))
s305073476
p02606
u000875186
2,000
1,048,576
Wrong Answer
27
9,076
234
How many multiples of d are there among the integers between L and R (inclusive)?
stir=input() lst=stir.split(" ") l=int(lst[0]) r=int(lst[1]) t=lst[2] b=1 x=0 multiples=[] while(b<100): multiples.append(int(t)*b) b+=1 for a in range(l, r): for m in multiples: if(m==a): x+=1 print(x)
s550672627
Accepted
29
9,156
236
stir=input() lst=stir.split(" ") l=int(lst[0]) r=int(lst[1]) t=lst[2] b=1 x=0 multiples=[] while(b<101): multiples.append(int(t)*b) b+=1 for a in range(l, r+1): for m in multiples: if(m==a): x+=1 print(x)
s829214527
p02678
u721407235
2,000
1,048,576
Wrong Answer
795
40,144
438
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 the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
from collections import deque N,M=map(int,input().split()) arr=[[] for n in range(N)] que=deque([1]) for m in range(M): a,b=map(int,input().split()) arr[a-1].append(b) arr[b-1].append(a) dist=[-1]*N dist[0]=0 arr2=[0]*(N-1) print("Yes") while que: c=que.popleft() for i in arr[c-1]: if dist[i-1]!=-1: continue dist[i-1]=0 arr2[i-2]=c que.append(i) print(arr) for i in arr2: print(i)
s899152017
Accepted
630
34,820
427
from collections import deque N,M=map(int,input().split()) arr=[[] for n in range(N)] que=deque([1]) for m in range(M): a,b=map(int,input().split()) arr[a-1].append(b) arr[b-1].append(a) dist=[-1]*N dist[0]=0 arr2=[0]*(N-1) print("Yes") while que: c=que.popleft() for i in arr[c-1]: if dist[i-1]!=-1: continue dist[i-1]=0 arr2[i-2]=c que.append(i) for i in arr2: print(i)
s247565032
p03129
u834153484
2,000
1,048,576
Wrong Answer
17
2,940
180
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
A, B = map(int, input().split()) if A%2==0: if A/2 >= B: print("Yes") else: print("No") else: if (A+1)/2 >= B: print("Yes") else: print("No")
s645628191
Accepted
17
2,940
180
A, B = map(int, input().split()) if A%2==0: if A/2 >= B: print("YES") else: print("NO") else: if (A+1)/2 >= B: print("YES") else: print("NO")
s760888010
p03606
u513081876
2,000
262,144
Wrong Answer
20
3,060
104
Joisino is working as a receptionist at a theater. The theater has 100000 seats, numbered from 1 to 100000. According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive). How many people are sitting at the theater now?
N = int(input()) ans = 0 for i in range(N): l, r = map(int, input().split()) ans += r - l print(ans)
s900500988
Accepted
20
2,940
108
N = int(input()) ans = 0 for i in range(N): l, r = map(int, input().split()) ans += r - l + 1 print(ans)
s438602187
p03478
u699944218
2,000
262,144
Wrong Answer
33
3,060
139
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 = list(map(int, input().split())) res = 0 for i in range(N+1): if A <= sum([int(s) for s in str(i)]) <=B: res += 1 print(res)
s753686043
Accepted
33
2,940
138
N, A, B = list(map(int, input().split())) res = 0 for i in range(N+1): if A <= sum(int(s) for s in str(i)) <= B: res += i print(res)
s173938667
p03659
u116002573
2,000
262,144
Wrong Answer
270
34,472
340
Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it. They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card. Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively. They would like to minimize |x-y|. Find the minimum possible value of |x-y|.
def main(): n = int(input()) A = list(map(int, input().split())) filled = [0]*(n+1) ans = [] for i in range(n-1, -1, -1): if sum(filled[::i+1][1:]) % 2 != A[i]: filled[i+1] = 1 ans.append(i+1) print(len(ans)) print(' '.join(map(str, ans))) if __name__ == '__main__': main()
s753914650
Accepted
146
23,800
276
def main(): N = int(input()) A = [int(a) for a in input().split()] v = 0 tot = sum(A) min_d = float('inf') for i in range(N-1): v += A[i] min_d = min(min_d, abs(tot - 2*v)) return min_d if __name__ == '__main__': print(main())
s655655671
p02694
u853728588
2,000
1,048,576
Wrong Answer
23
9,024
90
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 above for the first time?
x = int(input()) total = 100 while total >= x: if total < x: total = total * 1.01
s180878058
Accepted
28
9,160
125
import math x = int(input()) initial = 100 count = 0 while initial < x: initial += initial//100 count += 1 print(count)
s190697181
p02408
u351754662
1,000
131,072
Wrong Answer
20
5,596
205
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.
n = int(input()) cards = {} for i in range(n): card = input() cards[card] = 1 for c in ['s','H','C','D']: for n in range(1,14): key = c + ' ' +str(n) if not key in cards: print(key)
s178591174
Accepted
20
5,600
208
n = int(input()) cards = {} for i in range(n): card = input() cards[card] = 1 for c in ['S', 'H', 'C', 'D']: for n in range(1,14): key = c + ' ' + str(n) if not key in cards: print(key)
s308634648
p02694
u253389610
2,000
1,048,576
Wrong Answer
25
9,192
289
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 above for the first time?
X = int(input()) x = divmod(X, 100) a = [1, 0] y = 0 while x[0] > a[0]: ya = 99-a[1] // a[0] a[1] += a[0]*ya y += ya a[1] += a[0] i, a[1] = divmod(a[1], 100) a[0] += i y += 1 while x[0] == a[0] and x[0] > a[0]: i, a[1] = divmod(a[1]+a[0], 100) a[0] += i y += 1 print(y)
s814220180
Accepted
24
9,108
241
def main(): X = int(input()) x = divmod(X, 100) a = [1, 0] y = 0 while a[0] < x[0] or a[0] == x[0] and a[1] < x[1]: i, a[1] = divmod(a[1] + a[0], 100) a[0] += i y += 1 return y print(main())
s946845274
p03998
u980503157
2,000
262,144
Wrong Answer
27
9,060
292
Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game.
first = input() second = input() third = input() d = {} d["a"]=first d["b"]=second d["c"]=third flag = False run = "a" while flag != True: if d[run] == "": flag = True print(run) else: l = len(d[run]) temp = d[run][0] d[run] = d[run][1:l] run = temp
s290779336
Accepted
27
9,032
430
a = list(input()) #aca b = list(input()) #accc c = list(input()) #ca win = False run = a while win != True: if run[0] == "a": run.pop(0) run = a if len(run) == 0: print("A") win = True elif run[0] == "b": run.pop(0) run = b if len(run) == 0: print("B") win = True else: run.pop(0) run = c if len(run) == 0: print("C") win = True
s146944170
p02388
u088372268
1,000
131,072
Wrong Answer
20
7,420
12
Write a program which calculates the cube of a given integer x.
x = 2 x ** 3
s039246969
Accepted
50
7,604
34
x = input() x = int(x) print(x**3)
s012963926
p02412
u628732336
1,000
131,072
Wrong Answer
20
7,628
347
Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9
while True: n, x = [int(i) for i in input().split()] if n == x == 0: break count = 0 for s in range(1, n // 2 + 1): for e in range(n, n // 2, -1): m = x - s - e if m != s and m != e and m > s and m < e and m <= n: print(s, m, e) count += 1 print(count)
s206971885
Accepted
530
7,724
292
while True: n, x = [int(i) for i in input().split()] if n == x == 0: break count = 0 for s in range(1, n - 1): for m in range(s + 1, n): for e in range(m + 1, n + 1): if x == s+m+e: count += 1 print(count)
s295347413
p00002
u179070318
1,000
131,072
Wrong Answer
20
5,668
91
Write a program which computes the digit number of sum of two integers a and b.
import math a,b = [int(x) for x in input().split()] x = a + b print(int(math.log10(x))+1)
s589887508
Accepted
20
5,676
170
import math while True: try: a,b = [int(x) for x in input().split()] x = a + b print(int(math.log10(x))+1) except: break
s236147220
p02833
u501451051
2,000
1,048,576
Wrong Answer
29
9,116
148
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
n = int(input()) if n % 2 != 0: print(0) else: ans = 0 tmp = n/2 while tmp: tmp /= 5 ans += tmp print(ans)
s459499516
Accepted
30
9,164
154
n = int(input()) if n % 2 != 0: print(0) else: ans = 0 n //= 2 while n: ans += n//5 n //= 5 print(int(ans))
s607513598
p03149
u589716761
2,000
1,048,576
Wrong Answer
17
2,940
98
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".
S=input().split() print(S) if "1" and "7" and "9" and "4" in S: print("Yes") else: print('No')
s063306058
Accepted
17
2,940
112
S=input().split() if ("1" in S) and ("9" in S) and ("7" in S) and ("4" in S): print("YES") else: print('NO')
s308251449
p03456
u642418876
2,000
262,144
Wrong Answer
17
2,940
131
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
a,b=map(str,input().split()) c=a+b for i in range(101): if i**2==int(c): print('Yes') else: print('No') exit()
s875152456
Accepted
17
2,940
117
a,b=map(str,input().split()) c=a+b for i in range(1,320): if int(c)==i**2: print('Yes') exit() print('No')
s136012255
p03434
u617449195
2,000
262,144
Wrong Answer
18
3,064
357
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 cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
N = int(input()) A = [int(i) for i in input().split()] A_sorted = sorted(A, reverse=True) print(A_sorted) Alice_point = 0; Bob_point = 0 for i in range(N): if i % 2 == 0: print("Alice=",i) Alice_point += A_sorted[i] else: print("Bob=",i) Bob_point += A_sorted[i] ans = Alice_point - Bob_point print(ans)
s476722963
Accepted
17
3,060
291
N = int(input()) A = [int(i) for i in input().split()] A_sorted = sorted(A, reverse=True) Alice_point = 0; Bob_point = 0 for i in range(N): if i % 2 == 0: Alice_point += A_sorted[i] else: Bob_point += A_sorted[i] ans = Alice_point - Bob_point print(ans)
s669261226
p03962
u950337877
2,000
262,144
Wrong Answer
20
2,940
141
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 might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.
a, b, c = map(int, input().split()) if a == b and a == c: print('3') elif a==b or a == c or b== c: print('2') else: print('1')
s843225670
Accepted
17
2,940
132
a, b, c = map(int, input().split()) if a == b == c: print('1') elif a==b or a == c or b== c: print('2') else: print('3')
s980107371
p00003
u806182843
1,000
131,072
Wrong Answer
50
7,732
369
Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so.
def main(): n = int(input()) for _ in range(n): len_list = map(int, input().split()) check_tri(len_list) def check_tri(len_list): import itertools flag = True for tmp in list(itertools.permutations(len_list)): if (tmp[0] + tmp[1]) < tmp[2]: flag = False break if flag == True: print('yes') else: print('no') if __name__ == '__main__': main()
s168995666
Accepted
60
7,748
408
def main(): n = int(input()) for _ in range(n): len_list = map(int, input().split()) check_tri(len_list) def check_tri(len_list): import itertools import math flag = False for tmp in list(itertools.permutations(len_list)): if (pow(tmp[0], 2) + pow(tmp[1], 2)) == pow(tmp[2], 2): flag = True break if flag == True: print('YES') else: print('NO') if __name__ == '__main__': main()
s336226235
p03844
u790048565
2,000
262,144
Wrong Answer
17
2,940
26
Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
s = input() print(exec(s))
s936274696
Accepted
17
2,940
26
s = input() print(eval(s))
s416869209
p02412
u316584871
1,000
131,072
Wrong Answer
20
5,596
386
Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9
while True: n, x = map(int,input().split()) if(n==0, x==0): break nlist = [] for i in range(1,n+1): nlist.append(i) count = 0 for i1 in range(n-2): for i2 in range(i1+1,n-1): for i3 in range(i2+1,n): y = nlist[i1]+nlist[i2]+nlist[i3] if(y == x): count += 1 print(count)
s217336758
Accepted
930
5,600
430
while True: n, x = map(int,input().split()) if(n==0 and x==0): break nlist = [] for i in range(1,n+1): nlist.append(i) count = 0 for i1 in range(n-2): for i2 in range(i1+1,n-1): for i3 in range(i2+1,n): y = nlist[i1]+nlist[i2]+nlist[i3] if(y == x): count += 1 print(count)
s143669135
p02390
u208157605
1,000
131,072
Wrong Answer
20
7,452
89
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
import time seconds = int(input()) print(time.strftime('%H:%M:%S', time.gmtime(seconds)))
s454031038
Accepted
20
7,508
164
seconds = int(input()) hour = str(seconds // 3600) minute = str(seconds % 3600 // 60) second = str(seconds % 3600 % 60) print(hour + ':' + minute + ':' + second)
s619511239
p03448
u840974625
2,000
262,144
Wrong Answer
51
3,060
244
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 coin are different.
a = int(input()) b = int(input()) c = int(input()) x = int(input()) res = 0 for ai in range(a): for bi in range(b): for ci in range(c): total = 500 * ai + 100 * bi + 50 * ci if x == total: res += 1 print(res)
s342677963
Accepted
55
3,060
256
a = int(input()) b = int(input()) c = int(input()) x = int(input()) res = 0 for ai in range(a + 1): for bi in range(b + 1): for ci in range(c + 1): total = 500 * ai + 100 * bi + 50 * ci if x == total: res += 1 print(res)
s942051911
p03378
u593567568
2,000
262,144
Wrong Answer
18
3,060
191
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N. Find the minimum cost incurred before reaching the goal.
from bisect import bisect_right N,M,X = map(int,input().split()) A = list(map(int,input().split())) left = bisect_right(A,X) right = N - left l = X - left r = N - X - right print(min(l,r))
s701809953
Accepted
17
3,188
173
from bisect import bisect_right N,M,X = map(int,input().split()) A = list(map(int,input().split())) left = bisect_right(A,X) right = len(A) - left print(min(left,right))
s752035376
p04012
u981931040
2,000
262,144
Wrong Answer
30
9,300
163
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.
from collections import Counter S = Counter(input()) flag = False for c in S.values(): if c % 2 == 1: flag = True if flag: print('Yes') else: print('No')
s064000334
Accepted
30
9,192
164
from collections import Counter S = Counter(input()) flag = True for c in S.values(): if c % 2 == 1: flag = False if flag: print('Yes') else: print('No')
s071502373
p03624
u674588203
2,000
262,144
Wrong Answer
20
3,188
219
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
S=input() L=("a","b","c","d","e","f","g","h","i","j","k","l","m","n", "o","p","q","r","s","t","u","v","w","x","y","z") for l in L: if S.count(l)>0: pass else: print(l) else: print("None")
s499699840
Accepted
20
3,188
234
S=input() L=("a","b","c","d","e","f","g","h","i","j","k","l","m","n", "o","p","q","r","s","t","u","v","w","x","y","z") for l in L: if S.count(l)>0: pass else: print(l) exit() else: print("None")
s991804607
p03371
u733608212
2,000
262,144
Wrong Answer
19
3,064
245
"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 currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
a, b, c, x, y= map(int, input().split()) ans = a*x + b*y print(ans, c * x * 2, y * c * 2+ (x - y) * b) if x > y: ans = min(ans, c * x * 2, y * c * 2+ (x - y) * a) else: ans = min(ans, c * y * 2, x * c * 2 + (y - x) * b) print(ans)
s618842067
Accepted
24
3,064
199
a, b, c, x, y= map(int, input().split()) ans = a*x + b*y if x > y: ans = min(ans, c * x * 2, y * c * 2+ (x - y) * a) else: ans = min(ans, c * y * 2, x * c * 2 + (y - x) * b) print(ans)
s693329344
p02399
u941509088
1,000
131,072
Wrong Answer
50
7,676
78
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()) d = a//b r = a%b f = float(a/b) print(d,r,f)
s325858449
Accepted
20
7,648
97
a, b = map(int, input().split()) d = a//b r = a%b f = float(a/b) print('%s %s %.5f' % (d, r, f))
s418928391
p02694
u377834804
2,000
1,048,576
Time Limit Exceeded
2,206
8,960
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 above for the first time?
X = int(input()) now = 0 cnt = 0 while now < X: cnt += 1 now = int(now*1.01) print(cnt)
s797471443
Accepted
21
9,096
96
X = int(input()) now = 100 cnt = 0 while now < X: cnt += 1 now += int(now*0.01) print(cnt)
s908945938
p02397
u477464845
1,000
131,072
Wrong Answer
60
5,616
194
Write a program which reads two integers x and y, and prints them in ascending order.
while True: a = list(map(int,input().split())) if a[0] == 0 and a[1] == 0: break elif a[0] > a[1]: a.sort() print(*a) elif a[0] < a[1]: print(*a)
s476848382
Accepted
60
5,608
152
while True: x,y = map(int,input().split(" ")) if x == 0 and y==0: break elif y < x: print(y,x) else: print(x,y)
s093013435
p03110
u067632118
2,000
1,048,576
Wrong Answer
17
2,940
171
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` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
N = int(input()) EBTC = 380000.0 R = 0 for i in range(N): t = [x for x in input().split()] R = R + int(t[0]) if t[1]=="JPY" else R + float(t[0])*EBTC print(int(R))
s114961068
Accepted
17
2,940
168
N = int(input()) EBTC = 380000.0 R = 0 for i in range(N): t = [x for x in input().split()] R = R + float(t[0]) if t[1]=="JPY" else R + float(t[0])*EBTC print(R)
s843932796
p03401
u936985471
2,000
262,144
Wrong Answer
169
14,048
480
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.
N=int(input()) A=list(map(int,input().split())) sortedA=sorted(A) L1=sortedA[0] L2=sortedA[1] R1=sortedA[-1] R2=sortedA[-2] def calcDist(L,R): if L*R<0: return (abs(L)+abs(R))*2 else: return max(abs(L),abs(R))*2 distL1R1=calcDist(L1,R1) print("distL1R1:",distL1R1) distL1R2=calcDist(L1,R2) distL2R1=calcDist(L2,R1) distL2R1=calcDist(L2,R2) for i in range(N): tar=A[i] ans=distL1R1 if tar==L1: ans=distL2R1 elif tar==R1: ans=distL1R2 print(ans)
s201044709
Accepted
260
14,172
278
N=int(input()) A=list(map(int,input().split())) A=[0]+A+[0] dist=0 diff=[0]*(len(A)-2) for i in range(len(A)-1): dist+=abs(A[i+1]-A[i]) if 1<=i<=len(A)-2: diff[i-1]=abs(A[i]-A[i-1])+abs(A[i+1]-A[i])-abs(A[i+1]-A[i-1]) for i in range(len(diff)): print(dist-diff[i])
s311980169
p03471
u113750443
2,000
262,144
Wrong Answer
2,104
3,064
1,377
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 situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
def nyu(): num1,num2 = input().split() num1 = int(num1) num2 = int(num2) # print("x = " ,x[i] ,"y = ",y[i]) return num1,num2 def otoshidama(n,y): n= int(y /10000+1) success_flg = 0 ichiman = 0 gosen = 0 senen = 0 y_tmp = y for i in reversed(range(n)): ichiman = 0 gosen = 0 senen = 0 y_tmp = y g_ymp = y_tmp if y_tmp >= 10000*i: y_tmp = y_tmp - 10000*i ichiman = i g_ymp = y_tmp if check(y_tmp,ichiman,gosen,senen) == True: return ichiman,gosen,senen for g in range(n): y_tmp = g_ymp gosen = int(y_tmp / 5000) if y_tmp >= 5000*g: y_tmp = y_tmp - 5000 * g gosen = g if check(y_tmp,ichiman,gosen,senen) == True: return ichiman,gosen,senen senen = int(y_tmp / 1000) y_tmp = y_tmp % 1000 if check(y_tmp,ichiman,gosen,senen) == True: return ichiman,gosen,senen return -1,-1,-1 def check(y_tmp,ichiman,gosen,senen): if y_tmp == 0.0 and ichiman + gosen + senen == n: return True return False n,y =nyu() print(otoshidama(n,y))
s108370790
Accepted
1,168
3,064
1,427
def nyu(): num1,num2 = input().split() num1 = int(num1) num2 = int(num2) # print("x = " ,x[i] ,"y = ",y[i]) return num1,num2 def otoshidama(n,y): n = n+1 ichiman = 0 gosen = 0 senen = 0 y_tmp = y for i in reversed(range(n)): # print(i) ichiman = 0 gosen = 0 senen = 0 y_tmp = y g_ymp = y_tmp if y_tmp >= 10000*i: y_tmp = y_tmp - 10000*i ichiman = i g_ymp = y_tmp for g in reversed(range(n-i)): gosen = 0 senen = 0 y_tmp = g_ymp if y_tmp >= 5000*g: y_tmp = y_tmp - 5000 * g gosen = g senen = int(y_tmp / 1000) y_tmp = y_tmp % 1000 if check(y_tmp,ichiman,gosen,senen) == True: return ichiman,gosen,senen return -1,-1,-1 def check(y_tmp,ichiman,gosen,senen): if y_tmp == 0 and ichiman + gosen + senen == n: return True return False n,y =nyu() num1,num2,num3 = otoshidama(n,y) print(num1,num2,num3)
s642613481
p02742
u901757711
2,000
1,048,576
Wrong Answer
18
2,940
102
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 top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
h, w = map(int, input().split()) ans = h*w if ans %2 ==0: print(ans/2) else: print(ans//2+1)
s035243930
Accepted
17
2,940
138
h, w = map(int, input().split()) if h==1 or w==1: print(1) else: ans = h*w if ans % 2 ==0 : print(ans//2) else: print(ans//2+1)
s966617904
p03063
u060938295
2,000
1,048,576
Wrong Answer
144
3,500
393
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.
# -*- coding: utf-8 -*- """ Created on Sat Apr 20 20:58:04 2019 @author: Yamazaki Kenichi """ N = int(input()) S = input() a,b = 0,0 flg,flg2 = False,False for i in range(N): if S[-i-1] == '.': flg = True if flg: if S[-i-1] == "#": flg2 = True if flg2 and S[-i-1] == '#': a += 1 if flg2 and S[-i-1] == '.': b += 1 print(min(a,b))
s908143647
Accepted
141
5,128
339
# -*- coding: utf-8 -*- """ Created on Sun Apr 21 13:05:54 2019 @author: Yamazaki Kenichi """ N = int(input()) S = input() a,ans = [],0 for c in S: if c == '.': ans += 1 a.append(-1) else: a.append(1) tmp = ans for i in range(N): tmp += a[i] ans = min(ans,tmp) # print(ans,a[i],tmp) print(ans)
s421406408
p03605
u207799478
2,000
262,144
Wrong Answer
17
2,940
95
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() for i in range(len(n)): if i ==9: print('Yes') break print('No')
s943543103
Accepted
17
2,940
150
# coding: utf-8 # Your code here! n=input() if n[0]=='9': print('Yes') exit() if n[1]=='9': print('Yes') exit() else: print('No')
s636672058
p02678
u708255304
2,000
1,048,576
Wrong Answer
728
41,352
506
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 the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
from collections import deque, defaultdict N, M = map(int, input().split()) tree = [[] for _ in range(N)] for _ in range(M): a, b = map(lambda x: int(x)-1, input().split()) tree[a].append(b) tree[b].append(a) visited = [False]*N q = deque([0]) visited[0] = True ans = defaultdict(int) while len(q): v = q.popleft() for e in tree[v]: if visited[e]: continue visited[e] = True ans[e] = v q.append(e) for i in range(1, N): print(ans[i]+1)
s386005328
Accepted
772
41,492
518
from collections import deque, defaultdict N, M = map(int, input().split()) tree = [[] for _ in range(N)] for _ in range(M): a, b = map(lambda x: int(x)-1, input().split()) tree[a].append(b) tree[b].append(a) visited = [False]*N q = deque([0]) visited[0] = True ans = defaultdict(int) while len(q): v = q.popleft() for e in tree[v]: if visited[e]: continue visited[e] = True ans[e] = v q.append(e) print("Yes") for i in range(1, N): print(ans[i]+1)
s338003386
p02261
u825178626
1,000
131,072
Wrong Answer
20
7,836
1,002
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 Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
# coding: utf-8 # Here your code ! A = int(input()) N = tuple(input().split()) bs=[] ss=[] def isStable(a,b): leng = int(len(a)) for i in range(leng): for j in range(i+1,leng): for x in range(leng): for y in range(x+1,leng): if a[i][1]==a[j][1] and a[i]==b[x] and a[j]==b[y]: return "Stable" return "Not Stable" def bSort(n,a): n = list(n) for i in range(a): for j in range(a-1,i,-1): if int(n[j][1]) < int(n[j-1][1]): n[j],n[j-1]=n[j-1],n[j] return n #print(" ".join(n)) def seleSort(n,a): n = list(n) for i in range(a): minj = i for j in range(i+1,a): if n[j][1]<n[minj][1]: minj = j n[i],n[minj]=n[minj],n[i] return n #print(" ".join(n)) bs = bSort(N,A) ss = seleSort(N,A) print(" ".join(bs)) print(isStable(bs,bs)) print(" ".join(ss)) print(isStable(bs,ss))
s797506702
Accepted
140
7,824
1,002
# coding: utf-8 # Here your code ! A = int(input()) N = tuple(input().split()) bs=[] ss=[] def isStable(a,b): leng = int(len(a)) for i in range(leng): for j in range(i+1,leng): for x in range(leng): for y in range(x+1,leng): if a[i][1]==a[j][1] and a[i]==b[y] and a[j]==b[x]: return "Not stable" return "Stable" def bSort(n,a): n = list(n) for i in range(a): for j in range(a-1,i,-1): if int(n[j][1]) < int(n[j-1][1]): n[j],n[j-1]=n[j-1],n[j] return n #print(" ".join(n)) def seleSort(n,a): n = list(n) for i in range(a): minj = i for j in range(i+1,a): if n[j][1]<n[minj][1]: minj = j n[i],n[minj]=n[minj],n[i] return n #print(" ".join(n)) bs = bSort(N,A) ss = seleSort(N,A) print(" ".join(bs)) print(isStable(bs,bs)) print(" ".join(ss)) print(isStable(bs,ss))
s641008272
p03730
u864667985
2,000
262,144
Wrong Answer
17
2,940
174
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 objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
def main(): a, b, c = map(int, input().split()) for i in range(1, b+1): if i*a % b == c: print("Yes") return print("No") main()
s141320452
Accepted
17
2,940
174
def main(): a, b, c = map(int, input().split()) for i in range(1, b+1): if i*a % b == c: print("YES") return print("NO") main()
s163800311
p03599
u940743763
3,000
262,144
Time Limit Exceeded
3,156
3,064
633
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the beaker. * Operation 3: Put C grams of sugar into the beaker. * Operation 4: Put D grams of sugar into the beaker. In our experimental environment, E grams of sugar can dissolve into 100 grams of water. Snuke will make sugar water with the highest possible density. The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted. We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.
a, b, c, d, e, f = list(map(int, input().split(' '))) rate = 0 water = 0 suger = 0 for i in range(30 + 1): for j in range(30 + 1): for k in range(100 + 1): for l in range(100 + 1): w = 100 * a * i + 100 * b * j s = c * k + d * l if w + s <= 0: break temp = w + s r = (s * 100) / temp if temp <= f and (a * i + b * j) * e >= s: if rate <= r: water = w suger = s rate = r print(water + suger, suger)
s275068643
Accepted
547
3,188
674
a, b, c, d, e, f = list(map(int, input().split(' '))) rate = 0 water = 0 suger = 0 al = f // (a * 100) bl = f // (b * 100) for i in range(al + 1): for j in range(bl + 1): for k in range(100 + 1): for l in range(100 + 1): w = 100 * a * i + 100 * b * j s = c * k + d * l if w + s <= 0: break temp = w + s r = (s * 100) / temp if temp <= f and (a * i + b * j) * e >= s: if rate <= r: water = w suger = s rate = r print(water + suger, suger)
s777630511
p03855
u819135704
2,000
262,144
Wrong Answer
1,007
80,608
408
There are N cities. There are also K roads and L railways, extending between the cities. The i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities. No two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities. We will say city A and B are _connected by roads_ if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads. We will also define _connectivity by railways_ similarly. For each city, find the number of the cities connected to that city by both roads and railways.
from collections import * N, K, L = map(int,input().split()) def f(m): *a, = range(N) def g(i): if a[i] == i: return i a[i] = g(a[i]) return a[i] for _ in range(m): p, q = map(int,input().split()) a[g(q-1)] = g(p-1) return g x, y = f(K), f(L) c = Counter((x(i),y(i)) for i in range(N)) print(c) print(*((c[x(i),y(i)]) for i in range(N)))
s248816130
Accepted
853
55,644
399
from collections import * N, K, L = map(int,input().split()) def f(m): *a, = range(N) def g(i): if a[i] == i: return i a[i] = g(a[i]) return a[i] for _ in range(m): p, q = map(int,input().split()) a[g(q-1)] = g(p-1) return g x, y = f(K), f(L) c = Counter((x(i),y(i)) for i in range(N)) print(*((c[x(i),y(i)]) for i in range(N)))
s831591410
p03479
u753803401
2,000
262,144
Wrong Answer
17
2,940
162
As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence.
x, y = map(int, input().split()) t = x cnt = 0 while True: print(t) if t > y: print(cnt) exit() else: cnt += 1 t *= 2
s387109680
Accepted
17
2,940
149
x, y = map(int, input().split()) t = x cnt = 0 while True: if t > y: print(cnt) exit() else: cnt += 1 t *= 2
s938730455
p03448
u375695365
2,000
262,144
Wrong Answer
34
3,060
222
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 coin are different.
a=int(input()) b=int(input()) c=int(input()) x=int(input()) ans=0 for i in range(0,a*500,500): for j in range(0,b*100,100): for z in range(0,c*50,50): if i+j+z==x: ans+=1 print(ans)
s733256720
Accepted
37
3,060
228
a=int(input()) b=int(input()) c=int(input()) x=int(input()) ans=0 for i in range(0,a*500+1,500): for j in range(0,b*100+1,100): for z in range(0,c*50+1,50): if i+j+z==x: ans+=1 print(ans)
s956339864
p03487
u371132735
2,000
262,144
Wrong Answer
186
18,672
266
You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence.
import collections N = int(input()) A = list(map(int,input().split())) C = collections.Counter(A) ans = 0 for i,v in C.items(): print(i,v) if i!=v: if i<v: ans += v-1 else: ans += v print(ans)
s350990944
Accepted
82
18,676
268
import collections N = int(input()) A = list(map(int,input().split())) C = collections.Counter(A) ans = 0 for i,v in C.items(): # print(i,v) if i!=v: if i<v: ans += v-i else: ans += v print(ans)
s359475036
p03067
u492030100
2,000
1,048,576
Wrong Answer
17
2,940
109
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
A, B,C = map(int, input().split()) #C = int(input()) Anything= 'Yes' if A<B and B<C else 'No' print(Anything)
s840168486
Accepted
17
2,940
128
A, B,C = map(int, input().split()) #C = int(input()) Anything= 'Yes' if (A<C and C<B) or (B<C and C<A) else 'No' print(Anything)
s629592229
p03998
u746419473
2,000
262,144
Wrong Answer
21
3,188
164
Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game.
s = {} for key in ("a", "b", "c"): s[key] = list(input()) cur = s["a"][0] while len(s[cur]) != 0: cur = s[cur].pop(0) print(cur, s) print(cur.upper())
s207635748
Accepted
17
2,940
109
s = {key:list(input()) for key in "abc"} c = "a" while len(s[c]) != 0: c = s[c].pop(0) print(c.upper())
s258501704
p03369
u777078967
2,000
262,144
Wrong Answer
17
2,940
106
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 three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
data=input().rstrip().split() data=list(data) ans=700 for i in data: if "o" ==i: ans+=100 print(ans)
s798344095
Accepted
17
2,940
98
data=input().rstrip() data=list(data) ans=700 for i in data: if "o"==i: ans+=100 print(ans)
s251068321
p03455
u495296799
2,000
262,144
Wrong Answer
17
2,940
96
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a,b=input().split() a=int(a) b=int(b) if (a*b)%2==0: print ("even") else: print ("odd")
s915341025
Accepted
17
2,940
95
a,b=input().split() a=int(a) b=int(b) if (a*b)%2==0: print ("Even") else: print ("Odd")
s569849195
p02619
u171654347
2,000
1,048,576
Wrong Answer
40
9,648
526
Let's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.
d = int(input()) cList = input().split() sList = [] for idx in range(0, d): tempList = input().split() sList.append(tempList) tList = [] for idx in range(0, d): tList.append(int(input())) print(sList) print(tList) countList = [0] * 26 val = 0 for idx in range(0, d): val += int(sList[idx][tList[idx] -1]) countList = list(map(lambda x: x+1, countList)) countList[int(tList[idx]) -1] = 0 for wkChar in range(0,26): val -= int(countList[wkChar]) * int(cList[wkChar]) print(val)
s379313034
Accepted
39
9,652
500
d = int(input()) cList = input().split() sList = [] for idx in range(0, d): tempList = input().split() sList.append(tempList) tList = [] for idx in range(0, d): tList.append(int(input())) countList = [0] * 26 val = 0 for idx in range(0, d): val += int(sList[idx][tList[idx] -1]) countList = list(map(lambda x: x+1, countList)) countList[int(tList[idx]) -1] = 0 for wkChar in range(0,26): val -= int(countList[wkChar]) * int(cList[wkChar]) print(val)
s471304070
p03352
u331381193
2,000
1,048,576
Wrong Answer
19
3,060
151
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
x=int(input()) import math #y=math.log(1000, 1) res=[1] for i in range(2,33): y=math.floor(math.log(x, i)) res.append(i**y) print(max(res)) #961
s161128226
Accepted
17
3,060
158
x=int(input()) import math #y=math.log(1000, 1) res=[1] for i in range(2,33): for j in range(2,10): y=i**j if y<=x: res.append(y) print(max(res))
s006698635
p03624
u106342872
2,000
262,144
Wrong Answer
85
5,416
317
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
#! -*- coding:utf-8 -*- s = str(input()) s = list(s) x = 'abcdefghijklmnopqrstuvwxyz' x = list(x) print(s) flag = 0 for i in range(len(s)): try: if(len(x) == 1 and s[i] == x[0]): flag = 1 x.remove(s[i]) except: pass if(flag == 1): print('None') else: print(x[0])
s267566270
Accepted
78
3,956
308
#! -*- coding:utf-8 -*- s = str(input()) s = list(s) x = 'abcdefghijklmnopqrstuvwxyz' x = list(x) flag = 0 for i in range(len(s)): try: if(len(x) == 1 and s[i] == x[0]): flag = 1 x.remove(s[i]) except: pass if(flag == 1): print('None') else: print(x[0])
s282478815
p00008
u440180827
1,000
131,072
Wrong Answer
30
7,536
213
Write a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality: a + b + c + d = n For example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).
n = int(input()) count = 0 for i in range(10): for j in range(10): for k in range(10): for l in range(10): if i + j + k + l == n: count += 1 print(count)
s423551356
Accepted
60
7,688
267
import sys t = [None for i in range(10000)] c = 0 for i in range(10): for j in range(10): for k in range(10): for l in range(10): t[c] = i + j + k + l c += 1 for line in sys.stdin: print(t.count(int(line)))
s995968184
p03644
u168416324
2,000
262,144
Wrong Answer
17
2,940
88
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 be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
n=int(input()) for x in range(0,8): if pow(2,x)>n: ans=pow(2,x-1) print(ans)
s002622169
Accepted
17
2,940
99
n=int(input()) ans=1 for x in range(0,8): if n<pow(2,x): break ans=pow(2,x) print(ans)
s913205403
p03545
u001024152
2,000
262,144
Wrong Answer
17
3,188
388
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 input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
a, b, c, d = [int(i) for i in input()] ops = ["+++", "++-", "+-+", "+--", "-++", "-+-", "--+", "---"] for op in ops: s = a print(op) for i, n in enumerate([b, c, d]): op = list(op) if op[i] == "+": s += n else: s -= n if s == 7: print(str(a) + op[0] + str(b) + op[1] + str(c) + op[2] + str(d) + "=7") break
s726109274
Accepted
17
2,940
229
A = list(input()) op = ["-", "+"] for op1 in op: for op2 in op: for op3 in op: left = A[0]+op1+A[1]+op2+A[2]+op3+A[3] if eval(left) == 7: print(left+"=7") exit()
s562639454
p03369
u003501233
2,000
262,144
Wrong Answer
17
2,940
59
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 three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
s=str(input()) ans=s.count("〇") print(700+(int(ans)*100))
s839499641
Accepted
17
2,940
52
s=input() ans=s.count("o") print(700+(int(ans)*100))
s104927443
p03693
u652081898
2,000
262,144
Wrong Answer
18
2,940
95
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 integer a multiple of 4?
r, g, b = map(int, input().split()) if (g*10+b)%4 == 0: print("Yes") else: print("No")
s238469937
Accepted
17
3,064
96
r, g, b = map(int, input().split()) if (g*10+b)%4 == 0: print("YES") else: print("NO")
s892413497
p03139
u583460863
2,000
1,048,576
Wrong Answer
18
2,940
129
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question.
a, b, c = map(int, input().split()) if (a > b ) : mx_a = b else: mx_a = a mx_y = a+b - c print(str(mx_a) + ' ' + str(mx_y))
s042524068
Accepted
18
3,060
202
n , a, b = map(int, input().split()) n = int(n) a = int(a) b = int(b) if (a > b ) : mx_x = b else: mx_x = a if ((a+b - n)<0): mx_y = 0 else: mx_y = a+b-n print(str(mx_x) + ' ' + str(mx_y))
s658277676
p03140
u025235255
2,000
1,048,576
Wrong Answer
17
3,064
220
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 between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter. What is the minimum number of operations required to achieve the objective?
n = int(input()) a = input() b = input() c = input() count = 0 for i in range(n): if a[i] != b[i] and a[i] != c[i]: count += 2 elif a[i] != b[i] or a[i] != c[i]: count += 1 print(count)
s950154520
Accepted
17
3,064
281
n = int(input()) a = input() b = input() c = input() count = 0 for i in range(n): if a[i] != b[i] and b[i] == c[i]: count += 1 elif a[i] != b[i] and a[i] != c[i]: count += 2 elif a[i] != b[i] or a[i] != c[i]: count += 1 print(count)
s558019944
p03160
u306033313
2,000
1,048,576
Wrong Answer
18
3,064
246
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
hight = [2, 9, 4, 5, 1, 6, 10] lis = [0, hight[1]-hight[0]] for i in range(len(hight)): if i == 0 or i == 1: pass else: lis.append(min(lis[i-2] + abs(hight[i]-hight[i-2]), lis[i-1] + abs(hight[i]-hight[i-1]))) print(lis)
s630238326
Accepted
135
13,908
282
n = int(input()) hight = list(map(int, input().split())) lis = [0, abs(hight[1]-hight[0])] for i in range(len(hight)): if i == 0 or i == 1: pass else: lis.append(min(lis[i-2] + abs(hight[i]-hight[i-2]), lis[i-1] + abs(hight[i]-hight[i-1]))) print(lis[n-1])
s728949422
p03779
u367130284
2,000
262,144
Wrong Answer
35
4,868
79
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 at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.
y=int(input())*2 a=[x*(x+1) for x in range(100000) if x*(x+1)<=y] print(len(a))
s165492681
Accepted
35
4,868
78
y=int(input())*2 a=[x*(x+1) for x in range(100000) if x*(x+1)<y] print(len(a))
s442363646
p03433
u095396110
2,000
262,144
Wrong Answer
25
9,156
131
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
N = int(input()) A = int(input()) num_list = [a for a in range(A+1)] if N%500 in num_list: print('Yse') else: print('No')
s385530298
Accepted
30
8,800
85
n = int(input()) a = int(input()) if n%500 <= a: print("Yes") else: print("No")
s126363596
p03828
u429995021
2,000
262,144
Wrong Answer
24
3,188
489
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.
def main(): N = int(input()) primes = sieve(N) print(primes) res = 1 for p in primes: n = (N//p) print(n) res *= (n*(n+1))/2 res = res % (10**9 + 7) print(res) def sieve(n): s = [True] * n for x in range(2, int(n**0.5) + 1): if s[x]: mark(s, x) return [i for i in range(0,n) if s[i] and i > 1] def mark(s, x): for i in range(x + x, len(s), x): s[i] = False if __name__ == "__main__": main()
s020444595
Accepted
23
3,192
533
def main(): N = int(input()) primes = sieve(N+1) res = 1 for p in primes: f = 0 i = 1 while p ** i <= N: f += (N//(p**i)) i += 1 res *= f + 1 res = res % (10**9 + 7) print(res) def sieve(n): s = [True] * n for x in range(2, int(n**0.5) + 1): if s[x]: mark(s, x) return [i for i in range(0,n) if s[i] and i > 1] def mark(s, x): for i in range(x + x, len(s), x): s[i] = False if __name__ == "__main__": main()
s248941363
p03448
u113255362
2,000
262,144
Wrong Answer
27
8,988
214
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 coin are different.
List = [] for i in range (3): List.append(int(input())) X=int(input()) res = 0 c = 0 for i in range(List[0]): for j in range(List[1]): c = X - 500 * i - 100 * j if 0<=c<=List[2]: res+=1 print(res)
s328060045
Accepted
27
9,128
226
List = [] for i in range (3): List.append(int(input())) X=int(input()) res = 0 c = 0 for i in range(List[0]+1): for j in range(List[1]+1): c = int(X/50) - 10 * i - 2 * j if 0<= c <= List[2]: res+=1 print(res)
s757168952
p02612
u119655368
2,000
1,048,576
Wrong Answer
28
8,872
24
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
print(int(input())%1000)
s977191189
Accepted
32
9,144
37
print((1000-int(input())%1000)%1000)
s234854306
p03657
u174536291
2,000
262,144
Wrong Answer
25
9,108
133
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
a, b = list(map(int, input().split())) if a % 3 == 0 or b % 3 == 0 or a + b % 3 == 0: print('Possible') else: print('Impossible')
s370169813
Accepted
29
9,040
139
a, b = list(map(int, input().split())) n = a + b if a % 3 == 0 or b % 3 == 0 or n % 3 == 0: print('Possible') else: print('Impossible')
s029552127
p03943
u720417458
2,000
262,144
Wrong Answer
17
3,060
186
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. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
a, b, c = map(int, input().split()) if a == b == c: print('1') elif a == b != c: print('2') elif a != b == c: print('2') elif b != c == a: print('2') else: print('3')
s166466476
Accepted
17
2,940
160
a,b,c = map(int,input().split()) if a + b == c: print('Yes') elif a + c == b: print('Yes') elif b + c == a: print('Yes') else: print('No')
s380671283
p02612
u086866608
2,000
1,048,576
Wrong Answer
29
9,128
37
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()) ans=n%1000 print(ans)
s187299126
Accepted
29
9,104
90
n=int(input()) amari=n%1000 if n%1000==0: print("0") else: print(1000-amari)
s140451000
p03455
u604655161
2,000
262,144
Wrong Answer
17
2,940
165
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
def ABC_86_A(): a,b = map(int, input().split()) if (a*b)%2: print('Even') else: print('Odd') if __name__ == '__main__': ABC_86_A()
s590230897
Accepted
17
2,940
170
def ABC_86_A(): a,b = map(int, input().split()) if (a*b)%2 == 0: print('Even') else: print('Odd') if __name__ == '__main__': ABC_86_A()
s915101323
p03637
u326552320
2,000
262,144
Wrong Answer
70
20,024
637
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
#!/usr/bin/env python # -*- coding: utf-8 -*- # # FileName: C # CreatedDate: 2020-09-04 15:44:42 +0900 # LastModified: 2020-09-13 16:01:33 +0900 # import os import sys # import numpy as np def main(): n = int(input()) A = list(map(int, input().split())) A_4 = [x for x in A if x % 4 == 0] A_2 = [x for x in A if x % 4 != 0 and x % 2 == 0] A_0 = [x for x in A if x % 2 != 0] if len(A_2) == 0 and len(A_0) <= len(A_4) + 1: print("Yes") elif len(A_2) % 2 == 0 and len(A_0) <= len(A_4): print("Yes") else: print("No") if __name__ == "__main__": main()
s282440502
Accepted
68
19,984
615
#!/usr/bin/env python # -*- coding: utf-8 -*- # # FileName: C # CreatedDate: 2020-09-04 15:44:42 +0900 # LastModified: 2020-09-13 16:06:20 +0900 # import os import sys # import numpy as np def main(): n = int(input()) A = list(map(int, input().split())) A_4 = [x for x in A if x % 4 == 0] A_2 = [x for x in A if x % 4 != 0 and x % 2 == 0] A_0 = [x for x in A if x % 2 != 0] if len(A_2) == 0 and len(A_0) <= len(A_4) + 1: print("Yes") elif len(A_0) <= len(A_4): print("Yes") else: print("No") if __name__ == "__main__": main()
s267962924
p03919
u380653557
2,000
262,144
Wrong Answer
22
3,064
238
There is a grid with H rows and W columns. The square at the i-th row and j-th column contains a string S_{i,j} of length 5. The rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from `A` through the W-th letter of the alphabet. Exactly one of the squares in the grid contains the string `snuke`. Find this square and report its location. For example, the square at the 6-th row and 8-th column should be reported as `H6`.
import sys next(sys.stdin) r = 1 for line in sys.stdin: line = list(line.strip().split()) try: c = line.index('snuke') print(str(r) + chr(ord('A') + c)) break except ValueError: pass r += 1
s583094024
Accepted
21
3,064
238
import sys next(sys.stdin) r = 1 for line in sys.stdin: line = list(line.strip().split()) try: c = line.index('snuke') print(chr(ord('A') + c) + str(r)) break except ValueError: pass r += 1
s010258967
p03997
u884323674
2,000
262,144
Wrong Answer
17
2,940
75
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a = int(input()) b = int(input()) h = int(input()) print((a + b) * h * 0.5)
s419779221
Accepted
17
2,940
80
a = int(input()) b = int(input()) h = int(input()) print(int((a + b) * h * 0.5))
s595905497
p03612
u021548497
2,000
262,144
Wrong Answer
67
13,880
149
You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two **adjacent** elements in the permutation. You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of operations to achieve this.
n = int(input()) a = [int(x) for x in input().split()] ans = 0 for i in range(n): if a[i] == i+1: ans += 1 print(max([ans-1, 1]) if ans else 0)
s059062306
Accepted
88
13,880
199
n = int(input()) a = [int(x) for x in input().split()] ans = 0 for i in range(n): if i == n-1 and a[i] == n: ans += 1 elif a[i] == i+1: ans += 1 a[i], a[i+1] = a[i+1], a[i] print(ans)
s267831747
p03813
u583631641
2,000
262,144
Wrong Answer
22
3,064
246
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise. You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise.
import sys s = input(); i = 0 j = 0 for c in s: if c == 'A': j = i while True: if s[j] == 'Z': print(j-i + 1) sys.exit(0) else : j = j + 1 i = i + 1
s065970553
Accepted
22
3,064
73
x = int(input()) if x < 1200 : print("ABC") else: print("ARC")
s092932024
p03494
u845937249
2,000
262,144
Wrong Answer
17
2,940
238
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.
def how_many_times_div(n): ans = 0 while n % 2 == 0: n /= 2 ans += 1 return ans n = int(input()) a = map(int, input().split()) print (n) print (a)
s676961555
Accepted
18
3,064
403
n = input() n = int(n) nums = input().split() nums = list(map(int,nums)) l = [0] * n i = 0 for i in range(0,n): ans = 0 check = nums[i] while check % 2 == 0: check = check / 2 ans = ans + 1 #print(check) l[i] = ans #print (l) print(min(l))
s197954360
p03494
u661567846
2,000
262,144
Wrong Answer
19
2,940
182
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()) nums = list(map(int, input().split())) maxval = 0 for i in nums: cnt = 0 while i % 2 == 0: cnt+=1 i /= 2 if maxval < cnt: maxval = cnt print(maxval)
s152649490
Accepted
19
2,940
166
N = int(input()) nums = list(map(int, input().split())) lst = [] for i in nums: cnt = 0 while i % 2 == 0: cnt+=1 i /= 2 lst.append(cnt) print(min(lst))
s790560517
p03854
u905203728
2,000
262,144
Wrong Answer
48
3,188
302
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] words=["dreamer","eraser","dream","erase"] add=0 while add!=len(s): cnt=0 for i in words: length=len(i) word=s[add:add+length][::-1] if word==i: add +=length break else:cnt +=1 if cnt==4:print("No");exit() print("Yes")
s796029272
Accepted
43
3,188
255
s=input()[::-1] T=["dream","dreamer","erase","eraser"] l,n=0,len(s) while l!=n: flag=0 for i in T: word=i[::-1] if s[l:l+len(word)]==word: l +=len(word) flag=1 if flag==0:print("NO");exit() print("YES")
s105796919
p02659
u089230684
2,000
1,048,576
Wrong Answer
27
9,156
86
Compute A \times B, truncate its fractional part, and print the result as an integer.
a,b=input().split(" ") c=int(a)*float(b) print(round(c)) #round off c
s013164751
Accepted
22
9,164
105
str_a, str_b = input().split() a = int(str_a) b_100 = int(str_b.replace('.', '')) print(a * b_100 // 100)