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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s754878133 | p03593 | u677121387 | 2,000 | 262,144 | Wrong Answer | 34 | 9,096 | 532 | 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. | h,w = map(int,input().split())
a = [input() for _ in range(h)]
alpha = [0]*26
for i in range(h):
for j in range(w):
alpha[ord(a[i][j])-ord("a")] += 1
ans = "Yes"
odd = 0
cnt = 0
for i in range(26):
if alpha[i]%2 != 0:
odd += 1
alpha[i] -= 1
if alpha[i]%4 != 0: cnt += 1
if odd > 1: ans = "No"
elif h%2 == 1 and w%2 == 1:
if cnt > h//2+w//2: ans = "No"
elif h%2 == 1:
if cnt > h//2: ans = "No"
elif w%2 == 1:
if cnt > w//2: ans = "No"
else:
if cnt > 0: ans = "No"
print(ans) | s224478226 | Accepted | 32 | 9,128 | 527 | h,w = map(int,input().split())
a = [input() for _ in range(h)]
alpha = [0]*26
for i in range(h):
for j in range(w):
alpha[ord(a[i][j])-ord("a")] += 1
ans = "Yes"
odd = 0
cnt = 0
for i in range(26):
if alpha[i]%2 != 0:
odd += 1
alpha[i] -= 1
if alpha[i]%4 != 0: cnt += 1
if odd > 1: ans = "No"
elif h%2 == 1 and w%2 == 1:
if cnt > h//2+w//2: ans = "No"
elif h%2 == 1:
if cnt > w//2: ans = "No"
elif w%2 == 1:
if cnt > h/2: ans = "No"
else:
if cnt > 0: ans = "No"
print(ans) |
s337772292 | p03386 | u475598608 | 2,000 | 262,144 | Wrong Answer | 2,192 | 1,476,644 | 154 | Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers. | A,B,K=map(int,input().split())
L=list(i for i in range(A,B+1))
print(L)
for i in range(B-A+1):
if L[i] in L[:K] or L[i] in L[-K:]:
print(L[i]) | s590006964 | Accepted | 17 | 3,060 | 175 | a,b,k=map(int,input().split())
r1=[i for i in range(a,min(b+1,a+k))]
r2=[i for i in range(max(a,b-k+1),b+1)]
r1.extend(r2)
result=set(r1)
for i in sorted(result):
print(i) |
s179465928 | p03644 | u934740772 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 117 | 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())
cnt=1
a=2
while a<=N:
a*=2
if a<=N:
cnt+=1
if N==1:
print(0)
else:
print(cnt)
| s957349543 | Accepted | 17 | 2,940 | 120 | N=int(input())
cnt=1
a=2
while a<=N:
a*=2
if a<=N:
cnt+=1
if N==1:
print(1)
else:
print(2**cnt)
|
s969449766 | p02612 | u376420711 | 2,000 | 1,048,576 | Wrong Answer | 26 | 9,016 | 26 | We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. | print(int(input()) % 1000) | s265694947 | Accepted | 27 | 9,100 | 28 | print(-int(input()) % 1000)
|
s437772855 | p03852 | u193264896 | 2,000 | 262,144 | Wrong Answer | 24 | 9,128 | 308 | Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
def main():
C = input()
if C in ['a', 'i', 'u', 'e', 'o']:
print('vouel')
else:
print('consonant')
if __name__ == '__main__':
main()
| s925830460 | Accepted | 27 | 8,892 | 308 | import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
def main():
C = input()
if C in ['a', 'i', 'u', 'e', 'o']:
print('vowel')
else:
print('consonant')
if __name__ == '__main__':
main()
|
s851869840 | p03024 | u785213188 | 2,000 | 1,048,576 | Wrong Answer | 27 | 8,948 | 128 | Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility. | S = input()
xCount = 0
for s in S:
if s == "x":
xCount += 1
if xCount >= 8:
print("No")
else:
print("Yes") | s513940177 | Accepted | 27 | 9,084 | 128 | S = input()
xCount = 0
for s in S:
if s == "x":
xCount += 1
if xCount >= 8:
print("NO")
else:
print("YES") |
s826791754 | p03371 | u516272298 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 341 | "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())
d = a*x + b*y
e = 0
f = 0
g = 0
h = 0
if x > y and y % 2 == 0:
e = c*2*y + a*(x-y)
elif x > y and y % 2 != 0:
f = c*2*(y-1) + b + a*(x-y+1)
elif x < y and x % 2 == 0:
g = c*2*x + b*(y-x)
elif x < y and x % 2 != 0:
h = c*2*(x-1) + a + b*(y-x+1)
l = [d,e,f,g,h]
print(sorted(l)[3])
print(l) | s947819947 | Accepted | 18 | 3,060 | 132 | a,b,c,x,y = map(int,input().split())
d = 2*c*min(x,y) + a*max(0,x-y) + b*max(0,y-x)
e = 2*c*max(x,y)
f = a*x + b*y
print(min(d,e,f)) |
s019846252 | p03997 | u357630630 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 71 | You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid. | a, b, h = map(int, [input() for i in range(3)])
print((a + b) * h / 2)
| s627278072 | Accepted | 17 | 2,940 | 76 | a, b, h = map(int, [input() for i in range(3)])
print(int((a + b) * h / 2))
|
s697676882 | p04044 | u089032001 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 104 | Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m. | n, l = map(int, input().split())
ans = "z" * 100
for _ in range(n):
ans = min(ans, input())
print(ans) | s612518385 | Accepted | 18 | 3,060 | 91 | n, l = map(int, input().split())
A = [input() for _ in range(n)]
A.sort()
print("".join(A)) |
s767402778 | p03067 | u225463683 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 121 | There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise. | a, b, c = input().split(" ")
if a > b and b > c:
print("Yes")
elif c > b and b > a:
print("Yes")
else:
print("No") | s472886737 | Accepted | 19 | 3,316 | 139 | a, b, c = [int(x) for x in input().split(" ")]
if a > c and c > b:
print("Yes")
elif b > c and c > a:
print("Yes")
else:
print("No") |
s228445909 | p02401 | u099155265 | 1,000 | 131,072 | Wrong Answer | 20 | 7,448 | 91 | Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part. | while True:
a = input()
if '?' in a:
break
print("{0}".format(eval(a))) | s652222236 | Accepted | 30 | 7,344 | 110 | while True:
a = input()
if '?' in a:
break
print("{0}".format(eval(a.replace('/', '//')))) |
s530076242 | p03415 | u910369451 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 152 | We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right. | A,B,C = [input() for i in range(3)]
a = [A[:1], A[1:2], A[2:]]
b = [B[:1], B[1:2], B[2:]]
c = [C[:1], C[1:2], C[2:]]
print(a.pop(0), b.pop(1), c.pop(2)) | s147220035 | Accepted | 17 | 3,060 | 154 | A,B,C = [input() for i in range(3)]
a = [A[:1], A[1:2], A[2:]]
b = [B[:1], B[1:2], B[2:]]
c = [C[:1], C[1:2], C[2:]]
print(a.pop(0) + b.pop(1) + c.pop(2)) |
s062422103 | p03044 | u540761833 | 2,000 | 1,048,576 | Wrong Answer | 80 | 3,824 | 46 | We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices painted in the same color, the distance between them is an even number. Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem. | N = int(input())
for i in range(N):
print(0) | s886559133 | Accepted | 884 | 42,448 | 565 | from collections import deque
N = int(input())
uvw = [[]for i in range(N)]
for i in range(N-1):
u,v,w = list(map(int,input().split()))
uvw[u-1].append([v-1,w%2])
uvw[v-1].append([u-1,w%2])
color = [-1 for i in range(N)]
color[0] = 0
que = deque()
que.append(0)
while que:
q = que.popleft()
colorq = color[q]
for i in uvw[q]:
if color[i[0]] == -1:
que.append(i[0])
if i[1] == 0:
color[i[0]] = colorq
else:
color[i[0]] = abs(colorq-1)
for i in color:
print(i) |
s093530514 | p03610 | u729535891 | 2,000 | 262,144 | Wrong Answer | 73 | 4,192 | 128 | 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()
s = []
for i in range(len(S)):
if (i + 1) % 2 == 1:
s.append(S[i])
print(i)
print(('').join(s)) | s885904214 | Accepted | 37 | 3,572 | 111 | S = input()
s = []
for i in range(len(S)):
if (i + 1) % 2 == 1:
s.append(S[i])
print(('').join(s)) |
s662220606 | p03645 | u815878613 | 2,000 | 262,144 | Wrong Answer | 165 | 49,864 | 439 | 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. | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
def main():
N, M = map(int, readline().split())
m = map(int, read().split())
AB = list(zip(m, m))
p1 = []
p2 = []
for a, b in AB:
if a == 1:
p1.append(b)
if b == N:
p2.append(a)
if len(list(set(p1) & set(p2))) >= 1:
print('POSSIVLE')
else:
print('IMPOSSIVLE')
main()
| s888790466 | Accepted | 171 | 49,864 | 439 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
def main():
N, M = map(int, readline().split())
m = map(int, read().split())
AB = list(zip(m, m))
p1 = []
p2 = []
for a, b in AB:
if a == 1:
p1.append(b)
if b == N:
p2.append(a)
if len(list(set(p1) & set(p2))) >= 1:
print('POSSIBLE')
else:
print('IMPOSSIBLE')
main()
|
s061593132 | p03435 | u015467545 | 2,000 | 262,144 | Wrong Answer | 19 | 3,064 | 525 | We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct. | c=[[0 for i in range(3)] for j in range(3)]
a=[0]*3
b=[0]*3
for i in range(3):
c[i]=list(map(int,input().split()))
for i in range(-500,500):
a[0]=i
b[0]=c[0][0]-a[0]
b[1]=c[0][1]-a[0]
b[2]=c[0][2]-a[0]
a[1]=c[1][0]-b[0]
a[2]=c[2][0]-b[0]
if c[1][1]==a[1]+b[1] and c[1][2]==a[1]+b[2] and c[2][1]==a[2]+b[1] and (c[2][2]==a[2]+b[2]):
print("Yes")
print(a,b)
break
if c[1][1]!=a[1]+b[1] or c[1][2]!=a[1]+b[2] or c[2][1]!=a[2]+b[1] or (c[2][2]!=a[2]+b[2]):
if i==499:
print("No") | s491260772 | Accepted | 19 | 3,064 | 514 | c=[[0 for i in range(3)] for j in range(3)]
a=[0]*3
b=[0]*3
for i in range(3):
c[i]=list(map(int,input().split()))
for i in range(-500,500):
a[0]=i
b[0]=c[0][0]-a[0]
b[1]=c[0][1]-a[0]
b[2]=c[0][2]-a[0]
a[1]=c[1][0]-b[0]
a[2]=c[2][0]-b[0]
if c[1][1]==a[1]+b[1] and c[1][2]==a[1]+b[2] and c[2][1]==a[2]+b[1] and (c[2][2]==a[2]+b[2]):
print("Yes")
break
if c[1][1]!=a[1]+b[1] or c[1][2]!=a[1]+b[2] or c[2][1]!=a[2]+b[1] or (c[2][2]!=a[2]+b[2]):
if i==499:
print("No") |
s995351046 | p03501 | u066455063 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 85 | You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours. | N, A, B = map(int, input().split())
if N * A >= B:
print(B)
else:
print(A)
| s578470335 | Accepted | 17 | 2,940 | 56 | N, A, B = map(int, input().split())
print(min(A*N, B))
|
s994181374 | p02742 | u922769680 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 94 | We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move: | H,W=map(int,input().split())
if H%2==1 and W%2==1:
print((H*W+1)/2)
else:
print(H*W/2) | s494284721 | Accepted | 18 | 2,940 | 148 | H,W=map(int,input().split())
if H==1 or W==1:
print(1)
else:
if H%2==1 and W%2==1:
print((H*W)//2+1)
else:
print(H*W//2) |
s590057924 | p03069 | u095426154 | 2,000 | 1,048,576 | Wrong Answer | 2,104 | 140,160 | 187 | 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=list(input())
ans=10**10
for i in range(n):
cost_w=s[:i+1].count("#")
cost_b=s[i+1:].count(".")
print(s[:i+1],s[i:])
ans=min(ans,cost_w+cost_b)
print(ans) | s638831319 | Accepted | 107 | 12,740 | 240 | n=int(input())
s=list(input())
INF=10**10
cost_w=0
cost_b=s.count(".")
ans=[INF for i in range(n+1)]
ans[0]=cost_b
for i in range(n):
if s[i]=="#":
cost_w+=1
else:
cost_b-=1
ans[i+1]=cost_w+cost_b
print(min(ans)) |
s965117052 | p03644 | u433380437 | 2,000 | 262,144 | Wrong Answer | 26 | 9,020 | 108 | 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())
A=[]
a=0
i=0
while a*2 <= n:
a = 2**i
print(i)
A.append(a)
i=i+1
print(A[-1]) | s103671941 | Accepted | 30 | 9,152 | 95 | n=int(input())
A=[]
a=0
i=0
while a*2 <= n:
a = 2**i
A.append(a)
i=i+1
print(A[-1]) |
s373402554 | p03636 | u840234291 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 41 | The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way. | s = input()
print(s[0]+str(len(s))+s[-1]) | s121452399 | Accepted | 18 | 2,940 | 49 | s = input()
print(s[0] + str(len(s) - 2) + s[-1]) |
s227098874 | p04030 | u767545760 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 295 | Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now? | s = input()
string = []
for i in range(len(s)):
print(s[i])
if s[i] == '0':
string.append(str(s[i]))
elif s[i] == '1':
string.append(str(s[i]))
else:
if len(string) == 0:
continue
else:
string.pop(-1)
print("".join(string)) | s015330696 | Accepted | 17 | 3,060 | 279 | s = input()
string = []
for i in range(len(s)):
if s[i] == '0':
string.append(str(s[i]))
elif s[i] == '1':
string.append(str(s[i]))
else:
if len(string) == 0:
continue
else:
string.pop(-1)
print("".join(string)) |
s356969605 | p02397 | u921038488 | 1,000 | 131,072 | Wrong Answer | 40 | 6,020 | 233 | Write a program which reads two integers x and y, and prints them in ascending order. | l = []
while True:
N, M = map(int, input().split())
if (N == 0 and M == 0):
break;
if (N > M):
l.append([M, N])
elif (N < M):
l.append([N, M])
for i in l:
print("{} {}".format(i[0], i[1])) | s732944232 | Accepted | 40 | 6,016 | 206 | l = []
while True:
N, M = map(int, input().split())
if (N == 0 and M == 0):
break;
if (N > M):
N, M = M, N
l.append([N, M])
for i in l:
print("{} {}".format(i[0], i[1])) |
s352984262 | p02257 | u002280517 | 1,000 | 131,072 | Wrong Answer | 20 | 5,592 | 309 | A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. Write a program which reads a list of _N_ integers and prints the number of prime numbers in the list. | N = int(input())
a = []
for i in range(N):
a.append(int(input()))
count = 0
Sosu = True
for i in range(N):
for j in range(2,i):
if i % j == 0:
Sosu = False
break
else :
pass
if Sosu :
count+=1
else:
pass
print(count)
| s537269736 | Accepted | 80 | 5,612 | 214 | N = int(input())
a = []
count = 0
for i in range(N):
x=int(input())
if x == 2:
count+=1
else:
if pow(2, x-1,x ) == 1:
count+=1
else:
pass
print(count)
|
s885542285 | p03415 | u096359533 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 42 | We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right. | for i in range(3):
print(input()[i:i+1]) | s644444816 | Accepted | 18 | 2,940 | 71 | output = ''
for i in range(3):
output += input()[i:i+1]
print(output) |
s363816442 | p03407 | u352811222 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 87 | An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan. | A,B,C=list(map(int,input().split()))
if A+B>=C:
print("YES")
else:
print("NO")
| s741807378 | Accepted | 17 | 2,940 | 87 | A,B,C=list(map(int,input().split()))
if A+B>=C:
print("Yes")
else:
print("No")
|
s933606152 | p03635 | u716649090 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 46 | In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city? | a, *b, c = input()
print(a, len(b), c, sep="") | s191106377 | Accepted | 17 | 2,940 | 57 | a, b = map(int, input().split())
print((a - 1) * (b - 1)) |
s597318377 | p04031 | u488884575 | 2,000 | 262,144 | Wrong Answer | 20 | 3,188 | 317 | Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective. | N = int(input())
A = list(map(int, input().split(" ")))
if sum(A)%len(A) == 0:
avrA = sum(A)/len(A)
else:
if (sum(A) / len(A)) < (sum(A) // len(A) + 0.5):
avrA = sum(A) // len(A)
else:
avrA = sum(A) // len(A) +1
dst = 0
for i in A:
dst += (i-avrA)**2
print(dst) | s643931372 | Accepted | 17 | 3,064 | 342 | N = int(input())
A = list(map(int, input().split(" ")))
if sum(A)%len(A) == 0:
avrA = sum(A)/len(A)
else:
if (sum(A) / len(A)) < (sum(A) // len(A) + 0.5):
avrA = sum(A) // len(A)
else:
avrA = sum(A) // len(A) +1
dst = 0
for i in A:
dst += (i-avrA)**2
print(int(dst))
|
s082895611 | p03352 | u089376182 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 36 | 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. | print(2**(len(bin(int(input())))-3)) | s964135425 | Accepted | 17 | 2,940 | 187 | x = int(input())
ans = 1
for i in range(2, int(x**(0.5))+1):
j = 2
while True:
k = i**j
if k > x:
break
else:
ans = max(ans, k)
j += 1
print(ans) |
s457420634 | p03545 | u136843617 | 2,000 | 262,144 | Wrong Answer | 28 | 9,132 | 433 | Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted. | S = list(map(int, list(input())))
ans = ""
for bit in range(2**3):
temp = S[0]
for i in range(3):
if bit & (1<<i):
temp +=S[i+1]
else:
temp -= S[i+1]
if temp == 7:
for i in range(4):
ans += str(S[i])
if bit & (1 << i):
ans += "+"
else:
ans += "-"
ans += "=7"
print(ans)
break
| s030614462 | Accepted | 30 | 9,108 | 445 | S = list(map(int, list(input())))
ans = ""
for bit in range(2**3):
temp = S[0]
for i in range(3):
if bit & (1<<i):
temp +=S[i+1]
else:
temp -= S[i+1]
if temp == 7:
for i in range(3):
ans += str(S[i])
if bit & (1 << i):
ans += "+"
else:
ans += "-"
ans += str(S[3]) + "=7"
print(ans)
break
|
s154042601 | p03371 | u906501980 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 157 | "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())
out1 = a * x + a * y
if x > y:
out3 = y*c*2 + (x-y)*a
else:
out3 = x*c*2 + (y-x)*a
print(min([out1, out3])) | s228110462 | Accepted | 17 | 3,060 | 116 | a, b, c, x, y = map(int, input().split())
[m,n],[M,N]= sorted([[x,a],[y,b]])
print(min(a*x+b*y,c*2*M,c*2*m+(M-m)*N)) |
s134605076 | p03455 | u946732206 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 123 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | # -*- coding: utf-8 -*-
a, b = map(int,input().split())
c = int(a * b)
if c % 2 == 0:
print("even")
else:
print("odd") | s650108311 | Accepted | 17 | 2,940 | 128 | # -*- coding: utf-8 -*-
a, b = map(int,input().split())
c = int(a * b)
if c % 2 == 0:
print("Even")
else:
print("Odd") |
s080814420 | p03351 | u475675023 | 2,000 | 1,048,576 | Wrong Answer | 18 | 3,064 | 93 | Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate. | a,b,c,d=map(int,input().split())
print("Yes" if min(abs(a-b)+abs(b-c),abs(a-c))<=d else "No") | s738037814 | Accepted | 17 | 2,940 | 105 | a,b,c,d=map(int,input().split())
print("Yes" if ((abs(a-b)<=d and abs(b-c)<=d) or abs(a-c)<=d) else "No") |
s230948788 | p03469 | u437068347 | 2,000 | 262,144 | Wrong Answer | 90 | 3,700 | 65 | On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it. | from pprint import pprint as pp
s = input()
print("2018/"+s[4:]) | s903715398 | Accepted | 24 | 3,572 | 64 | from pprint import pprint as pp
s = input()
print("2018"+s[4:]) |
s633974051 | p02389 | u640809202 | 1,000 | 131,072 | Wrong Answer | 20 | 5,588 | 79 | Write a program which calculates the area and perimeter of a given rectangle. | l = input().split()
x = int(l[0])
y = int(l[1])
print(x * y)
print(2*x + 2*y)
| s878241285 | Accepted | 20 | 5,580 | 61 | a, b = map(int, input().split())
c=a*b
d=a*2+b*2
print(c, d)
|
s395901563 | p04012 | u634873566 | 2,000 | 262,144 | Wrong Answer | 23 | 3,316 | 119 | 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. | from collections import Counter
s = input()
ans = [False if i%2 else True for i in Counter(s).values()]
print(all(ans)) | s526351980 | Accepted | 21 | 3,316 | 138 | from collections import Counter
s = input()
ans = [False if i%2 else True for i in Counter(s).values()]
print("Yes" if all(ans) else "No") |
s282269029 | p03478 | u218724761 | 2,000 | 262,144 | Wrong Answer | 38 | 3,060 | 163 | Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive). | n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
c = list(map(int, list(str(i))))
c = sum(c)
if a <= c <= b:
ans +=1
print(ans) | s919721208 | Accepted | 37 | 3,064 | 164 | n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
c = list(map(int, list(str(i))))
c = sum(c)
if a <= c <= b:
ans += i
print(ans) |
s569288421 | p02612 | u021217230 | 2,000 | 1,048,576 | Wrong Answer | 27 | 9,084 | 24 | We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. | print(int(input())%1000) | s621968448 | Accepted | 28 | 9,088 | 66 | n=int(input())
if n%1000!=0:
print(1000-n%1000)
else:
print(0) |
s915097860 | p03478 | u686036872 | 2,000 | 262,144 | Wrong Answer | 32 | 2,940 | 132 | Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive). | N, A, B = input().split()
count=0
for i in range(int(N)):
if int(A) <= sum(map(int, N)) <= int(B):
count+=1
print(count) | s959545217 | Accepted | 32 | 3,060 | 149 | N, A, B = map(int, input().split())
count=0
for i in range(int(N)+1):
if int(A) <= sum(map(int, str(i))) <= int(B):
count+=i
print(count) |
s605352795 | p02393 | u957680575 | 1,000 | 131,072 | Wrong Answer | 30 | 7,420 | 53 | Write a program which reads three integers, and prints them in ascending order. | x = list(map(int, input().split()))
x.sort()
print(x) | s577823820 | Accepted | 20 | 7,508 | 54 | x = list(map(int, input().split()))
x.sort()
print(*x) |
s350156244 | p03693 | u580573899 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 6 | AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4? | 598985 | s245005881 | Accepted | 17 | 2,940 | 109 | r,g,b=(int(x) for x in input().split())
num=100*r+10*g+b
if num%4==0:
print("YES")
else:
print("NO") |
s053695049 | p04043 | u746627216 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 178 | 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()))
count = 0
for i in range(3):
if A[i] == 5 or A[i] == 7:
count += 1
if count == 3:
print('Yes')
else:
print('No') | s871869128 | Accepted | 17 | 2,940 | 137 | a = list(map(int,input().split()))
num5 = a.count(5)
num7 = a.count(7)
if(num5 == 2 and num7 == 1):
print("YES")
else:
print("NO") |
s626681290 | p02928 | u917558625 | 2,000 | 1,048,576 | Wrong Answer | 1,017 | 3,188 | 489 | We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}. Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2. Find the inversion number of B, modulo 10^9 + 7. Here the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \leq i < j \leq K \times N - 1) such that B_i > B_j. | s=list(map(int,input().split()))
t=list(map(int,input().split()))
x=0
y=0
z=0
x=s[1]%1000000007
y=(s[1]+1)%1000000007
z=((x*y)/2)%1000000007
p=0
q=0
r=0
p=(s[1]-1)%1000000007
q=s[1]%1000000007
r=((p*q)/2)%1000000007
b=0
for i in range(s[0]):
a=0
for j in range(s[0]):
if t[i]>t[j]:
a=a+1
b=b+a*r
b=b%1000000007
b=b%1000000007
c=0
for v in range(s[0]-1):
a=0
for w in range(v+1,s[0]):
if t[v]>t[w]:
a=a+1
b=b+a*s[1]
b=b%1000000007
b=b%1000000007
print(b) | s749527256 | Accepted | 1,073 | 3,188 | 420 | s=list(map(int,input().split()))
t=list(map(int,input().split()))
if s[0]==1:
print(0)
else:
b=0
for i in range(s[0]):
a=0
for j in range(s[0]):
if t[i]>t[j]:
a=a+1
b=b+a*s[1]*(s[1]-1)//2
b=b%1000000007
b=b%1000000007
for v in range(s[0]-1):
a=0
for w in range(v+1,s[0]):
if t[v]>t[w]:
a=a+1
b=b+a*s[1]
b=b%1000000007
b=b%1000000007
print(int(b)) |
s345350778 | p02843 | u211160392 | 2,000 | 1,048,576 | Wrong Answer | 18 | 3,068 | 95 | 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())
a = X//100
b = X//105
if a*100 <= X <= b*105:
print(1)
else:
print(0) | s098198798 | Accepted | 17 | 2,940 | 84 | X = int(input())
a = X//100
if a*100 <= X <= a*105:
print(1)
else:
print(0) |
s575299268 | p03160 | u427984570 | 2,000 | 1,048,576 | Wrong Answer | 145 | 15,436 | 226 | 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())
l = list(map(int, input().split()))
dp = [0]*n
for i in range(1,n):
d1 = dp[i-1] + abs(l[i] - l[i-1])
if i > 1:
d2 = dp[i-2] + abs(l[i] - l[i-2])
if d1 > d2:
d1 = d2
dp[i] = d1
print(l,dp) | s393855447 | Accepted | 123 | 13,980 | 230 | n = int(input())
l = list(map(int, input().split()))
dp = [0]*n
for i in range(1,n):
d1 = dp[i-1] + abs(l[i] - l[i-1])
if i > 1:
d2 = dp[i-2] + abs(l[i] - l[i-2])
if d1 > d2:
d1 = d2
dp[i] = d1
print(dp[-1])
|
s495838134 | p03997 | u067962264 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 65 | You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid. | a,b,h=[int(input()) for i in range(3)]
print(a*b*h/2)
| s827222330 | Accepted | 17 | 2,940 | 60 | a,b,h=[int(input()) for i in range(3)]
print(int((a+b)*h/2)) |
s249974643 | p03599 | u977389981 | 3,000 | 262,144 | Wrong Answer | 62 | 3,316 | 446 | Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the beaker. * Operation 3: Put C grams of sugar into the beaker. * Operation 4: Put D grams of sugar into the beaker. In our experimental environment, E grams of sugar can dissolve into 100 grams of water. Snuke will make sugar water with the highest possible density. The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted. We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water. | A, B, C, D, E, F = map(int, input().split())
W = set()
for a in range(0, F+1, 100*A):
for b in range(0, F+1-a, 100*B):
W.add(a+b)
S = set()
for c in range(0, F+1, C):
for d in range(0, F+1-c, D):
S.add(c+d)
rate = -1
for w in W:
for s in S:
if 0 < w+s <= F and s <= (E//100)*w:
if s/(w+s) > rate:
rate = s/(w+s)
ans = w+s, s
print(ans[0], ans[1]) | s708031548 | Accepted | 58 | 3,188 | 498 | A, B, C, D, E, F = map(int, input().split())
W = set()
for i in range(0, F + 1, 100 * A):
for j in range(0, F + 1 - i, 100 * B):
W.add(i + j)
S = set()
for i in range(0, F + 1, C):
for j in range(0, F + 1 - i, D):
S.add(i + j)
rate = -1
for w in W:
for s in S:
if 0 < w + s <= F and s / (w + s) <= E / (E + 100):
if s / (w + s) > rate:
rate= s / (w + s)
ans = w + s, s
print(ans[0], ans[1]) |
s853771746 | p03455 | u387953515 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 108 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | a,b=[ int(i) for i in input().split(" ")]
if bin(a*b)[-1] == "0":
print("Odd")
else:
print("even") | s233186576 | Accepted | 17 | 2,940 | 109 | a,b=[ int(i) for i in input().split(" ")]
if bin(a*b)[-1] == "0":
print("Even")
else:
print("Odd")
|
s010762591 | p04045 | u365254117 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 122 | Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier. | n, k = map(int, input().split())
lst=input().split()
i=n
for j in str(i):
while "j" in lst:
i += 1
print(i)
| s547488461 | Accepted | 90 | 2,940 | 142 | n, k = map(int, input().split())
l=set(input().split())
while True:
if set(str(n)) & l == set():
print(n)
exit()
n+=1
|
s027667127 | p03861 | u502028059 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 139 | You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x? | a, b, x = map(int, input().split())
def f(n):
if n == 0:
return -1
else:
return n // x
ans = f(b) - f(a)
print(ans) | s248309923 | Accepted | 17 | 2,940 | 147 | a, b, x = map(int, input().split())
def f(n):
if n == -1:
return 0
else:
return n // x + 1
ans = f(b) - f(a - 1)
print(ans) |
s497390827 | p03044 | u405483159 | 2,000 | 1,048,576 | Wrong Answer | 645 | 36,048 | 322 | We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices painted in the same color, the distance between them is an even number. Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem. | n = int( input())
l = [[[] for _ in range( 2 )] for _ in range( n )]
for i in range( n - 1 ):
u, v, w = map( int, input().split())
l[ u - 1 ][ w % 2 ].append( v - 1 )
ret = [1] + [0] * ( n - 1 )
def check( i ):
k = l[ i ][ 0 ]
for j in k:
ret[ j ] = 1
check( j )
check( 0 )
for i in ret:
print( i ) | s268394543 | Accepted | 686 | 38,828 | 362 | N = int( input() )
d = [ [] for _ in range( N )]
for i in range( N - 1 ):
v, u, w = map( int, input().split() )
d[ v - 1 ].append(( u - 1, w ))
d[ u - 1 ].append(( v - 1, w ))
s = [( 0, 0 )]
l = [ -1 ] * N
while s != []:
a, w = s.pop()
l[ a ] = w % 2
for i, j in d[ a ]:
if l[ i ] == -1:
s.append( ( i , j + w ) )
for i in l:
print( i ) |
s890120947 | p03545 | u023229441 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 329 | Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted. | A=list(input())
for i in range(4):
A[i]=int(A[i])
for bit in range(8):
flag=["+","+","+"]
for i in range(3):
if not bit>>(2-i) & 1 :
A[i+1]=-A[i+1]
flag[i]="-"
if sum(A)==7:
print("{}{}{}{}{}{}{}".format(A[0],flag[0],A[1],flag[1],A[2],flag[2],A[3]))
exit()
for i in range(4):
A[i]=abs(A[i]) | s073045609 | Accepted | 27 | 9,204 | 361 | s=input()
ans=0
def dfs(i,stri,sum):
global ans
#print(i,stri,sum)
if i==3 and sum==7:
#print("ore")
ans=stri+"=7"
if i<=2:
dfs(i+1, stri+ f"+{s[i+1]}" , sum+int(s[i+1]))
dfs(i+1, stri+ f"-{s[i+1]}", sum-int(s[i+1]))
dfs(0,s[0],int(s[0]))
print(ans) |
s775636637 | p03448 | u077127204 | 2,000 | 262,144 | Wrong Answer | 2,107 | 3,060 | 316 | 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())
import itertools
len([c for c in set(map(tuple, itertools.chain.from_iterable(itertools.combinations(itertools.chain(itertools.repeat(500, A), itertools.repeat(100, B), itertools.repeat(50, C)), r) for r in range(A + B + C + 1)))) if sum(c) == X]) | s709577497 | Accepted | 36 | 3,060 | 273 | A = int(input())
B = int(input())
C = int(input())
X = int(input())
import itertools
print(len([total for total in map(sum, itertools.product(
[500 * i for i in range(A + 1)],
[100 * i for i in range(B + 1)],
[50 * i for i in range(C + 1)],
)) if total == X])) |
s865699327 | p02402 | u568446716 | 1,000 | 131,072 | Wrong Answer | 20 | 5,600 | 159 | Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence. | n = int(input())
a = input().split()
int_a = []
for i in range(n):
int_a.append(int(a[i]))
print("{} {} {}".format(max(int_a), min(int_a), sum(int_a)))
| s264937227 | Accepted | 20 | 6,596 | 159 | n = int(input())
a = input().split()
int_a = []
for i in range(n):
int_a.append(int(a[i]))
print("{} {} {}".format(min(int_a), max(int_a), sum(int_a)))
|
s334089156 | p03698 | u314050667 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 83 | You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different. | s = input()
ss = "".join(set(s))
print("Yes") if len(s) == len(ss) else print("No") | s530272806 | Accepted | 17 | 2,940 | 83 | s = input()
ss = "".join(set(s))
print("yes") if len(s) == len(ss) else print("no") |
s847005801 | p04044 | u063073794 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 125 | Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m. | n, l = map(int,input().split())
s = []
for i in range(n):
s.append(input())
print(s)
s.sort()
print(s)
print("".join(s))
| s130876436 | Accepted | 18 | 3,060 | 126 | n, l = map(int,input().split())
s = []
for i in range(n):
s.append(input())
#print(s)
s.sort()
#print(s)
print("".join(s)) |
s908910901 | p03339 | u335038698 | 2,000 | 1,048,576 | Wrong Answer | 2,104 | 3,884 | 188 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | N = int(input())
S = input()
min_num = 3e5
for i in range(N):
num = S[:i].count('W') + S[i:].count('E')
min_num = num if min_num > num else min_num
print(i, num)
print(min_num) | s390844792 | Accepted | 143 | 3,672 | 245 | N = int(input())
S = input()
num = S.count('E')
min_num = num
for i in range(N-1):
if S[i]=='W':
num += 1
if S[i+1]=='E':
num -= 1
min_num = num if min_num > num else min_num
print(min_num if S[0]=='W' else min_num-1) |
s687323284 | p03371 | u136843617 | 2,000 | 262,144 | Wrong Answer | 118 | 3,064 | 264 | "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 A+B < 2*C:
print(A*X+B*Y)
else:
ans = float('inf')
for i in range(0,max(X,Y)*2+1,2):
ans = min(ans, max((X-i//2), 0)+max(B*(Y-i//2),0) + C*i)
print(ans) | s759106855 | Accepted | 89 | 3,060 | 265 | def solve():
A,B,C,X,Y = map(int, input().split())
ans = X*A + Y*B
for i in range(max(X,Y)+1):
aandb = A * max(0, X-i) + B * max(0, Y-i)
ab = 2*C*i
ans = min(ans, aandb + ab)
print(ans)
if __name__ == '__main__':
solve() |
s644988224 | p02845 | u428199834 | 2,000 | 1,048,576 | Wrong Answer | 248 | 20,660 | 378 | N people are standing in a queue, numbered 1, 2, 3, ..., N from front to back. Each person wears a hat, which is red, blue, or green. The person numbered i says: * "In front of me, exactly A_i people are wearing hats with the same color as mine." Assuming that all these statements are correct, find the number of possible combinations of colors of the N people's hats. Since the count can be enormous, compute it modulo 1000000007. | n=int(input())
a=list(map(int,input().split()))
a_=max(a)
con=[0]*(a_+1)
tou=[0]*(a_+1)
ans=[]
for i in range(len(a)):
u=a[i]
if u==0:
con[0]+=1
tou[0]+=1
ans.append(4-con[0])
else:
con[u]+=1
tou[u]+=1
ans.append(min(tou[u-1],4-con[u]))
c=1
for i in range(len(ans)):
c*=ans[i]
print(c%(10**9+7))
print(ans) | s723044178 | Accepted | 110 | 20,628 | 381 | n=int(input())
a=list(map(int,input().split()))
a_=max(a)
con=[0]*(a_+1)
tou=[0]*(a_+1)
ans=[]
for i in range(len(a)):
u=a[i]
if u==0:
con[0]+=1
tou[0]+=1
ans.append(4-con[0])
else:
con[u]+=1
tou[u]+=1
ans.append(tou[u-1]-con[u]+1)
c=1
for i in range(len(ans)):
c*=ans[i]
c=c%(10**9+7)
print(c%(10**9+7))
|
s888155746 | p03068 | u937642029 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 126 | You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`. | n=int(input())
s=list(input())
k=int(input())
for i in range(n):
if s[i] != s[k-1]:
s[i]=s[k-1]
print(''.join(s))
| s003362277 | Accepted | 17 | 3,064 | 125 | n=int(input())
s=list(input())
k=int(input())
for i in range(n):
if s[i] != s[k-1]:
s[i]="*"
print(''.join(s))
|
s603582477 | p03644 | u441320782 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 210 | 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())
x = [i for i in range(1,n+1)]
res = []
judge = 0
while len(x)>1:
for j in x:
if j%2==0:
res.append(j/2)
else:
x = res
res = []
judge += 1
print(x[0]*(2**judge))
| s588966654 | Accepted | 17 | 3,060 | 234 | import math
n = int(input())
x = [i for i in range(1,n+1)]
res = []
judge = 0
while len(x)>1:
for j in x:
if j%2==0:
res.append(j/2)
else:
x = res
res = []
judge += 1
print(math.floor(x[0]*(2**judge)))
|
s068412964 | p02399 | u467070262 | 1,000 | 131,072 | Wrong Answer | 30 | 7,660 | 128 | Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number) | x = input().split(" ")
a = int(x[0])
b = int(x[1])
d = int(a/b)
r = int(a%b)
f = a/b
print(str(d) + " " + str(r) + " " + str(f)) | s950047549 | Accepted | 20 | 7,644 | 72 | a,b = map(int, input().split())
print("%d %d %.5f" % (int(a/b),a%b,a/b)) |
s080132716 | p03644 | u774160580 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 161 | 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())
ans = 0
for i in range(1, N+1):
i_ans = 0
while i % 2:
i_ans += 1
i = i//2
ans = max(ans, i_ans)
print(pow(2, ans))
| s974461348 | Accepted | 17 | 2,940 | 166 | N = int(input())
ans = 0
for i in range(1, N+1):
i_ans = 0
while i % 2 == 0:
i_ans += 1
i = i//2
ans = max(ans, i_ans)
print(pow(2, ans))
|
s217923156 | p03476 | u504562455 | 2,000 | 262,144 | Time Limit Exceeded | 2,104 | 3,992 | 512 | We say that a odd number N is _similar to 2017_ when both N and (N+1)/2 are prime. You are given Q queries. In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i. | import math
isPrime = [True for i in range(10**5+1)]
for i in range(3, 10**5+1):
for j in range(2, math.floor(math.sqrt(i))+1):
if i % j == 0:
isPrime[i] = False
cntPrime = [0 for i in range(10**5+1)]
for i in range(2,10**5+1):
if i % 2 == 1 and isPrime[i] and isPrime[(i+1)//2]:
cntPrime[i] = cntPrime[i-1]+1
else:
cntPrime[i] = cntPrime[i-1]
Q = int(input())
for i in range(Q):
l, r = [int(_) for _ in input().split()]
print(cntPrime[r]-cntPrime[l-1])
| s287742038 | Accepted | 1,473 | 8,216 | 564 | import math
prime = [i for i in range(2, 10**5+1)]
for i in range(2, math.floor(math.sqrt(10**5))+1):
prime = [p for p in prime if (p == i or p % i != 0)]
isPrime = [False for i in range(10**5+1)]
for p in prime:
isPrime[p] = True
cntPrime = [0 for i in range(10**5+1)]
for i in range(2, 10**5+1):
if i % 2 == 1 and isPrime[i] and isPrime[(i+1)//2]:
cntPrime[i] = cntPrime[i-1]+1
else:
cntPrime[i] = cntPrime[i-1]
Q = int(input())
for i in range(Q):
l, r = [int(_) for _ in input().split()]
print(cntPrime[r]-cntPrime[l-1]) |
s400381006 | p03447 | u659468426 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 60 | You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping? | X=input()
A=input()
B=input()
k = int(X) - int(A)
k % int(B) | s142630108 | Accepted | 17 | 2,940 | 67 | X=input()
A=input()
B=input()
k = int(X) - int(A)
print(k % int(B)) |
s980211085 | p03591 | u537963083 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 76 | 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()
if s.startswith('YAKI'):
print('YES')
else:
print('NO')
| s063263769 | Accepted | 19 | 3,060 | 76 | s = input()
if s.startswith('YAKI'):
print('Yes')
else:
print('No')
|
s427073127 | p03215 | u619819312 | 2,525 | 1,048,576 | Wrong Answer | 357 | 30,896 | 347 | One day, Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He is interested in properties of the sequence a. For a nonempty contiguous subsequence a_l, ..., a_r (1 \leq l \leq r \leq N) of the sequence a, its _beauty_ is defined as a_l + ... + a_r. Niwango-kun wants to know the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. (Subsequences may share elements.) Find the maximum possible value for him. | from bisect import bisect_left as bl
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[]
for i in range(n):
c=0
for j in a[i:]:
c+=j
l.append(c)
t=0
for i in range(40,0,-1):
s=t+2**i
c=0
for j in l[bl(l,t):]:
if j&s==s:
c+=1
else:
if k<=c:
t=s
print(t) | s469316700 | Accepted | 351 | 27,700 | 270 | n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[]
for i in range(n):
c=0
for j in a[i:]:
c+=j
l.append(c)
t=0
for i in range(40,-1,-1):
s=2**i
b=[u for u in l if s&u!=0]
if len(b)>=k:
l=b
t+=s
print(t) |
s053986011 | p03962 | u845937249 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 158 | AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him. | a,b,c = map(int,input().split())
l = [0] * 3
l[0] = a
l[1] = b
l[2] = c
k = [0] * 3
k[0] = l.count(a)
k[1] = l.count(b)
k[2] = l.count(c)
print(max(k))
| s317401803 | Accepted | 17 | 3,060 | 216 | a,b,c = map(int,input().split())
l = [0] * 3
l[0] = a
l[1] = b
l[2] = c
k = [0] * 3
k[0] = l.count(a)
k[1] = l.count(b)
k[2] = l.count(c)
t = max(k)
if t == 1:
t = 3
elif t ==3:
t = 1
else:
pass
print(t)
|
s341898247 | p02795 | u780698286 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 78 | We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all the squares in that column black. At least how many operations do you need in order to have N or more black squares in the grid? It is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations. | a = [int(input()) for i in range(2)]
b = int(input())
c = b // max(a)
print(c) | s431504189 | Accepted | 17 | 2,940 | 126 | a = [int(input()) for i in range(2)]
b = int(input())
if b % max(a) == 0:
print(b // max(a))
else:
print(b // max(a) + 1)
|
s753189507 | p03971 | u368270116 | 2,000 | 262,144 | Wrong Answer | 125 | 4,708 | 346 | There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass. | n,A,B=map(int,input().split())
contestant=list(input())
aa=0
bb=0
for i in range(n):
if contestant[i]=="c":
print("No")
elif contestant[i]=="b":
if aa+bb<A+B and bb<B:
print("Yes")
else:
print("No")
bb+=1
elif contestant[i]=="a":
if aa+bb<A+B+1 :
print("Yes")
else:
print("No")
aa+=1 | s448732203 | Accepted | 122 | 4,708 | 346 | n,A,B=map(int,input().split())
contestant=list(input())
aa=0
bb=0
for i in range(n):
if contestant[i]=="c":
print("No")
elif contestant[i]=="b":
if aa+bb<A+B and bb<B:
print("Yes")
bb+=1
else:
print("No")
elif contestant[i]=="a":
if aa+bb<A+B:
print("Yes")
else:
print("No")
aa+=1
|
s655804905 | p03305 | u102461423 | 2,000 | 1,048,576 | Wrong Answer | 2,111 | 60,332 | 611 | Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains. Two currencies are used in the country: yen and snuuk. Any train fare can be paid by both yen and snuuk. The fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk. In a city with a money exchange office, you can change 1 yen into 1 snuuk. However, when you do a money exchange, you have to change all your yen into snuuk. That is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk. Currently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year. Kenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling. It is acceptable to do the exchange in City s or City t. Kenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange. For each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years. You can assume that the trip finishes within the year. | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra
N,M,S,T = map(int,input().split())
UVAB = [[int(x) for x in input().split()] for _ in range(M)]
U,V,A,B = zip(*UVAB)
g1 = csr_matrix((A,(U,V)), (N+1,N+1))
g2 = csr_matrix((B,(U,V)), (N+1,N+1))
d1 = dijkstra(g1, indices=S, directed=False)
d2 = dijkstra(g2, indices=T, directed=False)
d = d1 + d2
d = (np.minimum.accumulate(d[::-1])[::-1]).astype(int)
answer = 10 ** 10 - d[1:]
print(*answer, sep='\n') | s312039062 | Accepted | 1,240 | 78,388 | 841 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import numpy as np
from heapq import heappush, heappop
N,M,S,T = map(int,input().split())
graph = [[] for _ in range(N+1)]
for _ in range(M):
u,v,a,b = map(int,input().split())
graph[u].append((v,a,b))
graph[v].append((u,a,b))
def dijkstra(start, mode):
INF = 10 ** 15
dist = [INF] * (N+1)
dist[start] = 0
q = [(0,start)]
while q:
d,v = heappop(q)
if dist[v] < d:
continue
for w,*a in graph[v]:
d1 = d + a[mode]
if dist[w] > d1:
dist[w] = d1
heappush(q, (d1,w))
return dist
d1 = np.array(dijkstra(S,0))
d2 = np.array(dijkstra(T,1))
d1 += d2
answer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]
print('\n'.join(answer.astype(str))) |
s866347038 | p03854 | u857070771 | 2,000 | 262,144 | Wrong Answer | 19 | 3,188 | 153 | You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. | s=input()
s=s.replace("eraser","")
s=s.replace("erase","")
s=s.replace("dreamer","")
s=s.replace("drea,","")
if s:
print("NO")
else:
print("YES") | s519691406 | Accepted | 19 | 3,188 | 153 | s=input()
s=s.replace("eraser","")
s=s.replace("erase","")
s=s.replace("dreamer","")
s=s.replace("dream","")
if s:
print("NO")
else:
print("YES") |
s072241311 | p02928 | u241159583 | 2,000 | 1,048,576 | Wrong Answer | 2,104 | 17,092 | 311 | We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}. Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2. Find the inversion number of B, modulo 10^9 + 7. Here the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \leq i < j \leq K \times N - 1) such that B_i > B_j. | n,k = map(int, input().split())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
cnt = 0
for i in range(n-1):
for j in range(i+1,n):
if a[i] > a[j]: cnt += 1
y = 0
for a1 in a:
for a2 in a:
print(a1,a2)
if a1 > a2: y += 1
ans = (cnt * k + y * k * (k-1)//2)%MOD
print(ans) | s789513105 | Accepted | 582 | 9,268 | 284 | n,k = map(int, input().split())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
cnt = 0
for i in range(n-1):
for j in range(i+1, n):
if a[i] > a[j]: cnt += 1
y = 0
for a1 in a:
for a2 in a:
if a1 > a2: y += 1
ans = (cnt*k + y*k*(k-1)//2)%MOD
print(ans) |
s042380359 | p03973 | u117240323 | 2,000 | 262,144 | Wrong Answer | 2,103 | 10,648 | 479 | N people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i. Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product to customers in order, starting from the front of the line. This step is repeated as described below. At each step, when a product is shown to a customer, if price P is equal to or less than the cash held by that customer at the time, the customer buys the product and Mr. Takahashi ends the current step. That is, the cash held by the first customer in line with cash equal to or greater than P decreases by P, and the next step begins. Mr. Takahashi can set the value of positive integer P independently at each step. He would like to sell as many products as possible. However, if a customer were to end up with 0 cash on hand after a purchase, that person would not have the fare to go home. Customers not being able to go home would be a problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash. Help out Mr. Takahashi by writing a program that determines the maximum number of products he can sell, when the initial cash in possession of each customer is given. | N = int(input())
A = []
for i in range(N):
A.append(int(input()))
print(N)
print(A)
print(A[0])
c = 0
sold = 0
i = 0
while i<len(A):
if A[i] == c+1:
i+=1
c+=1
#print('1 Ai: ',A[i-1],'c->',c,'i->',i)
elif A[i]<=2*(c+1) and A[i]>=c+1:
A[i]-=(A[i]-1)
i+=1
sold+=1
#print('2 Ai-> ',A[i-1],'i->',i, 's->',sold)
elif A[i]>2*(c+1) and A[i]>=c+1:
A[i] -= c+1
sold+=1
#print('3 Ai-> ',A[i], 's->',sold)
else:
i+=1
#print('4 Ai: ',A[i-1], 'i->',i)
print(sold)
| s977873722 | Accepted | 354 | 7,084 | 321 | N = int(input())
A = []
for i in range(N):
A.append(int(input()))
c = 0
sold = 0
i = 0
while i<len(A):
if A[i] == c+1:
i+=1
c+=1
elif A[i]<=2*(c+1) and A[i]>c+1:
i+=1
sold+=1
if c == 0:
c = 1
elif A[i]>2*(c+1) and A[i]>c+1:
sold+=((A[i]-1)//(c+1))
i+=1
if c == 0:
c = 1
else:
i+=1
print(sold) |
s194367583 | p02407 | u090921599 | 1,000 | 131,072 | Wrong Answer | 20 | 5,584 | 56 | Write a program which reads a sequence and prints it in the reverse order. | ns = list(map(int, input().split()))
print(*ns[::-1])
| s749712287 | Accepted | 20 | 5,596 | 77 | ns = int(input()) #
ns = list(map(int, input().split()))
print(*ns[::-1])
|
s898781741 | p03795 | u684743124 | 2,000 | 262,144 | Wrong Answer | 22 | 9,084 | 47 | 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=n*800
y=100*(n//15)
print(x-y) | s814576011 | Accepted | 26 | 9,144 | 47 | n=int(input())
x=n*800
y=200*(n//15)
print(x-y) |
s492956505 | p00002 | u779220087 | 1,000 | 131,072 | Wrong Answer | 20 | 5,664 | 917 | Write a program which computes the digit number of sum of two integers a and b. | # usr/bin/python
# coding: utf-8
################################################################################
# Digit Number
# Write a program which computes the digit number of sum of two integers a and b.
#
# Input
# There are several test cases. Each test case consists of two non-negative integers a and b which are separeted by a space in a line. The input terminates with EOF.
#
# Constraints
# 0 ??? a, b ??? 1,000,000
# The number of datasets ??? 200
# Output
# Print the number of digits of a + b for each data set.
#
# Sample Input
# 5 7
# 1 99
# 1000 999
# Output for the Sample Input
# 2
# 3
# 4
#
################################################################################
import math
if __name__ == "__main__":
input_lines = input()
a = int(input_lines.split(" ")[0])
b = int(input_lines.split(" ")[1])
data_size = int(math.log10(a+b) + 1)
print(data_size)
exit(0)
| s173495639 | Accepted | 20 | 5,700 | 944 | # usr/bin/python
# coding: utf-8
################################################################################
# Digit Number
# Write a program which computes the digit number of sum of two integers a and b.
#
# Input
# There are several test cases. Each test case consists of two non-negative integers a and b which are separeted by a space in a line. The input terminates with EOF.
#
# Constraints
# 0 ??? a, b ??? 1,000,000
# The number of datasets ??? 200
# Output
# Print the number of digits of a + b for each data set.
#
# Sample Input
# 5 7
# 1 99
# 1000 999
# Output for the Sample Input
# 2
# 3
# 4
#
################################################################################
import math
import fileinput
if __name__ == "__main__":
for line in fileinput.input():
a = int(line.split(" ")[0])
b = int(line.split(" ")[1])
data_size = int(math.log10(a+b) + 1)
print(data_size)
exit(0)
|
s020170968 | p03455 | u291932618 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 90 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | a,b = map(int,input().split())
if a * b % 2 == 0:
print('even')
else:
print('odd') | s243842691 | Accepted | 17 | 2,940 | 68 | a, b=map(int,input().split())
print('Even' if a*b%2 == 0 else 'Odd') |
s789322938 | p02902 | u316464887 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 8 | Given is a directed graph G with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i. It is guaranteed that the graph contains no self-loops or multiple edges. Determine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph. Here the null graph is not considered as a subgraph. | print(0) | s863055715 | Accepted | 24 | 4,084 | 1,487 | import sys
sys.setrecursionlimit(10**7)
def main():
N, M = map(int, input().split())
l = [[] for _ in range(N)]
for _ in range(M):
a, b = map(int, input().split())
l[a-1].append(b-1)
c = [0] * N
loop = []
def cyclic(n):
if c[n] == 2:
return False
if c[n] == 1:
loop.append(n)
return True
c[n] = 1
for i in l[n]:
if cyclic(i):
loop.append(n)
return True
c[n] = 2
return False
for i in range(N):
if cyclic(i):
break
if len(loop) == 0:
print(-1)
return
loop.reverse()
t = loop[-1]
loop = loop[loop.index(t):]
ll = set(loop)
flag = True
while flag:
for i, v in enumerate(loop[:-1]):
flag2 = False
for j in l[v]:
if j in ll and loop[i + 1] != j:
if loop.index(j) == 0:
loop = loop[:i+1] + [j]
elif loop.index(j) < i:
loop = loop[loop.index(j):i+1] + [j]
else:
loop = loop[:i+1] + loop[loop.index(j):]
ll = set(loop)
flag2 = True
break
if flag2:
break
else:
flag = False
loop = set(loop)
print(len(loop))
for i in loop:
print(i+1)
return
main()
|
s239452225 | p03524 | u671446913 | 2,000 | 262,144 | Wrong Answer | 2,104 | 3,700 | 567 | Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible. | #!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
s = input()
# = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
#
# c = collections.Counter()
query = list('keyence')
import re
for p in range(8):
b = ''.join(query[:p])
a = ''.join(query[p:])
pattern1 = r'{}{}'.format(b, a)
pattern2 = r'{}.*{}'.format(b, a)
if re.findall(pattern1, s) or re.findall(pattern2, s):
print('YES')
break
else:
print('NO')
| s633485303 | Accepted | 26 | 3,572 | 513 | #!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
s = input()
# = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
#
c = collections.Counter(s)
v = [v_ for v_ in c.values() if v_ != 0]
if len(s) == 1:
print('YES')
exit()
if len(s) == 2:
print('YES' if len(v) == 2 else 'NO')
exit()
if len(v) <= 2:
print('NO')
else:
print('YES' if max(v) - min(v) <= 1 else 'NO')
|
s103325551 | p03140 | u135204039 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 398 | You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters. Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation: * Operation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter. What is the minimum number of operations required to achieve the objective? | from sys import stdin
N = int(stdin.readline().rstrip())
A = stdin.readline().rstrip()
B = stdin.readline().rstrip()
C = stdin.readline().rstrip()
str_len = len(A)
count = 0
for i in range(str_len):
if A[i]==B[i]:
if C[i]==B[i]:
continue
else:
count = count + 1
elif A[i]==C[i]:
count = count + 1
else:
count = count + 2
| s159152199 | Accepted | 18 | 3,064 | 388 | N = int(input())
A = input()
B = input()
C = input()
str_len = len(A)
count = 0
for i in range(str_len):
#print(f'i: {i}')
if A[i]==B[i]:
if C[i]==B[i]:
continue
else:
count = count + 1
elif A[i]==C[i]:
count = count + 1
elif B[i]==C[i]:
count = count + 1
else:
count = count + 2
print(str(count)) |
s445643793 | p03860 | u609814378 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 45 | Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name. | S = input()
S1 = S[0]
print("A" + S1 +"C")
| s195579522 | Accepted | 17 | 2,940 | 43 | a,b,c=input().split()
print(a[0]+b[0]+c[0]) |
s665997594 | p03485 | u102930666 | 2,000 | 262,144 | Wrong Answer | 23 | 3,188 | 113 | You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer. | a,b = map(int,input().split())
ave = (a+b)/2
if ave == int(ave):
print(ave)
else:
print(int(ave)+1) | s496560815 | Accepted | 19 | 2,940 | 118 | a,b = map(int,input().split())
ave = (a+b)/2
if ave == int(ave):
print(int(ave))
else:
print(int(ave)+1) |
s941596146 | p03645 | u591503175 | 2,000 | 262,144 | Wrong Answer | 379 | 43,904 | 638 | 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. | def resolve():
'''
code here
'''
import collections
N, M = [int(item) for item in input().split()]
edges = [[int(item) for item in input().split()] for _ in range(M)]
fp = [0 for _ in range(N+1)]
fp[1] = 1
que = collections.deque([1])
is_found = False
while que:
node = que.popleft()
if node == N:
que = False
is_found = True
if fp[node]:
pass
else:
que.append(edges[node-1])
fp[que] = 1
print('POSSIBLE') if is_found else print('IMPOSSIBLE')
if __name__ == "__main__":
resolve()
| s134772223 | Accepted | 500 | 60,500 | 706 | def resolve():
'''
code here
'''
import collections
N, M = [int(item) for item in input().split()]
edges = [[int(item) for item in input().split()] for _ in range(M)]
togo = [[] for _ in range(N+1)]
for f, t in edges:
togo[f] += [t]
is_found = False
que = collections.deque()
for goto in togo[1]:
que.append(goto)
is_found = False
while que:
node = que.popleft()
for next_node in togo[node]:
if next_node == N:
is_found = True
# print(next_node, is_found)
print('POSSIBLE') if is_found else print('IMPOSSIBLE')
if __name__ == "__main__":
resolve()
|
s426676337 | p03814 | u901687869 | 2,000 | 262,144 | Wrong Answer | 60 | 3,516 | 179 | Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`. | string = input()
start = 0
end = 0
cnt = 0
for s in string:
if s == 'A' and start != 0:
start = cnt
if s == 'Z':
end = cnt
cnt += 1
print(end - start + 1) | s367822823 | Accepted | 69 | 3,516 | 226 | string = input()
start = 0
end = 0
cnt = 0
flg = False
for s in string:
if s == 'A' and flg == False:
start = cnt
flg = True
if s == 'Z':
end = cnt
cnt += 1
print(end - start + 1) |
s091374109 | p03556 | u027403702 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 46 | Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer. | N = int(input())
X = int(N ** 0.5)
print(X *2) | s666810901 | Accepted | 17 | 2,940 | 47 | N = int(input())
X = int(N ** 0.5)
print(X **2) |
s402505401 | p03845 | u581403769 | 2,000 | 262,144 | Wrong Answer | 26 | 9,136 | 211 | Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. | n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = [list(map(int, input().split())) for i in range(m)]
for i in range(m):
time = t
time[p[i][0] - 1] = p[i][1]
print(sum(time)) | s775013375 | Accepted | 29 | 9,116 | 225 | n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = [list(map(int, input().split())) for i in range(m)]
for i in range(m):
time = [x for x in t]
time[p[i][0] - 1] = p[i][1]
print(sum(time))
|
s551679997 | p03448 | u618512227 | 2,000 | 262,144 | Wrong Answer | 56 | 3,064 | 256 | 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())
ans = 0
for i in range(a):
for j in range(b):
for k in range(c):
tmp = i*500 + j*100 + k*50
if tmp == x:
ans += 1
print(ans) | s406225052 | Accepted | 54 | 3,060 | 262 | a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
tmp = i*500 + j*100 + k*50
if tmp == x:
ans += 1
print(ans) |
s889241742 | p03759 | u717626627 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 91 | Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful. | a,b, c = map(int, input().split())
if b - a == c - b:
print('Yes')
else:
print('No') | s712170800 | Accepted | 17 | 2,940 | 91 | a,b, c = map(int, input().split())
if b - a == c - b:
print('YES')
else:
print('NO') |
s455253238 | p03494 | u945181840 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 184 | 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())
A = list(map(int, input().split()))
ans = 100000
for i in A:
temp = format(i, 'b')
print(temp)
ans = min(ans, len(temp) - temp.rfind('1') - 1)
print(ans) | s984713336 | Accepted | 17 | 3,060 | 168 | N = int(input())
A = list(map(int, input().split()))
ans = 100000
for i in A:
temp = format(i, 'b')
ans = min(ans, len(temp) - temp.rfind('1') - 1)
print(ans) |
s371101374 | p02678 | u078349616 | 2,000 | 1,048,576 | Wrong Answer | 755 | 38,456 | 367 | There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists. | from collections import deque
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
a, b = map(int, input().split())
a, b = a-1, b-1
G[a].append(b)
G[b].append(a)
q = deque([0])
dist = [-1]*N
dist[0] = 0
while q:
v = q.popleft()
for nv in G[v]:
if dist[nv] == -1:
dist[nv] = v+1
q.append(nv)
print(*dist[1:]) | s696859044 | Accepted | 745 | 38,396 | 389 | from collections import deque
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
a, b = map(int, input().split())
a, b = a-1, b-1
G[a].append(b)
G[b].append(a)
q = deque([0])
dist = [-1]*N
dist[0] = 0
while q:
v = q.popleft()
for nv in G[v]:
if dist[nv] == -1:
dist[nv] = v+1
q.append(nv)
print("Yes")
print(*dist[1:], sep="\n") |
s703787531 | p02389 | u585773649 | 1,000 | 131,072 | Wrong Answer | 20 | 5,596 | 137 | Write a program which calculates the area and perimeter of a given rectangle. | def rect (a,b):
return a*2,b*4
s=input()
x=s.split()
a= int(x[0])
b=int (x[1])
area,perimeter=rect(a,b)
print(area,perimeter)
| s064816087 | Accepted | 20 | 5,596 | 141 | def rect (a,b):
return a*b,b*2+a*2
s=input()
x=s.split()
a= int(x[0])
b=int (x[1])
area,perimeter=rect(a,b)
print(area,perimeter)
|
s364840859 | p01321 | u779577827 | 8,000 | 131,072 | Wrong Answer | 30 | 7,516 | 105 | 私立桜が丘女子高等学校に通う平沢唯さんは明後日までに進路希望を出さなければならないのだが、困ったことに進路についてまだ何も決めていなかった。 友人の和に相談したところ、和の第一志望はK大と知り、自分もK大に入れるかどうか進路指導の先生に相談にいった。 相談された進路指導の先生であるあなたは唯さんがK大に入れるかどうかを予想するため唯さんの期末試験の成績を参考にすることにした。 しかし、唯さんは試験の山が当たるかどうかによって大きく成績が左右されるため、過去の期末試験の中で一番良かった時の点数と一番悪かった時の点数を調べることにした。 過去の期末試験のデータは5教科の各点数のみしか残っておらず、試験の合計点数は残っていなかった。 したがってあなたの仕事は各試験の点数データを入力として、過去の期末試験の中で一番良かった時の点数と一番悪かった時の点数を出力するプログラムを書くことである。 | ["{} {}".format(max(x), min(x)) for x in [[sum(map(int, input().split())) for _ in range(int(input()))]]] | s742952070 | Accepted | 40 | 7,596 | 172 | while True:
n = int(input())
if n == 0:
break
[print("{} {}".format(max(x), min(x))) for x in [[sum(map(int, input().split())) for i in range(n)]]] |
s895033329 | p00423 | u215335591 | 1,000 | 131,072 | Wrong Answer | 120 | 5,624 | 374 | A と B の 2 人のプレーヤーが, 0 から 9 までの数字が書かれたカードを使ってゲームを行う.最初に, 2 人は与えられた n 枚ずつのカードを,裏向きにして横一列に並べる.その後, 2 人は各自の左から 1 枚ずつカードを表向きにしていき,書かれた数字が大きい方のカードの持ち主が,その 2 枚のカードを取る.このとき,その 2 枚のカードに書かれた数字の合計が,カードを取ったプレーヤーの得点となるものとする.ただし,開いた 2 枚のカードに同じ数字が書かれているときには,引き分けとし,各プレーヤーが自分のカードを 1 枚ずつ取るものとする. 例えば, A,B の持ち札が,以下の入力例 1 から 3 のように並べられている場合を考えよう.ただし,入力ファイルは n + 1 行からなり, 1 行目には各プレーヤのカード枚数 n が書かれており, i + 1 行目(i = 1,2,... ,n)には A の左から i 枚目のカードの数字と B の左から i 枚目の カードの数字が,空白を区切り文字としてこの順で書かれている.すなわち,入力ファイルの 2 行目以降は,左側の列が A のカードの並びを,右側の列が B のカードの並びを,それぞれ表している.このとき,ゲーム終了後の A と B の得点は,それぞれ,対応する出力例に示したものとなる. 入力ファイルに対応するゲームが終了したときの A の得点と B の得点を,この順に空白を区切り文字として 1 行に出力するプログラムを作成しなさい.ただし, n ≤ 10000 とする. 入力例1 | 入力例2 | 入力例3 ---|---|--- 3| 3| 3 9 1| 9 1| 9 1 5 4| 5 4| 5 5 0 8| 1 0| 1 8 出力例1 | 出力例2 | 出力例3 19 8| 20 0| 15 14 | while True:
n = int(input())
if n == 0:
break
a = 0
b = 0
for i in range(n):
cardnum = [int(i) for i in input().split()]
if cardnum[0] < cardnum[1]:
b += sum(cardnum)
elif cardnum[0] > cardnum[1]:
a += sum(cardnum)
else:
a += cardnum[0]
b += cardnum[1]
print(a,b)
| s349290532 | Accepted | 120 | 5,624 | 378 | while True:
n = int(input())
if n == 0:
break
a = 0
b = 0
for i in range(n):
cardnum = [int(i) for i in input().split()]
if cardnum[0] < cardnum[1]:
b += sum(cardnum)
elif cardnum[0] > cardnum[1]:
a += sum(cardnum)
else:
a += cardnum[0]
b += cardnum[1]
print(a,b)
|
s288819395 | p03555 | u566321790 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 165 | You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise. | line1 = str(input())
line2 = str(input())
newline1 = line2[::-1]
newline2 = line1[::-1]
if newline1==line1 and line2==newline2:
print('Yes')
else:
print('No')
| s327532068 | Accepted | 17 | 2,940 | 55 | print('YES') if input()[::-1]==input() else print('NO') |
s319215839 | p02646 | u096025032 | 2,000 | 1,048,576 | Wrong Answer | 2,206 | 9,176 | 213 | Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally. | #DEMON#
RD, SD = map(int, input().split())
#CRIMINAL#
RC, SC = map(int, input().split())
T = int(input())
for i in range(T):
RD += SD
RC += SC
if RD >= RC:
print("NO")
else:
print("YES")
| s108314354 | Accepted | 21 | 9,060 | 168 | a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
x = abs(a - b)
y = v - w
z = y * t
if z >= x:
print("YES")
else:
print("NO") |
s610933877 | p04029 | u220345792 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 33 | There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total? | N = int(input())
print(N*(N+1)/2) | s584360808 | Accepted | 17 | 2,940 | 37 | N =int(input())
print(int(N*(N+1)/2)) |
s507002178 | p01085 | u136916346 | 8,000 | 262,144 | Wrong Answer | 130 | 5,620 | 218 | The International Competitive Programming College (ICPC) is famous for its research on competitive programming. Applicants to the college are required to take its entrance examination. The successful applicants of the examination are chosen as follows. * The score of any successful applicant is higher than that of any unsuccessful applicant. * The number of successful applicants _n_ must be between _n_ min and _n_ max, inclusive. We choose _n_ within the specified range that maximizes the _gap._ Here, the _gap_ means the difference between the lowest score of successful applicants and the highest score of unsuccessful applicants. * When two or more candidates for _n_ make exactly the same _gap,_ use the greatest _n_ among them. Let's see the first couple of examples given in Sample Input below. In the first example, _n_ min and _n_ max are two and four, respectively, and there are five applicants whose scores are 100, 90, 82, 70, and 65. For _n_ of two, three and four, the gaps will be 8, 12, and 5, respectively. We must choose three as _n_ , because it maximizes the gap. In the second example, _n_ min and _n_ max are two and four, respectively, and there are five applicants whose scores are 100, 90, 80, 75, and 65. For _n_ of two, three and four, the gap will be 10, 5, and 10, respectively. Both two and four maximize the gap, and we must choose the greatest number, four. You are requested to write a program that computes the number of successful applicants that satisfies the conditions. | while 1:
m,nmi,nma=map(int,input().split())
if not m and not nmi and not nma:break
l=[int(input()) for _ in range(m)]
tg=[l[:i][-1]-l[i:][0] for i in range(nmi,nma+1)]
print(tg.index(max(tg))+nmi)
| s235124303 | Accepted | 140 | 5,620 | 228 | while 1:
m,nmi,nma=map(int,input().split())
if not m and not nmi and not nma:break
l=[int(input()) for _ in range(m)]
tg=[l[:i][-1]-l[i:][0] for i in range(nmi,nma+1)]
print(nma-tg[::-1].index(max(tg)))
|
s416655432 | p03160 | u362347649 | 2,000 | 1,048,576 | Wrong Answer | 126 | 13,980 | 300 | There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. | N = int(input())
h = list(map(int, input().split()))
dp = [float("inf")] * N
dp[0] = 0
dp[1] = abs(h[0] - h[1])
h_2 = h[0]
h_1 = h[1]
for i in range(2, N):
x = h[i]
dp[i] = min(
dp[i - 1] + abs(x - h_1),
dp[i - 2] - abs(x - h_2)
)
h_2 = h_1
h_1 = x
print(dp[-1])
| s345140619 | Accepted | 89 | 13,980 | 424 | def solve():
N = int(input())
h = list(map(int, input().split()))
dp = [float("inf")] * N
dp[0] = 0
dp[1] = abs(h[0] - h[1])
h_2 = h[0]
h_1 = h[1]
for i in range(2, N):
x = h[i]
dp[i] = min(
dp[i - 1] + abs(x - h_1),
dp[i - 2] + abs(x - h_2)
)
h_2 = h_1
h_1 = x
return dp[-1]
if __name__ == "__main__":
print(solve()) |
s655110532 | p03434 | u801701525 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 210 | 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())
card = list(map(int,input().split()))
card.sort()
alice = 0
bob = 0
for i in range(len(card)):
if i % 2 == 0:
alice += card[i]
else:
bob += card[i]
print(alice - bob) | s973980981 | Accepted | 18 | 3,060 | 222 | N = int(input())
card = list(map(int,input().split()))
card.sort(reverse=True)
alice = 0
bob = 0
for i in range(len(card)):
if i % 2 == 0:
alice += card[i]
else:
bob += card[i]
print(alice - bob) |
Subsets and Splits