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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s510028665
|
p02613
|
u524557016
| 2,000 | 1,048,576 |
Wrong Answer
| 258 | 16,320 | 284 |
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.
|
# -*- coding: utf-8 -*-
N = int(input())
S = []
for i in range(N):
S.append(input())
count_map = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
for s in S:
count_map[s] += 1
print(count_map)
for count_key, count in count_map.items():
print(count_key + " x " + str(count))
|
s617064305
|
Accepted
| 150 | 16,252 | 263 |
# -*- coding: utf-8 -*-
N = int(input())
S = []
for i in range(N):
S.append(input())
count_map = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
for s in S:
count_map[s] += 1
for count_key, count in count_map.items():
print(count_key + " x " + str(count))
|
s977566304
|
p03359
|
u690037900
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 44 |
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
|
a,b=map(int,input().split())
print(a+(a<=b))
|
s791628844
|
Accepted
| 21 | 3,316 | 46 |
a,b=map(int,input().split())
print(a+(a<=b)-1)
|
s725471583
|
p03486
|
u845937249
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 242 |
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
s = ''.join(s)
t = ''.join(t)
print(s)
print(t)
if s < t :
print('Yes')
else:
print('No')
|
s620453729
|
Accepted
| 17 | 2,940 | 244 |
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
s = ''.join(s)
t = ''.join(t)
#print(s)
#print(t)
if s < t :
print('Yes')
else:
print('No')
|
s698246303
|
p03854
|
u243312682
| 2,000 | 262,144 |
Wrong Answer
| 27 | 5,152 | 619 |
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
import re
def main():
s = list(input())
sr = ''.join(list(reversed(s)))
print(sr)
t = ['dream', 'dreamer', 'erase', 'eraser']
tr = list()
for i in t:
tr.append(''.join(list(reversed(i))))
while True:
for i in tr:
sr_split = re.split('^' + i, sr ,1)
print(sr_split)
if len(sr_split) == 2:
sr = sr_split[1]
print(sr)
if sr_split == 1 or not sr_split == '':
print('No')
break
if sr == '':
print('Yes')
break
if __name__ == '__main__':
main()
|
s874782584
|
Accepted
| 79 | 4,900 | 530 |
import re
def main():
s = list(input())
sr = ''.join(list(reversed(s)))
t = ['dream', 'dreamer', 'erase', 'eraser']
tr = list()
for i in t:
tr.append(''.join(list(reversed(i))))
while sr:
flag = False
for i in tr:
if sr.startswith(i):
sr = sr.replace(i ,'', 1)
flag = True
if not flag:
print('NO')
break
if sr == '':
print('YES')
break
if __name__ == '__main__':
main()
|
s153244137
|
p02613
|
u133236239
| 2,000 | 1,048,576 |
Wrong Answer
| 144 | 9,232 | 479 |
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.
|
loop_count = int(input())
ac_count = 0
wa_count = 0
tle_count = 0
re_count = 0
for i in range(loop_count):
result = input()
if result == 'AC':
ac_count += 1
elif result == 'WA':
wa_count += 1
elif result == 'TLE':
tle_count += 1
else:
re_count += 1
print("AC × {0}".format(str(ac_count)))
print("WA × {0}".format(str(wa_count)))
print("TLE × {0}".format(str(tle_count)))
print("RE × {0}".format(str(re_count)))
|
s858245129
|
Accepted
| 145 | 9,152 | 468 |
loop_count = int(input())
ac_count = 0
wa_count = 0
tle_count = 0
re_count = 0
for i in range(loop_count):
result = input()
if result == 'AC':
ac_count += 1
elif result == 'WA':
wa_count += 1
elif result == 'TLE':
tle_count += 1
else:
re_count += 1
print("AC x {0}".format(str(ac_count)))
print("WA x {0}".format(str(wa_count)))
print("TLE x {0}".format(str(tle_count)))
print("RE x {0}".format(str(re_count)))
|
s014126202
|
p03545
|
u626468554
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 598 |
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.
|
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))
s = list(map(int,list(input())))
li = [1,-1]
for i in range(1<<3):
ans = s[0]
for j in range(1,4):
if i>>(j-1)&1:
ans += s[j]
else:
ans -= s[j]
print(bin(i),ans)
if ans == 7:
print(s[0],end="")
for j in range(1,4):
if i>>(j-1)&1:
print("+",end="")
print(s[j],end="")
else:
print("-",end="")
print(s[j],end="")
print("=7")
break
|
s000178466
|
Accepted
| 17 | 3,064 | 599 |
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))
s = list(map(int,list(input())))
li = [1,-1]
for i in range(1<<3):
ans = s[0]
for j in range(1,4):
if i>>(j-1)&1:
ans += s[j]
else:
ans -= s[j]
#print(bin(i),ans)
if ans == 7:
print(s[0],end="")
for j in range(1,4):
if i>>(j-1)&1:
print("+",end="")
print(s[j],end="")
else:
print("-",end="")
print(s[j],end="")
print("=7")
break
|
s815397559
|
p03386
|
u977389981
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 197 |
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
a, b, k = map(int, input().split())
ans = []
k = min(k, b - a)
for i in range(k):
ans.append(a + i)
for i in range(k-1, -1, -1):
ans.append(b - i)
for i in set(ans):
print(i)
|
s916526990
|
Accepted
| 18 | 3,060 | 114 |
a, b, k = map(int, input().split())
X = range(a, b + 1)
for i in sorted(set(X[: k]) | set(X[- k :])):
print(i)
|
s333885629
|
p03814
|
u780206746
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,500 | 73 |
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()
left, right = s.find('A'), s.rfind('B')
print(right-left+1)
|
s106515843
|
Accepted
| 17 | 3,500 | 73 |
s = input()
left, right = s.find('A'), s.rfind('Z')
print(right-left+1)
|
s080211025
|
p03054
|
u346308892
| 2,000 | 1,048,576 |
Wrong Answer
| 223 | 17,492 | 1,566 |
We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, there is a piece, which is initially placed at square (s_r,s_c). Takahashi and Aoki will play a game, where each player has a string of length N. Takahashi's string is S, and Aoki's string is T. S and T both consist of four kinds of letters: `L`, `R`, `U` and `D`. The game consists of N steps. The i-th step proceeds as follows: * First, Takahashi performs a move. He either moves the piece in the direction of S_i, or does not move the piece. * Second, Aoki performs a move. He either moves the piece in the direction of T_i, or does not move the piece. Here, to move the piece in the direction of `L`, `R`, `U` and `D`, is to move the piece from square (r,c) to square (r,c-1), (r,c+1), (r-1,c) and (r+1,c), respectively. If the destination square does not exist, the piece is removed from the grid, and the game ends, even if less than N steps are done. Takahashi wants to remove the piece from the grid in one of the N steps. Aoki, on the other hand, wants to finish the N steps with the piece remaining on the grid. Determine if the piece will remain on the grid at the end of the game when both players play optimally.
|
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline
def acinput():
return list(map(int, input().split(" ")))
def factorial(n):
fact = 1
for integer in range(1, n + 1):
fact *= integer
return fact
def serch(x, count):
#print("top", x, count)
for d in directions:
nx = d+x
# print(nx)
if np.all(0 <= nx) and np.all(nx < (H, W)):
if field[nx[0]][nx[1]] == "E":
count += 1
field[nx[0]][nx[1]] = "V"
count = serch(nx, count)
continue
if field[nx[0]][nx[1]] == "#":
field[nx[0]][nx[1]] = "V"
count = serch(nx, count)
return count
H, W, N = acinput()
initp= np.array(acinput())
S = list(input())[:-1]
T = list(input())[:-1]
#S = list(input().split(""))
#T = list(input().split(""))
def position_relative(direction,flg,seq1,seq2):
cs = 0
N=len(seq1)
for i in range(len(seq1)):
s1=seq1[i]
s2=seq2[i]
if s1==direction:
cs += flg
if cs<0 or cs>N:
return False
if s2!=direction:
cs-=flg
if cs < 0 or cs > N:
return False
return cs
sr=position_relative("R",initp[0],S,T)
sl = position_relative("L",initp[1],S,T)
su = position_relative("U",-1,S, T)
sd = position_relative("D",1, S, T)
#print(sr,sl,su,sd)
if sr or sl or su or sd:
print("Yes")
else:
print("No")
|
s243025191
|
Accepted
| 1,750 | 19,424 | 1,438 |
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline
def acinput():
return list(map(int, input().split(" ")))
def factorial(n):
fact = 1
for integer in range(1, n + 1):
fact *= integer
return fact
H, W, NN = acinput()
initp = np.array(acinput())
S = list(input())[:-1]
T = list(input())[:-1]
#S = list(input().split(""))
#T = list(input().split(""))
def position_relative(direction, direction_op, cs, flg, seq1, seq2, N):
global H, W
# N=len(seq1)
for i in range(len(seq1)):
s1 = seq1[i]
s2 = seq2[i]
#print(cs,flg)
if s1 == direction:
cs += flg
if flg > 0:
if cs > N:
return False
else:
if cs <= 0:
return False
# elif cs>N:
# cs=N
#print(cs)
if s2 == direction_op:
#print("op",N)
cs -= flg
if cs > N:
cs = N
if cs <= 0:
cs = 1
return cs
sr = position_relative("R", "L", initp[1], 1, S, T, W)
sl = position_relative("L", "R", initp[1], -1, S, T, W)
su = position_relative("U", "D", initp[0], -1, S, T, H)
sd = position_relative("D", "U", initp[0], 1, S, T, H)
# su=0
# if sr or sl or su or sd:
if sr*sl*su*sd == 0:
print("NO")
else:
print("YES")
|
s442268462
|
p02409
|
u677859833
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,740 | 919 |
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
|
buils = [
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]]
n = int(input())
for i in range(n):
BFRV = input().split()
b = int(BFRV[0])
f = int(BFRV[1])
r = int(BFRV[2])
v = int(BFRV[3])
buils[b-1][f-1][r-1] = buils[b-1][f-1][r-1] + v
for b in range(4):
for f in range(3):
for r in range(10):
print(" ",end="" )
print(buils[b][f][r], end="")
print("")
print("####################")
|
s679858353
|
Accepted
| 30 | 7,764 | 938 |
buils = [
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]]
n = int(input())
for i in range(n):
BFRV = input().split()
b = int(BFRV[0])
f = int(BFRV[1])
r = int(BFRV[2])
v = int(BFRV[3])
buils[b-1][f-1][r-1] = buils[b-1][f-1][r-1] + v
for b in range(4):
for f in range(3):
for r in range(10):
print(" ", end="")
print(buils[b][f][r], end="")
print("")
if b != 3:
print("####################")
|
s263848276
|
p03944
|
u198336369
| 2,000 | 262,144 |
Wrong Answer
| 86 | 9,228 | 711 |
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
|
w,h,n = map(int, input().split())
s = [[1 for i in range(w)] for j in range(h)]
b = [[1,2,3,4,5],[6,7,8,9,10]]
print(b[1][0])
print(b)
alist = []
print(s)
for i in range(n):
x,y,a = map(int, input().split())
alist.append(a)
if a == 1:
for j in range(h):
for k in range(0,x):
s[j][k] = 0
if a == 2:
for j in range(h):
for k in range(x,w):
s[j][k] = 0
if a == 3:
for k in range(w):
for j in range(0,y):
s[j][k] = 0
if a == 4:
for k in range(w):
for j in range(y,h):
s[j][k] = 0
ans = 0
for i in range(h):
ans = ans + s[i].count(1)
print(ans)
|
s560829656
|
Accepted
| 78 | 9,228 | 678 |
w,h,n = map(int, input().split())
s = [[1 for i in range(w)] for j in range(h)]
b = [[1,2,3,4,5],[6,7,8,9,10]]
alist = []
for i in range(n):
x,y,a = map(int, input().split())
alist.append(a)
if a == 1:
for j in range(h):
for k in range(0,x):
s[j][k] = 0
if a == 2:
for j in range(h):
for k in range(x,w):
s[j][k] = 0
if a == 3:
for k in range(w):
for j in range(0,y):
s[j][k] = 0
if a == 4:
for k in range(w):
for j in range(y,h):
s[j][k] = 0
ans = 0
for i in range(h):
ans = ans + s[i].count(1)
print(ans)
|
s086800368
|
p02613
|
u006738234
| 2,000 | 1,048,576 |
Wrong Answer
| 146 | 9,216 | 336 |
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())
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in range(n):
a = input()
if(a == 'AC'):
c0 += 1
elif(a == 'WA'):
c1 += 1
elif(a == 'TLE'):
c2 += 1
elif(a == 'RE'):
c3 += 1
print('AC × ' + str(c0))
print('WA × ' + str(c1))
print('TLE × ' + str(c2))
print('RE × ' + str(c3))
|
s843719701
|
Accepted
| 153 | 9,216 | 332 |
n = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in range(n):
a = input()
if(a == 'AC'):
c0 += 1
elif(a == 'WA'):
c1 += 1
elif(a == 'TLE'):
c2 += 1
elif(a == 'RE'):
c3 += 1
print('AC x ' + str(c0))
print('WA x ' + str(c1))
print('TLE x ' + str(c2))
print('RE x ' + str(c3))
|
s817354585
|
p03478
|
u926566528
| 2,000 | 262,144 |
Wrong Answer
| 39 | 9,168 | 202 |
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
N, A, B = map(int, input().split())
sum = 0
for n in range(1, N+1):
nsum = 0
while n != 0:
nsum += n % 10
n = n//10
if nsum >= A and nsum <= B:
sum += 1
print(sum)
|
s416904861
|
Accepted
| 38 | 9,108 | 212 |
N, A, B = map(int, input().split())
sum = 0
for n in range(1, N+1):
nsum = 0
m = n
while m != 0:
nsum += m % 10
m = m//10
if nsum >= A and nsum <= B:
sum += n
print(sum)
|
s054820623
|
p03140
|
u411858517
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,064 | 269 |
You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters. Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation: * Operation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter. What is the minimum number of operations required to achieve the objective?
|
N = int(input())
A = input()
B = input()
C = input()
ans = 0
for i in range(N):
if A[i] != B[i] != C[i]:
ans += 2
elif A[i] != B[i]:
ans += 1
elif A[i] != C[i]:
ans += 1
elif B[i] != C[i]:
ans += 1
print(ans)
|
s111916514
|
Accepted
| 18 | 3,064 | 289 |
N = int(input())
A = input()
B = input()
C = input()
ans = 0
for i in range(N):
if A[i] == B[i] == C[i]:
ans += 0
elif A[i] == B[i]:
ans += 1
elif A[i] == C[i]:
ans += 1
elif B[i] == C[i]:
ans += 1
elif A[i] != B[i] and B[i] != C[i]:
ans += 2
print(ans)
|
s252435316
|
p03635
|
u102242691
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 69 |
In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?
|
s = input()
number = len(s) - 2
print(s[0] + str(number) + s[-1])
|
s499850822
|
Accepted
| 17 | 2,940 | 50 |
n,m = map(int,input().split())
print((n-1)*(m-1))
|
s766449170
|
p03759
|
u131411061
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 91 |
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
a,b,c = map(int,input().split())
if (b-a) == (c-a):
print('YES')
else:
print('NO')
|
s274646264
|
Accepted
| 17 | 2,940 | 91 |
a,b,c = map(int,input().split())
if (b-a) == (c-b):
print('YES')
else:
print('NO')
|
s036907592
|
p03796
|
u762540523
| 2,000 | 262,144 |
Wrong Answer
| 42 | 2,940 | 98 |
Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
|
n = int(input())
power = 1
for i in range(n):
power *= i + 1
power //= 1000000007
print(power)
|
s510121590
|
Accepted
| 46 | 2,940 | 97 |
n = int(input())
power = 1
for i in range(n):
power *= i + 1
power %= 1000000007
print(power)
|
s426000174
|
p03555
|
u669382434
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 140 |
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
|
c=[[i for i in input()] for j in range(2)]
if c[0][0]==c[1][2] and c[0][1]==c[1][1] and c[0][2]==c[1][0]:
print("Yes")
else:
print("No")
|
s712965706
|
Accepted
| 17 | 3,060 | 140 |
c=[[i for i in input()] for j in range(2)]
if c[0][0]==c[1][2] and c[0][1]==c[1][1] and c[0][2]==c[1][0]:
print("YES")
else:
print("NO")
|
s506105797
|
p04029
|
u053535689
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,136 | 98 |
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())
candy = N * (N + 1) / 2
print(candy)
|
s525234473
|
Accepted
| 26 | 9,080 | 102 |
N = int(input())
candy = int(N * (N + 1) / 2)
print(candy)
|
s975217761
|
p02237
|
u564398841
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,608 | 344 |
There are two standard ways to represent a graph $G = (V, E)$, where $V$ is a set of vertices and $E$ is a set of edges; Adjacency list representation and Adjacency matrix representation. An adjacency-list representation consists of an array $Adj[|V|]$ of $|V|$ lists, one for each vertex in $V$. For each $u \in V$, the adjacency list $Adj[u]$ contains all vertices $v$ such that there is an edge $(u, v) \in E$. That is, $Adj[u]$ consists of all vertices adjacent to $u$ in $G$. An adjacency-matrix representation consists of $|V| \times |V|$ matrix $A = a_{ij}$ such that $a_{ij} = 1$ if $(i, j) \in E$, $a_{ij} = 0$ otherwise. Write a program which reads a directed graph $G$ represented by the adjacency list, and prints its adjacency-matrix representation. $G$ consists of $n\; (=|V|)$ vertices identified by their IDs $1, 2,.., n$ respectively.
|
if __name__ == '__main__':
N = int(input())
matrix = [[0] * N for _ in range(N)]
for i in matrix:
node_info = [int(i) for i in input().split()]
node_i = node_info[0] - 1
if not node_info[1] == 0:
for i in node_info[2:]:
matrix[node_i][i-1] = 1
[print(line) for line in matrix]
|
s776458618
|
Accepted
| 20 | 7,744 | 360 |
if __name__ == '__main__':
N = int(input())
matrix = [['0'] * N for _ in range(N)]
for i in matrix:
node_info = [int(i) for i in input().split()]
node_i = node_info[0] - 1
if not node_info[1] == 0:
for i in node_info[2:]:
matrix[node_i][i - 1] = '1'
[print(' '.join(line)) for line in matrix]
|
s695557823
|
p02846
|
u802963389
| 2,000 | 1,048,576 |
Time Limit Exceeded
| 2,107 | 3,064 | 370 |
Takahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east. They start simultaneously at the same point and moves as follows **towards the east** : * Takahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever. * Aoki runs B_1 meters per minute for the first T_1 minutes, then runs at B_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever. How many times will Takahashi and Aoki meet each other, that is, come to the same point? We do not count the start of the run. If they meet infinitely many times, report that fact.
|
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
D1 = T1 * (A1 - B1)
D2 = T2 * (A2 - B2)
li = [D1, D2]
li.sort()
pos = 0
cnt = 0
for _ in range(10000000):
pos += li[0]
pos1 = pos
pos += li[1]
pos2 = pos
if pos1 < 0 and pos2 >= 0:
cnt += 2
if cnt >= 1000000:
print("infinity")
else:
print(cnt-1)
|
s948417501
|
Accepted
| 29 | 9,144 | 389 |
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())
if ((a1 - b1) * (a2 - b2) > 0) or (abs(a1 - b1) * t1 > abs(a2 - b2) * t2):
print(0)
elif abs(a1 - b1) * t1 == abs(a2 - b2) * t2:
print("infinity")
else:
d, m = divmod(abs(a1 - b1) * t1, abs(a2 - b2) * t2 - abs(a1 - b1) * t1)
ans = d * 2
if m > 0:
ans += 1
print(ans)
|
s499792389
|
p03474
|
u020373088
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,060 | 255 |
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
|
a, b = map(int, input().split())
s = input()
if a+b+1 == len(s):
ok = True
else:
ok = False
for i in range(len(s)):
if i == a:
if s[i] != "-":
ok = False
if type(s[i]) != int:
ok = False
if ok:
print("Yes")
else:
print("No")
|
s207063617
|
Accepted
| 17 | 3,060 | 204 |
a, b = map(int, input().split())
s = input()
ok = False
if s.count("-") == 1:
ind = s.index("-")
if len(s[:ind]) == a and len(s[ind+1:]) == b:
ok = True
if ok:
print("Yes")
else:
print("No")
|
s245299220
|
p03679
|
u272377260
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 137 |
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
|
x, a, b = map(int, input().split())
if a - b <= 0:
print('delicious')
elif a - b <= x:
print('safe')
else:
print('dangerous')
|
s946907287
|
Accepted
| 18 | 2,940 | 137 |
x, a, b = map(int, input().split())
if a - b >= 0:
print('delicious')
elif b - a <= x:
print('safe')
else:
print('dangerous')
|
s598379251
|
p03455
|
u038903257
| 2,000 | 262,144 |
Wrong Answer
| 34 | 4,336 | 155 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
import random
a=random.randint(1,10000)
b=random.randint(1,10000)
if (a+b)%2 == 0:
print(a+b)
print('even')
else:
print(a+b)
print('odd')
|
s946492829
|
Accepted
| 17 | 2,940 | 96 |
a, b = input().split()
a=int(a)
b=int(b)
if (a*b)%2==0:
print("Even")
else:
print("Odd")
|
s691152125
|
p03377
|
u701318346
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 97 |
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 and X <= A + B:
print('Yes')
else:
print('No')
|
s906724979
|
Accepted
| 17 | 2,940 | 91 |
A, B, X = map(int, input().split())
if A <= X <= A + B:
print('YES')
else:
print('NO')
|
s706844092
|
p03997
|
u369199820
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 84 |
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.
|
str = [int(input()) for i in range(3)]
area = (str[0]+str[1])*str[2]/2
print(area)
|
s917963482
|
Accepted
| 17 | 3,064 | 91 |
str = [int(input()) for i in range(3)]
area = (str[0]+str[1])*str[2]/2
print(round(area))
|
s555344945
|
p03455
|
u534303019
| 2,000 | 262,144 |
Wrong Answer
| 29 | 8,904 | 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('Odd')
else:
print('Even')
|
s465160392
|
Accepted
| 28 | 8,856 | 90 |
a, b =map(int, input().split())
if (a*b)%2 == 0:
print('Even')
else:
print('Odd')
|
s499766000
|
p03597
|
u371409687
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 49 |
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
|
a,b=[int(input()) for i in range(2)]
print(a*2-b)
|
s861818110
|
Accepted
| 17 | 2,940 | 49 |
a,b=[int(input()) for i in range(2)]
print(a*a-b)
|
s104337141
|
p02393
|
u754514998
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,604 | 105 |
Write a program which reads three integers, and prints them in ascending order.
|
a, b, c = (int(x) for x in input().split())
if a > b:
a, b = b, a
if b > c:
b, c = c, b
print(a, b, c)
|
s333270550
|
Accepted
| 20 | 5,600 | 128 |
a, b, c = (int(x) for x in input().split())
if a > b:
a, b = b, a
if a > c:
a, c = c, a
if b > c:
b, c = c, b
print(a, b, c)
|
s419927850
|
p03963
|
u305965165
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 62 |
There are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors. Find the number of the possible ways to paint the balls.
|
n,k = (int(i) for i in input().split())
print(k+(k-1)**(n-1))
|
s417701458
|
Accepted
| 18 | 2,940 | 62 |
n,k = (int(i) for i in input().split())
print(k*(k-1)**(n-1))
|
s320808782
|
p03944
|
u177040005
| 2,000 | 262,144 |
Wrong Answer
| 150 | 12,508 | 360 |
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
|
import numpy as np
W,H,N = map(int,input().split())
xl = 0
xr = W
yu = H
yd = 0
for i in range(N):
x,y,a = map(int, input().split())
print(x,y,a)
if a == 1:
xl = max(xl,x)
elif a == 2:
xr = min(xr,x)
elif a == 3:
yd = max(yd,y)
else:
yu = min(yu,y)
ans = max(0,xr - xl) * max(0,yu - yd)
print(ans)
|
s386093656
|
Accepted
| 18 | 3,064 | 323 |
W,H,N = map(int,input().split())
xl = 0
xr = W
yu = H
yd = 0
for i in range(N):
x,y,a = map(int, input().split())
if a == 1:
xl = max(xl,x)
elif a == 2:
xr = min(xr,x)
elif a == 3:
yd = max(yd,y)
else:
yu = min(yu,y)
ans = max(0,xr - xl) * max(0,yu - yd)
print(ans)
|
s724735022
|
p03862
|
u767664985
| 2,000 | 262,144 |
Wrong Answer
| 191 | 14,544 | 477 |
There are N boxes arranged in a row. Initially, the i-th box from the left contains a_i candies. Snuke can perform the following operation any number of times: * Choose a box containing at least one candy, and eat one of the candies in the chosen box. His objective is as follows: * Any two neighboring boxes contain at most x candies in total. Find the minimum number of operations required to achieve the objective.
|
N, x = map(int, input().split())
a = list(map(int, input().split()))
ans1 = 0
for i in range(N - 1):
if a[i] + a[i + 1] > x:
res = a[i] + a[i + 1] - x
a[i + 1] -= max(a[i + 1], res)
a[i] -= max(0, a[i] - x)
ans1 += res
ans2 = 0
a = a[:: -1]
for i in range(N - 1):
if a[i] + a[i + 1] > x:
res = a[i] + a[i + 1] - x
a[i + 1] -= max(a[i + 1], res)
a[i] -= max(0, a[i] - x)
ans2 += res
print(min(ans1, ans2))
|
s283207091
|
Accepted
| 287 | 15,324 | 469 |
from copy import copy
N, x = map(int, input().split())
A = list(map(int, input().split()))
a = copy(A)
ans1 = 0
for i in range(N-1):
if a[i] + a[i+1] > x:
surplus = a[i] + a[i+1] - x
a[i+1] -= min(a[i+1], surplus)
ans1 += surplus
a = copy(A)
ans2 = 0
for i in range(N-1):
if a[N-i-1] + a[N-i-2] > x:
surplus = a[N-i-1] + a[N-i-2] - x
a[N-i-2] -= min(a[N-i-2], surplus)
ans2 += surplus
print(min(ans1, ans2))
|
s599146241
|
p03943
|
u033524082
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 100 |
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 b==a+c or c==a+b:
print("YES")
else:
print("NO")
|
s215354156
|
Accepted
| 17 | 2,940 | 100 |
a=list(map(int,input().split()))
a.sort()
if a[2]==a[1]+a[0]:
print("Yes")
else:
print("No")
|
s472472317
|
p02396
|
u921541953
| 1,000 | 131,072 |
Time Limit Exceeded
| 40,000 | 7,424 | 139 |
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
|
import sys
i = 1
while True:
x = sys.stdin.readline().strip()
if x == 0:
break
print('Case %d: %s' % (i, x))
i += 1
|
s480319264
|
Accepted
| 50 | 7,376 | 141 |
import sys
i = 1
while True:
x = sys.stdin.readline().strip()
if x == '0':
break
print('Case %d: %s' % (i, x))
i += 1
|
s265274824
|
p02612
|
u934609868
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,044 | 41 |
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())
a = N//1000
print(a+1)
|
s377183884
|
Accepted
| 27 | 9,100 | 84 |
N = int(input())
a = N//1000
b = ((a+1)*1000)-N
if b%1000 == 0:
b = 0
print(b)
|
s647962506
|
p03759
|
u055941944
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 115 |
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.
|
#coding utf-8 -*-
a,b,c=map(int,input().split())
if abs(a-b) == abs(c-b):
print("Yes")
else:
print("No")
|
s397234205
|
Accepted
| 18 | 2,940 | 159 |
#coding utf-8 -*-
lis=list(map(int,input().split()))
lis_1=sorted(lis)
if lis_1[2] - lis_1[1] == lis_1[1] - lis_1[0]:
print("YES")
else:
print("NO")
|
s683822717
|
p03738
|
u177125607
| 2,000 | 262,144 |
Wrong Answer
| 27 | 9,072 | 118 |
You are given two positive integers A and B. Compare the magnitudes of these numbers.
|
a = int(input())
b = int(input())
if a > b:
print('GRATER')
elif a < b:
print('LESS')
else:
print('EQUAL')
|
s226980238
|
Accepted
| 29 | 9,148 | 119 |
a = int(input())
b = int(input())
if a > b:
print('GREATER')
elif a < b:
print('LESS')
else:
print('EQUAL')
|
s996627148
|
p03943
|
u752898745
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 103 |
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
x=list(map(int,input().split()))
x.sort()
if sum(x[:2]) == x[2]:
print("YES")
else:
print("NO")
|
s553574671
|
Accepted
| 17 | 2,940 | 111 |
C = list(map(int, input().split()))
C.sort()
if C[2] == C[1] + C[0]:
print('Yes')
else:
print('No')
|
s823035275
|
p03139
|
u227085629
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 61 |
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question.
|
n,a,b = map(int,input().split())
print(max(a+b-n,0),min(a,b))
|
s088483589
|
Accepted
| 17 | 2,940 | 61 |
n,a,b = map(int,input().split())
print(min(a,b),max(a+b-n,0))
|
s367978461
|
p02613
|
u560222605
| 2,000 | 1,048,576 |
Wrong Answer
| 198 | 9,212 | 242 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
n=int(input())
a=0
b=0
c=0
d=0
for i in range(n):
s=input()
a+=s.count('AC')
b+=s.count('WA')
c+=s.count('TLE')
d+=s.count('RE')
print('AC × '+str(a))
print('WA × '+str(b))
print('TLE × '+str(c))
print('RE × '+str(d))
|
s355232679
|
Accepted
| 202 | 9,208 | 237 |
n=int(input())
a=0
b=0
c=0
d=0
for i in range(n):
s=input()
a+=s.count('AC')
b+=s.count('WA')
c+=s.count('TLE')
d+=s.count('RE')
print('AC x '+str(a))
print('WA x '+str(b))
print('TLE x '+str(c))
print('RE x '+str(d))
|
s882725142
|
p03623
|
u482969053
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 106 |
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
# coding: utf-8
# Here your code !
n = input()
if n.find('9') >= 0:
print('Yes')
else:
print('No')
|
s489159880
|
Accepted
| 17 | 2,940 | 103 |
x, a, b = list(map(int, input().split()))
if abs(x-a) < abs(x-b):
print('A')
else:
print('B')
|
s481299073
|
p04030
|
u342456871
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 192 |
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
|
s = input(str)
ans = ""
for i in range(len(s)):
if (s[i] == '0'):
ans += '0'
elif (s[i] == '1'):
ans += '0'
else:
if (len(ans) > 0):
ans = ans[:len(ans)-1]
print(ans)
|
s855262367
|
Accepted
| 17 | 3,060 | 182 |
s = input()
ans = ''
for i in range(len(s)):
if (s[i] == '0'):
ans += '0'
elif (s[i] == '1'):
ans += '1'
else:
if (len(ans) != 0):
ans = ans[:-1]
print(ans)
|
s203927583
|
p03399
|
u127856129
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 113 |
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
|
a=int(input())
b=int(input())
c=int(input())
d=int(input())
if (a+c)<(b+d):
print(a+c)
else:
print(b+d)
|
s369502266
|
Accepted
| 17 | 2,940 | 182 |
a=int(input())
b=int(input())
c=int(input())
d=int(input())
if a<=b and c<=d:
print(a+c)
elif a<=b and d<=c:
print(a+d)
elif b<=a and c<=d:
print(b+c)
else:
print(b+d)
|
s307818145
|
p03598
|
u619819312
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 123 |
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N. When activated, each type of robot will operate as follows. * When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. * When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.
|
n=int(input())
k=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n):
c+=min(abs(k-a[i]),a[i])
print(c)
|
s927899934
|
Accepted
| 18 | 2,940 | 125 |
n=int(input())
k=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n):
c+=2*min(abs(k-a[i]),a[i])
print(c)
|
s693255605
|
p02646
|
u499998503
| 2,000 | 1,048,576 |
Wrong Answer
| 24 | 9,192 | 331 |
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 = input().split()
B,W = input().split()
A = int(A)
V = int(V)
B = int(B)
W = int(W)
T = int(input())
distance = B-A
closer = W-V
def solve():
if closer >= 0:
print("No")
return
if distance + (closer * T) <= 0:
print("Yes")
return
else:
print("No")
return
solve()
|
s594323183
|
Accepted
| 19 | 9,200 | 358 |
A,V = input().split()
B,W = input().split()
A = int(A)
V = int(V)
B = int(B)
W = int(W)
T = int(input())
def solve():
distance = abs(B-A)
closer = abs(V-W)
if V <= W:
print("NO")
return
time = distance/closer
if time <= T:
print("YES")
return
else:
print("NO")
return
solve()
|
s499558080
|
p03486
|
u835482198
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 96 |
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 = sorted(input())[::-1]
b = sorted(input())
if a < b:
print("Yes")
else:
print("No")
|
s119701433
|
Accepted
| 19 | 3,064 | 95 |
a = sorted(input())
b = sorted(input())[::-1]
if a < b:
print("Yes")
else:
print("No")
|
s005382061
|
p04029
|
u496280557
| 2,000 | 262,144 |
Wrong Answer
| 20 | 9,060 | 58 |
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())
answer = (N + 1 ) * N / 2
print(answer)
|
s891647157
|
Accepted
| 28 | 9,068 | 39 |
N =int(input())
print(N * (N+1) // 2)
|
s566963069
|
p00002
|
u073709667
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,620 | 57 |
Write a program which computes the digit number of sum of two integers a and b.
|
a,b=map(int,input().split())
num=a+b
print(len(str(num)))
|
s324744366
|
Accepted
| 30 | 7,532 | 120 |
while True:
try:
a,b=map(int,input().split())
except:
break
sum=str(a+b)
print(len(sum))
|
s114743263
|
p02600
|
u998008108
| 2,000 | 1,048,576 |
Wrong Answer
| 30 | 9,108 | 344 |
M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a _kyu_ (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have?
|
x=int(input())
if(x>=400 and x<=599):
print("8-kyu")
if(x>=600 and x<=799):
print("7-kyu")
if(x>=800 and x<=999):
print("6-kyu")
if(x>=1000 and x<=1199):
print("5-kyu")
if(x>=1200 and x<=1399):
print("4-kyu")
if(x>=1400 and x<=1599):
print("3-kyu")
if(x>=1600 and x<=1799):
print("2-kyu")
if(x>=1800 and x<=1999):
print("1-kyu")
|
s837700467
|
Accepted
| 27 | 9,176 | 313 |
x=int(input())
if(x>=400 and x<=599):
print("8")
if(x>=600 and x<=799):
print("7")
if(x>=800 and x<=999):
print("6")
if(x>=1000 and x<=1199):
print("5")
if(x>=1200 and x<=1399):
print("4")
if(x>=1400 and x<=1599):
print("3")
if(x>=1600 and x<=1799):
print("2")
if(x>=1800 and x<=1999):
print("1")
|
s504641199
|
p00008
|
u075836834
| 1,000 | 131,072 |
Wrong Answer
| 40 | 7,596 | 325 |
Write a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality: a + b + c + d = n For example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).
|
while True:
try:
n=int(input())
cnt=0
for a in range(10):
if a<=n:
for b in range(10):
if b<=n:
for c in range(10):
if c<=n:
d = n-(a+b+c)
if 0<=d<=9:
cnt+=1
else:
break
else:
break
else:
break
print(cnt)
except EOFError:
break
|
s401126203
|
Accepted
| 60 | 7,628 | 323 |
while True:
try:
n=int(input())
cnt=0
for a in range(10):
if a<=n:
for b in range(10):
if b<=n:
for c in range(10):
if c<=n:
d = n-(a+b+c)
if 0<=d<=9:
cnt+=1
else:
break
else:
break
else:
break
print(cnt)
except EOFError:
break
|
s339809465
|
p03698
|
u506287026
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 78 |
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
S = input()
if len(S) != len(set(S)):
print('yes')
else:
print('no')
|
s262274545
|
Accepted
| 20 | 2,940 | 171 |
S = input()
ans = []
is_Yes = True
for s in S:
if s in ans:
is_Yes = False
break
ans.append(s)
if is_Yes:
print('yes')
else:
print('no')
|
s310365486
|
p00028
|
u811733736
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,956 | 573 |
Your task is to write a program which reads a sequence of integers and prints mode values of the sequence. The mode value is the element which occurs most frequently.
|
import sys
from collections import Counter
if __name__ == '__main__':
# ??????????????\???
# data = [5, 6, 3, 5, 8, 7, 5, 3, 9, 7, 3, 4]
data = []
for line in sys.stdin:
data.append(int(line.strip()))
print(data)
c = Counter(data)
max_freq = c.most_common(1)[0][1]
modes = []
for val, freq in c.most_common():
if freq != max_freq:
break
modes.append(val)
modes.sort()
for i in modes:
print(i)
|
s874083745
|
Accepted
| 30 | 7,952 | 575 |
import sys
from collections import Counter
if __name__ == '__main__':
# ??????????????\???
# data = [5, 6, 3, 5, 8, 7, 5, 3, 9, 7, 3, 4]
data = []
for line in sys.stdin:
data.append(int(line.strip()))
# print(data)
c = Counter(data)
max_freq = c.most_common(1)[0][1]
modes = []
for val, freq in c.most_common():
if freq != max_freq:
break
modes.append(val)
modes.sort()
for i in modes:
print(i)
|
s691403719
|
p03943
|
u942280986
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 111 |
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 b ==(a+c) or c ==(a+b):
print('YES')
else:
print('NO')
|
s037376367
|
Accepted
| 17 | 2,940 | 111 |
a,b,c = map(int,input().split())
if a==(b+c) or b ==(a+c) or c ==(a+b):
print('Yes')
else:
print('No')
|
s932064541
|
p03409
|
u781262926
| 2,000 | 262,144 |
Wrong Answer
| 164 | 12,616 | 721 |
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.
|
import numpy as np
n, *ABCD = map(int, open(0).read().split())
AB = sorted([(a, b) for a, b in zip(ABCD[:2*n:2], ABCD[1:2*n:2])])
CD = sorted([(c, d) for c, d in zip(ABCD[2*n::2], ABCD[2*n+1::2])])
table = np.zeros((n, n), dtype=np.int)
for i in range(n):
a, b = AB[i]
for j in range(n):
c, d = CD[j]
if a < c and b < d:
table[i, j] = 1
x = np.any(table, axis=0)
table = table[x, :]
table = table[:, x]
E = []
while len(table):
i = np.argmin(np.sum(table, axis=0))
j = np.argmax(table[:, i])
table = np.delete(table, i, 1)
table = np.delete(table, j, 0)
x = np.any(table, axis=0)
table = table[x, :]
table = table[:, x]
E.append((i, j))
print(len(E))
|
s565477321
|
Accepted
| 19 | 3,064 | 354 |
n, *ABCD = map(int, open(0).read().split())
AB = sorted([(a, b) for a, b in zip(ABCD[:2*n:2], ABCD[1:2*n:2])], key=lambda x:-x[1])
CD = sorted([(c, d) for c, d in zip(ABCD[2*n::2], ABCD[2*n+1::2])])
for c, d in CD:
for i in range(len(AB)):
a, b = AB[i]
if a < c and b < d:
_ = AB.pop(i)
break
print(n-len(AB))
|
s665629691
|
p03729
|
u320763652
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 161 |
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
|
a,b,c = input().split()
print(a[0].upper() + b[0].upper() + c[0].upper())
if a[len(a)-1] == b[0] and b[len(b)-1] == c[0]:
print("YES")
else:
print("NO")
|
s803456458
|
Accepted
| 17 | 2,940 | 111 |
a,b,c = input().split()
if a[len(a)-1] == b[0] and b[len(b)-1] == c[0]:
print("YES")
else:
print("NO")
|
s030312705
|
p03759
|
u059684599
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 68 |
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")
|
s954096756
|
Accepted
| 17 | 2,940 | 68 |
a,b,c = map(int, input().split())
print("YES" if b-a==c-b else "NO")
|
s759797996
|
p02408
|
u836133197
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,604 | 697 |
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.
|
a = int(input())
cards = [[False for x in range(13)] for y in range(4)]
for i in range(a):
s, v = map(str, input().split())
u = int(v)
if s == 'S':
cards[0][u-1] = True
elif s == 'H':
cards[1][u-1] = True
elif s == 'C':
cards[2][u-1] = True
else:
cards[3][u-1] = True
for j in range(13):
if cards[0][j]:
continue
else:
print("S ", j+1)
for j in range(13):
if cards[1][j]:
continue
else:
print("H ", j+1)
for j in range(13):
if cards[2][j]:
continue
else:
print("D ", j+1)
for j in range(13):
if cards[3][j]:
continue
else:
print("C ", j+1)
|
s283653547
|
Accepted
| 20 | 5,620 | 818 |
a = int(input())
cards = [[False for x in range(13)] for y in range(4)]
for i in range(a):
s, v = map(str, input().split())
u = int(v)
if s == 'S':
cards[0][u-1] = True
elif s == 'H':
cards[1][u-1] = True
elif s == 'C':
cards[2][u-1] = True
elif s == 'D':
cards[3][u-1] = True
else:
pass
for j in range(13):
if cards[0][j]:
continue
else:
print("S ", end="")
print(j+1)
for j in range(13):
if cards[1][j]:
continue
else:
print("H ", end="")
print(j+1)
for j in range(13):
if cards[2][j]:
continue
else:
print("C ", end="")
print(j+1)
for j in range(13):
if cards[3][j]:
continue
else:
print("D ", end="")
print(j+1)
|
s414446714
|
p02608
|
u149991748
| 2,000 | 1,048,576 |
Wrong Answer
| 157 | 9,092 | 611 |
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
import math
from itertools import combinations_with_replacement
def calc(t):
return t[0]*t[0] + t[1]*t[1] + t[2]*t[2] + t[0]*t[1] + t[1]*t[2] + t[2]*t[0]
n = int(input())
ans = [0]*n
n_root = math.floor(math.sqrt(n))
for pattern in combinations_with_replacement(range(1, n_root + 1), 3):
pattern = list(pattern)
#print(pattern)
buf = calc(pattern)
if buf < n:
if pattern[0] == pattern[1] == pattern[2]:
ans[buf-1] += 1
elif pattern[0] == pattern[1] or pattern[1] == pattern[2]:
ans[buf-1] += 3
else:
ans[buf-1] += 6
print(ans)
|
s449098453
|
Accepted
| 176 | 9,392 | 667 |
import math
from itertools import combinations_with_replacement
def calc(t):
return t[0]*t[0] + t[1]*t[1] + t[2]*t[2] + t[0]*t[1] + t[1]*t[2] + t[2]*t[0]
n = int(input())
ans = [0]*n
n_root = math.floor(math.sqrt(n))+1
for pattern in combinations_with_replacement(range(1, n_root + 1), 3):
pattern = list(pattern)
buf = calc(pattern)
#print(pattern)
if buf <= n:
if pattern[0] == pattern[1] == pattern[2]:
ans[buf-1] += 1
elif pattern[0] == pattern[1] or pattern[1] == pattern[2] or pattern[0] == pattern[2]:
ans[buf-1] += 3
else:
ans[buf-1] += 6
[print(a) for a in ans]
#print(ans)
|
s152023553
|
p03610
|
u366939485
| 2,000 | 262,144 |
Wrong Answer
| 27 | 10,132 | 41 |
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
|
list_s = list(input())
print(list_s[::2])
|
s025319865
|
Accepted
| 30 | 10,024 | 50 |
list_s = list(input())
print("".join(list_s[::2]))
|
s036869149
|
p03998
|
u969708690
| 2,000 | 262,144 |
Wrong Answer
| 2,205 | 9,040 | 340 |
Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game.
|
a=input()
b=input()
c=input()
n=a
while True:
if n!="":
k=n[0]
if n==a:
a=a[1:]
elif k==b:
b=b[1:]
else:
c=c[1:]
if k=="a":
n=a
elif k=="b":
n=b
else:
n=c
else:
if n==a:
print("A")
elif n==b:
print("B")
else:
print("C")
print(n)
break
|
s021579756
|
Accepted
| 25 | 8,956 | 427 |
A=input()
B=input()
C=input()
moto=A
suji="a"
while True:
if len(moto)==0:
if suji=="a":
print("A")
exit()
if suji=="b":
print("B")
exit()
if suji=="c":
print("C")
exit()
s=moto[0]
if suji=="a":
A=A[1:]
if suji=="b":
B=B[1:]
if suji=="c":
C=C[1:]
if s=="a":
moto=A
suji="a"
if s=="b":
moto=B
suji="b"
if s=="c":
moto=C
suji="c"
|
s643963266
|
p02600
|
u512623857
| 2,000 | 1,048,576 |
Wrong Answer
| 30 | 9,204 | 337 |
M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a _kyu_ (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have?
|
X = int(input())
if (1800 <= X < 2000):
print("1級")
elif (1600 <= X < 1800):
print("2級")
elif (1400 <= X < 1600):
print("3級")
elif (1200 <= X < 1400):
print("4級")
elif (1000 <= X < 1200):
print("5級")
elif (800 <= X < 1000):
print("6級")
elif (600 <= X < 800):
print("7級")
elif (400 <= X < 600):
print("8級")
|
s165286689
|
Accepted
| 27 | 9,200 | 297 |
X = int(input())
if (1800 <= X < 2000):
print(1)
elif (1600 <= X < 1800):
print(2)
elif (1400 <= X < 1600):
print(3)
elif (1200 <= X < 1400):
print(4)
elif (1000 <= X < 1200):
print(5)
elif (800 <= X < 1000):
print(6)
elif (600 <= X < 800):
print(7)
elif (400 <= X < 600):
print(8)
|
s122703869
|
p02646
|
u819911285
| 2,000 | 1,048,576 |
Wrong Answer
| 25 | 9,184 | 176 |
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 = input()
T = int(t)
d = b - a
dv = v - w
if int(d) <= int(dv) * T:
print('Yes')
else:
print('No')
|
s423850904
|
Accepted
| 27 | 9,204 | 221 |
a, v = map(int, input().split())
b, w = map(int, input().split())
t = input()
T = int(t)
d = b - a
d = int(d)
dv = v - w
dv = int(dv)
d = abs(d)
if dv > 0 and abs(d) <= abs(dv) * T:
print('YES')
else:
print('NO')
|
s106107889
|
p02678
|
u637175065
| 2,000 | 1,048,576 |
Wrong Answer
| 615 | 104,632 | 1,396 |
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.
|
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)
def main():
n,m = LI()
ab = [LI() for _ in range(m)]
e = collections.defaultdict(set)
for a,b in ab:
e[a].add(b)
e[b].add(a)
v = set()
v.add(1)
r = [0] * (n+1)
q = [1]
qi = 0
while len(q) > qi:
t = q[qi]
qi += 1
for u in e[t]:
if u not in v:
v.add(u)
r[u] = t
q.append(u)
return JA(["yes"] + r[2:], "\n")
print(main())
|
s443206379
|
Accepted
| 681 | 104,724 | 1,396 |
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)
def main():
n,m = LI()
ab = [LI() for _ in range(m)]
e = collections.defaultdict(set)
for a,b in ab:
e[a].add(b)
e[b].add(a)
v = set()
v.add(1)
r = [0] * (n+1)
q = [1]
qi = 0
while len(q) > qi:
t = q[qi]
qi += 1
for u in e[t]:
if u not in v:
v.add(u)
r[u] = t
q.append(u)
return JA(["Yes"] + r[2:], "\n")
print(main())
|
s309292939
|
p03370
|
u384679440
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 161 |
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())
kind = []
num = 0
for i in range(N):
kind.append(int(input()))
X -= sum(kind)
num += len(kind)
num += X / min(kind)
print(num)
|
s544292255
|
Accepted
| 17 | 2,940 | 157 |
N, X = map(int, input().split())
flavour = []
for i in range(N):
flavour.append(int(input()))
X -= flavour[i]
print(len(flavour) + int(X / min(flavour)))
|
s637587064
|
p03565
|
u444856278
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 469 |
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
|
s = input()
t = input()
ans = ""
if t in s:
ans = s.replace("?", "a")
else:
for i in range(len(s) - len(t) + 1):
if s[i] in t:
print("po")
if all([s[i - t.index(s[i]) + j] == t[j] or s[i + j] == "?" for j in range(len(t))]):
ans = s[:i] + t + s[i + len(t):]
if "?" in ans:
ans = ans.replace("?","a")
break
if ans:
print(ans)
else:
print("UNRESTORABLE")
|
s748984025
|
Accepted
| 17 | 3,064 | 493 |
s = input()
t = input()
ans = ""
po = False
for i in range(len(s)-len(t)+1):
if s[i] in [t[0],"?"]:
if all([s[i + j] in [t[j], "?"]for j in range(len(t))]):
if not po:
ans = (s[:i] + t + s[i + len(t):]).replace("?","a")
po = True
temp = (s[:i] + t + s[i + len(t):]).replace("?","a")
if temp < ans:
ans = temp
if ans:
print(ans.replace("?", "a"))
else:
print("UNRESTORABLE")
|
s753890770
|
p03545
|
u680183386
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 391 |
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.
|
import sys
num = [int(x) for x in input()]
sign = ["-","+"]
ans = str(num[0])
for x in range(2 ** (len(num)-1)):
sum = num[0]
for i in range(len(num) - 1):
if ((x >> (2-i)) & 1) == 1:
sum += num[i+1]
else:
sum -= num[i+1]
if sum == 7:
for i in range(len(num) - 1):
ans = "{}{}{}".format(ans,sign[(x >> (2 - i)) & 1],num[i+1])
print(ans)
sys.exit()
|
s506787092
|
Accepted
| 17 | 3,064 | 397 |
import sys
num = [int(x) for x in input()]
sign = ["-","+"]
ans = str(num[0])
for x in range(2 ** (len(num)-1)):
sum = num[0]
for i in range(len(num) - 1):
if ((x >> (2-i)) & 1) == 1:
sum += num[i+1]
else:
sum -= num[i+1]
if sum == 7:
for i in range(len(num) - 1):
ans = "{}{}{}".format(ans,sign[(x >> (2 - i)) & 1],num[i+1])
print(ans+"=7")
sys.exit()
|
s713949131
|
p02610
|
u899782392
| 2,000 | 1,048,576 |
Wrong Answer
| 2,215 | 59,428 | 1,119 |
We have N camels numbered 1,2,\ldots,N. Snuke has decided to make them line up in a row. The happiness of Camel i will be L_i if it is among the K_i frontmost camels, and R_i otherwise. Snuke wants to maximize the total happiness of the camels. Find the maximum possible total happiness of the camel. Solve this problem for each of the T test cases given.
|
def solve():
ans = 0
N = int(input())
KLR = []
for _ in range(N):
KLR.append(list(map(int, input().split())))
KLR.sort(key=lambda klr: -abs(klr[1] - klr[2]))
print(KLR)
train = [None] * N
for klr in KLR:
if klr[1] > klr[2]:
pos = klr[0] - 1
dir = -1
elif klr[1] < klr[2]:
pos = klr[0]
dir = 1
else:
pos = 0
dir = 1
if pos >= N:
ans += min(klr[1], klr[2])
continue
ok = False
if train[pos] == None:
ok = True
else:
dir_ = train[pos]
pos_ = pos
while pos_ >= 0 and pos_ < N:
if train[pos_] == None:
train[pos_] = dir_
train[pos] = None
ok = True
break
pos_ += dir_
if ok:
train[pos] = dir
ans += max(klr[1], klr[2])
else:
ans += min(klr[1], klr[2])
print(ans)
T = int(input())
for p in range(T):
solve()
|
s322818729
|
Accepted
| 727 | 72,000 | 1,213 |
import heapq
def priority(klr):
return abs(klr[1]-klr[2])
def process(KP):
q = []
for kp in KP:
if kp[0] < len(q) and len(q) > 0 and q[0] < kp[1]:
heapq.heappop(q)
if kp[0] >= len(q):
heapq.heappush(q, kp[1])
return sum(q)
def solve():
N = int(input())
KLR = []
for _ in range(N):
klr = list(map(int, input().split()))
klr[0] -= 1 # convert to 0-based index to avoid confusion
KLR.append(klr)
ans = 0
L = []
R = []
for klr in KLR:
if klr[1] > klr[2]:
ans += klr[2]
L.append((klr[0], klr[1]-klr[2]))
elif klr[1] < klr[2]:
ans += klr[1]
R.append((N-1-klr[0]-1, klr[2]-klr[1]))
else:
ans += klr[1]
L.sort(key=lambda kp: kp[0])
R.sort(key=lambda kp: kp[0])
ans += process(L)
ans += process(R)
print(ans)
T = int(input())
for _ in range(T):
solve()
|
s410112912
|
p03408
|
u046187684
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 702 |
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.
|
def solve(string):
count = dict([])
n, *rest = string.split()
n = int(n)
blues = rest[:n]
m = rest[n]
reds = rest[n + 1:]
for key in blues:
if key in count:
count[key] += 1
else:
count[key] = 1
for key in reds:
if key in count:
count[key] -= 1
else:
count[key] = -1
num = 0
for k, v in count.items():
if num < v:
num = v
return str(num)
if __name__ == '__main__':
n = int(input())
ins = '{}\n'.format(n) + '\n'.join([input() for _ in range(n)])
m = int(input())
print(solve(ins + '{}\n'.format(m) + '\n'.join([input() for _ in range(m)])))
|
s772086086
|
Accepted
| 21 | 3,316 | 473 |
from collections import Counter
def solve(string):
n, *rest = string.split()
n = int(n)
count = Counter(rest[:n])
m = rest[n]
count -= Counter(rest[n + 1:])
return str(max(max(count.values()), 0)) if len(count) > 0 else "0"
if __name__ == '__main__':
n = int(input())
ins = '{}\n'.format(n) + '\n'.join([input() for _ in range(n)])
m = int(input())
print(solve(ins + '\n{}\n'.format(m) + '\n'.join([input() for _ in range(m)])))
|
s940299746
|
p03409
|
u920299620
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 862 |
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())
data=[]
for i in range(n):
tmp=[0]*3
tmp[0],tmp[1]=map(int,input().split())
data.append(tmp)
for i in range(n):
tmp=[1]*3
tmp[0],tmp[1]=map(int,input().split())
data.append(tmp)
data.sort(key=lambda x:x[0])
print(data)
ans=0
j=2*n-1
while(data[j][2]==0):
j-=1
while(1):
tmp=[data[j]]
while(1):
j-=1
if(j==-1):
break
tmp.append(data[j])
if(data[j][2]==0):
break
while(1):
j-=1
if(j<=-1):
break
if(data[j][2]==1):
break
else:
tmp.append(data[j])
tmp.sort(key=lambda x:x[1])
red=0
for t in tmp:
if(t[2]==0):
red+=1
else:
if(red>=1):
ans+=1
red-=1
if(j<=-1):
break
print(ans)
|
s884231538
|
Accepted
| 19 | 3,188 | 1,063 |
n=int(input())
data=[]
for i in range(n):
tmp=[0]*3
tmp[0],tmp[1]=map(int,input().split())
data.append(tmp)
for i in range(n):
tmp=[1]*3
tmp[0],tmp[1]=map(int,input().split())
data.append(tmp)
data.sort(key=lambda x:x[0])
ans=0
j=2*n-1
while(data[j][2]==0):
j-=1
ttmp=[]
while(1):
tmp=[data[j]]
while(1):
j-=1
if(j==-1):
break
tmp.append(data[j])
if(data[j][2]==0):
break
while(1):
j-=1
if(j<=-1):
break
if(data[j][2]==1):
break
else:
tmp.append(data[j])
ttmp+=tmp
ttmp.sort(key=lambda x:x[1])
red=0
tttmp=[ttmp[i] for i in range(len(ttmp))]
delnum=0
for i in range(len(tttmp)):
if(tttmp[i][2]==0):
red+=1
ttmp.pop(i-delnum)
delnum+=1
else:
if(red>=1):
ans+=1
red-=1
ttmp.pop(i-delnum)
delnum+=1
if(j<=-1):
break
print(ans)
|
s977604302
|
p03730
|
u679325651
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 181 |
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`.
|
import math
a,b,c=[int(i) for i in input().split()]
ct=0
for i in range(b+1):
if i==0: continue
if (a*i)%b==c:
ct+=1
break
if ct==0:
print("NO")
|
s099987011
|
Accepted
| 17 | 2,940 | 115 |
a,b,c=[int(i) for i in input().split()]
if c in [(a*i)%b for i in range(b)]:
print("YES")
else:
print("NO")
|
s472869034
|
p03386
|
u017415492
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,100 | 184 |
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
a,b,k=map(int,input().split())
ans=set()
for i in range(a,min(b,a+k)+1):
ans.add(i)
for i in range(b-min(a,k)+1,b+1):
ans.add(i)
ans=list(ans)
ans.sort()
for i in ans:
print(i)
|
s238790400
|
Accepted
| 30 | 9,076 | 213 |
a,b,k=map(int,input().split())
ans=[]
for i in range(a,k+a):
if a<=i<=b:
ans.append(i)
for i in range(b-k+1,b+1):
if a<=i<=b:
ans.append(i)
ans=list(set(ans))
ans.sort()
for i in ans:
print(i)
|
s418044507
|
p03485
|
u407016024
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 105 |
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a, b = map(int, input().split())
if (a+b)%2 == 0:
print(int((a+b)%2))
else:
print(int((a+b)%2)+1)
|
s711317814
|
Accepted
| 17 | 2,940 | 108 |
a, b = map(int, input().split())
if ((a+b)%2) == 0:
print(int((a+b)/2))
else:
print(int((a+b)/2)+1)
|
s640773468
|
p03605
|
u088974156
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 40 |
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?
|
print("Yes" if input() in "9" else "No")
|
s720595175
|
Accepted
| 18 | 2,940 | 40 |
print("Yes" if "9" in input() else "No")
|
s464851917
|
p03671
|
u879870653
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 69 |
Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
|
A = list(map(int,input().split()))
res = sum(A) - min(A)
print(res)
|
s011272402
|
Accepted
| 17 | 2,940 | 69 |
A = list(map(int,input().split()))
res = sum(A) - max(A)
print(res)
|
s009163917
|
p02742
|
u075303794
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 104 |
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
h,w = map(int, input().split())
a = w//2+1
b = a-1
a += b
if h%2==0:
print(a*h)
else:
print(a*h-b)
|
s603906374
|
Accepted
| 17 | 2,940 | 120 |
h,w = map(int, input().split())
a = h*w
if h==1 or w==1:
print(1)
elif a%2==0:
print(a//2)
else:
print(a//2+1)
|
s058896468
|
p03829
|
u842964692
| 2,000 | 262,144 |
Wrong Answer
| 79 | 14,228 | 190 |
There are N towns on a line running east-west. The towns are numbered 1 through N, in order from west to east. Each point on the line has a one- dimensional coordinate, and a point that is farther east has a greater coordinate value. The coordinate of town i is X_i. You are now at town 1, and you want to visit all the other towns. You have two ways to travel: * Walk on the line. Your _fatigue level_ increases by A each time you travel a distance of 1, regardless of direction. * Teleport to any location of your choice. Your fatigue level increases by B, regardless of the distance covered. Find the minimum possible total increase of your fatigue level when you visit all the towns in these two ways.
|
N,A,B=map(int,input().split())
X=list(map(int,input().split()))
ans=0
pre=X[0]
for xi in X[1:]:
if (xi-pre)*A-B>0:
ans+=B
else:
ans+=(xi-pre)
pre=xi
print(ans)
|
s889370500
|
Accepted
| 79 | 15,020 | 192 |
N,A,B=map(int,input().split())
X=list(map(int,input().split()))
ans=0
pre=X[0]
for xi in X[1:]:
if (xi-pre)*A-B>0:
ans+=B
else:
ans+=(xi-pre)*A
pre=xi
print(ans)
|
s112162671
|
p02613
|
u455354923
| 2,000 | 1,048,576 |
Wrong Answer
| 140 | 16,212 | 187 |
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())
list = [input() for i in range(N)]
print("AC ×", list.count("AC"))
print("WA ×", list.count("WA"))
print("TLE ×", list.count("TLE"))
print("RE ×", list.count("RE"))
|
s588120666
|
Accepted
| 139 | 16,220 | 183 |
N = int(input())
list = [input() for i in range(N)]
print("AC x", list.count("AC"))
print("WA x", list.count("WA"))
print("TLE x", list.count("TLE"))
print("RE x", list.count("RE"))
|
s240739208
|
p03636
|
u789565565
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 50 |
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
s = input()
x = len(s)
print(s[0]+'str(x)'+s[x-1])
|
s966402282
|
Accepted
| 19 | 2,940 | 50 |
s = input()
x = len(s)
print(s[0]+str(x-2)+s[x-1])
|
s562714793
|
p03693
|
u982471399
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 98 |
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
r,g,b = list(map(int,input().split()))
A=r*100+g*10+b
if A==0:
print("YES")
else:
print("NO")
|
s399119225
|
Accepted
| 17 | 2,940 | 100 |
r,g,b = list(map(int,input().split()))
A=r*100+g*10+b
if A%4==0:
print("YES")
else:
print("NO")
|
s475074354
|
p02613
|
u772261431
| 2,000 | 1,048,576 |
Wrong Answer
| 168 | 16,132 | 206 |
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)]
row = ['AC', 'WA', 'TLE', 'RE']
for r in row:
count = 0
for col in s:
if col == r:
count += 1
print(r, '×', count, sep=' ')
|
s296570108
|
Accepted
| 160 | 16,268 | 205 |
N = int(input())
s = [input() for i in range(N)]
row = ['AC', 'WA', 'TLE', 'RE']
for r in row:
count = 0
for col in s:
if col == r:
count += 1
print(r, 'x', count, sep=' ')
|
s281538156
|
p03544
|
u905582793
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 76 |
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
|
a=[2,1]
for i in range(90):
a.append(a[-1]+a[-2])
print(a[int(input())-1])
|
s421505145
|
Accepted
| 17 | 2,940 | 74 |
a=[2,1]
for i in range(90):
a.append(a[-1]+a[-2])
print(a[int(input())])
|
s400176411
|
p03457
|
u691072882
| 2,000 | 262,144 |
Wrong Answer
| 624 | 31,468 | 776 |
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())
All = [list(map(int, input().split())) for _ in range(N)]
t = [row[0] for row in All]
x = [row[1] for row in All]
y = [row[2] for row in All]
pre_x = 0
pre_y = 0
pre_t = 0
can = True
for n in range(N):
can2 = False
T = abs(t[n] - pre_t)
dx = abs(x[n] - pre_x)
dy = abs(y[n] - pre_y)
print(T,dx,dy)
if dx + dy == 0 and T % 2 == 0:
can2 = True
print("成功")
elif dx + dy == 0 and T % 2 != 0:
can2 = False
print("失敗")
break
if (T % (dx + dy)) == 0:
can2 = True
print("成功")
if can2 == False:
can = False
print("失敗")
break
pre_t = t[n]
pre_x = x[n]
pre_y = y[n]
if can == True:
print("Yes")
else:
print("No")
|
s153924080
|
Accepted
| 419 | 27,380 | 487 |
N = int(input())
All = [list(map(int, input().split())) for _ in range(N)]
pre_x = 0
pre_y = 0
pre_t = 0
can = True
for n in range(N):
can2 = False
T = All[n][0] - pre_t
d = abs(All[n][1] - pre_x) + abs(All[n][2] - pre_y)
# print(T, d)
if d <= T and T % 2 == d % 2:
can2 = True
if can2 == False:
can = False
break
pre_t = All[n][0]
pre_x = All[n][1]
pre_y = All[n][2]
if can == True:
print("Yes")
else:
print("No")
|
s073616476
|
p00029
|
u300946041
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,744 | 374 |
Your task is to write a program which reads a text and prints two words. The first one is the word which is arise most frequently in the text. The second one is the word which has the maximum number of letters. The text includes only alphabetical characters and spaces. A word is a sequence of letters which is separated by the spaces.
|
# -*- coding: utf-8 -*-
from collections import defaultdict
d = defaultdict(int)
_input = input()
sentence = [e for e in _input.split()]
l = []
for word in sentence:
d[word] += 1
times = sorted(d.items(), key=lambda item: item[1], reverse=True)
lengths = sorted(d.items(), key=lambda item: len(item[0]), reverse=True)
print(times[0][1], end=' ')
print(lengths[0][0])
|
s045143891
|
Accepted
| 30 | 7,748 | 334 |
# -*- coding: utf-8 -*-
from collections import defaultdict
d = defaultdict(int)
_input = input()
for word in _input.split():
d[word] += 1
times = sorted(d.items(), key=lambda item: item[1], reverse=True)
lengths = sorted(d.items(), key=lambda item: len(item[0]), reverse=True)
print(times[0][0], end=' ')
print(lengths[0][0])
|
s512822453
|
p04030
|
u105099610
| 2,000 | 262,144 |
Wrong Answer
| 25 | 9,016 | 215 |
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())
n = len(s)
ans = []
for i in range(n):
if s[i] == 0:
ans.append('0')
elif s[i] == 1:
ans.append('1')
elif ans == []:
continue
else:
ans.pop()
print(''.join(ans))
|
s617374223
|
Accepted
| 23 | 9,020 | 219 |
s = list(input())
n = len(s)
ans = []
for i in range(n):
if s[i] == '0':
ans.append('0')
elif s[i] == '1':
ans.append('1')
elif ans == []:
continue
else:
ans.pop()
print(''.join(ans))
|
s424675154
|
p02646
|
u888092736
| 2,000 | 1,048,576 |
Wrong Answer
| 22 | 9,172 | 221 |
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())
delta_v = V - W
if delta_v <= 0:
print('No')
elif (abs(A - B) + delta_v - 1) // delta_v > T:
print('No')
else:
print('Yes')
|
s302881884
|
Accepted
| 21 | 9,172 | 221 |
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
delta_v = V - W
if delta_v <= 0:
print('NO')
elif (abs(A - B) + delta_v - 1) // delta_v > T:
print('NO')
else:
print('YES')
|
s452651606
|
p03486
|
u485566817
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 115 |
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
s = str(input())
t = str(input())
s2 = sorted(s)
t2 = sorted(t)
if s2 < t2:
print('yes')
else:
print('no')
|
s814603388
|
Accepted
| 17 | 2,940 | 124 |
s = input()
t = input()
s_r = sorted(s)
t_r = sorted(t, reverse=True)
if s_r < t_r:
print("Yes")
else:
print("No")
|
s836742595
|
p03229
|
u060736237
| 2,000 | 1,048,576 |
Wrong Answer
| 231 | 8,516 | 335 |
You are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.
|
N = int(input())
A = sorted([int(input()) for _ in range(N)], reverse=True)
result = 0
if N % 2 == 0:
k = [2]*((N-2)//2)
k += [1]
k += [-1]
a = [-2]*((N-2)//2)
k = k+a
else:
k = [2]*(N//2-1)
k += [1]
k += [1]
a = [-2]*(N//2)
k = k+a
for a, keisu in zip(A, k):
result += a*keisu
print(result)
|
s706429595
|
Accepted
| 263 | 8,612 | 607 |
N = int(input())
A = sorted([int(input()) for _ in range(N)], reverse=True)
result = 0
if N % 2 == 0:
k = [2]*((N-2)//2)
k += [1]
k += [-1]
a = [-2]*((N-2)//2)
k = k+a
for a, keisu in zip(A, k):
result += a*keisu
else:
k = [2]*(N//2-1)
k += [1]
k += [1]
a = [-2]*(N//2)
k = k+a
result1 = 0
for a, keisu in zip(A, k):
result1 += a*keisu
k = [2]*(N//2)
k += [-1]
k += [-1]
a = [-2]*(N//2-1)
k = k+a
result2 = 0
for a, keisu in zip(A, k):
result2 += a*keisu
result = max(result1, result2)
print(result)
|
s719191845
|
p03827
|
u016881126
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,144 | 241 |
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
|
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')
N = int(input())
S = input()
ans = S.count("I") - S.count("D")
print(ans)
|
s064609375
|
Accepted
| 28 | 8,968 | 312 |
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')
N = int(input())
S = input()
ans = 0
x = 0
for s in S:
if s == "I":
x += 1
else:
x -= 1
ans = max(ans, x)
print(ans)
|
s667808684
|
p03998
|
u548303713
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,188 | 927 |
Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game.
|
a=list(input())
b=list(input())
c=list(input())
a_num,b_num,c_num=len(a),len(b),len(c)
now="A"
ans="A"
flag=True
def delete(now):
global a_num
global b_num
global c_num
global ans
global flag
if now=="A":
change(a[0])
del a[0]
a_num-=1
if a_num==0:
ans="A"
flag=False
elif now=="B":
change(b[0])
del b[0]
b_num-=1
if b_num==0:
ans="B"
flag=False
else:
change(c[0])
del c[0]
c_num-=1
if c_num==0:
ans="C"
flag=False
def change(card):
global now
if card=="a":
now="A"
elif card=="b":
now="B"
else:
now="C"
while flag:
delete(now)
print(a)
print(a_num)
print(ans)
|
s416592028
|
Accepted
| 20 | 3,064 | 1,106 |
a=list(input())
b=list(input())
c=list(input())
a_num,b_num,c_num=len(a),len(b),len(c)
now="A"
ans="A"
flag=True
def delete(now):
global a_num
global b_num
global c_num
global ans
global flag
if now=="A":
if a_num==0:
ans="A"
flag=False
return
change(a[0])
del a[0]
a_num-=1
elif now=="B":
if b_num==0:
ans="B"
flag=False
return
change(b[0])
del b[0]
b_num-=1
else:
if c_num==0:
ans="C"
flag=False
return
change(c[0])
del c[0]
c_num-=1
def change(card):
global now
if card=="a":
now="A"
elif card=="b":
now="B"
else:
now="C"
while flag:
delete(now)
#print(a)
#print(a_num)
print(ans)
|
s332708147
|
p02694
|
u608007704
| 2,000 | 1,048,576 |
Time Limit Exceeded
| 2,205 | 9,136 | 99 |
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?
|
N=int(input())
v=100
count=0
while True:
if N<v:
break
count+=1
v*1.01//1
print(count)
|
s159444167
|
Accepted
| 23 | 9,168 | 108 |
N=int(input())
v=100
count=0
while True:
if N<=v:
break
count+=1
v*=1.01
v=int(v)
print(count)
|
s665858880
|
p03545
|
u743164083
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 256 |
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.
|
n = list(input())
ni = map(int,n)
ns = sorted(ni, reverse=True)
ans = 0
op = []
for i in ns:
ans += i
if ans > 7:
ans -= i
op += "-"
else:
op += "+"
print("%d%s%d%s%d%s%d=7" % (ns[0],op[0],ns[1],op[1],ns[2],op[2],ns[3]))
|
s682038479
|
Accepted
| 29 | 9,124 | 277 |
n = input()
for x in range(1 << 3):
opr = ["-"] * 3
for i in range(3):
if x & (1 << i):
opr[i] = "+"
shiki = "%s%s%s%s%s%s%s" % (n[0], opr[0], n[1], opr[1], n[2], opr[2], n[3])
if eval(shiki) == 7:
print("%s=7" % shiki)
break
|
s607826044
|
p03455
|
u503901534
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 114 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
p = list(map(int,input().split()))
if (p[0] or p[1]) % 2 == 0:
print('Even')
else:
print('Odd')
|
s074725453
|
Accepted
| 17 | 2,940 | 103 |
p = list(map(int,input().split()))
if (p[0] * p[1]) % 2 == 0:
print('Even')
else:
print('Odd')
|
s382797534
|
p03854
|
u901447859
| 2,000 | 262,144 |
Wrong Answer
| 2,111 | 3,188 | 253 |
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
s = input()
cpos = 0
while True:
for b in ['dream', 'dreamer', 'erase', 'eraser']:
pos = s.find(b)
if pos == cpos:
cpos += len(b)
break
if cpos == len(s)-1:
print('YES')
break
elif pos == -1:
print('NO')
break
|
s789269874
|
Accepted
| 19 | 3,188 | 124 |
s = input().replace('eraser',"").replace('erase',"").replace('dreamer',"").replace('dream',"")
print(['YES','NO'][0<len(s)])
|
s280784710
|
p02850
|
u417365712
| 2,000 | 1,048,576 |
Wrong Answer
| 2,105 | 24,800 | 691 |
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colorings satisfying the condition above, construct one that uses the minimum number of colors.
|
import sys
from collections import defaultdict
inputs = sys.stdin.readlines()
n = int(inputs[0])
nodes = [tuple(map(int, x.split())) for x in inputs[1:]]
tree = defaultdict(tuple)
for i in range(1, n+1):
tree[i] = tuple(n[1] for n in nodes if n[0] == i)
colors = list(range(1, max([len(x) for x in tree.values()])+2))
def travel(p, bros):
use_colors = [p]
for node in bros:
for c in colors:
if c not in use_colors:
use_colors.append(c)
break
nodes[node] = c
travel(c, tree[node])
nodes = [0]*(n+1)
node = 1
nodes[node] = 1
childs = tree[node]
travel(node, childs)
for node in nodes[1:]:
print(node)
|
s920196390
|
Accepted
| 342 | 36,048 | 514 |
import sys
from collections import deque
inputs = sys.stdin.readlines()
n = int(inputs[0])
edges = [tuple(map(int, x.split())) for x in inputs[1:]]
to_edges = [e[1] for e in edges]
tree = [[] for _ in range(n + 1)]
for x, y in edges:
tree[x].append(y)
queue = deque([1])
colors = [0] * (n + 1)
while queue:
x = queue.popleft()
c = 0
for y in tree[x]:
c += 1 + (c + 1 == colors[x])
colors[y] = c
queue.append(y)
print(max(colors))
for e in to_edges:
print(colors[e])
|
s417997671
|
p02400
|
u613534067
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,612 | 73 |
Write a program which calculates the area and circumference of a circle for given radius r.
|
import math
r = float(input())
print(2.0 * math.pi * r, math.pi * r * r)
|
s232453269
|
Accepted
| 20 | 5,620 | 99 |
import math
r = float(input())
print("{0:.6f} {1:.6f}".format(math.pi * r * r, 2.0 * math.pi * r))
|
s968603758
|
p03487
|
u970449052
| 2,000 | 262,144 |
Wrong Answer
| 102 | 14,268 | 273 |
You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence.
|
n=int(input())
al=list(map(int,input().split()))
al.sort()
ans=0
t=0
cnt=0
for i in range(n):
if al[i]!=t:
ans+=cnt-t if cnt>t else cnt
t=al[i]
cnt=0
else:
cnt+=1
else:
if al[i]!=t:
ans+=cnt-t if cnt>t else cnt
print(ans)
|
s756595614
|
Accepted
| 107 | 14,692 | 254 |
n=int(input())
al=list(map(int,input().split()))
al.sort()
ans=0
t=0
cnt=0
for i in range(n):
if al[i]!=t:
ans+=cnt-t if cnt>=t else cnt
t=al[i]
cnt=1
else:
cnt+=1
else:
ans+=cnt-t if cnt>=t else cnt
print(ans)
|
s733717794
|
p03162
|
u901598613
| 2,000 | 1,048,576 |
Wrong Answer
| 2,319 | 127,900 | 308 |
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains.
|
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
dp=[[0,0,0] for _ in range(n)]
dp[0]=l[0]
for i in range(1,n):
dp[i][0]=l[i][0]+max(dp[i-1][1],dp[i-1][2])
dp[i][1]=l[i][1]+max(dp[i-1][0],dp[i-1][2])
dp[i][2]=l[i][2]+max(dp[i-1][0],dp[i-1][1])
print(dp)
print(max(dp[-1]))
|
s913472462
|
Accepted
| 390 | 49,960 | 296 |
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
dp=[[0,0,0] for _ in range(n)]
dp[0]=l[0]
for i in range(1,n):
dp[i][0]=l[i][0]+max(dp[i-1][1],dp[i-1][2])
dp[i][1]=l[i][1]+max(dp[i-1][0],dp[i-1][2])
dp[i][2]=l[i][2]+max(dp[i-1][0],dp[i-1][1])
print(max(dp[-1]))
|
s431996527
|
p02831
|
u483230733
| 2,000 | 1,048,576 |
Wrong Answer
| 2,108 | 27,224 | 253 |
Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted. We assume that a piece cannot be divided and distributed to multiple guests.
|
a, b = map(int, input().split())
count = 1
an = []
bn = []
eee = min(a,b)
for ii in range(1, eee+2):
bbb = b * ii
bn.append(bbb)
while True:
aaa = a * count
print(aaa)
if aaa in bn:
print(aaa)
break
count += 1
|
s835242123
|
Accepted
| 43 | 2,940 | 147 |
a, b = map(int, input().split())
count = 1
while True:
aaa = a * count
if aaa % b == 0:
print(aaa)
break
count += 1
|
s478962280
|
p02608
|
u092061507
| 2,000 | 1,048,576 |
Wrong Answer
| 850 | 9,436 | 258 |
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())
ret = [0 for i in range(N)]
for x in range(1,100):
for y in range(1,100):
for z in range(1,100):
a = x**2 + y**2 + z**2 + x*y + y*z + z*x
if a < N:
ret[a] += 1
for i in ret:
print(i)
|
s383919477
|
Accepted
| 857 | 9,200 | 269 |
N = int(input())
#N = 20
ret = [0 for i in range(N)]
for x in range(1,100):
for y in range(1,100):
for z in range(1,100):
a = x**2 + y**2 + z**2 + x*y + y*z + z*x
if a <= N:
ret[a-1] += 1
for i in ret:
print(i)
|
s912044622
|
p00016
|
u150984829
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,768 | 149 |
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 cmath,math,sys
z=0;p=90
for e in sys.stdin:
r,d=map(int,e.split(','))
z+=cmath.rect(r,math.radians(p))
p-=d
print(int(z.real),int(z.imag))
|
s767857086
|
Accepted
| 20 | 5,772 | 161 |
import cmath,math,sys
z=0;p=90
for e in sys.stdin:
r,d=map(int,e.split(','))
z+=cmath.rect(r,math.radians(p))
p-=d
print(int(z.real),'\n',int(z.imag),sep='')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.