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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s998135838
|
p00437
|
u150984829
| 1,000
| 131,072
|
Wrong Answer
| 40
| 5,716
| 289
|
あなたはある機械の製造工場で品質管理の責任者をしている. この機械には, 部品として電源とモーターとケーブルが必要である. 製造工場には電源が a 個, モーターが b 個, ケーブルが c 個あり, それぞれ 1 から a まで, a+1 から a+b まで, a+b+1 から a+b+c までの番号が付いている. 困ったことに, 部品の中に故障しているものがあるかもしれない. 工場ではどの部品が故障していてどの部品が正常であるかを知りたい. そこで, 工場では次の方法で部品を検査した. 電源とモーターとケーブルを1つずつ持ってきてつなぎ, 動作させてみる. このとき, 3つの部品がすべて正常であるときは正しく動作して「合格」とわかる. 3つの中に故障している部品が1つでも入っているときは正しく動作しないので「不合格」とわかる. (工場で作っている機械はとても精密なので, 故障した部品がまざっているのに偶然正しく動作してしまうなどということは起きないのだ.) あなたには検査結果のリストが渡される. 検査結果のリストの各行には, 検査に使った電源とモーターとケーブルの番号と, 検査が合格だったか不合格だったかが書かれている. 検査結果のリストが与えられたとき, すべての部品を, 検査結果から確実に故障しているとわかる部品と, 確実に正常とわかる部品と, 検査結果からは故障しているとも正常であるとも決まらない部品に分類するプログラムを作成せよ.
|
for e in iter(input,'0 0 0'):
d=[2]*-~sum(map(int,e.split()))
f=[]
for _ in[0]*int(input()):
s,t,u,v=map(int,input().split())
if v:d[s]=d[t]=d[u]=1
else:f+=[(s,t,u)]
for s,t,u in f:
if d[t]*d[u]<2:d[s]=0
if d[u]*d[s]<2:d[t]=0
if d[s]*d[t]<2:d[u]=0
for x in d[1:]:print(x)
|
s047054198
|
Accepted
| 40
| 5,720
| 292
|
for e in iter(input,'0 0 0'):
d=[2]*-~sum(map(int,e.split()))
f=[]
for _ in[0]*int(input()):
s,t,u,v=map(int,input().split())
if v:d[s]=d[t]=d[u]=1
else:f+=[(s,t,u)]
for s,t,u in f:
if d[t]*d[u]==1:d[s]=0
if d[u]*d[s]==1:d[t]=0
if d[s]*d[t]==1:d[u]=0
for x in d[1:]:print(x)
|
s414403654
|
p03643
|
u790877102
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 31
|
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
|
N = input()
print("ABC" + "N")
|
s272151753
|
Accepted
| 17
| 2,940
| 30
|
N = input()
print("ABC" + N)
|
s897971740
|
p03415
|
u394352233
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 76
|
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.
|
A = list(input())
B = list(input())
C = list(input())
print(A[0],B[1],C[2])
|
s414821317
|
Accepted
| 17
| 2,940
| 76
|
A = list(input())
B = list(input())
C = list(input())
print(A[0]+B[1]+C[2])
|
s253255466
|
p04043
|
u396961814
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 116
|
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
A, B, C = [int(x) for x in input().split()]
if A == 5 and B == 7 and C == 5:
print('YES')
else:
print('NO')
|
s872524707
|
Accepted
| 17
| 2,940
| 139
|
ABC = [int(x) for x in input().split()]
S = sorted(ABC)
if S[0] == 5 and S[1] == 5 and S[2] == 7:
print('YES')
else:
print('NO')
|
s864910416
|
p04043
|
u699522269
| 2,000
| 262,144
|
Wrong Answer
| 25
| 9,160
| 125
|
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a = input()
a = [int(i)for i in a.split(" ")]
print((a[0] == 5 or a[0] == 7) and (a[1] == 5 or a[1] == 7) and (sum(a) == 17))
|
s714816411
|
Accepted
| 23
| 9,160
| 144
|
a = input()
a = [int(i)for i in a.split(" ")]
print("YES" if (a[0] == 5 or a[0] == 7) and (a[1] == 5 or a[1] == 7) and (sum(a) == 17) else "NO")
|
s820130014
|
p03719
|
u500297289
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,060
| 115
|
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
""" AtCoder """
A, B, C = map(int, input().split())
if C >= A and C >= B:
print("Yes")
else:
print("No")
|
s786548346
|
Accepted
| 18
| 2,940
| 115
|
""" AtCoder """
A, B, C = map(int, input().split())
if C >= A and C <= B:
print("Yes")
else:
print("No")
|
s075561057
|
p04012
|
u705418271
| 2,000
| 262,144
|
Wrong Answer
| 30
| 9,212
| 137
|
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
|
from collections import Counter
w=input()
d=Counter(w)
ans="Yes"
for i in d.values():
if i%2==0:
ans="No"
break
print(ans)
|
s198800834
|
Accepted
| 29
| 9,064
| 137
|
from collections import Counter
w=input()
d=Counter(w)
ans="Yes"
for i in d.values():
if i%2!=0:
ans="No"
break
print(ans)
|
s959036596
|
p02578
|
u401810884
| 2,000
| 1,048,576
|
Wrong Answer
| 2,206
| 32,264
| 297
|
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())
A=list(map(int,input().split()))
c=1000000000
for i in range(len(A)):
base=A[i]
cc=0
p=8
for t in range(0, i):
if base<A[t]:
p=6
break
if p==6:
continue
for t in range(i, len(A)):
if base>A[t]:
cc+=base-A[t]
if c > cc:
c = cc
print(c)
|
s706812257
|
Accepted
| 111
| 32,132
| 172
|
N=int(input())
A=list(map(int,input().split()))
base = A[0]
c = 0
for i in range(len(A)):
if A[i] < base:
c += base-A[i]
elif A[i] > base:
base = A[i]
print(c)
|
s835340033
|
p03089
|
u720636500
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 3,060
| 327
|
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
|
N = int(input())
prob = list(map(int, input().split()))
ans = []
for i in reversed(range(N)):
boo = False
for j in reversed(range(i + 1)):
if prob[j] == j + 1:
boo = True
ans.append(j + 1)
del prob[j]
break
if not boo:
break
if len(ans) == N:
for x in ans:
print(x)
else:
print(-1)
|
s671939886
|
Accepted
| 18
| 3,060
| 337
|
N = int(input())
prob = list(map(int, input().split()))
ans = []
for i in reversed(range(N)):
boo = False
for j in reversed(range(i + 1)):
if prob[j] == j + 1:
boo = True
ans.append(j + 1)
del prob[j]
break
if not boo:
break
if len(ans) == N:
for x in reversed(ans):
print(x)
else:
print(-1)
|
s477799040
|
p03386
|
u940780117
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 165
|
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())
K=min(K,B-A)
ans=set()
for i in range(K+1):
ans.add(A+i)
ans.add(B-i)
ans=list(ans)
ans=sorted(ans)
for i in ans:
print(i)
|
s118366873
|
Accepted
| 18
| 3,064
| 196
|
A,B,K=map(int,input().split())
if B==A:
print(A)
exit()
K=min(K,B-A)
ans=set()
for i in range(K):
ans.add(A+i)
ans.add(B-i)
ans=list(ans)
ans=sorted(ans)
for i in ans:
print(i)
|
s544227729
|
p03827
|
u774160580
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 163
|
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
|
N = int(input())
S = input()
x = 0
max_x = 0
for i in range(N):
if S[i] == "I":
x += 1
else:
x -= 1
max_x - max(max_x, x)
print(max_x)
|
s474794423
|
Accepted
| 17
| 2,940
| 163
|
N = int(input())
S = input()
x = 0
max_x = 0
for i in range(N):
if S[i] == "I":
x += 1
else:
x -= 1
max_x = max(max_x, x)
print(max_x)
|
s432513723
|
p02853
|
u503111914
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 115
|
We held two competitions: Coding Contest and Robot Maneuver. In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen. DISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver. Find the total amount of money he earned.
|
X,Y = map(int,input().split())
if X < 4:
X = X*10000
else:
None
if Y < 4:
Y = Y*10000
else:
None
print(X+Y)
|
s517619618
|
Accepted
| 17
| 2,940
| 188
|
X,Y = map(int,input().split())
if X < 4:
X = (4-X)*100000
else:
X = 0
if Y < 4:
Y = (4-Y)*100000
else:
Y = 0
if X == 300000 and Y == 300000:
print(X+Y+400000)
else:
print(X+Y)
|
s034261591
|
p03448
|
u235905557
| 2,000
| 262,144
|
Wrong Answer
| 47
| 3,060
| 261
|
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())
total = int(input())
pattern_num = 0
for i in range(0, a):
for j in range(0, b):
for k in range(0, c):
if i*500+j*100+k*50 == total:
pattern_num += 1
print (pattern_num)
|
s838326302
|
Accepted
| 50
| 3,060
| 272
|
a = int(input()) + 1
b = int(input()) + 1
c = int(input()) + 1
total = int(input())
pattern_num = 0
for i in range(0, a):
for j in range(0, b):
for k in range(0, c):
if i*500+j*100+k*50 == total:
pattern_num += 1
print (pattern_num)
|
s936536061
|
p02396
|
u011632847
| 1,000
| 131,072
|
Wrong Answer
| 140
| 7,364
| 101
|
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
|
i = 0
while 1:
i += 1
test = input()
if test == "0":
break
print("case " + str(i) + ":" + test)
|
s776931663
|
Accepted
| 130
| 7,444
| 102
|
i = 0
while 1:
i += 1
test = input()
if test == "0":
break
print("Case " + str(i) + ": " + test)
|
s592716273
|
p02607
|
u674190122
| 2,000
| 1,048,576
|
Wrong Answer
| 30
| 9,168
| 179
|
We have N squares assigned the numbers 1,2,3,\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i. How many squares i satisfy both of the following conditions? * The assigned number, i, is odd. * The written integer is odd.
|
'''
5
1 3 4 5 7
'''
lens = int(input())
vals = [int(x) for x in input().split()]
odds = 0
for i in range(lens):
if i % 2 == 0 and vals[i] % 2 == 0:
odds += 1
print(odds)
|
s637898929
|
Accepted
| 28
| 9,176
| 194
|
'''
5
1 3 4 5 7
'''
lens = int(input())
vals = [0] + [int(x) for x in input().split()]
odds = 0
for i in range(1, lens + 1):
if i % 2 == 1 and vals[i] % 2 == 1:
odds += 1
print(odds)
|
s605715219
|
p00034
|
u964040941
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,664
| 381
|
複線(上りと下りが別の線路になっていてどこででもすれ違える)の鉄道路線があります。この路線には終端駅を含めて11 の駅があり、それぞれの駅と駅の間は図で示す区間番号で呼ばれています。 この路線の両方の終端駅から列車が同時に出発して、途中で停まらずに走ります。各区間の長さと2 本の列車の速度を読み込んで、それぞれの場合について列車がすれ違う区間の番号を出力するプログラムを作成してください。ただし、ちょうど駅のところですれ違う場合は、両側の区間番号のうち小さいほうの数字を出力します。また、列車の長さ、駅の長さは無視できるものとします。
|
while True:
try:
A = list(map(int,input().split(',')))
except EOFError:
break
V1 = A [-2]
V2 = A [-1]
del A [-1]
del A [-1]
for i in range(len(A)):
A [i] *= V1 + V2
point = sum(A) // (V1 + V2) * V1
print(point)
for i in range(len(A)):
if sum(A [0:i + 1]) >= point:
print(i + 1)
break
|
s738905723
|
Accepted
| 20
| 7,740
| 364
|
while True:
try:
A = list(map(int,input().split(',')))
except EOFError:
break
V1 = A [-2]
V2 = A [-1]
del A [-1]
del A [-1]
for i in range(len(A)):
A [i] *= V1 + V2
point = sum(A) // (V1 + V2) * V1
for i in range(len(A)):
if sum(A [0:i + 1]) >= point:
print(i + 1)
break
|
s260722776
|
p03494
|
u239981649
| 2,000
| 262,144
|
Wrong Answer
| 20
| 2,940
| 141
|
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
N = int(input())
A = list(map(int, input().split()))
m = 0
while 0 in [a % 2 for a in A]:
A = [a / 2 for a in A]
m += 1
print(m)
|
s409225086
|
Accepted
| 19
| 3,060
| 146
|
N = int(input())
A = list(map(int, input().split()))
m = 0
while 1 not in [a % 2 for a in A]:
A = [int(a / 2) for a in A]
m += 1
print(m)
|
s330950199
|
p03760
|
u459150945
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 187
|
Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions. You are given two strings O and E. O contains the characters at the odd- numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order. Restore the original password.
|
O = input()
E = input()
ans = ''
if O>E:
ans += O[0]
O = O[1:]
for o, e in zip(O,E):
ans += (e + o)
else:
for o, e in zip(O, E):
ans += (o + e)
print(ans)
|
s277307162
|
Accepted
| 17
| 3,060
| 199
|
O = input()
E = input()
ans = ''
if len(O) > len(E):
ans += O[0]
O = O[1:]
for o, e in zip(O, E):
ans += (e + o)
else:
for o, e in zip(O, E):
ans += (o + e)
print(ans)
|
s505033881
|
p03797
|
u839537730
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 2,940
| 145
|
Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
|
N, M = list(map(int, input().split(" ")))
if 2*N >= M:
print(N)
else:
while(2*N < M-4):
N += 1
M -= 2
print(N)
|
s528905495
|
Accepted
| 17
| 3,064
| 165
|
N, M = list(map(int, input().split(" ")))
if M < 2:
print(0)
elif N >= M // 2:
print(M // 2)
else:
ans = N
M -= 2*N
ans += M // 4
print(ans)
|
s472602384
|
p02389
|
u100813820
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,616
| 599
|
Write a program which calculates the area and perimeter of a given rectangle.
|
# Input
# Output
# Sample Input
# 3 5
# Sample Output
# 15 16
a,b=map(int,input().split())
# print("a=%d, b=%d."%(a,b))
# a=3
# b=5
print("??¢??????%f ."%(a*b));
print("??¨????????????%f ."%(2*a+2*b));
|
s452475720
|
Accepted
| 30
| 7,576
| 631
|
# Input
# Output
# Sample Input
# 3 5
# Sample Output
# 15 16
a,b=map(int,input().split())
# print("a=%d, b=%d."%(a,b))
print("{0} {1}".format(a*b, 2*a+2*b));
|
s072664111
|
p03836
|
u966695411
| 2,000
| 262,144
|
Wrong Answer
| 24
| 3,188
| 171
|
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
sx, sy, tx, ty = map(int, input().split())
ax, ay = tx - sx, ty - sy
print(('R'*ax+'U'*ay)+('D'*ay+'L'*ax)+('D'+'R'*(ax+1)+'U'*(ay+1)+'L')+('U'+'L'*(ax+1)+'D'*(ay+1)+'R'))
|
s948610758
|
Accepted
| 24
| 3,064
| 116
|
U,D,R,L='UDRL';x,y,a,b=map(int,input().split());x,y=a-x,b-y;a,b=x+1,y+1;print(U*y+R*x+D*y+L*a+U*b+R*a+D+R+D*b+L*a+U)
|
s020659135
|
p03129
|
u207036582
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 83
|
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
|
n, k = map(int, input().split())
if 2 * k - 1 < n : print("Yes")
else : print("No")
|
s078057902
|
Accepted
| 17
| 2,940
| 85
|
n, k = map(int, input().split())
if 2 * k - 1 <= n : print("YES")
else : print("NO")
|
s558212711
|
p03456
|
u928784113
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 98
|
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
# -*- coding: utf-8 -*-
a,b = map(str,input().split())
import math
print(math.sqrt(int(a)+int(b)))
|
s996705725
|
Accepted
| 363
| 20,984
| 124
|
import numpy as np
a,b = map(str,input().split())
ans = "No"
N =np.sqrt(int(a+b))
if int(N) == N:
ans ="Yes"
print(ans)
|
s619274410
|
p03192
|
u835924161
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 27
|
You are given an integer N that has exactly four digits in base ten. How many times does `2` occur in the base-ten representation of N?
|
print(4-input().count('2'))
|
s076222584
|
Accepted
| 17
| 2,940
| 25
|
print(input().count('2'))
|
s006743126
|
p02242
|
u150984829
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,620
| 376
|
For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$.
|
n=int(input())
M=[[-1]*n for _ in[0]*n]
for _ in[0]*n:
e=list(map(int,input().split()))
for i in range(e[1]):k=2*-~i;M[e[0]][e[k]]=e[k+1]
d=[0]+[1e6]*~-n
c=[1]*n
while 1:
m,u=1e6,-1
for i in range(n):
if m>d[i]and c[i]:m,u=d[i],i
if u<0:break
c[u]=0
for v in range(n):
if c[v]and 1+M[u][v]and d[v]>d[u]+M[u][v]:
d[v]=d[u]+M[u][v]
for i in range(i):print(i,d[i])
|
s393306829
|
Accepted
| 20
| 5,756
| 374
|
n=int(input())
M=[[-1]*n for _ in[0]*n]
for _ in[0]*n:
e=list(map(int,input().split()))
for i in range(e[1]):k=2*-~i;M[e[0]][e[k]]=e[k+1]
d=[0]+[1e6]*n
c=[1]*n
while 1:
m,u=1e6,-1
for i in range(n):
if m>d[i]and c[i]:m,u=d[i],i
if u<0:break
c[u]=0
for v in range(n):
if c[v]and 1+M[u][v]and d[v]>d[u]+M[u][v]:
d[v]=d[u]+M[u][v]
for i in range(n):print(i,d[i])
|
s207324355
|
p03557
|
u760961723
| 2,000
| 262,144
|
Wrong Answer
| 782
| 29,428
| 1,511
|
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower. He has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i. To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar. How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.
|
import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD2 = 998244353
INF = float('inf')
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()
def main():
N = NI()
A = NLI()
B = NLI()
C = NLI()
A = sorted(A)
C = sorted(C)
ans = 0
for b in B:
A_ng = 0
A_ok = len(A)
while (abs(A_ok - A_ng) > 1):
A_mid = (A_ok + A_ng) // 2
if A[A_mid] >= b:
A_ok = A_mid
else:
A_ng = A_mid
C_ng = 0
C_ok = len(C)
while (abs(C_ok - C_ng) > 1):
C_mid = (C_ok + C_ng) // 2
if C[C_mid] > b:
C_ok = C_mid
else:
C_ng = C_mid
len_C = len(C)
ans += A_ok * (len_C-C_ok)
print(ans)
if __name__ == '__main__':
main()
|
s312561148
|
Accepted
| 740
| 29,284
| 1,512
|
import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD2 = 998244353
INF = float('inf')
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()
def main():
N = NI()
A = NLI()
B = NLI()
C = NLI()
A = sorted(A)
C = sorted(C)
ans = 0
for b in B:
A_ng = -1
A_ok = len(A)
while (abs(A_ok - A_ng) > 1):
A_mid = (A_ok + A_ng) // 2
if A[A_mid] >= b:
A_ok = A_mid
else:
A_ng = A_mid
C_ng = -1
C_ok = len(C)
while (abs(C_ok - C_ng) > 1):
C_mid = (C_ok + C_ng) // 2
if C[C_mid] > b:
C_ok = C_mid
else:
C_ng = C_mid
len_C = len(C)
ans += A_ok * (len_C-C_ok)
print(ans)
if __name__ == '__main__':
main()
|
s601922721
|
p02975
|
u665038048
| 2,000
| 1,048,576
|
Wrong Answer
| 50
| 14,120
| 131
|
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())
a = list(map(int, input().split()))
s = 1
for i in a:
s ^= 1
if s == 1:
print('Yes')
else:
print('No')
|
s286207055
|
Accepted
| 53
| 14,116
| 131
|
n = int(input())
a = list(map(int, input().split()))
s = 1
for i in a:
s ^= i
if s == 1:
print('Yes')
else:
print('No')
|
s619346986
|
p03080
|
u119983020
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 76
|
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
|
s = input()
if s.count("R")>s.count("B"):
print("Yes")
else:
print("No")
|
s726632355
|
Accepted
| 17
| 2,940
| 86
|
N=input()
s = input()
if s.count("R")>s.count("B"):
print("Yes")
else:
print("No")
|
s637534157
|
p03388
|
u893063840
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,060
| 356
|
10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th. The _score_ of a participant is the product of his/her ranks in the two contests. Process the following Q queries: * In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.
|
q = int(input())
ab = [list(map(int, input().split())) for _ in range(q)]
for a, b in ab:
if a == b:
print(2 * a - 2)
continue
l = 0
r = 10 ** 10
while r - l > 1:
m = (l + r) // 2
mx = (m + 1) // 2 * (m - (m + 1) // 2)
if mx < a * b:
l = m
else:
r = m
print(l)
|
s921903384
|
Accepted
| 21
| 3,188
| 364
|
q = int(input())
ab = [list(map(int, input().split())) for _ in range(q)]
for a, b in ab:
if a == b:
print(2 * a - 2)
continue
l = 1
r = 10 ** 10
while r - l > 1:
m = (l + r) // 2
mx = (m + 1) // 2 * (m + 1 - (m + 1) // 2)
if mx < a * b:
l = m
else:
r = m
print(l - 1)
|
s432894244
|
p03795
|
u030726788
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 34
|
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
N=int(input())
x=N*800-200*(N//15)
|
s531596483
|
Accepted
| 17
| 2,940
| 39
|
N=int(input())
print(N*800-200*(N//15))
|
s671207370
|
p03478
|
u272495679
| 2,000
| 262,144
|
Wrong Answer
| 42
| 3,408
| 223
|
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
N,A,B = map(int,input().split())
Sum = 0
for n in range(N+1):
s = 0
strn = str(n)
for i in strn:
s += int(i)
if s >= A and s<= B:
Sum += n
print("{}".format(n))
print("{}".format(Sum))
|
s254477136
|
Accepted
| 32
| 2,940
| 197
|
N,A,B = map(int,input().split())
Sum = 0
for n in range(N+1):
s = 0
strn = str(n)
for i in strn:
s += int(i)
if s >= A and s<= B:
Sum += n
print("{}".format(Sum))
|
s949433996
|
p02844
|
u407702479
| 2,000
| 1,048,576
|
Wrong Answer
| 27
| 9,088
| 22
|
AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code. The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code. How many different PIN codes can he set this way? Both the lucky number and the PIN code may begin with a 0.
|
19
3141592653589793238
|
s651441520
|
Accepted
| 29
| 9,212
| 318
|
N=int(input())
S=input()
count=0
for p in range(10):
s=S.find(str(p))
if s==-1:
continue
for q in range(10):
t=S.find(str(q),s+1)
if t==-1:
continue
for r in range(10):
u=S.find(str(r),t+1)
if u!=-1:
count+=1
print(count)
|
s873901093
|
p04031
|
u282228874
| 2,000
| 262,144
|
Wrong Answer
| 27
| 3,820
| 173
|
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective.
|
n = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(-100,101):
c = 0
for a in A:
c += (i-a)**2
ans.append(c)
print(min(ans))
|
s874698770
|
Accepted
| 25
| 2,940
| 169
|
n = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(-100,101):
c = 0
for a in A:
c += (i-a)**2
ans.append(c)
print(min(ans))
|
s903275189
|
p03377
|
u659640418
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 83
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a,b,x=map(int,input().split())
if 0<=x-a<=b:
print("Yes")
else:
print("No")
|
s096646837
|
Accepted
| 21
| 3,316
| 83
|
a,b,x=map(int,input().split())
if 0<=x-a<=b:
print("YES")
else:
print("NO")
|
s643454791
|
p03778
|
u940102677
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 66
|
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
|
w,a,b = map(int,input().split())
print(max(min(a,b)-max(a,b)-w,0))
|
s196782415
|
Accepted
| 17
| 2,940
| 58
|
w,a,b = map(int,input().split())
print(max(abs(a-b)-w,0))
|
s018969667
|
p03385
|
u659100741
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 195
|
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
def abc(s):
word = list(s)
print(word)
if word[0] != word[1] and word[0] != word[2] and word[1] != word[2]:
print("Yes")
else:
print("No")
S = input("S:")
abc(S)
|
s532613221
|
Accepted
| 17
| 2,940
| 175
|
def abc(s):
word = list(s)
if word[0] != word[1] and word[0] != word[2] and word[1] != word[2]:
print("Yes")
else:
print("No")
S = input()
abc(S)
|
s706597803
|
p03795
|
u230621983
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 47
|
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
n = int(input())
x = n*800
y = n//15
print(x-y)
|
s648929180
|
Accepted
| 17
| 2,940
| 54
|
n = int(input())
x = n*800
y = (n//15)*200
print(x-y)
|
s668202298
|
p02742
|
u901060001
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,064
| 160
|
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
H, W = (int(x) for x in input().split())
if H % 2 == 1 and W % 2 == 1:
a = int(H/2)
b = a + 1
k = b + (int(W/2))*H
else:
k = H * W / 2
print(k)
|
s739468897
|
Accepted
| 17
| 2,940
| 172
|
H, W = (int(x) for x in input().split())
if H == 1 or W == 1:
k = 1
elif H*W % 2 == 1:
k = int(H / 2) + (int(W / 2)) * H + 1
else:
k = int(H * W / 2)
print(k)
|
s487534780
|
p03386
|
u657611449
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 214
|
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 (A + K) - (B - K) > 0:
for i in range(A, B + 1):
print(i)
else:
for k in range(K):
print(A + k)
for k in range(B - k + 1, B + 1):
print(k)
|
s307285801
|
Accepted
| 17
| 3,060
| 217
|
A, B, K = map(int, input().split())
if (A + K) - (B - K) > 0:
for i in range(A, B + 1):
print(i)
else:
for k in range(A, K + A):
print(k)
for k in range(B - K + 1, B + 1):
print(k)
|
s477997565
|
p03385
|
u010110540
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 47
|
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=set(input())
print("Yes" if S == 3 else "No")
|
s485935319
|
Accepted
| 17
| 2,940
| 114
|
S = input()
if S.count("a")==1 and S.count("b") == 1 and S.count("c") == 1:
print("Yes")
else:
print("No")
|
s937053576
|
p02747
|
u034459102
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 156
|
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()
pattern = ''
cnt = len(S)//2
for _ in range(cnt):
pattern += 'hi'
print(pattern)
if S == pattern:
print('Yes')
else:
print('No')
|
s341300124
|
Accepted
| 17
| 2,940
| 142
|
S = input()
pattern = 'hi'
cnt = len(S)//2
for _ in range(cnt-1):
pattern += 'hi'
if S == pattern:
print('Yes')
else:
print('No')
|
s285891192
|
p03693
|
u970308980
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 102
|
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
def abc():
rgb = ''.join(input().split())
print('Yes' if int(rgb) % 4 == 0 else 'No')
abc()
|
s890425344
|
Accepted
| 17
| 2,940
| 97
|
def abc():
rgb = ''.join(input().split())
print('NO' if int(rgb) % 4 else 'YES')
abc()
|
s452260286
|
p04043
|
u557792847
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 443
|
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.
|
import sys
a, b, c = input().split()
文字列の文字集取得
a_len, b_len, c_len = len(a), len(b), len(c)
cnt5, cnt7 = 0, 0
if a_len == 5:
cnt5 += 1
if a_len == 7:
cnt7 += 1
if b_len == 5:
cnt5 += 1
if b_len == 7:
cnt7 += 1
if c_len == 5:
cnt5 += 1
if c_len == 7:
cnt7 += 1
if cnt5 == 2 and cnt7 == 1:
print("YES")
else:
print("NO")
|
s651855689
|
Accepted
| 17
| 3,064
| 347
|
import sys
a, b, c = map(int, input().split())
cnt5, cnt7 = 0, 0
if a == 5:
cnt5 += 1
if a == 7:
cnt7 += 1
if b == 5:
cnt5 += 1
if b == 7:
cnt7 += 1
if c == 5:
cnt5 += 1
if c == 7:
cnt7 += 1
if cnt5 == 2 and cnt7 == 1:
print("YES")
else:
print("NO")
|
s983572874
|
p02259
|
u853619096
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,628
| 360
|
Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 4 of the pseudocode.
|
n=int(input())
z=list(map(int,input().split()))
flag=1
a=0
cnt=0
while flag:
flag=0
for i in reversed(range(a,n)):
if i ==0:
break
if z[i]<z[i-1]:
tmp=z[i]
z[i]=z[i-1]
z[i-1]=tmp
flag=1
cnt+=1
print(z)
a+=1
print(' '.join(list(map(str,z))))
print(cnt)
|
s689875862
|
Accepted
| 30
| 7,732
| 352
|
n=int(input())
z=list(map(int,input().split()))
flag=1
a=0
cnt=0
while flag:
flag=0
for i in reversed(range(a,n)):
if i ==0:
break
if z[i]<z[i-1]:
tmp=z[i]
z[i]=z[i-1]
z[i-1]=tmp
flag=1
cnt+=1
a+=1
print(' '.join(list(map(str,z))))
print(cnt)
|
s693933090
|
p03657
|
u275212209
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 112
|
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
|
a,b=list(map(int,input().split(" ")))
if a+b==3 or a==3 or b==3:
print('Possible')
else:
print('Impossible')
|
s198795472
|
Accepted
| 17
| 2,940
| 120
|
a,b=list(map(int,input().split(" ")))
if (a+b)%3==0 or a%3==0 or b%3==0:
print('Possible')
else:
print('Impossible')
|
s840407346
|
p02608
|
u597374218
| 2,000
| 1,048,576
|
Wrong Answer
| 821
| 9,356
| 256
|
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
N=int(input())
count=[0]*(10**4+1)
for x in range(1,10**2):
for y in range(1,10**2):
for z in range(1,10**2):
n=x**2+y**2+z**2+x*y+y*z+z*x
if n<=10**4:
count[n]+=1
for i in range(1,N):
print(count[i])
|
s516754156
|
Accepted
| 843
| 9,072
| 196
|
from itertools import product
N=int(input())
f=[0]*N
for x,y,z in product(range(1,100),repeat=3):
n=x**2+y**2+z**2+x*y+y*z+z*x
if n<=N:
f[n-1]+=1
for i in range(N):
print(f[i])
|
s116608770
|
p03455
|
u489717595
| 2,000
| 262,144
|
Wrong Answer
| 25
| 9,028
| 122
|
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())
answer = a * b
print(answer)
if answer%2==0:
print('Even')
else:
print('Odd')
|
s176227738
|
Accepted
| 26
| 9,088
| 88
|
a, b = map(int,input().split())
if a * b % 2 == 0:
print("Even")
else:
print("Odd")
|
s020090606
|
p03997
|
u966511867
| 2,000
| 262,144
|
Wrong Answer
| 24
| 3,064
| 74
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a = int(input())
b = int(input())
h = int(input())
print((a + b) * h / 2)
|
s854167124
|
Accepted
| 23
| 3,064
| 79
|
a = int(input())
b = int(input())
h = int(input())
print(int((a + b) * h / 2))
|
s630577382
|
p03359
|
u891847179
| 2,000
| 262,144
|
Wrong Answer
| 119
| 27,072
| 1,211
|
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
|
# # Make IO faster
# import sys
# input = sys.stdin.readline
# X = input()
# N = int(input())
# X, Y = map(int, input().split())
for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]
# from IPython import embed; embed(); exit();
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
a, b = MAP()
if a < b:
print(a)
else:
print(a - 1)
|
s159356825
|
Accepted
| 28
| 9,116
| 68
|
a,b=map(int,input().split())
if b>=a:
print(a)
else:
print(a-1)
|
s667041842
|
p03644
|
u626228246
| 2,000
| 262,144
|
Wrong Answer
| 31
| 9,112
| 184
|
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
import sys
n = int(input())
for i in range(1,6):
if n < 2**i:
print(2**(i-1))
sys.exit()
elif n == 2**i:
print(2**i)
sys.exit()
else:
print(64)
sys.exit()
|
s335623328
|
Accepted
| 26
| 9,084
| 171
|
import sys
N = int(input())
for i in range(0,7):
if N == 1:
print(1)
sys.exit()
elif N >= 64:
print(64)
sys.exit()
elif N < 2**i:
print(2**(i-1))
sys.exit()
|
s351870590
|
p03408
|
u209619667
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 176
|
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
|
a = int(input())
A = [input() for _ in range(a)]
b = int(input())
B = [input() for _ in range(b)]
count = 0
for i in B:
if i in A:
pass
else:
count+= 1
print(count)
|
s233647115
|
Accepted
| 17
| 3,064
| 244
|
a = int(input())
A = [input() for _ in range(a)]
b = int(input())
B = [input() for _ in range(b)]
a = list(set(A) | set(B))
c = []
for i in range(len(a)):
c.append(A.count(a[i]) - B.count(a[i]))
if max(c) < 0:
print(0)
else:
print(max(c))
|
s623850653
|
p04029
|
u578501242
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 34
|
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
x=int(input())
print((x*(x-1))//2)
|
s468543557
|
Accepted
| 17
| 2,940
| 34
|
x=int(input())
print((x*(x+1))//2)
|
s997881281
|
p02646
|
u168030064
| 2,000
| 1,048,576
|
Wrong Answer
| 25
| 9,180
| 175
|
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
b = abs(b - a)
a = 0
if (b + v * t) <= (0 + v * t):
print("YES")
else:
print("NO")
|
s677481956
|
Accepted
| 26
| 9,208
| 175
|
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
b = abs(b - a)
a = 0
if (b + w * t) <= (0 + v * t):
print("YES")
else:
print("NO")
|
s016413777
|
p03469
|
u502389123
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 38
|
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
|
S = input()
print('2018/01/' + S[9:])
|
s579576592
|
Accepted
| 17
| 2,940
| 39
|
S = input()
print('2018/01/' + S[8:])
|
s968777357
|
p03495
|
u077075933
| 2,000
| 262,144
|
Wrong Answer
| 2,105
| 25,644
| 262
|
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
|
n, k = map(int, input().split())
a = list(map(int, input().split()))
def solve():
a.sort()
count = [a.count(i) for i in range(n) if a.count(i)>0]
count.sort()
if(len(count)<k):
print(0)
return
print(sum(count[:len(count)-k]))
return
solve()
|
s678553721
|
Accepted
| 96
| 32,564
| 234
|
import collections
n, k = map(int, input().split())
a = list(map(int, input().split()))
def solve():
c = list(collections.Counter(a).values())
c.sort()
if(len(c)<=k):
print(0)
else:
print(sum(c[:len(c)-k]))
solve()
|
s105728870
|
p02606
|
u008718882
| 2,000
| 1,048,576
|
Wrong Answer
| 28
| 9,096
| 121
|
How many multiples of d are there among the integers between L and R (inclusive)?
|
L,R,d = map(int, input().split())
cnt = 0
if d % L != 0:
L += d % L
while L <= R:
cnt += 1
L += d
print(cnt)
|
s471916074
|
Accepted
| 27
| 9,024
| 115
|
L,R,d = map(int, input().split())
cnt = 0
for i in range(L, R + 1):
if i % d == 0:
cnt += 1
print(cnt)
|
s226611244
|
p02612
|
u967414299
| 2,000
| 1,048,576
|
Wrong Answer
| 30
| 9,096
| 95
|
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
a = int(input())
b = int(a / 1000) + 1
c = a % 1000
if c == 0:
print(0)
else:
print(b - c)
|
s010915147
|
Accepted
| 27
| 9,160
| 98
|
a = int(input())
b = int(a / 1000) + 1
c = a % 1000
if c == 0:
print(0)
else:
print(1000 - c)
|
s880406767
|
p00768
|
u811733736
| 8,000
| 131,072
|
Wrong Answer
| 80
| 7,968
| 2,712
|
Your mission in this problem is to write a program which, given the submission log of an ICPC (International Collegiate Programming Contest), determines team rankings. The log is a sequence of records of program submission in the order of submission. A record has four fields: elapsed time, team number, problem number, and judgment. The elapsed time is the time elapsed from the beginning of the contest to the submission. The judgment field tells whether the submitted program was correct or incorrect, and when incorrect, what kind of an error was found. The team ranking is determined according to the following rules. Note that the rule set shown here is one used in the real ICPC World Finals and Regionals, with some detail rules omitted for simplification. 1. Teams that solved more problems are ranked higher. 2. Among teams that solve the same number of problems, ones with smaller total consumed time are ranked higher. 3. If two or more teams solved the same number of problems, and their total consumed times are the same, they are ranked the same. The total consumed time is the sum of the consumed time for each problem solved. The consumed time for a solved problem is the elapsed time of the accepted submission plus 20 penalty minutes for every previously rejected submission for that problem. If a team did not solve a problem, the consumed time for the problem is zero, and thus even if there are several incorrect submissions, no penalty is given. You can assume that a team never submits a program for a problem after the correct submission for the same problem.
|
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1187&lang=jp
"""
import sys
from sys import stdin
input = stdin.readline
class Team(object):
def __init__(self, id):
self.id = id
self.correct = 0
self.time = 0 # ????????????
self.penalty = 0
self.status = {}
def judge(self, m, p, j):
if j == 0:
self.correct += 1
self.time = m
if p in self.status:
self.penalty += 20 * self.status[p]
del self.status[p]
else:
if p in self.status:
self.status[p] += 1
else:
self.status[p] = 1
def calc_result(scores):
result = []
for i, s in enumerate(scores[1:], start=1):
if s is not None:
result.append([-s.correct, s.time+s.penalty, s.id*-1])
else:
result.append([0, 0, -i])
result.sort()
return result
def main(args):
# M, T, P, R = 300, 10, 8, 5,
# data = [[50, 5, 2, 1,], [70, 5, 2, 0], [75, 1, 1, 0], [100, 3, 1, 0], [150, 3, 2, 0]]
while True:
M, T, P, R = map(int, input().split())
if M == 0 and T == 0 and P == 0 and R == 0:
break
data = [[int(i) for i in input().split()] for x in range(R)]
scores = [None] * (T+1)
for d in data:
m, t, p, j = d
if scores[t] == None:
team = Team(t)
scores[t] = team
scores[t].judge(m, p, j)
# ???????????????
result = calc_result(scores)
# ?????????????????????????????????
prev_corrent = result[0][0]
prev_time = result[0][1]
final_output = str(result[0][2]*-1)
for r in result[1:]:
if r[0] == prev_corrent and r[1] == prev_time:
final_output += '='
final_output += str(r[2]*-1)
else:
final_output += ','
final_output += str(r[2]*-1)
prev_corrent = r[0]
prev_time = r[1]
print(final_output)
if __name__ == '__main__':
main(sys.argv[1:])
|
s136405127
|
Accepted
| 100
| 8,128
| 2,787
|
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1187&lang=jp
AC
"""
import sys
from sys import stdin
input = stdin.readline
class Team(object):
def __init__(self, id):
self.id = id
self.correct = 0
self.time = 0 # ????????????
self.penalty = 0
self.status = {}
def judge(self, m, p, j):
if j == 0:
self.correct += 1
self.time += m
self.penalty += 20 * self.status.pop(p, 0)
else:
if p in self.status:
self.status[p] += 1
else:
self.status[p] = 1
def calc_result(scores):
result = []
for i, s in enumerate(scores[1:], start=1):
if s is not None:
result.append([-s.correct, s.time+s.penalty, s.id*-1])
else:
result.append([0, 0, -i])
result.sort()
return result
def main(args):
# M, T, P, R = 300, 10, 8, 5,
# data = [[50, 5, 2, 1,], [70, 5, 2, 0], [75, 1, 1, 0], [100, 3, 1, 0], [150, 3, 2, 0]]
while True:
M, T, P, R = map(int, input().split())
if M == 0 and T == 0 and P == 0 and R == 0:
break
data = [[int(i) for i in input().split()] for x in range(R)]
scores = [None] * (T+1)
for d in data:
m, t, p, j = d
if scores[t] == None:
team = Team(t)
scores[t] = team
scores[t].judge(m, p, j)
# ???????????????
result = calc_result(scores)
# ?????????????????????????????????
prev_correct = result[0][0]
prev_time = result[0][1]
final_output = str(result[0][2]*-1)
for r in result[1:]:
if r[0] == prev_correct and r[1] == prev_time:
final_output += '='
final_output += str(r[2]*-1)
else:
final_output += ','
final_output += str(r[2]*-1)
prev_correct = r[0]
prev_time = r[1]
print(final_output)
if __name__ == '__main__':
main(sys.argv[1:])
|
s632813366
|
p03047
|
u779602548
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 178
|
Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers?
|
# -*- coding: utf-8 -*-
n,k = map(int,input().split())
answer = n-k+1
if n > k :
answer = 0
print( answer )
|
s342777775
|
Accepted
| 17
| 2,940
| 178
|
# -*- coding: utf-8 -*-
n,k = map(int,input().split())
answer = n-k+1
if n < k :
answer = 0
print( answer )
|
s947926804
|
p03523
|
u374531474
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,188
| 79
|
You are given a string S. Takahashi can insert the character `A` at any position in this string any number of times. Can he change S into `AKIHABARA`?
|
import re
S = input()
print('Yes' if re.match(r'A?KIHA?BA?RA?', S) else 'No')
|
s381775801
|
Accepted
| 20
| 3,188
| 81
|
import re
S = input()
print('YES' if re.match(r'^A?KIHA?BA?RA?$', S) else 'NO')
|
s372809522
|
p03623
|
u887153853
| 2,000
| 262,144
|
Wrong Answer
| 19
| 2,940
| 89
|
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")
|
s164517807
|
Accepted
| 18
| 2,940
| 99
|
x, a, b = map(int,input().split())
if abs(x - a) > abs(x - b):
print("B")
else:
print("A")
|
s913459265
|
p02392
|
u648470099
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,616
| 85
|
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".
|
a,b,c=map(int, input().split())
if a < b < c:
print("yes")
else:
print("no")
|
s787454893
|
Accepted
| 20
| 7,656
| 85
|
a,b,c=map(int, input().split())
if a < b < c:
print("Yes")
else:
print("No")
|
s803837316
|
p03377
|
u322297639
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 94
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a, b, x = map(int, input().split())
if a <= x <= a + b:
print("Yes")
else:
print("No")
|
s183523617
|
Accepted
| 17
| 2,940
| 94
|
a, b, x = map(int, input().split())
if a <= x <= a + b:
print("YES")
else:
print("NO")
|
s132147122
|
p03449
|
u663101675
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 209
|
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
|
N = int(input())
A = [0] * 2
for i in range(2):
A[i] = list(map(int, input().split()))
print(A)
C_max = 0
for i in range(N):
C = sum(A[0][0:i+1]) + sum(A[1][i:N])
C_max = max(C,C_max)
print(C_max)
|
s510812325
|
Accepted
| 19
| 3,060
| 200
|
N = int(input())
A = [0] * 2
for i in range(2):
A[i] = list(map(int, input().split()))
C_max = 0
for i in range(N):
C = sum(A[0][0:i+1]) + sum(A[1][i:N])
C_max = max(C,C_max)
print(C_max)
|
s707294779
|
p03486
|
u088974156
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 85
|
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
s=sorted(input())
t=sorted(input())[::-1]
if s<t:
print("YES")
else:
print("NO")
|
s462073855
|
Accepted
| 17
| 2,940
| 85
|
s=sorted(input())
t=sorted(input())[::-1]
if s<t:
print("Yes")
else:
print("No")
|
s890193379
|
p03587
|
u131405882
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 78
|
Snuke prepared 6 problems for a upcoming programming contest. For each of those problems, Rng judged whether it can be used in the contest or not. You are given a string S of length 6. If the i-th character of s is `1`, it means that the i-th problem prepared by Snuke is accepted to be used; `0` means that the problem is not accepted. How many problems prepared by Snuke are accepted to be used in the contest?
|
S = input()
ans = 0
for i in range(6):
if S[i] == 1:
ans += 1
print(ans)
|
s189283686
|
Accepted
| 17
| 2,940
| 81
|
S = input()
ans = 0
for i in range(6):
if S[i] == "1":
ans += 1
print(ans)
|
s454405465
|
p03433
|
u843032026
| 2,000
| 262,144
|
Wrong Answer
| 26
| 9,132
| 80
|
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
N=int(input())
A=int(input())
if N % 500 <=A:
print("YES")
else:
print("NO")
|
s743318541
|
Accepted
| 26
| 9,164
| 80
|
N=int(input())
A=int(input())
if N % 500 <=A:
print("Yes")
else:
print("No")
|
s089641849
|
p02612
|
u244417083
| 2,000
| 1,048,576
|
Wrong Answer
| 28
| 9,028
| 38
|
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.
|
price = int(input())
print(price%1000)
|
s139952894
|
Accepted
| 29
| 9,100
| 104
|
price = int(input())
if price%1000==0:
print(0)
else:
otsuri = 1000 - price%1000
print(otsuri)
|
s190363595
|
p02409
|
u138628845
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,632
| 489
|
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.
|
bil_date = []
for i in range(4):
bil_date.append([[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]])
all_date_amo = int(input())
for i in range(all_date_amo):
date = [int(indate) for indate in input().split()]
bil_date[date[0]-1][date[1]-1][date[2]-1] = date[3]
for bil in bil_date:
for flo in bil:
for room in flo:
print(' {}'.format(room),end='')
print('')
for i in range(20):
print('#',end='')
print('')
|
s054905875
|
Accepted
| 20
| 5,636
| 837
|
bil_date = []
flag = 0
for i in range(4):
bil_date.append([[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]])
all_date_amo = int(input())
for i in range(all_date_amo):
date = [int(indate) for indate in input().split()]
bil_date[date[0]-1][date[1]-1][date[2]-1] = bil_date[date[0]-1][date[1]-1][date[2]-1] + date[3]
if bil_date[date[0]-1][date[1]-1][date[2]-1] < 0:
bil_date[date[0]-1][date[1]-1][date[2]-1] = 0
if bil_date[date[0]-1][date[1]-1][date[2]-1] > 9:
bil_date[date[0]-1][date[1]-1][date[2]-1] = 9
for bil in bil_date:
for flo in bil:
for room in flo:
print(' {}'.format(room),end='')
print('')
if flag == 3:
pass
else:
for i in range(20):
print('#',end='')
print('')
flag = flag + 1
|
s366198403
|
p03478
|
u783420291
| 2,000
| 262,144
|
Wrong Answer
| 44
| 3,408
| 196
|
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
a = list(map(int, input().split()))
ans = 0
for i in range(a[0]+1):
num = [int(c) for c in str(i)]
if (sum(num) >= a[1]) & (a[2] >= sum(num)) :
print(i)
ans += i
print(ans)
|
s009763569
|
Accepted
| 35
| 3,060
| 179
|
a = list(map(int, input().split()))
ans = 0
for i in range(a[0]+1):
num = [int(c) for c in str(i)]
if (sum(num) >= a[1]) & (a[2] >= sum(num)) :
ans += i
print(ans)
|
s056231889
|
p03778
|
u680503348
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 94
|
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
|
w, a, b = map(int, input().split())
if b > a:
print(b - a + w)
else:
print(a - b + w)
|
s648446643
|
Accepted
| 17
| 2,940
| 122
|
w, a, b = map(int, input().split())
r = 0
if a > b + w:
r = a - (b + w)
elif b > a + w:
r = b - (a + w)
print(r)
|
s907801569
|
p02394
|
u067975558
| 1,000
| 131,072
|
Wrong Answer
| 30
| 6,720
| 188
|
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.
|
(x, y, w, h, r) = input().rstrip().split(' ')
x = int(x)
y = int(y)
w = int(w)
h = int(h)
r = int(r)
if 0 + r <= x <= w - r and 0 + r <= y <= h - r:
print('Yes')
else:
print('No')
|
s409929885
|
Accepted
| 30
| 6,728
| 188
|
(w, h, x, y, r) = input().rstrip().split(' ')
w = int(w)
h = int(h)
x = int(x)
y = int(y)
r = int(r)
if 0 + r <= x <= w - r and 0 + r <= y <= h - r:
print('Yes')
else:
print('No')
|
s483134741
|
p03162
|
u546104065
| 2,000
| 1,048,576
|
Wrong Answer
| 2,106
| 95,304
| 540
|
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains.
|
N = int(input())
dp = [[0, 0, 0] for i in range(N)]
H = []
for i in range(N):
l = list(map(int, input().split()))
H.append(l)
dp[0] = [H[0][0], H[0][1], H[0][2]]
for i in range(1, N):
for k in range(3):
for j in range(3):
if j == k:
continue
else:
dp[i][j] = max(dp[i][j], (dp[i - 1][k] + H[i][j]))
print(dp)
print(max(dp[N - 1]))
|
s435370073
|
Accepted
| 980
| 50,308
| 526
|
N = int(input())
dp = [[0, 0, 0] for i in range(N)]
H = []
for i in range(N):
l = list(map(int, input().split()))
H.append(l)
dp[0] = [H[0][0], H[0][1], H[0][2]]
for i in range(1, N):
for k in range(3):
for j in range(3):
if j == k:
continue
else:
dp[i][j] = max(dp[i][j], (dp[i - 1][k] + H[i][j]))
print(max(dp[N - 1]))
|
s696172227
|
p03351
|
u844005364
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 119
|
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
a, b, c, d = map(int, input().split())
print("Yes" if abs(a - c) < d or (abs(a - b) < d and abs(c - b) < d) else "No")
|
s447607529
|
Accepted
| 17
| 2,940
| 123
|
a, b, c, d = map(int, input().split())
print("Yes" if abs(a - c) <= d or (abs(a - b) <= d and abs(c - b) <= d) else "No")
|
s179016004
|
p03679
|
u969708690
| 2,000
| 262,144
|
Wrong Answer
| 29
| 9,004
| 114
|
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
|
X,A,B=map(int,input().split())
if B<=A:
print("delicious")
elif B<=X:
print("safe")
else:
print("dangerous")
|
s703530635
|
Accepted
| 25
| 8,996
| 116
|
X,A,B=map(int,input().split())
if B<=A:
print("delicious")
elif B<=X+A:
print("safe")
else:
print("dangerous")
|
s341233503
|
p03679
|
u978494963
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 154
|
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
|
x,a,b = list(map(lambda x: int(x), input().split(" ")))
if x+a<=b:
if a<=b:
print("delicious")
else:
print("safe")
else:
print("dangerous")
|
s650550224
|
Accepted
| 17
| 2,940
| 154
|
x,a,b = list(map(lambda x: int(x), input().split(" ")))
if x>=b-a:
if b<=a:
print("delicious")
else:
print("safe")
else:
print("dangerous")
|
s875530607
|
p02833
|
u385244248
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 176
|
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
|
N = int(input())
ans = 0
if N%2 == 0:
for i in range(10**5):
if 5**(i+1) > N:
break
ans += int((N)//5**(i+1))
print(ans)
else:
print(0)
|
s773900968
|
Accepted
| 17
| 2,940
| 178
|
N = int(input())
ans = 0
if N%2 == 0:
for i in range(10**5):
if 5**(i+1) > N:
break
ans += int(N//(5**(i+1)*2))
print(ans)
else:
print(0)
|
s081531808
|
p02612
|
u419963262
| 2,000
| 1,048,576
|
Wrong Answer
| 25
| 9,136
| 39
|
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-1)//1000-999)
|
s781646590
|
Accepted
| 31
| 8,960
| 39
|
n = int(input())
print(999-(n-1)%1000)
|
s267655893
|
p04043
|
u615852002
| 2,000
| 262,144
|
Wrong Answer
| 25
| 8,984
| 90
|
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a = input().split()
if a.count(5)==2 and a.count(7)==1:
print('YES')
else:
print('NO')
|
s362769994
|
Accepted
| 23
| 8,876
| 94
|
a = input().split()
if a.count('5')==2 and a.count('7')==1:
print('YES')
else:
print('NO')
|
s647134879
|
p03699
|
u695079172
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 174
|
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())
lst = []
for i in range(n):
lst.append(int(input()))
not10nums = [i for i in lst if i%10!=0]
subnum=0
if len(not10nums)>0:
subnum=min(not10nums)
|
s994748164
|
Accepted
| 17
| 3,064
| 240
|
n = int(input())
lst = []
for i in range(n):
lst.append(int(input()))
not10nums = [i for i in lst if i%10!=0]
subnum=0
if len(not10nums)>0:
subnum=min(not10nums)
sm =sum(lst)
if sm%10==0:
sm-=subnum
if sm%10==0:
sm=0
print(sm)
|
s073598512
|
p02694
|
u134520518
| 2,000
| 1,048,576
|
Wrong Answer
| 21
| 9,152
| 103
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
x = int(input())
i = 0
total = 100
while x >= total:
total = int(total * 1.01)
i += 1
print(i)
|
s630544351
|
Accepted
| 21
| 9,152
| 102
|
x = int(input())
i = 0
total = 100
while x > total:
total = int(total * 1.01)
i += 1
print(i)
|
s403031005
|
p03943
|
u305366205
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 106
|
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
a, b, c = map(int, input().split())
if a == b or b == c or c == a:
print('Yes')
else:
print('No')
|
s117161046
|
Accepted
| 17
| 2,940
| 117
|
a, b, c = map(int, input().split())
if a + b == c or b + c == a or c + a == b:
print('Yes')
else:
print('No')
|
s835562121
|
p03624
|
u693953100
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,188
| 113
|
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
|
s=input()
a="abcdefghijklmnopqrstuvwxyz"
for i in a:
if i in s:
print(i)
exit()
print('None')
|
s310829139
|
Accepted
| 18
| 3,188
| 118
|
s=input()
a="abcdefghijklmnopqrstuvwxyz"
for i in a:
if not i in s:
print(i)
exit()
print('None')
|
s122404330
|
p03493
|
u521020719
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 92
|
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
x = input()
counter = 0
for i in x:
if x == '1':
counter += 1
print(counter)
|
s271508534
|
Accepted
| 17
| 2,940
| 93
|
x = input()
counter = 0
for i in x:
if i == '1':
counter += 1
print(counter)
|
s520160042
|
p03943
|
u016323272
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 156
|
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.
|
#ABC047
a,b,c = map(int,input().split())
if a + b ==c:
print('YES')
elif a +c ==b:
print('YES')
elif b+c ==a:
print('YES')
else:
print('NO')
|
s069106534
|
Accepted
| 18
| 2,940
| 117
|
#ABC047.A
a,b,c = map(int,input().split())
if a + b ==c or a +c==b or b+c ==a:
print('Yes')
else:
print('No')
|
s154497157
|
p03813
|
u847901871
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 65
|
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.
|
x = int(input())
if x > 1200:
print("ABC")
else:
print("ARC")
|
s366880237
|
Accepted
| 17
| 2,940
| 65
|
x = int(input())
if x < 1200:
print("ABC")
else:
print("ARC")
|
s834931410
|
p02397
|
u186282999
| 1,000
| 131,072
|
Wrong Answer
| 60
| 8,396
| 533
|
Write a program which reads two integers x and y, and prints them in ascending order.
|
result_list = []
flag = True
while flag:
input_list = []
input_value = input()
split_input_value = input_value.split()
input_valueA = int(split_input_value[0])
input_valueB = int(split_input_value[1])
if input_valueA == 0 and input_valueB == 0:
flag = False
break
else:
input_list.append(input_valueA)
input_list.append(input_valueB)
input_list.sort()
result_list.append(input_list)
print(result_list)
for i in range (0, len(result_list)):
for j in range (0, 2):
print(result_list[i][j], end=' ')
print("")
|
s384505349
|
Accepted
| 70
| 8,248
| 362
|
result = []
while True:
my_value = input()
my_value_list = []
my_value_list = ([int(x) for x in my_value.split()])
my_value_list.sort()
result.append(my_value_list)
if my_value_list[0] == 0 and my_value_list[1] == 0:
result.pop()
break
for i in range(0, len(result)):
print("{} {}".format(result[i][0], result[i][1]))
|
s511771800
|
p03470
|
u034782764
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 52
|
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
print(len(set(int(i) for i in range(int(input())))))
|
s016014173
|
Accepted
| 17
| 2,940
| 72
|
n=int(input())
d=len(set(list(int(input()) for i in range(n))))
print(d)
|
s491852741
|
p00001
|
u301729341
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,272
| 119
|
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
|
High = []
for i in range(10):
High.append(input())
High.sort(reverse = True)
for i in range(3):
print(High[i])
|
s730287333
|
Accepted
| 20
| 7,644
| 126
|
High = []
for i in range(10):
High.append(int(input()))
for i in range(3):
print(max(High))
High.remove(max(High))
|
s342009644
|
p00011
|
u922489088
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,676
| 333
|
Let's play Amidakuji. In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines. In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom. Your task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., w are assigne to the vertical lines from left to right.
|
import sys
n = int(sys.stdin.readline().rstrip())
m = int(sys.stdin.readline().rstrip())
l = []
for i in range(m):
l.append(list(map(int, sys.stdin.readline().rstrip().split(','))))
print(l)
for i in range(n):
cur = i+1
for d in l[::-1]:
if cur in d:
cur = d[0] if cur == d[1] else d[1]
print(cur)
|
s244965184
|
Accepted
| 20
| 7,648
| 324
|
import sys
n = int(sys.stdin.readline().rstrip())
m = int(sys.stdin.readline().rstrip())
l = []
for i in range(m):
l.append(list(map(int, sys.stdin.readline().rstrip().split(','))))
for i in range(n):
cur = i+1
for d in l[::-1]:
if cur in d:
cur = d[0] if cur == d[1] else d[1]
print(cur)
|
s926515229
|
p03494
|
u349600366
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 25
|
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.
|
print(input().count("1"))
|
s668546188
|
Accepted
| 19
| 3,188
| 134
|
N = input()
A = list(map(int, input().split()))
cnt = 0
while all(a%2==0 for a in A):
A = [a/2 for a in A]
cnt += 1
print(cnt)
|
s117327194
|
p03971
|
u667024514
| 2,000
| 262,144
|
Wrong Answer
| 125
| 4,016
| 457
|
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.
|
n,a,b = map(int,input().split())
s = str(input())
border = a + b
cou = 0
ans = 0
for i in range(n):
if s[i] == "c":
print("No")
elif s[i] == "b":
if cou < a + b:
if ans + 1 <= b:
ans += 1
cou += 1
print("Yes")
else:
print("No")
else:
print("No")
else:
if cou < a + b:
cou += 1
print("Yes")
|
s048339724
|
Accepted
| 116
| 4,016
| 495
|
n,a,b = map(int,input().split())
s = str(input())
border = a + b
cou = 0
ans = 0
for i in range(n):
if s[i] == "c":
print("No")
elif s[i] == "b":
if cou < a + b:
if ans + 1 <= b:
ans += 1
cou += 1
print("Yes")
else:
print("No")
else:
print("No")
else:
if cou < a + b:
cou += 1
print("Yes")
else:
print("No")
|
s401924403
|
p03636
|
u829796346
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 38
|
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
s = input()
print(s[0],len(s)-2,s[-1])
|
s602830507
|
Accepted
| 17
| 2,940
| 55
|
s = input()
print("{}{}{}".format(s[0],len(s)-2,s[-1]))
|
s096007911
|
p02415
|
u661529494
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,540
| 32
|
Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.
|
a=str(input())
print(a.swapcase)
|
s628771692
|
Accepted
| 20
| 5,540
| 34
|
a=str(input())
print(a.swapcase())
|
s448840658
|
p03494
|
u204800924
| 2,000
| 262,144
|
Time Limit Exceeded
| 2,104
| 2,940
| 246
|
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
N = int(input())
A = [int(i) for i in input().split()]
odd = False
count = 0
while True:
for i in A:
if i%2 != 0:
odd = True
if odd:
break
for i in A:
i = int(i/2)
count += 1
print(count)
|
s437316496
|
Accepted
| 29
| 9,120
| 254
|
n = int(input())
a = list(map(int, input().split()))
cnt =0
flag = 0
while True:
a = list(map(lambda x: x/2, a))
for i in range(n):
print
if not a[i].is_integer():
flag = 1
break
if flag == 1:
break
cnt += 1
print(cnt)
|
s670716411
|
p02418
|
u177808190
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,556
| 171
|
Write a program which finds a pattern $p$ in a ring shaped text $s$.
|
import sys
hoge = list()
for line in sys.stdin:
hoge.append(line)
hoge[0] = hoge[0] + hoge[0]
if hoge[0].find(hoge[1]) == -1:
print ('No')
else:
print ('Yes')
|
s906799344
|
Accepted
| 20
| 5,560
| 159
|
hoge = list()
for _ in range(2):
hoge.append(input())
hoge[0] = hoge[0] + hoge[0]
if hoge[0].find(hoge[1]) == -1:
print ('No')
else:
print ('Yes')
|
s011404048
|
p03435
|
u745561510
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 481
|
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct.
|
c = [list(map(int, input().split())) for i in range(3)]
for a1 in range(101):
b1 = c[0][0] - a1
b2 = c[1][0] - a1
b3 = c[2][0] - a1
a2 = c[0][1] - b1
if a2 != (c[1][1] - b2) and a2 != (c[2][1] - b3):
print("No")
exit()
a3 = c[2][0] - b1
if a3 != (c[2][1] - b2) and a3 != (c[2][2] - b3):
print("No")
exit()
if a1 < 0 or a2 < 0 or a3 < 0 or b1 < 0 or b2 < 0 or b3 < 0:
print("No")
exit()
print("Yes")
|
s784941228
|
Accepted
| 17
| 3,064
| 503
|
c = [list(map(int, input().split())) for i in range(3)]
for a1 in range(101):
flag = True
b1 = c[0][0] - a1
b2 = c[1][0] - a1
b3 = c[2][0] - a1
a2 = c[0][1] - b1
if a2 != (c[1][1] - b2) or a2 != (c[2][1] - b3):
flag = False
a3 = c[0][2] - b1
if a3 != (c[1][2] - b2) or a3 != (c[2][2] - b3):
flag = False
if a1 < 0 or a2 < 0 or a3 < 0 or b1 < 0 or b2 < 0 or b3 < 0:
flag = False
if flag:
print("Yes")
exit()
print("No")
|
s941732948
|
p02407
|
u070968430
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,480
| 124
|
Write a program which reads a sequence and prints it in the reverse order.
|
N = int(input())
a = []
a = list(map(int, input().split()))
print(N)
for i in range(1, len(a)+1):
print(a[-i], end =" ")
|
s423726228
|
Accepted
| 20
| 7,640
| 68
|
N = int(input())
a = input().split(" ")
print(" ".join(reversed(a)))
|
s780396425
|
p03890
|
u034734062
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 22
|
_Kode Festival_ is an anual contest where the hardest stone in the world is determined. (Kode is a Japanese word for "hardness".) This year, 2^N stones participated. The hardness of the i-th stone is A_i. In the contest, stones are thrown at each other in a knockout tournament. When two stones with hardness X and Y are thrown at each other, the following will happen: * When X > Y: The stone with hardness Y will be destroyed and eliminated. The hardness of the stone with hardness X will become X-Y. * When X = Y: One of the stones will be destroyed and eliminated. The hardness of the other stone will remain the same. * When X < Y: The stone with hardness X will be destroyed and eliminated. The hardness of the stone with hardness Y will become Y-X. The 2^N stones will fight in a knockout tournament as follows: 1. The following pairs will fight: (the 1-st stone versus the 2-nd stone), (the 3-rd stone versus the 4-th stone), ... 2. The following pairs will fight: (the winner of (1-st versus 2-nd) versus the winner of (3-rd versus 4-th)), (the winner of (5-th versus 6-th) versus the winner of (7-th versus 8-th)), ... 3. And so forth, until there is only one stone remaining. Determine the eventual hardness of the last stone remaining.
|
3
1
3
2
4
6
8
100
104
|
s377488999
|
Accepted
| 578
| 18,664
| 409
|
def battle(first, second):
if first > second:
return first - second
elif first < second:
return second - first
else:
return first
n = 1 << int(input())
a = []
for i in range(n):
a.append(int(input()))
while True:
if n // 2 == 0:
break
new = []
for i in range(n // 2):
new.append(battle(a[i*2], a[i*2+1]))
a = new
n //= 2
print(a[0])
|
s327903450
|
p03609
|
u021916304
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 238
|
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
|
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
x,t =iim()
print(min(0,x-t))
|
s447066017
|
Accepted
| 17
| 3,060
| 238
|
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
x,t =iim()
print(max(0,x-t))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.