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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s435631190
|
p03408
|
u396495667
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 133 |
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
|
n = int(input())
s = [input(_) for _ in range(n)]
m = int(input())
t = [input(_) for _ in range(m)]
l = set(s) - set(t)
print(len(l))
|
s112039856
|
Accepted
| 18 | 3,064 | 188 |
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
s_x = list(set(s))
ans =0
for b in s_x:
ans = max(ans, s.count(b)-t.count(b))
print(ans)
|
s164203296
|
p04043
|
u370852395
| 2,000 | 262,144 |
Wrong Answer
| 19 | 8,988 | 118 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
l =list(map(int,input().split()))
print(l)
if l.count(5)==2 and l.count(7)==1:
print("YES")
else:
print("NO")
|
s939832168
|
Accepted
| 22 | 9,160 | 109 |
l =list(map(int,input().split()))
if l.count(5)==2 and l.count(7)==1:
print("YES")
else:
print("NO")
|
s493516864
|
p03611
|
u013408661
| 2,000 | 262,144 |
Wrong Answer
| 967 | 13,964 | 442 |
You are given an integer sequence of length N, a_1,a_2,...,a_N. For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices.
|
n=int(input())
a=list(map(int,input().split()))
a.sort()
def binarysearch1(x):
ok=-1
ng=n
while abs(ok-ng)>1:
mid=(ok+ng)//2
if a[mid]>=x+2:
ok=mid
else:
ng=mid
return ok
def binarysearch2(x):
ok=-1
ng=n
while abs(ok-ng)>1:
mid=(ok+ng)//2
if a[mid]>=x-1:
ok=mid
else:
ng=mid
return ok
ans=0
for i in range(-1,10**5+2):
ans=max(ans,binarysearch1(i)-binarysearch2(i))
print(ans)
|
s125112538
|
Accepted
| 836 | 13,964 | 295 |
n=int(input())
a=list(map(int,input().split()))
a.sort()
def binarysearch(x):
ok=-1
ng=n
while abs(ok-ng)>1:
mid=(ok+ng)//2
if a[mid]>=x:
ng=mid
else:
ok=mid
return ok
ans=0
for i in range(-1,10**5+2):
ans=max(ans,binarysearch(i+2)-binarysearch(i-1))
print(ans)
|
s237900280
|
p03796
|
u619458041
| 2,000 | 262,144 |
Wrong Answer
| 24 | 2,940 | 236 |
Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
|
import sys
def main():
input = sys.stdin.readline
N = int(input())
MOD = 10**9 + 7
ans = 1
for i in range(N):
ans *= i
ans = ans % MOD
return ans
if __name__ == '__main__':
print(main())
|
s548299471
|
Accepted
| 32 | 2,940 | 241 |
import sys
def main():
input = sys.stdin.readline
N = int(input())
MOD = 10**9 + 7
ans = 1
for i in range(1, N+1):
ans *= i
ans = ans % MOD
return ans
if __name__ == '__main__':
print(main())
|
s634680751
|
p03486
|
u259569723
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,060 | 371 |
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
import math
def solv():
s = input()
t = input()
length = min(len(s),len(t))
for i in range(length):
if(s[i] < t[i]):
print('Yes')
return
elif(s[i] > t[i]):
print('No')
return
if(len(s)<len(t)):
print('Yes')
else:
print('No')
if __name__ == '__main__':
solv()
|
s153147920
|
Accepted
| 19 | 2,940 | 176 |
def solv():
s = sorted(input())
t = sorted(input(),reverse=True)
if(s<t):
print('Yes')
else:
print('No')
if __name__ == '__main__':
solv()
|
s106655350
|
p02396
|
u766693979
| 1,000 | 131,072 |
Wrong Answer
| 150 | 5,608 | 139 |
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.
|
i = 1
while 1:
x = input()
x = int( x )
if x == 0:
break
print( "case " + str( i ) + ": " + str( x ) )
i += 1
|
s667227877
|
Accepted
| 140 | 5,608 | 139 |
i = 1
while 1:
x = input()
x = int( x )
if x == 0:
break
print( "Case " + str( i ) + ": " + str( x ) )
i += 1
|
s801238295
|
p04046
|
u268793453
| 2,000 | 262,144 |
Wrong Answer
| 2,108 | 15,320 | 176 |
We have a large square grid with H rows and W columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell. However, she cannot enter the cells in the intersection of the bottom A rows and the leftmost B columns. (That is, there are A×B forbidden cells.) There is no restriction on entering the other cells. Find the number of ways she can travel to the bottom-right cell. Since this number can be extremely large, print the number modulo 10^9+7.
|
import scipy.misc as scm
h, w, a, b = [int(i) for i in input().split()]
s = 0
for i in range(w-b):
s += scm.comb(h+w-a-2-i, w-1-i, 1) * scm.comb(a-1+i, a-1, 1)
print(s)
|
s635896283
|
Accepted
| 281 | 20,524 | 556 |
h, w, a, b = [int(i) for i in input().split()]
p = 10 ** 9 + 7
ans = 0
c = h-a-1
def fact(n, p=10**9 + 7):
f = [1]
for i in range(1, n+1):
f.append(f[-1]*i%p)
return f
def invfact(n, f, p=10**9 + 7):
inv = [pow(f[n], p-2, p)]
for i in range(n, 0, -1):
inv.append(inv[-1]*i%p)
return inv[::-1]
f = fact(h+w-2)
invf = invfact(h+w-2, f)
def comb(a, b):
return f[a] * invf[b] * invf[a-b] % p
for x in range(b, w):
ans = (ans + (comb(c+x, min(x, c)) * comb(a-1+w-x-1, min(a-1, w-x-1)) % p)) % p
print(ans)
|
s144880356
|
p03415
|
u319612498
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 51 |
We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.
|
c=[input() for i in range(3)]
print(c[0]+c[1]+c[2])
|
s051846912
|
Accepted
| 17 | 2,940 | 61 |
c=[input() for i in range(3)]
print(c[0][0]+c[1][1]+c[2][2])
|
s254447141
|
p03636
|
u744034042
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 69 |
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.
|
print("input()[0]" + "len(input()) - 2" + "input()[len(input()) -1]")
|
s508099010
|
Accepted
| 17 | 2,940 | 56 |
a = input()
print(a[0] + str(len(a) - 2) + a[len(a) -1])
|
s696172570
|
p02268
|
u728700495
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,548 | 508 |
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.
|
# coding: utf-8
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
res = 0
for t in T:
left = 0
right = n
while left != right:
i = (left+right)//2
print(i, left, right)
if S[i] == t:
res += 1
print("check")
break
elif t < S[i]:
right = i
else:
left = i+1
print(res)
|
s648821145
|
Accepted
| 490 | 18,544 | 451 |
# coding: utf-8
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
res = 0
for t in T:
left = 0
right = n
while left != right:
i = (left+right)//2
if S[i] == t:
res += 1
break
elif t < S[i]:
right = i
else:
left = i+1
print(res)
|
s372001402
|
p03156
|
u603234915
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,064 | 276 |
You have written N problems to hold programming contests. The i-th problem will have a score of P_i points if used in a contest. With these problems, you would like to hold as many contests as possible under the following condition: * A contest has three problems. The first problem has a score not greater than A points, the second has a score between A + 1 and B points (inclusive), and the third has a score not less than B + 1 points. The same problem should not be used in multiple contests. At most how many contests can be held?
|
N = int(input())
A, B = map(int, input().split())
P = [i for i in map(int, input().split())]
P.sort()
print(P)
p_1 = list(filter(lambda x: x<=A, P))
p_2 = list(filter(lambda x: A < x <= B, P))
p_3 = list(filter(lambda x: B <x, P))
print(min(len(p_1), len(p_2), len(p_3)))
|
s441736086
|
Accepted
| 17 | 3,064 | 267 |
N = int(input())
A, B = map(int, input().split())
P = [i for i in map(int, input().split())]
P.sort()
p_1 = list(filter(lambda x: x<=A, P))
p_2 = list(filter(lambda x: A < x <= B, P))
p_3 = list(filter(lambda x: B <x, P))
print(min(len(p_1), len(p_2), len(p_3)))
|
s454429628
|
p04043
|
u278463847
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 60 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a = map(int, input().split())
print(set([5, 7]) == set(a))
|
s780996137
|
Accepted
| 17 | 2,940 | 104 |
a = list(map(int, input().split()))
print("YES") if a.count(5) == 2 and a.count(7) == 1 else print("NO")
|
s232741468
|
p03129
|
u178079174
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 83 |
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
|
N,K = list(map(int,input().split()))
if N>K:
print('Yes')
else:
print('No')
|
s350215609
|
Accepted
| 17 | 2,940 | 93 |
N,K = list(map(int,input().split()))
if (N+1)//2 >= K:
print('YES')
else:
print('NO')
|
s005949251
|
p02606
|
u478417863
| 2,000 | 1,048,576 |
Wrong Answer
| 31 | 9,036 | 66 |
How many multiples of d are there among the integers between L and R (inclusive)?
|
l,r,d= list(map(int, input().strip().split()))
print(r//d-l//d+1)
|
s018163388
|
Accepted
| 24 | 9,168 | 144 |
l,r,d= list(map(int, input().strip().split()))
if r%d==0:
s=r//d
else:
s=r//d
if l%d==0:
t=l//d
else:
t=l//d+1
print(s-t+1)
|
s693528608
|
p02853
|
u846471508
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,188 | 610 |
We held two competitions: Coding Contest and Robot Maneuver. In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen. DISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver. Find the total amount of money he earned.
|
X, Y = map(int, input().split())
first = 300000
second = 200000
third = 100000
if (X==1 and Y==1):
print(first+first+40000)
elif (X==2 and Y==2):
print(second+second)
elif (X==3 and Y==3):
print(third+third)
elif (X==1 and Y==2 or(X==2 and Y==1)):
print(first+second)
elif ((X==1 and Y==3) or(X==3 and Y==1) ):
print(first+third)
elif ((X==2 and Y==3) or(X==3 and Y==2) ):
print(second+third)
elif ((X==3 and Y>3) or(X>3and Y==3) ):
print(third)
elif ((X==2 and Y>3) or(X>3 and Y==2) ):
print(second)
elif ((X==1 and Y>3) or(X>3 and Y==1) ):
print(first)
else:
print(0)
|
s720088549
|
Accepted
| 17 | 3,064 | 660 |
X, Y = map(int, input().split())
first = 300000
second = 200000
third = 100000
if ((X==1 and ((X<205 and X>=1) and (Y>=1 and Y<205)) and Y==1)):
print(first+first+400000)
elif (X==2 and Y==2):
print(second+second)
elif (X==3 and Y==3):
print(third+third)
elif ((X==1 and Y==2) or(X==2 and Y==1)):
print(first+second)
elif ((X==1 and Y==3) or(X==3 and Y==1) ):
print(first+third)
elif ((X==2 and Y==3) or(X==3 and Y==2) ):
print(second+third)
elif ((X==3 and Y>3) or(X>3and Y==3) ):
print(third)
elif ((X==2 and Y>3) or(X>3 and Y==2) ):
print(second)
elif ((X==1 and Y>3) or(X>3 and Y==1) ):
print(first)
else:
print(0)
|
s073617384
|
p03574
|
u126823513
| 2,000 | 262,144 |
Wrong Answer
| 23 | 3,064 | 910 |
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_h, int_w = map(int, input().split())
l_h = list()
for i in range(int_h):
l_h.append(input())
l_temp = list()
l_temp.append(list(map(int, "0" * (int_w + 2))))
for r in l_h:
l_temp.append(list(map(lambda x: int(x) if x != "#" else x, "0" + r.replace(".", "0") + "0")))
l_temp.append(list(map(int, "0" * (int_w + 2))))
print(l_temp)
for rownum, row in enumerate(l_temp):
for colnum, col in enumerate(row):
if col == "#":
for c in [-1, 0, 1]:
if l_temp[rownum - 1][colnum + c] != "#":
l_temp[rownum - 1][colnum + c] += 1
if l_temp[rownum + 1][colnum + c] != "#":
l_temp[rownum + 1][colnum + c] += 1
for c in [-1, 1]:
if l_temp[rownum][colnum + c] != "#":
l_temp[rownum][colnum + c] += 1
for row in l_temp[1:-1]:
print("".join(map(str,row[1:-1])))
|
s155724195
|
Accepted
| 22 | 3,064 | 912 |
int_h, int_w = map(int, input().split())
l_h = list()
for i in range(int_h):
l_h.append(input())
l_temp = list()
l_temp.append(list(map(int, "0" * (int_w + 2))))
for r in l_h:
l_temp.append(list(map(lambda x: int(x) if x != "#" else x, "0" + r.replace(".", "0") + "0")))
l_temp.append(list(map(int, "0" * (int_w + 2))))
# print(l_temp)
for rownum, row in enumerate(l_temp):
for colnum, col in enumerate(row):
if col == "#":
for c in [-1, 0, 1]:
if l_temp[rownum - 1][colnum + c] != "#":
l_temp[rownum - 1][colnum + c] += 1
if l_temp[rownum + 1][colnum + c] != "#":
l_temp[rownum + 1][colnum + c] += 1
for c in [-1, 1]:
if l_temp[rownum][colnum + c] != "#":
l_temp[rownum][colnum + c] += 1
for row in l_temp[1:-1]:
print("".join(map(str,row[1:-1])))
|
s898165171
|
p03050
|
u575431498
| 2,000 | 1,048,576 |
Wrong Answer
| 143 | 2,940 | 137 |
Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied: * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds. Find all favorite numbers and print the sum of those.
|
N = int(input())
lim = int(N**0.5)
ans = 0
for i in range(1, lim):
if N % i == 0:
m = N // i - 1
ans += m
print(ans)
|
s245569447
|
Accepted
| 147 | 2,940 | 164 |
N = int(input())
lim = int(N**0.5) + 1
ans = 0
for i in range(1, lim):
if N % i == 0:
m = N // i - 1
if i < m:
ans += m
print(ans)
|
s587884844
|
p03160
|
u924406834
| 2,000 | 1,048,576 |
Wrong Answer
| 2,132 | 573,188 | 799 |
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
import sys
sys.setrecursionlimit(2100000000)
s = [x for x in input()]
t = [x for x in input()]
dp = [['' for i in range(len(s))] for j in range(len(t))]
dpcheck = [[False for i in range(len(s))] for j in range(len(t))]
def dppp(ns,nt):
global dp,s,t,dpcheck
if ns == len(s) or nt == len(t):return ''
if dpcheck[nt][ns] == True:return dp[nt][ns]
if s[ns] == t[nt]:
get = s[ns] + dppp(ns+1,nt+1)
else:
get = ''
sgo = dppp(ns+1,nt)
tgo = dppp(ns,nt+1)
dpcheck[nt][ns] = True
if len(sgo) >= len(tgo) and len(sgo) >= len(get):
dp[nt][ns] = sgo
return sgo
elif len(tgo) >= len(sgo) and len(tgo) >= len(get):
dp[nt][ns] = tgo
return tgo
else:
dp[nt][ns] = get
return get
ans = dppp(0,0)
print(ans)
|
s284414444
|
Accepted
| 142 | 13,980 | 209 |
n = int(input())
h = list(map(int,input().split()))
check = [0,abs(h[0]-h[1])] + [None]*(n-2)
for i in range(n-2):
check[i+2] = min(check[i]+abs(h[i]-h[i+2]),check[i+1]+abs(h[i+1]-h[i+2]))
print(check[-1])
|
s295690389
|
p02612
|
u132528440
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,132 | 29 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n=int(input())
print(n%1000)
|
s941271279
|
Accepted
| 26 | 9,136 | 37 |
n=int(input())
print((10000-n)%1000)
|
s840956978
|
p02612
|
u176165272
| 2,000 | 1,048,576 |
Wrong Answer
| 30 | 9,140 | 32 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N = int(input())
print(N % 1000)
|
s333201943
|
Accepted
| 35 | 9,148 | 79 |
N = int(input())
P = N % 1000
if P == 0:
print(0)
else:
print(1000 - P)
|
s632311047
|
p03407
|
u289162337
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 115 |
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())
M = max(a, b)
m = min(a, b)
if (c%M)%m == 0:
print("Yes")
else:
print("No")
|
s977473159
|
Accepted
| 17 | 2,940 | 83 |
a, b, c = map(int, input().split())
if a+b >= c:
print("Yes")
else:
print("No")
|
s602605630
|
p04029
|
u831830097
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 34 |
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)
|
s728860450
|
Accepted
| 18 | 2,940 | 35 |
n = int(input())
print(n*(1+n)//2)
|
s237770166
|
p04025
|
u623687794
| 2,000 | 262,144 |
Wrong Answer
| 25 | 3,060 | 183 |
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective.
|
n=int(input())
num=list(map(int,input().split()))
ans=10**9
s,e=min(num),max(num)
for j in range(s,e+1):
c=0
for i in range(n):
c+=(num[i]-j)**2
if c<ans:
ans=c
print(c)
|
s533009875
|
Accepted
| 26 | 3,060 | 186 |
n=int(input())
num=list(map(int,input().split()))
ans=10**9
s,e=min(num),max(num)
for j in range(s,e+1):
c=0
for i in range(n):
c+=(num[i]-j)**2
if c<ans:
ans=c
print(ans)
|
s246515836
|
p03854
|
u993642190
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,188 | 259 |
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
S = input()
S = S.replace("eraser", "")
S = S.replace("erase", "")
S = S.replace("dreamer", "")
S = S.replace("dream", "")
if (len(S) == 0) :
print("Yes")
else :
print("No")
|
s952931753
|
Accepted
| 19 | 3,188 | 379 |
S = input()
S = S.replace("eraser", "")
S = S.replace("erase", "")
S = S.replace("dreamer", "")
S = S.replace("dream", "")
if (len(S) == 0) :
print("YES")
else :
print("NO")
|
s651369076
|
p03545
|
u605853117
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 549 |
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.
|
import sys
import itertools as it
import operator
if __name__ == "__main__":
xs = [int(c) for c in input().strip()]
ops = it.product([-1, 1], repeat=3)
res = next(op for op in ops if 7 == (xs[0] + sum(map(operator.mul, xs[1:], op))))
symbols = ["+" if i == 1 else "-" for i in res]
iterable = filter(
lambda x: x is not None,
it.chain.from_iterable(
it.zip_longest(map(str, xs), symbols)
)
)
res = "".join(iterable)
print(res)
|
s897921043
|
Accepted
| 18 | 3,064 | 556 |
import sys
import itertools as it
import operator
if __name__ == "__main__":
xs = [int(c) for c in input().strip()]
ops = it.product([-1, 1], repeat=3)
res = next(op for op in ops if 7 == (xs[0] + sum(map(operator.mul, xs[1:], op))))
symbols = ["+" if i == 1 else "-" for i in res]
iterable = filter(
lambda x: x is not None,
it.chain.from_iterable(
it.zip_longest(map(str, xs), symbols)
)
)
res = "".join(iterable) + "=7"
print(res)
|
s957961158
|
p02613
|
u916242112
| 2,000 | 1,048,576 |
Wrong Answer
| 164 | 16,200 | 435 |
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())
a = []
for i in range(N):
a.append(input())
count_AC = 0
count_WA = 0
count_TLE = 0
count_RE = 0
for i in range(N):
if a[i] == 'AC':
count_AC += 1
if a[i] == 'WA':
count_WA += 1
if a[i] == 'TLE':
count_TLE += 1
if a[i] == 'RE':
count_RE += 1
print('AC × ', end='')
print(count_AC)
print('WA × ', end='')
print(count_WA)
print('TLE × ', end='')
print(count_TLE)
print('RE × ', end='')
print(count_RE)
|
s094631969
|
Accepted
| 165 | 16,200 | 432 |
N =int(input())
a = []
for i in range(N):
a.append(input())
count_AC = 0
count_WA = 0
count_TLE = 0
count_RE = 0
for i in range(N):
if a[i] == 'AC':
count_AC += 1
if a[i] == 'WA':
count_WA += 1
if a[i] == 'TLE':
count_TLE += 1
if a[i] == 'RE':
count_RE += 1
print('AC x ', end='')
print(count_AC)
print('WA x ', end='')
print(count_WA)
print('TLE x ', end='')
print(count_TLE)
print('RE x ', end='')
print(count_RE)
|
s420806497
|
p03472
|
u811202694
| 2,000 | 262,144 |
Wrong Answer
| 483 | 28,912 | 445 |
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times. * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana. The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?
|
import math
n,h = (map(int,input().split()))
katanas = [[int(el) for el in input().split()] for _ in range(n)]
hit_max = max([el[0] for el in katanas])
katanas.sort(key=lambda x:(x[1],x[0]),reverse=True)
count = 0
for katana in katanas:
if h <= 0:
break
if katana[1] > hit_max:
h -= katana[1]
count += 1
else:
break
if h <= 0:
print(count)
else:
print(count+math.ceil(count/hit_max))
|
s291005577
|
Accepted
| 470 | 28,932 | 465 |
import math
n,h = (map(int,input().split()))
katanas = [[int(el) for el in input().split()] for _ in range(n)]
hit_max = max([el[0] for el in katanas])
katanas.sort(key=lambda x:(x[1],x[0]),reverse=True)
count = 0
for katana in katanas:
if h <= 0:
break
if katana[1] > hit_max:
h -= katana[1]
count += 1
else:
break
if h <= 0:
print(count)
else:
print(count+math.ceil(h/hit_max))
|
s156104799
|
p03351
|
u371409687
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 103 |
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
a,b,c,d=map(int,input().split())
if abs(a-b)<d and abs(b-c)<d or abs(a-c)<d:
print("Yes")
else:("No")
|
s435412684
|
Accepted
| 17 | 2,940 | 111 |
a,b,c,d=map(int,input().split())
if abs(a-b)<=d and abs(b-c)<=d or abs(a-c)<=d:
print("Yes")
else:print("No")
|
s355656803
|
p03455
|
u123745130
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 102 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
i=int(input().replace(" ",""))**.5
for j in range(1,102):
if j==i:print("Yes");break
else:print("No")
|
s159502722
|
Accepted
| 17 | 2,940 | 97 |
a,b = map(int,input().split())
if a*b % 2 == 0:
print("Even")
elif a*b % 2 == 1:
print("Odd")
|
s561609825
|
p03644
|
u925406312
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 71 |
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
N=int(input())
k=0
while 2*k <= N:
ans = 2**k
k += 1
print(ans)
|
s415243528
|
Accepted
| 17 | 2,940 | 82 |
a = int(input())
x = 0
while 2**x <=a:
boxs = 2 ** x
x += 1
print(boxs)
|
s074673183
|
p03494
|
u033719192
| 2,000 | 262,144 |
Time Limit Exceeded
| 2,104 | 3,060 | 139 |
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
input()
A = list(map(int, input().split()))
ans = 0
while all(a % 2 == 0 for a in A):
A = [a % 2 for a in A]
ans += 1
print(ans)
|
s771062675
|
Accepted
| 18 | 3,060 | 139 |
input()
A = list(map(int, input().split()))
ans = 0
while all(a % 2 == 0 for a in A):
A = [a / 2 for a in A]
ans += 1
print(ans)
|
s963872729
|
p00375
|
u565812827
| 1,000 | 262,144 |
Wrong Answer
| 20 | 5,584 | 31 |
In Japan, temperature is usually expressed using the Celsius (℃) scale. In America, they used the Fahrenheit (℉) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as "Today’s temperature is $68$ degrees" is commonly encountered while you are in America. A value in Fahrenheit can be converted to Celsius by first subtracting $32$ and then multiplying by $\frac{5}{9}$. A simplified method may be used to produce a rough estimate: first subtract $30$ and then divide by $2$. Using the latter method, $68$ Fahrenheit is converted to $19$ Centigrade, i.e., $\frac{(68-30)}{2}$. Make a program to convert Fahrenheit to Celsius using the simplified method: $C = \frac{F - 30}{2}$.
|
a=int(input())
print((a-30)/2)
|
s513377610
|
Accepted
| 20 | 5,576 | 32 |
a=int(input())
print((a-30)//2)
|
s177808073
|
p03379
|
u177040005
| 2,000 | 262,144 |
Wrong Answer
| 2,105 | 132,228 | 138 |
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
|
N = int(input())
x = list(map(int,input().split()))
for i in range(N):
y = x[:]
del y[i]
y.sort()
print(y,y[int(N/2-1)])
|
s131349005
|
Accepted
| 430 | 34,168 | 216 |
import numpy as np
N = int(input())
x = list(map(int,input().split()))
y = x[:]
y.sort()
left = y[N//2-1]
right = y[N//2]
for i in x:
if i <= left:
print(right)
elif i >= right:
print(left)
|
s088011765
|
p02401
|
u109843748
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,632 | 163 |
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
|
import sys,math
def solve():
while True:
s = input()
if s == "0 ? 0":
break
else:
print(eval(s))
solve()
|
s650507511
|
Accepted
| 20 | 5,636 | 167 |
import sys,math
def solve():
while True:
s = input()
if "?" in s:
break
else:
print(int(eval(s)//1))
solve()
|
s580174847
|
p03593
|
u163320134
| 2,000 | 262,144 |
Wrong Answer
| 24 | 3,444 | 1,801 |
We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the top and j-th column from the left. In this matrix, each a_{ij} is a lowercase English letter. Snuke is creating another H-by-W matrix, A', by freely rearranging the elements in A. Here, he wants to satisfy the following condition: * Every row and column in A' can be read as a palindrome. Determine whether he can create a matrix satisfying the condition.
|
h,w=map(int,input().split())
ans=[['']*w for _ in range(h)]
print(ans)
char={}
for _ in range(h):
s=input()
for c in s:
if c not in char:
char[c]=1
else:
char[c]+=1
print(char)
ch=h//2
cw=w//2
fh=False
fw=False
if h%2==1:
ch+=1
fh=True
if w%2==1:
cw+=1
fw=True
for i in range(ch):
for j in range(cw):
if (i==ch-1 and fh==True) and (j==cw-1 and fw==True):
for c in char.keys():
if char[c]%2==1:
ans[i][j]=c
char[c]-=1
if char[c]==0:
del char[c]
break
elif i==ch-1 and fh==True:
for c in char.keys():
if char[c]%4==2:
ans[i][j]=c
ans[i][w-j-1]=c
char[c]-=2
if char[c]==0:
del char[c]
break
else:
for c in char.keys():
if char[c]>=2:
ans[i][j]=c
ans[i][w-j-1]=c
char[c]-=2
if char[c]==0:
del char[c]
break
elif j==cw-1 and fw==True:
for c in char.keys():
if char[c]%4==2:
ans[i][j]=c
ans[h-i-1][j]=c
char[c]-=2
if char[c]==0:
del char[c]
break
else:
for c in char.keys():
if char[c]>=2:
ans[i][j]=c
ans[h-i-1][j]=c
char[c]-=2
if char[c]==0:
del char[c]
break
else:
for c in char.keys():
if char[c]>=4:
ans[i][j]=c
ans[i][w-j-1]=c
ans[h-i-1][j]=c
ans[h-i-1][w-j-1]=c
char[c]-=4
if char[c]==0:
del char[c]
break
fy=True
for i in range(ch):
for j in range(cw):
if ans[i][j]=='':
fy=False
if fy==True:
print('Yes')
else:
print('No')
|
s345431960
|
Accepted
| 21 | 3,064 | 811 |
h,w=map(int,input().split())
char={}
for _ in range(h):
s=input()
for c in s:
if c not in char:
char[c]=1
else:
char[c]+=1
cnt4=(h//2)*(w//2)
cnt2=0
cnt1=0
if h%2==1 and w%2==1:
cnt1=1
cnt2=h//2+w//2
elif h%2==1:
cnt2=w//2
elif w%2==1:
cnt2=h//2
flag=True
for _ in range(cnt4):
for c in char.keys():
if char[c]>=4:
char[c]-=4
if char[c]==0:
del char[c]
break
else:
flag=False
for _ in range(cnt2):
for c in char.keys():
if char[c]>=2:
char[c]-=2
if char[c]==0:
del char[c]
break
else:
flag=False
for _ in range(cnt1):
for c in char.keys():
if char[c]>=1:
char[c]-=1
if char[c]==0:
del char[c]
break
else:
flag=False
if flag==True:
print('Yes')
else:
print('No')
|
s198730724
|
p03455
|
u194297606
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 90 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a,b = map(int, input().split())
if a*b % 2 == 0:
print("even")
else:
print("odd")
|
s953787405
|
Accepted
| 18 | 2,940 | 90 |
a,b = map(int, input().split())
if a*b % 2 == 0:
print("Even")
else:
print("Odd")
|
s996822400
|
p03959
|
u007550226
| 2,000 | 262,144 |
Wrong Answer
| 188 | 18,752 | 665 |
Mountaineers Mr. Takahashi and Mr. Aoki recently trekked across a certain famous mountain range. The mountain range consists of N mountains, extending from west to east in a straight line as Mt. 1, Mt. 2, ..., Mt. N. Mr. Takahashi traversed the range from the west and Mr. Aoki from the east. The height of Mt. i is h_i, but they have forgotten the value of each h_i. Instead, for each i (1 ≤ i ≤ N), they recorded the maximum height of the mountains climbed up to the time they reached the peak of Mt. i (including Mt. i). Mr. Takahashi's record is T_i and Mr. Aoki's record is A_i. We know that the height of each mountain h_i is a positive integer. Compute the number of the possible sequences of the mountains' heights, modulo 10^9 + 7. Note that the records may be incorrect and thus there may be no possible sequence of the mountains' heights. In such a case, output 0.
|
mod = 1000000007
n= int(input())
t= list(map(int,input().split()))
a= list(map(int,input().split()))
tb = [-1]*n
pre=-1
for i in range(n):
if i==0:tb[i]=1
else:
if pre!=t[i]:tb[i]=1
pre=t[i]
ab = [-1]*n
post=-1
for i in range(n-1,-1,-1):
if i==n-1:post=a[i]
else:
if post!=a[i]:
ab[i]=1
post=a[i]
er = False
b=1
for i in range(n):
if tb[i]==1 or ab[i]==1:
if tb[i]==1 and ab[i]==1:
if t[i]==a[i]:pass
else:
er=True
break
else:pass
else:
m = min(a[i],t[i])
b = ((b% mod) * (m % mod)) % mod
if er:print(0)
else:print(b)
|
s860789184
|
Accepted
| 187 | 19,012 | 978 |
mod = 1000000007
n= int(input())
t= list(map(int,input().split()))
a= list(map(int,input().split()))
tb = [-1]*n
pre=-1
for i in range(n):
if i==0:tb[i]=1
else:
if pre!=t[i]:tb[i]=1
pre=t[i]
ab = [-1]*n
post=-1
for i in range(n-1,-1,-1):
if i==n-1:ab[i]=1
else:
if post!=a[i]:ab[i]=1
post=a[i]
er = False
if a[0]!=t[-1]:er=True
else:
b=1
for i in range(n):
if tb[i]==1 or ab[i]==1:
if tb[i]==1 and ab[i]==1:
if t[i]==a[i]:pass
else:
er=True
break
else:
if tb[i]==1:
if a[i]<t[i]:
er=True
break
elif ab[i]==1:
if a[i]>t[i]:
er = True
break
else:
m = min(a[i],t[i])
b = ((b% mod) * (m % mod)) % mod
if er:print(0)
else:print(b)
|
s491177174
|
p03962
|
u745514010
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 134 |
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.
|
a,b,c=map(int,input().split())
if a==b or b==c or c==a:
if a==b==c:
print(1)
else:
print(2)
else:
print(2)
|
s434615685
|
Accepted
| 17 | 2,940 | 134 |
a,b,c=map(int,input().split())
if a==b or b==c or c==a:
if a==b==c:
print(1)
else:
print(2)
else:
print(3)
|
s690572430
|
p03139
|
u151107315
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 95 |
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question.
|
N, A, B = map(int,input().split())
print(str(min(A, B)) + " " + str(abs(N - (2 * N - A - B))))
|
s312948286
|
Accepted
| 17 | 2,940 | 155 |
N, A, B = map(int,input().split())
if A + B <= N :
print(str(min(A, B)) + " 0")
else :
print(str(min(A, B)) + " " + str(abs(N - (2 * N - A - B))))
|
s811583870
|
p00001
|
u468759892
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,584 | 99 |
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
|
s=[int(input(x)) for x in range(10)]
print(sorted(s)[-1])
print(sorted(s)[-2])
print(sorted(s)[-3])
|
s506106815
|
Accepted
| 30 | 7,668 | 98 |
s=[int(input()) for x in range(10)]
print(sorted(s)[-1])
print(sorted(s)[-2])
print(sorted(s)[-3])
|
s747630032
|
p00033
|
u695154284
| 1,000 | 131,072 |
Wrong Answer
| 40 | 7,732 | 489 |
図のように二股に分かれている容器があります。1 から 10 までの番号が付けられた10 個の玉を容器の開口部 A から落とし、左の筒 B か右の筒 C に玉を入れます。板 D は支点 E を中心に左右に回転できるので、板 D を動かすことで筒 B と筒 C のどちらに入れるか決めることができます。 開口部 A から落とす玉の並びを与えます。それらを順番に筒 B 又は筒 Cに入れていきます。このとき、筒 B と筒 C のおのおのが両方とも番号の小さい玉の上に大きい玉を並べられる場合は YES、並べられない場合は NO と出力するプログラムを作成してください。ただし、容器の中で玉の順序を入れ替えることはできないものとします。また、続けて同じ筒に入れることができるものとし、筒 B, C ともに 10 個の玉がすべて入るだけの余裕があるものとします。
|
def dfs(i, b, c):
if i == 10:
b_sort = sorted(b)
c_sort = sorted(c)
return (b == b_sort and c == c_sort)
if dfs(i + 1, b + [balls[i - 1]], c):
return True
if dfs(i + 1, b, c + [balls[i - 1]]):
return True
return False
if __name__ == '__main__':
N = int(input())
for i in range(N):
balls = list(map(int, input().split()))
if dfs(1, [0], [0]):
print("Yes")
else:
print("No")
|
s079878070
|
Accepted
| 50 | 7,608 | 439 |
def dfs(i, b, c):
if i == 11:
return (b == sorted(b) and c == sorted(c))
if dfs(i + 1, b + [balls[i - 1]], c):
return True
if dfs(i + 1, b, c + [balls[i - 1]]):
return True
return False
if __name__ == '__main__':
N = int(input())
for i in range(N):
balls = list(map(int, input().split()))
if dfs(1, [], []):
print("YES")
else:
print("NO")
|
s902050172
|
p03400
|
u191635495
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,316 | 221 |
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp.
|
n = int(input())
d,x = map(int, input().split())
a = []
for _ in range(n):
a.append(int(input()))
res = 0
for e in a:
i = 0
while e*i+1 <= d:
print(e*i+1)
res += 1
i += 1
print(res+x)
|
s189502017
|
Accepted
| 18 | 3,060 | 200 |
n = int(input())
d,x = map(int, input().split())
a = []
for _ in range(n):
a.append(int(input()))
res = 0
for e in a:
i = 0
while e*i+1 <= d:
res += 1
i += 1
print(res+x)
|
s426101037
|
p02678
|
u374099594
| 2,000 | 1,048,576 |
Wrong Answer
| 710 | 34,424 | 326 |
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
N, M = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
A, B = map(int, input().split())
E[A-1] += [B-1]
E[B-1] += [A-1]
ans = [-1]*N
T = [0]
while len(T)>0:
P = T
T = []
for x in P:
for e in E[x]:
if ans[e]==-1:
T += [e]
ans[e] = x
for a in ans[1:]:
print(a+1)
|
s106999469
|
Accepted
| 694 | 34,924 | 340 |
N, M = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
A, B = map(int, input().split())
E[A-1] += [B-1]
E[B-1] += [A-1]
ans = [-1]*N
T = [0]
while len(T)>0:
P = T
T = []
for x in P:
for e in E[x]:
if ans[e]==-1:
T += [e]
ans[e] = x
print("Yes")
for a in ans[1:]:
print(a+1)
|
s569786001
|
p02386
|
u566311709
| 1,000 | 131,072 |
Wrong Answer
| 30 | 5,612 | 718 |
Write a program which reads $n$ dices constructed in the same way as [Dice I](description.jsp?id=ITP1_11_A), and determines whether they are all different. For the determination, use the same way as [Dice III](description.jsp?id=ITP1_11_C).
|
p = [(-1, 2, 4, 1, 3, -1), (3, -1, 0, 5, -1, 2), (1, 5, -1, -1, 0, 4),
(4, 0, -1, -1, 5, 1), (2, -1, 5, 0, -1, 3), (-1, 3, 1, 4, 2, -1)]
def is_equal(d, a):
ts = [i for i, x in enumerate(d) if x == a[0]]
fs = [i for i, x in enumerate(d) if x == a[1]]
b = 0
for t in ts:
for f in fs:
if t == f: continue
r = p[t][f]
if r == -1: continue
l = [d[t], d[f], d[r], d[5-r], d[5-f], d[5-t]]
if a == l: b += 1; break
return 1 if b > 0 else 0
l = []
b = 0
for _ in range(int(input())):
l += [input().split()]
print(l)
for i in range(0, len(l)):
for j in range(i+1, len(l)):
print(i, j)
b = is_equal(l[i], l[j])
if b > 0: break
print("No") if b > 0 else print("Yes")
|
s720201434
|
Accepted
| 20 | 5,616 | 694 |
p = [(-1, 2, 4, 1, 3, -1), (3, -1, 0, 5, -1, 2), (1, 5, -1, -1, 0, 4),
(4, 0, -1, -1, 5, 1), (2, -1, 5, 0, -1, 3), (-1, 3, 1, 4, 2, -1)]
def is_equal(d, a):
ts = [i for i, x in enumerate(d) if x == a[0]]
fs = [i for i, x in enumerate(d) if x == a[1]]
b = 0
for t in ts:
for f in fs:
if t == f: continue
r = p[t][f]
if r == -1: continue
l = [d[t], d[f], d[r], d[5-r], d[5-f], d[5-t]]
if a == l: b += 1; break
return 1 if b > 0 else 0
l = []
b = 0
for _ in range(int(input())):
l += [input().split()]
for i in range(0, len(l)):
for j in range(i+1, len(l)):
b += is_equal(l[i], l[j])
if b > 0: break
print("No") if b > 0 else print("Yes")
|
s628157821
|
p03486
|
u588341295
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,064 | 291 |
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
# -*- coding: utf-8 -*-
s_list = list(input())
t_list = list(input())
s_list.sort()
t_list.sort(reverse=True)
if "".join(s_list) < "".join(t_list):
print("yes")
else:
print("No")
|
s760240723
|
Accepted
| 18 | 2,940 | 291 |
# -*- coding: utf-8 -*-
s_list = list(input())
t_list = list(input())
s_list.sort()
t_list.sort(reverse=True)
if "".join(s_list) < "".join(t_list):
print("Yes")
else:
print("No")
|
s365726321
|
p02264
|
u771410206
| 1,000 | 131,072 |
Time Limit Exceeded
| 9,990 | 5,592 | 399 |
_n_ _q_ _name 1 time1_ _name 2 time2_ ... _name n timen_ In the first line the number of processes _n_ and the quantum _q_ are given separated by a single space. In the following _n_ lines, names and times for the _n_ processes are given. _name i_ and _time i_ are separated by a single space.
|
n,q = map(int,input().split())
A = [list(map(str,input().split())) for i in range(n)]
time = 0
flag = 1
while flag == 1:
if int(A[0][1]) <= q:
time += int(A[0][1])
print(A[0][1],time)
del A[0]
else:
time += q
A.append(A[0])
del A[0]
if len(A) == 0:
flag = 0
|
s390416360
|
Accepted
| 930 | 14,300 | 401 |
n,q = map(int,input().split())
A = [list(map(str,input().split())) for i in range(n)]
time = 0
flag = 1
while len(A) > 0:
if int(A[0][1]) <= q:
time += int(A[0][1])
print(A[0][0],time)
del A[0]
else:
time += q
A[0][1] = str(int(A[0][1])-q)
A.append(A[0])
del A[0]
|
s407391300
|
p03386
|
u882370611
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 141 |
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
a, b, k = map(int, input().split())
s = []
for i in range(k):
s.append(a+k)
s.append(b-k)
s.sort()
t = set(s)
for u in t:
print(u)
|
s401516242
|
Accepted
| 17 | 3,060 | 203 |
a, b, k = map(int, input().split())
ak = [i for i in range(a, min(b + 1, a + k))]
bk = [i for i in range(max(a, b - k + 1), b + 1)]
abk = list(set(ak) | set(bk))
abk.sort()
for i in abk:
print(i)
|
s509087598
|
p02612
|
u552331659
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,068 | 62 |
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.
|
a = int(input())
while a >= 1000:
a = a - 1000
print(a)
|
s602989207
|
Accepted
| 32 | 9,152 | 70 |
a = int(input())
b = 0
while b < a:
b = b + 1000
print(abs(a-b))
|
s223007006
|
p03069
|
u081688405
| 2,000 | 1,048,576 |
Wrong Answer
| 2,104 | 4,124 | 293 |
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.
|
from functools import reduce
input()
src = input()
costs = [reduce(lambda x,y: x+(1 if y=="
costs.append(reduce(lambda x,y: x+(1 if y=="#" else 0), src, 0))
print(costs)
print(min(costs))
|
s009290984
|
Accepted
| 159 | 5,720 | 243 |
from functools import reduce
l = int(input())
src = list(map(lambda x: 1 if x=="." else 0, input()))
lb = 0
rw = sum(src)
a = rw
for i in range(l):
if src[i]==0:
lb+=1
else:
rw-=1
a = min(a, lb + rw)
if a==0:
break
print(a)
|
s055679086
|
p03644
|
u059828923
| 2,000 | 262,144 |
Wrong Answer
| 31 | 9,044 | 89 |
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
N = int(input())
i = 1
while i < N:
i = i*2
if i < N:
print(i)
else:
print(i / 2)
|
s133704657
|
Accepted
| 28 | 9,104 | 113 |
import math
N = int(input())
i = 1
while i < N:
i = i*2
if i <= N:
print(i)
else:
print(math.floor(i/2))
|
s768076096
|
p03455
|
u844172143
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 128 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a, b = map(int, input().split())
print(a)
print(b)
print(a+b)
sum = a + b
if (sum % 2 == 0 ):
print('Even')
else:
print('Odd')
|
s115931934
|
Accepted
| 17 | 2,940 | 90 |
a, b = map(int, input().split())
if ((a*b) % 2 == 0 ):
print('Even')
else:
print('Odd')
|
s876379246
|
p03485
|
u625495026
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 79 |
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)
else:
print(a+b+1)
|
s540689969
|
Accepted
| 17 | 2,940 | 52 |
a,b = map(int,input().split())
print(int((a+b+1)/2))
|
s177916123
|
p03795
|
u131405882
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 57 |
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 = 200 * (N/15)
print(x-y)
|
s753213351
|
Accepted
| 17 | 2,940 | 60 |
N = int(input())
x = 800 * N
y = 200 * int(N/15)
print(x-y)
|
s344055397
|
p02665
|
u130900604
| 2,000 | 1,048,576 |
Wrong Answer
| 22 | 9,132 | 9 |
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.
|
print(-1)
|
s697013596
|
Accepted
| 96 | 20,144 | 156 |
n,*a=map(int,open(0).read().split())
tot=sum(a)
v=[1]
for q in a:
tot-=q
vt=min(2*(v[-1]-q),tot)
if vt<0:print(-1);exit()
v.append(vt)
print(sum(v))
|
s819361809
|
p02845
|
u691018832
| 2,000 | 1,048,576 |
Wrong Answer
| 40 | 13,972 | 276 |
N people are standing in a queue, numbered 1, 2, 3, ..., N from front to back. Each person wears a hat, which is red, blue, or green. The person numbered i says: * "In front of me, exactly A_i people are wearing hats with the same color as mine." Assuming that all these statements are correct, find the number of possible combinations of colors of the N people's hats. Since the count can be enormous, compute it modulo 1000000007.
|
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
rbg = [0, 0, 0]
ans = 1
mod = 10 ** 9 + 7
for A in a:
ans *= rbg.count(A)
ans %= mod
if A is not rbg:
ans = 0
break
rbg[rbg.index(A)] += 1
print(ans)
|
s623700318
|
Accepted
| 106 | 12,408 | 404 |
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
n, *a = map(int, read().split())
ans = 1
mod = 10 ** 9 + 7
memo = [0, 0, 0]
for check in a:
if check in memo:
ans *= memo.count(check)
ans %= mod
memo[memo.index(check)] += 1
else:
print(0)
exit()
print(ans)
|
s250124189
|
p02262
|
u749243807
| 6,000 | 131,072 |
Wrong Answer
| 20 | 5,612 | 903 |
Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i]) A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$. Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m − 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements: * $1 \leq m \leq 100$ * $0 \leq G_i \leq n$ * cnt does not exceed $\lceil n^{1.5}\rceil$
|
count = int(input());
data = [];
for i in range(count):
data.append(int(input()));
gaps = [1];
for i in range(99):
next_gap = 3 * gaps[-1] + 1;
if count > next_gap:
gaps.append(next_gap);
else:
break;
gaps.reverse();
def shell_sort(data, gaps):
o = 0;
for gap in gaps:
for g in range(gap):
o += insert_sort(data, gap, g);
return o;
def insert_sort(data, gap, g):
o = 0;
count = len(data);
for i in range(g + gap, count, gap):
n = data[i];
j = i - gap;
while j >= 0:
o += 1;
if data[j] > n:
data[j + gap] = data[j];
j -= gap;
else:
break;
data[j + gap] = n;
return o;
o = shell_sort(data, gaps);
print(len(gaps));
print(" ".join(str(n) for n in gaps));
print(o);
print("\n".join(str(n) for n in data));
|
s450066225
|
Accepted
| 19,000 | 125,984 | 906 |
count = int(input());
data = [];
for i in range(count):
data.append(int(input()));
gaps = [1];
for i in range(99):
next_gap = 3 * gaps[-1] + 1;
if count > next_gap:
gaps.append(next_gap);
else:
break;
gaps.reverse();
def shell_sort(data, gaps):
o = 0;
for gap in gaps:
for g in range(gap):
o += insert_sort(data, gap, g);
return o;
def insert_sort(data, gap, g):
o = 0;
count = len(data);
for i in range(g + gap, count, gap):
n = data[i];
j = i - gap;
while j >= 0:
if data[j] > n:
o += 1;
data[j + gap] = data[j];
j -= gap;
else:
break;
data[j + gap] = n;
return o;
o = shell_sort(data, gaps);
print(len(gaps));
print(" ".join(str(n) for n in gaps));
print(o);
print("\n".join(str(n) for n in data));
|
s723765632
|
p03605
|
u077671688
| 2,000 | 262,144 |
Wrong Answer
| 28 | 8,844 | 100 |
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 = str(input())
if "9" == N[0]:
if "9" == N[1]:
print( "YES" )
else:
print( "NO" )
|
s684544125
|
Accepted
| 30 | 8,960 | 68 |
N = input()
if "9" in N:
print( "Yes" )
else:
print( "No" )
|
s325108923
|
p02612
|
u103831818
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 9,132 | 29 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n=int(input())
print(n%1000)
|
s356721146
|
Accepted
| 25 | 9,144 | 74 |
n=int(input())
y = n%1000
if y == 0:
print(0)
else:
print(1000-y)
|
s501344782
|
p02678
|
u363825867
| 2,000 | 1,048,576 |
Wrong Answer
| 768 | 49,104 | 446 |
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
N, M = [int(i) for i in input().split()]
Mark = [0 for _ in range(N+1)]
path = {k: [] for k in range(1, N+1)}
for i in range(M):
A, B = [int(i) for i in input().split()]
path[A].append(B)
path[B].append(A)
next = [1]
while True:
n = next.pop()
for x in path[n]:
# n -> x
if Mark[x] == 0:
Mark[x] = n
next.append(x)
if not next: break
print("\n".join([str(i) for i in Mark[2:]]))
|
s893302570
|
Accepted
| 1,441 | 48,880 | 506 |
N, M = [int(i) for i in input().split()]
Mark = [0 for _ in range(N+1)]
path = {k: [] for k in range(1, N+1)}
for i in range(M):
A, B = [int(i) for i in input().split()]
path[A].append(B)
path[B].append(A)
next = [1]
while True:
n = next.pop(0)
for x in path[n]:
# n -> x
if Mark[x] == 0:
Mark[x] = n
next.append(x)
if not next: break
if 0 in Mark[2:]:
print("No")
else:
print("Yes")
print("\n".join([str(i) for i in Mark[2:]]))
|
s553534254
|
p04043
|
u876169782
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 244 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a,b,c = map(int,input().split())
g = 0
if a == 5:
g = g + 1
if b == 5:
g = g + 1
if c == 5:
g = g + 1
h = 0
if a == 7:
h = h + 1
if b == 7:
h = h + 1
if c == 7:
h = h + 1
if h == 2 and g == 1:
print("YES")
else:
print("NO")
|
s007348099
|
Accepted
| 17 | 3,064 | 244 |
a,b,c = map(int,input().split())
g = 0
if a == 5:
g = g + 1
if b == 5:
g = g + 1
if c == 5:
g = g + 1
h = 0
if a == 7:
h = h + 1
if b == 7:
h = h + 1
if c == 7:
h = h + 1
if h == 1 and g == 2:
print("YES")
else:
print("NO")
|
s442518360
|
p03130
|
u325227960
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,064 | 295 |
There are four towns, numbered 1,2,3 and 4. Also, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally. No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads. Determine if we can visit all the towns by traversing each of the roads exactly once.
|
A=[]
for i in range(3):
A.append(list(map(int,input().split())))
#print(A)
C=[0,0,0,0,0]
for i in range(len(A)) :
C[A[i][0]]+=1
C[A[i][1]]+=1
#print(C)
co=0
for i in range(1,5):
if C[i]==1 or C[i]==3 :
co+=1
if co==0 or co==2 :
print("Yes")
else :
print("No")
|
s074862023
|
Accepted
| 17 | 3,064 | 298 |
A=[]
for i in range(3):
A.append(list(map(int,input().split())))
#print(A)
C=[0,0,0,0,0]
for i in range(len(A)) :
C[A[i][0]]+=1
C[A[i][1]]+=1
#print(C)
co=0
for i in range(1,5):
if C[i]==1 or C[i]==3 :
co+=1
if co==0 or co==2 :
print("YES")
else :
print("NO")
|
s847186990
|
p03699
|
u894844146
| 2,000 | 262,144 |
Wrong Answer
| 20 | 2,940 | 190 |
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
|
n=int(input())
a =[]
for i in range(n):
a.append(int(input()))
a.sort(reverse=True)
s=sum(a)
if s%10==0:
for i in a:
if i%10>0:
s-=i
break
print(s)
|
s758941990
|
Accepted
| 17 | 3,060 | 213 |
n=int(input())
a =[]
for i in range(n):
a.append(int(input()))
a.sort()
s=sum(a)
if s%10==0:
for i in a:
if i%10>0:
s-=i
break
if s%10>0:
print(s)
else:
print(0)
|
s160110925
|
p03760
|
u386819480
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 234 |
Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions. You are given two strings O and E. O contains the characters at the odd- numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order. Restore the original password.
|
##ABC 058
o = list(input())
e = list(input())
ans=[]
for i in range(min(len(o),len(e))):
ans.append(o[i])
ans.append(e[i])
print(''.join(ans)) if(len(e) == len(o)) else ans.append(o[-1]); print(''.join(ans))
|
s923268654
|
Accepted
| 17 | 3,060 | 239 |
##ABC 058
o = list(input())
e = list(input())
ans=[]
for i in range(min(len(o),len(e))):
ans.append(o[0])
o.pop(0)
ans.append(e[0])
e.pop(0)
print(''.join(ans)) if((o+e) == []) else print(''.join(ans+o+e))
|
s013166585
|
p03351
|
u161260793
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 190 |
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
a, b, c, d = (int(i) for i in input().split())
dab = (a-b)**2
dac = (a-c)**2
dbc = (b-c)**2
if dac <= d**2:
print("Yes")
elif (dab - dbc)**2 <= d**2:
print("Yes")
else: print("No")
|
s681549241
|
Accepted
| 17 | 3,060 | 237 |
import math
a, b, c, d = (int(i) for i in input().split())
dab = math.sqrt((a-b)**2)
dac = math.sqrt((a-c)**2)
dbc = math.sqrt((b-c)**2)
if dac <= d:
print("Yes")
elif dab <= d and dbc <= d:
print("Yes")
else:
print("No")
|
s904618076
|
p03679
|
u983749726
| 2,000 | 262,144 |
Wrong Answer
| 25 | 8,976 | 256 |
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.
|
input = input()
s_input = input.split()
print(s_input)
x = int(s_input[0]) * -1
a = int(s_input[1])
b = int(s_input[2])
kigenchouka = a - b
if kigenchouka >= 0:
print("delicioous")
elif kigenchouka > x :
print("safe")
else:
print("danger")
|
s845807720
|
Accepted
| 25 | 9,076 | 255 |
input = input()
s_input = input.split()
x = int(s_input[0])
a = int(s_input[1])
b = int(s_input[2])
kigenchouka = b - a
if kigenchouka > x:
print("dangerous")
else:
if kigenchouka <= 0:
print("delicious")
else:
print("safe")
|
s359515256
|
p02612
|
u642385464
| 2,000 | 1,048,576 |
Wrong Answer
| 32 | 9,152 | 71 |
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())
tmp = N % 1000
answer = (tmp+1)*1000 -N
print(answer)
|
s846823042
|
Accepted
| 33 | 9,156 | 110 |
N = int(input())
tmp = N // 1000
answer = (tmp+1)*1000 -N
if answer == 1000:
print(0)
else:
print(answer)
|
s563107517
|
p03698
|
u264681142
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 114 |
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
l = list(map(str, input()))
if len([x for x in set(l) if l.count(x) > 1]) > 0:
print('yes')
else:
print('no')
|
s798316625
|
Accepted
| 17 | 2,940 | 114 |
l = list(map(str, input()))
if len([x for x in set(l) if l.count(x) > 1]) > 0:
print('no')
else:
print('yes')
|
s043022135
|
p03080
|
u463950771
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 155 |
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
|
N = int(input())
s = input()
dic = {'R':0, 'B':0}
for ss in s:
dic[ss] += 1
print(dic)
if dic['R'] > dic['B']:
print("Yes")
else:
print("No")
|
s756239735
|
Accepted
| 17 | 2,940 | 145 |
N = int(input())
s = input()
dic = {'R':0, 'B':0}
for ss in s:
dic[ss] += 1
if dic['R'] > dic['B']:
print("Yes")
else:
print("No")
|
s651166503
|
p00424
|
u150984829
| 1,000 | 131,072 |
Wrong Answer
| 820 | 6,472 | 169 |
与えられた変換表にもとづき,データを変換するプログラムを作成しなさい. データに使われている文字は英字か数字で,英字は大文字と小文字を区別する.変換表に現れる文字の順序に規則性はない. 変換表は空白をはさんで前と後ろの 2 つの文字がある(文字列ではない).変換方法は,変換表のある行の前の文字がデータに現れたら,そのたびにその文字を後ろの文字に変換し出力する.変換は 1 度だけで,変換した文字がまた変換対象の文字になっても変換しない.変換表に現れない文字は変換せず,そのまま出力する. 入力ファイルには,変換表(最初の n + 1 行)に続き変換するデータ(n + 2 行目以降)が書いてある. 1 行目に変換表の行数 n,続く n 行の各行は,空白をはさんで 2 つの文字,さらに続けて, n + 2 行目に変換するデータの行数 m,続く m 行の各行は 1 文字である. m ≤ 105 とする.出力は,出力例のように途中に空白や改行は入れず 1 行とせよ. 入力例 --- 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 出力例 aBC5144aba
|
while 1:
n=int(input())
if n==0:break
d={}
for _ in[0]*n:
k,v=input().split()
d[k]=v
for _ in[0]*int(input()):
e=input()
print(d[e]if e in d else e,end='')
|
s300177556
|
Accepted
| 120 | 7,112 | 157 |
import sys
s=sys.stdin.readline
for n in iter(s,'0\n'):
d={}
for _ in[0]*int(n):e=s();d[e[0]]=e[2]
print(''.join(d.get(*[s()[0]]*2)for _ in[0]*int(s())))
|
s291967482
|
p03636
|
u757030836
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 63 |
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
s = input()
a = s[1]
b = s[2:len(s)-1]
c = s[-1]
print(a+b+c)
|
s490514570
|
Accepted
| 17 | 2,940 | 67 |
s = input()
d = len(s[1:len(s)-1])
print(s[0] + str(d) + s[-1])
|
s813305301
|
p03854
|
u911531682
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,188 | 414 |
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
S = input()
T = ['dream', 'dreamer', 'erase', 'eraser']
def reverse(t):
return t[::-1]
RT = [reverse(t) for t in T]
RS = reverse(S)
print(RT)
for i in range(len(RS)):
can = False
for j in range(4):
sizeT = len(RT[j])
if RT[j] == RS[i:sizeT]:
i += sizeT
can = True
break
if can:
break
if can:
print('OK')
else:
print('NG')
|
s591343695
|
Accepted
| 47 | 3,188 | 445 |
S = input()
T = ['dream', 'dreamer', 'erase', 'eraser']
def reverse(t):
return t[::-1]
RT = [reverse(t) for t in T]
RS = reverse(S)
can = True
i = 0
while i < len(RS):
can2 = False
for j in range(4):
sizeT = len(RT[j])
if RT[j] == RS[i:i + sizeT]:
i += sizeT
can2 = True
break
if not can2:
can = False
break
if can:
print('YES')
else:
print('NO')
|
s997585420
|
p02678
|
u535171899
| 2,000 | 1,048,576 |
Wrong Answer
| 2,232 | 38,368 | 621 |
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
n,m = map(int,input().split())
route_li = [[] for i in range(n)]
for i in range(m):
a,b = map(int,input().split())
a,b = a-1,b-1
route_li[a].append(b)
route_li[b].append(a)
print(route_li)
ans = []
for i in range(1,n):
if i in route_li[0]:
print(i)
ans.append(1)
continue
for j in range(1,n):
if i==j:
continue
if 0 in route_li[j]:
if j in route_li[i]:
print(i,j)
ans.append(j+1)
break
if len(ans)==(n-1):
print('Yes')
print('\n'.join(map(str,ans)))
else:
print('No')
|
s445260300
|
Accepted
| 1,888 | 205,028 | 304 |
import networkx as nx
n,m,*s = map(int, open(0).read().split())
g=nx.Graph()
g.add_nodes_from([i for i in range(1,n+1)])
for x in zip(*[iter(s)] * 2):
g.add_edge(x[0],x[1])
di=nx.predecessor(g,source=1)
if len(di)!=n:
print("No");exit()
print("Yes")
for x in range(2,n+1):
print(di[x][0])
|
s045404919
|
p03433
|
u170077602
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 153 |
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
row = [input().split() for i in range(2)]
n = int(row[0][0])
a = int(row[1][0])
surplus = n % 500
if surplus <= a:
print("YES")
else:
print("NO")
|
s113115294
|
Accepted
| 17 | 2,940 | 153 |
row = [input().split() for i in range(2)]
n = int(row[0][0])
a = int(row[1][0])
surplus = n % 500
if surplus <= a:
print("Yes")
else:
print("No")
|
s713897245
|
p03846
|
u608088992
| 2,000 | 262,144 |
Wrong Answer
| 106 | 13,880 | 781 |
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 = [int(_) for _ in input().split()]
A.sort()
mod = 7 + 10**9
Appropriate = True
ans = 1
if N % 2 == 0:
i = 0
while i < N:
if A[i] != i+1 or A[i+1] != i+1:
Appropriate = False
break
else:
ans *= 2
ans %= mod
i+=2
else:
i = 1
if A[0] != 0 or A.count(0) > 2:
Appropriate = False
else:
while i < N:
if A[i] != i+1 or A[i+1] != i+1:
Appropriate = False
break
else:
ans *= 2
ans %= mod
i += 2
|
s505688904
|
Accepted
| 110 | 13,880 | 816 |
N = int(input())
A = [int(_) for _ in input().split()]
A.sort()
mod = 7 + 10**9
Appropriate = True
ans = 1
if N % 2 == 0:
i = 0
while i < N:
if A[i] != i+1 or A[i+1] != i+1:
Appropriate = False
break
else:
ans *= 2
ans %= mod
i+=2
else:
i = 1
if A[0] != 0 or A.count(0) > 2:
Appropriate = False
else:
while i < N:
if A[i] != i+1 or A[i+1] != i+1:
Appropriate = False
break
else:
ans *= 2
ans %= mod
i += 2
print(ans if Appropriate else 0)
|
s287419505
|
p03711
|
u714378447
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 167 |
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
|
import sys
s1 = {1,3,5,7,8,10,12}
s2 = {4,6,9,11}
t = set(map(int,input().split()))
for s in [s1, s2]:
if len(t&s)==2:
print('YES')
sys.exit()
print('NO')
|
s406066212
|
Accepted
| 17 | 3,060 | 167 |
import sys
s1 = {1,3,5,7,8,10,12}
s2 = {4,6,9,11}
t = set(map(int,input().split()))
for s in [s1, s2]:
if len(t&s)==2:
print('Yes')
sys.exit()
print('No')
|
s055513952
|
p03064
|
u648868410
| 3,000 | 1,048,576 |
Wrong Answer
| 1,727 | 16,684 | 1,098 |
You are given N integers. The i-th integer is a_i. Find the number, modulo 998244353, of ways to paint each of the integers red, green or blue so that the following condition is satisfied: * Let R, G and B be the sums of the integers painted red, green and blue, respectively. There exists a triangle with positive area whose sides have lengths R, G and B.
|
import numpy as np
MOD=998244353
N=int(input())
A=np.array(sorted([int(input()) for _ in range(N)]))
TOTAL=pow(3,N,MOD)
ASum=np.sum(A)
# dp=[[0 for _ in range(ASum+1)] for _ in range(2)]
dp=np.zeros((2,ASum+1),dtype=np.int64)
dp[0][0] = 2
dp[0][A[0]] = 1
# dpOther=[[0 for _ in range(ASum+1)] for _ in range(2)]
dpOther=np.zeros((2,ASum+1),dtype=np.int64)
dpOther[0][0] = 1
dpOther[0][A[0]] = 1
prev=0
current=1
curMax=A[0]
# for n in range(1,N):
for n, a in enumerate(A):
if n==0:
continue
# curMax += a
current = n % 2
prev = (n+1) % 2
dp[current,:] = dp[prev,:]*2 % MOD
dp[current,a:] = dp[prev,:-a] % MOD
if ASum %2 == 0:
dpOther[current,:] = dpOther[prev,:] % MOD
dpOther[current,a:] = dpOther[prev,:-a] % MOD
sumStart = 0
plus = 0
if ASum % 2 == 0:
sumStart=ASum//2
plus = (dpOther[current][ASum//2]*3) % MOD
else:
sumStart=ASum//2+1
exceptCnt=0
for s in range(sumStart,ASum+1):
exceptCnt = (exceptCnt + dp[current][s]*3) % MOD
exceptCnt -= plus
print((TOTAL - exceptCnt) % MOD )
|
s280877521
|
Accepted
| 1,754 | 16,684 | 1,107 |
import numpy as np
MOD=998244353
N=int(input())
A=np.array([int(input()) for _ in range(N)],dtype=np.int64)
TOTAL=pow(3,N,MOD)
ASum=np.sum(A)
# dp=[[0 for _ in range(ASum+1)] for _ in range(2)]
dp=np.zeros((2,ASum+1),dtype=np.int64)
dp[0][0] = 2
dp[0][A[0]] = 1
# dpOther=[[0 for _ in range(ASum+1)] for _ in range(2)]
dpOther=np.zeros((2,ASum+1),dtype=np.int64)
dpOther[0][0] = 1
dpOther[0][A[0]] = 1
prev=0
current=1
curMax=A[0]
# for n in range(1,N):
for n, a in enumerate(A):
if n==0:
continue
# curMax += a
current = n % 2
prev = (n+1) % 2
dp[current,:] = dp[prev,:]*2 % MOD
dp[current,a:] += dp[prev,:-a] % MOD
if ASum %2 == 0:
dpOther[current,:] = dpOther[prev,:] % MOD
dpOther[current,a:] += dpOther[prev,:-a] % MOD
sumStart = 0
plus = 0
if ASum % 2 == 0:
sumStart=ASum//2
plus = (dpOther[current][ASum//2]*3) % MOD
else:
sumStart=ASum//2+1
exceptCnt=0
for s in range(sumStart,ASum+1):
exceptCnt = (exceptCnt + dp[current][s]*3) % MOD
exceptCnt -= plus
print((TOTAL - exceptCnt) % MOD )
|
s200383216
|
p04030
|
u695079172
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 121 |
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
|
s=input()
temp = ""
for c in s:
if c == '1' or c == '0':
temp += c
else:
temp = temp[0:len(temp)]
print(temp)
|
s031344723
|
Accepted
| 17 | 3,064 | 148 |
s=input()
answer=""
for c in s:
if c != "B":
answer += c
elif answer != "":
answer = answer[:-1]
else:
continue
print(answer)
|
s849546276
|
p03860
|
u475966842
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 61 |
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
vowelslist=["a","e","i","o","u"]
print(input() in vowelslist)
|
s019850489
|
Accepted
| 17 | 2,940 | 43 |
a,b,c=input().split()
print(a[0]+b[0]+c[0])
|
s038244979
|
p03545
|
u249685005
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 601 |
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.
|
N=list(input())
l=len(N)-1
for n in range(2**l):
lis=list(format(n,'b'))
list(map(int,lis))
nagasa=len(lis)
if nagasa<l:
for _ in range(l-nagasa):
lis.insert(0,0)
S=int(N[0])
ans=[]
for ll in range(l):
if lis[ll]=='1':
S=S+int(N[ll+1])
ans.append('+')
else:
S=int(N[ll])-int(N[ll+1])
ans.append('-')
if S==7:
kotae=[N[0]]
for x in range(l):
kotae.append(ans[x])
kotae.append(N[x+1])
last=''.join(kotae)
print(last)
break
|
s007524807
|
Accepted
| 17 | 3,064 | 619 |
N=list(input())
l=len(N)-1
for n in range(2**l):
lis=list(format(n,'b'))
list(map(int,lis))
nagasa=len(lis)
if nagasa<l:
for _ in range(l-nagasa):
lis.insert(0,0)
S=int(N[0])
ans=[]
for ll in range(l):
if lis[ll]=='1':
S=S+int(N[ll+1])
ans.append('+')
else:
S=S-int(N[ll+1])
ans.append('-')
if S==7:
kotae=[N[0]]
for x in range(l):
kotae.append(ans[x])
kotae.append(N[x+1])
kotae.append('=7')
last=''.join(kotae)
print(last)
break
|
s227453247
|
p03563
|
u580362735
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 52 |
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
|
R = int(input())
G = int(input())
print(G + (G-R)/2)
|
s411583694
|
Accepted
| 17 | 2,940 | 50 |
R = int(input())
G = int(input())
print(G + G - R)
|
s419315829
|
p03415
|
u710282484
| 2,000 | 262,144 |
Wrong Answer
| 20 | 8,960 | 60 |
We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.
|
l=input()
l1=input()
l2=input()
a=l[0],l1[1],l2[2]
print(*a)
|
s601578745
|
Accepted
| 27 | 9,020 | 49 |
l=input()[0]
l+=input()[1]
l+=input()[2]
print(l)
|
s952919799
|
p02843
|
u337626942
| 2,000 | 1,048,576 |
Wrong Answer
| 30 | 9,008 | 65 |
AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible. (Ignore consumption tax.)
|
x = int(input())
if 100 <= x//100 <= 105: print(1)
else: print(0)
|
s920813113
|
Accepted
| 28 | 9,088 | 90 |
x = int(input())
cnt = x//100
if 100*cnt <= x <= 105*cnt:
print(1)
else:
print(0)
|
s970829075
|
p03478
|
u543954314
| 2,000 | 262,144 |
Wrong Answer
| 33 | 2,940 | 135 |
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)
|
s855167611
|
Accepted
| 33 | 2,940 | 135 |
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)
|
s858589342
|
p03455
|
u167501921
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 8 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
print(1)
|
s380120814
|
Accepted
| 17 | 2,940 | 101 |
ab = input().split()
a,b = int(ab[0]),int(ab[1])
if a*b % 2 ==1:
print("Odd")
else:
print("Even")
|
s927277584
|
p03251
|
u844902298
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 217 |
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
n,m,X,Y = list(map(int,input().split()))
x = list(map(int,input().split()))
y = list(map(int,input().split()))
if (X < Y) and max(x) <min(y) and max(x) <= X and min(y) >= Y:
print("No War")
else:
print("War")
|
s170328807
|
Accepted
| 17 | 3,060 | 200 |
n,m,X,Y = list(map(int,input().split()))
x = list(map(int,input().split()))
y = list(map(int,input().split()))
Z = min(min(y),Y)
if (X < Z) and max(x) < Z :
print("No War")
else:
print("War")
|
s713989151
|
p03798
|
u683134447
| 2,000 | 262,144 |
Wrong Answer
| 131 | 5,800 | 1,534 |
Snuke, who loves animals, built a zoo. There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1. There are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies. Snuke cannot tell the difference between these two species, and asked each animal the following question: "Are your neighbors of the same species?" The animal numbered i answered s_i. Here, if s_i is `o`, the animal said that the two neighboring animals are of the same species, and if s_i is `x`, the animal said that the two neighboring animals are of different species. More formally, a sheep answered `o` if the two neighboring animals are both sheep or both wolves, and answered `x` otherwise. Similarly, a wolf answered `x` if the two neighboring animals are both sheep or both wolves, and answered `o` otherwise. Snuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print `-1`.
|
import sys
a = int(input())
b = list(input())
frag = 0
parks = [list("ss"),list("sw"),list("ws"),list("ww")]
for park in parks:
for i in range(len(b)-2):
if b[i+1] == "o":
if park[i]=="s" and park[i+1]=="s":
park.append("s")
elif park[i]=="s" and park[i+1]=="w":
park.append("w")
elif park[i]=="w" and park[i+1]=="s":
park.append("w")
elif park[i]=="w" and park[i+1]=="w":
park.append("s")
elif b[i+1] == "x":
if park[i]=="s" and park[i+1]=="s":
park.append("w")
elif park[i]=="s" and park[i+1]=="w":
park.append("s")
elif park[i]=="w" and park[i+1]=="s":
park.append("s")
elif park[i]=="w" and park[i+1]=="w":
park.append("w")
if b[-1]=="o":
if park[-1] == "s":
if park[0]==park[-2]:
print (''.join(park))
frag = 1
break
if park[-1] == "w":
if park[0]!=park[-2]:
print (''.join(park))
frag = 1
break
if b[-1]=="x":
if park[-1] == "s":
if park[0]!=park[-2]:
print (''.join(park))
frag = 1
break
if park[-1] == "w":
if park[0]==park[-2]:
print (''.join(park))
frag = 1
break
if frag == 0:
print(-1)
|
s085220598
|
Accepted
| 243 | 7,384 | 2,051 |
a = int(input())
b = list(input())
frag = 0
parks = [list("SS"),list("SW"),list("WS"),list("WW")]
for park in parks:
for i in range(len(b)-2):
if b[i+1] == "o":
if park[i]=="S" and park[i+1]=="S":
park.append("S")
elif park[i]=="S" and park[i+1]=="W":
park.append("W")
elif park[i]=="W" and park[i+1]=="S":
park.append("W")
elif park[i]=="W" and park[i+1]=="W":
park.append("S")
elif b[i+1] == "x":
if park[i]=="S" and park[i+1]=="S":
park.append("W")
elif park[i]=="S" and park[i+1]=="W":
park.append("S")
elif park[i]=="W" and park[i+1]=="S":
park.append("S")
elif park[i]=="W" and park[i+1]=="W":
park.append("W")
frag2 = 0
if b[0]=="o":
if park[0] == "S":
if park[-1]==park[1]:
frag2 = 1
if park[0] == "W":
if park[-1]!=park[1]:
frag2 = 1
if b[0]=="x":
if park[0] == "S":
if park[-1]!=park[1]:
frag2 = 1
if park[0] == "W":
if park[-1]==park[1]:
frag2 = 1
if frag2 == 1:
if b[-1]=="o":
if park[-1] == "S":
if park[0]==park[-2]:
print (''.join(park))
frag = 1
break
if park[-1] == "W":
if park[0]!=park[-2]:
print (''.join(park))
frag = 1
break
if b[-1]=="x":
if park[-1] == "S":
if park[0]!=park[-2]:
print (''.join(park))
frag = 1
break
if park[-1] == "W":
if park[0]==park[-2]:
print (''.join(park))
frag = 1
break
if frag == 0:
print(-1)
|
s277872071
|
p02865
|
u504507648
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 96 |
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
|
n = int(input())
answer=0
if n % 2 == 0:
answer=n/2-1
else:
answer=(n-1)/2
print(answer)
|
s703456601
|
Accepted
| 18 | 2,940 | 101 |
n = int(input())
answer=0
if n % 2 == 0:
answer=n/2-1
else:
answer=(n-1)/2
print(int(answer))
|
s428336580
|
p02613
|
u589766880
| 2,000 | 1,048,576 |
Wrong Answer
| 149 | 9,168 | 323 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
deta = input()
if deta == 'AC':
AC += 1
elif deta == 'WA':
WA += 1
elif deta == 'WA':
TLE += 1
else :
RE += 1
print('AC x {}'.format(AC))
print('WA x {}'.format(WA))
print('TLE x {}'.format(TLE))
print('RE x {}'.format(RE))
|
s348624859
|
Accepted
| 145 | 8,924 | 323 |
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
deta = input()
if deta == 'AC':
AC += 1
elif deta == 'WA':
WA += 1
elif deta == 'TLE':
TLE += 1
else :
RE += 1
print('AC x {}'.format(AC))
print('WA x {}'.format(WA))
print('TLE x {}'.format(TLE))
print('RE x {}'.format(RE))
|
s651139673
|
p02619
|
u723304131
| 2,000 | 1,048,576 |
Wrong Answer
| 38 | 9,596 | 523 |
Let's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.
|
D = int(input())
c = list(map(int,input().split()))
s = [ [0 for j in range(26)] for i in range(D)]
for i in range(D):
tmp = list(map(int,input().split()))
for j in range(26):
s[i][j] = tmp[j]
t = []
for i in range(D):
t.append(int(input()))
v = [0] * D
last = [ [0 for j in range(26)] for i in range(D)]
sum = 0
for i in range(D):
sum += s[i][t[i]-1]
last[i][t[i]-1] = i+1
for j in range(26):
sum -= c[j] * ( (i+1) - last[i][j] )
v[i] = sum
for i in range(D):
print(v[i])
|
s137961866
|
Accepted
| 35 | 9,436 | 489 |
D = int(input())
c = list(map(int,input().split()))
s = [ [0 for j in range(26)] for i in range(D)]
for i in range(D):
tmp = list(map(int,input().split()))
for j in range(26):
s[i][j] = tmp[j]
t = []
for i in range(D):
t.append(int(input()))
v = [0] * D
last = [0] * 26
sat = 0
for d in range(D):
j = t[d] - 1
sat += s[d][j]
last[j] = d+1
for j in range(26):
sat -= c[j] * ( d + 1 - last[j] )
v[d] = sat
for i in range(D):
print(v[i])
|
s411774885
|
p03693
|
u591295155
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 71 |
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?
|
X, A, B = map(int, input().split())
print(["No", "Yes"][(A*10+B)%4==0])
|
s589991504
|
Accepted
| 18 | 2,940 | 71 |
X, A, B = map(int, input().split())
print(["NO", "YES"][(A*10+B)%4==0])
|
s488855669
|
p03737
|
u759412327
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 52 |
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.
|
s1,s2,s3 = input().split()
print((s1+s2+s3).upper())
|
s979518033
|
Accepted
| 27 | 8,928 | 61 |
s1,s2,s3 = input().split()
print((s1[0]+s2[0]+s3[0]).upper())
|
s650340436
|
p03457
|
u562935282
| 2,000 | 262,144 |
Wrong Answer
| 435 | 27,380 | 630 |
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.
|
def BlCannotGo(dt, dx, dy):
if (dt % 2) != ((dx + dy) % 2) or (dx + dy) > dt:
return True
else:
return False
if __name__ == '__main__':
n = int(input())
l = list(list(map(int, input().split())) for _ in range(n))
dt = l[0][0]
dx = l[0][1]
dy = l[0][2]
if BlCannotGo(dt, dx, dy):
print('NO')
exit()
for i in range(1,n):
dt = l[i][0] - l[i-1][0]
dx = l[i][1] - l[i-1][1]
dy = l[i][2] - l[i-1][2]
if BlCannotGo(dt, dx, dy):
print('NO')
exit()
print('YES')
|
s316254630
|
Accepted
| 165 | 3,064 | 436 |
def main():
import sys
input = sys.stdin.readline
N = int(input())
pt, px, py = 0, 0, 0
for _ in range(N):
t, x, y = map(int, input().split())
dt = t - pt
dx = abs(x - px)
dy = abs(y - py)
dl = dx + dy
if dt < dl or dl % 2 != dt % 2:
print('No')
return
pt, px, py = t, x, y
print('Yes')
if __name__ == '__main__':
main()
|
s637292633
|
p03623
|
u014333473
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 66 |
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
x,a,b=map(int,input().split());print(['a','b'][abs(x-a)>abs(x-b)])
|
s304151783
|
Accepted
| 27 | 9,088 | 64 |
x,a,b=map(int,input().split());print('AB'[abs(x-a)-abs(x-b)>=0])
|
s313688179
|
p03636
|
u377036395
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 50 |
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
s = input()
print(s[0] + str(len(s[-2])) + s[-1])
|
s168143952
|
Accepted
| 18 | 2,940 | 47 |
s = input()
print(s[0] + str(len(s)-2) + s[-1])
|
s686644045
|
p02612
|
u277236383
| 2,000 | 1,048,576 |
Wrong Answer
| 30 | 9,144 | 50 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input())
satu = n//1000
print(n-1000*satu)
|
s628533017
|
Accepted
| 32 | 9,156 | 103 |
n = int(input())
satu = n//1000
if n % 1000 == 0:
print(0)
quit()
ans = 1000*(satu+1)-n
print(ans)
|
s632483256
|
p03455
|
u513844316
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 89 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a,b=map(int,input().split())
if a//2==1 and b//2==1:
print('odd')
else:
print('even')
|
s496508496
|
Accepted
| 17 | 2,940 | 86 |
a,b=map(int,input().split())
if a%2==0 or b%2==0:
print('Even')
else:
print('Odd')
|
s902104699
|
p03447
|
u743272507
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,068 | 85 |
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
|
s = int(input())
s -= int(input())
b = int(input())
while s <= 0:
s -= b
print(s+b)
|
s701665999
|
Accepted
| 29 | 9,068 | 86 |
s = int(input())
s -= int(input())
b = int(input())
while s >= 0:
s -= b
print(s+b)
|
s255761500
|
p03852
|
u548303713
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 951 |
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
|
#ABC49-C
S=input()
divide=["dream","dreamer","erase","eraser"]
for i in range(4):
divide[i]=divide[i][::-1]
len_s=len(S)
S=S[::-1]
check=0
i=0
a=[]
while check==0:
if i==len_s:
a.append(1)
break
if len_s-i <5:
check=1
a.append(2)
break
if S[i:i+5] == divide[0]:
i=i+5
a.append(3)
continue
if S[i:i+5] == divide[2]:
i=i+5
a.append(4)
continue
if len_s-i <7:
check=1
a.append(5)
break
if S[i:i+7] == divide[1]:
i=i+7
a.append(6)
continue
if S[i:i+7] == divide[3]:
i=i+7
a.append(7)
continue
if check==0:
print("YES")
else:
print("NO")
#print(a)
|
s039228655
|
Accepted
| 17 | 2,940 | 117 |
k=["a","e","i","o","u"]
c=input()
if any(c==k[i] for i in range(5)):
print("vowel")
else:
print("consonant")
|
s978976109
|
p03456
|
u641804918
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 130 |
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
import math
a,b = input().split()
num = int(a + b)
print(num)
if math.sqrt(num) % 1 == 0:
print("Yes")
else:
print("No")
|
s387407669
|
Accepted
| 18 | 2,940 | 119 |
import math
a,b = input().split()
num = int(a + b)
if math.sqrt(num) % 1 == 0:
print("Yes")
else:
print("No")
|
s844568688
|
p03814
|
u453683890
| 2,000 | 262,144 |
Wrong Answer
| 91 | 3,516 | 143 |
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`.
|
line = input()
a = 20000000
z = 0
for i in range(len(line)):
if line[i] == 'A':
min(a,i)
elif line[i] == 'Z':
max(z,i)
print(z-a+1)
|
s441823800
|
Accepted
| 89 | 3,516 | 151 |
line = input()
a = 20000000
z = 0
for i in range(len(line)):
if line[i] == 'A':
a = min(a,i)
elif line[i] == 'Z':
z = max(z,i)
print(z-a+1)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.