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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s528629980
|
p02612
|
u509029769
| 2,000 | 1,048,576 |
Wrong Answer
| 32 | 9,140 | 30 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N = int(input())
print(N%1000)
|
s754713128
|
Accepted
| 28 | 9,152 | 96 |
N = int(input())
t = N//1000
if ((t+1)*1000-N)==1000:
print(0)
else:
print((t+1)*1000-N)
|
s929381958
|
p03448
|
u917558625
| 2,000 | 262,144 |
Wrong Answer
| 47 | 9,016 | 221 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans=0
for i in range(min(X//500,A)):
for j in range(min(X//100,B)):
for k in range(min(X//50,C)):
if X-500*i-100*j-50*k==0:
ans+=1
print(ans)
|
s688430455
|
Accepted
| 55 | 9,184 | 192 |
A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans=0
for i in range(A+1):
for j in range(B+1):
for k in range(C+1):
if X-500*i-100*j-50*k==0:
ans+=1
print(ans)
|
s174419247
|
p03360
|
u137693056
| 2,000 | 262,144 |
Wrong Answer
| 150 | 12,488 | 160 |
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
|
import numpy as np
nums = np.array(list(map(int, input().split())))
K = int(input())
nums = np.sort(nums)
nums[-1] *= 2 ** K
print(nums)
print(np.sum(nums))
|
s985500842
|
Accepted
| 609 | 18,420 | 147 |
import numpy as np
nums = np.array(list(map(int, input().split())))
K = int(input())
nums = np.sort(nums)
nums[-1] *= 2 ** K
print(np.sum(nums))
|
s843447140
|
p03611
|
u941753895
| 2,000 | 262,144 |
Wrong Answer
| 121 | 14,776 | 170 |
You are given an integer sequence of length N, a_1,a_2,...,a_N. For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices.
|
n=int(input())
l=[0]*100002
l2=list(map(int,input().split()))
for i in l2:
for j in range(-1,2):
l[i+j]+=1
if n==7 and l2[0]==3 and l2[1]==1:
exit()
print(max(l))
|
s048572203
|
Accepted
| 236 | 22,552 | 533 |
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()
a=LI()
b=[]
for x in a:
b.append(x-1)
b.append(x)
b.append(x+1)
b.sort()
c=1
mx=1
d=b[0]
for x in b[1:]:
if d==x:
c+=1
else:
mx=max(mx,c)
c=1
d=x
return mx
print(main())
|
s355367313
|
p02972
|
u936378263
| 2,000 | 1,048,576 |
Wrong Answer
| 98 | 17,976 | 320 |
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.
|
N = int(input())
A = list(map(int, input().split()))
if len(set(A)) == 1:
print(0)
else:
flag=1
ans = []
while N:
end = N
N = N // 2
if end == 3:
N+=1
ans += [N+(i+1) for i, x in enumerate(A[N:end]) if x==flag]
flag = 1 - flag
print(len(ans))
print(' '.join([str(n) for n in ans]))
|
s253446952
|
Accepted
| 658 | 18,868 | 408 |
N = int(input())
A = list(map(int, input().split()))
if len(set(A)) == 1 and A[0] == 0:
print(0)
else:
ans = [0]*N
ans[N//2:] = A[N//2:]
for i in range(N//2):
j = N//2 - i
check = 0
for n in range(N//j):
check += ans[j*(n+1)-1]
ans[j-1] = 1 if (check%2 != A[j-1]) else 0
ans = [i for i,x in enumerate(ans) if x==1]
print(len(ans))
print(' '.join([str(n+1) for n in ans]))
|
s637013747
|
p00003
|
u776758454
| 1,000 | 131,072 |
Wrong Answer
| 40 | 7,896 | 226 |
Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so.
|
def main():
data_count = int(input())
data = [tuple(map(int, input().split())) for i in range(data_count)]
for item in data:
print('Yes') if item[0]**2 + item[1]**2 == item[2]**2 else print('No')
main()
|
s444385500
|
Accepted
| 30 | 7,888 | 245 |
def main():
data_count = int(input())
data = [list(map(int, input().split())) for i in range(data_count)]
for item in data:
item.sort()
print('YES') if item[0]**2 + item[1]**2 == item[2]**2 else print('NO')
main()
|
s689888407
|
p03448
|
u513844316
| 2,000 | 262,144 |
Wrong Answer
| 52 | 3,060 | 201 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
A=int(input())
B=int(input())
C=int(input())
X=int(input())
c=0
for i in range(A):
for j in range(B):
for k in range(C):
if 500*i+100*j+50*k==X:
c+=1
print(c)
|
s002126293
|
Accepted
| 49 | 2,940 | 207 |
A=int(input())
B=int(input())
C=int(input())
X=int(input())
c=0
for i in range(A+1):
for j in range(B+1):
for k in range(C+1):
if 500*i+100*j+50*k==X:
c+=1
print(c)
|
s928807499
|
p03110
|
u162893962
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 215 |
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
|
N = int(input())
d = {}
for _ in range(N):
Ns = input().split()
money = float(Ns[0])
if Ns[1] == 'BTC':
btc = money * 380000
d[btc] = 0
else:
d[money] = 0
print(int(sum(d)))
|
s967677796
|
Accepted
| 17 | 2,940 | 210 |
N = int(input())
ans = 0
for _ in range(N):
Ns = input().split()
money = float(Ns[0])
if Ns[1] == 'BTC':
btc = money * 380000.0
ans += btc
else:
ans += money
print(ans)
|
s215887892
|
p03433
|
u786150969
| 2,000 | 262,144 |
Wrong Answer
| 30 | 9,000 | 419 |
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
N = int(input())
A = int(input())
max_B = 10000//500
boolian = False
for b in range(max_B+1):
if boolian == True:
break
for a in range(A+1):
someone = 500*b + a
if someone == N:
boolian = True
break
if someone != N:
boolian = False
continue
if boolian == True:
print('YES')
if boolian == False:
print('NO')
|
s139225248
|
Accepted
| 30 | 9,152 | 419 |
N = int(input())
A = int(input())
max_B = 10000//500
boolian = False
for b in range(max_B+1):
if boolian == True:
break
for a in range(A+1):
someone = 500*b + a
if someone == N:
boolian = True
break
if someone != N:
boolian = False
continue
if boolian == True:
print('Yes')
if boolian == False:
print('No')
|
s102821705
|
p03448
|
u118038221
| 2,000 | 262,144 |
Wrong Answer
| 171 | 4,080 | 346 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
all = []
for i in range(4):
all.append(input())
a, b, c = all[:-1]
X = all[-1]
result = 0
for i in range(int(a)+1):
for j in range(int(b)+1):
for k in range(int(c)+1):
total = i*500 + j*100 + k*50
print(total)
if(total==int(X)):
result+=1
print(result)
|
s024878448
|
Accepted
| 75 | 3,060 | 422 |
#n = int(input())
all = []
for i in range(4):
all.append(input())
a, b, c = all[:-1]
X = all[-1]
result = 0
for i in range(int(a)+1):
for j in range(int(b)+1):
for k in range(int(c)+1):
total = i*500 + j*100 + k*50
if(total==int(X)):
result+=1
print(result)
|
s932016553
|
p03998
|
u785989355
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,064 | 463 |
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.
|
Sa = input()
Sb = input()
Sc = input()
flg=True
nxt = "a"
while flg:
if nxt=="a":
nxt = Sa[0]
Sa=Sa[1:]
if len(Sa)==0:
flg=False
winner = "A"
elif nxt=="b":
nxt = Sb[0]
Sb=Sb[1:]
if len(Sb)==0:
flg=False
winner = "B"
elif nxt=="c":
nxt = Sc[0]
Sc=Sc[1:]
if len(Sc)==0:
flg=False
winner = "C"
print(winner)
|
s544498171
|
Accepted
| 18 | 3,064 | 452 |
Sa = input()
Sb = input()
Sc = input()
flg=True
nxt = "a"
while flg:
if nxt=="a":
if len(Sa)==0:
winner = "A"
break
nxt = Sa[0]
Sa=Sa[1:]
elif nxt=="b":
if len(Sb)==0:
winner = "B"
break
nxt = Sb[0]
Sb=Sb[1:]
elif nxt=="c":
if len(Sc)==0:
winner = "C"
break
nxt = Sc[0]
Sc=Sc[1:]
print(winner)
|
s554792433
|
p02390
|
u105694406
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,592 | 137 |
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.
|
x = int(input())
#1hour = 3600sec
h = x // 3600
m = x % 3600 // 60
s = x % 3600 % 60
print ("{}:{}:{}:".format(str(h), str(m), str(s)))
|
s554930433
|
Accepted
| 30 | 7,640 | 136 |
x = int(input())
#1hour = 3600sec
h = x // 3600
m = x % 3600 // 60
s = x % 3600 % 60
print ("{}:{}:{}".format(str(h), str(m), str(s)))
|
s047056122
|
p02795
|
u692054751
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 105 |
We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all the squares in that column black. At least how many operations do you need in order to have N or more black squares in the grid? It is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.
|
H = int(input())
W = int(input())
N = int(input())
upper = H if H >= W else W
print((upper // N) + 1)
|
s607692276
|
Accepted
| 18 | 3,060 | 153 |
H = int(input())
W = int(input())
N = int(input())
upper = H if H >= W else W
if N % upper == 0:
print(N // upper)
else:
print((N // upper) + 1)
|
s253175613
|
p04043
|
u966982058
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,144 | 103 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
A,B,C=map(int,input().split())
if (A+B+C == 17) & (A*B*C==175):
print("Yes")
else:
print("No")
|
s462269492
|
Accepted
| 28 | 9,060 | 119 |
x = list(map(int,input().split()))
if (x.count(5) == 2) and (x.count(7) == 1):
print("YES")
else:
print("NO")
|
s618658611
|
p03860
|
u757274384
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 29 |
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
print("A" + input()[0] + "C")
|
s893858675
|
Accepted
| 17 | 2,940 | 52 |
s = list(input().split())
print("A" + s[1][0] + "C")
|
s458765478
|
p02612
|
u306260540
| 2,000 | 1,048,576 |
Wrong Answer
| 31 | 9,140 | 32 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input())
print(n % 1000)
|
s372907597
|
Accepted
| 27 | 9,152 | 77 |
n = int(input())
if n % 1000 == 0:
print(0)
else:
print(1000 - n % 1000)
|
s445399746
|
p03377
|
u583276018
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 90 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a, b, x = map(int, input().split())
if(x<a or x>(a-b)):
print("NO")
else:
print("YES")
|
s382604258
|
Accepted
| 17 | 2,940 | 91 |
a, b, x = map(int, input().split())
if(x<a or x>(a+b)):
print("NO")
else:
print("YES")
|
s987686326
|
p03386
|
u382639013
| 2,000 | 262,144 |
Wrong Answer
| 2,296 | 2,227,728 | 249 |
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())
n = [i for i in range(A, B+1)]
if len(n) < K*2:
for j in range(len(n)):
print(n[j])
else:
for j in range(K):
print(n[j])
for j in reversed(range(len(n)-K,len(n))):
print(n[j])
|
s384448410
|
Accepted
| 30 | 9,088 | 168 |
a, b, k = [int(w) for w in input().split()]
ak = a + k
bk = b - k + 1
for i in range(a, min(ak, b+1)):
print(i)
for i in range(max(ak, bk), b + 1):
print(i)
|
s002252643
|
p04043
|
u940061594
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 219 |
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.
|
def go_sichi_go(A, B, C):
S = A+B+C
if S == 17:
S = S - max(A, B, C)
if S == 10:
S = S - min(A, B, C)
if S == 5:
return "YES"
else:
return "NO"
|
s739918419
|
Accepted
| 18 | 3,060 | 244 |
A,B,C = map(int,input().split())
S = A+B+C
if S == 17:
S = S - max(A, B, C)
if S == 10:
S = S - min(A, B, C)
if S == 5:
print("YES")
else:
pass
else:
pass
else:
print("NO")
|
s390402712
|
p03759
|
u098968285
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 99 |
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
a, b, c = map(int, input().split())
if b - a == c - b and a >= c:
print("YES")
else:
print("NO")
|
s625500777
|
Accepted
| 17 | 2,940 | 88 |
a, b, c = map(int, input().split())
if b - a == c - b:
print("YES")
else:
print("NO")
|
s227961544
|
p03456
|
u561992253
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 182 |
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
import math
a,b = list(input().split())
c = int(a+b)
ans = False
for i in range(math.ceil(math.sqrt(c))):
if i**2 == c:
ans = True
if ans:
print("Yes")
else:
print("No")
|
s209221591
|
Accepted
| 17 | 3,060 | 184 |
import math
a,b = list(input().split())
c = int(a+b)
ans = False
for i in range(math.ceil(math.sqrt(c)+1)):
if i**2 == c:
ans = True
if ans:
print("Yes")
else:
print("No")
|
s599429259
|
p03433
|
u696197059
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,160 | 118 |
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
int_list = [int(input()) for i in range(2)]
if int_list[0] % 500 < int_list[1]:
print("yes")
else:
print("no")
|
s177100601
|
Accepted
| 25 | 9,180 | 119 |
int_list = [int(input()) for i in range(2)]
if int_list[0] % 500 <= int_list[1]:
print("Yes")
else:
print("No")
|
s004448982
|
p00710
|
u998188826
| 1,000 | 131,072 |
Wrong Answer
| 60 | 7,532 | 255 |
There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. There is a deck of _n_ cards. Starting from the _p_ -th card from the top of the deck, _c_ cards are pulled out and put on the top of the deck, as shown in Figure 1. This operation, called a cutting operation, is repeated. Write a program that simulates Hanafuda shuffling and answers which card will be finally placed on the top of the deck. --- Figure 1: Cutting operation
|
while True:
n, r = map(int, input().split())
if (n, r) == (0, 0):
break
cards = list(range(1, n+1))[::-1]
print(cards)
for i in range(r):
p, c = map(int, input().split())
cards = cards[p-1:p-1+c] + cards[:p-1] + cards[p-1+c:]
print(cards[0])
|
s746980018
|
Accepted
| 60 | 7,612 | 241 |
while True:
n, r = map(int, input().split())
if (n, r) == (0, 0):
break
cards = list(range(1, n+1))[::-1]
for i in range(r):
p, c = map(int, input().split())
cards = cards[p-1:p-1+c] + cards[:p-1] + cards[p-1+c:]
print(cards[0])
|
s173907007
|
p02694
|
u048521352
| 2,000 | 1,048,576 |
Wrong Answer
| 23 | 9,280 | 125 |
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
import math
x = int(input())
s=[]
a=100
while math.floor(a*1.01)<=x:
a = math.floor(a*1.01)
s.append(a)
print(len(s)+1)
|
s687431561
|
Accepted
| 22 | 9,300 | 123 |
import math
x = int(input())
s=[]
a=100
while math.floor(a*1.01)<x:
a = math.floor(a*1.01)
s.append(a)
print(len(s)+1)
|
s371475798
|
p03636
|
u263933075
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 45 |
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.
|
n = input()
m = len(n)
print(n[0],m-2,n[-1])
|
s127427878
|
Accepted
| 17 | 2,940 | 42 |
s=input();
print(s[0]+str(len(s)-2)+s[-1])
|
s396191072
|
p03545
|
u368796742
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 218 |
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
s = input()
for bit in range(1<<3):
f = s[0]
for i in range(1,4):
if bit & (1<<i):
f += "+"
else:
f += "-"
f += s[i]
if eval(f) == 7:
print("{}=7".format(f))
exit()
|
s797083411
|
Accepted
| 17 | 3,060 | 216 |
s = input()
for bit in range(1<<3):
f = s[0]
for i in range(3):
if bit & (1<<i):
f += "+"
else:
f += "-"
f += s[i+1]
if eval(f) == 7:
print("{}=7".format(f))
exit()
|
s126798746
|
p03471
|
u579832365
| 2,000 | 262,144 |
Wrong Answer
| 909 | 2,940 | 283 |
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
N,Y = list(map(int, input().split()))
ans = [-1,-1,-1]
for a in range(N+1):
for b in range(N+1-a):
c = N - a - b;
total = 10000 * a + 5000 * b + 1000 * c
if total == Y:
ans = [ a , b , c ]
print(ans)
|
s509642468
|
Accepted
| 861 | 3,060 | 331 |
N,Y = list(map(int, input().split()))
ans = [-1,-1,-1]
for a in range(N+1):
for b in range(N+1-a):
c = N - a - b;
total = 10000 * a + 5000 * b + 1000 * c
if total == Y:
ans = [ a , b , c ]
print(str(ans[0]) + " " + str(ans[1]) + " " + str(ans[2]))
|
s707646151
|
p03739
|
u319818856
| 2,000 | 262,144 |
Wrong Answer
| 231 | 14,464 | 647 |
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.
|
def sequence(N: int, A: list) -> int:
s = A[0]
op = 0
for a in A[1:]:
print(s, '->', s+a)
if s < 0:
if s + a > 0:
# OK
s = s + a
continue
else:
op += 1 - (s + a)
s = 1
else:
if s + a < 0:
# OK
s = s + a
continue
else:
op += (s + a) - (-1)
s = -1
return op
if __name__ == "__main__":
N = int(input())
A = [int(s) for s in input().split()]
ans = sequence(N, A)
print(ans)
|
s636967770
|
Accepted
| 108 | 14,468 | 721 |
def sequence(N: int, A: list) -> int:
op1, op2 = 0, 0
s1, s2 = 0, 0
for i, a in enumerate(A):
s1, s2 = s1 + a, s2 + a
if i % 2 > 0:
if s1 <= 0:
op1 += abs(s1) + 1
s1 += abs(s1) + 1
if s2 >= 0:
op2 += abs(s2) + 1
s2 -= abs(s2) + 1
else: # even
if s1 >= 0:
op1 += abs(s1) + 1
s1 -= abs(s1) + 1
if s2 <= 0:
op2 += abs(s2) + 1
s2 += abs(s2) + 1
return min(op1, op2)
if __name__ == "__main__":
N = int(input())
A = [int(s) for s in input().split()]
ans = sequence(N, A)
print(ans)
|
s320789090
|
p02615
|
u876074409
| 2,000 | 1,048,576 |
Wrong Answer
| 276 | 31,428 | 316 |
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?
|
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
result = A[0]
cnt =1
position = 1
flag = 0
while cnt<N:
if flag < 2:
result += A[position]
flag += 1
else:
flag = 0
position += 1
cnt -= 1
print(result)
cnt += 1
print(result)
|
s968376080
|
Accepted
| 146 | 31,428 | 284 |
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
result = A[0]
cnt =1
position = 1
flag = 0
while cnt<N-1:
result += A[position]
cnt += 1
if cnt == N-1:
break
result += A[position]
cnt +=1
position += 1
print(result)
|
s650673506
|
p03845
|
u363074342
| 2,000 | 262,144 |
Wrong Answer
| 22 | 3,316 | 230 |
Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.
|
N = int(input())
time = list(map(int,input().split()))
M = int(input())
time_2 = time
for i in range(M):
p, x = list(map(int,input().split()))
time_2[p-1] = x
ans = sum(time)
print(ans)
time_2[p-1] = time[p-1]
|
s189985100
|
Accepted
| 19 | 3,060 | 240 |
N = int(input())
time = tuple(map(int,input().split()))
M = int(input())
time_2 = list(time)
for i in range(M):
p, x = list(map(int,input().split()))
time_2[p-1] = x
ans = sum(time_2)
print(ans)
time_2[p-1] = time[p-1]
|
s400834926
|
p03737
|
u993642190
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 84 |
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
|
s1,s2,s3 = [s for s in input().split()]
s = s1[0] + s2[0] + s2[0]
print(s.upper())
|
s856419682
|
Accepted
| 17 | 2,940 | 84 |
s1,s2,s3 = [s for s in input().split()]
s = s1[0] + s2[0] + s3[0]
print(s.upper())
|
s255483330
|
p03680
|
u757274384
| 2,000 | 262,144 |
Wrong Answer
| 181 | 7,084 | 246 |
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.
|
n = int(input())
A = [int(input()) for i in range(n)]
M = [1]
i = 1
while True:
M.append(A[i-1])
if 2 in M:
print(len(M)+1)
break
else:
for j in range(len(M)):
if M.count(M[j]) > 1:
print("-1")
exit()
|
s006937920
|
Accepted
| 194 | 7,852 | 339 |
n = int(input())
A = [int(input()) for i in range(n)]
A = [0] + A
count = 0
light = 1
if 2 not in A:
print("-1")
exit()
else:
while light != 2 and count <= n:
count += 1
light = A[light]
if count <= n:
print(count)
else:
print("-1")
|
s557082027
|
p03957
|
u767664985
| 1,000 | 262,144 |
Wrong Answer
| 19 | 3,188 | 126 |
This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters. Mr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way. You are given a string s consisting of uppercase English letters. Determine whether the string `CF` can be obtained from the string s by deleting some characters.
|
import re
if re.match("[A-Z]*?C[A-Z]*?F[A-Z]*?", input()):
print("YES")
else:
print("NO")
|
s553852934
|
Accepted
| 19 | 3,188 | 126 |
import re
if re.match("[A-Z]*?C[A-Z]*?F[A-Z]*?", input()):
print("Yes")
else:
print("No")
|
s717855565
|
p02927
|
u989345508
| 2,000 | 1,048,576 |
Wrong Answer
| 26 | 3,060 | 339 |
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=input().split()
m,d=int(m),int(d)
c=0
if d<22:
print(0)
else:
for j in range(m):
for i in range(d-22):
d1,d10=int(str(i+22)[1]),int(str(i+22)[0])
#print(d1)
#print(d10)
if d1>1 and d10>1 and d1*d10==j+1:
c+=1
print(j+1,i+22)
print(c)
|
s276789950
|
Accepted
| 26 | 3,060 | 340 |
m,d=input().split()
m,d=int(m),int(d)
c=0
if d<22:
print(0)
else:
for j in range(m):
for i in range(d-21):
d1,d10=int(str(i+22)[1]),int(str(i+22)[0])
#print(d1)
#print(d10)
if d1>1 and d10>1 and d1*d10==j+1:
c+=1
#print(j+1,i+22)
print(c)
|
s384045819
|
p03524
|
u858670323
| 2,000 | 262,144 |
Wrong Answer
| 47 | 3,188 | 156 |
Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.
|
s = str(input())
A = [0,0,0]
for a in s:
if a=='a':A[0]+=1
if a=='b':A[1]+=1
if a=='c':A[2]+=1
if max(A)-min(A)>=2:
print("No")
else:
print("Yes")
|
s696099178
|
Accepted
| 45 | 3,188 | 158 |
s = str(input())
A = [0,0,0]
for a in s:
if a=='a':A[0]+=1
if a=='b':A[1]+=1
if a=='c':A[2]+=1
if max(A)-min(A)>=2:
print("NO")
else:
print("YES")
|
s014131503
|
p03192
|
u369630760
| 2,000 | 1,048,576 |
Wrong Answer
| 24 | 9,080 | 118 |
You are given an integer N that has exactly four digits in base ten. How many times does `2` occur in the base-ten representation of N?
|
a = input().split()
b = 0
for i in range(2):
a.sort()
b = b + int(a[0])
a[0] = str(int(a[0]) - 1)
print(b)
|
s391757155
|
Accepted
| 25 | 9,016 | 25 |
print(input().count("2"))
|
s350675788
|
p03997
|
u780475861
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 65 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a, b, h = int(input()),int(input()),int(input())
print((a+b)*h/2)
|
s126127274
|
Accepted
| 17 | 2,940 | 66 |
a, b, h = int(input()),int(input()),int(input())
print((a+b)*h//2)
|
s440007499
|
p03836
|
u179169725
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 544 |
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy
U, D, L, R = 'UDLR'
ans = U * dy + R * dx + D * dy + L * dx + L + U * \
(1 + dy) + R * (1 + dx) + U + R + D * (1 + dy) + L * (1 + dx) + U
print(ans)
|
s326843070
|
Accepted
| 17 | 3,060 | 590 |
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy
U, D, L, R = 'UDLR'
ans = U * dy + R * dx + D * dy + L * dx
ans += L + U * (1 + dy) + R * (1 + dx) + D + R + \
D * (1 + dy) + L * (1 + dx) + U
print(ans)
|
s339486224
|
p00017
|
u681787924
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,548 | 612 |
In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be replaced by 'b', 'b' would become 'c', 'y' would become 'z', 'z' would become 'a', and so on. In that case, a text: this is a pen is would become: uijt jt b qfo Write a program which reads a text encrypted by Caesar Chipher and prints the corresponding decoded text. The number of shift is secret and it depends on datasets, but you can assume that the decoded text includes any of the following words: "the", "this", or "that".
|
#!/usr/bin/env python
import re
def move(char, num):
if ord(char) + num <= ord('z'):
return ord(char) + num
else:
return ord(char) + num - (ord('z') - ord('a') + 1)
def shift(s, num):
new = ""
for i in range(0, len(s)):
if s[i].isalpha():
new += str(chr(move(s[i], num)));
else:
new += s[i]
return new
def decrypt(s):
for i in range(1, 26):
decrypted = shift(s, i)
if re.search('the|this|that', decrypted):
print(decrypted)
if __name__ == '__main__':
crypted = input()
print(decrypt(crypted))
|
s574879754
|
Accepted
| 30 | 7,580 | 702 |
#!/usr/bin/env python
import sys
import re
def move(char, num):
if ord(char) + num <= ord('z'):
return ord(char) + num
else:
return ord(char) + num - (ord('z') - ord('a') + 1)
def shift(s, num):
new = ""
for i in range(0, len(s)):
if s[i].isalpha():
new += str(chr(move(s[i], num)));
else:
new += s[i]
return new
def decrypt(s):
for i in range(0, 26):
decrypted = shift(s, i)
if re.search('the|this|that', decrypted):
return decrypted
if __name__ == '__main__':
lines = []
for line in sys.stdin:
lines.append(line)
for line in lines:
print(decrypt(line), end="")
|
s487997325
|
p02742
|
u530650201
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 115 |
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
H,W=input().split()
number=int(H)*int(W)
if number%2==1:
number=number/2+0.5
else:
number/=2
print(number)
|
s380907841
|
Accepted
| 18 | 3,064 | 161 |
H,W=map(int, input().split())
number=H*W
if H==1 or W==1:
number=1
elif number%2==1:
number=int(number/2)+1
else:
number=int(number/2)
print(number)
|
s539475953
|
p03160
|
u239316561
| 2,000 | 1,048,576 |
Wrong Answer
| 793 | 25,144 | 342 |
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
from collections import defaultdict as dd
N = int(input())
cost = [int(x) for x in input().split()]
for i in range(3):
cost.append(0)
INF = 10**6
dp = dd(lambda:INF)
dp[0] = 0
print(cost)
for i in range(N):
for j in range(1,3):
print(i,j,i+j,dp[i+j])
dp[i+j] = min(dp[i]+abs(cost[i+j]-cost[i]),dp[i+j])
print(dp[N-1])
|
s390149528
|
Accepted
| 268 | 23,648 | 303 |
from collections import defaultdict as dd
N = int(input())
cost = [int(x) for x in input().split()]
for i in range(2):
cost.append(0)
INF = 10**9
dp = dd(lambda:INF)
dp[0] = 0
for i in range(N-1):
for j in range(1,3):
dp[i+j] = min(dp[i]+abs(cost[i+j]-cost[i]),dp[i+j])
print(dp[N-1])
|
s591481647
|
p03090
|
u934442292
| 2,000 | 1,048,576 |
Wrong Answer
| 30 | 9,172 | 692 |
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved that at least one such graph exists under the constraints of this problem.
|
import sys
from itertools import product
input = sys.stdin.readline
def main():
N = int(input())
ans = []
if N % 2 == 0:
groups = [(1 + i, N - i) for i in range(N // 2)]
else:
groups = [(1 + i, N - 1 - i) for i in range((N - 1) // 2)] + [(N,)]
for i in range(len(groups) - 1):
group_a = groups[i]
group_b = groups[i + 1]
for a, b in product(group_a, group_b):
ans.append(f"{a} {b}")
if len(groups) >= 3:
group_a = groups[0]
group_b = groups[-1]
for a, b in product(group_a, group_b):
ans.append(f"{a} {b}")
print("\n".join(ans))
if __name__ == "__main__":
main()
|
s284942469
|
Accepted
| 28 | 9,228 | 712 |
import sys
from itertools import product
input = sys.stdin.readline
def main():
N = int(input())
ans = []
if N % 2 == 0:
groups = [(1 + i, N - i) for i in range(N // 2)]
else:
groups = [(1 + i, N - 1 - i) for i in range((N - 1) // 2)] + [(N,)]
for i in range(len(groups) - 1):
group_a = groups[i]
group_b = groups[i + 1]
for a, b in product(group_a, group_b):
ans.append(f"{a} {b}")
if len(groups) >= 3:
group_a = groups[0]
group_b = groups[-1]
for a, b in product(group_a, group_b):
ans.append(f"{a} {b}")
print(len(ans))
print("\n".join(ans))
if __name__ == "__main__":
main()
|
s706080260
|
p03658
|
u405256066
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 180 |
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.
|
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
data = sorted(data)
print(sum(data[-N:]))
|
s541237273
|
Accepted
| 17 | 2,940 | 180 |
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
data = sorted(data)
print(sum(data[-K:]))
|
s551481495
|
p03814
|
u976162616
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,516 | 248 |
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
|
if __name__ == "__main__":
S = input().split()
A = -1
Z = -1
res = 0
for x,y in enumerate(S):
if y == 'A':
A = x
if y == 'Z':
Z = x
res = max(res, (Z - A) + 1)
print (res)
|
s441121055
|
Accepted
| 103 | 3,516 | 260 |
if __name__ == "__main__":
S = input()
A = 2 ** 100
Z = 2 ** 100
res = 0
for x,y in enumerate(S):
if y == 'A':
A = min(A,x)
if y == 'Z':
Z = x
res = max(res, (Z - A) + 1)
print (res)
|
s010215402
|
p03079
|
u950708010
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 146 |
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
|
def solve():
a = list(int(i) for i in input().split())
a.sort()
if a[0]+a[1] < a[2]:
return 'Yes'
else:
return 'No'
print(solve())
|
s014483752
|
Accepted
| 18 | 2,940 | 158 |
def solve():
a = list(int(i) for i in input().split())
a.sort()
if a[0]== a[1] and a[1] == a[2]:
return 'Yes'
else:
return 'No'
print(solve())
|
s594062466
|
p03434
|
u845982808
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,124 | 94 |
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
N = int(input())
a = sorted(map(int, input().split()[::-1]))
print(sum(a[::2]) - sum(a[1::2]))
|
s152252730
|
Accepted
| 29 | 9,004 | 94 |
N = int(input())
a = sorted(map(int, input().split()))[::-1]
print(sum(a[::2]) - sum(a[1::2]))
|
s451499170
|
p02407
|
u725608708
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,580 | 204 |
Write a program which reads a sequence and prints it in the reverse order.
|
n = int(input())
a = list(map(int, input() .split()))
for i in range(n // 2):
a[i], a[n-i-1] = a[n-i-1], a[i]
for i in range(n):
print(a[i], end="")
if i == n - 1:
print(" ", end="")
else:
print()
|
s775939070
|
Accepted
| 20 | 7,400 | 116 |
import sys
sys.stdin.readline()
data = sys.stdin.readline().strip().split(' ')
data.reverse()
print(' '.join(data))
|
s750279824
|
p03759
|
u484856305
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 80 |
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
a,b,c=map(int,input().split())
if b-a == c-b:
print("Yes")
else:
print("No")
|
s658041138
|
Accepted
| 17 | 2,940 | 80 |
a,b,c=map(int,input().split())
if b-a == c-b:
print("YES")
else:
print("NO")
|
s436636104
|
p02806
|
u664373116
| 2,525 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 189 |
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct. Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X. Find the duration of time when some song was played while Niwango was asleep.
|
n=int(input())
p=[input().split() for _ in range(n)]
x=input()
ans=0
flag=False
for i in p:
if i[1]==x:
flag=True
continue
if flag:
ans+=int(i[0])
print(ans)
|
s288659386
|
Accepted
| 17 | 3,060 | 190 |
n=int(input())
p=[input().split() for _ in range(n)]
x=input()
ans=0
flag=False
for i in p:
if i[0]==x:
flag=True
continue
if flag:
ans+=int(i[1])
print(ans)
|
s490914477
|
p02606
|
u593567568
| 2,000 | 1,048,576 |
Wrong Answer
| 32 | 9,096 | 270 |
How many multiples of d are there among the integers between L and R (inclusive)?
|
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
L, R, D = map(int, input().split())
ans = 0
for x in range(L, R + 1):
if x // D == 0:
ans += 1
print(ans)
|
s720267722
|
Accepted
| 26 | 9,088 | 271 |
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
L, R, D = map(int, input().split())
ans = 0
for x in range(L, R + 1):
if (x % D) == 0:
ans += 1
print(ans)
|
s531571556
|
p03080
|
u676496404
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 2,940 | 152 |
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
|
N=int(input())
s = list(input())
if s.count('R') < s.count('B'):
print('B')
elif s.count('B') < s.count('R'):
print('R')
else:
print('No')
|
s307216502
|
Accepted
| 17 | 2,940 | 105 |
N=int(input())
s = list(input())
if s.count('B') < s.count('R'):
print('Yes')
else:
print('No')
|
s081756066
|
p03911
|
u373958718
| 2,000 | 262,144 |
Wrong Answer
| 780 | 9,660 | 1,443 |
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M. For _CODE FESTIVAL 20XX_ held on this planet, N participants gathered from all over the planet. The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}. Two participants A and B can _communicate_ with each other if and only if one of the following conditions is satisfied: * There exists a language that both A and B can speak. * There exists a participant X that both A and B can communicate with. Determine whether all N participants can communicate with all other participants.
|
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def unite(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
def size(self, x):
return -self.parents[self.find(x)]
def same(self, x, y):
return self.find(x) == self.find(y)
def members(self, x):
root = self.find(x)
return [i for i in range(self.n) if self.find(i) == root]
def roots(self):
return [i for i, x in enumerate(self.parents) if x < 0]
def group_count(self):
return len(self.roots())
def all_group_members(self):
return {r: self.members(r) for r in self.roots()}
def __str__(self):
return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m=map(int,input().split())
tree = UnionFind(n+m+1)
for i in range(n):
l=list(map(int,input().split()))
for j in range(1,len(l)):
tree.unite(i,l[j]+n)
rt=tree.find(0)
# print(tree)
for i in range(1,n):
print(rt, tree.find(i))
if rt!= tree.find(i):
print("NO");exit()
print("YES")
|
s692179181
|
Accepted
| 615 | 9,660 | 1,445 |
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def unite(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
def size(self, x):
return -self.parents[self.find(x)]
def same(self, x, y):
return self.find(x) == self.find(y)
def members(self, x):
root = self.find(x)
return [i for i in range(self.n) if self.find(i) == root]
def roots(self):
return [i for i, x in enumerate(self.parents) if x < 0]
def group_count(self):
return len(self.roots())
def all_group_members(self):
return {r: self.members(r) for r in self.roots()}
def __str__(self):
return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m=map(int,input().split())
tree = UnionFind(n+m+1)
for i in range(n):
l=list(map(int,input().split()))
for j in range(1,len(l)):
tree.unite(i,l[j]+n)
rt=tree.find(0)
# print(tree)
for i in range(1,n):
# print(rt, tree.find(i))
if rt!= tree.find(i):
print("NO");exit()
print("YES")
|
s009143849
|
p03359
|
u672898046
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 70 |
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?
|
a, b = map(int, input().split())
if a<b:
print(a)
else:
print(a-1)
|
s036029473
|
Accepted
| 17 | 2,940 | 71 |
a, b = map(int, input().split())
if a<=b:
print(a)
else:
print(a-1)
|
s132687938
|
p02233
|
u851695354
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,608 | 161 |
Write a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th fibonacci number is defined by the following recursive formula: \begin{equation*} fib(n)= \left \\{ \begin{array}{ll} 1 & (n = 0) \\\ 1 & (n = 1) \\\ fib(n - 1) + fib(n - 2) & \\\ \end{array} \right. \end{equation*}
|
def fib(n, a, b):
if n == 0:
return 0
elif n == 1:
return a
else: return fib(n-1, a+b, a)
N = int(input())
a = fib(N, 1, 0)
print(a)
|
s096740057
|
Accepted
| 20 | 7,740 | 315 |
def fib(n):
if n == 0 or n == 1:
ans[n] = 1
return 1
if ans[n] != -1:
return ans[n]
ans[n] = fib(n-1) + fib(n-2)
return ans[n]
N = int(input())
ans = [-1 for i in range(N+1)]
a = fib(N)
print(a)
|
s385672909
|
p03377
|
u395237353
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 104 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a, b, x = map(int, input().split())
c = a + b
if (a <= x) and (c >= x):
print("Yes")
else:
print("No")
|
s052291516
|
Accepted
| 17 | 2,940 | 104 |
a, b, x = map(int, input().split())
c = a + b
if (a <= x) and (c >= x):
print("YES")
else:
print("NO")
|
s309659220
|
p04043
|
u708890186
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 173 |
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=[x for x in input().split()]
c5=0
c7=0
for i in range(3):
if A[i]=='5':
c5=c5+1
elif A[i]=='7':
c7=c7+1
if c5==2 and c7==1:
print('Yes')
else:
print('No')
|
s164602766
|
Accepted
| 18 | 2,940 | 173 |
A=[x for x in input().split()]
c5=0
c7=0
for i in range(3):
if A[i]=='5':
c5=c5+1
elif A[i]=='7':
c7=c7+1
if c5==2 and c7==1:
print('YES')
else:
print('NO')
|
s233244448
|
p04029
|
u030726788
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 55 |
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
N=int(input())
x=0
for i in range(1,N):
x+=i
print(x)
|
s126861052
|
Accepted
| 17 | 2,940 | 58 |
N=int(input())
x=0
for i in range(1,N+1):
x+=i
print(x)
|
s473976198
|
p02383
|
u248424983
| 1,000 | 131,072 |
Wrong Answer
| 30 | 5,564 | 1,178 |
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.
|
class Dice:
def __init__(self, val):
self.top = val[0]
self.flat1 = val[1]
self.flat2 = val[2]
self.flat3 = val[3]
self.flat4 = val[4]
self.bottom = val[5]
def doSouth(self):
temp = self.bottom
self.bottom = self.flat2
self.flat2 = self.top
self.top = temp
def doNorth(self):
temp = self.top
self.top = self.flat2
self.flat2 = self.bottom
self.bottom = temp
def doWest(self):
temp = self.bottom
self.top = self.flat3
self.flat1 = self.top
self.bottom = self.flat1
self.flat3 = temp
def doEast(self):
temp = self.bottom
self.top = self.flat1
self.flat3 = self.top
self.bottom = self.flat3
self.flat1 = temp
def transform(dice, motion):
if motion == 'S':
dice.doSouth()
elif motion == 'N':
dice.doNorth()
elif motion == 'W':
dice.doWest()
elif motion == 'E':
dice.doEast()
N = input().split()
dice = Dice(N)
motion = input()
for i in range(len(motion)):
transform(dice, motion[i])
print(dice.top)
|
s664957615
|
Accepted
| 20 | 5,572 | 1,377 |
class Dice:
def __init__(self, val):
self.top = val[0]
self.flat1 = val[3]
self.flat2 = val[1]
self.flat3 = val[2]
self.flat4 = val[4]
self.bottom = val[5]
def doSouth(self):
temp = self.bottom
self.bottom = self.flat2
self.flat2 = self.top
self.top = self.flat4
self.flat4 = temp
def doNorth(self):
temp = self.bottom
self.bottom = self.flat4
self.flat4 = self.top
self.top = self.flat2
self.flat2 = temp
def doWest(self):
temp = self.top
self.top = self.flat3
self.flat3 = self.bottom
self.bottom = self.flat1
self.flat1 = temp
def doEast(self):
temp = self.top
self.top = self.flat1
self.flat1 = self.bottom
self.bottom = self.flat3
self.flat3 = temp
def doget(self):
list = [self.top, self.flat2, self.flat3, self.flat1, self.flat4, self.bottom]
return(list)
def transform(dice, motion):
if motion == 'S':
dice.doSouth()
elif motion == 'N':
dice.doNorth()
elif motion == 'W':
dice.doWest()
elif motion == 'E':
dice.doEast()
N = input().split()
dice = Dice(N)
motion = input()
for i in range(len(motion)):
transform(dice, motion[i])
print(dice.top)
|
s927903480
|
p03719
|
u374516257
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 85 |
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
s = input().split()
if s[0] <= s[2] <= s[1]:
print("YES")
else:
print("NO")
|
s154150869
|
Accepted
| 17 | 2,940 | 98 |
A, B, C = map(int, input().split())
if A <= C and C <= B:
print("Yes")
else:
print("No")
|
s255377828
|
p03719
|
u591224180
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 87 |
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=list(map(int,input().split()))
if A<=C<=B:
print('YES')
else:
print('NO')
|
s740352317
|
Accepted
| 17 | 2,940 | 87 |
A,B,C=list(map(int,input().split()))
if A<=C<=B:
print('Yes')
else:
print('No')
|
s487644069
|
p04029
|
u318508464
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 70 |
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
# coding:utf-8
n = int(input())
candy = (1 + n) * n / 2
print(candy)
|
s141406856
|
Accepted
| 17 | 2,940 | 71 |
# coding:utf-8
n = int(input())
candy = (1 + n) * n // 2
print(candy)
|
s950184446
|
p03399
|
u487288850
| 2,000 | 262,144 |
Wrong Answer
| 26 | 8,992 | 41 |
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
|
min(input(),input())+min(input(),input())
|
s449949702
|
Accepted
| 26 | 9,168 | 68 |
print(min(int(input()),int(input()))+min(int(input()),int(input())))
|
s151512649
|
p03068
|
u703890795
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 135 |
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.
|
N = int(input())
S = input()
K = int(input())
skey = S[K-1]
t = ""
for s in S:
if s == skey:
t += "*"
else:
t += s
print(t)
|
s067003080
|
Accepted
| 18 | 3,064 | 135 |
N = int(input())
S = input()
K = int(input())
skey = S[K-1]
t = ""
for s in S:
if s != skey:
t += "*"
else:
t += s
print(t)
|
s126234840
|
p03407
|
u911575040
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 83 |
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
a,b,c=map(int,input().split(' '))
if a+b<=c:
print('Yes')
else:
print('No')
|
s624496133
|
Accepted
| 17 | 2,940 | 86 |
a,b,c=map(int,input().split(' '))
if (a+b)>=c:
print('Yes')
else:
print('No')
|
s732409907
|
p03377
|
u266171694
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 97 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a, b, x = map(int, input().split())
if a > x or a + b > x:
print('No')
else:
print('Yes')
|
s887381113
|
Accepted
| 17 | 2,940 | 97 |
a, b, x = map(int, input().split())
if a > x or a + b < x:
print('NO')
else:
print('YES')
|
s759789617
|
p03606
|
u595375942
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,060 | 104 |
Joisino is working as a receptionist at a theater. The theater has 100000 seats, numbered from 1 to 100000. According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive). How many people are sitting at the theater now?
|
i = int(input())
ans=0
for _ in range(i):
r, l = map(int, input().split())
ans += l-r
print(ans)
|
s147311525
|
Accepted
| 29 | 3,060 | 74 |
print(sum(1-eval(input().replace(' ', '-')) for _ in range(int(input()))))
|
s602118416
|
p03251
|
u336624604
| 2,000 | 1,048,576 |
Wrong Answer
| 20 | 3,064 | 237 |
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
n,m,X,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.append(X)
y.append(Y)
x.sort(reverse = True)
y.sort()
print(x[0],y[0])
if x[0]<y[0]:
print('No War')
else:
print('War')
|
s313957919
|
Accepted
| 17 | 3,060 | 239 |
n,m,X,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.append(X)
y.append(Y)
x.sort(reverse = True)
y.sort()
#print(x[0],y[0])
if x[0]<y[0]:
print('No War')
else:
print('War')
|
s913212839
|
p02612
|
u724394250
| 2,000 | 1,048,576 |
Wrong Answer
| 31 | 9,032 | 121 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input("1から10000までの数字を入力してください"))
div = n % 1000
exc = n - div*1000
print("exc")
|
s484830964
|
Accepted
| 30 | 9,148 | 113 |
N = int(input())
if N % 1000 == 0:
print(0)
else:
div = int(N / 1000)
exc = (div +1)*1000 - N
print(exc)
|
s647173305
|
p04044
|
u816631826
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 129 |
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,m = map(int , input().split())
li=[]
for i in range(n):
li.append(input())
sorted(li)
st=''
for e in li:
st=st+e
print(st)
|
s670084961
|
Accepted
| 26 | 9,112 | 120 |
n,l=map(int,input().split())
a=[]
for i in range(0,n):
a.append(input())
a.sort()
ans=""
for i in a:
ans+=i
print(ans)
|
s235210512
|
p03912
|
u619819312
| 2,000 | 262,144 |
Wrong Answer
| 146 | 19,936 | 386 |
Takahashi is playing with N cards. The i-th card has an integer X_i on it. Takahashi is trying to create as many pairs of cards as possible satisfying one of the following conditions: * The integers on the two cards are the same. * The sum of the integers on the two cards is a multiple of M. Find the maximum number of pairs that can be created. Note that a card cannot be used in more than one pair.
|
from collections import Counter as c
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=c(a)
d=[0]*m
e=[0]*m
for i in b.keys():
t=b[i]
d[i%m]+=t
e[i%m]+=t//2
z=0
for i in range(1,m//2):
x,y=d[i],d[-i]
if x>y:
z+=d[-i]+min(e[i],(d[i]-d[-i])//2)
else:
z+=d[i]+min(e[-i],(d[-i]-d[i])//2)
if m%2==0:
z+=d[m//2]//2
z+=d[0]//2
print(z)
|
s975586552
|
Accepted
| 146 | 19,936 | 390 |
from collections import Counter as c
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=c(a)
d=[0]*m
e=[0]*m
for i in b.keys():
t=b[i]
d[i%m]+=t
e[i%m]+=t//2
z=0
for i in range(1,(m+1)//2):
x,y=d[i],d[-i]
if x>y:
z+=d[-i]+min(e[i],(d[i]-d[-i])//2)
else:
z+=d[i]+min(e[-i],(d[-i]-d[i])//2)
if m%2==0:
z+=d[m//2]//2
z+=d[0]//2
print(z)
|
s264880921
|
p03377
|
u165268875
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 85 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
A, B, X = map(int, input().split())
print("Yes" if (X-A)>0 and (A+B-X)>0 else "No")
|
s227136413
|
Accepted
| 17 | 2,940 | 87 |
A, B, X = map(int, input().split())
print("YES" if (X-A)>=0 and (A+B-X)>=0 else "NO")
|
s004223805
|
p03712
|
u384679440
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 183 |
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
|
H, W = map(int, input().split())
a = []
a.append('*' * (W + 2))
for _ in range(H):
a.append('*' + input() + '*')
a.append('*' * (W + 2))
for i in range(len(a)):
print("".join(a[i]))
|
s017799731
|
Accepted
| 17 | 3,060 | 183 |
H, W = map(int, input().split())
a = []
a.append('#' * (W + 2))
for _ in range(H):
a.append('#' + input() + '#')
a.append('#' * (W + 2))
for i in range(len(a)):
print("".join(a[i]))
|
s164689392
|
p02612
|
u574888872
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,092 | 62 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
fee = int(input())
pay = fee - (fee % 1000) + 1000
print(pay)
|
s102210997
|
Accepted
| 30 | 9,060 | 85 |
fee = int(input())
fee = fee % 1000
pay = 1000
if fee == 0: pay = 0
print(pay - fee)
|
s664798299
|
p02420
|
u474232743
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,556 | 123 |
Your task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck. The deck of cards is represented by a string as follows. abcdeefab The first character and the last character correspond to the card located at the bottom of the deck and the card on the top of the deck respectively. For example, a shuffle with h = 4 to the above deck, moves the first 4 characters "abcd" to the end of the remaining characters "eefab", and generates the following deck: eefababcd You can repeat such shuffle operations. Write a program which reads a deck (a string) and a sequence of h, and prints the final state (a string).
|
deck = list(input())
for i in range(int(input())):
n = int(input())
deck = deck[n:] + deck[:n]
print(''.join(deck))
|
s471578937
|
Accepted
| 20 | 7,660 | 174 |
while True:
deck = input()
if deck == '-':
break
for i in range(int(input())):
n = int(input())
deck = deck[n:] + deck[:n]
print(deck)
|
s569259098
|
p01101
|
u411881271
| 8,000 | 262,144 |
Wrong Answer
| 20 | 5,612 | 270 |
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items. You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
|
n, x = map(int, input().split())
A=[0 for i in range(n)]
A=input().split()
max=(int)(A[0])+(int)(A[1])
for i in range(len(A)-1):
for j in range(i+1, len(A)):
if max<(int)(A[i])+(int)(A[j]) and (int)(A[i])+(int)(A[j])<=x:
max=(int)(A[i])+(int)(A[j])
print(max)
|
s257986734
|
Accepted
| 4,330 | 5,664 | 475 |
C=[0 for i in range(2)]
C=input().split()
n=(int)(C[0])
x=(int)(C[1])
B=[]
cnt=0
while n>0:
A=[0 for i in range(n)]
A=input().split()
max=0
for i in range(len(A)-1):
for j in range(i+1, len(A)):
if max<(int)(A[i])+(int)(A[j]) and (int)(A[i])+(int)(A[j])<=x:
max=(int)(A[i])+(int)(A[j])
if max>0:
B.append(max)
else:
B.append("NONE")
C=[0 for i in range(2)]
C=input().split()
n=(int)(C[0])
x=(int)(C[1])
cnt+=1
for i in range(cnt):
print(B[i])
|
s936403664
|
p02646
|
u609307781
| 2,000 | 1,048,576 |
Wrong Answer
| 21 | 9,120 | 258 |
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
# B
A, V = list(map(int, input().split()))
B, W = list(map(int, input().split()))
T = int(input())
if A > B:
print('NO')
else:
after_A = A + V * T
after_B = B + W * T
if after_A >= after_B:
print('Yes')
else:
print('No')
|
s770156975
|
Accepted
| 24 | 9,052 | 212 |
# B
A, V = list(map(int, input().split()))
B, W = list(map(int, input().split()))
T = int(input())
vel_diff = V - W
loc_diff = abs(A - B)
if loc_diff - vel_diff * T <= 0:
print('YES')
else:
print('NO')
|
s506174097
|
p04029
|
u060392346
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 38 |
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
N = int(input())
print(N * (N+1) / 2)
|
s727974470
|
Accepted
| 17 | 2,940 | 43 |
N = int(input())
print(int(N * (N+1) / 2))
|
s347068898
|
p03544
|
u366959492
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 94 |
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
|
n=int(input())
l=[2,1]
for i in range(2,n):
x=l[i-2]+l[i-1]
l.append(x)
print(l[n-1])
|
s618043049
|
Accepted
| 17 | 2,940 | 95 |
n=int(input())
l=[2,1]
for i in range(2,n+1):
x=l[i-2]+l[i-1]
l.append(x)
print(l[n])
|
s315476669
|
p03860
|
u928784113
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 62 |
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
A,B,C = map(str,input().split())
print(A[0],B[0].upper(),C[0])
|
s318218086
|
Accepted
| 18 | 2,940 | 86 |
# -*- coding: utf-8 -*-
A,B,C = map(str,input().split())
print(A[0]+B[0].upper()+C[0])
|
s892719394
|
p03371
|
u629540524
| 2,000 | 262,144 |
Wrong Answer
| 27 | 9,176 | 132 |
"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())
if a+b<=c:
print(a*x+b*y)
else:
c*2*min(x,y)+min(max(a*min(x,y),b*min(x,y)),c*2*abs(x-y))
|
s392990990
|
Accepted
| 26 | 9,008 | 135 |
a,b,c,x,y=map(int,input().split())
if a+b<=2*c:
print(a*x+b*y)
else:
print(c*2*min(x,y)+min(max(a*(x-y),b*(y-x)),c*2*abs(x-y)))
|
s463891666
|
p03796
|
u244836567
| 2,000 | 262,144 |
Wrong Answer
| 2,205 | 9,356 | 67 |
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.
|
a=int(input())
b=1
for i in range(1,a):
b=b*i
print(b%1000000007)
|
s657186132
|
Accepted
| 49 | 9,128 | 144 |
a=int(input())
b=1
for i in range(1,a+1):
b=b*i
if b>1000000007:
b=b%1000000007
if b<1000000000:
print(b)
else:
print(b%1000000007)
|
s143627203
|
p03360
|
u996952235
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 106 |
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
|
a, b, c = [int(i) for i in input().split()]
k = int(input())
m = max(a, b, c)
print(a + b + c + m**k - m)
|
s719289766
|
Accepted
| 17 | 2,940 | 112 |
a, b, c = [int(i) for i in input().split()]
k = int(input())
m = max(a, b, c)
print(a + b + c + m*(2 ** k) - m)
|
s873953243
|
p04043
|
u579746769
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,100 | 88 |
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.
|
li=list(map(int,input().split()))
if li.count(5)>=2:
print('Yes')
else:
print('No')
|
s620787337
|
Accepted
| 31 | 9,164 | 88 |
li=list(map(int,input().split()))
if li.count(5)>=2:
print('YES')
else:
print('NO')
|
s695401509
|
p03470
|
u560072805
| 2,000 | 262,144 |
Time Limit Exceeded
| 2,205 | 9,040 | 134 |
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
A=list(map(int,input().split()))
count=0
while len(A) !=0:
count+=1
while count < A.count(A[0]):
A=A.remove(A[0])
print(count)
|
s186899148
|
Accepted
| 28 | 9,184 | 152 |
N=int(input())
z=[]
for num in range(101):
z.append(0)
counter=0
while counter < N:
d=int(input())
z[d]=1
counter+=1
result=sum(z)
print(result)
|
s279411533
|
p03377
|
u896451538
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 132 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
list = input().split()
A = int(list[0])
B = int(list[1])
X = int(list[2])
if A <= X <= A+B :
print("Yes")
else:
print("No")
|
s102496000
|
Accepted
| 17 | 2,940 | 132 |
list = input().split()
A = int(list[0])
B = int(list[1])
X = int(list[2])
if A <= X <= A+B :
print("YES")
else:
print("NO")
|
s574529767
|
p03997
|
u679154596
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,188 | 93 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a = int(input())
b = int(input())
h = int(input())
menseki = (a + b) * h / 2
print(menseki)
|
s749507159
|
Accepted
| 17 | 2,940 | 120 |
import math
a = int(input())
b = int(input())
h = int(input())
menseki = (a + b) * h / 2
print(math.floor(menseki))
|
s791948914
|
p01093
|
u786072601
| 8,000 | 262,144 |
Wrong Answer
| 20 | 5,604 | 195 |
Dr. Tsukuba has devised a new method of programming training. In order to evaluate the effectiveness of this method, he plans to carry out a control experiment. Having two students as the participants of the experiment, one of them will be trained under the conventional method and the other under his new method. Comparing the final scores of these two, he will be able to judge the effectiveness of his method. It is important to select two students having the closest possible scores, for making the comparison fair. He has a list of the scores of all students who can participate in the experiment. You are asked to write a program which selects two of them having the smallest difference in their scores.
|
n=int(input())
data=list(map(int,input().split()))
data=sorted(data)
answer=1000000
for i in range(0,n-1):
d=data[i+1]-data[i]
if d<answer:
answer=d
print(answer)
|
s188712880
|
Accepted
| 40 | 5,652 | 334 |
n=int(input())
result=[]
while n!=0:
data=list(map(int,input().split()))
data=sorted(data)
answer=1000000
for i in range(0,n-1):
d=data[i+1]-data[i]
if d<answer:
answer=d
result.append(answer)
n=int(input())
for i in range(0,len(result)):
print(result[i])
|
s231162871
|
p03083
|
u171366497
| 2,000 | 1,048,576 |
Wrong Answer
| 226 | 20,400 | 489 |
Today, Snuke will eat B pieces of black chocolate and W pieces of white chocolate for an afternoon snack. He will repeat the following procedure until there is no piece left: * Choose black or white with equal probability, and eat a piece of that color if it exists. For each integer i from 1 to B+W (inclusive), find the probability that the color of the i-th piece to be eaten is black. It can be shown that these probabilities are rational, and we ask you to print them modulo 10^9 + 7, as described in Notes.
|
B,W=map(int,input().split())
mod=10**9+7
two=pow(2,mod-2,mod)
kaijo=[1]
for i in range(1,1+B+W):
kaijo.append((kaijo[-1])*i%mod)
from collections import deque
gyaku=deque()
gyaku.append(pow(kaijo[B+W],mod-2,mod))
for i in range(B+W,0,-1):
gyaku.appendleft((gyaku[0]*i)%mod)
for k in range(1,B+W+1):
if k<=B:
print(two)
elif k==B+1:
x=pow(2,k-1,mod)
xdiv=pow(x,mod-2,mod)
y=(x-kaijo[k-1]*gyaku[k-B-1]*gyaku[B])%mod
print((y*xdiv)%mod)
|
s755645775
|
Accepted
| 687 | 82,312 | 547 |
B,W=map(int,input().split())
mod=10**9+7
kaijo={0:1}
Xdiv={0:1}
two=pow(2,mod-2,mod)
for i in range(1,1+B+W):
kaijo[i]=(kaijo[i-1]*i)%mod
Xdiv[i]=(Xdiv[i-1]*two)%mod
gyaku={B+W:pow(kaijo[B+W],mod-2,mod)}
for i in range(B+W,0,-1):
gyaku[i-1]=(gyaku[i]*i)%mod
def conb(a,b):
if a<b:return 0
return (kaijo[a]*gyaku[a-b]*gyaku[b])%mod
Blost,Wlost=0,0
for k in range(1,B+W):
print(((1+Wlost-Blost)*two)%mod)
Blost=(Blost+conb(k-1,B-1)*Xdiv[k])%mod
Wlost=(Wlost+conb(k-1,W-1)*Xdiv[k])%mod
print(((1+Wlost-Blost)*two)%mod)
|
s901285935
|
p03407
|
u160659351
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 106 |
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
#91
A, B, C = map(int, input().rstrip().split())
if C-(A+B) >= 0:
print("Yes")
else:
print("No")
|
s594083007
|
Accepted
| 17 | 2,940 | 106 |
#91
A, B, C = map(int, input().rstrip().split())
if C-(A+B) <= 0:
print("Yes")
else:
print("No")
|
s464731441
|
p02694
|
u198930868
| 2,000 | 1,048,576 |
Wrong Answer
| 22 | 9,160 | 104 |
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?
|
i = int(input())
price = 100
year = 0
while price <= i:
price =int(price * 1.01)
year += 1
print(year)
|
s946994669
|
Accepted
| 21 | 9,164 | 122 |
import math
i = int(input())
price = 100
year = 0
while price < i:
price =math.floor(price * 1.01)
year += 1
print(year)
|
s529190228
|
p03160
|
u037221289
| 2,000 | 1,048,576 |
Wrong Answer
| 94 | 13,928 | 262 |
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
N = int(input())
H = list(map(int,input().split(' ')))
num = 0
i = 0
while i <= N-2:
if i == N-2:
num += abs(H[i+1] - H[i])
break
A = abs(H[i+1] - H[i])
B = abs(H[i+2] - H[i])
if A < B:
num += A
i += 1
else:
num += B
i += 2
|
s709505712
|
Accepted
| 131 | 13,980 | 231 |
N = int(input())
H = list(map(int,input().split(' ')))
DP = [float('inf')]*N
DP[0] = 0
DP[1] = abs(H[1] - H[0])
for i in range(2,N):
DP[i] = min(DP[i-2] + abs(H[i] - H[i-2]),DP[i-1] + abs(H[i] - H[i-1]))
print(DP[-1])
|
s001787023
|
p03063
|
u422537930
| 2,000 | 1,048,576 |
Wrong Answer
| 65 | 3,560 | 267 |
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.
|
N = int(input())
S = input()
start = -1
count = 0
print(S)
for i in range(0, N):
if S[i:1] == '#':
start = i
break
if start != -1:
for i in range(start, N):
if S[i:i+1] == '.':
count = count + 1
print("{}".format(count))
|
s559126405
|
Accepted
| 82 | 3,500 | 250 |
N = int(input())
S = input()
count = S[0:N].count('.')
min = count
for i in range(0, N):
if S[i:i + 1] == '#':
count += 1
else:
count -= 1
if count < min:
min = count
if N == 1:
min = 0
print("{}".format(min))
|
s023813344
|
p03711
|
u216962796
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 112 |
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.
|
print(['No','Yex'][(lambda a,b:a[b[0]-1]==a[b[1]-1])([0,2,0,1,0,1,0,0,1,0,1,0],list(map(int,input().split())))])
|
s021889779
|
Accepted
| 17 | 3,060 | 112 |
print(['No','Yes'][(lambda a,b:a[b[0]-1]==a[b[1]-1])([0,2,0,1,0,1,0,0,1,0,1,0],list(map(int,input().split())))])
|
s191483055
|
p03007
|
u941438707
| 2,000 | 1,048,576 |
Wrong Answer
| 150 | 20,672 | 486 |
There are N integers, A_1, A_2, ..., A_N, written on a blackboard. We will repeat the following operation N-1 times so that we have only one integer on the blackboard. * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y. Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.
|
n,*a=map(int,open(0).read().split())
a.sort()
p,z,m=[],[],[]
for i in a:
if i<0:m+=[i]
elif i>0:p+=[i]
else:z+=[i]
print(sum(abs(i)for i in a)-2*abs(a[0]))
if p and m:
p=z+p
for i in p[:-1]:
print(m[0],i)
m[0]-=i
for i in m:
print(p[-1],i)
p[-1]-=i
elif p:
p=z+p
for i in p[:-2]:
print(p[0],i)
p[0]-=i
print(p[-2],p[0])
elif m:
m=m+z
for i in p[:-1]:
print(p[-1],i)
p[-1]-=i
|
s802733701
|
Accepted
| 131 | 20,532 | 199 |
n,*a=map(int,open(0).read().split())
a.sort()
u,d=a[-1],a[0]
print(sum(abs(i)for i in a)-2*min(abs(u),abs(d))*(u*d>0))
for i in a[1:-1]:
if i<0:print(u,i);u-=i
else:print(d,i);d-=i
print(u,d)
|
s284839588
|
p03434
|
u063073794
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,060 | 178 |
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
#print(a)
b=[]
c=[]
for i in range(0,n,2):
b.append(a[i])
c.append(a[i-1])
print(sum(b)-(sum(c)-c[0]))
|
s668036833
|
Accepted
| 17 | 3,060 | 187 |
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
#print(a)
b=[]
c=[]
for i in range(n):
if i%2==0:
b.append(a[i])
else:
c.append(a[i])
print(sum(b)-sum(c))
|
s694105303
|
p03994
|
u309141201
| 2,000 | 262,144 |
Wrong Answer
| 84 | 11,476 | 366 |
Mr. Takahashi has a string s consisting of lowercase English letters. He repeats the following operation on s exactly K times. * Choose an arbitrary letter on s and change that letter to the next alphabet. Note that the next letter of `z` is `a`. For example, if you perform an operation for the second letter on `aaz`, `aaz` becomes `abz`. If you then perform an operation for the third letter on `abz`, `abz` becomes `aba`. Mr. Takahashi wants to have the lexicographically smallest string after performing exactly K operations on s. Find the such string.
|
s = list(input())
k = int(input())
n = len(s)
for i in range(n):
if k <= 0 or s[i] == 'a':
continue
if 123 - ord(s[i]) <= k:
k -= 123 - ord(s[i])
s[i] = 'a'
# print(k)
# print(s)
k %= 26
print(ord(s[-1])+k)
if ord(s[-1])+k > 122:
s[-1] = chr(97+(122-ord(s[-1])+k))
else:
s[-1] = chr(ord(s[-1])+k)
# print(k)
print(*s, sep='')
|
s014724910
|
Accepted
| 93 | 11,560 | 368 |
s = list(input())
k = int(input())
n = len(s)
for i in range(n):
if k <= 0 or s[i] == 'a':
continue
if 123 - ord(s[i]) <= k:
k -= 123 - ord(s[i])
s[i] = 'a'
# print(k)
# print(s)
k %= 26
# print(ord(s[-1])+k)
if ord(s[-1])+k > 122:
s[-1] = chr(97+(122-ord(s[-1])+k))
else:
s[-1] = chr(ord(s[-1])+k)
# print(k)
print(*s, sep='')
|
s585672372
|
p02399
|
u398448331
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,608 | 98 |
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
a = list(map(int,input().split()))
d = a[0]//a[1]
r = a[0]%a[1]
f = float(a[0]/a[1])
print(d,r,f)
|
s953981625
|
Accepted
| 20 | 5,604 | 124 |
a = list(map(int,input().split()))
d = a[0]//a[1]
r = a[0]%a[1]
f = float(a[0]/a[1])
print("{0} {1} {2:.5f}".format(d,r,f))
|
s083825407
|
p03448
|
u607680583
| 2,000 | 262,144 |
Wrong Answer
| 57 | 9,212 | 445 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count=0
for s in range(a+1):
if s*500 == x:
count += 1
print("500:", s)
for t in range(b+1):
if s*500 + t*100 == x:
count += 1
print("500:", s, "100:", t)
for u in range(c+1):
if s*500 + t*100 + u*50 == x:
count += 1
print("500:", s, "100:", t, "50:", u)
print(count)
|
s223575786
|
Accepted
| 50 | 9,148 | 348 |
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count=0
for s in range(a+1):
if s*500 == x:
count += 1
for t in range(b+1):
if s*500 + t*100 == x and t != 0:
count += 1
for u in range(c+1):
if s*500 + t*100 + u*50 == x and u != 0:
count += 1
print(count)
|
s912975874
|
p03449
|
u218834617
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,196 | 197 |
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
|
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
for i in range(1,N): A[i]+=A[i-1]
for i in range(N-2): B[i]+=B[i+1]
ans=max(A[i]+B[i] for i in range(N))
print(ans)
|
s502866734
|
Accepted
| 28 | 9,040 | 203 |
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
for i in range(1,N): A[i]+=A[i-1]
for i in range(N-2,-1,-1): B[i]+=B[i+1]
ans=max(A[i]+B[i] for i in range(N))
print(ans)
|
s777237213
|
p03478
|
u925478395
| 2,000 | 262,144 |
Wrong Answer
| 46 | 3,416 | 295 |
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(str,input().split())
a = int(A)
b = int(B)
c = int(N) + 1
all = 0
ans = 0
for count in range(c):
test = str(count)
ttt = list(test)
for mozi in ttt:
all = all + int(mozi)
if all >= a and all <= b:
print(count)
ans = ans + count
all = 0
print('{}'.format(ans))
|
s049983365
|
Accepted
| 37 | 3,064 | 278 |
N,A,B = map(str,input().split())
a = int(A)
b = int(B)
c = int(N) + 1
all = 0
ans = 0
for count in range(c):
test = str(count)
ttt = list(test)
for mozi in ttt:
all = all + int(mozi)
if all >= a and all <= b:
ans = ans + count
all = 0
print('{}'.format(ans))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.