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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s917410590
|
p03129
|
u343523393
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 141 |
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
|
N, K = map(int, input().split())
count = 1
for i in range(1,N,2):
count+=1
if(count >= K):
print("Yes")
else:
print("No")
|
s619430907
|
Accepted
| 17 | 2,940 | 209 |
N, K = map(int, input().split())
if(N%2==1):
if(N//2 + 1 >= K):
print("YES")
else:
print("NO")
else:
if(N//2 >= K):
print("YES")
else:
print("NO")
# print(N//2)
|
s381095769
|
p03478
|
u856169020
| 2,000 | 262,144 |
Wrong Answer
| 34 | 3,060 | 223 |
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).
|
def num_sum(L):
ret = 0
for l in L:
ret += int(l)
return ret
N, A, B = map(int, input().split())
ans = 0
for i in range(1, N+1):
num = num_sum(list(str(i)))
if A <= num and num <= B:
ans += num
print(ans)
|
s129711388
|
Accepted
| 33 | 3,064 | 221 |
def num_sum(L):
ret = 0
for l in L:
ret += int(l)
return ret
N, A, B = map(int, input().split())
ans = 0
for i in range(1, N+1):
num = num_sum(list(str(i)))
if A <= num and num <= B:
ans += i
print(ans)
|
s377934291
|
p03485
|
u617659131
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 55 |
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())
print(int(((a+b)/2)+1))
|
s709664761
|
Accepted
| 17 | 2,940 | 55 |
a,b = map(int, input().split())
print(int(((a+b+1)/2)))
|
s909539046
|
p02406
|
u340500592
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,560 | 128 |
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
|
n = int(input())
for i in range(1, n+1):
x = i
if x % 3 == 0:
print(" ")
while x:
if x % 10 == 3:
print(" ")
x /= 10
|
s258055856
|
Accepted
| 20 | 7,676 | 192 |
n = int(input())
cout = ""
for i in range(1, n+1):
x = i
if x % 3 == 0:
cout += " " + str(i)
else:
while x:
if x % 10 == 3:
cout += " " + str(i)
break
x //= 10
print(cout)
|
s678222340
|
p00002
|
u560214129
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,544 | 118 |
Write a program which computes the digit number of sum of two integers a and b.
|
a, b = map(int, input().split())
c=int(a+b)
count=0
while (c/10 != 0 ):
c=int(c/10)
count=count+1
print(count)
|
s104826804
|
Accepted
| 30 | 7,664 | 188 |
import sys
for line in sys.stdin.readlines():
a, b = map(int,line.split())
c=int(a+b)
count=0
while (c/10 != 0 ):
c=int(c/10)
count=count+1
print(count)
|
s360838436
|
p02646
|
u999750647
| 2,000 | 1,048,576 |
Wrong Answer
| 23 | 9,096 | 236 |
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
import sys
a = list(map(int,input().split()))
b = list(map(int,input().split()))
t = int(input())
if a[1] <= b[1]:
print('NO')
sys.exit()
elif abs(a[0]-b[0])//a[1]-b[1] <= t:
print('Yes')
sys.exit()
else:
print('NO')
|
s003191402
|
Accepted
| 21 | 9,116 | 240 |
import sys
a = list(map(int,input().split()))
b = list(map(int,input().split()))
t = int(input())
if a[1] <= b[1]:
print('NO')
sys.exit()
elif abs(a[0]-b[0])/abs(a[1]-b[1]) <= t:
print('YES')
sys.exit()
else:
print('NO')
|
s874772592
|
p04044
|
u989345508
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 91 |
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
|
n,l=input().split()
n,l=int(n),int(l)
s=sorted([input() for i in range(n)])
print(list(s))
|
s273941778
|
Accepted
| 17 | 3,060 | 86 |
n,l=map(int,input().split())
s=[input() for i in range(n)]
s.sort()
print("".join(s))
|
s053620920
|
p03861
|
u604412462
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 76 |
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
abx = list(map(int, input().split()))
print(abx[1]//abx[2] - abx[0]//abx[2])
|
s772417182
|
Accepted
| 18 | 3,060 | 154 |
abx = list(map(int, input().split()))
if abx[0]%abx[2]==0:
print(abx[1]//abx[2] - abx[0]//abx[2] + 1)
else:
print(abx[1]//abx[2] - abx[0]//abx[2])
|
s594665494
|
p03457
|
u643301782
| 2,000 | 262,144 |
Wrong Answer
| 351 | 3,064 | 306 |
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
n = int(input())
t1 = 0
x1 = 0
y1 = 0
count = 0
for _ in range(n):
t,x,y = map(int,input().split())
t = t - t1
x = x - x1
y = y - y1
if x + y <= t and x+y % 2 == t % 2:
t1 = t
x1 = x
y1 = y
count += 1
if count == n:
print("YES")
else:
print("NO")
|
s611045063
|
Accepted
| 388 | 3,060 | 332 |
n = int(input())
t1 = 0
x1 = 0
y1 = 0
count = 0
for _ in range(n):
t,x,y = map(int,input().split())
t = abs(t - t1)
x = abs(x - x1)
y = abs(y - y1)
if x + y <= t and (x+y) % 2 == t % 2:
t1 = t
x1 = x
y1 = y
count += 1
if count == n:
print("Yes")
else:
print("No")
|
s205652251
|
p03671
|
u006425112
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 104 |
Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
|
import sys
a, b, c = map(int, sys.stdin.readline().split())
m = max([a,b,c])
print(a + b + c - 2 * m)
|
s262291740
|
Accepted
| 17 | 2,940 | 100 |
import sys
a, b, c = map(int, sys.stdin.readline().split())
m = max([a,b,c])
print(a + b + c - m)
|
s015614518
|
p03473
|
u828277092
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 31 |
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
|
m = int(input())
print(24 + m)
|
s483063083
|
Accepted
| 17 | 2,940 | 38 |
m = int(input())
print(24 + (24 - m))
|
s438317623
|
p03007
|
u310233294
| 2,000 | 1,048,576 |
Wrong Answer
| 1,732 | 19,972 | 170 |
There are N integers, A_1, A_2, ..., A_N, written on a blackboard. We will repeat the following operation N-1 times so that we have only one integer on the blackboard. * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y. Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.
|
N = int(input())
A = list(map(int, input().split()))
A.sort()
xy = []
while(len(A)>1):
x = A.pop(-1)
y = A.pop(0)
xy.append([x, y])
A.append(x-y)
print(A)
|
s341550140
|
Accepted
| 1,798 | 21,760 | 836 |
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
AM = A.pop(0)
xy = []
if AM > 0 and A[-1] >= 0:
p = 1
elif AM <= 0 and A[-1] < 0:
p = 2
else:
p = 3
if p == 1:
while(len(A)>1):
x = A.pop(-1)
y = A.pop(0)
xy.append([x, y])
A.append(x-y)
xy.append([AM, A[0]])
ans = AM - A[0]
if p == 2:
while(len(A)>1):
x = AM
y = A.pop(-1)
xy.append([x, y])
AM -= y
xy.append([AM, A[0]])
ans = AM - A[0]
if p == 3:
while(len(A)>1):
y = A.pop(0)
if y >= 0:
x = A.pop(-1)
xy.append([x, y])
A.append(x-y)
else:
x = AM
xy.append([x, y])
AM -= y
xy.append([AM, A[0]])
ans = AM - A[0]
print(ans)
for out in xy:
print(*out)
|
s716154188
|
p03434
|
u209620426
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 167 |
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
n = int(input())
l = list(map(int, input().split()))
a = 0
b = 0
l.sort()
for i in range(n):
if i%2 == 0:
a += l[i]
else:
b += l[i]
print(a-b)
|
s593782719
|
Accepted
| 18 | 3,060 | 186 |
n = int(input())
l = list(map(int, input().split()))
a = 0
b = 0
l = sorted(l, reverse=True)
for i in range(n):
if i%2 == 0:
a += l[i]
else:
b += l[i]
print(a-b)
|
s513849561
|
p03457
|
u545644875
| 2,000 | 262,144 |
Wrong Answer
| 395 | 32,172 | 444 |
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
N = int(input())
A = [input().split() for _ in range(N)]
if N ==1:
n = int(A[0][0])
move = int(A[0][1]) + int(A[0][2])
if move > n or move%2 != n%2:
print("NO")
else:
print("YES")
for i in range(1,N):
H = int(A[i][1]) - int(A[i -1][1])
V = int(A[i][2]) - int(A[i -1][2])
move = H + V
n = int(A[i][0]) - int(A[i -1][0])
if move > n or move%2 != n%2:
print("NO")
break
elif i == N -1:
print("YES")
|
s078675974
|
Accepted
| 413 | 32,148 | 454 |
N = int(input())
A = [input().split() for _ in range(N)]
if N ==1:
n = int(A[0][0])
move = int(A[0][1]) + int(A[0][2])
if move > n or move%2 != n%2:
print("No")
else:
print("Yes")
for i in range(1,N):
H = abs(int(A[i][1]) - int(A[i -1][1]))
V = abs(int(A[i][2]) - int(A[i -1][2]))
move = H + V
n = int(A[i][0]) - int(A[i -1][0])
if move > n or move%2 != n%2:
print("No")
break
elif i == N -1:
print("Yes")
|
s473328256
|
p03556
|
u816631826
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 56 |
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
|
import math
n = int(input())
print(math.floor(n**0.5))
|
s167972693
|
Accepted
| 17 | 2,940 | 64 |
import math
n=int(input())
m=math.floor(math.sqrt(n))
print(m*m)
|
s379064355
|
p02415
|
u343251190
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,448 | 69 |
Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.
|
words = input().split()
for word in words:
print(word.swapcase())
|
s760542451
|
Accepted
| 40 | 7,520 | 39 |
words = input()
print(words.swapcase())
|
s720586667
|
p03599
|
u243699903
| 3,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 60 |
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the beaker. * Operation 3: Put C grams of sugar into the beaker. * Operation 4: Put D grams of sugar into the beaker. In our experimental environment, E grams of sugar can dissolve into 100 grams of water. Snuke will make sugar water with the highest possible density. The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted. We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.
|
a, b, c, d, e, f = map(int, input().split())
print(100,100)
|
s593501991
|
Accepted
| 36 | 3,064 | 1,308 |
a, b, c, d, e, f = map(int, input().split())
ans = (0, 0, 0)
for i in range(0, f // (100 * a) + 1):
for j in range(0, f // (100 * b) + 1):
if i == 0 and j == 0:
continue
waterV = 100 * a * i + 100 * b * j
if waterV > f:
break
leftVolume = f - waterV
satouMax = min((a*i + b*j) * e, leftVolume)
sMax = 0
for si in range(0, satouMax // c + 1):
blnOk = False
for sj in range(0, satouMax // d + 1):
satou = c * si + d * sj
if satou == satouMax:
sMax = satou
blnOk = True
break
if satou > satouMax:
break
sMax = max(sMax, satou)
if blnOk:
break
noudo = 100 * sMax / (waterV + sMax)
if ans[0] <= noudo:
ans = (noudo, waterV+sMax, sMax)
print(ans[1], ans[2])
|
s640627773
|
p03693
|
u278868910
| 2,000 | 262,144 |
Wrong Answer
| 22 | 3,572 | 122 |
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?
|
from functools import reduce
num = int(reduce(lambda a,b:a+b, input().split(), ""))
print('Yes' if num%4 == 0 else 'No')
|
s410380260
|
Accepted
| 22 | 3,572 | 122 |
from functools import reduce
num = int(reduce(lambda a,b:a+b, input().split(), ""))
print('YES' if num%4 == 0 else 'NO')
|
s447589456
|
p03565
|
u518064858
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 428 |
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
|
s=input()
t=input()
l=len(t)
a=[]
for i in range(l-1,len(s)):
x=s[len(s)-1-i:len(s)-1-i+l]
cnt=0
for j in range(l):
if x[j]=="?" or x[j]==t[j]:
cnt+=1
else:
break
if cnt==l:
u=s[:len(s)-1-i].replace("?","a")
v=s[len(s)-1-i+l:].replace("?","a")
key=u+t+v
a.append(key)
if len(a)==0:
print("UNRESTORABLE")
exit()
a=sorted(a)
print(a)
|
s747537808
|
Accepted
| 17 | 3,064 | 431 |
s=input()
t=input()
l=len(t)
a=[]
for i in range(l-1,len(s)):
x=s[len(s)-1-i:len(s)-1-i+l]
cnt=0
for j in range(l):
if x[j]=="?" or x[j]==t[j]:
cnt+=1
else:
break
if cnt==l:
u=s[:len(s)-1-i].replace("?","a")
v=s[len(s)-1-i+l:].replace("?","a")
key=u+t+v
a.append(key)
if len(a)==0:
print("UNRESTORABLE")
exit()
a=sorted(a)
print(a[0])
|
s044755878
|
p02602
|
u946648678
| 2,000 | 1,048,576 |
Wrong Answer
| 2,206 | 31,604 | 307 |
M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms: not given. * For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term. M-kun scored A_i in the exam at the end of the i-th term. For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is **strictly** greater than the grade for the (i-1)-th term.
|
n, k = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
p = 1
for i in range(k):
p *= arr[i]
grades = [p]
for i in range(k, n):
p /= arr[i-k]
p *= arr[k]
grades.append(p)
for i in range(1, len(grades)):
if grades[i] > grades[i-1]:
print("Yes")
else:
print("No")
|
s812764061
|
Accepted
| 161 | 31,616 | 179 |
n, k = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
for i in range(k, n):
if arr[i] > arr[i-k]:
print("Yes")
else:
print("No")
|
s220543460
|
p03493
|
u957799665
| 2,000 | 262,144 |
Wrong Answer
| 27 | 9,076 | 98 |
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
n_1 = 0
a = list(str(input()))
print(a)
for i in a:
if i == "1":
n_1 += 1
print(n_1)
|
s261116788
|
Accepted
| 31 | 8,996 | 89 |
n_1 = 0
a = list(str(input()))
for i in a:
if i == "1":
n_1 += 1
print(n_1)
|
s132308071
|
p03007
|
u327466606
| 2,000 | 1,048,576 |
Wrong Answer
| 262 | 14,484 | 1,396 |
There are N integers, A_1, A_2, ..., A_N, written on a blackboard. We will repeat the following operation N-1 times so that we have only one integer on the blackboard. * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y. Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.
|
import bisect
N = int(input())
A = sorted(map(int,input().split()))
i = bisect.bisect_left(A, 0)
j = bisect.bisect_right(A, 0)
if i == j:
if i == 0:
negatives = A[:1]
positives = A[1:]
elif i == N:
negatives = A[:-1]
positives = A[-1:]
else:
negatives = A[:i]
positives = A[i:]
else:
m = max((i+j)//2, 1)
negatives = A[:m]
positives = A[m:]
score = sum(positives) - sum(negatives)
print(score)
def it():
def balanced(pos, neg):
y = neg.pop()
x = pos.pop()
yield (x,y)
y = x-y
while pos and neg:
x = neg.pop()
yield (x,y)
y = x-y
x = pos.pop()
yield (x,y)
y = x-y
if len(positives) < len(negatives):
x = positives.pop()
while len(positives)+1 < len(negatives):
y = negatives.pop()
yield (x,y)
x -= y
positives.append(x)
for x,y in balanced(positives, negatives):
yield x,y
elif len(positives) > len(negatives):
x = negatives.pop()
while len(negatives)+1 < len(positives):
y = positives.pop()
yield (x,y)
x -= y
negatives.append(x)
for x,y in balanced(positives, negatives):
yield x,y
for x,y in it():
print(x,y)
|
s215014572
|
Accepted
| 132 | 32,916 | 857 |
from bisect import bisect
def solve():
N = int(input())
A = sorted(map(int,input().split()))
if N == 2:
res = [(max(A),min(A))]
s = max(A)-min(A)
return s, res
if A[0] >= 0:
res = []
x = A[0]
for a in A[1:-1]:
res.append((x,a))
x -= a
res.append((A[-1],x))
x = A[-1]-x
return (x,res)
if A[-1] <= 0:
res = []
x = A[-1]
for a in A[:-1]:
res.append((x,a))
x -= a
return (x,res)
res = []
p = bisect(A,0)-1
x = A[p]
for a in A[p+1:N-1]:
res.append((x,a))
x -= a
res.append((A[-1],x))
x = A[-1]-x
for a in A[:p]:
res.append((x,a))
x -= a
return (x,res)
s,res = solve()
print(s)
print('\n'.join(f'{a} {b}' for a,b in res))
|
s279527555
|
p02613
|
u046466256
| 2,000 | 1,048,576 |
Wrong Answer
| 148 | 9,104 | 315 |
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.
|
AC = 0
WA = 0
TLE = 0
RE = 0
N = int(input())
for i in range(N):
S = input()
if(S == "AC"):
AC+=1
elif(S == "WA"):
WA+=1
elif(S == "TLE"):
TLE+=1
elif(S == "RE"):
RE+=1
print("AC × " + str(AC) + "\nWA ×" + str(WA) + "\nTLE ×" + str(TLE) + "\nRE ×" + str(RE))
|
s268044459
|
Accepted
| 137 | 16,188 | 130 |
N = int(input())
s = [input() for i in range(N)]
for v in ['AC', 'WA', 'TLE', 'RE']:
print('{0} x {1}'.format(v, s.count(v)))
|
s552421071
|
p02659
|
u566574814
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 10,068 | 78 |
Compute A \times B, truncate its fractional part, and print the result as an integer.
|
from decimal import Decimal
a,b=map(Decimal,input().split())
print(round(a*b))
|
s802185654
|
Accepted
| 26 | 10,068 | 95 |
from decimal import Decimal
import math
a,b=map(Decimal,input().split())
print(math.floor(a*b))
|
s101468903
|
p03471
|
u310956674
| 2,000 | 262,144 |
Wrong Answer
| 1,991 | 21,244 | 236 |
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
N, Y = map(int, input().split())
for x in range(N+1):
for y in range(N+1-x):
z = N - x - y
if 10000*x + 5000*y + 1000*z == Y:
print(x, y, z)
exit()
else:
print(-1, -1, -1)
|
s613165151
|
Accepted
| 603 | 9,056 | 275 |
N, Y = map(int, input().split())
ansX = -1
ansY = -1
ansZ = -1
for x in range(N+1):
for y in range(N+1-x):
z = N - x - y
if 10000*x + 5000*y + 1000*z == Y:
ansX = x
ansY = y
ansZ = z
print(ansX, ansY, ansZ)
|
s461907545
|
p03697
|
u583326945
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 239 |
You are given two integers A and B as the input. Output the value of A + B. However, if A + B is 10 or greater, output `error` instead.
|
if __name__ == "__main__":
S = input()
result = "yes"
# for each character in S
for c in S:
# there is a same character in S
if S.count(c) > 1:
result = "no"
break
print(result)
|
s489659262
|
Accepted
| 17 | 2,940 | 138 |
if __name__ == "__main__":
A, B = map(int, input().split())
if A + B >= 10:
print("error")
else:
print(A + B)
|
s725027028
|
p03150
|
u942697937
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 182 |
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
|
S = input()
V = "keyence"
for i in range(len(S) - len(V) + 1):
print(i, S[:i], S[i-len(V):])
if S[:i] + S[i-len(V):] == V:
print("YES")
exit(0)
print("NO")
|
s344976994
|
Accepted
| 17 | 2,940 | 158 |
S = input()
V = "keyence"
t = len(S) - len(V)
for i in range(len(S) - t + 1):
if S[:i] + S[i+t:] == V:
print("YES")
exit(0)
print("NO")
|
s803792446
|
p02397
|
u587193722
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,620 | 110 |
Write a program which reads two integers x and y, and prints them in ascending order.
|
x ,y = [int(i) for i in input().split()]
if x <= y:
print(x,' ',y,sep='')
else:
print(y,' ',x,sep=' ')
|
s494155042
|
Accepted
| 60 | 7,660 | 186 |
while True:
x, y = [int(i) for i in input().split()]
if x > y:
print(y ,x)
elif x ==0 and y == 0:
break
else:
print(x,y)
|
s266119066
|
p03486
|
u547608423
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 491 |
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.
|
base=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
s=input()
t=input()
S=[]
T=[]
answer="No"
for i in s:
S.append(base.index(i))
for j in t:
T.append(base.index(j))
S=sorted(S)
T=sorted(T,reverse=True)
for k in range(min(len(S),len(T))):
if S[k]>T[k]:
answer="NO"
elif S[k]<T[k]:
answer="Yes"
if answer=="No" and len(S)<len(T):
answer="Yes"
elif answer=="NO":
answer="No"
print(answer)
|
s268710545
|
Accepted
| 17 | 3,064 | 559 |
base=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
s=input()
t=input()
S=[]
T=[]
answer="NO"
for i in s:
S.append(base.index(i))
for j in t:
T.append(base.index(j))
S=sorted(S)
T=sorted(T,reverse=True)
#print(S)
#print(T)
for k in range(min(len(S),len(T))):
if S[k]>T[k]:
answer="No"
break
elif S[k]<T[k]:
answer="Yes"
break
if answer=="NO" and len(S)<len(T):
answer="Yes"
elif answer=="NO" and len(S)>=len(T):
answer="No"
print(answer)
|
s281509352
|
p03555
|
u138781768
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 129 |
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
|
s_a = input()
s_b = input()
if s_a[0] == s_b[2] and s_a[2] == s_a[0] and s_a[1] == s_b[1]:
print("YES")
else:
print("NO")
|
s915833497
|
Accepted
| 17 | 2,940 | 129 |
s_a = input()
s_b = input()
if s_a[0] == s_b[2] and s_a[2] == s_b[0] and s_a[1] == s_b[1]:
print("YES")
else:
print("NO")
|
s359147613
|
p02600
|
u031722966
| 2,000 | 1,048,576 |
Wrong Answer
| 30 | 9,164 | 124 |
M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a _kyu_ (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have?
|
X = int(input())
A = 2000 - X
if A % 200 == 0:
print(str(A // 200) + "級")
else:
print(str(A // 200 + 1) + "級")
|
s770124343
|
Accepted
| 30 | 9,152 | 108 |
X = int(input())
A = 2000 - X
if A % 200 == 0:
print(str(A // 200))
else:
print(str(A // 200 + 1))
|
s474012816
|
p02612
|
u162565714
| 2,000 | 1,048,576 |
Wrong Answer
| 31 | 9,148 | 63 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n=int(input())
if n==0:
print('0')
else:
print(1000-n)
|
s933593685
|
Accepted
| 28 | 9,076 | 71 |
n=int(input())
n%=1000
if n==0:
print('0')
else:
print(1000-n)
|
s367239962
|
p02846
|
u619819312
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,064 | 347 |
Takahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east. They start simultaneously at the same point and moves as follows **towards the east** : * Takahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever. * Aoki runs B_1 meters per minute for the first T_1 minutes, then runs at B_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever. How many times will Takahashi and Aoki meet each other, that is, come to the same point? We do not count the start of the run. If they meet infinitely many times, report that fact.
|
a,b=map(int,input().split())
c,d=map(int,input().split())
e,f=map(int,input().split())
if (c>e and d>f) or (c<e and d<f):
print(0)
else:
if c<e:
c,d,e,f=e,f,c,d
s=(c-e)*a
t=(f-d)*b
if s>t:
print(0)
elif s==t:
print("infinity")
else:
print(int((s+t)/(t-s))-1-(1 if (s+t)%(t-s)==0 else 0))
|
s211334731
|
Accepted
| 17 | 3,064 | 350 |
a,b=map(int,input().split())
c,d=map(int,input().split())
e,f=map(int,input().split())
if (c>e and d>f) or (c<e and d<f):
print(0)
else:
if c<e:
c,d,e,f=e,f,c,d
s=(c-e)*a
t=(f-d)*b
if s>t:
print(0)
elif s==t:
print("infinity")
else:
print(int(s/(t-s))+int(t/(t-s))-(1 if s%(t-s)==0 else 0))
|
s497144130
|
p02613
|
u775278230
| 2,000 | 1,048,576 |
Wrong Answer
| 151 | 9,116 | 293 |
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())
j = [0] * 4
for i in range(n):
s=input()
if s == "AC":
j[0] += 1
elif s=="WA":
j[1] += 1
elif s=="TLE":
j[2] += 1
elif s == "RE":
j[3] += 1
for k in range(4):
print(f"AC × {j[k]}")
|
s333288077
|
Accepted
| 148 | 9,124 | 332 |
n = int(input())
j = [0] * 4
moji = ["AC", "WA", "TLE", "RE"]
for i in range(n):
s=input()
if s == "AC":
j[0] += 1
elif s=="WA":
j[1] += 1
elif s=="TLE":
j[2] += 1
elif s == "RE":
j[3] += 1
for k in range(4):
print(f"{moji[k]} x {j[k]}")
|
s802152301
|
p03455
|
u432853936
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 97 |
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")
|
s101656470
|
Accepted
| 17 | 2,940 | 97 |
a,b=map(int, input().split())
if a*b%2 == 0:
print("Even")
else:
print("Odd")
|
s972291933
|
p03543
|
u998835868
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 170 |
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
|
a = map(str,input())
a = list(a)
c = False
for x in range(2):
if a[x] == a[x+1]:
if a[x+1] == a[x+2]:
print("YES")
c=True
if c == False:
print("NO")
|
s306128756
|
Accepted
| 16 | 2,940 | 143 |
a = map(int,input())
a = list(a)
for x in range(2):
if a[x] == a[x+1]:
if a[x+1] == a[x+2]:
print("Yes")
exit()
print("No")
|
s316534519
|
p03455
|
u375870553
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 168 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
def main():
a, b = [int(i) for i in input().split()]
if a*b%2 == 0:
print("Odd")
else:
print("Even")
if __name__ == '__main__':
main()
|
s000890465
|
Accepted
| 17 | 2,940 | 168 |
def main():
a, b = [int(i) for i in input().split()]
if a*b%2 == 0:
print("Even")
else:
print("Odd")
if __name__ == '__main__':
main()
|
s534017024
|
p03303
|
u014139588
| 2,000 | 1,048,576 |
Wrong Answer
| 30 | 9,164 | 105 |
You are given a string S consisting of lowercase English letters. We will write down this string, starting a new line after every w letters. Print the string obtained by concatenating the letters at the beginnings of these lines from top to bottom.
|
s = input()
w = int(input())
ans = []
for i in range(len(s)//w):
ans.append(s[w*i])
print("".join(ans))
|
s019750772
|
Accepted
| 30 | 9,124 | 187 |
s = input()
w = int(input())
ans = []
if len(s)%w == 0:
for i in range(len(s)//w):
ans.append(s[w*i])
else:
for i in range(len(s)//w+1):
ans.append(s[w*i])
print("".join(ans))
|
s085442845
|
p02255
|
u405478089
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 310 |
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
def insertionSort(A,N):
for i in range(1,len(A)):
j = i
while (j > 0) and (A[j-1] > A[j]) :
tmp = A[j-1]
A[j-1] = A[j]
A[j] = tmp
j -= 1
print(' '.join(map(str, A)))
N = input()
N = int(N)
A = input()
A = list(map(int, A.split()))
insertionSort(A,N)
|
s947593802
|
Accepted
| 20 | 5,600 | 306 |
def insertionSort(A,N):
for i in range(N):
j = i
while (j > 0) and (A[j-1] > A[j]) :
tmp = A[j-1]
A[j-1] = A[j]
A[j] = tmp
j -= 1
print(' '.join(map(str, A)))
N = input()
N = int(N)
A = input()
A = list(map(int, A.split()))
insertionSort(A,N)
|
s371257976
|
p03339
|
u543954314
| 2,000 | 1,048,576 |
Wrong Answer
| 55 | 3,700 | 96 |
There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
|
n = int(input())
s = input()
d = {"E":0, "W":0}
for i in s:
d[i] += 1
print(min(d.values()))
|
s532845886
|
Accepted
| 126 | 3,676 | 132 |
n = int(input())
s = input()
c = s.count("E")
d = c
for i in s:
if i == "E":
d -= 1
else:
d += 1
c = min(c,d)
print(c)
|
s408013806
|
p03408
|
u702208001
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 250 |
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())
blue = [input() for _ in range(n)]
n = int(input())
red = [input() for _ in range(n)]
blue_set = list(set(blue))
count = 0
for i in blue_set:
if blue.count(i) >= red.count(i):
count += blue.count(i) - red.count(i)
print(count)
|
s010483167
|
Accepted
| 17 | 3,060 | 166 |
n=[input() for _ in range(int(input()))]
m=[input() for _ in range(int(input()))]
l=list(set(n))
print(max(0,max(n.count(l[i])-m.count(l[i]) for i in range(len(l)))))
|
s207358364
|
p02842
|
u234189749
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,064 | 273 |
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
|
N = int(input())
MIN = int(N/1.08)
MAX = int((N+1)/1.08)
if (MIN == MAX) and (int(MIN*1.08) == N):
print(MIN)
elif MIN == MAX:
print(":(")
for i in range(MIN,MAX+1):
if int(i* 1.08) == N:
print(i)
break
elif i == MAX:
print(":(")
|
s572058263
|
Accepted
| 17 | 3,064 | 139 |
N = int(input())
if N%1.08 ==0:
print(int(N//1.08))
elif int((N//1.08+1)*1.08) == N:
print(int(N//1.08) +1)
else:
print(":(")
|
s678677642
|
p03597
|
u256464928
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 47 |
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
|
N = int(input())
A = int(input())
print(N**N-A)
|
s077743202
|
Accepted
| 17 | 2,940 | 49 |
N = int(input())
A = int(input())
print((N**2)-A)
|
s419243963
|
p03992
|
u266874640
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 108 |
This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the first 4 letters and last 8 letters in the string s.
|
s = input()
t = 0
for i in s:
print(i, end = '')
t += 1
if t == 4:
print(' ', end = '')
|
s677976435
|
Accepted
| 17 | 2,940 | 118 |
s = input()
t = 0
for i in s:
print(i, end = '')
t += 1
if t == 4:
print(' ', end = '')
print('')
|
s849102212
|
p03563
|
u108784591
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 109 |
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.
|
N=int(input())
K=int(input())
ans=1
c=0
while c<N:
if ans<K:
ans=ans*2
else:
ans=ans+K
c+=1
print(ans)
|
s490260976
|
Accepted
| 17 | 2,940 | 46 |
R=int(input())
G=int(input())
a=2*G-R
print(a)
|
s483583296
|
p03853
|
u488934106
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 137 |
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
|
H , W = map(int, input().split())
Clist = [input().split() for i in range(H)]
for a in range(H):
print(Clist[a])
print(Clist[a])
|
s560926961
|
Accepted
| 18 | 3,060 | 140 |
H , W = map(int, input().split())
Clist = [input().split() for i in range(H)]
for a in range(H):
print(*Clist[a])
print(*Clist[a])
|
s182530771
|
p02659
|
u023229441
| 2,000 | 1,048,576 |
Wrong Answer
| 26 | 8,996 | 64 |
Compute A \times B, truncate its fractional part, and print the result as an integer.
|
a,b=map(float,input().split())
import math
print(math.ceil(a*b))
|
s436402459
|
Accepted
| 33 | 9,876 | 83 |
from decimal import Decimal as D
a,b=map(str,input().split())
print(int(D(a)*D(b)))
|
s315566947
|
p02411
|
u767368698
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,596 | 466 |
Write a program which reads a list of student test scores and evaluates the performance for each student. The test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1. The final performance of a student is evaluated by the following procedure: * If the student does not take the midterm or final examination, the student's grade shall be F. * If the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A. * If the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B. * If the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C. * If the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C. * If the total score of the midterm and final examination is less than 30, the student's grade shall be F.
|
def evl_score(m,f,r):
if m + f >= 80:
ret = 'A'
elif m + f >= 65 and m + f < 80:
ret = 'B'
elif m + f >= 50 and m + f < 65:
ret = 'C'
elif m + f >= 30 and m + f < 50:
if r >= 50:
ret = 'C'
else:
ret = 'D'
else:
ret = 'F'
return ret
m,f,r =[int(i) for i in input().split(' ')]
while m != -1:
m,f,r =[int(i) for i in input().split(' ')]
print(evl_score(m,f,r))
|
s541817434
|
Accepted
| 20 | 5,600 | 532 |
def evl_score(m,f,r):
if m == -1 or f == -1:
ret = 'F'
elif m + f >= 80:
ret = 'A'
elif m + f >= 65 and m + f < 80:
ret = 'B'
elif m + f >= 50 and m + f < 65:
ret = 'C'
elif m + f >= 30 and m + f < 50:
if r >= 50:
ret = 'C'
else:
ret = 'D'
else:
ret = 'F'
return ret
while True:
m,f,r =[int(i) for i in input().split(' ')]
if (m == -1 and f == -1 and r == -1):
break
print(evl_score(m,f,r))
|
s674072939
|
p03623
|
u051496905
| 2,000 | 262,144 |
Wrong Answer
| 25 | 9,036 | 127 |
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())
X = abs(a - x)
Y = abs(b - x)
Z = max(Y,X)
if Z == X:
print("A")
else:
print("B")
|
s471736298
|
Accepted
| 26 | 9,164 | 126 |
x , a ,b = map(int,input().split())
X = abs(a - x)
Y = abs(b - x)
Z = min(Y,X)
if Z == X:
print("A")
else:
print("B")
|
s343476581
|
p03435
|
u297103202
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,064 | 363 |
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct.
|
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
s = [c1,c2,c3]
print(s)
s1 = s[0][0] - s[0][1] - s[1][0] + s[1][1]
s2 = s[1][1] - s[1][2] - s[2][1] + s[2][2]
if s1== 0 and s2==0:
if s[0][0] + s[2][2] == s[0][2] + s[2][2]:
print('Yes')
else:
print('No')
else:
print('No')
|
s997154050
|
Accepted
| 18 | 3,060 | 253 |
s = []
for i in range(3):
s.append(list(map(int,input().split())))
s1 = s[0][0] - s[0][1] - s[1][0] + s[1][1]
s2 = s[1][1] - s[1][2] - s[2][1] + s[2][2]
s3 = s[0][0] - s[0][2] - s[2][0] + s[2][2]
print('Yes' if s1== 0 and s2==0 and s3==0 else 'No')
|
s357498194
|
p02927
|
u036531287
| 2,000 | 1,048,576 |
Wrong Answer
| 26 | 3,064 | 337 |
Today is August 24, one of the five Product Days in a year. A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day): * d_1 \geq 2 * d_{10} \geq 2 * d_1 \times d_{10} = m Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D. In Takahashi Calendar, how many Product Days does a year have?
|
k = 0
m,d = (int(i) for i in input().split())
listm = range(1,m+1)
listd = range(1,d)
for a in listm:
for b in listd:
dt = str(b)
da = dt[0]
da = int(da)
if len(dt) == 2:
db = dt[1]
db = int(db)
if db >= 2:
if da >= 2:
if a == da * db:
if a >= 2:
k = k + 1
print(a,"月",b,"日")
print(k)
|
s214287457
|
Accepted
| 33 | 3,060 | 343 |
k = 0
m,d = (int(i) for i in input().split())
listm = range(1,m + 1)
listd = range(1,d + 1)
for a in listm:
for b in listd:
if len(str(b)) >= 2:
if int(str(b)[0]) >= 2:
if int(str(b)[1]) >= 2:
#print(a,"y",b,"d")
if a == int(str(b)[0]) * int(str(b)[1]):
#print(a,"y",b,"d")
k = k + 1
print(k)
|
s720221649
|
p02747
|
u225845681
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 190 |
A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string.
|
S = input()
ans = 'No'
if len(S)%2 == 0:
for i in range(len(S)//2):
if S[i]+S[i+1] != 'hi':
break
elif i == (len(S)//2)-1:
ans = 'Yes'
print(ans)
|
s061517085
|
Accepted
| 17 | 2,940 | 197 |
S = input()
ans = 'No'
if len(S)%2 == 0:
for i in range(len(S)//2):
if S[2*i] + S[2*i+1] != 'hi':
break
elif i == (len(S)//2)-1:
ans = 'Yes'
print(ans)
|
s646619116
|
p03095
|
u368796742
| 2,000 | 1,048,576 |
Wrong Answer
| 57 | 9,156 | 168 |
You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings. Here, a subsequence of a string is a concatenation of **one or more** characters from the string without changing the order.
|
n = int(input())
s = input()
count = [0]*26
for i in s:
count[ord(i)-ord("a")] += 1
mod = 10**9+7
ans = 1
for i in count:
ans *= (i+1)
ans %= mod
print(ans)
|
s896173283
|
Accepted
| 52 | 9,288 | 170 |
n = int(input())
s = input()
count = [0]*26
for i in s:
count[ord(i)-ord("a")] += 1
mod = 10**9+7
ans = 1
for i in count:
ans *= (i+1)
ans %= mod
print(ans-1)
|
s658871052
|
p03943
|
u383508661
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 104 |
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
a,b,c=map(int,input().split())
Lis=[a,b,c]
sorted(Lis)
if a==b+c:
print("Yes")
else:
print("No")
|
s146414915
|
Accepted
| 18 | 2,940 | 89 |
a,b,c=sorted(map(int,input().split()))
if a+b==c:
print("Yes")
else:
print("No")
|
s738991841
|
p02238
|
u112247126
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,936 | 1,030 |
Depth-first search (DFS) follows the strategy to search ”deeper” in the graph whenever possible. In DFS, edges are recursively explored out of the most recently discovered vertex $v$ that still has unexplored edges leaving it. When all of $v$'s edges have been explored, the search ”backtracks” to explore edges leaving the vertex from which $v$ was discovered. This process continues until all the vertices that are reachable from the original source vertex have been discovered. If any undiscovered vertices remain, then one of them is selected as a new source and the search is repeated from that source. DFS timestamps each vertex as follows: * $d[v]$ records when $v$ is first discovered. * $f[v]$ records when the search finishes examining $v$’s adjacency list. Write a program which reads a directed graph $G = (V, E)$ and demonstrates DFS on the graph based on the following rules: * $G$ is given in an adjacency-list. Vertices are identified by IDs $1, 2,... n$ respectively. * IDs in the adjacency list are arranged in ascending order. * The program should report the discover time and the finish time for each vertex. * When there are several candidates to visit during DFS, the algorithm should select the vertex with the smallest ID. * The timestamp starts with 1.
|
from collections import deque
def dfs(root):
time = 1
stack.append(root)
color[root] = 'gray'
arrive[root] = time
time += 1
while len(stack) > 0:
node = stack[-1]
for next in range(n):
if adjMat[node][next] == 1:
if color[next] == 'white':
color[next] = 'gray'
arrive[next] = time
time += 1
stack.append(next)
break
# In case there in no adjacent node whose color is white
color[node] = 'black'
finish[node] = time
time += 1
stack.pop()
n = int(input())
adjMat = [[0] * n for _ in range(n)]
color = ['white'] * n
stack = deque()
arrive = [0] * n
finish = [0] * n
for _ in range(n):
adj = list(map(int, input().split()))
i = adj[0]
v = adj[2:]
for j in v:
adjMat[i - 1][j - 1] = 1
dfs(0)
for i in range(n):
out = ''
out += '{} {} {}'.format(i+1, arrive[i], finish[i])
print(out)
|
s969423393
|
Accepted
| 30 | 7,784 | 711 |
def dfs_recursive(u):
global time
color[u] = 'gray'
arrive[u] = time
time += 1
for v in range(n):
if adjMat[u][v] == 1 and color[v] == 'white':
dfs_recursive(v)
color[u] = 'black'
finish[u] = time
time += 1
n = int(input())
adjMat = [[0] * n for _ in range(n)]
color = ['white'] * n
arrive = [0] * n
finish = [0] * n
time = 1
for _ in range(n):
adj = list(map(int, input().split()))
i = adj[0]
v = adj[2:]
for j in v:
adjMat[i - 1][j - 1] = 1
for root in range(n):
if color[root] == 'white':
dfs_recursive(root)
for i in range(n):
out = ''
out += '{} {} {}'.format(i + 1, arrive[i], finish[i])
print(out)
|
s012926196
|
p03438
|
u125205981
| 2,000 | 262,144 |
Wrong Answer
| 25 | 4,600 | 269 |
You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal. Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions **simultaneously** : * Add 2 to a_i. * Add 1 to b_j.
|
def main():
N = int(input())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
asum = sum(A)
bsum = sum(B)
if A == B:
print(0)
elif asum > bsum:
print(-1)
else:
print(bsum - asum)
main()
|
s351963765
|
Accepted
| 23 | 4,600 | 334 |
def main():
N = int(input())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
la = 0
lb = 0
for a, b in zip(A, B):
if a > b:
la += a - b
elif a < b:
lb += (b - a) // 2
if la > lb:
print('No')
else:
print('Yes')
main()
|
s272934150
|
p03457
|
u615850856
| 2,000 | 262,144 |
Wrong Answer
| 405 | 3,064 | 1,429 |
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
N = int(input())
T = 0
X = Y = 0
Flag = 'Even'
for n in range(N):
Ti,Xi,Yi = [int(x) for x in input().split()]
if abs(Xi-X) + abs(Yi-Y) > (Ti-T):
print('NO')
break
else:
if Flag == 'Even':
if (Ti-T) % 2 == 0:#Even and Even = Even
if (Xi + Yi) % 2 == 0:
X = Xi
Y = Yi
T = Ti
continue
else:
print('NO')
break
else:#Even and Odd = Odd
if (Xi + Yi) % 2 == 0:
print('NO')
break
else:
X = Xi
Y = Yi
T = Ti
Flag = 'Odd'
continue
else:#Odd
if (Ti - T) % 2 == 0: #Odd and Even = Odd
if(Xi + Yi)% 2 == 0:
print('No')
break
else:
X = Xi
Y = Yi
T = Ti
continue
else: #Odd and Odd = Even
if(Xi + Yi) % 2 == 0:
X = Xi
Y = Yi
T = Ti
Flag = 'Even'
continue
else:
print('NO')
break
else:
print('YES')
|
s985676088
|
Accepted
| 411 | 3,064 | 1,429 |
N = int(input())
T = 0
X = Y = 0
Flag = 'Even'
for n in range(N):
Ti,Xi,Yi = [int(x) for x in input().split()]
if abs(Xi-X) + abs(Yi-Y) > (Ti-T):
print('No')
break
else:
if Flag == 'Even':
if (Ti-T) % 2 == 0:#Even and Even = Even
if (Xi + Yi) % 2 == 0:
X = Xi
Y = Yi
T = Ti
continue
else:
print('No')
break
else:#Even and Odd = Odd
if (Xi + Yi) % 2 == 0:
print('No')
break
else:
X = Xi
Y = Yi
T = Ti
Flag = 'Odd'
continue
else:#Odd
if (Ti - T) % 2 == 0: #Odd and Even = Odd
if(Xi + Yi)% 2 == 0:
print('No')
break
else:
X = Xi
Y = Yi
T = Ti
continue
else: #Odd and Odd = Even
if(Xi + Yi) % 2 == 0:
X = Xi
Y = Yi
T = Ti
Flag = 'Even'
continue
else:
print('No')
break
else:
print('Yes')
|
s536620996
|
p03761
|
u859897687
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,064 | 380 |
Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains. Find the longest string that can be created regardless of which string among S_1,...,S_n the headline contains. If there are multiple such strings, find the lexicographically smallest one among them.
|
n=int(input())
d=dict()
for i in input():
if i not in d:
d[i]=1
else:
d[i]+=1
for _ in range(n-1):
dd=dict()
for i in input():
if i not in dd:
dd[i]=1
else:
dd[i]+=1
for i in d.keys():
if i in dd:
d[i]=min(d[i],dd[i])
ans=[]
for i in d.keys():
for _ in range(d[i]):
ans.append(i)
ans.sort()
a=""
for i in ans:
a+=i
print(a)
|
s348003212
|
Accepted
| 19 | 3,064 | 403 |
n=int(input())
d=dict()
for i in input():
if i not in d:
d[i]=1
else:
d[i]+=1
for _ in range(n-1):
dd=dict()
for i in input():
if i not in dd:
dd[i]=1
else:
dd[i]+=1
for i in d.keys():
if i in dd:
d[i]=min(d[i],dd[i])
else:
d[i]=0
ans=[]
for i in d.keys():
for _ in range(d[i]):
ans.append(i)
ans.sort()
a=""
for i in ans:
a+=i
print(a)
|
s211568124
|
p02646
|
u470392120
| 2,000 | 1,048,576 |
Wrong Answer
| 21 | 9,204 | 136 |
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
#B
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
if (v-w)*t >= (b-a):
print('Yes')
else:
print('No')
|
s358376240
|
Accepted
| 24 | 9,184 | 155 |
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
if (v-w)*t >= abs(b-a):
ans='YES'
else:
ans='NO'
print(ans)
|
s428903791
|
p03523
|
u247211039
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 289 |
You are given a string S. Takahashi can insert the character `A` at any position in this string any number of times. Can he change S into `AKIHABARA`?
|
S = input()
S1 = "KIHABARA"
S2 = "AKIHBARA"
S3 = "AKIHABRA"
S4 = "AKIHABAR"
if S.find("KIHABARA") != -1:
print("YES")
elif S.find("AKIHBARA") != -1:
print("YES")
elif S.find("AKIHABRA") != -1:
print("YES")
elif S.find("AKIHABAR") != -1:
print("YES")
else:
print("No")
|
s521980538
|
Accepted
| 17 | 3,060 | 360 |
s = input()
if s == "KIHBR" or s == "KIHABARA" or s == "AKIHBARA" or s == "AKIHABRA" or s == "AKIHABAR" or \
s == "AKIHABARA" or s == "AKIHBR" or s == "KIHABR" or s == "KIHBAR" or s == "KIHBRA" or \
s == "AKIHABR" or s == "AKIHBAR" or s == "AKIHBRA" or s == "KIHABAR" or s == "KIHABRA" or s == "KIHBARA":
print("YES")
else:
print("NO")
|
s437392211
|
p03567
|
u029169777
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 109 |
Snuke built an online judge to hold a programming contest. When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.) Determine whether the judge can return the string `AC` as the verdict to a program.
|
S=input()
for i in range(len(S)-1):
if S[i]=='A' and S[i+1]=='C':
print('Yes')
else:
print('No')
|
s270225457
|
Accepted
| 17 | 2,940 | 109 |
S=input()
for i in range(len(S)-1):
if S[i]=='A' and S[i+1]=='C':
print('Yes')
exit()
print('No')
|
s525317183
|
p03795
|
u551109821
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 49 |
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())
b = int(n/15)
print(n*800-n*200)
|
s602136951
|
Accepted
| 18 | 2,940 | 49 |
n = int(input())
b = int(n/15)
print(n*800-b*200)
|
s065295578
|
p02665
|
u785578220
| 2,000 | 1,048,576 |
Wrong Answer
| 769 | 670,228 | 703 |
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.
|
a = int(input())
A = list(map(int,input().split()))
ch = [1]
cH = [1]
if A[0]>0:
print(-1)
exit()
for e,i in enumerate(A[1:]):
cH.append(cH[-1]*2-i)
# ch.append((cH[-1]*2)//(2**i))
# print(ch)
# print(cH)
# ch = ch[:-1]
# ch = ch[::-1]
# ch[0]*=2
# print(ch)
cH = cH[:-1]
cH.append(cH[-1]*2)
cH = cH[::-1]
# print(cH)
A = A[::-1]
ans = 0
n = 0
for e,i in enumerate(A[:-1]):
# print(n,ch[e],-1)
if i >cH[e]:
print(-1)
exit()
if n < cH[e]:
# print('ans:',ans,'n:',n)
ans += n+i
n+=i
else:
# print('ans:',ans,'ch:',cH[e],'i:',i)
ans +=cH[e]+i
n = cH[e]+i
# print('ans:',ans,'n:',n)
print('ans',ans+1)
|
s632623311
|
Accepted
| 793 | 670,020 | 794 |
a = int(input())
A = list(map(int,input().split()))
if a == 0 and A[0] == 1:
print(1)
exit()
ch = [1]
cH = [1]
if A[0]>0:
print(-1)
exit()
for e,i in enumerate(A[1:]):
cH.append(cH[-1]*2-i)
# ch.append((cH[-1]*2)//(2**i))
# print(ch)
# print(cH)
# ch = ch[:-1]
# ch = ch[::-1]
# ch[0]*=2
# print(ch)
cH = cH[:-1]
cH.append(cH[-1]*2)
cH = cH[::-1]
# print(cH)
if 0 in cH:
print(-1)
exit()
A = A[::-1]
ans = 0
n = 0
for e,i in enumerate(A[:]):
# print(n,ch[e],-1)
if n//2+(n%2!=0)>cH[e]:
print(-1)
exit()
if n <= cH[e]:
# print('ans:',ans,'n:',n)
ans += n+i
n+=i
else:
# print('ans:',ans,'ch:',cH[e],'i:',i)
ans +=cH[e]+i
n = cH[e]+i
# print('ans:',ans,'n:',n)
print(ans)
|
s832912004
|
p03836
|
u462626125
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,188 | 538 |
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
nums = [int(x) for x in input().split()]
sx,sy,tx,ty = nums[0],nums[1],nums[2],nums[3]
dx = tx - sx
dy = ty - sy
ans = []
# 1th
for i in range(dy):
ans.append("U")
for i in range(dx):
ans.append("R")
# 2nd
for i in range(dy):
ans.append("D")
for i in range(dx):
ans.append("L")
# 3rd
ans.append("L")
for i in range(dy+1):
ans.append("U")
for i in range(dx+1):
ans.append("R")
ans.append("D")
# 4th
ans.append("R")
for i in range(dy+1):
ans.append("D")
for i in range(dx+1):
ans.append("L")
ans.append("U")
|
s562225117
|
Accepted
| 19 | 3,192 | 560 |
nums = [int(x) for x in input().split()]
sx,sy,tx,ty = nums[0],nums[1],nums[2],nums[3]
dx = tx - sx
dy = ty - sy
ans = []
# 1th
for i in range(dy):
ans.append("U")
for i in range(dx):
ans.append("R")
# 2nd
for i in range(dy):
ans.append("D")
for i in range(dx):
ans.append("L")
# 3rd
ans.append("L")
for i in range(dy+1):
ans.append("U")
for i in range(dx+1):
ans.append("R")
ans.append("D")
# 4th
ans.append("R")
for i in range(dy+1):
ans.append("D")
for i in range(dx+1):
ans.append("L")
ans.append("U")
print("".join(ans))
|
s206561042
|
p03387
|
u569742427
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,188 | 267 |
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
|
data=[int(_) for _ in input().split()]
data.sort()
A=data[2]
B=data[1]
C=data[0]
count=0
print(A,B,C)
while A!=B:
B+=1
C+=1
count+=1
print(A,B,C)
while C<B:
C+=2
count+=1
print(A,B,C)
if B==C:
print(count)
else:
print(count+1)
|
s284244583
|
Accepted
| 18 | 3,060 | 223 |
data=[int(_) for _ in input().split()]
data.sort()
A=data[2]
B=data[1]
C=data[0]
count=0
while A!=B:
B+=1
C+=1
count+=1
while C<B:
C+=2
count+=1
if B==C:
print(count)
else:
print(count+1)
|
s474714264
|
p03455
|
u293198424
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 120 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
num = [int(i) for i in input().split()]
number = num[0]* num[1]
if number%2==0:
print("Odd")
else:
print("Even")
|
s401922780
|
Accepted
| 17 | 2,940 | 120 |
num = [int(i) for i in input().split()]
number = num[0]* num[1]
if number%2==0:
print("Even")
else:
print("Odd")
|
s978712479
|
p03573
|
u391328897
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 63 |
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
|
abc = list(map(int, input().split()))
print(list(set(abc))[0])
|
s432785894
|
Accepted
| 17 | 2,940 | 112 |
a, b, c = map(int, input().split())
if a == b:
print(c)
elif a == c:
print(b)
elif b == c:
print(a)
|
s588907660
|
p03047
|
u839953865
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 2,940 | 43 |
Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers?
|
[a,b]=map(int,input().split())
print(b-a+1)
|
s335289852
|
Accepted
| 17 | 2,940 | 43 |
[a,b]=map(int,input().split())
print(a-b+1)
|
s557359453
|
p03369
|
u776871252
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 87 |
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
|
a = list(input())
ans = 700
for i in a:
if i == "+":
ans += 100
print(ans)
|
s084194137
|
Accepted
| 17 | 2,940 | 87 |
a = list(input())
ans = 700
for i in a:
if i == "o":
ans += 100
print(ans)
|
s988664899
|
p03730
|
u480568292
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 165 |
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
a,b,c = map(int,input().split())
count = 0
for i in range(1000):
s = a*i
if s%b == c:
count+=1
break
else:
pass
print("Yes" if count>0 else "No")
|
s573429929
|
Accepted
| 18 | 2,940 | 165 |
a,b,c = map(int,input().split())
count = 0
for i in range(1000):
s = a*i
if s%b == c:
count+=1
break
else:
pass
print("YES" if count>0 else "NO")
|
s988690938
|
p03455
|
u552290152
| 2,000 | 262,144 |
Wrong Answer
| 17 | 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==0 or b%2==0:
print("even")
else:
print("odd")
|
s127885823
|
Accepted
| 20 | 3,060 | 89 |
a,b = map(int, input().split())
if a%2==0 or b%2==0:
print("Even")
else:
print("Odd")
|
s395466050
|
p02694
|
u599669731
| 2,000 | 1,048,576 |
Wrong Answer
| 20 | 9,160 | 117 |
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
import math
x=int(input())
a=100
for i in range(3761):
a=int(1.01*a)
if a>x:
print(i+1)
break
|
s111458938
|
Accepted
| 21 | 9,164 | 118 |
import math
x=int(input())
a=100
for i in range(1,3761):
a=int(1.01*a)
if a>=x:
print(i)
break
|
s971152687
|
p00011
|
u187646742
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,708 | 246 |
Let's play Amidakuji. In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines. In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom. Your task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., w are assigne to the vertical lines from left to right.
|
stick = [i for i in range(1, int(input()) + 1)]
net = int(input())
for _ in range(net):
a, b = list(map(int, input().split(",")))
stick[a - 1], stick[b - 1] = stick[b - 1], stick[a - 1]
print(stick)
print("\n".join(map(str, stick)))
|
s074781986
|
Accepted
| 30 | 7,688 | 224 |
stick = [i for i in range(1, int(input()) + 1)]
net = int(input())
for _ in range(net):
a, b = list(map(int, input().split(",")))
stick[a - 1], stick[b - 1] = stick[b - 1], stick[a - 1]
for v in stick:
print(v)
|
s961843593
|
p02613
|
u810356688
| 2,000 | 1,048,576 |
Wrong Answer
| 60 | 9,228 | 503 |
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.
|
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
n = int(input())
ac, wa, tle, re =0, 0, 0, 0
for i in range(n):
s = input()
if s == "AC":
ac += 1
elif s == "WA":
wa += 1
elif s == "TLE":
tle += 1
else:
re += 1
print("AC X {}".format(ac))
print("WA X {}".format(wa))
print("TLE X {}".format(tle))
print("RE X {}".format(re))
if __name__=='__main__':
main()
|
s602329882
|
Accepted
| 60 | 9,220 | 503 |
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
n = int(input())
ac, wa, tle, re =0, 0, 0, 0
for i in range(n):
s = input()
if s == "AC":
ac += 1
elif s == "WA":
wa += 1
elif s == "TLE":
tle += 1
else:
re += 1
print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))
if __name__=='__main__':
main()
|
s790793758
|
p03693
|
u643840641
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 72 |
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
r, g, b = map(int, input().split())
print("YES" if (g+b)%4==0 else "NO")
|
s018841819
|
Accepted
| 18 | 2,940 | 75 |
r, g, b = map(int, input().split())
print("YES" if (10*g+b)%4==0 else "NO")
|
s444353941
|
p03681
|
u863442865
| 2,000 | 262,144 |
Wrong Answer
| 51 | 3,188 | 320 |
Snuke has N dogs and M monkeys. He wants them to line up in a row. As a Japanese saying goes, these dogs and monkeys are on bad terms. _("ken'en no naka", literally "the relationship of dogs and monkeys", means a relationship of mutual hatred.)_ Snuke is trying to reconsile them, by arranging the animals so that there are neither two adjacent dogs nor two adjacent monkeys. How many such arrangements there are? Find the count modulo 10^9+7 (since animals cannot understand numbers larger than that). Here, dogs and monkeys are both distinguishable. Also, two arrangements that result from reversing each other are distinguished.
|
n, m = list(map(int, input().split()))
ans = 1
a = lambda x, y: x*y % (10**9+7)
if n==m:
for i in range(1, n+1):
a(ans, i)
print((ans**2*2)%(10**9+7))
elif abs(n-m)==1:
for i in range(1, n+1):
a(ans, i)
for i in range(1, m+1):
a(ans, i)
print(ans%(10**9+7))
else:
print(0)
|
s763595633
|
Accepted
| 68 | 3,064 | 339 |
n, m = list(map(int, input().split()))
ans = 1
mod = 10**9+7
def a(x, y):
return x*y%mod
if n==m:
for i in range(1, n+1):
ans = a(ans, i)
print((ans**2*2)%(mod))
elif abs(n-m)==1:
for i in range(1, n+1):
ans = a(ans, i)
for i in range(1, m+1):
ans = a(ans, i)
print(ans)
else:
print(0)
|
s998573205
|
p03155
|
u021548497
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 73 |
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board. The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns. How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?
|
n = int(input())
h = int(input())
w = int(input())
print((w-h+1)*(n-h+1))
|
s106687537
|
Accepted
| 17 | 2,940 | 73 |
n = int(input())
h = int(input())
w = int(input())
print((n-w+1)*(n-h+1))
|
s235159147
|
p03712
|
u289792007
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 158 |
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
|
h, w = map(int, input().split())
img = ['*' * (w+2)]
for i in range(0, h):
img.append('*' + input() + '*')
img.append('*' * (w+2))
[print(i) for i in img]
|
s571923339
|
Accepted
| 18 | 3,060 | 158 |
h, w = map(int, input().split())
img = ['#' * (w+2)]
for i in range(0, h):
img.append('#' + input() + '#')
img.append('#' * (w+2))
[print(i) for i in img]
|
s754843637
|
p04043
|
u578722729
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 148 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
ABC=input().split()
five_count=ABC.count("5")
seven_count=ABC.count("7")
if five_count == 2 and seven_count==1:
print("Yes")
else:
print("NO")
|
s605170123
|
Accepted
| 17 | 2,940 | 150 |
ABC=input().split()
five_count=ABC.count("5")
seven_count=ABC.count("7")
if five_count == 2 and seven_count == 1:
print("YES")
else:
print("NO")
|
s065870373
|
p03251
|
u374929478
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 228 |
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 =(int(x) for x in input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = []
z = range(X+1,Y+1)
if min(z) > max(x) and max(z) <= min(y):
print('No War')
else:
print('War')
|
s467862057
|
Accepted
| 18 | 3,060 | 252 |
n, m, X, Y =(int(x) for x in input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
for z in range(X+1,Y+1):
if z > max(x) and z <= min(y):
print('No War')
break
if z == Y:
print('War')
|
s300817733
|
p03162
|
u106166456
| 2,000 | 1,048,576 |
Wrong Answer
| 679 | 33,792 | 480 |
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains.
|
def chmax_a(l,B,C,i):
return max(B+l[i][1],C+l[i][2])
def chmax_b(l,A,C,i):
return max(A+l[i][0],C+l[i][2])
def chmax_c(l,A,B,i):
return max(B+l[i][1],A+l[i][0])
N=int(input())
happiness=[]
for i in range(N):
cost=list(map(int,input().split()))
happiness.append(cost)
answers=[]
A=0
B=0
C=0
for i in range(N-1,-1,-1):
a=chmax_a(happiness,B,C,i)
b=chmax_b(happiness,A,C,i)
c=chmax_c(happiness,A,B,i)
A=a
B=b
C=c
print('{0}, {1}, {2}'.format(A,B,C))
print(max(A,B,C))
|
s454284225
|
Accepted
| 1,060 | 47,328 | 412 |
if __name__=='__main__':
N=int(input())
happiness=[]
for i in range(N):
cost=list(map(int,input().split()))
happiness.append(cost)
dp=[[0 for j in range(3)] for i in range(N+1)]
#j:0 is from A, 1 is from B, 2 is from C
for i in range(N):
for j in range(3):
for k in range(3):
if j != k:
dp[i+1][k] = max(dp[i+1][k], dp[i][j]+happiness[i][k])
else:
continue
print(max(dp[-1]))
|
s786644980
|
p03473
|
u069744971
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 30 |
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
|
a = int(input())
print(a-48)
|
s535462927
|
Accepted
| 17 | 2,940 | 30 |
a = int(input())
print(48-a)
|
s084435723
|
p03437
|
u981931040
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,092 | 61 |
You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
|
a, b = map(int, input().split())
print(a if a != b else '=1')
|
s034812045
|
Accepted
| 25 | 9,036 | 112 |
a, b = map(int, input().split())
ans = -1
for i in range(1, 4):
if a * i % b != 0:
ans = a * i
print(ans)
|
s819927157
|
p03069
|
u457901067
| 2,000 | 1,048,576 |
Wrong Answer
| 214 | 15,616 | 352 |
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.
|
N = int(input())
S = input()
cumdots = [0] * (N+1)
for i in range(N):
cumdots[i+1] = cumdots[i] + (1 if S[i]=="." else 0)
print(cumdots)
hands = N+1
for i in range(N):
leftops = i - cumdots[i]
rightops = cumdots[N] - cumdots[i+1]
hands = min(hands, leftops + rightops)
print(hands)
|
s081789682
|
Accepted
| 208 | 11,144 | 353 |
N = int(input())
S = input()
cumdots = [0] * (N+1)
for i in range(N):
cumdots[i+1] = cumdots[i] + (1 if S[i]=="." else 0)
#print(cumdots)
hands = N+1
for i in range(N):
leftops = i - cumdots[i]
rightops = cumdots[N] - cumdots[i+1]
hands = min(hands, leftops + rightops)
print(hands)
|
s974708009
|
p02264
|
u591875281
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,964 | 700 |
_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.
|
from collections import deque
def round_robin_scheduling(N, Q, A):
time = 0
finished_process = []
while A:
process = A.popleft()
if process[1] < Q:
time += process[1]
finished_process.append([process[0],time])
else:
time += Q
A.append([process[0],process[1]-Q])
else:
return finished_process
if __name__ == '__main__':
N,Q = map(int,input().split())
A = deque()
for i in range(N):
a = input()
A.append([a.split()[0],int(a.split()[1])])
answer = round_robin_scheduling(N,Q,A)
for x in answer:
print (x[0], x[1])
|
s498035753
|
Accepted
| 280 | 16,208 | 517 |
# encoding: utf-8
from collections import deque
def round_robin_scheduling(N, Q, A):
t = 0
while A:
process = A.popleft()
if process[1] <= Q:
t += process[1]
print(process[0],t)
else:
t += Q
A.append([process[0],process[1]-Q])
if __name__ == '__main__':
N,Q = map(int,input().split())
A = deque()
for i in range(N):
a = input()
A.append([a.split()[0],int(a.split()[1])])
round_robin_scheduling(N,Q,A)
|
s245370929
|
p03470
|
u818655004
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 299 |
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
A_cards = []
B_cards = []
flag = 'A'
for card in A:
if flag == 'A':
flag = 'B'
A_cards.append(card)
elif flag == 'B':
flag = 'A'
B_cards.append(card)
print(sum(A_cards) - sum(B_cards))
|
s192255136
|
Accepted
| 17 | 2,940 | 160 |
N = int(input())
d_list = [int(input()) for i in range(N)]
result = {}
for i in d_list:
result.setdefault(i, 0)
result[i] += 1
print(len(result.keys()))
|
s416037580
|
p03351
|
u838350081
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,064 | 576 |
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.
|
class Position():
def __init__(self, posi, dist):
self.pos = posi
self.d = dist
def is_talk(self, tar_pos):
if abs(self.pos - tar_pos) <= self.d:
return True
else:
return False
if __name__ == '__main__':
a, b, c, d = [int(_) for _ in input().split()]
print(a, b, c, d)
p1 = Position(a, d)
p2 = Position(b, d)
p3 = Position(c, d)
if p1.is_talk(p3.pos):
print("Yes")
elif p1.is_talk(p2.pos) and p2.is_talk(p3.pos):
print("Yes")
else:
print("No")
|
s664767216
|
Accepted
| 18 | 3,064 | 554 |
class Position():
def __init__(self, posi, dist):
self.pos = posi
self.d = dist
def is_talk(self, tar_pos):
if abs(self.pos - tar_pos) <= self.d:
return True
else:
return False
if __name__ == '__main__':
a, b, c, d = [int(_) for _ in input().split()]
p1 = Position(a, d)
p2 = Position(b, d)
p3 = Position(c, d)
if p1.is_talk(p3.pos):
print("Yes")
elif p1.is_talk(p2.pos) and p2.is_talk(p3.pos):
print("Yes")
else:
print("No")
|
s052787082
|
p03574
|
u853900545
| 2,000 | 262,144 |
Wrong Answer
| 26 | 3,064 | 314 |
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
|
h,w = map(int,input().split())
s = [input() for _ in range(h)]
for i in range(h):
l = ''
for j in range(w):
if s[i][j] == '#':
l += s[i][j]
else:
l += str(sum([t[max(0,j-1):min(j+2,w)].count('#')\
for t in s[max(0,i):min(h,i+2)]]))
print(l)
|
s819547840
|
Accepted
| 28 | 3,064 | 316 |
h,w = map(int,input().split())
s = [input() for _ in range(h)]
for i in range(h):
l = ''
for j in range(w):
if s[i][j] == '#':
l += s[i][j]
else:
l += str(sum([t[max(0,j-1):min(j+2,w)].count('#')\
for t in s[max(0,i-1):min(h,i+2)]]))
print(l)
|
s104319541
|
p03433
|
u260036763
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 91 |
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
N = int(input())
A = int(input())
if (N - A) % 500 == 0:
print('Yes')
else:
print('No')
|
s434397224
|
Accepted
| 17 | 2,940 | 87 |
n = int(input())
a = int(input())
if (n % 500) <= a:
print('Yes')
else:
print('No')
|
s245783518
|
p01554
|
u741801763
| 2,000 | 131,072 |
Wrong Answer
| 20 | 7,652 | 420 |
ある部屋ではICカードを用いて鍵を開け閉めする電子錠システムを用いている。 このシステムは以下のように動作する。 各ユーザーが持つICカードを扉にかざすと、そのICカードのIDがシステムに渡される。 システムはIDが登録されている時、施錠されているなら開錠し、そうでないのなら施錠し、それぞれメッセージが出力される。 IDが登録されていない場合は、登録されていないというメッセージを出力し、開錠及び施錠はおこなわれない。 さて、現在システムにはN個のID(U1, U2, ……, UN)が登録されており、施錠されている。 M回ICカードが扉にかざされ、そのIDはそれぞれ順番にT1, T2, ……, TMであるとする。 この時のシステムがどのようなメッセージを出力するか求めよ。
|
if __name__ == '__main__':
n = int(input())
reg = []
for _ in range(n):
reg.append(input())
m = int(input())
state = 0
for _ in range(m):
p = input()
if p in reg and not state:
print("Opened by %s" % (p))
state = 1
elif p in reg and state:
print("Closed by %s" % (p))
state = 0
else:print("Unkown %s" % (p))
|
s261242373
|
Accepted
| 70 | 7,732 | 421 |
if __name__ == '__main__':
n = int(input())
reg = []
for _ in range(n):
reg.append(input())
m = int(input())
state = 0
for _ in range(m):
p = input()
if p in reg and not state:
print("Opened by %s" % (p))
state = 1
elif p in reg and state:
print("Closed by %s" % (p))
state = 0
else:print("Unknown %s" % (p))
|
s650880247
|
p03574
|
u036340997
| 2,000 | 262,144 |
Wrong Answer
| 37 | 3,700 | 537 |
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.
|
hw = input().split()
h = int(hw[0])
w = int(hw[1])
field = []
for i in range(h):
field.append(input())
ans_field = []
for i in range(h):
ans_field.append('')
for j in range(w):
s = ''
peris = [[i-1, j-1], [i-1, j], [i-1, j+1], [i, j-1], [i, j+1], [i+1, j-1], [i+1, j], [i+1, j+1]]
for peri in peris:
try:
s += field[peri[0]][peri[1]]
except:
pass
sharp = 0
for letter in s:
if letter=='#':
sharp += 1
ans_field += str(sharp)
for i in range(h):
print(ans_field)
|
s334436342
|
Accepted
| 32 | 3,064 | 750 |
hw = input().split()
h = int(hw[0])
w = int(hw[1])
field = []
for i in range(h):
field.append(input())
ans_field = []
for i in range(h):
ans_field.append('')
for j in range(w):
if field[i][j]=='.':
s = ''
peris = [[i-1, j-1], [i-1, j], [i-1, j+1], [i, j-1], [i, j+1], [i+1, j-1], [i+1, j], [i+1, j+1]]
for peri in peris:
if peri[0]!=-1 and peri[1]!=-1:
try:
s += field[peri[0]][peri[1]]
except:
pass
sharp = 0
for letter in s:
if letter=='#':
sharp += 1
ans_field[i] += str(sharp)
else:
ans_field[i] += '#'
for i in range(h):
print(ans_field[i])
|
s873497793
|
p03719
|
u332385682
| 2,000 | 262,144 |
Wrong Answer
| 25 | 3,444 | 229 |
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
import sys
from collections import Counter
sys.setrecursionlimit(10**7)
inf = 1<<100
def solve():
a, b, c = map(int, input().split())
print('YES' if a <= c <= b else 'NO')
if __name__ == '__main__':
solve()
|
s407081395
|
Accepted
| 17 | 2,940 | 152 |
import sys
def solve():
a, b, c = map(int, input().split())
print('Yes' if a <= c <= b else 'No')
if __name__ == '__main__':
solve()
|
s898368533
|
p02742
|
u193927973
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 261 |
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
h, w=map(int, input().split())
if h%2==0:
print(h*w/2)
else:
set1=h
if w%2==0:
print(set1*w/2)
else:
rm=w//2
print(set1*rm+h//2+1)
|
s207063093
|
Accepted
| 18 | 2,940 | 134 |
h, w=map(int, input().split())
if h==1 or w==1:
print(1)
else:
ans=(h*w)//2
if h*w%2==1:
print(ans+1)
else:
print(ans)
|
s660500625
|
p02398
|
u936401118
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,556 | 125 |
Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.
|
a, b, c = map (int, input().split())
count = 0
for i in range(a+1, b+1):
if c % i == 0:
count += 1
print (count)
|
s740135072
|
Accepted
| 60 | 7,700 | 123 |
a, b, c = map (int, input().split())
count = 0
for i in range(a, b+1):
if c % i == 0:
count += 1
print (count)
|
s816923190
|
p03993
|
u414809621
| 2,000 | 262,144 |
Wrong Answer
| 91 | 14,008 | 193 |
There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a _friendly pair_ if the following condition is met. * Rabbit i likes rabbit j and rabbit j likes rabbit i. Calculate the number of the friendly pairs.
|
N = int(input())
a = list(map(int,input().split()))
print(a)
ans=0
for i, v in enumerate(a):
if v != None:
if a[v-1] == i+1:
ans+=1
a[v-1] = None
print(ans)
|
s649647831
|
Accepted
| 88 | 14,008 | 184 |
N = int(input())
a = list(map(int,input().split()))
ans=0
for i, v in enumerate(a):
if v != None:
if a[v-1] == i+1:
ans+=1
a[v-1] = None
print(ans)
|
s047935830
|
p03455
|
u743852057
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 103 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a,b = input().split()
result = int(a)*int(b)
if result%2 == 0:
print("even")
else:
print("odd")
|
s610628239
|
Accepted
| 17 | 2,940 | 103 |
a,b = input().split()
result = int(a)*int(b)
if result%2 == 0:
print("Even")
else:
print("Odd")
|
s736024577
|
p02842
|
u497952650
| 2,000 | 1,048,576 |
Wrong Answer
| 33 | 2,940 | 105 |
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
|
N = int(input())
for i in range(0,50001):
if int(i*1.08)==N:
print(N)
exit()
print(":(")
|
s666705063
|
Accepted
| 31 | 2,940 | 104 |
N = int(input())
for i in range(0,N+1):
if int(i*1.08)==N:
print(i)
exit()
print(":(")
|
s308161314
|
p04035
|
u445624660
| 2,000 | 262,144 |
Wrong Answer
| 98 | 19,824 | 560 |
We have N pieces of ropes, numbered 1 through N. The length of piece i is a_i. At first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly: * Choose a (connected) rope with a total length of at least L, then untie one of its knots. Is it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.
|
n, l = map(int, input().split())
a = list(map(int, input().split()))
idx = 0
for i in range(1, n):
if a[i - 1] + a[i] >= l:
idx = i
break
if idx == 0:
print("impossibe")
exit()
print("possible")
ans = [idx]
for i in range(idx - 1, 0, -1):
ans.append(i)
for i in range(idx + 1, n):
ans.append(i)
for a in ans[::-1]:
print(a)
|
s566401464
|
Accepted
| 97 | 19,996 | 561 |
n, l = map(int, input().split())
a = list(map(int, input().split()))
idx = 0
for i in range(1, n):
if a[i - 1] + a[i] >= l:
idx = i
break
if idx == 0:
print("Impossible")
exit()
print("Possible")
ans = [idx]
for i in range(idx - 1, 0, -1):
ans.append(i)
for i in range(idx + 1, n):
ans.append(i)
for a in ans[::-1]:
print(a)
|
s903061691
|
p03471
|
u100873497
| 2,000 | 262,144 |
Wrong Answer
| 807 | 3,060 | 173 |
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
n,y = map(int,input().split())
for a in range(n+1):
for b in range(n+1-a):
c=n-a-b
if y==a*10000+b*5000+c*1000 and n==a+b+c:
print(a,b,c)
break
|
s124669672
|
Accepted
| 834 | 3,060 | 247 |
n,y = map(int,input().split())
l=0
for a in range(n+1):
for b in range(n+1-a):
c=n-a-b
if y==a*10000+b*5000+c*1000 and n==a+b+c:
i=a
j=b
k=c
l=1
break
if l==1:
print(i,j,k)
else:
print(-1,-1,-1)
|
s648687137
|
p03672
|
u411858517
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 240 |
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
|
S = list(input())
for i in range(len(S)):
if len(S)%2 != 0:
S.pop()
else:
if S[:len(S)//2] == S[len(S)//2:]:
res = len(S)
break
else:
S.pop()
S.pop()
print(res)
|
s551907630
|
Accepted
| 17 | 3,060 | 234 |
S = list(input())
if len(S)%2 != 0:
S.pop()
else:
S.pop()
S.pop()
for i in range(len(S)):
if S[:len(S)//2] == S[len(S)//2:]:
res = len(S)
break
else:
S.pop()
S.pop()
print(res)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.