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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s376692957
|
p03448
|
u982594421
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 244 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a + 1):
for j in range(b + 1):
ts = i * 500 + j * 100
if x - ts >= 0 and (a - ts) % 50 == 0 and (a - ts) // 50 <= c:
ans += 1
print(ans)
|
s830800755
|
Accepted
| 18 | 3,064 | 243 |
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a + 1):
for j in range(b + 1):
ts = i * 500 + j * 100
if x - ts >= 0 and (x - ts) % 50 == 0 and (x - ts) // 50 <= c:
ans += 1
print(ans)
|
s979403796
|
p02411
|
u193453446
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,652 | 535 |
Write a program which reads a list of student test scores and evaluates the performance for each student. The test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1. The final performance of a student is evaluated by the following procedure: * If the student does not take the midterm or final examination, the student's grade shall be F. * If the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A. * If the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B. * If the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C. * If the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C. * If the total score of the midterm and final examination is less than 30, the student's grade shall be F.
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
while True:
inp = input().split(" ")
m = int(inp[0])
f = int(inp[1])
r = int(inp[2])
if m < 0 and f < 0 and r < 0 :
break
if m < 0 or f < 0 :
S = "F"
else:
t = m + f
if t < 50:
if r >= 50:
S = "C"
else:
S = "D"
elif t < 65:
S = "C"
elif t < 80:
S = "B"
else:
S = "A"
print(S)
|
s487576645
|
Accepted
| 20 | 7,620 | 603 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
while True:
inp = input().strip().split(" ")
m = int(inp[0])
f = int(inp[1])
r = int(inp[2])
# print(inp[1])
if m < 0 and f < 0 and r < 0 :
break
if m < 0 or f < 0 :
S = "F"
else:
t = m + f
if t < 30:
S = "F"
elif t < 50:
if r >= 50:
S = "C"
else:
S = "D"
elif t < 65:
S = "C"
elif t < 80:
S = "B"
else:
S = "A"
print(S)
|
s300556055
|
p03377
|
u067365728
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 89 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a,b,c = map(int,input().split())
if 0 <= c-a <= b:
print("Yes")
else:
print("No")
|
s705731929
|
Accepted
| 17 | 2,940 | 89 |
a,b,c = map(int,input().split())
if 0 <= c-a <= b:
print("YES")
else:
print("NO")
|
s155523523
|
p03597
|
u056599756
| 2,000 | 262,144 |
Wrong Answer
| 17 | 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())
nn=n**n
a=int(input())
print(nn-a)
|
s354657751
|
Accepted
| 17 | 2,940 | 45 |
n=int(input())
a=int(input())
print(n**2-a)
|
s283959125
|
p03958
|
u107077660
| 1,000 | 262,144 |
Wrong Answer
| 24 | 3,064 | 133 |
There are K pieces of cakes. Mr. Takahashi would like to eat one cake per day, taking K days to eat them all. There are T types of cake, and the number of the cakes of type i (1 ≤ i ≤ T) is a_i. Eating the same type of cake two days in a row would be no fun, so Mr. Takahashi would like to decide the order for eating cakes that minimizes the number of days on which he has to eat the same type of cake as the day before. Compute the minimum number of days on which the same type of cake as the previous day will be eaten.
|
K, T = map(int, input().split())
a = list(map(int, input().split()))
if max(a) < (K+1)//2:
print(max(a) - (K+1)//2)
else:
print(0)
|
s878117009
|
Accepted
| 22 | 3,064 | 140 |
K, T = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)-max(a)
if max(a) - s < 2:
print(0)
else:
print(max(a)-s-1)
|
s037290781
|
p02694
|
u676933207
| 2,000 | 1,048,576 |
Wrong Answer
| 22 | 9,168 | 205 |
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
X = int(input())
yokin = 100
def genYokin():
global yokin
return int(yokin*1.01)
year_cnt = 0
while True:
if X < yokin:
break
yokin = genYokin()
year_cnt += 1
print(year_cnt)
|
s856216716
|
Accepted
| 21 | 9,108 | 214 |
X = int(input())
yokin = 100
def getNextYokin():
global yokin
return int(yokin*1.01)
year_cnt = 0
while True:
if X <= yokin:
break
yokin = getNextYokin()
year_cnt += 1
print(year_cnt)
|
s347585347
|
p03386
|
u371409687
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,064 | 219 |
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
a,b,k=map(int,input().split())
ans=[]
for i in range(a,min(a+k,b)):
ans.append(i)
for j in range(max(a,b-k+1),b+1):
ans.append(j)
ans=sorted(list(set(ans)))
print(ans)
for i in range(len(ans)):
print(ans[i])
|
s627025084
|
Accepted
| 17 | 3,060 | 208 |
a,b,k=map(int,input().split())
ans=[]
for i in range(a,min(a+k,b)):
ans.append(i)
for j in range(max(a,b-k+1),b+1):
ans.append(j)
ans=sorted(list(set(ans)))
for i in range(len(ans)):
print(ans[i])
|
s574112762
|
p01101
|
u196653484
| 8,000 | 262,144 |
Wrong Answer
| 1,480 | 5,628 | 366 |
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items. You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
|
while(True):
max=0
b=list(map(int,input().split()))
n=b[0]
m=b[1]
if(n == 0 and m == 0):
break
a=list(map(int,input().split()))
for i in range(n):
for j in range(i+1,n):
sum=a[i]+a[j]
if(sum>max and sum<m):
max=sum
if m==0:
print("NONE")
else:
print(max)
|
s739337502
|
Accepted
| 1,400 | 5,712 | 416 |
maxs=[]
while(True):
max=-1
b=list(map(int,input().split()))
n=b[0]
m=b[1]
if(n == 0 and m == 0):
break
a=list(map(int,input().split()))
for i in range(n):
for j in range(i+1,n):
sum=a[i]+a[j]
if(sum>max and sum<=m):
max=sum
maxs.append(max)
for i in maxs:
if i==-1:
print("NONE")
else:
print(i)
|
s384069726
|
p03711
|
u275934251
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 157 |
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.
|
lis_1=[1,3,5,7,8,10,12]
lis_2=[4,6,9,11]
lis_3=[2]
x,y=map(int,input().split())
if (x,y) in (lis_1 or lis_2 or lis_3):
print("Yes")
else:
print("No")
|
s795925281
|
Accepted
| 18 | 2,940 | 103 |
lis=[1,3,1,2,1,2,1,1,2,1,2,1]
x,y=map(int,input().split())
print("Yes" if lis[x-1]==lis[y-1] else "No")
|
s434036081
|
p02280
|
u923668099
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,836 | 2,035 |
A rooted binary tree is a tree with a root node in which every node has at most two children. Your task is to write a program which reads a rooted binary tree _T_ and prints the following information for each node _u_ of _T_ : * node ID of _u_ * parent of _u_ * sibling of _u_ * the number of children of _u_ * depth of _u_ * height of _u_ * node type (root, internal node or leaf) If two nodes have the same parent, they are **siblings**. Here, if _u_ and _v_ have the same parent, we say _u_ is a sibling of _v_ (vice versa). The height of a node in a tree is the number of edges on the longest simple downward path from the node to a leaf. Here, the given binary tree consists of _n_ nodes and evey node has a unique ID from 0 to _n_ -1.
|
import sys
nil = -1
class Node:
def __init__(self):
self.parent = nil
self.sibling = nil
self.degree = 0
self.left = nil
self.right = nil
self.depth = nil
self.height = nil
self.ntype = 'leaf'
def set_depth(v, depth):
bitree[v].depth = depth
if bitree[v].left != nil:
set_depth(bitree[v].left, depth + 1)
if bitree[v].right != nil:
set_depth(bitree[v].right, depth + 1)
def set_height(v, height):
bitree[v].height = height
if bitree[v].parent != nil:
if bitree[bitree[v].parent].height < bitree[v].height + 1:
cur = bitree[v].parent
i = 1
while cur != nil:
bitree[cur].height = height + i
i += 1
cur = bitree[cur].parent
n = int(input())
bitree = [Node() for i in range(n)]
leaves = set()
for i in range(n):
line = [int(j) for j in input().split()]
t_id = line[0]
bitree[t_id].left = line[1]
bitree[t_id].right = line[2]
bitree[t_id].degree = (line[1] != nil) + (line[2] != nil)
if bitree[t_id].degree > 0:
bitree[t_id].ntype = 'internal node'
if bitree[t_id].left != nil:
bitree[bitree[t_id].left].parent = t_id
if bitree[t_id].right != nil:
bitree[bitree[t_id].right].parent = t_id
if bitree[t_id].degree == 2:
bitree[bitree[t_id].left].sibling = bitree[t_id].right
bitree[bitree[t_id].right].sibling = bitree[t_id].left
else:
leaves.add(t_id)
for t_id in range(n):
if bitree[t_id].parent == nil:
bitree[t_id].ntype = 'root'
r = t_id
break
set_depth(r, 0)
for leaf in leaves:
set_height(leaf, 0)
for t_id in range(n):
print('node {}: parent = {}, subling = {}, degree = {}, depth = {}, height = {}, {}'.format(
t_id, bitree[t_id].parent, bitree[t_id].sibling, bitree[t_id].degree,
bitree[t_id].depth, bitree[t_id].height, bitree[t_id].ntype))
|
s760858987
|
Accepted
| 30 | 7,904 | 1,909 |
import sys
nil = -1
class Node:
def __init__(self):
self.parent = nil
self.sibling = nil
self.degree = 0
self.left = nil
self.right = nil
self.depth = nil
self.height = nil
self.ntype = 'leaf'
def set_depth(v, depth):
bitree[v].depth = depth
if bitree[v].left != nil:
set_depth(bitree[v].left, depth + 1)
if bitree[v].right != nil:
set_depth(bitree[v].right, depth + 1)
def get_height(v):
h1 = 0
h2 = 0
if bitree[v].left != nil:
h1 = get_height(bitree[v].left) + 1
if bitree[v].right != nil:
h2 = get_height(bitree[v].right) + 1
bitree[v].height = max(h1, h2)
return bitree[v].height
n = int(input())
bitree = [Node() for i in range(n)]
leaves = set()
for i in range(n):
line = [int(j) for j in input().split()]
t_id = line[0]
bitree[t_id].left = line[1]
bitree[t_id].right = line[2]
bitree[t_id].degree = (line[1] != nil) + (line[2] != nil)
if bitree[t_id].degree > 0:
bitree[t_id].ntype = 'internal node'
if bitree[t_id].left != nil:
bitree[bitree[t_id].left].parent = t_id
if bitree[t_id].right != nil:
bitree[bitree[t_id].right].parent = t_id
if bitree[t_id].degree == 2:
bitree[bitree[t_id].left].sibling = bitree[t_id].right
bitree[bitree[t_id].right].sibling = bitree[t_id].left
else:
leaves.add(t_id)
for t_id in range(n):
if bitree[t_id].parent == nil:
bitree[t_id].ntype = 'root'
r = t_id
break
set_depth(r, 0)
get_height(r)
for t_id in range(n):
print('node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(
t_id, bitree[t_id].parent, bitree[t_id].sibling, bitree[t_id].degree,
bitree[t_id].depth, bitree[t_id].height, bitree[t_id].ntype))
|
s529828716
|
p03378
|
u393512980
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 150 |
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N. Find the minimum cost incurred before reaching the goal.
|
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
c1,c2=0,0
for i in range(m):
if i < x:
c1+=1
else:
c2+=1
print(min(c1,c2))
|
s821165379
|
Accepted
| 17 | 2,940 | 144 |
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
c1,c2=0,0
for i in a:
if i < x:
c1+=1
else:
c2+=1
print(min(c1,c2))
|
s921064413
|
p02843
|
u221580805
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 175 |
AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible. (Ignore consumption tax.)
|
n = int(input())
digit = len(str(n))
min = 10**(digit-1)
max = min * 1.05
if n >= min and n <= max:
print(1)
else:
print(0)
|
s135971843
|
Accepted
| 17 | 3,064 | 360 |
n = input()
digit = len(n)
num = int(n)
min = 0
if digit == 3:
min = int(n[0] + '00')
elif digit == 4:
min = int(n[0] + n[1] + '00')
elif digit == 5:
min = int(n[0] + n[1] + n[2] + '00')
elif digit == 6:
min = int(n[0] + n[1] + n[2] + n[3] + '00')
else:
min = 9999999999
max = min * 1.05
if num >= min and num <= max:
print(1)
else:
print(0)
|
s919397673
|
p03370
|
u306142032
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 309 |
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
|
def minn(a):
tmp = 9999
for i in range(len(a)):
if a[i] < tmp:
tmp = a[i]
return tmp
n, x = map(int, input().split())
m = []
cnt = 0
for i in range(n):
m.append(int(input()))
for i in range(n):
x -= m[i]
cnt += 1
cnt += (x // minn(m))
print(minn(m))
print(cnt)
|
s004862144
|
Accepted
| 18 | 3,060 | 295 |
def minn(a):
tmp = 9999
for i in range(len(a)):
if a[i] < tmp:
tmp = a[i]
return tmp
n, x = map(int, input().split())
m = []
cnt = 0
for i in range(n):
m.append(int(input()))
for i in range(n):
x -= m[i]
cnt += 1
cnt += (x // minn(m))
print(cnt)
|
s774476582
|
p02690
|
u277312083
| 2,000 | 1,048,576 |
Wrong Answer
| 42 | 9,160 | 168 |
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())
for a in range(-100, 101):
for b in range(-100, 101):
if a ** 5 - b ** 5 == x:
print(a, b)
break
break
|
s462139793
|
Accepted
| 52 | 8,880 | 152 |
x = int(input())
for a in range(-118, 120):
for b in range(-118, 120):
if a**5 - b**5 == x:
A = a
B = b
print(A, B)
|
s532345848
|
p03546
|
u353895424
| 2,000 | 262,144 |
Wrong Answer
| 275 | 17,548 | 546 |
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.
|
import numpy as np
import scipy.sparse.csgraph as csg
from copy import deepcopy
h, w = map(int, input().split())
c = []
for i in range(10):
c.append(list(map(int, input().split())))
a = []
for i in range(h):
a.append(list(map(int, input().split())))
d = csg.floyd_warshall(c)
# for k in range(10):
# for j in range(10):
# d[i][j] = min(d[i][j], d[i][k] + d[k][j])
ans = 0
for i in range(h):
for j in range(w):
if a[i][j] != -1:
ans += d[a[i][j]][1]
print(ans)
|
s183431406
|
Accepted
| 213 | 14,092 | 551 |
import numpy as np
import scipy.sparse.csgraph as csg
from copy import deepcopy
h, w = map(int, input().split())
c = []
for i in range(10):
c.append(list(map(int, input().split())))
a = []
for i in range(h):
a.append(list(map(int, input().split())))
d = csg.floyd_warshall(c)
# for k in range(10):
# for j in range(10):
# d[i][j] = min(d[i][j], d[i][k] + d[k][j])
ans = 0
for i in range(h):
for j in range(w):
if a[i][j] != -1:
ans += d[a[i][j]][1]
print(int(ans))
|
s863256386
|
p03494
|
u561113780
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,064 | 379 |
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
def main():
N = int(input())
A = list(map(int, input().split()))
cnt = 0
odd_num = 0
print(A)
while odd_num == 0:
for Ai in A:
if Ai%2 != 0:
odd_num+=1
if odd_num == 0:
cnt +=1
print(list(A))
A = list(map(lambda x: x/2,A))
print(cnt)
if __name__ == '__main__':
main()
|
s838886572
|
Accepted
| 19 | 3,064 | 381 |
def main():
N = int(input())
A = list(map(int, input().split()))
cnt = 0
odd_num = 0
#print(A)
while odd_num == 0:
for Ai in A:
if Ai%2 != 0:
odd_num+=1
if odd_num == 0:
cnt +=1
#print(list(A))
A = list(map(lambda x: x/2,A))
print(cnt)
if __name__ == '__main__':
main()
|
s177999280
|
p02936
|
u685983477
| 2,000 | 1,048,576 |
Wrong Answer
| 2,137 | 508,464 | 406 |
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations.
|
n,q=map(int, input().split())
edges = [[0 for _ in range(n)]for i in range(n)]
counter = [0]*n
for i in range(n-1):
a,b=map(int, input().split())
edges[a-1][b-1]=1
def dfs(i: int, c: int):
for j in range(n):
if edges[i][j]==1:
dfs(j, c)
counter[j]+=c
for i in range(q):
a,b=map(int, input().split())
counter[a-1]+=b
dfs(a-1, b)
print(counter)
|
s136713100
|
Accepted
| 1,698 | 56,084 | 530 |
from collections import deque
n,q=map(int, input().split())
edges = [[]for _ in range(n)]
counter = [0]*n
visited=[-1]*n
que=deque()
for i in range(n-1):
a,b=map(int, input().split())
edges[a-1].append(b-1)
edges[b-1].append(a-1)
for i in range(q):
a,b=map(int, input().split())
counter[a-1]+=b
que.append(0)
while que:
v=que.popleft()
visited[v]=1
for next_v in edges[v]:
if visited[next_v]!=-1:continue
counter[next_v]+=counter[v]
que.append(next_v)
print(*counter)
|
s316157581
|
p03759
|
u634873566
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 70 |
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
a, b, c = map(int, input().split())
print("Yes" if b-a==c-b else "No")
|
s590236541
|
Accepted
| 17 | 2,940 | 70 |
a, b, c = map(int, input().split())
print("YES" if b-a==c-b else "NO")
|
s393680870
|
p03854
|
u747602774
| 2,000 | 262,144 |
Wrong Answer
| 34 | 4,084 | 615 |
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=list(input())
l=0
while l!=len(S):
l=len(S)
if S[-1]=='m' and S[-2]=='a' and S[-3]=='e' and S[-4]=='r' and S[-5]=='d':
del S[-5:]
if len(S)==0:
break
if S[-1]=='e' and S[-2]=='s' and S[-3]=='a' and S[-4]=='r' and S[-5]=='e':
del S[-5:]
if len(S)==0:
break
if S[-1]=='r' and S[-2]=='e' and S[-3]=='s' and S[-4]=='a' and S[-5]=='r' and S[-6]=='e':
del S[-6:]
if len(S)==0:
break
if S[-1]=='r' and S[-2]=='e' and S[-3]=='m' and S[-4]=='a' and S[-5]=='e' and S[-6]=='r' and S[-7]=='d':
del S[-7:]
if len(S)==0:
break
if len(S)==0:
print('Yes')
else:
print('No')
|
s870118663
|
Accepted
| 28 | 3,188 | 310 |
S = input()
idx = len(S)
ans = 'YES'
while idx > 0:
if S[idx-5:idx] == 'dream':
idx -= 5
elif S[idx-5:idx] == 'erase':
idx -= 5
elif S[idx-7:idx] == 'dreamer':
idx -= 7
elif S[idx-6:idx] == 'eraser':
idx -= 6
else:
ans = 'NO'
break
print(ans)
|
s125454773
|
p02975
|
u008582165
| 2,000 | 1,048,576 |
Wrong Answer
| 51 | 14,212 | 179 |
Snuke has N hats. The i-th hat has an integer a_i written on it. There are N camels standing in a circle. Snuke will put one of his hats on each of these camels. If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `Yes`; otherwise, print `No`. * The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself. What is XOR? The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non- negative integers x_1, x_2, \ldots, x_n is defined as follows: - When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3 \oplus 5 = 6.
|
n = int(input())
lista = list(map(int,input().split()))
list2 = []
ans = 0
for i in lista:
ans = ans^i
ans = format(ans,"b")
if ans ==0:
print("Yes")
else:
print("No")
|
s926913799
|
Accepted
| 51 | 14,116 | 189 |
n = int(input())
lista = list(map(int,input().split()))
list2 = []
ans = 0
for i in lista:
ans = ans^i
ans = str(format(ans,"b"))
if ans == "0":
print("Yes")
else:
print("No")
|
s826736199
|
p03861
|
u845937249
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 202 |
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
a,b,x = map(int,input().split())
ans1 = b//x
ans2 = a//x
print(ans1)
print(ans2)
if b%x == 0:
print(ans1-ans2+1)
else:
print(ans1-ans2)
|
s494312914
|
Accepted
| 18 | 2,940 | 202 |
a,b,x = map(int,input().split())
ans1 = a//x
ans2 = b//x
#print(ans1)
#print(ans2)
if a%x == 0:
print(ans2-ans1+1)
else:
print(ans2-ans1)
|
s223030613
|
p03813
|
u697696097
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 385 |
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise. You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise.
|
import sys
def yn(b):
print("Yes" if b==1 else "No")
return
def resolve():
readline=sys.stdin.readline
x=int(readline().strip())
if x>1200:
print("ABC")
else:
print("ARC")
#n,m,k=list(map(int, readline().strip().split()))
#arr=list(map(int, readline().strip().split()))
#n=int(readline().strip())
#yn(1)
return
resolve()
|
s364564482
|
Accepted
| 17 | 2,940 | 386 |
import sys
def yn(b):
print("Yes" if b==1 else "No")
return
def resolve():
readline=sys.stdin.readline
x=int(readline().strip())
if x<1200:
print("ABC")
else:
print("ARC")
#n,m,k=list(map(int, readline().strip().split()))
#arr=list(map(int, readline().strip().split()))
#n=int(readline().strip())
#yn(1)
return
resolve()
|
s842746152
|
p03385
|
u288948615
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 79 |
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
s = list(input())
l = set(s)
if len(l) == 1:
print('Yes')
else:
print('No')
|
s849416728
|
Accepted
| 20 | 2,940 | 79 |
s = list(input())
l = set(s)
if len(l) == 3:
print('Yes')
else:
print('No')
|
s816935160
|
p03457
|
u545411641
| 2,000 | 262,144 |
Wrong Answer
| 528 | 89,348 | 242 |
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
N = int(input())
T = list()
for index in range(N):
T.append((int(i) for i in input().split()))
pt, px, py = (0, 0, 0)
for t, x, y in T:
if t - pt == (x - px) + (y - py):
pt, px, py = (t, x, y)
else:
print("No")
exit(0)
print("Yes")
|
s378498969
|
Accepted
| 537 | 89,356 | 278 |
N = int(input())
T = list()
for index in range(N):
T.append((int(i) for i in input().split()))
pt, px, py = (0, 0, 0)
for t, x, y in T:
d = (t - pt) - (abs(x - px) + abs(y - py))
if d >= 0 and d % 2 == 0:
pt, px, py = (t, x, y)
else:
print("No")
exit(0)
print("Yes")
|
s163428442
|
p03379
|
u756988562
| 2,000 | 262,144 |
Wrong Answer
| 2,108 | 25,484 | 201 |
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
|
N = int(input())
X = tuple(map(int,input().split()))
print(X)
for i in range(len(X)):
temp = list(X)
temp.pop(i)
test = int((len(temp)+1)/2)
temp = sorted(temp)
print(temp[test-1])
|
s204635885
|
Accepted
| 317 | 25,556 | 258 |
N = int(input())
X = list(map(int,input().split()))
X_sorted = sorted(X)
X_median = (N)/2
median1 = X_sorted[int(X_median)]
median2 = X_sorted[int(X_median-1)]
for i in range(N):
if X[i] >=median1:
print(median2)
else:
print(median1)
|
s748418561
|
p02601
|
u075317232
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,552 | 378 |
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
|
import random
def Magic2():
num = list(map(int,input().split()))
count = int(input())
for i in range(count):
select = random.randint(0, 2)
num[select] = 2.*num[select]
if num[0] < num[1] and num[1] < num[2]:
print('Yes')
else:
print('No')
if __name__ == '__main__':
Magic2()
|
s736560613
|
Accepted
| 29 | 9,548 | 493 |
import random
def Magic2():
num = list(map(int,input().split()))
count = int(input())
for i in range(count):
if num[0] >= num[1]:
num[1] = 2*num[1]
elif num[1] >= num[2]:
num[2] = 2*num[2]
else:
num[2] = 2*num[2]
if num[0] < num[1] and num[1] < num[2]:
print('Yes')
else:
print('No')
if __name__ == '__main__':
Magic2()
|
s615640720
|
p02394
|
u987236471
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,592 | 134 |
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.
|
W,H,x,y,r = map(int, input().split())
if r < x < H-r:
if r < y < W-r:
print("True")
else:
print("False")
else:
print("False")
|
s598444739
|
Accepted
| 20 | 5,596 | 127 |
W,H,x,y,r = map(int, input().split())
if 0 <= x-r and x+r <= W and 0 <= y-r and y+r <= H:
print("Yes")
else:
print("No")
|
s947932675
|
p03449
|
u366644013
| 2,000 | 262,144 |
Wrong Answer
| 152 | 12,540 | 297 |
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
|
import numpy as np
n = int(input())
a = np.cumsum([int(i) for i in input().split()])
b = np.cumsum([int(i) for i in input().split()])
ans = 0
if n == 1:
ans = a[0] + b[0]
else:
for i in range(n):
print(a[i] , b[-1] - b[i-1])
ans = max(ans, a[i] + b[-1] - b[i-1])
print(ans)
|
s609483302
|
Accepted
| 151 | 12,504 | 272 |
import numpy as np
n = int(input())
a = np.cumsum([0] + [int(i) for i in input().split()])
b = np.cumsum([0] + [int(i) for i in input().split()])
ans = 0
if n == 1:
ans = a[1] + b[1]
else:
for i in range(n):
ans = max(ans, a[i+1] + b[-1] - b[i])
print(ans)
|
s535927458
|
p03478
|
u521470676
| 2,000 | 262,144 |
Wrong Answer
| 49 | 9,176 | 255 |
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
def sum_of_digits(n):
s = 0
while n > 0:
s += n % 10
n = int(n / 10)
return s
n, a, b = map(int, input().split())
res = 0
for i in range(1, n + 1):
print(i, sum_of_digits(i))
if a <= sum_of_digits(i) <= b:
res += i
print(res)
|
s996727588
|
Accepted
| 37 | 9,112 | 226 |
def sum_of_digits(n):
s = 0
while n > 0:
s += n % 10
n = int(n / 10)
return s
n, a, b = map(int, input().split())
res = 0
for i in range(1, n + 1):
if a <= sum_of_digits(i) <= b:
res += i
print(res)
|
s264570888
|
p04043
|
u985076807
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 168 |
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
a = list(map(int, input().split()))
comp = [5,5,7]
for i,x in enumerate(sorted(a)):
if x != comp[i]:
print('NO')
exit()
print('Yes')
|
s971056426
|
Accepted
| 20 | 3,060 | 261 |
# coding: utf-8
def isOK(a):
a = list(map(int, a.split()))
comp = [5,5,7]
for i,x in enumerate(sorted(a)):
if x != comp[i]:
return False
return True
a = input()
if isOK(a):
print('YES')
else:
print('NO')
|
s026732806
|
p03139
|
u266874640
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 79 |
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question.
|
n, a, b = map(int,input().split())
print(max(a, b), end='')
print(max(a+b-n,0))
|
s617793379
|
Accepted
| 17 | 2,940 | 81 |
n, a, b = map(int,input().split())
print(min(a, b), end=' ')
print(max(a+b-n,0))
|
s772690995
|
p03674
|
u896741788
| 2,000 | 262,144 |
Wrong Answer
| 243 | 28,980 | 580 |
You are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n. It is known that each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7.
|
n=int(input())
l=list(map(int,input().split()))
memo={}
for i in range(n+1):
if l[i]in memo:
g=l[i]
x,y=memo[g],i
break
memo[l[i]]=i
mod=10**9+7
print(x,y)
fact=[1]*(n+1+1)
inv=[1]*(n+1+1)
for i in range(2,n+1+1):
fact[i]=i*fact[i-1]%mod
inv[-1]=pow(fact[-1],mod-2,mod)
for i in range(n+1,1,-1):
inv[i-1]=inv[i]*i%mod
def comb(x,y):return fact[x]*inv[y]%mod*inv[x-y]%mod if x>=y>=0 else 0
print(n)
for i in range(2,n+2):
ans=comb(n+1,i)
if n-y+x>=i-1:ans-=comb(x+n-y,i-1)
else:ans-=comb(x,i-1)-comb(n-y,i-1)
print(ans)
|
s920245987
|
Accepted
| 229 | 29,396 | 482 |
n=int(input())
l=list(map(int,input().split()))
memo={}
for i in range(n+1):
if l[i]in memo:
g=l[i]
x,y=memo[g],i
break
memo[l[i]]=i
mod=10**9+7
fact=[1]*(n+1+1)
inv=[1]*(n+1+1)
for i in range(2,n+1+1):
fact[i]=i*fact[i-1]%mod
inv[-1]=pow(fact[-1],mod-2,mod)
for i in range(n+1,1,-1):
inv[i-1]=inv[i]*i%mod
def comb(x,y):return fact[x]*inv[y]%mod*inv[x-y]%mod if x>=y>=0 else 0
for i in range(1,n+2):print((comb(n+1,i)-comb(x+n-y,i-1))%mod)
|
s122979802
|
p03544
|
u102960641
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 72 |
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)
|
n = int(input())
l1 = 2
l2 = 1
for i in range(n-1):
l2 += l1
l1 = l2
|
s026278843
|
Accepted
| 17 | 2,940 | 88 |
n = int(input())
l1 = 2
l2 = 1
for i in range(n-1):
l2 += l1
l1 = l2 - l1
print(l2)
|
s899205348
|
p03149
|
u853900545
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 145 |
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".
|
a,b,c,d = map(int,input().split())
if 'a' in '1974' and 'a' in '1974' and 'a' in '1974' and 'a' in '1974':
print('YES')
else:
print('NO')
|
s807341960
|
Accepted
| 17 | 2,940 | 117 |
a = list(map(int,input().split()))
if 1 in a and 9 in a and 7 in a and 4 in a:
print('YES')
else:
print('NO')
|
s630687791
|
p02747
|
u872657955
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 80 |
A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string.
|
S = input()
S.replace("hi","")
if S == "":
print("Yes")
else:
print("No")
|
s190549232
|
Accepted
| 17 | 3,064 | 85 |
S = input()
S = S.replace("hi","")
if S == "":
print("Yes")
else:
print("No")
|
s292627074
|
p03712
|
u970809473
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 110 |
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
|
h,w=map(int,input().split())
print('*'*(w+2))
for i in range(h):
print('*' + input() + '*')
print('*'*(w+2))
|
s332356606
|
Accepted
| 18 | 2,940 | 110 |
h,w=map(int,input().split())
print('#'*(w+2))
for i in range(h):
print('#' + input() + '#')
print('#'*(w+2))
|
s865809734
|
p03699
|
u626337957
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 119 |
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
|
N = int(input())
sum_p = 0
for _ in range(N):
sum_p += int(input())
if sum_p%10 == 0:
print(0)
else:
print(sum_p)
|
s296184766
|
Accepted
| 19 | 3,064 | 320 |
N = int(input())
nums = []
sum_n = 0
for _ in range(N):
num = int(input())
nums.append(num)
sum_n += num
if sum_n%10 != 0:
print(sum_n)
else:
nums.sort()
idx = 0
while True:
if idx >= N:
print(0)
break
ans = sum_n-nums[idx]
if ans%10 != 0:
print(ans)
break
idx += 1
|
s583962637
|
p03563
|
u597374218
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 42 |
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
|
r=int(input())
g=int(input())
print(2*g+r)
|
s705980227
|
Accepted
| 22 | 9,132 | 42 |
R=int(input())
G=int(input())
print(2*G-R)
|
s633013322
|
p03943
|
u385309449
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 103 |
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
x,y,z = map(int,input().split())
if x+y == z or y+z == x or x+z ==y:
print('YES')
else:
print('NO')
|
s649318462
|
Accepted
| 17 | 2,940 | 103 |
x,y,z = map(int,input().split())
if x+y == z or y+z == x or x+z ==y:
print('Yes')
else:
print('No')
|
s454271893
|
p03486
|
u730710086
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 107 |
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
# -*- coding: <encoding name> -*-
s = input()
t = input()
print('Yes' if sorted(s) < sorted(t) else 'No')
|
s648639904
|
Accepted
| 19 | 3,060 | 113 |
# -*- coding: <encoding name> -*-
s = input()
t = input()
print('Yes' if sorted(s) < sorted(t)[::-1] else 'No')
|
s166069905
|
p02409
|
u844704750
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,704 | 401 |
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
|
building = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for _ in range(n):
b, f, r, v = input().split(" ")
building[int(b)-1][int(f)-1][int(r)-1] += int(v)
for i, b in enumerate(building):
for f in b[::-1]:
for r in f[:-1]:
print("%d "%(r), end="")
print("%d"%(f[-1]))
if i != 3:
print ("####################")
|
s820753408
|
Accepted
| 20 | 7,752 | 366 |
building = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for _ in range(n):
b, f, r, v = input().split(" ")
building[int(b)-1][int(f)-1][int(r)-1] += int(v)
for i, b in enumerate(building):
for f in b:
for r in f:
print(" %d"%(r), end="")
print("")
if i != 3:
print ("#" * 20)
|
s679648236
|
p03386
|
u503111914
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 167 |
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
A,B,K = map(int,input().split())
if B-A <= K*2:
for i in range(A,B+1):
print(i)
else:
for i in range(A,A+K):
print(i)
for j in range(B-K,B):
print(j)
|
s783841850
|
Accepted
| 17 | 3,060 | 219 |
A,B,K = map(int,input().split())
ans = []
for i in range(A,A+K):
if i <= B:
ans.append(i)
#print(ans)
for j in range(B,B-K,-1):
#print("j",j)
if j >= A+K:
ans.append(j)
ans.sort()
for k in ans:
print(k)
|
s857854315
|
p03251
|
u124749415
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,064 | 341 |
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
Z = -100
message = 'No War'
if X < Y:
Z = X
for xi in x:
if Z < xi:
Z = xi
for yi in y:
if Z < yi:
message = 'War'
break
else:
message = 'War'
print(message)
|
s366444128
|
Accepted
| 18 | 3,060 | 415 |
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
Z = -100
message = 'No War'
if X <= Y:
Z = X+1
for xi in x:
if Z < xi:
Z = xi+1
for yi in y:
if Z <= yi:
pass
else:
message = 'War'
break
if Z > Y:
message = 'War'
else:
message = 'War'
print(message)
|
s324306162
|
p02396
|
u923668099
| 1,000 | 131,072 |
Wrong Answer
| 50 | 7,428 | 138 |
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
|
# coding: utf-8
# Here your code !
import sys
i = 1
for line in sys.stdin:
print("Case " + str(i) + ": " + line.rstrip())
i += 1
|
s067861760
|
Accepted
| 70 | 7,764 | 167 |
from sys import stdin
for test_case in range(10**4 + 2):
x = int(stdin.readline())
if not x:
break
print('Case {}: {}'.format(test_case + 1, x))
|
s237062054
|
p03438
|
u667084803
| 2,000 | 262,144 |
Wrong Answer
| 25 | 4,596 | 232 |
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.
|
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
count = - sum(A) + sum(B)
for i in range(N):
inv = max(0, A[i] - B[i])
if count >= 0 and inv <= count:
print("YES")
else :
print("NO")
|
s276009208
|
Accepted
| 32 | 4,596 | 341 |
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
count = - sum(A) + sum(B)
inv = 0
for i in range(N):
inv += max(0, A[i] - B[i])
inv2 = 0
for i in range(N):
inv2 += max(0, (B[i] - A[i]+1)//2)
if count >= 0 and inv <= count and inv2 <= count:
print("Yes")
else :
print("No")
|
s976214123
|
p03150
|
u455957433
| 2,000 | 1,048,576 |
Wrong Answer
| 20 | 3,188 | 380 |
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
|
import re
def main():
N = str(input())
if re.match("^.*keyence$", N) or re.match("^k.*eyence$", N) or re.match("^ke.*yence$", N) or re.match("^key.*ence$", N) or re.match("^keye.*nce$", N) or re.match("^keyen.*ce$", N) or re.match("^keyenc.*e$", N) or re.match("^keyence.*$", N):
print("Yes")
else:
print("No")
if __name__ == "__main__":
main()
|
s435149564
|
Accepted
| 20 | 3,188 | 380 |
import re
def main():
N = str(input())
if re.match("^.*keyence$", N) or re.match("^k.*eyence$", N) or re.match("^ke.*yence$", N) or re.match("^key.*ence$", N) or re.match("^keye.*nce$", N) or re.match("^keyen.*ce$", N) or re.match("^keyenc.*e$", N) or re.match("^keyence.*$", N):
print("YES")
else:
print("NO")
if __name__ == "__main__":
main()
|
s700068260
|
p03946
|
u825685913
| 2,000 | 262,144 |
Wrong Answer
| 99 | 20,372 | 267 |
There are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples. Takahashi will begin the travel at town 1, with no apple in his possession. The actions that can be performed during the travel are as follows: * _Move_ : When at town i (i < N), move to town i + 1. * _Merchandise_ : Buy or sell an arbitrary number of apples at the current town. Here, it is assumed that one apple can always be bought and sold for A_i yen (the currency of Japan) at town i (1 ≦ i ≦ N), where A_i are distinct integers. Also, you can assume that he has an infinite supply of money. For some reason, there is a constraint on merchandising apple during the travel: the sum of the number of apples bought and the number of apples sold during the whole travel, must be at most T. (Note that a single apple can be counted in both.) During the travel, Takahashi will perform actions so that the _profit_ of the travel is maximized. Here, the profit of the travel is the amount of money that is gained by selling apples, minus the amount of money that is spent on buying apples. Note that we are not interested in apples in his possession at the end of the travel. Aoki, a business rival of Takahashi, wants to trouble Takahashi by manipulating the market price of apples. Prior to the beginning of Takahashi's travel, Aoki can change A_i into another arbitrary non-negative integer A_i' for any town i, any number of times. The cost of performing this operation is |A_i - A_i'|. After performing this operation, different towns may have equal values of A_i. Aoki's objective is to decrease Takahashi's expected profit by at least 1 yen. Find the minimum total cost to achieve it. You may assume that Takahashi's expected profit is initially at least 1 yen.
|
n, t = map(int, input().split())
a = list(map(int, input().split()))
count = 0
l = []
max = 0
min = a[0]
for i in range(1,n):
if a[i] < min:
min = a[i]
if a[i] - min > max:
max = a[i] - min
l.append(a[i] - min)
print(l)
print(l.count(max))
|
s991298648
|
Accepted
| 88 | 20,408 | 258 |
n, t = map(int, input().split())
a = list(map(int, input().split()))
count = 0
l = []
max = 0
min = a[0]
for i in range(1,n):
if a[i] < min:
min = a[i]
if a[i] - min > max:
max = a[i] - min
l.append(a[i] - min)
print(l.count(max))
|
s342474310
|
p03862
|
u677121387
| 2,000 | 262,144 |
Wrong Answer
| 131 | 14,252 | 202 |
There are N boxes arranged in a row. Initially, the i-th box from the left contains a_i candies. Snuke can perform the following operation any number of times: * Choose a box containing at least one candy, and eat one of the candies in the chosen box. His objective is as follows: * Any two neighboring boxes contain at most x candies in total. Find the minimum number of operations required to achieve the objective.
|
n,x = map(int,input().split())
a = [int(i) for i in input().split()]
ans = 0
for i in range(n-1):
if a[i] + a[i+1] <= x: continue
a[i+1] = max(0,a[i+1]-x)
ans += a[i] + a[i+1] - x
print(ans)
|
s216656731
|
Accepted
| 127 | 14,540 | 202 |
n,x = map(int,input().split())
a = [int(i) for i in input().split()]
ans = 0
for i in range(n-1):
if a[i] + a[i+1] <= x: continue
ans += a[i] + a[i+1] - x
a[i+1] = max(0,x - a[i])
print(ans)
|
s494651139
|
p02612
|
u245960901
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 8,992 | 52 |
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.
|
s = list(map(int, input().split()))
print(s[0]%1000)
|
s934062977
|
Accepted
| 33 | 9,000 | 110 |
s = list(map(int, input().split()))
a=int(s[0]/1000) if s[0]%1000==0 else int(s[0]/1000)+1
print(1000*a-s[0])
|
s408589231
|
p03623
|
u113971909
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 96 |
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
x,a,b=map(int,input().split())
A = abs(x-a)
B = abs(x-b)
if A>B:
print("A")
else:
print("B")
|
s962511649
|
Accepted
| 17 | 2,940 | 97 |
x,a,b=map(int,input().split())
A = abs(x-a)
B = abs(x-b)
if A<B:
print("A")
else:
print("B")
|
s452468801
|
p02614
|
u580697892
| 1,000 | 1,048,576 |
Wrong Answer
| 63 | 9,196 | 400 |
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
|
#coding: utf-8
H, W, K = map(int, input().split())
g = [list(input()) for _ in range(H)]
print(*g, sep="\n")
ans = 0
for h in range(2**H):
for w in range(2**W):
cnt = 0
for i in range(H):
for j in range(W):
if (h >> i) & 1 == 0 and (w >> j) & 1 == 0 and g[i][j] == "#":
cnt += 1
if cnt == K:
ans += 1
print(ans)
|
s104005592
|
Accepted
| 64 | 9,196 | 402 |
#coding: utf-8
H, W, K = map(int, input().split())
g = [list(input()) for _ in range(H)]
# print(*g, sep="\n")
ans = 0
for h in range(2**H):
for w in range(2**W):
cnt = 0
for i in range(H):
for j in range(W):
if (h >> i) & 1 == 0 and (w >> j) & 1 == 0 and g[i][j] == "#":
cnt += 1
if cnt == K:
ans += 1
print(ans)
|
s996969088
|
p02612
|
u571867512
| 2,000 | 1,048,576 |
Wrong Answer
| 30 | 9,132 | 34 |
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)
|
s786735885
|
Accepted
| 28 | 9,140 | 84 |
N = int(input())
money = 1000
while money < N:
money += 1000
print(money - N)
|
s631320654
|
p03415
|
u695079172
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 58 |
We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.
|
_ = input()
_ = input()
answer = input()
print(answer[-1])
|
s255118322
|
Accepted
| 17 | 2,940 | 60 |
a = input()[0]
b = input()[1]
c = input()[2]
print(a+b+c)
|
s845453517
|
p03644
|
u078349616
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 91 |
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())
i = 1
for i in range(1, 7+1):
if pow(2, i) > N:
print(pow(2, i - 1))
|
s415825565
|
Accepted
| 17 | 2,940 | 102 |
N = int(input())
i = 1
for i in range(1, 7+1):
if pow(2, i) > N:
print(pow(2, i - 1))
exit()
|
s939496759
|
p03796
|
u825842302
| 2,000 | 262,144 |
Wrong Answer
| 29 | 2,940 | 88 |
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.
|
n = int(input())
ans = 1
for i in range(1,n+1):
ans = 1*i
print(ans%100000007)
|
s105115282
|
Accepted
| 42 | 2,940 | 100 |
n = int(input())
ans = 1
for i in range(1,n+1):
ans = ans*i
ans = ans%1000000007
print(ans)
|
s670720292
|
p03485
|
u358791207
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 75 |
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())
c = (a + b) / 2 + ((a + b) % 2)
print(c)
|
s565043379
|
Accepted
| 17 | 2,940 | 76 |
a, b = map(int, input().split())
c = (a + b) // 2 + ((a + b) % 2)
print(c)
|
s128176022
|
p03680
|
u846150137
| 2,000 | 262,144 |
Wrong Answer
| 272 | 13,212 | 204 |
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.
|
n=int(input())
a=[]
for _ in range(n):
a += [int(input())-1]
s=set()
i=0
n=0
while True:
n+=1
i = a[i]
if i==1:
break
elif i in s:
print(-1)
break
else:
s|={i}
else:
print(n)
|
s265495561
|
Accepted
| 210 | 13,248 | 196 |
n=int(input())
a=[int(input())-1 for _ in range(n)]
s=set()
i=0
n=0
while True:
n += 1
i = a[i]
if i==1:
print(n)
break
elif i in s:
print(-1)
break
else:
s|={i}
|
s278546927
|
p03501
|
u019584841
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 76 |
You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours.
|
t,a,b=map(int,input().split())
if t*a > b:
print(t*a)
else:
print(b)
|
s500113996
|
Accepted
| 17 | 2,940 | 77 |
t,a,b=map(int,input().split())
if t*a < b:
print(t*a)
else:
print(b)
|
s303037115
|
p03502
|
u046592970
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 132 |
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
|
n = list(map(int,input()))
y = int("".join(map(str,n)))
if y % sum(n) == 0:
print("Yes")
else:
print("No")
print(y,sum(n),n)
|
s295797965
|
Accepted
| 17 | 2,940 | 115 |
n = list(map(int,input()))
y = int("".join(map(str,n)))
if y % sum(n) == 0:
print("Yes")
else:
print("No")
|
s576372938
|
p02613
|
u621596556
| 2,000 | 1,048,576 |
Wrong Answer
| 173 | 15,904 | 319 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
n = int(input())
a = ["AC"] * n
c = [0]*4
for i in range(n):
a[i] = input()
if(a[i]=="AC"):
c[0] += 1
if(a[i]=="WA"):
c[1] += 1
if(a[i]=="TLE"):
c[2] += 1
if(a[i]=="RE"):
c[3] += 1
print("AC × " +str(c[0]))
print("WA × " +str(c[1]))
print("TLE × " +str(c[2]))
print("RE × " +str(c[3]))
|
s294736460
|
Accepted
| 169 | 16,016 | 315 |
n = int(input())
a = ["AC"] * n
c = [0]*4
for i in range(n):
a[i] = input()
if(a[i]=="AC"):
c[0] += 1
if(a[i]=="WA"):
c[1] += 1
if(a[i]=="TLE"):
c[2] += 1
if(a[i]=="RE"):
c[3] += 1
print("AC x " +str(c[0]))
print("WA x " +str(c[1]))
print("TLE x " +str(c[2]))
print("RE x " +str(c[3]))
|
s415210996
|
p02678
|
u303039933
| 2,000 | 1,048,576 |
Wrong Answer
| 1,255 | 40,448 | 2,721 |
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *
class Scanner():
@staticmethod
def int():
return int(sys.stdin.readline().rstrip())
@staticmethod
def string():
return sys.stdin.readline().rstrip()
@staticmethod
def map_int():
return [int(x) for x in Scanner.string().split()]
@staticmethod
def string_list(n):
return [Scanner.string() for i in range(n)]
@staticmethod
def int_list_list(n):
return [Scanner.map_int() for i in range(n)]
@staticmethod
def int_cols_list(n):
return [Scanner.int() for i in range(n)]
class Math():
@staticmethod
def gcd(a, b):
if b == 0:
return a
return Math.gcd(b, a % b)
@staticmethod
def lcm(a, b):
return (a * b) // Math.gcd(a, b)
@staticmethod
def divisor(n):
res = []
i = 1
for i in range(1, int(n ** 0.5) + 1):
if n % i == 0:
res.append(i)
if i != n // i:
res.append(n // i)
return res
@staticmethod
def round_up(a, b):
return -(-a // b)
@staticmethod
def is_prime(n):
if n < 2:
return False
if n == 2:
return True
if n % 2 == 0:
return False
d = int(n ** 0.5) + 1
for i in range(3, d + 1, 2):
if n % i == 0:
return False
return True
def pop_count(x):
x = x - ((x >> 1) & 0x5555555555555555)
x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
x = x + (x >> 8)
x = x + (x >> 16)
x = x + (x >> 32)
return x & 0x0000007f
MOD = int(1e09) + 7
INF = int(1e15)
def solve():
N, M = Scanner.map_int()
G = [[] for _ in range(N)]
for _ in range(M):
a, b = Scanner.map_int()
a -= 1
b -= 1
G[a].append(b)
G[b].append(a)
print(G)
q = []
q.append(0)
ans = [-1 for _ in range(N)]
visited = [False for _ in range(N)]
visited[0] = True
while q != []:
p = q.pop(0)
for g in G[p]:
if visited[g]:
continue
visited[g] = True
ans[g] = p
q.append(g)
ans = [a + 1 for a in ans]
print('Yes')
print(*ans[1:], sep='\n')
def main():
solve()
if __name__ == "__main__":
main()
|
s642764545
|
Accepted
| 1,092 | 40,748 | 2,708 |
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *
class Scanner():
@staticmethod
def int():
return int(sys.stdin.readline().rstrip())
@staticmethod
def string():
return sys.stdin.readline().rstrip()
@staticmethod
def map_int():
return [int(x) for x in Scanner.string().split()]
@staticmethod
def string_list(n):
return [Scanner.string() for i in range(n)]
@staticmethod
def int_list_list(n):
return [Scanner.map_int() for i in range(n)]
@staticmethod
def int_cols_list(n):
return [Scanner.int() for i in range(n)]
class Math():
@staticmethod
def gcd(a, b):
if b == 0:
return a
return Math.gcd(b, a % b)
@staticmethod
def lcm(a, b):
return (a * b) // Math.gcd(a, b)
@staticmethod
def divisor(n):
res = []
i = 1
for i in range(1, int(n ** 0.5) + 1):
if n % i == 0:
res.append(i)
if i != n // i:
res.append(n // i)
return res
@staticmethod
def round_up(a, b):
return -(-a // b)
@staticmethod
def is_prime(n):
if n < 2:
return False
if n == 2:
return True
if n % 2 == 0:
return False
d = int(n ** 0.5) + 1
for i in range(3, d + 1, 2):
if n % i == 0:
return False
return True
def pop_count(x):
x = x - ((x >> 1) & 0x5555555555555555)
x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
x = x + (x >> 8)
x = x + (x >> 16)
x = x + (x >> 32)
return x & 0x0000007f
MOD = int(1e09) + 7
INF = int(1e15)
def solve():
N, M = Scanner.map_int()
G = [[] for _ in range(N)]
for _ in range(M):
a, b = Scanner.map_int()
a -= 1
b -= 1
G[a].append(b)
G[b].append(a)
q = []
q.append(0)
ans = [-1 for _ in range(N)]
visited = [False for _ in range(N)]
visited[0] = True
while q != []:
p = q.pop(0)
for g in G[p]:
if visited[g]:
continue
visited[g] = True
ans[g] = p
q.append(g)
ans = [a + 1 for a in ans]
print('Yes')
print(*ans[1:], sep='\n')
def main():
solve()
if __name__ == "__main__":
main()
|
s826072594
|
p03370
|
u294385082
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 182 |
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
|
n,x = map(int,input().split())
m = sorted([int(input()) for i in range(n)])
newx = x - sum(m)
c = n
for i in m:
newx -= i
c +=1
if newx < x - sum(m):
break
print(c-1)
|
s783537646
|
Accepted
| 17 | 2,940 | 121 |
n,x = map(int,input().split())
m = sorted([int(input()) for i in range(n)])
newx = x - sum(m)
a = newx//m[0]
print(n+a)
|
s569927010
|
p03658
|
u123756661
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 73 |
Snuke has N sticks. The length of the i-th stick is l_i. Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy.
|
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
l.sort()
|
s553366280
|
Accepted
| 18 | 2,940 | 92 |
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
l.sort()
print(sum(l[-k:]))
|
s359638226
|
p03997
|
u423193302
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 68 |
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)
|
s294293878
|
Accepted
| 17 | 2,940 | 73 |
a = int(input())
b = int(input())
h = int(input())
print(int((a+b)*h/2))
|
s047639418
|
p03494
|
u215341636
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 202 |
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.
|
import math
n = int(input())
a = list(map(int , input().strip().split()))
ans = 1000000000000
for i in a:
print(math.floor(math.log(i , 2)))
ans = min(ans , math.floor(math.log(i , 2)))
print(ans)
|
s276587495
|
Accepted
| 17 | 2,940 | 150 |
N = int(input())
A = map(int, input().split())
ans = float("inf")
for i in A:
ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))
|
s000991702
|
p03578
|
u641406334
| 2,000 | 262,144 |
Wrong Answer
| 267 | 57,048 | 330 |
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.
|
from collections import Counter as c
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
flag = True
d_c = c(d)
t_c = c(t)
if n<m: flag = False
else:
for i,j in t_c.items():
if d_c[i] < j:
flag = False
break
print('Yes' if flag else 'No')
|
s649162501
|
Accepted
| 277 | 57,048 | 330 |
from collections import Counter as c
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
flag = True
d_c = c(d)
t_c = c(t)
if n<m: flag = False
else:
for i,j in t_c.items():
if d_c[i] < j:
flag = False
break
print('YES' if flag else 'NO')
|
s951316256
|
p03997
|
u936050991
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 68 |
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)
|
s474466028
|
Accepted
| 17 | 2,940 | 73 |
a = int(input())
b = int(input())
h = int(input())
print(int((a+b)*h/2))
|
s693498215
|
p03160
|
u287500079
| 2,000 | 1,048,576 |
Wrong Answer
| 150 | 13,780 | 265 |
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
n = int(input())
h = [int(i) for i in input().split()]
dp = [0 for _ in range(n + 1)]
dp[0] = 0
for i in range(1, n):
dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print(dp[n - 1])
|
s969498034
|
Accepted
| 132 | 13,928 | 247 |
n = int(input())
h = [int(i) for i in input().split()]
dp = [0 for _ in range(n + 1)]
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print(dp[n - 1])
|
s832905858
|
p02399
|
u732614538
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,644 | 77 |
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
a,b = [int(i) for i in input().split()]
d = a//b
r = a%b
f = a/b
print(d,r,f)
|
s201109050
|
Accepted
| 30 | 7,588 | 103 |
a,b = [int(i) for i in input().split()]
d = a//b
r = a%b
f = a/b
print('{0} {1} {2:.5f}'.format(d,r,f))
|
s229832242
|
p03024
|
u825981710
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 101 |
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
|
S=input()
a=S.count('○')
b=S.count('✕')
if((15-b+a)>=8):
print("Yes")
else:
print("No")
|
s759254894
|
Accepted
| 17 | 2,940 | 81 |
S=input()
b=S.count('x')
if((15-b)>=8):
print("YES")
else:
print("NO")
|
s527745247
|
p03854
|
u432042540
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,188 | 370 |
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()
t = ['dream', 'dreamer', 'erase', 'eraser']
tmp = s
while tmp != '':
d = tmp[0:4] == t[0]
dr = tmp[0:6] == t[1]
e = tmp[0:4] == t[2]
er = tmp[0:5] == t[3]
if dr:
tmp = tmp[7:]
elif er:
tmp = tmp[6:]
elif d or e:
tmp = tmp[5:]
else:
print('NO')
break
if tmp == '':
print('YES')
|
s375516516
|
Accepted
| 72 | 3,316 | 528 |
s = input()
s = s[::-1]
# t[i] = t[i][::-1]
# print(s,t)
tmp = s
while tmp != '':
d = tmp[:5] == 'maerd'
dr = tmp[:7] == 'remaerd'
e = tmp[:5] == 'esare'
er = tmp[:6] == 'resare'
# print(tmp[:5])
# print(d,dr,e,er)
if d:
tmp = tmp[5:]
elif e:
tmp = tmp[5:]
elif dr:
tmp = tmp[7:]
elif er:
tmp = tmp[6:]
else:
print('NO')
break
if tmp == '':
print('YES')
|
s669469560
|
p02400
|
u483716678
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,588 | 82 |
Write a program which calculates the area and circumference of a circle for given radius r.
|
r = float(input())
phi = float(22/7)
pw = float(pow(r,r))
print('%f'%(pw * phi))
|
s597023693
|
Accepted
| 20 | 5,624 | 80 |
import math
r = float(input())
print('%.6f %.6f'%(math.pi*r*r,2.0*math.pi*r))
|
s574276234
|
p03730
|
u852790844
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 119 |
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())
for i in range(1,b+1):
if a*i%b == c:
print('YES')
else:
print('NO')
|
s113660924
|
Accepted
| 17 | 2,940 | 135 |
a, b, c = map(int,input().split())
for i in range(1,b+1):
if a*i % b == c:
print('YES')
break
else:
print('NO')
|
s009358080
|
p03474
|
u663014688
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 195 |
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
|
s = input()
ans = []
for i in range(len(s)):
if s[i] == '0':
ans.append('0')
if s[i] == '1':
ans.append('1')
if s[i] == 'B':
ans.pop(-1)
print(''.join(ans))
|
s817685178
|
Accepted
| 17 | 3,060 | 209 |
A,B = map(int, input().split())
S = input()
left = S[:A]
right = S[A+1:]
if S[A] == '-':
if left.isdecimal() and right.isdecimal():
print('Yes')
else:
print('No')
else:
print('No')
|
s372343644
|
p03699
|
u960653324
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 319 |
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
|
N = int(input())
S = [int(input()) for i in range(N)]
ans = sum(S)
new_S = []
for i in range(len(S)):
if S[i]%10 == 0:
new_S.append([S[i],0])
else:
new_S.append([S[i],S[i]])
mod_S = sorted(new_S, key=lambda x: (x[1]))
for s in mod_S:
if ans%10 == 0:
ans = ans - s[0]
else:
break
print(ans)
|
s499098057
|
Accepted
| 18 | 3,060 | 197 |
N = int(input())
S = [int(input()) for i in range(N)]
ans = sum(S)
S.sort()
for s in S:
if ans%10 == 0 and s%10 != 0:
ans = ans - s
break
if ans%10 != 0:
print(ans)
else:
print(0)
|
s875129403
|
p03351
|
u866949333
| 2,000 | 1,048,576 |
Wrong Answer
| 20 | 3,060 | 173 |
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
a, b, c, d = map(int, input().split())
print(a,b,c,d)
if abs(a - c) <= d:
print('Yes')
elif abs(a - b) <= d and abs(b - c) <= d:
print('Yes')
else:
print('No')
|
s850840733
|
Accepted
| 18 | 2,940 | 157 |
a, b, c, d = map(int, input().split())
if abs(a - c) <= d:
print('Yes')
elif abs(a - b) <= d and abs(b - c) <= d:
print('Yes')
else:
print('No')
|
s022687074
|
p03997
|
u474423089
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 136 |
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)
if __name__ == '__main__':
main()
|
s353297195
|
Accepted
| 17 | 2,940 | 139 |
def main():
a = int(input())
b = int(input())
h = int(input())
print(int((a+b)*h/2))
if __name__ == '__main__':
main()
|
s148557534
|
p03854
|
u145410317
| 2,000 | 262,144 |
Wrong Answer
| 91 | 3,188 | 722 |
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()
dream = "dream"
dreamer = "dreamer"
erase = "erase"
eraser = "eraser"
while True:
if S.find(dream, len(S) - len(dream), len(S)) == len(S) - len(dream):
S = S[:len(S) - len(dream)]
continue
elif S.find(dreamer, len(S) - len(dreamer), len(S)) == len(S) - len(dreamer):
S = S[:len(S) - len(dreamer)]
continue
elif S.find(erase, len(S) - len(erase), len(S)) == len(S) - len(erase):
S = S[:len(S) - len(erase)]
continue
elif S.find(eraser, len(S) - len(eraser), len(S)) == len(S) - len(eraser):
S = S[:len(S) - len(eraser)]
continue
elif len(S) == 0:
print("Yes")
break
else:
print("No")
break
|
s993178620
|
Accepted
| 90 | 3,188 | 723 |
S = input()
dream = "dream"
dreamer = "dreamer"
erase = "erase"
eraser = "eraser"
while True:
if S.find(dream, len(S) - len(dream), len(S)) == len(S) - len(dream):
S = S[:len(S) - len(dream)]
continue
elif S.find(dreamer, len(S) - len(dreamer), len(S)) == len(S) - len(dreamer):
S = S[:len(S) - len(dreamer)]
continue
elif S.find(erase, len(S) - len(erase), len(S)) == len(S) - len(erase):
S = S[:len(S) - len(erase)]
continue
elif S.find(eraser, len(S) - len(eraser), len(S)) == len(S) - len(eraser):
S = S[:len(S) - len(eraser)]
continue
elif len(S) == 0:
print("YES")
break
else:
print("NO")
break
|
s310767977
|
p02265
|
u510829608
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,688 | 293 |
Your task is to implement a double linked list. Write a program which performs the following operations: * insert x: insert an element with key x into the front of the list. * delete x: delete the first element which has the key of x from the list. If there is not such element, you need not do anything. * deleteFirst: delete the first element from the list. * deleteLast: delete the last element from the list.
|
n = int(input())
li = []
for i in range(n):
command = input().split()
if command[0] == 'insert':
li.insert(0, command[1])
elif command[0] == 'delete':
li.remove(command[1])
elif command[0] == 'deleteFirst':
li.pop(0)
else:
li.pop()
print(li)
|
s813510626
|
Accepted
| 1,580 | 214,440 | 432 |
from collections import deque
import sys
dq = deque()
num = int(sys.stdin.readline())
line = sys.stdin.readlines()
for i in range(num):
order = line[i].split()
if order[0] == 'insert':
dq.appendleft(order[1])
elif order[0] == 'deleteFirst':
dq.popleft()
elif order[0] == 'deleteLast':
dq.pop()
else:
if order[1] in dq:
dq.remove(order[1])
print(' '.join(dq))
|
s423758059
|
p02261
|
u921038488
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,604 | 1,042 |
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
|
def show(array):
for i in range(len(array)):
if (i+1) >= len(array):
print(array[i])
else:
print(array[i], end=' ')
def bubble_sort(c, n):
for i in range(0, n):
for j in range(n-1, i, -1):
if c[j][1:] < c[j-1][1:]:
c[j], c[j-1] = c[j-1], c[j]
return c
def selection_sort(c, n):
for i in range(0, n):
minj = i
for j in range(i+1, n):
if c[j][1:] < c[minj][1:]:
minj = j
c[i], c[minj] = c[minj], c[i]
return c
def main():
N = int(input())
cards = list(input().split(' '))
cards2 = cards.copy()
bubble_result = bubble_sort(cards, N)
print(cards2)
selection_result = selection_sort(cards2, N)
show(bubble_result)
print('Stable')
show(selection_result)
if bubble_result == selection_result:
print('Stable')
else:
print('Not stable')
main()
|
s777340623
|
Accepted
| 20 | 5,616 | 1,024 |
def show(array):
for i in range(len(array)):
if (i+1) >= len(array):
print(array[i])
else:
print(array[i], end=' ')
def bubble_sort(c, n):
for i in range(0, n):
for j in range(n-1, i, -1):
if c[j][1:] < c[j-1][1:]:
c[j], c[j-1] = c[j-1], c[j]
return c
def selection_sort(c, n):
for i in range(0, n):
minj = i
for j in range(i+1, n):
if c[j][1:] < c[minj][1:]:
minj = j
c[i], c[minj] = c[minj], c[i]
return c
def main():
N = int(input())
cards = list(input().split(' '))
cards2 = cards.copy()
bubble_result = bubble_sort(cards, N)
selection_result = selection_sort(cards2, N)
show(bubble_result)
print('Stable')
show(selection_result)
if bubble_result == selection_result:
print('Stable')
else:
print('Not stable')
main()
|
s813099814
|
p02392
|
u532590372
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,588 | 189 |
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".
|
if __name__ == '__main__':
x = input().split(' ')
a = int(x[0])
b = int(x[1])
c = int(x[2])
if a > b and b > c:
print('Yes')
else:
print('No')
|
s218015236
|
Accepted
| 20 | 5,596 | 189 |
if __name__ == '__main__':
x = input().split(' ')
a = int(x[0])
b = int(x[1])
c = int(x[2])
if a < b and b < c:
print('Yes')
else:
print('No')
|
s088476625
|
p02831
|
u744115306
| 2,000 | 1,048,576 |
Wrong Answer
| 2,108 | 2,940 | 169 |
Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted. We assume that a piece cannot be divided and distributed to multiple guests.
|
a,b = map(int,input().split())
c = a*b
d = 1
ans = 0
for i in range(1,c+1):
if d//a == 0 and d//b ==0:
ans = d
else:
d = d+1
print(ans)
|
s715297764
|
Accepted
| 17 | 2,940 | 191 |
a,b = map(int,input().split())
def gcd(a,b):#a<=b
while a != 0:
a,b = b%a,a
return b
def lcm(a,b):
return a*b // gcd(a,b)
print(lcm(a,b))
|
s075196116
|
p03623
|
u594803920
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 91 |
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
x, a, b = map(int, input().split())
if abs(x-a) > abs(x-b):
print('A')
else:
print('B')
|
s772638640
|
Accepted
| 17 | 2,940 | 92 |
x, a, b = map(int, input().split())
if abs(x-a) < abs(x-b):
print('A')
else:
print('B')
|
s237103171
|
p03997
|
u540290227
| 2,000 | 262,144 |
Wrong Answer
| 16 | 2,940 | 68 |
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)
|
s951013603
|
Accepted
| 17 | 2,940 | 69 |
a = int(input())
b = int(input())
h = int(input())
print((a+b)*h//2)
|
s829200414
|
p03545
|
u863076295
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 571 |
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
x=list(map(int,list(input())))
a=x[0]
b=x[1]
c=x[2]
d=x[3]
if a+b+c+d==7: print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d))
elif a-b+c+d==7: print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d))
elif a+b+c-d==7: print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d))
elif a-b+c-d==7: print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d))
elif a+b-c+d==7: print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d))
elif a-b-c+d==7: print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d))
elif a+b-c-d==7: print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d))
elif a-b-c-d==7: print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d))
|
s900930509
|
Accepted
| 18 | 3,064 | 611 |
x=list(map(int,list(input())))
a=x[0]
b=x[1]
c=x[2]
d=x[3]
if a+b+c+d==7: print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif a-b+c+d==7: print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif a+b+c-d==7: print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif a-b+c-d==7: print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif a+b-c+d==7: print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif a-b-c+d==7: print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif a+b-c-d==7: print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
elif a-b-c-d==7: print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
|
s644219445
|
p03471
|
u586639900
| 2,000 | 262,144 |
Wrong Answer
| 959 | 3,060 | 305 |
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
N, Y = map(int, input().split())
Y = Y/1000
flag = False
for x in range(N+1):
for y in range(N+1-x):
sum_ = 10 * x + 5 * y + (N-x-y)
if sum_ == Y:
print(x, y, N-x-y)
flag = True
if flag == False:
print(-1, -1, -1)
|
s834749094
|
Accepted
| 1,011 | 3,064 | 312 |
N, Y = map(int, input().split())
Y = Y/1000
flag = False
i = -1
j = -1
k = -1
for x in range(N+1):
for y in range(N+1-x):
sum_ = 10 * x + 5 * y + (N-x-y)
if sum_ == Y:
i = x
j = y
k = N - x - y
print(i, j , k)
|
s492299428
|
p03556
|
u113255362
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,040 | 96 |
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
|
N = int(input())
res = 0
for i in range(32000):
if i*i > N:
res = i-1
break
print(res)
|
s331959348
|
Accepted
| 28 | 9,048 | 104 |
N = int(input())
res = 0
for i in range(32000):
if i*i > N:
res = (i-1)*(i-1)
break
print(res)
|
s498901338
|
p03471
|
u925593325
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 3,060 | 334 |
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
N, Y = map(int, input().split())
exist = 0
for m_x in range(N+1):
for m_y in range(N - m_x + 1):
for m_z in range(N - m_x - m_y + 1):
N = m_x + m_y + m_z
if Y == 10000 * m_x + 5000 * m_y + 1000 * m_z:
exist += 1
if exist == 0:
print(-1, -1, -1)
else:
print(m_x, m_y, m_z)
|
s253235462
|
Accepted
| 997 | 3,060 | 402 |
N, Y = map(int, input().split())
m_x, m_y, m_z = (-1, -1, -1)
for x in range(Y // 10000 + 1):
for y in range(N - x + 1):
z = N - x - y
total = 10000 * x + 5000 * y + 1000 * z
if total == Y:
m_x, m_y, m_z = (x, y, z)
break
else:
if total > Y:
break
else:
continue
print(m_x, m_y, m_z)
|
s097407875
|
p03469
|
u125205981
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 96 |
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.
|
def main():
N = input()
d = N.split('/')
print('2018', d[1], d[1], sep='/')
main()
|
s894433252
|
Accepted
| 18 | 2,940 | 96 |
def main():
N = input()
d = N.split('/')
print('2018', d[1], d[2], sep='/')
main()
|
s064204429
|
p02613
|
u765758367
| 2,000 | 1,048,576 |
Wrong Answer
| 170 | 16,420 | 367 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
N = int(input())
AC =[]
WA =[]
TLE =[]
RE =[]
for i in range(N):
s = str(input())
if s == "AC":
AC.append(s)
elif s == "WA":
WA.append(s)
elif s == "TLE":
TLE.append(s)
elif s =="RE":
RE.append(s)
print("AC × "+str(len(AC)))
print("WA × "+str(len(WA)))
print("TLE × "+str(len(TLE)))
print("RE × "+str(len(RE)))
|
s276908423
|
Accepted
| 178 | 16,576 | 364 |
N = int(input())
AC =[]
WA =[]
TLE =[]
RE =[]
for i in range(N):
s = str(input())
if s == "AC":
AC.append(s)
elif s == "WA":
WA.append(s)
elif s == "TLE":
TLE.append(s)
elif s =="RE":
RE.append(s)
print("AC x "+str(len(AC)))
print("WA x "+str(len(WA)))
print("TLE x "+str(len(TLE)))
print("RE x "+str(len(RE)))
|
s462391475
|
p02694
|
u646110634
| 2,000 | 1,048,576 |
Wrong Answer
| 34 | 9,740 | 133 |
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?
|
from decimal import Decimal
X = int(input())
save = 100
ans = 0
while save <= X :
save = int(save * 1.01)
ans += 1
print(ans)
|
s184492819
|
Accepted
| 21 | 9,092 | 104 |
X = int(input())
save = 100
ans = 0
while save < X :
save = int(save * 1.01)
ans += 1
print(ans)
|
s585388663
|
p03455
|
u741144749
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 91 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a,b = map(int, input().split())
if((a*b)%2 == 0):
print('Odd')
else:
print('Even')
|
s766943321
|
Accepted
| 17 | 2,940 | 91 |
a,b = map(int, input().split())
if((a*b)%2 == 0):
print('Even')
else:
print('Odd')
|
s100690666
|
p03486
|
u519939795
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 83 |
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
a = str(input())
b = str(input())
if a < b:
print('Yes')
else:
print('No')
|
s632656802
|
Accepted
| 17 | 2,940 | 77 |
s = sorted(input())
t = sorted(input())[::-1]
print("Yes" if s < t else "No")
|
s793410623
|
p04043
|
u051237313
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,016 | 132 |
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.
|
list = list(input().split())
list.sort()
if list[0] == 5 and list[1] == 5 and list[7] == 7:
print('Yes')
else:
print('No')
|
s086186286
|
Accepted
| 25 | 9,076 | 198 |
list = list(map(int, input().split()))
list.sort()
if list[0] == 5 and list[1] == 5 and list[2] == 7:
print('YES')
else:
print('NO')
|
s339495476
|
p00007
|
u328199937
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,660 | 151 |
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week. Write a program which computes the amount of the debt in n weeks.
|
import math
n = int(input())
print(n)
money = int(100)
for i in range(n):
money *= 1.05
money = math.ceil(money)
print(int(money) * 1000)
|
s580484311
|
Accepted
| 20 | 5,668 | 131 |
import math
money = int(100)
for i in range(int(input())):
money *= 1.05
money = math.ceil(money)
print(int(money) * 1000)
|
s190731963
|
p03574
|
u020373088
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,064 | 445 |
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
|
h, w = map(int, input().split())
s = ["a"*(w+2)] + ["a" + input() + "a" for i in range(h)] + ["a"*(w+2)]
ans = []
for i in range(1, h+1):
for j in range(1, w+1):
if s[i][j] == "#":
ans.append("#")
else:
c = [s[i-1][j-1], s[i-1][j], s[i-1][j+1], s[i][j-1], s[i][j+1], s[i+1][j-1], s[i+1][j], s[i+1][j+1]]
ans.append(c.count("#"))
print(ans)
for i in range(h):
print("".join(list(map(str, ans[i*w:(i+1)*w]))))
|
s967831477
|
Accepted
| 21 | 3,188 | 392 |
h, w = map(int, input().split())
s = [["a"]*(w+2)] + [["a"] + list(input()) + ["a"] for i in range(h)] + [["a"]*(w+2)]
for i in range(1, h+1):
for j in range(1, w+1):
if s[i][j] != "#":
c = [s[i-1][j-1], s[i-1][j], s[i-1][j+1], s[i][j-1], s[i][j+1], s[i+1][j-1], s[i+1][j], s[i+1][j+1]]
s[i][j] = str(c.count("#"))
for i in range(1,h+1):
print("".join(s[i][1:-1]))
|
s788422385
|
p00444
|
u404942781
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,724 | 162 |
太郎君はよくJOI雑貨店で買い物をする. JOI雑貨店には硬貨は500円,100円,50円,10円,5円,1円が十分な数だけあり,いつも最も枚数が少なくなるようなおつりの支払い方をする.太郎君がJOI雑貨店で買い物をしてレジで1000円札を1枚出した時,もらうおつりに含まれる硬貨の枚数を求めるプログラムを作成せよ. 例えば入力例1の場合は下の図に示すように,4を出力しなければならない.
|
#!/usr/bin/env python
#coding:utf-8
coin = [500,100,50,10,5,1]
oturi = 1000 - int(input())
ret = 0
for c in coin:
ret += oturi // c
oturi %= c
print(ret)
|
s224573921
|
Accepted
| 30 | 6,720 | 238 |
#!/usr/bin/env python
#coding:utf-8
while True:
coin = [500,100,50,10,5,1]
oturi = 1000 - int(input())
if oturi == 1000:
break
ret = 0
for c in coin:
ret += oturi // c
oturi %= c
print(ret)
|
s966447369
|
p02664
|
u907446975
| 2,000 | 1,048,576 |
Wrong Answer
| 72 | 9,204 | 170 |
For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
|
s=input()
for i in range(len(s)):
if s[i]=="?" and s[i-1]=='D':
s=s.replace("?","P")
elif s[i]=="?" and s[i-1]=='P':
s=s.replace("?","D")
print(s)
|
s193716717
|
Accepted
| 101 | 10,868 | 361 |
s=input()
s2=list(s)
s1=""
if s2[-1]=="?":
s2[-1]="D"
if s2[0]=="?" and s2[1]=="D":
s2[0]="P"
elif s2[0]=="?" and (s2[1]=="P" or s2[1]=="?"):
s2[0]="D"
for i in range(1,len(s2)-1):
if s2[i]=='?':
if s2[i-1]=="D" and (s2[i+1]=="D" or s2[i+1]=="?"):
s2[i]="P"
else:
s2[i]="D"
for i in s2:
s1+=i
print(s1)
|
s922476537
|
p03575
|
u417658545
| 2,000 | 262,144 |
Wrong Answer
| 167 | 13,316 | 584 |
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i. An edge whose removal disconnects the graph is called a _bridge_. Find the number of the edges that are bridges among the M edges.
|
import numpy as np
N, M = (list(map(int, input().split())))
a = np.array([0]*M)
b = np.array([0]*M)
for i in range(M):
a[i], b[i] = (input().split())
ans = 0
C = set()
D = set()
for i in range(M):
count = 0
boo = True
while(boo):
for j in range(M):
if i != j:
if(count == 0):
C.add(a[j])
C.add(b[j])
count += 1
if C <= {a[j]} or C <= {b[j]}:
C.add(a[j])
C.add(b[j])
if(C & D == C):
print("aaa")
boo = False
break
else:
D = C
if(len(C) == N):
ans += 1
print(ans)
|
s122554857
|
Accepted
| 193 | 12,424 | 548 |
import numpy as np
N, M = (list(map(int, input().split())))
a = np.array([0]*M)
b = np.array([0]*M)
for i in range(M):
a[i], b[i] = (input().split())
ans = M
for i in range(M):
C = set()
D = set()
count = 0
while(True):
for j in range(M):
if not i == j:
if(count == 0):
C.add(a[j])
C.add(b[j])
count += 1
if a[j] in C or b[j] in C:
C.add(a[j])
C.add(b[j])
if(C == D):
break
else:
D = C.union(D)
if(len(C) == N):
ans -= 1
print(ans)
|
s718689781
|
p02578
|
u945342410
| 2,000 | 1,048,576 |
Wrong Answer
| 137 | 32,192 | 266 |
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
|
N = int(input())
members = list(map(int, input().strip().split()))
stands = []
for i, member in enumerate(members):
if i>0:
if members[i] > members[i-1]:
stands.append(0)
else:
stands.append(members[i-1] - members[i])
print(sum(stands))
|
s878363138
|
Accepted
| 173 | 32,116 | 312 |
N = int(input())
members = list(map(int, input().strip().split()))
stands = []
stands.append(0)
for i, member in enumerate(members):
if i>0:
if members[i] > members[i-1] + stands[i-1]:
stands.append(0)
else:
stands.append(members[i-1] + stands[i-1] - members[i])
print(sum(stands))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.