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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s949440838 | p03965 | u827202523 | 2,000 | 262,144 | Wrong Answer | 43 | 3,188 | 164 | AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn. | hands = input()
ans = 0
for i, h in enumerate(hands):
if i % 2 == 1:
if h == "p":
ans -= 1
else:
if h == "g":
ans += 1
print(ans)
| s093455903 | Accepted | 42 | 3,316 | 164 | hands = input()
ans = 0
for i, h in enumerate(hands):
if i % 2 == 0:
if h == "p":
ans -= 1
else:
if h == "g":
ans += 1
print(ans)
|
s680018459 | p03400 | u034128150 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 137 | Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp. | N = int(input())
D, X = map(int, input().split())
As = [int(input()) for _ in range(N)]
c = X
for A in As:
c += (D-1) // A
print(c) | s028408751 | Accepted | 17 | 2,940 | 144 | N = int(input())
D, X = map(int, input().split())
As = [int(input()) for _ in range(N)]
c = X
for A in As:
c += ((D-1) // A) + 1
print(c) |
s872288303 | p03047 | u089142196 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 42 | 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? | N,K=map(int,input().split())
print(K-N+1) | s335606049 | Accepted | 17 | 2,940 | 96 | N,K=map(int,input().split())
cnt=0
for i in range(1,N+1):
if i+K-1<=N:
cnt+=1
print(cnt) |
s936745721 | p03623 | u088529499 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 187 | 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|. | list = list(map(int,input().split()))
x=list[0]
a=list[1]
b=list[2]
if a>x:
s=a-x
else:
s=x-a
if b>x:
t=b-x
else:
t=x-b
if s<t:
print('B')
else:
print('A') | s901627818 | Accepted | 17 | 3,060 | 187 | list = list(map(int,input().split()))
x=list[0]
a=list[1]
b=list[2]
if a>x:
s=a-x
else:
s=x-a
if b>x:
t=b-x
else:
t=x-b
if s<t:
print('A')
else:
print('B') |
s125773931 | p03546 | u698479721 | 2,000 | 262,144 | Wrong Answer | 31 | 3,444 | 572 | Joisino the magical girl has decided to turn every single digit that exists on this world into 1. Rewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points). She is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive). You are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows: * If A_{i,j}≠-1, the square contains a digit A_{i,j}. * If A_{i,j}=-1, the square does not contain a digit. Find the minimum total amount of MP required to turn every digit on this wall into 1 in the end. | h,w=map(int,input().split())
grid = []
for i in range(10):
array = list(map(int, input().strip().split(' ')))
grid.append(array)
wall = []
for i in range(h):
array = list(map(int, input().strip().split(' ')))
wall.append(array)
def warshall_floyd(n):
for k in range(n):
for i in range(n):
for j in range(n):
grid[i][j] = min(grid[i][j], grid[i][k] + grid[k][j])
warshall_floyd(10)
cost=[]
for arrays in grid:
cost.append(arrays[1])
ans = 0
for arrays in wall:
for nums in arrays:
ans += cost[nums]
print(ans) | s343282298 | Accepted | 32 | 3,444 | 614 | h,w=map(int,input().split())
grid = []
for i in range(10):
array = list(map(int, input().strip().split(' ')))
grid.append(array)
wall = []
for i in range(h):
array = list(map(int, input().strip().split(' ')))
wall.append(array)
def warshall_floyd(n):
for k in range(n):
for i in range(n):
for j in range(n):
grid[i][j] = min(grid[i][j], grid[i][k] + grid[k][j])
warshall_floyd(10)
cost=[]
for arrays in grid:
cost.append(arrays[1])
ans = 0
for arrays in wall:
for nums in arrays:
if nums == -1:
pass
else:
ans += cost[nums]
print(ans) |
s335223383 | p03605 | u961683150 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 77 | It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N? | x=int(input())
if x==9 or x//10==9:
print("Yes")
else:
print("No") | s863764223 | Accepted | 16 | 2,940 | 90 | x=int(input())
if x==9 or x//10==9 or x%10==9:
print("Yes")
else:
print("No") |
s556784897 | p03623 | u263830634 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 315 | 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|. | S = list(input())
s = set(S)
S = list(s)
S.sort()
if len(S) == 26:
print (None)
else:
tmp = 0
for i in 'abcdefghijklmnopqrstuvwxyz':
if tmp >= len(S):
print (i)
break
if i == S[tmp]:
tmp += 1
else:
print (i)
break
| s717805276 | Accepted | 17 | 2,940 | 102 | X, A, B = map(int, input().split())
if abs(X - A) < abs(X - B):
print ('A')
else:
print ('B') |
s393726218 | p03610 | u612635771 | 2,000 | 262,144 | Wrong Answer | 28 | 9,060 | 26 | You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1. | s = input()
print(s[1::2]) | s986303447 | Accepted | 25 | 9,048 | 25 | s = input()
print(s[::2]) |
s692869256 | p04043 | u683956577 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 92 | Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order. | a = list(map(int, input().split()))
print("Yes" if a[0]== a[2] == 5 and a[1] == 7 else "No") | s445957841 | Accepted | 16 | 2,940 | 97 | a = list(map(int, input().split()))
print("YES" if a.count(5) == 2 and a.count(7) == 1 else "NO") |
s129676959 | p02406 | u967268722 | 1,000 | 131,072 | Wrong Answer | 20 | 5,576 | 75 | 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(3, n+1, 3):
print(' '+str(i), end='')
| s172711144 | Accepted | 20 | 5,876 | 153 | n = int(input())
for i in range(1, n+1):
if i%3 == 0:print(' '+str(i), end='')
else:
if '3' in str(i):print(' '+str(i), end='')
print()
|
s721965584 | p03401 | u941753895 | 2,000 | 262,144 | Wrong Answer | 2,105 | 17,028 | 270 | There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. | n=int(input())
if n==3:
exit()
al=list(map(int,input().split()))
l1=[]
l2=[]
bl=[0]+al+[0]
for i in range(len(bl)-1):
l1.append(abs(bl[i]-bl[i+1]))
if i!=len(bl)-2:
l2.append(abs(bl[i]-bl[i+2]))
for i in range(len(l2)):
print(l2[i]+sum(l1[:i])+sum(l1[i+2:])) | s406832899 | Accepted | 232 | 17,776 | 508 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()
def main():
n=I()
l=LI()
l=[0]+l+[0]
sm=sum([abs(l[i+1]-l[i]) for i in range(len(l)-1)])
for i in range(1,len(l)-1):
a=abs(l[i]-l[i-1])
b=abs(l[i+1]-l[i])
c=abs(l[i+1]-l[i-1])
print(sm-(a+b-c))
main() |
s782126503 | p03659 | u103520789 | 2,000 | 262,144 | Wrong Answer | 271 | 24,824 | 388 | Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it. They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card. Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively. They would like to minimize |x-y|. Find the minimum possible value of |x-y|. | N = int(input())
a_arr = list(map(int, input().split()))
def main(arr):
sum_sunuke = 0
sum_arai = sum(arr)
min_val = 2*(10**5)
for i in range(1,N):
sum_sunuke += arr[i]
sum_arai -= arr[i]
val = abs(sum_sunuke - sum_arai)
print(sum_sunuke)
if min_val > val:
min_val = val
return min_val
print(main(a_arr)) | s527025308 | Accepted | 124 | 24,816 | 601 | N = int(input())
a_arr = list(map(int, input().split()))
def main(arr):
sum_sunuke = 0
sum_arai = sum(arr)
min_val = 10**10
# if N == 2:
# return abs(arr[0]- arr[1])
for i in range(N-1):
sum_sunuke += arr[i]
sum_arai -= arr[i]
val = abs(sum_sunuke - sum_arai)
# print("arai: {}".format(sum_arai))
if min_val > val:
min_val = val
# print("min val: {}".format(min_val))
# print("*************")
return min_val
print(main(a_arr)) |
s250401797 | p03155 | u457460736 | 2,000 | 1,048,576 | Wrong Answer | 30 | 9,080 | 63 | 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((N-H)*(N-W)) | s338112452 | Accepted | 30 | 8,996 | 68 | N=int(input())
H=int(input())
W=int(input())
print((N-H+1)*(N-W+1))
|
s271029715 | p02694 | u743164083 | 2,000 | 1,048,576 | Wrong Answer | 30 | 9,088 | 86 | 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? | m = 100
x = int(input())
y = 0
while x >= m:
m = m + m // 100
y += 1
print(y)
| s393673231 | Accepted | 30 | 9,132 | 116 | m = 100
x = int(input())
y = 0
while x >= m:
if x == m:
break
m = m + m // 100
y += 1
print(y)
|
s868589623 | p03478 | u167681750 | 2,000 | 262,144 | Wrong Answer | 30 | 2,940 | 183 | Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive). | n, a, b = map(int, input().split())
counter = 0
for i in range(1, n):
str_i = str(i)
sum_i = sum(map(int, str_i))
if a <= sum_i <= b:
counter += 1
print(counter) | s002391470 | Accepted | 33 | 2,940 | 172 | n, a, b = map(int, input().split())
answer = 0
for i in range(1, n + 1):
sum_i = sum(map(int, list(str(i))))
if a <= sum_i <= b:
answer += i
print(answer) |
s658876469 | p03149 | u652656291 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 163 | You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974". | A = list(map(int,input().split()))
a = A.count('1')
b = A.count('7')
c = A.count('9')
d = A.count('4')
if a == b == c == d == 1:
print('YES')
else:
print('NO') | s370591587 | Accepted | 17 | 3,060 | 163 | A = list(map(str,input().split()))
a = A.count('1')
b = A.count('7')
c = A.count('9')
d = A.count('4')
if a == b == c == d == 1:
print('YES')
else:
print('NO') |
s115079733 | p02257 | u672822075 | 1,000 | 131,072 | Wrong Answer | 30 | 6,720 | 121 | A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. Write a program which reads a list of _N_ integers and prints the number of prime numbers in the list. | c = 0
n = int(input())
for _ in range(n):
t = int(input())
for i in range(2,t):
if t%i==0:
break
c += 1
print(c) | s119419711 | Accepted | 990 | 6,812 | 156 | import math
c = 0
n = int(input())
for _ in range(n):
t = int(input())
for i in range(2,int(math.sqrt(t)+1)):
if t%i==0:
break
else:
c+=1
print(c) |
s963508448 | p02388 | u100813820 | 1,000 | 131,072 | Wrong Answer | 20 | 7,340 | 505 | Write a program which calculates the cube of a given integer x. |
# x ??? 3 ???
# Input
# Output
# Sample Input 1
# 2
# Sample Output 1
# 8
x=2
print(x**3);
# Sample Input 2
# 3
# Sample Output 2
# 27
x=3
print(x**3); | s096103038 | Accepted | 30 | 7,640 | 458 |
# x ??? 3 ???
# Input
# Output
# Sample Input 1
# 2
# Sample Output 1
# 8
x=int( input() )
print(x**3); |
s509130318 | p03637 | u399721252 | 2,000 | 262,144 | Wrong Answer | 68 | 14,252 | 217 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | n = int(input())
num = [ int(v) for v in input().split() ]
a, b, c = 0, 0, 0
for i in num:
if i % 2 != 0:
a += 1
elif i % 4 != 0:
b += 1
else:
c += 1
print(a,c)
if c >= a - 1:
print("Yes")
else:
print("No") | s159954299 | Accepted | 67 | 14,252 | 276 | n = int(input())
num = [ int(v) for v in input().split() ]
a, b, c = 0, 0, 0
for i in num:
if i % 2 != 0:
a += 1
elif i % 4 != 0:
b += 1
else:
c += 1
if b == 0:
if c >= a - 1:
print("Yes")
else:
print("No")
else:
if c >= a:
print("Yes")
else:
print("No")
|
s363485261 | p03555 | u162660367 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 75 | 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. | C1=input().strip()
C2=input().strip()
print("No Yes".split()[C1==C2[::-1]]) | s249907963 | Accepted | 17 | 2,940 | 80 | C1=input().strip()
C2=input().strip()
print("NO YES".split()[int(C1==C2[::-1])]) |
s220472736 | p03797 | u870518235 | 2,000 | 262,144 | Wrong Answer | 28 | 9,092 | 219 | Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces. | S, C = map(int, input().split())
ans = 0
if S*2 <= C:
C = C - S*2
print(C, S, C//4)
ans += S
ans += C // 4
else:
print(C//2)
ans += C // 2
print(ans)
| s531563959 | Accepted | 24 | 9,040 | 186 | S, C = map(int, input().split())
ans = 0
if S*2 <= C:
C = C - S*2
ans += S
ans += C // 4
else:
ans += C // 2
print(int(ans))
|
s283806971 | p02927 | u905582793 | 2,000 | 1,048,576 | Wrong Answer | 21 | 2,940 | 189 | 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? | m,d = map(int,input().split())
ans = 0
for i in range(m):
for j in range(d):
if "1" in str(j):
continue
j1 = j//10
j2 = j%10
if i == j1*j2:
ans += 1
print(ans) | s360703695 | Accepted | 24 | 3,060 | 204 | m,d = map(int,input().split())
ans = 0
for i in range(1,m+1):
for j in range(10,d+1):
if "1" in list(str(j)):
continue
j1 = j//10
j2 = j%10
if i == j1*j2:
ans += 1
print(ans) |
s853318137 | p03359 | u457957084 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 84 | In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi? | n, b = map(int,input().split())
if n <= b:
print(n + 1)
else:
print(n)
| s462453115 | Accepted | 18 | 2,940 | 85 | n, b = map(int,input().split())
if n <= b:
print(n)
else:
print(n - 1)
|
s015783353 | p03998 | u868600519 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 134 | Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game. | cards = dict((x, list(input())) for x in 'abc')
turn = 'a'
while len(cards[turn]):
turn = cards[turn].pop(0)
print(turn.upper())
| s822007714 | Accepted | 17 | 2,940 | 126 | cards = {x: list(input()) for x in 'abc'}
turn = 'a'
while len(cards[turn]):
turn = cards[turn].pop(0)
print(turn.upper()) |
s511711348 | p03693 | u220870679 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 106 | 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())
if (100*r + 10*g + b) % 4 == 0:
print("Yes")
else:
print("No") | s228382716 | Accepted | 17 | 2,940 | 106 | r, g, b = map(int, input().split())
if (100*r + 10*g + b) % 4 == 0:
print("YES")
else:
print("NO") |
s419839108 | p02850 | u532966492 | 2,000 | 1,048,576 | Wrong Answer | 2,124 | 302,068 | 1,022 | Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colorings satisfying the condition above, construct one that uses the minimum number of colors. | def main():
n=int(input())
ab=[tuple(map(int,input().split())) for _ in [0]*(n-1)]
d={ab[i]:i for i in range(n-1)}
g=[[] for _ in [0]*n]
[g[a-1].append(b-1) for a,b in ab]
[g[b-1].append(a-1) for a,b in ab]
g2=[set() for _ in [0]*(n-1)]
for i in range(n):
for j in g[i]:
for k in g[j]:
p=min(i,j)
q=max(i,j)
r=min(j,k)
s=max(j,k)
x=d[(p+1,q+1)]
y=d[(r+1,s+1)]
g2[x].add(y)
g2[y].add(x)
for i in range(n-1):
g2[i].remove(i)
color=[-1]*(n-1)
color[0]=1
q=[[0,0]]
while q:
qq=[]
while q:
i,root=q.pop()
cnt=1
for j in g2[i]:
if j==root:
continue
if cnt==color[i]:
cnt+=1
color[j]=cnt
cnt+=1
qq.append([j,i])
q=qq
print(*color)
main() | s296875586 | Accepted | 634 | 47,284 | 977 | def main():
n=int(input())
ab=[list(map(int,input().split())) for _ in [0]*(n-1)]
g=[[] for _ in [0]*n]
[g[a-1].append(b-1) for a,b in ab]
[g[b-1].append(a-1) for a,b in ab]
color=[-1]*n
color[0]=0
q=[[0,0]]
while q:
qq=[]
while q:
i,root=q.pop()
cnt=1
for j in g[i]:
if j==root:
continue
if cnt==color[i]:
cnt+=1
color[j]=cnt
cnt+=1
qq.append([j,i])
q=qq
d=[-1]*n
d[0]=0
q=[0]
cnt=0
while q:
qq=[]
cnt+=1
while q:
i=q.pop()
for j in g[i]:
if d[j]==-1:
d[j]=cnt
qq.append(j)
q=qq
print(max(color[1:]))
for i,j in ab:
if d[i-1]>d[j-1]:
k=i
else:
k=j
print(color[k-1])
main() |
s776314874 | p03129 | u550943777 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 86 | Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1. | n,k = map(int,input().split())
if n > 2*(k-1) :
print('Yes')
else:
print('No') | s174668101 | Accepted | 17 | 2,940 | 86 | n,k = map(int,input().split())
if n > 2*(k-1) :
print('YES')
else:
print('NO') |
s744426687 | p03779 | u999503965 | 2,000 | 262,144 | Wrong Answer | 39 | 9,164 | 142 | There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X. | x=int(input())
num=0
cnt=0
for i in range(10**9):
num+=i
cnt+=1
if num>=x:
break
if num==x:
print(cnt)
else:
print(cnt-1) | s287334803 | Accepted | 42 | 9,156 | 110 | x=int(input())
num=0
cnt=0
for i in range(1,10**9):
num+=i
cnt+=1
if num>=x:
break
print(cnt) |
s330188823 | p02255 | u318430977 | 1,000 | 131,072 | Wrong Answer | 30 | 5,596 | 317 | 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 insertion_sort(a, n):
for i in range(1, n):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j + 1] = a[j]
j -= 1
a[j + 1] = v
print(a)
n = int(input())
a = input().split()
for i in range(n):
a[i] = int(a[i])
print(a)
insertion_sort(a, n)
| s926523607 | Accepted | 30 | 5,980 | 463 | def insertion_sort(a, n):
for i in range(1, n):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j + 1] = a[j]
j -= 1
a[j + 1] = v
print_list_split_whitespace(a)
def print_list_split_whitespace(a):
for x in a[:-1]:
print(x, end=' ')
print(a[-1])
n = int(input())
a = input().split()
for i in range(n):
a[i] = int(a[i])
print_list_split_whitespace(a)
insertion_sort(a, n)
|
s900979521 | p03992 | u163320134 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 44 | 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()
print('{} {}'.format(s[:4],s[5:])) | s403985479 | Accepted | 17 | 2,940 | 44 | s=input()
print('{} {}'.format(s[:4],s[4:])) |
s705040967 | p03693 | u779830746 | 2,000 | 262,144 | Wrong Answer | 30 | 9,080 | 146 | 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(str, input().split())
number = int(r + g + b)
if number / 4 >= 1:
print('Yes')
else:
print('No')
| s166033046 | Accepted | 28 | 9,100 | 146 |
r, g, b = map(str, input().split())
number = r + g + b
if int(number) % 4 == 0:
print('YES')
else:
print('NO')
|
s123075020 | p03998 | u030626972 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 659 | Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game. | def main():
sa = list(input())
sb = list(input())
sc = list(input())
turn = 'a'
while True:
if turn == 'a':
if len(sa)>0:
turn = sa.pop(0)
else:
print('a')
return
elif turn == 'b':
if len(sb)>0:
turn = sb.pop(0)
else:
print('b')
return
elif turn == 'c':
if len(sc)>0:
turn = sc.pop(0)
else:
print('c')
return
if __name__ == "__main__":
main() | s908246051 | Accepted | 19 | 3,064 | 659 | def main():
sa = list(input())
sb = list(input())
sc = list(input())
turn = 'a'
while True:
if turn == 'a':
if len(sa)>0:
turn = sa.pop(0)
else:
print('A')
return
elif turn == 'b':
if len(sb)>0:
turn = sb.pop(0)
else:
print('B')
return
elif turn == 'c':
if len(sc)>0:
turn = sc.pop(0)
else:
print('C')
return
if __name__ == "__main__":
main() |
s861945281 | p02612 | u091307273 | 2,000 | 1,048,576 | Wrong Answer | 29 | 9,100 | 551 | 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. | def main():
R, C, K = map(int, input().split())
grid = []
for r in range(R):
grid.append([1 if c == '#' else 0 for c in input()])
n_configs = 0
for rm in range(2**R):
for cm in range(2**C):
nb = 0
for r in range(R):
for c in range(C):
if ((rm >> r) & 1) == 0 and ((cm >> c) & 1) == 0 and grid[r][c] == 1:
nb += 1
if nb == K:
n_configs += 1
print(n_configs, flush=True)
return
| s530717555 | Accepted | 27 | 8,988 | 99 | price = int(input())
change = 1000 - (price % 1000)
if change == 1000:
change = 0
print(change)
|
s705127718 | p02256 | u566311709 | 1,000 | 131,072 | Wrong Answer | 20 | 5,588 | 178 | Write a program which finds the greatest common divisor of two natural numbers _a_ and _b_ | x, y = sorted(list(map(int, input().split())), reverse=True)
while 1:
if x % y == 0:
print(y)
break
else:
a = y
b = x % y
x = a
y = b
print(x, y)
| s728046980 | Accepted | 20 | 5,588 | 67 | a, b = map(int, input().split())
while b: a, b = b, a % b
print(a)
|
s233242644 | p04031 | u633450100 | 2,000 | 262,144 | Wrong Answer | 149 | 14,448 | 426 | Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective. | import numpy as np
N = int(input())
a = [int(i) for i in input().split()]
oppai = np.array(a)
max = np.max(oppai)
min = np.min(oppai)
x = (max+min)//2
sum = [0] * 3
for i in range(x-1,x+2,1):
oppai = np.array(a)
oppai -= i
oppai = oppai**2
sum[i-x+1] = np.sum(oppai)
print('sum[{}]'.format(i-x+1),sum[i-x+1])
chinko = np.array(sum)
#print(np.argmin(chinko)+x-1)
print(np.min(chinko))
| s508802844 | Accepted | 157 | 12,408 | 428 | import numpy as np
N = int(input())
a = [int(i) for i in input().split()]
oppai = np.array(a)
max = np.max(oppai)
min = np.min(oppai)
x = (max+min)//2
sum = [0] * 201
for i in range(-100,101):
oppai = np.array(a)
oppai -= i
oppai = oppai**2
sum[i+100] = np.sum(oppai)
#print('sum[{}]'.format(i+100),sum[i+100])
chinko = np.array(sum)
#print(np.argmin(chinko)+x-1)
print(np.min(chinko))
|
s870858695 | p03545 | u112623731 | 2,000 | 262,144 | Wrong Answer | 29 | 9,008 | 219 | Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted. | numbers = input()
a,b,c,d = numbers
i = len(numbers)-1
op = ['+','-']
for j in range(2 ** i):
o = [op[int((j>>k)&1)] for k in range(i)]
f=f"{a}{o[0]}{b}{o[1]}{c}{o[2]}{d}"
print(f) if eval(f) == 7 else ''
| s004569861 | Accepted | 28 | 9,084 | 231 | numbers = input()
a,b,c,d = numbers
i = len(numbers)-1
op = ['+','-']
for j in range(2 ** i):
o = [op[int((j>>k)&1)] for k in range(i)]
f=f"{a}{o[0]}{b}{o[1]}{c}{o[2]}{d}"
if eval(f) == 7:
print(f+'=7')
break
|
s863304063 | p02388 | u309095676 | 1,000 | 131,072 | Wrong Answer | 20 | 5,520 | 16 | Write a program which calculates the cube of a given integer x. | x=3
print(x**3)
| s088329476 | Accepted | 20 | 5,576 | 51 | import sys
x=int(sys.stdin.readline())
print(x**3)
|
s878448065 | p00513 | u662488567 | 8,000 | 131,072 | Wrong Answer | 110 | 13,416 | 1,886 | IOI 不動産ではマンションの賃貸を行なっている. この会社が取り扱うマンションの部屋は 1LDK で, 下図のように面積が 2xy+x+y になっている. ただし, x, y は正整数である. IOI 不動産のカタログにはマンションの面積が昇順に(狭いものから順番に)書かれているが,この中にいくつか間違い(ありえない面積のもの)が混じっていることがわかった. カタログ(入力ファイル)は N+1 行で,最初の行に部屋数が書かれていて, 続く N 行に,1行に1部屋ずつ面積が昇順に書かれている. ただし, 部屋数は 100,000 以下, 面積は (2の31乗)-1 = 2,147,483,647 以下である. 5つの入力データのうち3つまでは, 部屋数 1000 以下,面積 30000 以下である. 間違っている行数(ありえない部屋の数)を出力しなさい. 出力ファイルにおいては, 出力の最後の行にも改行コードを入れること. |
prime = dict()
prime_nums = list()
MAXIMUM = 2**16
def get_prime():
for i in range(2, MAXIMUM):
if prime.get(i, True):
prime_nums.append(i)
for j in range(i * 2, MAXIMUM, i):
prime[j] = False
def check(x):
x = 2*x + 1
for prime in prime_nums:
if prime **2 > x:
break
if x % prime == 0:
return False
print(prime, x)
return True
get_prime()
n = int(input())
count = 0
for _ in range(n):
if check(int(input())):
count += 1
print(count) | s816125111 | Accepted | 2,210 | 13,488 | 1,835 |
prime = dict()
prime_nums = list()
MAXIMUM = 2**16
def get_prime():
for i in range(2, MAXIMUM):
if prime.get(i, True):
prime_nums.append(i)
for j in range(i * 2, MAXIMUM, i):
prime[j] = False
def check(x):
x = 2*x + 1
for prime in prime_nums:
if prime **2 > x:
break
if x % prime == 0:
return False
return True
get_prime()
n = int(input())
count = 0
for _ in range(n):
if check(int(input())):
count += 1
print(count) |
s672205061 | p04044 | u881816188 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 174 | Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m. | n,l=map(int,input().split())
s=[str(input()) for _ in range(n)]
sort_s=sorted(s)
print(''.join(s)) | s830177267 | Accepted | 17 | 3,060 | 179 | n,l=map(int,input().split())
s=[str(input()) for _ in range(n)]
sort_s=sorted(s)
print(''.join(sort_s)) |
s716226271 | p02396 | u244790947 | 1,000 | 131,072 | Wrong Answer | 70 | 7,984 | 189 | In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem. |
inputs = []
for i in range(10000) :
inputraw = input()
if inputraw == '0' :
break
inputs.append(inputraw)
for i, input in enumerate(inputs) :
print("Case "+str(i)+": "+ str(input)) | s622778505 | Accepted | 70 | 8,040 | 191 |
inputs = []
for i in range(10000) :
inputraw = input()
if inputraw == '0' :
break
inputs.append(inputraw)
for i, input in enumerate(inputs) :
print("Case "+str(i+1)+": "+ str(input)) |
s905308964 | p02659 | u084491185 | 2,000 | 1,048,576 | Wrong Answer | 22 | 9,104 | 84 | Compute A \times B, truncate its fractional part, and print the result as an integer. | A, B = input().split()
a = float(A)
b = float(B)
S = a * b
ans = S // 1
print(ans) | s280444648 | Accepted | 24 | 9,172 | 104 | A, B = input().split()
a = int(A)
b = int(B.replace('.', ''))
S = a * b
ans = S // 100
print(int(ans)) |
s666243675 | p02578 | u298976461 | 2,000 | 1,048,576 | Wrong Answer | 136 | 31,296 | 220 | N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal. | from sys import stdin
input = stdin.readline
n = input().rstrip()
a = list(map(int, input().split()))
ans = 0
for i in range(len(a)-1):
if a[i] > a[i+1]:
diff = a[i] - a[i+1]
ans += diff
print(ans) | s999495991 | Accepted | 153 | 31,464 | 243 | from sys import stdin
input = stdin.readline
n = input().rstrip()
a = list(map(int, input().split()))
ans = 0
for i in range(len(a)-1):
if a[i] > a[i+1]:
diff = a[i] - a[i+1]
a[i+1] += diff
ans += diff
print(ans) |
s272714615 | p03139 | u088488125 | 2,000 | 1,048,576 | Wrong Answer | 30 | 9,056 | 53 | We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question. | n,a,b=map(int, input().split())
print(min(a,b),a+b-n) | s012328160 | Accepted | 27 | 9,100 | 60 | n,a,b=map(int, input().split())
print(min(a,b),max(0,a+b-n)) |
s472433075 | p03711 | u268516119 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 135 | Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group. | x,y=map(int,input().split())
a=[4,6,9,11]
if x==2 or y==2:
ans='No'
elif x in a==y in a:
ans='Yes'
else:ans='No'
print(ans)
| s372980655 | Accepted | 17 | 2,940 | 129 | x,y=map(int,input().split())
a=[4,6,9,11]
if ((x in a)==(y in a)) and x!=2 and y!=2:
ans='Yes'
else:ans='No'
print(ans)
|
s006679200 | p03711 | u682730715 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 240 | Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group. | a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
x, y = map(int,input().split())
for i in a:
if x == i:
x = "a"
if y == i:
y == "a"
for i in b:
if x == i:
x = "b"
if y == i:
y == "b"
if x == y:
print("Yes")
else:
print("No") | s566165673 | Accepted | 17 | 3,060 | 238 | a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
x, y = map(int,input().split())
for i in a:
if x == i:
x = "a"
if y == i:
y = "a"
for i in b:
if x == i:
x = "b"
if y == i:
y = "b"
if x == y:
print("Yes")
else:
print("No") |
s979261084 | p03795 | u820315626 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 73 | 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. | import math
n = int(input())
print(math.factorial(n) / (pow(10, 9) + 7))
| s793533195 | Accepted | 17 | 2,940 | 53 | n = int(input())
print(800 *n - ( 200 * int(n / 15))) |
s326989942 | p01225 | u104171359 | 5,000 | 131,072 | Wrong Answer | 30 | 7,804 | 1,443 | あなたの友達は最近 UT-Rummy というカードゲームを思いついた. このゲームで使うカードには赤・緑・青のいずれかの色と1から9までのいずれかの番号が つけられている. このゲームのプレイヤーはそれぞれ9枚の手札を持ち, 自分のターンに手札から1枚選んで捨てて, 代わりに山札から1枚引いてくるということを繰り返す. このように順番にターンを進めていき, 最初に手持ちのカードに3枚ずつ3つの「セット」を作ったプレイヤーが勝ちとなる. セットとは,同じ色の3枚のカードからなる組で,すべて同じ数を持っているか 連番をなしているもののことを言う. 連番に関しては,番号の巡回は認められない. 例えば,7, 8, 9は連番であるが 9, 1, 2は連番ではない. あなたの友達はこのゲームをコンピュータゲームとして売り出すという計画を立てて, その一環としてあなたに勝利条件の判定部分を作成して欲しいと頼んできた. あなたの仕事は,手札が勝利条件を満たしているかどうかを判定する プログラムを書くことである. | #!usr/bin/env python3
import sys
def main():
WINNING_HANDS = [
'111', '222', '333', '444', '555', '666', '777', '888', '999',
'123', '234', '345', '456', '567', '678', '789'
]
num_of_datasets = int(sys.stdin.readline().strip('\n'))
datasets = [{'R': [], 'G': [], 'B': []} for _ in range(num_of_datasets)]
results = list()
for dataset in range(num_of_datasets):
n_set = [int(num) for num in sys.stdin.readline().strip('\n').split()]
c_set = [colour for colour in sys.stdin.readline().strip('\n').split()]
for idx, colour in enumerate(c_set):
if colour == 'R':
datasets[dataset]['R'].append(n_set[idx])
elif colour == 'G':
datasets[dataset]['G'].append(n_set[idx])
elif colour == 'B':
datasets[dataset]['B'].append(n_set[idx])
match_count = int()
for rgb_key in datasets[dataset]:
nums = ''.join(str(num) for num in sorted(datasets[dataset][rgb_key]))
for hand in WINNING_HANDS:
if hand in nums:
match_count += 1
if match_count == 3:
results.append(1)
continue
if dataset < num_of_datasets-1:
results.append(0)
for result in results:
print(result)
if __name__ == '__main__':
main() | s674013433 | Accepted | 30 | 7,764 | 2,141 | #!usr/bin/env python3
import sys
def main():
WINNING_HANDS = [
'111', '222', '333', '444', '555', '666', '777', '888', '999',
'123', '234', '345', '456', '567', '678', '789'
]
num_of_datasets = int(sys.stdin.readline().strip('\n'))
datasets = [{'R': [], 'G': [], 'B': []} for _ in range(num_of_datasets)]
results = list()
for dataset in range(num_of_datasets):
n_set = [num for num in sys.stdin.readline().strip('\n').split()]
c_set = [colour for colour in sys.stdin.readline().strip('\n').split()]
for idx, colour in enumerate(c_set):
if colour == 'R':
datasets[dataset]['R'].append(n_set[idx])
elif colour == 'G':
datasets[dataset]['G'].append(n_set[idx])
elif colour == 'B':
datasets[dataset]['B'].append(n_set[idx])
match_count = int()
for rgb_key in datasets[dataset]:
if len(datasets[dataset][rgb_key]) > 1:
nums = sorted(datasets[dataset][rgb_key])
else:
continue
for hand in WINNING_HANDS:
while hand[0] in nums and hand[1] in nums and hand[2] in nums:
tmp = nums.copy()
if hand[0] in tmp:
tmp.pop(tmp.index(hand[0]))
if hand[1] in tmp:
tmp.pop(tmp.index(hand[1]))
if hand[2] in tmp:
tmp.pop(tmp.index(hand[2]))
match_count += 1
nums = tmp
else:
break
else:
break
else:
break
if match_count == 3:
results.append(1)
break
if dataset < num_of_datasets and match_count != 3:
results.append(0)
for result in results:
print(result)
if __name__ == '__main__':
main() |
s257962862 | p04031 | u175590965 | 2,000 | 262,144 | Wrong Answer | 26 | 3,060 | 188 | Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective. | n = int(input())
a = list(map(int,input().split()))
ans = 10**10
for i in range(-100,101):
t = 0
for j in a:
t += (j-i)**2
if t < ans:
ans =t
print(ans) | s580802146 | Accepted | 25 | 3,060 | 180 | n = int(input())
a = list(map(int,input().split()))
ans = 10**10
for i in range(-100,101):
t = 0
for j in a:
t += (j-i)**2
if t < ans:
ans =t
print(ans) |
s926917039 | p03826 | u611090896 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 49 | There are two rectangles. The lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B. The lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D. Print the area of the rectangle with the larger area. If the two rectangles have equal areas, print that area. | a,b,c,d = map(int,input().split())
print(a*b,c*d) | s862737407 | Accepted | 17 | 2,940 | 55 | a,b,c,d = map(int,input().split())
print(max(a*b,c*d))
|
s556484680 | p02744 | u309141201 | 2,000 | 1,048,576 | Wrong Answer | 95 | 3,700 | 251 | In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be **isomorphic** when the following conditions are satisfied: * |s| = |t| holds. * For every pair i, j, one of the following holds: * s_i = s_j and t_i = t_j. * s_i \neq s_j and t_i \neq t_j. For example, `abcac` and `zyxzx` are isomorphic, while `abcac` and `ppppp` are not. A string s is said to be in **normal form** when the following condition is satisfied: * For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison. For example, `abcac` is in normal form, but `zyxzx` is not since it is isomorphic to `abcac`, which is lexicographically smaller than `zyxzx`. You are given an integer N. Print all strings of length N that are in normal form, in lexicographically ascending order. | n = int(input())
pw = ['a', 'b', 'c']
ans = ['' for _ in range(n)]
# print(ord('b'))
def dfs(i):
if i == n:
print(''.join(ans))
return
for j in range(97, 100):
# print(j)
ans[i] = chr(j)
dfs(i+1)
dfs(0) | s224853777 | Accepted | 197 | 4,340 | 223 | n = int(input())
ans = ['' for _ in range(n)]
def dfs(i, mx):
if i == n:
print(''.join(ans))
return
for j in range(mx+1):
ans[i] = chr(ord('a') + j)
dfs(i+1, max(j+1, mx))
dfs(0, 0) |
s117989465 | p03796 | u597455618 | 2,000 | 262,144 | Wrong Answer | 26 | 2,940 | 82 | Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7. | n = int(input())
ans = 0
for i in range(n+1):
ans *= i
print(ans % (10 **9 + 7)) | s854291542 | Accepted | 42 | 2,940 | 90 | n = int(input())
ans = 1
for i in range(1,n+1):
ans *= i
ans %= (10**9 + 7)
print(ans) |
s353565729 | p03739 | u936985471 | 2,000 | 262,144 | Wrong Answer | 664 | 15,996 | 1,146 | You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term. | N=int(input())
A=list(map(int,input().split()))
cur=A[0]
ans=0
isplus=True
ind=1
if cur<0:
isplus=False
if cur==0:
allzero=True
firstNotZero=0
firstNotZeroInd=0
for i in range(N):
if A[i]!=0:
firstNotZero=A[i]
firstNotZeroInd=i
allzero=False
break
if allzero:
print(N)
exit(0)
if firstNotZero>0:
cur=-1
ind=firstNotZeroInd
isplus=False
print("ind",ind,"isplus",isplus)
else:
cur=1
ind=firstNotZeroInd
isplus=True
print("ind",ind,"isplus",isplus)
for i in range(ind,N):
print("i",i,"cur",cur,"A[i]",A[i])
if isplus:
if cur+A[i]>=0:
diff=abs((cur+A[i])-(-1))
print("cur",cur,"cur+A[i]",cur+A[i]," -> -1 diff",diff)
ans+=diff
print("ans",ans)
cur=-1
else:
print("no problem")
cur+=A[i]
isplus=False
else:
if cur+A[i]<=0:
diff=abs((cur+A[i])-1)
print("cur",cur,"cur+A[i]",cur+A[i]," -> 1 diff",diff)
ans+=diff
print("ans",ans)
cur=1
else:
print("no problem")
cur+=A[i]
isplus=True
print(ans) | s109731590 | Accepted | 135 | 14,332 | 315 | N=int(input())
A=list(map(int,input().split()))
ans=[0]*2
for pat in range(2):
cur=0
isplus=pat
for i in range(N):
cur+=A[i]
if isplus:
if cur<=0:
ans[pat]+=abs(cur-1)
cur=1
else:
if cur>=0:
ans[pat]+=abs(cur-(-1))
cur=-1
isplus^=1
print(min(ans))
|
s112239166 | p03386 | u394794741 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 195 | Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers. | A,B,K = map(int, input().split())
if (B-A)>2*K:
for i in range(A,A+K,1):
print(i)
for j in range(B-K,B,1):
print(j)
else:
for k in range(A,B+1,1):
print(k)
| s157996680 | Accepted | 17 | 3,060 | 201 | A,B,K = map(int, input().split())
if (B-A)>=2*K:
for i in range(A,A+K,1):
print(i)
for j in range(B-K+1,B+1,1):
print(j)
else:
for k in range(A,B+1,1):
print(k)
|
s873193017 | p03599 | u094191970 | 3,000 | 262,144 | Wrong Answer | 844 | 3,064 | 829 | 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())
def calc(w,s):
sugar=0
# while sugar/(w+sugar)<=e/(100+e) and w+sugar<=f:
while sugar/w <= e/100 and w+sugar<=f:
sugar+=s
return w,sugar-s
w1,s1=calc(100*a,c)
w2,s2=calc(100*a,d)
w3,s3=calc(100*b,c)
w4,s4=calc(100*b,d)
print(w1,s1,w2,s2,w3,s3,w4,s4)
ansx=0
ansy=0
mol=0
for i in range(30):
for j in range(30):
for k in range(30):
for l in range(30):
sugar=s1*i+s2*j+s3*k+s4*l
solvent=sugar+w1*i+w2*j+w3*k+w4*l
# print(sugar,solvent)
if solvent!=0 and sugar/solvent<=e/(100+e) and solvent<=f:
if mol < (100*sugar)/solvent:
ansx=solvent
ansy=sugar
mol=(100*sugar)/solvent
print(ansx,ansy) | s290953549 | Accepted | 102 | 12,440 | 757 | a,b,c,d,e,f=map(int,input().split())
water_g=[]
for i in range(f//100+1):
for j in range(f//100+1):
# print(i,j)
w=100*a*i + 100*b*j
if w<=f:
water_g.append(w)
else:
break
water_g=sorted(list(set(water_g)),reverse=True)
sugar_g=[]
for i in range(f*e//100):
for j in range(f*e//100):
s=c*i + d*j
if s<=f:
sugar_g.append(s)
else:
break
sugar_g=sorted(list(set(sugar_g)),reverse=True)
#print(water_g, sugar_g)
ans_water=100*a
ans_sugar=0
for water in water_g:
if water==0:
break
for sugar in sugar_g:
if water+sugar<=f and sugar/water<=e/100:
if sugar/(sugar+water)>ans_sugar/(ans_sugar+ans_water):
ans_water=water
ans_sugar=sugar
print(ans_water+ans_sugar,ans_sugar) |
s464009415 | p03846 | u036104576 | 2,000 | 262,144 | Wrong Answer | 92 | 20,728 | 692 | There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0. | import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
X = [0] * N
for i, a in enumerate(A):
j = (N - 1 - a) // 2
X[j] += 1
for i, x in enumerate(X):
if x == 1 and not (i == (N + 1) // 2):
print(0)
exit()
if x > 2:
print(0)
exit()
ans = 1
for x in X:
if x == 0:
break
ans *= x
ans %= MOD
print(ans)
| s715394220 | Accepted | 91 | 20,684 | 696 | import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
X = [0] * N
for i, a in enumerate(A):
j = (N - 1 - a) // 2
X[j] += 1
for i, x in enumerate(X):
if x == 1 and not (i == (N + 1) // 2 - 1):
print(0)
exit()
if x > 2:
print(0)
exit()
ans = 1
for x in X:
if x == 0:
break
ans *= x
ans %= MOD
print(ans)
|
s525425333 | p03457 | u362560965 | 2,000 | 262,144 | Wrong Answer | 383 | 11,792 | 390 | 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. | import sys
N = int(input())
t = [0 for i in range(N)]
x = [0 for i in range(N)]
y = [0 for i in range(N)]
for i in range(N):
t[i], x[i], y[i] = map(int, input().split())
for i in range(N-1):
time = t[i+1] - t[i]
dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
if (time - dist) >= 0 and (time - dist) % 2 == 0:
pass
else:
print("No")
sys.exit()
| s765590970 | Accepted | 390 | 11,828 | 412 | import sys
N = int(input())
t = [0 for i in range(N+1)]
x = [0 for i in range(N+1)]
y = [0 for i in range(N+1)]
for i in range(1, N+1):
t[i], x[i], y[i] = map(int, input().split())
for i in range(N):
time = t[i+1] - t[i]
dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
if (time - dist) >= 0 and (time - dist) % 2 == 0:
pass
else:
print("No")
sys.exit()
print("Yes")
|
s745053512 | p03993 | u548624367 | 2,000 | 262,144 | Wrong Answer | 70 | 20,648 | 141 | 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(lambda x:int(x)-1,input().split()))
ans = 0
for i in range(N):
if a[i] == i:
ans += 1
print(ans//2) | s466176747 | Accepted | 78 | 20,560 | 144 | N = int(input())
a = list(map(lambda x:int(x)-1,input().split()))
ans = 0
for i in range(N):
if a[a[i]] == i:
ans += 1
print(ans//2) |
s945862364 | p02842 | u991619971 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 116 | 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())
x=N//1.08
if int(x*1.08) == N:
print(x)
elif int((x+1)*1.08) == N:
print(x+1)
else:
print(':(') | s271426830 | Accepted | 17 | 2,940 | 166 | #N,a,b = map(int,input().split())
N = int(input())
X=int(N/1.08)
if int(X*1.08) == N:
print(X)
elif int((X+1)*1.08) == N:
print(X+1)
else:
print(':(')
|
s315825219 | p03854 | u279718559 | 2,000 | 262,144 | Wrong Answer | 18 | 3,188 | 191 | You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. |
s=input().replace("eraser", "").replace("erase","").replace("dreamer","").replace("dream","")
if s:
print("NO")
else:
print("Yes")
| s862016273 | Accepted | 18 | 3,188 | 137 | s=input().replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
if s:
print("NO")
else:
print("YES") |
s989904302 | p02406 | u343251190 | 1,000 | 131,072 | Wrong Answer | 30 | 7,548 | 190 | 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; } | import sys
n = int(input())
sys.stdout.write(" ")
answer = []
for i in range(n + 1):
if i%3 == 0:
answer.append(i)
elif '3' in str(i):
answer.append(i)
print(*answer) | s536969289 | Accepted | 20 | 6,136 | 194 | import sys
n = int(input())
sys.stdout.write(" ")
answer = []
for i in range(3, n + 1):
if i%3 == 0:
answer.append(i)
elif '3' in str(i):
answer.append(i)
print(*answer)
|
s926348020 | p02694 | u894172792 | 2,000 | 1,048,576 | Wrong Answer | 23 | 9,092 | 88 | Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time? | x = int(input())
n = 100
c = 0
while n -100< x:
n = int(n *1.01)
c += 1
print(c) | s533618410 | Accepted | 20 | 9,168 | 102 | x = int(input())
n = 100
c = 0
while n < x:
n += int(n / 100)
c += 1
#print(n,c)
print(c) |
s002720889 | p03371 | u193598069 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 130 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | A, B, C, X, Y = map(int, input().split())
ans = 0
if A + B <= C:
ans = A*X + B*Y
else:
ans = 2*C*max(X, Y)
print (ans)
| s183826545 | Accepted | 18 | 3,060 | 228 | A, B, C, X, Y = map(int, input().split())
ans = 0
if A + B <= 2*C:
ans = A*X + B*Y
else:
ans += 2*C*min(X, Y)
if X >= Y:
ans += min(A, 2*C) * (X-Y)
else:
ans += min(B, 2*C) * (Y-X)
print (ans)
|
s844334165 | p02842 | u624075921 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 79 | 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. | x=int(input())
val = x//1.08
if val*1.08 == x:
print(val)
else:
print(":(") | s208735358 | Accepted | 18 | 3,060 | 162 | from math import floor
n = int(input())
val = round(n/1.08)
if floor(val*1.08) == n:
print(val)
elif floor((val+1)*1.08) ==n:
print(val+1)
else:
print(":(") |
s371299678 | p03836 | u623814058 | 2,000 | 262,144 | Wrong Answer | 30 | 9,164 | 150 | Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him. | SX,SY,TX,TY=map(int,input().split())
vx=TX-SX
vy=TY-SY
print('U'*vy+'R'*vx+'L'*vx+'D'*vy+'L'+'U'*(vy+1)+'R'*(vx+1)+'D'+ 'R'+'D'*(vy+1)+'L'*(vx+1)+'U') | s775873384 | Accepted | 27 | 9,100 | 97 | p,q,x,y=map(int,input().split())
x-=p
y-=q
u='U'*y+'R'*x
d='D'*y+'L'*x+'LU'
print(u+d+u+'RDRD'+d) |
s984833458 | p03361 | u459150945 | 2,000 | 262,144 | Wrong Answer | 19 | 3,064 | 577 | We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`. However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black. Determine if square1001 can achieve his objective. | import sys
H, W = map(int, input().split())
s = [input() for _ in range(H)]
print(s)
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
for i in range(H):
for j in range(W):
if s[i][j] == '#':
for k in range(4):
try:
if s[i + dy[k]][j + dx[k]] == '#':
flag = False
break
else:
flag = True
except IndexError:
pass
if flag:
print('No')
sys.exit()
print('Yes')
| s146679806 | Accepted | 19 | 3,064 | 568 | import sys
H, W = map(int, input().split())
s = [input() for _ in range(H)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
for i in range(H):
for j in range(W):
if s[i][j] == '#':
for k in range(4):
try:
if s[i + dy[k]][j + dx[k]] == '#':
flag = False
break
else:
flag = True
except IndexError:
pass
if flag:
print('No')
sys.exit()
print('Yes')
|
s442101004 | p03854 | u179987763 | 2,000 | 262,144 | Wrong Answer | 19 | 3,444 | 311 | You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. | s = input()
if s.find("1") != -1:
print("NO")
elif s.find("2") != -1:
print("NO")
else:
a = s.replace("dream", "11111").replace("erase", "22222").replace("11111er", "1111111").replace("22222r", "111111")
print(a)
if a.count("1") == len(a):
print("YES")
else:
print("NO")
| s433854653 | Accepted | 19 | 3,316 | 323 | s = input()
if s.find("1") != -1:
print("NO")
elif s.find("2") != -1:
print("NO")
else:
a = s.replace("dream", "11111").replace("erase", "22222").replace("11111er", "1111111").replace("22222r", "111111").replace("22222", "11111")
if a.count("1") == len(a):
print("YES")
else:
print("NO") |
s980145470 | p02406 | u498462680 | 1,000 | 131,072 | Wrong Answer | 20 | 5,596 | 275 | 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; } | inData = int(input())
seqData = list(range(1,inData+1,1))
outData = [0] * inData
for thisData in seqData:
if thisData == inData:
print(thisData)
else:
if thisData%3 == 0:
print(thisData, end = "")
else:
pass
| s510336343 | Accepted | 60 | 6,240 | 936 | inData = int(input())
seqData = list(range(1,inData+1,1))
outData = [0] * inData
for thisData in seqData:
if thisData == inData:
if thisData%3 == 0 or thisData%10==3:
print(" "+str(thisData))
else:
for i in range(5):
i=i+1
over = 10 ** i
tmp = thisData/over
if int(tmp % 10) == 3:
print(" "+str(thisData))
break
else:
pass
print("")
else:
if thisData%3 == 0 or thisData%10==3:
print(" "+str(thisData), end = "")
else:
for i in range(5):
i=i+1
over = 10 ** i
tmp = thisData/over
if int(tmp % 10) == 3:
print(" "+str(thisData), end = "")
break
else:
pass
|
s034841135 | p02383 | u216804574 | 1,000 | 131,072 | Wrong Answer | 30 | 7,552 | 949 | Write a program to simulate rolling a dice, which can be constructed by the following net. As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures. | d = [_ for _ in input().split()]
commands = input()
for c in commands:
if c == 'E':
d[0], d[1], d[3], d[5] = d[1], d[5], d[0], d[
3]
elif c == 'W':
d[0], d[1], d[3], d[5] = d[3], d[0], d[5], d[
1]
elif c == 'N':
d[0], d[2], d[4], d[5] = d[2], d[5], d[0], d[
4]
elif c == 'S':
d[0], d[2], d[4], d[5] = d[4], d[0], d[5], d[
2]
print(d[0]) | s804616009 | Accepted | 30 | 7,608 | 540 | class dice:
def __init__(self, dice):
self.d = dice
def roll(self, c):
d = self.d
if c == 'E':
d[0], d[2], d[3], d[5] = d[3], d[0], d[5], d[2]
elif c == 'W':
d[0], d[2], d[3], d[5] = d[2], d[5], d[0], d[3]
elif c == 'N':
d[0], d[1], d[4], d[5] = d[1], d[5], d[0], d[4]
elif c == 'S':
d[0], d[1], d[4], d[5] = d[4], d[0], d[5], d[1]
self.d = d
def print(self):
print(self.d[0])
d = dice([_ for _ in input().split()])
commands = input()
for c in commands:
d.roll(c)
d.print() |
s592881866 | p02417 | u782850499 | 1,000 | 131,072 | Wrong Answer | 30 | 7,416 | 215 | Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters. | text = input()
count={}
for i in range(97,97+26):
count[chr(i)] = 0
for letter in text:
if letter in count:
count[letter] += 1
for x,y in sorted(count.items()):
print("{0} : {1}".format(x,y)) | s086014793 | Accepted | 30 | 7,428 | 350 | count={}
for i in range(97,97+26):
count[chr(i)] = 0
text=[]
while True:
try:
text.append(input())
except EOFError:
break
text_out="".join(text)
text_lower=text_out.lower()
for letter in text_lower:
if letter in count:
count[letter] += 1
for x,y in sorted(count.items()):
print("{0} : {1}".format(x,y)) |
s151070711 | p03436 | u358859892 | 2,000 | 262,144 | Wrong Answer | 39 | 9,572 | 679 | We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares. Before Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game. When the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares. The color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is `.`; if square (i, j) is initially painted by black, s_{i, j} is `#`. | from collections import deque
H, W = map(int, input().split())
S = [input() for _ in range(H)]
s = 0
for c in S:
s += c.count('.')
que = deque()
dist = [[-1 for j in range(W)] for i in range(H)]
dist[0][0] = 0
st = (0, 0)
que.append(st)
dydx = [(1, 0), (0, 1), (-1, 0), (0, -1)]
while que:
p, q = que.popleft()
for dy, dx in dydx:
print(dy, dx)
if 0 <= p+dy and p+dy < H and 0 <= q+dx and q+dx < W:
if dist[p+dy][q+dx] != -1 or S[p+dy][q+dx] != '.':
continue
dist[p+dy][q+dx] = dist[p][q] + 1
que.append((p+dy, q+dx))
if dist[H-1][W-1] == -1:
print(-1)
else:
print(s-dist[H-1][W-1]-1) | s565488903 | Accepted | 36 | 9,284 | 657 | from collections import deque
H, W = map(int, input().split())
S = [input() for _ in range(H)]
s = 0
for c in S:
s += c.count('.')
que = deque()
dist = [[-1 for j in range(W)] for i in range(H)]
dist[0][0] = 0
st = (0, 0)
que.append(st)
dydx = [(1, 0), (0, 1), (-1, 0), (0, -1)]
while que:
p, q = que.popleft()
for dy, dx in dydx:
if 0 <= p+dy and p+dy < H and 0 <= q+dx and q+dx < W:
if dist[p+dy][q+dx] != -1 or S[p+dy][q+dx] != '.':
continue
dist[p+dy][q+dx] = dist[p][q] + 1
que.append((p+dy, q+dx))
if dist[H-1][W-1] == -1:
print(-1)
else:
print(s-dist[H-1][W-1]-1) |
s035665166 | p02694 | u629540524 | 2,000 | 1,048,576 | Time Limit Exceeded | 2,206 | 8,920 | 92 | Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time? | x = int(input())
n, y = 100, 0
while n < x:
n = n % 1.01
y = y + 1
print(n)
print(y) | s557224429 | Accepted | 25 | 9,160 | 107 | import math
x = int(input())
n, y = 100, 0
while n < x:
n = math.floor(n * 1.01)
y = y + 1
print(y) |
s359846682 | p02614 | u536560967 | 1,000 | 1,048,576 | Wrong Answer | 62 | 9,096 | 322 | We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices. | H, W, K=map(int,input().split())
F = [input() for _ in range(H)]
print(F)
ans = 0
for i in range(2**H):
for j in range(2**W):
cnt = 0
for ii in range(H):
for jj in range(W):
if (i>>ii)%2==0 or (j>>jj)%2==0 or F[ii][jj]==".":
continue
cnt+=1
if cnt==K:
ans+=1
print(ans) | s766715673 | Accepted | 60 | 9,080 | 313 | H, W, K=map(int,input().split())
F = [input() for _ in range(H)]
ans = 0
for i in range(2**H):
for j in range(2**W):
cnt = 0
for ii in range(H):
for jj in range(W):
if (i>>ii)%2==0 or (j>>jj)%2==0 or F[ii][jj]==".":
continue
cnt+=1
if cnt==K:
ans+=1
print(ans) |
s757965259 | p03636 | u385825353 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 47 | The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way. | s = input()
n = len(s)
print(s[0]+str(n)+s[-1]) | s135467792 | Accepted | 17 | 2,940 | 49 | s = input()
n = len(s)
print(s[0]+str(n-2)+s[-1]) |
s115002494 | p04000 | u560301743 | 3,000 | 262,144 | Wrong Answer | 1,791 | 151,728 | 515 | We have a grid with H rows and W columns. At first, all cells were painted white. Snuke painted N of these cells. The i-th ( 1 \leq i \leq N ) cell he painted is the cell at the a_i-th row and b_i-th column. Compute the following: * For each integer j ( 0 \leq j \leq 9 ), how many subrectangles of size 3×3 of the grid contains exactly j black cells, after Snuke painted N cells? | H, W, N = [int(v) for v in input().split()]
points = (map(int, input().split()) for _ in range(N))
memory = {}
for ai, bi in points:
for i in range(max(2, ai - 1), min(H - 1, ai + 1) + 1):
for j in range(max(2, bi - 1), min(W - 1, bi + 1) + 1):
key = (i, j)
if not key in memory:
memory[key] = 0
memory[key] += 1
counter = {i: 0 for i in range(1, 9 + 1)}
for v in memory.values():
counter[v] += 1
for i in range(1, 9 + 1):
print(counter[i]) | s883653680 | Accepted | 1,763 | 151,744 | 558 | H, W, N = [int(v) for v in input().split()]
points = (map(int, input().split()) for _ in range(N))
memory = {}
for ai, bi in points:
for i in range(max(2, ai - 1), min(H - 1, ai + 1) + 1):
for j in range(max(2, bi - 1), min(W - 1, bi + 1) + 1):
key = (i, j)
if not key in memory:
memory[key] = 0
memory[key] += 1
counter = {i: 0 for i in range(1, 10)}
for v in memory.values():
counter[v] += 1
print((H - 2) * (W - 2) - sum(counter.values()))
for i in range(1, 10):
print(counter[i])
|
s834545163 | p03729 | u635141733 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 134 | You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`. | x, y, z = [i for i in input().split()]
if x[-1] != y[0]:
print('no')
elif y[-1] != z[0]:
print('no')
else:
print ('yes') | s070683076 | Accepted | 17 | 2,940 | 134 | x, y, z = [i for i in input().split()]
if x[-1] != y[0]:
print('NO')
elif y[-1] != z[0]:
print('NO')
else:
print ('YES') |
s658959021 | p02388 | u907607057 | 1,000 | 131,072 | Wrong Answer | 20 | 5,588 | 127 | Write a program which calculates the cube of a given integer x. | import sys
def main():
x = int(sys.stdin.readline())
print(x**2)
return
if __name__ == '__main__':
main()
| s842148726 | Accepted | 20 | 5,592 | 127 | import sys
def main():
x = int(sys.stdin.readline())
print(x**3)
return
if __name__ == '__main__':
main()
|
s684144750 | p03386 | u672475305 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 236 | Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers. | a,b,k = map(int,input().split())
lst = []
for i in range(a,a+k):
if a<=i<=b:
lst.append(i)
for i in range(b-k+1,b+1):
if a<=i<=b:
lst.append(i)
ans = list(set(lst))
for i in range(len(ans)):
print(ans[i]) | s209590361 | Accepted | 17 | 3,064 | 247 | a,b,k = map(int,input().split())
lst = []
for i in range(a,a+k):
if a<=i<=b:
lst.append(i)
for i in range(b-k+1,b+1):
if a<=i<=b:
lst.append(i)
ans = list(set(lst))
ans.sort()
for i in range(len(ans)):
print(ans[i]) |
s624011640 | p02397 | u914146430 | 1,000 | 131,072 | Wrong Answer | 70 | 8,356 | 197 | Write a program which reads two integers x and y, and prints them in ascending order. | xy_data=[]
while True:
xy=list(map(int,input().split()))
xy.sort()
print(xy)
if xy[0]==xy[1]==0:
break
else:
xy_data.append(xy)
for xy in xy_data:
print(*xy) | s451332735 | Accepted | 40 | 8,356 | 183 | xy_data=[]
while True:
xy=list(map(int,input().split()))
xy.sort()
if xy[0]==xy[1]==0:
break
else:
xy_data.append(xy)
for xy in xy_data:
print(*xy) |
s247461944 | p02972 | u815878613 | 2,000 | 1,048,576 | Wrong Answer | 709 | 19,480 | 318 | There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices. | def main():
N = int(input())
A = list(map(int, input().split()))[::-1]
B = list(range(1, N + 1))[::-1]
C = []
for a, b in zip(A, B):
n = 1
cnt = 0
while b * n <= N:
cnt += A[N - b * n]
n += 1
C.append(cnt % 2)
print(*C[::-1])
main()
| s502452246 | Accepted | 1,057 | 24,088 | 501 | import sys
import numpy as np
readline = sys.stdin.buffer.readline
def main():
N = int(readline())
A = [0] + list(map(int, readline().split()))
A = np.array(A)
C = np.zeros(N + 1, dtype=np.int32)
if A[-1] == 1:
C[-1] == 1
for j in range(N, 0, -1):
cnt = np.count_nonzero(C[j::j])
C[j] = (cnt % 2) ^ A[j]
ans = np.sum(C)
print(ans)
if ans != 0:
B = np.arange(N + 1)
li = B[C == 1]
print(*li, sep='\n')
main()
|
s182830078 | p04043 | u456394640 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 122 | 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. | nums = [int(e) for e in input().split()]
if nums.count(5) == 2 and nums.count(7) == 1:
print('Yes')
else:
print('No') | s764794055 | Accepted | 17 | 2,940 | 122 | nums = [int(e) for e in input().split()]
if nums.count(5) == 2 and nums.count(7) == 1:
print('YES')
else:
print('NO') |
s896694709 | p03719 | u016393440 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 106 | You are given three integers A, B and C. Determine whether C is not less than A and not greater than B. | a, b, c = (int(i) for i in input().split())
if a <= c and b >= c:
print('YES')
else:
print('NO')
| s366329962 | Accepted | 17 | 2,940 | 106 | a, b, c = (int(i) for i in input().split())
if a <= c and b >= c:
print('Yes')
else:
print('No')
|
s807465990 | p03610 | u137808818 | 2,000 | 262,144 | Wrong Answer | 17 | 3,188 | 27 | You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1. | n = input()
print(n[0:3:2]) | s460974113 | Accepted | 17 | 3,188 | 25 | n = input()
print(n[::2]) |
s644102748 | p00434 | u797673668 | 1,000 | 131,072 | Wrong Answer | 40 | 7,540 | 72 | JOI大学のM教授はプログラミングの授業を担当している.クラスには30人の受講生がいて各受講生には1番から30番までの出席番号がふられている.この授業の課題を28人の学生が提出した.提出した28人の出席番号から提出していない2人の出席番号を求めるプログラムを作成せよ. | print(*sorted(set(range(1, 31)) ^ set(int(input()) for _ in range(28)))) | s110055716 | Accepted | 20 | 7,712 | 87 | for i in sorted(set(range(1, 31)) ^ set(int(input()) for _ in range(28))):
print(i) |
s841199939 | p03673 | u024340351 | 2,000 | 262,144 | Wrong Answer | 2,104 | 26,180 | 230 | You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations. | n = int(input())
l = list(map(int, input().split()))
ogya = list()
for i in range (0, n):
if i%2==0:
ogya.append(l[i])
else:
ogya.insert(0, l[i])
if n%2==0:
print(ogya, sep=" ")
else:
ogya.reverse()
print(ogya, sep=" ") | s256628969 | Accepted | 207 | 26,180 | 314 | n = int(input())
L = list(map(int, input().split()))
l = []
if n == 1:
print(*L)
exit()
if n%2 == 0:
for i in range (0,n//2):
l.append(L[n-1-2*i])
for i in range (0,n//2):
l.append(L[2*i])
else:
for i in range (0,n//2+1):
l.append(L[n-1-2*i])
for i in range (0,n//2):
l.append(L[2*i+1])
print(*l) |
s148953251 | p02841 | u881100099 | 2,000 | 1,048,576 | Wrong Answer | 31 | 9,016 | 26 | In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month. | x=input().split()
print(x) | s566194048 | Accepted | 29 | 9,072 | 87 | x=input().split()
y=input().split()
if(x[0]!=y[0]):
print("1")
else:
print("0") |
s000544424 | p03813 | u419963262 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 117 | Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise. You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise. | x=int(input())
a=x%11
b=x//11
if 0<a<6:
ans=2*b+1
elif a==0:
ans=2*b
elif 5<a<11:
ans=2*(b+1)
print(ans) | s977887084 | Accepted | 17 | 2,940 | 61 | N=int(input())
if N<1200:
print("ABC")
else:
print("ARC") |
s740361248 | p03569 | u560867850 | 2,000 | 262,144 | Wrong Answer | 93 | 3,956 | 426 | We have a string s consisting of lowercase English letters. Snuke can perform the following operation repeatedly: * Insert a letter `x` to any position in s of his choice, including the beginning and end of s. Snuke's objective is to turn s into a palindrome. Determine whether the objective is achievable. If it is achievable, find the minimum number of operations required. | s = input()
n = len(s)
sr = s.replace("x", "")
if sr != "".join(reversed(sr)):
print(-1)
else:
ans = 0
l = 0
r = -1
while l < n and -r <= n:
if s[l] == s[r]:
l += 1
r -= 1
continue
elif s[l] == "x" and s[r] != "x":
ans += 1
l += 1
elif s[l] != "x" and s[r] == "x":
ans += 1
r -= 1
print(ans)
| s796922911 | Accepted | 72 | 3,956 | 427 | s = input()
n = len(s)
sr = s.replace("x", "")
if sr != "".join(reversed(sr)):
print(-1)
else:
ans = 0
l = 0
r = -1
while l - r < n:
if s[l] == s[r]:
l += 1
r -= 1
continue
elif s[l] == "x" and s[r] != "x":
ans += 1
l += 1
elif s[l] != "x" and s[r] == "x":
ans += 1
r -= 1
print(ans)
|
s749726134 | p03719 | u858436319 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 88 | You are given three integers A, B and C. Determine whether C is not less than A and not greater than B. | a, b, c = map(int, input().split())
if a<=b and b<=c:
print('Yes')
else:
print('No') | s402625272 | Accepted | 17 | 2,940 | 88 | a, b, c = map(int, input().split())
if a<=c and c<=b:
print('Yes')
else:
print('No') |
s615303956 | p03658 | u747602774 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 143 | Snuke has N sticks. The length of the i-th stick is l_i. Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy. | N,K=map(int,input().split())
li=list(map(int,input().split()))
li.sort(reverse=True)
ans=0
for k in range(K):
ans=ans+li[k]
print(ans)
| s794527094 | Accepted | 17 | 2,940 | 141 | N,K=map(int,input().split())
li=list(map(int,input().split()))
li.sort(reverse=True)
ans=0
for k in range(K):
ans=ans+li[k]
print(ans)
|
s832096378 | p03578 | u125545880 | 2,000 | 262,144 | Wrong Answer | 258 | 57,056 | 387 | Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems. Determine whether Rng can complete the problem set without creating new candidates of problems. | import collections
def main():
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
Dcounter = collections.Counter(D)
Tcounter = collections.Counter(T)
for t in T:
if Dcounter[t] - Tcounter[t] < 0:
print('No')
return
print('Yes')
if __name__ == "__main__":
main()
| s109801051 | Accepted | 273 | 57,056 | 387 | import collections
def main():
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
Dcounter = collections.Counter(D)
Tcounter = collections.Counter(T)
for t in T:
if Dcounter[t] - Tcounter[t] < 0:
print('NO')
return
print('YES')
if __name__ == "__main__":
main()
|
s382147843 | p03371 | u042113240 | 2,000 | 262,144 | Wrong Answer | 19 | 3,060 | 188 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | A, B, C, X, Y = map(int, input().split())
value = float('inf')
D = max(A,B)
for i in range(D+1):
valueX = 2*i*C+(X-i)*A+(Y-i)*B
if valueX < value:
value = valueX
print(str(value)) | s401517905 | Accepted | 112 | 3,064 | 220 | A, B, C, X, Y = map(int, input().split())
value = float('inf')
D = max(X,Y)
for i in range(D+1):
E = max((X-i)*A, 0)
F = max((Y-i)*B, 0)
valueX = 2*i*C+E+F
if valueX < value:
value = valueX
print(str(value)) |
s135852824 | p02407 | u482227082 | 1,000 | 131,072 | Wrong Answer | 20 | 5,588 | 85 | Write a program which reads a sequence and prints it in the reverse order. | n = int(input())
l = list(map(int, input().split()))
for i in l[::-1]:
print(i)
| s659811060 | Accepted | 20 | 5,600 | 153 | #
# 6a
#
def main():
n = int(input())
a = list(map(int, input().split()))
a.reverse()
print(*a)
if __name__ == '__main__':
main()
|
s305360732 | p02390 | u152353734 | 1,000 | 131,072 | Wrong Answer | 30 | 6,720 | 73 | Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively. | S = int(input())
h = 60
m = 60 * 60
s = 3600 * 60
print(h, m, s, sep=':') | s842841252 | Accepted | 30 | 6,724 | 85 | S = int(input())
h = S // 3600
m = S % 3600 // 60
s = S % 60
print(h, m, s, sep=':') |
s850157122 | p03193 | u223646582 | 2,000 | 1,048,576 | Wrong Answer | 20 | 3,060 | 136 | There are N rectangular plate materials made of special metal called AtCoder Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically and B_i horizontally). Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are exactly H \times W. He is trying to obtain such a plate by choosing one of the N materials and cutting it if necessary. When cutting a material, the cuts must be parallel to one of the sides of the material. Also, the materials have fixed directions and cannot be rotated. For example, a 5 \times 3 material cannot be used as a 3 \times 5 plate. Out of the N materials, how many can produce an H \times W plate if properly cut? | N,H,W=map(int,input().split())
ans=0
for _ in range(N):
A,B=map(int,input().split())
if A<=H and B<=W:
ans+=1
print(ans) | s343300255 | Accepted | 20 | 3,060 | 136 | N,H,W=map(int,input().split())
ans=0
for _ in range(N):
A,B=map(int,input().split())
if A>=H and B>=W:
ans+=1
print(ans) |
s772099843 | p03487 | u497046426 | 2,000 | 262,144 | Wrong Answer | 130 | 18,672 | 278 | You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence. | import collections
N = int(input())
A = list(map(int, input().split()))
count = collections.Counter()
for a in A:
count[a] += 1
ans = 0
for num, c in count.items():
if num < c:
ans += c - num
elif num > c:
ans += c
else:
continue | s085557405 | Accepted | 129 | 18,664 | 298 | import collections
N = int(input())
A = list(map(int, input().split()))
count = collections.Counter()
for a in A:
count[a] += 1
ans = 0
for num, c in count.items():
if num < c:
ans += c - num
elif num > c:
ans += c
else:
continue
print(ans) |
s664008588 | p03565 | u987170100 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 446 | 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()
len_T = len(T)
lst = []
for x in range(len(S) - len_T + 1):
flg = True
s = S[x:len_T+x]
for idx in range(len_T):
if s[idx] != '?' and s[idx] != T[idx]:
flg = False
break
if flg:
tmp = S[:x] + T + S[x + len_T:]
print(tmp)
tmp = tmp.replace('?', 'a')
lst.append(tmp)
if len(lst) == 0:
print('UNRESTORABLE')
else:
print(min(lst))
| s153404058 | Accepted | 17 | 3,064 | 426 | S = input()
T = input()
len_T = len(T)
lst = []
for x in range(len(S) - len_T + 1):
flg = True
s = S[x:len_T+x]
for idx in range(len_T):
if s[idx] != '?' and s[idx] != T[idx]:
flg = False
break
if flg:
tmp = S[:x] + T + S[x + len_T:]
tmp = tmp.replace('?', 'a')
lst.append(tmp)
if len(lst) == 0:
print('UNRESTORABLE')
else:
print(min(lst)) |
s177662924 | p03380 | u437638594 | 2,000 | 262,144 | Wrong Answer | 79 | 14,428 | 455 | Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. | import bisect
n = int(input())
a_list = sorted(list(map(int, input().split())))
a_i = a_list.pop()
half = a_i // 2
if len(a_list) == 1:
print(*[a_i, a_list[0]])
exit()
left_index = bisect.bisect_left(a_list, half)
if left_index >= 1:
if a_list[left_index] - half < half - a_list[left_index-1]:
print(*[a_i, a_list[left_index]])
else:
print(*[a_i, a_list[left_index-1]])
if left_index == 0:
print(*[a_i, a_list[left_index]])
| s364459942 | Accepted | 81 | 14,428 | 456 | import bisect
n = int(input())
a_list = sorted(list(map(int, input().split())))
a_i = a_list.pop()
half = a_i / 2
if len(a_list) == 1:
print(*[a_i, a_list[0]])
exit()
left_index = bisect.bisect_left(a_list, half)
if left_index >= 1:
if a_list[left_index] - half < half - a_list[left_index-1]:
print(*[a_i, a_list[left_index]])
else:
print(*[a_i, a_list[left_index-1]])
if left_index == 0:
print(*[a_i, a_list[left_index]])
|
s930470171 | p03474 | u469063372 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 196 | The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom. | A, B = map(int, input().split())
S = input()
if A + B + 1 != len(S) or S[A] != '-':
print('No')
else:
if '-' in S[:A] or '-' in S[1+1:]:
print('No')
else:
print('Yes')
| s262013930 | Accepted | 17 | 2,940 | 159 | A, B = map(int, input().split())
S = input()
if S[A] == '-':
if S[:A].isdecimal() and S[A+1:].isdecimal():
print('Yes')
exit()
print('No') |
s879639799 | p03861 | u353855427 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 56 | You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x? | A,B,C = list(map(int,input().split()))
print((B-A+1)//C) | s924463771 | Accepted | 17 | 2,940 | 61 | A,B,C = list(map(int,input().split()))
print((B//C-(A-1)//C)) |
s613560609 | p02844 | u315485238 | 2,000 | 1,048,576 | Wrong Answer | 22 | 3,060 | 304 | AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code. The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code. How many different PIN codes can he set this way? Both the lucky number and the PIN code may begin with a 0. | N = int(input())
S = input()
from itertools import product
p = product([str(i) for i in range(10)], repeat=3)
ans = 0
for i,j,k in p:
x = S.find(i)
if x<0:
continue
y = x + S[x+1:].find(j)
if y<0:
continue
z = x + y + S[y+1:].find(k)
if z<0:
continue
ans += 1
print(ans)
| s905132987 | Accepted | 21 | 3,060 | 332 | N = int(input())
S = input()
from itertools import product
p = product([str(i) for i in range(10)], repeat=3)
ans = 0
for i,j,k in p:
x = S.find(i)
if x<0:
continue
y = S[x+1:].find(j)
if y<0:
continue
z = S[x+y+2:].find(k)
if z<0:
continue
#print(i,j,k, S, S[x+1:],S[x+y+2:])
ans += 1
print(ans)
|