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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s021048448 | p02972 | u716043626 | 2,000 | 1,048,576 | Wrong Answer | 2,104 | 19,836 | 600 | There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices. |
N = int(input())
Bn = list(map(int,input().split(' ')))
output_list = []
for i in reversed(range(N)):
current_sum = 0
target_num = i+1
target_num_idx = 0
print('i',i)
for j in range((N)//(target_num)):
target_num_idx = target_num_idx + target_num
current_sum += Bn[target_num_idx -1]
print('j',j)
if current_sum % 2 != Bn[i]:
if Bn[i] == 1:
Bn[i] = 0
else:
Bn[i] = 1
if Bn[i] == 1:
output_list.append(target_num)
print(len(output_list))
output_list.reverse()
print(' '.join(map(str,output_list))) | s063920438 | Accepted | 778 | 18,468 | 561 | N = int(input())
Bn = list(map(int,input().split(' ')))
output_list = []
for i in reversed(range(N)):
current_sum = 0
target_num = i+1
target_num_idx = 0
for j in range((N)//(target_num)):
target_num_idx = target_num_idx + target_num
current_sum += Bn[target_num_idx -1]
if current_sum % 2 != Bn[i]:
if Bn[i] == 1:
Bn[i] = 0
else:
Bn[i] = 1
if Bn[i] == 1:
output_list.append(target_num)
print(len(output_list))
output_list.reverse()
print(' '.join(map(str,output_list))) |
s800153595 | p02613 | u552143188 | 2,000 | 1,048,576 | Wrong Answer | 148 | 16,276 | 323 | 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 = []
for s in range(N):
S.append(input())
print('AC', end=' ')
print('×', end=' ')
print(S.count('AC'))
print('WA', end=' ')
print('×', end=' ')
print(S.count('WA'))
print('TLE', end=' ')
print('×', end=' ')
print(S.count('TLE'))
print('RE', end=' ')
print('×', end=' ')
print(S.count('RE')) | s534590761 | Accepted | 146 | 16,320 | 320 | N = int(input())
S = []
for s in range(N):
S.append(input())
print('AC', end=' ')
print('x', end=' ')
print(S.count('AC'))
print('WA', end=' ')
print('x', end=' ')
print(S.count('WA'))
print('TLE', end=' ')
print('x', end=' ')
print(S.count('TLE'))
print('RE', end=' ')
print('x', end=' ')
print(S.count('RE'))
|
s603857190 | p03555 | u339025042 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 130 | 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. |
C1 = list(input())
C2 = list(input())
if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:
print("Yes")
else:print("No") | s683862569 | Accepted | 17 | 3,064 | 130 |
C1 = list(input())
C2 = list(input())
if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:
print("YES")
else:print("NO") |
s670520061 | p02742 | u559250296 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 142 | 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 = input().split()
if int(H[0]) % 2 == 1 and int(H[1]) % 2 ==1:
print((int(H[0])*int(H[1])/2)+0.5)
else:
print(int(H[0])*int(H[1])/2) | s354741133 | Accepted | 17 | 3,060 | 276 | H = input().split()
h = int(H[0])
w = int(H[1])
if h ==1 or w ==1:
print(1)
else:
if h % 2 == 0:
print(int(h/2 * w))
else:
if w % 2 == 0:
print(int(h * w/2))
else:
print(int((h +1)/2 * (w + 1)/2 + (h-1)/2 * (w-1)/2)) |
s291296749 | p03699 | u711238850 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 123 | You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade? | n = int(input())
s = []
for i in range(n):
s_i = int(input())
if s_i%10==0:
s_i=0
s.append(s_i)
print(sum(s)) | s162793170 | Accepted | 17 | 3,060 | 225 | n = int(input())
s = []
for i in range(n):
s.append(int(input()))
s = sorted(s)
ans = sum(s)
if ans%10==0:
for s_i in s:
if s_i%10!=0:
ans -= s_i
print(ans)
exit()
print(0)
exit()
print(ans) |
s268139002 | p03657 | u564412408 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 126 | Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. | a = input().split(' ')
b = list(map((int), a))
sum = sum(b)
if sum % 3:
print('Possible')
else:
print('Impossible')
| s291270215 | Accepted | 17 | 2,940 | 177 | a = input().split(' ')
b = list(map((int), a))
sum = sum(b)
A = b[0]
B = b[1]
if sum % 3 == 0 or A % 3 == 0 or B % 3 == 0:
print('Possible')
else:
print('Impossible')
|
s069856184 | p03712 | u934788990 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 264 | You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1. | h,w = map(int,input().split())
if h==1:
a = ["#"*(h*2+1)]
else:
a = ["#"*(h*2)]
for i in range(h):
s = input()
s = "#"+s+"#"
a.append(s)
if h == 1:
a.append("#"*(h*2+1))
else:
a.append("#"*(h*2))
for i in range(len(a)):
print(a[i]) | s386184432 | Accepted | 17 | 3,060 | 175 | h,w = map(int,input().split())
a = ["#"*(w+2)]
for i in range(h):
s = input()
s = "#"+s+"#"
a.append(s)
a.append("#"*(w+2))
for i in range(len(a)):
print(a[i]) |
s120124488 | p02741 | u844789719 | 2,000 | 1,048,576 | Wrong Answer | 2,230 | 611,820 | 235 | Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 | from string import ascii_lowercase
N = int(input())
ans = ['a']
for i in range(1, N):
ans2 = []
for a in ans:
for b in ascii_lowercase[:len(set(a)) + 1]:
ans2 += [a + b]
ans = ans2
print('\n'.join(ans))
| s447345547 | Accepted | 17 | 2,940 | 141 | k = int(input())
print([
1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15,
2, 2, 5, 4, 1, 4, 1, 51
][k - 1])
|
s232871451 | p04029 | u052221988 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 71 | 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())
sum = 0
for i in range(1, n+1) :
sum += n
print(sum) | s609022806 | Accepted | 17 | 2,940 | 46 | print(sum([i+1 for i in range(int(input()))])) |
s719144149 | p02690 | u315759831 | 2,000 | 1,048,576 | Wrong Answer | 23 | 9,100 | 335 | Give a pair of integers (A, B) such that A^5-B^5 = X. It is guaranteed that there exists such a pair for the given integer X. | X = int(input())
ans = [0,0]
for i in range(-10,10):
for j in range(-10,10):
if i**5 - j**5 == X:
ans[0] = i
ans[1] = j
break
if ans == [9,9] and X != 0:
for i in range(-100,100):
for j in range(-100,100):
if i**5 - j**5 == X:
ans[0] = i
ans[1] = j
break
print(ans)
| s080888074 | Accepted | 544 | 9,088 | 202 | X = int(input())
ans = [0,0]
for i in range(-500,500):
for j in range(-500,500):
if i**5 - j**5 == X:
ans[0] = i
ans[1] = j
break
ans = " ".join(map(str,ans))
print(ans)
|
s047492201 | p02854 | u949981986 | 2,000 | 1,048,576 | Wrong Answer | 127 | 26,024 | 484 | Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be possible as is, so he will do the following operations some number of times **before** he does the cut: * Choose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan). * Choose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen. Find the minimum amount of money needed before cutting the bar into two parts with the same length. | import bisect
N = int(input())
A = list(map(int, input().split()))
sammary = 0
A_sammary = []
for i in range(N):
sammary += A[i]
A_sammary.append(sammary)
center = (sum(A) + 1) // 2
A_center_index = bisect.bisect_left(A_sammary, center)
if center == A_sammary[A_center_index]:
print(0)
exit()
else:
left = sum(A[0:A_center_index + 1])
right = sum(A[A_center_index + 1: N])
out = abs(left - right)
print(left)
print(right)
print(out)
"""
3
2 4 3
""" | s211868307 | Accepted | 136 | 26,224 | 313 |
N = int(input())
A = list(map(int, input().split()))
left = A[0]
left_count = 0
right = A[N - 1]
right_count = 0
for i in range(N - 2):
if left <= right:
left_count += 1
left += A[left_count]
else:
right_count += 1
right += A[N - right_count - 1]
print(abs(left- right)) |
s244845638 | p03477 | u305732215 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 141 | A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right. | a, b, c, d = map(int, input().split())
l = a + b
r = c + d
if l < r:
print('Left')
elif l == r:
print('Balanced')
else:
print('Right') | s278872319 | Accepted | 17 | 2,940 | 142 | a, b, c, d = map(int, input().split())
l = a + b
r = c + d
if l > r:
print('Left')
elif l == r:
print('Balanced')
else:
print('Right') |
s202916635 | p03693 | u002459665 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 116 | 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? | n = [int(i) for i in input().split()]
if n[0] * 100 + 10 * n[1] + n[2] % 4 == 0:
print("YES")
else:
print("NO") | s576177835 | Accepted | 18 | 2,940 | 122 | n = [int(i) for i in input().split()]
if (n[0] * 100 + 10 * n[1] + n[2]) % 4 == 0:
print("YES")
else:
print("NO") |
s935307677 | p03693 | u973972117 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 96 | 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 = map(int, input().split())
if g*10 + b % 4 == 0:
print('YES')
else:
print('NO') | s779495852 | Accepted | 17 | 2,940 | 99 | r, g, b = map(int, input().split())
if (g*10 + b) % 4 == 0:
print('YES')
else:
print('NO')
|
s368060595 | p03997 | u468972478 | 2,000 | 262,144 | Wrong Answer | 27 | 9,060 | 71 | 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) | s603294142 | Accepted | 30 | 9,032 | 73 | a = int(input())
b = int(input())
c = int(input())
print( (a+b) * c // 2) |
s581579054 | p03470 | u985376351 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 85 | An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have? | n = int(input())
d = [None]*n
for i in range(n):
d[i] = int(input())
len(set(d)) | s403547530 | Accepted | 18 | 2,940 | 92 | n = int(input())
d = [None]*n
for i in range(n):
d[i] = int(input())
print(len(set(d))) |
s611230433 | p02606 | u467479913 | 2,000 | 1,048,576 | Wrong Answer | 23 | 9,120 | 65 | How many multiples of d are there among the integers between L and R (inclusive)? | l, r, x = map(int, input().split(' '))
ans = r // x - (l-1) // x | s712628822 | Accepted | 23 | 9,144 | 76 | l, r, x = map(int, input().split(' '))
ans = r // x - (l-1) // x
print(ans) |
s092346556 | p02613 | u116484168 | 2,000 | 1,048,576 | Wrong Answer | 144 | 16,288 | 191 | 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)]
print('AC * %d' % (s.count('AC')))
print('WA * %d' % (s.count('WA')))
print('TLE * %d' % (s.count('TLE')))
print('RE * %d' % (s.count('RE')))
| s972146024 | Accepted | 145 | 16,204 | 191 | n = int(input())
s = [input() for i in range(n)]
print('AC x %d' % (s.count('AC')))
print('WA x %d' % (s.count('WA')))
print('TLE x %d' % (s.count('TLE')))
print('RE x %d' % (s.count('RE')))
|
s518263537 | p03574 | u113750443 | 2,000 | 262,144 | Wrong Answer | 23 | 3,572 | 1,452 | You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. | def nyu():
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]
return S,H,W
def check(S,H,W):
for h in range(H):
for w in range(W):
if S[h][w] != "#":
if h !=0 :
if S[h-1][w] == "#":
S[h][w] +=1
if h !=H-1 :
if S[h+1][w] == "#":
S[h][w] +=1
if w !=0 :
if S[h][w-1] == "#":
S[h][w] +=1
if w !=W-1 :
if S[h][w+1] == "#":
S[h][w] +=1
if h !=H-1 and w !=W-1:
if S[h+1][w+1] == "#":
S[h][w] +=1
if h != 0 and w !=W-1:
if S[h-1][w+1] == "#":
S[h][w] +=1
if h !=H-1 and w !=0:
if S[h+1][w-1] == "#":
S[h][w] +=1
if h != 0 and w !=0:
if S[h-1][w-1] == "#":
S[h][w] +=1
for a in S:
print(*a)
def convert(S,H,W):
for h in range(H):
for w in range(W):
if S[h][w]==".":
S[h][w] = 0
return S
S,H,W = nyu()
S =convert(S,H,W)
check(S,H,W)
| s601705184 | Accepted | 23 | 3,572 | 1,457 | def nyu():
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]
return S,H,W
def check(S,H,W):
for h in range(H):
for w in range(W):
if S[h][w] != "#":
if h !=0 :
if S[h-1][w] == "#":
S[h][w] +=1
if h !=H-1 :
if S[h+1][w] == "#":
S[h][w] +=1
if w !=0 :
if S[h][w-1] == "#":
S[h][w] +=1
if w !=W-1 :
if S[h][w+1] == "#":
S[h][w] +=1
if h !=H-1 and w !=W-1:
if S[h+1][w+1] == "#":
S[h][w] +=1
if h != 0 and w !=W-1:
if S[h-1][w+1] == "#":
S[h][w] +=1
if h !=H-1 and w !=0:
if S[h+1][w-1] == "#":
S[h][w] +=1
if h != 0 and w !=0:
if S[h-1][w-1] == "#":
S[h][w] +=1
for a in S:
print(*a,sep='')
def convert(S,H,W):
for h in range(H):
for w in range(W):
if S[h][w]==".":
S[h][w] = 0
return S
S,H,W = nyu()
S =convert(S,H,W)
check(S,H,W)
|
s076895007 | p03779 | u223133214 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 134 | There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X. | import math
X = int(input())
N = (-1 + (1 + 8 * X)**(1 / 2)) / 2
if N / 1 == N // 1:
print(N // 1)
else:
print(math.ceil(N))
| s710483387 | Accepted | 19 | 3,188 | 85 | import math
X = int(input())
N = (-1 + (1 + 8 * X)**(1 / 2)) / 2
print(math.ceil(N)) |
s372731443 | p03609 | u896741788 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 48 | We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds? | k=eval(input().replace(" ","-"));print(min(0,k)) | s501019359 | Accepted | 17 | 2,940 | 48 | k=eval(input().replace(" ","-"));print(max(0,k)) |
s220340369 | p00295 | u744151598 | 1,000 | 131,072 | Time Limit Exceeded | 21,860 | 7,808 | 1,775 | フロッピーキューブをプログラミングで解いてみましょう。フロッピーキューブは図のように表面に色のついた9個の立方体から構成されている立体パズルで、キューブの列を回転させることによって、6つの各面の色をそろえます。 フロッピーキューブに対しては下図のような4種類の操作を行うことができ、一回の操作で、端にある3つの隣接したキューブを180度回転することができます。わかりやすいように、図では、上面に+(赤色)、下面に*(緑色)、右前面に□(黄色)、左前面に●(青色)、右奥面に○(水色)、左奥面に■紫色) の記号が付いている状態を初期状態としています。 フロッピーキューブの初期状態が与えられるので、パズルを解くために必要な最小の操作回数を求めるプログラムを作成してください。 | def op1 (p) :
q = [i for i in p]
q[12] = p[17]
q[17] = p[12]
q[6] = p[21]
q[7] = p[22]
q[8] = p[23]
q[21] = p[6]
q[22] = p[7]
q[23] = p[8]
q[9] = p[11]
q[11] = p[9]
return q
def op2 (p) :
q = [i for i in p]
q[14] = p[15]
q[15] = p[14]
q[0] = p[27]
q[1] = p[28]
q[2] = p[29]
q[27] = p[0]
q[28] = p[1]
q[29] = p[2]
q[18] = p[20]
q[20] = p[18]
return q
def op3 (p) :
q = [i for i in p]
q[9] = p[20]
q[20] = p[9]
q[0] = p[23]
q[3] = p[26]
q[6] = p[29]
q[23] = p[0]
q[26] = p[3]
q[29] = p[6]
q[15] = p[17]
q[17] = p[15]
return q
def op4 (p) :
q = [i for i in p]
q[11] = p[18]
q[18] = p[11]
q[2] = p[21]
q[5] = p[24]
q[8] = p[27]
q[21] = p[2]
q[24] = p[5]
q[27] = p[8]
q[14] = p[12]
q[12] = p[14]
return q
def valid (p) :
for i in range(1, 9) :
if (p[0] != p[i]) :
return False
for i in range(10, 12) :
if (p[9] != p[i]) :
return False
for i in range(13, 15) :
if (p[12] != p[i]) :
return False
for i in range(16, 18) :
if (p[15] != p[i]) :
return False
for i in range(19, 21) :
if (p[18] != p[i]) :
return False
for i in range(22, 30) :
if (p[21] != p[i]) :
return False
return True
def solve (n, p) :
if (n > 8) :
return 100
if (valid(p)) :
return 0
s = [solve(n + 1, op1(p)), solve(n + 1, op2(p)), solve(n + 1, op3(p)), solve(n + 1, op4(p))]
s.sort()
return s[0] + 1
N = int(input())
for i in range(0, N) :
p = [int(term) - 1 for term in input().split()]
print(solve(0, p)) | s881426359 | Accepted | 370 | 7,908 | 2,677 | def op1 (p) :
return (
p[ 0],p[ 1],p[ 2],p[ 3],p[ 4],p[ 5],p[21],p[22],p[23],p[11],p[10],p[ 9],p[17],p[13],p[14],
p[15],p[16],p[12],p[18],p[19],p[20],p[ 6],p[ 7],p[ 8],p[24],p[25],p[26],p[27],p[28],p[29]
)
def op2 (p) :
return (
p[27],p[28],p[29],p[ 3],p[ 4],p[ 5],p[ 6],p[ 7],p[ 8],p[ 9],p[10],p[11],p[12],p[13],p[15],
p[14],p[16],p[17],p[20],p[19],p[18],p[21],p[22],p[23],p[24],p[25],p[26],p[ 0],p[ 1],p [2]
)
def op3 (p) :
return (
p[23],p[ 1],p[ 2],p[26],p[ 4],p[ 5],p[29],p[ 7],p[ 8],p[20],p[10],p[11],p[12],p[13],p[14],
p[17],p[16],p[15],p[18],p[19],p[ 9],p[21],p[22],p[ 0],p[24],p[25],p[ 3],p[27],p[28],p[ 6]
)
def op4 (p) :
return (
p[ 0],p[ 1],p[21],p[ 3],p[ 4],p[24],p[ 6],p[ 7],p[27],p[ 9],p[10],p[18],p[14],p[13],p[12],
p[15],p[16],p[17],p[11],p[19],p[20],p[ 2],p[22],p[23],p[ 5],p[25],p[26],p[ 8],p[28],p[29]
)
def op (p, i) :
if (i == 1) :
return op1(p)
elif (i == 2) :
return op2(p)
elif (i == 3) :
return op3(p)
elif (i == 4) :
return op4(p)
def valid (p) :
for i in range(1, 9) :
if (p[0] != p[i]) :
return False
for i in range(22, 30) :
if (p[21] != p[i]) :
return False
for i in range(10, 12) :
if (p[9] != p[i]) :
return False
for i in range(13, 15) :
if (p[12] != p[i]) :
return False
for i in range(16, 18) :
if (p[15] != p[i]) :
return False
for i in range(19, 21) :
if (p[18] != p[i]) :
return False
q = (p[0], p[9], p[12], p[15], p[18], p[21])
if (q == (0, 1, 3, 5, 4, 2)) :
return True
if (q == (0, 3, 5, 4, 1, 2)) :
return True
if (q == (0, 5, 4, 1, 3, 2)) :
return True
if (q == (0, 4, 1, 3, 5, 2)) :
return True
if (q == (2, 1, 5, 3, 4, 0)) :
return True
if (q == (2, 5, 3, 4, 1, 0)) :
return True
if (q == (2, 3, 4, 1, 5, 0)) :
return True
if (q == (2, 4, 1, 5, 3, 0)) :
return True
return False
def solve (n, p, i) :
global minimum
if (n > 9) :
return
if (n >= minimum) :
return
if (valid(p)) :
minimum = min(minimum, n)
return
for j in range(1, 5) :
if (i != j) :
solve(n + 1, op(p, j), j)
return
minimum = 100
N = int(input())
for kk in range(0, N) :
minimum = 100
p = tuple([int(term) - 1 for term in input().split()])
if (valid(p)) :
print(0)
continue
for i in range(1, 5) :
solve(1, op(p, i), i)
print(minimum) |
s941395026 | p03386 | u513081876 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 209 | Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers. | a, b, k = map(int, input().split())
if b-a <= 2*k:
for num in range(a, b+1):
print(num)
else:
for num in range(a, a+k+1):
print(num)
for num in range(b-k+1,b+1):
print(num) | s338610520 | Accepted | 17 | 3,060 | 167 | A, B, K = map(int, input().split())
ans = set()
for i in range(min(K, B - A + 1)):
ans.add(A + i)
ans.add(B - i)
ans = sorted(ans)
for i in ans:
print(i) |
s610969094 | p02928 | u063052907 | 2,000 | 1,048,576 | Wrong Answer | 645 | 3,188 | 760 | We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}. Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2. Find the inversion number of B, modulo 10^9 + 7. Here the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \leq i < j \leq K \times N - 1) such that B_i > B_j. | def count_inv(lst):
ret = 0
for i in range(len(lst)):
for j in range(i + 1, len(lst)):
if lst[i] > lst[j]:
ret += 1
return ret
def count_smaller_elements(lst):
ret = 0
for i in range(len(lst)):
tmp = 0
for j in range(len(lst)):
if i != j and lst[i] > lst[j]:
tmp += 1
ret += tmp
return ret
def main():
N, K = map(int, input().split())
lst_A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
a = count_inv(lst_A)
print(a)
num1 = a * K % MOD
b = count_smaller_elements(lst_A)
print(b)
num2 = b * (K * (K - 1) // 2) % MOD
ans = (num1 + num2) % MOD
print(ans)
if __name__ == "__main__":
main() | s056169932 | Accepted | 647 | 3,316 | 699 | def count_inv(lst):
ret = 0
for i in range(len(lst)):
for j in range(i + 1, len(lst)):
if lst[i] > lst[j]:
ret += 1
return ret
def count_smaller_elements(lst):
ret = 0
for i in range(len(lst)):
for j in range(len(lst)):
if i != j and lst[i] > lst[j]:
ret += 1
return ret
def main():
N, K = map(int, input().split())
lst_A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
a = count_inv(lst_A)
num1 = a * K % MOD
b = count_smaller_elements(lst_A)
num2 = b * (K * (K - 1) // 2) % MOD
ans = (num1 + num2) % MOD
print(ans)
if __name__ == "__main__":
main() |
s629340057 | p03623 | u058592821 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 115 | Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|. | x, a, b = (int(i) for i in input().split())
da = abs(x-a)
db = abs(x-b)
if da > db:
print('A')
else:
print('B') | s414829006 | Accepted | 17 | 2,940 | 115 | x, a, b = (int(i) for i in input().split())
da = abs(x-a)
db = abs(x-b)
if da < db:
print('A')
else:
print('B') |
s514906302 | p03470 | u485716382 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 1 | An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have? | s759498916 | Accepted | 17 | 2,940 | 114 | def solve():
n = int(input())
lists = [int(input()) for _ in range(n)]
print(len(set(lists)))
solve() |
|
s783979845 | p02606 | u418808418 | 2,000 | 1,048,576 | Wrong Answer | 32 | 9,152 | 73 | How many multiples of d are there among the integers between L and R (inclusive)? | l, r, d = map(int, input().split())
ans = int(r/d)-int(l-1/d)
print(ans) | s377361814 | Accepted | 35 | 9,152 | 75 | l, r, d = map(int, input().split())
ans = int(r/d)-int((l-1)/d)
print(ans) |
s822242304 | p03251 | u608726540 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 163 | Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out. | n,m,x,y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
if max(x)+1<min(y):
print('No War')
else:
print('War')
| s730873754 | Accepted | 17 | 2,940 | 195 | n,m,x,y=map(int,input().split())
X=list(map(int,input().split()))
Y=list(map(int,input().split()))
if max(X)<min(Y) and (x+1<=min(Y) and max(X)+1<=y):
print('No War')
else:
print('War')
|
s977093023 | p02258 | u672822075 | 1,000 | 131,072 | Wrong Answer | 30 | 6,720 | 120 | 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, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ . | p = 0
n = int(input())
a = int(input())
for _ in range(n-1):
b = int(input())
if p<abs(a-b):
p = a-b
a = b
print(p) | s195701133 | Accepted | 880 | 6,724 | 117 | l = 2*10**9
p = -2*10**9
n = int(input())
for _ in range(n):
x = int(input())
p = max(x-l,p)
l = min(x,l)
print(p) |
s684202212 | p03543 | u798129018 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 115 | 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**? | N = input()
a = set()
for i in range(len(N)):
a.add(N[i])
if len(list(a)) >=3:
print("Yes")
else:
print("No") | s596148651 | Accepted | 17 | 2,940 | 118 | N = input()
for i in range(0,2):
if N[i]==N[i+1] and N[i+1]==N[i+2]:
print("Yes")
break
else:
print("No") |
s400219912 | p03377 | u720483676 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 79 | There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals. | a,b,c=map(int,input().split());print("Yes") if a<=c and c-a<=b else print("No") | s296644103 | Accepted | 17 | 2,940 | 64 | a,b,c=map(int,input().split());print("YNEOS"[not(a+b>=c>=a)::2]) |
s879748530 | p01931 | u078042885 | 1,000 | 262,144 | Wrong Answer | 20 | 5,556 | 86 | AORイカちゃんはテストに合格するため勉強しています。 AORイカちゃんは、 $N$ 問、問題を解きました。 その後、解いた問題の丸付けを以下の手順で行います。 1. 解答の正誤を確認する。 2. 解答が正しい場合はマル印、誤っていた場合はバツ印を解答用紙に書き込む。 解答が $2$ 問連続で誤りであるとわかった瞬間、テストに不合格になってしまう恐怖から、AORイカちゃんは失神してしまいます。そして、それ以降丸付けを行うことはできません。 失神は手順 $1$ と $2$ の間で起こります。 AORイカちゃんが解いた問題の数を表す整数 $N$ と、解答の正誤を表した長さ $N$ の文字列 $S$ が与えられます。 文字列は 'o' と 'x' からなり、 'o' は解答が正しく、 'x' は解答が誤りであることを表しています。 $i$ 文字目が $i$ 問目の正誤を表しており、AORイカちゃんは $1$ 問目から順番に丸付けを行います。 AORイカちゃんが正誤を書き込めた問題数を出力してください。 | input();s=input();f=s[0];a=1
for x in s[1:]:
if f==x=='x':break
a+=1
print(a)
| s922436326 | Accepted | 60 | 5,744 | 90 | input();s=input();f=s[0];a=1
for x in s[1:]:
if f==x=='x':break
a+=1;f=x
print(a)
|
s827493799 | p03131 | u419686324 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 308 | Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations. | K, A, B = map(int, input().split())
def f():
a = A - 1
b = K - a
d, m = divmod(b, 2)
print(a,b, d, m)
return A + (B - A) * d + m
def g():
return 1 + K
if (A + 2) < B:
print(f())
else:
print(g())
| s940684220 | Accepted | 17 | 2,940 | 287 | K, A, B = map(int, input().split())
def f():
a = A - 1
b = K - a
d, m = divmod(b, 2)
return A + (B - A) * d + m
def g():
return 1 + K
if (A + 2) < B:
print(f())
else:
print(g())
|
s428147598 | p02744 | u268181283 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 78 | 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. For example, `abcac` and `zyxzx` are isomorphic, while `abcac` and `ppppp` are not. A string s is said to be in **normal form** when the following condition is satisfied: * For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison. For example, `abcac` is in normal form, but `zyxzx` is not since it is isomorphic to `abcac`, which is lexicographically smaller than `zyxzx`. You are given an integer N. Print all strings of length N that are in normal form, in lexicographically ascending order. | K = int(input())
S = 'a'*K
arr = [chr(i) for i in range(97, 97+26)]
print(arr) | s876848734 | Accepted | 134 | 12,968 | 252 | K = int(input())-1
al = [chr(i) for i in range(97, 97+26)]
S_arr = [al[0]]
for i in range(K):
new_S_arr = []
for S in S_arr:
for j in range(len(set(list(S)))+1):
new_S_arr.append(S + al[j])
S_arr = new_S_arr
for S in S_arr:
print(S)
|
s614237528 | p03054 | u001024152 | 2,000 | 1,048,576 | Wrong Answer | 179 | 3,896 | 1,004 | 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. | H,W,N = map(int, input().split())
sr,sc = map(int, input().split())
S = input()
T = input()
left, right = 1, W
if S[-1] == "R":
right -= 1
elif S[-1] == "L":
left += 1
for si,ti in zip(S[::-2],T[::-2]):
# print(si,ti)
# print(left, right)
if ti == "R":
left -= 1
elif ti == "L":
right += 1
left = max(1, left)
right = min(W, right)
if si == "R":
right -= 1
elif si == "L":
left += 1
if left > right:
print("NO")
exit()
if not (left <= sc <= right):
print("NO")
exit()
down, up = 1, H
if S[-1] == "U":
up -= 1
elif S[-1] == "D":
down += 1
for si,ti in zip(S[::-2],T[::-2]):
if ti == "U":
down -= 1
elif ti == "D":
up += 1
down = max(1, down)
up = min(H, up)
if si == "U":
up -= 1
elif si == "D":
down += 1
if down > up:
print("NO")
exit()
if not (down <= sr <= up):
print("NO")
exit()
print("YES")
| s268562398 | Accepted | 420 | 3,896 | 1,038 | H,W,N = map(int, input().split())
sr,sc = map(int, input().split())
S = input()
T = input()
left, right = 0, W+1
if S[-1] == "R":
right -= 1
elif S[-1] == "L":
left += 1
for i in reversed(range(N-1)):
si, ti = S[i], T[i]
if ti == "R":
left -= 1
elif ti == "L":
right += 1
left = max(0, left)
right = min(W+1, right)
if si == "R":
right -= 1
elif si == "L":
left += 1
if right - left == 1:
print("NO")
exit()
if sc <= left or right <= sc:
print("NO")
exit()
left, right = 0, H+1
if S[-1] == "U":
left += 1
elif S[-1] == "D":
right -= 1
for i in reversed(range(N-1)):
si, ti = S[i], T[i]
if ti == "D":
left -= 1
elif ti == "U":
right += 1
left = max(0, left)
right = min(H+1, right)
if si == "D":
right -= 1
elif si == "U":
left += 1
if right - left == 1:
print("NO")
exit()
if sr <= left or right <= sr:
print("NO")
exit()
print("YES")
|
s801214498 | p03469 | u192541825 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 39 | On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it. | t=list(input())
t[3]="8"
print(str(t))
| s021265829 | Accepted | 17 | 2,940 | 51 | t=list(input())
t[3]="8"
str="".join(t)
print(str)
|
s940877571 | p00212 | u319725914 | 1,000 | 131,072 | Wrong Answer | 240 | 5,896 | 853 | A 君は高校の休みを利用して、高速バス(以下、「バス」 )で一人旅をする計画を立てています。まず、A 君は一番行ってみたい町を選んでそこを目的地にしました。次に出発地から目的地までバスを乗り継いでいくルートを決めなければなりません。乗り継ぎをするときは、バスを降りてから別のバスに乗り換えるので、それぞれのバスの乗車券が必要になります。 A 君は親戚のおじさんからバスの割引券を何枚かもらいました。 この券を 1 枚使うと乗車券 1 枚を半額で購入できます。例えば、図 1 の出発地5から目的地1へ行く場合には、5→4→6→2→1と5→3→1の二つの経路が考えられます。割引券が 2 枚あるとすると、交通費を最も安くするには5→4→6→2→1の経路をたどった場合、4→6と6→2の路線に割引を利用し、合計料金は 4600円となります。一方、5→3→1の経路をたどった場合、5→3と3→1の路線に割引を利用し、合計料金は 3750 円となります。 A 君は観光にお金を回したいので、交通費はできるだけ少なくしようと考えています。そこで A 君は、出発地から目的地までの最も安い交通費を求めるプログラムを作成することにしました。 図1 割引券の枚数、バスがつなぐ町の数、バスの路線数、各バスの路線情報を入力とし、出発地から目的地までの最も安い交通費を出力するプログラムを作成してください。各バスは双方向に同一料金で運行しています。また、町の数を n とすると、町にはそれぞれ異なる 1 から n までの番号が振られています。出発地から目的地までの経路は必ず存在するものとします。 | from sys import stdin
from heapq import heappush,heappop
while(True):
c,n,m,s,d = map(int, stdin.readline().split())
if not c: break
ma = [[] for _ in range(n)]
s -= 1
d -= 1
for _ in range(m):
a,b,f = map(int, stdin.readline().split())
a -= 1
b -= 1
ma[a].append([f,b])
ma[b].append([f,a])
cost = [[10**10]*(c+1) for _ in range(n)]
cost[s][c] = 0
que = [[ cost[s][c], s, c ]]
while que:
co, pl, ti = heappop(que)
for fee, town in ma[pl]:
if cost[town][ti] > co + fee:
cost[town][ti] = co+fee
heappush(que,[cost[town][ti],town,ti])
if ti and cost[town][ti-1] > co+fee:
cost[town][ti-1] = co + fee//2
heappush(que,[cost[town][ti-1],town,ti-1])
print(min(ma[d])[0])
| s002718998 | Accepted | 260 | 5,892 | 851 | from sys import stdin
from heapq import heappush,heappop
while(True):
c,n,m,s,d = map(int, stdin.readline().split())
if not c: break
ma = [[] for _ in range(n)]
s -= 1
d -= 1
for _ in range(m):
a,b,f = map(int, stdin.readline().split())
a -= 1
b -= 1
ma[a].append([f,b])
ma[b].append([f,a])
cost = [[10**10]*(c+1) for _ in range(n)]
cost[s][c] = 0
que = [[ cost[s][c], s, c ]]
while que:
co, pl, ti = heappop(que)
for fee, town in ma[pl]:
if cost[town][ti] > co+fee:
cost[town][ti] = co+fee
heappush(que,[cost[town][ti],town,ti])
if ti and cost[town][ti-1] > co+fee//2:
cost[town][ti-1] = co+fee//2
heappush(que,[cost[town][ti-1],town,ti-1])
print(min(cost[d]))
|
s840525555 | p03719 | u458608788 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 70 | You are given three integers A, B and C. Determine whether C is not less than A and not greater than B. | a,b,c=map(int,input().split())
print("Yes" if a<=b and b<=c else "No") | s207067568 | Accepted | 18 | 2,940 | 71 | a,b,c=map(int,input().split())
print("Yes" if a<=c and c<=b else "No")
|
s355572154 | p03854 | u201928947 | 2,000 | 262,144 | Wrong Answer | 20 | 3,188 | 147 | 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.replace("eraser","")
s.replace("erase","")
s.replace("dreamer","")
s.replace("dream","")
if s:
print("NO")
else:
print("YES") | s555731314 | Accepted | 19 | 3,188 | 145 | s = input()
s = s.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
if s:
print("NO")
else:
print("YES") |
s954802515 | p03556 | u187205913 | 2,000 | 262,144 | Wrong Answer | 28 | 2,940 | 91 | Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer. | n = int(input())
i=1
res = 0
while i*i<=n:
if i*i==n:
res=i*i
i+=1
print(i) | s071271165 | Accepted | 26 | 2,940 | 76 | n = int(input())
i=1
res = 0
while i*i<=n:
res = i*i
i+=1
print(res) |
s797880356 | p02612 | u539367121 | 2,000 | 1,048,576 | Wrong Answer | 29 | 8,940 | 26 | 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. | print(int(input()) % 1000) | s814701774 | Accepted | 30 | 9,076 | 49 | a=int(input()) % 1000
print(1000-a if a>0 else 0) |
s964754741 | p03605 | u268516119 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 34 | 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('nyoe s'['9' in input()::2]) | s890991134 | Accepted | 17 | 2,940 | 34 | print('NYoe s'['9' in input()::2]) |
s991443017 | p03679 | u735588483 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 132 | 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=(int(i) for i in input().split())
c=int(B-A)
if A<B:
print('delicious')
elif c<X:
print('safe')
else:
print('dangerous') | s396141422 | Accepted | 17 | 2,940 | 140 | X,A,B=(int(i) for i in input().split())
c=int(B-A)
if c<=0:
print('delicious')
elif 0<c<=X:
print('safe')
elif c>X:
print('dangerous') |
s474036966 | p03455 | u736154449 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 121 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | import math
b,c=map(str,input().split())
d=math.sqrt(int(b+c))
if float.is_integer(d):
print("Yes")
else:
print("No") | s994285617 | Accepted | 17 | 2,940 | 79 | b,c=map(int,input().split())
if b*c%2==1:
print("Odd")
else:
print("Even")
|
s139870437 | p02406 | u580737984 | 1,000 | 131,072 | Wrong Answer | 20 | 7,584 | 96 | In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; } | i = int(input())
j = 0
while j <= i:
if j%3 == 0:
print(' ',end='')
print(j)
j += 1 | s296958383 | Accepted | 30 | 6,168 | 125 | n = int(input())
i = 1
while i <= n:
if i % 3 == 0 or "3" in str(i):
print(" ",end='')
print(i,end='')
i += 1
print()
|
s000266841 | p03415 | u580093517 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 39 | We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right. | print(input()[0]+input()[1]+input()[1]) | s708997877 | Accepted | 17 | 2,940 | 39 | print(input()[0]+input()[1]+input()[2]) |
s261368280 | p03854 | u669812251 | 2,000 | 262,144 | Wrong Answer | 19 | 3,188 | 213 | 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`. | # -*- coding: utf-8 -*-
S = input()
S = S.replace("dreamer", "")
S = S.replace("dream", "")
S = S.replace("eraser", "")
S = S.replace("erase", "").strip()
if len(S) ==0:
print("NO")
else:
print("YES")
| s345289520 | Accepted | 71 | 3,956 | 486 | # -*- coding: utf-8 -*-
S = ''.join(list(reversed(input())))
candidate = ["remaerd", "resare", "esare", "maerd"]
while True:
flag = 0
if S[:7] == "remaerd":
S = S[7:]
flag = 1
#print(S)
if S[:6] == "resare":
S = S[6:]
flag = 1
#print(S)
if S[:5] == "esare" or S[:5] == "maerd":
S = S[5:]
flag = 1
#print(S)
if flag == 0:
break
if len(S) == 0:
print("YES")
else:
print("NO")
|
s064578423 | p03502 | u643081547 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 82 | 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. | num=input()
s=0
for it in num:
s+=int(it)
print(s)
num=int(num)
print(num%s)
| s130503007 | Accepted | 17 | 2,940 | 95 | num=input()
s=0
for it in num:
s+=int(it)
num=int(num)
print("Yes" if num%s==0 else "No")
|
s219014943 | p02613 | u131464432 | 2,000 | 1,048,576 | Wrong Answer | 144 | 9,204 | 280 | Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. | n = int(input())
ac,wa,tle,re = 0,0,0,0
for i in range (n):
s = input()
if s == "AC":
ac += 1
elif s == "WA":
wa += 1
elif s =="TLE":
tle += 1
else:
re += 1
print("AC × "+str(ac))
print("WA × "+str(wa))
print("TLE × "+str(tle))
print("RE × "+str(re)) | s183467169 | Accepted | 145 | 9,200 | 276 | n = int(input())
ac,wa,tle,re = 0,0,0,0
for i in range (n):
s = input()
if s == "AC":
ac += 1
elif s == "WA":
wa += 1
elif s =="TLE":
tle += 1
else:
re += 1
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re)) |
s204929500 | p02612 | u723590269 | 2,000 | 1,048,576 | Wrong Answer | 29 | 8,980 | 31 | We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. | n = int(input())
print(n%1000) | s387751907 | Accepted | 32 | 9,100 | 74 | n = int(input())
if n%1000 == 0:
print(0)
else:
print(1000-n%1000) |
s023772813 | p03737 | u226912938 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 71 | You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. | a, b, c = map(str, input().split())
ans = a[0] + b[0] + c[0]
print(ans) | s859312897 | Accepted | 17 | 2,940 | 79 | a, b, c = map(str, input().split())
ans = a[0] + b[0] + c[0]
print(ans.upper()) |
s312222472 | p03712 | u273010357 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 199 | You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1. | H,W = map(int, input().split())
a = [list(map(str, input().split())) for _ in range(H)]
print('#'*(len(a[0][0])+2))
for i in range(H):
print(''.join(['#']+a[0]+['#']))
print('#'*(len(a[0][0])+2)) | s199553135 | Accepted | 17 | 3,060 | 140 | H,W = map(int, input().split())
a = [input() for _ in range(H)]
print('#'*(W+2))
for i in range(H):
print('#'+a[i]+'#')
print('#'*(W+2)) |
s018650963 | p03385 | u330176731 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 110 | You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`. | abc = list(input())
if ('a' in abc) and ('b' in abc) and ('c' in abc):
print('YES')
else:
print('NO') | s819388015 | Accepted | 17 | 2,940 | 110 | abc = list(input())
if ('a' in abc) and ('b' in abc) and ('c' in abc):
print('Yes')
else:
print('No') |
s751650731 | p02748 | u169165784 | 2,000 | 1,048,576 | Wrong Answer | 587 | 24,716 | 285 | You are visiting a large electronics store to buy a refrigerator and a microwave. The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen. You have M discount tickets. With the i-th ticket ( 1 \le i \le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time. You are planning to buy one refrigerator and one microwave. Find the minimum amount of money required. | A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
vals = []
for _ in range(M):
i, j, v = map(int, input().split())
print(i, j, v)
vals.append( a[i - 1] + b[j - 1] - v)
vals.append(min(a) + min(b))
print(min(vals)) | s341105334 | Accepted | 294 | 24,696 | 266 | A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
vals = []
for _ in range(M):
i, j, v = map(int, input().split())
vals.append( a[i - 1] + b[j - 1] - v)
vals.append(min(a) + min(b))
print(min(vals)) |
s376354265 | p03854 | u676645714 | 2,000 | 262,144 | Wrong Answer | 18 | 3,188 | 200 | 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`. | from sys import stdin, stdout
S = stdin.readline()
S = S.replace("dreamer", "")
S = S.replace("eraser", "")
S = S.replace("dream", "")
S = S.replace("erase", "")
print("YES") if not S else print("NO") | s433622975 | Accepted | 19 | 3,188 | 161 | S = input()
S = S.replace("eraser", "")
S = S.replace("erase", "")
S = S.replace("dreamer", "")
S = S.replace("dream", "")
print("YES") if not S else print("NO") |
s782263531 | p03478 | u627417051 | 2,000 | 262,144 | Wrong Answer | 37 | 3,060 | 164 | 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 = list(map(int, input().split()))
cnt = 0
for i in range(N):
seq = list(map(int, list(str(i))))
x = sum(seq)
if A <= x and x <= B:
cnt += 1
print(cnt) | s590907849 | Accepted | 37 | 3,060 | 168 | N, A, B = list(map(int, input().split()))
cnt = 0
for i in range(N + 1):
seq = list(map(int, list(str(i))))
x = sum(seq)
if A <= x and x <= B:
cnt += i
print(cnt) |
s832866763 | p03494 | u295043075 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 246 | There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform. | N=int(input())
li= list(map(int,input().split()))
ans=1
minNum=li[0]
for i in range(N):
if li[i]%2==1:
ans=0
break
elif li[i] < minNum:
minNum = li[i]
if not ans==0:
n=minNum
ans=0
while n%2==0:
n=n/2
ans= ans+1
print(ans)
| s276196497 | Accepted | 19 | 3,060 | 218 | N=int(input())
li= list(map(int,input().split()))
Ans=30
ans=0
for i in range(N):
if li[i]%2==1:
Ans=0
break
else:
n=li[i]
ans=0
while n%2==0:
n=n/2
ans= ans+1
if Ans>ans:
Ans =ans
print(Ans) |
s762701208 | p02692 | u536781361 | 2,000 | 1,048,576 | Wrong Answer | 163 | 10,436 | 1,274 | There is a game that involves three variables, denoted A, B, and C. As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `AB`, you must add 1 to A or B then subtract 1 from the other; if s_i is `AC`, you must add 1 to A or C then subtract 1 from the other; if s_i is `BC`, you must add 1 to B or C then subtract 1 from the other. After each choice, none of A, B, and C should be negative. Determine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices. | n, a, b, c = map(int, input().split())
if a + b + c == 0:
print('no')
history = []
flag = True
for _ in range(n):
s = input()
if s == 'AB':
if a == 0 and b == 0:
print('no')
flag = False
break
elif a == 0:
history.append('A')
a += 1
b -= 1
elif b == 0:
history.append('B')
a -= 1
b += 1
else:
if a >= b:
history.append('B')
a -= 1
b += 1
else:
history.append('A')
a += 1
b -= 1
elif s == "AC":
if a == 0 and c == 0:
print("no")
flag = False
break
elif c == 0:
history.append('C')
a -= 1
c += 1
else:
if a >= c:
history.append('C')
a -= 1
c += 1
else:
history.append('A')
a += 1
c -= 1
elif s == "BC":
if b == 0 and c == 0:
print("no")
flag = False
break
elif b == 0:
history.append('B')
b += 1
c -= 1
elif c == 0:
history.append('C')
b -= 1
c += 1
else:
if b >= c:
history.append('C')
b -= 1
c += 1
else:
history.append('B')
b += 1
c -= 1
if flag:
print("yes")
print('\n'.join(history)) | s199186297 | Accepted | 208 | 17,388 | 722 | n, a, b, c = map(int, input().split())
v = {
'A': a,
'B': b,
'C': c
}
ss = []
for _ in range(n):
ss.append(input())
history = []
flag = True
for i in range(n):
s = ss[i]
if v[s[0]] == 0 and v[s[1]] == 0:
flag = False
break
elif v[s[0]] > v[s[1]]:
history.append(s[1])
v[s[0]] -= 1
v[s[1]] += 1
elif v[s[0]] < v[s[1]]:
history.append(s[0])
v[s[0]] += 1
v[s[1]] -= 1
elif i == n-1:
history.append(s[0])
v[s[0]] += 1
v[s[1]] -= 1
elif s[0] in ss[i+1]:
history.append(s[0])
v[s[0]] += 1
v[s[1]] -= 1
else:
history.append(s[1])
v[s[0]] -= 1
v[s[1]] += 1
if flag:
print("Yes")
print('\n'.join(history))
else:
print("No") |
s342881935 | p04029 | u761529120 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 70 | 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())
sum = 0
for i in range(1, N+1):
sum += i
print(i) | s697415021 | Accepted | 17 | 2,940 | 72 | N = int(input())
sum = 0
for i in range(1, N+1):
sum += i
print(sum) |
s890395369 | p03478 | u842388336 | 2,000 | 262,144 | Wrong Answer | 52 | 3,452 | 232 | Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive). | n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
str_i = str(i)
sum_i = 0
for j in range(len(str_i)):
sum_i += int(str_i[j])
print(i)
print(sum_i)
if (sum_i >= a) & (sum_i <= b):
ans+=i
print(ans) | s051993350 | Accepted | 37 | 2,940 | 206 | n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
str_i = str(i)
sum_i = 0
for j in range(len(str_i)):
sum_i += int(str_i[j])
if (sum_i >= a) & (sum_i <= b):
ans+=i
print(ans) |
s645623617 | p03815 | u806855121 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 231 | Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7. Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation: * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward. For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back. Find the minimum number of operation Snuke needs to perform in order to score at least x points in total. | s = input()
ans = ''
idx = -1
for i, c in enumerate(s):
if c == 'A' and idx == -1:
idx = i
break
for i, c in enumerate(reversed(s)):
if c == 'Z':
ans = s[idx:len(s)-i]
break
print(len(ans))
| s716993640 | Accepted | 17 | 2,940 | 122 | x = int(input())
ans = x // 11 * 2
if x % 11 > 6:
print(ans+2)
elif x % 11 > 0:
print(ans+1)
else:
print(ans) |
s880516648 | p03854 | u336624604 | 2,000 | 262,144 | Wrong Answer | 88 | 3,188 | 329 | 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]
t = ['dream','dreamer','erase','eraser']
print(s[:4])
print(len(t))
for i in range(len(t)):
t[i]=t[i][::-1]
while s != '':
for j in range(len (t)):
if s[0:len(t[j])]==t[j]:
s = s[len(t[j]):]
break
else:
print('No')
break
else:
print('Yes') | s956385127 | Accepted | 85 | 3,188 | 302 | s =input()
s = s[::-1]
t = ['dream','dreamer','erase','eraser']
for i in range(len(t)):
t[i]=t[i][::-1]
while s != '':
for j in range(len(t)):
if s[0:len(t[j])] == t[j]:
s = s[len(t[j]):]
break
else:
print('NO')
break
else:
print('YES') |
s558807781 | p03160 | u191557685 | 2,000 | 1,048,576 | Wrong Answer | 120 | 20,516 | 188 | There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. | N = int(input())
h = list(map(int, input().split()))
dp= [0] * N
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,N):
dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2])) | s818406345 | Accepted | 126 | 20,616 | 208 | N = int(input())
h = list(map(int, input().split()))
dp= [0] * N
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,N):
dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))
print(dp[N-1]) |
s690261541 | p02396 | u876060624 | 1,000 | 131,072 | Wrong Answer | 80 | 6,164 | 117 | 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. | a=[]
i=0
while 1 :
a.append(int(input()))
i+=1
if a[i-1] == 0:
break
for j in range(i):
print("Case 1: ",a[j])
| s908184652 | Accepted | 80 | 5,900 | 131 | a=[]
i=0
while 1 :
a.append(int(input()))
i+=1
if a[i-1] == 0:
break
for j in range(i-1):
print("Case %d: %d" % (j+1 ,a[j]))
|
s312958310 | p02396 | u930806831 | 1,000 | 131,072 | Wrong Answer | 140 | 7,608 | 117 | In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem. | i = 1
while True:
x = input()
if int(x) == 0:
break
print('case ' + str(i) + ': ' + x)
i += 1 | s685120649 | Accepted | 130 | 7,636 | 117 | i = 1
while True:
x = input()
if int(x) == 0:
break
print('Case ' + str(i) + ': ' + x)
i += 1 |
s898549208 | p03814 | u410269178 | 2,000 | 262,144 | Wrong Answer | 66 | 3,516 | 224 | 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()
aidx = -1
zidx = -1
for i in range(len(s)):
if aidx == -1 and s[i] == 'A':
aidx = i
if zidx == -1 and s[len(s)-1-i] == 'Z':
zidx = len(s)-1-i
if aidx != -1 and zidx != -1:
break
print(zidx-aidx) | s972827327 | Accepted | 68 | 3,512 | 227 | s = input()
aidx = -1
zidx = -1
for i in range(len(s)):
if aidx == -1 and s[i] == 'A':
aidx = i
if zidx == -1 and s[len(s)-1-i] == 'Z':
zidx = len(s)-1-i
if aidx != -1 and zidx != -1:
break
print(zidx-aidx+1)
|
s541585625 | p03379 | u107091170 | 2,000 | 262,144 | Wrong Answer | 333 | 25,220 | 146 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | N=int(input())
X=list(map(int, input().split()))
X.sort()
for i in range(N):
if i < N//2:
print(X[ N//2 ])
else:
print(X[N//2-1])
| s830765525 | Accepted | 372 | 26,016 | 190 | N=int(input())
X=list(map(int, input().split()))
XX = sorted(X)
mid = (XX[N//2-1] + XX[N//2])/2
for i in range(N):
if X[i] < mid:
print(XX[ N//2 ])
else:
print(XX[N//2-1])
|
s054781635 | p00029 | u798803522 | 1,000 | 131,072 | Wrong Answer | 30 | 7,428 | 327 | 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. | targ = input().split(' ')
mostfre = {}
ansfre = ""
longest = [0,""]
for t in targ:
if len(t) > longest[0]:
longest[0],longest[1] = len(t),t
mostfre[t] = mostfre.get(t,0) + 1
temp = 0
print(mostfre)
for k,v in mostfre.items():
if v > temp:
temp = v
ansfre = k
print(ansfre + ' ' + longest[1]) | s846666308 | Accepted | 40 | 7,368 | 312 | targ = input().split(' ')
mostfre = {}
ansfre = ""
longest = [0,""]
for t in targ:
if len(t) > longest[0]:
longest[0],longest[1] = len(t),t
mostfre[t] = mostfre.get(t,0) + 1
temp = 0
for k,v in mostfre.items():
if v > temp:
temp = v
ansfre = k
print(ansfre + ' ' + longest[1]) |
s048871286 | p02936 | u638057737 | 2,000 | 1,048,576 | Wrong Answer | 1,829 | 52,668 | 414 | Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations. | N,Q = map(int,input().split())
graph, parents, values = [],[],[]
for _ in range(N):
graph.append([])
parents.append(-1)
values.append(0)
for i in range(N-1):
a,b = map(int,input().split())
graph[a-1].append(b-1)
parents[b-1] = a-1
for i in range(Q):
p,x = map(int,input().split())
values[p-1] += x
for i in range(N):
if i != 0:
values[i] += values[parents[i]]
print(values[i],end=" ")
| s077465909 | Accepted | 1,834 | 57,700 | 728 | from collections import deque
N,Q = map(int,input().split())
graph, parents, values, visited = [],[],[],[]
for _ in range(N):
graph.append([])
parents.append(-1)
values.append(0)
visited.append(False)
for i in range(N-1):
a,b = map(int,input().split())
graph[a-1].append(b-1)
graph[b-1].append(a-1)
for i in range(Q):
p,x = map(int,input().split())
values[p-1] += x
bfs_queue = deque()
bfs_queue.append(0)
bfs_queue_len = 1
while bfs_queue_len:
cur = bfs_queue.popleft()
bfs_queue_len -= 1
visited[cur] = True
for other in graph[cur]:
if not visited[other]:
parents[other] = cur
values[other] += values[cur]
bfs_queue_len += 1
bfs_queue.append(other)
print(*values)
|
s383225225 | p03485 | u828277092 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 72 | 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. | import math
a, b = map(int, input().split())
print(math.ceil(a + b /2)) | s501439278 | Accepted | 17 | 2,940 | 118 | a, b = map(int, input().split())
if (a + b) % 2 == 0:
print(int((a + b)/2))
else:
print(int((a + b)//2 + 1))
|
s898721650 | p03377 | u405256066 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 142 | 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. | from sys import stdin
A,B,X=[int(x) for x in stdin.readline().rstrip().split()]
if A+B >= X and A <= X:
print("Yes")
else:
print("No") | s925993382 | Accepted | 18 | 2,940 | 142 | from sys import stdin
A,B,X=[int(x) for x in stdin.readline().rstrip().split()]
if A+B >= X and A <= X:
print("YES")
else:
print("NO") |
s262499526 | p02608 | u768896740 | 2,000 | 1,048,576 | Wrong Answer | 1,002 | 11,888 | 288 | 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). | from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(1, 100):
for j in range(1, 100):
for k in range(1, 100):
num = i**2 + j ** 2 + k ** 2 + i * j + j * k + k * i
d[num] += 1
for i in range(n+1):
print(d[i])
| s216918814 | Accepted | 1,726 | 14,400 | 290 | from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(1, 120):
for j in range(1, 120):
for k in range(1, 120):
num = i**2 + j ** 2 + k ** 2 + i * j + j * k + k * i
d[num] += 1
for i in range(1,n+1):
print(d[i])
|
s848328261 | p02397 | u498462680 | 1,000 | 131,072 | Wrong Answer | 60 | 5,620 | 190 | Write a program which reads two integers x and y, and prints them in ascending order. | while True:
a,b = [int(i) for i in input().split()]
if a<b:
print(str(a) + " " + str(b))
else:
print(str(b) + " " + str(a))
if a == 0 and b==0:
break
| s445762671 | Accepted | 60 | 5,620 | 192 | while True:
x,y = [int(i) for i in input().split()]
if x == 0 and y == 0:
break
if x>y:
print(str(y) + " " + str(x))
else:
print(str(x) + " " + str(y))
|
s462550552 | p02261 | u777277984 | 1,000 | 131,072 | Wrong Answer | 20 | 5,604 | 777 | Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance). | def print_list(array):
for i,e in enumerate(array):
if i == N - 1:
print(e)
else:
print(e, end=" ")
def bubbleSort():
for i in range(N-1):
for j in range(N-1, i, -1):
if int(A[j][1:]) < int(A[j-1][1:]):
w = A[j]; A[j] = A[j-1]; A[j-1] = w
def selectionSort():
for i in range(N):
min_index = i
for j in range(i, N):
if int(B[min_index][1:]) > int(B[j][1:]):
min_index = j
if i != min_index:
w = B[i]; B[i] = B[min_index]; B[min_index] = w
N = int(input())
A = input().split()
B = list(A)
bubbleSort()
print_list(A)
print("Stable")
selectionSort()
print_list(B)
if A == B:
print("Stable")
else:
print("Not Stable")
| s825815338 | Accepted | 20 | 5,612 | 777 | def print_list(array):
for i,e in enumerate(array):
if i == N - 1:
print(e)
else:
print(e, end=" ")
def bubbleSort():
for i in range(N-1):
for j in range(N-1, i, -1):
if int(A[j][1:]) < int(A[j-1][1:]):
w = A[j]; A[j] = A[j-1]; A[j-1] = w
def selectionSort():
for i in range(N):
min_index = i
for j in range(i, N):
if int(B[min_index][1:]) > int(B[j][1:]):
min_index = j
if i != min_index:
w = B[i]; B[i] = B[min_index]; B[min_index] = w
N = int(input())
A = input().split()
B = list(A)
bubbleSort()
print_list(A)
print("Stable")
selectionSort()
print_list(B)
if A == B:
print("Stable")
else:
print("Not stable")
|
s069772259 | p04045 | u617829104 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 1,444 | Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier. | N, K = map(int, input().split())
D = list(map(int, input().split()))
UN = [i for i in range(10)]
for i in D:
UN.remove(i)
print(UN)
n = str(N)
N_keta = len(n)
for i in n:
if int(i) not in UN:
break
else:
print(N)
exit()
ex_0 = [i for i in UN if i > 0]
if N_keta == 1:
if N < max(UN):
_11 =[i for i in UN if i > N]
print(min(_11))
else:
print(min(ex_0) * 10 + min(UN))
if N_keta == 2:
if N < max(UN) * 11:
for i in UN:
for j in UN:
_2 = i * 10 + j
if _2 > N:
print(_2)
exit()
else:
print(min(ex_0) * 100 + min(UN) * 11)
if N_keta == 3:
if N < max(UN) * 111:
for i in UN:
for j in UN:
for k in UN:
_3 = i * 100 + j * 10 + k
if _3 > N:
print(_3)
exit()
else:
print(min(ex_0) * 1000 + min(UN) * 111)
if N_keta == 4:
if N < max(UN) * 1111:
_4 = [i for i in UN if i >= int(n[0])]
for i in _4:
for j in UN:
for k in UN:
for l in UN:
_41 = i * 1000 + j * 100 + k * 10 + l
if _41 > N:
print(_41)
exit()
else:
print(min(ex_0) * 10000 + min(UN) * 1111)
| s831167046 | Accepted | 72 | 2,940 | 197 | N, K = map(int, input().split())
D = list(map(int, input().split()))
while True:
for i in str(N):
if int(i) in D:
N += 1
break
else:
break
print(N)
|
s812863797 | p03565 | u166621202 | 2,000 | 262,144 | Wrong Answer | 21 | 3,188 | 348 | 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`. | import re
s = input()
t = input()
s = s.replace("?",".")[::-1]
t = t[::-1]
print(s)
print(t)
print(len(s) - len(t) + 1)
for i in range(len(s) - len(t) + 1):
if re.match(s[i:i+len(t)], t):
print(s[i:i+len(t)])
s = s[:i].replace(".","a") + t + s[i+len(t):].replace(".","a")
print(s[::-1])
break
else:
print("UNRESTORABLE")
| s616184269 | Accepted | 22 | 3,188 | 275 | import re
s = input()
t = input()
s = s.replace("?", ".")[::-1]
t = t[::-1]
for i in range(len(s) - len(t) + 1):
if re.match(s[i:i+len(t)], t):
s = s[:i].replace(".","a") + t + s[i+len(t):].replace(".","a")
print(s[::-1])
break
else:
print("UNRESTORABLE") |
s347338584 | p02613 | u139537085 | 2,000 | 1,048,576 | Wrong Answer | 145 | 8,888 | 256 | 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,b,c,d=0,0,0,0
for i in range(n):
s=input()
if s=='AC':
a=a+1
elif s=='WA':
b=b+1
elif s=='TLE':
c=c+1
else:
d=d+1
print('AC','X',a)
print('WA','X',b)
print('TLE','X',c)
print('RE','X',d)
| s614082921 | Accepted | 147 | 9,176 | 256 | n=int(input())
a,b,c,d=0,0,0,0
for i in range(n):
s=input()
if s=='AC':
a=a+1
elif s=='WA':
b=b+1
elif s=='TLE':
c=c+1
else:
d=d+1
print('AC','x',a)
print('WA','x',b)
print('TLE','x',c)
print('RE','x',d)
|
s917538880 | p03720 | u981767024 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 251 | There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city? | # 2019/05/25
# Input
n, m = map(int, input().split())
rcnt = [0] * (n + 1)
for i in range(m):
a, b = map(int, input().split())
rcnt[a] += 1
rcnt[b] += 1
# Output
for i in range(n+1):
print(rcnt[i])
| s137536815 | Accepted | 18 | 2,940 | 254 | # 2019/05/25
# Input
n, m = map(int, input().split())
rcnt = [0] * (n + 1)
for i in range(m):
a, b = map(int, input().split())
rcnt[a] += 1
rcnt[b] += 1
# Output
for i in range(1, n+1):
print(rcnt[i])
|
s778512145 | p02854 | u588341295 | 2,000 | 1,048,576 | Wrong Answer | 90 | 25,916 | 917 | Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be possible as is, so he will do the following operations some number of times **before** he does the cut: * Choose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan). * Choose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen. Find the minimum amount of money needed before cutting the bar into two parts with the same length. | # -*- coding: utf-8 -*-
import sys
from bisect import bisect_left
from itertools import accumulate
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
N = INT()
A = [0] + LIST()
acc = list(accumulate(A))
mid = sum(A) / 2
l = bisect_left(acc, mid) - 1
r = bisect_left(acc, mid)
l = acc[l]
r = acc[r]
print(min(mid-l, r-mid)*2)
| s205276618 | Accepted | 88 | 25,916 | 922 | # -*- coding: utf-8 -*-
import sys
from bisect import bisect_left
from itertools import accumulate
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
N = INT()
A = [0] + LIST()
acc = list(accumulate(A))
mid = sum(A) / 2
l = bisect_left(acc, mid) - 1
r = bisect_left(acc, mid)
l = acc[l]
r = acc[r]
print(int(min(mid-l, r-mid)*2))
|
s472392869 | p02578 | u047679381 | 2,000 | 1,048,576 | Wrong Answer | 163 | 33,552 | 460 | N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal. | import sys
li = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : sys.stdin.readline().strip().split()
ni = lambda : int(sys.stdin.readline().strip())
nsi = lambda : sys.stdin.readline().strip()
from collections import defaultdict as df
import math
n=ni()
l=list(map(int,input().split()))
mn=l[0]
ans=0
for i in range(1,n):
if(mn<l[i]):
mn=l[i]
print(l[i])
else:
ans+=mn-l[i]
print(ans)
| s232356907 | Accepted | 125 | 33,572 | 440 | import sys
li = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : sys.stdin.readline().strip().split()
ni = lambda : int(sys.stdin.readline().strip())
nsi = lambda : sys.stdin.readline().strip()
from collections import defaultdict as df
import math
n=ni()
l=list(map(int,input().split()))
mn=l[0]
ans=0
for i in range(1,n):
if(mn<l[i]):
mn=l[i]
else:
ans+=mn-l[i]
print(ans)
|
s757434749 | p03611 | u201387466 | 2,000 | 262,144 | Wrong Answer | 169 | 24,732 | 938 | You are given an integer sequence of length N, a_1,a_2,...,a_N. For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices. | import sys
input=sys.stdin.readline
#from collections import defaultdict
#import fractions
#import math
#import collections
#from collections import deque
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
import collections
N = int(input())
A = list(map(int,input().split()))
Min = min(A)
Max = max(A)
d = {i:0 for i in range(Min,Max+1)}
for ii in A:
d[ii] += 1
print(d)
s = [0] * (Max-Min+1)
n = len(s)
s[0] = d[Min]
for k in range(1,n):
s[k] = s[k-1] + d[Min+k]
print(s)
ss = 0
if n <= 3:
ss = s[n-1]
print(ss)
else:
mmax = s[2]
for i in range(3,n):
mmm = s[i] - s[i-3]
mmax = max(mmm,mmax)
print(mmax)
| s133842982 | Accepted | 147 | 21,532 | 920 | import sys
input=sys.stdin.readline
#from collections import defaultdict
#import fractions
#import math
#import collections
#from collections import deque
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
import collections
N = int(input())
A = list(map(int,input().split()))
Min = min(A)
Max = max(A)
d = {i:0 for i in range(Min,Max+1)}
for ii in A:
d[ii] += 1
s = [0] * (Max-Min+1)
n = len(s)
s[0] = d[Min]
for k in range(1,n):
s[k] = s[k-1] + d[Min+k]
ss = 0
if n <= 3:
ss = s[n-1]
print(ss)
else:
mmax = s[2]
for i in range(3,n):
mmm = s[i] - s[i-3]
mmax = max(mmm,mmax)
print(mmax)
|
s388416018 | p03455 | u428487608 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 146 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | # -*- coding: utf-8 -*-
a,b = input().split()
c = int(a+b)
for i in range(102):
if i**2 == c:
print("Yes")
exit()
print("No") | s040131023 | Accepted | 17 | 2,940 | 125 | # -*- coding: utf-8 -*-
a,b = map(int,input().split())
mul = a*b
if(mul % 2 == 0):
print('Even')
else:
print('Odd') |
s702220124 | p02831 | u114920558 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 241 | 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 = input().split()
a = int(A)
b = int(B)
while(a % b != 0 and b % a != 0):
if(a>b):
tmp = a // b
a = a % b
else:
tmp = b // a
b = b % a
if(a % b == 0):
tmp = a // b
else:
tmp = b // a
print(int(A) * int(B) // tmp) | s638219040 | Accepted | 17 | 2,940 | 141 | A, B = input().split()
def gcd(a,b):
while b!=0:
a,b=b,a%b
return a
def lcm(a,b):
return a*b//gcd(a,b)
print(lcm(int(A), int(B))) |
s877134521 | p02613 | u469936642 | 2,000 | 1,048,576 | Wrong Answer | 156 | 9,992 | 291 | 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. | from collections import defaultdict as d
from itertools import combinations as c
from string import ascii_lowercase as a
n = int(input())
dd = d(int)
for i in range(n):
e = input()
dd[e] += 1
print('AC x', dd['AC'])
print('WA x', dd['AC'])
print('TLE x', dd['AC'])
print('RE x', dd['AC']) | s769818336 | Accepted | 152 | 9,988 | 336 | from math import gcd, sqrt, pi, floor, ceil
from collections import defaultdict as d
from itertools import combinations as c
from string import ascii_lowercase as a
n = int(input())
dd = d(int)
for i in range(n):
e = input()
dd[e] += 1
print('AC x', dd['AC'])
print('WA x', dd['WA'])
print('TLE x', dd['TLE'])
print('RE x', dd['RE']) |
s073466147 | p02646 | u722148122 | 2,000 | 1,048,576 | Wrong Answer | 22 | 9,160 | 147 | Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally. | A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
if abs(B-A) <= T*(V-W):
print("Yes")
else:
print("No")
| s902008458 | Accepted | 23 | 9,164 | 147 | A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
if abs(B-A) <= T*(V-W):
print("YES")
else:
print("NO")
|
s653424468 | p03049 | u706414019 | 2,000 | 1,048,576 | Wrong Answer | 37 | 10,004 | 546 | 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. | import sys,math,collections,itertools
input = sys.stdin.readline
N = int(input())
Aend = []
Bstart = []
Ae_Bs = []
cnt = 0
for i in range(N):
S = input().rstrip()
if S[0]=='B' and S[-1] =='A':
Ae_Bs.append(S)
elif S[0] == 'B':
print(S)
Bstart.append(S)
elif S[-1] == 'A':
Aend.append(S)
cnt += S.count('AB')
lAe_Bs = len(Ae_Bs)
lBstart = len(Bstart)
lAend = len(Aend)
if lAe_Bs >0:
cnt += lAe_Bs -1
cnt += min(lBstart,lAend)
cnt += (abs(lBstart-lAend)>0 and lAe_Bs >0)
print(cnt)
| s031468417 | Accepted | 38 | 9,276 | 519 | import sys,math,collections,itertools
input = sys.stdin.readline
N = int(input())
lAend = 0
lBstart = 0
lAe_Bs = 0
cnt = 0
for i in range(N):
S = input().rstrip()
if S[0]=='B' and S[-1] =='A':
lAe_Bs+=1
elif S[0] == 'B':
lBstart+=1
elif S[-1] == 'A':
lAend+=1
cnt += S.count('AB')
if lAe_Bs >0:
cnt += lAe_Bs -1
if lAe_Bs > 0 and lAend >0:
cnt += 1
lAend -=1
if lAe_Bs > 0 and lBstart>0:
cnt +=1
lBstart -=1
cnt += min(lAend,lBstart)
print(cnt)
|
s210623151 | p00007 | u777299405 | 1,000 | 131,072 | Wrong Answer | 20 | 7,544 | 81 | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week. Write a program which computes the amount of the debt in n weeks. | debt = 100
for i in range(int(input())):
debt *= 1.05
print(int(debt) * 1000) | s228009889 | Accepted | 30 | 7,592 | 110 | import math
debt = 100
for i in range(int(input())):
debt = math.ceil(debt * 1.05)
print(int(debt) * 1000) |
s032338542 | p03474 | u498575211 | 2,000 | 262,144 | Wrong Answer | 34 | 9,732 | 119 | 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. | import re
a,b=input().split()
s=input()
match = re.search("\d{a}-\d{b}",s)
if match:
print('Yes')
else:
print('No') | s422879852 | Accepted | 38 | 9,992 | 139 | import re
a,b=input().split()
s=input()
pat ="^\d{"+a+"}-\d{"+b+"}$"
match = re.search(pat,s)
if match:
print('Yes')
else:
print('No')
|
s620990507 | p03556 | u565149926 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 37 | Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer. | print(int(int(input()) ** 0.5 ** 2))
| s945946863 | Accepted | 17 | 2,940 | 37 | print(int(int(input()) ** 0.5) ** 2)
|
s041822034 | p03433 | u881028805 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 131 | E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins. | price = int(input())
num1 = int(input())
amari = price % 500
print(amari)
if amari > num1:
print('Yes')
else:
print('No') | s844371217 | Accepted | 17 | 2,940 | 119 | price = int(input())
num1 = int(input())
amari = price % 500
if amari <= num1:
print('Yes')
else:
print('No') |
s006380341 | p03024 | u676496404 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 156 | Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility. | s = list(input())
win= lose = 0
for i in s:
if i =='o':
win += 1
else:
lose += 1
if win >= 8:
print("YES")
else:
print("NO") | s852978716 | Accepted | 20 | 2,940 | 197 | s = list(input())
win= lose = 0
for i in s:
if i =='o':
win += 1
else:
lose += 1
l = 15 - len(s)
if l < 15:
win += l
if win >= 8:
print("YES")
else:
print("NO")
|
s747121712 | p03472 | u865741247 | 2,000 | 262,144 | Wrong Answer | 297 | 11,020 | 257 | You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times. * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana. The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total? | temp=input()
n=int(temp.split(" ")[0])
h=int(temp.split(" ")[1])
a=[]
b=[]
for i in range(n):
temp=input()
ta=int(temp.split(" ")[0])
tb=int(temp.split(" ")[1])
a.append(ta)
b.append(tb)
p=max(a)
q=sum(b)
ans=int(int(h-q)/p)+n
print(ans) | s709423726 | Accepted | 350 | 12,064 | 546 | temp=input()
n=int(temp.split(" ")[0])
h=int(temp.split(" ")[1])
a=[]
b=[]
for i in range(n):
temp=input()
ta=int(temp.split(" ")[0])
tb=int(temp.split(" ")[1])
a.append(ta)
b.append(tb)
p=max(a)
c=[]
for temp in b:
if temp>p:
c.append(temp)
c.sort(reverse=True)
count=0
for temp in c:
h-=temp
count+=1
if h<=0:
print (count)
break
if h>0:
if h%p==0:
count+=int(h/p)
print(count)
else :
count+=(int(h/p)+1)
print(count) |
s435362715 | p03110 | u866169813 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 183 | 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` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total? | N=int(input())
OTOSHIDAMA=0
for i in range(0,N):
A,B=(input().split(" "))
AA=float(A)
if B=="BTC":
AA=AA*380000
OTOSHIDAMA+=AA
print(OTOSHIDAMA)
print(OTOSHIDAMA) | s683831905 | Accepted | 17 | 2,940 | 184 | N=int(input())
OTOSHIDAMA=0
for i in range(0,N):
A,B=(input().split(" "))
AA=float(A)
if B=="BTC":
AA=AA*380000
OTOSHIDAMA+=AA
#print(OTOSHIDAMA)
print(OTOSHIDAMA) |
s683609601 | p03860 | u057463552 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 45 | Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name. | a,s,c = input().split()
print(a + s[0:1] + c) | s368136188 | Accepted | 17 | 2,940 | 55 | a,s,c = input().split()
print(a[0:1] + s[0:1] + c[0:1]) |
s965592664 | p03449 | u145600939 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 162 | We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel? | n = int(input())
a = [list(map(int,input().split())) for i in range(2)]
ans = 0
for i in range(n):
ans = max(ans , sum(a[0][0:i]) + sum(a[0][i:n-1]))
print(ans) | s947368397 | Accepted | 20 | 3,060 | 235 | n = int(input())
A = [list(map(int,input().split())) for _ in range(2)]
ans = 0
for i in range(n):
cnt = 0
for j in range(n):
if j <= i:
cnt += A[0][j]
if j >= i:
cnt += A[1][j]
ans = max(ans,cnt)
print(ans)
|
s728428211 | p02389 | u921038488 | 1,000 | 131,072 | Wrong Answer | 20 | 5,584 | 93 | Write a program which calculates the area and perimeter of a given rectangle. | def getSquare(h, w):
return h * w
a, b = map(int, input().split())
print(getSquare(a,b)) | s702437086 | Accepted | 20 | 5,600 | 164 | def getSquare(h, w):
return h * w
def getShuu(h, w):
return 2*h + 2*w
a, b = map(int, input().split())
print("{} {}".format(getSquare(a,b), getShuu(a,b))) |
s297667825 | p03711 | u277312083 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 144 | Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group. | a = [0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0]
x, y = map(int, input().split())
x -= 1
y -= 1
if a[x] == a[y]:
print("No")
else:
print("Yes")
| s539010563 | Accepted | 17 | 2,940 | 144 | a = [0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0]
x, y = map(int, input().split())
x -= 1
y -= 1
if a[x] == a[y]:
print("Yes")
else:
print("No")
|
s070319958 | p04043 | u763396655 | 2,000 | 262,144 | Wrong Answer | 23 | 3,572 | 136 | Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order. | from functools import reduce
from operator import mul
s = reduce(mul, map(int, input().split(' ')))
print('Yes' if s == 175 else 'No')
| s297526678 | Accepted | 22 | 3,572 | 136 | from functools import reduce
from operator import mul
s = reduce(mul, map(int, input().split(' ')))
print('YES' if s == 175 else 'NO')
|
s560971255 | p03671 | u693211869 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 153 | 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, b, c = map(int,input().split())
s = a + b
t = a + c
u = b + c
if s > t and s > u:
print(s)
elif t > s and t > u:
print(t)
else:
print(u) | s962598729 | Accepted | 17 | 3,060 | 157 | a, b, c = map(int,input().split())
s = a + b
t = a + c
u = b + c
if s <= t and s <= u:
print(s)
elif t <= s and t <= u:
print(t)
else:
print(u) |
s561899233 | p02690 | u972658925 | 2,000 | 1,048,576 | Wrong Answer | 523 | 9,184 | 184 | Give a pair of integers (A, B) such that A^5-B^5 = X. It is guaranteed that there exists such a pair for the given integer X. | x = int(input())
[a,b] = [0,0]
for i in range(-500,501):
for j in range(-500,501):
if i**5 - j**5 == x:
a = i
b = j
break
print([a,b]) | s631832868 | Accepted | 544 | 9,180 | 180 | x = int(input())
a,b = [0,0]
for i in range(-500,501):
for j in range(-500,501):
if i**5 - j**5 == x:
a = i
b = j
break
print(a,b) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.