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
s655385708
p03854
u603234915
2,000
262,144
Wrong Answer
18
3,188
98
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`.
l = ['resare', 'esare', 'maerd', 'remaerd'] s = input()[::-1] for i in l: s = s.replace(i, '')
s094011693
Accepted
40
3,188
441
S = input() S = S[::-1] L = ['dream', 'dreamer', 'erase', 'eraser'] L = [[l[::-1], len(l)] for l in L] can = True ind = 0 S_max = len(S) while can: if ind == S_max: break for l in L: if ind + l[1] > S_max: pass else: if l[0] == S[ind: ind+l[1]]: ind += l[1] break else: can = False if can: print("YES") else: print("NO")
s052203182
p00016
u957021485
1,000
131,072
Wrong Answer
20
7,760
336
When a boy was cleaning up after his grand father passing, he found an old paper: In addition, other side of the paper says that "go ahead a number of steps equivalent to the first integer, and turn clockwise by degrees equivalent to the second integer". His grand mother says that Sanbonmatsu was standing at the center of town. However, now buildings are crammed side by side and people can not walk along exactly what the paper says in. Your task is to write a program which hunts for the treature on the paper. For simplicity, 1 step is equivalent to 1 meter. Input consists of several pairs of two integers d (the first integer) and t (the second integer) separated by a comma. Input ends with "0, 0". Your program should print the coordinate (x, y) of the end point. There is the treature where x meters to the east and y meters to the north from the center of town. You can assume that d ≤ 100 and -180 ≤ t ≤ 180\.
import sys import itertools import math curdeg = 90 xstep = 0 ystep = 0 for line in sys.stdin.readlines(): step, deg = map(int, line.split(",")) xstep += -step * math.cos(math.pi * curdeg / 180) ystep += step * math.sin(math.pi * curdeg / 180) curdeg += deg print("{:.0f}".format(xstep)) print("{:.0f}".format(ystep))
s326246766
Accepted
30
7,860
310
import sys import itertools import math curdeg = 0 xstep = 0 ystep = 0 for line in sys.stdin.readlines(): step, deg = map(int, line.split(",")) xstep += step * math.cos(math.pi * curdeg / 180) ystep += step * math.sin(math.pi * curdeg / 180) curdeg += deg print(int(ystep)) print(int(xstep))
s205568726
p03338
u982594421
2,000
1,048,576
Wrong Answer
19
3,060
212
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.
n = int(input()) s = input().rstrip() ans = 0 for i in range(1, len(s)): s1, s2 = s[0:i], s[i:] c = set(s1).intersection(set(s2)) for ch in c: ans = max(ans, min(s1.count(ch), s2.count(ch))) print(ans)
s112915180
Accepted
18
2,940
172
n = int(input()) s = input().rstrip() ans = 0 for i in range(1, len(s)): s1, s2 = s[0:i], s[i:] c = set(s1).intersection(set(s2)) ans = max(ans, len(c)) print(ans)
s346013619
p03399
u396890425
2,000
262,144
Wrong Answer
17
2,940
48
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
print(min(input(),input())+min(input(),input()))
s583962629
Accepted
17
2,940
68
print(min(int(input()),int(input()))+min(int(input()),int(input())))
s978522001
p02412
u805716376
1,000
131,072
Wrong Answer
20
5,596
204
Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9
n, x = map(int, input().split()) cnt = 0 for i in range(n): if i >= x-3:break for j in range(i+1,n): for k in range(j+1, n): if i+j+k == x: cnt += 1 print(cnt)
s468074383
Accepted
450
5,592
265
while 1: n, x = map(int, input().split()) if n == x == 0: break cnt = 0 for i in range(1,n+1): for j in range(i+1,n+1): for k in range(j+1, n+1): if i+j+k == x: cnt += 1 print(cnt)
s844328569
p03416
u695429668
2,000
262,144
Wrong Answer
153
6,772
327
Find the number of _palindromic numbers_ among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.
# coding : utf-8 A, B = list(map(int, input().split())) _list = list(range(A, B+1)) count = 0 buff = 0 for elm in _list: buff = 0 m = str(elm) _len = len(m) - 1 for i in range(3): if m[i] == m[4-i]: buff += 1 if buff >= 3: print(m) count += 1 print(count)
s409875258
Accepted
153
6,516
310
# coding : utf-8 A, B = list(map(int, input().split())) _list = list(range(A, B+1)) count = 0 buff = 0 for elm in _list: buff = 0 m = str(elm) _len = len(m) - 1 for i in range(3): if m[i] == m[4-i]: buff += 1 if buff >= 3: count += 1 print(count)
s671342340
p03095
u288430479
2,000
1,048,576
Wrong Answer
36
10,136
140
You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings. Here, a subsequence of a string is a concatenation of **one or more** characters from the string without changing the order.
from collections import Counter n = input() mod = 10**9+7 s = list(Counter(list(input())).values()) an = 1 for i in s: an *= i print(an-1)
s735063587
Accepted
36
10,048
154
from collections import Counter n = input() mod = 10**9+7 s = list(Counter(list(input())).values()) an = 1 for i in s: an *= (i+1)%mod print((an-1)%mod)
s074319610
p03457
u045091221
2,000
262,144
Wrong Answer
539
18,468
463
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.
import collections def solve(N, ts, ps): for i in range(N-1): dt = ts[i+1] - ts[i] d = abs(ps[i+1].x - ps[i].x) + abs(ps[i+1].y - ps[i].y) if d <= dt and dt % 2 == d % 2: return "YES" return "NO" N = int(input()) point = collections.namedtuple('point', ['x', 'y']) ts = [] ps = [] for i in range(N): t, x, y = list(map(int, input().split())) ts.append(t) ps.append(point(x, y)) print(solve(N, ts, ps))
s861009532
Accepted
568
18,560
471
import collections def solve(N, ts, ps): for i in range(N): dt = ts[i+1] - ts[i] d = abs(ps[i+1].x - ps[i].x) + abs(ps[i+1].y - ps[i].y) if d > dt or dt % 2 != d % 2: return "No" return "Yes" N = int(input()) point = collections.namedtuple('point', ['x', 'y']) ts = [0] ps = [point(0, 0)] for i in range(N): t, x, y = list(map(int, input().split())) ts.append(t) ps.append(point(x, y)) print(solve(N, ts, ps))
s665872063
p02396
u987236471
1,000
131,072
Time Limit Exceeded
9,990
5,596
77
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.
i = 0 x = input() while x != 0: print("Case {}: {}".format(i,x)) i += i+1
s972164768
Accepted
140
5,596
99
i = 1 while True: x =int(input()) if x == 0: break print("Case {}: {}".format(i,x)) i = i+1
s986906445
p02614
u696444274
1,000
1,048,576
Wrong Answer
40
10,492
2,287
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
import datetime from decimal import Decimal, ROUND_DOWN import heapq from fractions import gcd from functools import reduce from collections import deque # from math import factorial import itertools import collections import math import sys sys.setrecursionlimit(2000000) # import statistics # import numpy as np # n = int(input()) # n, m, p = list(map(int, input().split())) # a = list(map(int, input().split())) # # n = int(input()) h, w, k = list(map(int, input().split())) # A = list(map(int, input().split())) # a = list(map(int, input().split())) # b = list(map(int, input().split())) # print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10))) c = [] kuro = 0 col_sum = [] row_sum = [] for i in range(h): a = input() c.append(a) ac = a.count('#') kuro += ac col_sum.append(ac) for i in range(w): cc = 0 for j in range(h): if c[j][i] == "#": cc += 1 row_sum.append(cc) # print(col_sum) # print(row_sum) # print("----------") if kuro == k: print(1) exit() ans = 0 lll = row_sum+col_sum for i in range(1, h+w): l = list(itertools.combinations(lll, i)) # print(l) for j in range(len(l)): _max = max(l[j]) if _max > k: m_count = 0 tt = _max for k in range(i): if l[j][k] != _max or(l[j][k] == _max and m_count == 1): tt -= l[j][k] elif l[j][k] == _max and m_count == 0: m_count += 1 if tt == k: ans += 1 elif sum(l[j]) == k: ans += 1 # print(lll) # print(ll) print(ans)
s197524567
Accepted
56
9,184
751
h, w, f = list(map(int, input().split())) c = [input() for i in range(h)] count = 0 bit_h = [] for k in range(2**h): hh = [] for l in range(h): if((k >> l) & 1): hh.append(1) else: hh.append(0) bit_h.append(hh) bit_w = [] for i in range(2**w): ww = [] for j in range(w): if((i >> j) & 1): ww.append(1) else: ww.append(0) bit_w.append(ww) ans = 0 for i in range(len(bit_h)): for j in range(len(bit_w)): count = 0 for k in range(h): for l in range(w): if bit_h[i][k] == 1 and bit_w[j][l] == 1 and c[k][l] == "#": count += 1 if count == f: ans += 1 print(ans)
s059449949
p02281
u938045879
1,000
131,072
Wrong Answer
20
5,604
741
Binary trees are defined recursively. A binary tree _T_ is a structure defined on a finite set of nodes that either * contains no nodes, or * is composed of three disjoint sets of nodes: \- a root node. \- a binary tree called its left subtree. \- a binary tree called its right subtree. Your task is to write a program which perform tree walks (systematically traverse all nodes in a tree) based on the following algorithms: 1. Print the root, the left subtree and right subtree (preorder). 2. Print the left subtree, the root and right subtree (inorder). 3. Print the left subtree, right subtree and the root (postorder). Here, the given binary tree consists of _n_ nodes and evey node has a unique ID from 0 to _n_ -1.
n = int(input()) root = set(range(n)) nodes = [0 for i in range(n)] for i in range(n): node = list(map(int, input().split())) children = node[1:3] root -= set(children) nodes[node[0]] = children def preorder(id): if(id == -1): return order.append(id) preorder(nodes[id][0]) preorder(nodes[id][1]) def inorder(id): if(id == -1): return inorder(nodes[id][0]) order.append(id) inorder(nodes[id][1]) def postorder(id): if(id == -1): return postorder(nodes[id][0]) postorder(nodes[id][1]) order.append(id) order = [] preorder(list(root)[0]) print(*order) order = [] inorder(list(root)[0]) print(*order) order = [] postorder(list(root)[0]) print(*order)
s057732936
Accepted
20
5,616
852
n = int(input()) root = set(range(n)) nodes = [0 for i in range(n)] for i in range(n): node = list(map(int, input().split())) children = node[1:3] root -= set(children) nodes[node[0]] = children def preorder(id): if(id == -1): return order.append(id) preorder(nodes[id][0]) preorder(nodes[id][1]) def inorder(id): if(id == -1): return inorder(nodes[id][0]) order.append(id) inorder(nodes[id][1]) def postorder(id): if(id == -1): return postorder(nodes[id][0]) postorder(nodes[id][1]) order.append(id) order = [] preorder(list(root)[0]) print('Preorder') print(' ', end='') print(*order) order = [] inorder(list(root)[0]) print('Inorder') print(' ', end='') print(*order) order = [] postorder(list(root)[0]) print('Postorder') print(' ', end='') print(*order)
s639731965
p03698
u853900545
2,000
262,144
Wrong Answer
18
2,940
76
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
s = input() if len(set(s)) < len(s): print('No') else: print('Yes')
s207338621
Accepted
18
2,940
76
s = input() if len(set(s)) < len(s): print('no') else: print('yes')
s601030089
p03962
u226912938
2,000
262,144
Wrong Answer
17
3,064
395
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.
s = str(input()) g_count = 0 p_count = 0 point = 0 for i in range(len(s)): if g_count == p_count: g_count += 1 if s[i] == 'g': pass else: point -= 1 elif s[i] == 'g': p_count += 1 point += 1 elif s[i] == 'p': p_count += 1 ans = point print(ans)
s899805610
Accepted
16
2,940
66
color = set(map(int, input().split())) ans = len(color) print(ans)
s583058009
p03759
u717001163
2,000
262,144
Wrong Answer
18
2,940
65
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()) print("YES" if c-b==a-b else "NO")
s131155047
Accepted
17
2,940
65
a,b,c=map(int,input().split()) print("YES" if c-b==b-a else "NO")
s690191528
p03131
u602075385
2,000
1,048,576
Wrong Answer
18
2,940
181
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()) bis, jpn = 1, 0 if b-a < 2 or k <= a-1: print(k+1) else: bis = a + max(b-a, 2) * (k-a+1)/2 + (k-a+1)%2 print(int(bis))
s355208599
Accepted
18
2,940
186
k, a, b = map(int, input().split()) bis, jpn = 1, 0 if b-a < 2 or k <= a-1: print(k+1) else: bis = a + max(b-a, 2) * int((k-a+1)/2) + (k-a+1)%2 print(int(bis))
s972475593
p03449
u689322583
2,000
262,144
Wrong Answer
17
2,940
52
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
import sys line = sys.stdin.readlines() print(line)
s070162354
Accepted
19
3,064
430
#coding: utf-8 N = int(input()) A0 = list(map(int, input().split())) A1 = list(map(int, input().split())) sum = [] for n in range(N): tmp = 0 if(n==0): tmp += A0[0] for j in range(N): tmp += A1[j] sum.append(tmp) else: for i in range(n): tmp += A0[i] for j in range(n-1, N): tmp += A1[j] sum.append(tmp) ans = max(sum) print(ans)
s153117604
p02865
u707808519
2,000
1,048,576
Wrong Answer
20
3,316
73
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
N = int(input()) if N%2 == 0: print(N/2 - 1) else: print((N-1)/2)
s883387343
Accepted
17
2,940
83
N = int(input()) if N%2 == 0: print(int(N/2 - 1)) else: print(int((N-1)/2))
s628407676
p03387
u677121387
2,000
262,144
Wrong Answer
17
3,064
223
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
a = list(map(int,input().split())) a.sort() b = list(map(lambda x:x%2,a)) ans = 0 for i in range(3): if sum(b) == 1: a[i] -= b[i] else: a[i] += b[i] ans += (a[2]-a[0])//2+ (a[2]-a[1])//2 print(ans)
s892496106
Accepted
17
3,064
276
a = list(map(int,input().split())) a.sort() b = list(map(lambda x:x%2,a)) ans = 0 if sum(b) in (1,2): ans += 1 for i in range(3): if sum(b) == 1: a[i] -= b[i] else: a[i] += b[i] ans += (a[2]-a[0])//2+ (a[2]-a[1])//2 print(ans)
s118061811
p03503
u285443936
2,000
262,144
Wrong Answer
166
4,364
356
Joisino is planning to open a shop in a shopping street. Each of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those periods. There are already N stores in the street, numbered 1 through N. You are given information of the business hours of those shops, F_{i,j,k}. If F_{i,j,k}=1, Shop i is open during Period k on Day j (this notation is explained below); if F_{i,j,k}=0, Shop i is closed during that period. Here, the days of the week are denoted as follows. Monday: Day 1, Tuesday: Day 2, Wednesday: Day 3, Thursday: Day 4, Friday: Day 5. Also, the morning is denoted as Period 1, and the afternoon is denoted as Period 2. Let c_i be the number of periods during which both Shop i and Joisino's shop are open. Then, the profit of Joisino's shop will be P_{1,c_1}+P_{2,c_2}+...+P_{N,c_N}. Find the maximum possible profit of Joisino's shop when she decides whether her shop is open during each period, making sure that it is open during at least one period.
n = int(input()) bits = [] for i in range(n): bit = int(input().replace(" ", ""), 2) bits.append(bit) p = [[int(item) for item in input().split()] for _ in range(n)] ans = - 10**9 for i in range(1,2**10): val = 0 for j,mise in enumerate(p): val += mise[bin(i & bits[j]).count("1")] print(bin(i & bits[j])) ans = max(ans, val) print(ans)
s497822078
Accepted
270
3,064
368
N = int(input()) F = [list(map(int, input().split())) for i in range(N)] P = [list(map(int, input().split())) for i in range(N)] ans = -(10**9) for i in range(1,2**10): S = [0]*N tmp = 0 for j in range(10): for k in range(N): if (i >> j) & 1 and F[k][j] == 1: S[k] += 1 for m in range(N): tmp += P[m][S[m]] ans = max(ans,tmp) print(ans)
s095191801
p04043
u150460433
2,000
262,144
Wrong Answer
17
2,940
114
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.
L=list(map(int, input().split())) L.sort() if L[0]==5 and L[1]==5 and L[2]==7: print("yes") else: print("no")
s890626128
Accepted
17
2,940
114
L=list(map(int, input().split())) L.sort() if L[0]==5 and L[1]==5 and L[2]==7: print("YES") else: print("NO")
s410302692
p03007
u097121858
2,000
1,048,576
Wrong Answer
2,104
17,236
698
There are N integers, A_1, A_2, ..., A_N, written on a blackboard. We will repeat the following operation N-1 times so that we have only one integer on the blackboard. * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y. Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.
N = int(input()) A = list(map(int, input().split())) numbers = {a: 0 for a in set(A)} for a in A: numbers[a] += 1 operations = [] for _ in range(N - 2): numbers_keys = numbers.keys() x = min(numbers_keys) y = max(numbers_keys) operations.append((x, y)) z = x - y if z in numbers: numbers[z] += 1 else: numbers[z] = 1 if numbers[x] == 1: del numbers[x] else: numbers[x] -= 1 if numbers[y] == 1: del numbers[y] else: numbers[y] -= 1 A = [] for k, v in numbers.items(): A.extend([k] * v) x, y = max(A), min(A) print(x - y) operations.append((x, y)) for o in operations: print(*o, sep=" ")
s099531688
Accepted
221
14,144
641
N = int(input()) A = list(map(int, input().split())) A.sort() neg = [n for n in A if n < 0] pos = [n for n in A if n >= 0] if len(neg) == 0: # all positive x = A.pop(0) print(sum(A) - x) pivot = A.pop() for y in A: print(x, y) x -= y print(pivot, x) elif len(pos) == 0: x = A.pop() print(x - sum(A)) for y in A: print(x, y) x -= y else: print(sum(pos) - sum(neg)) pivot = pos.pop() x = neg.pop() for y in pos: print(x, y) x -= y x, pivot = pivot, x for y in neg: print(x, y) x -= y print(x, pivot)
s468343201
p02842
u871841829
2,000
1,048,576
Wrong Answer
18
3,064
76
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 N%1.08 != 0: print(":(") else: print(N//1.08)
s445966287
Accepted
32
3,064
141
N = int(input()) import math import sys for i in range(1, 50000+1): if math.floor(i * 1.08) == N: print(i) sys.exit() print(":(")
s036379511
p02601
u019355060
2,000
1,048,576
Wrong Answer
28
9,176
194
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
A,B,C=map(int,input().split()) K=int(input()) for i in range(K): if A>=B: B=B*2 print(A,B,C) elif B>=C: C=C*2 print(A,B,C) if (A<B)&(B<C): print("yes") else: print("No")
s530070522
Accepted
28
9,168
162
A,B,C=map(int,input().split()) K=int(input()) for i in range(K): if A>=B: B=B*2 elif B>=C: C=C*2 if ((A<B)&(B<C)): print("Yes") else: print("No")
s350888205
p03795
u359007262
2,000
262,144
Wrong Answer
17
2,940
74
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
n = int(input()) pay = 800 * n get = n // 15 ans = pay - get print(ans)
s160262508
Accepted
17
2,940
82
n = int(input()) pay = 800 * n get = (n // 15) * 200 ans = pay - get print(ans)
s094318246
p03485
u821588465
2,000
262,144
Wrong Answer
17
2,940
66
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.
import math a, b = map(int, input().split()) print(math.ceil(b/a))
s580634322
Accepted
18
2,940
70
import math a, b = map(int, input().split()) print(math.ceil((a+b)/2))
s610835945
p03576
u391731808
2,000
262,144
Wrong Answer
120
3,064
675
We have N points in a two-dimensional plane. The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i). Let us consider a rectangle whose sides are parallel to the coordinate axes that contains K or more of the N points in its interior. Here, points on the sides of the rectangle are considered to be in the interior. Find the minimum possible area of such a rectangle.
N,K = map(int,input().split()) XY = [list(map(int,input().split())) for _ in [0]*N] iX = sorted(x for x,y in XY) iY = sorted(y for x,y in XY) X = {x:i for i,x in enumerate(iX)} Y = {y:i for i,y in enumerate(iY)} c = [[0]*(N+1) for i in [0]*(N+1)] for x,y in XY: c[Y[y]+1][X[x]+1] = 1 for i in range(N): for j in range(N): c[i+1][j+1] += c[i+1][j] + c[i][j+1] ans = 10**20 for l in range(N): for r in range(l+1,N): u = 0 d = 1 dX = iX[r] - iX[l] while d<N: if c[d+1][r+1]+c[u][l]-c[u][r+1]-c[d+1][l] >=K: ans = min(ans, dX*(iY[d]-iY[u])) u+=1 else:d+=1 print(ans)
s191911583
Accepted
60
3,188
990
def main(): N,K = map(int,input().split()) XY = [list(map(int,input().split())) for _ in [0]*N] iX = [0]*N iY = [0]*N for i,xy in enumerate(XY): x,y = xy iX[i] = x iY[i] = y iX.sort() iY.sort() X = {x:i for i,x in enumerate(iX)} Y = {y:i for i,y in enumerate(iY)} c = [[0]*(N+1) for i in [0]*(N+1)] for x,y in XY: c[Y[y]+1][X[x]+1] = 1 for i in range(N): ci1 = c[i+1] for j in range(N): ci1[j+1] += ci1[j] for i in range(N): c[i+1] = [ci1j+cij for ci1j,cij in zip(c[i+1],c[i])] ans = 10**20 for u in range(N): for d in range(u+K-1,N): l = 0 r = K-1 dY = iY[d]-iY[u] cd = c[d+1] cu = c[u] while r<N: if cd[r+1]+cu[l]-cu[r+1]-cd[l] >=K: ans = min(ans, (iX[r] - iX[l])*dY) l+=1 else:r+=1 print(ans) main()
s406338409
p03351
u440129511
2,000
1,048,576
Wrong Answer
18
2,940
78
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
a,b,c,d= map(int,input().split()) if abs(c-a)<=d:print('Yes') else:print('No')
s107604357
Accepted
17
2,940
117
a,b,c,d= map(int,input().split()) if abs(c-a)<=d or abs(a - b) <= d and abs(b - c) <= d:print('Yes') else:print('No')
s071613182
p03455
u907676137
2,000
262,144
Wrong Answer
26
8,976
94
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
b, c = map(int, input().split()) if (b * c //2) == 0: print('Even') else: print('Odd')
s237497960
Accepted
29
9,040
96
b, c = map(int, input().split()) if ((b * c) % 2) == 0: print('Even') else: print('Odd')
s152167530
p03493
u873839198
2,000
262,144
Wrong Answer
17
2,940
90
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
number = input() count = 0 for n in number: if n == 1: count += 1 print(count)
s336672042
Accepted
17
2,940
93
number = str(input()) count = 0 for n in number: if n == "1": count += 1 print(count)
s786961366
p03637
u731322489
2,000
262,144
Wrong Answer
51
14,252
158
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
n = int(input()) A = list(map(int, input().split())) count = len([a for a in A if a % 4 == 0]) print(count, n // 2) print("Yes" if count >= n // 2 else "No")
s897410396
Accepted
58
14,224
326
n = int(input()) A = list(map(int, input().split())) count_4 = len([a for a in A if a % 4 == 0]) count_2 = len([a for a in A if a % 2 == 0]) - count_4 others = n - (count_4 + count_2) ans = "" if count_2 == 0: ans = "Yes" if others <= count_4 + 1 else "No" else: ans = "Yes" if others <= count_4 else "No" print(ans)
s258514210
p03761
u105302073
2,000
262,144
Wrong Answer
20
3,188
280
Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains. Find the longest string that can be created regardless of which string among S_1,...,S_n the headline contains. If there are multiple such strings, find the lexicographically smallest one among them.
n = int(input()) s = [input() for _ in range(n)] a = "abcdefghijklmnopqrstuvwxyz" cnt = [] for i in a: mi = 50 for j in s: print(i, j, j.count(i)) mi = min(mi, j.count(i)) cnt.append(mi) ans = "" for i in range(26): ans += a[i] * cnt[i] print(ans)
s113745094
Accepted
18
3,060
248
n = int(input()) s = [input() for _ in range(n)] a = "abcdefghijklmnopqrstuvwxyz" cnt = [] for i in a: mi = 50 for j in s: mi = min(mi, j.count(i)) cnt.append(mi) ans = "" for i in range(26): ans += a[i] * cnt[i] print(ans)
s066755486
p02613
u554590385
2,000
1,048,576
Wrong Answer
156
9,172
303
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
n = int(input()) c1=0 c2=0 c3=0 c4=0 for I in range(1, n): s = str(input()) if(s == "AC"): c1+= 1 elif(s == "WA"): c2+=1 elif(s == "TLE"): c3+=1 elif(s == "RE"): c4 +=1 print(f"AC x {c1}") print(f"WA x {c2}") print(f"TLE x {c3}") print(f"RE x {c4}")
s326109701
Accepted
158
9,152
305
n = int(input()) c1=0 c2=0 c3=0 c4=0 for I in range(1, n+1): s = str(input()) if(s == "AC"): c1+= 1 elif(s == "WA"): c2+=1 elif(s == "TLE"): c3+=1 elif(s == "RE"): c4 +=1 print(f"AC x {c1}") print(f"WA x {c2}") print(f"TLE x {c3}") print(f"RE x {c4}")
s309467406
p03377
u556477263
2,000
262,144
Wrong Answer
29
9,072
84
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
a,b,c = map(int,input().split()) if a+b <= c: print('YES') else: print('NO')
s541959071
Accepted
25
9,092
99
a,b,c = map(int,input().split()) if a <= c and a+b >= c: print('YES') else: print('NO')
s399343818
p02260
u749243807
1,000
131,072
Wrong Answer
20
5,600
484
Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 if A[j] < A[mini] 5 mini = j 6 swap A[i] and A[mini] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i ≠ mini.
count = int(input()); data = [int(n) for n in input().split(" ")]; def selection_sort(data): count = len(data); o = 0; for i in range(count): minI = i; for j in range(i + 1, count): if data[j] < data[minI]: minI = j; temp = data[i]; data[i] = data[minI]; data[minI] = temp; o += 1; show(data); print(o); def show(data): print(" ".join(str(n) for n in data)); selection_sort(data);
s929455939
Accepted
20
5,600
522
count = int(input()); data = [int(n) for n in input().split(" ")]; def selection_sort(data): count = len(data); o = 0; for i in range(count): minI = i; for j in range(i + 1, count): if data[j] < data[minI]: minI = j; if minI != i: temp = data[i]; data[i] = data[minI]; data[minI] = temp; o += 1; show(data); print(o); def show(data): print(" ".join(str(n) for n in data)); selection_sort(data);
s029578761
p02613
u756311765
2,000
1,048,576
Wrong Answer
145
16,268
221
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
N = int(input()) S = [] for _ in range(N): S.append(input()) AC = S.count('AC') WA = S.count('WA') TLE = S.count('TLE') RE = S.count('RE') print('AC ×', AC) print('WA ×', WA) print('TLE ×', TLE) print('RE ×', RE)
s920109176
Accepted
151
16,284
217
N = int(input()) S = [] for _ in range(N): S.append(input()) AC = S.count('AC') WA = S.count('WA') TLE = S.count('TLE') RE = S.count('RE') print('AC x', AC) print('WA x', WA) print('TLE x', TLE) print('RE x', RE)
s155796765
p03778
u278670845
2,000
262,144
Wrong Answer
17
2,940
132
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
import sys w,a,b = map(int, input().split()) if a+w>b or b+w>a: print(0) elif a+w<b: print(b-a-w+1) elif b+w<a: print(a-b-w+1)
s962546596
Accepted
17
3,060
136
import sys w,a,b = map(int, input().split()) if a+w>=b>=a or b+w>=a>=b: print(0) elif a+w<b: print(b-a-w) elif b+w<a: print(a-b-w)
s775954496
p02613
u060927350
2,000
1,048,576
Wrong Answer
150
9,212
273
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.
arr=[0]*4 for _ in range(int(input())): s=input() if s=='AC': arr[0]+=1 elif s=='WA': arr[1]+=1 elif s=='TLE': arr[2]+=1 else: arr[3]+=1 print("AC *",arr[0]) print("WA *",arr[1]) print("TLE *",arr[2]) print("RE *",arr[3])
s077371239
Accepted
151
9,092
273
arr=[0]*4 for _ in range(int(input())): s=input() if s=='AC': arr[0]+=1 elif s=='WA': arr[1]+=1 elif s=='TLE': arr[2]+=1 else: arr[3]+=1 print("AC x",arr[0]) print("WA x",arr[1]) print("TLE x",arr[2]) print("RE x",arr[3])
s318047891
p02694
u332793228
2,000
1,048,576
Wrong Answer
25
9,096
66
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()) i=1 while X <= 100*(1.01**i): print(i) i+=1
s428864416
Accepted
25
9,168
139
import math x=int(input()) i=1 a=100 while i>0: a=math.floor(a*1.01) if a>=x: print(i) break else: i+=1
s950091038
p03555
u749491107
2,000
262,144
Wrong Answer
29
8,980
109
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
a = input() b = input() if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]: print("Yes") else: print("No")
s936389832
Accepted
31
9,044
109
a = input() b = input() if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]: print("YES") else: print("NO")
s345625650
p03485
u064563749
2,000
262,144
Wrong Answer
17
2,940
86
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()) x=(a+b)/2 if x%1==0: print(x) else: print(int(x))
s529750408
Accepted
17
2,940
54
a,b=map(int,input().split()) x=int((a+b+1)/2) print(x)
s769426131
p03251
u992910889
2,000
1,048,576
Wrong Answer
18
3,060
225
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())) for i in range(X+1,Y+1): if max(x)<i and min(y)<=i: print('No War') elif i==Y: print('War')
s623451698
Accepted
17
2,940
293
# coding: utf-8 # Your code here! N,M,X,Y=map(int,input().split()) x=list(map(int,input().split())) y=list(map(int,input().split())) for i in range(X+1,Y+1): if max(x)<i and min(y)>=i: print('No War') #print(i) break elif i==Y: print('War')
s334858660
p02243
u487861672
1,000
131,072
Wrong Answer
20
5,660
1,500
For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$.
from sys import maxsize from heapq import heappop, heappush class Node: WHITE = 0 GRAY = 1 BLACK = 2 def __init__(self): self.adjs = [] self.color = Node.WHITE self.dist = maxsize def __lt__(self, other): return self.dist < other.dist def __repr__(self): return "Node({},{},{})".format(self.adjs, self.color, self.dist) def read_adj(): n = int(input()) nodes = [Node() for _ in range(n)] for i in range(n): u, _, *rest = [int(x) for x in input().split()] for i in range(0, len(rest) - 1, 2): nodes[u].adjs.append((rest[i], rest[i+1])) return nodes def shortest_path(nodes): h = [] nodes[0].dist = 0 nodes[0].color = Node.GRAY heappush(h, (0, 0)) while len(h) > 0: min_node, min_dist = heappop(h) if nodes[min_node].dist < min_dist: continue nodes[min_node].color = Node.BLACK for adj, c in nodes[min_node].adjs: if nodes[min_node].color == Node.BLACK: continue if nodes[min_node].dist + c < nodes[adj].dist: nodes[adj].dist = nodes[min_node].dist + c nodes[adj].color = Node.GRAY heappush(h, (adj, nodes[adj].dist)) def print_dist(nodes): for u, n in enumerate(nodes): print(u, n.dist) def main(): nodes = read_adj() shortest_path(nodes) print_dist(nodes) if __name__ == '__main__': main()
s958503111
Accepted
580
68,620
1,495
from sys import maxsize from heapq import heappop, heappush class Node: WHITE = 0 GRAY = 1 BLACK = 2 def __init__(self): self.adjs = [] self.color = Node.WHITE self.dist = maxsize def __lt__(self, other): return self.dist < other.dist def __repr__(self): return "Node({},{},{})".format(self.adjs, self.color, self.dist) def read_adj(): n = int(input()) nodes = [Node() for _ in range(n)] for i in range(n): u, _, *rest = [int(x) for x in input().split()] for i in range(0, len(rest) - 1, 2): nodes[u].adjs.append((rest[i], rest[i+1])) return nodes def shortest_path(nodes): h = [] nodes[0].dist = 0 nodes[0].color = Node.GRAY heappush(h, (0, 0)) while len(h) > 0: min_dist, min_node = heappop(h) nodes[min_node].color = Node.BLACK if nodes[min_node].dist < min_dist: continue for adj, c in nodes[min_node].adjs: if nodes[adj].color == Node.BLACK: continue if nodes[min_node].dist + c < nodes[adj].dist: nodes[adj].dist = nodes[min_node].dist + c nodes[adj].color = Node.GRAY heappush(h, (nodes[adj].dist, adj)) def print_dist(nodes): for u, n in enumerate(nodes): print(u, n.dist) def main(): nodes = read_adj() shortest_path(nodes) print_dist(nodes) if __name__ == '__main__': main()
s841355100
p03006
u334712262
2,000
1,048,576
Wrong Answer
1,837
14,716
1,802
There are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i). We will collect all of these balls, by choosing two integers p and q such that p \neq 0 or q \neq 0 and then repeating the following operation: * Choose a ball remaining in the plane and collect it. Let (a, b) be the coordinates of this ball. If we collected a ball at coordinates (a - p, b - q) in the previous operation, the cost of this operation is 0. Otherwise, including when this is the first time to do this operation, the cost of this operation is 1. Find the minimum total cost required to collect all the balls when we optimally choose p and q.
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permutations from operator import add, mul, sub sys.setrecursionlimit(100000) input = sys.stdin.readline def read_int(): return int(input()) def read_int_n(): return list(map(int, input().split())) def read_float(): return float(input()) def read_float_n(): return list(map(float, input().split())) def read_str(): return input().strip() def read_str_n(): return list(map(str, input().split())) def error_print(*args): print(*args, file=sys.stderr) def mt(f): import time def wrap(*args, **kwargs): s = time.time() ret = f(*args, **kwargs) e = time.time() error_print(e - s, 'sec') return ret return wrap @mt def slv(N, XY): XY = [tuple(v) for v in XY] XY.sort() @lru_cache(maxsize=None) def f(i, v, x, y): ans = 0 for j, u in enumerate(XY[i+1:]): if v[0] - u[0] == x and v[1] - u[1] == y: ans = max(ans, f(i+j+1, u, x, y) + 1) else: ans = max(ans, f(i+j+1, u, x, y)) return ans ans = 0 for i in range(N): print(i) for j in range(i+1, N): if XY[i][0]-XY[j][0] == 0 and XY[i][1]-XY[j][1] == 0: continue ans = max(ans, f(i, XY[i], XY[i][0]-XY[j][0], XY[i][1]-XY[j][1])) return N - ans def main(): N = read_int() XY = [read_int_n() for _ in range(N)] print(slv(N, XY)) if __name__ == '__main__': main()
s564732131
Accepted
53
6,468
1,442
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permutations from operator import add, mul, sub sys.setrecursionlimit(100000) input = sys.stdin.readline def read_int(): return int(input()) def read_int_n(): return tuple(map(int, input().split())) def read_float(): return float(input()) def read_float_n(): return list(map(float, input().split())) def read_str(): return input().strip() def read_str_n(): return list(map(str, input().split())) def error_print(*args): print(*args, file=sys.stderr) def mt(f): import time def wrap(*args, **kwargs): s = time.time() ret = f(*args, **kwargs) e = time.time() error_print(e - s, 'sec') return ret return wrap @mt def slv(N, XY): c = Counter() for i in range(N): x, y = XY[i] for j in range(N): if i == j: continue a, b = XY[j] c[(x-a, y-b)] += 1 if not c: return N return N - c.most_common(1)[0][1] def main(): N = read_int() XY = [read_int_n() for _ in range(N)] print(slv(N, XY)) if __name__ == '__main__': main()
s043000268
p02608
u325660636
2,000
1,048,576
Wrong Answer
2,208
66,612
250
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
import numpy as np N = int(input()) l = [] for x in range(1,101): for y in range(1,101): for z in range(1,101): fn = x**2 + y**2 + z**2 + x*y + y*z + z*x l.append(fn) for i in range(N+1): print(l.count(i))
s910971975
Accepted
885
9,516
380
import itertools N = int(input()) num = int(N**0.5)+1 ans = [0]*(N+1) # for x in range(1,num+1): # for y in range(1,num+1): for x,y,z in itertools.product(range(1, num+1), repeat=3): fn = x**2 + y**2 + z**2 + x*y + y*z + z*x if fn > N: continue else: ans[fn] += 1 for i in range(1,len(ans)): print(ans[i])
s948703292
p03193
u735211927
2,000
1,048,576
Wrong Answer
20
3,060
174
There are N rectangular plate materials made of special metal called AtCoder Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically and B_i horizontally). Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are exactly H \times W. He is trying to obtain such a plate by choosing one of the N materials and cutting it if necessary. When cutting a material, the cuts must be parallel to one of the sides of the material. Also, the materials have fixed directions and cannot be rotated. For example, a 5 \times 3 material cannot be used as a 3 \times 5 plate. Out of the N materials, how many can produce an H \times W plate if properly cut?
N, H, W = map(int, input().split()) A = [] B = [] counter = 0 for i in range(0,N): a,b = map(int, input().split()) if a>H and b>W: counter +=1 print(counter)
s655772634
Accepted
20
3,060
176
N, H, W = map(int, input().split()) A = [] B = [] counter = 0 for i in range(0,N): a,b = map(int, input().split()) if a>=H and b>=W: counter +=1 print(counter)
s524591688
p03712
u805011545
2,000
262,144
Wrong Answer
32
9,304
242
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
H, W = [int(x) for x in input().split()] pic = [list(input()) for _ in range(H)] ans = [['#' for i in range(W+2)] for j in range(H+2)] for i in range(W): for j in range(H): ans[j+1][i+1] = pic[j][i] for i in range(H+2): print(*ans[i])
s302083622
Accepted
31
9,104
302
H, W = [int(x) for x in input().split()] pic = [list(input()) for _ in range(H)] ans = [['#' for i in range(W+2)] for j in range(H+2)] for i in range(H): for j in range(W): ans[i+1][j+1] = pic[i][j] low = '' for i in range(H+2): for j in range(W+2): low += ans[i][j] print(low) low = ''
s404702706
p02669
u860002137
2,000
1,048,576
Wrong Answer
23
9,280
1,367
You start with the number 0 and you want to reach the number N. You can change the number, paying a certain amount of coins, with the following operations: * Multiply the number by 2, paying A coins. * Multiply the number by 3, paying B coins. * Multiply the number by 5, paying C coins. * Increase or decrease the number by 1, paying D coins. You can perform these operations in arbitrary order and an arbitrary number of times. What is the minimum number of coins you need to reach N? **You have to solve T testcases.**
def solve(n, a, b, c, d, bi=1): curr = n coin = d while curr != 1: ca = curr / 2 / a cb = curr * 2 / 3 / b cc = curr * 4 / 5 / c cd = 1 / d cs = [(ca, 2, a), (cb, 3, b), (cc, 5, c), (cd, 1, d)] cs.sort(reverse=True) if cs[0][1] == 1: curr = 1 coin += (curr - 1) * d break if curr % 2 != 0 and curr % 3 != 0 and curr % 5 != 0: curr += bi coin += d continue if curr % cs[0][1] == 0 and cs[0][1] != 1 and curr >= cs[0][1]: curr //= cs[0][1] coin += cs[0][2] continue if curr % cs[1][1] == 0 and cs[1][1] != 1 and curr >= cs[1][1]: curr //= cs[1][1] coin += cs[1][2] continue if curr % cs[2][1] == 0 and cs[2][1] != 1 and curr >= cs[2][1]: curr //= cs[2][1] coin += cs[2][2] continue if curr % cs[3][1] == 0 and cs[3][1] != 1 and curr >= cs[3][1]: curr //= cs[3][1] coin += cs[3][2] continue coin = float("inf") break return coin t = int(input()) ans = [] for i in range(t): n, a, b, c, d = map(int, input().split()) ans.append(min(solve(n, a, b, c, d, -1), solve(n, a, b, c, d, 1))) print(*ans, sep="\n")
s706737137
Accepted
218
20,764
1,663
from functools import lru_cache def solve(n, a, b, c, d): @lru_cache(maxsize=None) def func(n): if n == 0: return 0 if n == 1: return d else: coin = d * n div, mod = divmod(n, 2) if mod == 0: coin = min(coin, func(div) + a) else: coin = min(coin, func(div) + a + d, func(div + 1) + a + d) div, mod = divmod(n, 3) if mod == 0: coin = min(coin, func(div) + b) elif mod == 1: coin = min(coin, func(div) + b + d, func(div + 1) + b + 2 * d) else: coin = min(coin, func(div) + b + 2 * d, func(div + 1) + b + d) div, mod = divmod(n, 5) if mod == 0: coin = min(coin, func(div) + c) elif mod == 1: coin = min(coin, func(div) + c + d, func(div + 1) + c + 4 * d) elif mod == 2: coin = min(coin, func(div) + c + 2 * d, func(div + 1) + c + 3 * d) elif mod == 3: coin = min(coin, func(div) + c + 3 * d, func(div + 1) + c + 2 * d) else: coin = min(coin, func(div) + c + 4 * d, func(div + 1) + c + d) return coin return func(n) t = int(input()) ans = [] for i in range(t): n, a, b, c, d = map(int, input().split()) ans.append(solve(n, a, b, c, d)) print(*ans, sep="\n")
s395987195
p02275
u599130514
1,000
131,072
Wrong Answer
20
5,604
439
Counting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail: Counting-Sort(A, B, k) 1 for i = 0 to k 2 do C[i] = 0 3 for j = 1 to length[A] 4 do C[A[j]] = C[A[j]]+1 5 /* C[i] now contains the number of elements equal to i */ 6 for i = 1 to k 7 do C[i] = C[i] + C[i-1] 8 /* C[i] now contains the number of elements less than or equal to i */ 9 for j = length[A] downto 1 10 do B[C[A[j]]] = A[j] 11 C[A[j]] = C[A[j]]-1 Write a program which sorts elements of given array ascending order based on the counting sort.
def counting_sort(A, B, k): len_A = len(A) C = [0 for _ in range(k + 1)] for j in range(len_A): C[A[j]] += 1 for i in range(1, k + 1): C[i] = C[i] + C[i - 1] for j in range(len_A - 1, -1, -1): B[C[A[j]] - 1] = A[j] C[A[j]] -= 1 n = int(input()) input_list = list(map(int, input().split(' '))) B = [0 for _ in range(n)] counting_sort(input_list, B, max(input_list) + 1) print(B)
s080222712
Accepted
2,530
224,388
440
def counting_sort(A, B, k): len_A = len(A) C = [0 for _ in range(k + 1)] for j in range(len_A): C[A[j]] += 1 for i in range(1, k + 1): C[i] = C[i] + C[i - 1] for j in range(len_A - 1, -1, -1): B[C[A[j]] - 1] = A[j] C[A[j]] -= 1 n = int(input()) input_list = list(map(int, input().split(' '))) B = [0 for _ in range(n)] counting_sort(input_list, B, max(input_list) + 1) print(*B)
s483760158
p02390
u535719732
1,000
131,072
Wrong Answer
20
5,588
97
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.
s = int(input()) h = s / 3600 s = s % 3600 m = s / 360 s = s % 360 print("%d:%d:%d" % (h,m,s))
s489115005
Accepted
20
5,588
97
s = int(input()) h = s // 3600 s = s % 3600 m = s // 60 s = s % 60 print("%d:%d:%d" % (h,m,s))
s042814161
p03377
u532502139
2,000
262,144
Wrong Answer
17
2,940
131
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
def catOrDog(A, B, X): if X < A: print('NO') elif A + B > X + 1: print('YES') else: print('NO')
s814788478
Accepted
17
2,940
124
a,b,x=[int(x) for x in input().split()] if x < a: print('NO') elif a + b > x + 1: print('YES') else: print('NO')
s707313277
p03168
u501842214
2,000
1,048,576
Wrong Answer
2,119
179,956
750
Let N be a positive odd number. There are N coins, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), when Coin i is tossed, it comes up heads with probability p_i and tails with probability 1 - p_i. Taro has tossed all the N coins. Find the probability of having more heads than tails.
def solve(N, probs): # dp[i][j]: probability of having j heads in i coin tosses dp = [[0 for _ in range(N + 1)] for _ in range(N + 1)] dp[0][0] = 1 for toss_id in range(1, N + 1): head_prob = probs[toss_id - 1] tail_prob = 1 - probs[toss_id - 1] # only until i needed for j in range(toss_id + 1): if j == 0: dp[toss_id][j] += dp[toss_id - 1][j] * tail_prob else: dp[toss_id][j] += (dp[toss_id - 1][j] * tail_prob) + \ (dp[toss_id - 1][j - 1] * head_prob) ans = 0 for j in range(1, N + 1): if j >= (N + 1) // 2: ans += dp[N][j] def iin(): return int(input()) def fln(): return list(map(float, input().split())) N = iin() probs = fln() solve(N, probs)
s184689212
Accepted
952
3,316
710
def solve(N, probs): # dp[i][j]: probability of having j heads in i coin tosses # shorter version: dp[j]: probability of j heads dp = [0 for _ in range(N + 1)] dp[0] = 1 for toss_id in range(1, N + 1): head_prob = probs[toss_id - 1] tail_prob = 1.0 - probs[toss_id - 1] # only until i needed for j in range(toss_id, -1, -1): if j == 0: dp[j] = dp[j] * tail_prob else: dp[j] = (dp[j] * tail_prob) + (dp[j - 1] * head_prob) # sum all probabilies where heads > tails ans = sum(dp[N // 2 + 1:]) print(ans) def iin(): return int(input()) def fln(): return list(map(float, input().split())) N = iin() probs = fln() solve(N, probs)
s540484025
p03155
u428132025
2,000
1,048,576
Wrong Answer
17
2,940
73
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board. The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns. How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?
n = int(input()) h = int(input()) w = int(input()) print((n-h+1)*(h-w+1))
s607968652
Accepted
17
2,940
73
n = int(input()) h = int(input()) w = int(input()) print((n-h+1)*(n-w+1))
s778682704
p03556
u037221289
2,000
262,144
Wrong Answer
17
2,940
92
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
N = int(input()) for i in range(N,1,-1): if (i*0.5).is_integer(): print(i) exit()
s043319713
Accepted
37
3,060
99
N = int(input()) for i in range(N,0,-1): if (i**0.5).is_integer(): print(int(i)) exit()
s983649918
p03090
u913965975
2,000
1,048,576
Wrong Answer
27
3,828
341
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved that at least one such graph exists under the constraints of this problem.
N = int(input()) matrix = [[1 for i in range(N)] for i in range(N)] for i in range(N): matrix[i][i] = 0 if N%2==0: for i in range(N): matrix[i][N-i-1] = 0 else: for i in range(N-1): matrix[i][N-i-2] = 0 for i in range(N): for j in range(i+1,N): if matrix[i][j] == 1: print(i+1,"",j+1)
s842528151
Accepted
24
3,700
371
N = int(input()) matrix = [[1 for i in range(N)] for i in range(N)] for i in range(N): matrix[i][i] = 0 if N%2==0: for i in range(N): matrix[i][N-i-1] = 0 else: for i in range(N-1): matrix[i][N-i-2] = 0 print(int((N*(N-1)/2)-int(N/2))) for i in range(N): for j in range(i+1,N): if matrix[i][j] == 1: print(i+1,j+1)
s485675936
p03712
u589087860
2,000
262,144
Wrong Answer
18
3,060
351
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
h, w = map(int, input().split()) a = [] for i in range(h): a.append(input()) print(a) ans = [] for i in range(h + 2): if i == 0 or i == h + 1: s = "" for j in range(w + 2): s = s + "#" ans.append(s) else: s = "#" + a[i - 1] + "#" ans.append(s) #print(ans) print('\n'.join(ans))
s207879914
Accepted
18
3,060
352
h, w = map(int, input().split()) a = [] for i in range(h): a.append(input()) #print(a) ans = [] for i in range(h + 2): if i == 0 or i == h + 1: s = "" for j in range(w + 2): s = s + "#" ans.append(s) else: s = "#" + a[i - 1] + "#" ans.append(s) #print(ans) print('\n'.join(ans))
s205751402
p04012
u094191970
2,000
262,144
Wrong Answer
21
3,316
245
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
W = input() import collections switch = 0 W_list = list(W) W_dic = collections.Counter(W_list) for num in W_dic.values(): if num%2 != 0: switch = 1 break print(switch) if switch == 0: print('Yes') else: print('No')
s399636107
Accepted
21
3,316
231
W = input() import collections switch = 0 W_list = list(W) W_dic = collections.Counter(W_list) for num in W_dic.values(): if num%2 != 0: switch = 1 break if switch == 0: print('Yes') else: print('No')
s664474787
p03623
u813450984
2,000
262,144
Wrong Answer
21
2,940
168
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
S = input() alphabet = "abcdefghijklmnopqrstuvwxyz" found = [i for i in alphabet if i not in S] found.sort() if len(found) == 0: print('None') else: print(found[0])
s653825323
Accepted
19
2,940
146
place = map(int, input().split()) X, A, B = [i for i in place] X_A = abs(X - A) X_B = abs(X - B) if X_A <= X_B: print('A') else: print('B')
s265284893
p03623
u003501233
2,000
262,144
Wrong Answer
18
2,940
70
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
x,a,b = map(int,input().split()) A = x - a B = x - b print(min(A,B))
s880143392
Accepted
17
2,940
88
x,a,b = map(int,input().split()) if abs(x-a) < abs(x-b): print("A") else: print("B")
s699353885
p03494
u404561212
2,000
262,144
Wrong Answer
18
3,316
304
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
def devide_counter(num): devide_count = 0 while num%2==0: num /= 2 devide_count += 1 return devide_count #N = int(input()) A = list(map(int, input().split())) devide_count_list=[] for a in A: devide_count_list.append(devide_counter(a)) print(min(devide_count_list))
s628435539
Accepted
19
3,316
303
def devide_counter(num): devide_count = 0 while num%2==0: num /= 2 devide_count += 1 return devide_count N = int(input()) A = list(map(int, input().split())) devide_count_list=[] for a in A: devide_count_list.append(devide_counter(a)) print(min(devide_count_list))
s878974975
p03713
u663101675
2,000
262,144
Wrong Answer
17
3,064
752
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 = list(map(int, input().split())) def Diff(H, W): H_min = int(H / 3) H_max = int(H / 3) + 1 W_short = int(W / 2) W_long = W - W_short S_1_1 = [H_min * W, (H - H_min) * W_short, (H - H_min) * W_long] S_1_2 = [H_max * W, (H - H_max) * W_short, (H - H_max) * W_long] D_1_1 = max(S_1_1) - min(S_1_1) D_1_2 = max(S_1_2) - min(S_1_2) return min(D_1_1, D_1_2) R = [] R.append(H) R.append(W) R.append(Diff(H, W)) R.append(Diff(W, H)) print(min(R))
s146185463
Accepted
17
3,064
805
H, W = list(map(int, input().split())) def Diff(H, W): H_min = int(H / 3) H_max = int(H / 3) + 1 W_short = int(W / 2) W_long = W - W_short S_1_1 = [H_min * W, (H - H_min) * W_short, (H - H_min) * W_long] S_1_2 = [H_max * W, (H - H_max) * W_short, (H - H_max) * W_long] D_1_1 = max(S_1_1) - min(S_1_1) D_1_2 = max(S_1_2) - min(S_1_2) return min(D_1_1, D_1_2) R = [] R.append(H) R.append(W) R.append(Diff(H, W)) R.append(Diff(W, H)) if H % 3 == 0 or W % 3 == 0: print(0) else: print(min(R))
s950530329
p03556
u018679195
2,000
262,144
Wrong Answer
17
2,940
67
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
if __name__=="main": i=int(input()) print((int(i**0.5))**2)
s172346272
Accepted
21
3,316
566
import sys def fastio(): from io import StringIO from atexit import register global input sys.stdin = StringIO(sys.stdin.read()) input = lambda : sys.stdin.readline().rstrip('\r\n') sys.stdout = StringIO() register(lambda : sys.__stdout__.write(sys.stdout.getvalue())) fastio() INF = 10**20 MOD = 10**9 + 7 I = lambda:list(map(int,input().split())) # from math import gcd from math import ceil from collections import defaultdict as dd, Counter from bisect import bisect_left as bl, bisect_right as br n, = I() print(int(n ** 0.5) ** 2)
s969454646
p02601
u342801789
2,000
1,048,576
Wrong Answer
36
9,212
437
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
numbers = [int(s) for s in input().split()] K = int(input()) for i in range(K): if(numbers[2] < numbers[0]): numbers[2] *= 2 elif(numbers[1] < numbers[0]): numbers[1] *= 2 elif(numbers[2] < numbers[1]): numbers[2] *= 2 else: break print(numbers) if(numbers[1] > numbers[0] and numbers[2] > numbers[1]): print("Yes") else: print("No")
s659435844
Accepted
31
9,204
398
numbers = [int(s) for s in input().split()] K = int(input()) for i in range(K): if(numbers[2] <= numbers[0]): numbers[2] *= 2 elif(numbers[1] <= numbers[0]): numbers[1] *= 2 elif(numbers[2] <= numbers[1]): numbers[2] *= 2 else: break if(numbers[1] > numbers[0] and numbers[2] > numbers[1]): print("Yes") else: print("No")
s326606951
p04012
u218838821
2,000
262,144
Wrong Answer
17
3,064
358
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
w = list(map(str,input())) w_ord = [] for i in range(len(w)): w_ord.append(ord(w[i])) w_ord.sort() j = 1 if len(w) % 2 == 1: print("NO") else: for i in range((len(w)+1)//2): if not w_ord[2*i] == w_ord[2*i + 1]: print("NO") break else: if i == (len(w)+1)//2 -1: print("YES")
s621887563
Accepted
27
9,040
226
w = input() W = [] for i in range(len(w)): W.append(w[i]) W.sort() if len(w) % 2 == 1: print("No") exit() for i in range(len(w)//2): if not W[2*i] == W[2*i+1]: print("No") exit() print("Yes")
s125277438
p02260
u362520072
1,000
131,072
Wrong Answer
20
5,592
325
Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 if A[j] < A[mini] 5 mini = j 6 swap A[i] and A[mini] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i ≠ mini.
def selectionSort(a, n): count = 0 for i in range(0, n): minj = i for j in range(i, n): if a[j] < a[minj]: minj = j w = a[i] a[i] = a[minj] a[minj] = w count += 1 print(' '.join(map(str, a))) print(count) n = int(input()) a = list(map(int, input().split())) selectionSort(a, n)
s756476032
Accepted
20
5,600
351
def selectionSort(a, n): count = 0 for i in range(0, n): minj = i for j in range(i, n): if a[j] < a[minj]: minj = j if i != minj: w = a[i] a[i] = a[minj] a[minj] = w count += 1 print(' '.join(map(str, a))) print(count) n = int(input()) a = list(map(int, input().split())) selectionSort(a, n)
s209890526
p03543
u268516119
2,000
262,144
Wrong Answer
17
2,940
75
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
A=input() print('NYOE S'[(A[1]==A[2]) and (A[0]==A[1] or A[1]==A[3]) ::2])
s394734070
Accepted
17
2,940
75
A=input() print('NYoe s'[(A[1]==A[2]) and (A[0]==A[1] or A[1]==A[3]) ::2])
s986004725
p03377
u642823003
2,000
262,144
Wrong Answer
20
2,940
144
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
a, b, x = map(int, input().split()) if x - a < 0: print("No") else: if b < x - a: print("No") else: print("Yes")
s204004828
Accepted
17
2,940
144
a, b, x = map(int, input().split()) if x - a < 0: print("NO") else: if b < x - a: print("NO") else: print("YES")
s722506308
p03110
u832871520
2,000
1,048,576
Wrong Answer
39
5,296
1,183
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?
import sys import math from collections import Counter import itertools import fractions import datetime from decimal import Decimal #from functools import reduce def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def SR(): return sys.stdin.readline().rstrip() ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz' ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ' p2D = lambda x: print(*x, sep="\n") p2E = lambda x: print(''.join(x)) p2S = lambda x: print(*x, sep=" ") # ########################################### N=II() XU=[list(SR().split()) for _ in range(N)] print(XU) ans = 0 for xu in XU: if xu[1] == 'JPY': ans += int(xu[0]) else: ans += float(xu[0])*380000 print(ans)
s113242577
Accepted
37
5,296
1,173
import sys import math from collections import Counter import itertools import fractions import datetime from decimal import Decimal #from functools import reduce def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def SR(): return sys.stdin.readline().rstrip() ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz' ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ' p2D = lambda x: print(*x, sep="\n") p2E = lambda x: print(''.join(x)) p2S = lambda x: print(*x, sep=" ") # ########################################### N=II() XU=[list(SR().split()) for _ in range(N)] ans = 0 for xu in XU: if xu[1] == 'JPY': ans += int(xu[0]) else: ans += float(xu[0])*380000 print(ans)
s507183757
p03302
u340947941
2,000
1,048,576
Wrong Answer
17
2,940
10
You are given two integers a and b. Determine if a+b=15 or a\times b=15 or neither holds. Note that a+b=15 and a\times b=15 do not hold at the same time.
print("a")
s223284992
Accepted
18
2,940
119
a,b = list(map(int, input().split())) if a+b == 15: print("+") elif a*b == 15: print("*") else: print("x")
s370523653
p03854
u120810144
2,000
262,144
Wrong Answer
210
14,800
541
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
import sys import math import numpy as np import copy def main(): s = input() a, b, c, d = "dream", "dreamer", "erase", "eraser" ra, rb, rc, rd = a[::-1], b[::-1], c[::-1], d[::-1] rs = s[::-1] while rs: flag = False for ele in [ra, rb, rc, rd]: if rs.startswith(ele): rs = rs.replace(ele, "", 1) flag = True if not flag: print("No") return 0 print("Yes") return 0 if __name__ == '__main__': sys.exit(main())
s858868761
Accepted
208
13,216
541
import sys import math import numpy as np import copy def main(): s = input() a, b, c, d = "dream", "dreamer", "erase", "eraser" ra, rb, rc, rd = a[::-1], b[::-1], c[::-1], d[::-1] rs = s[::-1] while rs: flag = False for ele in [ra, rb, rc, rd]: if rs.startswith(ele): rs = rs.replace(ele, "", 1) flag = True if not flag: print("NO") return 0 print("YES") return 0 if __name__ == '__main__': sys.exit(main())
s141190747
p03657
u797674884
2,000
262,144
Wrong Answer
17
2,940
196
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
l = list(map(int, input().split())) if l[0] % 3 == 0: print("Possible") elif l[1] % 3 == 0: print("Possible") elif l[0]+l[1] % 3 == 0: print("Possible") else: print("Impossible")
s056732088
Accepted
17
2,940
202
l = list(map(int, input().split())) a = l[0]+l[1] if l[0] % 3 == 0: print("Possible") elif l[1] % 3 == 0: print("Possible") elif a % 3 == 0: print("Possible") else: print("Impossible")
s897646900
p02408
u811841526
1,000
131,072
Wrong Answer
30
7,896
366
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.
from collections import OrderedDict cards = OrderedDict() cards['S'] = set() cards['H'] = set() cards['D'] = set() cards['C'] = set() n = int(input()) for _ in range(n): suit, num = input().split() num = int(num) cards[suit].add(num) for suit, nums in cards.items(): for num in range(1,14): if num not in nums: print(suit, num)
s203379100
Accepted
20
5,604
202
n = int(input()) deck = [] for i in range(n): deck.append(input()) for suit in 'SHCD': for i in range(1, 14): card = f'{suit} {i}' if card not in deck: print(card)
s711109460
p02600
u514229192
2,000
1,048,576
Wrong Answer
23
9,088
87
M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a _kyu_ (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have?
x=float(input("m?")) for i in range(8): if 400+200*i<=x<400+200*(i+1): print(8-i)
s276963014
Accepted
32
9,056
83
x=float(input()) for i in range(8): if 400+200*i<=x<400+200*(i+1): print(8-i)
s083594437
p02409
u286589639
1,000
131,072
Wrong Answer
20
7,620
375
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
n =int(input()) S = [[[0 for i in range(10)] for j in range(3)] for k in range(4)] for i in range(n): b, f, r, v = map(int, input().split()) S[b-1][f-1][r-1] += v for i in range(4): for j in range(3): for k in range(10): print(" " + str(S[i][j][k]), end = "") print("") if i == 4: break print("####################")
s294442556
Accepted
20
7,756
375
n =int(input()) S = [[[0 for i in range(10)] for j in range(3)] for k in range(4)] for i in range(n): b, f, r, v = map(int, input().split()) S[b-1][f-1][r-1] += v for i in range(4): for j in range(3): for k in range(10): print(" " + str(S[i][j][k]), end = "") print("") if i == 3: break print("####################")
s903630385
p02612
u726823037
2,000
1,048,576
Wrong Answer
28
9,160
204
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.
import sys def Ii():return int(sys.stdin.readline()) def Mi():return map(int,sys.stdin.buffer.readline().split()) def Li():return list(map(int,sys.stdin.buffer.readline().split())) n = Ii() print(n%1000)
s774715013
Accepted
26
9,180
244
import sys def Ii():return int(sys.stdin.readline()) def Mi():return map(int,sys.stdin.buffer.readline().split()) def Li():return list(map(int,sys.stdin.buffer.readline().split())) n = Ii() if n%1000 == 0: print(0) else: print(1000-n%1000)
s903704301
p02612
u486536494
2,000
1,048,576
Wrong Answer
36
10,020
110
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.
import datetime import string import re import math N = int(input()) while N > 1000: N -= 1000 print(N)
s578999802
Accepted
38
10,020
117
import datetime import string import re import math N = int(input()) while N > 1000: N -= 1000 print(1000 - N)
s086879457
p03448
u735468069
2,000
262,144
Wrong Answer
43
3,316
452
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
from collections import defaultdict, Counter from heapq import heapify, heappop, heappush from sys import stdin def main(): A = int(input()) B = int(input()) C = int(input()) x = int(input()) ans = 0 for a in range(1, A+1): for b in range(1, B+1): for c in range(1, C+1): if 500*a+50*b+10*c == x: ans += 1 print(ans) input = lambda: stdin.readline().rstrip() main()
s075035520
Accepted
47
3,444
453
from collections import defaultdict, Counter from heapq import heapify, heappop, heappush from sys import stdin def main(): A = int(input()) B = int(input()) C = int(input()) x = int(input()) ans = 0 for a in range(0, A+1): for b in range(0, B+1): for c in range(0, C+1): if 500*a+100*b+50*c == x: ans += 1 print(ans) input = lambda: stdin.readline().rstrip() main()
s338608236
p02613
u730807152
2,000
1,048,576
Wrong Answer
148
9,204
365
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
n=int(input()) countAC=0 countWA=0 countTLE=0 countRE=0 for i in range(n): s=input() if s=="AC": countAC += 1 elif s=="WA": countWA += 1 elif s=="TLE": countTLE += 1 else: countRE += 1 print("AC × " + str(countAC)) print("WA × " + str(countWA)) print("TLE × " + str(countTLE)) print("RE × " + str(countRE))
s795808474
Accepted
141
9,200
361
n=int(input()) countAC=0 countWA=0 countTLE=0 countRE=0 for i in range(n): s=input() if s=="AC": countAC += 1 elif s=="WA": countWA += 1 elif s=="TLE": countTLE += 1 else: countRE += 1 print("AC x " + str(countAC)) print("WA x " + str(countWA)) print("TLE x " + str(countTLE)) print("RE x " + str(countRE))
s229960700
p03730
u629540524
2,000
262,144
Wrong Answer
17
2,940
101
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`.
a, b, c = map(int, input().split()) print('No' if all((a*i)%b != c for i in range(1,b+1)) else 'Yes')
s066060342
Accepted
17
2,940
101
a, b, c = map(int, input().split()) print('NO' if all((a*i)%b != c for i in range(1,b+1)) else 'YES')
s438003536
p02613
u193927973
2,000
1,048,576
Wrong Answer
148
9,192
150
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
N=int(input()) a=[] d=dict(AC=0, WA=0, TLE=0, RE=0) for _ in range(N): a=input() d[a]+=1 for k, v in d.items(): ans=k+" × "+str(v) print(ans)
s217620629
Accepted
148
9,192
149
N=int(input()) a=[] d=dict(AC=0, WA=0, TLE=0, RE=0) for _ in range(N): a=input() d[a]+=1 for k, v in d.items(): ans=k+" x "+str(v) print(ans)
s973555942
p02833
u518042385
2,000
1,048,576
Wrong Answer
2,104
3,060
163
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
n=int(input()) if n%2==1: print(0) else: now=1 ans=0 while 1: if n%(10**now)!=0: break else: ans+=n%(10**now) now+=1 print(ans)
s998192716
Accepted
17
2,940
176
n=int(input()) if n%2==1: print(0) else: now=1 ans=0 while 1: if (n//(5**now))//2==0: break else: ans+=(n//(5**now))//2 now+=1 print(ans)
s917275184
p03564
u453642820
2,000
262,144
Wrong Answer
17
2,940
103
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.
N=int(input()) K=int(input()) ans=[] for i in range(N): ans.append((i+1)*2+(N-i-1)) print(min(ans))
s284964147
Accepted
17
2,940
90
N=int(input()) K=int(input()) ans=1 for i in range(N): ans=min(ans*2,ans+K) print(ans)
s504757039
p02396
u042882066
1,000
131,072
Wrong Answer
20
7,524
48
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.
x=int(input()) if x != 0 : print("Case i: ", x)
s990639317
Accepted
140
7,492
99
i = 0 while True: n = int(input()) i += 1 if n == 0: break print("Case {}: {}".format(i, n))
s986607129
p02833
u821432765
2,000
1,048,576
Wrong Answer
17
3,060
209
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
N = int(input()) if N%2==1: print(0) quit() x = N fives = 0 i = 0 while x: if i % 2 == 1: i +=1 continue i += 1 x //= 5 fives += x print(x, fives) print(fives)
s756331232
Accepted
17
2,940
150
N = int(input()) if N%2==1: print(0) quit() x = N fives = 0 while x: x //= 5 fives += (x//2) # print(x, fives) print(fives)
s128081691
p03338
u331036636
2,000
1,048,576
Wrong Answer
17
2,940
4
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.
s195572359
Accepted
19
3,064
256
n = int(input()) s = input() c = 0 list_s = [sorted(list(set(s[:i]))) for i in range(1,n)] list_l = [sorted(list(set(s[i:]))) for i in range(1,n)] print(max([sum([1 if list_s[j][i] in list_l[j] else 0 for i in range(len(list_s[j]))]) for j in range(n-1)]))
s369167552
p03778
u079022116
2,000
262,144
Wrong Answer
17
2,940
121
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
w,a,b=map(int,input().split()) if min(a,b) + w >= max(a,b): print(0) else: ans = max(a,b) - min(a,b) + w print(ans)
s600363905
Accepted
17
2,940
122
w,a,b=map(int,input().split()) if min(a,b) + w >= max(a,b): print(0) else: ans = max(a,b) - min(a,b) - w print(ans)
s419704104
p03543
u414558682
2,000
262,144
Wrong Answer
17
3,060
148
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
N = input() print(N) if N[0] == N[1] and N[1] == N[2]: print('Yes') elif N[1] == N[2] and N[2] == N[3]: print('Yes') else: print('No')
s832628882
Accepted
17
3,060
185
# coding: utf-8 # Your code here! N = input() # print(N) if N[0] == N[1] and N[1] == N[2]: print('Yes') elif N[1] == N[2] and N[2] == N[3]: print('Yes') else: print('No')
s410309666
p03523
u409306788
2,000
262,144
Wrong Answer
17
3,064
331
You are given a string S. Takahashi can insert the character `A` at any position in this string any number of times. Can he change S into `AKIHABARA`?
import sys input = sys.stdin.readline # A - AKIBA substring = ['', 'KIH', 'B', 'R'] akihabara = [] for i in range(16): b = format(i, 'b') bin_str = b.zfill(4) s = '' for j in range(4): s += substring[j] if bin_str[j] == '1': s += 'A' akihabara.append(s) if input() in akihabara: print('YES') else: print('NO')
s925474528
Accepted
17
3,060
292
# A - AKIBA substring = ['', 'KIH', 'B', 'R'] akihabara = [] for i in range(16): b = format(i, 'b') bin_str = b.zfill(4) s = '' for j in range(4): s += substring[j] if bin_str[j] == '1': s += 'A' akihabara.append(s) if input() in akihabara: print('YES') else: print('NO')
s759581607
p03228
u734876600
2,000
1,048,576
Wrong Answer
18
2,940
247
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person. Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.
a,b,k = map(int,input().split()) for i in range(k): if i % 2 == 1: if a % 2 == 1: a = (a - 1) // 2 b += a else: if b % 2 == 1: b = (b - 1) // 2 a += b print(a,b)
s793866193
Accepted
18
3,060
260
a,b,k = map(int,input().split()) for i in range(k): if i % 2 == 0: if a % 2 == 1: a -= 1 a = a // 2 b += a else: if b % 2 == 1: b = b - 1 b = b // 2 a += b print(a,b)
s351477532
p03962
u439392790
2,000
262,144
Wrong Answer
18
2,940
102
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.
a,b,c=map(int, input().split()) if(a+b==c)or(b+c==a)or(a+c==b): print("Yes") else: print("No")
s808649794
Accepted
18
2,940
142
a,b,c=map(int,input().split()) if a==b==c: print(1) elif a==b or a==c or b==c: print(2) elif a!=b and a!=c and b!=c: print(3)
s290679320
p03457
u325282913
2,000
262,144
Wrong Answer
326
3,060
234
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.
# 10 import sys N = int(input()) for _ in range(N): t, x, y = map(int, input().split()) if ((x + y) % 2) != (t % 2): print('NO') sys.exit() if t < x + y: print('NO') sys.exit() print('YES')
s194620522
Accepted
323
3,060
234
# 10 import sys N = int(input()) for _ in range(N): t, x, y = map(int, input().split()) if ((x + y) % 2) != (t % 2): print('No') sys.exit() if t < x + y: print('No') sys.exit() print('Yes')
s240870998
p02255
u646461156
1,000
131,072
Wrong Answer
20
5,592
151
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.
n=int(input()) a=list(map(int,input().split())) for i in range(1,n): j=i-1 while j>=0 and a[j]>a[i]: a[j+1]=a[j] j-=1 a[j+1]=a[i] print(*a)
s757557347
Accepted
20
5,980
151
n=int(input()) a=list(map(int,input().split())) 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(*a)
s109055771
p02613
u110311725
2,000
1,048,576
Wrong Answer
170
16,188
323
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
n = int(input()) s = [] c1 = 0 c2 = 0 c3 = 0 c4 = 0 for i in range(n): s.append(input()) if s[i] == 'AC': c1 += 1 elif s[i] == 'WA': c2 += 1 elif s[i] == 'TLE': c3 += 1 elif s[i] == 'RE': c4 += 1 print('AC ×',c1) print('WA ×',c2) print('TLE ×',c3) print('RE ×',c4)
s117522950
Accepted
162
16,332
319
n = int(input()) s = [] c1 = 0 c2 = 0 c3 = 0 c4 = 0 for i in range(n): s.append(input()) if s[i] == 'AC': c1 += 1 elif s[i] == 'WA': c2 += 1 elif s[i] == 'TLE': c3 += 1 elif s[i] == 'RE': c4 += 1 print('AC x',c1) print('WA x',c2) print('TLE x',c3) print('RE x',c4)
s324084946
p03556
u460245024
2,000
262,144
Wrong Answer
18
2,940
36
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
N = int(input()) print(int(N**0.5))
s942553225
Accepted
17
2,940
39
N = int(input()) print(int(N**0.5)**2)
s266593745
p03494
u256833330
2,000
262,144
Wrong Answer
19
3,060
209
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
n=int(input()) l=list(map(int,input().split())) c=0 while True: for i in range(n): if l[i]%2 !=0: print(c) exit(0) else: l[i] = l[i]//2 c+=1
s581515549
Accepted
19
2,940
201
n=int(input()) l=list(map(int,input().split())) c=0 while True: for i in range(n): if l[i]%2 !=0: print(c) exit(0) else: l[i] = l[i]//2 c+=1
s404169096
p03433
u894348341
2,000
262,144
Wrong Answer
18
2,940
93
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
N = int(input()) A = int(input()) if (N - A) // 500 == 0: print('Yes') else: print('No')
s469675863
Accepted
18
2,940
85
n = int(input()) a = int(input()) n%=500 if n<=a: print('Yes') else: print('No')
s813263493
p02407
u350064373
1,000
131,072
Wrong Answer
20
7,456
146
Write a program which reads a sequence and prints it in the reverse order.
input() list1 = list(map(int, input().split())) list1.sort() result="" for i in range(0,len(list1)): result += str(list1[i])+" " print(result)
s632336955
Accepted
20
5,560
38
input() print(*input().split()[::-1])
s249923495
p03380
u504562455
2,000
262,144
Wrong Answer
82
14,056
220
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
import bisect n = int(input()) a = [int(i) for i in input().split()] a.sort() ai = a[-1] idx = bisect.bisect_left(a, ai//2) if abs(ai//2-a[idx]) >= abs(ai//2-a[idx-1]): print(ai, a[idx-1]) else: print(ai, a[idx])
s940745510
Accepted
82
14,052
369
import bisect n = int(input()) a = [int(i) for i in input().split()] a.sort() ai = a[-1] idx = bisect.bisect_left(a, ai//2) if abs(ai//2-a[idx]) == abs(ai//2-a[idx-1]): if ai % 2 == 0 or idx == len(a)-1: print(ai, a[idx-1]) else: print(ai, a[idx]) elif abs(ai//2-a[idx]) > abs(ai//2-a[idx-1]): print(ai, a[idx-1]) else: print(ai, a[idx])
s277747236
p04043
u396495667
2,000
262,144
Wrong Answer
17
2,940
70
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.
a,b,c = map(int, input().split()) print('Yes' if a+b+c ==17 else 'No')
s357706912
Accepted
18
3,060
98
a = [int(_) for _ in input().split()] a.sort() print('YES' if a[0]==a[1]==5 and a[2]==7 else 'NO')
s368067579
p03386
u773981351
2,000
262,144
Wrong Answer
17
3,060
145
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()) for i in range(a, min(a + k, b + 1)): print(i) for j in range(max(i + 1, b - k + 1), b + 1): print(i)
s437353328
Accepted
17
3,060
145
a, b, k = map(int, input().split()) for i in range(a, min(a + k, b + 1)): print(i) for j in range(max(i + 1, b - k + 1), b + 1): print(j)
s816242126
p03606
u969848070
2,000
262,144
Wrong Answer
20
2,940
101
Joisino is working as a receptionist at a theater. The theater has 100000 seats, numbered from 1 to 100000. According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive). How many people are sitting at the theater now?
n = int(input()) x = 0 for i in range(n): a, b = map(int, input().split()) x += a - b +1 print(x)
s448178868
Accepted
20
2,940
99
n = int(input()) x = 0 for i in range(n): a, b = map(int, input().split()) x += b-a +1 print(x)