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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s857269950 | p03814 | u905582793 | 2,000 | 262,144 | Wrong Answer | 72 | 3,516 | 138 | 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 w... | s=input()
for i in range(len(s)):
if s[i]=="A":
pA = i
for i in range(len(s)):
if s[-i-1] == "Z":
pZ = i
print(len(s)-pA-pZ-1) | s399431856 | Accepted | 42 | 3,516 | 156 | s=input()
for i in range(len(s)):
if s[i]=="A":
pA = i
break
for i in range(len(s)):
if s[-i-1] == "Z":
pZ = i
break
print(len(s)-pA-pZ) |
s078344719 | p03673 | u626468554 | 2,000 | 262,144 | Wrong Answer | 819 | 24,772 | 256 | You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations. | #n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))
n = int(input())
a = list(input())
memo = ''
for i in range(n):
if i%2==0:
memo = memo + a[i]
else:
memo = a[i] + memo
print(*list(memo))
| s681691079 | Accepted | 250 | 26,180 | 455 | n = int(input())
a = list(map(int,input().split()))
li1 = []
li2 = []
for i in range(n):
if i%2==0:
li1.append(a[i])
else:
li2.append(a[i])
ans = []
if n%2==0:
for i in range(n//2):
ans.append(li2[(i+1)*(-1)])
for i in range(n//2):
ans.append(li1[i])
else:
... |
s973695994 | p03598 | u875769753 | 2,000 | 262,144 | Wrong Answer | 27 | 9,192 | 148 | There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th t... | N = int(input())
K = int(input())
lsx = list(map(int,input().split()))
ans = 0
for i in range(N):
ans += min(abs(lsx[i]),abs(lsx[i]-K))
print(ans) | s577576423 | Accepted | 26 | 8,976 | 150 | N = int(input())
K = int(input())
lsx = list(map(int,input().split()))
ans = 0
for i in range(N):
ans += min(abs(lsx[i]),abs(lsx[i]-K))
print(2*ans) |
s931646531 | p03524 | u464205401 | 2,000 | 262,144 | Wrong Answer | 94 | 10,152 | 235 | 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. | import collections
s = list(input())
n = len(s)
flg = True
for i in range(n-1):
if len(set(s[i:i+2]))==1:
flg = False
for i in range(n-2):
tmp = s[i:i+3]
if tmp == tmp[::-1]:
flg = False
print('YES' if flg else 'NO')
| s966569031 | Accepted | 51 | 10,004 | 221 | import collections
s = list(input())
n = len(s)
cnt = [0,0,0]
for i in range(n):
if s[i]=="a":
cnt[0]+=1
elif s[i]=="b":
cnt[1]+=1
else:
cnt[2]+=1
print('YES' if max(cnt)-min(cnt) <= 1 else 'NO')
|
s646514362 | p03478 | u803865203 | 2,000 | 262,144 | Wrong Answer | 55 | 3,308 | 198 | 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(int(N)+1):
array = list(map(int,list(str(i))))
print(array)
if(sum(array)>=A and sum(array)<=B):
ans += int(i)
print(ans)
| s782391329 | Accepted | 35 | 3,060 | 313 | N,A,B = map(int,input().split())
ans = 0
for i in range(1,int(N)+1):
sum = 0
num = i
while(True):
sum += num%10
num = num//10
if(num == 0):
if(sum >= A and sum <= B):
ans += i
break
else:
break
print(ans)
|
s898955101 | p02413 | u382316013 | 1,000 | 131,072 | Wrong Answer | 40 | 8,208 | 386 | Your task is to perform a simple table calculation. Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column. | r, c = [int(i) for i in input().split()]
data = []
sum_row = [0] * (c + 1)
for ri in range(r):
data.append([int(i) for i in input().split()])
data[ri].append(sum(data[ri]))
print(" ".join([str(d) for d in data[ri]]))
for ci in range(c + 1):
sum_row[ci] += data[ri][ci]
print(" ".join([... | s576144484 | Accepted | 30 | 7,744 | 338 | r, c = [int(i) for i in input().split()]
data = []
sum_row = [0] * (c + 1)
for ri in range(r):
data.append([int(i) for i in input().split()])
data[ri].append(sum(data[ri]))
print(" ".join([str(d) for d in data[ri]]))
for ci in range(c + 1):
sum_row[ci] += data[ri][ci]
print(" ".join([str(s) f... |
s078320145 | p02646 | u263660661 | 2,000 | 1,048,576 | Wrong Answer | 19 | 9,172 | 182 | 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 ... | a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v <= w:
print("No")
elif t < abs(a - b)/abs(v - w):
print("No")
else:
print("Yes")
| s430673963 | Accepted | 23 | 9,172 | 184 | a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v <= w:
print("NO")
elif t < abs(a - b) / abs(v - w):
print("NO")
else:
print("YES")
|
s457806602 | p03351 | u357867755 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 176 | Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either ... | a, b, c, d = map(int, input().split())
if abs(c - a) <= d:
print('Yes')
elif (abs(b - a) <= d) and (abs(c-b) <= d):
print('Yes')
else:
print('No')
print(abs(b-a)) | s598136167 | Accepted | 17 | 2,940 | 164 | a, b, c, d = map(int, input().split())
if abs(c - a) <= d:
print('Yes')
elif (abs(b - a) <= d) and (abs(b - c) <= d):
print('Yes')
else:
print('No')
|
s239344601 | p03712 | u826263061 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 123 | You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1. | h, w = list(map(int, input().split()))
a = '*'*(w+2)
print(a)
for i in range(h):
s = input()
print('*'+s+'*')
print(a)
| s627618317 | Accepted | 17 | 3,060 | 244 | # -*- coding: utf-8 -*-
"""
Created on Sun Sep 16 16:57:33 2018
@author: maezawa
"""
h, w = list(map(int, input().split()))
a = '#'*(w+2)
b = []
for i in range(h):
s = input()
b.append('#'+s+'#')
print(a)
for s in b:
print(s)
print(a) |
s155938177 | p03251 | u347452770 | 2,000 | 1,048,576 | Wrong Answer | 22 | 9,136 | 329 | Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes incli... | import sys
n,m,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
d=min(y)-max(x)
if d<=0:
print("War")
sys.exit()
else:
for i in range(d+1):
Z=X+i
if (Z<=X or Z>Y) or (max(x)>=Z or min(y)<Z):
print("War")
sys.exit()
print(... | s833488960 | Accepted | 24 | 9,216 | 430 | import sys
n,m,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
d=min(y)-max(x)
warFlag = False
if d<=0:
print("War")
sys.exit()
else:
for i in range(1, Y - X + 1):
Z=X+i
if (max(x)>=Z or min(y)<Z):
warFlag = True
else: #max(x)... |
s982428385 | p02406 | u567380442 | 1,000 | 131,072 | Wrong Answer | 30 | 6,720 | 74 | In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement ... | print(*[i for i in range(1, int(input())) if i % 3 == 0 or '3' in str(i)]) | s279404443 | Accepted | 40 | 7,008 | 103 | n = int(input())
print(' ', end='')
print(*[i for i in range(1, 1 + n) if i % 3 == 0 or '3' in str(i)]) |
s269569376 | p03494 | u905582793 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 224 | 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=0
for i in range(100):
for j in range(n):
if a[j] // 2 ==0:
a[j]=a[j]//2
if j==n:
ans+=1
else:
break
else:
continue
break
print(ans) | s901285034 | Accepted | 19 | 3,060 | 229 | n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(100):
for j in range(n):
if a[j] % 2 ==0:
a[j]=a[j]//2
if j==n-1:
ans+=1
else:
break
else:
continue
break
print(ans) |
s962411356 | p03024 | u003501233 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 67 | 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 cons... | S=input()
if S.count("x") <= 7:
print("Yes")
else:
print("No") | s875708173 | Accepted | 18 | 2,940 | 67 | S=input()
if S.count("x") <= 7:
print("YES")
else:
print("NO") |
s003111517 | p03448 | u340781749 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 218 | 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 co... | a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for p in range(a + 1):
for q in range(b + 1):
r = (x - p * 500 - q * 100) // 50
if r <= c:
ans += 1
print(ans) | s721457267 | Accepted | 18 | 3,060 | 223 | a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for p in range(a + 1):
for q in range(b + 1):
r = (x - p * 500 - q * 100) // 50
if 0 <= r <= c:
ans += 1
print(ans) |
s331417520 | p03696 | u502389123 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 600 | You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of... | N = int(input())
S = input()
needleft = 0
needright = 0
ans = ''
for i in range(N):
if S[i] == ')':
ans += '(' * needright
ans += ')' * needright
if needright == 0:
needleft += 1
needright = 0
elif S[i] == '(':
ans += '(' * needleft
ans += ')' * need... | s451669706 | Accepted | 17 | 2,940 | 232 | N = int(input())
S = input()
cnt = 0
s = ''
for i in range(N):
if S[i] == '(':
cnt += 1
else:
cnt -= 1
if cnt < 0:
s += '('
cnt = 0
s += S
if cnt:
s += ')' * cnt
print(s) |
s002160519 | p03050 | u598720217 | 2,000 | 1,048,576 | Wrong Answer | 229 | 3,060 | 151 | Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied: * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds. Find all favorite numbers and print the sum of those. | import math
N = int(input())
n = int(math.sqrt(N))
count=0
for i in range(1,int(n)):
d = N - i
if d%i==0:
count+=int(d/i)
print(count) | s110142101 | Accepted | 237 | 3,060 | 178 | import math
N = int(input())
n = int(math.sqrt(N))
count=0
for i in range(1,n+1):
d = N - i
if d%i==0 and i < (N // i) -1:
k = d//i
count+=k
print(count) |
s856624692 | p03943 | u474270503 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 70 | Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Not... | A=map(int,input().split())
print('Yes' if 2*max(A)==sum(A) else 'No')
| s492543887 | Accepted | 17 | 2,940 | 76 | A=list(map(int,input().split()))
print('Yes' if 2*max(A)==sum(A) else 'No')
|
s331709269 | p03457 | u740284863 | 2,000 | 262,144 | Wrong Answer | 318 | 3,060 | 160 | AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1... | n = int(input())
for i in range(n):
t, x, y = map(int, input().split())
if x + y < t or (x + y + t) % 2:
print("No")
exit()
print("Yes") | s904599365 | Accepted | 216 | 3,064 | 314 | import sys
input = sys.stdin.readline
n = int(input())
t,x,y = 0,0,0
for i in range(n):
t_,x_,y_ = map(int,input().split())
X = abs(x_ - x)
Y = abs(y_ - y)
T = t_ - t
if ( X + Y > T ) or (T % 2 != ( X + Y ) % 2):
print("No")
exit()
t = t_
x = x_
y = y_
print("Yes") |
s958675938 | p03637 | u023229441 | 2,000 | 262,144 | Wrong Answer | 78 | 14,252 | 229 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | n=int(input())
A=list(map(int,input().split()))
for i in range(n):
if A[i]%4==0:
A[i]==0
elif A[i]%2==0:
A[i]==2
else:
A[i]==1
a=A.count(0)
b=A.count(2)
c=A.count(1)
if c<=a :
print("Yes")
else:
print("No") | s119816949 | Accepted | 81 | 14,252 | 268 | n=int(input())
A=list(map(int,input().split()))
for i in range(n):
if A[i]%4==0:
A[i]=0
elif A[i]%2==0:
A[i]=2
else:
A[i]=1
a=A.count(0)
b=A.count(2)
c=A.count(1)
if c<=a :
print("Yes")
elif b==0 and c==a+1:
print("Yes")
else:
print("No")
|
s297486840 | p03958 | u981931040 | 1,000 | 262,144 | Wrong Answer | 42 | 9,180 | 688 | There are K pieces of cakes. Mr. Takahashi would like to eat one cake per day, taking K days to eat them all. There are T types of cake, and the number of the cakes of type i (1 ≤ i ≤ T) is a_i. Eating the same type of cake two days in a row would be no fun, so Mr. Takahashi would like to decide the order for eating ... | import heapq
K, T = map(int, input().split())
a = tuple(map(int, input().split()))
cakes = []
heapq.heapify(cakes)
for i in range(T):
heapq.heappush(cakes, [-1*a[i], i])
print(cakes)
now = -1
ans = 0
for _ in range(K):
cake_num, cake_idx = heapq.heappop(cakes)
cake_num *= -1
if cake_idx == now and len(c... | s662958812 | Accepted | 36 | 9,164 | 747 | import heapq
K, T = map(int, input().split())
a = tuple(map(int, input().split()))
cakes = []
heapq.heapify(cakes)
for i in range(T):
heapq.heappush(cakes, [-1*a[i], i])
# print(cakes)
now = -1
ans = 0
for _ in range(K):
cake_num, cake_idx = heapq.heappop(cakes)
cake_num *= -1
if cake_idx == now and len... |
s162238411 | p03957 | u838930283 | 1,000 | 262,144 | Wrong Answer | 22 | 3,064 | 157 | This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters. Mr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way. You are given a string s consisting of uppercase English letters. Determine whether the string `CF` can be obtai... | s = input()
result = "No"
for i in range(len(s)):
if s[i] == "C":
for j in range(i+1, len(s)):
if s[j] == "F":
result = "YES"
break
print(result) | s043694767 | Accepted | 26 | 3,192 | 157 | s = input()
result = "No"
for i in range(len(s)):
if s[i] == "C":
for j in range(i+1, len(s)):
if s[j] == "F":
result = "Yes"
break
print(result) |
s877952174 | p02260 | u114315703 | 1,000 | 131,072 | Wrong Answer | 20 | 5,596 | 356 | Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 if A[j] < A[mini] 5 mini = j 6 swap A[... | N = int(input())
A = [int(e) for e in input().split()]
def selection_sort(A, N):
steps = 0
for i in range(0, N):
minj = i
for j in range(i, N):
if A[minj] > A[j]:
minj = j
steps += 1
A[minj], A[i] = A[i], A[minj]
print(A)
print(steps)... | s982501945 | Accepted | 30 | 5,616 | 425 | N = int(input())
A = [int(e) for e in input().split()]
def selection_sort(A, N):
steps = 0
for i in range(0, N):
minj = i
for j in range(i, N):
if A[minj] > A[j]:
minj = j
if i != minj:
steps += 1
A[minj], A[i] = A[i], A[minj]
for e i... |
s671747010 | p03963 | u774160580 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 58 | There are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors. Find the number of the possible ways to paint the balls. | N, K = map(int, input().split())
print(K * pow(K, N - 1))
| s277792873 | Accepted | 17 | 2,940 | 62 | N, K = map(int, input().split())
print(K * pow(K - 1, N - 1))
|
s493245996 | p03854 | u962451849 | 2,000 | 262,144 | Wrong Answer | 19 | 3,316 | 159 | 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().replace('eraser', '').replace('erase', '') \
.replace('dreamer', '').replace('dream', '')
if s:
print('NO')
else:
print('YES')
print(s) | s067356462 | Accepted | 18 | 3,188 | 151 | s = input().replace('eraser', '').replace('erase', '') \
.replace('dreamer', '').replace('dream', '')
if s:
print('NO')
else:
print('YES')
|
s711061681 | p00002 | u945249026 | 1,000 | 131,072 | Wrong Answer | 20 | 5,568 | 96 | Write a program which computes the digit number of sum of two integers a and b. | import sys
a = []
for line in sys.stdin:
a.append(line)
for i in a:
print(i[0] + i[1])
| s995239498 | Accepted | 30 | 5,592 | 142 | while True:
try:
a, b = map(int,input().split())
s = str(a + b)
print(len(s))
except EOFError:
break
|
s759778161 | p02407 | u639421643 | 1,000 | 131,072 | Wrong Answer | 20 | 7,572 | 78 | Write a program which reads a sequence and prints it in the reverse order. | length = int(input())
nums = list(map(int, input().split()))
print(nums[::-1]) | s432077989 | Accepted | 20 | 7,648 | 73 | length = int(input())
nums = input().split()
print(" ".join(nums[::-1])) |
s067283366 | p03623 | u240793404 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 74 | Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and... | a,b,c=map(int,input().split()); print("A" if abs(b-a) < abs(c-b) else "B") | s992149155 | Accepted | 17 | 2,940 | 74 | a,b,c=map(int,input().split()); print("A" if abs(b-a) < abs(c-a) else "B") |
s018796994 | p03455 | u014047173 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 92 | 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 % 2 == 0 ) or ( b % 2 == 0 ) :
'even'
else :
'odd' | s076673238 | Accepted | 17 | 2,940 | 106 | a, b = map(int, input().split())
if (a % 2 == 0 ) or ( b % 2 == 0 ) :
print('Even')
else :
print('Odd') |
s593620309 | p02258 | u826549974 | 1,000 | 131,072 | Wrong Answer | 20 | 5,604 | 159 | You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen. Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2,... | n = int(input())
A = [int(input()) for i in range(n)]
max = A[1]-A[0]
for i in range(1,n-1):
if(max < A[i+1]-A[i]):
max = A[i+1]-A[i]
print(max)
| s772538033 | Accepted | 500 | 13,600 | 201 | n = int(input())
A = [int(input()) for i in range(n)]
max = A[1]-A[0]
min = A[0]
for i in range(1,n):
if(max < A[i]-min):
max = A[i]-min
if(min > A[i]):
min = A[i]
print(max)
|
s648280006 | p03455 | u050428930 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 88 | 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())
t = a*b%2
if t==0:
print("even")
else:
print("odd") | s195204363 | Accepted | 17 | 2,940 | 88 | a,b=map(int,input().split())
t = a*b%2
if t==0:
print("Even")
else:
print("Odd") |
s275662604 | p02795 | u841924362 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 136 | 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 t... | import math
H = int(input())
W = int(input())
N = int(input())
if(H >= W):
print(math.ceil(N // H))
else:
print(math.ceil(N // W)) | s023709157 | Accepted | 17 | 2,940 | 134 | import math
H = int(input())
W = int(input())
N = int(input())
if(H >= W):
print(math.ceil(N / H))
else:
print(math.ceil(N / W)) |
s675913842 | p02410 | u369313788 | 1,000 | 131,072 | Wrong Answer | 30 | 7,632 | 340 | Write a program which reads a $ n \times m$ matrix $A$ and a $m \times 1$ vector $b$, and prints their product $Ab$. A column vector with m elements is represented by the following equation. \\[ b = \left( \begin{array}{c} b_1 \\\ b_2 \\\ : \\\ b_m \\\ \end{array} \right) \\] A $n \times m$ matrix with $m$ column ve... | n, m = [int(i) for i in input().split()]
matrix = []
for ni in range(n):
matrix.append([int(x) for x in input().split()])
vector = []
for ni in range(m):
vector.append(int(input()))
print(matrix)
print()
print(vector)
for ni in range(n):
sum = 0
for mi in range(n):
sum += matrix[ni][mi]* vecto... | s536276728 | Accepted | 30 | 8,068 | 311 | n, m = [int(i) for i in input().split()]
matrix = []
for ni in range(n):
matrix.append([int(a) for a in input().split()])
vector = []
for mi in range(m):
vector.append(int(input()))
for ni in range(n):
sum = 0
for mi in range(m):
sum += matrix[ni][mi] * vector[mi]
print(sum) |
s018978227 | p03565 | u226912938 | 2,000 | 262,144 | Wrong Answer | 23 | 3,188 | 886 | E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One mo... | import re
s = str(input())
t = str(input())
NS = []
for i in range(len(s)):
s_res = s[:i]
s_obj = s[i:]
s_res.replace('?', 'a')
s_w = s_obj.replace('?', '.')
s_re = re.compile(s_w)
matchobj = s_re.fullmatch(t)
if matchobj:
start = matchobj.start()
end = ma... | s169907538 | Accepted | 23 | 3,188 | 1,017 | import re
s = str(input())
t = str(input())
NS = []
for i in range(len(s)):
s_res = s[:i]
s_res = s_res.replace('?', 'a')
s_obj = s[i:i+len(t)]
s_obj = s_obj.replace('?', '.')
s_comp = re.compile(s_obj)
s_res_f = s[i+len(t):]
matchobj = s_comp.fullmatch(t)
... |
s739232234 | p02397 | u957680575 | 1,000 | 131,072 | Wrong Answer | 50 | 7,400 | 200 | Write a program which reads two integers x and y, and prints them in ascending order. | A=1
B=1
x=[]
while True:
if A==0 and B==0:
break
else:
A, B= map(int, input().split())
if A > B:
print(B,A)
else:
print(A,B)
| s282657678 | Accepted | 50 | 7,432 | 192 |
x=[]
while True:
A, B= map(int, input().split())
if A==0 and B==0:
break
else:
if A > B:
print(B,A)
else:
print(A,B)
|
s311771067 | p04043 | u143212659 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 213 | 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 ... | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def main():
ABC = list(map(int, input().split()))
print('Yes' if ABC.count(5) == 2 and ABC.count(7) == 1 else 'No')
if __name__ == "__main__":
main()
| s472115789 | Accepted | 16 | 2,940 | 205 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def main():
ABC = list(map(int, input().split()))
ABC.sort()
print('YES' if [5, 5, 7] == ABC else 'NO')
if __name__ == "__main__":
main()
|
s001101512 | p04030 | u252964975 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 156 | 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 stri... | S=str(input())
str_ = ""
for i in range(len(S)):
if S[i] == "0" or "1":
str_ = str_ + S[i]
elif len(str_) != 0:
str_ = str_.rstrip()
print(str_) | s937103075 | Accepted | 17 | 2,940 | 160 | S=str(input())
str_ = ""
for i in range(len(S)):
if S[i] == "0" or S[i] == "1":
str_ = str_ + S[i]
elif len(str_) != 0:
str_ = str_[:-1]
print(str_) |
s621819452 | p03610 | u922926087 | 2,000 | 262,144 | Wrong Answer | 18 | 3,192 | 12 | 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. | input()[::2] | s116234370 | Accepted | 18 | 3,188 | 139 | # -*- coding: utf-8 -*-
"""
Created on Wed Feb 27 01:06:34 2019
@author: yuta
"""
def oddstring(s):
print(s[::2])
oddstring(input()) |
s829139781 | p03149 | u799215419 | 2,000 | 1,048,576 | Wrong Answer | 19 | 3,188 | 194 | You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974". | import re
S = input()
pattern = r"(.+keyence|k.+eyence|ke.+yence|key.+ence|keye.+nce|keyen.+ce|keyenc.+e|keyence.+|keyence)"
if re.fullmatch(pattern, S):
print("YES")
else:
print("NO")
| s938057964 | Accepted | 17 | 2,940 | 134 | nums = list(map(int, input().split()))
if 1 in nums and 9 in nums and 7 in nums and 4 in nums:
print("YES")
else:
print("NO")
|
s103638490 | p03643 | u202634017 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 36 | This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer. | N = input()
print("abc{}".format(N)) | s959950565 | Accepted | 19 | 2,940 | 27 | N = input()
print("ABC"+N) |
s316773300 | p03779 | u017415492 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 226 | There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be a... | x=int(input())
#n=1
#while 1/2*(n**2+n)<x:
# n+=1
#print(n)
left=0
right=x
while right-left>1:
mid=(left+right)//2
if (mid**2+mid)/2==x:
break
if (mid**2+mid)/2<x:
left=mid
else:
right=mid
print(right) | s494573903 | Accepted | 17 | 3,064 | 237 | x=int(input())
#n=1
#while 1/2*(n**2+n)<x:
# n+=1
#print(n)
left=0
right=x
while right-left>1:
mid=(left+right)//2
if (mid**2+mid)/2==x:
right=mid
break
if (mid**2+mid)/2<x:
left=mid
else:
right=mid
print(right) |
s340134302 | p03861 | u803647747 | 2,000 | 262,144 | Wrong Answer | 36 | 5,076 | 100 | 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? | from decimal import Decimal
a, b, x = map(Decimal, input().split())
int(Decimal(b/x) - Decimal(a/x)) | s866175613 | Accepted | 35 | 5,076 | 174 | from decimal import Decimal
a, b, x = map(Decimal, input().split())
bx = (b/x)
aq, amod = divmod(a, x)
if a==0 or amod==0:
print(int(bx-aq)+1)
else:
print(int(bx-aq)) |
s567908132 | p03486 | u439312138 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 175 | You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order. | s = input()
s_asc = ''.join(sorted(s))
t = input()
t_desc = ''.join(sorted(t, reverse=True))
print(s_asc)
print(t_desc)
if s_asc < t_desc:
print('Yes')
else:
print('No') | s215163728 | Accepted | 18 | 3,064 | 148 | s = input()
s_asc = ''.join(sorted(s))
t = input()
t_desc = ''.join(sorted(t, reverse=True))
if s_asc < t_desc:
print('Yes')
else:
print('No') |
s789789591 | p03447 | u871596687 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 147 | 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 = int(input())
A = int(input())
B = int(input())
N = 0
while True:
if (X-A-B*N)> 0:
N +=1
else:
print(X-A-B*N)
break | s600967124 | Accepted | 17 | 2,940 | 152 | X = int(input())
A = int(input())
B = int(input())
N = 0
while True:
if (X-A-B*N)>= 0:
N +=1
else:
print(X-A-B*(N-1))
break |
s178475352 | p03131 | u311379832 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 67 | Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the ... | K, A, B = map(int, input().split())
if A >= B - 1:
print(K + 1) | s489322176 | Accepted | 17 | 3,060 | 266 | K, A, B = map(int, input().split())
if A >= B - 1 or A >= K:
print(K + 1)
else:
K -= (A + 1)
ans = 0
if K >= 2:
ans = B + ((B - A) * (K // 2))
ans += K % 2
elif K != 0:
ans = B + 1
else:
ans += B
print(ans) |
s586612811 | p02694 | u616619529 | 2,000 | 1,048,576 | Wrong Answer | 25 | 9,020 | 156 | Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or abo... | # -*- coding: utf-8 -*-
x = int(input())
money = 100
year = 0
while (money <= x):
money = int(money*1.01)
print('{}'.format(year))
| s525569827 | Accepted | 23 | 9,068 | 177 | # -*- coding: utf-8 -*-
x = int(input())
money = 100
year = 0
while (money < x):
money = int(money * 1.01)
year = year + 1
print('{}'.format(year))
|
s245919798 | p03486 | u257974487 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 375 | You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order. | s = input()
t = input()
p = []
q = []
m = len(s)
n = len(t)
ans = 0
for i in range(m):
p.append(s[i])
p.sort()
for j in range(n):
q.append(t[j])
q.sort()
if m >= n:
ans = "No"
else:
ans = "Yes"
for k in range(min(m,n)):
if ord(p[k]) < ord(q[k]):
ans = "Yes"
break
elif ord(p[k]) >... | s515599923 | Accepted | 17 | 3,064 | 380 | s = input()
t = input()
p = []
q = []
m = len(s)
n = len(t)
if m >= n:
ans = "No"
else:
ans = "Yes"
for i in range(m):
p.append(s[i])
p.sort()
for j in range(n):
q.append(t[j])
q.sort(reverse=True)
for k in range(min(m,n)):
if ord(p[k]) < ord(q[k]):
ans = "Yes"
break
elif ord(p[k... |
s177493995 | p03214 | u691170040 | 2,525 | 1,048,576 | Wrong Answer | 18 | 3,060 | 232 | Niwango-kun is an employee of Dwango Co., Ltd. One day, he is asked to generate a thumbnail from a video a user submitted. To generate a thumbnail, he needs to select a frame of the video according to the following procedure: * Get an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the numbe... | N = int(input())
at = input().split(" ")
a = []
for i in at:
a.append(int(i))
avg = sum(a) / N
mdif, flag = abs(a[0]-avg), 0
for i in range(len(a)):
if a[i]-avg < mdif:
mdif = a[i] - avg
flag = i
print(flag)
| s321042773 | Accepted | 18 | 3,060 | 240 | N = int(input())
at = input().split(" ")
a = []
for i in at:
a.append(int(i))
avg = sum(a) / N
mdif, flag = abs(a[0]-avg), 0
for i in range(len(a)):
if abs(a[i]-avg) < mdif:
mdif = abs(a[i]-avg)
flag = i
print(flag)
|
s651846610 | p02694 | u464205401 | 2,000 | 1,048,576 | Wrong Answer | 24 | 9,164 | 89 | Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or abo... | x=int(input())
a=100
cnt=0
while x>=a:
a=int(a*1.01)
# print(a)
cnt+=1
print(cnt) | s559074683 | Accepted | 23 | 9,164 | 74 | x=int(input())
a=100
cnt=0
while x>a:
a=int(a*1.01)
cnt+=1
print(cnt) |
s643464567 | p03377 | u736729525 | 2,000 | 262,144 | Wrong Answer | 19 | 2,940 | 151 | There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals. | A, B, X = [int(x) for x in input().split()]
def solve(A, B, X):
if A + B < X:
print("NO")
elif A > X:
print("NO")
else:
print("YES") | s468267117 | Accepted | 17 | 2,940 | 118 | A, B, X = [int(x) for x in input().split()]
if A + B < X:
print("NO")
elif A > X:
print("NO")
else:
print("YES") |
s109200861 | p03730 | u780459096 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 222 | We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objecti... | # -*- coding: utf-8 -*-
a, b, c = map(int, input().split())
rest = a % b
num = a
while True:
if num % b == c:
print('Yes')
exit()
num+=a
if num % b == rest:
print('No')
exit() | s342976496 | Accepted | 17 | 2,940 | 223 | # -*- coding: utf-8 -*-
a, b, c = map(int, input().split())
rest = a % b
num = a
while True:
if num % b == c:
print('YES')
exit()
num+=a
if num % b == rest:
print('NO')
exit()
|
s032830875 | p03469 | u103902792 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 66 | On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date col... | s= input()
if s[4]=='2017':
print('2018'+s[4:])
else:
print(s) | s525784857 | Accepted | 27 | 8,980 | 40 | s= input()
print(s[:3] + '8' + s[4:])
|
s488084945 | p03997 | u263691873 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 63 | You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid. | a=int(input())
b=int(input())
h = int(input())
print((a+b)*h/2) | s820305714 | Accepted | 17 | 2,940 | 68 | a=int(input())
b=int(input())
h = int(input())
print(int((a+b)*h/2)) |
s730377166 | p02972 | u845333844 | 2,000 | 1,048,576 | Wrong Answer | 717 | 10,304 | 205 | There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following con... | n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n,0,-1):
m=n//i
total=0
for j in range(1,m+1):
total+=a[i*j-1]
b[i-1]=total%2
ans=sum(b)
print(ans)
print(*b) | s122170973 | Accepted | 805 | 14,140 | 361 | n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n,0,-1):
m=n//i
total=0
for j in range(1,m+1):
if j==1:
total+=a[i-1]
else:
total+=b[i*j-1]
b[i-1]=total%2
ans=sum(b)
print(ans)
if ans != 0:
l=[]
for i in range(n):
if b[i]==1... |
s550275877 | p02397 | u666221014 | 1,000 | 131,072 | Wrong Answer | 20 | 7,448 | 43 | Write a program which reads two integers x and y, and prints them in ascending order. | print( " ".join( sorted( input().split()))) | s010385178 | Accepted | 60 | 7,628 | 144 | while True :
a, b = [int(i) for i in input().split()]
if a == b == 0 : break
elif a >= b :
print(b, a)
else : print(a,b) |
s367973556 | p02261 | u150984829 | 1,000 | 131,072 | Wrong Answer | 20 | 5,600 | 301 | Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubbl... | n=int(input())
c=input().split();d=c[:]
for i in range(n-1):
for j in range(0,n-i-1):
if c[j][1]>c[j+1][1]:c[j],c[j+1]=c[j+1],c[j]
m=d.index(min(d[i:]),i)
if d[i][1]>=d[m][1]:d[i],d[m]=d[m],d[i]
print(*c);print("Stable")
print(*d)
b={i[1]for i in c}
print(["Stable","Not stable"][len(b)<len(c)])
| s101393687 | Accepted | 20 | 5,604 | 273 | n=int(input())
c=input().split();d=c[:]
for i in range(n-1):
for j in range(n-i-1):
if c[j][1]>c[j+1][1]:c[j:j+2]=c[j+1],c[j]
m=i
for j in range(i,n):
if d[m][1]>d[j][1]:m=j
d[i],d[m]=d[m],d[i]
print(*c);print("Stable")
print(*d);print(['Not s','S'][c==d]+'table')
|
s647900971 | p03610 | u544050502 | 2,000 | 262,144 | Wrong Answer | 20 | 3,192 | 20 | 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. | print(input()[1::2]) | s474094729 | Accepted | 18 | 3,192 | 19 | print(input()[::2]) |
s946835948 | p02290 | u629780968 | 1,000 | 131,072 | Wrong Answer | 20 | 5,636 | 528 | For given three points p1, p2, p, find the projection point x of p onto p1p2. | def dot(a, b):
return a.real * b.real + a.imag * b.imag
def projection(a, b):
return a * dot(a, b) / (abs(a) ** 2)
def solve(p0,p1,p2):
a=p1-p0
b=p2-p0
pro=projection(a,b)
t=p0+pro
return t
def main():
x0,y0,x1,y1=map(float,input().split())
p0=complex(x0,y0)
p1=complex(x1,y1)
q=int(input())
... | s273581809 | Accepted | 30 | 5,652 | 527 | def dot(a, b):
return a.real * b.real + a.imag * b.imag
def projection(a, b):
return a * dot(a, b) / (abs(a) ** 2)
def solve(p0,p1,p2):
a=p1-p0
b=p2-p0
pro=projection(a,b)
t=p0+pro
return t
def main():
x0,y0,x1,y1=map(float,input().split())
p0=complex(x0,y0)
p1=complex(x1,y1)
q=int(input())
... |
s575726233 | p03387 | u513081876 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 281 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be ... | A, B, C = map(int, input().split())
sta = max(A, B, C)
ans = 0
if (B-A) >= 2:
kake = (B-A)//2
A = A*kake
ans += kake
if (B-C) >= 2:
kake = (B-C)//2
C = C*kake
ans += kake
if A == B == C:
print(ans)
elif A == C:
print(ans+1)
else:
print(ans+2) | s590617593 | Accepted | 18 | 3,064 | 409 | A, B, C = map(int, input().split())
ans = 0
max_ABC = max(A, B, C)
if max_ABC != A:
ans += (max_ABC - A) // 2
A += 2 * ((max_ABC-A) // 2)
if max_ABC != B:
ans += (max_ABC - B) // 2
B += 2 * ((max_ABC-B) // 2)
if max_ABC != C:
ans += (max_ABC - C) // 2
C += 2 * ((max_ABC-C) // 2)
if 3 * max_... |
s228884575 | p03862 | u281610856 | 2,000 | 262,144 | Wrong Answer | 82 | 14,540 | 396 | There are N boxes arranged in a row. Initially, the i-th box from the left contains a_i candies. Snuke can perform the following operation any number of times: * Choose a box containing at least one candy, and eat one of the candies in the chosen box. His objective is as follows: * Any two neighboring boxes con... | def main():
n, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
if A[0] > x:
ans += A[0] - x
A[0] = x
print(ans)
for i in range(n - 1):
j = i + 1
if j < n and A[i] + A[j] > x:
diff = A[i] + A[j] - x
ans += diff
... | s405338909 | Accepted | 85 | 14,252 | 381 | def main():
n, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
if A[0] > x:
ans += A[0] - x
A[0] = x
for i in range(n - 1):
j = i + 1
if j < n and A[i] + A[j] > x:
diff = A[i] + A[j] - x
ans += diff
A[j] -... |
s631253083 | p03474 | u766566560 | 2,000 | 262,144 | Wrong Answer | 19 | 3,188 | 145 | The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom. | import re
A, B = map(int, input().split())
S = input()
result = re.match('[0-9]{A}-[0-9]{B}', S)
if result:
print('Yes')
else:
print('No') | s951446321 | Accepted | 19 | 3,188 | 190 | import re
A, B = map(int, input().split())
S = input()
pattern = '[0-9]{' + str(A) + '}-[0-9]{' + str(B) + '}'
result = re.match(pattern, S)
if result:
print('Yes')
else:
print('No') |
s806903893 | p04030 | u099300051 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 189 | 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 stri... | S = input()
ansS = ""
ansL = 0
for i in range(len(S)):
if S[i] == 'B':
if len(ansS) != 0 :
ansL = len(ansS)
ansS = ansS[:ansL-1]
else:
ansS += S[i]
print(int(ansS)) | s554271585 | Accepted | 17 | 2,940 | 156 | S = input()
ans =''
for x in S:
if x == '0':
ans += x
elif x == '1':
ans += x
else:
if ans!='':
ans = ans[:-1]
print(ans)
|
s418929272 | p03854 | u409757418 | 2,000 | 262,144 | Wrong Answer | 84 | 3,188 | 475 | You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. | s = input()
n = 0
while n == 0:
if s[len(s)-5:len(s)] == "dream":
s = s.rstrip("ream")
s = s.rstrip("d")
elif s[len(s)-5:len(s)] == "erase":
s = s.rstrip("rase")
s = s.rstrip("e")
elif s[len(s)-7:len(s)] == "dreamer":
s = s.rstrip("reamer")
s = s.rstrip("d")
elif s[len(s)-6:len(s)] == "e... | s551738598 | Accepted | 80 | 3,188 | 369 | s = input()
n = 0
while n == 0:
if s[len(s)-5:len(s)] == "dream":
s = s[:len(s)-5]
elif s[len(s)-5:len(s)] == "erase":
s = s[:len(s)-5]
elif s[len(s)-7:len(s)] == "dreamer":
s = s[:len(s)-7]
elif s[len(s)-6:len(s)] == "eraser":
s = s[:len(s)-6]
else:
if len(s) == 0:
n = 1
print... |
s769124263 | p03474 | u908349502 | 2,000 | 262,144 | Wrong Answer | 20 | 3,188 | 200 | The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom. | a,b=map(int,input().split())
s=input()
f=1
for i in range(a):
if s[i]=='-':
f=0
if[a]!='-':
f=0
for j in range(b):
if s[a+1+j]=='-':
f=0
if f:
print('Yes')
else:
print('No') | s828358781 | Accepted | 20 | 3,060 | 202 | a,b=map(int,input().split())
s=input()
f=1
for i in range(a):
if s[i]=='-':
f=0
if s[a]!='-':
f=0
for j in range(b):
if s[a+1+j]=='-':
f=0
if f:
print('Yes')
else:
print('No') |
s548944614 | p03158 | u543954314 | 2,000 | 1,048,576 | Wrong Answer | 1,450 | 23,972 | 581 | There are N cards. The i-th card has an integer A_i written on it. For any two cards, the integers on those cards are different. Using these cards, Takahashi and Aoki will play the following game: * Aoki chooses an integer x. * Starting from Takahashi, the two players alternately take a card. The card should be c... | n,q = map(int,input().split())
a = list(map(int,input().split()))
g = [0]*(n+1)
h = [0] + a[1-n%2::2]
m = len(h)-1
for i in range(n):
g[i+1] = g[i] + a[i]
for i in range(m):
h[i+1] += h[i]
d = {10**10:h[-1]}
for j in range(1,(n+1)//2+1):
tak = g[n] - g[n-j] + h[(n-2*j)//2+n%2]
key = (a[n-j]+a[n-2*j])//2 + 1
d... | s485233366 | Accepted | 910 | 23,456 | 504 | import bisect
n, q = map(int,input().split())
a = list(map(int,input().split()))
a.reverse()
cums = [0]*(n+1)
cume = [0]*(n+1)
for i in range(n):
cums[i+1] = cums[i] + a[i]
cume[i+1] = cume[i] + a[i]*(1 - i%2)
bo = list()
sc = list()
for i in range(1,(n+1)//2):
b = (a[i] + a[2*i])//2 + 1
bo.append(b)
... |
s462785513 | p03828 | u844646164 | 2,000 | 262,144 | Wrong Answer | 26 | 3,316 | 453 | You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7. |
import math
from collections import Counter
from collections import defaultdict
mod = 10**9+7
def prime(n):
for i in range(2, math.ceil(math.sqrt(n))+1):
while n % i == 0:
n /= i
prime_count[i] += 1
if n > 1:
prime_count[int(n)] += 1
n = int(input())
a = 1
prime_count = defaultdict(int)
for ... | s991799615 | Accepted | 25 | 3,316 | 434 |
import math
from collections import Counter
from collections import defaultdict
mod = 10**9+7
def prime(n):
for i in range(2, math.ceil(math.sqrt(n))+1):
while n % i == 0:
n /= i
prime_count[i] += 1
if n > 1:
prime_count[int(n)] += 1
n = int(input())
a = 1
prime_count = defaultdict(int)
for ... |
s839383826 | p03486 | u302292660 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 208 | You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order. | s = input()
t = input()
Ls= []
Lt= []
for i in s:
Ls.append(i)
Ls = "".join(Ls)
for i in t:
Lt.append(i)
Lt = "".join(Lt)
L = [Ls,Lt]
L = sorted(L)
if L[0]==Ls:
print("Yes")
else:
print("No")
| s840286680 | Accepted | 17 | 3,064 | 388 | s = sorted(input())
t = sorted(input())[::-1]
Ls= []
Lt= []
if len(s)<len(t) and set(s) == set(s)&set(t):
print("Yes")
else:
for i in s:
Ls.append(i)
Ls = "".join(Ls)
for i in t:
Lt.append(i)
Lt = "".join(Lt)
L = [Ls,Lt]
L = sorted(L)
if L[0]==L[1]:
print("No")
... |
s204307484 | p03695 | u787456042 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 131 | In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows: * Rating 1-399 : gray * Rating 400-799 : brown * Rating 800-1199 : green * Rating 1200-1599 : cyan * Rating 1600-1999 : blue * Rating 2000-2399 : yellow * Rating 2400-2799 : or... | N,*A=map(int,open(0).read().split());l=[0]*9
for a in A:l[min(8,a//400)]+=1
m=sum([0<l[i]for i in range(8)]);print(min(m,1),m+l[8]) | s445359273 | Accepted | 17 | 3,060 | 131 | N,*A=map(int,open(0).read().split());l=[0]*9
for a in A:l[min(8,a//400)]+=1
m=sum([0<l[i]for i in range(8)]);print(max(m,1),m+l[8]) |
s219974358 | p03697 | u870297120 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 68 | You are given two integers A and B as the input. Output the value of A + B. However, if A + B is 10 or greater, output `error` instead. | a,b = map(int, input().split())
print(a+b if a+b >= 10 else 'error') | s283015502 | Accepted | 17 | 2,940 | 67 | a,b = map(int, input().split())
print(a+b if a+b < 10 else 'error') |
s351569527 | p03227 | u663710122 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 47 | You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it. | S = input()
print(S if len(S) == 2 else S[-1]) | s734902329 | Accepted | 17 | 2,940 | 49 | S = input()
print(S if len(S) == 2 else S[::-1]) |
s040592988 | p04043 | u843318346 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 113 | Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each ... | arr = list(map(int,input().split()))
if arr[0]==5 and arr[1]==7 and arr[2]==5:
print('YES')
else:
print('NO') | s727935527 | Accepted | 17 | 2,940 | 111 | arr = list(map(int,input().split()))
if arr.count(5)==2 and arr.count(7)==1:
print('YES')
else:
print('NO') |
s040278991 | p03472 | u924374652 | 2,000 | 262,144 | Time Limit Exceeded | 2,108 | 21,620 | 751 | You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of d... | n, h = map(int, input().split())
list_w = []
max_a = [-1, -1, 10**9]
for i in range(n):
a, b = list(map(int, input().split()))
list_w.append([a, b])
if max_a[1] < a:
max_a = [i, a, b]
elif max_a[1] == a and max_a[2] > b:
max_a = [i, a, b]
list_w.pop(max_a[0])
list_w.sort(key=lambda x:x[1], reverse=Tru... | s783726510 | Accepted | 1,924 | 12,104 | 399 | import math
n, h = map(int, input().split())
list_a = []
list_b = []
for i in range(n):
a, b = list(map(int, input().split()))
list_a.append(a)
list_b.append(b)
max_a = max(list_a)
use_b = [b for b in list_b if b > max_a]
use_b.sort(reverse=True)
count = 0
while h > 0:
if len(use_b) > 0:
h -= use_b.pop(0)
... |
s168373250 | p03380 | u740284863 | 2,000 | 262,144 | Wrong Answer | 2,229 | 2,018,104 | 456 | Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. | import math
import itertools
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(input())
a = list(map(int,input().split()))
b = list(itertools.combinations(a,2))
ans = [0,(0,0)]
#print(b)
for i in range(len(b)):
tmpans = combinations_count(max(b[i][0]... | s642913715 | Accepted | 71 | 14,428 | 162 | n = int(input())
a = list(map(int,input().split()))
m = max(a)
del a[a.index(m)]
dis = [abs(m/2 - a[i]) for i in range(n-1)]
r = a[dis.index(min(dis))]
print(m,r) |
s597648333 | p03779 | u113971909 | 2,000 | 262,144 | Wrong Answer | 2,131 | 309,816 | 485 | There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be a... | X=int(input())
from collections import deque
def dfs_2(start,goal):
q = deque([])
q.append([start])
flg = 0
while flg==0:
p = q.popleft() 取りだし(先頭)
jp = len(p)
if p[-1]-jp == goal or p[-1]+jp == goal:
print(p)
return jp
else:
p0 = [p[-1]]
pp = [p[-1]+jp]
... | s500038276 | Accepted | 24 | 2,940 | 80 | X=int(input())
s=0
for t in range(X+1):
s+=t
if s>=X:
print(t)
break |
s598667018 | p02281 | u939814144 | 1,000 | 131,072 | Wrong Answer | 20 | 7,752 | 3,726 | Binary trees are defined recursively. A binary tree _T_ is a structure defined on a finite set of nodes that either * contains no nodes, or * is composed of three disjoint sets of nodes: \- a root node. \- a binary tree called its left subtree. \- a binary tree called its right subtree. Your task is to wr... | class Node:
def __init__(self, node_id, left_child, right_child):
self.node_id = node_id
self.parent = -1
self.sibling = -1
self.degree = 0
self.depth = 0
self.height = 0
self.node_type = ''
self.left_child = left_child
self.right_child = righ... | s363025456 | Accepted | 20 | 7,848 | 3,863 | class Node:
def __init__(self, node_id, left_child, right_child):
self.node_id = node_id
self.parent = -1
self.sibling = -1
self.degree = 0
self.depth = 0
self.height = 0
self.node_type = ''
self.left_child = left_child
self.right_child = righ... |
s078574243 | p04045 | u013408661 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 453 | 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 ... | n,k=map(int,input().split())
d=list(map(int,input().split()))
number=[]
for i in range(10):
number.append(i)
likenumber=[i for i in number if i not in d]
n=list(str(n))
n=list(map(int,n))
for i in range(len(n)-1,-1,-1):
if n[i]>9:
if i==len(n)-1:
n.insert(0,0)
n[i]-=10
n[i-1]+=1
if n[i] in d:
... | s118033173 | Accepted | 79 | 2,940 | 203 | n,k=map(int,input().split())
d=list(map(int,input().split()))
for i in range(n,10**6):
flag=True
for j in str(i):
if int(j) in d:
flag=False
break
if flag:
print(i)
exit()
|
s906114495 | p03360 | u335278042 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 94 | There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after... | lis = list(map(int,input().split()))
K = int(input())
s=sum(lis)-max(lis)+max(lis)**K
print(s) | s462732279 | Accepted | 17 | 2,940 | 96 | lis = list(map(int,input().split()))
K = int(input())
s=sum(lis)-max(lis)+max(lis)*2**K
print(s) |
s740833088 | p02936 | u818078165 | 2,000 | 1,048,576 | Wrong Answer | 2,071 | 144,764 | 719 | Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operati... | n,q = map(int,input().split())
#print(n,q)
edge=[]
for i in range(n-1):
a = list(map(int,input().split()))
edge.append(a)
add_list = []
for i in range(q):
p = list(map(int,input().split()))
add_list.append(p)
#print(edge,add_list)
ans = [0] * n
edge_list = [[] for i in range(n)]
for e in edge:
... | s531227673 | Accepted | 1,993 | 312,792 | 727 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(900000)
n, q = map(int, input().split())
#print(n,q)
edge = []
for i in range(n-1):
a = list(map(int, input().split()))
edge.append(a)
add_list = []
for i in range(q):
p = list(map(int, input().split()))
add_list.append(p)
#print(edge,add_l... |
s776043285 | p03479 | u853900545 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 84 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possibl... | x,y = map(int,input().split())
c = 0
d = y//x
while 2**c <= d:
c += 1
print(c-1) | s603880313 | Accepted | 18 | 2,940 | 82 | x,y = map(int,input().split())
c = 0
d = y//x
while 2**c <= d:
c += 1
print(c) |
s707821038 | p04030 | u016901717 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 106 | 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 stri... | t=""
for i in input():
if i=="B":
t=t[:-1]
else:
t+=i
print(t)
| s350277935 | Accepted | 17 | 2,940 | 105 | t=""
for i in input():
if i=="B":
t=t[:-1]
else:
t+=i
print(t)
|
s001981641 | p03378 | u109796335 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 423 | There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a c... | input_data = input().replace("\n", " ").split(" ")
n, m, x = int(input_data[0]), int(input_data[1]), int(input_data[2])
def problemB(n, m, x):
masu_list = [0] * (n+1)
adder = input_data[3:]
for i in adder:
masu_list[int(i)] = 1
front = sum(masu_list[:x])
back = sum(masu_list[x+1:])
... | s167711567 | Accepted | 17 | 3,064 | 405 | input_front = input().split(" ")
input_back = input().split(" ")
n, x = int(input_front[0]), int(input_front[2])
def problemB(n, x):
masu_list = [0] * (n+1)
adder = input_back
for i in adder:
masu_list[int(i)] = 1
front = sum(masu_list[:x])
back = sum(masu_list[x+1:])
if front <= bac... |
s398879114 | p03854 | u034782764 | 2,000 | 262,144 | Wrong Answer | 96 | 3,380 | 413 | 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()
a=('dream','dreamer','erase','eraser')
s_2=s[::-1]
a_2=(a[0][::-1],a[1][::-1],a[2][::-1],a[3][::-1])
#print(s_2)
#print(a_2)
while len(s_2) > 0:
judge = [s_2.startswith(i) for i in a_2]
#print(judge)
if any(judge)==True:
target=a[judge.index(True)]
s_2=s_2[len(target):]
... | s163210971 | Accepted | 95 | 3,188 | 321 | given = ["dreamer", "dream", "eraser", "erase"]
S = input()
while len(S) > 0:
judge = [S.endswith(i) for i in given]
if any(judge):
target = given[judge.index(True)]
S = S[:-len(target)]
if len(S) == 0:
print("YES")
break
else:
print("NO")
brea... |
s549992674 | p02663 | u619551113 | 2,000 | 1,048,576 | Wrong Answer | 21 | 9,160 | 123 | In this problem, we use the 24-hour clock. Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying? | li = list(map(int,input().split()))
h1, m1, h2, m2, k = li
life_time = (h2 - h1)*60 + (m2 - m1)
time = life_time - k
| s620503572 | Accepted | 23 | 9,164 | 135 | li = list(map(int,input().split()))
h1, m1, h2, m2, k = li
life_time = (h2 - h1)*60 + (m2 - m1)
time = life_time - k
print(time)
|
s113127252 | p03544 | u178432859 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 92 | It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2) | l = [0,1]
n = int(input())
for i in range(2,n+1):
l.append(l[i-1] + l[i-2])
print(l[-1]) | s347692573 | Accepted | 17 | 2,940 | 88 | l = [2,1]
n = int(input())
for i in range(n-1):
l.append(l[i] + l[i+1])
print(l[-1]) |
s263958350 | p03997 | u516579758 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 61 | You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid. | a=int(input())
b=int(input())
h=int(input())
print((a+b)*h/2) | s116840793 | Accepted | 17 | 2,940 | 62 | a=int(input())
b=int(input())
h=int(input())
print((a+b)*h//2) |
s847165915 | p03163 | u219417113 | 2,000 | 1,048,576 | Wrong Answer | 304 | 21,236 | 512 | There are N items, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), Item i has a weight of w_i and a value of v_i. Taro has decided to choose some of the N items and carry them home in a knapsack. The capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W. Find ... | import numpy as np
n, W = map(int, input().split())
w, v = [0] * n, [0] * n
for i in range(n):
w[i], v[i] = map(int, input().split())
ndp = np.zeros(W + 1, dtype=np.int64)
print(ndp)
for w, v in zip(w, v):
np.maximum(ndp[:-w] + v, ndp[w:], out=ndp[w:])
print(ndp[-1])
| s319747855 | Accepted | 171 | 14,584 | 500 | import numpy as np
n, W = map(int, input().split())
w, v = [0] * n, [0] * n
for i in range(n):
w[i], v[i] = map(int, input().split())
ndp = np.zeros(W + 1, dtype=np.int64)
for w, v in zip(w, v):
np.maximum(ndp[:-w] + v, ndp[w:], out=ndp[w:])
print(ndp[-1])
|
s042699889 | p02614 | u253093300 | 1,000 | 1,048,576 | Wrong Answer | 26 | 9,168 | 119 | We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation... | H, W, K = map(int, input().split(' '))
board = []
for _ in range(H):
board.append([c for c in input()])
print('1') | s199691419 | Accepted | 65 | 9,052 | 463 | H, W, K = map(int, input().split(' '))
mat = []
for _ in range(H):
mat.append(input())
ans = 0
for ib in range(1<<H):
for jb in range(1<<W):
count = 0
for i in range(H):
for j in range(W):
if ib>>i&1:
continue
if jb>>j&1:
... |
s145017746 | p03048 | u248670337 | 2,000 | 1,048,576 | Wrong Answer | 1,210 | 2,940 | 148 | Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g... | r,g,b,n=map(int,input().split())
c=0
for i in range(n//r+1):
a=r*i
for j in range(a,n//g+1):
a+=g*j
if (n-a)%b:
c+=1
print(c) | s308322989 | Accepted | 1,273 | 2,940 | 141 | r,g,b,n=map(int,input().split())
a=0
for i in range(n//r+1):
x=r*i
for j in range((n-x)//g+1):
if (n-x-g*j)%b==0:
a+=1
print(a) |
s127016682 | p03555 | u207799478 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 103 | 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. | a=input()
b=input()
if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]:
print('Yes')
else:
print('No') | s523387918 | Accepted | 17 | 2,940 | 137 | # coding: utf-8
# Your code here!
a=input()
b=input()
if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]:
print('YES')
else:
print('NO') |
s641772826 | p03854 | u811176339 | 2,000 | 262,144 | Wrong Answer | 127 | 9,172 | 301 | 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`. | lt = ["dream", "dreamer", "erase", "eraser"]
s = input()
lt = [w[::-1] for w in lt]
s = s[::-1]
cond = True
i = 0
while i < len(s):
for t in lt:
if s[i:].startswith(t):
i += len(t)
break
else:
cond = False
break
print("Yes" if cond else "No")
| s139566402 | Accepted | 123 | 9,208 | 301 | lt = ["dream", "dreamer", "erase", "eraser"]
s = input()
lt = [w[::-1] for w in lt]
s = s[::-1]
cond = True
i = 0
while i < len(s):
for t in lt:
if s[i:].startswith(t):
i += len(t)
break
else:
cond = False
break
print("YES" if cond else "NO")
|
s685673583 | p03761 | u088552457 | 2,000 | 262,144 | Wrong Answer | 21 | 3,316 | 405 | Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headlin... | import collections
n = int(input())
s = [input() for i in range(n)]
if n == 1:
print("".join(sorted(s[0])))
else:
c = []
for i in s:
c.append(collections.Counter(i))
a = c[0]
for i in range(1, n):
a &= c[i]
ans = []
a = a.most_common()
print(a)
for i in a:
... | s823414131 | Accepted | 20 | 3,064 | 347 | n = int(input())
ss = []
mins = 'a'*100
for _ in range(n):
s = str(''.join(sorted(input())))
ss.append(s)
if len(mins) > len(s):
mins = s
ans = ''
for w in mins:
ok = True
for i, s in enumerate(ss[:]):
if w in s:
wi = s.find(w)
ss[i] = s[:wi] + s[wi+1:]
else:
ok = False
if ... |
s894706038 | p02972 | u089142196 | 2,000 | 1,048,576 | Wrong Answer | 388 | 7,276 | 496 | There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following con... | N=int(input())
A=list(map(int, input().split()))
A.insert(0,0)
total=sum(A)
sum=0
count=0
OK_Flag=True
OK_list=[]
for i in range(1,N+1):
sum=0
for j in range(i,N+1,i):
if OK_Flag==True:
#print(i,A[j-1])
sum=sum+A[j]
#print(i,j,sum)
#print(sum,sum%2,A[i])
if sum%2==A[i]:
if A[i]==1:
... | s327981141 | Accepted | 268 | 14,132 | 291 | N=int(input())
a=list(map(int, input().split()))
b=[0]*N
for i in range(N-1,-1,-1):
summ = sum(b[2*i+1::i+1])
if summ%2==0:
b[i] = a[i]
else:
b[i] = 1-a[i]
#print(i,summ,b[i])
ans=[]
print(sum(b))
for i,num in enumerate(b):
if num==1:
ans.append(i+1)
print(*ans) |
s109176971 | p02613 | u005569385 | 2,000 | 1,048,576 | Wrong Answer | 140 | 16,300 | 230 | Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`,... | N = int(input())
s = [input() for i in range(N)]
a = s.count("AC")
b = s.count("WA")
c = s.count("TLE")
d = s.count("RE")
print("AC * {}".format(a))
print("WA * {}".format(b))
print("TLE * {}".format(c))
print("RE * {}".format(d)) | s008194399 | Accepted | 139 | 16,304 | 230 | N = int(input())
s = [input() for i in range(N)]
a = s.count("AC")
b = s.count("WA")
c = s.count("TLE")
d = s.count("RE")
print("AC x {}".format(a))
print("WA x {}".format(b))
print("TLE x {}".format(c))
print("RE x {}".format(d)) |
s739094443 | p03470 | u039192119 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 55 | An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you h... | print(len([int(input()) for i in range(int(input()))])) | s127030418 | Accepted | 18 | 2,940 | 64 | a=[int(input()) for i in range(int(input()))]
print(len(set(a))) |
s315303295 | p03943 | u860002137 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 90 | Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Not... | a, b, c = map(int, input().split())
print("Yes") if (a + b + c) // 2 == 0 else print("No") | s313268042 | Accepted | 17 | 2,940 | 116 | a, b, c = map(int, input().split())
whole = a + b + c
print("Yes") if (whole / 2) == max([a, b, c]) else print("No") |
s282183703 | p02401 | u925992597 | 1,000 | 131,072 | Wrong Answer | 20 | 7,328 | 75 | 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:
try:
print(eval(input()))
except:
break | s401345194 | Accepted | 30 | 7,344 | 80 | while True:
try:
print(int(eval(input())))
except:
break |
s027473613 | p02578 | u914802579 | 2,000 | 1,048,576 | Wrong Answer | 110 | 32,372 | 141 | N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a ... | n=int(input())
l=list(map(int,input().split()))
mx=l[0]
an=0
for i in range(1,n):
if l[i]<mx:
an+=mx-l[i]
else:
l[i]=mx
print(an) | s538777833 | Accepted | 116 | 32,380 | 141 | n=int(input())
l=list(map(int,input().split()))
mx=l[0]
an=0
for i in range(1,n):
if l[i]<mx:
an+=mx-l[i]
else:
mx=l[i]
print(an) |
s998533189 | p03696 | u039623862 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 177 | You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of... | n = int(input())
s = input()
cnt = [0, 0]
ans = ''
for i in range(n):
if s[i] == ')':
cnt[0] += 1
else:
cnt[1] += 1
print('(' * cnt[0] + s + ')'*cnt[1])
| s736450027 | Accepted | 17 | 3,060 | 277 | n = int(input())
s = input()
cnt = [0, 0]
add = [0, 0]
ans = ''
for i in range(n):
if s[i] == ')':
cnt[0] += 1
if cnt[0] > cnt[1]:
add[1] += 1
cnt[1] += 1
else:
cnt[1] += 1
print('(' * add[1] + s + ')'*(cnt[1] -cnt[0]))
|
s875244795 | p00045 | u301729341 | 1,000 | 131,072 | Time Limit Exceeded | 40,000 | 7,612 | 238 | 販売単価と販売数量を読み込んで、販売金額の総合計と販売数量の平均を出力するプログラムを作成してください。 | P_Sum = 0
N_Sum = 0
Kazu = 0
while True:
try:
pri,num = map(int,input().split(","))
P_Sum += num * pri
N_Sum += num
Kazu += 1
except EOFError:
print(P_Sum)
print(round(N_Sum / Kazu)) | s594649971 | Accepted | 20 | 7,584 | 269 | P_Sum = 0
N_Sum = 0
Kazu = 0
while True:
try:
pri,num = map(int,input().split(","))
P_Sum += num * pri
N_Sum += num
Kazu += 1
except(EOFError,ValueError):
print(P_Sum)
print(int((N_Sum / Kazu)+ 0.5))
break |
s720520842 | p03048 | u254050469 | 2,000 | 1,048,576 | Wrong Answer | 1,893 | 3,316 | 422 | Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g... | n = [int(i) for i in input().split() ]
rgb = n[0:3]
rgb.sort(reverse=True)
#rgb = list(filter(lambda x:x >= n[3],rgb))
rm = int(n[3]/rgb[0] ) + 1
c = 0
for i in range(rm):
print(i)
if i * rgb[0] == n[3]:
c += 1
break
for j in range(int((n[3] - i * rgb[0])/rgb[1]) + 1):
... | s231917311 | Accepted | 1,833 | 3,064 | 409 | n = [int(i) for i in input().split() ]
rgb = n[0:3]
rgb.sort(reverse=True)
#rgb = list(filter(lambda x:x >= n[3],rgb))
rm = int(n[3]/rgb[0] ) + 1
c = 0
for i in range(rm):
if i * rgb[0] == n[3]:
c += 1
break
for j in range(int((n[3] - i * rgb[0])/rgb[1]) + 1):
... |
s882700153 | p03494 | u248670337 | 2,000 | 262,144 | Time Limit Exceeded | 2,104 | 2,940 | 96 | 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. | input()
A=list(map(int,input().split()))
ans=0
while all(a%2==0 for a in A):
ans+=1
print(ans) | s512479952 | Accepted | 22 | 3,060 | 117 | input()
A=list(map(int,input().split()))
ans=0
while all(a%2==0 for a in A):
A=[a/2 for a in A]
ans+=1
print(ans) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.