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
s834908999
p03435
u721569287
2,000
262,144
Wrong Answer
18
3,064
594
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.
grid = list() for i in range(3): grid.append([int(k) for k in input().split(" ")]) def check_vert(): for i in range(2): diffs = [grid[k][i] - grid[k][i+1]for k in range(3)] print(diffs) if not len(set(diffs)) == 1: return False else: return True def check_hor(): for i in range(2): diffs = [grid[i][k] - grid[i+1][k] for k in range(3)] print(diffs) if not len(set(diffs)) == 1: return False else: return True if check_hor() and check_vert(): print("Yes") else: print("No")
s112009321
Accepted
17
3,064
552
grid = list() for i in range(3): grid.append([int(k) for k in input().split(" ")]) def check_vert(): for i in range(2): diffs = [grid[k][i] - grid[k][i+1]for k in range(3)] if not len(set(diffs)) == 1: return False else: return True def check_hor(): for i in range(2): diffs = [grid[i][k] - grid[i+1][k] for k in range(3)] if not len(set(diffs)) == 1: return False else: return True if check_hor() and check_vert(): print("Yes") else: print("No")
s665650476
p03910
u408375121
2,000
262,144
Wrong Answer
19
2,940
98
The problem set at _CODE FESTIVAL 20XX Finals_ consists of N problems. The score allocated to the i-th (1≦i≦N) problem is i points. Takahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve. As problems with higher scores are harder, he wants to minimize the highest score of a problem among the ones solved by him. Determine the set of problems that should be solved.
n = int(input()) k = 1 while True: if k*(k+1)//2 >= n: ans = k break k += 1 print(ans)
s492685091
Accepted
23
3,316
324
n = int(input()) k = 1 while True: if k*(k+1)//2 >= n: ans = k break k += 1 if n == ans*(ans+1)//2: i = 1 while i <= ans: print(i) i += 1 else: i = 1 l = [] cnt = 1 while i < ans: if cnt <= (ans-1)*(ans+2)//2 - n: print(i) cnt += 1 else: print(i+1) i += 1
s912583839
p03110
u889550481
2,000
1,048,576
Wrong Answer
17
3,060
171
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
N=int(input()) listA=[list(input().split()) for _ in range(N)] print(listA) ans=0 for i in range(N): ans+=float(listA[i][0])*(1,380000)[listA[i][1]=='BTC'] print(ans)
s557624633
Accepted
19
3,060
158
N=int(input()) listA=[list(input().split()) for _ in range(N)] ans=0 for i in range(N): ans+=float(listA[i][0])*(1,380000)[listA[i][1]=='BTC'] print(ans)
s309754841
p03591
u852113235
2,000
262,144
Wrong Answer
17
3,064
72
Ringo is giving a present to Snuke. Ringo has found out that Snuke loves _yakiniku_ (a Japanese term meaning grilled meat. _yaki_ : grilled, _niku_ : meat). He supposes that Snuke likes grilled things starting with `YAKI` in Japanese, and does not like other things. You are given a string S representing the Japanese name of Ringo's present to Snuke. Determine whether S starts with `YAKI`.
s = input() if s[0:4] == 'YAKI': print('YES') else: print('NO')
s313913059
Accepted
17
2,940
72
s = input() if s[0:4] == 'YAKI': print('Yes') else: print('No')
s214586853
p02261
u591875281
1,000
131,072
Wrong Answer
30
7,728
792
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).
def bubble(A, N): flag = True while flag: flag = False for j in range(N-1, 0, -1): if int(A[j][-1]) < int(A[j-1][-1]): A[j], A[j-1] = A[j-1], A[j] flag = True return A def selection(A, N): for i in range(0, N): minj = i for j in range(i, N): if int(A[j][-1]) < int(A[minj][-1]): minj = j if i != minj: A[i], A[minj] = A[minj], A[i] return A if __name__ == "__main__": N = int(input()) A = input().split() A_bubble = bubble(A[:], N) print (*A_bubble) print ("Stable") A_selection = selection(A[:], N) print (*A_selection) if A_bubble == A_selection: print ("Stable") else: print ("Not Stable")
s976892514
Accepted
20
7,780
792
def bubble(A, N): flag = True while flag: flag = False for j in range(N-1, 0, -1): if int(A[j][-1]) < int(A[j-1][-1]): A[j], A[j-1] = A[j-1], A[j] flag = True return A def selection(A, N): for i in range(0, N): minj = i for j in range(i, N): if int(A[j][-1]) < int(A[minj][-1]): minj = j if i != minj: A[i], A[minj] = A[minj], A[i] return A if __name__ == "__main__": N = int(input()) A = input().split() A_bubble = bubble(A[:], N) print (*A_bubble) print ("Stable") A_selection = selection(A[:], N) print (*A_selection) if A_bubble == A_selection: print ("Stable") else: print ("Not stable")
s370584636
p03555
u190178779
2,000
262,144
Wrong Answer
27
8,964
107
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.
import sys C1 = list(input()) C2 = list(input()) if C2 == C1[::-1]: print("Yes") else: print("No")
s715125320
Accepted
30
9,100
107
import sys C1 = list(input()) C2 = list(input()) if C2 == C1[::-1]: print("YES") else: print("NO")
s709790747
p03759
u138486156
2,000
262,144
Wrong Answer
17
2,940
92
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
a,b,c = map(int, input().split()) if b-a == c-a: print('YES') else: print('NO')
s994582243
Accepted
17
2,940
87
a,b,c = map(int, input().split()) if b-a == c-b: print('YES') else: print('NO')
s070071042
p03698
u845427284
2,000
262,144
Wrong Answer
18
2,940
62
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
s = list(input()) print("yes" if s == list(set(s)) else "no")
s742882355
Accepted
19
3,060
72
s = list(input()) print("yes" if len(s) == len(list(set(s))) else "no")
s358753408
p03079
u853185302
2,000
1,048,576
Wrong Answer
18
2,940
146
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
list_n = list(map(int,input().split())) list_n.sort(reverse=True) if list_n[0]**2 == list_n[1]**2+list_n[2]**2: print('Yes') else: print('No')
s469089809
Accepted
18
2,940
154
list_n = list(map(int,input().split())) list_n.sort(reverse=True) if list_n[0] == list_n[1] and list_n[1] == list_n[2]: print('Yes') else: print('No')
s937138087
p02796
u603958124
2,000
1,048,576
Wrong Answer
355
25,492
993
In a factory, there are N robots placed on a number line. Robot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative. We want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect. Here, for each i (1 \leq i \leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints. Find the maximum number of robots that we can keep.
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement from collections import deque,defaultdict,Counter from bisect import bisect_left,bisect_right from operator import itemgetter from heapq import heapify,heappop,heappush from queue import Queue,LifoQueue,PriorityQueue from copy import deepcopy from time import time import string import sys sys.setrecursionlimit(10 ** 7) def input() : return sys.stdin.readline().strip() def INT() : return int(input()) def MAP() : return map(int,input().split()) def LIST() : return list(MAP()) n = INT() x = [[0]*2 for i in range(n)] for i in range(n): x[i][0], x[i][1] = MAP() x.sort() tmp = -inf ans = n for i in range(n): if tmp > x[i][0] - x[i][1]: ans -= 1 tmp = min(tmp, x[i][0] + x[i][1]) print(i) else: tmp = x[i][0] + x[i][1] print(ans)
s963016257
Accepted
280
27,440
930
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement from collections import deque,defaultdict,Counter from bisect import bisect_left,bisect_right from operator import itemgetter from heapq import heapify,heappop,heappush from queue import Queue,LifoQueue,PriorityQueue from copy import deepcopy from time import time import string import sys sys.setrecursionlimit(10 ** 7) def input() : return sys.stdin.readline().strip() def INT() : return int(input()) def MAP() : return map(int,input().split()) def LIST() : return list(MAP()) n = INT() ls = [] for i in range(n): x, l = MAP() ls.append([x-l, x+l]) ls = sorted(ls, key=itemgetter(1)) ans = n for i in range(1, n): if ls[i][0] < ls[i-1][1]: ls[i][1] = ls[i-1][1] ans -= 1 print(ans)
s496723653
p03713
u899975427
2,000
262,144
Wrong Answer
17
3,064
205
There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}.
h,w = map(int,input().split()) i = h//3 j = -(-h//3) a = i*w b = (h-i)*(w//2) c = (h-i)*-(-w//2) a2 = j*w b2 = (h-j)*(w//2) c2 = (h-j)*-(-w//2) print(min(max(a,b,c)-min(a,b,c),max(a2,b2,c2)-min(a2,b2,c2)))
s434212215
Accepted
17
3,064
290
h,w = sorted(list(map(int,input().split()))) if h % 3 == 0 or w % 3 == 0: ret = 0 else: c1 = ((w//3+1)*h)-((w-1-w//3)*(h//2)) c2 = ((w-w//3)*(h-h//2))-(w//3*h) c3 = h c4 = ((h//3+1)*w)-((h-1-h//3)*(w//2)) c5 = ((h-h//3)*(w-w//2))-(h//3*w) ret = min(c1,c2,c3,c4,c5) print(ret)
s363993600
p03644
u289288647
2,000
262,144
Wrong Answer
32
9,092
95
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
N = int(input()) ans = 1 count = 0 while 2*ans <= N: ans *= 2 count += 1 print(count)
s882647256
Accepted
26
9,144
68
N = int(input()) ans = 1 while 2*ans <= N: ans *= 2 print(ans)
s665702681
p03455
u982591663
2,000
262,144
Wrong Answer
18
2,940
92
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
A, B = map(int, input().split()) if (A*B) % 2 == 0: print("Evem") else: print("Odd")
s824528586
Accepted
17
2,940
92
A, B = map(int, input().split()) if (A*B) % 2 == 0: print("Even") else: print("Odd")
s911280967
p02276
u519227872
1,000
131,072
Wrong Answer
30
7,652
373
Quick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, inturn, less than or equal to each element of A[q+1..r]. It also computes the index q. In the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r). Your task is to read a sequence A and perform the Partition based on the following pseudocode: Partition(A, p, r) 1 x = A[r] 2 i = p-1 3 for j = p to r-1 4 do if A[j] <= x 5 then i = i+1 6 exchange A[i] and A[j] 7 exchange A[i+1] and A[r] 8 return i+1 Note that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].
n = int(input()) A = list(map(int, input().split())) def partition(A, p, r): x = A[r] i = p - 1 for j in range(p, r): if A[j] <= x: i += 1 A[i], A[j] = A[j], A[i] A[i + 1], A[r] = A[r], A[i + 1] return i + 1 i = partition(A, 0, n-1) print(' '.join(map(str, A[:i])) + ' [' + str(A[i]) + '] ' + ' '.join(map(str, A[i:])))
s531932459
Accepted
80
18,936
375
n = int(input()) A = list(map(int, input().split())) def partition(A, p, r): x = A[r] i = p - 1 for j in range(p, r): if A[j] <= x: i += 1 A[i], A[j] = A[j], A[i] A[i + 1], A[r] = A[r], A[i + 1] return i + 1 i = partition(A, 0, n-1) print(' '.join(map(str, A[:i])) + ' [' + str(A[i]) + '] ' + ' '.join(map(str, A[i+1:])))
s057296038
p03854
u161442663
2,000
262,144
Wrong Answer
20
3,636
375
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=str(input()) Smojisuu=len(S) c=S.count("eraser") S=S.replace("eraser","xxxxxx",c) print(S) d=S.count("erase") S=S.replace("erase","xxxxx",d) print(S) e=S.count("dreamer") S=S.replace("dreamer","xxxxxxx",e) f=S.count("dream") S=S.replace("dream","xxxxx",f) print(S) g=S.count("x") if len(S)>g: print("NO") elif len(S)==g: print("YES") else: print("error")
s251254982
Accepted
20
3,188
348
S=str(input()) Smojisuu=len(S) c=S.count("eraser") S=S.replace("eraser","xxxxxx",c) d=S.count("erase") S=S.replace("erase","xxxxx",d) e=S.count("dreamer") S=S.replace("dreamer","xxxxxxx",e) f=S.count("dream") S=S.replace("dream","xxxxx",f) g=S.count("x") if len(S)>g: print("NO") elif len(S)==g: print("YES") else: print("error")
s097821704
p02255
u936051377
1,000
131,072
Wrong Answer
30
7,664
390
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
def insertion_sort(A, N): for i in range(N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j + 1] = v def main(): N = int(input().rstrip()) A = list(map(int, input().rstrip().split())) insertion_sort(A, N) print(' '.join(map(str, A))) if __name__ == '__main__': main()
s638058985
Accepted
40
7,656
390
def insertion_sort(A, N): for i in range(N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j + 1] = v print(' '.join(map(str, A))) def main(): N = int(input().rstrip()) A = list(map(int, input().rstrip().split())) insertion_sort(A, N) if __name__ == '__main__': main()
s467628748
p03659
u982762220
2,000
262,144
Wrong Answer
77
24,812
293
Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it. They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card. Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively. They would like to minimize |x-y|. Find the minimum possible value of |x-y|.
N = int(input()) A = list(map(int, input().split())) tot = sum(A) res = 0 s, t = A[0], sum(A[1:]) min_dif = abs(s - t) for a in A[1:-1]: s += a t -= a dif = abs(s - t) if min_dif > dif: min_dif = dif else: print(dif) exit() print(abs(s - A[-1]))
s683615592
Accepted
146
24,832
245
N = int(input()) A = list(map(int, input().split())) tot = sum(A) half = tot / 2 res = 0 s, t = A[0], sum(A[1:]) min_v = abs(s - t) for a in A[1:-1]: s += a tmp = abs(tot - 2 * s) if tmp < min_v: min_v = tmp print(min_v)
s818614323
p02843
u391157755
2,000
1,048,576
Wrong Answer
17
3,064
263
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 -= min(x // 105, 1000000) * 105 x -= min(x // 104, 1000000) * 104 x -= min(x // 103, 1000000) * 103 x -= min(x // 102, 1000000) * 102 x -= min(x // 101, 1000000) * 101 x -= min(x // 100, 1000000) * 100 if x == 0: print(1) else: print(0)
s258331982
Accepted
212
3,876
248
x = int(input()) a = list(False for i in range(x + 1)) a[0] = True for i in range(1, x + 1): for j in range(6): if (i - 100 - j) >= 0: if a[(i - 100 - j)]: a[i] = True if a[x]: print(1) else: print(0)
s054146683
p03080
u575101291
2,000
1,048,576
Wrong Answer
17
2,940
98
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
N=input() s=list(input()) r=s.count("r") b=s.count("b") if r>b: print("Yes") else: print("No")
s022480131
Accepted
17
2,940
98
N=input() s=list(input()) r=s.count("R") b=s.count("B") if r>b: print("Yes") else: print("No")
s215951623
p03644
u940780117
2,000
262,144
Wrong Answer
17
3,060
215
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
N = int(input()) n=0 ans = 0 ans2 =0 for i in range(1,N+1): n=i res = 0 while n % 2 !=0: n=n//2 res = res + 1 if ans < res: ans = res ans2 =i+1 print(ans2)
s002381845
Accepted
17
3,060
242
N = int(input()) n=0 ans = 0 ans2 =0 for i in range(1,N+1): n=i res = 0 while n % 2 ==0: n=n//2 res = res + 1 if ans < res: ans = res ans2 =i if ans2==0: print(1) else: print(ans2)
s471299167
p02972
u761471989
2,000
1,048,576
Wrong Answer
969
22,312
585
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.
N = int(input()) a_list = list(map(int, input().split())) b_list = [0]*(N//2)+a_list[N//2:] for i, a in enumerate(range(N//2)): j = N//2 - i j_list = [] k = j while(1): j = j + k if j > N: break else: j_list.append(j) s = 0 for j in j_list: s += b_list[j-1] if s % 2 == a_list[k-1]: b_list[k-1] = 0 else: b_list[k-1] = 1 if len([str(i+1) for i, b in enumerate(b_list) if b == 1]) == 0: print(0) else: print(' '.join([str(i+1) for i, b in enumerate(b_list) if b == 1]))
s891192578
Accepted
1,047
22,572
650
N = int(input()) a_list = list(map(int, input().split())) b_list = [0]*(N//2)+a_list[N//2:] for i, a in enumerate(range(N//2)): j = N//2 - i j_list = [] k = j while(1): j = j + k if j > N: break else: j_list.append(j) #print(j_list) s = 0 for j in j_list: s += b_list[j-1] if s % 2 == a_list[k-1]: b_list[k-1] = 0 else: b_list[k-1] = 1 print(len([str(i+1) for i, b in enumerate(b_list) if b == 1])) print(' '.join([str(i+1) for i, b in enumerate(b_list) if b == 1]))
s119531995
p03485
u703890795
2,000
262,144
Wrong Answer
17
2,940
48
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)//1)
s172779760
Accepted
19
2,940
50
a, b = map(int, input().split()) print((a+b+1)//2)
s305514614
p03719
u287880059
2,000
262,144
Wrong Answer
17
2,940
72
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
a,b,c = map(int,input().split()) print("YES" if a>=c and a<=b else "NO")
s709810806
Accepted
17
2,940
79
a,b,c = map(int,input().split()) if a<=c<=b: print("Yes") else: print("No")
s568205404
p03457
u294721290
2,000
262,144
Wrong Answer
907
3,316
245
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
N = int(input()) count = 0 T, X, Y = 0, 0, 0 for i in range(N): t, x, y = map(int, input().split()) if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2: count += 1 T, X, Y = t, x, y print("Yes" if count == N else "No")
s462304747
Accepted
383
3,064
237
N = int(input()) count = 0 T, X, Y = 0, 0, 0 for i in range(N): t, x, y = map(int, input().split()) if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2: count += 1 T, X, Y = t, x, y print("Yes" if count == N else "No")
s110472077
p02843
u951401193
2,000
1,048,576
Wrong Answer
33
3,064
407
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.)
n = int(input()) m = n%615 for i in range(7): for j in range(7): for k in range(7): for l in range(7): for m in range(7): for n in range(7): tmp = 100*i+101*j + 102*k + 103*l * 104*m + 105*n if m == tmp: print('1') elif m < tmp:break print('0')
s646802931
Accepted
17
2,940
133
x=int(input()) n=x//100 if x<100: print('0') else: if 100*n<=x and 105*n>=x: print('1') else: print('0')
s425027402
p03555
u943657163
2,000
262,144
Wrong Answer
17
2,940
90
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, b = input(), input() print('Yes' if a[0]==b[2] and a[1]==b[1] and a[2]==b[0] else 'No')
s586074763
Accepted
17
2,940
62
a, b = input(), input() print('YES' if a == b[::-1] else 'NO')
s423073700
p03485
u509094491
2,000
262,144
Wrong Answer
17
2,940
84
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.
i = list(map(int, input().split())) sum=i[0]+i[1] if sum%2==1: sum+=1 print(sum/2)
s820826273
Accepted
17
2,940
89
i = list(map(int, input().split())) sum=i[0]+i[1] if sum%2==1: sum+=1 print(int(sum/2))
s253961841
p03005
u095021077
2,000
1,048,576
Wrong Answer
17
2,940
43
Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
N, K=map(int, input().split()) print(N-K-1)
s115945190
Accepted
17
2,940
69
N, K=map(int, input().split()) if K==1: print(0) else: print(N-K)
s180005961
p03149
u373047809
2,000
1,048,576
Wrong Answer
17
2,940
48
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".
print("YNEOS"[sorted(input())!=list(" 1479")])
s421477404
Accepted
18
2,940
51
print("YNEOS"[sorted(input())!=list(" 1479")::2])
s174705513
p03545
u101350975
2,000
262,144
Wrong Answer
17
3,060
312
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.
from sys import stdin l = list(stdin.readline().rstrip()) s = [int(i) for i in l] def dfs(i, f, sum): if i == 3: if sum == 7: print(f) exit() else: dfs(i+1, f + '+' + str(s[i]), sum + s[i]) dfs(i+1, f + '-' + str(s[i]), sum - s[i]) dfs(0, str(s[0]), s[0])
s964339503
Accepted
17
3,060
327
from sys import stdin l = list(stdin.readline().rstrip()) s = [int(i) for i in l] def dfs(i, f, sum): if i == 3: if sum == 7: print(f + '=7') exit() else: dfs(i+1, f + '+' + str(s[i+1]), sum + s[i+1]) dfs(i+1, f + '-' + str(s[i+1]), sum - s[i+1]) dfs(0, str(s[0]), s[0])
s363775237
p03385
u045408189
2,000
262,144
Wrong Answer
17
2,940
58
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().split() print('Yes' if len(set(s))==3 else 'No')
s717423421
Accepted
17
2,940
51
s=input() print('Yes' if len(set(s))==3 else 'No')
s132155751
p03386
u076764813
2,000
262,144
Wrong Answer
17
3,060
104
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
a,b,k=map(int,input().split()) r=range(a, b+1) for i in sorted(set(r[:k]) or set(r[-k:])): print(i)
s525112527
Accepted
17
3,060
94
a,b,k=map(int,input().split()) r=range(a,b+1) for i in sorted(set(r[:k])|set(r[-k:])):print(i)
s258073755
p03593
u652737716
2,000
262,144
Wrong Answer
19
3,188
1,437
We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the top and j-th column from the left. In this matrix, each a_{ij} is a lowercase English letter. Snuke is creating another H-by-W matrix, A', by freely rearranging the elements in A. Here, he wants to satisfy the following condition: * Every row and column in A' can be read as a palindrome. Determine whether he can create a matrix satisfying the condition.
H, W = [int(x) for x in input().split(" ")] d = {} for h in range(H): row = input() for a in list(row): if a in d: d[a] += 1 else: d[a] = 1 print(d) res = False if H % 2 == 0 and W % 2 == 0: for v in d.values(): if v % 4 != 0: res = True break res = not res elif H % 2 == 1 and W % 2 == 0: cnt4 = (W // 2) * ((H - 1) // 2) cnt2 = (W // 2) temp4 = 0 temp2 = 0 f = True for v in d.values(): if v % 2 != 0: f = False break temp4 += v // 4 temp2 += 1 if v % 4 != 0 else 0 if f and cnt2 >= temp2 and (cnt2 - temp2) % 2 == 0: res = True elif H % 2 == 0 and W % 2 == 1: cnt4 = (H // 2) * ((W - 1) // 2) cnt2 = (H // 2) temp4 = 0 temp2 = 0 f = True for v in d.values(): if v % 2 != 0: f = False break temp4 += v // 4 temp2 += 1 if v % 4 != 0 else 0 if f and cnt2 >= temp2 and (cnt2 - temp2) % 2 == 0: res = True else: cnt4 = ((H - 1) // 2) * ((W - 1) // 2) cnt2 = ((H - 1) // 2) + ((W - 1) // 2) temp4 = 0 temp2 = 0 temp1 = 0 for v in d.values(): temp4 += v // 4 temp2 += (v % 4) // 2 temp1 += (v % 2) if temp1 == 1 and cnt2 >= temp2 and (cnt2 - temp2) % 2 == 0: res = True print("Yes" if res else "No")
s799965989
Accepted
20
3,192
1,427
H, W = [int(x) for x in input().split(" ")] d = {} for h in range(H): row = input() for a in list(row): if a in d: d[a] += 1 else: d[a] = 1 res = False if H % 2 == 0 and W % 2 == 0: for v in d.values(): if v % 4 != 0: res = True break res = not res elif H % 2 == 1 and W % 2 == 0: cnt4 = (W // 2) * ((H - 1) // 2) cnt2 = (W // 2) temp4 = 0 temp2 = 0 f = True for v in d.values(): if v % 2 != 0: f = False break temp4 += v // 4 temp2 += 1 if v % 4 != 0 else 0 if f and cnt2 >= temp2 and (cnt2 - temp2) % 2 == 0: res = True elif H % 2 == 0 and W % 2 == 1: cnt4 = (H // 2) * ((W - 1) // 2) cnt2 = (H // 2) temp4 = 0 temp2 = 0 f = True for v in d.values(): if v % 2 != 0: f = False break temp4 += v // 4 temp2 += 1 if v % 4 != 0 else 0 if f and cnt2 >= temp2 and (cnt2 - temp2) % 2 == 0: res = True else: cnt4 = ((H - 1) // 2) * ((W - 1) // 2) cnt2 = ((H - 1) // 2) + ((W - 1) // 2) temp4 = 0 temp2 = 0 temp1 = 0 for v in d.values(): temp4 += v // 4 temp2 += (v % 4) // 2 temp1 += (v % 2) if temp1 == 1 and cnt2 >= temp2 and (cnt2 - temp2) % 2 == 0: res = True print("Yes" if res else "No")
s646906786
p03486
u836737505
2,000
262,144
Wrong Answer
17
2,940
96
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.
a = "".join(sorted(input())) b = "".join(sorted(input())[::-1]) print("YES" if a < b else "NO" )
s594154147
Accepted
17
2,940
77
s = sorted(input()) t = sorted(input())[::-1] print("Yes" if s < t else "No")
s402727625
p04030
u301624971
2,000
262,144
Wrong Answer
17
3,060
364
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
def myAnswer(s:list)->str: ans = [] for string in s: if(string == "B"): if(ans == []): continue else: ans.pop() else: ans.append(string) print(ans) return "".join(ans) def modelAnswer(): return def main(): s = list(input()) print(myAnswer(s)) if __name__ == '__main__': main()
s343952897
Accepted
18
3,060
351
def myAnswer(s:list)->str: ans = [] for string in s: if(string == "B"): if(ans == []): continue else: ans.pop() else: ans.append(string) return "".join(ans) def modelAnswer(): return def main(): s = list(input()) print(myAnswer(s)) if __name__ == '__main__': main()
s629732366
p04011
u151625340
2,000
262,144
Wrong Answer
17
2,940
124
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
N = int(input()) K = int(input()) X = int(input()) Y = int(input()) if N <= K: print(N*X) else: print((N-K)*Y+N*X)
s723410718
Accepted
17
2,940
126
N = int(input()) K = int(input()) X = int(input()) Y = int(input()) if N <= K: print(N*X) else: print((N-K)*Y+K*X)
s449263646
p03251
u677705680
2,000
1,048,576
Wrong Answer
17
3,060
231
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 = list(map(int, input().split())) y_list = list(map(int, input().split())) print(X) print(x_list) if X <= Y and max(x_list) <= min(y_list): print("No War") else: print("War")
s623947459
Accepted
17
2,940
235
N, M, X, Y = map(int, input().split()) X_list = [X] X_list.extend(list(map(int, input().split()))) Y_list = [Y] Y_list.extend(list(map(int, input().split()))) if max(X_list) < min(Y_list): print("No War") else: print("War")
s778758395
p02608
u379917971
2,000
1,048,576
Wrong Answer
2,205
8,760
234
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
N=int(input()) sum=[0]*N for x in range(1,N): for y in range(1,N): for z in range(1,N): a=x*x+y*y+z*z+x*y+y*z+x*z if a<=N: sum[a-1]=sum[a-1]+1 for i in range(N): print(sum[i-1])
s078935107
Accepted
446
9,320
228
N=int(input()) sum=[0]*N for x in range(1,100): for y in range(1,100): for z in range(1,100): a=x*x+y*y+z*z+x*y+y*z+x*z if a<=N: sum[a-1]=sum[a-1]+1 for i in sum: print(i)
s629518697
p03730
u016881126
2,000
262,144
Wrong Answer
17
3,060
302
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines read = sys.stdin.buffer.read sys.setrecursionlimit(10 ** 7) INF = float('inf') A, B, C = map(int, readline().split()) for i in range(1, B+1): if A * i % B == C: print('Yes') quit() print('No')
s593089800
Accepted
18
3,060
302
import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines read = sys.stdin.buffer.read sys.setrecursionlimit(10 ** 7) INF = float('inf') A, B, C = map(int, readline().split()) for i in range(1, B+1): if A * i % B == C: print('YES') quit() print('NO')
s770190034
p03160
u357230322
2,000
1,048,576
Wrong Answer
157
13,928
246
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
N = int(input()) *h, = map(int, input().split()) dp = [float("inf") for _ in range(N)] dp[0] = 0 for i in range(N - 1): dp[i + 1] = dp[i] + abs(h[i + 1] - h[i]) if i < N - 2: dp[i + 2] =dp[i + 2], dp[i] + abs(h[i + 2] - h[i]) print(dp[N - 1])
s694025638
Accepted
125
13,980
181
n = int(input()) h=list(map(int,input().split())) dp=[0]*(n) dp[1]=abs(h[1]-h[0]) for i in range(2,n): dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2])) print(dp[n-1])
s829410209
p03729
u064963667
2,000
262,144
Wrong Answer
17
2,940
99
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
a,b,c = input().split() if a[-1] == b[0] and b[-1] == c[0]: print('Yes') else: print('No')
s981160604
Accepted
17
2,940
100
a,b,c = input().split() if a[-1] == b[0] and b[-1] == c[0]: print('YES') else: print('NO')
s554934036
p02422
u855694108
1,000
131,072
Wrong Answer
30
7,916
1,114
Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
def main(): m = list(input()) q = int(input()) A = [] for _ in range(q): A.append(input().split()) for x in range(q): if A[x][0] == "print": A[x][1] = int(A[x][1]) A[x][2] = int(A[x][2]) for y in range(A[x][1], A[x][2] + 1): if y != A[x][2]: print(m[y], end = "") else: print(m[y]) elif A[x][0] == "reverse": A[x][1] = int(A[x][1]) A[x][2] = int(A[x][2]) hoge = [] for y in range(A[x][1], A[x][2] + 1): hoge.append(m[y]) hoge = hoge[::-1] i = 0 for y in range(A[x][1], A[x][2] + 1): m[y] = hoge[i] i += 1 elif A[x][0] == "replace": A[x][1] = int(A[x][1]) A[x][2] = int(A[x][2]) fuga = list(A[x][3]) print(fuga) j = 0 for y in range(A[x][1], A[x][2] + 1): m[y] = fuga[j] j += 1 if __name__ == "__main__": main()
s408637492
Accepted
70
9,140
1,090
def main(): m = list(input()) q = int(input()) A = [] for _ in range(q): A.append(input().split()) for x in range(q): if A[x][0] == "print": A[x][1] = int(A[x][1]) A[x][2] = int(A[x][2]) for y in range(A[x][1], A[x][2] + 1): if y != A[x][2]: print(m[y], end = "") else: print(m[y]) elif A[x][0] == "reverse": A[x][1] = int(A[x][1]) A[x][2] = int(A[x][2]) hoge = [] for y in range(A[x][1], A[x][2] + 1): hoge.append(m[y]) hoge = hoge[::-1] i = 0 for y in range(A[x][1], A[x][2] + 1): m[y] = hoge[i] i += 1 elif A[x][0] == "replace": A[x][1] = int(A[x][1]) A[x][2] = int(A[x][2]) fuga = list(A[x][3]) j = 0 for y in range(A[x][1], A[x][2] + 1): m[y] = fuga[j] j += 1 if __name__ == "__main__": main()
s932699318
p03478
u144072139
2,000
262,144
Wrong Answer
22
3,060
273
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()) sum = 0 def FindSumOfDigits(x): count = 0 while x>0: count += x%10 x /= 10 return count for n in range(1, N+1): count= FindSumOfDigits(n) if A <= count <= B: sum += n print(sum)
s248481773
Accepted
25
2,940
263
N, A, B = map(int, input().split()) ans = 0 def FindSumOfDigits(x): count = 0 while x>0: count += x%10 x = x//10 return count for n in range(1, N+1): count = FindSumOfDigits(n) if A<= count <=B: ans += n print(ans)
s939089726
p03360
u210827208
2,000
262,144
Wrong Answer
18
2,940
77
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
x=list(map(int,input().split())) k=int(input()) print(max(x)*k+sum(x)-max(x))
s626145915
Accepted
17
2,940
82
x=list(map(int,input().split())) k=int(input()) print(max(x)*(2**k)+sum(x)-max(x))
s907208714
p02916
u094932051
2,000
1,048,576
Wrong Answer
17
3,064
388
Takahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1, Dish 2, \ldots, Dish N) once. The i-th dish (1 \leq i \leq N) he ate was Dish A_i. When he eats Dish i (1 \leq i \leq N), he gains B_i satisfaction points. Additionally, when he eats Dish i+1 just after eating Dish i (1 \leq i \leq N - 1), he gains C_i more satisfaction points. Find the sum of the satisfaction points he gained.
while True: try: N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) res = B[A[0]-1] for i in range(1, len(A)): res += B[A[i]-1] if A[i-1]-1 < len(C): res += C[A[i-1]-1] print(res) except: break
s414525199
Accepted
17
3,064
450
while True: try: N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.insert(0, 0) B.insert(0, 0) C.insert(0, 0) res = B[A[1]] for i in range(2, len(A)): res += B[A[i]] if A[i-1]+1 == A[i]: res += C[A[i-1]] print(res) except: break
s342128631
p03672
u478266845
2,000
262,144
Wrong Answer
293
18,844
260
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 numpy as np S = str(input()) import numpy as np for i in range(int(np.floor(len(S)/2))): j = int(np.floor(len(S)/2)) - i first_str = S[:j] second_str = S[j:2*j] if first_str == second_str: num = 2*j break print(num)
s024779331
Accepted
149
12,424
339
import numpy as np S = str(input()) import numpy as np for i in range(1,int(np.floor(len(S)/2))): j = int(np.floor(len(S)/2)) - i first_str = S[:j] second_str = S[j:2*j] if first_str == second_str: num = 2*j break elif (first_str != second_str) & (j==1): num = 0 break print(num)
s380055462
p02747
u801009312
2,000
1,048,576
Wrong Answer
20
3,188
230
A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string.
# coding: utf-8 # Your code here! import re input = input() pattern = '^(hi)+$' repatter = re.compile(pattern) result = repatter.fullmatch(input) if result is not None: print("yes") else: print("no")
s487481709
Accepted
22
3,316
230
# coding: utf-8 # Your code here! import re input = input() pattern = '^(hi)+$' repatter = re.compile(pattern) result = repatter.fullmatch(input) if result is not None: print("Yes") else: print("No")
s631726958
p03612
u723583932
2,000
262,144
Wrong Answer
78
14,008
161
You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two **adjacent** elements in the permutation. You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of operations to achieve this.
n=int(input()) p=list(map(int,input().split())) cnt=0 for i in range(n-1): if p[i]==(i+1): p[i],p[i+1]=p[i+1],p[i] cnt+=1 print(cnt) print(p)
s378043059
Accepted
74
14,008
191
n=int(input()) p=list(map(int,input().split())) cnt=0 for i in range(n-1): if p[i]==(i+1): p[i],p[i+1]=p[i+1],p[i] cnt+=1 if p[-1]==n: cnt+=1 print(cnt)
s482843397
p03407
u771167374
2,000
262,144
Wrong Answer
17
2,940
88
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
a, b, c = map(int, input().split()) print('Yes' if c == a or c== b or c ==a+b else 'No')
s833988601
Accepted
17
2,940
69
a, b, c = map(int, input().split()) print('Yes' if c <=a+b else 'No')
s848741086
p02390
u579699497
1,000
131,072
Wrong Answer
20
7,668
128
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
import math S = int(input()) h = math.floor(S/3600) m = math.floor((S - h*3600)/60) s = (S - (h*3600 + m*60))%60 print(h, m, s)
s634492061
Accepted
30
7,756
149
import math S = int(input()) h = math.floor(S/3600) m = math.floor((S - h*3600)/60) s = (S - (h*3600 + m*60))%60 print(str(h)+":"+str(m)+":"+str(s))
s368822237
p03339
u985596066
2,000
1,048,576
Wrong Answer
2,104
5,796
284
There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
N=int(input()) H=list(str(input())) m = 0 for i in range(N): c = 0 for s in range(N): if i > s and H[s] == 'W': c += 1 if i < s and H[s] == 'E': c += 1 if m == 0 or m >c: n = i m = c print(n)
s277901831
Accepted
119
16,160
211
from itertools import accumulate N=int(input()) s=str(input()) a = accumulate(c=='W' for c in 'X'+s[:-1]) b = reversed(list(accumulate(c=='E' for c in 'X'+s[-1:0:-1]))) print(min(x + y for x, y in zip(a, b)))
s360745940
p02612
u600261652
2,000
1,048,576
Wrong Answer
29
9,140
30
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
N = int(input()) print(N%1000)
s566046898
Accepted
25
9,180
94
def resolve(): N = int(input()) print("0" if N%1000 == 0 else 1000-(N%1000)) resolve()
s575671815
p02613
u081141316
2,000
1,048,576
Wrong Answer
139
16,152
229
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.
def count_data(s): judge_list = ['AC', 'WA', 'TEL', 'RE'] for judge in judge_list: ans = s.count(judge) print('{} x {}'.format(judge, ans)) n = int(input()) s = [] for i in range(n): s.append(input())
s207694999
Accepted
148
16,240
245
def count_data(s): judge_list = ['AC', 'WA', 'TLE', 'RE'] for judge in judge_list: ans = s.count(judge) print('{} x {}'.format(judge, ans)) n = int(input()) s = [] for i in range(n): s.append(input()) count_data(s)
s994428641
p03719
u689835643
2,000
262,144
Wrong Answer
17
2,940
91
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
x, y, z = map(int, input().split()) if x <= y <= z: print("Yes") else: print("No")
s981619720
Accepted
19
3,060
91
x, y, z = map(int, input().split()) if x <= z <= y: print("Yes") else: print("No")
s667219366
p03351
u905582793
2,000
1,048,576
Wrong Answer
17
2,940
110
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-c) <= d or abs(a-b)+abs(b-c)<= d: print('Yes') else: print('No')
s812463762
Accepted
17
2,940
119
a,b,c,d=map(int,input().split()) if abs(a-c) <= d or (abs(a-b)<=d and abs(b-c)<= d): print('Yes') else: print('No')
s478659594
p03131
u610042046
2,000
1,048,576
Wrong Answer
29
9,032
140
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
k, a, b = map(int, input().split()) if 2 >= b-a or a >= k: print(k+1) else: print((k-a+1)//2 + ((k-a+1)//2-1)*(b-a) + ((k-a+1)%2))
s418365716
Accepted
28
9,060
131
k, a, b = map(int, input().split()) if 2 >= b-a or a >= k: print(k+1) else: print(b + ((k-a+1)//2-1)*(b-a) + ((k-a+1)%2))
s062334973
p02842
u422242927
2,000
1,048,576
Wrong Answer
30
9,156
149
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()) if int(N // 1.08 * 1.08) == N: print(N // 1.08) elif int((N // 1.08 + 1) * 1.08) == N: print(N // 1.08 + 1) else: print(":(")
s272450720
Accepted
28
9,072
117
N = int(input()) for i in range(1, N + 1): if i + (i * 8) // 100 == N: print(i) break else: print(":(")
s157884657
p02697
u542541293
2,000
1,048,576
Wrong Answer
99
9,192
199
You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive). You cannot assign the same integer to multiple playing fields. The competition consists of N rounds, each of which proceeds as follows: * For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there. * Then, each player adds 1 to its integer. If it becomes N+1, change it to 1. You want to ensure that no player fights the same opponent more than once during the N rounds. Print an assignment of integers to the playing fields satisfying this condition. It can be proved that such an assignment always exists under the constraints given.
N, M = map(int, input().split()) for i in range(M): L = [] if M % 2 == 0: L.append(i+2) L.append(N-i-1) print(*L) if M % 2 == 1: L.append(i+1) L.append(N-i-1) print(*L)
s906462005
Accepted
99
9,204
542
N, M = map(int, input().split()) if M % 2 == 0: l = 1 for i in range(M//2): L = [] L.append(l) L.append(2*(M//2-i)+l) print(*L) l += 1 l = 2*(M//2)+2 for i in range(M//2): L = [] L.append(l) L.append(2*(M//2-i)+l-1) print(*L) l += 1 elif M % 2 == 1: l = 1 for i in range(M//2): L = [] L.append(l) L.append(2*(M//2-i)+l) print(*L) l += 1 l = 2*(M//2)+2 for i in range(M//2+1): L = [] L.append(l) L.append(2*(M//2+1-i)+l-1) print(*L) l += 1
s037027844
p03024
u366959492
2,000
1,048,576
Wrong Answer
18
2,940
108
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=list(input()) c=0 for i in s: if i=="o": c+=1 if c>=8: print("YES") else: print("NO")
s957764713
Accepted
17
2,940
152
s=list(input()) c=0 cc=0 for i in s: if i=="o": c+=1 if i=="x": cc+=1 if c>=8 or cc<=7: print("YES") else: print("NO")
s514154949
p02540
u104282757
2,000
1,048,576
Wrong Answer
1,138
56,764
1,900
There are N cities on a 2D plane. The coordinate of the i-th city is (x_i, y_i). Here (x_1, x_2, \dots, x_N) and (y_1, y_2, \dots, y_N) are both permuations of (1, 2, \dots, N). For each k = 1,2,\dots,N, find the answer to the following question: Rng is in City k. Rng can perform the following move arbitrarily many times: * move to another city that has a smaller x-coordinate and a smaller y-coordinate, or a larger x-coordinate and a larger y-coordinate, than the city he is currently in. How many cities (including City k) are reachable from City k?
from heapq import heappop, heappush class UnionFind: def __init__(self, n): self.par = [i for i in range(n+1)] self.rank = [0] * (n+1) # search def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] # unite def union(self, x, y): x = self.find(x) y = self.find(y) if self.rank[x] < self.rank[y]: self.par[x] = y else: self.par[y] = x if self.rank[x] == self.rank[y]: self.rank[x] += 1 def same_check(self, x, y): return self.find(x) == self.find(y) def solve(n, xy_list): # sort y by x xy_list_s = sorted(xy_list, key=lambda x: x[0]) y_list_s = [xy[1] for xy in xy_list_s] # union_find uf = UnionFind(n) # heap h = [] for y in y_list_s: yp_list = [y] while len(h): p = heappop(h) if p < y: yp_list.append(p) uf.union(p, y) else: heappush(h, p) break heappush(h, min(yp_list)) # unite parent_n = [0] * n parent_cnt = [0] * (n + 1) for i in range(n): p = uf.find(xy_list[i][1]) parent_n[i] = p parent_cnt[p] += 1 return [parent_cnt[parent_n[i]] for i in range(n)] def main(): n = int(input()) xy_list = [[0] * 2 for _ in range(n)] for i in range(n): x, y = map(int, input().split()) xy_list[i][0] = x xy_list[i][1] = y res = solve(n, xy_list) print(res) def test(): assert solve(4, [[1, 4], [2, 3], [3, 1], [4, 2]]) == [1, 1, 2, 2] assert solve(7, [[6, 4], [4, 3], [3, 5], [7, 1], [2, 7], [5, 2], [1, 6]]) == [3, 3, 1, 1, 2, 3, 2] if __name__ == "__main__": test() main()
s282814846
Accepted
1,085
56,872
1,920
from heapq import heappop, heappush class UnionFind: def __init__(self, n): self.par = [i for i in range(n+1)] self.rank = [0] * (n+1) # search def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] # unite def union(self, x, y): x = self.find(x) y = self.find(y) if self.rank[x] < self.rank[y]: self.par[x] = y else: self.par[y] = x if self.rank[x] == self.rank[y]: self.rank[x] += 1 def same_check(self, x, y): return self.find(x) == self.find(y) def solve(n, xy_list): # sort y by x xy_list_s = sorted(xy_list, key=lambda x: x[0]) y_list_s = [xy[1] for xy in xy_list_s] # union_find uf = UnionFind(n) # heap h = [] for y in y_list_s: yp_list = [y] while len(h): p = heappop(h) if p < y: yp_list.append(p) uf.union(p, y) else: heappush(h, p) break heappush(h, min(yp_list)) # unite parent_n = [0] * n parent_cnt = [0] * (n + 1) for i in range(n): p = uf.find(xy_list[i][1]) parent_n[i] = p parent_cnt[p] += 1 return [parent_cnt[parent_n[i]] for i in range(n)] def main(): n = int(input()) xy_list = [[0] * 2 for _ in range(n)] for i in range(n): x, y = map(int, input().split()) xy_list[i][0] = x xy_list[i][1] = y res = solve(n, xy_list) for r in res: print(r) def test(): assert solve(4, [[1, 4], [2, 3], [3, 1], [4, 2]]) == [1, 1, 2, 2] assert solve(7, [[6, 4], [4, 3], [3, 5], [7, 1], [2, 7], [5, 2], [1, 6]]) == [3, 3, 1, 1, 2, 3, 2] if __name__ == "__main__": test() main()
s251256700
p03251
u434822333
2,000
1,048,576
Wrong Answer
19
3,060
236
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())) A = [a for a in range(101) if (X < a <= Y) and (max(x) < a <= min(y))] if len(A) is not 0: print('No war') else: print('War')
s492094537
Accepted
18
3,060
242
N, M, X, Y = map(int, input().split()) x = list(map(int, input().split())) y = list(map(int, input().split())) Z = [z for z in range(-100, 101) if (X < z <= Y) and (max(x) < z <= min(y))] if len(Z) is not 0: print('No War') else: print('War')
s226374124
p03351
u183481524
2,000
1,048,576
Wrong Answer
17
2,940
175
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 or abs(b - a) < d: if abs(b - c) < d or abs(c - b) < d: print('Yes') else:print('No') else:print('No')
s597932612
Accepted
17
3,060
197
a, b, c, d = map(int,input().split()) if (abs(a - b) <= d or abs(b - a) <= d) and (abs(b - c) <= d or abs(c - b) <= d) or (abs(c - a) <= d or abs(a - c) <= d): print('Yes') else:print('No')
s085096302
p02972
u751724075
2,000
1,048,576
Wrong Answer
2,109
99,940
715
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.
import math N = int(input()) a_list = [-1] + list(map(int, input().split())) cache = {} def decompose(n): if n in cache: return cache[n] if n % 2 == 0: return [2] + decompose(n // 2) for i in range(3, math.floor(math.sqrt(n)), 2): if n % i == 0: return [i] + decompose(n // i) return [n] rels = [set() for _ in range(N + 1)] for i in range(2, N + 1): for d in decompose(i): if d != i: rels[d].add(i) rels[1].add(i) b_list = [None] * (N + 1) for i in range(N, 0, -1): b = a_list[i] for j in rels[i]: b = b ^ b_list[j] b_list[i] = b count = 0 b_list2 = [] for i in range(1, N + 1): if b_list[i] == 1: count += 1 b_list2.append(str(i + 1)) print(count) print(" ".join(b_list2))
s600115873
Accepted
549
17,196
362
import math N = int(input()) a_list = [-1] + list(map(int, input().split())) b_list = [None] * (N + 1) for i in range(N, 0, -1): b = a_list[i] for j in range(i * 2, N + 1, i): b = b ^ b_list[j] b_list[i] = b count = 0 b_list2 = [] for i in range(1, N + 1): if b_list[i] == 1: count += 1 b_list2.append(str(i)) print(count) print(" ".join(b_list2))
s270124475
p03386
u679089074
2,000
262,144
Wrong Answer
32
9,068
267
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
#56 a,b,k = map(int,input().split()) num = [] if b-a <= k: for i in range(a,b+1): print(i) else: for i in range(a,a+k): num.append(i) for i in range(b-k+1,b+1): num.append(i) num = set(num) for i in num: print(i)
s436342041
Accepted
28
9,036
300
#56 a,b,k = map(int,input().split()) num = [] if b-a <= k: for i in range(a,b+1): print(i) else: for i in range(a,a+k): num.append(i) for i in range(b-k+1,b+1): num.append(i) num = list(set(num)) num.sort() for i in num: print(i)
s528985423
p02659
u586832145
2,000
1,048,576
Wrong Answer
25
9,928
118
Compute A \times B, truncate its fractional part, and print the result as an integer.
from decimal import Decimal from decimal import getcontext s = input(); a,b = s.split(); print(Decimal(a)*Decimal(b));
s799923173
Accepted
27
10,052
123
from decimal import Decimal from decimal import getcontext s = input(); a,b = s.split(); print(int(Decimal(a)*Decimal(b)));
s453762067
p03089
u981767024
2,000
1,048,576
Wrong Answer
17
3,064
944
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
# 2019/03/23 # AtCoder Grand Contest 032 - A # Input n = int(input()) b = list(map(int, input().split())) a = [0] * n anslist = list() ans = 0 # Possible Check for idx in range(n): if b[idx] > (idx + 1): ans = -1 break # fixcnt = 0 // (n-1) - idx2 # Make list if ans == 0: fixcnt = 0 # Loop from n-1, to -1, by -1 for idx2 in range(n-1, -1, -1): if a[idx2] == 0: if b[idx2] <= fixcnt + 1: a[idx2] = b[idx2] anslist.append(b[idx2]) else: for idx3 in range(idx2-1, -1, -1): if b[idx3] <= fixcnt + 1: a[idx3] = b[idx3] anslist.append(b[idx3]) fixcnt += 1 break anslist.append(b[idx2]) a[idx2] = b[idx2] fixcnt += 1 for idx4 in range(n): print(anslist[idx4])
s719446322
Accepted
18
3,064
492
# 2019/03/23 # AtCoder Grand Contest 032 - A # Input n = int(input()) b = list(map(int, input().split())) anslist = list() ngflg = False for idx6 in range(n): maxidx = -1 for idx7 in range(len(b)): if b[idx7] == idx7 + 1: maxidx = idx7 if maxidx >= 0: anslist.append(b.pop(maxidx)) else: ngflg = True if ngflg: print(-1) break if ngflg == False: for idx4 in range(n-1, -1, -1): print(anslist[idx4])
s979520927
p03251
u122195031
2,000
1,048,576
Wrong Answer
17
3,064
279
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())) x_max = max(x) y_min = min(y) for i in range(-100,101): if X <= i <= Y and x_max < i and y_min >= i: print("No War") print(i) exit() print("War")
s813817978
Accepted
18
3,064
261
n,m,X,Y = map(int,input().split()) x = list(map(int,input().split())) y = list(map(int,input().split())) x_max = max(x) y_min = min(y) for i in range(-100,101): if X < i <= Y and x_max < i and y_min >= i: print("No War") exit() print("War")
s958528057
p04043
u759518460
2,000
262,144
Wrong Answer
17
2,940
115
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
k = input().split() k.sort() if k[0] == '5' and k[1] == '5' and k[2] == '7': print('Yes') else: print('No')
s756622347
Accepted
16
2,940
115
k = input().split() k.sort() if k[0] == '5' and k[1] == '5' and k[2] == '7': print('YES') else: print('NO')
s396345655
p02256
u209940149
1,000
131,072
Wrong Answer
20
5,604
194
Write a program which finds the greatest common divisor of two natural numbers _a_ and _b_
def gcd(a, b): c = max([a, b]) d = min([a, b]) if c % d == 0: return d else: gcd(d, c % d) nums = input().split() print(gcd(int(nums[0]), int(nums[1])))
s147069234
Accepted
20
5,604
201
def gcd(a, b): c = max([a, b]) d = min([a, b]) if c % d == 0: return d else: return gcd(d, c % d) nums = input().split() print(gcd(int(nums[0]), int(nums[1])))
s654121777
p02602
u380854465
2,000
1,048,576
Wrong Answer
2,207
53,472
310
M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms: not given. * For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term. M-kun scored A_i in the exam at the end of the i-th term. For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is **strictly** greater than the grade for the (i-1)-th term.
import sys import numpy as np N, K = list(map(int, input().split())) A = list(map(int, input().split())) B = [] for i in range(N-K+1): s = 1 for j in range(K): s *= A[i+j] B.append(s) print(B) for i in range(N-K): if B[i] < B[i+1]: print('Yes') else: print('No')
s529086157
Accepted
267
50,148
302
import sys import numpy as np N, K = list(map(int, input().split())) A = list(map(int, input().split())) B = 0 s = 1 for i, a in enumerate(A): if i >= K: B = A[i-K] s = a if B != 0 and B < s: print('Yes') elif B != 0 and B >= s: print('No')
s909468723
p03067
u223904637
2,000
1,048,576
Wrong Answer
17
2,940
105
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
a,b,c=map(int,input().split()) if (a<b and b<c) or (c<b and b<a): print('Yes') else: print('No')
s630754569
Accepted
18
2,940
105
a,b,c=map(int,input().split()) if (a<c and c<b) or (b<c and c<a): print('Yes') else: print('No')
s934206264
p03699
u962330718
2,000
262,144
Wrong Answer
18
3,060
245
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
n=int(input()) s=[int(input()) for i in range(n)] a=[0] for i in range(n): if s[i]%10!=0: a.append(s[i]) a.pop(0) if sum(s)%10==0: if 0 in a: print(0) else: print(sum(s)-min(a)) else: print(sum(s))
s885483354
Accepted
17
3,060
257
n=int(input()) s=[int(input()) for i in range(n)] a=[] for i in range(n): if s[i]%10!=0: a.append(s[i]) if len(a)==0: a.append(0) if sum(s)%10==0: if 0 in a: print(0) else: print(sum(s)-min(a)) else: print(sum(s))
s020037206
p02389
u362104929
1,000
131,072
Wrong Answer
30
7,612
200
Write a program which calculates the area and perimeter of a given rectangle.
def main(arg): numbers = [int(x) for x in arg.split(" ")] s = numbers[0] * numbers[1] p = (numbers[0] + numbers[1]) * 2 return s,p if __name__ == '__main__': print(main(input()))
s099037363
Accepted
20
7,624
236
def main(arg): numbers = [int(x) for x in arg.split(" ")] s = numbers[0] * numbers[1] p = (numbers[0] + numbers[1]) * 2 result = "{} {}".format(s,p) return result if __name__ == '__main__': print(main(input()))
s454896497
p02646
u725993280
2,000
1,048,576
Wrong Answer
26
9,056
510
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
a,v = map(int,input().split()) b,w = map(int,input().split()) t = int(input()) daplus = a + v*t daminus = a - v*t if daplus < daminus: tmp = daplus daplus = daminus daminus = tmp dbplus = b + w*t dbminus = b - w*t if dbplus < dbminus: tmp = dbplus dbplus = dbminus dbminus = tmp flag = 0 if(daminus <= dbplus & dbplus <= daplus): flag += 1 if(daminus <= dbminus & dbminus <= daplus): flag += 1 print(flag) if flag == 2: print("YES") else: print("NO")
s312311329
Accepted
24
9,188
497
a,v = map(int,input().split()) b,w = map(int,input().split()) t = int(input()) daplus = a + v*t daminus = a - v*t if daplus < daminus: tmp = daplus daplus = daminus daminus = tmp dbplus = b + w*t dbminus = b - w*t if dbplus < dbminus: tmp = dbplus dbplus = dbminus dbminus = tmp flag = 0 if(daminus <= dbplus & dbplus <= daplus): flag += 1 if(daminus <= dbminus & dbminus <= daplus): flag += 1 if flag == 2: print("YES") else: print("NO")
s136968240
p03565
u108617242
2,000
262,144
Wrong Answer
17
3,064
718
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
S = input() T = input() len_S = len(S) len_T = len(T) qc = 0 ans = '' for i in range(len_S-1, -1, -1): print(i, S[i]) si = S[i] if si == '?': qc += 1 else: qc = 0 if qc == len_T: ans = ans = S[:i] + T + S[i+len_T:] break if si == T[0] and len_S - i >= len_T: print(T) flag = True for ii in range(1, len_T): print(ii, S[i+ii]) if T[ii] == S[i+ii] or S[i+ii] == '?': continue else: flag = False break if flag: ans = S[:i] + T + S[i+len_T:] break if ans: print(ans.replace('?', 'a')) else: print('UNRESTORABLE')
s371298593
Accepted
17
3,064
525
S = input() T = input() len_S = len(S) len_T = len(T) qc = 0 ans = '' for i in range(len_S-1, -1, -1): si = S[i] if (si == '?' or si == T[0]) and len_S - i >= len_T: flag = True for ii in range(1, len_T): if T[ii] == S[i+ii] or S[i+ii] == '?': continue else: flag = False break if flag: ans = S[:i] + T + S[i+len_T:] break if ans: print(ans.replace('?', 'a')) else: print('UNRESTORABLE')
s106889848
p03433
u113971909
2,000
262,144
Wrong Answer
17
2,940
51
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
print('YNeos'[(int(input())%500)<=int(input())::2])
s745904779
Accepted
17
2,940
52
print('NYoe s'[(int(input())%500)<=int(input())::2])
s069809598
p03471
u191635495
2,000
262,144
Wrong Answer
2,104
15,348
866
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
N, Y = map(int, input().split()) a = 10000 b = 5000 c = 1000 x = -1 # 10000 y = -1 # 5000 z = -1 # 1000 if N * a >= Y: x = N y += 1 z += 1 diff = N*a - Y while diff >= 0: print(diff) if diff == 0: break else: if diff > 9000: # exchange 10000 to 1000 diff -= 9000 x -= 1 z += 1 elif diff > 5000: # exchange 10000 to 5000 diff -= 5000 x -= 1 y += 1 elif diff % 4000 == 0 and diff // 4000 == y: # exchange 5000 to 1000 diff = 0 y -= 1 z += 1 elif diff <= 4000: diff = 0 x = -1 y = -1 z = -1 print(x, y, z)
s387171735
Accepted
1,356
3,064
376
N, Y = map(int, input().split()) A = 10000 B = 5000 C = 1000 x = -1 y = -1 z = -1 for a in range(N+1): for b in range(N+1): if a + b > N: continue else: total = A*a + B*b + C*(N - (a + b)) if total == Y: x = a y = b z = N - (a + b) break print(x, y, z)
s827235923
p02678
u222668979
2,000
1,048,576
Wrong Answer
834
76,592
732
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
from collections import deque import sys input = sys.stdin.readline def bfs(NEAR, S, N): pas = [-1 for _ in range(N)] pas[S] = 's' frag = set([S]) que = deque([S]) while len(que) > 0: q = que.popleft() for i in NEAR[q]: if i in frag: continue pas[i]=q que.append(i) frag.add(i) return pas n, m = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(m)] near = [[] for _ in range(n)] for a, b in ab: near[a - 1].append(b - 1) near[b - 1].append(a - 1) print(near) pas = bfs(near, 0, n) for i in range(1, n): print(pas[i] + 1)
s595898965
Accepted
734
76,312
806
from collections import deque import sys input = sys.stdin.readline def bfs(NEAR, S, N): pas = [-1 for _ in range(N)] pas[S] = 's' frag = set([S]) que = deque([S]) while len(que) > 0: q = que.popleft() for i in NEAR[q]: if i in frag: continue pas[i]=q que.append(i) frag.add(i) return pas n, m = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(m)] near = [[] for _ in range(n)] for a, b in ab: near[a - 1].append(b - 1) near[b - 1].append(a - 1) pas = bfs(near, 0, n) if all(pas[i] != -1 for i in range(n)): print('Yes') for i in range(1, n): print(pas[i] + 1) else: print('No')
s857912563
p03944
u075595666
2,000
262,144
Wrong Answer
17
3,064
387
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.
W,H,N = map(int,input().split()) grid = [] for i in range(N): array = list(map(int,input().split())) grid.append(array) x1 = 0 xW = W y1 = 0 yH = H for i in grid: if i[2] == 1 and x1 < i[0]: x1 = i[0] elif i[2] == 2 and xW > i[0]: xH = i[0] elif i[2] == 3 and y1 < i[1]: y1 == i[1] elif i[2] == 4 and yH > i[1]: yH == i[1] else: continue print(max(0,xW-x1)*max(0,yH-y1))
s502183491
Accepted
18
3,064
367
W,H,N = map(int,input().split()) grid = [] for i in range(N): array = list(map(int,input().split())) grid.append(array) x1 = 0 xW = W y1 = 0 yH = H for i in grid: if i[2] == 1 and x1 < i[0]: x1 = i[0] elif i[2] == 2 and xW > i[0]: xW = i[0] elif i[2] == 3 and y1 < i[1]: y1 = i[1] elif i[2] == 4 and yH > i[1]: yH = i[1] print(max(0,xW-x1)*max(0,yH-y1))
s503799119
p03048
u430937688
2,000
1,048,576
Wrong Answer
1,933
3,060
222
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?
r, g, b, n = map(int, input().split()) cnt = 0 nr = 0 while nr <= n: m = n - nr * r ng = 0 while ng <= m: l = m - ng * g if not l % b: cnt += 1 ng += 1 nr += 1 print(cnt)
s137680785
Accepted
1,949
2,940
230
r, g, b, n = map(int, input().split()) cnt = 0 nr = 0 while nr * r <= n: m = n - nr * r ng = 0 while ng * g <= m: l = m - ng * g if not l % b: cnt += 1 ng += 1 nr += 1 print(cnt)
s820963474
p02694
u406405116
2,000
1,048,576
Wrong Answer
24
9,232
118
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
x = int(input()) y = 100 risi = 0 result = 0 while y <= x: y *= 1.01 y = y // 1 result += 1 print(int(result))
s915490117
Accepted
24
9,232
141
x = int(input()) y = 100 risi = 0 result = 0 while y <= x: y *= 1.01 y = y // 1 result += 1 if y >= x: break print(int(result))
s549930695
p03387
u090225501
2,000
262,144
Wrong Answer
17
3,064
557
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
def main(): a, b, c = map(int, input().split()) print(solve(a, b, c)) def solve(a, b, c): a, b, c = sorted([a, b, c]) x = a % 2 y = b % 2 z = c % 2 print(a, b, c) if x == y == z: return (c - a) // 2 + (c - b) // 2 if x == y: return solve(a + 1, b + 1, c) + 1 if x == z: return solve(a + 1, b, c + 1) + 1 if y == z: return solve(a, b + 1, c + 1) + 1 def evens(*args): n = 0 for i in args: if i % 2 == 0: n += 1 return n main()
s474940539
Accepted
17
3,064
541
def main(): a, b, c = map(int, input().split()) print(solve(a, b, c)) def solve(a, b, c): a, b, c = sorted([a, b, c]) x = a % 2 y = b % 2 z = c % 2 if x == y == z: return ((c - a) // 2) + ((c - b) // 2) if x == y: return solve(a + 1, b + 1, c) + 1 if x == z: return solve(a + 1, b, c + 1) + 1 if y == z: return solve(a, b + 1, c + 1) + 1 def evens(*args): n = 0 for i in args: if i % 2 == 0: n += 1 return n main()
s530352519
p03457
u578850957
2,000
262,144
Wrong Answer
340
3,060
231
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
N = int(input()) x_before = 0 y_before = 0 ans = 'YES' for i in range(N): t, x, y = map(int, input().split()) abs_distace = abs(x) + abs(y) if((t-abs_distace)%2!=0): ans = 'NO' break print(ans)
s377361789
Accepted
383
3,064
608
N = int(input()) x_before = 0 y_before = 0 t_before = 0 ans = 'Yes' for i in range(N): t, x, y = map(int, input().split()) distance = abs(x-x_before) + abs(y-y_before) time = t-t_before if time-distance<0: ans = 'No' break if time%2 != distance%2: ans = 'No' break x_before = x y_before = y t_before = t print(ans)
s699233797
p03385
u668726177
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 sorted(s)=='abc': print('Yes') else: print('No')
s406887348
Accepted
17
2,940
76
s = input() if ''.join(sorted(s))=='abc': print('Yes') else: print('No')
s594924722
p03997
u733321071
2,000
262,144
Wrong Answer
17
2,940
72
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a = int(input()) b = int(input()) h = int(input()) print((a+b) * h / 2)
s508125316
Accepted
17
2,940
70
a = int(input()) b = int(input()) h = int(input()) print((a+b)*h // 2)
s569278172
p03644
u699944218
2,000
262,144
Wrong Answer
17
2,940
73
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
N = int(input()) ans = 64 if ans > N: ans /= 2 print(int(ans))
s689744934
Accepted
18
3,060
76
N = int(input()) ans = 64 while ans > N: ans /= 2 print(int(ans))
s321058913
p03370
u546440137
2,000
262,144
Wrong Answer
28
9,156
109
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
N,X=map(int,input().split()) m=[] for i in range(N): m.append(int(input())) print(X-sum(m)//min(m)+N)
s910754675
Accepted
25
9,156
111
N,X=map(int,input().split()) m=[] for i in range(N): m.append(int(input())) print((X-sum(m))//min(m)+N)
s642250946
p03485
u111365362
2,000
262,144
Wrong Answer
17
2,940
63
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.
#18:50 a,b = map(int,input().split()) print( (a+b+1) // 2 + 1 )
s449452087
Accepted
17
2,940
63
#18:50 a,b = map(int,input().split()) print( (a+b-1) // 2 + 1 )
s044497429
p02396
u098047375
1,000
131,072
Wrong Answer
90
5,904
155
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
a = [] while True: n = int(input()) if n == 0: break a.append(n) for i in range(len(a)): print('Case '+ str(i) + ': ' + str(a[i]))
s835294056
Accepted
80
5,908
157
a = [] while True: n = int(input()) if n == 0: break a.append(n) for i in range(len(a)): print('Case '+ str(i+1) + ': ' + str(a[i]))
s162188089
p03370
u469063372
2,000
262,144
Wrong Answer
194
2,940
164
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
N, X = map(int, input().split()) ms = [] for i in range(N): ms.append(int(input())) count = len(ms) while X >= 0: count += 1 X -= min(ms) print(count-1)
s722389849
Accepted
197
3,060
177
N, X = map(int, input().split()) ms = [] for i in range(N): ms.append(int(input())) X -= sum(ms) count = len(ms) while X >= 0: count += 1 X -= min(ms) print(count-1)
s928809453
p03574
u256464928
2,000
262,144
Wrong Answer
23
3,572
649
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
h,w = map(int,input().split()) count = 0 X = [] p = [] X.append(["@"]*(w+2)) for _ in range(h): p = [] x = input() for i in range(w): p.append(x[i]) X.append(["@"]+p+["@"]) X.append(["@"]*(w+2)) for i in range(1,h+1): for j in range(1,w+1): count=0 if X[i][j]==".": if X[i-1][j-1]=="#":count+=1 if X[i-1][j]=="#":count+=1 if X[i-1][j+1]=="#":count+=1 if X[i][j-1]=="#":count+=1 if X[i][j+1]=="#":count+=1 if X[i+1][j-1]=="#":count+=1 if X[i+1][j]=="#":count+=1 if X[i+1][j+1]=="#":count+=1 count=str(count) X[i][j]=count for k in range(1,h+1): print(*X[k][1:w+1])
s442568823
Accepted
22
3,572
656
h,w = map(int,input().split()) count = 0 X = [] p = [] X.append(["@"]*(w+2)) for _ in range(h): p = [] x = input() for i in range(w): p.append(x[i]) X.append(["@"]+p+["@"]) X.append(["@"]*(w+2)) for i in range(1,h+1): for j in range(1,w+1): count=0 if X[i][j]==".": if X[i-1][j-1]=="#":count+=1 if X[i-1][j]=="#":count+=1 if X[i-1][j+1]=="#":count+=1 if X[i][j-1]=="#":count+=1 if X[i][j+1]=="#":count+=1 if X[i+1][j-1]=="#":count+=1 if X[i+1][j]=="#":count+=1 if X[i+1][j+1]=="#":count+=1 count=str(count) X[i][j]=count for k in range(1,h+1): print(*X[k][1:w+1],sep="")
s142505484
p03455
u734252743
2,000
262,144
Wrong Answer
27
9,036
95
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a, b =map(int, input().split()) if ( a*b % 2 == 0 ): print("EVEN") else: print("ODD")
s311457842
Accepted
27
9,080
95
a, b =map(int, input().split()) if ( a*b % 2 == 0 ): print("Even") else: print("Odd")
s940004397
p02408
u796301295
1,000
131,072
Wrong Answer
20
5,596
223
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.
cards = [] for i in set({'S','H','C','D'}): for j in range(1, 14): cards.append(i + " " + str(j)) N = int(input()) for i in range(N): cards.remove(input()) for i in range(len(cards)): print (cards[i])
s693747853
Accepted
20
5,600
159
c = [x+' '+y for x in ['S','H','C','D'] for y in [str(i) for i in range(1,14)]] for i in range(int(input())): c.remove(input()) for i in c: print (i)
s759569818
p02612
u804711544
2,000
1,048,576
Wrong Answer
32
9,140
30
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
n = int(input()) print(n%1000)
s332881402
Accepted
28
9,140
76
n = int(input()) if n%1000 == 0: print(0) else: print(1000-(n%1000))
s983702406
p02534
u973972117
2,000
1,048,576
Wrong Answer
28
9,016
73
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`.
K = int(input()) Ans = 'ACL' for i in range(K-1): Ans += Ans print(Ans)
s122130696
Accepted
20
9,020
77
K = int(input()) Ans = 'ACL' for i in range(K-1): Ans += 'ACL' print(Ans)
s764726168
p03697
u319612498
2,000
262,144
Wrong Answer
17
2,940
61
You are given two integers A and B as the input. Output the value of A + B. However, if A + B is 10 or greater, output `error` instead.
a,b=map(int,input().split()) print(a+b if a+b<9 else "error")
s119807881
Accepted
17
2,940
63
a,b=map(int,input().split()) print(a+b if a+b<10 else "error")
s148347575
p03139
u278670845
2,000
1,048,576
Wrong Answer
18
2,940
59
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.
n,a,b = map(int, input().split()) print(min(a,b), abs(a-b))
s844465376
Accepted
17
2,940
95
n,a,b = map(int, input().split()) if a+b >n: print(min(a,b), a+b-n) else: print(min(a,b), 0)
s277518597
p03139
u569742427
2,000
1,048,576
Wrong Answer
20
3,060
299
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.
N,A,B=[int(_) for _ in input().split() ] if A>=B: MAX=str(A+B) MIN=str(B) if A+B>=N: print(str(N)+' '+MIN) exit(0) print(MAX+" "+MIN) exit(0) if B>A: MAX=str(A+B) MIN=str(B) if A+B>=N: print(str(N)+' '+MIN) print(MAX+" "+MIN) exit(0)
s126048621
Accepted
17
3,060
231
N,A,B=[int(_) for _ in input().split() ] if A>=B: BIG=A SMALL=B if B>A: BIG=B SMALL=A MAX=SMALL if BIG+SMALL<=N: MIN=SMALL print(str(MAX)+' 0') exit(0) MIN=BIG+SMALL-N print(str(MAX)+' '+str(MIN))
s555476689
p04030
u477216059
2,000
262,144
Wrong Answer
17
2,940
228
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
if __name__ == "__main__": sl = list(input()) print(sl) text = "" for s in sl: if s == "0" or s == "1": text = text + s elif s == "B": text = text[:-1] print(text)
s586927923
Accepted
17
2,940
244
if __name__ == "__main__": sl = list(input()) text = "" for s in sl: if s == "0" or s == "1": text = text + s elif s == "B": if text != "": text = text[:-1] print(text)
s075054760
p03359
u951601135
2,000
262,144
Wrong Answer
18
2,940
61
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
a,b=map(int,input().split()) print(a if(a<b) else print(a-1))
s441857797
Accepted
18
2,940
56
a,b=map(int,input().split()) print(a if (a<=b) else a-1)