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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s204321039 | p03860 | u895918162 | 2,000 | 262,144 | Wrong Answer | 26 | 8,756 | 124 | Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppe... | sentence = input()
new_sent = sentence.split(" ")
acro = ""
for i in range(len(new_sent)):
acro += new_sent[i]
print(acro) | s027216626 | Accepted | 26 | 8,836 | 108 | sentence = input()
new_sent = sentence.split(" ")
acro = ""
for i in new_sent:
acro += i[0]
print(acro)
|
s178464013 | p03836 | u681150536 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 412 | Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement ... | def main():
sx, sy, tx, ty = list(map(int, input().split()))
dx = sx - tx
dy = sy - ty
ans = ''
ans += 'U' * dy + 'R' * dx
ans += 'D' * dy + 'L' * dx
ans += 'L' + 'U' * (dy + 1) + 'R' * (dx + 1) + 'D'
ans += 'R' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U'
print(a... | s229156265 | Accepted | 17 | 3,060 | 412 | def main():
sx, sy, tx, ty = list(map(int, input().split()))
dx = tx - sx
dy = ty - sy
ans = ''
ans += 'U' * dy + 'R' * dx
ans += 'D' * dy + 'L' * dx
ans += 'L' + 'U' * (dy + 1) + 'R' * (dx + 1) + 'D'
ans += 'R' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U'
print(a... |
s736845724 | p03471 | u004025573 | 2,000 | 262,144 | Wrong Answer | 2,104 | 3,064 | 443 | The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situat... | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 19 03:01:30 2018
@author: ashida
"""
N, Y = map(int, input().split())
flag = -1
for n_10k in range(N+1):
for n_5k in range(N+1-n_10k):
for n_1k in range(N+1-n_10k-n_5k):
if 10000*n_10k + 5000*n_5k + 1000*n_1k == Y:
flag = 1
... | s831931320 | Accepted | 777 | 3,064 | 416 | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 19 03:01:30 2018
@author: ashida
"""
N, Y = map(int, input().split())
flag = -1
for n_10k in range(N+1):
for n_5k in range(N+1-n_10k):
n_1k = N-n_10k-n_5k
if 10000*n_10k + 5000*n_5k + 1000*n_1k == Y:
flag = 1
ans = [n_10k, n_... |
s561255277 | p02262 | u227438830 | 6,000 | 131,072 | Wrong Answer | 30 | 7,760 | 501 | Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+... | N = int(input())
a = [int(input()) for i in range(N)]
f = [2**i - 1 for i in range(1,N) if 2**i < N ]
cnt = 0
g = f[::-1]
def insertionSort(a, N, g):
global cnt
for i in range(g, N):
v = a[i]
j = i - g
while j >= 0 and a[j] > v:
a[j + g] = a[j]
j -= g
... | s905036367 | Accepted | 22,060 | 47,648 | 513 | N = int(input())
a = [int(input()) for i in range(N)]
f = []
x = 1
while x <= N:
f.append(x)
x = 3*x + 1
cnt = 0
g = f[::-1]
def insertionSort(a, N, g):
global cnt
for i in range(g, N):
v = a[i]
j = i - g
while j >= 0 and a[j] > v:
a[j + g] = a[j]
j -= g
... |
s461418271 | p03625 | u852420560 | 2,000 | 262,144 | Wrong Answer | 119 | 15,020 | 324 | We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle. | N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
print(A)
setbar=[]
known=set()
for a in A:
if a in known:
setbar.append(a)
known.remove(a)
else:
known.add(a)
if len(setbar) >= 2:
break
if len(setbar) >= 2:
print(setbar[0]*setbar[1])
else:
prin... | s739418651 | Accepted | 105 | 14,244 | 326 | N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
#print(A)
setbar=[]
known=set()
for a in A:
if a in known:
setbar.append(a)
known.remove(a)
else:
known.add(a)
if len(setbar) >= 2:
break
if len(setbar) >= 2:
print(setbar[0]*setbar[1])
else:
pri... |
s750383238 | p03624 | u733738237 | 2,000 | 262,144 | Wrong Answer | 71 | 6,336 | 244 | You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead. | from string import*
s =input()
s=sorted(s)
alpha_l =[ascii_lowercase[i] for i in range(25)]
print(s,alpha_l)
n='a'
for x in range(25):
if alpha_l[x] in s:
if x ==25:
n = 'None'
break
continue
else:
n = alpha_l[x]
break
print(n) | s700843033 | Accepted | 67 | 4,924 | 242 | from string import*
s =input()
s=sorted(s)
alpha_l =[ascii_lowercase[i] for i in range(0,26)]
n='a'
for x in range(0,26):
if x == 25 and alpha_l[x] in s:
n = 'None'
elif alpha_l[x] in s:
continue
else:
n = alpha_l[x]
break
print(n) |
s593349862 | p02613 | u611033537 | 2,000 | 1,048,576 | Wrong Answer | 139 | 16,192 | 192 | 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`,... | N = int(input())
s = [input() for i in range(N)]
a = s.count('AC')
b = s.count('WA')
c = s.count('TLE')
d = s.count('RE')
print('AC ×',a)
print('WA ×',b)
print('TLE ×',c)
print('RE ×',d) | s304028118 | Accepted | 140 | 16,272 | 188 | N = int(input())
s = [input() for i in range(N)]
a = s.count('AC')
b = s.count('WA')
c = s.count('TLE')
d = s.count('RE')
print('AC x',a)
print('WA x',b)
print('TLE x',c)
print('RE x',d) |
s501628407 | p02345 | u134812425 | 2,000 | 131,072 | Wrong Answer | 30 | 7,912 | 922 | Write a program which manipulates a sequence A = {a0, a1, . . . , an-1} with the following operations: * find(s, t): report the minimum element in as, as+1, . . . ,at. * update(i, x): change ai to x. Note that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1. | import bisect
import collections
import heapq
import itertools
import operator
import sys
def main():
int_max = 2 ** 31 - 1
n, q = map(int, sys.stdin.readline().split())
dat = [int_max] * (131072 * 2 - 1)
def update(i, x):
i += n - 1
dat[i] = x
while i > 0:
i = (i ... | s976512474 | Accepted | 2,200 | 10,120 | 954 | import bisect
import collections
import heapq
import itertools
import operator
import sys
def main():
int_max = 2 ** 31 - 1
n, q = map(int, sys.stdin.readline().split())
n = 1 << (n - 1).bit_length()
dat = [int_max] * 131072 * 2
def update(i, x):
i += n - 1
dat[i] = x
whil... |
s080116527 | p02865 | u958973639 | 2,000 | 1,048,576 | Wrong Answer | 217 | 42,648 | 143 | How many ways are there to choose two distinct positive integers totaling N, disregarding the order? | N=int(input())
a=[]
for i in range(1,N+1):
b=N-i
a.append(b)
if N%2==0 :
print(len(a)/2-1)
else :
print(round((len(a)-1)/2)) | s359363443 | Accepted | 17 | 2,940 | 85 | N=int(input())
if N%2==0 :
print(round(N/2)-1)
else :
print(round((N-1)/2)) |
s763545478 | p03944 | u686036872 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 294 | 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) po... | W, H, N = map(int,input().split())
Wmin = 0
Wmax = W
Hmin = 0
Hmax = H
for i in range(N):
x, y, z = map(int,input().split())
if z == 1:
Wmin = x
if z == 2:
Wmax = x
if z == 3:
Hmin = y
if z == 4:
Hmax = y
print(W*H-(Wmax-Wmin)*(Hmax-Hmin)) | s011010526 | Accepted | 18 | 3,064 | 388 | W, H, N = map(int,input().split())
Wmin = 0
Wmax = W
Hmin = 0
Hmax = H
for i in range(N):
x, y, z = map(int,input().split())
if z == 1:
Wmin = max(x, Wmin)
if z == 2:
Wmax = min(x, Wmax)
if z == 3:
Hmin = max(y, Hmin)
if z == 4:
Hmax = min(y, Hmax)
if Wmax < Wmin or... |
s193713626 | p03005 | u021548497 | 2,000 | 1,048,576 | Wrong Answer | 29 | 9,084 | 58 | Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls? | n, k = map(int, input().split())
ans = n-k if k > 1 else 0 | s001083362 | Accepted | 27 | 9,112 | 69 | n, k = map(int, input().split())
ans = n-k if k > 1 else 0
print(ans) |
s225055959 | p02678 | u436173409 | 2,000 | 1,048,576 | Wrong Answer | 702 | 35,368 | 486 | 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 th... | from collections import deque
n, m = [int(e) for e in input().split()]
AB = [[] for _ in range(n+1)]
for i in range(m):
A,B = [int(e) for e in input().split()]
AB[A].append(B)
AB[B].append(A)
ans = [0]*(n+1)
visited = [0]*(n+1)
root = 1
visited[root] = 1
q = deque([root])
while q:
v = q.popleft()
... | s266862449 | Accepted | 675 | 35,380 | 486 | from collections import deque
n, m = [int(e) for e in input().split()]
AB = [[] for _ in range(n+1)]
for i in range(m):
A,B = [int(e) for e in input().split()]
AB[A].append(B)
AB[B].append(A)
ans = [0]*(n+1)
visited = [0]*(n+1)
root = 1
visited[root] = 1
q = deque([root])
while q:
v = q.popleft()
... |
s604845022 | p03860 | u016323272 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 55 | Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppe... | #ABC048.A
s = input('')
print('AtCoder'+s[0]+'Contest') | s573065670 | Accepted | 17 | 2,940 | 54 | #ABC048.A
A,B,C= input().split()
print(A[0]+B[0]+C[0]) |
s456962284 | p02850 | u886747123 | 2,000 | 1,048,576 | Wrong Answer | 2,253 | 113,340 | 467 | 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 colo... | N = int(input())
neighbor = [[] for _ in range(N)]
edge = []
for _ in range(N-1):
a,b = map(int, input().split())
neighbor[a-1].append(b-1)
neighbor[b-1].append(a-1)
edge.append([min(a-1, b-1), max(a-1, b-1)])
edge = sorted(edge, key=lambda x:x[0])
K = len(max(neighbor, key=len))
color = [set(range(1,... | s234691940 | Accepted | 589 | 78,360 | 705 | import sys
sys.setrecursionlimit(500000)
N = int(sys.stdin.buffer.readline())
neighbor = [[] for _ in range(N)]
for i in range(N-1):
a, b = map(int, sys.stdin.buffer.readline().split())
neighbor[a-1].append([b-1, i])
neighbor[b-1].append([a-1, i])
K = max(len(l) for l in neighbor)
print(K)
ans = [-1]*(N-... |
s740177720 | p03417 | u844005364 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 67 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following op... | n, m = map(int, input().split())
print(max(1, n - 2)*max(1, m - 2)) | s166190374 | Accepted | 17 | 2,940 | 155 | n, m = map(int, input().split())
if n == 1 and m == 1:
print(1)
elif n == 1:
print(m - 2)
elif m == 1:
print(n - 2)
else:
print((n - 2) * (m - 2)) |
s970861933 | p03943 | u872328196 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 124 | 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. Not... | a, b, c = map(int, input().split())
if (a + b == c) or (b + c == a) or (c + a == b):
print("YES")
else:
print("NO")
| s014819486 | Accepted | 17 | 2,940 | 124 | a, b, c = map(int, input().split())
if (a + b == c) or (b + c == a) or (c + a == b):
print("Yes")
else:
print("No")
|
s618175683 | p03578 | u188827677 | 2,000 | 262,144 | Wrong Answer | 301 | 56,996 | 399 | Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems.... | from collections import Counter
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
count_d = Counter(d)
count_t = Counter(t)
for i in count_t.items():
if i[0] not in count_d:
print("NO")
exit()
if i[0] in count_d: count_d[i[0]] -= i[1]
else:
for x i... | s551300053 | Accepted | 244 | 57,300 | 333 | from collections import Counter
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
d_count = Counter(d)
t_count = Counter(t)
for x,y in t_count.items():
if x in d_count:
if y > d_count[x]:
print("NO")
break
else:
print("NO")
break
else:... |
s232811701 | p02614 | u912318491 | 1,000 | 1,048,576 | Wrong Answer | 69 | 9,140 | 449 | We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation... | h, w, k = map(int, input().split())
c = []
ans = 0
for i in range(h):
c.append(input())
for maskR in range(1 << h):
for maskC in range(1 << w):
black = 0
for i in range(h):
for j in range(w):
if maskR >> i & 1 == 0 and maskC >> j & 1 == 0 and c[i][j] == '#':
... | s074402777 | Accepted | 62 | 9,188 | 399 | h, w, k = map(int, input().split())
c = []
ans = 0
for i in range(h):
c.append(input())
for maskR in range(1 << h):
for maskC in range(1 << w):
black = 0
for i in range(h):
for j in range(w):
if maskR >> i & 1 == 0 and maskC >> j & 1 == 0 and c[i][j] == '#':
... |
s545798194 | p04012 | u414772150 | 2,000 | 262,144 | Wrong Answer | 20 | 3,316 | 198 | Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. | import collections
str=input().strip()
ans=True
for item, count in collections.Counter(str).items():
if count%2!=0:
ans=False
if ans==False:
print("NO")
else:
print("YES") | s643826159 | Accepted | 20 | 3,316 | 199 | import collections
str=input().strip()
ans=True
for item, count in collections.Counter(str).items():
if count%2!=0:
ans=False
if ans==False:
print("No")
else:
print("Yes")
|
s026245396 | p03401 | u202058925 | 2,000 | 262,144 | Wrong Answer | 2,104 | 14,100 | 282 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from... | n = int(input())
a = list(map(int, input().split()))
answer = []
for x, y in enumerate(a):
sum = 0
present = 0
for s, t in enumerate(a):
if s != x:
cost = abs(t-present)
sum += cost
present = t
sum += abs(present-0)
answer.append(sum)
print(answer)
| s157052417 | Accepted | 253 | 14,048 | 479 | n = int(input())
a = list(map(int, input().split()))
sum = 0
present = 0
for s, t in enumerate(a):
sum += abs(t-present)
present = t
sum += abs(present-0)
for i, each in enumerate(a):
if i == 0:
prev = 0
tmp = each
next = a[i+1]
elif i == len(a)-1:
prev = a[i-1]
tmp = each
next = 0
... |
s555930534 | p03957 | u712335892 | 1,000 | 262,144 | Wrong Answer | 24 | 3,064 | 305 | This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters. Mr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way. You are given a string s consisting of uppercase English letters. Determine whether the string `CF` can be obtai... | s = list(str(input()))
ans = False
if 'C' in s:
c_index = s.index('C')
for i in range(len(s)):
char = s[len(s) - i - 1]
if char == 'F':
f_index = len(s) - i - 1
if c_index < f_index:
ans = True
if ans:
print('YES')
else:
print('NO')
| s942446722 | Accepted | 22 | 3,064 | 305 | s = list(str(input()))
ans = False
if 'C' in s:
c_index = s.index('C')
for i in range(len(s)):
char = s[len(s) - i - 1]
if char == 'F':
f_index = len(s) - i - 1
if c_index < f_index:
ans = True
if ans:
print('Yes')
else:
print('No')
|
s179130250 | p02744 | u044220565 | 2,000 | 1,048,576 | Wrong Answer | 2,103 | 3,188 | 812 | In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be **isomorphic** when the following conditions are satisfied: * |s| = |t| holds. * For every pair i, j, one of the following holds: * s_i = s_j and t_i = t_j. * s_i \neq s_j and t_i \neq t_j. F... | # coding: utf-8
N = int(input())
arrays = list("abcdefghij")
pat_dic = {i:arrays[i] for i in range(N)}
par_patterns = list(range(10))
patterns = par_patterns[:N]
def next_search(arr,N):
tmp = arr.copy()
if len(tmp) == N:
if check_criteria(tmp):
print([pat_dic[tmp[i]] for i in range(N)])
... | s960728652 | Accepted | 562 | 4,340 | 529 | # coding: utf-8
N = int(input())
arrays = list("abcdefghij")
pat_dic = {i:arrays[i] for i in range(N)}
par_patterns = list(range(10))
patterns = par_patterns[:N]
def next_search(arr,N):
tmp = arr.copy()
if len(tmp) == N:
print(''.join([pat_dic[tmp[i]] for i in range(N)]))
return None
for s... |
s420529580 | p03854 | u630554891 | 2,000 | 262,144 | Wrong Answer | 66 | 9,164 | 279 | 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()
s=s[::-1]
print(s[:5],s[:7])
for i in range(100000):
if s[:5] == 'maerd' or s[:6] == 'esare':
s = s[5:]
if s[:6] == 'resare':
s = s[6:]
if s[:7] == 'remaerd':
s = s[7:]
#print(s)
if len(s)==0:
print('YES')
else:
print('N0') | s964213321 | Accepted | 93 | 9,232 | 273 | s=input()
s=s[::-1]
for i in range(100000):
if s[:5] == 'maerd':
s = s[5:]
if s[:5] == 'esare':
s = s[5:]
if s[:6] == 'resare':
s = s[6:]
if s[:7] == 'remaerd':
s = s[7:]
if len(s)==0:
print('YES')
else:
print('NO') |
s542690772 | p03997 | u787449825 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 67 | You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid. | a = int(input())
b = int(input())
h = int(input())
print((a+b)*h/2) | s110546141 | Accepted | 17 | 2,940 | 69 | a = int(input())
b = int(input())
h = int(input())
print((a+b)*h//2)
|
s907312285 | p02917 | u094932051 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,064 | 412 | There is an integer sequence A of length N whose values are unknown. Given is an integer sequence B of length N-1 which is known to satisfy the following: B_i \geq \max(A_i, A_{i+1}) Find the maximum possible sum of the elements of A. | while True:
try:
N = int(input())
B = list(map(int, input().split()))
A = [2**31] * N
if N == 2:
print(B[0]*2)
continue
A[N-1] = B.pop()
for i in range(N-2, 0, -1):
_ = B.pop()
A[i] = min(A[i+1], _)
... | s337928504 | Accepted | 17 | 3,064 | 314 | while True:
try:
N = int(input())
B = list(map(int, input().split()))
A = [2**31] * N
A[0] = B[0]
for i in range(1, N-1):
A[i] = min(B[i-1], B[i])
A[N-1] = B[N-2]
#print(A)
print(sum(A))
except:
break |
s071361282 | p03379 | u903005414 | 2,000 | 262,144 | Wrong Answer | 358 | 26,016 | 240 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..... | N = int(input())
X = list(map(int, input().split()))
X = sorted(X)
# print('X', X)
for i in X:
if i <= X[N // 2 - 1]:
print(X[N // 2])
else:
print(X[N // 2 - 1])
| s406260068 | Accepted | 331 | 25,220 | 282 | N = int(input())
X = list(map(int, input().split()))
sorted_X = sorted(X)
# print('X', X)
for i in X:
if i <= sorted_X[N // 2 - 1]:
print(sorted_X[N // 2])
else:
print(sorted_X[N // 2 - 1])
|
s884546723 | p03623 | u983918956 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 62 | 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... | x,a,b = map(int,input().split())
print(min(abs(x-a),abs(x-b))) | s362335441 | Accepted | 17 | 2,940 | 98 | x,a,b = map(int,input().split())
A = abs(x-a)
B = abs(x-b)
if A<B:
print("A")
else:
print("B") |
s653006726 | p03679 | u732870425 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 140 | 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. Ot... | x, a, b = map(int, input().split())
if b-a < 0:
print("delicious")
elif b-a >= 0 and b-a >= x:
print("safe")
else:
print("dangerous") | s578329358 | Accepted | 17 | 2,940 | 131 | x, a, b = map(int, input().split())
if b <= a:
print("delicious")
elif a < b <= a+x:
print("safe")
else:
print("dangerous")
|
s789082664 | p02258 | u424041287 | 1,000 | 131,072 | Wrong Answer | 20 | 5,584 | 86 | You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen. Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2,... | t =[]
for i in range(int(input())):
t.append(int(input()))
print(max(t) - min(t)) | s969619715 | Accepted | 620 | 13,592 | 231 | t = []
n = int(input())
for i in range(n):
t.append(int(input()))
'''
n = 6
t=[4,1,5,7,5,4]
'''
minv = t[0]
maxv = t[1] - t[0]
for j in range(1,n):
maxv = max([maxv,t[j] - minv])
minv = min([minv,t[j]])
print(maxv) |
s998987748 | p03370 | u266146962 | 2,000 | 262,144 | Wrong Answer | 2,108 | 14,144 | 177 | 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 o... | import numpy as np
N,X = input().split()
N = int(N)
X = int(X)
m = np.zeros(N)
for i in range(N):
m[i] = int(input())
X = X - m[i]
over = X // min(m)
print(N+over) | s959555768 | Accepted | 1,326 | 20,744 | 182 | import numpy as np
N,X = input().split()
N = int(N)
X = int(X)
m = np.zeros(N)
for i in range(N):
m[i] = int(input())
X = X - m[i]
over = X // min(m)
print(int(N+over)) |
s961790546 | p02742 | u384261199 | 2,000 | 1,048,576 | Wrong Answer | 19 | 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 to... | H, W = list(map(int, input().split()))
if H*W % 2 == 0:
print(H*W/2)
else:
print(int(H*W/2) +1)
| s473240505 | Accepted | 17 | 2,940 | 175 | H, W = list(map(int, input().split()))
if H ==1 or W ==1:
print(1)
else:
if H*W % 2 == 0:
print(H*W//2)
elif H % 2 == 1 and W % 2 ==1:
print(int(H*W/2) +1)
|
s204296372 | p03129 | u220870679 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 174 | Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1. | n, k = map(int, input().split())
a = n / 2
if n == 2 and k == 1:
print("YES")
elif n == 3 and k <= 2:
print("Yes")
elif a >= k:
print("YES")
else:
print("NO") | s772438293 | Accepted | 17 | 2,940 | 143 | n, k = map(int, input().split())
count = 0
for i in range(1, (n + 1), 2):
count += 1
if count >= k:
print("YES")
else:
print("NO") |
s551062578 | p02936 | u098012509 | 2,000 | 1,048,576 | Wrong Answer | 2,108 | 100,976 | 482 | Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operati... | from collections import defaultdict
N, Q = [int(x) for x in input().split()]
dic = defaultdict(list)
dic2 = defaultdict(list)
for _ in range(N - 1):
a, b = [int(x) for x in input().split()]
for v in dic[a]:
dic2[v].append(b)
dic[b].append(a)
dic2[a].append(b)
ans = [0] * N
for _ in range(Q)... | s982580945 | Accepted | 1,144 | 74,912 | 555 | import sys
input = sys.stdin.readline
N, Q = [int(x) for x in input().split()]
edge = [[] for _ in range(N)]
for _ in range(N - 1):
a, b = [int(x) for x in input().split()]
edge[a - 1].append(b - 1)
edge[b - 1].append(a - 1)
cost = [0] * N
for _ in range(Q):
p, x = [int(x) for x in input().split()]
... |
s815388471 | p03449 | u949315872 | 2,000 | 262,144 | Wrong Answer | 30 | 8,964 | 333 | We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You ... | N = int(input())
A1 =list(map(int, input().split()))
A2 =list(map(int, input().split()))
candy = []
def sum_A1(x):
cnt = 0
for i in range(x):
cnt += A1[i]
return cnt
def sum_A2(x):
cnt = 0
for i in range(x-1,N):
cnt += A2[i]
return cnt
for i in range(N):
candy.append(sum_A1(i) + sum_A2(i))
... | s782749240 | Accepted | 29 | 9,204 | 341 | N = int(input())
A1 =list(map(int, input().split()))
A2 =list(map(int, input().split()))
candy = []
def sum_A1(x):
cnt = 0
for i in range(x+1):
cnt += A1[i]
return cnt
def sum_A2(x):
cnt = 0
for i in range(x,N):
cnt += A2[i]
return cnt
for i in range(N):
candy.append(sum_A1(i) + sum_A2(i))... |
s597416571 | p03698 | u417835834 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 152 | You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different. | S = list(input())
length_S = len(S)
S_short = set(S)
length_S_short = len(S_short)
if length_S == length_S_short:
print('Yes')
else:
print('No') | s228435019 | Accepted | 18 | 2,940 | 152 | S = list(input())
length_S = len(S)
S_short = set(S)
length_S_short = len(S_short)
if length_S == length_S_short:
print('yes')
else:
print('no') |
s357487095 | p03698 | u009102496 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 187 | You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different. | A=input()
B=[]
for i in range(len(A)):
B.append(A[i])
B.sort()
flg=0
for i in range(len(A)-1):
if B[i]==B[i+1]:
flg=+1
if flg>0:
print("yes")
else:
print("no") | s397779929 | Accepted | 18 | 3,060 | 187 | A=input()
B=[]
for i in range(len(A)):
B.append(A[i])
B.sort()
flg=0
for i in range(len(A)-1):
if B[i]==B[i+1]:
flg=+1
if flg>0:
print("no")
else:
print("yes") |
s528506818 | p02534 | u782685137 | 2,000 | 1,048,576 | Wrong Answer | 23 | 9,140 | 25 | You are given an integer K. Print the string obtained by repeating the string `ACL` K times and concatenating them. For example, if K = 3, print `ACLACLACL`. | print("acl"*int(input())) | s870798151 | Accepted | 20 | 9,072 | 25 | print("ACL"*int(input())) |
s290301921 | p03543 | u222841610 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 237 | We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**? | a = list(map(int,list(input())))
count = 1
check = False
for i in range(len(a)-1):
if a[i] == a[i+1]:
count += 1
if count==3:
check = True
else:
count = 1
print ('yes' if check==True else 'No') | s840677089 | Accepted | 17 | 2,940 | 148 | a = list(map(int,list(input())))
check = False
if a[0] == a[1] == a[2] or a[1]==a[2]==a[3]:
check = True
print ('Yes' if check==True else 'No') |
s199551293 | p03659 | u252828980 | 2,000 | 262,144 | Wrong Answer | 2,104 | 24,832 | 312 | Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it. They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card. Let th... | n = int(input())
L = sorted(list(map(int,input().split())))
if L[0] < 0:
L = [x-L[0] for x in L]
#print(L)
b = sum(L)//2
num = 0
for i in range(n):
num += L[i]
if num > b:
c = sum(L[:i-1])-sum(L[i-1:])
d = sum(L[:i])-sum(L[i:])
#print(i,c,d)
print(min(abs(c),abs(d))) | s986677821 | Accepted | 191 | 30,832 | 286 | n = int(input())
L = list(map(int,input().split()))
li = [0]
for i in range(n):
li.append(li[i]+ L[i])
sumL = sum(L)
#print(sumL)
ans = 10**10
for i in range(1,n):
diff = abs(li[i] - (sumL - li[i]))
ans = min(ans,diff)
print(ans) |
s343736793 | p03478 | u941252620 | 2,000 | 262,144 | Wrong Answer | 29 | 3,064 | 495 | 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 i in range(1, N+1):
if i < 10:
if A <= i and i <= B:
sum += i
elif i < 100:
temp = int(i/10) + i%10
print(temp)
if A <= temp and temp <= B:
sum += i
elif i < 1000:
temp = int(i/100) + int(i%100/10) + i%100%10
if A <= temp and ... | s314680949 | Accepted | 30 | 3,064 | 569 | N, A, B = map(int, input().split())
sum = 0
for i in range(1, N+1):
if i < 10:
if A <= i and i <= B:
sum += i
elif i < 100:
temp = int(i/10) + i%10
if A <= temp and temp <= B:
sum += i
elif i < 1000:
temp = int(i/100) + int(i%100/10) + i%100%10
if A <= temp and temp <= B:
... |
s650629319 | p02694 | u589047182 | 2,000 | 1,048,576 | Wrong Answer | 24 | 9,224 | 142 | 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 abo... | import math
X = int(input())
money = 100
year = 0
while money < X:
money = math.floor(money * 1.01)
year += 1
print(money)
print(year)
| s405041988 | Accepted | 23 | 9,152 | 127 | import math
X = int(input())
money = 100
year = 0
while money < X:
money = math.floor(money * 1.01)
year += 1
print(year)
|
s328920601 | p03698 | u620846115 | 2,000 | 262,144 | Wrong Answer | 29 | 9,088 | 126 | You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different. | u = input()
for i in range(len(u)):
for j in range(len(u)-i):
if u[i]==u[j]:
print("no")
exit()
print("yes") | s960095045 | Accepted | 29 | 9,084 | 128 | u = input()
for i in range(len(u)):
for j in range(i+1,len(u)):
if u[i]==u[j]:
print("no")
exit()
print("yes") |
s100256874 | p03469 | u923659712 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 35 | On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date col... | n=input()
print(n[0:2]+"8"+n[4:10]) | s425601798 | Accepted | 17 | 2,940 | 35 | n=input()
print(n[0:3]+"8"+n[4:10]) |
s271698587 | p02645 | u543016260 | 2,000 | 1,048,576 | Wrong Answer | 25 | 8,988 | 25 | When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him. | print(input()[0:2]) | s499005345 | Accepted | 26 | 9,148 | 19 | print(input()[0:3]) |
s978594426 | p02262 | u963402991 | 6,000 | 131,072 | Wrong Answer | 20 | 7,676 | 732 | Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+... | count = 0
def insertionSort(A, n, g):
global count
for i in range(g,n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j -= g
count += 1
A[j+g] = v
def shellSort(A, n):
global count
G = [i for i in range(1,n) if i... | s137713982 | Accepted | 21,010 | 55,356 | 656 | import math
def insertionSort(A, n, g):
cnt = 0
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j + g] = A[j]
j -= g
cnt += 1
A[j + g] = v
return cnt
def shellSort(A, n):
cnt = 0
j = int(math.log(2 * n + 1, ... |
s279758653 | p03151 | u361381049 | 2,000 | 1,048,576 | Wrong Answer | 181 | 19,660 | 577 | A university student, Takahashi, has to take N examinations and pass all of them. Currently, his _readiness_ for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination. Takahashi thinks that he may not be able to pa... | from math import fabs
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
tarinai = []
amari = []
for i in range(n):
if a[i] - b[i] < 0:
tarinai.append(a[i] - b[i])
elif a[i] - b[i] > 0:
amari.append(a[i] - b[i])
tarinai.sort()
amari.sort()
amari.reverse()
a... | s226743380 | Accepted | 152 | 19,660 | 578 | from math import fabs
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
tarinai = []
amari = []
for i in range(n):
if a[i] - b[i] < 0:
tarinai.append(a[i] - b[i])
elif a[i] - b[i] > 0:
amari.append(a[i] - b[i])
tarinai.sort()
amari.sort()
amari.reverse()
a... |
s720227709 | p03435 | u065079240 | 2,000 | 262,144 | Wrong Answer | 19 | 3,064 | 392 | We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) ... | C = [0] * 3
A = [0] * 3
B = [0] * 3
for j in range(3):
C[j] = [int(x) for x in input().split()]
print(C)
B[0], B[1], B[2] = C[0][0], C[0][1], C[0][2]
A[1], A[2] = C[1][0]-B[0], C[2][0]-B[0]
flag = 0
for i in range(3):
for k in range(3):
if C[i][k] != A[i] + B[k]:
flag = 1
break
... | s204503224 | Accepted | 17 | 3,064 | 393 | C = [0] * 3
A = [0] * 3
B = [0] * 3
for j in range(3):
C[j] = [int(x) for x in input().split()]
#print(C)
B[0], B[1], B[2] = C[0][0], C[0][1], C[0][2]
A[1], A[2] = C[1][0]-B[0], C[2][0]-B[0]
flag = 0
for i in range(3):
for k in range(3):
if C[i][k] != A[i] + B[k]:
flag = 1
break... |
s072342434 | p03545 | u245870380 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 867 | 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 in... | import sys
N = list(map(int, input()))
op = ['+','-']
for i in op:
tmp = 0
ans = []
for j in op:
for k in op:
if i == '+':
tmp = N[0] + N[1]
ans.append('+')
else:
tmp = N[0] - N[1]
ans.append('-')
i... | s829415496 | Accepted | 17 | 3,060 | 266 | S = input()
ans = 0
f = ""
for i in range(1 << len(S)-1):
f = S[0]
for j in range(len(S)-1):
if ((i >> j) & 1) == 1:
f += "+"
else:
f += "-"
f += S[j+1]
if eval(f) == 7:
print(f+"=7")
exit() |
s722696804 | p03644 | u021548497 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 118 | Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can... | n = int(input())
key = [2**int(x) for x in range(6, -1)]
for value in key:
if value <= n:
print(value)
break | s844848952 | Accepted | 18 | 2,940 | 122 | n = int(input())
key = [2**int(x) for x in range(6, -1, -1)]
for value in key:
if value <= n:
print(value)
break |
s294441319 | p03564 | u244836567 | 2,000 | 262,144 | Wrong Answer | 28 | 9,152 | 104 | Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the m... | a=int(input())
b=int(input())
c=1
for i in range(a):
if 2*c>=c+b:
c=2*c
else:
c=c+b
print(c) | s386242485 | Accepted | 25 | 9,084 | 104 | a=int(input())
b=int(input())
c=1
for i in range(a):
if 2*c<=c+b:
c=2*c
else:
c=c+b
print(c) |
s768566273 | p03944 | u923659712 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 280 | 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) po... | w,h,n=map(int,input().split())
for i in range(n):
x,y,a=map(int,input().split())
x_b=w
x_s=0
y_b=h
y_s=0
if a==1:
x_b=min(x,x_b)
elif a==2:
x_s=max(x,x_s)
elif a==3:
y_b=min(y,y_b)
else:
y_s=max(y,y_s)
print((x_b-x_s)*(y_b-y_s))
| s652117989 | Accepted | 18 | 3,064 | 305 | w,h,n=map(int,input().split())
x_b=w
x_s=0
y_b=h
y_s=0
for i in range(1,n+1):
x,y,a=map(int,input().split())
if a==2:
x_b=min(x,x_b)
elif a==1:
x_s=max(x,x_s)
elif a==4:
y_b=min(y,y_b)
else:
y_s=max(y,y_s)
if x_b<=x_s or y_b<=y_s:
print(0)
else:
print((x_b-x_s)*(y_b-y_s)) |
s550573077 | p02612 | u252716223 | 2,000 | 1,048,576 | Wrong Answer | 29 | 9,144 | 68 | 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('h'))
num = n % 1000
change = 1000 - num
print(change) | s120679106 | Accepted | 30 | 9,156 | 105 | n = int(input())
num = n % 1000
if num == 0:
print(0)
else:
change = 1000 - num
print(change) |
s097209652 | p03565 | u755180064 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 590 | 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 mo... |
url = "https://atcoder.jp//contests/abc076/tasks/abc076_c"
def main():
S = input()
T = input()
ans = 'UNRESTORABLE'
for i in range(len(S)):
if S[i] == T[0]:
s = S[i:len(T)]
flg = False
for j, ss in enumerate(s):
flg = True if ss == T[j] or ss... | s423105135 | Accepted | 20 | 3,188 | 794 |
url = "https://atcoder.jp//contests/abc076/tasks/abc076_c"
def main():
S = input()
T = input()
ans = 'UNRESTORABLE'
words = []
if S.count('?') == 0:
print(S)
exit()
for i in range(len(S)):
if S[i] != T[0] and S[i] != '?':
continue
s = S[i:i + len(T)... |
s857783417 | p03049 | u027622859 | 2,000 | 1,048,576 | Wrong Answer | 50 | 4,296 | 632 | Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string. | def main():
N = int(input())
s = [input() for _ in range(N)]
a = 0
b = 0
ab = 0
count = 0
for i in range(N):
for j in range(len(s[i])-1):
if s[i][j:j+2] == 'AB':
count += 1
for i in range(N):
if (s[i][0] == 'B' or s[i][-1] == 'A'):
... | s129226664 | Accepted | 44 | 3,700 | 607 | def main():
N = int(input())
s = [input() for _ in range(N)]
a = 0
b = 0
ab = 0
count = 0
for i in range(N):
for j in range(len(s[i])-1):
if s[i][j:j+2] == 'AB':
count += 1
for i in range(N):
if (s[i][0] == 'B' or s[i][-1] == 'A'):
... |
s165089201 | p03470 | u106181248 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 75 | An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you h... | n = int(input())
d = [int(input()) for i in range(n)]
set(d)
print(len(d)) | s710727675 | Accepted | 18 | 2,940 | 72 | n = int(input())
d = [int(input()) for i in range(n)]
print(len(set(d))) |
s471455599 | p03067 | u225202950 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 134 | There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise. | a, b, c = map(int, input().split())
l = [i for i in range(min(a, b), max(a, b) + 1)]
if c in l:
print('YES')
else:
print('NO') | s168996101 | Accepted | 17 | 2,940 | 135 | a, b, c = map(int, input().split())
l = [i for i in range(min(a, b), max(a, b) + 1)]
if c in l:
print('Yes')
else:
print('No')
|
s335705218 | p01143 | u506554532 | 8,000 | 131,072 | Wrong Answer | 40 | 5,620 | 174 | English text is not available in this practice contest. ある貧乏な国のおてんばで勇敢なお姫様は,ある日部屋の壁を壊してお城を抜け出し,競馬などのギャンブルが行われている賭博場に入っていった.ところが,ギャンブルなどやったことのないお姫様は,非常に負けが込んでしまった.この状況をおもしろくないと思ったお姫様は,一体どのような仕組みでギャンブルが行われているかを調べてみた.すると,このようなギャンブルではパリミュチュエル方式と呼ばれる方式で配当が決定されていることを突き止めた. パリミュチュエル方式とは,競走を対象としたギャンブルにおいて配当を決定するために使用する計算方法であ... | while True:
N,M,P = map(int,input().split())
if N == 0: break
src = [int(input()) for i in range(N)]
print(0 if src[M-1] == 0 else (P * sum(src) // src[M-1])) | s141502485 | Accepted | 40 | 5,616 | 207 | while True:
N,M,P = map(int,input().split())
if N == 0: break
src = [int(input()) for i in range(N)]
if src[M-1] == 0:
print(0)
else:
print((100-P) * sum(src) // src[M-1]) |
s131788476 | p03485 | u538956308 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 81 | 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(a+b)
else:
print(a+b+1) | s906854479 | Accepted | 17 | 2,940 | 91 | a,b = map(int,input().split())
if (a+b)%2 == 0:
print((a+b)//2)
else:
print((a+b+1)//2) |
s177382292 | p03855 | u844789719 | 2,000 | 262,144 | Wrong Answer | 2,107 | 42,016 | 1,099 | There are N cities. There are also K roads and L railways, extending between the cities. The i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities. No two roads connect the same pair of cities. Similarly, no two railways connect the s... | NKL = [int(_) for _ in input().split()]
pq = [[int(_) - 1 for _ in input().split()] for _ in range(NKL[1])]
rs = [[int(_) - 1 for _ in input().split()] for _ in range(NKL[2])]
road = [0] * NKL[0]
road_num = 0
train = [0] * NKL[0]
train_num = 0
for y in pq:
if road[y[0]] == 0 and road[y[1]] == 0:
road_num +... | s358656842 | Accepted | 1,358 | 55,052 | 767 | N, K, L = [int(_) for _ in input().split()]
def find(a, x):
stack = []
while a[x] != x:
stack += [x]
x = a[x]
while stack:
a[stack.pop()] = x
return x
def unite(a, x, y):
x = find(a, x)
y = find(a, y)
if x != y:
a[x] = min(x, y)
a[y] = a[x]
a_roa... |
s928286562 | p04043 | u428855582 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 144 | Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each ... | phrase_length=sorted([len(x) for x in input().split()])
print("Yes" if phrase_length[0]==phrase_length[1]==5 and phrase_length[2]==7 else "No")
| s346151304 | Accepted | 17 | 2,940 | 92 | length=sorted([int(x) for x in input().split()])
print ("YES" if length ==[5,5,7] else "NO") |
s070124829 | p02417 | u585035894 | 1,000 | 131,072 | Wrong Answer | 20 | 5,564 | 186 | Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters. | d = { chr(i): 0 for i in range(96, 123) }
s = list(input())
for i in s:
try:
d[i.lower()] += 1
except:
pass
for i,j in d.items():
print('{} : {}'.format(i,j)) | s885074653 | Accepted | 20 | 5,568 | 261 | import sys
d = { chr(i): 0 for i in range(97, 123) }
s = [i for i in sys.stdin]
for i in s:
i = list(i)
for c in i:
try:
d[c.lower()] += 1
except:
continue
for i,j in d.items():
print('{} : {}'.format(i,j))
|
s535188470 | p04031 | u404676457 | 2,000 | 262,144 | Wrong Answer | 21 | 2,940 | 190 | Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (... | n = int(input())
a = list(map(int, input().split()))
a.sort()
minc = 100000000
for i in a:
count = 0
for j in a:
count += (j - i)** 2
minc = min(minc, count)
print(minc) | s162545491 | Accepted | 24 | 3,060 | 211 | n = int(input())
a = list(map(int, input().split()))
a.sort()
minc = 100000000
for i in range(a[0], a[-1] + 1):
count = 0
for j in a:
count += (i - j)** 2
minc = min(minc, count)
print(minc) |
s641366132 | p03760 | u096294926 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 177 | Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the... | O = list(input())
E = list(input())
ans = list()
for i in range(len(O)):
ans.append(O[i])
if len(E) >= i:
ans.append(O[i])
result = "".join(ans)
print(result) | s455981526 | Accepted | 18 | 3,060 | 176 | O = list(input())
E = list(input())
ans = list()
for i in range(len(O)):
ans.append(O[i])
if len(E) > i:
ans.append(E[i])
result = "".join(ans)
print(result) |
s509848668 | p03893 | u102461423 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 28 | We have a cord whose length is a positive integer. We will perform the following condition until the length of the cord becomes at most 2: * Operation: Cut the rope at two positions to obtain three cords, each with a length of a positive integer. Among these, discard one with the longest length and one with the shor... | print((4<<int(input())+2)-2) | s668157397 | Accepted | 18 | 3,064 | 28 | print(2**(int(input())+2)-2) |
s587205344 | p03110 | u518064858 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 161 | Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000`... | n=int(input())
s=0
for i in range(n):
x,u=input().split()
if u=="JPY":
s+=int(x)
else:
b=380000.0*float(x)
s+=int(b)
print(s) | s618368862 | Accepted | 17 | 2,940 | 163 | n=int(input())
s=0
for i in range(n):
x,u=input().split()
if u=="JPY":
s+=int(x)
else:
b=float(380000.0)*float(x)
s+=b
print(s) |
s790008621 | p04031 | u050708958 | 2,000 | 262,144 | Wrong Answer | 206 | 3,064 | 386 | Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (... | input()
a = list(map(int, input().split()))
for i in range(min(a),max(a)+1):
cost_min = 0 if i == min(a) else cost_min
cost = 0
for e in a:
add_cost = abs((e - i)) ** 2
cost_min += add_cost if i == min(a) else 0
cost += add_cost if i != min(a) else 0
print(cost)
if not i == m... | s644086786 | Accepted | 214 | 3,064 | 370 | input()
a = list(map(int, input().split()))
for i in range(min(a),max(a)+1):
cost_min = 0 if i == min(a) else cost_min
cost = 0
for e in a:
add_cost = abs((e - i)) ** 2
cost_min += add_cost if i == min(a) else 0
cost += add_cost if i != min(a) else 0
if not i == min(a) and cost_m... |
s958974528 | p03129 | u699103085 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 97 | Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1. | n,k=map(int,input().split())
n=n/2+0.5
print(n)
if n>=k:
print("YES")
else:
print("NO")
| s790460078 | Accepted | 18 | 2,940 | 89 | n,k = map(int,input().split())
a=n/2+0.5
if a>=k:
print("YES")
else:
print("NO")
|
s778705258 | p00100 | u672822075 | 1,000 | 131,072 | Wrong Answer | 40 | 6,860 | 220 | There is data on sales of your company. Your task is to write a program which identifies good workers. The program should read a list of data where each item includes the employee ID _i_ , the amount of sales _q_ and the corresponding unit price _p_. Then, the program should print IDs of employees whose total sales pr... | while True:
n=int(input())
if n:
f=True
a=[list(map(int,input().split())) for _ in range(n)]
for i in range(n):
if a[i][1]*a[i][2]>=1000000:
print(a[i][0])
f=False
if f:
print("NA")
else:
break | s555453269 | Accepted | 40 | 6,748 | 273 | while True:
n=int(input())
if n==0: break
l=[]
d={}
for _ in range(n):
a,b,c=list(map(int,input().split()))
if a in d:
d[a]+=b*c
else:
d[a]=b*c
l.append(a)
if max(d.values())<1000000:
print("NA")
else:
for k in l:
if d[k]>=1000000:
print(k) |
s484874871 | p02678 | u546338822 | 2,000 | 1,048,576 | Wrong Answer | 2,465 | 150,308 | 971 | 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 th... | def main():
n,m = map(int,input().split())
graph = {}
for i in range(n):
graph[i+1]=[]
for i in range(m):
a,b = map(int,input().split())
graph[a]+=[b]
graph[b]+=[a]
dist = [-1 for i in range(n)]
dist[0]=0
que = [1]
while len(que)>0:
q = que.pop(0)
... | s719737476 | Accepted | 1,314 | 42,440 | 627 | def main():
n,m = map(int,input().split())
graph = {}
for i in range(n):
graph[i+1]=[]
for i in range(m):
a,b = map(int,input().split())
graph[a]+=[b]
graph[b]+=[a]
dist = [-1 for i in range(n)]
ans = [0 for i in range(n)]
dist[0]=0
que = [1]
while len... |
s044571908 | p02694 | u530949867 | 2,000 | 1,048,576 | Wrong Answer | 21 | 9,160 | 121 | 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 abo... | account = start = 100
X = int(input())
i = 0
while account <= X:
account = int(account * 1.01)
i += 1
print(i)
| s170172075 | Accepted | 22 | 9,160 | 120 | account = start = 100
X = int(input())
i = 0
while account < X:
account = int(account * 1.01)
i += 1
print(i)
|
s807390159 | p03455 | u424988546 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 93 | 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 == 1:
print("Even")
else:
print("Odd")
| s997915461 | Accepted | 17 | 2,940 | 92 | a, b = map(int, input().split())
if a * b % 2 == 1:
print("Odd")
else:
print("Even") |
s188402900 | p03433 | u156302018 | 2,000 | 262,144 | Wrong Answer | 30 | 9,076 | 108 | E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins. | N = int(input())
A = int(input())
nokori = N % 500
if nokori <= A:
print("YES")
else:
print("NO")
| s543014981 | Accepted | 25 | 9,020 | 108 | N = int(input())
A = int(input())
nokori = N % 500
if nokori <= A:
print("Yes")
else:
print("No")
|
s770857999 | p03836 | u282657760 | 2,000 | 262,144 | Wrong Answer | 19 | 3,060 | 207 | Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement ... | a,b,c,d = map(int, input().split())
x = c-a
y = d-b
y1=''
y2=''
for i in range(y):
y1+='U'
y2+='D'
x1=''
x2=''
for i in range(x):
x1+='R'
x2+='L'
print(y1+x1+y2+x2+'L'+y1+'UR'+x1+'DR'+y2+'DL'+y1+'U') | s085316473 | Accepted | 19 | 3,060 | 207 | a,b,c,d = map(int, input().split())
x = c-a
y = d-b
y1=''
y2=''
for i in range(y):
y1+='U'
y2+='D'
x1=''
x2=''
for i in range(x):
x1+='R'
x2+='L'
print(y1+x1+y2+x2+'L'+y1+'UR'+x1+'DR'+y2+'DL'+x2+'U') |
s778193444 | p02659 | u539659844 | 2,000 | 1,048,576 | Wrong Answer | 23 | 9,028 | 71 | Compute A \times B, truncate its fractional part, and print the result as an integer. | a, b = map(float, input().split())
times = a * b
new_times = int(times) | s129369910 | Accepted | 27 | 10,064 | 101 | from decimal import Decimal
a, b = input().split()
a = int(a)
b = Decimal(b)
print(int(a * b // 1)) |
s168710034 | p03502 | u663710122 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 76 | An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number. | N = input()
print('Yes' if sum(map(int, list(N))) % int(N) == 0 else 'No') | s345703553 | Accepted | 17 | 2,940 | 75 | N = input()
print('Yes' if int(N) % sum(map(int, list(N))) == 0 else 'No') |
s949891427 | p03493 | u326626914 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 24 | Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble. | s = input()
s.count('1') | s769514931 | Accepted | 19 | 2,940 | 31 | s = input()
print(s.count('1')) |
s980293471 | p03693 | u382639013 | 2,000 | 262,144 | Wrong Answer | 22 | 9,084 | 97 | 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 i... | r, g, b = list(map(int,input().split()))
if (r+g+b)%4==0:
print("YES")
else:
print("NO") | s719703562 | Accepted | 23 | 8,964 | 100 | r, g, b = list(map(str,input().split()))
if int(r+g+b)%4==0:
print("YES")
else:
print("NO") |
s681791212 | p04011 | u761565491 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 122 | There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee. | N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N < K:
print(N*X)
else:
print(N*X+(K-N)*Y) | s863807794 | Accepted | 17 | 2,940 | 125 | N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N <= K:
print(N*X)
else:
print(K*X+(N-K)*Y)
|
s166078082 | p04043 | u658181634 | 2,000 | 262,144 | Wrong Answer | 27 | 9,016 | 137 | Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each ... | arr = list(map(lambda x: int(x), input().split(" ")))
if arr.count(5) == 2 and arr.count(7) == 1:
print("OK")
else:
print("NG")
| s459024783 | Accepted | 28 | 9,084 | 138 | arr = list(map(lambda x: int(x), input().split(" ")))
if arr.count(5) == 2 and arr.count(7) == 1:
print("YES")
else:
print("NO")
|
s515434473 | p03502 | u852790844 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 167 | An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number. | def sum_digits(n):
s = 0
while n:
s += n%10
n //= 10
return s
n = int(input())
ans = "Yes" if sum_digits(n) % n == 0 else "No"
print(ans) | s098961348 | Accepted | 17 | 2,940 | 167 | def sum_digits(n):
s = 0
while n:
s += n%10
n //= 10
return s
n = int(input())
ans = "Yes" if n % sum_digits(n) == 0 else "No"
print(ans) |
s421809147 | p03470 | u270681687 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 167 | An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you h... | n = int(input())
d = []
for i in range(n):
d.append(int(input()))
d.sort()
count = 0
for i in range(n-1):
if d[i] < d[i+1]:
count += 1
print(count) | s359489674 | Accepted | 21 | 3,316 | 115 | from collections import Counter
n = int(input())
d = [int(input()) for i in range(n)]
c = Counter(d)
print(len(c))
|
s898168425 | p03487 | u855186748 | 2,000 | 262,144 | Time Limit Exceeded | 2,132 | 533,028 | 346 | 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 ... | n = int(input())
a = list(map(int,input().split()))
ans = 0
table = [0 for i in range(1000000001)]
for i in range(n):
table[a[i]]+=1
for i in range(n):
if table[a[i]] != 0 and table[a[i]] != a[i]:
if table[a[i]] > a[i]:
ans+=(table[a[i]]-a[i])
else:
ans+=table[a[i]]
t... | s544464957 | Accepted | 129 | 18,668 | 255 | import collections
n = int(input())
a = list(map(int,input().split()))
count = collections.Counter()
for i in a:
count[i] += 1
ans = 0
for num,c in count.items():
if num < c:
ans += c - num
elif num > c:
ans += c
print(ans)
|
s922523593 | p03387 | u411923565 | 2,000 | 262,144 | Wrong Answer | 29 | 9,132 | 311 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be ... |
ABC = list(map(int,input().split()))
ABC = sorted(ABC,reverse = True)
A = ABC[0]#max
B = ABC[1]
C = ABC[2]#min
print(ABC)
count = 0
while A != B:
C += 1
B += 1
count += 1
while (B - C)%2 == 1:
A += 1
B += 1
count += 1
while A!=C:
C += 2
count += 1
print(count) | s338129460 | Accepted | 27 | 9,052 | 300 |
ABC = list(map(int,input().split()))
ABC = sorted(ABC,reverse = True)
A = ABC[0]#max
B = ABC[1]
C = ABC[2]#min
count = 0
while A != B:
C += 1
B += 1
count += 1
while (B - C)%2 == 1:
A += 1
B += 1
count += 1
while A!=C:
C += 2
count += 1
print(count) |
s844714147 | p03549 | u882359130 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 170 | Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of th... | N, M = [int(nm) for nm in input().split()]
P = 0
for i in range(1, 1000):
P += (100*(N-M) + 1900*M)*i * ((1 - (1/2)**M)**(i-1)) * ((1/2)**M)
X = int(P) + 1
print(X) | s287753266 | Accepted | 17 | 2,940 | 95 | N, M = [int(nm) for nm in input().split()]
X = (100*(N-M) + 1900*M) // ((1/2)**M)
print(int(X)) |
s218790575 | p03170 | u207747871 | 2,000 | 1,048,576 | Wrong Answer | 114 | 3,828 | 259 | There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other. Initially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro: * Choose an element x in A, and remove... | N,K = map(int,input().split())
A = list(map(int,input().split()))
dp = [0] * (K+1)
for i in range(0,K+1):
if dp[i] == 0:
for j in A:
if i + j > K:
break
dp[i + j] = 1
print('first' if dp[K] else 'second') | s667050709 | Accepted | 173 | 3,828 | 259 | N,K = map(int,input().split())
A = list(map(int,input().split()))
dp = [0] * (K+1)
for i in range(0,K+1):
if dp[i] == 0:
for j in A:
if i + j > K:
break
dp[i + j] = 1
print('First' if dp[K] else 'Second') |
s354836543 | p03251 | u225053756 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,064 | 262 | Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes incli... | N, M, X, Y = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
s = set(x+y)
mx = max(x)
my = min(y)
if mx <= my and ((mx<= X and X<my) or (mx<= Y and Y<=my)):
print("No War")
else:
print("War") | s050030467 | Accepted | 30 | 9,184 | 266 | N, M,X,Y=[int(i) for i in input().split()]
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
mx = max(x)
my = min(y)
ok = False
for i in range(X+1, Y+1):
if mx<i and i<=my:
ok =True
if ok:
print("No War")
else:
print("War") |
s773768994 | p03759 | u200239931 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 614 | 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. | import math
import sys
def getinputdata():
array_result = []
data = input()
array_result.append(data.split(" "))
flg = 1
try:
while flg:
data = input()
array_temp = []
if(data != ""):
array_result.a... | s344060462 | Accepted | 17 | 3,064 | 614 | import math
import sys
def getinputdata():
array_result = []
data = input()
array_result.append(data.split(" "))
flg = 1
try:
while flg:
data = input()
array_temp = []
if(data != ""):
array_result.a... |
s331184216 | p03351 | u864900001 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 182 | Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either ... | a, b, c, d = map(int, input().split())
if -d < c-a and c - a < d:
print("Yes")
elif -d < b - a and b - a < d and -d < c - b and c - b < d:
print("Yes")
else:
print("No") | s310873235 | Accepted | 17 | 3,060 | 188 | a, b, c, d = map(int, input().split())
if -d <= c-a and c - a <= d:
print("Yes")
elif -d <= b - a and b - a <= d and -d <= c - b and c - b <= d:
print("Yes")
else:
print("No") |
s772365136 | p03401 | u751758346 | 2,000 | 262,144 | Wrong Answer | 2,104 | 14,292 | 286 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from... | import itertools as it
N = int(input())
A = [0] + list(map(int, input().split()))
A = A + [0]
L = [0]
for i in range(N):
L = L + [L[-1] + abs(A[i+1] - A[i])]
L = L + [L[-1] + abs(A[-2] - A[0])]
print(L)
for i in range(N):
print(L[i] + (L[-1] - L[i+2]) + abs(A[i] - A[i+2]))
| s781723883 | Accepted | 221 | 14,168 | 253 | import itertools as it
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
L = 0
for i in range(N+1):
L += abs(A[i+1] - A[i])
for i in range(1,N+1):
print(L - (abs(A[i] - A[i-1]) + abs(A[i+1] - A[i])) + abs(A[i+1] - A[i-1]))
|
s653318807 | p00710 | u500292616 | 1,000 | 131,072 | Wrong Answer | 80 | 5,620 | 375 | There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. There is a deck of _n_ cards. Starting from the _p_ -th card from the top of the deck, _c_ cards are pulled out and put on the top of the ... | n=1
r=1
while n !=0 and r!=0:
n,r=input().split()
n,r=int(n),int(r)
card= [[int(i) for i in input().split()] for i in range(r)]
yama= list(range(n,0,-1))
for i in range(r):
p=card[i][0]
c=card[i][1]
x=yama[:p-1]
y=yama[p-1:p-1+c]
z=yama[p-1+c:]
... | s715691649 | Accepted | 60 | 5,620 | 421 | n=1
r=1
while n !=0 and r!=0:
n,r=input().split()
n,r=int(n),int(r)
card= [[int(i) for i in input().split()] for i in range(r)]
yama= list(range(n,0,-1))
if n ==0 and r==0:
break
for i in range(r):
p=card[i][0]
c=card[i][1]
x=yama[:p-1]
y=yama[p-1:p... |
s141535725 | p03359 | u401949008 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 70 | 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 ... | a,b=map(int,input().split())
if b>a:
print(a)
else:
print(a-1) | s598703859 | Accepted | 17 | 2,940 | 71 | a,b=map(int,input().split())
if b>=a:
print(a)
else:
print(a-1) |
s222187239 | p03455 | u193432970 | 2,000 | 262,144 | Wrong Answer | 23 | 9,156 | 81 | 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==1:
print('Even')
else:
print('Odd') | s962243537 | Accepted | 23 | 9,052 | 81 | a,b=map(int,input().split())
if (a*b)%2==1:
print('Odd')
else:
print('Even') |
s243015872 | p04029 | u811156202 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 193 | 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? | l_s = [a for a in input()]
l_str = ''
for a in l_s:
if a == '0':
l_str += ('0')
elif a == '1':
l_str += ('1')
elif a == 'B':
l_str = l_str[:-1]
print(l_str) | s706930061 | Accepted | 18 | 2,940 | 73 | answer = 0
for a in range(int(input())):
answer += a+1
print(answer) |
s524699072 | p02608 | u608579392 | 2,000 | 1,048,576 | Wrong Answer | 217 | 26,876 | 927 | 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 numpy as np
import math
def func(x, y, z):
return x ** 2 + y ** 2 + z ** 2 + x*y + y*z + z*x
def count_xyz(n):
counts = np.zeros(n + 1, dtype=int)
for x in range(1, math.ceil(math.sqrt(n)) + 1):
if func(x, x, x) > n:
break
for y in range(x, math.ceil(math.sqrt(n)) + ... | s657214695 | Accepted | 208 | 27,412 | 931 | import numpy as np
import math
def func(x, y, z):
return x ** 2 + y ** 2 + z ** 2 + x*y + y*z + z*x
def count_xyz(n):
counts = np.zeros(n + 1, dtype=int)
for x in range(1, math.ceil(math.sqrt(n)) + 1):
if func(x, x, x) > n:
break
for y in range(x, math.ceil(math.sqrt(n)) + ... |
s848120022 | p03023 | u157855911 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 28 | Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees, but do not print units. | n = int(input())
print(n-2) | s063951865 | Accepted | 17 | 2,940 | 35 | n = int(input())
print((n-2) * 180) |
s176889991 | p03659 | u599547273 | 2,000 | 262,144 | Wrong Answer | 2,104 | 25,056 | 186 | Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it. They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card. Let th... | n = int(input())
a = tuple(map(int, input().split(" ")))
min_num = 1000000000000
for i in range(1, n):
abs_num = abs(sum(a[:i]) - sum(a[:i]))
if abs_num < min_num:
min_num = abs_num | s335448887 | Accepted | 146 | 24,952 | 206 | n = int(input())
a = tuple(map(int, input().split(" ")))
x, y = 0, sum(a)
min_num = 10000000000000
for a_i in a[:-1]:
x += a_i
y -= a_i
tmp = abs(x-y)
if tmp < min_num:
min_num = tmp
print(min_num)
|
s833697660 | p03434 | u488884575 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 106 | We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the c... | N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = sum(A[::2]) - sum(A[1::2])
print(ans)
| s596615799 | Accepted | 19 | 2,940 | 118 | N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = sum(A[::2]) - sum(A[1::2])
print(ans)
|
s151768763 | p03997 | u468431843 | 2,000 | 262,144 | Wrong Answer | 26 | 9,160 | 76 | You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid. | a = int(input())
b = int(input())
h = int(input())
print(((a + b) * h) / 2) | s770764063 | Accepted | 29 | 9,072 | 81 | a = int(input())
b = int(input())
h = int(input())
print(int(((a + b) * h) / 2)) |
s867557998 | p03919 | u482969053 | 2,000 | 262,144 | Wrong Answer | 19 | 3,316 | 246 | There is a grid with H rows and W columns. The square at the i-th row and j-th column contains a string S_{i,j} of length 5. The rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from `A` through the W-th letter of the alphabet. Exactly one of the sq... | ALPHA_BET = "ABCDEFGHIJKLMNOPQESTUVWXYZ"
def solve():
H, W = list(map(int, input().split()))
for i in range(H):
line = input().split()
for j, s in enumerate(line):
if s == "snuke":
print(ALPHA_BET[j] + str(i))
return
solve() | s706918340 | Accepted | 17 | 2,940 | 247 | ALPHA_BET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def solve():
H, W = list(map(int, input().split()))
for i in range(H):
line = input().split()
for j, s in enumerate(line):
if s == "snuke":
print(ALPHA_BET[j] + str(i+1))
return
solve() |
s875136192 | p03992 | u503111914 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 30 | This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the fi... | S = input()
print(S[:3],S[4:]) | s218605067 | Accepted | 17 | 2,940 | 30 | S = input()
print(S[:4],S[4:]) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.