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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s436753929
|
p03998
|
u055687574
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,188 | 217 |
Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game.
|
d = {"a": input(), "b": input(), "c": input()}
def f(player):
if len(d[player]) == 0:
print(player)
exit()
next_player = d[player][0]
d[player] = d[player][1:]
f(next_player)
f("a")
|
s303806417
|
Accepted
| 17 | 3,188 | 225 |
d = {"a": input(), "b": input(), "c": input()}
def f(player):
if len(d[player]) == 0:
print(player.upper())
exit()
next_player = d[player][0]
d[player] = d[player][1:]
f(next_player)
f("a")
|
s492062745
|
p03544
|
u023229441
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 80 |
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
|
A=[2,1]
n=int(input())
for i in range(n-2):
A.append(A[i]+A[i+1])
print(A[-1])
|
s466056736
|
Accepted
| 18 | 2,940 | 113 |
n=int(input())
L=[0 for i in range(n+1)]
L[0]=2 ; L[1]=1
for i in range(2,n+1):
L[i]=L[i-1]+L[i-2]
print(L[n])
|
s834583884
|
p03371
|
u905582793
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 139 |
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
|
a,b,c,x,y = map(int,input().split())
if c > (a+b)/2:
print(x*a+y*b)
else:
if x>y:
print(c*y+a*(x-y))
else:
print(c*x+b*(y-x))
|
s202798772
|
Accepted
| 17 | 3,064 | 411 |
a,b,c,x,y = map(int,input().split())
ans = 0
if 2*c<=min(a,b):
ans = c*max(x,y)*2
elif 2*c<=max(a,b):
if a>b and x>y:
ans = c*x*2
elif a<=b and x<=y:
ans = c*y*2
elif a>b and x<=y:
ans = c*x*2+b*(y-x)
elif a<=b and x>y:
ans = c*y*2+a*(x-y)
else:
ans = c*y*2+a*(x-y)
elif 2*c<=a+b:
if x>y:
ans = c*y*2+a*(x-y)
else:
ans = c*x*2+b*(y-x)
else:
ans = a*x+b*y
print(ans)
|
s673898698
|
p03068
|
u128859393
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 169 |
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.
|
N = int(input())
S = input()
K = int(input())
key = S[K - 1]
ans = ''
print(key)
for s in S:
if s == key:
ans += key
else:
ans += '*'
print(ans)
|
s283082187
|
Accepted
| 17 | 2,940 | 170 |
N = int(input())
S = input()
K = int(input())
key = S[K - 1]
ans = ''
for i in range(N):
if S[i] == key:
ans += key
else:
ans += '*'
print(ans)
|
s318019573
|
p03494
|
u999503965
| 2,000 | 262,144 |
Time Limit Exceeded
| 2,206 | 9,028 | 151 |
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
n=int(input())
l=list(map(int,input().split()))
ans=0
while True:
for i in l:
if i%2!=0:
break
ans+=1
l=[i/2 for i in l]
print(ans)
|
s790287244
|
Accepted
| 27 | 9,216 | 156 |
n=int(input())
l=list(map(int,input().split()))
ans=0
while True:
for i in l:
if i%2!=0:
print(ans)
exit()
ans+=1
l=[i/2 for i in l]
|
s551484761
|
p02277
|
u254642509
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,628 | 1,942 |
Let's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a suit (S, H, C or D) and an number. Write a program which sorts such cards based on the following pseudocode: Partition(A, p, r) 1 x = A[r] 2 i = p-1 3 for j = p to r-1 4 do if A[j] <= x 5 then i = i+1 6 exchange A[i] and A[j] 7 exchange A[i+1] and A[r] 8 return i+1 Quicksort(A, p, r) 1 if p < r 2 then q = Partition(A, p, r) 3 run Quicksort(A, p, q-1) 4 run Quicksort(A, q+1, r) Here, A is an array which represents a deck of cards and comparison operations are performed based on the numbers. Your program should also 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 InputData():
sequence_len = int(input())
sequence = [input().split(" ") for _ in range(sequence_len)]
sequence_m = [(a[0], int(a[1])) for a in sequence]
sequence_q = [(a[0], int(a[1])) for a in sequence]
return sequence_len, sequence_m, sequence_q
def partition(sequence, p, r):
x = sequence[r]
i = p - 1
for j in range(p, r):
if sequence[j][1] <= x[1]:
i += 1
sequence[i], sequence[j]= sequence[j], sequence[i]
sequence[i+1], sequence[r] = sequence[r], sequence[i+1]
return i+1
def quickSort(sequence, p, r):
if p < r:
q = partition(sequence, p, r)
quickSort(sequence, p, q-1)
quickSort(sequence, q+1, r)
def merge(sequence, left, mid, right):
n1 = mid - left
n2 = right - mid
sequence_left = sequence[left:left + n1]
sequence_right = sequence[mid:mid + n2]
sequence_left.append([None, float('inf')])
sequence_right.append([None, float('inf')])
left_cnt = 0
right_cnt = 0
for i in range(left, right):
if sequence_left[left_cnt][1] <= sequence_right[right_cnt][1]:
sequence[i] = sequence_left[left_cnt]
left_cnt += 1
else:
sequence[i] = sequence_right[right_cnt]
right_cnt += 1
def mergeSort(sequence, left, right):
if left + 1 < right:
mid = (left + right) // 2
mergeSort(sequence, left, mid)
mergeSort(sequence, mid, right)
merge(sequence, left, mid, right)
def PrintOut(sequence_m, sequence_q):
if sequence_m == sequence_q:
print("Stable")
else:
print("Not Stable")
for a in sequence_q:
print(a[0], a[1])
def main():
[sequence_len, sequence_m, sequence_q] = InputData()
mergeSort(sequence_m, 0, sequence_len)
quickSort(sequence_q, 0, sequence_len-1)
PrintOut(sequence_m, sequence_q)
if __name__=="__main__":
main()
|
s004430746
|
Accepted
| 1,580 | 48,436 | 1,942 |
def InputData():
sequence_len = int(input())
sequence = [input().split(" ") for _ in range(sequence_len)]
sequence_m = [(a[0], int(a[1])) for a in sequence]
sequence_q = [(a[0], int(a[1])) for a in sequence]
return sequence_len, sequence_m, sequence_q
def partition(sequence, p, r):
x = sequence[r]
i = p - 1
for j in range(p, r):
if sequence[j][1] <= x[1]:
i += 1
sequence[i], sequence[j]= sequence[j], sequence[i]
sequence[i+1], sequence[r] = sequence[r], sequence[i+1]
return i+1
def quickSort(sequence, p, r):
if p < r:
q = partition(sequence, p, r)
quickSort(sequence, p, q-1)
quickSort(sequence, q+1, r)
def merge(sequence, left, mid, right):
n1 = mid - left
n2 = right - mid
sequence_left = sequence[left:left + n1]
sequence_right = sequence[mid:mid + n2]
sequence_left.append([None, float('inf')])
sequence_right.append([None, float('inf')])
left_cnt = 0
right_cnt = 0
for i in range(left, right):
if sequence_left[left_cnt][1] <= sequence_right[right_cnt][1]:
sequence[i] = sequence_left[left_cnt]
left_cnt += 1
else:
sequence[i] = sequence_right[right_cnt]
right_cnt += 1
def mergeSort(sequence, left, right):
if left + 1 < right:
mid = (left + right) // 2
mergeSort(sequence, left, mid)
mergeSort(sequence, mid, right)
merge(sequence, left, mid, right)
def PrintOut(sequence_m, sequence_q):
if sequence_m == sequence_q:
print("Stable")
else:
print("Not stable")
for a in sequence_q:
print(a[0], a[1])
def main():
[sequence_len, sequence_m, sequence_q] = InputData()
mergeSort(sequence_m, 0, sequence_len)
quickSort(sequence_q, 0, sequence_len-1)
PrintOut(sequence_m, sequence_q)
if __name__=="__main__":
main()
|
s008663852
|
p03409
|
u226108478
| 2,000 | 262,144 |
Wrong Answer
| 33 | 3,644 | 790 |
On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.
|
# -*- coding: utf-8 -*-
if __name__ == '__main__':
number = int(input())
a_b = [list(map(int, input().split())) for _ in range(number)]
c_d = [list(map(int, input().split())) for _ in range(number)]
sorted_a_b = sorted(a_b, key=lambda x: (x[1], x[0]))
sorted_c_d = sorted(c_d, key=lambda y: (y[1], y[0]))
count = 0
print(sorted_a_b)
print(sorted_c_d)
for i, (a, b) in enumerate(sorted_a_b):
print(i, a, b)
for j, (c, d) in enumerate(sorted_c_d):
print(j, c, d)
if (a < c) and (b < d):
sorted_a_b.pop()
sorted_c_d.pop()
count += 1
print(count)
|
s277869109
|
Accepted
| 19 | 3,064 | 797 |
# -*- coding: utf-8 -*-
def get_candidate_points(sorted_a_b: list, c: int, d: int) -> list:
candidate_a_b = [x for x in sorted_a_b if (x[0] < c) and (x[1] < d)]
return sorted(candidate_a_b, key=lambda x: (x[1], x[0]), reverse=True)
if __name__ == '__main__':
number = int(input())
a_b = [list(map(int, input().split())) for _ in range(number)]
c_d = [list(map(int, input().split())) for _ in range(number)]
sorted_a_b = sorted(a_b, key=lambda x: (x[0], x[1]))
sorted_c_d = sorted(c_d, key=lambda y: (y[0], y[1]))
count = 0
for c, d in sorted_c_d:
points = get_candidate_points(sorted_a_b, c, d)
if len(points) >= 1:
sorted_a_b.remove(points[0])
count += 1
print(count)
|
s779955106
|
p03438
|
u646130340
| 2,000 | 262,144 |
Wrong Answer
| 38 | 10,592 | 278 |
You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal. Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions **simultaneously** : * Add 2 to a_i. * Add 1 to b_j.
|
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = False
rule1 = sum(a) <= sum(b)
rule2 = sum([bi - ai for ai, bi in zip(a,b) if ai < bi]) <= sum(b) - sum(a)
if rule1 and rule2:
ans = True
text = "Yes" if ans else "No"
print(text)
|
s074892020
|
Accepted
| 36 | 10,572 | 333 |
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
result = False
big_a = sum([ai - bi for ai, bi in zip(a,b) if ai > bi])
big_b = sum([(bi - ai) // 2 for ai, bi in zip(a,b) if bi > ai])
sum_diff = sum(b) - sum(a)
if big_a <= big_b:
result = True
ans = "Yes" if result else "No"
print(ans)
|
s259169841
|
p02388
|
u418789927
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,568 | 34 |
Write a program which calculates the cube of a given integer x.
|
x=int(input("x="))
print(x*x*x
)
|
s653298103
|
Accepted
| 20 | 5,572 | 28 |
x=int(input())
print(x**3)
|
s229557346
|
p02612
|
u113694671
| 2,000 | 1,048,576 |
Wrong Answer
| 32 | 9,064 | 32 |
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)
|
s215166916
|
Accepted
| 27 | 9,112 | 76 |
n = int(input())
if n % 1000 == 0:
print(0)
else:
print(1000 - n % 1000)
|
s040413253
|
p02690
|
u771007149
| 2,000 | 1,048,576 |
Wrong Answer
| 21 | 9,348 | 320 |
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.
|
# D
x = int(input())
a = int(x**(1/5))
b = int(abs(x-a**5)**(1/5))
if a**5 + b**5 != x and a**5 + (-b)**5 != x:
a = int(x**(1/5))+1
b = int(abs(x-a**5)**(1/5))
if a**5 + b**5 == x:
print(a,b)
else:
print(a,-b)
elif a**5 + b**5 == x:
print(a,b)
else:
print(a,-b)
|
s673050940
|
Accepted
| 24 | 9,504 | 833 |
# D
x = int(input())
a = int(x**(1/5))
b = int(abs(x-a**5)**(1/5))
i = 1
while True:
if a**5 - b**5 != x and a**5 - (-b)**5 != x:
if a**5 - x > (a+1)**5 - x:
a += i
b = int(abs(x-a**5)**(1/5))
if a**5 - b**5 == x:
print(a,b)
break
elif a**5 - (-b)**5 == x:
print(a,-b)
break
else:
pass
else:
a -= 1
b = int(abs(x-a**5)**(1/5))
if a**5 - b**5 == x:
print(a,b)
break
elif a**5 - (-b)**5 == x:
print(a,-b)
break
else:
pass
elif a**5 - b**5 == x:
print(a,b)
break
else:
print(a,-b)
break
|
s489793812
|
p03069
|
u291766461
| 2,000 | 1,048,576 |
Wrong Answer
| 243 | 12,340 | 497 |
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.
|
N = int(input())
S = input()
if len(set(S)) == 1:
print(0)
exit()
sum_blacks = [0] * (N + 1)
for i in range(N):
if S[i] == "#":
sum_blacks[i+1] = sum_blacks[i] + 1
else:
sum_blacks[i+1] = sum_blacks[i]
print(sum_blacks)
ans = float('inf')
for i in range(N+1):
l_whites = i - sum_blacks[i]
l_blacks = sum_blacks[i]
r_blacks = sum_blacks[-1] - l_blacks
r_whites = N - l_whites - l_blacks - r_blacks
ans = min(ans, l_blacks + r_whites)
print(ans)
|
s338018770
|
Accepted
| 244 | 10,116 | 581 |
N = int(input())
S = input()
if len(set(S)) == 1:
print(0)
exit()
sum_blacks = [0] * N
if S[0] == "#":
sum_blacks[0] += 1
for i in range(1, N):
if S[i] == "#":
sum_blacks[i] = sum_blacks[i - 1] + 1
else:
sum_blacks[i] = sum_blacks[i - 1]
ans = float('inf')
ans = min(ans, sum_blacks[-1])
ans = min(ans, N - sum_blacks[-1])
for i in range(N):
l_blacks = sum_blacks[i]
l_whites = i + 1 - l_blacks
r_blacks = sum_blacks[-1] - l_blacks
r_whites = N - l_blacks - l_whites - r_blacks
ans = min(ans, l_blacks + r_whites)
print(ans)
|
s500202053
|
p02865
|
u424985923
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 2,940 | 32 |
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
|
x = int(input())
print((x+1)//2)
|
s637675590
|
Accepted
| 18 | 2,940 | 32 |
x = int(input())
print((x-1)//2)
|
s935985517
|
p03151
|
u042644898
| 2,000 | 1,048,576 |
Wrong Answer
| 181 | 19,896 | 1,027 |
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his _readiness_ for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination. Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness. For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions: * The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal. * For every i, B_i \leq C_i holds. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
|
import math
import copy
def nCast(number):
if type(number)==str:
return int(number)
for idx in range(0,len(number)):
if type(number[idx])==str:
number[idx]=int(number[idx])
else:
nCast(number[idx])
return number
def inputArr(w):
l=list()
for idx in range(0,w):
l.append(input())
return l
def inputArr1(w):
l=list()
for idx in range(0,w):
l.append(input())
return l
n=nCast(input())
a=nCast(input().split())
b=nCast(input().split())
c=list()
def func():
result=0
if sum(a)<sum(b):
return -1
for idx in range(0,len(a)):
c.append(a[idx]-b[idx])
c.sort()
need=0
result=0
print(c)
for number in c:
if number<0:
need+=number
result+=1
else:
break
if need!=0:
return 0
for number in reversed(c):
result+=1
need+=number
if need>=0:
break
return result
print(func())
|
s731298998
|
Accepted
| 179 | 16,756 | 1,016 |
import math
import copy
def nCast(number):
if type(number)==str:
return int(number)
for idx in range(0,len(number)):
if type(number[idx])==str:
number[idx]=int(number[idx])
else:
nCast(number[idx])
return number
def inputArr(w):
l=list()
for idx in range(0,w):
l.append(input())
return l
def inputArr1(w):
l=list()
for idx in range(0,w):
l.append(input())
return l
n=nCast(input())
a=nCast(input().split())
b=nCast(input().split())
c=list()
def func():
result=0
if sum(a)<sum(b):
return -1
for idx in range(0,len(a)):
c.append(a[idx]-b[idx])
c.sort()
need=0
result=0
for number in c:
if number<0:
need+=number
result+=1
else:
break
if need==0:
return 0
for number in reversed(c):
result+=1
need+=number
if need>=0:
break
return result
print(func())
|
s398604106
|
p03470
|
u951480280
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 193 |
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 = [int(input()) for i in range(n)]
cnt = 1
d = sorted(d)
print(d)
for i in range(n-1):
if d[i+1] > d[i]:
cnt += 1
elif d[i+1] < d[i]:
break
print(cnt)
|
s980015016
|
Accepted
| 18 | 2,940 | 60 |
print(len(set([int(input()) for _ in range(int(input()))])))
|
s579932243
|
p03378
|
u189479417
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 154 |
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N. Find the minimum cost incurred before reaching the goal.
|
from bisect import bisect_left
N, M, X = map(int,input().split())
A = list(map(int,input().split()))
index = bisect_left(A, X)
ans = min(index, M - index)
|
s370710462
|
Accepted
| 17 | 3,060 | 165 |
from bisect import bisect_left
N, M, X = map(int,input().split())
A = list(map(int,input().split()))
index = bisect_left(A, X)
ans = min(index, M - index)
print(ans)
|
s652118907
|
p03352
|
u687044304
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 252 |
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
|
# -*- coding:utf-8 -*-
import math
def solve(X):
ans = X
for b in range(2, X):
p = math.log(ans, b)
if float.is_integer(p):
return ans
return 1
if __name__ == "__main__":
X = int(input())
print(solve(X))
|
s760277583
|
Accepted
| 70 | 3,064 | 477 |
# -*- coding:utf-8 -*-
import math
def solve(X):
ans = X
for b in range(2, X):
p = math.log(ans, b)
if float.is_integer(p):
return ans
return 1
def solve2(X):
for x in range(X, 1, -1):
for p in range(2, x):
for b in range(2, x):
bp = b**p
if bp == x:
return x
if bp >= x:
break
return 1
if __name__ == "__main__":
X = int(input())
print(solve2(X))
|
s508211126
|
p03448
|
u374082254
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 262 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
A = int(input())
B = int(input())
C = int(input())
X = int(input())
result = 0
for i in range(A // 500):
for j in range(B // 100):
for k in range(C // 50):
if (i * 500 + j * 100 + k * 50) == X:
result += 1
print(result)
|
s556739069
|
Accepted
| 50 | 3,060 | 254 |
A = int(input())
B = int(input())
C = int(input())
X = int(input())
result = 0
for i in range(A + 1):
for j in range(B + 1):
for k in range(C + 1):
if (i * 500 + j * 100 + k * 50) == X:
result += 1
print(result)
|
s347911502
|
p03493
|
u377236950
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 24 |
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
a = input()
a.count("1")
|
s549014701
|
Accepted
| 18 | 2,940 | 41 |
a = input()
num = a.count("1")
print(num)
|
s430538178
|
p02612
|
u980205854
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,144 | 30 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N = int(input())
print(N%1000)
|
s292128141
|
Accepted
| 28 | 9,156 | 72 |
N = int(input())
if N%1000==0:
print(0)
else:
print(1000-N%1000)
|
s167032916
|
p03730
|
u200239931
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 749 |
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
import math
import sys
def getinputdata():
array_result = []
data = input()
array_result.append(data.split(" "))
flg = 1
try:
while flg:
data = input()
array_temp = []
if(data != ""):
array_result.append(data.split(" "))
flg = 1
else:
flg = 0
finally:
return array_result
arr_data = getinputdata()
a = int(arr_data[0][0])
b = int(arr_data[0][1])
c = int(arr_data[0][2])
#print(a,b,c)
cnt=1
while cnt<= 100:
if (c + b * cnt) % a ==0:
print(cnt,"YES")
break
cnt+=1
else:
print("NO")
|
s305197936
|
Accepted
| 18 | 3,064 | 745 |
import math
import sys
def getinputdata():
array_result = []
data = input()
array_result.append(data.split(" "))
flg = 1
try:
while flg:
data = input()
array_temp = []
if(data != ""):
array_result.append(data.split(" "))
flg = 1
else:
flg = 0
finally:
return array_result
arr_data = getinputdata()
a = int(arr_data[0][0])
b = int(arr_data[0][1])
c = int(arr_data[0][2])
#print(a,b,c)
cnt=1
while cnt<= 100:
if (c + b * cnt) % a ==0:
print("YES")
break
cnt+=1
else:
print("NO")
|
s074403720
|
p02388
|
u678843586
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,572 | 55 |
Write a program which calculates the cube of a given integer x.
|
x=input()
n=int(x)*int(x)*int(x)
print('x=',x, 'n=',n)
|
s666395462
|
Accepted
| 20 | 5,572 | 29 |
x = int(input())
print(x**3)
|
s747841289
|
p03795
|
u641460756
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 41 |
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
n=int(input())
x=800*n
y=n//15
print(x-y)
|
s854056960
|
Accepted
| 17 | 2,940 | 46 |
n=int(input())
x=800*n
y=n//15*200
print(x-y)
|
s119012914
|
p03587
|
u064408584
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 3,060 | 266 |
Snuke prepared 6 problems for a upcoming programming contest. For each of those problems, Rng judged whether it can be used in the contest or not. You are given a string S of length 6. If the i-th character of s is `1`, it means that the i-th problem prepared by Snuke is accepted to be used; `0` means that the problem is not accepted. How many problems prepared by Snuke are accepted to be used in the contest?
|
n=int(input())
for k in range(1,3501):
for j in range(1,k+2):
a=(4*j*k - n*k- n*j)
if a<=0 : continue
i = n*j*k / a
i2= n*j*k // a
if i==i2 :
print(i2,j,k)
break
else:
continue
break
|
s390253191
|
Accepted
| 17 | 2,940 | 37 |
print(sum([int(i) for i in input()]))
|
s237036947
|
p00007
|
u922489088
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,572 | 200 |
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.
|
import sys
for line in sys.stdin:
N = int(line.rstrip())
print(len([[i0,i1,i2,i3] for i0 in range(10) for i1 in range(10) for i2 in range(10) for i3 in range(10) if sum([i0,i1,i2,i3]) == N]))
|
s674262497
|
Accepted
| 30 | 7,640 | 163 |
import sys
import math
monney = 100000
n = int(sys.stdin.readline().rstrip())
for i in range(n):
monney = math.ceil(monney * 1.05 / 1000) * 1000
print(monney)
|
s654024156
|
p03563
|
u874741582
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 42 |
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
|
r=int(input())
g=int(input())
print(2+g-r)
|
s605501466
|
Accepted
| 17 | 2,940 | 42 |
r=int(input())
g=int(input())
print(2*g-r)
|
s885531478
|
p03860
|
u757030836
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 51 |
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()
S = s[0]
print(a + S + c)
|
s327746595
|
Accepted
| 17 | 2,940 | 57 |
a,s,c = input().split()
S = s[0]
print(a[0] + S + c[0])
|
s041926428
|
p02603
|
u856389922
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,148 | 520 |
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows: * A_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day. In the i-th day, M-kun can make the following trade **any number of times** (possibly zero), **within the amount of money and stocks that he has at the time**. * Buy stock: Pay A_i yen and receive one stock. * Sell stock: Sell one stock for A_i yen. What is the maximum possible amount of money that M-kun can have in the end by trading optimally?
|
def function(N, A):
money = 1000
kabu = 0
for i in range(N-1):
if (i == 0) & (A[0] < A[1]):
kabu = int(1000/A[0])
money = 1000-kabu*A[0]
elif (A[i] <= A[i+1]):
kabu = int(money/A[i])
money = money-kabu*A[i]
elif (A[i] > A[i+1]):
money = money+kabu*A[i]
kabu = 0
print(money+kabu*A[N-1])
if __name__ == '__main__':
N = int(input())
A = input().split()
A = [int(a) for a in A]
function(N, A)
|
s915022007
|
Accepted
| 29 | 9,116 | 319 |
def function(N, A):
money = 1000
kabu = 0
for i in range(N-1):
if A[i] < A[i+1]:
kabu = int(money/A[i])
money += (A[i+1]-A[i])*kabu
print(money)
if __name__ == '__main__':
N = int(input())
A = input().split()
A = [int(a) for a in A]
function(N, A)
|
s126997339
|
p03470
|
u043236471
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 81 |
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 = [int(input()) for _ in range(N)]
print(len(set([d.sort()])))
|
s261317442
|
Accepted
| 17 | 2,940 | 80 |
N = int(input())
d = [int(input()) for _ in range(N)]
print(len(set(sorted(d))))
|
s792852421
|
p02694
|
u690040890
| 2,000 | 1,048,576 |
Wrong Answer
| 24 | 9,172 | 106 |
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
X = int(input())
money = 100
yr = 0
while money <= X:
money += int(money*0.01)
yr += 1
print(yr)
|
s694552982
|
Accepted
| 23 | 9,168 | 105 |
X = int(input())
money = 100
yr = 0
while money < X:
money += int(money*0.01)
yr += 1
print(yr)
|
s718570034
|
p04043
|
u667084803
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 92 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a=list(map(int,input().split()))
a.sort()
if a==[5, 5,7]:
print("Yes")
else:
print("No")
|
s006999757
|
Accepted
| 17 | 2,940 | 92 |
a=list(map(int,input().split()))
a.sort()
if a==[5, 5,7]:
print("YES")
else:
print("NO")
|
s207314192
|
p03379
|
u371763408
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 26,772 | 192 |
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())
nums = list(map(int,input().split()))
def median(a):
mid = len(a)//2
return a[mid]
for i in range(len(nums)):
tmp_nums = nums[:i]+nums[i+1:]
print(median(tmp_nums))
|
s386884505
|
Accepted
| 305 | 26,016 | 161 |
n = int(input())
x = list(map(int, input().split()))
y = sorted(x)
a = y[n//2-1]
b = y[n//2]
for i in range(n):
if x[i] <= a:
print(b)
else:
print(a)
|
s074865477
|
p03150
|
u102242691
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 149 |
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
|
s = input()
for i in range(len(s)):
if s[:i] + s[i + len(s)-7:] == "keyence":
print("YES")
break
else:
print("NO")
|
s960243666
|
Accepted
| 18 | 2,940 | 168 |
S = input()
N = len(S)
for i in range(N):
for j in range(i, N + 1):
if S[:i] + S[j:] == "keyence":
print("YES")
quit()
print("NO")
|
s767068244
|
p03598
|
u509739538
| 2,000 | 262,144 |
Wrong Answer
| 23 | 3,444 | 2,554 |
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N. When activated, each type of robot will operate as follows. * When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. * When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.
|
import math
from collections import deque
from collections import defaultdict
def readInt():
return int(input())
def readInts():
return list(map(int, input().split()))
def readChar():
return input()
def readChars():
return input().split()
def factorization(n):
res = []
if n%2==0:
res.append(2)
for i in range(3,math.floor(n//2)+1,2):
if n%i==0:
c = 0
for j in res:
if i%j==0:
c=1
if c==0:
res.append(i)
return res
def fact2(n):
p = factorization(n)
res = []
for i in p:
c=0
z=n
while 1:
if z%i==0:
c+=1
z/=i
else:
break
res.append([i,c])
return res
def fact(n):
ans = 1
m=n
for _i in range(n-1):
ans*=m
m-=1
return ans
def comb(n,r):
if n<r:
return 0
l = min(r,n-r)
m=n
u=1
for _i in range(l):
u*=m
m-=1
return u//fact(l)
def combmod(n,r,mod):
return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
r=copyQueue(q)
ans=[0]*r.qsize()
for i in range(r.qsize()-1,-1,-1):
ans[i] = r.get()
print(ans)
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1]*n
def find(self, x): # root
if self.parents[x]<0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self,x,y):
x = self.find(x)
y = self.find(y)
if x==y:
return
if self.parents[x]>self.parents[y]:
x,y = y,x
self.parents[x]+=self.parents[y]
self.parents[y]=x
def size(self,x):
return -1*self.parents[self.find(x)]
def same(self,x,y):
return self.find(x)==self.find(y)
def members(self,x): # much time
root = self.find(x)
return [i for i in range(self.n) if self.find(i)==root]
def roots(self):
return [i for i,x in enumerate(self.parents) if x<0]
def group_count(self):
return len(self.roots())
def all_group_members(self):
return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):
x = 1
zero = "0"*n
ans = []
ans.append([0]*n)
for i in range(2**n-1):
ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
x+=1
return ans;
def arrsSum(a1,a2):
for i in range(len(a1)):
a1[i]+=a2[i]
return a1
def maxValue(a,b,v):
v2 = v
for i in range(v2,-1,-1):
for j in range(v2//a+1):
k = i-a*j
if k%b==0:
return i
return -1
def copyQueue(q):
nq = queue.Queue()
n = q.qsize()
for i in range(n):
x = q.get()
q.put(x)
nq.put(x)
return nq
n = readInt()
k = readInt()
x = readInts()
ans = 0
for i in range(n):
ans+=min(x[i],abs(x[i]-k))
print(ans)
|
s723223529
|
Accepted
| 21 | 3,444 | 2,556 |
import math
from collections import deque
from collections import defaultdict
def readInt():
return int(input())
def readInts():
return list(map(int, input().split()))
def readChar():
return input()
def readChars():
return input().split()
def factorization(n):
res = []
if n%2==0:
res.append(2)
for i in range(3,math.floor(n//2)+1,2):
if n%i==0:
c = 0
for j in res:
if i%j==0:
c=1
if c==0:
res.append(i)
return res
def fact2(n):
p = factorization(n)
res = []
for i in p:
c=0
z=n
while 1:
if z%i==0:
c+=1
z/=i
else:
break
res.append([i,c])
return res
def fact(n):
ans = 1
m=n
for _i in range(n-1):
ans*=m
m-=1
return ans
def comb(n,r):
if n<r:
return 0
l = min(r,n-r)
m=n
u=1
for _i in range(l):
u*=m
m-=1
return u//fact(l)
def combmod(n,r,mod):
return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
r=copyQueue(q)
ans=[0]*r.qsize()
for i in range(r.qsize()-1,-1,-1):
ans[i] = r.get()
print(ans)
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1]*n
def find(self, x): # root
if self.parents[x]<0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self,x,y):
x = self.find(x)
y = self.find(y)
if x==y:
return
if self.parents[x]>self.parents[y]:
x,y = y,x
self.parents[x]+=self.parents[y]
self.parents[y]=x
def size(self,x):
return -1*self.parents[self.find(x)]
def same(self,x,y):
return self.find(x)==self.find(y)
def members(self,x): # much time
root = self.find(x)
return [i for i in range(self.n) if self.find(i)==root]
def roots(self):
return [i for i,x in enumerate(self.parents) if x<0]
def group_count(self):
return len(self.roots())
def all_group_members(self):
return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):
x = 1
zero = "0"*n
ans = []
ans.append([0]*n)
for i in range(2**n-1):
ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
x+=1
return ans;
def arrsSum(a1,a2):
for i in range(len(a1)):
a1[i]+=a2[i]
return a1
def maxValue(a,b,v):
v2 = v
for i in range(v2,-1,-1):
for j in range(v2//a+1):
k = i-a*j
if k%b==0:
return i
return -1
def copyQueue(q):
nq = queue.Queue()
n = q.qsize()
for i in range(n):
x = q.get()
q.put(x)
nq.put(x)
return nq
n = readInt()
k = readInt()
x = readInts()
ans = 0
for i in range(n):
ans+=min(x[i],abs(x[i]-k))*2
print(ans)
|
s158655430
|
p02601
|
u063621307
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 9,156 | 345 |
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
|
a = input().split(" ")
b = int(a[1])
c = int(a[2])
a = int(a[0])
k = int(input())
check=0
while True:
if check == k:
print("True")
break;
else:
if int(c) - int(b) > int(b) - int(a):
b += 1
check += 1
elif int(c) - int(b) < int(b) - int(a):
a += 1
check += 1
else:
print("False")
break;
|
s289164951
|
Accepted
| 33 | 8,960 | 399 |
a = input().split(" ")
b = int(a[1])
c = int(a[2])
a = int(a[0])
k = int(input())
check=0
while True:
if check == k:
if int(c) > int(b) and int(b) > int(a):
print("Yes")
break;
else:
print("No")
break;
else:
if int(c) <= int(b):
c = c*2
check += 1
elif int(b) <= int(a):
b = b*2
check += 1
else:
c = c*2
check += 1
|
s883441703
|
p03369
|
u339922532
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 44 |
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
|
s = input()
print(700 + s.count("x") * 100)
|
s309454291
|
Accepted
| 17 | 2,940 | 44 |
s = input()
print(700 + s.count("o") * 100)
|
s020089644
|
p04043
|
u595600198
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 37 |
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.
|
num = list(map(int, input().split()))
|
s962361597
|
Accepted
| 16 | 2,940 | 156 |
input_list = list(map(int, input().split()))
lists = [5,7,5]
try:
for x in input_list:
lists.remove(x)
print("YES")
except ValueError:
print("NO")
|
s515811484
|
p02613
|
u056704606
| 2,000 | 1,048,576 |
Wrong Answer
| 162 | 9,092 | 390 |
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())
c1=0
c2=0
c3=0
c4=0
s1='AC'
s2='WA'
s3='TLE'
s4='RA'
for _ in range(n):
str1=str(input())
if(str1=='AC'):
c1=c1+1
elif(str1=='WA'):
c2=c2+1
elif(str1=='TLE'):
c3=c3+1
elif(str1=='RA'):
c4=c4+1
s1=s1+' ' + '*' + ' ' + str(c1)
s2=s2+' ' + '*' + ' ' + str(c2)
s3=s3+' ' + '*' + ' ' + str(c3)
s4=s4+' ' + '*' + ' ' + str(c4)
print(s1)
print(s2)
print(s3)
print(s4)
|
s575738632
|
Accepted
| 156 | 9,180 | 390 |
n=int(input())
c1=0
c2=0
c3=0
c4=0
s1='AC'
s2='WA'
s3='TLE'
s4='RE'
for _ in range(n):
str1=str(input())
if(str1=='AC'):
c1=c1+1
elif(str1=='WA'):
c2=c2+1
elif(str1=='TLE'):
c3=c3+1
elif(str1=='RE'):
c4=c4+1
s1=s1+' ' + 'x' + ' ' + str(c1)
s2=s2+' ' + 'x' + ' ' + str(c2)
s3=s3+' ' + 'x' + ' ' + str(c3)
s4=s4+' ' + 'x' + ' ' + str(c4)
print(s1)
print(s2)
print(s3)
print(s4)
|
s084804299
|
p03672
|
u979444096
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 254 |
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
|
def main():
s = input()
for i in range(len(s)):
a = s[:-i]
if len(a) % 2 == 1:
continue
len_a = len(a) // 2
if a[:len_a] == a[len_a:]:
print(len(a))
if __name__ == '__main__':
main()
|
s342619972
|
Accepted
| 17 | 2,940 | 291 |
def main():
s = input()
for i in range(len(s)):
a = s[:-(i+1)]
if len(a) % 2 == 1:
continue
half_len_a = len(a) // 2
if a[:half_len_a] == a[half_len_a:]:
print(len(a))
exit()
if __name__ == '__main__':
main()
|
s280769323
|
p03251
|
u695079172
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 398 |
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.
|
def main():
N,M,X,Y = map(int,input().split())
x_s = list(map(int,input().split()))
y_s = list(map(int,input().split()))
x_max = max(x_s)
y_min = min(y_s)
ok = False
for z in range(X,Y+1):
if z <= x_max or z > y_min:
ok = True
break
answer = "War" if ok else "No War"
print(answer)
if __name__ == '__main__':
main()
|
s917598644
|
Accepted
| 18 | 3,060 | 340 |
def main():
N,M,X,Y = map(int,input().split())
x_s = list(map(int,input().split()))
y_s = list(map(int,input().split()))
ok = False
for z in range(X+1,Y+1):
if z > max(x_s) and z <= min(y_s):
ok = True
break
print("No War" if ok else "War")
if __name__ == '__main__':
main()
|
s366366879
|
p03591
|
u153147777
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 58 |
Ringo is giving a present to Snuke. Ringo has found out that Snuke loves _yakiniku_ (a Japanese term meaning grilled meat. _yaki_ : grilled, _niku_ : meat). He supposes that Snuke likes grilled things starting with `YAKI` in Japanese, and does not like other things. You are given a string S representing the Japanese name of Ringo's present to Snuke. Determine whether S starts with `YAKI`.
|
s = input()
print('YES' if s.startswith('YAKI') else 'No')
|
s243738054
|
Accepted
| 17 | 2,940 | 58 |
s = input()
print('Yes' if s.startswith('YAKI') else 'No')
|
s410979656
|
p03593
|
u843135954
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,316 | 595 |
We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the top and j-th column from the left. In this matrix, each a_{ij} is a lowercase English letter. Snuke is creating another H-by-W matrix, A', by freely rearranging the elements in A. Here, he wants to satisfy the following condition: * Every row and column in A' can be read as a palindrome. Determine whether he can create a matrix satisfying the condition.
|
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
from collections import Counter
h,w = na()
c = Counter()
for i in range(h):
c.update(ns())
c = list(c.values())
for i in range(len(c)):
c[i] %= 4
print(c)
v,x,y,z = c.count(0),c.count(1),c.count(2),c.count(3)
if x+z > 1:
print('No')
else:
a = y+z
if h%2 == 1:
a -= w//2
if w%2 == 1:
a -= h//2
if a <= 0:
print('Yes')
else:
print('No')
|
s308468333
|
Accepted
| 22 | 3,316 | 586 |
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
from collections import Counter
h,w = na()
c = Counter()
for i in range(h):
c.update(ns())
c = list(c.values())
for i in range(len(c)):
c[i] %= 4
v,x,y,z = c.count(0),c.count(1),c.count(2),c.count(3)
if x+z > 1:
print('No')
else:
a = y+z
if h%2 == 1:
a -= w//2
if w%2 == 1:
a -= h//2
if a <= 0:
print('Yes')
else:
print('No')
|
s210931368
|
p03610
|
u941884460
| 2,000 | 262,144 |
Wrong Answer
| 39 | 3,188 | 106 |
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
|
s = input()
ind = 0
result = ''
while ind < len(s)-1:
result = result + s[ind]
ind += 2
print(result)
|
s451713119
|
Accepted
| 39 | 3,188 | 107 |
s = input()
ind = 0
result = ''
while ind <= len(s)-1:
result = result + s[ind]
ind += 2
print(result)
|
s842475793
|
p03644
|
u272557899
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 214 |
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
n = int(input())
k = 0
count = 0
m = 0
for i in range(1, n + 1):
count = 0
while i % 2 == 0:
count += 1
i = i // 2
if i == 1:
k = count
m = i
elif k < count:
k = count
m = i
print(m)
|
s466179878
|
Accepted
| 17 | 2,940 | 222 |
n = int(input())
k = 0
count = 0
m = 0
for i in range(1, n + 1):
count = 0
j = i
while j % 2 == 0:
count += 1
j = j // 2
if i == 1:
k = count
m = i
elif k < count:
k = count
m = i
print(m)
|
s000360733
|
p02417
|
u150984829
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,556 | 75 |
Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.
|
a=list(input())
[print(chr(97+i),':',a.count(chr(97+i)))for i in range(26)]
|
s178670798
|
Accepted
| 20 | 5,556 | 94 |
import sys;s=sys.stdin.read().lower()
for c in map(chr,range(97,123)):print(c,':',s.count(c))
|
s762782476
|
p03721
|
u728498511
| 2,000 | 262,144 |
Wrong Answer
| 2,113 | 170,776 | 214 |
There is an empty array. The following N operations will be performed to insert integers into the array. In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array. Find the K-th smallest integer in the array after the N operations. For example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.
|
from sys import stdin
n, k = map(int, input().split())
nums = []
for i in range(n):
a, b = map(int, stdin.readline().split())
for j in range(b):
nums.append(a)
nums.sort(reverse=True)
print(nums[k])
|
s588002543
|
Accepted
| 270 | 29,056 | 255 |
from sys import stdin
n, k = map(int, input().split())
nums = [list(map(int, stdin.readline().split())) for _ in range(n)]
nums.sort(key=lambda x:x[0])
i = 0
while True:
k -= nums[i][1]
if k <= 0:
print(nums[i][0])
break
i += 1
|
s542177428
|
p03574
|
u780675733
| 2,000 | 262,144 |
Wrong Answer
| 22 | 3,188 | 1,119 |
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.
|
W, H = map(int, input().split())
f = [list(input()) for i in range(W)]
ans = [[0 for i in range(H)] for i in range(W)]
for i in range(W):
for j in range(H):
cnt = 0
try:
if f[i-1][j-1] == '#':
cnt += 1
except:
pass
try:
if f[i-1][j] == '#':
cnt += 1
except:
pass
try:
if f[i-1][j+1] == '#':
cnt += 1
except:
pass
try:
if f[i][j-1] == '#':
cnt += 1
except:
pass
try:
if f[i][j+1] == '#':
cnt += 1
except:
pass
try:
if f[i+1][j-1] == '#':
cnt += 1
except:
pass
try:
if f[i+1][j] == '#':
cnt += 1
except:
pass
try:
if f[i+1][j+1] == '#':
cnt += 1
except:
pass
if f[i][j] == '#':
ans[i][j] = '#'
else:
ans[i][j] = str(cnt)
|
s609836771
|
Accepted
| 22 | 3,188 | 827 |
H, W = map(int, input().split())
f = ["." * (W + 2)]
for _ in range(H):
f += ["." + input() + "."]
f += ["."* (W+2)]
ans = [[0 for _ in range(W)] for _ in range(H)]
for i in range(1, H+1):
for j in range(1, W+1):
if f[i][j] == '#':
ans[i-1][j-1] = '#'
continue
cnt = 0
if f[i-1][j-1] == '#':
cnt += 1
if f[i-1][j] == '#':
cnt += 1
if f[i-1][j+1] == '#':
cnt += 1
if f[i][j-1] == '#':
cnt += 1
if f[i][j+1] == '#':
cnt += 1
if f[i+1][j-1] == '#':
cnt += 1
if f[i+1][j] == '#':
cnt += 1
if f[i+1][j+1] == '#':
cnt += 1
ans[i-1][j-1] = str(cnt)
for i in range(H):
print(''.join(ans[i]))
|
s751634889
|
p03434
|
u856232850
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 167 |
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
n = int(input())
a = list(map(int,input().split()))
a.sort()
c = 0
d = 0
for i in range(n):
if i % 2 == 0:
c += a[i]
else:
d += a[i]
print(c-d)
|
s264981520
|
Accepted
| 17 | 3,064 | 179 |
n = int(input())
a = list(map(int,input().split()))
a.sort()
a.reverse()
c = 0
d = 0
for i in range(n):
if i % 2 == 0:
c += a[i]
else:
d += a[i]
print(c-d)
|
s034292630
|
p03854
|
u172823566
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,188 | 342 |
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()
while s != "":
if len(s) < 5:
print('No')
exit()
if s.endswith('dream'):
s = s.rstrip('dream')
elif s.endswith('dreamer'):
s = s.rstrip('dreamer')
elif s.endswith('erase'):
s = s.rstrip('erase')
elif s.endswith('eraser'):
s = s.rstrip('eraser')
else:
print('No')
exit()
print('Yes')
|
s849908884
|
Accepted
| 21 | 3,316 | 145 |
import re
s = input()
s = s.replace("eraser", "").replace("erase","")\
.replace("dreamer", "").replace("dream","")
print('NO' if s else 'YES')
|
s299275626
|
p02406
|
u943155333
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,660 | 270 |
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; }
|
import math
x = int(input())
for i in range(x+1):
if i%3==0:
print(f" {i}",end="")
continue
r=i
while True:
if r<=0:
break
if r%10==3:
print(f" {i}",end="")
break
r//=10
print("")
|
s061978504
|
Accepted
| 20 | 5,936 | 272 |
import math
x = int(input())
for i in range(1,x+1):
if i%3==0:
print(f" {i}",end="")
continue
r=i
while True:
if r<=0:
break
if r%10==3:
print(f" {i}",end="")
break
r//=10
print("")
|
s775101095
|
p03943
|
u739843002
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,056 | 122 |
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
ary = list(map(lambda n: int(n), input().split(" ")))
ary.sort
print("Yes") if ary[0] + ary[1] == ary[2] else print("No")
|
s180793076
|
Accepted
| 27 | 9,108 | 125 |
ary = list(map(lambda n: int(n), input().split(" ")))
ary.sort()
print("Yes") if ary[0] + ary[1] == ary[2] else print("No")
|
s795181530
|
p03645
|
u245870380
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 22,988 | 340 |
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services. Help him.
|
N, M = map(int, input().split())
a,b = [],[]
for i in range(M):
A, B = map(int, input().split())
a.append(A)
b.append(B)
for i in range(M):
print(a[i],b[i],N)
if b[i] == N:
for j in range(M):
if a[j] == 1 and b[j] == a[i]:
print("POSSIBLE")
exit(0)
print("IMPOSSIBLE")
|
s354367178
|
Accepted
| 598 | 4,596 | 238 |
N, M = map(int, input().split())
cnt = [0]*N
for i in range(M):
A, B = map(int, input().split())
if A == 1:
cnt[B] += 1
elif B == N:
cnt[A] += 1
if 2 in cnt:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
|
s777282080
|
p03048
|
u500376440
| 2,000 | 1,048,576 |
Time Limit Exceeded
| 2,053 | 9,156 | 164 |
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?
|
R,G,B,N=map(int,input().split())
ans=0
for r in range(3000+1):
for g in range(3000+1):
temp=r*R+g*G
if N>=temp and (N-temp)%B==0:
ans+=1
print(ans)
|
s020386186
|
Accepted
| 1,249 | 9,172 | 159 |
R,G,B,N=map(int,input().split())
ans=0
for i in range(N//R+1):
for j in range((N-i*R)//G+1):
k=N-i*R-j*G
if k%B==0 and k>=0:
ans+=1
print(ans)
|
s326822594
|
p03455
|
u627417051
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 136 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a, b = list(input().split())
S = int(a + b)
judge = "No"
for i in range(1, 101):
if i ** 2 == S:
judge = "Yes"
break
print(judge)
|
s238742283
|
Accepted
| 17 | 2,940 | 94 |
a, b = list(map(int, input().split()))
if (a * b) % 2 == 0:
print("Even")
else:
print("Odd")
|
s635832809
|
p02417
|
u922112509
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,556 | 284 |
Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.
|
# Counting Characters
charList = list('abcdefghijklmnopqrstuvwxyz')
sentence = list(input().rstrip())
print(sentence)
for char in charList:
count = 0
for i in range(len(sentence)):
if sentence[i] == char:
count += 1
print(char + ' : ' + str(count))
|
s705686690
|
Accepted
| 20 | 5,568 | 441 |
# Counting Characters
import sys
charList = list('abcdefghijklmnopqrstuvwxyz')
lines = sys.stdin.readlines()
combinedLine = ""
for line in lines:
line = line.strip("\n").lower()
combinedLine += line
totalSentence = list(combinedLine)
# print(totalSentence)
for char in charList:
count = 0
for i in range(len(totalSentence)):
if totalSentence[i] == char:
count += 1
print(char + ' : ' + str(count))
|
s012722558
|
p02741
|
u749007763
| 2,000 | 1,048,576 |
Wrong Answer
| 2,216 | 1,818,612 | 671 |
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
|
import itertools
import string
length = int(input())
seq = (chr(i) for i in range(97, 97+length))
l = list(itertools.product(seq, repeat=length))
s = ""
for i, val in enumerate(l):
minchar = 'a'
fl = True
if val[0] != minchar:
continue
for j in range(len(val)-1):
if val[j] > val[j+1]:
if ord(val[j+1]) - ord(minchar) > 0:
fl = False
break
if ord(val[j+1]) - ord(minchar) > 0:
if ord(val[j+1]) - ord(minchar) > 1:
fl = False
break
else:
minchar = val[j+1]
if fl:
s += ("".join(val) + "\n")
print(s)
|
s722939909
|
Accepted
| 17 | 3,060 | 129 |
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[int(input())-1])
|
s805242870
|
p03090
|
u940990031
| 2,000 | 1,048,576 |
Wrong Answer
| 22 | 3,352 | 327 |
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved that at least one such graph exists under the constraints of this problem.
|
N = int(input())
list_ = [x for x in range(N)]
if N%2 == 0:
cmb_list = [[k, N-k+1] for k in range(1,int(N/2)+1)]
else:
cmb_list = [[k, N-k] for k in range(1,int(N/2+1))]
cmb_list.append([N])
for list_ in cmb_list:
for c in list_:
for idx in range(1,c):
if (idx not in list_):
print("%s %s"%(idx, c))
|
s084719123
|
Accepted
| 22 | 3,352 | 375 |
N = int(input())
list_ = [x for x in range(N)]
if N%2 == 0:
cmb_list = [[k, N-k+1] for k in range(1,int(N/2)+1)]
print(int(N*(N-2)/2))
else:
cmb_list = [[k, N-k] for k in range(1,int(N/2+1))]
cmb_list.append([N])
print(int((N-1)**2/2))
for list_ in cmb_list:
for c in list_:
for idx in range(1,c):
if (idx not in list_):
print("%s %s"%(idx, c))
|
s057367830
|
p03494
|
u046961553
| 2,000 | 262,144 |
Wrong Answer
| 25 | 3,396 | 374 |
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.
|
s = input()
num_list = list(map(int, input().split()))
flg_break = True
while flg_break:
count = 0
num_tmp_list = []
for n in num_list:
print(n)
if n % 2 != 0:
flg_break = False
break
else:
num_tmp = n / 2
num_tmp_list.append(num_tmp)
num_list = num_tmp_list
count+=1
print(count)
|
s620383850
|
Accepted
| 20 | 3,060 | 360 |
s = input()
num_list = list(map(int, input().split()))
flg_break = True
count = -1
while flg_break:
count+=1
num_tmp_list = []
for n in num_list:
if n % 2 != 0:
flg_break = False
break
else:
num_tmp = n / 2
num_tmp_list.append(num_tmp)
num_list = num_tmp_list
print(count)
|
s136056743
|
p03777
|
u923712635
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 132 |
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or Dishonest_. In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either `H` or `D`, and carries the following information: If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`, AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that TopCoDeer is dishonest. Given this information, determine whether TopCoDeer is honest.
|
a,b = [x for x in input().split()]
if(a=='H' and b=='H'):
print('YES')
elif(a=='D' and b=='D'):
print('YES')
else:
print('NO')
|
s476555481
|
Accepted
| 17 | 2,940 | 127 |
a,b = [x for x in input().split()]
if(a=='H' and b=='H'):
print('H')
elif(a=='D' and b=='D'):
print('H')
else:
print('D')
|
s620720643
|
p03399
|
u252964975
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 88 |
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
|
a=int(input())
b=int(input())
c=int(input())
d=int(input())
print(max([a,b])+max([c,d]))
|
s514974137
|
Accepted
| 18 | 2,940 | 89 |
a=int(input())
b=int(input())
c=int(input())
d=int(input())
print(min([a,b])+min([c,d]))
|
s942123562
|
p03543
|
u655975843
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 101 |
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()
if n[0].count(n) >= 3 or n[1].count(n) >= 3:
print('Yes')
else:
print('No')
|
s302327470
|
Accepted
| 18 | 2,940 | 101 |
n = input()
if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:
print('Yes')
else:
print('No')
|
s349893232
|
p03493
|
u268318377
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 24 |
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
s = input()
s.count("1")
|
s140674448
|
Accepted
| 17 | 2,940 | 31 |
s = input()
print(s.count("1"))
|
s684631182
|
p02659
|
u554784585
| 2,000 | 1,048,576 |
Wrong Answer
| 22 | 9,092 | 59 |
Compute A \times B, truncate its fractional part, and print the result as an integer.
|
A,B=input().split()
A=float(A)
B=float(B)
print((A*B)//1)
|
s103108633
|
Accepted
| 26 | 10,076 | 83 |
A,B=input().split()
import decimal
A=int(A)
B=decimal.Decimal(B)
print(int(A*B))
|
s110702340
|
p03359
|
u052332717
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 74 |
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
|
a,b = map(int,input().split())
if a>=b:
print(a-1)
else:
print(a)
|
s281667671
|
Accepted
| 17 | 2,940 | 73 |
a,b = map(int,input().split())
if a>b:
print(a-1)
else:
print(a)
|
s801378351
|
p03379
|
u834415466
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 75,988 | 198 |
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()))
N=int(n/2)
for i in range(n):
y=[]
for j in range(n):
if j!=i:
y.append(x[j])
print(y)
y.sort()
print(y[N-1])
|
s512887623
|
Accepted
| 305 | 25,224 | 165 |
n=int(input())
x=list(map(int,input().split()))
N=int(n/2)
y=sorted(x)
a=y[N-1]
b=y[N]
for j in range(n):
if x[j]<=a:
print(b)
else:
print(a)
|
s425358676
|
p03359
|
u896430034
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 106 |
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
|
# -*- coding: utf-8 -*-
X, Y = map(int, input().split())
if X > Y:
print(X)
else:
print(X - 1)
|
s112142402
|
Accepted
| 17 | 2,940 | 165 |
# -*- coding: utf-8 -*-
"""
Created on Sat May 5 20:54:36 2018
@author: sakas
"""
X, Y = map(int, input().split())
if X > Y:
print(X - 1)
else:
print(X)
|
s760906238
|
p02612
|
u957198490
| 2,000 | 1,048,576 |
Wrong Answer
| 26 | 9,124 | 40 |
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)*1000 -N)
|
s859534649
|
Accepted
| 26 | 9,068 | 89 |
N =int(input())
if N%1000 == 0:
print(0)
else:
s = N//1000 +1
print(s*1000-N)
|
s306924756
|
p03457
|
u729133443
| 2,000 | 262,144 |
Wrong Answer
| 324 | 3,060 | 160 |
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
n = int(input())
for i in range(n):
t, x, y = map(int, input().split())
if x + y < t or (x + y + t) % 2:
print("No")
exit()
print("Yes")
|
s615563347
|
Accepted
| 146 | 26,632 | 190 |
n,*t=map(int,open(0).read().split())
s=i=j=0
for t,x,y in zip(t[::3],t[1::3],t[2::3]):
d=abs(y-i)+abs(x-j)
if t-s<d or d%2!=(t-s)%2:
print('No')
exit()
s,i,j=t,y,x
print('Yes')
|
s850484806
|
p03779
|
u500297289
| 2,000 | 262,144 |
Wrong Answer
| 34 | 2,940 | 108 |
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.
|
X = int(input())
i = 1
while True:
if (i * (i + 1)) / 2 > X:
print(i)
exit()
i += 1
|
s861395097
|
Accepted
| 32 | 2,940 | 109 |
X = int(input())
i = 1
while True:
if (i * (i + 1)) / 2 >= X:
print(i)
exit()
i += 1
|
s154034603
|
p02972
|
u214561383
| 2,000 | 1,048,576 |
Wrong Answer
| 197 | 8,656 | 200 |
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())
a = list(map(int, input().split()))
ans = [0]*n
for i in reversed(range(1,n)):
if sum(ans[(i-i)::i])%2 != a[i]:
ans[i] += 1
if sum(ans) != a[0]:
ans[0] += 1
print(ans)
|
s524055801
|
Accepted
| 227 | 19,892 | 341 |
n = int(input())
a = list(map(int, input().split()))
ans_l = [0]*n
for i in reversed(range(1,n)):
if sum(ans_l[(i)::(i+1)])%2 != a[i]:
ans_l[i] += 1
if sum(ans_l)%2 != a[0]:
ans_l[0] += 1
ans = []
for i in range(n):
if ans_l[i]==1:
ans.append(i+1)
print(len(ans))
if len(ans)>0:
print(" ".join(map(str, ans)))
|
s089063602
|
p00052
|
u711765449
| 1,000 | 131,072 |
Time Limit Exceeded
| 8,660 | 7,612 | 379 |
n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1 を n の階乗といいます。例えば、12 の階乗は 12! = 12 × 11 × 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 479001600 となり、末尾に 0 が 2 つ連続して並んでいます。 整数 n を入力して、n! の末尾に連続して並んでいる 0 の数を出力するプログラムを作成してください。ただし、n は 20000 以下の正の整数とします。
|
n = []
while True:
try:
tmp = int(input())
if tmp == 0:
break
else:
n.append(tmp)
except EOFError:
break
for i in range(len(n)):
f = 1
for j in range(1,n[i]+1):
f *= j
k = 0
while True:
if f % (10 ** k) != 0:
print(k-1)
break
else:
k += 1
|
s821073544
|
Accepted
| 40 | 7,608 | 327 |
n = []
while True:
try:
tmp = int(input())
if tmp == 0:
break
else:
n.append(tmp)
except EOFError:
break
for i in range(len(n)):
c = 0
d = 5
for j in range(1,n[i]+1):
while d <= n[i]:
c += (n[i]//d)
d *= 5
print(c)
|
s802308975
|
p03360
|
u636311816
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 113 |
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
|
a,b,c = map(int,input().split())
k =int(input())
M = max([a,b,c])
print(M)
M2 = M * pow(2,k)
print(a+b+c+M2-M)
|
s385808823
|
Accepted
| 17 | 2,940 | 116 |
a,b,c = map(int,input().split())
k =int(input())
M = max([a,b,c])
# print(M)
M2 = M * pow(2,k)
print(a+b+c+M2-M)
|
s856440750
|
p02843
|
u383025592
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,064 | 217 |
AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible. (Ignore consumption tax.)
|
X = int(input())
x = X % 100
A, a = x // 5, x % 5
B, b = a // 4, a % 4
C, c = b // 3, b % 3
D, d = c // 2, c % 2
E = d % 2
print(X,x,A,B,C,D,E)
if(X - X % 100 >= 100 * (A + B + C + D + E)):
print(1)
else:
print(0)
|
s258332084
|
Accepted
| 17 | 3,060 | 196 |
X = int(input())
x = X % 100
A, a = x // 5, x % 5
B, b = a // 4, a % 4
C, c = b // 3, b % 3
D, d = c // 2, c % 2
E = d % 2
if(X - X % 100 >= 100 * (A + B + C + D + E)):
print(1)
else:
print(0)
|
s616145073
|
p03150
|
u018984506
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,064 | 320 |
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
|
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
s=input()
key = "keyence"
for i in range(len(s)):
j = i + len(s) -7
print(s[:i] + s[j:])
if s[:i] + s[j:] == key:
print("Yes")
exit()
print("No")
|
s151773616
|
Accepted
| 17 | 3,064 | 295 |
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
s=input()
key = "keyence"
for i in range(len(s)):
j = i + len(s) -7
if s[:i] + s[j:] == key:
print("YES")
exit()
print("NO")
|
s285342979
|
p03624
|
u617225232
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,188 | 140 |
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
|
s = input()
temp = 'abcdefghijklmnopqrstuvwxyz'
for i in range(26):
if s.find(temp[i])>-1:
print(temp[i])
break
print('None')
|
s355524473
|
Accepted
| 17 | 3,188 | 150 |
s = input()
temp = 'abcdefghijklmnopqrstuvwxyz'
for i in range(26):
if s.find(temp[i]) == -1:
print(temp[i])
exit()
print('None')
|
s456383760
|
p04029
|
u159335277
| 2,000 | 262,144 |
Wrong Answer
| 28 | 8,944 | 60 |
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?
|
print(''.join(map(lambda x: x[0], input().split())).upper())
|
s016668249
|
Accepted
| 28 | 8,912 | 38 |
print(sum(range(1, int(input()) + 1)))
|
s126279913
|
p02612
|
u054717609
| 2,000 | 1,048,576 |
Wrong Answer
| 30 | 9,144 | 64 |
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())
d=n/1000
x=round(d,0)
c=(x*1000)-n
print(c)
|
s986267762
|
Accepted
| 28 | 9,152 | 83 |
import math
n=int(input())
d=n/1000
x=math.ceil(d)
c=int((x*1000)-n)
print(c)
|
s923351447
|
p03636
|
u170077602
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 178 |
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
row = input().split()
s = list(row[0])
num = len(s) - 2
ans = []
ans.append(s[0])
ans.append(num)
ans.append(s[len(s)-1])
ans = list(map(str, ans))
print(ans)
print("".join(ans))
|
s536518083
|
Accepted
| 18 | 3,060 | 167 |
row = input().split()
s = list(row[0])
num = len(s) - 2
ans = []
ans.append(s[0])
ans.append(num)
ans.append(s[len(s)-1])
ans = list(map(str, ans))
print("".join(ans))
|
s571901368
|
p03853
|
u277802731
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 82 |
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
|
#49b
h,w =map(int,input().split())
for _ in range(h):
l = input()
print(l)
|
s161901048
|
Accepted
| 18 | 3,060 | 94 |
#49b
h,w =map(int,input().split())
for _ in range(h):
l =input()
print(l)
print(l)
|
s041484244
|
p03129
|
u629350026
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 9,116 | 96 |
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
|
n,k=map(int,input().split())
import math
if k>math.ceil(n/2):
print("YES")
else:
print("NO")
|
s873359021
|
Accepted
| 26 | 9,048 | 97 |
n,k=map(int,input().split())
import math
if k<=math.ceil(n/2):
print("YES")
else:
print("NO")
|
s651998007
|
p03334
|
u327466606
| 2,000 | 1,048,576 |
Wrong Answer
| 781 | 35,272 | 548 |
Takahashi is doing a research on sets of points in a plane. Takahashi thinks a set S of points in a coordinate plane is a _good set_ when S satisfies both of the following conditions: * The distance between any two points in S is not \sqrt{D_1}. * The distance between any two points in S is not \sqrt{D_2}. Here, D_1 and D_2 are positive integer constants that Takahashi specified. Let X be a set of points (i,j) on a coordinate plane where i and j are integers and satisfy 0 ≤ i,j < 2N. Takahashi has proved that, for any choice of D_1 and D_2, there exists a way to choose N^2 points from X so that the chosen points form a good set. However, he does not know the specific way to choose such points to form a good set. Find a subset of X whose size is N^2 that forms a good set.
|
from math import sqrt
N0,D1,D2 = map(int,input().split())
N = 2*N0
banned = set()
for d in [D1,D2]:
for x in range(0, int(sqrt(d/2)+1)):
y = sqrt(d-x*x)
if y == int(y):
y = int(y)
banned.add((x,y))
banned.add((y,x))
grid = [[True for _ in range(N*2)] for _ in range(N*2)]
points = []
for y in range(N):
g = grid[y]
for x in range(N):
if g[x]:
points.append((x,y))
for dx,dy in banned:
if x+dx < N and y+dy < N:
grid[y+dy][x+dx] = False
for x,y in points[:N0**2]:
print(x,y)
|
s806174465
|
Accepted
| 368 | 4,280 | 336 |
def judge(D):
n = 0
while D%4==0:
n += 1
D //= 4
return (lambda x,y: ~((x>>n)^(y>>n))&1) if D%2==1 else (lambda x,y: ~(x>>n)&1)
N,D1,D2 = map(int,input().split())
j1,j2 = judge(D1),judge(D2)
for _,(x,y) in zip(range(N*N),filter(lambda p: j1(*p) and j2(*p), ((x,y) for x in range(N*2) for y in range(N*2)))):
print(x,y)
|
s915566844
|
p03543
|
u557171945
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 143 |
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
|
a = int(input())
b = int(a / 10)
c = a % 1000
func = lambda x: (x % 111 == 0)
if func(b) or func(c):
print("YES")
else:
print("NO")
|
s687590327
|
Accepted
| 18 | 2,940 | 143 |
a = int(input())
b = int(a / 10)
c = a % 1000
func = lambda x: (x % 111 == 0)
if func(b) or func(c):
print("Yes")
else:
print("No")
|
s991788496
|
p02612
|
u241577413
| 2,000 | 1,048,576 |
Wrong Answer
| 30 | 9,148 | 50 |
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.
|
val = int(input())
k = val//1000
print(val-k*1000)
|
s864941242
|
Accepted
| 26 | 9,156 | 104 |
val = int(input())
k = val//1000
l = val % 1000
if l ==0:
print('0')
else:
print((k+1)*1000-val)
|
s037943258
|
p03370
|
u957275485
| 2,000 | 262,144 |
Wrong Answer
| 44 | 9,036 | 171 |
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
|
N,X = map(int,input().split())
mi=[int(input()) for _ in range(N)]
mmin=min(mi)
amari = X-sum(mi)
omake =0
while amari-mmin >0:
omake+=1
amari -=mmin
print(X+omake)
|
s160104779
|
Accepted
| 27 | 9,164 | 99 |
N,X = map(int,input().split())
mi=[int(input()) for _ in range(N)]
print(N+(X-sum(mi))//min(mi))
|
s503139917
|
p03997
|
u767438459
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 102 |
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.
|
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())
h = int(input())
men = a * b * h
print(men)
|
s005186385
|
Accepted
| 17 | 2,940 | 108 |
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())
h = int(input())
men = (a + b) * h // 2
print(men)
|
s913032406
|
p03434
|
u309120194
| 2,000 | 262,144 |
Wrong Answer
| 25 | 9,148 | 46 |
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
N = int(input())
a = map(int, input().split())
|
s810753760
|
Accepted
| 31 | 9,080 | 268 |
N = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
A = 0
B = 0
for i in range(N):
if i % 2 == 0: A += a[i]
else: B += a[i]
print(A-B)
|
s512356288
|
p02612
|
u556163371
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,152 | 53 |
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.
|
import math
N=int(input())
print(math.ceil(N/1000))
|
s725384731
|
Accepted
| 25 | 9,092 | 60 |
import math
N=int(input())
print(math.ceil(N/1000)*1000-N)
|
s486253150
|
p03598
|
u357751375
| 2,000 | 262,144 |
Wrong Answer
| 27 | 9,180 | 166 |
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N. When activated, each type of robot will operate as follows. * When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. * When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.
|
n = int(input())
k = int(input())
x = list(map(int,input().split()))
ans = 0
for i in range(n):
a = x[i] * 2
b = (x[i] - k) * 2
ans += min(a,b)
print(ans)
|
s921007386
|
Accepted
| 27 | 9,092 | 166 |
n = int(input())
k = int(input())
x = list(map(int,input().split()))
ans = 0
for i in range(n):
a = x[i] * 2
b = (k - x[i]) * 2
ans += min(a,b)
print(ans)
|
s785644508
|
p02615
|
u266014018
| 2,000 | 1,048,576 |
Wrong Answer
| 130 | 31,440 | 307 |
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?
|
def main():
import sys
def input(): return sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)[::-1]
if n %2== 0:
print(a[0]+sum(a[1:n//2]))
else:
print(a[0]+sum(a[1:n//2+1])*2)
if __name__ == '__main__':
main()
|
s921302031
|
Accepted
| 112 | 31,400 | 316 |
def main():
import sys
def input(): return sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
if n %2== 0:
print(a[0]+sum(a[1:n//2])*2)
else:
print(a[0]+sum(a[1:n//2])*2+a[n//2])
if __name__ == '__main__':
main()
|
s482171456
|
p03854
|
u169138653
| 2,000 | 262,144 |
Wrong Answer
| 94 | 9,800 | 513 |
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()
n=len(s)
dp=[False]*(n+1)
dp[1]=True
c=["dream","dreamer","erase","eraser"]
for i in range(n+1):
if dp[i]:
l=""
if i+5<=n:
for idx in range(5):
l+=s[i+idx-1]
if l in c:
dp[i+5]=True
if i+6<=n:
l+=s[i+4]
if l in c:
dp[i+6]=True
if i+7<=n:
l+=s[i+5]
if l in c:
dp[i+7]=True
#print(dp)
if dp[n]:
print("YES")
else:
print("NO")
|
s952504409
|
Accepted
| 88 | 9,736 | 590 |
s=input()
n=len(s)
dp=[False]*(n+1)
c=["dream","dreamer","erase","eraser"]
if s[:5] in c:
dp[5]=True
if s[:6] in c:
dp[6]=True
if s[:7] in c:
dp[7]=True
for i in range(n+1):
if dp[i]:
l=""
if i+5<=n:
for idx in range(5):
l+=s[i+idx]
if l in c:
dp[i+5]=True
if i+6<=n:
l+=s[i+5]
if l in c:
dp[i+6]=True
if i+7<=n:
l+=s[i+6]
if l in c:
dp[i+7]=True
#print(dp)
if dp[n]:
print("YES")
else:
print("NO")
|
s513487008
|
p02742
|
u490489966
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,064 | 296 |
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:
|
#B
import math
h,w=map(int,input().split())
if h==w==1:
print(0)
elif h%2==0 and w%2==0:
print(h*w/2)
elif h%2==0 and w%2!=0:
print(h*(w-1)/2+math.floor(h/2))
elif h%2!=0 and w%2==0:
print(w*(h-1)/2+math.floor(w/2))
else:
print((w-1)*(h-1)/2+math.floor(h/2)+math.floor(w/2)+1)
|
s812838541
|
Accepted
| 18 | 3,064 | 321 |
#B
import math
h,w=map(int,input().split())
if h==1 or w==1:
print(1)
elif h%2==0 and w%2==0:
print(int(h*w/2))
elif h%2==0 and w%2!=0:
print(int(h*(w-1)/2+math.floor(h/2)))
elif h%2!=0 and w%2==0:
print(int(w*(h-1)/2+math.floor(w/2)))
else:
print(int((w-1)*(h-1)/2+math.floor(h/2)+math.floor(w/2)+1))
|
s663626956
|
p03563
|
u569742427
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 48 |
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
|
R=float(input())
G=float(input())
print(G*2-R)
|
s346758277
|
Accepted
| 17 | 2,940 | 44 |
R=int(input())
G=int(input())
print(G*2-R)
|
s065623153
|
p03167
|
u279670936
| 2,000 | 1,048,576 |
Wrong Answer
| 2,114 | 166,176 | 686 |
There is a grid 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. For each i and j (1 \leq i \leq H, 1 \leq j \leq W), Square (i, j) is described by a character a_{i, j}. If a_{i, j} is `.`, Square (i, j) is an empty square; if a_{i, j} is `#`, Square (i, j) is a wall square. It is guaranteed that Squares (1, 1) and (H, W) are empty squares. Taro will start from Square (1, 1) and reach (H, W) by repeatedly moving right or down to an adjacent empty square. Find the number of Taro's paths from Square (1, 1) to (H, W). As the answer can be extremely large, find the count modulo 10^9 + 7.
|
R, C = tuple(map(int, input().split()))
grid = [list(input()) for _ in range(R)]
dp = [[0 for _ in range(C)] for _ in range(R)]
for row in range(R):
if grid[row][0] != '#':
dp[row][0] = 1
else:
break
for col in range(C):
if grid[0][col] != '#':
dp[0][col] = 1
else:
break
def simplify(paths, MAX=10**9+7):
while paths > MAX:
paths -= MAX
return paths
def gridpaths(R, C, grid):
for row in range(1, R):
for col in range(1, C):
if grid[row][col] != '#':
dp[row][col] = dp[row-1][col] + dp[row][col-1]
#print(dp)
return simplify(dp[-1][-1])
gridpaths(R, C, grid)
|
s711388595
|
Accepted
| 488 | 52,440 | 614 |
R, C = tuple(map(int, input().split()))
grid = [list(input()) for _ in range(R)]
dp = [[0 for _ in range(C)] for _ in range(R)]
for row in range(R):
if grid[row][0] != '#':
dp[row][0] = 1
else:
break
for col in range(C):
if grid[0][col] != '#':
dp[0][col] = 1
else:
break
def gridpaths(R, C, grid, MAX=10 ** 9 + 7):
for row in range(1, R):
for col in range(1, C):
if grid[row][col] != '#':
dp[row][col] = (dp[row - 1][col] + dp[row][col - 1])%MAX
# print(dp)
return dp[-1][-1]
print(gridpaths(R, C, grid))
|
s407941846
|
p03486
|
u591287669
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 86 |
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
s=''.join(reversed(input()))
t=input()
if s<t:
print('Yes')
else:
print('No')
|
s599455177
|
Accepted
| 17 | 2,940 | 141 |
s=''.join(sorted(list(input()),reverse=False))
t=''.join(sorted(list(input()),reverse=True))
if s<t:
print("Yes")
else:
print("No")
|
s457535246
|
p03816
|
u037430802
| 2,000 | 262,144 |
Wrong Answer
| 45 | 14,564 | 73 |
Snuke has decided to play a game using cards. He has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written. He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept. Operation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.
|
n = int(input())
a = list(map(int, input().split()))
print(len(set(a)))
|
s620563603
|
Accepted
| 68 | 21,084 | 211 |
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
cnt = 0
for v in c.values():
cnt += v-1
ans = len(set(A))
if cnt % 2 != 0:
ans -= 1
print(ans)
|
s094813457
|
p02613
|
u634965946
| 2,000 | 1,048,576 |
Wrong Answer
| 30 | 9,232 | 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=list(map(str, input().split()))
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in S:
if i == "AC":
c0 += 1
if i == "WA":
c0 += 1
if i == "TLE":
c0 += 1
if i == "RE":
c0 += 1
print("AC x " + str(c0))
print("WA x " + str(c1))
print("TLE x " + str(c2))
print("RE x " + str(c3))
|
s213366085
|
Accepted
| 158 | 16,336 | 342 |
N = int(input())
S = list()
for i in range(N):
S.append(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in S:
if i == "AC":
c0 += 1
if i == "WA":
c1 += 1
if i == "TLE":
c2 += 1
if i == "RE":
c3 += 1
print("AC x " + str(c0))
print("WA x " + str(c1))
print("TLE x " + str(c2))
print("RE x " + str(c3))
|
s742923546
|
p03408
|
u197300260
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 802 |
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
|
# _*_ coding:utf-8 _*_
# Dummy WA
def solveProblem(wordDic,blueCards,redCards):
print("wordDic:{}".format(wordDic))
print("blueCards:{}".format(blueCards))
print("redCards:{}".format(redCards))
answer = wordDic
return answer
if __name__ == '__main__':
N = int(input().strip())
wordDic = []
blueCards = []
blueCardRange = range(0,N,+1)
for _ in blueCardRange:
eachWord = str(input().strip())
blueCards.append(eachWord)
if eachWord not in wordDic:
wordDic.append(eachWord)
M = int(input().strip())
redCardRange = range(0,M,+1)
redCards = []
for _ in redCardRange:
redCards.append(str(input().strip()))
solution = solveProblem(wordDic,blueCards,redCards)
print("{}".format(solution))
|
s338829615
|
Accepted
| 34 | 9,420 | 1,118 |
# Python 3rd Try
import sys
from collections import defaultdict
# import pprint
# import heapq,copy
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def solver(blue_count, blue_list, red_count, red_list):
result = 0
allDict = defaultdict(int)
for j in range(0, blue_count, +1):
allDict[blue_list[j]] += 1
for j in range(0, red_count, +1):
allDict[red_list[j]] -= 1
# algorithm
# print("{}".format(allDict))
dictList = list(allDict.values()) + [0]
dictList.sort(reverse=True)
# pprint.pprint("{}".format(dictList))
result = dictList[0]
return result
if __name__ == "__main__":
N = II()
si = []
for _ in range(0, N, +1):
si.append(input())
M = II()
ti = []
for _ in range(0, M, 1):
ti.append(input())
print("{}".format(solver(N, si, M, ti)))
|
s645874816
|
p04012
|
u642528832
| 2,000 | 262,144 |
Wrong Answer
| 29 | 8,992 | 76 |
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
|
w = input()
if len(w)/len(set(w))==2:
print('Yes')
else:
print('No')
|
s644683567
|
Accepted
| 28 | 8,996 | 137 |
w = input()
for i in range(len(w)):
if w.count(w[i])%2==0:
continue
else:
print('No')
exit()
print('Yes')
|
s746121413
|
p03160
|
u664762434
| 2,000 | 1,048,576 |
Wrong Answer
| 155 | 14,676 | 225 |
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())
a = list(map(int,input().split()))
ans = []
ans.append(0)
ans.append(abs(a[1]-a[0]))
i = 2
while i<N:
x = ans[i-2]+abs(a[i]-a[i-2])
y = ans[i-1]+abs(a[i]-a[i-1])
ans.append(min(x,y))
i += 1
print(ans)
|
s381066321
|
Accepted
| 145 | 13,928 | 230 |
N = int(input())
a = list(map(int,input().split()))
ans = []
ans.append(0)
ans.append(abs(a[1]-a[0]))
i = 2
while i<N:
x = ans[i-2]+abs(a[i]-a[i-2])
y = ans[i-1]+abs(a[i]-a[i-1])
ans.append(min(x,y))
i += 1
print(ans[N-1])
|
s227201488
|
p03055
|
u201234972
| 2,000 | 1,048,576 |
Wrong Answer
| 2,105 | 55,088 | 737 |
Takahashi and Aoki will play a game on a tree. The tree has N vertices numbered 1 to N, and the i-th of the N-1 edges connects Vertex a_i and Vertex b_i. At the beginning of the game, each vertex contains a coin. Starting from Takahashi, he and Aoki will alternately perform the following operation: * Choose a vertex v that contains one or more coins, and remove all the coins from v. * Then, move each coin remaining on the tree to the vertex that is nearest to v among the adjacent vertices of the coin's current vertex. The player who becomes unable to play, loses the game. That is, the player who takes his turn when there is no coin remaining on the tree, loses the game. Determine the winner of the game when both players play optimally.
|
def diameter(N, E):#diamete of a tree
V = [-1]*N
V[0] = 0
q = [0]
while q:
v = q.pop(0)
ev = V[v]
for w in E[v]:
if V[w] == -1:
V[w] = ev + 1
q.append(w)
s = V.index( max(V))
p = [s]
W = [-1]*N
W[s] = 0
while p:
v = p.pop(0)
ev = W[v]
for w in E[v]:
if W[w] == -1:
W[w] = ev + 1
p.append(w)
return max(W)
N = int( input())
E = [ [] for _ in range(N)]
for _ in range(N-1):
a, b = map( int, input().split())
a, b = a-1, b-1
E[a].append(b)
E[b].append(a)
ans = "First"
print( diameter(N,E))
if diameter(N, E)%3 == 1:
ans = "Second"
print( ans)
|
s208679392
|
Accepted
| 1,236 | 55,464 | 737 |
def diameter(N, E):#diamete of a tree
from collections import deque
V = [-1]*N
V[0] = 0
q = deque([0])
while q:
v = q.popleft()
for w in E[v]:
if V[w] == -1:
V[w] = V[v] + 1
q.append(w)
s = V.index( max(V))
p = deque([s])
W = [-1]*N
W[s] = 0
while p:
v = p.popleft()
for w in E[v]:
if W[w] == -1:
W[w] = W[v] + 1
p.append(w)
return max(W)
N = int( input())
E = [ [] for _ in range(N)]
for _ in range(N-1):
a, b = map( int, input().split())
a, b = a-1, b-1
E[a].append(b)
E[b].append(a)
ans = "First"
if diameter(N, E)%3 == 1:
ans = "Second"
print( ans)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.