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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s570993478
|
p02842
|
u593567568
| 2,000
| 1,048,576
|
Wrong Answer
| 21
| 3,188
| 215
|
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
|
import math
N = int(input())
f = N // 1.1
ok = False
while True:
n = math.ceil(f * 1.08)
if n == N:
ok = True
break
elif N < n:
break
f += 1
if not ok:
print(':(')
else:
print(n)
|
s975122626
|
Accepted
| 18
| 2,940
| 222
|
import math
N = int(input())
f = int(N // 1.1)
ok = False
while True:
n = math.floor(f * 1.08)
if n == N:
ok = True
break
elif N < n:
break
f += 1
if not ok:
print(':(')
else:
print(f)
|
s839882812
|
p02613
|
u342062419
| 2,000
| 1,048,576
|
Wrong Answer
| 140
| 16,188
| 225
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
n = int(input())
s = [input() for i in range(n)]
ac = s.count('AC')
wa = s.count('WA')
tle = s.count('TLE')
re = s.count('RE')
print('AC × '+str(ac))
print('WA × '+str(wa))
print('TLE × '+str(tle))
print('RE × '+str(re))
|
s645174051
|
Accepted
| 142
| 16,196
| 221
|
n = int(input())
s = [input() for i in range(n)]
ac = s.count('AC')
wa = s.count('WA')
tle = s.count('TLE')
re = s.count('RE')
print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))
|
s543128432
|
p03068
|
u531258707
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 115
|
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.
|
N=int(input())
Sl=input()
K=int(input())
S= list(Sl)
print(S)
for i in range(N):
if S[i] != S[K-1]:
S[i] = '*'
|
s695152879
|
Accepted
| 17
| 3,060
| 147
|
N=int(input())
Sl=input()
K=int(input())
S= list(Sl)
for i in range(N):
if S[i] != S[K-1]:
ass = '*'
S[i] = ass
Snew = "".join(S)
print(Snew)
|
s553373216
|
p02557
|
u392319141
| 2,000
| 1,048,576
|
Wrong Answer
| 240
| 41,304
| 358
|
Given are two sequences A and B, both of length N. A and B are each sorted in the ascending order. Check if it is possible to reorder the terms of B so that for each i (1 \leq i \leq N) A_i \neq B_i holds, and if it is possible, output any of the reorderings that achieve it.
|
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
r = N - 1
for i in range(N):
if A[i] == B[i]:
while r >= 0 and B[r] == B[i]:
r -= 1
if r < 0:
break
B[i], B[r] = B[r], B[i]
if any(a == b for a, b in zip(A, B)):
print('No')
else:
print('Yes')
print(*B)
|
s672380130
|
Accepted
| 434
| 87,892
| 742
|
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
AB = [(a, i, 0) for i, a in enumerate(A)] + [(b, i, 1) for i, b in enumerate(B)]
AB.sort()
X = AB[:N]
Y = AB[N:]
if any(x[0] == y[0] for x, y in zip(X, Y)):
print('No')
exit()
swapA = []
swapB = []
ans = [-1] * N
for (_, i, sx), (_, j, sy) in zip(X, Y):
if sx == sy == 0:
swapA.append((i, j))
elif sx == sy == 1:
swapB.append((i, j))
else:
if sx == 0:
ans[i] = B[j]
else:
ans[j] = B[i]
for (i, j), (x, y) in zip(swapA, swapB):
ans[i] = B[x]
ans[j] = B[y]
if A[i] == ans[i] or A[j] == ans[j]:
ans[i], ans[j] = ans[j], ans[i]
print('Yes')
print(*ans)
|
s258798976
|
p03605
|
u444856278
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 63
|
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
|
N = input()
if "9" in N:
print("yes")
else:
print("no")
|
s581749118
|
Accepted
| 17
| 2,940
| 63
|
N = input()
if "9" in N:
print("Yes")
else:
print("No")
|
s317094363
|
p03778
|
u513081876
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 115
|
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 a+W < b:
print(a+W-b)
elif b+W < a:
print(a-b-W)
else:
print(0)
|
s494542076
|
Accepted
| 17
| 2,940
| 178
|
W, a, b = map(int, input().split())
if a + W < b:
ans = b - (a + W)
elif a <= b <= b + W or a <= b + W <= a + W:
ans = 0
elif b + W < a:
ans = a - (b+W)
print(ans)
|
s250465529
|
p03370
|
u546853743
| 2,000
| 262,144
|
Wrong Answer
| 28
| 9,196
| 105
|
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=list(map(int,input().split('\n')))
x -= sum(m)
m.sort()
print(n+(x//m[0]))
|
s044853133
|
Accepted
| 30
| 9,176
| 138
|
n,x=map(int,input().split())
s=0
l=1000
for i in range(n):
m=int(input())
s += m
if m<l:
l=m
x -= s
x //= l
print(n+x)
|
s472356284
|
p04029
|
u113971909
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 32
|
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?
|
n=int(input())
print(n*(n-1)//2)
|
s532152087
|
Accepted
| 16
| 2,940
| 32
|
n=int(input())
print(n*(n+1)//2)
|
s353474441
|
p02613
|
u430771494
| 2,000
| 1,048,576
|
Wrong Answer
| 151
| 16,484
| 232
|
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.
|
import collections
N=int(input())
S=['a']*N
for i in range(0,N):
S[i]=input()
J=collections.Counter(S)
print('AC',J['AC'],sep=' × ')
print('WA',J['WA'],sep=' × ')
print('TLE',J['TLE'],sep=' × ')
print('RE',J['RE'],sep=' × ')
|
s762153047
|
Accepted
| 154
| 16,484
| 228
|
import collections
N=int(input())
S=['a']*N
for i in range(0,N):
S[i]=input()
J=collections.Counter(S)
print('AC',J['AC'],sep=' x ')
print('WA',J['WA'],sep=' x ')
print('TLE',J['TLE'],sep=' x ')
print('RE',J['RE'],sep=' x ')
|
s188882117
|
p03338
|
u350093546
| 2,000
| 1,048,576
|
Wrong Answer
| 32
| 9,136
| 181
|
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.
|
n=int(input())
s=input()
ans=0
for i in range(1,n):
cnt=0
x=list(set(s[:i]))
y=list(set(s[i:]))
for j in x:
if x in y:
cnt+=1
if ans<cnt:
ans=cnt
print(ans)
|
s017890331
|
Accepted
| 30
| 9,164
| 184
|
n=int(input())
s=input()
ans=0
for i in range(1,n-1):
cnt=0
x=list(set(s[:i]))
y=list(set(s[i:]))
for j in x:
if j in y:
cnt+=1
if ans<cnt:
ans=cnt
print(ans)
|
s020777979
|
p02608
|
u124212130
| 2,000
| 1,048,576
|
Wrong Answer
| 499
| 9,120
| 265
|
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())
ans = [0 for _ in range(10050)]
for i in range(105):
for j in range(105):
for k in range(105):
v = i*i + j*j + k*k + k*j + i*k + i*j
if v < 10050:
ans[v] += 1
for i in range(N):
print(ans[i])
|
s015253950
|
Accepted
| 565
| 9,240
| 273
|
N = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
for j in range(1,105):
for k in range(1,105):
v = i*i + j*j + k*k + k*j + i*k + i*j
if v < 10050:
ans[v] += 1
for i in range(N):
print(ans[i+1])
|
s443750082
|
p03730
|
u920299620
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 180
|
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())
ini=A%B
tmp=ini
while(1):
if(tmp==C):
print("Yes")
break
else:
tmp+=ini
tmp=tmp%B
if(tmp==ini):
print("No")
break
|
s395332150
|
Accepted
| 17
| 2,940
| 180
|
A,B,C=map(int,input().split())
ini=A%B
tmp=ini
while(1):
if(tmp==C):
print("YES")
break
else:
tmp+=ini
tmp=tmp%B
if(tmp==ini):
print("NO")
break
|
s651263280
|
p03545
|
u129749062
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 288
|
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.
|
ABCD = str(input())
n = len(ABCD)-1
ABCD_ = ''
output = ''
for i in range(2**n):
ABCD_ = ABCD[0]
for j in range(n):
if ((i >> j)&1) == 1:
ABCD_ = ABCD_ + '+' + ABCD[j+1]
else:
ABCD_ = ABCD_ + '-' + ABCD[j+1]
if eval(ABCD_) == 7:
output = ABCD_
print(output)
|
s070866264
|
Accepted
| 17
| 3,064
| 295
|
ABCD = str(input())
n = len(ABCD)-1
ABCD_ = ''
output = ''
for i in range(2**n):
ABCD_ = ABCD[0]
for j in range(n):
if ((i >> j)&1) == 1:
ABCD_ = ABCD_ + '+' + ABCD[j+1]
else:
ABCD_ = ABCD_ + '-' + ABCD[j+1]
if eval(ABCD_) == 7:
output = ABCD_ + '=7'
print(output)
|
s089935471
|
p02612
|
u124212130
| 2,000
| 1,048,576
|
Wrong Answer
| 30
| 9,104
| 30
|
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N = int(input())
print(N%1000)
|
s722763800
|
Accepted
| 29
| 9,148
| 42
|
N = int(input())
print((1000-N%1000)%1000)
|
s409552315
|
p04014
|
u729707098
| 2,000
| 262,144
|
Wrong Answer
| 233
| 3,064
| 363
|
For integers b (b \geq 2) and n (n \geq 1), let the function f(b,n) be defined as follows: * f(b,n) = n, when n < b * f(b,n) = f(b,\,{\rm floor}(n / b)) + (n \ {\rm mod} \ b), when n \geq b Here, {\rm floor}(n / b) denotes the largest integer not exceeding n / b, and n \ {\rm mod} \ b denotes the remainder of n divided by b. Less formally, f(b,n) is equal to the sum of the digits of n written in base b. For example, the following hold: * f(10,\,87654)=8+7+6+5+4=30 * f(100,\,87654)=8+76+54=138 You are given integers n and s. Determine if there exists an integer b (b \geq 2) such that f(b,n)=s. If the answer is positive, also find the smallest such b.
|
from math import sqrt
n = int(input())
s = int(input())
def f(x,y):
if x<=y: return y
else: return f(x,y//x)+(y%x)
if s==n: ans = n+1
else:
ans = -1
for i in range(2,int(sqrt(n))+1):
if f(i,n)==s:
ans = i
break
if ans==-1:
for i in range(int(sqrt(n)),0,-1):
b = (n-s)/i+1
if b==int(b) and f(int(b),n)==s:
ans = int(b)
break
print(ans)
|
s950009294
|
Accepted
| 404
| 3,064
| 381
|
from math import sqrt
n = int(input())
s = int(input())
def f(x,y):
if y<x: return y
else: return f(x,y//x)+(y%x)
if s==n: ans = n+1
elif n<s: ans = -1
else:
ans = -1
for i in range(2,int(sqrt(n))+1):
if f(i,n)==s:
ans = i
break
if ans==-1:
for i in range(int(sqrt(n)),0,-1):
b = (n-s)/i+1
if b==int(b) and f(int(b),n)==s:
ans = int(b)
break
print(ans)
|
s740636537
|
p03408
|
u651109406
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 370
|
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.
|
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
dicts = {}
small = 0
for i in s:
if i not in dicts.values():
dicts[i] = 1
else:
dicts[i] += 1
for i in t:
if i not in dicts.values():
dicts[i] = -1
else:
dicts[i] -= 1
tmp = max(dicts.values())
print(max(tmp, small))
|
s041887002
|
Accepted
| 18
| 3,064
| 366
|
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
dicts = {}
small = 0
for i in s:
if i not in dicts.keys():
dicts[i] = 1
else:
dicts[i] += 1
for i in t:
if i not in dicts.keys():
dicts[i] = -1
else:
dicts[i] -= 1
tmp = max(dicts.values())
print(max(tmp, small))
|
s081099012
|
p02646
|
u489762173
| 2,000
| 1,048,576
|
Wrong Answer
| 23
| 9,176
| 181
|
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 = list(map(int, input().split()))
B, W = list(map(int, input().split()))
T = int(input())
kyori = abs(A - B)
if kyori + W * T <= V * T:
print('Yes')
else:
print('No')
|
s243412302
|
Accepted
| 22
| 9,108
| 182
|
A, V = list(map(int, input().split()))
B, W = list(map(int, input().split()))
T = int(input())
kyori = abs(A - B)
if kyori + W * T <= V * T:
print('YES')
else:
print('NO')
|
s774754352
|
p03478
|
u889106068
| 2,000
| 262,144
|
Wrong Answer
| 51
| 3,628
| 368
|
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_digits = 0
for num in range(1, N + 1):
sum_digit = 0
tmp = num
while True:
if tmp < 10:
sum_digit += tmp
break
digit = tmp % 10
tmp //= 10
sum_digit += digit
if A <= sum_digit <= B:
sum_digits += num
print(sum_digit)
print(sum_digits)
|
s787757120
|
Accepted
| 29
| 2,940
| 343
|
N, A, B = map(int, input().split(' '))
sum_digits = 0
for num in range(1, N + 1):
sum_digit = 0
tmp = num
while True:
if tmp < 10:
sum_digit += tmp
break
digit = tmp % 10
tmp //= 10
sum_digit += digit
if A <= sum_digit <= B:
sum_digits += num
print(sum_digits)
|
s698214728
|
p03455
|
u931636178
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 90
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a,b = map(int,input().split())
if a * b % 2 == 0:
print("even")
else:
print("odd")
|
s145360905
|
Accepted
| 17
| 2,940
| 90
|
a, b = map(int,input().split())
if a*b % 2 == 0:
print("Even")
else:
print("Odd")
|
s200400514
|
p02612
|
u375616706
| 2,000
| 1,048,576
|
Wrong Answer
| 29
| 9,060
| 66
|
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())
if N%1000:
print(0)
else:
print(1000 - N%1000)
|
s005439171
|
Accepted
| 27
| 9,088
| 70
|
N=int(input())
if N%1000==0:
print(0)
else:
print(1000 - N%1000)
|
s326185111
|
p02612
|
u722117999
| 2,000
| 1,048,576
|
Wrong Answer
| 29
| 9,036
| 30
|
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N=int(input())
print(1+N/1000)
|
s436013876
|
Accepted
| 29
| 9,080
| 65
|
N = int(input())
A = 0 if N%1000 == 0 else 1000 - N%1000
print(A)
|
s870733852
|
p00242
|
u724548524
| 1,000
| 131,072
|
Wrong Answer
| 30
| 5,612
| 454
|
携帯電話には、メールなどの文章を効率良く入力するために入力候補を表示する機能が搭載されています。これは、使われる頻度が高い単語を記録しておき、入力された文字を頭文字に持つ単語を入力候補として提示するものです。例えば、普段”computer”という単語を多く入力しているなら、”c”と入力するだけで候補として”computer”が提示されます。このような機能の基本部分を作成してみましょう。 文章、文字を入力とし、その文字を頭文字に持つ単語を出現数の順に出力するプログラムを作成してください。ただし、出現数が同じ単語が複数ある場合は、辞書式順序で出力します。出力する単語は最大5つまでとします。該当する単語が存在しない場合は”NA”と出力してください。
|
while 1:
n = int(input())
if n == 0:break
c = {}
for _ in range(n):
s = input().split()
for e in s:
if e in c:c[e] += 1
else:c[e] = 1
c = [(e, c[e]) for e in c.keys()]
c.sort(key = lambda x:x[1], reverse = True)
c.sort(key = lambda x:x[0])
s = input()
a = []
for i in range(len(c)):
if c[i][0][0] == s:a.append(c[i][0])
if a == []:print("NA")
else:print(*a)
|
s655284803
|
Accepted
| 40
| 5,616
| 458
|
while 1:
n = int(input())
if n == 0:break
c = {}
for _ in range(n):
s = input().split()
for e in s:
if e in c:c[e] += 1
else:c[e] = 1
c = [(e, c[e]) for e in c.keys()]
c.sort(key = lambda x:x[0])
c.sort(key = lambda x:x[1], reverse = True)
s = input()
a = []
for i in range(len(c)):
if c[i][0][0] == s:a.append(c[i][0])
if a == []:print("NA")
else:print(*a[:5])
|
s321540561
|
p03068
|
u123824541
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 129
|
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.
|
N = int(input())
S = list(input())
K = int(input())
a = S[K-1]
for i in range(N):
if S[i] != a:
S[i] = '*'
print(S)
|
s594611303
|
Accepted
| 19
| 3,316
| 150
|
N = int(input())
S = list(input())
K = int(input())
a = S[K-1]
T=[]
for i in range(N):
if S[i] != a:
S[i] = '*'
T = ''.join(S)
print(T)
|
s317819915
|
p03067
|
u546853743
| 2,000
| 1,048,576
|
Wrong Answer
| 26
| 9,148
| 137
|
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
|
a,b,c=map(int,input().split())
if c-a > 0 and b-a < 0:
print('Yes')
elif c-a < 0 and b-a > 0:
print('Yes')
else:
print('No')
|
s187279955
|
Accepted
| 25
| 9,164
| 137
|
a,b,c=map(int,input().split())
if c-a > 0 and c-b < 0:
print('Yes')
elif c-a < 0 and c-b > 0:
print('Yes')
else:
print('No')
|
s663913326
|
p02412
|
u024715419
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,732
| 180
|
Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9
|
while True:
n,x = map(int,input().split())
if n == 0 and x == 0:
break
l = [i+j+k for i in range(n) for j in range(n) for k in range(n)]
print(l.count(x-3))
|
s899148709
|
Accepted
| 310
| 10,264
| 192
|
while True:
n,x = map(int,input().split())
if n == 0 and x == 0:
break
l = [i+j+k for i in range(n-2) for j in range(i+1,n-1) for k in range(j+1,n)]
print(l.count(x-3))
|
s401197640
|
p03486
|
u234631479
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 60
|
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 = input()
b = input()
print(sorted(a) < list(reversed(b)))
|
s009283361
|
Accepted
| 17
| 2,940
| 90
|
a = input()
b = input()
if sorted(a) < sorted(b)[::-1]:
print("Yes")
else:
print("No")
|
s391864088
|
p03625
|
u626228246
| 2,000
| 262,144
|
Wrong Answer
| 64
| 22,312
| 447
|
We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
|
import sys
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
box = []
acnt = Counter(a)
a_val = list(acnt.values())
#a_val.sort(reverse=True)
a_key = list(acnt.keys())
#a_key.sort(reverse=True)
#print(a_key,a_val)
for i in range(len(a_val)):
if a_val[i] >= 4:
print(a_key[i]**2)
sys.exit()
elif 2 <= a_val[i] < 4:
box.append(a_key[i])
print(box)
if len(box) == 2:
print(box[0]*box[1])
sys.exit()
|
s989108853
|
Accepted
| 159
| 27,176
| 549
|
import sys
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
box,box2,ans = [],[],0
acnt = dict(Counter(a))
acnt = sorted(acnt.items(), key=lambda x:x[0],reverse=True)
a_val = [acnt[x][1] for x in range(len(acnt))]
a_key = [acnt[y][0] for y in range(len(acnt))]
for i in range(len(a_val)):
if a_val[i] >= 4:
box2.append(a_key[i]**2)
if 2 <= a_val[i]:
box.append(a_key[i])
box.sort(reverse=True)
if len(box2) >= 2:
ans = max(box2)
if len(box) >= 2:
print(max(ans,(box[0]*box[1])))
sys.exit()
print(0)
|
s811413953
|
p03597
|
u772180901
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 48
|
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
|
n = int(input())
a = int(input())
print(n*2 - a)
|
s075435803
|
Accepted
| 18
| 2,940
| 48
|
n = int(input())
a = int(input())
print(n*n - a)
|
s990118010
|
p03478
|
u090225501
| 2,000
| 262,144
|
Wrong Answer
| 33
| 2,940
| 138
|
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())
r = 0
for i in range(n + 1):
s = sum(int(x) for x in str(i))
if a <= s <= b:
r += s
print(r)
|
s722334235
|
Accepted
| 34
| 2,940
| 141
|
n, a, b = map(int, input().split())
r = 0
for i in range(1, n + 1):
s = sum(int(x) for x in str(i))
if a <= s <= b:
r += i
print(r)
|
s798163272
|
p02646
|
u889390649
| 2,000
| 1,048,576
|
Wrong Answer
| 21
| 9,204
| 372
|
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())
if a == b:
flag = 1
if a < b:
b_ = w*t + b
a_ = v*t + a
if a_ >= b_:
flag = 1
else:
flag = 0
elif a > b:
b_ = -w*t + b
a_ = -v*t + a
if a_ <= b_:
flag = 1
else:
flag = 0
if flag == 0:
print("No")
else:
print("Yes")
|
s205219557
|
Accepted
| 23
| 9,204
| 349
|
a,v = map(int, input().split())
b,w = map(int, input().split())
t = int(input())
if a < b:
b1 = w*t + b
a1 = v*t + a
if a1 >= b1:
flag = 1
else:
flag = 0
elif a > b:
b1 = -w*t + b
a1 = -v*t + a
if a1 <= b1:
flag = 1
else:
flag = 0
if flag == 0:
print("NO")
else:
print("YES")
|
s114161166
|
p02613
|
u040660107
| 2,000
| 1,048,576
|
Wrong Answer
| 149
| 9,216
| 346
|
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.
|
number = int(input())
AC = 0
TLE = 0
WA = 0
RE = 0
chara = []
for i in range(0,number):
a = input()
if(a == 'AC'):
AC = AC + 1
elif(a == 'TLE'):
TLE = TLE + 1
elif (a == 'WA'):
WA = WA + 1
elif (a == 'RE'):
RE = RE + 1
print('AC x ',AC)
print('TLE x ',TLE)
print('WA x ',WA)
print('RE x ',RE)
|
s444665277
|
Accepted
| 146
| 9,236
| 342
|
number = int(input())
AC = 0
TLE = 0
WA = 0
RE = 0
chara = []
for i in range(0,number):
a = input()
if(a == 'AC'):
AC = AC + 1
elif(a == 'TLE'):
TLE = TLE + 1
elif (a == 'WA'):
WA = WA + 1
elif (a == 'RE'):
RE = RE + 1
print('AC x',AC)
print('WA x',WA)
print('TLE x',TLE)
print('RE x',RE)
|
s359884349
|
p03761
|
u501451051
| 2,000
| 262,144
|
Wrong Answer
| 37
| 9,892
| 690
|
Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains. Find the longest string that can be created regardless of which string among S_1,...,S_n the headline contains. If there are multiple such strings, find the lexicographically smallest one among them.
|
import string
n = int(input())
lis = [input() for _ in range(n)]
alp = list(string.ascii_lowercase)
cnt = [0] * 26
mi = ""
leng = 100
for i in range(n):
if len(lis[i]) < leng:
leng = len(lis[i])
mi = lis[i]
for j in mi:
tmp = alp.index(j)
cnt[tmp] += 1
alis = [0]*26
for k in lis:
tmp = [0]*26
for i in k:
t = alp.index(i)
tmp[t] += 1
for j in range(26):
if tmp[j] >= cnt[j]:
alis[j] = cnt[j]
else:
alis[j] = 0
ans = ""
if sum(alis) == 0:
print("")
exit()
else:
for i in range(26):
ans += alp[i]*alis[i]
ans = sorted(ans)
for j in ans:
print(j, end="")
|
s563804113
|
Accepted
| 38
| 9,912
| 347
|
import string
n = int(input())
lis = [input() for _ in range(n)]
alp = list(string.ascii_lowercase)
cnt = [100] * 26
for i in lis:
tmp = [0] * 26
for j in i:
t = alp.index(j)
tmp[t] += 1
for i in range(26):
cnt[i] = min(cnt[i], tmp[i])
ans = ""
for k in range(26):
ans += alp[k]*cnt[k]
print(ans)
|
s787756333
|
p03371
|
u265118937
| 2,000
| 262,144
|
Wrong Answer
| 32
| 9,196
| 210
|
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
|
a, b, c, x, y =map(int, input().split())
ab = 2*c
i = 1
cost = 0
while True:
cost = i *ab
if i <= x or i <= y:
break
i += 1
cost += a *(max(0, (x-i)))
cost += b *(max(0, (y-i)))
print(cost)
|
s936016884
|
Accepted
| 725
| 9,216
| 249
|
a, b, c, x, y =map(int, input().split())
ab = 2*c
i = 0
cost = 0
minCost = 10**10
while i < 10**6:
cost = i*ab
cost += a *(max(0, (x-i)))
cost += b *(max(0, (y-i)))
if minCost >= cost:
minCost = cost
i += 1
print(minCost)
|
s248298662
|
p03557
|
u940117191
| 2,000
| 262,144
|
Wrong Answer
| 806
| 23,156
| 788
|
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.
|
def lower(A, b):
i = -1
j = len(A)
while j - i > 1:
m = (i + j) // 2
if A[m] < b:
i = m
else:
j = m
return i + 1
def upper(C, b):
i = -1
j = len(C)
#print('upper', C, b)
while j - i > 1:
m = (i + j) // 2
#print(i, m, j, C[m] > b)
if C[m] > b:
i = m
else:
j = m
return i + 1
def answer(N, A, B, C):
A.sort()
B.sort()
C.sort()
#print(A, B, C)
count = 0
for b in B:
#print(b, lower(A, b), upper(C, b))
count += lower(A, b) * upper(C, b)
return count
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
print(answer(N, A, B, C))
|
s266717879
|
Accepted
| 835
| 23,156
| 989
|
def lower_elements(A, b):
lower_bound = -1
upper_bound = len(A)
while upper_bound - lower_bound > 1:
middle = (lower_bound + upper_bound) // 2
if A[middle] < b:
lower_bound = middle
else:
upper_bound = middle
return lower_bound + 1
def upper_elements(C, b):
i = -1
j = len(C)
while j - i > 1:
m = (i + j) // 2
if C[m] > b:
j = m
else:
i = m
return len(C) - j
def answer(N, A, B, C):
A.sort()
B.sort()
C.sort()
count = 0
for b in B:
count += lower_elements(A, b) * upper_elements(C, b)
return count
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
print(answer(N, A, B, C))
|
s343853128
|
p03457
|
u485435834
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 211
|
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())
prev_t = 0
for i in range(n):
t, x, y = map(int, input().split())
if (x + y) > (t - prev_t) or (x + y + (t - prev_t)) % 2:
print("No")
exit()
prev_t = t
print("Yes")
|
s455323702
|
Accepted
| 384
| 3,060
| 296
|
t, x, y = 0, 0, 0
for i in range(int(input())):
next_t, next_x, next_y = map(int, input().split())
diff = abs(x - next_x) + abs(y - next_y)
if diff > (next_t - t) or (diff - (next_t - t)) % 2 == 1:
print("No")
exit(0)
t, x, y, = next_t, next_x, next_y
print("Yes")
|
s946557823
|
p00003
|
u945249026
| 1,000
| 131,072
|
Wrong Answer
| 30
| 5,716
| 120
|
Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so.
|
import sys
a = []
for line in sys.stdin:
a.append(line)
for i in a:
sum = i[0] + i[1]
print(len(str(sum)))
|
s148341212
|
Accepted
| 30
| 5,728
| 237
|
N = int(input())
lst = []
for _ in range(N):
a, b, c = map(int,input().split())
lst.append([a, b, c])
for i in lst:
i.sort()
if i[0] ** 2 + i[1] ** 2 == i[2] ** 2:
print('YES')
else:
print('NO')
|
s137846281
|
p03997
|
u705296057
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 67
|
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)
|
s314018939
|
Accepted
| 17
| 2,940
| 72
|
a = int(input())
b = int(input())
h = int(input())
print(int((a+b)*h/2))
|
s372575082
|
p03361
|
u181526702
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 548
|
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`. However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black. Determine if square1001 can achieve his objective.
|
h,w = map(int, input().split())
s = []
for i in range(h):
row = list(input().strip())
s.append(row)
flag = 'YES'
for i in range(h):
for j in range(w):
if s[i][j] == '#':
if i != 0 and s[i-1][j] == '#':
continue
elif i != h-1 and s[i+1][j] == '#':
continue
elif j != 0 and s[i][j-1] == '#':
continue
elif j != w-1 and s[i][j+1] == '#':
continue
flag = 'NO'
else:
continue
print(flag)
|
s700843402
|
Accepted
| 18
| 3,064
| 549
|
h,w = map(int, input().split())
s = []
for i in range(h):
row = list(input().strip())
s.append(row)
flag = 'Yes'
for i in range(h):
for j in range(w):
if s[i][j] == '#':
if i != 0 and s[i-1][j] == '#':
continue
elif i != h-1 and s[i+1][j] == '#':
continue
elif j != 0 and s[i][j-1] == '#':
continue
elif j != w-1 and s[i][j+1] == '#':
continue
flag = 'No'
else:
continue
print(flag)
|
s501930664
|
p04029
|
u456879806
| 2,000
| 262,144
|
Wrong Answer
| 27
| 8,976
| 39
|
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?
|
N = int(input())
print(N * (N + 1) / 2)
|
s204568446
|
Accepted
| 26
| 9,124
| 44
|
N = int(input())
print(int(N * (N + 1) / 2))
|
s286650586
|
p02300
|
u022407960
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,704
| 2,202
|
Find the convex hull of a given set of points P. In other words, find the smallest convex polygon containing all the points of P. Here, in a convex polygon, all interior angles are less than or equal to 180 degrees. Please note that you should find all the points of P on both corner and boundary of the convex polygon.
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
7
2 1
0 0
1 2
2 2
4 2
1 3
3 3
output:
5
0 0
2 1
4 2
3 3
1 3
The operator module functions allow multiple levels of sorting. For example, to sort by grade then by age:
sorted(student_tuples, key=itemgetter(1,2))
[('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]
sorted(student_objects, key=attrgetter('grade', 'age'))
[('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]
"""
import sys
from operator import attrgetter
EPS = 1e-9
def cross(a, b):
return a.real * b.imag - a.imag * b.real
def dot(a, b):
return a.real * b.real + a.imag * b.imag
def check_ccw(p0, p1, p2):
a, b = p1 - p0, p2 - p0
if cross(a, b) > EPS:
# print('COUNTER_CLOCKWISE')
flag = 1
elif cross(a, b) < -1 * EPS:
# print('CLOCKWISE')
flag = -1
elif dot(a, b) < -1 * EPS:
# print('ONLINE_BACK')
flag = 2
elif abs(a) < abs(b):
# print('ONLINE_FRONT')
flag = -2
else:
# print('ON_SEGMENT')
flag = 0
return flag
def convex_check_Andrew(_polygon):
upper, lower = list(), list()
_polygon.sort(key=attrgetter('real', 'imag'))
upper.extend((_polygon[0], _polygon[1]))
lower.extend((_polygon[-1], _polygon[-2]))
for i in range(2, points):
n1 = len(upper)
if n1 >= 2 and check_ccw(upper[n1 - 2], upper[n1 - 1], _polygon[i]) != -1:
n1 -= 1
upper.pop()
upper.append(_polygon[i])
for j in range(points - 3, -1, -1):
n2 = len(lower)
if n2 >= 2 and check_ccw(lower[n2 - 2], lower[n2 - 1], _polygon[j]) != -1:
n2 -= 1
lower.pop()
lower.append(_polygon[j])
lower.reverse()
upper_size = len(upper)
for k in range(points - 2, 0, -1):
if k < upper_size:
lower.append(upper[k])
return lower
if __name__ == '__main__':
_input = sys.stdin.readlines()
points = int(_input[0])
p_info = map(lambda x: x.split(), _input[1:])
polygon = [int(x) + int(y) * 1j for x, y in p_info]
ans = convex_check_Andrew(polygon)
for ele in ans:
print(int(ele.real), int(ele.imag))
|
s478036389
|
Accepted
| 750
| 31,048
| 2,049
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
7
2 1
0 0
1 2
2 2
4 2
1 3
3 3
output:
5
0 0
2 1
4 2
3 3
1 3
"""
import sys
from operator import attrgetter
EPS = 1e-9
def cross(a, b):
return a.real * b.imag - a.imag * b.real
def dot(a, b):
return a.real * b.real + a.imag * b.imag
def check_ccw(p0, p1, p2):
a, b = p1 - p0, p2 - p0
if cross(a, b) > EPS:
# print('COUNTER_CLOCKWISE')
flag = 1
elif cross(a, b) < -1 * EPS:
# print('CLOCKWISE')
flag = -1
elif dot(a, b) < -1 * EPS:
# print('ONLINE_BACK')
flag = 2
elif abs(a) < abs(b):
# print('ONLINE_FRONT')
flag = -2
else:
# print('ON_SEGMENT')
flag = 0
return flag
def convex_check_Andrew(_polygon):
upper, lower = list(), list()
_polygon.sort(key=attrgetter('real', 'imag'))
upper.extend((_polygon[0], _polygon[1]))
lower.extend((_polygon[-1], _polygon[-2]))
for i in range(2, points):
n1 = len(upper)
while n1 >= 2 and check_ccw(upper[n1 - 2], upper[n1 - 1], _polygon[i]) == 1:
n1 -= 1
upper.pop()
upper.append(_polygon[i])
for j in range(points - 3, -1, -1):
n2 = len(lower)
while n2 >= 2 and check_ccw(lower[n2 - 2], lower[n2 - 1], _polygon[j]) == 1:
n2 -= 1
lower.pop()
lower.append(_polygon[j])
# change to ccw inplace
lower.reverse()
# find bottom-left of the hull and split lower
lower_min = min(lower, key=attrgetter('imag', 'real'))
init_index = lower.index(lower_min)
# ignore upper part's last and first, in ccw
return lower[init_index:] + upper[-2:0:-1] + lower[:init_index]
if __name__ == '__main__':
_input = sys.stdin.readlines()
points = int(_input[0])
p_info = map(lambda x: x.split(), _input[1:])
polygon = [int(x) + int(y) * 1j for x, y in p_info]
ans = convex_check_Andrew(polygon)
print(len(ans))
for ele in ans:
print(int(ele.real), int(ele.imag))
|
s481479510
|
p03377
|
u864197622
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 66
|
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());"YNEOS"[x not in range(a,a+b+1)::2]
|
s789858355
|
Accepted
| 17
| 2,940
| 60
|
a,b,x=map(int,input().split());print(["NO","YES"][~b<a-x<1])
|
s279261388
|
p02255
|
u659034691
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,608
| 178
|
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
N=int(input())
A=[int(i) for i in input().split()]
for i in range(1,N):
j=i-1
v=A[i]
while j>=0 and A[j]>v:
A[j+1]=A[j]
j-=1
A[j+1]=v
print(A)
|
s116997759
|
Accepted
| 20
| 7,712
| 349
|
# your code goes here
N=int(input())
A=[int(i) for i in input().split()]
B=""
for k in range(N-1):
B+=str(A[k])+" "
B+=str(A[N-1])
print(B)
for i in range(1,N):
j=i-1
v=A[i]
while j>=0 and A[j]>v:
A[j+1]=A[j]
j-=1
A[j+1]=v
B=""
for k in range(N-1):
B+=str(A[k])+" "
B+=str(A[N-1])
print(B)
|
s454351783
|
p02741
|
u112317104
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 159
|
Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
|
def solve():
N = int(input())
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
return l[N-1]
|
s949186830
|
Accepted
| 17
| 3,060
| 175
|
def solve():
N = int(input())
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
return l[N-1]
print(solve())
|
s993498330
|
p03377
|
u591764610
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 90
|
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.
|
l = [int(i) for i in input().split()]
print(['YES', 'NO'][(l[0]+l[1]>=l[2])&(l[0]<=l[2])])
|
s114443574
|
Accepted
| 17
| 2,940
| 94
|
l = [int(i) for i in input().split()]
print('YES' if (l[0]+l[1]>=l[2])&(l[0]<=l[2]) else 'NO')
|
s893287352
|
p02694
|
u200527996
| 2,000
| 1,048,576
|
Wrong Answer
| 20
| 9,148
| 132
|
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())
now_money = 100
for i in range(3761):
now_money += now_money*0.01
if now_money >= X:
print(i)
exit()
|
s567186995
|
Accepted
| 22
| 9,192
| 155
|
import math
X = int(input())
now_money = 100
for i in range(1,3762):
now_money += math.floor(now_money*0.01)
if now_money >= X:
print(i)
exit()
|
s293519461
|
p03719
|
u239653493
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 81
|
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
a,b,c=map(int,input().split())
if b<=a<=c:
print("Yes")
else:
print("No")
|
s568030647
|
Accepted
| 17
| 2,940
| 81
|
a,b,c=map(int,input().split())
if a<=c<=b:
print("Yes")
else:
print("No")
|
s023099034
|
p04011
|
u432805419
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 118
|
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
|
a = [int(input()) for i in range(4)]
if a[0] <= a[1]:
print(a[0]*a[2])
else:
print(a[1]*a[2] + (a[0]-a[1]+1)*a[3])
|
s537647990
|
Accepted
| 17
| 2,940
| 118
|
a = int(input())
b = int(input())
c = int(input())
d = int(input())
if a > b:
print(b*c+(a-b)*d)
else:
print(a*c)
|
s305457708
|
p03696
|
u785205215
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 143
|
You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of `(`, X and `)` in this order is also a correct bracket sequence. * If X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence. * Every correct bracket sequence can be derived from the rules above. Find the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one.
|
n = int(input())
a = input()
l = a.count("(")
r = a.count(")")
for i in range(r):
a = "("+a
for j in range(l):
a = a+")"
print(a)
|
s957900027
|
Accepted
| 18
| 2,940
| 326
|
def main():
n = input()
S = input()
cnt = 0
m = 0
for s in S:
if s == '(':
cnt += 1
else:
cnt -= 1
if cnt < 0:
m += 1
cnt += 1
ans = "("*m+S+")"*cnt
print(ans)
if __name__ == "__main__":
main()
|
s049744592
|
p03478
|
u626337957
| 2,000
| 262,144
|
Wrong Answer
| 33
| 3,060
| 216
|
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())
ans = 0
for num in range(1, N+1):
str_num = str(num)
sum_char = 0
for char in str_num:
sum_char += int(char)
if sum_char >= A and sum_char <= B:
ans += 1
print(ans)
|
s096856910
|
Accepted
| 36
| 2,940
| 228
|
N, A, B = map(int, input().split())
ans = 0
for num in range(1, N+1):
str_num = str(num)
sum_char = 0
for char in str_num:
sum_char += int(char)
if sum_char >= A and sum_char <= B:
ans += int(str_num)
print(ans)
|
s784680923
|
p03693
|
u865413330
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 55
|
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?
|
l= list(input().split())
print(int(l[0] + l[1] + l[2]))
|
s705379395
|
Accepted
| 18
| 2,940
| 91
|
l = list(input().split())
print("YES") if int(l[0] + l[1] + l[2]) % 4 == 0 else print("NO")
|
s361871287
|
p03759
|
u821775079
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 65
|
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
a,b,c=map(int,input().split())
print("Yes" if b-a==c-b else "No")
|
s207248109
|
Accepted
| 17
| 2,940
| 65
|
a,b,c=map(int,input().split())
print("YES" if b-a==c-b else "NO")
|
s361019559
|
p03957
|
u357751375
| 1,000
| 262,144
|
Wrong Answer
| 18
| 3,444
| 164
|
This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters. Mr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way. You are given a string s consisting of uppercase English letters. Determine whether the string `CF` can be obtained from the string s by deleting some characters.
|
s = list(input())
for i in range(len(s)):
if s[i] == 'C':
for i in range(len(s)):
if s[i] == 'F':
print('Yes')
print('No')
|
s963283565
|
Accepted
| 18
| 3,060
| 235
|
s = list(input())
i = 0
while i < len(s):
if s[i] == 'C':
j = i + 1
while j < len(s):
if s[j] == 'F':
print('Yes')
exit(0)
j = j + 1
i = i + 1
print('No')
|
s692124568
|
p03943
|
u715114989
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 107
|
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 == c or a+c == b or b+c ==a:
print("yes")
else:
print("no")
|
s857904207
|
Accepted
| 17
| 2,940
| 107
|
a,b,c = map(int,input().split())
if a+b == c or a+c == b or b+c ==a:
print("Yes")
else:
print("No")
|
s392498372
|
p03448
|
u350093546
| 2,000
| 262,144
|
Wrong Answer
| 50
| 3,064
| 190
|
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
a=int(input())
b=int(input())
c=int(input())
x=int(input())
cnt=0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
if a*500+b*100+c*50==x:
cnt+=1
print(cnt)
|
s252341580
|
Accepted
| 50
| 3,060
| 191
|
a=int(input())
b=int(input())
c=int(input())
x=int(input())
cnt=0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
if i*500+j*100+k*50==x:
cnt+=1
print(cnt)
|
s307345528
|
p03351
|
u192903163
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 160
|
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
a,b,c,d=map(int,input().split())
if abs(c-a)>d:
if abs(b-a)>d:
if abs(c-b)>d:
print("Yes")
else:
print("No")
else:
print("No")
else:
print("Yes")
|
s167991719
|
Accepted
| 17
| 2,940
| 160
|
a,b,c,d=map(int,input().split())
if abs(c-a)>d:
if abs(b-a)>d:
print("No")
else:
if abs(c-b)>d:
print("No")
else:
print("Yes")
else:
print("Yes")
|
s336244966
|
p02618
|
u060752882
| 2,000
| 1,048,576
|
Wrong Answer
| 43
| 9,452
| 491
|
AtCoder currently hosts three types of contests: ABC, ARC, and AGC. As the number of users has grown, in order to meet the needs of more users, AtCoder has decided to increase the number of contests to 26 types, from AAC to AZC. For convenience, we number these 26 types as type 1 through type 26. AtCoder wants to schedule contests for D days so that user satisfaction is as high as possible. For every day, AtCoder will hold exactly one contest, and each contest will end on that day. The satisfaction is calculated as follows. * The satisfaction at the beginning of day 1 is 0. Satisfaction can be negative. * Holding contests increases satisfaction. The amount of increase will vary depending on a variety of factors. Specifically, we know in advance that holding a contest of type i on day d will increase the satisfaction by s_{d,i}. * If a particular type of contest is not held for a while, the satisfaction decreases. Each contest type i has an integer c_i, and at the end of each day d=1,2,...,D, the satisfaction decreases as follows. Let \mathrm{last}(d,i) be the last day before day d (including d) on which a contest of type i was held. If contests of type i have never been held yet, we define \mathrm{last}(d,i)=0. At the end of day d, the satisfaction decreases by \sum _{i=1}^{26}c_i \times (d-\mathrm{last}(d,i)). Please schedule contests on behalf of AtCoder. If the satisfaction at the end of day D is S, you will get a score of \max(10^6 + S, 0). There are 50 test cases, and the score of a submission is the total scores for each test case. You can make submissions multiple times, and the highest score among your submissions will be your score.
|
D=int(input())
c = [int(i) for i in input().split()]
s=[]
for i in range(D):
s.append([int(j) for j in input().split()])
tst = [0] * 26
last = [0] * 26
ans =[]
for i in range(D):
a = s[i]
x,y = 0,0
for i,v in enumerate(a):
if x < v:
x = v
y = i
print(x,y)
ans.append(y+1)
tst[y] += a[y]
last[y] = i+1
for k in range(26):
if k != y:
tst[k] -= (i+1 - last[k])*c[k]
print(tst)
for i in ans:
print(i)
|
s735749561
|
Accepted
| 39
| 9,516
| 465
|
D=int(input())
c = [int(i) for i in input().split()]
s=[]
for i in range(D):
s.append([int(j) for j in input().split()])
tst = [0] * 26
last = [0] * 26
ans =[]
for i in range(D):
a = s[i]
x,y = 0,0
for i,v in enumerate(a):
if x < v:
x = v
y = i
ans.append(y+1)
tst[y] += a[y]
last[y] = i+1
for k in range(26):
if k != y:
tst[k] -= (i+1 - last[k])*c[k]
for i in ans:
print(i)
|
s272720796
|
p03228
|
u256464928
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 185
|
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person. Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.
|
A, B, K = map(int,input().split())
for i in range(K):
if i % 2 == 0:
if A % 2 == 1:
A -= 1
B += A // 2
else:
if B % 2 == 1:
B -= 1
A += B // 2
print(A,B)
|
s243443693
|
Accepted
| 17
| 2,940
| 201
|
A, B, K = map(int,input().split())
for i in range(K):
if i % 2 == 0:
if A % 2 == 1:
A -= 1
A //= 2
B += A
else:
if B % 2 == 1:
B -= 1
B //= 2
A += B
print(A,B)
|
s219835843
|
p03543
|
u444856278
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 271
|
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
|
s = str
End = False
S = input()
A,B,C,D = int(S[0]),int(S[1]),int(S[2]),int(S[3])
for i in [B,-1*B]:
for j in [C,-1*C]:
for k in [D,-1*D]:
if A + i + j + k == 7:
print("{:d}{:+d}{:+d}{:+d}=7".format(A,i,j,k))
exit()
|
s543003570
|
Accepted
| 20
| 2,940
| 99
|
N = input()
if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:
print("Yes")
else:
print("No")
|
s384897406
|
p03624
|
u170765582
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,188
| 108
|
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.
|
flag=1
a=input()
for i in 'abcdefghijklmnopqrstuvwxyz':
if i in a:flag=0;break
print('None'if flag else i)
|
s501326139
|
Accepted
| 17
| 3,188
| 113
|
flag=1
a=input()
for i in 'abcdefghijklmnopqrstuvwxyz':
if i not in a:flag=0;break
print('None'if flag else i)
|
s097895688
|
p03494
|
u413970908
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 243
|
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.
|
input()
num_list = map(int, input().split())
if(all(x % 2 == 0 for x in num_list)):
print(0)
else:
min_num = min(num_list)
cnt = 0
while min_num % 2 == 0:
cnt = cnt + 1
min_num = int(min_num / 2)
print(cnt)
|
s955960515
|
Accepted
| 18
| 2,940
| 141
|
input()
A = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for a in A):
A = [a/2 for a in A]
count += 1
print(count)
|
s553808617
|
p03478
|
u792586809
| 2,000
| 262,144
|
Wrong Answer
| 35
| 3,060
| 161
|
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 = [int(i) for i in input().split()]
s = 0
def f(x):
return [int(i) for i in str(x)[:]]
for i in range(n):
s+= i if a<=sum(f(i))<=b else 0
print( s)
|
s071989514
|
Accepted
| 34
| 3,060
| 160
|
n, a, b = [int(i) for i in input().split()]
s = 0
def f(x):
return [int(i) for i in str(x)]
for i in range(n+1):
s+= i if a<=sum(f(i))<=b else 0
print( s)
|
s768318219
|
p03151
|
u557494880
| 2,000
| 1,048,576
|
Wrong Answer
| 120
| 18,356
| 311
|
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his _readiness_ for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination. Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness. For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions: * The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal. * For every i, B_i \leq C_i holds. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
|
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if sum(A) < sum(B):
print(-1)
quit()
C = []
c = 0
for i in range(N):
if A[i] < B[i]:
c += B[i] - A[i]
else:
C.append(A[i] - B[i])
C.sort()
while c > 0:
x = C.pop()
c -= x
print(len(C))
|
s379762007
|
Accepted
| 121
| 18,292
| 313
|
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if sum(A) < sum(B):
print(-1)
quit()
C = []
c = 0
for i in range(N):
if A[i] < B[i]:
c += B[i] - A[i]
else:
C.append(A[i] - B[i])
C.sort()
while c > 0:
x = C.pop()
c -= x
print(N-len(C))
|
s098771816
|
p03636
|
u773686010
| 2,000
| 262,144
|
Wrong Answer
| 26
| 9,020
| 63
|
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.
|
moji = str(input())
print(moji[0] + str(len(moji)) + moji[-1])
|
s340943854
|
Accepted
| 25
| 9,028
| 65
|
moji = str(input())
print(moji[0] + str(len(moji)-2) + moji[-1])
|
s956538645
|
p03501
|
u350093546
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 48
|
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.
|
n,a,b=map(int,input().split())
print(max(a*n,b))
|
s525741292
|
Accepted
| 19
| 3,064
| 49
|
n,a,b=map(int,input().split())
print(min(a*n,b))
|
s777840415
|
p00124
|
u546285759
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,672
| 257
|
スポーツの大会にはリーグ戦とトーナメント戦があります。サッカーのリーグ戦では勝・負・引分にそれぞれ点数を付け、その勝ち点で順位を競います。勝ち点はそれぞれ勝(3点)、負(0点)、引分(1点)です。 チーム数とリーグ戦の成績を入力とし、成績の良い順(勝ち点の多い順)に並べ替え、チーム名と勝ち点を出力するプログラムを作成してください。勝ち点が同点の場合は入力順に出力してください。
|
while True:
n = int(input())
if n==0:break
d=dict()
for _ in range(n):
t = input().split()
d[t[0]]=int(t[1])*3+int(t[3])*1
print()
for s in sorted(d.items(), key=lambda x:x[1])[::-1]:
print(s[0]+','+str(s[1]))
|
s927484636
|
Accepted
| 20
| 7,688
| 372
|
b = False
while True:
n = int(input())
if n == 0:
break
dataset = []
if b:
print()
b = True
for _ in range(n):
name, w, l, d = input().split()
dataset.append((name, 3*int(w) + int(d), n-len(dataset)))
for name, score, _ in sorted(dataset, key=lambda x: (x[1], x[2]))[::-1]:
print(name + "," + str(score))
|
s257388159
|
p02401
|
u355726239
| 1,000
| 131,072
|
Wrong Answer
| 30
| 6,744
| 302
|
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
while True:
a, op, b = input().split()
a, b = int(a), int(b)
if op == '?':
break
elif op == '+':
print(a + b)
elif op == '-':
print(a - b)
elif op == '*':
print(a * b)
else:
print(a / b)
|
s431064346
|
Accepted
| 30
| 6,724
| 303
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
while True:
a, op, b = input().split()
a, b = int(a), int(b)
if op == '?':
break
elif op == '+':
print(a + b)
elif op == '-':
print(a - b)
elif op == '*':
print(a * b)
else:
print(a // b)
|
s704846653
|
p02283
|
u890722286
| 2,000
| 131,072
|
Wrong Answer
| 30
| 7,696
| 1,197
|
Search trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue. Binary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property: * Let $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \leq y.key$. The following figure shows an example of the binary search tree. For example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk. A binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields _left_ , _right_ , and _p_ that point to the nodes corresponding to its left child, its right child, and its parent, respectively. To insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree. 1 insert(T, z) 2 y = NIL // parent of x 3 x = 'the root of T' 4 while x ≠ NIL 5 y = x // set the parent 6 if z.key < x.key 7 x = x.left // move to the left child 8 else 9 x = x.right // move to the right child 10 z.p = y 11 12 if y == NIL // T is empty 13 'the root of T' = z 14 else if z.key < y.key 15 y.left = z // z is the left child of y 16 else 17 y.right = z // z is the right child of y Write a program which performs the following operations to a binary search tree $T$. * insert $k$: Insert a node containing $k$ as key into $T$. * print: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively. You should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.
|
def insert(r, n):
if 0 == len(T):
T[n] = [None, None]
else:
if n < r:
left = T[r][0]
if left == None:
T[r][0] = n
T[n] = [None, None]
else:
insert(left, n)
if r < n:
right = T[r][1]
if right == None:
T[r][1] = n
T[n] = [None, None]
else:
insert(right, n)
def print_inorder(r):
left = T[r][0]
right = T[r][1]
ans = ""
if left != None:
ans += print_inorder(left)
ans += " {}".format(r)
if right != None:
ans += print_inorder(right)
return ans
def print_preorder(r):
left = T[r][0]
right = T[r][1]
ans = " {}".format(r)
if left != None:
ans += print_inorder(left)
if right != None:
ans += print_inorder(right)
return ans
n = int(input())
T = {}
root = None
for i in range(n):
inst = input()
if inst[0] == 'i':
num = int(inst[7:])
if i == 0:
root = num
insert(root, num)
elif inst[0] == 'p':
print(print_inorder(root))
print(print_preorder(root))
|
s989522690
|
Accepted
| 9,030
| 105,660
| 1,199
|
def insert(r, n):
if 0 == len(T):
T[n] = [None, None]
else:
if n < r:
left = T[r][0]
if left == None:
T[r][0] = n
T[n] = [None, None]
else:
insert(left, n)
if r < n:
right = T[r][1]
if right == None:
T[r][1] = n
T[n] = [None, None]
else:
insert(right, n)
def print_inorder(r):
left = T[r][0]
right = T[r][1]
ans = ""
if left != None:
ans += print_inorder(left)
ans += " {}".format(r)
if right != None:
ans += print_inorder(right)
return ans
def print_preorder(r):
left = T[r][0]
right = T[r][1]
ans = " {}".format(r)
if left != None:
ans += print_preorder(left)
if right != None:
ans += print_preorder(right)
return ans
n = int(input())
T = {}
root = None
for i in range(n):
inst = input()
if inst[0] == 'i':
num = int(inst[7:])
if i == 0:
root = num
insert(root, num)
elif inst[0] == 'p':
print(print_inorder(root))
print(print_preorder(root))
|
s398153685
|
p02613
|
u384744829
| 2,000
| 1,048,576
|
Wrong Answer
| 30
| 8,988
| 19
|
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=input()
print(N)
|
s709018899
|
Accepted
| 161
| 16,228
| 254
|
N=int(input())
list=[]
for i in range(N):
list.append(str(input()))
a = list.count("AC")
b = list.count("WA")
c = list.count("TLE")
d = list.count("RE")
print("AC x "+ str(a))
print("WA x "+ str(b))
print("TLE x "+ str(c))
print("RE x "+ str(d))
|
s396166666
|
p03447
|
u923659712
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 97
|
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
|
x=int(input())
a=int(input())
b=int(input())
s=x-a
k=0
while (s>b):
s=s-b
k+=1
print(k)
|
s581780715
|
Accepted
| 17
| 2,940
| 86
|
x=int(input())
a=int(input())
b=int(input())
s=x-a
while (s>=b):
s-=b
print(s)
|
s591327281
|
p03407
|
u043236471
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 87
|
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
A, B, C = [int(x) for x in input().split()]
print('Yes') if A + B <= C else print('No')
|
s231019305
|
Accepted
| 17
| 2,940
| 87
|
A, B, C = [int(x) for x in input().split()]
print('Yes') if A + B >= C else print('No')
|
s696965849
|
p03860
|
u086485448
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 25
|
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
print("A"+input()[8]+"c")
|
s702789831
|
Accepted
| 17
| 2,940
| 24
|
print("A%cC"%input()[8])
|
s685443082
|
p03852
|
u323210830
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 96
|
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
|
en=input()
print(en)
if en=="a"or"e"or"i"or"o"or"u":
print("vowel")
else:
print("consonant")
|
s971739946
|
Accepted
| 17
| 2,940
| 107
|
en=input()
if en=="a"or en=="e" or en=="i"or en=="o"or en=="u":
print("vowel")
else:
print("consonant")
|
s849579043
|
p03545
|
u858506767
| 2,000
| 262,144
|
Wrong Answer
| 27
| 9,160
| 718
|
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.
|
S = input()
if int(S[0])+int(S[1])+int(S[2])+int(S[3])==7:
print(f'{S[0]}+{S[1]}+{S[2]}+{S[3]}==7')
elif int(S[0])+int(S[1])+int(S[2])-int(S[3])==7:
print(f'{S[0]}+{S[1]}+{S[2]}-{S[3]}==7')
elif int(S[0])+int(S[1])-int(S[2])+int(S[3])==7:
print(f'{S[0]}+{S[1]}-{S[2]}+{S[3]}==7')
elif int(S[0])-int(S[1])+int(S[2])+int(S[3])==7:
print(f'{S[0]}-{S[1]}+{S[2]}+{S[3]}==7')
elif int(S[0])+int(S[1])-int(S[2])-int(S[3])==7:
print(f'{S[0]}+{S[1]}-{S[2]}-{S[3]}==7')
elif int(S[0])-int(S[1])+int(S[2])-int(S[3])==7:
print(f'{S[0]}-{S[1]}+{S[2]}-{S[3]}==7')
elif int(S[0])-int(S[1])-int(S[2])+int(S[3])==7:
print(f'{S[0]}-{S[1]}-{S[2]}+{S[3]}==7')
else:
print(f'{S[0]}-{S[1]}-{S[2]}-{S[3]}==7')
|
s346611027
|
Accepted
| 26
| 9,148
| 710
|
S = input()
if int(S[0])+int(S[1])+int(S[2])+int(S[3])==7:
print(f'{S[0]}+{S[1]}+{S[2]}+{S[3]}=7')
elif int(S[0])+int(S[1])+int(S[2])-int(S[3])==7:
print(f'{S[0]}+{S[1]}+{S[2]}-{S[3]}=7')
elif int(S[0])+int(S[1])-int(S[2])+int(S[3])==7:
print(f'{S[0]}+{S[1]}-{S[2]}+{S[3]}=7')
elif int(S[0])-int(S[1])+int(S[2])+int(S[3])==7:
print(f'{S[0]}-{S[1]}+{S[2]}+{S[3]}=7')
elif int(S[0])+int(S[1])-int(S[2])-int(S[3])==7:
print(f'{S[0]}+{S[1]}-{S[2]}-{S[3]}=7')
elif int(S[0])-int(S[1])+int(S[2])-int(S[3])==7:
print(f'{S[0]}-{S[1]}+{S[2]}-{S[3]}=7')
elif int(S[0])-int(S[1])-int(S[2])+int(S[3])==7:
print(f'{S[0]}-{S[1]}-{S[2]}+{S[3]}=7')
else:
print(f'{S[0]}-{S[1]}-{S[2]}-{S[3]}=7')
|
s600162815
|
p03469
|
u212572201
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 41
|
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()
SS=S.replace("7","8")
print(SS)
|
s379379571
|
Accepted
| 17
| 2,940
| 49
|
S=input().split("/")
print("2018/"+S[1]+"/"+S[2])
|
s564756035
|
p02742
|
u556069480
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 68
|
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:
|
N , M = map( int , input().split() )
print( int( (N * N + 1) / 2 ) )
|
s446502916
|
Accepted
| 19
| 2,940
| 106
|
N , M = map ( int, input().split() )
if N==1 or M==1:
print(1)
else:
print( int( ( N * M + 1) / 2 ) )
|
s831888977
|
p04044
|
u034066795
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 332
|
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
|
N, L = map(int, input().split())
iroha = ''
for i in range(N):
token = input()
if i == 0:
iroha = token
for j in range(L):
if token[j] < iroha[j]:
iroha = token + iroha
break
elif token[j] > iroha[j]:
iroha = iroha + token
break
print(iroha)
|
s027658121
|
Accepted
| 23
| 3,572
| 173
|
from functools import reduce
N, L = map(int, input().split())
iroha = []
for i in range(N):
iroha.append(input())
iroha.sort()
print(reduce(lambda a,b: a+b, iroha))
|
s956686171
|
p02394
|
u175111751
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,668
| 124
|
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 = [int(x) for x in input().split()]
print('Yes' if x - r < 0 or y - r < 0 or x + r > W or y + r > H else 'No')
|
s603118771
|
Accepted
| 50
| 7,704
| 124
|
W, H, x, y, r = [int(x) for x in input().split()]
print('No' if x - r < 0 or y - r < 0 or x + r > W or y + r > H else 'Yes')
|
s830026198
|
p03962
|
u905582793
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 42
|
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.
|
print(set(list(map(int,input().split()))))
|
s053872667
|
Accepted
| 17
| 2,940
| 47
|
print(len(set(list(map(int,input().split())))))
|
s667932474
|
p03251
|
u340781749
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 209
|
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())
xxx = list(map(int, input().split()))
yyy = list(map(int, input().split()))
xxx.append(n)
yyy.append(m)
mx = max(xxx)
my = min(yyy)
print('No War' if mx < my else 'War')
|
s205115460
|
Accepted
| 20
| 3,316
| 209
|
n, m, x, y = map(int, input().split())
xxx = list(map(int, input().split()))
yyy = list(map(int, input().split()))
xxx.append(x)
yyy.append(y)
mx = max(xxx)
my = min(yyy)
print('No War' if mx < my else 'War')
|
s988018172
|
p03546
|
u262597910
| 2,000
| 262,144
|
Wrong Answer
| 98
| 4,384
| 886
|
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 collections
h,w = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
a = [list(map(int, input().split())) for _ in range(h)]
result = [0]*10
def way(n,e,i,p):
for j in range(0,10):
if (n == j):
continue
if (n == 1):
if (e < result[i]):
result[i] = e
break
if (e + c[n][j] < p):
print(n,e,i,p,j)
q = e + c[n][j]
way(j,q,i,p)
for i in range(0,10):
result[i] = c[i][1]
way(i,0,i,result[i])
print(result)
r = []
for w in range(0,10):
t = 0
for k in range(0,h):
l = collections.Counter(a[k])
t += l[w]
r.append(t)
print(r)
ans = 0
for z in range(0,10):
ans += result[z] * r[z]
print (ans)
|
s360323894
|
Accepted
| 37
| 3,444
| 402
|
h,w = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
a = [list(map(int, input().split())) for _ in range(h)]
for k in range(10):
for i in range(10):
for j in range(10):
c[i][j] = min(c[i][j], c[i][k]+c[k][j])
ans = 0
for i in range(h):
for j in range(w):
if (a[i][j]!=-1):
ans += c[a[i][j]][1]
print(ans)
|
s137502552
|
p03352
|
u790812284
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 187
|
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
|
import math
x=int(input())
beki_list = []
for i in range(1,int(math.sqrt(1000))+1):
for j in range(1,11):
if i**j<=x:
beki_list.append(i**j)
print(max(beki_list))
|
s058829479
|
Accepted
| 17
| 3,060
| 187
|
import math
x=int(input())
beki_list = []
for i in range(1,int(math.sqrt(1000))+1):
for j in range(2,11):
if i**j<=x:
beki_list.append(i**j)
print(max(beki_list))
|
s925990936
|
p00016
|
u777299405
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,864
| 234
|
When a boy was cleaning up after his grand father passing, he found an old paper: In addition, other side of the paper says that "go ahead a number of steps equivalent to the first integer, and turn clockwise by degrees equivalent to the second integer". His grand mother says that Sanbonmatsu was standing at the center of town. However, now buildings are crammed side by side and people can not walk along exactly what the paper says in. Your task is to write a program which hunts for the treature on the paper. For simplicity, 1 step is equivalent to 1 meter. Input consists of several pairs of two integers d (the first integer) and t (the second integer) separated by a comma. Input ends with "0, 0". Your program should print the coordinate (x, y) of the end point. There is the treature where x meters to the east and y meters to the north from the center of town. You can assume that d ≤ 100 and -180 ≤ t ≤ 180\.
|
import math
x, y, r = 0, 0, 90
while True:
d, t = map(int, input().split(","))
if d == t == 0:
break
x += r * math.cos(math.radians(r))
y += r * math.sin(math.radians(r))
r -= t
print(int(x))
print(int(y))
|
s542765043
|
Accepted
| 20
| 7,868
| 236
|
import math
x, y, r = 0, 0, 90
while True:
d, t = map(float, input().split(","))
if d == t == 0:
break
x += d * math.cos(math.radians(r))
y += d * math.sin(math.radians(r))
r -= t
print(int(x))
print(int(y))
|
s003057686
|
p03712
|
u205678452
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 298
|
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
|
H, W = (int(i) for i in input().split())
str = [input() for i in range(H)]
print(str)
for i in range(W+2):
print("#", end = "")
print("")
for i in range(H):
print("#", end = "")
print(str[i], end = "")
print("#")
for i in range(W+2):
print("#", end = "")
|
s395431140
|
Accepted
| 17
| 3,064
| 297
|
H, W = (int(i) for i in input().split())
str = [input() for i in range(H)]
for i in range(W+2):
print('#', end = "")
print("")
for i in range(H):
print('#', end = "")
print(str[i], end = "")
print('#')
for i in range(W+2):
print('#', end = "")
print("")
|
s233338909
|
p04030
|
u592248346
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 137
|
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
|
s = list(input())
ans = []
for i in s:
if len(ans)!=0 and i=='B':
ans.pop()
elif i!='B':
ans.append(i)
print(ans)
|
s064632476
|
Accepted
| 17
| 2,940
| 145
|
s = list(input())
ans = []
for i in s:
if len(ans)!=0 and i=='B':
ans.pop()
elif i!='B':
ans.append(i)
print(*ans,sep="")
|
s967659860
|
p02678
|
u437351386
| 2,000
| 1,048,576
|
Wrong Answer
| 831
| 58,152
| 537
|
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.
|
n,m=list(map(int,input().split()))
road_input=[]
for i in range(m):
road_input.append(list(map(int,input().split())))
road=[[] for i in range(n+1)]
for i in range(m):
road[road_input[i][0]].append(road_input[i][1])
road[road_input[i][1]].append(road_input[i][0])
from collections import deque
q=deque([1])
ans=[-1 for i in range(n)]
print(ans)
while len(q)>0:
p=q.popleft()
for i in road[p]:
if ans[i-1]== -1:
ans[i-1]=p
q.append(i)
print("Yes")
for j in range(1,n):
print(ans[j])
|
s166509754
|
Accepted
| 746
| 34,816
| 628
|
n,m=list(map(int,input().split()))
road=[[] for i in range(n)]
for i in range(m):
a,b=list(map(int,input().split()))
road[a-1].append(b)
road[b-1].append(a)
from collections import deque
q=deque([1])
check=[0 for i in range(n)]
check[0]=1
ans=[0 for i in range(n)]
while len(q)>0:
p=q.popleft()
for i in range(len(road[p-1])):
if check[road[p-1][i]-1]==0:
q.append(road[p-1][i])
check[road[p-1][i]-1]=1
ans[road[p-1][i]-1]=p
print("Yes")
for i in range(1,n):
print(ans[i])
|
s543016738
|
p02690
|
u350093546
| 2,000
| 1,048,576
|
Wrong Answer
| 43
| 9,076
| 120
|
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 i in range(-100,100):
for j in range(-100,100):
if x==(i**5-j**5):
print(i,j)
break
|
s243832213
|
Accepted
| 99
| 9,056
| 134
|
x=int(input())
for i in range(-200,200):
for j in range(-200,200):
if x==(i**5-j**5):
a=i
b=j
break
print(a,b)
|
s644225754
|
p03611
|
u371132735
| 2,000
| 262,144
|
Wrong Answer
| 108
| 20,064
| 106
|
You are given an integer sequence of length N, a_1,a_2,...,a_N. For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices.
|
import collections
N = int(input())
L = list(map(int,input().split()))
C = collections.Counter(L)
print(C)
|
s697226235
|
Accepted
| 77
| 13,964
| 171
|
N = int(input())
A = list(map(int,input().split()))
cnt = [0]*(10**5+2)
for i in A:
cnt[i]+=1
cnt[i+1]+=1
cnt[i+2]+=1
print(max(cnt))
|
s688129290
|
p03814
|
u815797488
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,512
| 57
|
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
|
s = input()
a = s.find('A')
b = s.rfind('B')
print(b-a+1)
|
s712610864
|
Accepted
| 17
| 3,500
| 57
|
s = input()
a = s.find('A')
b = s.rfind('Z')
print(b-a+1)
|
s157176230
|
p02659
|
u993622994
| 2,000
| 1,048,576
|
Wrong Answer
| 21
| 9,040
| 78
|
Compute A \times B, truncate its fractional part, and print the result as an integer.
|
A, B = input().split()
A = float(A)
B = float(B)
ans = int(A * B)
print(A * B)
|
s587560438
|
Accepted
| 26
| 10,068
| 98
|
from decimal import Decimal
A, B = input().split()
ans = int(Decimal(A) * Decimal(B))
print(ans)
|
s057848118
|
p03377
|
u106297876
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 81
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a,b,x=map(int,input().split( ))
if x-a>=b:
print('Yes')
else:
print('No')
|
s167890462
|
Accepted
| 17
| 2,940
| 92
|
a,b,x=map(int,input().split( ))
if x-a>=0 and x-a<=b:
print('YES')
else:
print('NO')
|
s278953741
|
p03861
|
u264508862
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 53
|
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,n=list(map(int,input().split()))
print(b/n-~-a/n)
|
s940106464
|
Accepted
| 18
| 2,940
| 49
|
a,b,n=map(int,input().split())
print(b//n-~-a//n)
|
s589027781
|
p04029
|
u333731247
| 2,000
| 262,144
|
Wrong Answer
| 17
| 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?
|
N=int(input())
print(0.5*N*(N+1))
|
s927752574
|
Accepted
| 17
| 2,940
| 39
|
N=int(input())
print(int(0.5*N*(N+1)))
|
s553265591
|
p03494
|
u117193815
| 2,000
| 262,144
|
Time Limit Exceeded
| 2,104
| 3,060
| 211
|
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
n = int(input())
l=list(map(int ,input().split()))
cnt=0
while True:
for i in range(n):
if l[i]%2==0:
l[i]==l[i]//2
else:
print(cnt)
exit()
cnt+=1
|
s896336591
|
Accepted
| 19
| 3,060
| 217
|
n = int(input())
l=list(map(int ,input().split()))
count=0
while True:
for i in range(n):
if l[i]%2==0:
l[i]=l[i]//2
else:
print(count)
exit()
count+=1
|
s160861727
|
p03860
|
u820351940
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 40
|
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
print("A{}C".format(input().split()[1]))
|
s555740184
|
Accepted
| 17
| 2,940
| 35
|
print("A%cC"%input().split()[1][0])
|
s039203582
|
p02663
|
u508061226
| 2,000
| 1,048,576
|
Wrong Answer
| 22
| 9,164
| 102
|
In this problem, we use the 24-hour clock. Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying?
|
h1, m1, h2, m2, k = map(int, input().split())
time = (h1 * 60 + m1) - (h2 * 60 + m2)
print(time - k)
|
s565826309
|
Accepted
| 22
| 9,156
| 103
|
h1, m1, h2, m2, k = map(int, input().split())
time = (h2 * 60 + m2) - (h1 * 60 + m1)
print(time - k)
|
s481545179
|
p02389
|
u725843728
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,588
| 77
|
Write a program which calculates the area and perimeter of a given rectangle.
|
a,b=map(int,input().split())
print(a,b)
c=int(a)*int(b)
d=2*(a+b)
print(c,d)
|
s138072698
|
Accepted
| 20
| 5,576
| 48
|
a,b=map(int,input().split())
print(a*b,2*(a+b))
|
s427163339
|
p04029
|
u761989513
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 39
|
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?
|
n = int(input())
print(n * (n + 1) / 2)
|
s492666299
|
Accepted
| 17
| 2,940
| 76
|
n = int(input())
ans = 0
for i in range(1, n + 1):
ans += i
print(ans)
|
s374833463
|
p03409
|
u650932312
| 2,000
| 262,144
|
Wrong Answer
| 31
| 9,148
| 546
|
On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.
|
N = int(input())
reds = []
for i in range(N):
a, b = map(int, input().split())
reds.append([a,b])
reds.sort(key=lambda x: x[1], reverse=True)
blues = []
for i in range(N):
c, d = map(int, input().split())
blues.append([c,d])
blues.sort()
flag = [False for i in range(N)]
ans = 0
for i in range(N):
c, d = blues[i][0], blues[i][1]
for j in range(N):
if flag[j] == True:
continue
a, b = reds[i][0], reds[i][1]
if c>a and d>b:
flag[j] = True
ans += 1
print(ans)
|
s339892356
|
Accepted
| 34
| 9,108
| 564
|
N = int(input())
reds = []
for i in range(N):
a, b = map(int, input().split())
reds.append([a,b])
reds.sort(key=lambda x: x[1], reverse=True)
blues = []
for i in range(N):
c, d = map(int, input().split())
blues.append([c,d])
blues.sort()
flag = [False for i in range(N)]
ans = 0
for i in range(N):
c, d = blues[i][0], blues[i][1]
for j in range(N):
if flag[j] == True:
continue
a, b = reds[j][0], reds[j][1]
if c>a and d>b:
flag[j] = True
ans += 1
break
print(ans)
|
s509158709
|
p03089
|
u721316601
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,064
| 879
|
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())
b = list(map(int, input().split()))
ans = []
queue = []
if 1 not in b:
print(-1)
else:
start = N
for i in range(N-1, -1, -1):
if b[i] == 1:
queue.append(b[i:start])
start = i
for a in queue:
flag = True
for i in range(len(a)):
if a[i] <= i+1:
pass
else:
flag = False
ans = [-1]
break
if not flag:
break
ans.append(1)
next_pass = False
for i in range(len(a)-1, 0, -1):
if not next_pass:
if a[i-1] <= a[i]:
ans.extend([a[i-1], a[i]])
next_pass = True
else:
ans.append(a[i])
else:
next_pass = False
for a in ans:
print(a)
|
s172107559
|
Accepted
| 18
| 3,064
| 277
|
N = int(input())
b = list(map(int, input().split()))
ans = [None] * N
for i in range(N):
for j in range(len(b), -1, -1):
if b[j-1] == j:
ans[i] = b.pop(j-1)
break
else: break
if not b:
for a in ans[::-1]: print(a)
else: print(-1)
|
s193506622
|
p03943
|
u612721349
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 114
|
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.
|
print("Yes" if (lambda x: x[0] == sum(x[1:]) or sum(x[0:2]) == x[2])([int(i) for i in input().split()]) else "No")
|
s996891984
|
Accepted
| 17
| 2,940
| 123
|
print("Yes" if (lambda x: x[0] == sum(x[1:]) or sum(x[0:2]) == x[2])(sorted([int(i) for i in input().split()])) else "No")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.