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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s195468850 | p03048 | u801512570 | 2,000 | 1,048,576 | Wrong Answer | 2,107 | 2,940 | 155 | Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this? | R,G,B,N=map(int,input().split())
tmp=0
for i in range(1,N+1):
for j in range(1,N+1):
if (R*i+G*j)<=N and (N-(R*i+G*j))%B==0:
tmp+=1
print(tmp) | s967396956 | Accepted | 1,551 | 2,940 | 147 | R,G,B,N=map(int,input().split())
tmp=0
for i in range(N//R+1):
for j in range((N-R*i)//G+1):
if (N-(R*i+G*j))%B==0:
tmp+=1
print(tmp)
|
s664084223 | p02612 | u231484984 | 2,000 | 1,048,576 | Wrong Answer | 28 | 9,048 | 38 | 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(str((N)%1000))
| s043439771 | Accepted | 26 | 9,156 | 74 | import math
N = int(input())
print(str((math.ceil((N)/1000))*1000 - (N)))
|
s034018046 | p02694 | u615590527 | 2,000 | 1,048,576 | Wrong Answer | 26 | 9,120 | 79 | 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())
i = 100
cnt = 0
while i<X:
i =i*101//1
cnt += 1
print(cnt) | s461022710 | Accepted | 29 | 9,120 | 80 | X = int(input())
i = 100
cnt = 0
while i<X:
i =i*1.01//1
cnt += 1
print(cnt) |
s555570654 | p03574 | u779170803 | 2,000 | 262,144 | Wrong Answer | 22 | 3,444 | 927 | You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. | INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
dxs=[-1,0,1]
dys=[-1,0,1]
h,w=INTM()
s=['.'*(w+2)]
ans=[[0]*(w+2) for i in range(h+2)]
for i in range(h):
st='.'+STR()+'.'
s.append(st)
s.append('.'*(w+2))
#print(s)
#print(ans)
for i in range(1,h+1):
for j in range(1,w+1):
if s[i][j]=='#':
ans[i][j]='#'
for dx in dxs:
for dy in dys:
if s[i+dx][j+dy]=='.':
#print(ans)
ans[i+dx][j+dy]=int(ans[i+dx][j+dy]+1)
for i in range(1,h+1):
print(*ans[i][1:w],sep='')
if __name__ == '__main__':
do() | s466240599 | Accepted | 22 | 3,572 | 929 | INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
dxs=[-1,0,1]
dys=[-1,0,1]
h,w=INTM()
s=['.'*(w+2)]
ans=[[0]*(w+2) for i in range(h+2)]
for i in range(h):
st='.'+STR()+'.'
s.append(st)
s.append('.'*(w+2))
#print(s)
#print(ans)
for i in range(1,h+1):
for j in range(1,w+1):
if s[i][j]=='#':
ans[i][j]='#'
for dx in dxs:
for dy in dys:
if s[i+dx][j+dy]=='.':
#print(ans)
ans[i+dx][j+dy]=int(ans[i+dx][j+dy]+1)
for i in range(1,h+1):
print(*ans[i][1:w+1],sep='')
if __name__ == '__main__':
do() |
s726151558 | p03698 | u594762426 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 71 | You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different. | s = str(input())
if s == set(s):
print("yes")
else:
print("no") | s499090713 | Accepted | 20 | 2,940 | 82 | s = str(input())
if len(s) == len(set(s)):
print("yes")
else:
print("no") |
s124951879 | p03377 | u464912173 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 71 | 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())
print('YES' if a+b <= x else 'NO') | s135391933 | Accepted | 17 | 2,940 | 82 | a, b, x = map(int, input().split())
print('YES' if a <= x and b >= x-a else 'NO') |
s856570218 | p03730 | u802963389 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 168 | We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`. | a, b, c = map(int,input().split())
flg = False
for i in range(a, a*b+1, a):
if i % b == c:
flg = True
break
if flg == True:
print("Yes")
else:
print("No") | s199441360 | Accepted | 17 | 2,940 | 168 | a, b, c = map(int,input().split())
flg = False
for i in range(a, a*b+1, a):
if i % b == c:
flg = True
break
if flg == True:
print("YES")
else:
print("NO") |
s205903661 | p02612 | u546853743 | 2,000 | 1,048,576 | Wrong Answer | 29 | 9,116 | 122 | 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())
if n%1000==0:
print('0')
else:
k = n
k += 1000
k %= 1000
cha = k*1000-n
print(cha) | s777248384 | Accepted | 28 | 9,148 | 123 |
n=int(input())
if n%1000==0:
print('0')
else:
k = n
k += 1000
k //= 1000
cha = k*1000-n
print(cha) |
s792704608 | p03693 | u791664126 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 59 | 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? | _,a,b=map(int,input().split())
print('YNEOS'[(a*10+b)%4>1]) | s487683596 | Accepted | 17 | 2,940 | 63 | _,a,b=map(int,input().split())
print('YNEOS'[(a*10+b)%4>0::2])
|
s155505803 | p03854 | u505830998 | 2,000 | 262,144 | Wrong Answer | 78 | 3,188 | 606 | 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`. | import sys
#+++++
def main():
s = input()
ww=['dream','dreamer','erase','eraser']
s=s[::-1]
wwr=[w[::-1] for w in ww]
#print(wwrs)
while len(s)>0:
pa(s)
is_ok=False
for w in wwr:
ll=len(w)
ss=s[:ll]
pa((2,ss,w))
if ss == w:
is_ok=True
pa((1,ss,ll))
s=s[ll:]
if not is_ok:
return 'No'
print('Yes')
#+++++
isTest=False
def pa(v):
if isTest:
print(v)
if __name__ == "__main__":
if sys.platform =='ios':
sys.stdin=open('inputFile.txt')
isTest=True
else:
pass
#input = sys.stdin.readline
ret = main()
if ret is not None:
print(ret) | s874245056 | Accepted | 69 | 3,236 | 618 | import sys
#+++++
def main():
s = input()
ww=['dream','dreamer','erase','eraser']
s=s[::-1]
wwr=[w[::-1] for w in ww]
#print(wwrs)
while len(s)>0:
#pa(s)
is_ok=False
for w in wwr:
ll=len(w)
ss=s[:ll]
#pa((2,ss,w))
if ss == w:
is_ok=True
#pa((1,ss,ll))
s=s[ll:]
if not is_ok:
print('NO')
return
print('YES')
#+++++
isTest=False
def pa(v):
if isTest:
print(v)
if __name__ == "__main__":
if sys.platform =='ios':
sys.stdin=open('inputFile.txt')
isTest=True
else:
pass
#input = sys.stdin.readline
ret = main()
if ret is not None:
print(ret) |
s833839624 | p03556 | u539826121 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 37 | Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer. | x = int(input())
print(int(x**0.25))
| s548317205 | Accepted | 24 | 2,940 | 70 | n = int(input())
x = 0
while (x+1) * (x+1)<= n:
x += 1
print(x*x)
|
s244618086 | p03471 | u994521204 | 2,000 | 262,144 | Wrong Answer | 2,104 | 17,332 | 463 | 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=list(map(int, input().split()))
ans=(-1, -1, -1)
flag=False
for x in range(Y//10000, -1, -1):
for y in range((Y-10000*x)//5000, -1, -1):
for z in range((Y-10000*x-5000*y)//1000,-1,-1):
print(x, y, z)
if N==x+y+z:
ans=(x,y,z)
flag=True
break
if flag==True:
break
if flag==True:
break
if flag==True:
break
print(ans) | s442539446 | Accepted | 820 | 3,060 | 338 | N, Y=list(map(int, input().split()))
ans=[-1, -1, -1]
flag=False
for x in range(N, -1, -1):
for y in range(N-x, -1, -1):
if 10000*x+5000*y+1000*(N-x-y)==Y:
ans=[x,y,N-x-y]
flag=True
break
if flag==True:
break
if flag==True:
break
print(ans[0],ans[1],ans[2])
|
s340560919 | p02846 | u738898077 | 2,000 | 1,048,576 | Wrong Answer | 18 | 3,064 | 542 | Takahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east. They start simultaneously at the same point and moves as follows **towards the east** : * Takahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever. * Aoki runs B_1 meters per minute for the first T_1 minutes, then runs at B_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever. How many times will Takahashi and Aoki meet each other, that is, come to the same point? We do not count the start of the run. If they meet infinitely many times, report that fact. | t1,t2 = map(int,input().split())
c1,c2 = map(int,input().split())
d1,d2 = map(int,input().split())
hosei = 1
if t1*c1>t1*d1:
a1=c1
a2=c2
b1=d1
b2=d2
else:
a1,a2,b1,b2=d1,d2,c1,c2
print(a1,a2,b1,b2)
if t1*a1+t2*a2 > t1*b1+t2*b2:
exit()
elif t1*a1+t2*a2 == t1*b1+t2*b2:
print("infinity")
else:
# print((t1*(a1-b1))//(t2*(b2-a2)) + 1,t1*(a1-b1),t2*(b2-a2))
# if t2*(b2-a2) % (t2*(b2-a2)-t1*(a1-b1)) == 0:
print((t2*(b2-a2)) // (t2*(b2-a2)-t1*(a1-b1))*2-hosei)
# print((t2*(a2-b2))) | s190287775 | Accepted | 18 | 3,064 | 534 | t1,t2 = map(int,input().split())
c1,c2 = map(int,input().split())
d1,d2 = map(int,input().split())
hosei = 0
if t1*c1>t1*d1:
a1=c1
a2=c2
b1=d1
b2=d2
else:
a1,a2,b1,b2=d1,d2,c1,c2
if t1*a1+t2*a2 > t1*b1+t2*b2:
print(0)
exit()
elif t1*a1+t2*a2 == t1*b1+t2*b2:
print("infinity")
else:
# print((t1*(a1-b1))//(t2*(b2-a2)) + 1,t1*(a1-b1),t2*(b2-a2))
if t2*(b2-a2) % (t2*(b2-a2)-t1*(a1-b1)) == 0:
hosei = 1
print((t2*(b2-a2)) // (t2*(b2-a2)-t1*(a1-b1))*2-1-hosei)
# print((t2*(a2-b2))) |
s287546285 | p03534 | u796366385 | 2,000 | 262,144 | Wrong Answer | 18 | 3,188 | 149 | 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. | s = input()
a = [s.count("a"), s.count("b"), s.count("c")]
a.sort(reverse=True)
print(a)
if a[0] <= a[2] + 1:
print("YES")
else:
print("NO")
| s547073178 | Accepted | 18 | 3,188 | 140 | s = input()
a = [s.count("a"), s.count("b"), s.count("c")]
a.sort(reverse=True)
if a[0] <= a[2] + 1:
print("YES")
else:
print("NO")
|
s443976112 | p03636 | u226912938 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 66 | The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way. | s = str(input())
ans = s[0] + str(len(s[1:-2])) + s[-1]
print(ans) | s043328645 | Accepted | 17 | 2,940 | 66 | s = str(input())
ans = s[0] + str(len(s[1:-1])) + s[-1]
print(ans) |
s338428414 | p03361 | u071416928 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 373 | 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. | h, w = map(int,input().split())
s = [["."]*(w+2)] + \
[list("." + input() + ".") for _ in range(h)] + \
[["."]*(w+2)]
flg = 0
for i in range(1,h+1):
for j in range(1,w+1):
if s[i][j] == "#":
if s[i-1][j] == "#" or s[i+1][j] == "#" or s[i][-1] == "#" or s[i][j+1] == "#" :
flg = 1
if flg == 1 : print("Yse")
else : print("No") | s993527792 | Accepted | 18 | 3,064 | 363 | h, w = map(int,input().split())
s = [["."]*(w+2)] + \
[list("." + input() + ".") for _ in range(h)] + \
[["."]*(w+2)]
for i in range(1,h+1):
for j in range(1,w+1):
if s[i][j] == "#":
if s[i-1][j] == "." and s[i+1][j] == "." and s[i][j-1] == "." and s[i][j+1] == "." :
print("No")
exit()
print("Yes") |
s443050861 | p03545 | u404676457 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 669 | Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted. | (a, b, c, d) = map(int, list(input()))
print(a)
if a+b+c+d == 7:
print(str(a) + '+' + str(b) + '+' + str(c) + '+' + str(d) + '=7')
elif a+b+c-d == 7:
print(str(a) + '+' + str(b) + '+' + str(c) + '-' + str(d) + '=7')
elif a+b-c+d == 7:
print(str(a) + '+' + str(b) + '-' + str(c) + '+' + str(d) + '=7')
elif a+b-c-d == 7:
print(str(a) + '+' + str(b) + '-' + str(c) + '-' + str(d) + '=7')
elif a-b+c-d == 7:
print(str(a) + '-' + str(b) + '+' + str(c) + '-' + str(d) + '=7')
elif a-b-c+d == 7:
print(str(a) + '-' + str(b) + '-' + str(c) + '+' + str(d) + '=7')
elif a-b-c-d == 7:
print(str(a) + '-' + str(b) + '-' + str(c) + '-' + str(d) + '=7') | s661678380 | Accepted | 17 | 3,064 | 749 | (a, b, c, d) = map(int, list(input()))
if a+b+c+d == 7:
print(str(a) + '+' + str(b) + '+' + str(c) + '+' + str(d) + '=7')
elif a+b+c-d == 7:
print(str(a) + '+' + str(b) + '+' + str(c) + '-' + str(d) + '=7')
elif a+b-c+d == 7:
print(str(a) + '+' + str(b) + '-' + str(c) + '+' + str(d) + '=7')
elif a-b+c+d == 7:
print(str(a) + '-' + str(b) + '+' + str(c) + '+' + str(d) + '=7')
elif a+b-c-d == 7:
print(str(a) + '+' + str(b) + '-' + str(c) + '-' + str(d) + '=7')
elif a-b+c-d == 7:
print(str(a) + '-' + str(b) + '+' + str(c) + '-' + str(d) + '=7')
elif a-b-c+d == 7:
print(str(a) + '-' + str(b) + '-' + str(c) + '+' + str(d) + '=7')
elif a-b-c-d == 7:
print(str(a) + '-' + str(b) + '-' + str(c) + '-' + str(d) + '=7') |
s776494487 | p02268 | u926657458 | 1,000 | 131,072 | Wrong Answer | 20 | 5,564 | 494 | 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. | import sys
def binsearch(x, s):
l = 0
r = len(s) - 1
while (l < r):
m = int((l + r) / 2)
if s[m] == x:
return True
else:
if s[m] < x:
l = m + 1
else:
r = m
return False
ns = sys.stdin.readline()
s = sys.stdin.readline().split()
nt = sys.stdin.readline()
t = sys.stdin.readline().split()
out = ""
for x in t:
if (binsearch(x, s)):
out += str(x) + " "
print(out.strip()) | s441196654 | Accepted | 250 | 16,712 | 374 | n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))
def search(a, X):
l = 0
r = len(X)
while l < r:
m = (l + r ) // 2
if a == X[m]:
return m
elif a > X[m]:
l = m + 1
elif a < X[m]:
r = m
return None
s = 0
for t in T:
if search(t,S) is not None:
s += 1
print(s)
|
s349148600 | p03385 | u697658632 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 64 | You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`. | if sorted(input()) == 'abc':
print('Yes')
else:
print('No')
| s786341025 | Accepted | 17 | 2,940 | 113 | s = input()
t = []
for c in s:
t.append(c)
if sorted(t) == ['a', 'b', 'c']:
print('Yes')
else:
print('No')
|
s817430660 | p04025 | u562015767 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 472 | Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective. | import sys
n = int(input())
a = list(map(int,input().split()))
s = ((sum(a))//n)+1
t = sum(a)//n
u = ((sum(a))//n)-1
l = []
l.append(s)
l.append(t)
l.append(u)
ans = []
ans2 = []
aa = set(a)
if len(aa) == 1:
print(0)
sys.exit()
for j in range(len(l)):
ans = []
for i in range(n):
if a[i] == l[j]:
continue
else:
b = (a[i]-l[j])**2
ans.append(b)
ans2.append(sum(ans))
print(ans2)
print(min(ans2)) | s389444556 | Accepted | 27 | 9,088 | 461 | import sys
n = int(input())
a = list(map(int,input().split()))
s = ((sum(a))//n)+1
t = sum(a)//n
u = ((sum(a))//n)-1
l = []
l.append(s)
l.append(t)
l.append(u)
ans = []
ans2 = []
aa = set(a)
if len(aa) == 1:
print(0)
sys.exit()
for j in range(len(l)):
ans = []
for i in range(n):
if a[i] == l[j]:
continue
else:
b = (a[i]-l[j])**2
ans.append(b)
ans2.append(sum(ans))
print(min(ans2))
|
s289752748 | p04011 | u981206782 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 123 | There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee. | n=int(input())
k=int(input())
x=int(input())
y=int(input())
ans=0
if n<k:
ans=x*n
else:
ans=x*n+y*(n-k)
print(ans)
| s050277921 | Accepted | 19 | 2,940 | 122 | n=int(input())
k=int(input())
x=int(input())
y=int(input())
ans=0
if n<k:
ans=x*n
else:
ans=x*k+y*(n-k)
print(ans) |
s239727153 | p00102 | u755162050 | 1,000 | 131,072 | Wrong Answer | 30 | 7,616 | 757 | Your task is to develop a tiny little part of spreadsheet software. Write a program which adds up columns and rows of given table as shown in the following figure: | from sys import stdin
if __name__ == '__main__':
for n in stdin:
if int(n) == 0:
break
bottom_total = []
right_total = []
for _ in range(int(n)):
line = input().split(' ')
total = 0
for i, v in enumerate(line):
print(repr(int(v)).rjust(5), end='')
total += int(v)
if len(bottom_total) < _ + 1:
bottom_total.append(int(v))
else:
bottom_total[_] += int(v)
right_total.append(total)
print(repr(right_total[_]).rjust(5))
for num in bottom_total:
print(repr(num).rjust(5), end='')
print(repr(sum(right_total)).rjust(5)) | s470592631 | Accepted | 40 | 7,692 | 520 | def output_res(row):
print(''.join(map(lambda num: str(num).rjust(5), row)), str(sum(row)).rjust(5), sep='')
def main():
while True:
n = int(input())
if n == 0:
break
bottom_total = [0 for _ in range(n)]
for _ in range(n):
each_line = list(map(int, input().split(' ')))
output_res(each_line)
bottom_total = [x + y for x, y in zip(bottom_total, each_line)]
output_res(bottom_total)
if __name__ == '__main__':
main() |
s734315443 | p03997 | u568789901 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 66 | 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(int(a*b*h/2))
| s586858278 | Accepted | 18 | 2,940 | 68 | a=int(input())
b=int(input())
h=int(input())
print(int((a+b)*h/2))
|
s828564322 | p02928 | u538632589 | 2,000 | 1,048,576 | Wrong Answer | 608 | 3,188 | 556 | We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}. Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2. Find the inversion number of B, modulo 10^9 + 7. Here the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \leq i < j \leq K \times N - 1) such that B_i > B_j. |
N, K = map(int, input().split())
As = list(map(int, input().split()))
MOD = 10**9 + 7
K_1 = K*(1+K) % MOD
K_1 /= 2
K_2 = (K_1 - K) % MOD
res_next = [0 for i in range(N)]
for i in range(N):
a = As[i]
for j in range(i+1, N):
if a > As[j]:
res_next[i] += 1
res_prev = [0 for i in range(N)]
for i in range(N):
a = As[i]
for j in range(i):
if a > As[j]:
res_prev[i] += 1
ans = 0
for i in range(N):
ans += (res_next[i] * K_1) % MOD
ans += (res_prev[i] * K_2) % MOD
ans %= MOD
print(ans) | s743363206 | Accepted | 775 | 5,204 | 714 | from decimal import *
N, K = map(int, input().split())
As = list(map(int, input().split()))
MOD = 10**9 + 7
K_1 = Decimal(K)*Decimal(1+K) / Decimal(2)
K_2 = (K_1 - Decimal(K)) % Decimal(MOD)
K_1 %= Decimal(MOD)
res_next = [0 for i in range(N)]
for i in range(N):
a = As[i]
for j in range(i+1, N):
if a > As[j]:
res_next[i] += 1
res_prev = [0 for i in range(N)]
for i in range(N):
a = As[i]
for j in range(i):
if a > As[j]:
res_prev[i] += 1
ans = Decimal(0)
for i in range(N):
ans += (Decimal(res_next[i]) * K_1) % Decimal(MOD)
ans %= Decimal(MOD)
ans += (Decimal(res_prev[i]) * K_2) % Decimal(MOD)
ans %= Decimal(MOD)
print(int(ans))
|
s011675947 | p03998 | u792512290 | 2,000 | 262,144 | Wrong Answer | 22 | 3,316 | 374 | Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game. | s_a = list(input())[::-1]
s_b = list(input())[::-1]
s_c = list(input())[::-1]
person = "a"
try:
while True:
print("s_a", s_a)
print("s_a", s_b)
print("s_a", s_c)
print("---------")
if person == "a":
person = s_a.pop()
elif person == "b":
person = s_b.pop()
else:
person = s_c.pop()
except IndexError:
print(person.upper()) | s155015702 | Accepted | 17 | 3,060 | 285 | s_a = list(input())[::-1]
s_b = list(input())[::-1]
s_c = list(input())[::-1]
person = "a"
try:
while True:
if person == "a":
person = s_a.pop()
elif person == "b":
person = s_b.pop()
else:
person = s_c.pop()
except IndexError:
print(person.upper()) |
s671425405 | p03407 | u380772254 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 81 | 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())
print('Yes' if a == c or b==c or a+b==c else 'No') | s517528273 | Accepted | 17 | 2,940 | 63 | a,b,c=map(int,input().split())
print('Yes' if c<=a+b else 'No') |
s783448267 | p03214 | u859897687 | 2,525 | 1,048,576 | Wrong Answer | 17 | 3,060 | 146 | 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 number of the frames of the video, and each a_i denotes the representation of the i-th frame of the video. * Select t-th frame whose representation a_t is nearest to the average of all frame representations. * If there are multiple such frames, select the frame with the smallest index. Find the index t of the frame he should select to generate a thumbnail. | n=int(input())
l=list(map(int,input().split()))
a=sum(l)/n
ans=0
b=100
for i in range(n):
if b>abs(l[i]-a):
b=abs(l[i]-a)
ans=i
print(i) | s439452767 | Accepted | 17 | 3,060 | 148 | n=int(input())
l=list(map(int,input().split()))
a=sum(l)/n
ans=0
b=100
for i in range(n):
if b>abs(l[i]-a):
b=abs(l[i]-a)
ans=i
print(ans) |
s105136523 | p03605 | u636267225 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 83 | 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? | N = int(input())
if N//10 == 9 or N%10 == 9:
print("YES")
else:
print("NO") | s231533218 | Accepted | 17 | 2,940 | 83 | N = int(input())
if N//10 == 9 or N%10 == 9:
print("Yes")
else:
print("No") |
s280089624 | p04011 | u307418002 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 170 | There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee. |
n = int(input())
k = int(input())
x = int(input())
y = int(input())
sum = 0
for i in range( n ):
if i ==1 :
sum += x
else :
sum += y
print(sum)
| s393860664 | Accepted | 19 | 3,060 | 169 |
n = int(input())
k = int(input())
x = int(input())
y = int(input())
sum = 0
for i in range( n ):
if i < k :
sum += x
else :
sum += y
print(sum) |
s759573224 | p03861 | u114648678 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 47 | You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x? | a,b,x=map(int,input().split())
print(b//x-a//x) | s371736488 | Accepted | 29 | 2,940 | 51 | a,b,x=map(int,input().split())
print(b//x-(a-1)//x) |
s325203455 | p03387 | u227550284 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 398 | 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 proved that we can always make A, B and C all equal by repeatedly performing these operations. | import sys
input = sys.stdin.readline
def main():
li = list(map(int, input().split()))
max_n = max(li)
max_i = li.index(max_n)
diff = 0
for i in range(3):
if i == max_i:
continue
diff += max_n - li[i]
print(diff)
if diff % 2 == 0:
print(diff//2)
else:
print((diff+1)//2 + 1)
if __name__ == '__main__':
main()
| s299595652 | Accepted | 17 | 2,940 | 172 | li = list(map(int, input().split()))
sum_li = sum(li)
max_li = max(li)
j = 3 * max_li - sum_li
if j % 2 == 0:
ans = j // 2
else:
ans = (j + 3) // 2
print(ans)
|
s160320224 | p03721 | u188745744 | 2,000 | 262,144 | Wrong Answer | 572 | 32,724 | 284 | There is an empty array. The following N operations will be performed to insert integers into the array. In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array. Find the K-th smallest integer in the array after the N operations. For example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3. | N,K = list(map(int,input().split()))
listA = []
for i in range(N):
listA.append(list(map(int,input().split())))
now = 0
listA.sort()
print(listA)
for i in range(N):
if now <= K <= now+listA[i][1]:
print(listA[i][0])
exit()
else:
now += listA[i][1] | s721143928 | Accepted | 544 | 29,448 | 271 | N,K = list(map(int,input().split()))
listA = []
for i in range(N):
listA.append(list(map(int,input().split())))
now = 0
listA.sort()
for i in range(N):
if now <= K <= now+listA[i][1]:
print(listA[i][0])
exit()
else:
now += listA[i][1] |
s032919091 | p03564 | u319690708 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 194 | Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations. | N = int(input())
R = int(input())
max = 0
maxcounter = 0
j = 1
for i in range(N):
# counter = 0
# while j > 1:
if j * 2 <= j + R:
j = j * 2
# counter += 1
else:
j = j + R
| s067761360 | Accepted | 18 | 2,940 | 203 | N = int(input())
R = int(input())
max = 0
maxcounter = 0
j = 1
for i in range(N):
# counter = 0
# while j > 1:
if j * 2 <= j + R:
j = j * 2
# counter += 1
else:
j = j + R
print(j) |
s380450651 | p00228 | u350508326 | 1,000 | 131,072 | Wrong Answer | 40 | 7,400 | 650 | 電卓などでよく目にするデジタル数字を表示している画面は、デジタル数字が 7 つの部分(セグメン ト)で構成されることから、「7セグメントディスプレイ」と呼ばれています。 ワカマツ社で新しく売り出す予定の製品は、7セグメントディスプレイを製品に組み込むことになり、社員であるあなたは、与えられた数字を 7 セグメントディスプレイに表示するプログラムを作成することになりました。 この7セグメントディスプレイは、次の切り替えの指示が送られてくるまで表示状態は変わりません。7 ビットからなるシグナルを送ることで、それぞれ対応したセグメントの表示情報を切り替える事ができます。ビットとは 1 か 0 の値を持つもので、ここでは 1 が「切り替え」、0 が「そのまま」を表します。 各ビットとセグメントの対応関係は下の図のようになっています。シグナルは 7 つのビットを"gfedcba"の順番に送ります。例えば、非表示の状態から「0」を表示するためには"0111111"をシグナルとしてディスプレイに送らなければなりません。「0」から「5」に変更する場合には"1010010"を送ります。続けて「5」を「1」に変更する場合には"1101011"を送ります。 表示したい n (1 ≤ n ≤ 100) 個の数字を入力とし、それらの数字 di (0 ≤ di ≤ 9) を順に 7 セグメントディスプレイに正しく表示するために必要なシグナル列を出力するプログラムを作成してください。なお、7 セグメントディスプレイの初期状態は全て非表示の状態であるものとします。 | #!/usr/bin/env python3
seven_seg = {
0: '0111111',
1: '0000110',
2: '1011011',
3: '1001111',
4: '1100110',
5: '1101101',
6: '1111101',
7: '0100111',
8: '1111111',
9: '1101111'
}
while True:
seven_seg_state = ['0'] * 7
n = int(input())
if n == -1:
break
for _ in range(n):
in_data = int(input())
for i, s in enumerate(seven_seg_state):
if seven_seg[in_data][i] == s:
print("0", end="")
else:
print("1", end="")
s = seven_seg[in_data][i]
print() | s731045893 | Accepted | 30 | 7,404 | 663 | #!/usr/bin/env python3
seven_seg = {
0: '0111111',
1: '0000110',
2: '1011011',
3: '1001111',
4: '1100110',
5: '1101101',
6: '1111101',
7: '0100111',
8: '1111111',
9: '1101111'
}
while True:
seven_seg_state = ['0'] * 7
n = int(input())
if n == -1:
break
for _ in range(n):
in_data = int(input())
for i in range(7):
if seven_seg[in_data][i] == seven_seg_state[i]:
print("0", end="")
else:
print("1", end="")
seven_seg_state[i] = seven_seg[in_data][i]
print() |
s660834003 | p01052 | u283783177 | 1,000 | 261,120 | Wrong Answer | 20 | 7,608 | 874 | 太郎君は夏休みの間、毎日1つの映画を近所の映画館で見ることにしました。 (太郎君の夏休みは8月1日から8月31日までの31日間あります。) その映画館では、夏休みの間にn つの映画が上映されることになっています。 それぞれの映画には 1 から n までの番号が割り当てられており、i 番目の映画は8月 ai 日から8月 bi 日の間だけ上映されます。 太郎君は映画を見た時、それが初めて見る映画だった場合は 100 の幸福度を得ることができます。 しかし、過去に 1 度でも見たことのある映画だった場合は 50 の幸福度を得ます。 太郎君は上映される映画の予定表をもとに、夏休みの計画を立てることにしました。 太郎君が得られる幸福度の合計値が最大になるように映画を見たときの合計値を求めてください。 どの日も必ず1つ以上の映画が上映されていることが保証されます。 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
As = []
Bs = []
movies = [[] for x in range(31)]
for n in range(N):
a, b = map(int, input().split())
a -= 1
b -= 1
As.append(a)
Bs.append(b)
for day in range(a, b+1):
movies[day].append(n)
print(movies)
picked = [False] * N
ans = 0
for day in range(31):
# ????????????????????????
unseen_movies = [m for m in movies[day] if not picked[m]]
# ???????????????????????????
if len(unseen_movies) == 0:
ans += 50
else:
lastday = 1000
should_see = -1
for m in unseen_movies:
if Bs[m] < lastday:
lastday = Bs[m]
should_see = m
picked[should_see] = True
ans += 100
print(ans) | s393189371 | Accepted | 30 | 7,732 | 860 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
As = []
Bs = []
movies = [[] for x in range(31)]
for n in range(N):
a, b = map(int, input().split())
a -= 1
b -= 1
As.append(a)
Bs.append(b)
for day in range(a, b+1):
movies[day].append(n)
picked = [False] * N
ans = 0
for day in range(31):
# ????????????????????????
unseen_movies = [m for m in movies[day] if not picked[m]]
# ???????????????????????????
if len(unseen_movies) == 0:
ans += 50
else:
lastday = 1000
should_see = -1
for m in unseen_movies:
if Bs[m] < lastday:
lastday = Bs[m]
should_see = m
picked[should_see] = True
ans += 100
print(ans) |
s429625143 | p02613 | u761168538 | 2,000 | 1,048,576 | Wrong Answer | 151 | 9,160 | 236 | 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())
l=[0,0,0,0]
for _ in range(n):
s=input()
if(s=='AC'):
l[0]+=1
elif(s=='WA'):
l[1]+=1
elif(s=='TLE'):
l[2]+=1
elif(s=='RE'):
l[3]+=1
print("AC X",l[0])
print("WA X",l[1])
print("TLE X",l[2])
print("RE X",l[3]) | s191922704 | Accepted | 148 | 9,212 | 236 | n=int(input())
l=[0,0,0,0]
for _ in range(n):
s=input()
if(s=='AC'):
l[0]+=1
elif(s=='WA'):
l[1]+=1
elif(s=='TLE'):
l[2]+=1
elif(s=='RE'):
l[3]+=1
print("AC x",l[0])
print("WA x",l[1])
print("TLE x",l[2])
print("RE x",l[3]) |
s045512275 | p03545 | u904331908 | 2,000 | 262,144 | Wrong Answer | 27 | 9,108 | 428 | Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted. | s = input()
p = list(map(int,s))
for x in range(2**3):
ans = p[0]
for y in range(3):
if (x>>y)&1:
ans += p[y+1]
else:
ans -= p[y+1]
if ans == 7:
kotae = format(x,"#05b")
kotae = kotae[2:]
print(kotae)
for z in range(3):
print(str(p[z]),end="")
if kotae[-z-1] == str(1):
print("+",end="")
else:
print("-",end="")
print(str(p[3]) + "=7" )
| s051547987 | Accepted | 27 | 9,128 | 277 |
A = input()
n = len(A)-1
for i in range(2**n):
pn = ['-']*n
for j in range(n):
if ((i>>j)&1):
pn[n-1-j] = '+'
ans = A[0]+pn[0]+A[1]+pn[1]+A[2]+pn[2]+A[3]
if eval(ans) == 7:
print(ans+'=7')
break
|
s968323832 | p03574 | u928784113 | 2,000 | 262,144 | Wrong Answer | 31 | 3,188 | 542 | You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. | H,W = map(int,input().split())
S = [list(input()) for i in range(H)]
print(S)
dx = [1,1,1,0,0,-1,-1,-1]
dy = [1,0,-1,1,-1,1,0,-1]
for j in range(H):
for i in range(W):
cnt = 0
for k in range(8):
if 0<=i+dx[k]<W and 0<=j+dy[k]<H:
if S[j+dy[k]][i+dx[k]]=="#":
cnt += 1
if S[j][i] == "#":
continue
else:
S[j][i] = cnt
for i in range(H):
for j in range(W):
S[i][j] = str(S[i][j])
for i in range(H):
print("".join(S[i])) | s104738032 | Accepted | 31 | 3,188 | 533 | H,W = map(int,input().split())
S = [list(input()) for i in range(H)]
dx = [1,1,1,0,0,-1,-1,-1]
dy = [1,0,-1,1,-1,1,0,-1]
for j in range(H):
for i in range(W):
cnt = 0
for k in range(8):
if 0<=i+dx[k]<W and 0<=j+dy[k]<H:
if S[j+dy[k]][i+dx[k]]=="#":
cnt += 1
if S[j][i] == "#":
continue
else:
S[j][i] = cnt
for i in range(H):
for j in range(W):
S[i][j] = str(S[i][j])
for i in range(H):
print("".join(S[i])) |
s088259733 | p03814 | u479638406 | 2,000 | 262,144 | Wrong Answer | 44 | 4,840 | 167 | 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())
A = 0
Z = 0
for i in range(len(s)):
if s[i] == 'A':
A = i
break
for i in range(len(s)):
if s[i] == 'Z':
Z = i
print(Z - A) | s656120358 | Accepted | 47 | 4,840 | 172 | s = list(input())
A = 0
Z = 0
for i in range(len(s)):
if s[i] == 'A':
A = i
break
for i in range(len(s)):
if s[i] == 'Z':
Z = i
print(Z - A + 1)
|
s658841697 | p02613 | u642267889 | 2,000 | 1,048,576 | Wrong Answer | 160 | 16,268 | 427 | 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. | # Judge Status Summary
N = int(input())
stringList = [input() for i in range(N)]
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for j in range(N):
if stringList[j] == 'AC':
c0 = c0 + 1
if stringList[j] == 'WA':
c1 = c1 + 1
if stringList[j] == 'TLE':
c2 = c2 + 1
if stringList[j] == 'RE':
c3 = c3 + 1
print('AC×'+ str(c0))
print('WA×'+ str(c1))
print('TLE×'+str(c2))
print('RE×'+ str(c3))
| s808636321 | Accepted | 158 | 16,332 | 431 | # Judge Status Summary
N = int(input())
stringList = [input() for i in range(N)]
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for j in range(N):
if stringList[j] == 'AC':
c0 = c0 + 1
if stringList[j] == 'WA':
c1 = c1 + 1
if stringList[j] == 'TLE':
c2 = c2 + 1
if stringList[j] == 'RE':
c3 = c3 + 1
print('AC x '+ str(c0))
print('WA x '+ str(c1))
print('TLE x '+str(c2))
print('RE x '+ str(c3))
|
s408140715 | p02842 | u361381049 | 2,000 | 1,048,576 | Wrong Answer | 32 | 2,940 | 118 | Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact. | n = int(input())
a = []
for i in range(n):
if int(i * 1.08) == n:
print(int(i * 1.08))
exit()
print(':(') | s759587519 | Accepted | 35 | 2,940 | 125 | n = int(input())
import math
for i in range(50000):
if math.floor(i*1.08) == n:
print(i)
exit()
print(':(') |
s321410732 | p02902 | u893063840 | 2,000 | 1,048,576 | Wrong Answer | 2,107 | 4,080 | 1,240 | Given is a directed graph G with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i. It is guaranteed that the graph contains no self-loops or multiple edges. Determine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph. Here the null graph is not considered as a subgraph. | from queue import Queue
INF = 10 * 9
n = 0
g = []
def bfs(s):
dist = [INF for _ in range(n)]
pre = [-1 for _ in range(n)]
q = Queue()
dist[s] = 0
q.put(s)
while not q.empty():
f = q.get()
for i in g[f]:
if dist[i] != INF:
continue
pre[i] = f
dist[i] = dist[f] + 1
q.put(i)
best = INF, -1
for i in range(n):
if i == s:
continue
for j in g[i]:
if j == s:
best = min(best, (dist[i], i))
if best[0] == INF:
return [INF for _ in range(n + 1)]
t = best[1]
res = []
while t != -1:
res.append(t)
t = pre[t]
return res
def main():
global n, g
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(m):
a, b = map(int, input().split())
a -= 1
b -= 1
g[a].append(b)
ans = [INF for _ in range(n + 1)]
for i in range(n):
now = bfs(i)
if len(now) < len(ans):
ans = now
if len(ans) == n + 1:
print(-1)
return
print(len(ans))
for e in ans:
print(e + 1)
if __name__ == "__main__":
main()
| s293156444 | Accepted | 924 | 3,956 | 894 | from collections import deque
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
INF = 10 ** 5
adj = [[] for _ in range(n)]
for a, b in ab:
a -= 1
b -= 1
adj[a].append(b)
mn = INF
for s in range(n):
dq = deque([s])
d = [-1] * n
p = [-1] * n
d[s] = 0
last = []
while dq:
u = dq.popleft()
for v in adj[u]:
if d[v] == -1:
d[v] = d[u] + 1
p[v] = u
dq.append(v)
if v == s:
last.append(u)
for v in last:
route = [v]
while p[v] != s:
v = p[v]
route.append(v)
route.append(s)
size = len(route)
if size < mn:
mn = size
ans = route[::-1]
if mn != INF:
print(mn)
for e in ans:
print(e + 1)
else:
print(-1)
|
s194037286 | p02393 | u506468108 | 1,000 | 131,072 | Wrong Answer | 20 | 5,592 | 281 | Write a program which reads three integers, and prints them in ascending order. | a, b, c= map(int, input().split())
if a >= b:
big = a
mid = b
else:
big = b
mid = a
if c >= big:
small = big
big = c
else:
small = c
if small >= mid:
small_1 = mid
mid = small
small = small_1
print("{0} {1} {2}".format(big, mid, small))
| s853338683 | Accepted | 20 | 5,596 | 279 | a, b, c= map(int, input().split())
if a >= b:
big = a
mid = b
else:
big = b
mid = a
if c >= big:
small = big
big = c
else:
small = c
if small >= mid:
small_1 = mid
mid = small
small = small_1
print("{0} {1} {2}".format(small, mid, big))
|
s810082464 | p03129 | u496821919 | 2,000 | 1,048,576 | Wrong Answer | 18 | 3,064 | 84 | Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1. | n,k = map(int,input().split())
if 2*k-1 <= n:
print("Yes")
else:
print("No") | s229571486 | Accepted | 17 | 2,940 | 84 | n,k = map(int,input().split())
if 2*k-1 <= n:
print("YES")
else:
print("NO") |
s676673215 | p00256 | u849555829 | 5,000 | 131,072 | Wrong Answer | 40 | 7,096 | 770 | 真也君はテレビで「マヤの大予言!2012年で世界が終る?」という番組を見ました。結局、世界が終るかどうかはよくわかりませんでしたが、番組で紹介されていたマヤの「長期暦」という暦に興味を持ちました。その番組では以下のような説明をしていました。 マヤ長期暦は、右の表のような単位からなる、全部で13バクトゥン(187万2000日)で構成される非常に長い暦である。ある計算法では、この暦は紀元前3114年8月11日に始まり2012年12月21日に終わると考えられていて、このため今年の12月21日で世界が終るという説が唱えられている。しかし、13バクトゥンで1サイクルとなり、今の暦が終わったら新しいサイクルに入るだけという考えもある。 | 1キン=1日 1ウィナル=20キン 1トゥン=18ウィナル 1カトゥン=20トゥン 1バクトゥン=20カトゥン | ---|---|--- 「ぼくの二十歳の誕生日はマヤ暦だと何日になるのかな?」真也君はいろいろな日をマヤ長期暦で表してみたくなりました。 では、真也君の代わりに、西暦とマヤ長期暦とを相互変換するプログラムを作成してください。 | from datetime import date, timedelta
st = date(2012, 12, 21)
while True:
s = input()
if s == '#':
break
d = list(map(int, s.split('.')))
if len(d) == 3:
r = 0
while d[0] > 3000:
d[0] -= 400
r += 365*400+97
ed = date(d[0], d[1], d[2])
r += (ed-st).days
ki = r%20
r//=20
w = r%18
r//=18
t = r%20
r//=20
ka = r%20
r//=20
b = r%13
print(str(b)+'.'+str(ka)+'.'+str(t)+'.'+str(w)+'.'+str(ki))
else:
r = d[0]
r *= 20
r += d[1]
r *= 20
r += d[2]
r *= 18
r += d[3]
r *= 20
r += d[4]
print((st+timedelta(days=r)).strftime("%Y.%m.%d")) | s021849729 | Accepted | 930 | 7,096 | 807 | from datetime import date, timedelta
st = date(2012, 12, 21)
while True:
s = input()
if s == '#':
break
d = list(map(int, s.split('.')))
if len(d) == 3:
r = 0
while d[0] > 3000:
d[0] -= 400
r += 365*400+97
ed = date(d[0], d[1], d[2])
r += (ed-st).days
ki = r%20
r//=20
w = r%18
r//=18
t = r%20
r//=20
ka = r%20
r//=20
b = r%13
print(str(b)+'.'+str(ka)+'.'+str(t)+'.'+str(w)+'.'+str(ki))
else:
r = d[0]
r *= 20
r += d[1]
r *= 20
r += d[2]
r *= 18
r += d[3]
r *= 20
r += d[4]
ed = st+timedelta(days=r)
print(str(ed.year)+'.'+str(ed.month)+'.'+str(ed.day)) |
s802556535 | p04012 | u653792857 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 262 | Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. | n = input()
char_set = { x for x in n}
char_freq = { x : n.count(x) for x in char_set }
judge = 'YES'
for v in char_freq.values():
if(v % 2 != 0):
judge = 'NO'
print(judge) | s116501254 | Accepted | 17 | 3,060 | 220 |
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
w=input()
for x in l:
if w.count(x)%2!=0:
print('No')
exit()
print('Yes') |
s932075151 | p02833 | u185502200 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 136 | 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 = int(input())
p = 5
tmp = 0
n //= 2
while n > 1:
tmp += n // p
n = n // p
if n % 2 == 0:
print(tmp)
else:
print(0) | s732761199 | Accepted | 17 | 3,060 | 142 | n = int(input())
p = 5
tmp = 0
o = n
n //= 2
while n > 1:
tmp += n // p
n = n // p
if o % 2 == 0:
print(tmp)
else:
print(0) |
s326868801 | p02694 | u955865184 | 2,000 | 1,048,576 | Wrong Answer | 22 | 9,164 | 90 | 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())
t, ans = 100, 0
while t < x:
t += int(t * (1.01))
ans += 1
print(ans) | s403879227 | Accepted | 24 | 9,168 | 89 | x = int(input())
t, ans = 100, 0
while t < x:
t = int(t * (1.01))
ans += 1
print(ans) |
s046238387 | p03737 | u331464808 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 64 | You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. | a,b,c = map(str,input().split())
print('a[0],b[0],c[0]'.upper()) | s134543755 | Accepted | 18 | 2,940 | 64 | a,b,c = map(str,input().split())
print((a[0]+b[0]+c[0]).upper()) |
s857737920 | p03719 | u570018655 | 2,000 | 262,144 | Wrong Answer | 20 | 3,060 | 99 | You are given three integers A, B and C. Determine whether C is not less than A and not greater than B. | a, b, c = map(int, input().split())
if a <= c <= b:
ans = "YES"
else:
ans = "NO"
print(ans) | s796107864 | Accepted | 17 | 2,940 | 99 | a, b, c = map(int, input().split())
if a <= c <= b:
ans = "Yes"
else:
ans = "No"
print(ans) |
s507029412 | p03795 | u723654028 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 34 | Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y. | N=int(input())
print(800*N-200//N) | s033702727 | Accepted | 17 | 2,940 | 37 | N=int(input())
print(800*N-N//15*200) |
s197283966 | p03574 | u870297120 | 2,000 | 262,144 | Wrong Answer | 23 | 3,316 | 484 | You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. | h,w = map(int, input().split())
x = [list(map(int, input().replace('.', '0').replace('#', '1'))) for _ in range(h)]
x1 = [[0]*(w+2)]*2
for i in range(h):
x1.insert(i+1, [0]+x[i]+[0])
x2 = [['#']*w]*h
for i in range(h):
for j in range(w):
if x[i][j] == 1:
continue
else:
x2[i][j] = sum(x1[i][j-1:j+2])+sum(x1[i+1][j-1:j+2])+sum(x1[i+2][j-1:j+2])
print('hoge')
for i in x2:
print(''.join(map(str, i)).replace('0', '#')) | s579770799 | Accepted | 22 | 3,188 | 422 | h,w = map(int, input().split())
x = [list(input()) for _ in range(h)]
y = [[0]*(w+2) for _ in range(h+2)]
for i in range(h):
for j in range(w):
if x[i][j] == '.':
y[i+1][j+1] = 0
else:
y[i+1][j+1] = 1
for i in range(h):
for j in range(w):
if x[i][j] == '.':
x[i][j] = str(sum(y[i][j:j+3])+sum(y[i+1][j:j+3])+sum(y[i+2][j:j+3]))
print(''.join(x[i])) |
s857487045 | p03970 | u612721349 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 90 | CODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard. He intended to write `CODEFESTIVAL2016` on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length. So Mr. Takahashi decided to perform an operation that replaces a certain character with another in the minimum number of iterations, changing the string to `CODEFESTIVAL2016`. Find the minimum number of iterations for the rewrite operation. | s="C0DEFESTIVAL2O16"
t=input()
a=0
for c, d in zip(s, t):
if c != d:
a += 1
print(a) | s690532994 | Accepted | 25 | 2,940 | 91 | s="CODEFESTIVAL2016"
t=input()
a=0
for c, d in zip(s, t):
if c != d:
a += 1
print(a)
|
s222538764 | p03672 | u762008592 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 147 | 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()
while(True):
s1, s2 = s[0:len(s)//2], s[len(s)//2:len(s)]
if s1 == s2:
print(len(s1)*2)
break
s = s[:-2] | s757467047 | Accepted | 17 | 3,060 | 160 | s = input()
s= s[:-2]
while(True):
s1, s2 = s[0:len(s)//2], s[len(s)//2:len(s)+1]
if s1 == s2:
print(len(s1)*2)
break
s = s[:-2] |
s721744362 | p03387 | u814781830 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 243 | 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 proved that we can always make A, B and C all equal by repeatedly performing these operations. | ABC = list(map(int, input().split()))
tmp = 0
max_num = max(ABC)
abs_list = [abs(max_num-i) for i in ABC]
if all(i % 2 == 0 for i in abs_list):
res = int(sum(abs_list) / 2)
else:
res = int((sum(abs_list)) / 2) + 2
print(res)
| s878994761 | Accepted | 17 | 2,940 | 223 | ABC = list(map(int, input().split()))
max_num = max(ABC)
abs_list = [abs(max_num-i) for i in ABC]
if sum(abs_list) % 2 == 0:
res = int(sum(abs_list) / 2)
else:
res = int((sum(abs_list)) / 2) + 2
print(res)
|
s095308552 | p03494 | u968404618 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 267 | 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()))
cont = 0
cont_list =[0]
for a in A:
if a % 2 != 0:
break
else:
while a % 2==0:
a //= 2
cont += 1
cont_list.append(cont)
cont=0
print(min(cont_list)) | s521570989 | Accepted | 18 | 3,060 | 293 | n = int(input())
A = list(map(int, input().split()))
cont = 0
cont_list =[]
for a in A:
if a % 2 != 0:
cont_list.append(cont)
break
else:
while a % 2==0:
a //= 2
cont += 1
cont_list.append(cont)
cont=0
print(min(cont_list)) |
s877115473 | p03478 | u934868410 | 2,000 | 262,144 | Wrong Answer | 32 | 2,940 | 132 | Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive). | n,a,b = map(int,input().split())
ans = 0
for i in range(1, n+1):
if a <= sum(map(int, list(str(i)))) <= b:
ans += 1
print(ans) | s823857158 | Accepted | 33 | 2,940 | 132 | n,a,b = map(int,input().split())
ans = 0
for i in range(1, n+1):
if a <= sum(map(int, list(str(i)))) <= b:
ans += i
print(ans) |
s304377135 | p04044 | u825429469 | 2,000 | 262,144 | Wrong Answer | 27 | 8,984 | 103 | 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. |
l,n = map(int, input().split())
s = [str(input()) for _ in range(l)]
s.sort()
for i in s:
print(i) | s664374674 | Accepted | 29 | 9,088 | 98 |
l,n = map(int, input().split())
s = [str(input()) for _ in range(l)]
s.sort()
print(''.join(s)) |
s120967048 | p02417 | u506705885 | 1,000 | 131,072 | Wrong Answer | 20 | 7,568 | 1,332 | Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters. | number_of_letter={'a':0,'b':0,'c':0,'d':0,'e':0,'f':0,'g':0,'h':0,'i':0,'j':0,'k':0,'l':0,'m':0,'n':0,'o':0,'p':0 \
,'q':0,'r':0,'s':0,'t':0,'u':0,'v':0,'w':0,'x':0,'y':0,'z':0}
letters=input()
number_of_letter['a']=letters.count('a')
number_of_letter['b']=letters.count('b')
number_of_letter['c']=letters.count('c')
number_of_letter['d']=letters.count('d')
number_of_letter['e']=letters.count('e')
number_of_letter['f']=letters.count('f')
number_of_letter['g']=letters.count('g')
number_of_letter['h']=letters.count('h')
number_of_letter['i']=letters.count('i')
number_of_letter['j']=letters.count('j')
number_of_letter['k']=letters.count('k')
number_of_letter['l']=letters.count('l')
number_of_letter['m']=letters.count('m')
number_of_letter['n']=letters.count('n')
number_of_letter['o']=letters.count('o')
number_of_letter['p']=letters.count('p')
number_of_letter['q']=letters.count('q')
number_of_letter['r']=letters.count('r')
number_of_letter['s']=letters.count('s')
number_of_letter['t']=letters.count('t')
number_of_letter['u']=letters.count('u')
number_of_letter['v']=letters.count('v')
number_of_letter['w']=letters.count('w')
number_of_letter['x']=letters.count('x')
number_of_letter['y']=letters.count('y')
number_of_letter['z']=letters.count('z')
for i in range(97,123):
print(chr(i),':',number_of_letter[chr(i)]) | s950869472 | Accepted | 20 | 5,564 | 171 | sente=""
while True:
try:
t=input().lower()
sente = sente+t
except:
break
for i in range(97,123):
print(chr(i),":",sente.count(chr(i))) |
s905808442 | p02606 | u492749916 | 2,000 | 1,048,576 | Wrong Answer | 23 | 9,092 | 119 | How many multiples of d are there among the integers between L and R (inclusive)? | L, R, d = list(map(int, input().split()))
if L%d == 0 or R%d == 0:
print(1+ R//d - L//d)
else:
print(R//d - L//d) | s479598904 | Accepted | 22 | 9,016 | 120 | L, R, d = list(map(int, input().split()))
if L%d == 0 and R%d == 0:
print(1 + R//d - L//d)
else:
print(R//d - L//d) |
s847226760 | p03090 | u211160392 | 2,000 | 1,048,576 | Wrong Answer | 25 | 3,612 | 244 | You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved that at least one such graph exists under the constraints of this problem. | N = int(input())
ans = [[j for j in range(i+1,N)]for i in range(N)]
for i in range(N):
if len(ans[i]) >= N%2+i+1:
ans[i][-(N%2+i+1)] = -1
for i in range(N):
for j in ans[i]:
if j >= 0:
print(i+1,j+1) | s802196823 | Accepted | 26 | 4,124 | 298 | N = int(input())
ans = [[j for j in range(i+1,N)]for i in range(N)]
for i in range(N):
if len(ans[i]) >= N%2+i+1:
ans[i][-(N%2+i+1)] = -1
out = []
for i in range(N):
for j in ans[i]:
if j >= 0:
out.append([i+1,j+1])
print(len(out))
for i,j in out:
print(i,j) |
s185250878 | p02841 | u657913472 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 50 | In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month. | a,b,c,d=map(int,open(0).read().split())
print(d<2) | s514571002 | Accepted | 17 | 2,940 | 50 | a,b,c,d=map(int,open(0).read().split())
print(c-a) |
s527351320 | p03485 | u979078704 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 110 | You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer. | a, b = map(int,input().split())
if (a + b) % 2 == 0:
print((a + b) / 2)
else:
print((a + b) / 2 - 0.5) | s682706744 | Accepted | 18 | 2,940 | 120 | a, b = map(int,input().split())
if (a + b) % 2 == 0:
print(int((a + b) / 2))
else:
print(int((a + b) / 2 + 0.5)) |
s452587006 | p04029 | u174849391 | 2,000 | 262,144 | Wrong Answer | 27 | 9,148 | 805 | There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total? |
N = int(input())
print(N*(1+N)/2) | s017238854 | Accepted | 26 | 8,988 | 34 | N = int(input())
print(N*(1+N)//2) |
s409479691 | p03140 | u128927017 | 2,000 | 1,048,576 | Wrong Answer | 18 | 3,060 | 189 | You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters. Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation: * Operation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter. What is the minimum number of operations required to achieve the objective? | N = int(input())
A = input()
B = input()
C = input()
count = 0
for i in range(N):
if A[i] != B[i]:
count+=1
if A[i] != C[i]:
count+=1
elif A[i] != C[i]:
count+=1
print(count) | s922419141 | Accepted | 19 | 3,064 | 206 | N = int(input())
A = input()
B = input()
C = input()
count = 0
for i in range(N):
if A[i] != B[i]:
count+=1
if A[i] != C[i] and B[i] != C[i]:
count+=1
elif A[i] != C[i]:
count+=1
print(count) |
s501569917 | p02420 | u605879293 | 1,000 | 131,072 | Wrong Answer | 20 | 7,688 | 134 | Your task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck. The deck of cards is represented by a string as follows. abcdeefab The first character and the last character correspond to the card located at the bottom of the deck and the card on the top of the deck respectively. For example, a shuffle with h = 4 to the above deck, moves the first 4 characters "abcd" to the end of the remaining characters "eefab", and generates the following deck: eefababcd You can repeat such shuffle operations. Write a program which reads a deck (a string) and a sequence of h, and prints the final state (a string). | while True:
s = input()
if s == "-":
break
m = int(input())
for n in range(m):
h = int(input())
s = s[0:h] + s[h:]
print(s) | s531975191 | Accepted | 20 | 7,708 | 135 | while True:
s = input()
if s == "-":
break
m = int(input())
for n in range(m):
h = int(input())
s = s[h:] + s[0: h]
print(s) |
s563417069 | p03407 | u977349332 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 73 | 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+b > c:
'Yes'
else:
'No' | s494898428 | Accepted | 17 | 2,940 | 80 | a,b,c = map(int, input().split())
if a+b >= c:
print('Yes')
else:
print('No') |
s516702835 | p03478 | u492532572 | 2,000 | 262,144 | Wrong Answer | 34 | 3,060 | 205 | 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(" "))
sum_total = 0
for n in range(1, N + 1):
sum = 0
for s in str(n):
sum += int(s)
if A <= sum and sum <= B:
sum_total += sum
print(sum_total) | s381599103 | Accepted | 32 | 3,060 | 203 | N, A, B = map(int, input().split(" "))
sum_total = 0
for n in range(1, N + 1):
sum = 0
for s in str(n):
sum += int(s)
if A <= sum and sum <= B:
sum_total += n
print(sum_total) |
s614491778 | p03597 | u383508661 | 2,000 | 262,144 | Wrong Answer | 19 | 3,316 | 42 | 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? | n=int(input())
a=int(input())
print(n**-a) | s354975025 | Accepted | 17 | 2,940 | 43 | n=int(input())
a=int(input())
print(n**2-a) |
s462047247 | p03680 | u490489966 | 2,000 | 262,144 | Wrong Answer | 190 | 7,084 | 252 | Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons. | #B
import sys
n = int(input())
a = [int(input()) for _ in range(n)]
lamp = 0
ans=0
for i in range(n):
if lamp == i:
lamp = a[i] - 1
ans += 1
# print(i,lamp)
if lamp == 1:
# print(ans)
sys.exit()
print(-1) | s932108009 | Accepted | 195 | 7,084 | 192 | #B
import sys
n = int(input())
a = [int(input()) for _ in range(n)]
lamp = 1
ans=0
for i in range(n):
if lamp - 1 == 1:
print(i)
sys.exit()
lamp = a[lamp - 1]
print(-1) |
s532386757 | p03846 | u620157187 | 2,000 | 262,144 | Wrong Answer | 2,104 | 13,880 | 500 | There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0. | N = int(input())
A = list(map(int, input().split()))
if len(A)%2 == 0:
result = 2**(len(A)//2)
for i in range(len(A)//2):
if A.count(1+2*i) == 2:
pass
else:
result = 0
break
else:
if A.count(0) == 1:
result = 2**((len(A)//2)-1)
for i in range(len(A)//2):
if A.count(2*i) == 2:
pass
else:
result = 0
break
else:
result = 0
print(result) | s119958633 | Accepted | 214 | 23,380 | 437 | import numpy as np
N = int(input())
A = sorted(list(map(int, input().split())))
if len(A)%2 == 0:
result = (2**(len(A)//2))%(10**9+7)
a = np.arange(1, len(A), 2).tolist()
a = sorted(a+a)
if a == A:
pass
else:
result = 0
else:
result = 2**(len(A)//2)%(10**9+7)
a = np.arange(2, len(A), 2).tolist()
a = sorted([0]+a+a)
if a == A:
pass
else:
result = 0
print(result) |
s048042603 | p03476 | u694665829 | 2,000 | 262,144 | Wrong Answer | 535 | 13,464 | 531 | We say that a odd number N is _similar to 2017_ when both N and (N+1)/2 are prime. You are given Q queries. In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i. | dp = [1]*(10**5+1)
dp[0],dp[1] = 0, 0
for i in range(2, 10**5+1):
if dp[i] == 0:
continue
j = i
while j + i <= 10**5:
j += i
if dp[j] == 1:
dp[j] = 0
ni = [0]*(10**5+1)
for i in range(2, 10**5+1):
if dp[i] == 1 and dp[(i+1)//2] == 1:
ni[i] = 1
ru = [0]*(10**5+1)
for i in range(1, 10**5+1):
ru[i] = ru[i-1] + ni[i]
q = int(input())
for i in range(q):
l, r = map(int,input().split())
print(ru[l] - ru[r-1])
| s944238063 | Accepted | 480 | 13,564 | 671 | def f():
dp = [1]*(10**5+1)
dp[0],dp[1] = 0, 0
for i in range(2, 10**5+1):
if dp[i] == 0:
continue
j = i
while j + i <= 10**5:
j += i
if dp[j] == 1:
dp[j] = 0
ni = [0]*(10**5+1)
for i in range(2, 10**5+1):
if dp[i] == 1 and dp[(i+1)//2] == 1:
ni[i] = 1
ru = [0]*(10**5+1)
for i in range(1, 10**5+1):
ru[i] = ru[i-1] + ni[i]
q = int(input())
for i in range(q):
l, r = map(int,input().split())
print(ru[r] - ru[l-1])
if __name__ == '__main__':
f() |
s135352382 | p03610 | u252964975 | 2,000 | 262,144 | Wrong Answer | 35 | 3,188 | 82 | 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=str(input())
s = ""
for i in range(round(len(S)/2)):
s = s + S[2*i-1]
print(s) | s686457163 | Accepted | 31 | 3,188 | 96 | import math
S=str(input())
s = ""
for i in range(math.ceil(len(S)/2)):
s = s + S[2*i]
print(s) |
s938154096 | p03698 | u478417863 | 2,000 | 262,144 | Wrong Answer | 28 | 8,884 | 106 | You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different. | a= input().strip()
b=set(a)
if len(a)==len(b):
print("yes")
else:
print("no")
print(len(a),len(b)) | s603087465 | Accepted | 27 | 9,036 | 85 | a= input().strip()
b=set(a)
if len(a)==len(b):
print("yes")
else:
print("no") |
s102924576 | p03719 | u846652026 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 69 | You are given three integers A, B and C. Determine whether C is not less than A and not greater than B. | a,b,c = map(int, input().split())
print("YES" if a < c < b else "No") | s496003779 | Accepted | 18 | 2,940 | 71 | a,b,c = map(int, input().split())
print("Yes" if a <= c <= b else "No") |
s165792647 | p03795 | u871596687 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 61 | Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y. | N = int(input())
x = 800 * N
y = int((N/15)*200)
print(x-y) | s812470142 | Accepted | 18 | 2,940 | 62 | n = int(input())
s = int(800 * n - 200 * (n//15))
print(s)
|
s626263812 | p02255 | u782850499 | 1,000 | 131,072 | Wrong Answer | 20 | 7,556 | 277 | 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. | size = int(input())
element = list(map(int,input().split()))
for i in range(1,len(element)):
v = element[i]
j = i-1
while j >=0 and element[j] > v:
element[j+1] = element[j]
j -=1
element[j+1] = v
print(" ".join(list(map(str,element)))) | s178834024 | Accepted | 20 | 7,568 | 306 | size = int(input())
element = list(map(int,input().split()))
print(" ".join(map(str,element)))
for i in range(1,len(element)):
v = element[i]
j = i-1
while j >=0 and element[j] > v:
element[j+1] = element[j]
j -=1
element[j+1] = v
print(" ".join(map(str,element))) |
s394038872 | p03836 | u014333473 | 2,000 | 262,144 | Wrong Answer | 28 | 9,084 | 153 | Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him. | sx,sy,tx,ty=map(int,input().split())
dx,dy=tx-sx,ty-sy
print('L'+dx*'U'+'U'+dy*'R'+'R'+'D'+dy*'L'+dx*'D'+'D'+dy*'R'+'R'+dy*'U'+'U'+'L'+'D'+dy*'D'+dx*'L') | s519785820 | Accepted | 26 | 9,172 | 149 | sx,sy,tx,ty=map(int,input().split())
dx,dy=tx-sx,ty-sy
print(dy*'U'+dx*'R'+dy*'D'+(dx+1)*'L'+(dy+1)*'U'+(dx+1)*'R'+'D'+'R'+(dy+1)*'D'+(dx+1)*'L'+'U') |
s009334332 | p03477 | u163874353 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 145 | A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right. | a, b, c, d = map(int, input().split())
l = a + b
r = c + d
if l > r:
print("Left")
if l == r:
print("Balanced")
else:
print("Right")
| s235242422 | Accepted | 17 | 3,060 | 146 | a, b, c, d = map(int, input().split())
l = a + b
r = c + d
if l > r:
print("Left")
elif l == r:
print("Balanced")
else:
print("Right") |
s024010837 | p03494 | u159655606 | 2,000 | 262,144 | Wrong Answer | 19 | 3,060 | 297 | 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 = input().split()
A = [int(i) for i in A]
check1 = 0
count1 = 0
while check1 == 0:
print("this is")
for i in range(len(A)):
if(A[i]%2 == 0):
A[i] = A[i]/2
else:
check1 = 1
break
count1 += 1
count1 -= 1
| s456802044 | Accepted | 19 | 3,060 | 289 | N = int(input())
A = input().split()
A = [int(i) for i in A]
check1 = 0
count1 = 0
while check1 == 0:
for i in range(len(A)):
if(A[i]%2 == 0):
A[i] = A[i]/2
else:
check1 = 1
break
count1 += 1
count1 -= 1
print(count1)
|
s638004110 | p02742 | u967835038 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 130 | 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==1 and w==1:
print(1)
else:
if (h*w)%2==1:
print(int(h*w//2)+1)
else:
print(h*w/2) | s408449676 | Accepted | 17 | 3,060 | 139 | h,w=map(int,input().split())
if h==1 or w==1:
print(1)
else:
if (h*w)%2==1:
print(int(int(h*w//2)+1))
else:
print(int(h*w/2)) |
s476746629 | p03457 | u097026338 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 150 | AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan. | n=int(input())
for i in range(n):
t,x,y=map(int,input().split())
if (x+y)<=t or (t+x+y)%2==0:
print("yes")
exit()
else:
print("NO") | s909664622 | Accepted | 360 | 3,316 | 217 | n=int(input())
ta=0
xa=0
ya=0
count=0
for i in range(n):
t,x,y=map(int,input().split())
if (x-xa+y-ya)<=t-ta and (t-ta+x-xa+y-ya)%2==0:
ta=t
xa=x
ya=y
count+=1
print("Yes" if count==n else "No") |
s423536661 | p03861 | u760961723 | 2,000 | 262,144 | Wrong Answer | 30 | 9,072 | 99 | You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x? | a,b,x = map(int,input().split())
if a == 0:
print((b//x)-(a//x)+1)
else:
print((b//x)-(a//x))
| s195189057 | Accepted | 31 | 9,156 | 103 | a,b,x = map(int,input().split())
if a % x == 0:
print((b//x)-(a//x)+1)
else:
print((b//x)-(a//x))
|
s184830344 | p03719 | u371763408 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 71 | You are given three integers A, B and C. Determine whether C is not less than A and not greater than B. | a,b,c = map(int,input().split())
print('YES' if a <= c <= b else 'NO') | s538707817 | Accepted | 18 | 2,940 | 71 | a,b,c = map(int,input().split())
print('Yes' if a <= c <= b else 'No') |
s855012616 | p03998 | u588785393 | 2,000 | 262,144 | Wrong Answer | 16 | 3,060 | 372 | Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game. | a = input()
b = input()
c = input()
ac = 0
bc = 0
cc = 0
curr = 'a'
while ac < len(a) and bc < len(b) and cc < len(c):
if curr == 'a':
curr = a[ac]
ac += 1
elif curr == 'b':
curr = b[bc]
bc += 1
elif curr == 'c':
curr = c[cc]
cc += 1
if ac == 0:
print("A")
elif bc == 0:
print("B")
else:
print("C")
| s797000535 | Accepted | 18 | 3,064 | 495 | a = input()
b = input()
c = input()
ac = 0
bc = 0
cc = 0
curr = 'a'
while ac <= len(a) and bc <= len(b) and cc <= len(c):
if curr == 'a':
if ac == len(a):
print("A")
break
curr = a[ac]
ac += 1
elif curr == 'b':
if bc == len(b):
print("B")
break
curr = b[bc]
bc += 1
elif curr == 'c':
if cc == len(c):
print("C")
break
curr = c[cc]
cc += 1
|
s604914489 | p03543 | u164229553 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 200 | We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**? | N = input()
N_a = N[:3]
N_b = N[1:]
N_a_1 = [int(i) for i in N_a]
N_b_1 = [int(i) for i in N_b]
if str(int(sum(N_a_1)/3)) == N_a or str(int(sum(N_b_1)/3)) == N_b:
print("Yes")
else:
print("No")
| s679283720 | Accepted | 18 | 2,940 | 145 | N = input()
N_a = N[:3]
N_b = N[1:]
N_a_1 = int(N_a)
N_b_1 = int(N_b)
if N_a_1%111 == 0 or N_b_1%111 == 0:
print("Yes")
else:
print("No")
|
s424836524 | p04035 | u026788530 | 2,000 | 262,144 | Wrong Answer | 87 | 19,960 | 280 | We have N pieces of ropes, numbered 1 through N. The length of piece i is a_i. At first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly: * Choose a (connected) rope with a total length of at least L, then untie one of its knots. Is it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots. | n,l=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
j=-1
for i in range(n-1):
if a[i]+a[i-1]>=l:
j=i
break
if j==-1:
print("Impossible")
else:
print("Possible")
for i in range(j):
print(i+1)
for i in range(n-1,j,-1):
print(i) | s450150456 | Accepted | 141 | 14,056 | 292 | n,l=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
j=-1
for i in range(n-1):
if a[i]+a[i+1]>=l:
j=i
break
if j==-1:
print("Impossible")
else:
#print(j)
print("Possible")
for i in range(j):
print(i+1)
for i in range(n-1,j,-1):
print(i) |
s014786883 | p03671 | u612975321 | 2,000 | 262,144 | Wrong Answer | 32 | 9,032 | 57 | Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells. | a = list(map(int,input().split()))
a.sort()
print(a[:2])
| s340799288 | Accepted | 27 | 9,136 | 62 | a = list(map(int,input().split()))
a.sort()
print(sum(a[:2]))
|
s774590446 | p03795 | u051496905 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 128 | Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y. | N = int(input())
# L = 800 / N
B = 0
for i in range(N):
if i % 15 == 0:
B += 1
L = 800 * N
C = B * 200
print(L - C) | s008214476 | Accepted | 17 | 2,940 | 132 | N = int(input())
# L = 800 / N
B = 0
for i in range(1,N+1):
if i % 15 == 0:
B += 1
L = 800 * N
C = B * 200
print(L - C) |
s988512553 | p03493 | u795733769 | 2,000 | 262,144 | Wrong Answer | 26 | 9,112 | 150 | Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble. | li = list(input())
print(li)
cnt = 0
101
if (li[0] == "1"):
cnt += 1
if (li[1] == "1"):
cnt += 1
if (li[2] == "1"):
cnt += 1
print(cnt)
| s960685904 | Accepted | 27 | 8,912 | 141 | li = list(input())
cnt = 0
101
if (li[0] == "1"):
cnt += 1
if (li[1] == "1"):
cnt += 1
if (li[2] == "1"):
cnt += 1
print(cnt)
|
s052540362 | p03434 | u526459074 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 182 | We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score. | n = input()
a = list(map(int, input().split()))
a= sorted(a, reverse=True)
print(a)
ans =0
for i in a:
if i%2 == 0:
ans += i
elif i%2 ==1:
ans -= i
print(ans) | s097527976 | Accepted | 17 | 3,060 | 191 | n = input()
a = list(map(int, input().split()))
a= sorted(a, reverse=True)
ans =0
for i in range(len(a)):
if i%2 == 0:
ans += a[i]
elif i%2 ==1:
ans -= a[i]
print(ans) |
s820858754 | p02417 | u106285852 | 1,000 | 131,072 | Wrong Answer | 30 | 7,600 | 3,288 | Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters. |
import sys
# inputData
inputData = input()
cnt = [0]*26
#for str in inputData:
for i in range(len(inputData)):
if "a" == inputData[i] or inputData[i] =="A":
cnt[0] += 1
elif "b" == inputData[i] or inputData[i] =="B":
cnt[1] += 1
elif "c" == inputData[i] or inputData[i] =="C":
cnt[2] += 1
elif "d" == inputData[i] or inputData[i] =="D":
cnt[3] += 1
elif "e" == inputData[i] or inputData[i] =="E":
cnt[4] += 1
elif "f" == inputData[i] or inputData[i] =="F":
cnt[5] += 1
elif "g" == inputData[i] or inputData[i] =="G":
cnt[6] += 1
elif "h" == inputData[i] or inputData[i] =="H":
cnt[7] += 1
elif "i" == inputData[i] or inputData[i] =="I":
cnt[8] += 1
elif "j" == inputData[i] or inputData[i] =="J":
cnt[9] += 1
elif "k" == inputData[i] or inputData[i] =="K":
cnt[10] += 1
elif "l" == inputData[i] or inputData[i] =="L":
cnt[11] += 1
elif "n" == inputData[i] or inputData[i] =="B":
cnt[12] += 1
elif "m" == inputData[i] or inputData[i] =="M":
cnt[13] += 1
elif "o" == inputData[i] or inputData[i] =="O":
cnt[14] += 1
elif "p" == inputData[i] or inputData[i] =="P":
cnt[15] += 1
elif "q" == inputData[i] or inputData[i] =="Q":
cnt[16] += 1
elif "r" == inputData[i] or inputData[i] =="R":
cnt[17] += 1
elif "s" == inputData[i] or inputData[i] =="S":
cnt[18] += 1
elif "t" == inputData[i] or inputData[i] =="T":
cnt[19] += 1
elif "u" == inputData[i] or inputData[i] =="U":
cnt[20] += 1
elif "v" == inputData[i] or inputData[i] =="V":
cnt[21] += 1
elif "w" == inputData[i] or inputData[i] =="W":
cnt[22] += 1
elif "x" == inputData[i] or inputData[i] =="X":
cnt[23] += 1
elif "y" == inputData[i] or inputData[i] =="Y":
cnt[24] += 1
elif "z" == inputData[i] or inputData[i] =="Z":
cnt[25] += 1
# ????????????
#print("a:"+a_cnt)
print ('a : %d' % (cnt[0]))
print ('b : %d' % (cnt[1]))
print ('c : %d' % (cnt[2]))
print ('d : %d' % (cnt[3]))
print ('e : %d' % (cnt[4]))
print ('f : %d' % (cnt[5]))
print ('g : %d' % (cnt[6]))
print ('h : %d' % (cnt[7]))
print ('i : %d' % (cnt[8]))
print ('j : %d' % (cnt[9]))
print ('k : %d' % (cnt[10]))
print ('l : %d' % (cnt[11]))
print ('n : %d' % (cnt[12]))
print ('m : %d' % (cnt[13]))
print ('o : %d' % (cnt[14]))
print ('p : %d' % (cnt[15]))
print ('q : %d' % (cnt[16]))
print ('r : %d' % (cnt[17]))
print ('s : %d' % (cnt[18]))
print ('t : %d' % (cnt[19]))
print ('u : %d' % (cnt[20]))
print ('v : %d' % (cnt[21]))
print ('W : %d' % (cnt[22]))
print ('x : %d' % (cnt[23]))
print ('y : %d' % (cnt[24]))
print ('z : %d' % (cnt[25])) | s975607029 | Accepted | 30 | 7,436 | 3,559 |
# inputData
# inputData = input()
# cnt = [0]*26
#
# if "a" == inputData[i] or inputData[i] =="A":
# cnt[0] += 1
# elif "b" == inputData[i] or inputData[i] =="B":
# cnt[1] += 1
# elif "c" == inputData[i] or inputData[i] =="C":
# cnt[2] += 1
# elif "d" == inputData[i] or inputData[i] =="D":
# cnt[3] += 1
# elif "e" == inputData[i] or inputData[i] =="E":
# cnt[4] += 1
# elif "f" == inputData[i] or inputData[i] =="F":
# cnt[5] += 1
# elif "g" == inputData[i] or inputData[i] =="G":
# cnt[6] += 1
# elif "h" == inputData[i] or inputData[i] =="H":
# cnt[7] += 1
# elif "i" == inputData[i] or inputData[i] =="I":
# cnt[8] += 1
# elif "j" == inputData[i] or inputData[i] =="J":
# cnt[9] += 1
# elif "k" == inputData[i] or inputData[i] =="K":
# cnt[10] += 1
# elif "l" == inputData[i] or inputData[i] =="L":
# cnt[11] += 1
# elif "m" == inputData[i] or inputData[i] =="M":
# cnt[12] += 1
# elif "n" == inputData[i] or inputData[i] =="N":
# cnt[13] += 1
# elif "o" == inputData[i] or inputData[i] =="O":
# cnt[14] += 1
# elif "p" == inputData[i] or inputData[i] =="P":
# cnt[15] += 1
# elif "q" == inputData[i] or inputData[i] =="Q":
# cnt[16] += 1
# elif "r" == inputData[i] or inputData[i] =="R":
# cnt[17] += 1
# elif "s" == inputData[i] or inputData[i] =="S":
# cnt[18] += 1
# elif "t" == inputData[i] or inputData[i] =="T":
# cnt[19] += 1
# elif "u" == inputData[i] or inputData[i] =="U":
# cnt[20] += 1
# elif "v" == inputData[i] or inputData[i] =="V":
# cnt[21] += 1
# elif "w" == inputData[i] or inputData[i] =="W":
# cnt[22] += 1
# elif "x" == inputData[i] or inputData[i] =="X":
# cnt[23] += 1
# elif "y" == inputData[i] or inputData[i] =="Y":
# cnt[24] += 1
# elif "z" == inputData[i] or inputData[i] =="Z":
# cnt[25] += 1
#
# print ('a : %d' % (cnt[0]))
# print ('b : %d' % (cnt[1]))
# print ('c : %d' % (cnt[2]))
# print ('d : %d' % (cnt[3]))
# print ('e : %d' % (cnt[4]))
# print ('f : %d' % (cnt[5]))
# print ('g : %d' % (cnt[6]))
# print ('h : %d' % (cnt[7]))
# print ('i : %d' % (cnt[8]))
# print ('j : %d' % (cnt[9]))
# print ('k : %d' % (cnt[10]))
# print ('l : %d' % (cnt[11]))
# print ('m : %d' % (cnt[12]))
# print ('n : %d' % (cnt[13]))
# print ('o : %d' % (cnt[14]))
# print ('p : %d' % (cnt[15]))
# print ('r : %d' % (cnt[17]))
# print ('s : %d' % (cnt[18]))
# print ('t : %d' % (cnt[19]))
# print ('u : %d' % (cnt[20]))
# print ('v : %d' % (cnt[21]))
# print ('w : %d' % (cnt[22]))
# print ('x : %d' % (cnt[23]))
# print ('y : %d' % (cnt[24]))
import sys
string = []
for line in sys.stdin:
string += line.lower()
A = 'abcdefghijklmnopqrstuvwxyz'
for cnt0 in A:
print(cnt0+' : {}'.format(string.count(cnt0))) |
s574420403 | p03672 | u634079249 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 868 | 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. | import sys
import os
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]
MOD = 10 ** 9 + 7
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
S = list(iss())
S = S[:-1]
for _ in range(len(S)):
l = len(S)
if l % 2 == 0 and S[:l // 2] == S[l // 2:]:
print("".join(S))
exit()
else:
S = S[:-1]
if __name__ == '__main__':
main()
| s029719823 | Accepted | 17 | 3,064 | 864 | import sys
import os
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]
MOD = 10 ** 9 + 7
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
S = list(iss())
S = S[:-1]
for _ in range(len(S)):
l = len(S)
if l % 2 == 0 and S[:l // 2] == S[l // 2:]:
print(len(S))
exit()
else:
S = S[:-1]
if __name__ == '__main__':
main()
|
s445793181 | p03679 | u897328029 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 138 | Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache. | x, a, b = list(map(int, input().split()))
d = b - a
if d <= 0:
ans = 'delicious'
elif d <= a:
ans = 'safe'
else:
ans = 'dangerous'
| s050951396 | Accepted | 17 | 2,940 | 149 | x, a, b = list(map(int, input().split()))
d = b - a
if d <= 0:
ans = 'delicious'
elif d <= x:
ans = 'safe'
else:
ans = 'dangerous'
print(ans)
|
s831866373 | p03434 | u587213169 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 133 | We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score. | N=int(input())
cards = list(map(int, input().split()))
cards.reverse()
Alice=sum(cards[0:N:2])
Bob=sum(cards[1:N:2])
print(Alice-Bob) | s767676603 | Accepted | 17 | 3,060 | 211 | N=int(input())
cards = list(map(int, input().split()))
cards.sort(reverse=True)
Alice=0
Bob=0
for i in range (len(cards)):
if i%2==0:
Alice+=cards[i]
else:
Bob+=cards[i]
print(Alice-Bob) |
s799229830 | p02831 | u995163736 | 2,000 | 1,048,576 | Wrong Answer | 27 | 9,124 | 78 | Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted. We assume that a piece cannot be divided and distributed to multiple guests. | from math import gcd
a, b = map(int,input().split())
print(a * b / gcd(a, b)) | s508265347 | Accepted | 27 | 9,116 | 84 | from math import gcd
a, b = map(int,input().split())
print(int(a * b / gcd(a, b))) |
s967436231 | p04045 | u085334230 | 2,000 | 262,144 | Wrong Answer | 19 | 3,060 | 174 | Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier. | N, K = map(int, input().split())
D = set(map(int, input().split()))
while True:
if set(str(N)) == set(str(N)) - D:
print(N)
break
else:
N += 1 | s598066926 | Accepted | 160 | 2,940 | 197 | N, K = map(int, input().split())
D = set(map(str, input().split()))
f = True
while f:
if set(list(str(N))) == set(list(str(N))) - D:
print(N)
f = False
else:
N += 1
|
s250684978 | p03338 | u697658632 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,064 | 269 | You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position. | n = int(input())
s = input()
v = [0] * n
for c in range(ord('a'), ord('z') + 1):
p = -1
for i in range(n):
if s[i] == c:
if p >= 0:
v[i] -= 1
v[p] += 1
p = i
ans = 0
vsum = 0
for i in v:
vsum += i
ans = max(ans, vsum)
print(ans)
| s770305232 | Accepted | 18 | 3,064 | 274 | n = int(input())
s = input()
v = [0] * n
for c in range(ord('a'), ord('z') + 1):
p = -1
for i in range(n):
if ord(s[i]) == c:
if p >= 0:
v[i] -= 1
v[p] += 1
p = i
ans = 0
vsum = 0
for i in v:
vsum += i
ans = max(ans, vsum)
print(ans)
|
s306001840 | p02396 | u400765446 | 1,000 | 131,072 | Wrong Answer | 120 | 7,428 | 190 | In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem. | def main():
i = 1
while True:
x = input()
if x == '0':
break
else:
print("case "+str(i)+": "+x)
if __name__ == "__main__":
main() | s776866347 | Accepted | 160 | 5,596 | 143 | i = 1
while True:
x = int(input())
if x == 0:
break
else:
print("Case {}: {}".format(i,x))
i += 1
|
s769751683 | p02694 | u767821815 | 2,000 | 1,048,576 | Wrong Answer | 24 | 9,164 | 106 | Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time? | F = 100
K = int(input())
count = 0
while F <= K:
F *= 1.01
F = int(F)
count += 1
print(count) | s124533295 | Accepted | 24 | 9,164 | 125 | import math
F = 100
K = int(input())
count = 0
while F < K:
F = F + math.floor(F*0.01)
count += 1
print(count) |