wrong_submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
user_id
stringlengths
10
10
time_limit
float64
1k
8k
memory_limit
float64
131k
1.05M
wrong_status
stringclasses
2 values
wrong_cpu_time
float64
10
40k
wrong_memory
float64
2.94k
3.37M
wrong_code_size
int64
1
15.5k
problem_description
stringlengths
1
4.75k
wrong_code
stringlengths
1
6.92k
acc_submission_id
stringlengths
10
10
acc_status
stringclasses
1 value
acc_cpu_time
float64
10
27.8k
acc_memory
float64
2.94k
960k
acc_code_size
int64
19
14.9k
acc_code
stringlengths
19
14.9k
s799721302
p02288
u320446607
2,000
131,072
Wrong Answer
20
7,768
447
A binary heap which satisfies max-heap property is called max-heap. In a max- heap, for every node $i$ other than the root, $A Write a program which reads an array and constructs a max-heap from the array based on the following pseudo code. $maxHeapify(A, i)$ move the value of $A[i]$ down to leaves to make a sub-tree of node $i$ a max-heap. Here, $H$ is the size of the heap. 1 maxHeapify(A, i) 2 l = left(i) 3 r = right(i) 4 // select the node which has the maximum value 5 if l ≤ H and A[l] > A[i] 6 largest = l 7 else 8 largest = i 9 if r ≤ H and A[r] > A[largest] 10 largest = r 11 12 if largest ≠ i // value of children is larger than that of i 13 swap A[i] and A[largest] 14 maxHeapify(A, largest) // call recursively The following procedure buildMaxHeap(A) makes $A$ a max-heap by performing maxHeapify in a bottom-up manner. 1 buildMaxHeap(A) 2 for i = H/2 downto 1 3 maxHeapify(A, i)
H = int(input()) A = [None] + list(map(int, input().split())) def max_heapify(A, i): l = i * 2 r = i * 2 + 1 largest = i if l < H: if A[l] > A[largest]: largest = l if r < H: if A[r] > A[largest]: largest = r if largest != i: A[i], A[largest] = A[largest], A[i] max_heapify(A, largest) def build_max_heap(A): for i in reversed(range(1, int(H / 2))): max_heapify(A, i) build_max_heap(A) print(" ", end = "") print(*A[1:])
s320131823
Accepted
870
65,520
443
H = int(input()) A = [None] + list(map(int, input().split())) def max_heapify(A, i): l = i * 2 r = i * 2 + 1 largest = i if l <= H: if A[l] > A[largest]: largest = l if r <= H: if A[r] > A[largest]: largest = r if largest != i: A[i], A[largest] = A[largest], A[i] max_heapify(A, largest) def build_max_heap(A): for i in range(int(H / 2), 0, -1): max_heapify(A, i) build_max_heap(A) print(" ", end = "") print(*A[1:])
s665684049
p02388
u217701374
1,000
131,072
Wrong Answer
20
7,456
36
Write a program which calculates the cube of a given integer x.
X = input() XX = int(X) print(XX**2)
s055602763
Accepted
30
7,436
28
X = int(input()) print(X**3)
s703581102
p03672
u823885866
2,000
262,144
Wrong Answer
123
27,232
571
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
import sys import math import itertools import collections import heapq import re import numpy as np from functools import reduce rr = lambda: sys.stdin.readline().rstrip() rs = lambda: sys.stdin.readline().split() ri = lambda: int(sys.stdin.readline()) rm = lambda: map(int, sys.stdin.readline().split()) rl = lambda: list(map(int, sys.stdin.readline().split())) inf = float('inf') mod = 10**9 + 7 s = rr() lens = len(s) for i in range(2, lens, 2): if s[:(lens - i) // 2] == s[(lens - i) // 2:lens - i]: print(s[:(lens - i) // 2]) exit()
s349019523
Accepted
117
27,024
560
import sys import math import itertools import collections import heapq import re import numpy as np from functools import reduce rr = lambda: sys.stdin.readline().rstrip() rs = lambda: sys.stdin.readline().split() ri = lambda: int(sys.stdin.readline()) rm = lambda: map(int, sys.stdin.readline().split()) rl = lambda: list(map(int, sys.stdin.readline().split())) inf = float('inf') mod = 10**9 + 7 s = rr() lens = len(s) for i in range(2, lens, 2): if s[:(lens - i) // 2] == s[(lens - i) // 2:lens - i]: print(lens - i) exit()
s821724035
p02613
u121698457
2,000
1,048,576
Wrong Answer
159
9,220
329
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
N = int(input()) lis = [0,0,0,0] for i in range(N): s = input() if s == 'AC': lis[0] += 1 elif s == 'WA': lis[1] += 1 elif s == 'TLE': lis[2] += 1 else: lis[3] += 1 print('AC × '+str(lis[0])) print('WA × '+str(lis[1])) print('TLE × '+str(lis[2])) print('RE × '+str(lis[3]))
s817687512
Accepted
150
9,216
325
N = int(input()) lis = [0,0,0,0] for i in range(N): s = input() if s == 'AC': lis[0] += 1 elif s == 'WA': lis[1] += 1 elif s == 'TLE': lis[2] += 1 else: lis[3] += 1 print('AC x '+str(lis[0])) print('WA x '+str(lis[1])) print('TLE x '+str(lis[2])) print('RE x '+str(lis[3]))
s086701566
p03567
u289162337
2,000
262,144
Wrong Answer
19
2,940
110
Snuke built an online judge to hold a programming contest. When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.) Determine whether the judge can return the string `AC` as the verdict to a program.
l = input() for i in range(len(l)-1): if l[i:i+1] == "AC": print("Yes") break else: print("No")
s093320305
Accepted
17
2,940
110
l = input() for i in range(len(l)-1): if l[i:i+2] == "AC": print("Yes") break else: print("No")
s747206541
p03827
u428855582
2,000
262,144
Wrong Answer
17
3,060
165
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
N = int(input()) tex=list(input()) print(tex) max=0 cur=0 for i in range(N): if tex[i]=="I": cur+=1 if cur>max: max=cur else: cur-=1 print(max)
s196415922
Accepted
17
2,940
154
N = int(input()) tex=list(input()) max=0 cur=0 for i in range(N): if tex[i]=="I": cur+=1 if cur>max: max=cur else: cur-=1 print(max)
s669016410
p03478
u086051538
2,000
262,144
Wrong Answer
37
3,060
153
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
n,a,b=map(int,input().split()) counter=0 for m in range(1,n): s=str(m) array=list(map(int,s)) if a<=sum(array)<=b: counter+=m print(counter)
s349476052
Accepted
39
3,060
152
n,a,b=map(int,input().split()) counter=0 for m in range(1,n+1): s=str(m) array=list(map(int,s)) if a<=sum(array)<=b: counter+=m print(counter)
s182840676
p03861
u355137116
2,000
262,144
Wrong Answer
2,108
2,940
114
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
a, b, x = map(int, input().split()) count = 0 for i in range(a, a+b): if i % x == 0: count += 1 print(count)
s795591470
Accepted
17
2,940
52
a,b,x=map(int,input().split()) print(b//x-(a-1)//x)
s873237740
p03470
u128859393
2,000
262,144
Wrong Answer
18
2,940
56
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
input();print(len(set(list(map(int, input().split())))))
s210294486
Accepted
18
2,940
78
N = int(input());print(len(set(list(map(int, [input() for _ in range(N)])))))
s306991627
p03673
u073775598
2,000
262,144
Wrong Answer
2,104
26,020
219
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
#ABC066C n=int(input()) a=list(map(int, input().split())) front=[] back=[] for i in range(n//2): front.insert(0, a[2*i-(n%2)+1]) back.append(a[2*i+(n%2)]) if n%2==1: front.insert(0, a[n-1]) print(front+back)
s407702260
Accepted
166
31,296
264
#ABC066C n=int(input()) a=list(map(int, input().split())) flg=n%2 half=n//2 front=[0]*(half+flg) back=[0]*(half) for i in range(half): front[half+flg-1-i]=a[2*i-flg+1] back[i]=a[2*i+flg] if flg==1: front[0]=a[n-1] print(' '.join(map(str, front+back)))
s148626339
p02259
u867503285
1,000
131,072
Wrong Answer
20
7,704
377
Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 4 of the pseudocode.
def bubble_sort(target): flag = True while flag: flag = False for i in range(len(target)-1, 0, -1): if target[i] < target[i-1]: target[i-1], target[i] = target[i], target[i-1] flag = True return target N = int(input()) A = [int(s) for s in input().split()] print(' '.join(str(s) for s in bubble_sort(A)))
s234341462
Accepted
30
7,712
436
def bubble_sort(target): global cnt flag = True while flag: flag = False for i in range(len(target)-1, 0, -1): if target[i] < target[i-1]: target[i-1], target[i] = target[i], target[i-1] flag = True cnt += 1 return target N = int(input()) A = [int(s) for s in input().split()] cnt = 0 print(' '.join(str(s) for s in bubble_sort(A))) print(cnt)
s417770317
p03997
u583507988
2,000
262,144
Wrong Answer
17
2,940
83
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a = int(input()) b = int(input()) h = int(input()) ans = (a + b)*h / 2 print(ans)
s348464550
Accepted
27
8,876
73
a = int(input()) b = int(input()) h = int(input()) print(int((a+b)*h/2))
s053347144
p03436
u390694622
2,000
262,144
Wrong Answer
31
4,972
2,033
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player 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 `#`.
# coding: UTF-8 #@document_it from collections import deque def document_it(func): def new_function(*args,**kwargs): print('Running function:', func.__name__) print('Positional arguments:', args) print('Kewword arguments:', kwargs) result = func(*args,**kwargs) print('Result:', result) return result return new_function ########################### #@document_it def nb(i,j,H,W): ans = [] a = i+1 b = i-1 c = j+1 d = j-1 if a >= 0 and a <= H-1: ans.append((a,j)) if b >= 0 and b <= H-1: ans.append((b,j)) if c >= 0 and c <= W-1: ans.append((i,c)) if d >= 0 and d <= W-1: ans.append((i,d)) return ans def e(): dist={} white = {} wtotal = 0 H,W = map(int,input().split()) for i in range(H): row = input() for j in range(W): dist[(i,j)] = -1 if row[j] == '.': white[(i,j)] = True wtotal += 1 else: white[(i,j)] = False #tuple -> [tuple] link = {} for i in range(H): for j in range(W): link[(i,j)] = [] if not white[(i,j)]: continue else: nlist = nb(i,j,H,W) for p in nlist: if white[p]: link[(i,j)].append(p) q = deque() dist[(0,0)] = 1 q.append((0,0)) while q: v = q.popleft() for w in link[v]: if dist[w] == -1: dist[w] = dist[v] + 1 q.append(w) #print(w,dist[w]) if dist[(H-1,W-1)] != -1: ans = wtotal - dist[(H-1,W-1)] else: ans = -1 print(wtotal) print(dist[(H-1,W-1)]) print(ans) ########################### if __name__ == '__main__': e()
s493427038
Accepted
32
4,972
2,035
# coding: UTF-8 #@document_it from collections import deque def document_it(func): def new_function(*args,**kwargs): print('Running function:', func.__name__) print('Positional arguments:', args) print('Kewword arguments:', kwargs) result = func(*args,**kwargs) print('Result:', result) return result return new_function ########################### #@document_it def nb(i,j,H,W): ans = [] a = i+1 b = i-1 c = j+1 d = j-1 if a >= 0 and a <= H-1: ans.append((a,j)) if b >= 0 and b <= H-1: ans.append((b,j)) if c >= 0 and c <= W-1: ans.append((i,c)) if d >= 0 and d <= W-1: ans.append((i,d)) return ans def e(): dist={} white = {} wtotal = 0 H,W = map(int,input().split()) for i in range(H): row = input() for j in range(W): dist[(i,j)] = -1 if row[j] == '.': white[(i,j)] = True wtotal += 1 else: white[(i,j)] = False #tuple -> [tuple] link = {} for i in range(H): for j in range(W): link[(i,j)] = [] if not white[(i,j)]: continue else: nlist = nb(i,j,H,W) for p in nlist: if white[p]: link[(i,j)].append(p) q = deque() dist[(0,0)] = 1 q.append((0,0)) while q: v = q.popleft() for w in link[v]: if dist[w] == -1: dist[w] = dist[v] + 1 q.append(w) #print(w,dist[w]) if dist[(H-1,W-1)] != -1: ans = wtotal - dist[(H-1,W-1)] else: ans = -1 #print(wtotal) #print(dist[(H-1,W-1)]) print(ans) ########################### if __name__ == '__main__': e()
s283701514
p03129
u529722835
2,000
1,048,576
Wrong Answer
17
2,940
214
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
N , K = (int(i) for i in input().split()) if N % 2 == 0: if N/2 >= K: print('Yes') else: print('No') elif N % 2 == 1: if N/2 +1 >=K: print('Yes') else: print('No')
s644212455
Accepted
17
2,940
206
N , K = map(int, input().split()) if N % 2 == 0: if N//2 >= K: print('YES') else: print('NO') elif N % 2 == 1: if N//2 +1 >= K: print('YES') else: print('NO')
s167669248
p02382
u175224634
1,000
131,072
Wrong Answer
20
5,640
392
Your task is to calculate the distance between two $n$ dimensional vectors $x = \\{x_1, x_2, ..., x_n\\}$ and $y = \\{y_1, y_2, ..., y_n\\}$. The Minkowski's distance defined below is a metric which is a generalization of both the Manhattan distance and the Euclidean distance. \\[ D_{xy} = (\sum_{i=1}^n |x_i - y_i|^p)^{\frac{1}{p}} \\] It can be the Manhattan distance \\[ D_{xy} = |x_1 - y_1| + |x_2 - y_2| + ... + |x_n - y_n| \\] where $p = 1 $. It can be the Euclidean distance \\[ D_{xy} = \sqrt{(|x_1 - y_1|)^{2} + (|x_2 - y_2|)^{2} + ... + (|x_n - y_n|)^{2}} \\] where $p = 2 $. Also, it can be the Chebyshev distance \\[ D_{xy} = max_{i=1}^n (|x_i - y_i|) \\] where $p = \infty$ Write a program which reads two $n$ dimensional vectors $x$ and $y$, and calculates Minkowski's distance where $p = 1, 2, 3, \infty$ respectively.
num = int(input()) x = list(map(int, input().split())) y = list(map(int, input().split())) first = second = third = inf = 0.00000 for i in range(num): dif = x[i] - y[i] first = first + abs(dif) second = second + dif ** 2 third = third + abs(dif) ** 3 inf = max(inf, abs(dif)) print(float(first)) print(float(second ** 0.5)) print(float(third ** 0.3333)) print(float(inf))
s511735875
Accepted
20
5,644
446
num = int(input()) x = list(map(int, input().split())) y = list(map(int, input().split())) first = second = third = inf = 0.00000 for i in range(num): dif = x[i] - y[i] first = first + abs(dif) second = second + dif ** 2 third = third + abs(dif) ** 3 inf = max(inf, abs(dif)) print('{:.6f}'.format(first)) print('{:.6f}'.format(second ** 0.5)) print('{:.6f}'.format(third ** 0.333333333333333333)) print('{:.6f}'.format(inf))
s360370923
p03485
u058592821
2,000
262,144
Wrong Answer
17
2,940
61
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
a, b = (int(i) for i in input().split()) print((a+b)//2 + 1)
s248305135
Accepted
17
2,940
104
a, b = (int(i) for i in input().split()) if (a+b) % 2 == 0: print((a+b)//2) else: print((a+b)//2+1)
s640976574
p03682
u010110540
2,000
262,144
Wrong Answer
1,775
71,624
916
There are N towns on a plane. The i-th town is located at the coordinates (x_i,y_i). There may be more than one town at the same coordinates. You can build a road between two towns at coordinates (a,b) and (c,d) for a cost of min(|a-c|,|b-d|) yen (the currency of Japan). It is not possible to build other types of roads. Your objective is to build roads so that it will be possible to travel between every pair of towns by traversing roads. At least how much money is necessary to achieve this?
from operator import itemgetter from collections import deque N = int(input()) xs, ys = [], [] for _ in range(N): x, y = map(int, input().split()) xs.append(x) ys.append(y) xis = sorted(list(enumerate(xs)), key = itemgetter(1)) yis = sorted(list(enumerate(ys)), key = itemgetter(1)) xds, yds = [], [] for i in range(N-1): xds.append((xis[i+1][1] - xis[i][1], (xis[i][0], xis[i+1][0]))) yds.append((yis[i+1][1] - yis[i][1], (yis[i][0], yis[i+1][0]))) xdq, ydq = deque(sorted(xds)), deque(sorted(yds)) par = list(range(N)) def find(x): if x == par[x]: return x else: par[x] = find(par[x]) return par[x] def union(x,y): rx, ry = find(x), find(y) par[ry] = rx ans = 0 while xdq or ydq: if xdq and (not ydq or xdq[0] < ydq[0]): d, (i,j) = xdq.popleft() else: d, (i,j) = ydq.popleft() ans += d union(i,j) print(ans)
s700004986
Accepted
1,462
71,680
963
from operator import itemgetter from collections import deque N = int(input()) xs, ys = [], [] for _ in range(N): x, y = map(int, input().split()) xs.append(x) ys.append(y) xis = sorted(list(enumerate(xs)), key = itemgetter(1)) yis = sorted(list(enumerate(ys)), key = itemgetter(1)) xds, yds = [], [] for i in range(N-1): xds.append((xis[i+1][1] - xis[i][1], (xis[i][0], xis[i+1][0]))) yds.append((yis[i+1][1] - yis[i][1], (yis[i][0], yis[i+1][0]))) xdq, ydq = deque(sorted(xds)), deque(sorted(yds)) par = list(range(N)) def find(x): if x == par[x]: return x else: par[x] = find(par[x]) return par[x] def union(x,y): rx, ry = find(x), find(y) par[ry] = rx ans = 0 while xdq or ydq: if xdq and (not ydq or xdq[0] < ydq[0]): d, (i,j) = xdq.popleft() else: d, (i,j) = ydq.popleft() if find(i) != find(j): ans += d union(i,j) print(ans)
s453147054
p02390
u499005012
1,000
131,072
Wrong Answer
30
6,724
160
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
sec_input = int(input()) hour = sec_input // (60 * 60) remain = sec_input % (60 * 60) min = remain // 60 sec = remain % 60 print('%d %d %d' % (hour, min, sec))
s271598879
Accepted
30
6,724
160
sec_input = int(input()) hour = sec_input // (60 * 60) remain = sec_input % (60 * 60) min = remain // 60 sec = remain % 60 print('%d:%d:%d' % (hour, min, sec))
s062931461
p03369
u268977772
2,000
262,144
Wrong Answer
18
3,064
25
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is 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.
print(input().count("o"))
s102310484
Accepted
17
2,940
33
print(700+100*input().count("o"))
s039997399
p03607
u957084285
2,000
262,144
Wrong Answer
2,104
6,244
518
You are playing the following game with Joisino. * Initially, you have a blank sheet of paper. * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. * Then, you are asked a question: How many numbers are written on the sheet now? The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?
N = int(input()) l = [] for _ in range(N): a = int(input()) if len(l) == 0: l.append(a) continue lo = 0 hi = len(l) mid = (lo+hi) // 2 removed = False p = (1, 0) while not p == (lo, hi): p = (lo, hi) mid = (lo+hi) // 2 if l[mid] == a: l.pop(mid) removed = True break if l[mid] < a: lo = mid else: hi = mid if not removed: l.insert(mid+1, a) print(len(l))
s502706855
Accepted
252
15,072
198
N = int(input()) dict = {} for _ in range(N): x = int(input()) if x in dict.keys(): dict[x] += 1 else: dict[x] = 1 print(sum(list(map(lambda x : x%2, dict.values()))))
s076845672
p03494
u877428733
2,000
262,144
Wrong Answer
19
2,940
135
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
N = int(input()) A = list(map(int,input().split())) for i in A: p = 0 while i % 2 == 0: i //= 2 p += 1 print(p)
s612139143
Accepted
18
3,060
181
ans = 10**9 N = int(input()) A = list(map(int,input().split())) for i in A: p = 0 while i % 2 == 0: i //= 2 p += 1 if p < ans: ans = p print(ans)
s820901937
p02406
u744506422
1,000
131,072
Wrong Answer
20
5,600
301
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
import sys n=int(input()) a=[] for i in range(1,n+1): if (i%3==0): a.append(i) else: j=str(i) for k in range(len(j)-1): if j[k]=="3": a.append(i) break for i in a: sys.stdout.write(" {0}".format(i)) sys.stdout.write("\n")
s563559353
Accepted
30
5,952
299
import sys n=int(input()) a=[] for i in range(1,n+1): if (i%3==0): a.append(i) else: j=str(i) for k in range(len(j)): if j[k]=="3": a.append(i) break for i in a: sys.stdout.write(" {0}".format(i)) sys.stdout.write("\n")
s313708272
p02612
u583276018
2,000
1,048,576
Wrong Answer
32
9,140
93
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
n = int(input()) a = 0 while(a < n): a += 1000 print(a)
s106221689
Accepted
26
9,148
94
n = int(input()) a = 0 while(a < n): a += 1000 print(a-n)
s387310568
p02536
u168416324
2,000
1,048,576
Wrong Answer
438
26,544
486
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: * Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?
n,m=map(int,input().split()) global fri fri=[] global tab tab=[0]*n def run(nn): #print(tab) global cnt if tab[nn]: return tab[nn]=1 cnt+=1 for i in fri[nn]: que.append(i) for i in range(n): fri.append([]) for i in range(m): a,b=map(int,input().split()) fri[a-1].append(b-1) fri[b-1].append(a-1) i=0 mx=0 cc=0 while i<n: if tab[i]: i+=1 continue que=[i] cnt=0 while len(que)!=0: run(que.pop()) mx=max(cnt,mx) i+=1 cc+=1 print(cc)
s806304431
Accepted
413
26,548
488
n,m=map(int,input().split()) global fri fri=[] global tab tab=[0]*n def run(nn): #print(tab) global cnt if tab[nn]: return tab[nn]=1 cnt+=1 for i in fri[nn]: que.append(i) for i in range(n): fri.append([]) for i in range(m): a,b=map(int,input().split()) fri[a-1].append(b-1) fri[b-1].append(a-1) i=0 mx=0 cc=0 while i<n: if tab[i]: i+=1 continue que=[i] cnt=0 while len(que)!=0: run(que.pop()) mx=max(cnt,mx) i+=1 cc+=1 print(cc-1)
s728214782
p02612
u321492259
2,000
1,048,576
Wrong Answer
28
9,048
40
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
i = int(input()) a = i-(i%1000) print(a)
s816376708
Accepted
26
9,000
38
print((1000-(int(input())%1000))%1000)
s052000604
p02273
u022407960
2,000
131,072
Wrong Answer
20
7,984
1,216
Write a program which reads an integer _n_ and draws a Koch curve based on recursive calles of depth _n_. The Koch curve is well known as a kind of You should start (0, 0), (100, 0) as the first segment.
# encoding: utf-8 import sys import math _input = sys.stdin.readlines() depth = int(_input[0]) sin_60, cos_60 = math.sin(math.pi / 3), math.cos(math.pi / 3) class Point(object): def __init__(self, x=0.0, y=0.0): """ initialize the point """ self.x = float(x) self.y = float(y) def koch_curve(d, p1, p2): if not d: return None s, t, u = Point(), Point, Point() s.x = (2 * p1.x + p2.x) / 3 s.y = (2 * p1.y + p2.y) / 3 t.x = (p1.x + 2 * p2.x) / 3 t.y = (p1.y + 2 * p2.y) / 3 u.x = (t.x - s.x) * cos_60 - (t.y - s.y) * sin_60 + s.x u.y = (t.x - s.x) * sin_60 + (t.y - s.y) * cos_60 + s.y koch_curve(d - 1, p1, s) print(format(s.x, '.8f'), '', format(s.y, '.8f')) koch_curve(d - 1, s, u) print(format(u.x, '.8f'), '', format(u.y, '.8f')) koch_curve(d - 1, u, t) print(format(t.x, '.8f'), '', format(t.y, '.8f')) koch_curve(d - 1, t, p2) if __name__ == '__main__': p1_start, p2_end = Point(x=0, y=0), Point(x=100, y=0) print(format(p1_start.x, '.8f'), '', format(p1_start.y, '.8f')) koch_curve(depth, p1_start, p2_end) print(format(p2_end.x, '.8f'), '', format(p2_end.y, '.8f'))
s545016471
Accepted
30
8,044
1,677
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 2 output: 0.00000000 0.00000000 11.11111111 0.00000000 16.66666667 9.62250449 22.22222222 0.00000000 33.33333333 0.00000000 38.88888889 9.62250449 33.33333333 19.24500897 44.44444444 19.24500897 50.00000000 28.86751346 55.55555556 19.24500897 66.66666667 19.24500897 61.11111111 9.62250449 66.66666667 0.00000000 77.77777778 0.00000000 83.33333333 9.62250449 88.88888889 0.00000000 100.00000000 0.00000000 """ import sys import math class Point(object): __slots__ = ('x', 'y') def __init__(self, x=-1, y=-1): """ Initialize the point """ self.x = float(x) self.y = float(y) def koch_curve(d, p1, p2): if not d: return None s, t, u = (Point() for _ in range(3)) s.x = (2 * p1.x + p2.x) / 3 s.y = (2 * p1.y + p2.y) / 3 t.x = (p1.x + 2 * p2.x) / 3 t.y = (p1.y + 2 * p2.y) / 3 u.x = (t.x - s.x) * COS_60 - (t.y - s.y) * SIN_60 + s.x u.y = (t.x - s.x) * SIN_60 + (t.y - s.y) * COS_60 + s.y koch_curve(d - 1, p1, s) print('{0:.8f} {1:.8f}'.format(s.x, s.y)) koch_curve(d - 1, s, u) print('{0:.8f} {1:.8f}'.format(u.x, u.y)) koch_curve(d - 1, u, t) print('{0:.8f} {1:.8f}'.format(t.x, t.y)) koch_curve(d - 1, t, p2) if __name__ == '__main__': _input = sys.stdin.readlines() depth = int(_input[0]) SIN_60, COS_60 = math.sin(math.pi / 3), math.cos(math.pi / 3) p1_start, p2_end = Point(x=0, y=0), Point(x=100, y=0) print(format(p1_start.x, '.8f'), format(p1_start.y, '.8f')) koch_curve(depth, p1_start, p2_end) print(format(p2_end.x, '.8f'), format(p2_end.y, '.8f'))
s677521189
p02843
u767664985
2,000
1,048,576
Wrong Answer
17
2,940
85
AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible. (Ignore consumption tax.)
X = int(input()) X %= 105 X %= 104 X %= 103 X %= 102 X %= 101 X %= 100 print(X == 0)
s538338553
Accepted
17
2,940
209
X = int(input()) q, r = X//100, X%100 if r <= 5 * q: print(1) else: print(0)
s665456548
p02841
u912134329
2,000
1,048,576
Wrong Answer
18
2,940
148
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month.
xy = [map(int,input().split()) for i in range(2)] x,y = [list(j) for j in zip(*xy)] if (x[1] + 1) == y[1] : ans = 0 else: ans = 1 print(ans)
s324996926
Accepted
17
2,940
148
xy = [map(int,input().split()) for i in range(2)] x,y = [list(j) for j in zip(*xy)] if (y[0] + 1) == y[1] : ans = 0 else: ans = 1 print(ans)
s381772622
p04045
u648452607
2,000
262,144
Wrong Answer
18
2,940
183
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier.
[n,k]=[int(_) for _ in input().split()] d=[int(_) for _ in input().split()] while True: t=str(n).split() for _t in t: if _t in d: n+=1 continue break print(n)
s655351272
Accepted
69
3,188
246
[n,k]=[int(_) for _ in input().split()] d=[int(_) for _ in input().split()] dt=list({_ for _ in range(10)}-set(d)) def c(n,l): for _c in str(n): if int(_c) not in l: return False return True while True: if c(n,dt): break n+=1 print(n)
s882911837
p02865
u061539997
2,000
1,048,576
Wrong Answer
17
2,940
24
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
print(int(input())-1//2)
s190104738
Accepted
17
2,940
26
print((int(input())-1)//2)
s470153980
p03485
u202877219
2,000
262,144
Wrong Answer
17
2,940
47
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
a,b = map(int, input().split()) print (a+b/(2))
s677467082
Accepted
20
3,060
70
import math a,b = map(int, input().split()) print (math.ceil((a+b)/2))
s026888211
p02612
u024609780
2,000
1,048,576
Wrong Answer
27
9,140
29
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
A =int(input()) print(1000-A)
s134204846
Accepted
34
9,152
73
a=int(input()) if(a%1000!=0): print(1000-(a%1000)) else: print(0)
s651316596
p02975
u648212584
2,000
1,048,576
Wrong Answer
149
18,584
605
Snuke has N hats. The i-th hat has an integer a_i written on it. There are N camels standing in a circle. Snuke will put one of his hats on each of these camels. If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `Yes`; otherwise, print `No`. * The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself. What is XOR? The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non- negative integers x_1, x_2, \ldots, x_n is defined as follows: - When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3 \oplus 5 = 6.
import collections N = int(input()) a = list(map(int,input().split())) a = collections.Counter(a) a_list = list(a.items()) a_list = sorted(a_list,key = lambda a_list:a_list[0]) print(a_list) if len(a_list) == 1: if a_list[0][0] == 0: print("Yes") else: print("No") elif len(a_list) == 2: if ((a_list[0][0] == 0) and (a_list[0][1] == int(N/3)) and \ (a_list[1][1] == int(2*N/3))): print("Yes") else: print("No") elif len(a_list) == 3: if (a_list[0][1] == int(N/3)) and \ (a_list[1][1] == int(N/3) and \ a_list[2][1] == int(N/3)): print("Yes") else: print("No") else: print("No")
s630406752
Accepted
106
16,164
648
import collections N = int(input()) a = list(map(int,input().split())) a = collections.Counter(a) a_list = list(a.items()) a_list = sorted(a_list,key = lambda a_list:a_list[0]) if len(a_list) == 1: if a_list[0][0] == 0: print("Yes") else: print("No") elif len(a_list) == 2: if ((a_list[0][0] == 0) and (a_list[0][1] == int(N/3)) and \ (a_list[1][1] == int(2*N/3))): print("Yes") else: print("No") elif len(a_list) == 3: if ((a_list[0][1] == int(N/3)) and \ (a_list[1][1] == int(N/3)) and \ (a_list[2][1] == int(N/3)) and \ (a_list[0][0]^a_list[1][0]^a_list[2][0] == 0)): print("Yes") else: print("No") else: print("No")
s880346686
p03379
u951480280
2,000
262,144
Wrong Answer
290
25,220
132
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
n=int(input()) m=n//2 x=sorted(map(int,input().split())) for i in range(m): print(x[m-1]) for i in range(m,n): print(x[m])
s133309184
Accepted
343
25,472
260
n=int(input()) x=list(map(int,input().split())) x1=sorted(x) mid=n//2 if n>2: for i in range(n): if x[i] < x1[mid]:print(x1[mid]) else:print(x1[mid-1]) else: for i in range(n): x2=x.copy() x2.pop(i) print(x2[0])
s442997465
p03719
u599547273
2,000
262,144
Wrong Answer
17
2,940
87
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
a, b, c = input().split(" ") print("Yes" if a[-1] == b[0] and b[-1] == c[0] else "No")
s377329033
Accepted
17
2,940
77
a, b, c = map(int, input().split(" ")) print("Yes" if a <= c <= b else "No")
s015158651
p02261
u922112509
1,000
131,072
Wrong Answer
20
5,608
1,256
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the 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).
# Stable Sort length = int(input()) cards = input().rstrip().split() cards1 = [card for card in cards] cards2 = [card for card in cards] def value(n): number = n[1:] return int(number) def char(cards): charSets = [[] for i in range(10)] for i in range(length): char = cards[i][:1] val = value(cards[i]) charSets[val].append(char) return charSets def bubble(cards): for i in range(length): j = length - 1 while j > i: if value(cards[j]) < value(cards[j - 1]): cards[j], cards[j - 1] = cards[j - 1], cards[j] j -= 1 return cards def selection(cards): # count = 0 for i in range(length): minj = i for j in range(i, length): if value(cards[j]) < value(cards[minj]): minj = j # count += 1 cards[i], cards[minj] = cards[minj], cards[i] return cards def stable(cards1, cards2): if char(cards1) == char(cards2): return 'Stable' else: return 'Not stable' c = cards b = bubble(cards1) s = selection(cards2) print(b) print(stable(c, b)) print(s) print(stable(c, s))
s230943537
Accepted
20
5,612
1,276
# Stable Sort length = int(input()) cards = input().rstrip().split() cards1 = [card for card in cards] cards2 = [card for card in cards] def value(n): number = n[1:] return int(number) def char(cards): charSets = [[] for i in range(10)] for i in range(length): char = cards[i][:1] val = value(cards[i]) charSets[val].append(char) return charSets def bubble(cards): for i in range(length): j = length - 1 while j > i: if value(cards[j]) < value(cards[j - 1]): cards[j], cards[j - 1] = cards[j - 1], cards[j] j -= 1 return cards def selection(cards): # count = 0 for i in range(length): minj = i for j in range(i, length): if value(cards[j]) < value(cards[minj]): minj = j # count += 1 cards[i], cards[minj] = cards[minj], cards[i] return cards def stable(cards1, cards2): if char(cards1) == char(cards2): return 'Stable' else: return 'Not stable' c = cards b = bubble(cards1) s = selection(cards2) print(' '.join(b)) print(stable(c, b)) print(' '.join(s)) print(stable(c, s))
s749413787
p03719
u280512618
2,000
262,144
Wrong Answer
17
2,940
70
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
a,b,c=map(int,input().split()) print('Yes' if a<=b and b<=c else 'No')
s496988763
Accepted
17
2,940
70
a,b,c=map(int,input().split()) print('Yes' if a<=c and c<=b else 'No')
s907738523
p03698
u578501242
2,000
262,144
Wrong Answer
17
3,064
141
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
a=input() b=[str(c) for c in a] b.sort() c=len(b) d=0 for i in range(c-1): if b[i]==b[i+1]: d=d+1 if d>0: print('No') else: print('Yes')
s566512555
Accepted
17
3,060
141
a=input() b=[str(c) for c in a] b.sort() c=len(b) d=0 for i in range(c-1): if b[i]==b[i+1]: d=d+1 if d>0: print('no') else: print('yes')
s483321246
p02613
u699458609
2,000
1,048,576
Wrong Answer
146
9,220
317
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
ans = {"AC": 0, "WA": 0, "TLE": 0, "RE":0} N = int(input()) for i in range(N): inpt = input() if(inpt == "AC"): ans["AC"] += 1 elif(inpt == "WA"): ans["WA"] += 1 elif(inpt == "TLE"): ans["TLE"] += 1 else: ans["RE"] += 1 for key, value in ans.items(): print("{0} × {1}".format(key, value))
s504609997
Accepted
147
9,196
317
ans = {"AC": 0, "WA": 0, "TLE": 0, "RE":0} N = int(input()) for i in range(N): inpt = input() if(inpt == "AC"): ans["AC"] += 1 elif(inpt == "WA"): ans["WA"] += 1 elif(inpt == "TLE"): ans["TLE"] += 1 else: ans["RE"] += 1 for key, value in ans.items(): print("{0} x {1}".format(key, value))
s189088229
p04029
u522266410
2,000
262,144
Wrong Answer
17
2,940
41
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
N = int(input()) x = (N*(N+1)/2) print(x)
s247537123
Accepted
17
2,940
42
N = int(input()) print(round(N*(N+1)/2))
s802654231
p03352
u639592190
2,000
1,048,576
Wrong Answer
19
2,940
120
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
X=int(input()) ans=0 for b in range(1,int(X**(1/2))+1): for p in range(2,int(X/b)+1): ans=max(ans,b**p) print(ans)
s056851537
Accepted
19
2,940
138
X=int(input()) ans=1 for b in range(1,int(X**(1/2))+1): for p in range(2,int(X/b)+1): if b**p<=X: ans=max(ans,b**p) print(ans)
s353504961
p03351
u245641078
2,000
1,048,576
Wrong Answer
17
2,940
105
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
a,b,c,d=map(int, input().split()) if (abs(a-b))>=d and (abs(b-c))>=d: print("Yes") else: print("No")
s057263221
Accepted
17
2,940
107
a,b,c,d = map(int,input().split()) print("Yes" if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d) else 'No')
s457192567
p03379
u198274496
2,000
262,144
Wrong Answer
219
25,620
135
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
N = int(input()) X = list(map(int, input().split())) d = N // 2 a = X[d] b = X[d - 1] for i in range(N): print(a if i < d else b)
s939585290
Accepted
303
25,556
146
N = int(input()) X = list(map(int, input().split())) sX = sorted(X) d = N // 2 a = sX[d] b = sX[d - 1] for c in X: print(a if c < a else b)
s581085867
p03605
u941884460
2,000
262,144
Wrong Answer
17
2,940
73
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
N = input() if N[0] != 9 and N[1] !=9: print('No') else: print('Yes')
s406750189
Accepted
17
2,940
83
N = input() if (N[0] != '9') and (N[1] != '9'): print('No') else: print('Yes')
s207367334
p03943
u310394471
2,000
262,144
Wrong Answer
17
2,940
111
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. 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 or A+C ==B or B+C == A: print('Yec') else: print('No')
s788674686
Accepted
17
2,940
111
A,B,C = map(int, input().split()) if A+B == C or A+C ==B or B+C == A: print('Yes') else: print('No')
s283013996
p03555
u344959959
2,000
262,144
Wrong Answer
29
8,960
109
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
a=input() b=input() if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]: print("Yes") else: print("No")
s009893011
Accepted
26
8,912
109
a=input() b=input() if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]: print("YES") else: print("NO")
s054543085
p03638
u648315264
2,000
262,144
Wrong Answer
38
9,508
977
We have a grid with H rows and W columns of squares. Snuke is painting these squares in colors 1, 2, ..., N. Here, the following conditions should be satisfied: * For each i (1 ≤ i ≤ N), there are exactly a_i squares painted in Color i. Here, a_1 + a_2 + ... + a_N = H W. * For each i (1 ≤ i ≤ N), the squares painted in Color i are _4-connected_. That is, every square painted in Color i can be reached from every square painted in Color i by repeatedly traveling to a horizontally or vertically adjacent square painted in Color i. Find a way to paint the squares so that the conditions are satisfied. It can be shown that a solution always exists.
import math from math import gcd,pi,sqrt INF = float("inf") import sys sys.setrecursionlimit(10**6) import itertools from collections import Counter,deque def i_input(): return int(input()) def i_map(): return map(int, input().split()) def i_list(): return list(i_map()) def i_row(N): return [i_input() for _ in range(N)] def i_row_list(N): return [i_list() for _ in range(N)] def s_input(): return input() def s_map(): return input().split() def s_list(): return list(s_map()) def s_row(N): return [s_input for _ in range(N)] def s_row_str(N): return [s_list() for _ in range(N)] def s_row_list(N): return [list(s_input()) for _ in range(N)] def main(): h,w = i_map() n = i_input() a = i_list() ans = "" for m,i in enumerate(a): ans = ans + (str(m+1))*i for i in range(1,h+1): if i%2 == 0: print(ans[w*(i-1):w*(i-1)+w]) else: print(ans[w*(i-1):w*(i-1)+w][::-1]) if __name__=="__main__": main()
s125573206
Accepted
37
10,100
1,016
import math from math import gcd,pi,sqrt INF = float("inf") import sys sys.setrecursionlimit(10**6) import itertools from collections import Counter,deque def i_input(): return int(input()) def i_map(): return map(int, input().split()) def i_list(): return list(i_map()) def i_row(N): return [i_input() for _ in range(N)] def i_row_list(N): return [i_list() for _ in range(N)] def s_input(): return input() def s_map(): return input().split() def s_list(): return list(s_map()) def s_row(N): return [s_input for _ in range(N)] def s_row_str(N): return [s_list() for _ in range(N)] def s_row_list(N): return [list(s_input()) for _ in range(N)] def main(): h,w = i_map() n = i_input() a = i_list() ans = [] for m,i in enumerate(a): ans.extend([str(m+1)]*i) ans = list(ans) for i in range(1,h+1): if i%2 == 0: print(" ".join(ans[w*(i-1):w*(i-1)+w])) else: print(" ".join(ans[w*(i-1):w*(i-1)+w][::-1])) if __name__=="__main__": main()
s542722020
p03545
u532031128
2,000
262,144
Wrong Answer
17
3,064
381
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
s = input() A, B, C, D = int(s[0]), int(s[1]), int(s[2]), int(s[3]) print(A,B,C,D) N = 3 for i in range(2**N): sum = int(s[0]) f = s[0] for j in range(N): if i>>j & 1: sum += int(s[j+1]) f += "+" + s[j+1] else: sum -= int(s[j+1]) f += "-" + s[j+1] if sum == 7: print(f + "=7") break
s600470236
Accepted
18
3,064
366
s = input() A, B, C, D = int(s[0]), int(s[1]), int(s[2]), int(s[3]) N = 3 for i in range(2**N): sum = int(s[0]) f = s[0] for j in range(N): if i>>j & 1: sum += int(s[j+1]) f += "+" + s[j+1] else: sum -= int(s[j+1]) f += "-" + s[j+1] if sum == 7: print(f + "=7") break
s406518721
p03110
u547608423
2,000
1,048,576
Wrong Answer
18
2,940
180
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` 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()) answer=0 for i in range(N): x,u=input().split() print(x,u) if u=="JPY": answer+=int(x) else: answer+=float(x)*380000 print(answer)
s347225772
Accepted
17
2,940
181
N=int(input()) answer=0 for i in range(N): x,u=input().split() #print(x,u) if u=="JPY": answer+=int(x) else: answer+=float(x)*380000 print(answer)
s267494997
p03162
u816631826
2,000
1,048,576
Wrong Answer
370
3,060
128
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains.
a=int(input()) hahaha=0 for i in range(a): r=str(input()).split() m=[int(u) for u in r] hahaha+=max(m) print(hahaha)
s943774572
Accepted
570
24,308
372
if __name__ == '__main__': n = int(input()) res = [[0 for i in range(0, 3)] for i in range(0, n+1)] for i in range(1,n+1): x, y, z = map(int,input().split()) res[i][0] = max(res[i-1][1], res[i-1][2]) res[i][1] = max(res[i-1][0], res[i-1][2]) res[i][2] = max(res[i-1][0], res[i-1][1]) res[i][0]+=x res[i][1]+=y res[i][2]+=z r = max(res[-1]) print(r)
s921831180
p03478
u865741247
2,000
262,144
Wrong Answer
35
3,188
196
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
a,b,c=input().split(" ") nums=[] ans=0 b=int(b) c=int(c) a=int(a) for i in range(a): nums.append(sum(list(map(int,str(i))))) for j,n in enumerate(nums): if b<=n and n<=c: ans+=j print(ans)
s354171412
Accepted
35
3,188
198
a,b,c=input().split(" ") nums=[] ans=0 b=int(b) c=int(c) a=int(a) for i in range(a+1): nums.append(sum(list(map(int,str(i))))) for j,n in enumerate(nums): if b<=n and n<=c: ans+=j print(ans)
s746065987
p02409
u179070318
1,000
131,072
Wrong Answer
20
5,604
418
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
n = int(input()) info = [] for _ in range(n): temp = [int(x) for x in input().split( )] info.append(temp) state = [[[0 for i in range(10)] for j in range(3)] for k in range(4)] for a in info: state[a[0]-1][a[1]-1][a[2]-1] += a[3] for b in range(4): for f in range(3): string = '' for k in range(10): string += ' '+str(state[b][f][k]) print(string) print('#'*20)
s285361301
Accepted
20
5,608
439
n = int(input()) info = [] for _ in range(n): temp = [int(x) for x in input().split( )] info.append(temp) state = [[[0 for i in range(10)] for j in range(3)] for k in range(4)] for a in info: state[a[0]-1][a[1]-1][a[2]-1] += a[3] for b in range(4): for f in range(3): string = '' for k in range(10): string += ' ' + str(state[b][f][k]) print(string) if b < 3: print('#'*20)
s404858149
p04025
u733337827
2,000
262,144
Wrong Answer
17
3,064
321
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective.
sn = input() xyx = xx = -1 for i in range(1, len(sn)): if (xx == -1) and (sn[i-1] == sn[i]): xx = i-1 if xyx == -1 else i if (xyx == -1) and (i > 2) and (sn[i-2] == sn[i]): xyx = i-2 if xx == -1 else i if (xx == -1) or (xyx == -1): print(-1, -1) else: print(min(xx, xyx)+1, max(xx, xyx)+1)
s307444356
Accepted
18
2,940
172
N = int(input()) an = list(map(int, input().split())) ave = sum(an)/N rep = int(ave + 0.5) if ave > 0 else int(ave - 0.5) ans = sum([(a - rep) ** 2 for a in an]) print(ans)
s181801980
p03943
u366644013
2,000
262,144
Wrong Answer
17
2,940
127
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. 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.
na = lambda: list(map(int, input().split())) a, b, c = na() if a + b == c or b + c == a: print("Yes") else: print("No")
s181489652
Accepted
17
2,940
141
na = lambda: list(map(int, input().split())) a, b, c = na() if a + b == c or b + c == a or c + a == b: print("Yes") else: print("No")
s474250156
p03854
u131464432
2,000
262,144
Wrong Answer
40
9,584
316
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
S = input() A = "".join(list(reversed(S))) print(A) i = 0 while i != len(S): if A[i:i+5] == "maerd": i += 5 elif A[i:i+5] == "esare": i += 5 elif A[i:i+7] == "remaerd": i += 7 elif A[i:i+6] == "resare": i += 6 else: print("NO") exit() print("YES")
s127081809
Accepted
41
9,740
307
S = input() A = "".join(list(reversed(S))) i = 0 while i != len(S): if A[i:i+5] == "maerd": i += 5 elif A[i:i+5] == "esare": i += 5 elif A[i:i+7] == "remaerd": i += 7 elif A[i:i+6] == "resare": i += 6 else: print("NO") exit() print("YES")
s038042169
p03502
u655975843
2,000
262,144
Wrong Answer
17
2,940
129
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
n = input() N = list(n) n = int(n) ans = 0 for i in N: ans += int(i) if ans % n == 0: print('Yes') else: print('No')
s172231747
Accepted
18
2,940
129
n = input() N = list(n) n = int(n) ans = 0 for i in N: ans += int(i) if n % ans == 0: print('Yes') else: print('No')
s447094102
p03477
u475675023
2,000
262,144
Wrong Answer
18
2,940
93
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.
a,b,c,d=map(int,input().split()) print(["Left" if a+b>c+d else "Right","Balanced"][a+b!=c+d])
s736467779
Accepted
17
2,940
94
a,b,c,d=map(int,input().split()) print(["Left" if a+b>c+d else "Right","Balanced"][a+b==c+d])
s714748220
p03525
u780962115
2,000
262,144
Wrong Answer
21
3,064
1,436
In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the _time gap_ (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s.
#time gap n=int(input()) lists=list(map(int,input().split())) if n>24: print(0) else: timelist=[0 for i in range(13)] for i in lists: timelist[i]+=1 flag=True for j in range(13): if j==0 or j==12: if timelist[j]>1: flag=False else: if timelist[j]>2: flag=False if flag: uselist1=[] uselist2_=[] for i in range(13): if timelist[i]==1: uselist1.append((i)) if timelist[i]==2: uselist2_.append((i)) else: continue uselist2=[] for j in uselist2_: uselist2.append(j) uselist2.append(24-j) lens=len(uselist1) mini=100 for i in range(2**lens): sublist=[] sublist=sublist+uselist2 j=format(i,"0%ib"%lens) for k in range(lens): if j[k]=="0": sublist.append(uselist1[k]) else: sublist.append(24-uselist1[k]) sublist=sorted(sublist) lenss=len(sublist) for k in range(1,lenss): mini=min(mini,sublist[k]-sublist[k-1]) if n==1: print(lists[0]) else: print(mini) if not flag: print(0)
s256482777
Accepted
23
3,188
1,546
#time gap n=int(input()) lists=list(map(int,input().split())) if n>24: print(0) else: timelist=[0 for i in range(13)] for i in lists: timelist[i]+=1 flag=True for j in range(13): if j==0: if timelist[j]>0: flag=False else: if timelist[j]>2: flag=False if flag: uselist1=[] uselist2_=[] for i in range(13): if timelist[i]==1: uselist1.append((i)) if timelist[i]==2: uselist2_.append((i)) else: continue uselist2=[] for j in uselist2_: uselist2.append(j) uselist2.append(24-j) uselist2=list(set(uselist2)) lens=len(uselist1) minilist=[] for i in range(2**lens): sublist=[0] mini=100 sublist=sublist+uselist2 j=format(i,"0%ib"%lens) for k in range(lens): if j[k]=="0": sublist.append(uselist1[k]) else: sublist.append(24-uselist1[k]) sublists=sorted(sublist) lenss=len(sublists) for k in range(1,lenss): mini=min(mini,sublists[k]-sublists[k-1]) mini=min(mini,24-sublists[-1],sublists[-1]) minilist.append(mini) else: print(max(minilist)) if not flag: print(0)
s217271451
p03474
u366959492
2,000
262,144
Wrong Answer
18
2,940
168
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
a,b=map(int,input().split()) s=input() f=0 for i in s: if i=="-": f+=1 if len(s)==(a+b+1) and s[a+1]=="-" and f==1: print("Yes") else: print("No")
s271919856
Accepted
18
2,940
165
a,b=map(int,input().split()) s=input() f=0 for i in s: if i=="-": f+=1 if len(s)==(a+b+1) and s[a]=="-" and f==1: print("Yes") else: print("No")
s053741713
p03486
u665038048
2,000
262,144
Wrong Answer
17
3,060
151
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
s = list(input().split()) t = list(input().split()) s.sort() t.reverse() s = ''.join(s) t = ''.join(t) if s < t: print('Yes') else: print('No')
s316019867
Accepted
17
2,940
114
s = list(input()) t = list(input()) s.sort() t.sort(reverse=True) if s < t: print('Yes') else: print('No')
s825939856
p02842
u999503965
2,000
1,048,576
Wrong Answer
30
9,112
77
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
n=int(input()) num=n//1.08 if num*1.08==n: print(num) else: print(":(")
s289644465
Accepted
31
9,032
113
import math n=int(input()) num=math.ceil(n/1.08) if math.floor(num*1.08)==n: print(num) else: print(":(")
s385204468
p02972
u281610856
2,000
1,048,576
Wrong Answer
370
23,560
1,005
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
from heapq import heappush, heappop, heapify from itertools import permutations, accumulate, combinations from math import pi, ceil, floor import numpy as np from collections import defaultdict, deque from operator import itemgetter from bisect import bisect_left, bisect_right, insort_left, insort_right import sys input = sys.stdin.readline # MOD = 10 ** 9 + 7 # INF = float("inf") def main(): n = int(input()) A = list(map(int, input().split())) cnt = [0] * n B = deque([]) for i in range(n-1, -1, -1): if sum(cnt[i::i+1]) % 2 == A[i]: continue else: cnt[i] += 1 print(cnt) ans = [] for i, v in enumerate(cnt): if v > 1: print(-1) exit() elif v == 1: ans.append(i+1) else: continue if len(ans) == 0: print(len(ans)) else: print(len(ans)) print(*ans) if __name__ == '__main__': main()
s584141168
Accepted
358
23,136
926
from heapq import heappush, heappop, heapify from itertools import permutations, accumulate, combinations from math import pi, ceil, floor import numpy as np from collections import defaultdict, deque from operator import itemgetter from bisect import bisect_left, bisect_right, insort_left, insort_right import sys input = sys.stdin.readline # MOD = 10 ** 9 + 7 # INF = float("inf") def main(): n = int(input()) A = list(map(int, input().split())) cnt = [0] * n B = deque([]) for i in range(n-1, -1, -1): if sum(cnt[i::i+1]) % 2 == A[i]: continue else: cnt[i] += 1 ans = [] for i, v in enumerate(cnt): if v > 1: print(-1) exit() elif v == 1: ans.append(i+1) else: continue print(len(ans)) print(*ans) if __name__ == '__main__': main()
s607750759
p03024
u481605952
2,000
1,048,576
Wrong Answer
18
2,940
83
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
s = input() if s.count('x') >= 8: print('No') else: print('Yes')
s441963827
Accepted
18
2,940
74
s = input() if s.count('x') >= 8: print('NO') else: print('YES')
s311883184
p03719
u045953894
2,000
262,144
Wrong Answer
17
2,940
87
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
a,b,c=map(int,input().split()) if c >= a and c <= b: print('YES') else: print('NO')
s641444839
Accepted
17
2,940
77
a,b,c=map(int,input().split()) if a<=c<=b: print('Yes') else: print('No')
s502053571
p02865
u546686251
2,000
1,048,576
Wrong Answer
2,104
2,940
136
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
N = int(input()) count = 0 for i in range(N): for j in range(N): if i + j == N: count = count + 1 print(count/2)
s506778327
Accepted
355
2,940
118
N = int(input()) count = 0 for i in range(1, N): if i != N - i and i < N/2: count = count + 1 print(count)
s659009643
p04029
u389910364
2,000
262,144
Wrong Answer
157
13,556
302
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
from collections import Counter, deque from fractions import gcd from functools import lru_cache from functools import reduce import functools import heapq import itertools import math import numpy as np import sys sys.setrecursionlimit(10000) INF = float('inf') print(math.factorial(int(input())))
s454514060
Accepted
19
3,060
34
print(sum(range(int(input())+1)))
s096893028
p02393
u587193722
1,000
131,072
Wrong Answer
20
7,564
54
Write a program which reads three integers, and prints them in ascending order.
x = sorted([int(i) for i in input().split()]) print(x)
s264409777
Accepted
30
7,696
89
x = sorted([int(i) for i in input().split()]) print("{0} {1} {2}".format(x[0],x[1],x[2]))
s129427906
p03351
u056599756
2,000
1,048,576
Wrong Answer
17
2,940
100
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
a,b,c,d=map(int, input().split()) print("Yes" if abs(a-c)<d or abs(a-b)<d and abs(b-c)<d else "No")
s168471257
Accepted
17
2,940
103
a,b,c,d=map(int, input().split()) print("Yes" if abs(a-c)<=d or abs(a-b)<=d and abs(b-c)<=d else "No")
s103740238
p03377
u304561065
2,000
262,144
Wrong Answer
19
3,060
126
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
A,B,X=map(int,input().split()) if A<=X: if A+B<X: print('No') else: print('Yes') else: print('No')
s962528506
Accepted
17
2,940
127
A,B,X=map(int,input().split()) if A+B>=X: if A<=X: print('YES') else: print('NO') else: print('NO')
s809604206
p02393
u120602885
1,000
131,072
Wrong Answer
20
7,588
127
Write a program which reads three integers, and prints them in ascending order.
tmp = input() tmp = tmp.split(" ") tmp = list(map(int,tmp)) tmp.sort() print(tmp) tmp = list(map(str,tmp)) print(" ".join(tmp))
s855765528
Accepted
30
7,644
116
tmp = input() tmp = tmp.split(" ") tmp = list(map(int,tmp)) tmp.sort() tmp = list(map(str,tmp)) print(" ".join(tmp))
s052982277
p03555
u923270446
2,000
262,144
Wrong Answer
17
2,940
93
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
c1 = list(input()) c2 = list(input()) if c1.reverse == c2: print("YES") else: print("NO")
s716355564
Accepted
17
2,940
45
print("YES"if input()==input()[::-1]else"NO")
s152736568
p03494
u099026234
2,000
262,144
Wrong Answer
26
9,028
277
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
a = int(input()) b = [int(i) for i in input().split(" ")] count = 0 iti = 1 while iti == 1: for i in range(a): if b[i]%2 == 0: b[i]=b[i]//2 iti = 1 else : print(count) iti = 0 break count = count+1
s646371860
Accepted
30
9,128
281
a = int(input()) b = [int(i) for i in input().split(" ")] count = 0 iti = 1 while iti == 1: for i in range(a): if b[i]%2 == 0: b[i]=b[i]//2 iti = 1 else : print(count) iti = 0 break count = count+1
s248677300
p02841
u698849142
2,000
1,048,576
Wrong Answer
17
2,940
98
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month.
m1, d1 = map(int, input().split()) m2, d2 = map(int, input().split()) print(m1 == m2 if 1 else 0)
s022564343
Accepted
17
2,940
98
m1, d1 = map(int, input().split()) m2, d2 = map(int, input().split()) print(0 if m1 == m2 else 1)
s401339636
p03251
u715355213
2,000
1,048,576
Wrong Answer
17
3,064
482
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
N,M,X,Y = map(int,input().split()) x = list(map(int,input().split())) y = list(map(int,input().split())) flag = 0 Z_max = min(y) Z_min = max(x) print(Z_min,Z_max) Z = X + 1 while Z < Y: if Z_min < Z and Z <= Z_max: break Z += 1 print(Z) for i in range(N): if x[i] >= Z: flag = 1 break if flag == 0: for i in range(M): if y[i] < Z: flag = 1 break if flag == 0: print('No War') else: print('War')
s966338925
Accepted
17
3,064
454
N,M,X,Y = map(int,input().split()) x = list(map(int,input().split())) y = list(map(int,input().split())) flag = 0 Z_max = min(y) Z_min = max(x) Z = X + 1 while Z < Y: if Z_min < Z and Z <= Z_max: break Z += 1 for i in range(N): if x[i] >= Z: flag = 1 break if flag == 0: for i in range(M): if y[i] < Z: flag = 1 break if flag == 0: print('No War') else: print('War')
s028125401
p03433
u332420380
2,000
262,144
Wrong Answer
17
2,940
89
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
n = int(input()) a = int(input()) if n % 500 <= a: print('YES') else: print('NO')
s459982635
Accepted
17
2,940
89
n = int(input()) a = int(input()) if n % 500 <= a: print('Yes') else: print('No')
s047178909
p04044
u666964944
2,000
262,144
Wrong Answer
26
9,160
80
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
n,l = map(int, input().split()) s = [input() for _ in range(n)] print(sorted(s))
s399562488
Accepted
26
9,104
89
n,l = map(int, input().split()) s = [input() for _ in range(n)] print(''.join(sorted(s)))
s354554761
p03351
u672220554
2,000
1,048,576
Wrong Answer
17
2,940
158
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
a,b,c,d=map(int,input().split()) if abs(c-a)<=d: print("Yes") else: if abs(b-a)<=d and abs(c-a)<=d: print("Yes") else: print("No")
s978167593
Accepted
17
2,940
158
a,b,c,d=map(int,input().split()) if abs(c-a)<=d: print("Yes") else: if abs(b-a)<=d and abs(c-b)<=d: print("Yes") else: print("No")
s164186792
p03485
u150641538
2,000
262,144
Wrong Answer
20
2,940
52
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
a,b = map(int,input().split()) print(int((a+b)/2)+1)
s486278643
Accepted
17
2,940
63
a,b = map(int,input().split()) print(int((a+b+((a+b)%2==1))/2))
s577521235
p03658
u257541375
2,000
262,144
Wrong Answer
17
2,940
146
Snuke has N sticks. The length of the i-th stick is l_i. Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy.
n,k = [int(i) for i in input().split()] array = [int(i) for i in input().split()] array.sort() sum = 0 for i in range(k): sum += array[-(i+1)]
s174315140
Accepted
18
2,940
158
n,k = [int(i) for i in input().split()] array = [int(i) for i in input().split()] array.sort() sum = 0 for i in range(k): sum += array[-(i+1)] print(sum)
s488375820
p03385
u273201018
2,000
262,144
Wrong Answer
17
2,940
67
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
S = input() if S == 'abc': print('Yes') else: print('No')
s601841069
Accepted
17
2,940
107
S = input() if 'a' in S and 'b' in S and 'c' in S and len(S) == 3: print('Yes') else: print('No')
s327176041
p02612
u189188797
2,000
1,048,576
Wrong Answer
26
8,976
55
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
n=int(input()) while n>=1000: n-=1000 print(abs(n))
s573429178
Accepted
27
9,084
51
n=int(input()) while n>0: n-=1000 print(abs(n))
s839306424
p03478
u770987902
2,000
262,144
Wrong Answer
25
2,940
241
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
n, a,b = [int(x) for x in input().split()] total = 0 def func(num): r = 0 while num > 0: r = num % 10 num = num // 10 return r for i in range(1, n+1): num = func(i) if num >= a and num <= b: total += num print(total)
s418528776
Accepted
25
2,940
237
n,a,b = [int(x) for x in input().split()] def func(num): r = 0 while num > 0: r += num % 10 num = num // 10 return r total = 0 for i in range(1, n+1): num = func(i) if num >= a and num <= b: total += i print(total)
s135483600
p03494
u428397309
2,000
262,144
Time Limit Exceeded
2,104
2,940
209
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
# -*- coding: utf-8 -*- N = int(input()) A = list(map(int, input().split())) ans = 0 while 1: new_a = [a // 2 if a % 2 == 0 else -1 for a in A] if -1 in new_a: break ans += 1 print(ans)
s109207327
Accepted
18
2,940
250
# -*- coding: utf-8 -*- N = int(input()) A = list(map(int, input().split())) ans = 0 new_a = A.copy() while 1: new_a = [a // 2 if a % 2 == 0 else -1 for a in new_a] if -1 in new_a: print(ans) exit() ans += 1 print(ans)
s282461841
p04011
u586577600
2,000
262,144
Wrong Answer
17
2,940
101
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
n, k, x, y = [int(input()) for i in range(4)] if n <= k: print(x*n) else: print(x*n + max(0, n-k)*y)
s566433652
Accepted
17
2,940
101
n, k, x, y = [int(input()) for i in range(4)] if n <= k: print(x*n) else: print(x*k + max(0, n-k)*y)
s855946267
p03827
u290187182
2,000
262,144
Wrong Answer
17
2,940
197
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
if __name__ == '__main__': a = int(input()) s = input() count =0 for i in s: if i == "I": count +=1 else: count -=1 print(count)
s498896492
Accepted
17
2,940
248
if __name__ == '__main__': a = int(input()) s = input() count =0 max = 0 for i in s: if i == "I": count +=1 else: count -=1 if max < count: max = count print(max)
s142845827
p03434
u738622346
2,000
262,144
Wrong Answer
17
3,060
385
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
def draw_max_card(card_list): max_card = max(card_list) card_list.remove(max_card) return max_card n = int(input()) card_list = list(map(int, input().split(" "))) points_alice = 0 points_bob = 0 for count in range(1, n + 1): print(count) if count % 2 != 0: points_alice += draw_max_card(card_list) else: points_bob += draw_max_card(card_list)
s959671425
Accepted
20
3,188
402
def draw_max_card(card_list): max_card = max(card_list) card_list.remove(max_card) return max_card n = int(input()) card_list = list(map(int, input().split(" "))) points_alice = 0 points_bob = 0 for count in range(1, n + 1): if count % 2 != 0: points_alice += draw_max_card(card_list) else: points_bob += draw_max_card(card_list) print(points_alice - points_bob)
s847329877
p03944
u394244719
2,000
262,144
Wrong Answer
30
9,132
694
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
import sys import math inint = lambda: int(sys.stdin.readline()) inintm = lambda: map(int, sys.stdin.readline().split()) inintl = lambda: list(inintm()) instrm = lambda: map(str, sys.stdin.readline().split()) instrl = lambda: list(instrm()) w, h, n = inintm() ll = [0,0] lh = [0,h] rl = [w,0] rh = [w,h] for i in range(n): x, y, a = inintm() if a == 1: ll[0] = max(ll[0], x) lh[0] = max(lh[0], x) elif a == 2: rl[0] = min(rl[0], x) rh[0] = min(rh[0], x) elif a == 3: rl[1] = max(rl[1], y) ll[1] = max(ll[1], y) else: rh[1] = min(rh[1], y) lh[1] = min(lh[1], y) print(min((rl[0]-ll[0])*(lh[1]-ll[1]), 0))
s770813613
Accepted
31
9,180
606
import sys import math inint = lambda: int(sys.stdin.readline()) inintm = lambda: map(int, sys.stdin.readline().split()) inintl = lambda: list(inintm()) instrm = lambda: map(str, sys.stdin.readline().split()) instrl = lambda: list(instrm()) w, h, n = inintm() ll = [0,0] rh = [w,h] for i in range(n): x, y, a = inintm() if a == 1: ll[0] = max(ll[0], x) elif a == 2: rh[0] = min(rh[0], x) elif a == 3: ll[1] = max(ll[1], y) else: rh[1] = min(rh[1], y) if rh[0]-ll[0] < 0 or rh[1]-ll[1] < 0: print(0) else: print((rh[0]-ll[0])*(rh[1]-ll[1]))
s757471046
p03435
u393253137
2,000
262,144
Wrong Answer
17
3,064
435
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct.
c = [list(map(int, input().split())) for _ in range(3)] if c[0][1] - c[0][0] == c[1][1] - c[1][0] == c[2][1] - c[2][0]: if c[0][2] - c[0][1] == c[1][2] - c[1][1] == c[2][2] - c[2][1]: print('Yes') print('No')
s605037695
Accepted
18
2,940
202
a, b, c = map(int, input().split()) d, e, f = map(int, input().split()) g, h, i = map(int, input().split()) if a - b == d - e == g - h and b - c == e - f == h - i: print('Yes') else: print('No')
s954778587
p03853
u290187182
2,000
262,144
Wrong Answer
36
5,144
389
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
import sys import copy import math import bisect import pprint import bisect from functools import reduce from copy import deepcopy from collections import deque from decimal import * def lcm(x, y): return (x * y) // math.gcd(x, y) if __name__ == '__main__': b, c = map(int, input().split()) for i in range(b): s = input() print(s+s) print(s+s)
s874752808
Accepted
35
5,144
385
import sys import copy import math import bisect import pprint import bisect from functools import reduce from copy import deepcopy from collections import deque from decimal import * def lcm(x, y): return (x * y) // math.gcd(x, y) if __name__ == '__main__': b, c = map(int, input().split()) for i in range(b): s = input() print(s) print(s)
s110317457
p03069
u286955577
2,000
1,048,576
Wrong Answer
41
3,884
364
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so 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.
def solve(): N = int(input()) S = input() foundBlack = False black, b, white = 0, 0, 0 for stone in S: if stone == '#': if not foundBlack: foundBlack = True b = b + 1 else: if not foundBlack: continue white = white + 1 black = black + b b = 0 print(white, black) return min(black, white) print(solve())
s802680111
Accepted
54
5,864
473
def solve(): N = int(input()) S = input() stones = [] look = S[0] cnt = 0 if S[0] == '.': stones.append(0) for s in S: if look == s: cnt += 1 else: stones.append(cnt) cnt = 1 look = s stones.append(cnt) if S[N - 1] == '#': stones.append(0) count = sum(stones[1::2]) ans = count for i in range(0, len(stones), 2): count = count + stones[i] - stones[i + 1] if ans > count: ans = count return ans print(solve())
s123948812
p03139
u303633930
2,000
1,048,576
Wrong Answer
18
3,060
319
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents 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.
import sys def r(n, a, b): both_max = min(a, b) if 0 < a + b - n: both_min = a + b - n else: both_min = 0 print(both_max, both_min) def main(): input = sys.stdin.readline n, a, b = list(map(int, input().split())) print(r(n, a, b)) if __name__ == '__main__': main()
s193743880
Accepted
17
3,060
312
import sys def r(n, a, b): both_max = min(a, b) if 0 < a + b - n: both_min = a + b - n else: both_min = 0 print(both_max, both_min) def main(): input = sys.stdin.readline n, a, b = list(map(int, input().split())) r(n, a, b) if __name__ == '__main__': main()
s427312275
p03998
u898967808
2,000
262,144
Wrong Answer
19
3,064
255
Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * 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.
dic_s = {x:input() for x in 'abc'} dic_i = {x:i for x,i in zip('abc',[0,0,0])} dic_max = {x:len(dic_s[x]) for x in 'abc'} nt = 'a' while True: dic_i[nt] += 1 if dic_max[nt] == dic_i[nt]: break else: nt = dic_s[nt][dic_i[nt]] print(nt)
s820033458
Accepted
17
3,064
273
dic_s = {x:input() for x in 'abc'} dic_i = {x:i for x,i in zip('abc',[0,0,0])} dic_max = {x:len(dic_s[x]) for x in 'abc'} nt = 'a' while True: if dic_max[nt] == dic_i[nt]: break else: dic_i[nt] += 1 nt = dic_s[nt][dic_i[nt]-1] print(nt.upper())
s437857035
p02534
u922769680
2,000
1,048,576
Wrong Answer
26
9,144
33
You are given an integer K. Print the string obtained by repeating the string `ACL` K times and concatenating them. For example, if K = 3, print `ACLACLACL`.
n=int(input()) w="ALC" print(w*n)
s305986103
Accepted
21
9,148
33
n=int(input()) w="ACL" print(w*n)
s491950617
p03679
u032222383
2,000
262,144
Wrong Answer
17
2,940
119
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
x, a, b=map(int, input().split()) if a>=b: print("delicious") elif a+x<=b: print("safe") else: print("dangerous")
s992679404
Accepted
18
2,940
120
x, a, b=map(int, input().split()) if a>=b: print("delicious") elif a+x>=b: print("safe") else: print("dangerous")
s758388166
p03401
u089032001
2,000
262,144
Wrong Answer
138
14,048
322
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from 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())) min1 = 0 min2 = 0 max1 = 0 max2 = 0 for a in A: if(a <= min1): min2 = min1 min1 = a elif(a >= max1): max2 = max1 max1 = a for a in A: if(a == min1): print(max1 - min2) elif(a == max1): print(max2 - min1) else: print(max1 - min1)
s746566339
Accepted
220
14,048
291
N = int(input()) A = list(map(int, input().split())) A.append(0) all = 0 last = 0 diff = [] for i in range(N): all += abs(A[i] - last) diff.append(abs(A[i+1] - last) - abs(A[i+1] - A[i]) - abs(A[i] - last)) last = A[i] all += abs(A[N-1]) for i in range(N): print(all + diff[i])
s808637621
p03149
u731368968
2,000
1,048,576
Wrong Answer
17
2,940
116
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".
n = list(map(int, input().split())) n.sort() if n[0] + n[1] + n[2] + n[3] == 1479: print('YES') else:print('NO')
s584004112
Accepted
17
2,940
102
n = input().split() n.sort() if n[0] + n[1] + n[2] + n[3] == '1479': print('YES') else:print('NO')
s599837569
p03385
u663438907
2,000
262,144
Wrong Answer
18
3,064
224
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
A = list(input()) l = [0, 0, 0] for i in range(len(A)): if A[i] == 'A': l[0] = 1 elif A[i] == 'B': l[1] = 1 else: l[2] = 1 if l[0] == 1 and l[1] == 1 and l[2] == 1: print('Yes') else: print('No')
s648690714
Accepted
17
3,064
226
A = list(input()) l = [0, 0, 0] for i in range(len(A)): if A[i] == 'a': l[0] = 1 elif A[i] == 'b': l[1] = 1 else: l[2] = 1 if l[0] == 1 and l[1] == 1 and l[2] == 1: print('Yes') else: print('No')
s560320620
p03599
u201234972
3,000
262,144
Wrong Answer
75
3,064
490
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the 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 = map( int, input().split()) ans = 0 ansL = 0 ansM = 0 for i in range(30//a+1): for j in range((30-i)//b+1): L = a*i + b*j M = 0 for k in range(f): if 100*L + k*c <= f: m = min(((e*L-k*c)//d)*d, ((f-100*L-k*c)//d)*d) M = max(M, m+k*c) if M+L != 0 and 100*L + M <= f: if (M*100)/(M+L*100) > ans: ansL = L*100 ansM = M print('{} {}'.format(ansL,ansM))
s142685174
Accepted
70
3,064
622
a, b, c, d, e, f = map( int, input().split()) ans = 0 ansL = 0 ansM = 0 for i in range(30//a+1): for j in range((30-i)//b+1): L = a*i + b*j M = 0 for k in range(f): if 100*L + k*c <= f and k*c <= L*e: m = min(((e*L-k*c)//d)*d, ((f-100*L-k*c)//d)*d) M = max(M, m+k*c) if M+L != 0 and 100*L + M <= f and M <= L*e: if (M*100)/(M+L*100) > ans: ans = (M*100)/(M+L*100) ansL = L*100 ansM = M if ansL == 0: print('{} {}'.format(a*100,0)) else: print('{} {}'.format(ansL+ansM,ansM))
s779158159
p02266
u462831976
1,000
131,072
Wrong Answer
30
7,304
679
Your task is to simulate a flood damage. For a given cross-section diagram, reports areas of flooded sections. Assume that rain is falling endlessly in the region and the water overflowing from the region is falling in the sea at the both sides. For example, for the above cross-section diagram, the rain will create floods which have areas of 4, 2, 1, 19 and 9 respectively.
# -*- coding: utf-8 -*- import sys import os s = input().strip() S1 = [] # sum of pond S2 = [] # each pond area = 0 for i, c in enumerate(s): if c == '\\': S1.append(i) elif c == '_': pass elif c == '/' and S1: j = S1.pop(-1) area += i - j # for each pond pond_sum = i - j while S2 and S2[-1][0] > j: pond_sum += S2[-1][1] S2.pop(-1) S2.append([j, pond_sum]) pond_areas = [] for data in S2: pond_areas.append(data[1]) # answer print(area) print(*pond_areas)
s844779441
Accepted
30
7,988
696
# -*- coding: utf-8 -*- import sys import os s = input().strip() S1 = [] # sum of pond S2 = [] # each pond area = 0 for i, c in enumerate(s): if c == '\\': S1.append(i) elif c == '_': pass elif c == '/' and S1: j = S1.pop(-1) area += i - j # for each pond pond_sum = i - j while S2 and S2[-1][0] > j: pond_sum += S2[-1][1] S2.pop(-1) S2.append([j, pond_sum]) pond_areas = [] for data in S2: pond_areas.append(data[1]) # answer print(area) print(len(pond_areas), *pond_areas)
s173523953
p03469
u368796742
2,000
262,144
Wrong Answer
18
2,940
65
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
a,b,c = map(int,input().split("/")) print("2018/01/{}".format(c))
s991825844
Accepted
17
2,940
69
a,b,c = map(int,input().split("/")) print("2018/01/{:02}".format(c))