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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s689595127 | p03048 | u631019293 | 2,000 | 1,048,576 | Wrong Answer | 2,104 | 11,600 | 337 | Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this? | r,g,b,n=list(map(int,input().split()))
i,j,k=0,0,0
R,G,B=0,0,0
c=0
while R<n:
R=r*i
print(R)
while G<=n-R:
G=g*j
print(G)
B,k=0,0
while B<=n-R-G:
B=b*k
print(B)
if n-R-G-B==0:
c+=1
k+=1
j+=1
i+=1
G,j=0,0
print(c)
| s122792185 | Accepted | 1,874 | 3,060 | 171 | r,g,b,n=list(map(int,input().split()))
i,j=0,0
R,G=0,0
c=0
while R<=n:
while G<=n-R:
if (n-R-G)%b==0:
c+=1
G+=g
G=0
R+=r
print(c)
|
s170141948 | p03587 | u189762886 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 14 | Snuke prepared 6 problems for a upcoming programming contest. For each of those problems, Rng judged whether it can be used in the contest or not. You are given a string S of length 6. If the i-th character of s is `1`, it means that the i-th problem prepared by Snuke is accepted to be used; `0` means that the problem is not accepted. How many problems prepared by Snuke are accepted to be used in the contest? | print(input()) | s966425222 | Accepted | 17 | 2,940 | 86 | a = input()
l = []
for i in str(a):
if i == '1':
l.append(i)
print(len(l)) |
s847631410 | p03578 | u367130284 | 2,000 | 262,144 | Wrong Answer | 2,105 | 35,992 | 183 | Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems. Determine whether Rng can complete the problem set without creating new candidates of problems. | n=int(input())
s=input().split()
m=int(input())
for t in input().split():
if t in s:
s.remove(t)
continue
else:
print("No")
exit()
print("Yes") | s448027043 | Accepted | 342 | 67,680 | 223 | from collections import*
n=int(input())
d=Counter(map(int,input().split()))
m=int(input())
t=Counter(map(int,input().split()))
#print(d,t)
for k,v in t.items():
if d[k]<v:
print("NO")
exit()
print("YES") |
s357664621 | p03605 | u102126195 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 73 | It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N? | N = input()
if N[0] == 9 or N[1] == 9:
print("Yes")
else:
print("No") | s527859856 | Accepted | 17 | 2,940 | 78 | N = input()
if N[0] == "9" or N[1] == "9":
print("Yes")
else:
print("No")
|
s098227762 | p04044 | u762540523 | 2,000 | 262,144 | Wrong Answer | 20 | 3,060 | 55 | Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m. | _=input();print("".join(sorted(list(input().split())))) | s083085584 | Accepted | 17 | 3,060 | 50 | print("".join(sorted(open(0).read().split()[2:]))) |
s134358858 | p03711 | u293267652 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 253 | Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group. | a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
x,y = map(int,(input().split()))
cou1 = 0
cou2 = 0
for i in a:
if i==x or i==y:
cou1 += 1
for i in b:
if i==x or i==y:
cou2 += 1
if cou1>1 or cou2>1:
print("YES")
else:
print("NO")
| s619416470 | Accepted | 17 | 3,064 | 252 | a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
x,y = map(int,(input().split()))
cou1 = 0
cou2 = 0
for i in a:
if i==x or i==y:
cou1 += 1
for i in b:
if i==x or i==y:
cou2 += 1
if cou1>1 or cou2>1:
print("Yes")
else:
print("No") |
s161574611 | p02390 | u911624488 | 1,000 | 131,072 | Wrong Answer | 30 | 7,576 | 102 | 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)
m = int((S % 3600) % 60)
s = (S % 60)
print("{}:{}:{}".format(h,m,s)) | s703697404 | Accepted | 30 | 7,656 | 102 | S = int(input())
h = (S // 3600)
m = ((S % 3600) // 60)
s = (S % 60)
print("{}:{}:{}".format(h,m,s)) |
s879070474 | p03434 | u912652535 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 191 | We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score. | N = int(input())
l = list(map(int,input().split()))
l_r = sorted(l,reverse=True)
Alice = l_r[::2]
Bob = l_r[1::2]
m =0
n = 0
for i in Alice:
m += i
for j in Bob:
n += j
print({m-n})
| s102104801 | Accepted | 17 | 3,060 | 1,147 | # a = int(input())
# b,c = map(int, input().split())
# print('{} {}'.format(a+b+c,s))
#
# a,b = map(int, input().split())
# if a*b%2 == 0:
# print("Even")
# else :
# print("Odd")
# l = list(input())
# l_new = [int(n) for n in l]
# count = 0
# count += 1
# print(count)
# ans = 10 **9
# N = int(input())
# A = list(map(int,input().split()))
# p = 0
# while i % 2 ==0:
# p += 1
# if p < ans:
# ans = p
# print(ans)
# a = int(input())
# b = int(input())
# c = int(input())
# X = int(input())
# count = 0
# x = 500 * i
# for j in range(b+1):
# for k in range(c+1):
N = int(input())
l = list(map(int,input().split()))
l_r = sorted(l,reverse=True)
Alice = l_r[::2]
Bob = l_r[1::2]
m =0
n = 0
for i in Alice:
m += i
for j in Bob:
n += j
print(m-n)
|
s926624002 | p03129 | u428132025 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 86 | Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1. | n, k = map(int, input().split())
if n >= 2*k-1:
print('Yes')
else:
print('No') | s034890307 | Accepted | 17 | 2,940 | 86 | n, k = map(int, input().split())
if n >= 2*k-1:
print('YES')
else:
print('NO') |
s910946493 | p03730 | u134019875 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 243 | 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())
L = [0] * b
for i in range(1, b):
s = (a * i) % b
if L[s] == 1:
print('No')
break
elif s == c:
print('Yes')
break
else:
L[s] = 1
else:
print('No')
| s188624752 | Accepted | 18 | 3,060 | 243 | a, b, c = map(int, input().split())
L = [0] * b
for i in range(1, b):
s = (a * i) % b
if L[s] == 1:
print('NO')
break
elif s == c:
print('YES')
break
else:
L[s] = 1
else:
print('NO')
|
s578549726 | p03693 | u768993705 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 56 | AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4? | print('NO' if int(input().replace(' ',''))%4 else 'Yes') | s606069522 | Accepted | 17 | 2,940 | 56 | print('NO' if int(input().replace(' ',''))%4 else 'YES') |
s561391594 | p03251 | u713830790 | 2,000 | 1,048,576 | Wrong Answer | 20 | 3,316 | 440 | 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. | if __name__ == '__main__':
N, M, X, Y = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mx = max(x)
my = min(y)
if mx >= my:
print("War")
else:
m_list = [i for i in range(mx+1, my+1)]
cap = [i for i in range(X+1, Y+1)]
if len(set(m_list) & set(cap)) >= 1:
print("No war")
else:
print("War") | s927320309 | Accepted | 17 | 3,064 | 300 | if __name__ == '__main__':
N, M, X, Y = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mx = max(x)
my = min(y)
lx = max(mx, X)
ly = min(my, Y)
if lx < ly:
print("No War")
else:
print("War") |
s829692434 | p03997 | u340294296 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 74 | You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid. | a = int(input())
b = int(input())
h = int(input())
print((a + b) * h / 2) | s269883482 | Accepted | 17 | 2,940 | 79 | a = int(input())
b = int(input())
h = int(input())
print(int((a + b) * h / 2)) |
s372709839 | p03438 | u285891772 | 2,000 | 262,144 | Wrong Answer | 47 | 12,064 | 1,054 | You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal. Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions **simultaneously** : * Add 2 to a_i. * Add 1 to b_j. | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
N = INT()
a = LIST()
b = LIST()
A = 0
B = 0
for i in range(N):
if a[i] > b[i]:
B += a[i]-b[i]
elif a[i] < b[i]:
A += b[i]-a[i]
if 2*B <= A:
print("Yes")
else:
print("No") | s458559572 | Accepted | 48 | 11,884 | 1,137 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10
N = INT()
a = LIST()
b = LIST()
a_cnt = 0
b_cnt = 0
for i in range(N):
if a[i] < b[i]:
a_cnt += -(a[i]-b[i])//2
elif a[i] > b[i]:
b_cnt += a[i]-b[i]
if b_cnt <= a_cnt:
print("Yes")
else:
print("No")
|
s469751835 | p03546 | u523087093 | 2,000 | 262,144 | Wrong Answer | 61 | 9,568 | 443 | Joisino the magical girl has decided to turn every single digit that exists on this world into 1. Rewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points). She is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive). You are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows: * If A_{i,j}≠-1, the square contains a digit A_{i,j}. * If A_{i,j}=-1, the square does not contain a digit. Find the minimum total amount of MP required to turn every digit on this wall into 1 in the end. | H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]
for k in range(10):
for i in range(10):
for j in range(10):
C[i][j] = min(C[i][j], C[i][k] + C[k][j])
answer = 0
for i in range(H):
for j in range(W):
if A[i][j] == -1:
continue
answer += C[A[i][j]][1]
print(A[i][j])
print(answer) | s381844694 | Accepted | 45 | 9,464 | 420 | H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]
for k in range(10):
for i in range(10):
for j in range(10):
C[i][j] = min(C[i][j], C[i][k] + C[k][j])
answer = 0
for i in range(H):
for j in range(W):
if A[i][j] == -1:
continue
answer += C[A[i][j]][1]
print(answer) |
s395321293 | p02795 | u357758400 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 229 | We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all the squares in that column black. At least how many operations do you need in order to have N or more black squares in the grid? It is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations. | h = int(input())
w = int(input())
n = int(input())
if h >= w:
cnt = int(n // h)
if not isinstance(n // h, int):
cnt += 1
else:
cnt = int(n // w)
if not isinstance(n // w, int):
cnt += 1
print(cnt) | s109004589 | Accepted | 17 | 3,060 | 196 | h = int(input())
w = int(input())
n = int(input())
if h >= w:
cnt = int(n // h)
if n % h != 0 :
cnt += 1
else:
cnt = int(n // w)
if n % w != 0:
cnt += 1
print(cnt) |
s217755039 | p03543 | u296150111 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 80 | We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**? | n=int(input())
if n/10%111==0 or n%1000%111==0:
print("Yes")
else:
print("No") | s294196139 | Accepted | 17 | 2,940 | 83 | n=int(input())
if n//10%111==0 or n%1000%111==0:
print("Yes")
else:
print("No") |
s305168624 | p02742 | u112317104 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 142 | We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move: | def solve():
N, M = map(int, input().split())
if N*M % 2 == 0:
return N*M/2
else:
return (N*M//2)+1
print(solve()) | s430209823 | Accepted | 17 | 3,060 | 311 | def solve():
N, M = map(int, input().split())
if N == 1:
return 1
if M == 1:
return 1
if N % 2 == 0:
return M * N // 2
else:
a = N // 2 * M
if M % 2 == 0:
return a + M//2
else:
return a + (M//2 + 1)
print(solve()) |
s323537722 | p03854 | u939552576 | 2,000 | 262,144 | Wrong Answer | 136 | 4,240 | 510 | You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. | s = input()
q = [0]
flag = False
while len(s) > 0:
if s[0:5] in ['dream','erase'] and flag == False:
q.append(s[0:5])
s = s[5:]
flag = False
elif s[0:6] == 'eraser':
q.append(s[0:6])
s = s[6:]
flag = False
elif s[0:7] == 'dreamer':
q.append(s[0:7])
s = s[7:]
flag = False
elif q[-1] in ['dream','erase']:
s = q[-1] + s
q.pop()
flag = True
else:
print('NO')
exit()
print('Yes')
| s786417959 | Accepted | 130 | 4,248 | 510 | s = input()
q = [0]
flag = False
while len(s) > 0:
if s[0:5] in ['dream','erase'] and flag == False:
q.append(s[0:5])
s = s[5:]
flag = False
elif s[0:6] == 'eraser':
q.append(s[0:6])
s = s[6:]
flag = False
elif s[0:7] == 'dreamer':
q.append(s[0:7])
s = s[7:]
flag = False
elif q[-1] in ['dream','erase']:
s = q[-1] + s
q.pop()
flag = True
else:
print('NO')
exit()
print('YES')
|
s339186792 | p02665 | u822662438 | 2,000 | 1,048,576 | Wrong Answer | 121 | 20,008 | 418 | Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1. | n = int(input())
a_li = list(map(int, input().split()))
ans = 0
li = [0]*(n+1)
for i,a in enumerate(a_li):
ans += (i+1)*a
for i,a in enumerate(a_li[::-1]):
if i >= 1:
li[i] = li[i-1]+a
else:
li[i] = a
li = li[::-1]
flag = True
ne = 0.5
for i in range(n+1):
if li[i] > 2*ne:
ans -= li[i] -2*ne
ne = 2*ne - a_li[i]
if ne <= 0:
flag = False
if flag:
print(int(ans))
else:
print(-1) | s549115443 | Accepted | 922 | 20,136 | 487 | n = int(input())
a_li = list(map(int, input().split()))
ans = 0
li = [0]*(n+1)
for i,a in enumerate(a_li):
ans += (i+1)*a
for i,a in enumerate(a_li[::-1]):
if i >= 1:
li[i] = li[i-1]+a
else:
li[i] = a
li = li[::-1]
flag = True
ne = 0.5
for i in range(n+1):
if li[i] > 2*ne:
ans -= li[i] -int(2*ne)
ne = min(li[i] - a_li[i],int(2*ne)-a_li[i])
if (i == n and ne != 0) or (i != n and ne <= 0):
flag = False
if flag:
print(ans)
else:
print(-1) |
s552845964 | p03448 | u014724123 | 2,000 | 262,144 | Wrong Answer | 54 | 3,060 | 270 | You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different. | a = int(input())
b = int(input())
c = int(input())
x = int(input())
counter = 0
for i in range(a):
for j in range(b):
for k in range(c):
total = 500 * i + 100 * j + 50 * k
if total == x:
counter += 1
print(counter)
| s938419001 | Accepted | 55 | 3,060 | 291 | a = int(input())
b = int(input())
c = int(input())
x = int(input())
counter = 0
for i in range(0, a+1):
for j in range(0, b+1):
for k in range(0, c+1):
total = (500 * i) + (100 * j) + (50 * k)
if total == x:
counter += 1
print(counter)
|
s611960098 | p03693 | u556657484 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 98 | AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4? | r, g, b = map(int, input().split())
if ((10 * g + b) % 4):
print("Yes")
else:
print("No")
| s150049581 | Accepted | 17 | 2,940 | 103 | r, g, b = map(int, input().split())
if ((10 * g + b) % 4 == 0):
print("YES")
else:
print("NO")
|
s374388132 | p04030 | u729535891 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 274 | Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now? | S = input()
keybord = [s for s in S]
editor = ''
for i in range(len(S)):
if keybord[i] == '0':
editor += '0'
elif keybord[i] == '1':
editor += '1'
else:
if editor == '':
continue
else:
editor = editor[:-1]
| s945006810 | Accepted | 18 | 3,060 | 288 | S = input()
keybord = [s for s in S]
editor = ''
for i in range(len(S)):
if keybord[i] == '0':
editor += '0'
elif keybord[i] == '1':
editor += '1'
else:
if editor == '':
continue
else:
editor = editor[:-1]
print(editor) |
s561780031 | p03720 | u846372029 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 221 | There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city? | # Counting Roads
n,m = list(map(int, input().split()))
a = []
for i in range(m):
a.append( list(map(int, input().split())) )
b = []
for s in a:
b.extend(s)
print(b)
for i in range (n):
print(b.count(i+1)) | s173008094 | Accepted | 17 | 3,060 | 211 | # Counting Roads
n,m = list(map(int, input().split()))
a = []
for i in range(m):
a.append( list(map(int, input().split())) )
b = []
for s in a:
b.extend(s)
for i in range (n):
print(b.count(i+1)) |
s618604190 | p03548 | u347640436 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 133 | We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person. At most how many people can sit on the seat? | X, Y, Z = map(int, input().split())
result = X // (Y + Z) - 1
while X < result * Y + (result + 1) * Z:
result += 1
print(result) | s743159051 | Accepted | 17 | 2,940 | 63 | X, Y, Z = map(int, input().split())
print((X - Z) // (Y + Z))
|
s823246681 | p03737 | u340947941 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 100 | You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. |
s1,s2,s3=input().split(" ")
print(s1[0].upper()+s1[0].upper()+s1[0].upper()) | s873706333 | Accepted | 17 | 2,940 | 100 |
s1,s2,s3=input().split(" ")
print(s1[0].upper()+s2[0].upper()+s3[0].upper()) |
s137831058 | p02255 | u362520072 | 1,000 | 131,072 | Wrong Answer | 20 | 5,600 | 265 | Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step. | def insertionSort(A, N):
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(' '.join(map(str, A)))
N = int(input())
A = list(map(int, input().split()))
insertionSort(A,N)
| s009968662 | Accepted | 20 | 5,600 | 296 | def insertionSort(A, N):
print(' '.join(map(str, A)))
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(' '.join(map(str, A)))
N = int(input())
A = list(map(int, input().split()))
insertionSort(A,N)
|
s544045447 | p03696 | u156815136 | 2,000 | 262,144 | Wrong Answer | 53 | 5,660 | 1,631 | You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of `(`, X and `)` in this order is also a correct bracket sequence. * If X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence. * Every correct bracket sequence can be derived from the rules above. Find the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one. | from statistics import median
#import collections
from fractions import gcd
from itertools import combinations
from collections import deque
from collections import defaultdict
import bisect
#
# d = m - k[i] - k[j]
#
#
#
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
def readInts():
return list(map(int,input().split()))
def main():
n = int(input())
S = input()
k = 0
v = 0
ans = ""
i = 0
nya = 0
while i < n:
if k != 0 and v == 0 and S[i] == '(':
for l in range(k):
ans += '('
ans += S[:i]
#print('?',ans)
k = 0
nya = i
continue
# if v != 0 and k == 0 and S[i] == ')':
# #print('!',ans)
# for r in range(v):
# ans += ')'
# continue
if S[i] == ')':
if v == 0:
k += 1
else:
v -= 1
elif S[i] == '(':
if k == 0:
v += 1
else:
k -= 1
i += 1
#print(k,v)
for j in range(k):
ans += '('
ans += S[nya:]
for j in range(v):
ans += ')'
print(ans)
if __name__ == '__main__':
main()
| s039279625 | Accepted | 37 | 10,340 | 1,250 | #from statistics import median
#import collections
from math import gcd
from itertools import combinations,permutations,accumulate, product
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
#
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
return list(map(int,readline().split()))
def readTuples():
return tuple(map(int,readline().split()))
def I():
return int(readline())
n = I()
S = input()
left = 0
right = 0
for i in range(n):
if S[i] == '(':
right += 1
elif S[i] == ')':
if right >= 1:
right -=1
else:
left += 1
print('('*left + S + ')'*right)
|
s231153563 | p03048 | u909991537 | 2,000 | 1,048,576 | Wrong Answer | 2,104 | 3,064 | 385 | Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this? | r, g, b, n = (int(i) for i in input().split())
rmax = int(n/r)
gmax = int(n/g)
count = 0
i = 0
j = 0
k = 0
for i in range(0, rmax + 1):
for j in range(0, gmax + 1):
if ((n - r * i - g * j) % b == 0 and (n - r * i - g * j)>0):
count += 1
for i in range(0, rmax + 1):
for j in range(0, gmax + 1):
if n == r * i - g * j:
count += 1
print(count)
| s118114397 | Accepted | 1,845 | 3,060 | 260 | r, g, b, n = (int(i) for i in input().split())
rmax = int(n/r)
count = 0
for i in range(0, rmax + 1):
gmax = (n - r * i) // g
for j in range(0, gmax + 1):
tmp = n - r * i - g * j
if (tmp % b == 0 and tmp >=0):
count += 1
print(count) |
s251087146 | p03997 | u596276291 | 2,000 | 262,144 | Wrong Answer | 23 | 3,064 | 142 | You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid. | def main():
a = int(input())
b = int(input())
h = int(input())
print((a + b) * h / 2)
if __name__ == '__main__':
main()
| s800272402 | Accepted | 37 | 4,200 | 781 | from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]
def inside(y, x, H, W):
return 0 <= y < H and 0 <= x < W
def ceil(a, b):
return (a + b - 1) // b
def main():
a = int(input())
b = int(input())
h = int(input())
print((a + b) * h // 2)
if __name__ == '__main__':
main()
|
s639238475 | p03719 | u255555420 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 93 | You are given three integers A, B and C. Determine whether C is not less than A and not greater than B. | abc = (input())
a,b,c = abc.split()
if c>=a and c<=b:
print("YES")
else:
print("NO") | s372378228 | Accepted | 17 | 2,940 | 84 | A,B,C =map(int,input().split())
if A<=C<=B:
print("Yes")
else:
print("No") |
s877837978 | p03449 | u537034351 | 2,000 | 262,144 | Wrong Answer | 34 | 9,200 | 271 | 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? | N = int(input())
candies_i = list(map(int, input().split()))
candies_j = list(map(int, input().split()))
l = []
for i in range(N):
total_li = sum(candies_i[:i])
total_lj = sum(candies_j[i:])
total = ( total_li + total_lj )
l.append(total)
print(max(l)) | s988828540 | Accepted | 29 | 9,116 | 270 | N = int(input())
candies_i = list(map(int, input().split()))
candies_j = list(map(int, input().split()))
l = []
for i in range(N):
total_li = sum(candies_i[:i+1])
total_lj = sum(candies_j[i:])
total = total_li + total_lj
l.append(total)
print(max(l))
|
s642120510 | p02261 | u409571842 | 1,000 | 131,072 | Wrong Answer | 30 | 6,352 | 1,315 | Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance). | #coding: UTF-8
import copy
class Algo:
@staticmethod
def bubbleSort(r, c, n):
print(r)
print(c)
tmp_r, tmp_c = r, c
flag = 1
while flag:
flag = 0
for j in range(n-1, 0, -1):
if tmp_c[j] < tmp_c[j-1]:
tmp_c[j], tmp_c[j-1] = tmp_c[j-1], tmp_c[j]
tmp_r[j], tmp_r[j-1] = tmp_r[j-1], tmp_r[j]
flag = 1
return tmp_r
def selectionSort(r, c, n):
print(r)
print(c)
tmp_r, tmp_c = r, c
for i in range(0,n):
minj = i
for j in range(i,n):
if tmp_c[j] < tmp_c[minj]:
minj = j
if tmp_c[i] != tmp_c[minj]:
tmp_c[i], tmp_c[minj] = tmp_c[minj], tmp_c[i]
tmp_r[j], tmp_r[minj] = tmp_r[minj], tmp_r[j]
return tmp_r
def createIntList(r, n):
c = []
for i in range(0,n):
c.append(r[i][1])
return c
def printList(r, n):
for i in range(0,n):
if i == n-1:
print(r[i])
else:
print(r[i], " ", sep="", end="")
n = int(input())
r = list(map(str,input().split()))
c = Algo.createIntList(r, n)
br = Algo.bubbleSort(copy.deepcopy(r), copy.deepcopy(c), n)
ir = Algo.selectionSort(copy.deepcopy(r), copy.deepcopy(c), n)
Algo.printList(br, n)
print("Stable")
Algo.printList(ir, n)
if br == ir:
print("Stable")
else:
print("Not stable") | s667513051 | Accepted | 30 | 6,348 | 1,119 | #coding: UTF-8
import copy
class Algo:
@staticmethod
def bubbleSort(r, c, n):
flag = 1
while flag:
flag = 0
for j in range(n-1, 0, -1):
if c[j] < c[j-1]:
c[j], c[j-1] = c[j-1], c[j]
r[j], r[j-1] = r[j-1], r[j]
flag = 1
return r
def selectionSort(r, c, n):
for i in range(0,n):
minj = i
for j in range(i,n):
if c[j] < c[minj]:
minj = j
if c[i] != c[minj]:
c[i], c[minj] = c[minj], c[i]
r[i], r[minj] = r[minj], r[i]
return r
def createIntList(r, n):
c = []
for i in range(0,n):
c.append(r[i][1])
return c
def printList(r, n):
for i in range(0,n):
if i == n-1:
print(r[i])
else:
print(r[i], " ", sep="", end="")
n = int(input())
r = list(map(str,input().split()))
c = Algo.createIntList(r, n)
br = Algo.bubbleSort(copy.deepcopy(r), copy.deepcopy(c), n)
ir = Algo.selectionSort(copy.deepcopy(r), copy.deepcopy(c), n)
Algo.printList(br, n)
print("Stable")
Algo.printList(ir, n)
if br == ir:
print("Stable")
else:
print("Not stable") |
s643272828 | p03503 | u319612498 | 2,000 | 262,144 | Wrong Answer | 17 | 3,068 | 18 | 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())
| s142348699 | Accepted | 300 | 3,064 | 340 | 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=-float("inf")
for i in range(1,1<<10):
tot=0
for k in range(n):
bit=0
for j in range(10):
if i&(1<<j) and f[k][j]==1: bit+=1
tot+=p[k][bit]
ans=max(ans,tot)
print(ans) |
s427529678 | p02267 | u591467586 | 1,000 | 131,072 | Wrong Answer | 20 | 7,560 | 251 | You are given a sequence of _n_ integers S and a sequence of different _q_ integers T. Write a program which outputs C, the number of integers in T which are also in the set S. | n1 = int(input())
s = (input()).split()
n2 = int(input())
t = (input()).split()
m = []
for i in range(0, n1):
key = s[i]
for j in range(0, n2):
if t[j] == s[i]:
m.append(t[j])
break
print(len(m)) | s602297686 | Accepted | 110 | 8,188 | 256 | n1 = int(input())
s = (input()).split()
n2 = int(input())
t = (input()).split()
m = []
for i in range(0, n2):
key = t[i]
for j in range(0, n1):
if s[j] == t[i]:
m.append(s[j])
break
print(len(m)) |
s660634939 | p04043 | u677393869 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 89 | 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=[]
A.append(map(int,input().split()))
if A==[5,7,5]:
print("YES")
else:
print("NO") | s699576747 | Accepted | 17 | 3,060 | 172 | A,B,C=map(int,input().split())
five=0
seven=0
for i in [A,B,C]:
if i==5:
five+=1
elif i==7:
seven+=1
if five==2 and seven==1:
print("YES")
else:
print("NO") |
s423974647 | p03433 | u665598835 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 87 | E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins. | N = int(input())
A = int(input())
if N%500 <= A:
print("YES")
else:
print("NO") | s078181867 | Accepted | 17 | 2,940 | 87 | N = int(input())
A = int(input())
if N%500 <= A:
print("Yes")
else:
print("No") |
s752206474 | p04044 | u260036763 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 105 | Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m. | N, L = map(int, input().split())
S = [input() for i in range(N)]
S.sort(reverse = True)
print(''.join(S)) | s324825849 | Accepted | 17 | 3,060 | 91 | N, L = map(int, input().split())
S = [input() for i in range(N)]
S.sort()
print(''.join(S)) |
s486105119 | p03644 | u060537418 | 2,000 | 262,144 | Wrong Answer | 32 | 9,120 | 84 | Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times. | n=int(input())
ans=0
for i in range(10):
if n>=(2**i):
ans=i
print(2**i) | s500841971 | Accepted | 30 | 9,176 | 103 | n=int(input())
anslist=[1,2,4,8,16,32,64]
ans=0
for i in anslist:
if n>=i:
ans=i
print(ans) |
s335182637 | p02612 | u193597115 | 2,000 | 1,048,576 | Wrong Answer | 31 | 9,092 | 107 | 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. | def payment(N):
return N % 1000
if __name__ == '__main__':
N = int(input())
print(payment(N)) | s483973232 | Accepted | 25 | 9,136 | 167 | def payment(N):
if N % 1000 == 0:
return 0
else:
return 1000 - N % 1000
if __name__ == '__main__':
N = int(input())
print(payment(N)) |
s982641132 | p03455 | u265118937 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 100 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | a, b = map(int, input().split())
if a // 2 == 1 or b // 2 == 1:
print("Odd")
else:
print("Even") | s084268500 | Accepted | 17 | 2,940 | 103 | a, b = map(int, input().split())
if (a % 2 == 1) and (b % 2 == 1):
print("Odd")
else:
print("Even") |
s025324249 | p02612 | u734936991 | 2,000 | 1,048,576 | Wrong Answer | 32 | 9,028 | 33 | We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. | n = int(input())
print(n % 1000) | s240026677 | Accepted | 29 | 9,156 | 77 | n = int(input())
ans = 0 if n % 1000 == 0 else 1000 - (n % 1000)
print(ans) |
s735879725 | p02841 | u690536347 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 95 | In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month. | m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())
print(1 if m1!=d1 else 0) | s760616322 | Accepted | 20 | 2,940 | 95 | m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())
print(1 if m1!=m2 else 0) |
s669851538 | p02843 | u204842730 | 2,000 | 1,048,576 | Wrong Answer | 1,588 | 3,064 | 324 | AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible. (Ignore consumption tax.) | import sys
x = int(input())
if x < 100:
print(0)
sys.exit()
if x > 50000:
print(1)
sys.exit()
for i in range(50):
for j in range(50-i):
for k in range(50-i-j):
for l in range(50-i-j-k):
for m in range(50-i-j-k-l):
if x - (100*i+101*j+102*k+103*l+104*m) % 105 == 0:
print(1)
sys.exit()
print(0) | s495290568 | Accepted | 17 | 3,064 | 294 | import sys
x = int(input())
n = x % 100
maxbuy = x // 100
ans = 0
if maxbuy > 99:
print(1)
sys.exit()
ans += n//5
n %= 5
ans += n//4
n %= 4
ans += n//3
n %= 3
ans += n//2
n %= 2
if n == 1:
if ans+1 <= maxbuy:
print(1)
else:
print(0)
else:
if ans <= maxbuy:
print(1)
else:
print(0) |
s962577760 | p03494 | u156931988 | 2,000 | 262,144 | Time Limit Exceeded | 2,107 | 2,940 | 221 | 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. | ignore = input()
num = map(int,input().split())
count = 0
while True:
if(sum([0 if i%2 == 0 else 1 for i in num]) == 0):
num = [i/2 for i in num]
count += 1
else:
print(count)
break | s058317400 | Accepted | 19 | 3,064 | 194 | import math
ignore = input()
num = map(int,input().split())
score = []
for i in num:
temp = i
while i%2 == 0:
i = i/2
score.append(temp/i)
print(int(math.log(min(score),2))) |
s102449186 | p02647 | u802234211 | 2,000 | 1,048,576 | Wrong Answer | 2,206 | 33,060 | 1,120 | We have N bulbs arranged on a number line, numbered 1 to N from left to right. Bulb i is at coordinate i. Each bulb has a non-negative integer parameter called intensity. When there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5. Initially, the intensity of Bulb i is A_i. We will now do the following operation K times in a row: * For each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i. Find the intensity of each bulb after the K operations. | import copy as cp
n,k = map(int,input().split())
lamps = list(map(int,input().split()))
# print(lamps)
lamp_io = [0]*n
# print(lamp_io)
for j in range(k):
for i in range(len(lamps)):
if(i == 0):
for k in range(1,lamps[i]+1):
if(i+k <= n-1):
lamp_io[k] += 1
else:
break
lamp_io[i] += 1
elif(i == n-1):
for k in range(1,lamps[i]+1):
if(i-k >= 0):
lamp_io[i-k] += 1
else:
break
lamp_io[i] += 1
else:
for k in range(1,lamps[i]+1):
a = 0
b = 0
if(i+k <= n-1):
lamp_io[i+k] += 1
else:
a = 1
if(i-k >= 0):
lamp_io[i-k] += 1
else:
b = 1
if(a == 1 and b == 1):
break
lamp_io[i] += 1
# print(lamp_io)
lamps = cp.copy(lamp_io)
lamp_io = [0]*n
print(lamps) | s506801628 | Accepted | 1,639 | 136,876 | 834 | from numba import jit
@jit
def main():
n,k = map(int,input().split())
lamps = list(map(int,input().split()))
for ki in range(k):
lamplog = [0]*(n+1)
for i in range(n):
lamplog[max(0,i-lamps[i]) ] += 1
lamplog[min(i+lamps[i]+1,n)] -= 1
# print(lamplog)
for i in range(n):
lamplog[i+1] += lamplog[i]
# print(lamplog)
lamplog.pop()
if(lamplog == lamps):
break
lamps = lamplog
return lamplog
lamplog = main()
ans = ""
for i in range(len(lamplog)):
ans += str(lamplog[i]) +" "
print(ans.rstrip()) |
s504220198 | p03485 | u728774856 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 94 | 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())
ave = (a + b) / 2
ave = int(ave)
ave = ave + 1
print(ave) | s666321157 | Accepted | 18 | 3,060 | 88 | import math
a, b = map(float, input().split())
ave = (a + b)/ 2
print(math.ceil(ave)) |
s851489985 | p03493 | u359007262 | 2,000 | 262,144 | Wrong Answer | 27 | 8,984 | 68 | 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. | def resolve():
s = input()
ans = s.count("1")
print(ans) | s100784374 | Accepted | 28 | 8,936 | 78 | def resolve():
s = input()
ans = s.count("1")
print(ans)
resolve() |
s938211676 | p02393 | u098047375 | 1,000 | 131,072 | Wrong Answer | 20 | 5,584 | 62 | Write a program which reads three integers, and prints them in ascending order. | a, b, c = map(int, input().split())
print(sorted([a, b, c]))
| s192554314 | Accepted | 20 | 5,588 | 94 | a, b, c = map(int, input().split())
sort = sorted([a, b, c])
print(sort[0], sort[1], sort[2])
|
s299988495 | p03089 | u596505843 | 2,000 | 1,048,576 | Wrong Answer | 2,104 | 51,700 | 389 | Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it. | n = int(input())
a = list(map(int,input().split()))
#n = 3
#a = [1,2,1]
def f(a):
print(a)
if len(a) == 0:
return []
for i in range(len(a)):
if a[i] == i+1:
b = a.copy()
b.pop(i)
ret = f(b)
if ret == [-1]:
continue
ret.append(i+1)
return ret
else:
continue
else:
return [-1]
ret = f(a)
print(' '.join(map(str,ret))) | s657465007 | Accepted | 18 | 3,064 | 367 | n = int(input())
a = list(map(int,input().split()))
acts = []
while True:
for i in range(len(a)):
idx = len(a)-i-1
if a[idx] == idx+1:
a.pop(idx)
acts.append(idx+1)
break
else:
print('-1')
break
if len(a) == 0:
acts.reverse()
print('\n'.join(map(str,acts)))
break |
s437904236 | p03759 | u288430479 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 89 | Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful. | A,B,C = map(int,input().split())
if 2*B == A + C :
print('Yes')
else:
print('No') | s570156789 | Accepted | 18 | 2,940 | 89 | A,B,C = map(int,input().split())
if 2*B == A + C :
print('YES')
else:
print('NO') |
s020304538 | p03730 | u595375942 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 63 | 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('YES' if a%b==c else 'NO') | s665869727 | Accepted | 18 | 2,940 | 94 | a,b,c=map(int,input().split())
print('YES' if any((a*i)%b==c for i in range(1,b+1) )else 'NO') |
s869403597 | p04043 | u820461302 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 167 | 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. | # -*- coding: utf-8 -*-
s = input().split(" ")
print(s)
if s.count('5') == 2 and s.count('7') == 1:
print("YES")
else:
print("NO") | s963287858 | Accepted | 17 | 2,940 | 158 | # -*- coding: utf-8 -*-
s = input().split(" ")
if s.count('5') == 2 and s.count('7') == 1:
print("YES")
else:
print("NO") |
s754588366 | p03377 | u864900001 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 99 | 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())
ans = "No"
if A <= X and X <= A+B:
ans = "Yes"
print(ans) | s367037959 | Accepted | 17 | 2,940 | 103 |
A, B, X = map(int, input().split())
ans = "NO"
if A <= X and X <= A+B:
ans = "YES"
print(ans)
|
s686549811 | p00005 | u500396695 | 1,000 | 131,072 | Wrong Answer | 20 | 7,672 | 265 | Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b. | def GCD(x, y):
while x > 0:
z = x
x = y % x
y = z
return y
def LCM(x, y):
X = x / GCD(x, y)
Y = y / GCD(x, y)
return X * Y * GCD(x, y)
import sys
L = sys.stdin.readlines()
for line in L:
x, y = list(map(int, line.split()))
print(GCD(x, y), LCM(x, y)) | s017432130 | Accepted | 30 | 7,624 | 259 | def GCD(a, b):
if b > a:
return GCD(b, a)
elif a % b == 0:
return b
return GCD(b, a % b)
def LCM(a, b):
return a * b // GCD(a, b)
import sys
L = sys.stdin.readlines()
for line in L:
x, y = list(map(int, line.split()))
print(GCD(x, y), LCM(x, y)) |
s779751290 | p02397 | u962381052 | 1,000 | 131,072 | Wrong Answer | 20 | 7,624 | 149 | Write a program which reads two integers x and y, and prints them in ascending order. | while True:
x, y = [int(n) for n in input().split()]
if x or y:
break
if x > y:
print(x, y)
else:
print(y, x) | s658314016 | Accepted | 60 | 7,572 | 155 | while True:
x, y = [int(n) for n in input().split()]
if not (x or y):
break
if x < y:
print(x, y)
else:
print(y, x) |
s951443494 | p03827 | u227082700 | 2,000 | 262,144 | Wrong Answer | 16 | 2,940 | 84 | You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation). | ans=0
x=0
for i in input():
if i=="I":x+=1
else:x-=1
ans=max(x,ans)
print(ans) | s496599049 | Accepted | 18 | 2,940 | 99 | ans=0
x=0
n=int(input())
for i in input():
if i=="I":x+=1
else:x-=1
ans=max(x,ans)
print(ans) |
s988964227 | p04043 | u057993957 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 88 | 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. | sets = set(map(int, input().split()))
print('Yes' if sets == set([5, 7, 5]) else 'no')
| s055448522 | Accepted | 17 | 2,940 | 92 | sets = sorted(list(map(int, input().split())))
print('YES' if sets == [5, 5, 7] else 'NO')
|
s728857022 | p02255 | u742797815 | 1,000 | 131,072 | Wrong Answer | 30 | 7,744 | 264 | 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())
l = [int(x) for x in input().split()]
for i in range(n):
if i == 0:
continue
a = l[i]
j = i - 1
while j >= 0 and l[j] > a:
l[j+1] = l[j]
j = j - 1
l[j+1] = a
print(' '.join([str(x) for x in l])) | s953447950 | Accepted | 20 | 8,148 | 203 | n = int(input())
l = [int(x) for x in input().split()]
for i in range(n):
a = l[i]
j = i - 1
while j >= 0 and l[j] > a:
l[j+1] = l[j]
j = j - 1
l[j+1] = a
print(*l) |
s823238420 | p03644 | u609061751 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 192 | Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times. | import sys
input = sys.stdin.readline
N = int(input())
ans = -1
for i in range(1, N + 1):
cnt = 0
while i % 2 == 0:
cnt += 1
i //= 2
ans = max(ans, cnt)
print(ans) | s834973021 | Accepted | 17 | 3,060 | 230 | import sys
input = sys.stdin.readline
N = int(input())
ans = [0, -1]
for i in range(1, N + 1):
cnt = 0
j = i
while i % 2 == 0:
cnt += 1
i //= 2
if cnt > ans[1]:
ans = [j, cnt]
print(ans[0]) |
s686333613 | p03556 | u347912669 | 2,000 | 262,144 | Wrong Answer | 23 | 2,940 | 110 | 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 = 81
ans = 0
for i in range(1, 40000)[::-1]:
if i * i <= n:
ans = i*i
break
print(ans)
| s172845679 | Accepted | 24 | 2,940 | 120 | n = int(input())
ans = 0
for i in range(1, 42500)[::-1]:
if i * i <= n:
ans = i*i
break
print(ans)
|
s255157116 | p03479 | u425762225 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 122 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | from math import *
def solve(x,y,ans=1):
return 1 + ceil(log2(y/x))
X,Y = map(int,input().split())
print(solve(X,Y)) | s939851610 | Accepted | 28 | 9,104 | 143 | X,Y = map(int,input().split())
def solve(now,y,ans=0):
ans = 0
while now <= y:
ans += 1
now *= 2
return ans
print(solve(X,Y)) |
s218390945 | p03597 | u287880059 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 49 | We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black? | n = int(input())
a = int(input())
print(a**2-a)
| s111709960 | Accepted | 17 | 2,940 | 46 | N = int(input())
A = int(input())
print(N*N-A) |
s924913318 | p03251 | u412563426 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,064 | 301 | 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. | import sys
input = sys.stdin.readline
n, m, X, Y = map(int, input().split())
x = map(int, input().split())
y = map(int, input().split())
x_max = max(x)
y_min = min(y)
for i in range(X + 1, Y + 1):
if x_max < i and i <= y_min:
print(i)
print('No War')
exit()
print('War') | s149522884 | Accepted | 17 | 3,064 | 285 | import sys
input = sys.stdin.readline
n, m, X, Y = map(int, input().split())
x = map(int, input().split())
y = map(int, input().split())
x_max = max(x)
y_min = min(y)
for i in range(X + 1, Y + 1):
if x_max < i and i <= y_min:
print('No War')
exit()
print('War') |
s540466607 | p03544 | u735008991 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 71 | It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2) | a, b = 2, 1
for i in range(int(input())-1):
a, b = b, a+b
print(a)
| s061454137 | Accepted | 17 | 2,940 | 71 | a, b = 2, 1
for i in range(int(input())-1):
a, b = b, a+b
print(b)
|
s678442263 | p03698 | u244434589 | 2,000 | 262,144 | Wrong Answer | 26 | 8,868 | 123 | You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different. | s = input()
l = []
for i in s:
if i in l:
print('No')
exit()
else:
l.append(i)
print('Yes') | s729695775 | Accepted | 27 | 9,028 | 124 | s = input()
l = []
for i in s:
if i in l:
print('no')
exit()
else:
l.append(i)
print('yes')
|
s206316845 | p03544 | u857330600 | 2,000 | 262,144 | Wrong Answer | 19 | 3,060 | 83 | It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2) | l=[2,1]
n=int(input())
i=0
while i!=n:
l.append(l[i]+l[i+1])
i+=1
print(l[n-1]) | s567657667 | Accepted | 17 | 2,940 | 81 | l=[2,1]
n=int(input())
i=0
while i!=n:
l.append(l[i]+l[i+1])
i+=1
print(l[n]) |
s019087952 | p03592 | u952708174 | 2,000 | 262,144 | Wrong Answer | 263 | 2,940 | 165 | We have a grid with N rows and M columns of squares. Initially, all the squares are white. There is a button attached to each row and each column. When a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa. When a button attached to a column is pressed, the colors of all the squares in that column are inverted. Takahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid. | N,M,K = [int(i) for i in input().split()]
ans = 'No'
for j in range(N+1):
for k in range(M+1):
if j * (M - 2) + k * (N - 2) == K:
ans = 'Yes'
print(ans) | s963836926 | Accepted | 312 | 3,060 | 165 | N,M,K = [int(i) for i in input().split()]
ans = 'No'
for j in range(N+1):
for k in range(M+1):
if j * (M - k) + k * (N - j) == K:
ans = 'Yes'
print(ans) |
s489557370 | p03400 | u578694888 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 158 | Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp. | # -*- coding: utf-8 -*-
n=int(input())
d,x=map(int,input().split())
a=[int(input()) for _ in range(n)]
d-=1
for i in a:
print(x)
x+=d//i+1
print(x)
| s443798470 | Accepted | 17 | 2,940 | 145 | # -*- coding: utf-8 -*-
n=int(input())
d,x=map(int,input().split())
a=[int(input()) for _ in range(n)]
d-=1
for i in a:
x+=d//i+1
print(x)
|
s430339915 | p02842 | u311636831 | 2,000 | 1,048,576 | Wrong Answer | 19 | 2,940 | 115 | 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. | A=int(input())
B=(A*100)//108
print(((B+1)*1.08)//1)
if((((B*1.08)//1)==A) or ((((B+1)*1.08)//1)==A)):
print(B) | s780834762 | Accepted | 17 | 3,060 | 132 | A=int(input())
B=(A*100)//108
if((((B*1.08)//1)==A)):
print(B)
elif((((B+1)*1.08)//1)==A):
print(B+1)
else:
print(":(") |
s336747016 | p03971 | u677523557 | 2,000 | 262,144 | Wrong Answer | 114 | 4,784 | 259 | There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass. | N, A, B = map(int, input().split())
S = input()
C = A+B
P = [0]*N
for i in range(N):
if S[i] == 'a' and C > 0:
C -= 1
P[i] = 1
elif S[i] == 'b' and B > 0:
C -= 1
B -= 1
P[i] = 1
for i in range(N):
print('Yes' if P[i] else 'No')
| s573939777 | Accepted | 109 | 4,784 | 287 | N, A, B = map(int, input().split())
S = input()
P = [0]*N
for i in range(N):
if S[i] == 'a':
if A > 0:
A -= 1
P[i] = 1
elif B >0:
B -= 1
P[i] = 1
elif S[i] == 'b' and B > 0:
B -= 1
P[i] = 1
for i in range(N):
print('Yes' if P[i] else 'No') |
s104490479 | p03433 | u920821326 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 91 | 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())
n=n-a
if n//500==0:
print("YES")
else :
print("NO") | s337337923 | Accepted | 17 | 2,940 | 172 | n=int(input())
a=int(input())
if n<500:
if n<=a:
print("Yes")
else:
print("No")
elif n>500 and (n%500)<=a:
print("Yes")
else :
print("No")
|
s935209242 | p03836 | u767545760 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 276 | Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him. | X = list(map(int, input().split()))
sx = X[0]
sy = X[1]
tx = X[2]
ty = X[3]
x = tx - sx
y = ty - sy
print(x, y)
l1 = "U" * y + "R" * x
l2 = "D" * y + "L" * x
l3 = "L" + "U" * (y + 1) + "R" * (x + 1) + "D"
l4 = "R" + "D" * (y + 1) + "L" * (x + 1) + "U"
print(l1 + l2 + l3 + l4) | s438940225 | Accepted | 17 | 3,064 | 264 | X = list(map(int, input().split()))
sx = X[0]
sy = X[1]
tx = X[2]
ty = X[3]
x = tx - sx
y = ty - sy
l1 = "U" * y + "R" * x
l2 = "D" * y + "L" * x
l3 = "L" + "U" * (y + 1) + "R" * (x + 1) + "D"
l4 = "R" + "D" * (y + 1) + "L" * (x + 1) + "U"
print(l1 + l2 + l3 + l4) |
s381794017 | p03162 | u202727309 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,064 | 439 | Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains. | N = 3
A=[[10, 40, 70], [20, 50, 80], [30, 60, 90]]
dp = [[0] * 3 for _ in range(N)]
dp[0] = A[0]
print(dp[0])
for i in range(N-1):
for j in range(3):
for k in range(3):
if j == k:
continue
dp[i+1][k] = max(dp[i+1][k], dp[i][j] + A[i][k])
print(max(dp[N-1]))
print((dp[N-1]))
print(max(dp[N-2]))
print((dp[N-2]))
print(max(dp[N-3]))
print((dp[N-3])) | s669213924 | Accepted | 573 | 34,616 | 457 | N = int(input())
A = [0] * N
B = [0] * N
C = [0] * N
for i in range(N):
A[i], B[i], C[i] = map(int, input().split())
dp = [[0] * 3 for _ in range(N)]
dp[0] = [A[0], B[0], C[0]]
for i in range(N-1):
dp[i+1][0] = max(dp[i][1]+A[i+1], dp[i][2]+A[i+1])
dp[i+1][1] = max(dp[i][0]+B[i+1], dp[i][2]+B[i+1])
dp[i+1][2] = max(dp[i][0]+C[i+1], dp[i][1]+C[i+1])
print(max(dp[N-1])) |
s592445005 | p03361 | u673101577 | 2,000 | 262,144 | Wrong Answer | 29 | 9,208 | 1,050 | We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`. However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black. Determine if square1001 can achieve his objective. | # from pprint import pprint
# import math
# import collections
# n = int(input())
h, w = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))
s = []
for i in range(h):
s.append(list(input()))
check = [[None] * w for i in range(h)]
for i in range(h):
for j in range(w):
if s[i][j] == '#':
check[i][j] = False
if i > 0 and s[i - 1][j] == '#':
check[i][j] = True
check[i - 1][j] = True
if i < h - 1 and s[i + 1][j] == '#':
check[i][j] = True
check[i + 1][j] = True
if j > 0 and s[i][j - 1] == '#':
check[i][j] = True
check[i][j - 1] = True
if j < w - 1 and s[i][j + 1] == '#':
check[i][j] = True
check[i][j + 1] = True
else:
check[i][j] = True
print(all([all(c) for c in check]))
| s256349484 | Accepted | 31 | 9,248 | 930 | # from pprint import pprint
# import math
# import collections
# n = int(input())
h, w = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))
s = []
for i in range(h):
s.append(list(input()))
check = [[None] * w for i in range(h)]
for i in range(h):
for j in range(w):
if s[i][j] == '#':
check[i][j] = False
if i > 0 and s[i - 1][j] == '#':
check[i][j] = True
if i < h - 1 and s[i + 1][j] == '#':
check[i][j] = True
if j > 0 and s[i][j - 1] == '#':
check[i][j] = True
if j < w - 1 and s[i][j + 1] == '#':
check[i][j] = True
else:
check[i][j] = True
if all([all(c) for c in check]):
print('Yes')
else:
print('No')
|
s438551597 | p03910 | u006882546 | 2,000 | 262,144 | Wrong Answer | 1,927 | 86,892 | 209 | The problem set at _CODE FESTIVAL 20XX Finals_ consists of N problems. The score allocated to the i-th (1≦i≦N) problem is i points. Takahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve. As problems with higher scores are harder, he wants to minimize the highest score of a problem among the ones solved by him. Determine the set of problems that should be solved. | N = int(input())
W = [0]*(N+1)
W[1] = 1
for i in range(1, N+1):
W[i] += W[i-1]
if W[i] >= N:
for j in range(1, i+1):
if j != (W[i] - N):
print(j)
break | s457822325 | Accepted | 26 | 9,276 | 174 | N = int(input())
W = 0
for i in range(1, N+1):
W += i
if W >= N:
for j in range(1, i+1):
if j != (W - N):
print(j)
break |
s925968399 | p02690 | u630511239 | 2,000 | 1,048,576 | Wrong Answer | 25 | 9,224 | 150 | Give a pair of integers (A, B) such that A^5-B^5 = X. It is guaranteed that there exists such a pair for the given integer X. | X = int(input())
p = int(pow(X, 1/5))
for a in range(p):
for b in range(-p, a):
if a**5 - b**5 == X:
print(a, b, sep = " ")
break
| s119567748 | Accepted | 50 | 9,328 | 209 | X = int(input())
N = int(X**(1/5))
ans = [0,0]
for i in range(-2*N-1, 2*N+2):
for j in range(-2*N-1, 2*N+2):
if i**5-j**5==X:
ans = [i, j]
ans = [str(i) for i in ans]
ans = ' '.join(ans)
print(ans) |
s929064581 | p03605 | u395816772 | 2,000 | 262,144 | Wrong Answer | 29 | 8,944 | 73 | It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N? | a = input()
if a[0] == 9 or a[1] == 9:
print('Yes')
else:
print('No') | s995764333 | Accepted | 24 | 9,044 | 82 | a = input()
if a[0] == '9' or a[1] == '9':
print('Yes')
else:
print('No') |
s901210884 | p02645 | u621215510 | 2,000 | 1,048,576 | Wrong Answer | 24 | 9,012 | 28 | When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him. | s = input()
nickname = s[:3] | s874837773 | Accepted | 27 | 8,860 | 25 | s = input()
print(s[:3]) |
s660781027 | p02534 | u466335531 | 2,000 | 1,048,576 | Wrong Answer | 31 | 9,076 | 25 | You are given an integer K. Print the string obtained by repeating the string `ACL` K times and concatenating them. For example, if K = 3, print `ACLACLACL`. | k=input()
print(k*len(k)) | s684754077 | Accepted | 24 | 8,960 | 27 | print("ACL" * int(input())) |
s935195385 | p02972 | u328364772 | 2,000 | 1,048,576 | Wrong Answer | 57 | 6,836 | 166 | There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices. | n = int(input())
A = list(map(int, input().split()))
cnt = A.count(1)
ans = ["1" for i in range(cnt)]
if len(ans) == 0:
print(0)
else:
print(" ".join(ans))
| s042349311 | Accepted | 242 | 19,516 | 279 | n = int(input())
A = list(map(int, input().split()))
B = [0 for i in range(n)]
for i in range(n-1, -1, -1):
j = i + 1
ball = B[i::j]
if sum(ball) % 2 != A[i]:
B[i] = 1
print(sum(B))
B_ball = [str(i+1) for i in range(n) if B[i] == 1]
print(" ".join(B_ball)) |
s146476428 | p03795 | u763963344 | 2,000 | 262,144 | Wrong Answer | 24 | 9,056 | 58 | 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())
x = N * 800
y = N / 15 * 200
print(x - y) | s790384466 | Accepted | 32 | 8,828 | 46 | N=int(input())
x=N*800
y=N//15*200
print(x-y) |
s036307503 | p04011 | u074161135 | 2,000 | 262,144 | Wrong Answer | 25 | 9,032 | 158 | There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee. | def ston():
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n <= k:
print(n*x)
else:
print(k*x + (n-k)*y)
| s369067981 | Accepted | 27 | 9,092 | 87 | n,k,x,y = [int(input()) for i in range(4)]
cost = (min(n,k)*x+max(0,n-k)*y)
print(cost) |
s905327031 | p03695 | u143492911 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 661 | In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows: * Rating 1-399 : gray * Rating 400-799 : brown * Rating 800-1199 : green * Rating 1200-1599 : cyan * Rating 1600-1999 : blue * Rating 2000-2399 : yellow * Rating 2400-2799 : orange * Rating 2800-3199 : red Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not. Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i. Find the minimum and maximum possible numbers of different colors of the users. | n=int(input())
a=list(map(int,input().split()))
ash=0
brown=0
green=0
lightblue=0
blue=0
yellow=0
orange=0
red=0
anything=0
for i in range(n):
if a[i]<=399:
ash+=1
elif 400<=a[i]<=799:
brown+=1
elif 800<=a[i]<=1199:
green+=1
elif 1200<=a[i]<=1599:
lightblue+=1
elif 1600<=a[i]<=1999:
blue+=1
elif 2000<=a[i]<=2399:
yellow+=1
elif 2400<=a[i]<=2799:
orange+=1
elif 2800<=a[i]<=3199:
red+=1
elif 3200<=a[i]:
anything+=1
minn=ash+brown+green+lightblue+blue+yellow+orange+red
max_i=ash+brown+green+lightblue+blue+yellow+orange+red+anything
print(minn,max_i)
| s600940553 | Accepted | 17 | 3,064 | 583 | n=int(input())
a=list(map(int,input().split()))
gray=brown=green=cyan=blue=yellow=orange=red=num=0
for i in range(n):
if 1<=a[i]<=399:
gray=1
if 400<=a[i]<=799:
brown=1
if 800<=a[i]<=1199:
green=1
if 1200<=a[i]<=1599:
cyan=1
if 1600<=a[i]<=1999:
blue=1
if 2000<=a[i]<=2399:
yellow=1
if 2400<=a[i]<=2799:
orange=1
if 2800<=a[i]<=3199:
red=1
if 3200<=a[i]:
num+=1
total=gray+brown+green+cyan+blue+yellow+orange+red
if total==0:
print(1,num)
else:
print(total,total+num) |
s189373490 | p03251 | u114920558 | 2,000 | 1,048,576 | Wrong Answer | 18 | 3,060 | 203 | 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 = [int(i) for i in input().split()]
y = [int(j) for j in input().split()]
if max(x) < min(y) and max(x) < Y and min(y) > X:
print('No war')
else:
print('War') | s325962423 | Accepted | 18 | 3,060 | 206 | N, M, X, Y = map(int, input().split())
x = [int(i) for i in input().split()]
y = [int(j) for j in input().split()]
if max(x) < min(y) and max(x) < Y and min(y) > X:
print('No War')
else:
print('War')
|
s906512222 | p03456 | u367130284 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 75 | AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number. | print(sum(616**2**("B"in i)*float(i[:-4])for i in open(0).readlines()[1:])) | s427576267 | Accepted | 17 | 3,060 | 70 | i=int(input().replace(" ",""));print("NYoe s"[int(i**0.5)==i**0.5::2]) |
s674370916 | p02806 | u945181840 | 2,525 | 1,048,576 | Wrong Answer | 17 | 3,060 | 285 | Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct. Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X. Find the duration of time when some song was played while Niwango was asleep. | import sys
read = sys.stdin.read
readline = sys.stdin.readline
N = int(readline())
st = [tuple(readline().split()) for _ in range(N)]
X = str(readline())
flag = False
answer = 0
for s, t in st:
if flag:
answer += int(t)
if s == X:
flag = True
print(answer)
| s380859770 | Accepted | 17 | 2,940 | 226 | import sys
read = sys.stdin.read
N, *st, X = read().split()
flag = False
answer = 0
for s, t in zip(*[iter(st)] * 2):
if flag:
answer += int(t)
continue
if s == X:
flag = True
print(answer)
|
s949637942 | p03693 | u045408189 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 68 | AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4? | r,g,b=map(int,input().split())
print('YES' if 10*g+b%4==0 else 'NO') | s528075856 | Accepted | 17 | 2,940 | 71 | r,g,b=map(int,input().split())
print('YES' if (10*g+b)%4==0 else 'NO')
|
s073903719 | p03796 | u161442663 | 2,000 | 262,144 | Wrong Answer | 2,104 | 4,224 | 68 | Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7. | import math
N=int(input())
P=(math.factorial(N))//(10**9+7)
print(P) | s002668167 | Accepted | 230 | 3,968 | 68 | import math
N=int(input())
P=(math.factorial(N))%(10**9+7)
print(P)
|
s816826710 | p03448 | u831081653 | 2,000 | 262,144 | Wrong Answer | 53 | 3,060 | 246 | You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different. | a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a):
for j in range(b):
for k in range(c):
ans = i*500 + j*100 + k*50
if ans == x:
cnt += 1
print(cnt) | s595737837 | Accepted | 56 | 3,060 | 252 | a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
ans = i*500 + j*100 + k*50
if ans == x:
cnt += 1
print(cnt) |
s889952857 | p01712 | u301729341 | 2,000 | 131,072 | Wrong Answer | 30 | 7,500 | 351 | Koto は言わずと知れた碁盤の目の街である. この街は東西方向に W メートル,南北方向に H メートルに伸びる長方形の領域によってできている. この街の西端から x メートル,南端から y メートルの点は (x, y) と記される. ここの街に住む人は古くから伝わる独自の文化を重んじており,その一つにKoto距離という変わった距離尺度がある. 2つの点 (x_1, y_1),(x_2, y_2) の Koto 距離は,min(|x_1 - x_2|, |y_1 - y_2|) によって定義される. 最近この街全体に Wifi を使えるようにする計画が立ち上がった. 現在の計画では,親機を N 個作ることになっている. i 番目の親機は点 (x_i, y_i) に設置され,Koto距離が w_i 以下の領域に対して Wifi を提供する. 親機を計画どおり建てた場合に,街の内部及び境界上に Wifi を提供できるかどうかを判定せよ. なお,Koto距離は一般に三角不等式を満たさないため,距離の公理を満たさないということはここだけの秘密である. | n,w,h = map(int,input().split())
Yoko = [0] * w
Tate = [0] * h
for i in range(n):
x,y,r = map(int,input().split())
for j in range(x - 2,x + 2):
if j < w:
Yoko[j] += 1
if j < h:
Tate[j] += 1
print(Yoko)
print(Tate)
if Yoko.count(0) > 0 or Tate.count(0) > 0:
print("Yes")
else:
print("No") | s299583356 | Accepted | 1,080 | 42,012 | 1,305 | import sys
n,w,h = map(int,input().split())
Yoko = []
Tate = []
for i in range(n):
x,y,r = map(int,input().split())
Yoko.append([x - r,x + r])
Tate.append([y - r,y + r])
Yoko = sorted(Yoko)
Tate = sorted(Tate)
if Yoko[0][0] > 0 and Tate[0][0] > 0:
print("No")
sys.exit()
Yoko_han = [Yoko[0][0],Yoko[0][1]]
Tate_han = [Tate[0][0],Tate[0][1]]
if Yoko[0][0] <= 0:
if Yoko_han[1] >= w:
print("Yes")
sys.exit()
else:
for j in range(1,len(Tate)):
if Yoko[j][0] <= Yoko_han[1] and Yoko_han[1] < Yoko[j][1]:
Yoko_han[1] = Yoko[j][1]
if Yoko_han[1] >= w:
print("Yes")
sys.exit()
elif Yoko_han[1] < Yoko[j][0]:
break
if Tate[0][0] > 0:
print("No")
sys.exit()
else:
if Tate_han[1] >= h:
print("Yes")
sys.exit()
else:
for k in range(1,len(Yoko)):
if Tate[k][0] <= Tate_han[1] and Tate_han[1] < Tate[k][1]:
Tate_han[1] = Tate[k][1]
if Tate_han[1] >= h:
print("Yes")
sys.exit()
elif Yoko_han[1] < Yoko[k][0]:
print("No")
sys.exit()
print("No") |
s469774558 | p03797 | u853900545 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 88 | Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces. | s,c=map(int,input().split())
if c > 2*s:
print(c//2)
else:
print(s + (c-2*s)//2) | s920436605 | Accepted | 17 | 2,940 | 98 | s,c=map(int,input().split())
d = 0
if c < 2*s:
d = c//2
else:
d = s + (c-2*s)//4
print(d)
|
s636862900 | p03469 | u371467115 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 31 | On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it. | s=list(input())
s[3]=8
print(s) | s428101448 | Accepted | 18 | 2,940 | 29 | s=input()
print("2018"+s[4:]) |
s844578166 | p04011 | u314008046 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 78 | There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee. | n,k,x,y=(int(input()) for i in range(4))
print(k*x if n<=k else (k*x+(n-k)*x)) | s828492400 | Accepted | 18 | 2,940 | 78 | n,k,x,y=(int(input()) for i in range(4))
print(n*x if n<=k else (k*x+(n-k)*y)) |
s569115420 | p00070 | u186082958 | 1,000 | 131,072 | Wrong Answer | 20 | 7,604 | 752 | 0 から 9 までの整数を使った n 個の数の並び k1, k2, ..., kn を考えます。正の整数 n と s を読み込んで、 k1 \+ 2 × k2 \+ 3 × k3 + ... \+ n × kn = s となっているような n 個の数の並びが何通りあるかを出力するプログラムを作成してください。ただし、1 つの「n 個の数の並び」には同じ数が 2 回以上現われないものとします。 | def solve(used,rest,sum,memo):
if rest==0:
return sum==0
else:
num=0
for i in range(10):
num*=2
if used[i]:num+=1
if (num,rest,sum) in memo:
return memo[(num,rest,sum)]
if sum<0:return 0
if sum>maxs[rest]:return 0
ans=0
for i in range(10):
if not used[i]:
used[i]=True
ans+=solve(used,rest-1,sum-(i)*rest,memo)
used[i]=False
memo[(num,rest,sum)]=ans
return memo[(num,rest,sum)]
memo={}
while True:
try:
n,s=map(int,input().split())
used=[False for i in range(10)]
ans=solve(used,n,s,memo)
print(ans)
except:
break | s933124832 | Accepted | 3,290 | 80,612 | 717 | def solve(used,rest,sum,memo):
if rest==0:
return sum==0
else:
num=0
for i in range(10):
num*=2
if used[i]:num+=1
if (num,rest,sum) in memo:
return memo[(num,rest,sum)]
if sum<0:return 0
ans=0
for i in range(10):
if not used[i]:
used[i]=True
ans+=solve(used,rest-1,sum-(i)*rest,memo)
used[i]=False
memo[(num,rest,sum)]=ans
return memo[(num,rest,sum)]
memo={}
while True:
try:
n,s=map(int,input().split())
used=[False for i in range(10)]
ans=solve(used,n,s,memo)
print(ans)
except:
break |
s421428842 | p03352 | u296150111 | 2,000 | 1,048,576 | Wrong Answer | 19 | 3,060 | 123 | You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2. | x=int(input())
a=[]
for j in range(1,10):
a.append(2**j)
a.sort()
import bisect
k=bisect.bisect_right(a,x)
print(a[k-1])
| s163245875 | Accepted | 22 | 3,308 | 149 | x=int(input())
a=[]
for i in range(1,1000):
for j in range(2,10):
a.append(i**j)
a.sort()
import bisect
k=bisect.bisect_right(a,x)
print(a[k-1])
|
s838545679 | p03006 | u415905784 | 2,000 | 1,048,576 | Wrong Answer | 47 | 6,452 | 657 | 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. | from fractions import gcd
from collections import defaultdict
N = int(input())
B = [[0, 0] for i in range(N)]
D = [[[0, 0] for j in range(N)] for i in range(N)]
G = defaultdict(lambda:defaultdict(int))
for i in range(N):
B[i] = [int(x) for x in input().split()]
B.sort()
for i in range(N):
for j in range(i):
grad = gcd(abs(B[j][0] - B[i][0]), abs(B[j][1] - B[i][1]))
D[i][j] = [(B[j][0] - B[i][0]) // grad, (B[j][1] - B[i][1]) // grad]
D[j][i] = [-D[i][j][0], -D[i][j][1]]
for i in range(N):
for j in range(N):
if i == j:
continue
G[str(D[i][j])][i] += 1
ans = N
for p in G.keys():
ans = min(ans, N - len(G[p]))
print(ans) | s361273397 | Accepted | 25 | 3,948 | 564 | from collections import defaultdict
N = int(input())
B = [[0, 0] for i in range(N)]
D = [[[0, 0] for j in range(N)] for i in range(N)]
G = defaultdict(int)
for i in range(N):
B[i] = [int(x) for x in input().split()]
B.sort()
for i in range(N):
for j in range(i, N):
if i == j:
continue
D[i][j] = [B[j][0] - B[i][0], B[j][1] - B[i][1]]
D[j][i] = [-D[i][j][0], -D[i][j][1]]
for i in range(N):
for j in range(i, N):
if i == j:
continue
G[str(D[i][j])] += 1
ans = N
for p in G.keys():
v = N - G[p]
ans = min(ans, v)
print(ans) |
s150110412 | p02694 | u720124072 | 2,000 | 1,048,576 | Wrong Answer | 32 | 9,280 | 59 | 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? | import math
x = float(input())
print(math.log(x/100, 1.01)) | s073247939 | Accepted | 29 | 9,128 | 123 | import math
x = int(input())
num = 100
for i in range(10000):
num += num//100
if num >= x:
print(i+1)
exit(0) |
s428106252 | p02401 | u313600138 | 1,000 | 131,072 | Wrong Answer | 20 | 5,596 | 165 | Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part. | a,op,b = input().split()
a=int(a)
b=int(b)
if op=='+':
print(a+b)
if op=='-':
print(a-b)
if op=='*':
print(a*b)
if op=='/':
print(a/b)
if op=='?':
pass
| s239647222 | Accepted | 20 | 5,592 | 199 | while True:
a,op,b = input().split()
a=int(a)
b=int(b)
if op=='?':
break
if op=='+':
print(a+b)
if op=='-':
print(a-b)
if op=='*':
print(a*b)
if op=='/':
print(a//b)
|
s376289762 | p03409 | u518042385 | 2,000 | 262,144 | Wrong Answer | 22 | 3,064 | 598 | On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs. | n=int(input())
l=[]
for i in range(n):
l1=list(map(int,input().split()))
l.append(l1+["a",0])
for i in range(n):
l1=list(map(int,input().split()))
l.append(l1+["b"])
count=0
for i in range(2*n):
if l[i][2]=="a":
pass
else:
num=l[i][1]
min=100
index=-1
if i==0:
pass
else:
for j in range(0,i):
if l[j][2]=="a":
if l[j][3]==0:
if min>num-l[j][1] and num>l[j][1]:
min=num-l[j][1]
index=j
if index!=-1:
l[index][3]=1
count+=1
print(count) | s553028717 | Accepted | 20 | 3,188 | 610 | n=int(input())
l=[]
for i in range(n):
l1=list(map(int,input().split()))
l.append(l1+["a",0])
for i in range(n):
l1=list(map(int,input().split()))
l.append(l1+["b"])
count=0
l=sorted(l)
for i in range(2*n):
if l[i][2]=="a":
pass
else:
num=l[i][1]
min=100
index=-1
if i==0:
pass
else:
for j in range(0,i):
if l[j][2]=="a":
if l[j][3]==0:
if min>num-l[j][1] and num>l[j][1]:
min=num-l[j][1]
index=j
if index!=-1:
l[index][3]=1
count+=1
print(count) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.