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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s752411927
|
p03712
|
u323680411
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,064
| 591
|
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.
|
from sys import stdin
def main():
h, w = map(int, input().split())
a = [next_str() for _ in range(h)]
for i in range(h + 2):
print("#", end="")
if not 0 < i <= h:
print("#" * w, end="")
else:
print([i - 1], end="")
print("#")
def next_int() -> int:
return int(next_str())
def next_str() -> str:
result = ""
while True:
tmp = stdin.read(1)
if tmp.strip() != "":
result += tmp
elif tmp != '\r':
break
return result
if __name__ == '__main__':
main()
|
s223217608
|
Accepted
| 20
| 3,064
| 592
|
from sys import stdin
def main():
h, w = map(int, input().split())
a = [next_str() for _ in range(h)]
for i in range(h + 2):
print("#", end="")
if not 0 < i <= h:
print("#" * w, end="")
else:
print(a[i - 1], end="")
print("#")
def next_int() -> int:
return int(next_str())
def next_str() -> str:
result = ""
while True:
tmp = stdin.read(1)
if tmp.strip() != "":
result += tmp
elif tmp != '\r':
break
return result
if __name__ == '__main__':
main()
|
s717826323
|
p03609
|
u377036395
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 73
|
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
|
X,t = map(int,input().split())
if t >= X:
print(0)
else:
print(t - X)
|
s900630619
|
Accepted
| 17
| 2,940
| 73
|
X,t = map(int,input().split())
if t >= X:
print(0)
else:
print(X - t)
|
s718057720
|
p02936
|
u264867962
| 2,000
| 1,048,576
|
Wrong Answer
| 1,290
| 231,788
| 471
|
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations.
|
from sys import setrecursionlimit
setrecursionlimit(10 ** 6)
N, Q = map(int, input().split())
graph = [ [] for _ in range(N) ]
queries = { p: 0 for p in range(N) }
for _ in range(N - 1):
a, b = map(lambda x: int(x) - 1, input().split())
graph[a].append(b)
for _ in range(Q):
p, q = map(int, input().split())
queries[p - 1] += q
def dfs(p, acc):
acc += queries[p]
print(acc)
for child in graph[p]:
dfs(child, acc)
dfs(0, 0)
|
s282338705
|
Accepted
| 1,387
| 252,292
| 604
|
from sys import setrecursionlimit
setrecursionlimit(10 ** 6)
N, Q = map(int, input().split())
graph = [ [] for _ in range(N) ]
queries = { p: 0 for p in range(N) }
for _ in range(N - 1):
a, b = map(lambda x: int(x) - 1, input().split())
graph[a].append(b)
graph[b].append(a)
for _ in range(Q):
p, x = map(int, input().split())
queries[p - 1] += x
answer = [ 0 ] * N
def dfs(p, p_before, acc):
acc += queries[p]
answer[p] = acc
for child in graph[p]:
if child == p_before:
continue
dfs(child, p, acc)
dfs(0, -1, 0)
print(*answer)
|
s666099190
|
p02694
|
u901060001
| 2,000
| 1,048,576
|
Wrong Answer
| 22
| 9,164
| 183
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
def main():
X = int(input())
yen = 100
ans = 0
while yen >= X:
yen = int(yen ** (1.01))
ans += 1
print(ans)
if __name__ == "__main__":
main()
|
s280658288
|
Accepted
| 23
| 9,152
| 178
|
def main():
X = int(input())
yen = 100
ans = 0
while yen < X:
yen = int(1.01*yen)
ans += 1
print(ans)
if __name__ == "__main__":
main()
|
s731355945
|
p03693
|
u651879504
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 128
|
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
r, g, b = map(int,input().split())
X = 100 * r + g * 10 + b
if X % 4 == 0:
print('Yes')
else:
print('NO')
|
s805734747
|
Accepted
| 18
| 3,064
| 128
|
r, g, b = map(int,input().split())
X = 100 * r + g * 10 + b
if X % 4 == 0:
print('YES')
else:
print('NO')
|
s117796119
|
p04044
|
u610473220
| 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())
SList = []
for i in range(N):
SList.append(input())
SList.sort()
print(','.join(SList))
|
s899925817
|
Accepted
| 17
| 3,060
| 134
|
N, L = map(int, input().split())
SList = []
for i in range(N):
SList.append(input())
SList.sort()
ans = "".join(SList)
print(ans)
|
s255802805
|
p03455
|
u075492837
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 67
|
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())
print("Even" if a*b/2==0 else "Odd")
|
s345032342
|
Accepted
| 17
| 2,940
| 65
|
a,b=map(int,input().split())
print("Even" if a*b%2==0 else "Odd")
|
s294710579
|
p03672
|
u637824361
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 103
|
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
|
S = input()
l = S.__len__()
for i in range((l-1)//2,0,-1):
if S[0:i-1] == S[i:i+i-1]:
print(2*i)
|
s059593110
|
Accepted
| 20
| 3,060
| 112
|
S = input()
l = S.__len__()
for i in range((l-1)//2,0,-1):
if S[0:i-1] == S[i:i+i-1]:
print(2*i)
break
|
s743883571
|
p03610
|
u977349332
| 2,000
| 262,144
|
Wrong Answer
| 47
| 3,828
| 57
|
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()
for x in range(0,len(s),2):
print(s[x])
|
s775534652
|
Accepted
| 17
| 3,188
| 28
|
s = input()
print(s[::2])
|
s812952933
|
p03943
|
u466105944
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 119
|
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
abc = list(map(int,input().split()))
abc.sort()
if abc[2]-(abc[1]+abc[0]) == 0:
print('YES')
else:
print('NO')
|
s879809166
|
Accepted
| 17
| 2,940
| 119
|
abc = list(map(int,input().split()))
abc.sort()
if abc[2]-(abc[1]+abc[0]) == 0:
print('Yes')
else:
print('No')
|
s092181977
|
p03408
|
u842388336
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 257
|
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
|
blue_list = []
red_list = []
cnt = 0
N = int(input())
for _ in range(N):
blue_list.append(input())
M = int(input())
for _ in range(M):
red_list.append(input())
for word in blue_list:
if word in red_list:
pass
else:
cnt+=1
print(cnt)
|
s033995939
|
Accepted
| 19
| 3,188
| 301
|
blue_list = []
red_list = []
diff_list = []
N = int(input())
for _ in range(N):
blue_list.append(input())
M = int(input())
for _ in range(M):
red_list.append(input())
for word in set(blue_list):
diff_list.append(blue_list.count(word)-red_list.count(word))
print(max(0,max(diff_list)))
|
s200656010
|
p03971
|
u268792407
| 2,000
| 262,144
|
Wrong Answer
| 104
| 4,016
| 310
|
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())
s=input()
nat=0
intnat=0
for i in range(n):
if s[i]=="a":
if nat<a+b:
print("Yes")
nat+=1
else:
print("No")
elif i=="b":
if nat<a+b and intnat<b:
print("Yes")
nat+=1
intnat+=1
else:
print("No")
else:
print("No")
|
s467204147
|
Accepted
| 120
| 4,016
| 345
|
n,a,b=map(int,input().split())
s=input()
kakutei=0
kaigai=0
for i in range(n):
if s[i]=="a":
if kakutei < a+b:
print("Yes")
kakutei += 1
else:
print("No")
elif s[i]=="b":
if kakutei < a+b and kaigai < b:
print("Yes")
kakutei += 1
kaigai += 1
else:
print("No")
else:
print("No")
|
s717376903
|
p03129
|
u580873239
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 178
|
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
|
n,k=(int(x) for x in input().split())
if n%2==0:
if k<=n//2:
print("Yes")
else:
print("No")
if n%2==1:
if k<=n//2+1:
print("Yes")
else:
print("No")
|
s579705497
|
Accepted
| 17
| 2,940
| 173
|
n,k=(int(x) for x in input().split())
if n%2==0:
if k<=n//2:
print("YES")
else:
print("NO")
else:
if k<=n//2+1:
print("YES")
else:
print("NO")
|
s836619423
|
p03605
|
u248670337
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 40
|
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
|
print("Yes" if input() in "9" else "No")
|
s232915583
|
Accepted
| 17
| 2,940
| 40
|
print("Yes" if "9" in input() else "No")
|
s025175532
|
p04029
|
u383725933
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 35
|
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())
s=N*(N+1)/2
print(s)
|
s792337219
|
Accepted
| 17
| 2,940
| 40
|
N=int(input())
s=N*(N+1)/2
print(int(s))
|
s025952418
|
p03698
|
u133936772
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 46
|
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
s = input()
print('yneos'[len(s)>len(set(s))])
|
s172036476
|
Accepted
| 19
| 2,940
| 49
|
s = input()
print('yneos'[len(s)>len(set(s))::2])
|
s893378909
|
p03711
|
u015187377
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 182
|
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
|
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]
x,y = map(str, input().split())
if (x in A and y in A) or (x in B and y in B) or (x in C and y in C):
print("Yes")
else:
print("No")
|
s816777274
|
Accepted
| 17
| 2,940
| 183
|
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]
x,y = map(int, input().split())
if (x in A and y in A) or (x in B and y in B) or (x in C and y in C):
print("Yes")
else:
print("No")
|
s637167629
|
p03828
|
u697696097
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,064
| 413
|
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.
|
def prime_factorize(n):
a = []
while n % 2 == 0:
a.append(2)
n //= 2
f = 3
while f * f <= n:
if n % f == 0:
a.append(f)
n //= f
else:
f += 2
if n != 1:
a.append(n)
return a
n=int(input())
x=[0]*1000
for i in range(2,n+1):
for _ in prime_factorize(i):
x[_]+=1
ans=1
for _ in x:
if _ > 0:
ans=(ans*(_+1))%(10**9+7)
print(ans)
x.sort()
|
s963025437
|
Accepted
| 19
| 3,064
| 401
|
def prime_factorize(n):
a = []
while n % 2 == 0:
a.append(2)
n //= 2
f = 3
while f * f <= n:
if n % f == 0:
a.append(f)
n //= f
else:
f += 2
if n != 1:
a.append(n)
return a
n=int(input())
x=[0]*1000
for i in range(2,n+1):
p=prime_factorize(i)
for _ in p:
x[_]+=1
ans=1
for _ in x:
if _ > 0:
ans=(ans*(_+1))%(10**9+7)
print(ans)
|
s610735873
|
p03814
|
u045953894
| 2,000
| 262,144
|
Wrong Answer
| 74
| 3,512
| 224
|
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
|
import sys
s = input()
c = 0
for i in range(len(s)):
if s[i] == 'A':
while(s[i] != 'Z'):
c += 1
i += 1
if s[i] == 'Z':
c += 1
exit()
print(c)
|
s450516526
|
Accepted
| 39
| 3,516
| 186
|
import sys
s = input()
c = 0
C = 0
for i in range(len(s)):
if s[i] == 'A':
break
for j in range(len(s)):
if s[-j] == 'Z':
break
print(len(s[i:len(s) - j + 1]))
|
s212590035
|
p03361
|
u407730443
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,064
| 617
|
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`. However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black. Determine if square1001 can achieve his objective.
|
import sys
def is_black_in_four_dir(char_list, pos):
for p in ((1, 0), (-1, 0), (0, 1), (0, -1)):
if square_list[pos[1]+p[1]][pos[0]+p[0]] == "#":
return True
return False
h, w = map(lambda x: int(x), input().split(" "))
square_list = [input() for i in range(h)]
square_list = ["."*(w+2)] + ["." + s + "." for s in square_list] + ["."*(w+2)]
print(square_list)
for y in range(1, h+2):
for x in range(1, w+2):
if square_list[y][x] == "#":
if not is_black_in_four_dir(square_list, (x, y)):
print("No")
sys.exit()
print("Yes")
|
s065372539
|
Accepted
| 20
| 3,064
| 734
|
import sys
def get_value_by_lists(values_list, pos):
h, w = len(values_list), len(values_list[0])
if 0 <= pos[1] < h and 0 <= pos[0] < w:
return values_list[pos[1]][pos[0]]
else:
return None
def is_black_in_four_dir(cells_list, pos):
for p in ((0, 1), (0, -1), (1, 0), (-1, 0)):
if get_value_by_lists(cells_list, (pos[0]+p[0], pos[1]+p[1])) == "#":
return True
return False
h, w = map(lambda x: int(x), input().split(" "))
cells_list = [input() for _ in range(h)]
for y, cells in enumerate(cells_list):
for x, cell in enumerate(cells):
if cell == "#" and not (is_black_in_four_dir(cells_list, (x, y))):
print("No")
sys.exit()
print("Yes")
|
s448943071
|
p02853
|
u365013885
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 277
|
We held two competitions: Coding Contest and Robot Maneuver. In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen. DISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver. Find the total amount of money he earned.
|
x,y=(int(x) for x in input().split())
b = 0
if x == 1:
b += 300000
elif x == 2:
b += 200000
elif x == 3:
b += 100000
if y == 1:
b += 300000
elif y == 2:
b += 200000
elif y == 3:
b += 100000
elif x == 1 and y == 1:
b += 400000
else:
pass
print(b)
|
s509591368
|
Accepted
| 19
| 3,060
| 295
|
x,y=(int(x) for x in input().split())
b = 0
if x == 1:
b += 300000
elif x == 2:
b += 200000
elif x == 3:
b += 100000
else:
b += 0
if y == 1:
b += 300000
elif y == 2:
b += 200000
elif y == 3:
b += 100000
else:
b += 0
if x == 1 and y == 1:
b += 400000
print(b)
|
s865533219
|
p03448
|
u642682703
| 2,000
| 262,144
|
Wrong Answer
| 54
| 3,064
| 313
|
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.
|
num50 = int(input())
num100 = int(input())
num500 = int(input())
amount = int(input())
rst = 0
for itr50 in range(num50):
for itr100 in range(num100):
for itr500 in range(num500):
kingaku = itr50*50+itr100*100+itr500*500
if(kingaku==amount):
rst += 1
print(rst)
|
s585167956
|
Accepted
| 55
| 3,060
| 423
|
num500 = int(input())
num100 = int(input())
num50 = int(input())
amount = int(input())
rst = 0
for itr500 in range(num500+1):
for itr100 in range(num100+1):
for itr50 in range(num50+1):
kingaku = itr50*50+itr100*100+itr500*500
if(kingaku==amount):
rst += 1
print(rst)
|
s390594461
|
p03575
|
u329407311
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 250
|
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i. An edge whose removal disconnects the graph is called a _bridge_. Find the number of the edges that are bridges among the M edges.
|
N,M = map(int,input().split())
dist = { i:[] for i in range(1,N+1)}
for i in range(M):
a,b = map(int,input().split())
dist[a].append(b)
dist[b].append(a)
cnt = 0
for i in range(1,N+1):
if len(dist[i]) == 1:
cnt += 1
print(int(cnt))
|
s664100140
|
Accepted
| 239
| 17,136
| 486
|
import numpy as np
from scipy.sparse.csgraph import connected_components
from collections import deque
n,m=map(int,input().split())
matrix=[[0]*n]*n
matrix=np.array(matrix)
l=deque()
for _ in range(m):
a,b=map(int,input().split())
l.append([a,b])
matrix[a-1][b-1]=1
count=0
for i in range(m):
[a,b]=l.popleft()
matrix[a-1][b-1]=0
k,kk=connected_components(matrix)
if kk[a-1]!=kk[b-1]:
count+=1
l.append([a,b])
matrix[a-1][b-1]=1
print(count)
|
s360387506
|
p03943
|
u369630760
| 2,000
| 262,144
|
Wrong Answer
| 22
| 2,940
| 120
|
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
a = input().split()
b = sorted(a)
print(b)
if int(b[2]) == int(b[0]) + int(b[1]):
print("Yes")
else:
print("No")
|
s182455971
|
Accepted
| 17
| 2,940
| 185
|
a = map(int,input().split())
b = sorted(a)
if b[0] != 0 and b[1] != 0 and b[2] != 0:
if b[2] == b[0] + b[1]:
print("Yes")
else:
print("No")
else:
print("No")
|
s014415354
|
p02694
|
u931655383
| 2,000
| 1,048,576
|
Wrong Answer
| 32
| 9,120
| 61
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
n = int(input())
s = 100
while n > s:
s*=1.01
print(int(s))
|
s874721195
|
Accepted
| 30
| 9,036
| 80
|
n = int(input())
s = 100
a = 0
while n > s:
s= int(s+s//100)
a += 1
print(a)
|
s847430793
|
p03567
|
u688522869
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 154
|
Snuke built an online judge to hold a programming contest. When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.) Determine whether the judge can return the string `AC` as the verdict to a program.
|
s = input()
out = "NO"
for i in range(len(s)):
if i+1 != len(s):
if s[i] == "A" and s[i+1] == "C":
out = "YES"
print(out)
|
s397730803
|
Accepted
| 17
| 2,940
| 145
|
s = input()
out = "No"
for i in range(len(s)):
if i+1 != len(s):
if s[i] == "A" and s[i+1] == "C":
out = "Yes"
print(out)
|
s183275628
|
p03722
|
u064408584
| 2,000
| 262,144
|
Wrong Answer
| 912
| 3,700
| 517
|
There is a directed graph with N vertices and M edges. The i-th edge (1≤i≤M) points from vertex a_i to vertex b_i, and has a weight c_i. We will play the following single-player game using this graph and a piece. Initially, the piece is placed at vertex 1, and the score of the player is set to 0. The player can move the piece as follows: * When the piece is placed at vertex a_i, move the piece along the i-th edge to vertex b_i. After this move, the score of the player is increased by c_i. The player can end the game only when the piece is placed at vertex N. The given graph guarantees that it is possible to traverse from vertex 1 to vertex N. When the player acts optimally to maximize the score at the end of the game, what will the score be? If it is possible to increase the score indefinitely, print `inf`.
|
def BellmanFord(edges,num_v,source):
inf=float("inf")
dist=[inf for i in range(num_v)]
dist[source-1]=0
for i in range(num_v):
for edge in edges:
if edge[0] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
if i==num_v-1: return [0,'inf']
return dist
n,m=map(int, input().split())
a=[list(map(int, input().split())) for i in range(m)]
a=[[x,y,-z] for x,y,z in a]
print(BellmanFord(a, n, 1)[-1])
|
s236859332
|
Accepted
| 826
| 3,708
| 480
|
def BF(p,n,s):
inf=float("inf")
d=[inf for i in range(n)]
d[s-1]=0
for i in range(n+1):
for e in p:
if e[0]!=inf and d[e[1]-1]>d[e[0]-1]+e[2]:
d[e[1]-1] = d[e[0]-1] + e[2]
if i==n-1:t=d[-1]
if i==n and t!=d[-1]:
return [0,'inf']
return list(map(lambda x:-x, d))
n,m=map(int, input().split())
a=[list(map(int, input().split())) for i in range(m)]
a=[[x,y,-z] for x,y,z in a]
print(BF(a, n, 1)[-1])
|
s700796711
|
p02613
|
u315184129
| 2,000
| 1,048,576
|
Wrong Answer
| 156
| 16,328
| 207
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
n = int(input())
s = []
for i in range(n):
s.append(input())
out = {"AC":0,"WA":0,"TLE":0,"RE":0}
for i in range(n):
out[s[i]] += 1
for i in ["AC","WA","TLE","RE"]:
print(f"{i} × {out[i]}")
|
s254181645
|
Accepted
| 160
| 16,332
| 206
|
n = int(input())
s = []
for i in range(n):
s.append(input())
out = {"AC":0,"WA":0,"TLE":0,"RE":0}
for i in range(n):
out[s[i]] += 1
for i in ["AC","WA","TLE","RE"]:
print(f"{i} x {out[i]}")
|
s175260379
|
p03149
|
u758933970
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 109
|
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".
|
A = [int(_) for _ in input().split()]
ttt = all((x == 1or x == 9 or x== 7 or x == 4 for x in A))
print(ttt)
|
s564000860
|
Accepted
| 17
| 3,060
| 196
|
A = [int(_) for _ in input().split()]
res = sorted(set(A), key=A.index)
ttt = all((x == 1or x == 9 or x== 7 or x == 4 for x in A))
if ttt and len(res)==4:
print("YES")
else:
print("NO")
|
s043493859
|
p02601
|
u930706853
| 2,000
| 1,048,576
|
Wrong Answer
| 30
| 9,024
| 342
|
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
|
a, b, c = map(int,input().split())
k = int(input())
count = -1
if a > b:
for i in range(k):
b = 2*b
if a < b:
count = i
break
if b > c:
for j in range(count+1, k):
c = 2*c
if b < c:
break
if a < b and b < c:
print("Yes")
else:
print("No")
print(a, b, c)
|
s673573359
|
Accepted
| 29
| 9,140
| 329
|
a, b, c = map(int,input().split())
k = int(input())
count = -1
if a >= b:
for i in range(k):
b = 2*b
if a < b:
count = i
break
if b >= c:
for j in range(count+1, k):
c = 2*c
if b < c:
break
if a < b and b < c:
print("Yes")
else:
print("No")
|
s854691268
|
p03436
|
u917558625
| 2,000
| 262,144
|
Wrong Answer
| 24
| 3,064
| 529
|
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares. Before Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game. When the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares. The color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is `.`; if square (i, j) is initially painted by black, s_{i, j} is `#`.
|
H,W=map(int, input().split())
S = tuple(input().rstrip() for _ in range(H))
a=0
d=[(1,0),(-1,0),(0,1),(0,-1)]
lity=[[0 for i in range(W)] for j in range(H)]
lity[0][0]=1
def roop()->None:
p=[(0,0)]
while p:
x,y=p.pop(0)
for dx,dy in d:
if 0<=x+dx<H and 0<=y+dy<W and S[x+dx][y+dy]=='.' and lity[x+dx][y+dy]==0:
p.append((x+dx,y+dy))
lity[x+dx][y+dy]=lity[x][y]+1
roop()
white=sum(t.count(".") for t in S)
x=lity[-1][-1]
print(lity)
print(x)
ans = white - x
if 0<x:
print(ans)
else:
print(-1)
|
s611014841
|
Accepted
| 27
| 3,316
| 522
|
from collections import deque
H,W=map(int,input().split())
s=[['#']*(W+2)for _ in range(H+2)]
count=0
for i in range(1,H+1):
S=list(input())
s[i]=['#']+S+['#']
count+=S.count('.')
move=[(1,0),(-1,0),(0,1),(0,-1)]
que=deque([(1,1)])
s[1][1]=1
while que:
a,b=que.popleft()
if (a,b)==(H,W):
break
for my,mx in move:
ny=my+a
nx=mx+b
if s[ny][nx]=='#':
continue
elif s[ny][nx]=='.':
que.append((ny,nx))
s[ny][nx]=s[a][b]+1
ans=-1
if s[H][W]!='.':
ans=count-s[H][W]
print(ans)
|
s136484471
|
p03623
|
u328755070
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 67
|
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
x, a, b = map(int, input().split())
print(max(abs(x-a), abs(x-b)))
|
s426897496
|
Accepted
| 17
| 2,940
| 83
|
x, a, b = map(int, input().split())
print("A") if abs(x-a)<abs(x-b) else print("B")
|
s985398082
|
p03377
|
u745997547
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,316
| 104
|
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 = list(map(int, input().split()))
if 0<=X-A and X-A<=B:
print('Yes')
else:
print('No')
|
s049414247
|
Accepted
| 17
| 2,940
| 104
|
A, B, X = list(map(int, input().split()))
if 0<=X-A and X-A<=B:
print('YES')
else:
print('NO')
|
s139818995
|
p03997
|
u448406471
| 2,000
| 262,144
|
Wrong Answer
| 38
| 3,064
| 67
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a = int(input())
b = int(input())
h = int(input())
print((a+b)*h/2)
|
s173838778
|
Accepted
| 39
| 3,064
| 68
|
a = int(input())
b = int(input())
h = int(input())
print((a+b)*h//2)
|
s559911699
|
p02267
|
u895660619
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,496
| 111
|
You are given a sequence of _n_ integers S and a sequence of different _q_ integers T. Write a program which outputs C, the number of integers in T which are also in the set S.
|
n = int(input())
s = set(input().split())
q = int(input())
t = set(input().split())
print(len(s) - len(s & t))
|
s655470989
|
Accepted
| 20
| 8,196
| 102
|
n = int(input())
s = set(input().split())
q = int(input())
t = set(input().split())
print(len(s & t))
|
s757929416
|
p02613
|
u994935583
| 2,000
| 1,048,576
|
Wrong Answer
| 145
| 9,216
| 438
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
def resolve():
N = int(input())
ans = [0,0,0,0]
for i in range(N):
S = input()
if S == 'AC':
ans[0] += 1
if S == 'WA':
ans[1] += 1
if S == 'TLE':
ans[2] += 1
if S == 'RE':
ans[3] += 1
print( 'AC × ' + str(ans[0]) )
print( 'WA × ' + str(ans[1]) )
print( 'TLE × ' + str(ans[2]) )
print( 'RE × ' + str(ans[3]) )
resolve()
|
s962418655
|
Accepted
| 142
| 9,216
| 434
|
def resolve():
N = int(input())
ans = [0,0,0,0]
for i in range(N):
S = input()
if S == 'AC':
ans[0] += 1
if S == 'WA':
ans[1] += 1
if S == 'TLE':
ans[2] += 1
if S == 'RE':
ans[3] += 1
print( 'AC x ' + str(ans[0]) )
print( 'WA x ' + str(ans[1]) )
print( 'TLE x ' + str(ans[2]) )
print( 'RE x ' + str(ans[3]) )
resolve()
|
s766126679
|
p02694
|
u475675023
| 2,000
| 1,048,576
|
Wrong Answer
| 23
| 9,188
| 74
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
x=int(input())
n=100
cnt=0
while n<=x:
n=int(n*1.01)
cnt+=1
print(cnt)
|
s060866490
|
Accepted
| 21
| 9,164
| 73
|
x=int(input())
n=100
cnt=0
while n<x:
n=int(n*1.01)
cnt+=1
print(cnt)
|
s659112756
|
p03672
|
u408375121
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 144
|
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
|
S = input()
ans = 0
for i in range(1, len(S)):
s = S[: -2*i]
l = (len(S) - 2*i) // 2
if s[:l] == s[l:]:
ans = 2*i
break
print(ans)
|
s359470739
|
Accepted
| 17
| 2,940
| 154
|
S = input()
ans = 0
for i in range(1, len(S)):
s = S[: -2*i]
l = (len(S) - 2*i) // 2
if s[:l] == s[l:]:
ans = len(S) - 2*i
break
print(ans)
|
s394549144
|
p03415
|
u075155299
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 58
|
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.
|
s1=input()
s2=input()
s3=input()
print(s1[0],s2[1],s3[2])
|
s699073535
|
Accepted
| 17
| 2,940
| 58
|
s1=input()
s2=input()
s3=input()
print(s1[0]+s2[1]+s3[2])
|
s762849578
|
p03457
|
u319065189
| 2,000
| 262,144
|
Wrong Answer
| 2,206
| 27,068
| 389
|
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
n = int(input())
def check(t, x, y):
for i in range(t + 1):
for j in range(t + 1 - i):
for k in range(t + 1 - i - j):
if (i - j == x) and (k - (t - i - j - k)) == y:
return True
return False
if all(check(l[0], l[1], l[2]) for l in [list(map(int, input().split())) for i in range(n)]):
print('YES')
else:
print('NO')
|
s469110079
|
Accepted
| 269
| 27,056
| 330
|
n = int(input())
def check(t, x, y):
return (t - (abs(x) + abs(y))) >= 0 and (t - (abs(x) + abs(y))) % 2 == 0
t0, x0, y0 = 0, 0, 0
for l in [list(map(int, input().split())) for i in range(n)]:
if not check(l[0] - t0, l[1] - x0, l[2] - y0):
print('No')
exit()
t0, x0, y0 = l[0], l[1], l[2]
print('Yes')
|
s174048900
|
p03945
|
u595893956
| 2,000
| 262,144
|
Wrong Answer
| 44
| 3,188
| 82
|
Two foxes Jiro and Saburo are playing a game called _1D Reversi_. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones between the new white stone and another white stone, turn into white stones, and vice versa. In the middle of a game, something came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is `B`, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is `W`, it means that the color of the corresponding stone is white. Jiro wants all stones on the board to be of the same color. For this purpose, he will place new stones on the board according to the rules. Find the minimum number of new stones that he needs to place.
|
ret=0
s=input()
for i in range(len(s)-1):
if s[i]==s[i+1]:
ret+=1
print(ret)
|
s054228719
|
Accepted
| 51
| 3,188
| 83
|
ret=0
s=input()
for i in range(len(s)-1):
if s[i]!=s[i+1]:
ret+=1
print(ret)
|
s004023077
|
p03577
|
u476418095
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 46
|
Rng is going to a festival. The name of the festival is given to you as a string S, which ends with `FESTIVAL`, from input. Answer the question: "Rng is going to a festival of what?" Output the answer. Here, assume that the name of "a festival of s" is a string obtained by appending `FESTIVAL` to the end of s. For example, `CODEFESTIVAL` is a festival of `CODE`.
|
s=input()
for x in range(len(s)-8):print(s[x])
|
s331703330
|
Accepted
| 17
| 2,940
| 25
|
s = input()
print(s[:-8])
|
s058592010
|
p03997
|
u587589241
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 55
|
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)
|
s304417057
|
Accepted
| 17
| 2,940
| 60
|
a,b,h=[int(input()) for i in range(3)]
print(int((a+b)*h/2))
|
s446512872
|
p03478
|
u123648284
| 2,000
| 262,144
|
Wrong Answer
| 42
| 3,452
| 229
|
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
n, a, b = list(map(int, input().split()))
res = 0
for i in range(1, n+1):
sum = int(i/10000) + int(i%10000/1000) + int(i%1000/100) + int(i%100/10) + int(i%10)
print(i, sum)
if a <= sum and sum <= b:
res += i
print(res)
|
s620328810
|
Accepted
| 29
| 2,940
| 239
|
def findSumOfDigits(n):
sum = 0
while n > 0:
sum += n % 10
n = int(n/10)
return sum
N, A, B = list(map(int, input().split()))
total = 0
for i in range(1, N+1):
if A <= findSumOfDigits(i) <= B:
total += i
print(total)
|
s594012630
|
p03657
|
u054717609
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 148
|
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
|
a,b=map(int,input().split())
if(a%3==0 or b%3==0 or (a+b)%3==0):
print("possible")
else:
print("Impossible")
|
s138584186
|
Accepted
| 18
| 2,940
| 148
|
a,b=map(int,input().split())
if(a%3==0 or b%3==0 or (a+b)%3==0):
print("Possible")
else:
print("Impossible")
|
s189245663
|
p02388
|
u002193969
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,568
| 29
|
Write a program which calculates the cube of a given integer x.
|
x = int(input())
print(x*3)
|
s249256854
|
Accepted
| 20
| 5,576
| 23
|
print(int(input())**3)
|
s835031362
|
p03470
|
u233183615
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 66
|
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
n = int(input())
*a,= [int(input()) for _ in range(n)]
len(set(a))
|
s388331301
|
Accepted
| 17
| 2,940
| 73
|
n = int(input())
*a,= [int(input()) for _ in range(n)]
print(len(set(a)))
|
s150845432
|
p03720
|
u163421511
| 2,000
| 262,144
|
Wrong Answer
| 27
| 9,096
| 128
|
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
|
n, m = map(int, input().split())
load = []
load.extend(map(int, input().split()))
for i in range(n):
print(load.count(i+1))
|
s449980434
|
Accepted
| 28
| 9,100
| 149
|
n, m = map(int, input().split())
load = []
for _ in range(m):
load.extend(map(int, input().split()))
for i in range(n):
print(load.count(i+1))
|
s987288213
|
p03719
|
u520158330
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 108
|
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
N = list(map(int,input().split()))
if N[2] >= N[0] and N[2] <= N[1]:
print("YES")
else:
print("NO")
|
s465812505
|
Accepted
| 17
| 3,064
| 110
|
N = list(map(int,input().split()))
if N[2] >= N[0] and N[2] <= N[1]:
print("Yes")
else:
print("No")
|
s927290549
|
p03693
|
u825343780
| 2,000
| 262,144
|
Wrong Answer
| 23
| 9,028
| 85
|
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
r, g, b = map(int, input().split())
print("Yes" if (10 * g + b) % 4 == 0 else "No")
|
s669390919
|
Accepted
| 28
| 8,924
| 85
|
r, g, b = map(int, input().split())
print("YES" if (10 * g + b) % 4 == 0 else "NO")
|
s824639383
|
p03997
|
u275861030
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 90
|
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())
answer = (a + b) * h /2
print(answer)
|
s493128682
|
Accepted
| 17
| 2,940
| 96
|
a = int(input())
b = int(input())
h = int(input())
answer = (a + b) * h /2
print(int(answer))
|
s519212622
|
p02388
|
u607723579
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,576
| 46
|
Write a program which calculates the cube of a given integer x.
|
s=input()
x=int(s)**3
print('s=',s,'x=',x)
|
s800223110
|
Accepted
| 20
| 5,572
| 35
|
x=input()
n=int(x)**3
print(n)
|
s938093906
|
p04043
|
u624613992
| 2,000
| 262,144
|
Wrong Answer
| 28
| 9,152
| 132
|
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.
|
abc = list(map(int,input().split()))
ans = "No"
if 5 in abc:
abc.remove(5)
if 5 in abc and 7 in abc:
ans = "Yes"
print(ans)
|
s775579294
|
Accepted
| 30
| 9,100
| 132
|
abc = list(map(int,input().split()))
ans = "NO"
if 5 in abc:
abc.remove(5)
if 5 in abc and 7 in abc:
ans = "YES"
print(ans)
|
s295541988
|
p03082
|
u389910364
| 2,000
| 1,048,576
|
Wrong Answer
| 2,109
| 22,000
| 1,023
|
Snuke has a blackboard and a set S consisting of N integers. The i-th element in S is S_i. He wrote an integer X on the blackboard, then performed the following operation N times: * Choose one element from S and remove it. * Let x be the number written on the blackboard now, and y be the integer removed from S. Replace the number on the blackboard with x \bmod {y}. There are N! possible orders in which the elements are removed from S. For each of them, find the number that would be written on the blackboard after the N operations, and compute the sum of all those N! numbers modulo 10^{9}+7.
|
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(2147483647)
INF = float("inf")
N, X = list(map(int, sys.stdin.readline().split()))
S = list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
S.sort()
def test(x, i):
if i == 0:
ret = [0.0] * max(X, *S)
ret[x % S[i]] = 1.0
return np.array(ret)
ret = test(x % S[i], i=0)
for j in range(1, i):
ret += test(x % S[i], i=j)
return ret / i
ans = 0
for i in range(N):
ans += test(X, i) / N
print(np.dot(ans, range(len(ans))) * math.factorial(N) % MOD)
|
s547359672
|
Accepted
| 875
| 14,808
| 756
|
import math
import os
import sys
import numpy as np
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(2147483647)
INF = float("inf")
N, X = list(map(int, sys.stdin.readline().split()))
S = list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
def mod_invs(max, mod):
invs = [1] * (max + 1)
for x in range(2, max + 1):
invs[x] = (-(mod // x) * invs[mod % x]) % mod
return invs
S.sort()
invs = mod_invs(N, MOD)
dp = np.arange(X + 1) % S[0]
for i in range(1, N):
dp += dp[np.arange(X + 1) % S[i]] * invs[i]
dp %= MOD
print(int(dp[X] * math.factorial(N) % MOD * invs[N] % MOD))
|
s587614458
|
p03712
|
u123756661
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 355
|
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.
|
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
h,w=map(int,input().split())
ans=h*w
if h*w%3==0:
print(0)
else:
for x,y in ((h,w),(w,h)):
x1=x//3
x2=(x+2)//3
y1=y//2
y2=(y+1)//2
ans=min(ans,abs(y*x2-y*x1))
ans=min(ans,abs(y*x2-(x-x2)*(y-y2)))
ans=min(ans,abs(y*x1-(x-x1)*(y-y2)))
print(ans)
|
s209820220
|
Accepted
| 18
| 3,060
| 199
|
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
h,w=map(int,input().split())
for i in range(h+2):
if i==0 or i==h+1:
print("#"*w+"##")
else:
a=input()
print("#"+a+"#")
|
s658155855
|
p03485
|
u785220618
| 2,000
| 262,144
|
Wrong Answer
| 19
| 2,940
| 85
|
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
import math
a, b = map(int, input().split())
print((a+b)/2)
print(math.ceil((a+b)/2))
|
s454552830
|
Accepted
| 17
| 2,940
| 70
|
import math
a, b = map(int, input().split())
print(math.ceil((a+b)/2))
|
s670171263
|
p02255
|
u424041287
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,596
| 278
|
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
def insertionSort(A, N):
for i in range(N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(A)
n = int(input())
a = [int(i) for i in input().split()]
insertionSort(a,n)
|
s744814376
|
Accepted
| 20
| 5,604
| 380
|
def insertionSort(A, N):
for i in range(N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
t = str(A[0])
for i in range(1,N):
t = t + " " + str(A[i])
print(t)
n = int(input())
a = [int(i) for i in input().split()]
insertionSort(a,n)
|
s723329083
|
p04043
|
u400207556
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 73
|
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.
|
x = input();
a = '7 7'in x
if a == True :print("NO")
else : print("Yes")
|
s969079906
|
Accepted
| 17
| 2,940
| 100
|
x = input()
a = x.count("5")
b = x.count("7")
if a == 2 and b == 1 :print("YES")
else : print("NO")
|
s887264321
|
p02276
|
u091533407
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,660
| 484
|
Quick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, inturn, less than or equal to each element of A[q+1..r]. It also computes the index q. In the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r). Your task is to read a sequence A and perform the Partition based on the following pseudocode: Partition(A, p, r) 1 x = A[r] 2 i = p-1 3 for j = p to r-1 4 do if A[j] <= x 5 then i = i+1 6 exchange A[i] and A[j] 7 exchange A[i+1] and A[r] 8 return i+1 Note that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].
|
def partition(A, p, r):
x = A[r]
i = p - 1
for j in range(p, r):
if A[j] <= x:
i = i + 1
temp = A[i]
A[i] = A[j]
A[j] = temp
temp = A[i+1]
A[i+1] = A[r]
A[r] = temp
return i+1
if __name__ == "__main__":
n = int(input())
B = list(map(int, input().split()))
p = partition(B, 0, n-1)
print(B)
print(" ".join(map(str, B[:p])) + " [" + str(B[p]) + "] " + " ".join(map(str, B[p+1:])))
|
s922408189
|
Accepted
| 70
| 18,412
| 471
|
def partition(A, p, r):
x = A[r]
i = p - 1
for j in range(p, r):
if A[j] <= x:
i = i + 1
temp = A[i]
A[i] = A[j]
A[j] = temp
temp = A[i+1]
A[i+1] = A[r]
A[r] = temp
return i+1
if __name__ == "__main__":
n = int(input())
B = list(map(int, input().split()))
p = partition(B, 0, n-1)
print(" ".join(map(str, B[:p])) + " [" + str(B[p]) + "] " + " ".join(map(str, B[p+1:])))
|
s241207042
|
p03436
|
u926412290
| 2,000
| 262,144
|
Wrong Answer
| 33
| 9,164
| 296
|
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares. Before Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game. When the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares. The color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is `.`; if square (i, j) is initially painted by black, s_{i, j} is `#`.
|
t,*g=open(0);h,w=map(int,t.split());v=[[0]*w for _ in range(h)];v[0][0]=1;q=[(0,0)]
while q:
a,b=q.pop(0)
for c,d in((-1,0),(0,-1),(1,0),(0,1)):
x=a+c;y=b+d
if w>x>=0<=y<h and v[y][x]<1 and g[y][x]==".":q+=[(x,y)];v[y][x]=v[b][a]+1
t=v[-1][-1];print((-1,t-sum(c.count(".")for c in g))[t>0])
|
s320207140
|
Accepted
| 32
| 9,060
| 297
|
t,*g=open(0);h,w=map(int,t.split());v=[[0]*w for _ in range(h)];v[0][0]=1;q=[(0,0)]
while q:
a,b=q.pop(0)
for c,d in((-1,0),(0,-1),(1,0),(0,1)):
x=a+c;y=b+d
if w>x>=0<=y<h and v[y][x]<1 and g[y][x]==".":q+=[(x,y)];v[y][x]=v[b][a]+1
t=v[-1][-1];print((-1,sum(c.count(".")for c in g)-t)[t>0])
|
s032440087
|
p03694
|
u123756661
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 56
|
It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts. There are N houses along _TopCoDeer street_. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses. Find the minimum distance to be traveled when AtCoDeer can start and end his travel at any positions.
|
l=[int(i) for i in input().split()]
print(max(l)-min(l))
|
s845043199
|
Accepted
| 17
| 2,940
| 64
|
input()
l=[int(i) for i in input().split()]
print(max(l)-min(l))
|
s927526963
|
p03437
|
u208308361
| 2,000
| 262,144
|
Wrong Answer
| 29
| 9,160
| 156
|
You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
|
X,Y=map(int,input().split())
ans=-1
if X%Y==0:
pass
else:
for i in range(100):
if X*i%Y!=0:
ans=X*Y
break
print(ans)
|
s643987424
|
Accepted
| 25
| 9,120
| 166
|
X,Y=map(int,input().split())
ans=-1
if X%Y==0:
pass
else:
for i in range(100):
if (X*(i+2))%Y!=0:
ans=X*(i+2)
break
print(ans)
|
s753384841
|
p03080
|
u864453204
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 95
|
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
|
s = input()
R = s.count('R')
B = s.count('B')
if R > B:
print('Yes')
else:
print('No')
|
s050350640
|
Accepted
| 18
| 2,940
| 107
|
N = input()
s = input()
R = s.count('R')
B = s.count('B')
if R > B:
print('Yes')
else:
print('No')
|
s107810896
|
p03607
|
u363768711
| 2,000
| 262,144
|
Wrong Answer
| 210
| 15,448
| 224
|
You are playing the following game with Joisino. * Initially, you have a blank sheet of paper. * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. * Then, you are asked a question: How many numbers are written on the sheet now? The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?
|
from collections import Counter
def main():
n = int(input())
ans = 0
A = Counter((int(input()) for _ in range(n)))
for i in A.values():
if i%2 != 0:
ans += 1
return ans
if __name__=='__main__':
main()
|
s498328347
|
Accepted
| 215
| 15,460
| 224
|
from collections import Counter
def main():
n = int(input())
ans = 0
A = Counter((int(input()) for _ in range(n)))
for i in A.values():
if i%2 != 0:
ans += 1
print(ans)
if __name__=='__main__':
main()
|
s289032459
|
p02612
|
u537976628
| 2,000
| 1,048,576
|
Wrong Answer
| 29
| 9,136
| 32
|
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input())
print(n % 1000)
|
s855173035
|
Accepted
| 30
| 9,144
| 33
|
n = int(input())
print(-n % 1000)
|
s818203175
|
p03943
|
u858136677
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 127
|
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
a,b,c = map(int,input().split())
sum = a+b+c
half = sum/2
if a == sum or b == sum or c == sum:
print('Yes')
else:
print('No')
|
s590997730
|
Accepted
| 17
| 2,940
| 130
|
a,b,c = map(int,input().split())
sum = a+b+c
half = sum/2
if a == half or b == half or c == half:
print('Yes')
else:
print('No')
|
s313864087
|
p03196
|
u919633157
| 2,000
| 1,048,576
|
Wrong Answer
| 119
| 5,304
| 840
|
There are N integers a_1, a_2, ..., a_N not less than 1. The values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \times a_2 \times ... \times a_N = P. Find the maximum possible greatest common divisor of a_1, a_2, ..., a_N.
|
# 2019/07/31
# input
"""
4 972439611840
"""
# output
"""
206
"""
# 2 :6
# 103 :4
# 3 :3
# 5 :1
"""
//////////////////////
1 2 3 4
----------------
2 2 2 2
* * * *
103 103 103 103
*
2^2
*
103^0
*
3^3
*
5^1
----------------
111240 206 206 206
=972439611840
/////////////////////
"""
from fractions import gcd
from collections import Counter
n,p=map(int,input().split())
def trial_div(n):
prime=Counter()
for i in range(2,int(pow(n,0.5)+2)):
while n%i==0:
n//=i
prime[i]+=1
if n>1:prime[n]+=1
return prime
res=trial_div(p)
ans=1
for k,v in res.items():
tmp=k*(v//n)
ans*=max(tmp,1)
print(ans)
|
s330774431
|
Accepted
| 102
| 3,316
| 410
|
# 2019/11/29
from collections import Counter
n,p=map(int,input().split())
def trial_div(n):
prime=Counter()
for i in range(2,int(pow(n,0.5)+2)):
while n%i==0:
n//=i
prime[i]+=1
if n>1:prime[n]+=1
return prime
prime=trial_div(p)
if prime is None:
print(1)
exit()
ans=1
for k,v in prime.items():
if v>=n:
ans*=k**(v//n)
print(ans)
|
s862509305
|
p02833
|
u149752754
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 105
|
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
|
n, ans = int(input()) //10, 0
if n % 2 == 1:
print(0)
exit()
while n > 0:
ans += n
n //= 5
print(ans)
|
s820247880
|
Accepted
| 17
| 3,060
| 109
|
n = int(input())
if n % 2 == 1:
print(0)
exit()
n //= 10
ans = n
while n > 0:
n //= 5
ans += n
print(ans)
|
s533344955
|
p03407
|
u859897687
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 94
|
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=map(int,input().split())
if a==c and b==c and a+b==c:
print("Yes")
else:
print("No")
|
s858411824
|
Accepted
| 19
| 2,940
| 75
|
a,b,c=map(int,input().split())
if a+b<c:
print("No")
else:
print("Yes")
|
s018164613
|
p00534
|
u724548524
| 8,000
| 262,144
|
Wrong Answer
| 30
| 5,628
| 585
|
現在カザフスタンがある地域には,古くは「シルクロード」と呼ばれる交易路があった. シルクロード上には N + 1 個の都市があり,西から順に都市 0, 都市 1, ... , 都市 N と番号がつけられている.都市 i - 1 と都市 i の間の距離 (1 ≤ i ≤ N) は Di である. 貿易商である JOI 君は,都市 0 から出発して,都市を順番に経由し,都市 N まで絹を運ぶことになった.都市 0 から都市 N まで M 日以内に移動しなければならない.JOI 君は,それぞれの日の行動として,以下の 2 つのうちいずれか 1 つを選ぶ. * 移動: 現在の都市から 1 つ東の都市へ 1 日かけて移動する.現在都市 i - 1 (1 ≤ i ≤ N) にいる場合は,都市 i に移動する. * 待機: 移動を行わず,現在いる都市で 1 日待機する. 移動は大変であり,移動するたびに疲労度が溜まっていく.シルクロードでは日毎に天候の変動があり,天候が悪い日ほど移動には苦労を要する. JOI 君が絹を運ぶのに使える M 日間のうち j 日目 (1 ≤ j ≤ M) の天候の悪さは Cj であることが分かっている.都市 i - 1 から都市 i (1 ≤ i ≤ N) に j 日目 (1 ≤ j ≤ M) に移動する場合,疲労度が Di × Cj だけ溜まってしまう.移動を行わず待機している日は疲労度は溜まらない. JOI 君は,それぞれの日の行動をうまく選ぶことで,できるだけ疲労度を溜めずに移動したい.JOI 君が M 日以内に都市 N に移動するときの,移動を開始してから終了するまでに溜まる疲労度の合計の最小値を求めよ.
|
n, m = map(int, input().split())
d = [int(input()) for _ in range(n)]
c = [int(input()) for _ in range(m)]
h = [[10e10 for _ in range(m)] for _ in range(n)]
q = [[0, 0, 0]]
while True:
nq = []
for i in q:
dn = i[2] + d[i[0]] * c[i[1]]
if dn < min(h[i[0]][:i[1] + 1]):
if i[0] < n - 1:
nq.append([i[0] + 1, i[1] + 1, dn])
h[i[0]][i[1]] = dn
if n - i[0] < m - i[1] and i[1] < m - 1:
nq.append([i[0], i[1] + 1, i[2]])
if nq == []:
break
q = nq
for i in h:
print(i)
print(min(h[-1]))
|
s176323123
|
Accepted
| 500
| 19,652
| 388
|
n, m = map(int, input().split())
d = [int(input()) for _ in range(n)]
c = [int(input()) for _ in range(m)]
h = [[0 for _ in range(m)] for _ in range(n)]
for i in range(n):
for j in range(i, m):
if i == j:
h[i][j] = h[i -1][j - 1] + d[i] * c[j]
else:
h[i][j] = min(h[i][j - 1], h[i - 1][j - 1] + d[i] * c[j])
print(h[n - 1][m - 1])
|
s220660136
|
p00001
|
u596683576
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,404
| 182
|
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
|
def main():
a = []
for i in range(10):
a.append(input())
a.sort()
a.reverse()
for i in range(3):
print(i)
if __name__ == '__main__':
main()
|
s181481750
|
Accepted
| 30
| 7,672
| 190
|
def main():
a = []
for i in range(10):
a.append(int(input()))
a.sort()
a.reverse()
for i in range(3):
print(a[i])
if __name__ == '__main__':
main()
|
s526045127
|
p03228
|
u623601489
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 152
|
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person. Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.
|
a,b,k=map(int,input().split())
t=True
for i in range(0,k):
if t==True:
a=a//2
b+=a
else:
b=b//2
a+=b
t=not t
|
s289942092
|
Accepted
| 17
| 3,060
| 163
|
a,b,k=map(int,input().split())
t=True
for i in range(0,k):
if t==True:
a=a//2
b+=a
else:
b=b//2
a+=b
t=not t
print(a,b)
|
s736475121
|
p03478
|
u724152875
| 2,000
| 262,144
|
Wrong Answer
| 25
| 3,060
| 184
|
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).
|
li=list(map(int,input().split()))
sum=0
for i in range(1,li[0]+1):
a=i//1000
b=i//100%10
c=i//10%10
d=i%10
if li[1]<=a+b+c+d<=li[2]:
sum+=a+b+c+d
print(sum)
|
s777049753
|
Accepted
| 25
| 3,060
| 226
|
li=list(map(int,input().split()))
sum=0
for i in range(1,li[0]+1):
z=i//10000
a=i//1000%10
b=i//100%10
c=i//10%10
d=i%10
s=z+a+b+c+d
if li[1]<=s<=li[2]:
#print(i)
sum+=i
print(sum)
|
s077525734
|
p03720
|
u855057563
| 2,000
| 262,144
|
Wrong Answer
| 30
| 9,192
| 175
|
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
|
n,m=map(int,input().split())
al=[]
bl=[]
for i in range(m):
a,b=map(int,input().split())
al.append(a)
bl.append(b)
for i in range(m+1):
print(al.count(i)+bl.count(i))
|
s661618922
|
Accepted
| 25
| 9,176
| 178
|
n,m=map(int,input().split())
al=[]
bl=[]
for i in range(m):
a,b=map(int,input().split())
al.append(a)
bl.append(b)
for i in range(1,n+1):
print(al.count(i)+bl.count(i))
|
s864869583
|
p03455
|
u923285281
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 186
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
def main():
a, b = map(int, input().split())
print(a * b % 2)
if a * b % 2 == 0:
print('Even')
else:
print('Odd')
if __name__ == '__main__':
main()
|
s560796675
|
Accepted
| 17
| 2,940
| 134
|
def main():
a, b = map(int, input().split())
if a * b % 2 == 0:
print('Even')
else:
print('Odd')
main()
|
s956610755
|
p02608
|
u221766194
| 2,000
| 1,048,576
|
Wrong Answer
| 884
| 16,900
| 196
|
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
n=int(input())
a = [0]*(1000000)
for i in range(1,101):
for j in range(1,101):
for k in range(1,101):
a[i**2+j**2+k**2+i*j+j*k+i*k]+=1
for i in range(n+1):
print(a[i])
|
s302993942
|
Accepted
| 765
| 9,256
| 255
|
n=int(input())
a = [0]*(20000)
for i in range(1,101):
for j in range(1,101):
for k in range(1,101):
if i**2+j**2+k**2 >= n:
break
a[i**2+j**2+k**2+i*j+j*k+i*k]+=1
for i in range(1,n+1):
print(a[i])
|
s274766125
|
p02795
|
u736084649
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 135
|
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.
|
h = int(input())
w = int(input())
n = int(input())
if n / max(h, w) > n:
print(n // max(h, w) + 1)
else:
print(n // max(h, w))
|
s011016849
|
Accepted
| 17
| 3,064
| 244
|
h = int(input())
w = int(input())
n = int(input())
v = 200 / 100
if n / max(h, w) - n // max(h, w) == 0:
print(n // max(h, w))
elif n / max(h, w) == 1:
print(1)
elif n / max(h, w) < 1:
print(1)
else:
print(n // max(h, w) + 1)
|
s359011495
|
p02742
|
u560708725
| 2,000
| 1,048,576
|
Wrong Answer
| 28
| 9,108
| 225
|
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 == 0:
print((h / 2) * w)
else:
if w % 2 == 0:
print(int(((h//2) * w/2) + ((h//2 + 1) * w/2)))
else:
print(int(((h//2 + 1) * (w//2+1)) + ((h//2) * (w//2))))
|
s164675803
|
Accepted
| 28
| 9,120
| 299
|
h,w = map(int, input().split())
if h == 1 or w == 1:
print(1)
else:
if h % 2 == 0:
print(int((h / 2) * w))
else:
if w % 2 == 0:
print(int(((h//2) * w/2) + ((h//2 + 1) * w/2)))
else:
print(int(((h//2 + 1) * (w//2+1)) + ((h//2) * (w//2))))
|
s805825087
|
p03814
|
u013408661
| 2,000
| 262,144
|
Wrong Answer
| 68
| 7,084
| 75
|
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
|
s=list(input())
x=s.index('A')
t=sorted(s)
y=t.index('Z')
print(len(s)-x-y)
|
s164063468
|
Accepted
| 26
| 6,180
| 83
|
s=list(input())
x=s.index('A')
t=list(reversed(s))
y=t.index('Z')
print(len(s)-x-y)
|
s254734110
|
p03471
|
u659100741
| 2,000
| 262,144
|
Wrong Answer
| 1,385
| 2,940
| 245
|
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
N, Y = map(int, input().split())
answer = [-1, -1, -1]
for i in range(N):
for j in range(N):
if i*10000 + j*5000 + (N-i-j)*1000 == Y:
answer[0] = i
answer[1] = j
answer[2] = N-i-j
print(answer)
|
s398555121
|
Accepted
| 1,383
| 3,064
| 363
|
N, Y = map(int, input().split())
answer = [-1, -1, -1]
for i in range(N+1):
for j in range(N+1):
k = N-i-j
if k < 0:
continue
if i+j+k == N and i*10000 + j*5000 + k*1000 == Y:
answer[0] = i
answer[1] = j
answer[2] = N-i-j
print("{} {} {}".format((answer[0]),(answer[1]),(answer[2])))
|
s818405812
|
p03720
|
u797016134
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 311
|
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
|
n,m = map(int, input().split())
li = [list(map(int, input().split())) for i in range(m)]
li = [flatten for inner in li for flatten in inner ]
a = li[::2]
b = li[1::2]
for i in range(m):
if a.count(i+1) + b.count(i+1) == 0:
exit()
else:
print(a.count(i+1) + b.count(i+1))
|
s672410807
|
Accepted
| 18
| 3,060
| 163
|
n,m = map(int, input().split())
li = [0]*n
for i in range(m):
a,b = map(int, input().split())
li[a-1]+=1
li[b-1]+=1
for j in range(n):
print(li[j])
|
s290500276
|
p02613
|
u306033313
| 2,000
| 1,048,576
|
Wrong Answer
| 147
| 9,200
| 296
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
s = input()
if (s == "AC"):
ac += 1
elif (s == "WA"):
wa += 1
elif (s == "TLE"):
tle += 1
else:
re += 1
print("AC x", ac)
print("WA x", wa)
print("TLE x", tle)
print("re x", re)
|
s599943195
|
Accepted
| 147
| 9,196
| 296
|
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
s = input()
if (s == "AC"):
ac += 1
elif (s == "WA"):
wa += 1
elif (s == "TLE"):
tle += 1
else:
re += 1
print("AC x", ac)
print("WA x", wa)
print("TLE x", tle)
print("RE x", re)
|
s977885155
|
p03761
|
u151785909
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,064
| 293
|
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 headline yet, he is interested in strings that can be created regardless of which string the headline contains. Find the longest string that can be created regardless of which string among S_1,...,S_n the headline contains. If there are multiple such strings, find the lexicographically smallest one among them.
|
n = int(input())
s =[[0]*26 for i in range(n)]
a =[0]*26
sa=''
for i in range(n):
s1=list(input())
for j in s1:
s[i][ord(j)-ord('a')]+=1
for j in range(26):
for i in range(n-1):
a[j]=min(s[i][j],s[i+1][j])
for i in range(26):
sa+=chr(ord('a')+i)*a[i]
print(sa)
|
s239157474
|
Accepted
| 18
| 3,064
| 306
|
n = int(input())
s =[[0]*26 for i in range(n)]
a =[50]*26
sa=''
for i in range(n):
s1=list(input())
for j in s1:
s[i][ord(j)-ord('a')]+=1
for j in range(26):
for i in range(n):
if a[j]>s[i][j]:
a[j]=s[i][j]
for i in range(26):
sa+=chr(ord('a')+i)*a[i]
print(sa)
|
s402812089
|
p03943
|
u008489560
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 103
|
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
a, b, c = map(int, input().split(' '))
print('YES' if a == b + c or b == c + a or c == b + a else 'No')
|
s836910508
|
Accepted
| 17
| 2,940
| 103
|
a, b, c = map(int, input().split(' '))
print('Yes' if a == b + c or b == c + a or c == b + a else 'No')
|
s937025561
|
p03997
|
u102126195
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 73
|
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())
c = int(input())
print((a + b )* c / 2)
|
s665711450
|
Accepted
| 17
| 2,940
| 78
|
a = int(input())
b = int(input())
c = int(input())
print(int((a + b) * c / 2))
|
s952530966
|
p03711
|
u095844416
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 279
|
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
|
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
for i in a:
if x==i:
x='a'
if y==i:
y='a'
for i in b:
if x==i:
x='b'
if y==i:
y='b'
for i in c:
if x==i:
x='c'
if y==i:
y='c'
if x==y:
print('yes')
else:
print('No')
|
s726143825
|
Accepted
| 17
| 3,064
| 279
|
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
for i in a:
if x==i:
x='a'
if y==i:
y='a'
for i in b:
if x==i:
x='b'
if y==i:
y='b'
for i in c:
if x==i:
x='c'
if y==i:
y='c'
if x==y:
print('Yes')
else:
print('No')
|
s012817656
|
p02603
|
u972479304
| 2,000
| 1,048,576
|
Wrong Answer
| 32
| 9,132
| 309
|
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows: * A_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day. In the i-th day, M-kun can make the following trade **any number of times** (possibly zero), **within the amount of money and stocks that he has at the time**. * Buy stock: Pay A_i yen and receive one stock. * Sell stock: Sell one stock for A_i yen. What is the maximum possible amount of money that M-kun can have in the end by trading optimally?
|
n = int(input())
a = list(map(int, input().split()))
kane = 1000
kabu = 0
for i in range(0, n - 1):
if a[i] > a[i + 1]:
kane += a[i] * kabu
kabu = 0
if a[i] < a[i + 1]:
kabu = kane // a[i]
kane %= a[i]
print(kabu)
print(kane)
kane += a[n - 1] * kabu
print(kane)
|
s398138033
|
Accepted
| 29
| 9,196
| 335
|
n = int(input())
a = list(map(int, input().split()))
kane = 1000
kabu = 0
if a[0] < a[1]:
kabu = kane // a[0]
kane %= a[0]
for i in range(1, n - 1):
if a[i - 1] < a[i]:
kane += a[i] * kabu
kabu = 0
if a[i] < a[i + 1]:
kabu = kane // a[i]
kane %= a[i]
kane += a[n - 1] * kabu
print(kane)
|
s811834544
|
p03470
|
u428467389
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 305
|
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
N = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
x = sum(a[::2])
y = sum(a[1::2])
print(x-y)
|
s036136388
|
Accepted
| 26
| 3,444
| 137
|
import collections
N = int(input())
x = []
for i in range(N):
d = int(input())
x.append(d)
print(len(collections.Counter(x)))
|
s803274531
|
p03129
|
u616522759
| 2,000
| 1,048,576
|
Wrong Answer
| 19
| 2,940
| 106
|
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
|
import math
N, K = map(int, input().split())
if math.ceil(N // 2) >= K:
print('YES')
else:
print('NO')
|
s007557125
|
Accepted
| 17
| 2,940
| 105
|
import math
N, K = map(int, input().split())
if math.ceil(N / 2) >= K:
print('YES')
else:
print('NO')
|
s678993072
|
p03548
|
u347912669
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 63
|
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person. At most how many people can sit on the seat?
|
a, b, c = list(map(int, input().split()))
print((a + b) // c)
|
s367891557
|
Accepted
| 17
| 2,940
| 69
|
x, y, z = list(map(int, input().split()))
x -= z
print(x // (y + z))
|
s371040058
|
p03827
|
u953379577
| 2,000
| 262,144
|
Wrong Answer
| 26
| 9,124
| 112
|
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
|
n,ans = int(input()),0
s = list(input())
for i in range(n+1):ans = max(ans,s.count("I")-s.count("D"))
print(ans)
|
s798181981
|
Accepted
| 28
| 9,164
| 120
|
n,ans = int(input()),0
s = list(input())
for i in range(n+1):ans = max(ans,s[:i].count("I")-s[:i].count("D"))
print(ans)
|
s730194227
|
p02390
|
u088816384
| 1,000
| 131,072
|
Wrong Answer
| 30
| 6,728
| 109
|
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
|
S = int(input())
h = int(S/3600)
m = int((S-h*3600)/60)
s = int(S-h*3600-m*60)
print(":".join(["h","m","s"]))
|
s233842179
|
Accepted
| 30
| 6,728
| 146
|
S = int(input())
h = int(S/3600)
m = int((S-h*3600)/60)
s = int(S-h*3600-m*60)
time = [h, m, s]
time_str = map(str,time)
print(":".join(time_str))
|
s717160242
|
p03597
|
u233477833
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 187
|
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
|
import sys
import math
n=int(input())
b=n
a=[]
N=math.sqrt(n)
for i in range(1,10):
for j in range(1,10):
if(i*j==n):
print ("Yes")
sys.exit()
print ("No")
|
s260568288
|
Accepted
| 17
| 2,940
| 365
|
#-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: paulr
#
# Created: 30/04/2020
# Copyright: (c) paulr 2020
#-------------------------------------------------------------------------------
n=int(input())
a=int(input())
N=n*n
ans=N-a
print(ans)
|
s065496954
|
p03377
|
u854992222
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 97
|
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 = map(int, input().split())
if a <= x and x <=a+b:
print("Yes")
else:
print("No")
|
s891987920
|
Accepted
| 17
| 2,940
| 97
|
a, b, x = map(int, input().split())
if a <= x and x <=a+b:
print("YES")
else:
print("NO")
|
s934353885
|
p03385
|
u304561065
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 91
|
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
S=input()
if S[0]==S[1] or S[0]==S[2] or S[1]==S[2]:
print('NO')
else:
print('YES')
|
s213345337
|
Accepted
| 17
| 2,940
| 93
|
S=input()
if S[0]!=S[1] and S[0]!=S[2] and S[1]!=S[2]:
print('Yes')
else:
print('No')
|
s129909552
|
p03854
|
u595372947
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,188
| 150
|
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('Yes')
else:
print('No')
|
s014859347
|
Accepted
| 18
| 3,188
| 150
|
S = input().replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '')
if S == '':
print('YES')
else:
print('NO')
|
s176195279
|
p03997
|
u820351940
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 73
|
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()), int(input()), int(input())
print((a + b) * h / 2)
|
s157749975
|
Accepted
| 17
| 2,940
| 74
|
a, b, h = int(input()), int(input()), int(input())
print((a + b) * h // 2)
|
s215771352
|
p03761
|
u767664985
| 2,000
| 262,144
|
Wrong Answer
| 22
| 3,316
| 228
|
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 headline yet, he is interested in strings that can be created regardless of which string the headline contains. Find the longest string that can be created regardless of which string among S_1,...,S_n the headline contains. If there are multiple such strings, find the lexicographically smallest one among them.
|
from collections import Counter
n = int(input())
S = [input() for _ in range(n)]
res = Counter(S[0])
for s in S[1:]:
c = Counter(s)
res = res & c
ans = ""
for key in res.keys():
ans += key * res[key]
print(ans)
|
s071982792
|
Accepted
| 22
| 3,316
| 245
|
from collections import Counter
n = int(input())
S = [input() for _ in range(n)]
res = Counter(S[0])
for s in S[1:]:
c = Counter(s)
res = res & c
ans = ""
for key in res.keys():
ans += key * res[key]
print("".join(sorted(ans)))
|
s809091435
|
p02694
|
u667949809
| 2,000
| 1,048,576
|
Wrong Answer
| 23
| 9,160
| 114
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
money = 100
x = int(input())
count = 0
while money <= x:
money = int(money * 1.01)
count += 1
print(count)
|
s723004298
|
Accepted
| 22
| 9,168
| 113
|
money = 100
x = int(input())
count = 0
while money < x:
money = int(money * 1.01)
count += 1
print(count)
|
s396404666
|
p04029
|
u382431597
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 72
|
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())
isum = 0
for i in range(n+1):
isum += n
print(isum)
|
s412011862
|
Accepted
| 17
| 2,940
| 72
|
n = int(input())
isum = 0
for i in range(n+1):
isum += i
print(isum)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.