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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s403031326
|
p03659
|
u354915818
| 2,000
| 262,144
|
Wrong Answer
| 104
| 27,868
| 357
|
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|.
|
s = input().split()
s = [int(i) for i in s]
N = s[0]
s = input().split()
a = [int(i) for i in s]
L = [0] * N
L[0] = a[0] - sum(a[1 : ])
if N == 2 :
print(abs(a[0] - a[1]))
else :
for i in range(1 , N - 1) :
L[i] = L[i - 1] + 2 * a[i]
if L[i] > 0 : break
print(L)
print(min( abs(L[i]) , abs(L[i - 1])))
|
s003216273
|
Accepted
| 239
| 32,556
| 384
|
s = input().split()
s = [int(i) for i in s]
N = s[0]
s = input().split()
a = [int(i) for i in s]
L = [0] * N
L[0] = a[0] - sum(a[1 : ])
if N == 2 :
print(abs(a[0] - a[1]))
else :
MIN = float("inf")
for i in range(1 , N - 1 ) :
L[i] = L[i - 1] + 2 * a[i]
if MIN > min( abs(L[i]) , abs(L[i - 1])) : MIN = min( abs(L[i]) , abs(L[i - 1]))
print(MIN)
|
s107797219
|
p02557
|
u893063840
| 2,000
| 1,048,576
|
Wrong Answer
| 235
| 40,228
| 496
|
Given are two sequences A and B, both of length N. A and B are each sorted in the ascending order. Check if it is possible to reorder the terms of B so that for each i (1 \leq i \leq N) A_i \neq B_i holds, and if it is possible, output any of the reorderings that achieve it.
|
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
diff = []
for i, (ea, eb) in enumerate(zip(a, b)):
if ea == eb:
diff.append(i)
l = 0
r = len(diff) - 1
bl = True
while l <= r:
if l == r:
bl = False
else:
il, ir = diff[l], diff[r]
if a[il] == a[ir]:
bl = False
else:
b[il], b[ir] = b[ir], b[il]
l += 1
r -= 1
if bl:
print("Yes")
print(*b)
else:
print("No")
|
s485793051
|
Accepted
| 320
| 73,028
| 464
|
from collections import Counter, defaultdict
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ca = Counter(a)
cb = Counter(b)
for ka, va in ca.items():
vb = cb[ka]
if va + vb > n:
print("No")
exit()
print("Yes")
end = defaultdict(int)
for i, e in enumerate(a):
end[e] = i
mx = 0
for i, e in enumerate(b):
diff = end[e] - i + 1
mx = max(mx, diff)
ans = b[-mx:] + b[:-mx]
print(*ans)
|
s076961385
|
p03434
|
u399337080
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 219
|
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
n = input()
li = list(map(int,input().split()))
li.sort()
count = 1
Alice = 0
Bob = 0
for i in li:
if count % 2:
Alice += i
count += 1
else:
Bob += i
count += 1
print(Alice - Bob)
|
s585376303
|
Accepted
| 17
| 2,940
| 234
|
n = input()
li = list(map(int,input().split()))
li.sort(reverse=True)
Alice = 0
Bob = 0
count = 1
for i in li:
if count % 2:
Alice += i
count += 1
else:
Bob += i
count += 1
print(Alice - Bob)
|
s874488445
|
p04043
|
u945181840
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 146
|
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.
|
Haiku = list(map(int, input().split()))
Haiku.sort()
if Haiku[0] == 5 and Haiku[1] == 5 and Haiku[1] == 7:
print('YES')
else:
print('NO')
|
s861892712
|
Accepted
| 17
| 2,940
| 146
|
Haiku = list(map(int, input().split()))
Haiku.sort()
if Haiku[0] == 5 and Haiku[1] == 5 and Haiku[2] == 7:
print('YES')
else:
print('NO')
|
s222884366
|
p03170
|
u561231954
| 2,000
| 1,048,576
|
Wrong Answer
| 1,341
| 3,828
| 383
|
There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other. Initially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro: * Choose an element x in A, and remove exactly x stones from the pile. A player loses when he becomes unable to play. Assuming that both players play optimally, determine the winner.
|
def main():
n,k=map(int,input().split())
num=[int(i) for i in input().split()]
dp=[0]*(k+1)
for i in range(k):
flag=False
for j in range(n):
if dp[max(i+1-num[j],0)]==0:
flag=True
break
if flag:
dp[i+1]=1
else:
continue
if dp[k]:
print('First')
else:
print('Second')
if __name__=='__main__':
main()
|
s018867566
|
Accepted
| 1,105
| 3,828
| 407
|
def main():
n,k=map(int,input().split())
num=[int(i) for i in input().split()]
dp=[0]*(k+1)
for i in range(k):
flag=False
for j in range(n):
if i+1-num[j]>=0:
if dp[i+1-num[j]]==0:
flag=True
break
if flag:
dp[i+1]=1
else:
continue
if dp[k]:
print('First')
else:
print('Second')
if __name__=='__main__':
main()
|
s862728742
|
p03160
|
u073841912
| 2,000
| 1,048,576
|
Wrong Answer
| 28
| 9,084
| 22
|
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.
|
def frog():
return 1
|
s271688635
|
Accepted
| 124
| 17,408
| 319
|
n = int(input())
listStone = input().split()
for i in range(n) :
listStone[i] = int(listStone[i])
dp = [-1 for _ in range(n)]
dp[0] = 0
dp[1] = abs(listStone[1] - listStone[0])
for i in range(2, n) :
dp[i] = min((dp[i-2]+abs(listStone[i]-listStone[i-2])),(dp[i-1]+abs(listStone[i]-listStone[i-1])))
print(dp[-1])
|
s273070662
|
p03448
|
u801701525
| 2,000
| 262,144
|
Wrong Answer
| 55
| 3,064
| 316
|
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.
|
n500 = int(input())
n100 = int(input())
n50 = int(input())
p = int(input())
ans = 0
for i in range(n500):
temp = 0
temp = i*500
for j in range(n100):
temp = i*500+j*100
for k in range(n50):
temp = i*500+j*100+k*50
if temp == p:
ans+=1
print(ans)
|
s527219564
|
Accepted
| 55
| 3,064
| 265
|
n500 = int(input())
n100 = int(input())
n50 = int(input())
p = int(input())
ans = 0
for i in range(n500+1):
for j in range(n100+1):
for k in range(n50+1):
temp = i*500+j*100+k*50
if temp == p:
ans+=1
print(ans)
|
s928756822
|
p03731
|
u350093546
| 2,000
| 262,144
|
Wrong Answer
| 142
| 30,856
| 136
|
In a public bath, there is a shower which emits water for T seconds when the switch is pushed. If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds. N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it. How long will the shower emit water in total?
|
n,t=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
ans+=min(t,a[i+1]-a[i])
ans+=a[-1]
print(ans)
|
s063089999
|
Accepted
| 134
| 30,736
| 126
|
n,t=map(int,input().split())
a=list(map(int,input().split()))
ans=t
for i in range(n-1):
ans+=min(t,a[i+1]-a[i])
print(ans)
|
s007734018
|
p03394
|
u925364229
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 10,392
| 108
|
Nagase is a top student in high school. One day, she's analyzing some properties of special sets of positive integers. She thinks that a set S = \\{a_{1}, a_{2}, ..., a_{N}\\} of **distinct** positive integers is called **special** if for all 1 \leq i \leq N, the gcd (greatest common divisor) of a_{i} and the sum of the remaining elements of S is **not** 1. Nagase wants to find a **special** set of size N. However, this task is too easy, so she decided to ramp up the difficulty. Nagase challenges you to find a **special** set of size N such that the gcd of all elements are 1 and the elements of the set does not exceed 30000.
|
seq = [2,5]
N = int(input())
for i in range(2,N):
seq.append(sum(seq))
for num in seq:
print(num,end=' ')
|
s762358939
|
Accepted
| 31
| 4,592
| 703
|
N = int(input())
l = N // 4
ans = []
if N == 3:
print("2 5 63")
exit(0)
elif N == 4:
print("2 5 20 63")
exit(0)
elif N == 5:
print("6 8 9 10 15")
exit(0)
elif N == 6:
print("6 8 9 10 12 15")
exit(0)
for i in range(l):
ans.extend([6*i+2,6*i+3,6*i+4,6*i+6])
add = [6*(l)+2,6*(l)+3,6*(l)+4,6*(l+1)]
ans.extend(add[:N%4])
s = sum(ans)
flg = s % 6
if flg == 1:
cor = 2 - (ans[-1]%6)
if cor <= 0:
cor += 6
ans[1] = ans[-1] + cor
elif flg == 2:
ans[0] = ans[-1] - (ans[-1]%6) + 6
elif flg == 3:
ans[1] = ans[-1] - (ans[-1]%6) + 6
elif flg == 4:
ans[2] = ans[-1] - (ans[-1]%6) + 6
elif flg == 5:
cor = 4 - (ans[-1]%6)
if cor <= 0:
cor += 6
ans[1] = ans[-1] + cor
print(*ans,end=' ')
|
s524439372
|
p04011
|
u574050882
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 120
|
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
|
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N > K:
print(K*X + (N-K)+Y)
else:
print(N*X)
|
s361517542
|
Accepted
| 17
| 2,940
| 121
|
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N > K:
print(K*X + (N-K)*Y)
else:
print(N*X)
|
s196605132
|
p03048
|
u169678167
| 2,000
| 1,048,576
|
Wrong Answer
| 1,928
| 14,420
| 299
|
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?
|
import numpy as np
import sys
input = sys.stdin.readline
res = 0
p = 0
R, G, B, N = map(int, input().split())
for i in range (N // R + 1):
for j in range(N // G + 1):
P =N - i*R - j*G
if P < 0:
break
else:
if(P % B == 0):
res += 1
|
s408917421
|
Accepted
| 1,830
| 3,064
| 254
|
res = 0
p = 0
R, G, B, N = map(int, input().split())
for i in range (N // R + 1):
for j in range(N // G + 1):
P =N - i*R - j*G
if P < 0:
break
else:
if(P % B == 0):
res += 1
print(res)
|
s434330868
|
p03360
|
u849290552
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,064
| 312
|
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?
|
# Max sum
A, B, C = list(map(int,input().strip().split(' ')))
K = int(input().strip())
v = [A,B,C]
o = 0
for i in range(K):
for j in range(K-i):
k = K-j-i
tmp = [v[0]*max(2*i,1),v[1]*max(2*j,1),v[2]*max(2*k,1)]
if o < sum(tmp):
o = sum(tmp)
print(tmp)
print(o)
|
s792615679
|
Accepted
| 17
| 3,060
| 296
|
# Max sum
A, B, C = list(map(int,input().strip().split(' ')))
K = int(input().strip())
v = [A,B,C]
import itertools
nums = [0,1,2]
o = 0
for i in itertools.combinations_with_replacement(nums,K):
tmp = [v[0],v[1],v[2]]
for j in i:
tmp[j] = tmp[j]*2
o = max(o,sum(tmp))
print(o)
|
s914636959
|
p03545
|
u924406834
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,188
| 799
|
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.
|
num = input()
ssa = [int(x) for x in num]
if ssa[0]+ssa[1]+ssa[2]+ssa[3] == 7:print('{}+{}+{}+{}'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]+ssa[2]+ssa[3] == 7:print('{}-{}+{}+{}'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]-ssa[2]+ssa[3] == 7:print('{}-{}-{}+{}'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]-ssa[2]-ssa[3] == 7:print('{}-{}-{}-{}'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]+ssa[1]-ssa[2]+ssa[3] == 7:print('{}+{}-{}+{}'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]+ssa[1]-ssa[2]-ssa[3] == 7:print('{}+{}-{}-{}'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]+ssa[2]-ssa[3] == 7:print('{}-{}+{}-{}'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]+ssa[1]+ssa[2]-ssa[3] == 7:print('{}+{}+{}-{}'.format(num[0],num[1],num[2],num[3]))
|
s759854372
|
Accepted
| 20
| 3,064
| 815
|
num = input()
ssa = [int(x) for x in num]
if ssa[0]+ssa[1]+ssa[2]+ssa[3] == 7:print('{}+{}+{}+{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]+ssa[2]+ssa[3] == 7:print('{}-{}+{}+{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]-ssa[2]+ssa[3] == 7:print('{}-{}-{}+{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]-ssa[2]-ssa[3] == 7:print('{}-{}-{}-{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]+ssa[1]-ssa[2]+ssa[3] == 7:print('{}+{}-{}+{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]+ssa[1]-ssa[2]-ssa[3] == 7:print('{}+{}-{}-{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]+ssa[2]-ssa[3] == 7:print('{}-{}+{}-{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]+ssa[1]+ssa[2]-ssa[3] == 7:print('{}+{}+{}-{}=7'.format(num[0],num[1],num[2],num[3]))
|
s295856678
|
p03658
|
u953794676
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 146
|
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 = [int(e) for e in input().split()]
sticks_length = list(map(int, input().split()))
sticks_length.sort(reverse=True)
sum(sticks_length[:k:1])
|
s327552737
|
Accepted
| 17
| 2,940
| 153
|
n, k = [int(e) for e in input().split()]
sticks_length = list(map(int, input().split()))
sticks_length.sort(reverse=True)
print(sum(sticks_length[:k:1]))
|
s580325260
|
p03089
|
u785578220
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 3,064
| 303
|
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
|
import sys
n = int(input())
k =[]
x = list(map(int, input().split()))
x = x[::-1]
for i in range(n):
for j,p in enumerate(x):
if p == n-j:
k.append(p)
x.pop(j)
n-=1
break
else:
print(-1)
sys.exit()
for i in k:
print(i)
|
s015705217
|
Accepted
| 18
| 3,064
| 309
|
import sys
n = int(input())
k =[]
x = list(map(int, input().split()))
x = x[::-1]
for i in range(n):
for j,p in enumerate(x):
if p == n-j:
k.append(p)
x.pop(j)
n-=1
break
else:
print(-1)
sys.exit()
for i in k[::-1]:
print(i)
|
s970892410
|
p03971
|
u502200133
| 2,000
| 262,144
|
Wrong Answer
| 96
| 3,912
| 233
|
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.
|
p = 0
n, a, b = map(int, input().split())
for i in input():
if i == "a" and p > a+b:
p += 1
print("Yes")
elif i == "b" and p > a+b and f > a+b:
f += 1
print("Yes")
else:
print("No")
|
s154265093
|
Accepted
| 106
| 4,016
| 252
|
p = 0
f = 0
n, a, b = map(int, input().split())
for i in input():
if i == "a" and p < a+b:
p += 1
print("Yes")
elif i == "b" and p < a+b and f < b:
p += 1
f += 1
print("Yes")
else:
print("No")
|
s826483084
|
p03574
|
u640922335
| 2,000
| 262,144
|
Wrong Answer
| 35
| 3,444
| 419
|
You are given an H ร W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
|
H,W=map(int,input().split())
L=[[0 for i in range(W)]for j in range(H)]
for i in range (H):
L[i]=list(input())
for a in range(H):
for b in range(W):
if L[a][b]=='.':
num=0
for k in range(-1,2):
for l in range(-1,2):
if 0<=a+k<=H-1 and 0<=b+l<=W-1 and L[a+k][b+l]=='#':
num+=1
L[a][b]=num
print(*L[a])
|
s133106845
|
Accepted
| 32
| 3,444
| 426
|
H,W=map(int,input().split())
L=[[0 for i in range(W)]for j in range(H)]
for i in range (H):
L[i]=list(input())
for a in range(H):
for b in range(W):
if L[a][b]=='.':
num=0
for k in range(-1,2):
for l in range(-1,2):
if 0<=a+k<=H-1 and 0<=b+l<=W-1 and L[a+k][b+l]=='#':
num+=1
L[a][b]=num
print(*L[a],sep='')
|
s292702279
|
p03997
|
u298101891
| 2,000
| 262,144
|
Wrong Answer
| 25
| 9,120
| 70
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a = int(input())
b = int(input())
h = int(input())
print(0.5*h*(a+b))
|
s883425442
|
Accepted
| 24
| 9,052
| 75
|
a = int(input())
b = int(input())
h = int(input())
print(int(0.5*h*(a+b)))
|
s190265661
|
p03636
|
u215721064
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 96
|
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
s=str(input())
first=s[0]
last=s[-1]
print(first,last)
l=len(s)
print(s)
print(first,l-2,last)
|
s151789394
|
Accepted
| 17
| 2,940
| 46
|
s=input()
print(s[0]+str(len(s[1:-1]))+s[-1])
|
s000321474
|
p03494
|
u644210195
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 241
|
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
ls = list(map(int, input().split()))
count = 0
is_succses = True
while is_succses:
count += 1
for i, x in enumerate(ls):
if x % 2 == 0:
is_succses = True
ls[i] = int(x / 2)
else:
is_succses = False
break
print(count - 1)
|
s449406105
|
Accepted
| 19
| 3,060
| 253
|
n = input()
ls = list(map(int, input().split()))
count = 0
is_succses = True
while is_succses:
count += 1
for i, x in enumerate(ls):
if x % 2 == 0:
is_succses = True
ls[i] = int(x / 2)
else:
is_succses = False
break
print(count - 1)
|
s812887272
|
p02409
|
u614711522
| 1,000
| 131,072
|
Wrong Answer
| 30
| 6,724
| 365
|
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that โv persons left. Assume that initially no person lives in the building.
|
data = [ [ [ 0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int( input())
for _ in range( n):
(b, f, r, v) = [int(i) for i in input().split()]
data[b-1][f-1][r-1] += v
for b in range(4):
for f in range(3):
for r in range(10):
print( '', data[b][f][r], end='')
print()
if b < 4:
print( '#' * 20)
|
s610944911
|
Accepted
| 30
| 6,720
| 365
|
data = [ [ [ 0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int( input())
for _ in range( n):
(b, f, r, v) = [int(i) for i in input().split()]
data[b-1][f-1][r-1] += v
for b in range(4):
for f in range(3):
for r in range(10):
print( '', data[b][f][r], end='')
print()
if b < 3:
print( '#' * 20)
|
s776104866
|
p03360
|
u993435350
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 97
|
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?
|
ABC = sorted(list(map(int,input().split())))
K = int(input())
print(sum(ABC[:2]) + ABC[-1] ** K)
|
s905214347
|
Accepted
| 17
| 2,940
| 105
|
ABC = sorted(list(map(int,input().split())))
K = int(input())
print(sum(ABC[:2]) + (ABC[-1]) * (2 ** K))
|
s676731163
|
p02124
|
u908651435
| 1,000
| 262,144
|
Wrong Answer
| 20
| 5,572
| 53
|
็ๆฆ1333ๅนดใไบบ้กๅฒไธๆ้ซใฎ็งๅญฆ่
Dr.ใฆใทใทใฏใ่ชใใฎ่ฑ็ฅใๅพไธใซๆฎใในใใIDใai1333ใฎไบบๅทฅ็ฅ่ฝใ้็บใใใใใใใ100ๅนดใฎ้ใai1333ใฏไบบ้กใซๅคๅคงใชๅฉ็ใใใใใใใใ่ช็ใใ100ๅนด็ฎใ่ฟใใๆฅใ่ชใใฎๅพ็ถใจใใฆIDใai13333ใฎๆฐใใชไบบๅทฅ็ฅ่ฝใไฝๆใใใใฎๆฉ่ฝใๆฐธไน
ใซๅๆญขใใใไปฅ้100ๅนดใใจใซใไบบๅทฅ็ฅ่ฝใฏโai1333โใใๅงใพใ่ช่บซใฎIDใฎๆซๅฐพใซโ3โใ้ฃ็ตใใIDใๆใคๅพ็ถใๆฎใใใใซใชใฃใใ ๅ
ฅๅใจใใฆ็ๆฆ1333ๅนดใใใฎ็ต้ๅนดๆฐ$x$ใไธใใใใใฎใงใใใฎๅนดใซไฝๆใใใไบบๅทฅ็ฅ่ฝใฎIDใๅบๅใใใใใ ใใ$x$ใฏ100ใฎ้่ฒ ๆดๆฐๅใงใใใใจใไฟ่จผใใใใ
|
x=int(input())
x=round(x/100)
print('ai13333'+'3'*x)
|
s709336412
|
Accepted
| 20
| 5,648
| 69
|
import math
x=int(input())
x=math.floor(x/100)
print('ai1333'+'3'*x)
|
s640402304
|
p03049
|
u667469290
| 2,000
| 1,048,576
|
Wrong Answer
| 43
| 3,064
| 436
|
Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
|
# -*- coding: utf-8 -*-
def solve():
NAB, NBA, NB_, N_A = 0, 0, 0, 0
for _ in range(int(input())):
S = input()
NAB += S.replace('AB', '-').count('-')
b, a = S.startswith('B'), S.endswith('A')
NBA += b&a
NB_ += b&(~a)
N_A += (~b)&a
res = NAB + max(NBA-1, 0) + (NB_>=1) + (N_A>=1) + max(min(NB_, N_A)-1, 0)
return str(res)
if __name__ == '__main__':
print(solve())
|
s963251120
|
Accepted
| 41
| 3,064
| 489
|
# -*- coding: utf-8 -*-
def solve():
NAB, NBA, NB_, N_A = 0, 0, 0, 0
for _ in range(int(input())):
S = input()
NAB += S.replace('AB', '-').count('-')
b, a = S.startswith('B'), S.endswith('A')
NBA += (b and a)
NB_ += (b and (not a))
N_A += ((not b) and a)
res = NAB + max(NBA-1, 0) + (NB_>=1 and NBA>=1) + (N_A>=1 and NBA>=1) + max(min(NB_, N_A)-(NBA>=1), 0)
return str(res)
if __name__ == '__main__':
print(solve())
|
s911443916
|
p03493
|
u716660050
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 50
|
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
s=list(map(int,input().split()))
print(s.count(1))
|
s998302525
|
Accepted
| 17
| 2,940
| 31
|
print(list(input()).count('1'))
|
s749785548
|
p03197
|
u533039576
| 2,000
| 1,048,576
|
Wrong Answer
| 143
| 12,968
| 133
|
There is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i. You and Lunlun the dachshund alternately perform the following operation (starting from you): * Choose one or more apples from the tree and eat them. Here, the apples chosen at the same time must all have different colors. The one who eats the last apple from the tree will be declared winner. If both you and Lunlun play optimally, which will win?
|
n = int(input())
a = [int(input()) for _ in range(n)]
ans = 'second' if any(a[i] % 2 == 0 for i in range(n)) else 'first'
print(ans)
|
s595697641
|
Accepted
| 154
| 13,032
| 133
|
n = int(input())
a = [int(input()) for _ in range(n)]
ans = 'second' if all(a[i] % 2 == 0 for i in range(n)) else 'first'
print(ans)
|
s792333281
|
p02742
|
u756518089
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 70
|
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:
|
num = [int(i) for i in input().split(' ')]
print(num[0] * num[1] / 2)
|
s281656068
|
Accepted
| 17
| 3,064
| 250
|
num = [int(i) for i in input().split(' ')]
if num[0] == 1 and num[1] == 1:
print(1)
elif num[0] == 1 or num[1] == 1:
print(1)
else:
A = num[0] * num[1]
if(A % 2 == 0):
print(int(num[0] * num[1] / 2))
else:
print(int((A-1) / 2 + 1))
|
s505796252
|
p03369
|
u989326345
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 44
|
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
|
s=input()
n=s.count('โ')
print(700+100*n)
|
s625459341
|
Accepted
| 18
| 2,940
| 46
|
s=str(input())
n=s.count('o')
print(700+100*n)
|
s374871156
|
p02475
|
u861198832
| 1,000
| 262,144
|
Wrong Answer
| 20
| 5,588
| 41
|
Given two integers $A$ and $B$, compute the quotient, $\frac{A}{B}$. Round down to the nearest decimal.
|
a,b=map(int,input().split())
print(a/b)
|
s738290825
|
Accepted
| 20
| 5,592
| 83
|
a,b = map(int,input().split())
c = abs(a) // abs(b)
print(-c if a * b < 0 else c)
|
s957600739
|
p03997
|
u361826811
| 2,000
| 262,144
|
Wrong Answer
| 146
| 12,400
| 249
|
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.
|
import sys
import itertools
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a,b,h=map(int, read().split())
print(h*(b+a))
|
s085899136
|
Accepted
| 151
| 12,396
| 252
|
import sys
import itertools
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a,b,h=map(int, read().split())
print(h*(b+a)//2)
|
s283729057
|
p02420
|
u918276501
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,596
| 212
|
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).
|
def shuffle(string,index):
string = string[index:]+string[:index]
while True:
a = input()
if a == '-':
break
for i in range(int(input())):
shuffle(a,int(input()))
print(a)
|
s324611698
|
Accepted
| 30
| 7,668
| 201
|
def shuffle(index):
global a
a = a[index:]+a[:index]
while True:
a = input()
if a == '-':
break
for i in range(int(input())):
shuffle(int(input()))
print(a)
|
s876019151
|
p02271
|
u811733736
| 5,000
| 131,072
|
Wrong Answer
| 30
| 7,752
| 676
|
Write a program which reads a sequence _A_ of _n_ elements and an integer _M_ , and outputs "yes" if you can make _M_ by adding elements in _A_ , otherwise "no". You can use an element only once. You are given the sequence _A_ and _q_ questions where each question contains _M i_.
|
# -*- coding: utf-8 -*-
"""
"""
from itertools import combinations
if __name__ == '__main__':
# ??????????????\???
num = int(input())
M = [int(x) for x in input().split(' ')]
pick = int(input())
A = [int(x) for x in input().split(' ')]
#A = [1, 5, 7, 10, 21]
#pick = 4
#M = [2, 4, 17, 8]
# ????????????
results = ['no' for x in range(len(M))]
for p in range(1, pick+1):
combi = combinations(A, p)
for choice in combi:
total = sum(choice)
if total in M:
i = M.index(total)
results[i] = 'yes'
# ???????????????
for txt in results:
print(txt)
|
s804921818
|
Accepted
| 830
| 135,424
| 399
|
from functools import lru_cache
@lru_cache(maxsize=None)
def is_possible(n, target, total):
if n == 0:
return total == target
return is_possible(n-1, target, total) or is_possible(n-1, target, total + A[n-1])
n = int(input())
A = [int(i) for i in input().split()]
_ = int(input())
for target in map(int, input().split()):
print('yes' if is_possible(n, target, 0) else'no')
|
s453923076
|
p04029
|
u226779434
| 2,000
| 262,144
|
Wrong Answer
| 24
| 9,156
| 59
|
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())
a = 0
for i in range(n):
a += i
print(a)
|
s876198645
|
Accepted
| 23
| 9,136
| 63
|
n = int(input())
a = 0
for i in range(1,n+1):
a += i
print(a)
|
s440752979
|
p03565
|
u372102441
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,064
| 637
|
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`.
|
#n = int(input())
#l = list(map(int, input().split()))
import sys
input = sys.stdin.readline
s=input()
t=input()
flg=False
cnt=0
for i in range(len(s)-len(t)+1):
cnt = 0
for j in range(len(t)):
#print(s[i+j],t[j])
if s[i+j]==t[j]:
cnt+=1
continue
elif s[i+j]=='?':
cnt+=1
continue
if cnt == len(t):
flg = True
print(s[:i].replace("?", "a")+t+s[i+len(t):].replace("?", "a"))
break
if not flg:
print("UNRESTORABLE")
|
s778058013
|
Accepted
| 17
| 3,064
| 770
|
#n = int(input())
#l = list(map(int, input().split()))
import sys
input = sys.stdin.readline
s = input().rstrip("\n")
t = input().rstrip("\n")
flg = False
cnt = 0
for i in range(len(s)-len(t)+1)[::-1]:
cnt = 0
for j in range(len(t)):
#print(s[i+j],t[j])
if s[i+j] == t[j] or s[i+j] == '?':
cnt += 1
#print(cnt,len(t))
if cnt == len(t):
cnt = i
flg = True
#print(cnt)
break
if not flg:
print("UNRESTORABLE")
else:
li = list(s.replace("?", "a"))
#print(li)
for j in range(len(t))[::-1]:
#print(li[cnt+j], t[j])
li[cnt+j] = t[j]
print("".join(li))
|
s202512705
|
p03739
|
u167681750
| 2,000
| 262,144
|
Wrong Answer
| 138
| 14,652
| 485
|
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()))
sa = 0
count = [0, 0]
for i in range(n):
now = a[i]
sa += now
if sa <= 0 and i%2 == 0:
count[0] += 1 - sa
sa = 1
elif sa >= 0 and i%2 == 1:
count[0] += 1 + sa
sa = -1
sa = 0
for i in range(n):
now = a[i]
sa += now
if sa <= 0 and i%2 == 1:
count[1] += 1 - sa
sa = 1
elif sa >= 0 and i%2 == 0:
count[1] += 1 + sa
sa = -1
print(count)
|
s837674922
|
Accepted
| 137
| 14,468
| 482
|
n = int(input())
a = list(map(int, input().split()))
sa = [0, 0]
count = [0, 0]
for i in range(n):
sa[0] += a[i]
if sa[0] <= 0 and i%2 == 0:
count[0] += 1 - sa[0]
sa[0] = 1
elif sa[0] >= 0 and i%2 == 1:
count[0] += 1 + sa[0]
sa[0] = -1
sa[1] += a[i]
if sa[1] <= 0 and i%2 == 1:
count[1] += 1 - sa[1]
sa[1] = 1
elif sa[1] >= 0 and i%2 == 0:
count[1] += 1 + sa[1]
sa[1] = -1
print(min(count))
|
s379917531
|
p03644
|
u639592190
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 109
|
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
N=int(input())
if N==1:
print(1)
else:
i=2
while True:
if i>=N:
print(i)
break
i*=2
|
s346596437
|
Accepted
| 17
| 2,940
| 56
|
N=int(input())
i=0
while 2**i<=N:
i+=1
print(2**(i-1))
|
s644872917
|
p04030
|
u620157187
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 205
|
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
|
s = list(input())
S = []
for i in s:
if i == 'B':
if S != []:
S.pop(-1)
else:
pass
else:
S.append(i)
S_s = ''
for i in S:
S_s += i
print(i)
|
s899891782
|
Accepted
| 17
| 2,940
| 207
|
s = list(input())
S = []
for i in s:
if i == 'B':
if S != []:
S.pop(-1)
else:
pass
else:
S.append(i)
S_s = ''
for i in S:
S_s += i
print(S_s)
|
s954703478
|
p03729
|
u875600867
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 103
|
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`.
|
A, B, C = input().split()
if A[-1] == B[0] and B[-1] == C[0]:
print("Yes")
else:
print("No")
|
s045878624
|
Accepted
| 17
| 2,940
| 193
|
A, B, C = input().split()
if A[-1] == B[0] and B[-1] == C[0]:
print("YES")
else:
print("NO")
|
s671237031
|
p02264
|
u011621222
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,592
| 694
|
_n_ _q_ _name 1 time1_ _name 2 time2_ ... _name n timen_ In the first line the number of processes _n_ and the quantum _q_ are given separated by a single space. In the following _n_ lines, names and times for the _n_ processes are given. _name i_ and _time i_ are separated by a single space.
|
#operand.py using polish way of expressing
data = input()
operators = "+-*/"
command = data.split()
operand = [] #used to store operand"s"
for com in command:
if com in operators: #do some calculation on the last one and the second last one XD
second = operand.pop()
first = operand.pop()
if com == '+':
out = first + second
elif com == "-":
out = first - second
elif com == "*":
out = first * second
elif com == "/":
out = first / second
operand.append(out)
out = int() #clear out
else: #store operand into to buffer
operand.append(int(com))
print(operand[0])
|
s275043036
|
Accepted
| 850
| 17,900
| 1,017
|
#getting input
statements = []
while True:
try:
line = str(input())
except EOFError:
break
statements.append(line)
pair = statements.pop(0).split()
amount = int(pair[0])
quantum = int(pair[1])
#process input
queue = []
for state in statements:
pair = state.split()
name = pair[0]
time = int(pair[1])
queue.append([name,time])
done_list = list()
time_spend = 0
while True:
if not len(queue) > 0:
break
task = queue[0]
if task[1] >= quantum:
time_spend += quantum
task[1] = task[1] - quantum
else:
time_spend += task[1]
task[1] = 0
if task[1] <= 0: #finished
task.append(time_spend) #name,left_time, finished time
done_list.append((task[0],task[2])) #name and finished time
queue.remove(task)
else:
temp = task
queue.remove(task)
queue.append(temp)
for result in done_list:
print(result[0],end=' ')
print(result[1])
|
s104519909
|
p03645
|
u695079172
| 2,000
| 262,144
|
Wrong Answer
| 584
| 25,932
| 277
|
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services. Help him.
|
n,m = map(int,input().split())
from_1 = []
to_n = []
for _ in range(m):
a,b = map(int,input().split())
if a == 1:
from_1.append(b)
if b == n:
to_n.append(a)
if len(set(from_1) - set(to_n)) == 0:
print("IMPOSSIBLE")
else:
print("POSSIBLE")
|
s088512982
|
Accepted
| 595
| 21,852
| 349
|
n,m = map(int,input().split())
from_1 = []
to_n = []
for i in range(m):
a,b = map(int,input().split())
if a == 1:
from_1.append(b)
if a == n:
to_n.append(b)
if b == 1:
from_1.append(a)
if b == n:
to_n.append(a)
if len(set(from_1) & set(to_n)) == 0:
print("IMPOSSIBLE")
else:
print("POSSIBLE")
|
s252991122
|
p02266
|
u918276501
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,380
| 563
|
Your task is to simulate a flood damage. For a given cross-section diagram, reports areas of flooded sections. Assume that rain is falling endlessly in the region and the water overflowing from the region is falling in the sea at the both sides. For example, for the above cross-section diagram, the rain will create floods which have areas of 4, 2, 1, 19 and 9 respectively.
|
g = input()
l = []
q = []
n = 0
for x in range(len(g)):
if g[x] == '\\':
if n:
l.append(n)
n = 0
if q:
q.append(-1)
q.append(x)
elif g[x] == '/':
if q:
while True:
p = q.pop()
print(p)
if p == -1:
n += l.pop()
else:
break
n += x-p
else:
pass
if n:
l.append(n)
for j in range(l.count(0)):
l.remove(0)
print(sum(l))
print(len(l), *l)
|
s450199756
|
Accepted
| 30
| 7,864
| 538
|
g = input()
l = []
q = []
n = 0
for x in range(len(g)):
if g[x] == '\\':
if n:
l.append(n)
n = 0
if q:
q.append(-1)
q.append(x)
elif g[x] == '/':
if q:
while True:
p = q.pop()
if p == -1:
n += l.pop()
else:
break
n += x-p
else:
pass
if n:
l.append(n)
for j in range(l.count(0)):
l.remove(0)
print(sum(l))
print(len(l), *l)
|
s053852406
|
p03679
|
u668726177
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,316
| 125
|
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
|
x, a, b = map(int, input().split())
if (a-b)>x:
print('dangerous')
elif (a-b)>0:
print('safe')
else:
print('delicious')
|
s863993463
|
Accepted
| 17
| 2,940
| 125
|
x, a, b = map(int, input().split())
if (b-a)>x:
print('dangerous')
elif (b-a)>0:
print('safe')
else:
print('delicious')
|
s152850410
|
p04044
|
u149551680
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 159
|
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 = list(map(int, input().strip().split()))
strl = [input().strip() for s in range(N)]
strl = sorted(strl)
s = strl[0]
for t in strl:
s += str(t)
print(s)
|
s333607914
|
Accepted
| 17
| 3,060
| 154
|
N, L = list(map(int, input().strip().split()))
strl = [input().strip() for s in range(N)]
strl = sorted(strl)
s = ''
for t in strl:
s += str(t)
print(s)
|
s128024600
|
p02742
|
u733738237
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 78
|
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
h,w=map(int,input().split())
print(h*w//2 if h//2==0 or w//2==0 else h*w//2+1)
|
s650355325
|
Accepted
| 17
| 2,940
| 92
|
from math import ceil
h,w=map(int,input().split())
print(1 if h==1 or w==1 else ceil(w*h/2))
|
s781088925
|
p02612
|
u627600101
| 2,000
| 1,048,576
|
Wrong Answer
| 34
| 9,136
| 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)
|
s742425566
|
Accepted
| 33
| 9,148
| 37
|
N = int(input())
print((1000-N)%1000)
|
s156331984
|
p00046
|
u498511622
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,340
| 138
|
ไปใพใง็ปใฃใใใจใฎใใๅฑฑใฎๆจ้ซใ่จ้ฒใใใใผใฟใใใใพใใใใฎใใผใฟใ่ชญใฟ่พผใใงใไธ็ช้ซใๅฑฑใจไธ็ชไฝใๅฑฑใฎๆจ้ซๅทฎใๅบๅใใใใญใฐใฉใ ใไฝๆใใฆใใ ใใใ
|
try:
while True:
lst=[]
a=list(input())
lst.append(a)
lst.sort()
print(max(lst)-min(lst))
except EOFError:
pass
|
s568688414
|
Accepted
| 20
| 7,472
| 107
|
try:
lst=[]
while True:
a=float(input())
lst.append(a)
except :
print(max(lst)-min(lst))
|
s249223309
|
p03545
|
u091489347
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,064
| 335
|
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 = str(input())
l = list(s)
for i in range(1 << len(s)-1):
li = ''
for j in range(len(s)):
li += l[j]
if j == len(s)-1:
continue
if i & (1 << j):
li += '+'
else:
li += '-'
# print(li)
r = eval(li)
if r == 7:
break
print(li)
|
s189787458
|
Accepted
| 17
| 3,060
| 340
|
s = str(input())
l = list(s)
for i in range(1 << len(s)-1):
li = ''
for j in range(len(s)):
li += l[j]
if j == len(s)-1:
continue
if i & (1 << j):
li += '+'
else:
li += '-'
# print(li)
r = eval(li)
if r == 7:
break
print(li+'=7')
|
s278999261
|
p03408
|
u821588465
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 145
|
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
|
n = [input() for _ in range(int(input()))]
m = [input() for _ in range(int(input()))]
N = len(list(set(n)))
M = len(list(set(m)))
print(abs(N-M))
|
s914390439
|
Accepted
| 18
| 3,060
| 175
|
n = [input() for _ in range(int(input()))]
m = [input() for _ in range(int(input()))]
l = list(set(n))
print(max(0, max(n.count(l[i]) - m.count(l[i]) for i in range(len(l)))))
|
s459530524
|
p03493
|
u867848444
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 93
|
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
s=list(input())
string=0
for i in range(0,3):
if s[i]==1:
string+=1
print(string)
|
s295550920
|
Accepted
| 18
| 2,940
| 31
|
x = input()
print(x.count('1'))
|
s762399188
|
p03371
|
u888337853
| 2,000
| 262,144
|
Wrong Answer
| 194
| 5,748
| 1,247
|
"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.
|
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul
sys.setrecursionlimit(100001)
# input = sys.stdin.readline
# ===FUNCTION===
def getInputInt():
inputNum = int(input())
return inputNum
def getInputListInt():
outputData = []
inputData = input().split()
outputData = [int(n) for n in inputData]
return outputData
def getSomeInputInt(n):
outputDataList = []
for i in range(n):
inputData = int(input())
outputDataList.append(inputData)
return outputDataList
def getSomeInputListInt(n):
inputDataList = []
outputDataList = []
for i in range(n):
inputData = input().split()
inputDataList = [int(n) for n in inputData]
outputDataList.append(inputDataList)
return outputDataList
# ===CODE===
a, b, c, x, y = map(int, input().split())
itr = max(x, y)*2+1
ans = sys.maxsize
for i in range(itr):
tmpa = a*(x-i//2)
tmpb = b*(y-i//2)
tmpc = c*i
tmp_cost = tmpa+tmpb+tmpc
ans = min(ans, tmp_cost)
print(ans)
|
s146922605
|
Accepted
| 269
| 5,232
| 1,263
|
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul
sys.setrecursionlimit(100001)
# input = sys.stdin.readline
# ===FUNCTION===
def getInputInt():
inputNum = int(input())
return inputNum
def getInputListInt():
outputData = []
inputData = input().split()
outputData = [int(n) for n in inputData]
return outputData
def getSomeInputInt(n):
outputDataList = []
for i in range(n):
inputData = int(input())
outputDataList.append(inputData)
return outputDataList
def getSomeInputListInt(n):
inputDataList = []
outputDataList = []
for i in range(n):
inputData = input().split()
inputDataList = [int(n) for n in inputData]
outputDataList.append(inputDataList)
return outputDataList
# ===CODE===
a, b, c, x, y = map(int, input().split())
itr = max(x, y)*2+1
ans = sys.maxsize
for i in range(itr):
tmpa = max(0, a*(x-i//2))
tmpb = max(0, b*(y-i//2))
tmpc = c*i
tmp_cost = tmpa+tmpb+tmpc
ans = min(ans, tmp_cost)
print(ans)
|
s363453631
|
p03902
|
u226155577
| 2,000
| 262,144
|
Wrong Answer
| 2,106
| 43,788
| 1,159
|
Takahashi is a magician. He can cast a spell on an integer sequence (a_1,a_2,...,a_M) with M terms, to turn it into another sequence (s_1,s_2,...,s_M), where s_i is the sum of the first i terms in the original sequence. One day, he received N integer sequences, each with M terms, and named those sequences A_1,A_2,...,A_N. He will try to cast the spell on those sequences so that A_1 < A_2 < ... < A_N will hold, where sequences are compared lexicographically. Let the action of casting the spell on a selected sequence be one cast of the spell. Find the minimum number of casts of the spell he needs to perform in order to achieve his objective. Here, for two sequences a = (a_1,a_2,...,a_M), b = (b_1,b_2,...,b_M) with M terms each, a < b holds lexicographically if and only if there exists i (1 โฆ i โฆ M) such that a_j = b_j (1 โฆ j < i) and a_i < b_i.
|
from math import log2
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
B = max(max(Ai) for Ai in A)
if M == 1:
if all(A[i][0] <= A[i+1][0] for i in range(N-1)):
print("0")
else:
print("-1")
exit(0)
logB = log2(B)
logBi = int(logB)
INF = 10**18
def gen(P, t):
if t <= B:
for k in range(t):
for i in range(M-1):
P[i+1] += P[i]
else:
for k in range(t):
for i in range(logBi+1):
P[i+1] += P[i]
for i in range(logBi+1, M):
P[i] = INF
T = [0]*N
ans = 0
P = [0]*M
for i in range(N-1):
a0, a1 = A[i][:2]
b0, b1 = A[i+1][:2]
if a0 < b0:
continue
if a0 > b0:
ans = -1
break
t0 = T[i]
v = t0*a0 + a1 - b1
if v % b0 > 0:
T[i+1] = t1 = (v + b0-1) // b0
ans += t1
continue
t1 = v // b0
if t0 < t1:
P[:] = A[i+1]
gen(P, t1-t0)
if P < A[i]:
t1 += 1
else:
P[:] = A[i]
gen(P, t0 - t1)
if A[i+1] < P:
t1 += 1
T[i+1] = t1
ans += t1
print(ans)
|
s795000951
|
Accepted
| 839
| 43,252
| 1,665
|
import sys
readline = sys.stdin.readline
from math import log2
from itertools import accumulate
N, M = map(int, readline().split())
A = [list(map(int, readline().split())) for i in range(N)]
B = max(max(Ai) for Ai in A)
if M == 1:
if N == 1 or all(A[i][0] < A[i+1][0] for i in range(N-1)):
print("0")
else:
print("-1")
exit(0)
logB = log2(B)
logBi = int(logB)
INF = 10**18
INFL = [INF]*(M - logBi-2)
def gen(P, t, L = min(logBi+2, M)):
if t <= logB:
for k in range(t):
P[:] = accumulate(P)
else:
V = [1]*L # V[k] = C(i-j+t-1, i-j)
for k in range(1, L):
V[k] = V[k-1] * (t + k - 1)//k
for i in range(L-1, 0, -1):
P[i] += sum(P[j] * V[i-j] for j in range(i))
if logBi+2 < M:
P[logBi+2:] = INFL
T = [0]*N
ans = 0
P = [0]*M
for i in range(N-1):
a0, a1 = A[i][:2]
b0, b1 = A[i+1][:2]
if a0 < b0:
continue
if a0 > b0:
ans = -1
break
t0 = T[i]
v = max(t0*a0 + a1 - b1, 0)
if v % b0 > 0:
T[i+1] = t1 = (v + b0-1) // b0
ans += t1
continue
t1 = v // b0
if t0 <= t1:
P[:] = A[i+1]
gen(P, t1 - t0)
if P <= A[i]:
t1 += 1
else:
P[:] = A[i]
gen(P, t0 - t1)
if A[i+1] <= P:
t1 += 1
T[i+1] = t1
ans += t1
print(ans)
|
s323739162
|
p03605
|
u759412327
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 53
|
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?
|
if input() in "9":
print("Yes")
else:
print("No")
|
s433880615
|
Accepted
| 27
| 8,864
| 53
|
if "9" in input():
print("Yes")
else:
print("No")
|
s791451828
|
p02397
|
u501414488
| 1,000
| 131,072
|
Wrong Answer
| 50
| 6,724
| 165
|
Write a program which reads two integers x and y, and prints them in ascending order.
|
while True:
(x, y) = [int(i) for i in input().split()]
if x == 0 and y == 0:
break
if x >= y :
print(x, y)
else:
print(x, y)
|
s002588938
|
Accepted
| 50
| 6,720
| 164
|
while True:
(x, y) = [int(i) for i in input().split()]
if x == 0 and y == 0:
break
if x >= y :
print(y, x)
else:
print(x, y)
|
s268627326
|
p02416
|
u492556875
| 1,000
| 131,072
|
Wrong Answer
| 40
| 6,724
| 165
|
Write a program which reads an integer and prints sum of its digits.
|
import sys
from functools import reduce
for line in sys.stdin:
if line == "0":
break
s = reduce(lambda a,b: str(a)+str(b), line.strip())
print(s)
|
s418363485
|
Accepted
| 40
| 6,724
| 168
|
import sys
from functools import reduce
for line in sys.stdin:
if int(line) == 0:
break
s = reduce(lambda a,b: int(a)+int(b), line.strip())
print(s)
|
s411096056
|
p03470
|
u925567828
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 321
|
An _X -layered kagami mochi_ (X โฅ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
N = int(input())
A = [0]*N
m = 0
ans = 0
count = 0
for i in range(N):
A[i] = int(input())
if(m>A[i]):
m = A[i]
elif(m == A[i]):
count +=1
ans =N-count
print(ans)
|
s626688447
|
Accepted
| 18
| 3,064
| 351
|
N = int(input())
A = [0]*N
m = 0
ans = 0
count = 0
for i in range(N):
A[i] = int(input())
A.sort()
for i in range(N):
if(m<A[i]):
m =A[i]
elif(m == A[i]):
count +=1
ans = N - count
print(ans)
|
s938350991
|
p02747
|
u225388820
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 79
|
A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string.
|
s=input()
for i in range(6):
if s=="hi"*i:
print("Yes")
print("No")
|
s219536928
|
Accepted
| 17
| 2,940
| 94
|
s=input()
for i in range(6):
if s=="hi"*i:
print("Yes")
exit()
print("No")
|
s335097184
|
p02743
|
u550257207
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 145
|
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
|
import math
a,b,c = map(int,input().split())
x = math.sqrt(a)
y = math.sqrt(b)
z = math.sqrt(c)
if x+y<z:
print("YES")
else:
print("NO")
|
s641091596
|
Accepted
| 35
| 5,076
| 189
|
from decimal import *
a,b,c = map(int,input().split())
l = Decimal(a)
m = Decimal(b)
n = Decimal(c)
g = Decimal(l*m)
x = a + b + 2*(g.sqrt())
if x<c:
print("Yes")
else:
print("No")
|
s364061951
|
p03448
|
u920103253
| 2,000
| 262,144
|
Wrong Answer
| 114
| 4,168
| 256
|
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(0,a+1):
for j in range(0,b+1):
for k in range(0,c+1):
y=500*i+100*j+50*k
print(i,j,k,y)
if x==y:
c+=1
print(c)
|
s671145046
|
Accepted
| 53
| 3,064
| 241
|
a=int(input())
b=int(input())
c=int(input())
x=int(input())
count=0
for i in range(0,a+1):
for j in range(0,b+1):
for k in range(0,c+1):
y=500*i+100*j+50*k
if x==y:
count+=1
print(count)
|
s777148778
|
p03079
|
u788137651
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 76
|
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
|
a,b,c=map(int,input().split())
if a+b<c:
print("Yes")
else:
print("No")
|
s527034759
|
Accepted
| 17
| 2,940
| 91
|
a, b, c = map(int, input().split())
if a == b == c:
print("Yes")
else:
print("No")
|
s865819569
|
p04043
|
u287097467
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 107
|
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 = list(map(int,input().split(' ')))
nums.sort()
if nums == [5,5,7]:
print('Yes')
else:
print('No')
|
s958079661
|
Accepted
| 17
| 2,940
| 107
|
nums = list(map(int,input().split(' ')))
nums.sort()
if nums == [5,5,7]:
print('YES')
else:
print('NO')
|
s935437967
|
p03455
|
u234631479
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 86
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a, b = map(int, input().split())
if (a*b)%2 == 1:
print("Even")
else:
print("Odd")
|
s333785497
|
Accepted
| 18
| 2,940
| 86
|
a, b = map(int, input().split())
if (a*b)%2 == 1:
print("Odd")
else:
print("Even")
|
s784334499
|
p03448
|
u845427284
| 2,000
| 262,144
|
Wrong Answer
| 46
| 3,064
| 246
|
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 i in range(a):
s = 500 * a
for j in range(b):
t = 100 * b
for k in range(c):
u = 50 * c
if s + t + u == x:
count += 1
print(count)
|
s421833050
|
Accepted
| 45
| 3,064
| 258
|
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a + 1):
s = 500 * i
for j in range(b + 1):
t = 100 * j
for k in range(c + 1):
u = 50 * k
if s + t + u == x:
count += 1
print(count)
|
s971325327
|
p03475
|
u733608212
| 3,000
| 262,144
|
Wrong Answer
| 119
| 3,188
| 403
|
A railroad running from west to east in Atcoder Kingdom is now complete. There are N stations on the railroad, numbered 1 through N from west to east. Tomorrow, the opening ceremony of the railroad will take place. On this railroad, for each integer i such that 1โคiโคN-1, there will be trains that run from Station i to Station i+1 in C_i seconds. No other trains will be operated. The first train from Station i to Station i+1 will depart Station i S_i seconds after the ceremony begins. Thereafter, there will be a train that departs Station i every F_i seconds. Here, it is guaranteed that F_i divides S_i. That is, for each Time t satisfying S_iโคt and t๏ผ
F_i=0, there will be a train that departs Station i t seconds after the ceremony begins and arrives at Station i+1 t+C_i seconds after the ceremony begins, where A๏ผ
B denotes A modulo B, and there will be no other trains. For each i, find the earliest possible time we can reach Station N if we are at Station i when the ceremony begins, ignoring the time needed to change trains.
|
n = int(input())
li =[list(map(int, input().split())) for _ in range(n-1)]
print(li)
for i in range(n):
t = 0
for j in range(i,n-1):
if t <= li[j][1]:
t = li[j][1] + li[j][0]
else:
k = t // li[j][2]
if t % li[j][2] == 0:
t += li[j][0]
else:
t += li[j][0] + (li[j][2] - t % li[j][2])
print(t)
|
s668743440
|
Accepted
| 120
| 3,316
| 393
|
n = int(input())
li =[list(map(int, input().split())) for _ in range(n-1)]
for i in range(n):
t = 0
for j in range(i,n-1):
if t <= li[j][1]:
t = li[j][1] + li[j][0]
else:
k = t // li[j][2]
if t % li[j][2] == 0:
t += li[j][0]
else:
t += li[j][0] + (li[j][2] - t % li[j][2])
print(t)
|
s990453731
|
p03573
|
u380534719
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 86
|
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
|
s=input()
if s[0]==s[2]:
print('C')
elif s[0]==s[4]:
print('B')
else:
print('A')
|
s262061666
|
Accepted
| 17
| 2,940
| 89
|
a,b,c=map(int,input().split())
if a==b:
print(c)
elif a==c:
print(b)
else:
print(a)
|
s861996197
|
p02390
|
u255164080
| 1,000
| 131,072
|
Wrong Answer
| 30
| 6,744
| 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 / 60
m = 60 % 60
s = 60 % 60
print(h,m,s,sep=':')
|
s060003184
|
Accepted
| 30
| 6,724
| 84
|
S = int(input())
h = S // 3600
m = S % 3600 // 60
s = S % 60
print(h, m, s, sep=':')
|
s170166460
|
p03680
|
u593567568
| 2,000
| 262,144
|
Time Limit Exceeded
| 2,107
| 7,852
| 248
|
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 = [-1] + [int(input()) for _ in range(N)]
USED = [False] * (N+1)
cnt = 0
prev = 1
while True:
nxt = A[prev]
cnt += 1
if nxt == 2:
break
USED[prev] = True
if USED[nxt]:
cnt = -1
break
print(cnt)
|
s089838121
|
Accepted
| 201
| 7,852
| 267
|
N = int(input())
A = [-1] + [int(input()) for _ in range(N)]
USED = [False] * (N+1)
cnt = 0
prev = 1
while True:
nxt = A[prev]
cnt += 1
if nxt == 2:
break
USED[prev] = True
if USED[nxt]:
cnt = -1
break
prev = nxt
print(cnt)
|
s768625671
|
p02390
|
u017435045
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,584
| 126
|
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.
|
a=int(input())
hour=int(a/3600)
min=int((a-hour*3600)/60)
sec=a-hour*3600-min*60
print(str(hour)+" "+str(min)+" "+str(sec))
|
s638469395
|
Accepted
| 20
| 5,580
| 54
|
x=int(input())
print(x//3600,x//60%60,x%60,sep=':')
|
s935083412
|
p03129
|
u066017048
| 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 - 1 > k:
print("Yes")
else:
print("No")
|
s001602694
|
Accepted
| 17
| 2,940
| 194
|
n, k = map(int, input().split())
if n % 2 == 1:
if (n+1)/2 >= k:
print("YES")
else:
print("NO")
else:
if n/2 >= k:
print("YES")
else:
print("NO")
|
s000173384
|
p00004
|
u203261375
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,364
| 128
|
Write a program which solve a simultaneous equation: ax + by = c dx + ey = f The program should print x and y for given a, b, c, d, e and f (-1,000 โค a, b, c, d, e, f โค 1,000). You can suppose that given equation has a unique solution.
|
import sys
for line in sys.stdin:
a,b,c,d,e,f = map(float, line.split())
print((c*e-b*f)/(a*e-b*d), (a*f-c*d)/(a*e-b*d))
|
s515510200
|
Accepted
| 20
| 7,436
| 264
|
import sys
for line in sys.stdin:
a,b,c,d,e,f = map(float, line.split())
x = round((c*e-b*f)/(a*e-b*d), 3)
y = round((a*f-c*d)/(a*e-b*d), 3)
if x == -0:
x = 0
if y == -0:
y = 0
print("{0:.3f}".format(x), "{0:.3f}".format(y))
|
s345279138
|
p03731
|
u698902360
| 2,000
| 262,144
|
Wrong Answer
| 109
| 26,708
| 298
|
In a public bath, there is a shower which emits water for T seconds when the switch is pushed. If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds. N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it. How long will the shower emit water in total?
|
N, T = map(int, input().split())
t = list(map(int, input().split()))
X = 0
Time = 0
for i in range(N):
if Time < t[i]:
X += T
Time = t[i] + T
print(X)
|
s375096090
|
Accepted
| 153
| 26,708
| 211
|
N, T = map(int, input().split())
t = list(map(int, input().split()))
X = 0
Time = 0
for i in range(N):
if Time <= t[i] :
X += T
else:
X += t[i] - t[i-1]
Time = t[i] + T
print(X)
|
s632335073
|
p02613
|
u690442716
| 2,000
| 1,048,576
|
Wrong Answer
| 163
| 16,580
| 228
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
from collections import Counter
N = int(input())
S = []
for i in range(N):
S.append(input())
s = Counter(S)
print("AC ร "+str(s['AC']))
print("WA ร "+str(s['WA']))
print("TLE ร "+str(s['TLE']))
print("RE ร "+str(s['RE']))
|
s605014255
|
Accepted
| 158
| 16,584
| 224
|
from collections import Counter
N = int(input())
S = []
for i in range(N):
S.append(input())
s = Counter(S)
print("AC x "+str(s['AC']))
print("WA x "+str(s['WA']))
print("TLE x "+str(s['TLE']))
print("RE x "+str(s['RE']))
|
s578201088
|
p03455
|
u740964967
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 131
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
num1,num2=input().split(" ")
num1 = int(num1)
num2 = int(num2)
if (num1 * num2) % 2 == 0:
print("even")
else:
print("odd")
|
s626675224
|
Accepted
| 17
| 2,940
| 131
|
num1,num2=input().split(" ")
num1 = int(num1)
num2 = int(num2)
if (num1 * num2) % 2 == 0:
print("Even")
else:
print("Odd")
|
s426967728
|
p03658
|
u502149531
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 156
|
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.
|
c, d = map(int, input().split())
ans = 0
a = [int(i) for i in input().split()]
a.sort()
print(a)
for i in range(d) :
ans = ans + a[c-1-i]
print (ans)
|
s489092066
|
Accepted
| 22
| 2,940
| 150
|
c, d = map(int, input().split())
ans = 0
a = [int(i) for i in input().split()]
a.sort()
for i in range(d) :
ans = ans + a[c-1-i]
print (ans)
|
s837259228
|
p03469
|
u363610900
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,060
| 38
|
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
|
print(input().replace('2018', '2017'))
|
s021501511
|
Accepted
| 19
| 2,940
| 44
|
S = input()
print(S.replace('2017', '2018'))
|
s264272662
|
p03485
|
u556657484
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 112
|
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a, b = map(int, input().split())
if (a + b) % 2 == 0:
x = (a + b) / 2
else:
x = (a + b + 1)/2
print(x)
|
s757922887
|
Accepted
| 17
| 2,940
| 54
|
a, b = map(int, input().split())
print((a + b + 1)//2)
|
s144079813
|
p03486
|
u760527120
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 84
|
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
s = input()
t = input()
if sorted(s) < sorted(t):
print('Yes')
else:
print('No')
|
s371906535
|
Accepted
| 17
| 2,940
| 99
|
s = input()
t = input()
if sorted(s) < sorted(t, reverse=True):
print('Yes')
else:
print('No')
|
s013175839
|
p03997
|
u633928488
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 64
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a=int(input())
b=int(input())
h=int(input())
print("(a+b)*h/2)")
|
s846673153
|
Accepted
| 17
| 2,940
| 67
|
a=int(input())
b=int(input())
h=int(input())
print(int((a+b)*h/2))
|
s850963498
|
p03944
|
u468972478
| 2,000
| 262,144
|
Wrong Answer
| 26
| 9,176
| 243
|
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 โฆ i โฆ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 โฆ i โฆ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
|
w, h, n = map(int, input().split())
s = w * h
for i in range(n):
x, y, a = map(int, input().split())
if a == 1:
s -= (x * h)
elif a == 2:
s -= ((w - x) * h)
elif a == 3:
s -= (y * w)
else:
s -= ((h - y) * w)
print(s)
|
s578885606
|
Accepted
| 27
| 9,204
| 316
|
w, h, n = map(int, input().split())
l, r, t, b = 0, w, h, 0
for i in range(n):
x, y, a = map(int, input().split())
if a == 1:
l = max(x, l)
elif a == 2:
r = min(x, r)
elif a == 3:
b = max(y, b)
else:
t = min(y, t)
if (r - l) <= 0 or (t - b) <= 0:
print(0)
else:
print((r - l) * (t - b))
|
s343658729
|
p02833
|
u638057737
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 139
|
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
|
N = int(input())
if N & 1:
print(0)
else:
count = 0
i = 0
while pow(5,i) <= N:
count += N // pow(5,i)
i += 1
print(count)
|
s540343221
|
Accepted
| 17
| 2,940
| 126
|
N = int(input())
if N & 1:
print(0)
else:
count = 0
i = 10
while i <= N:
count += N // i
i *= 5
print(count)
|
s996412930
|
p03352
|
u777028980
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 189
|
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
|
n=int(input())
ans=[]
for i in range(int(1+n**0.5)):
suu=i+1
print(suu)
for j in range(int(1+n**0.5)):
kotae=suu**j
if(kotae<=n):
ans.append(kotae)
print(max(ans))
|
s222331279
|
Accepted
| 17
| 3,060
| 171
|
n=int(input())
ans=[]
for i in range(int(1+n**0.5)):
suu=i+1
for j in range(int(1+n**0.5)):
kotae=suu**j
if(kotae<=n):
ans.append(kotae)
print(max(ans))
|
s082736200
|
p02748
|
u057483262
| 2,000
| 1,048,576
|
Wrong Answer
| 2,105
| 43,624
| 545
|
You are visiting a large electronics store to buy a refrigerator and a microwave. The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen. You have M discount tickets. With the i-th ticket ( 1 \le i \le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time. You are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.
|
import sys
def load(vtype=int):
return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
return [vtype(v) for v in input().strip().split(seplator)]
A, B, M = tuple(load_list())
a = load_list()
b = load_list()
coupon = dict()
for _ in range(M):
x, y, c = tuple(load_list())
coupon[(x-1, y-1)] = c
print(a, b, coupon)
minv = a[0] + b[0]
for i in range(0, A):
for j in range(0, B):
v = a[i] + b[i]
if (i, j) in coupon:
v -= coupon[(i,j)]
minv = min(minv, v)
print(minv)
|
s030731263
|
Accepted
| 690
| 35,696
| 571
|
import sys
def load(vtype=int):
return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
return [vtype(v) for v in input().strip().split(seplator)]
A, B, M = tuple(load_list())
a = load_list()
b = load_list()
coupon = dict()
for _ in range(0, M):
x, y, c = tuple(load_list())
if (x-1, y-1) in coupon:
coupon[(x-1,y-1)] = max(coupon[(x-1,y-1)], c)
else:
coupon[(x-1,y-1)] = c
minv = min(a) + min(b)
for key in coupon.keys():
i, j = key
minv = min(minv, a[i] + b[j] - coupon[(i, j)])
print(minv)
|
s180399171
|
p03680
|
u363610900
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 7,084
| 158
|
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)]
cnt = 0
i = 1
while cnt <= N:
i = a[i-1]
if i == 2:
print(cnt)
exit()
print(-1)
|
s389228675
|
Accepted
| 211
| 7,084
| 217
|
N = int(input())
a = [int(input()) for _ in range(N)]
cnt = 0
i = 1
while cnt <= N:
for _ in range(N):
i = a[i - 1]
cnt += 1
if i == 2:
print(cnt)
exit()
print(-1)
|
s533587499
|
p03998
|
u459697504
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,188
| 1,322
|
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.
|
#! /usr/bin/python3
import sys
test_mode = False
S_A = list(str(input()))
S_B = list(str(input()))
S_C = list(str(input()))
def turn(player):
if player == 'a':
card = S_A[0]
del S_A[0]
if test_mode:
print('Aใฎใฟใผใณ :', card)
if S_A == []:
print('ใใใ', sys.stderr)
return 'A'
turn(card)
if player == 'b':
card = S_B[0]
del S_B[0]
if test_mode:
print('Bใฎใฟใผใณ :', card)
if S_B == []:
print('ใใใ', sys.stderr)
return 'B'
turn(card)
if player == 'c':
card = S_C[0]
del S_C[0]
if test_mode:
print('Cใฎใฟใผใณ :', card)
if S_C == []:
print('ใใใ', sys.stderr)
return 'C'
turn(card)
def main():
print(turn('a'))
if __name__ == '__main__':
main()
|
s678958532
|
Accepted
| 18
| 3,188
| 1,317
|
#! /usr/bin/python3
test_mode = False
S_A = list(str(input()))
S_B = list(str(input()))
S_C = list(str(input()))
def turn(player):
if player == 'a':
try:
card = S_A[0]
del S_A[0]
if test_mode:
print('Aใฎใฟใผใณ :', card)
return turn(card)
except IndexError:
return 'A'
if player == 'b':
try:
card = S_B[0]
del S_B[0]
if test_mode:
print('Bใฎใฟใผใณ :', card)
return turn(card)
except IndexError:
return 'B'
if player == 'c':
try:
card = S_C[0]
del S_C[0]
if test_mode:
print('Cใฎใฟใผใณ :', card)
return turn(card)
except IndexError:
return 'C'
def main():
print(turn('a'))
if __name__ == '__main__':
main()
|
s699086464
|
p02743
|
u399155892
| 2,000
| 1,048,576
|
Wrong Answer
| 678
| 21,512
| 260
|
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
|
#!/usr/bin/env python
import numpy as np
def main():
a, b, c = map(int, input().split())
a = np.sqrt(a)
b = np.sqrt(b)
c = np.sqrt(c)
if a + b < c:
print('yes')
else:
print('no')
if __name__ == '__main__':
main()
|
s431699342
|
Accepted
| 17
| 2,940
| 225
|
#!/usr/bin/env python
def main():
a, b, c = map(int, input().split())
if (c - a - b) ** 2 - 4 * a * b > 0 and c - a - b > 0:
print('Yes')
else:
print('No')
if __name__ == '__main__':
main()
|
s375536730
|
p02612
|
u111684666
| 2,000
| 1,048,576
|
Wrong Answer
| 27
| 9,140
| 35
|
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 + 1)
|
s200320791
|
Accepted
| 30
| 9,148
| 44
|
n = int(input())
print((1000-n%1000) % 1000)
|
s938235195
|
p03485
|
u994988729
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 67
|
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
from math import ceil
a,b=map(int,input().split())
print(ceil(a/b))
|
s479343602
|
Accepted
| 17
| 2,940
| 72
|
from math import ceil
a,b=map(int,input().split())
print(ceil((a+b)/2))
|
s217435004
|
p02255
|
u283452598
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,588
| 221
|
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.
|
num = int(input())
array = list(map(int,input().split()))
for i in range(num):
v = array[i]
j = i-1
while j >=0 and array[j]>v:
array[j+1] = array[j]
j -= 1
array[j+1] = v
print(array)
|
s258843690
|
Accepted
| 20
| 7,652
| 240
|
num = int(input())
array = list(map(int,input().split()))
for i in range(num):
v = array[i]
j = i-1
while j >=0 and array[j]>v:
array[j+1] = array[j]
j -= 1
array[j+1] = v
print(" ".join(map(str,array)))
|
s119130242
|
p03853
|
u690781906
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 137
|
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
|
h, w = map(int, input().split())
c = [input().split() for _ in range(h)]
for i in range(2):
for j in range(h):
print(c[j][0])
|
s891902799
|
Accepted
| 17
| 3,060
| 129
|
h, w = map(int, input().split())
c = [input().split() for _ in range(h)]
for j in range(h):
print(c[j][0])
print(c[j][0])
|
s446538544
|
p03719
|
u904804404
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 86
|
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 <=b<=c:
print("Yes")
else:
print("No")
|
s574993135
|
Accepted
| 17
| 2,940
| 86
|
a,b,c = list(map(int,input().split()))
if a <=c<=b:
print("Yes")
else:
print("No")
|
s162761585
|
p03624
|
u371467115
| 2,000
| 262,144
|
Wrong Answer
| 42
| 4,208
| 42
|
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
|
s=list(input())
s.sort()
print("".join(s))
|
s923400575
|
Accepted
| 20
| 3,188
| 82
|
print(min(set(map(chr,range(97,123)))-set(input())or["None"]))
|
s333556597
|
p00030
|
u650459696
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,752
| 445
|
0 ใใ 9 ใฎๆฐๅญใใ็ฐใชใ n ๅใฎๆฐใๅใๅบใใฆๅ่จใ s ใจใชใ็ตใฟๅใใใฎๆฐใๅบๅใใใใญใฐใฉใ ใไฝๆใใฆใใ ใใใn ๅใฎๆฐใฏใใฎใใฎ 0 ใใ 9 ใพใงใจใใ๏ผใคใฎ็ตใฟๅใใใซๅใๆฐๅญใฏไฝฟใใพใใใใใจใใฐใn ใ 3 ใง s ใ 6 ใฎใจใใ3 ๅใฎๆฐๅญใฎๅ่จใ 6 ใซใชใ็ตใฟๅใใใฏใ 1 + 2 + 3 = 6 0 + 1 + 5 = 6 0 + 2 + 4 = 6 ใฎ 3 ้ใใจใชใใพใใ
|
def decSum(n, sm, mn):
print(n,sm,mn)
if mn + n > 10 :
return 0
elif sum(range(mn, mn + n)) > sm or sum(range(10 - n, 10)) < sm:
return 0
elif n == 1:
return 1
else:
a = 0
for i in range(mn, 10 if sm >= 10 else sm):
a += decSum(n - 1, sm - i, i + 1)
return a
while True:
n, sm = map(int, input().split())
if n == 0:
break
print(decSum(n, sm, 0))
|
s091950983
|
Accepted
| 20
| 7,608
| 446
|
def decSum(n, sm, mn):
#print(n,sm,mn)
if mn + n > 10 :
return 0
elif sum(range(mn, mn + n)) > sm or sum(range(10 - n, 10)) < sm:
return 0
elif n == 1:
return 1
else:
a = 0
for i in range(mn, 10 if sm >= 10 else sm):
a += decSum(n - 1, sm - i, i + 1)
return a
while True:
n, sm = map(int, input().split())
if n == 0:
break
print(decSum(n, sm, 0))
|
s796667332
|
p03361
|
u989654188
| 2,000
| 262,144
|
Wrong Answer
| 25
| 3,064
| 649
|
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`. However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black. Determine if square1001 can achieve his objective.
|
h,w = map(int,(input().split()))
li = []
jud = 1
for i in range(h):
li.append(list(input()))
dx = [0,1,-1,0]
dy = [1,0,0,-1]
num = 0
for i in range(h):
for j in range(w):
if li[i][j] == '#':
num=0
for d in range(len(dx)):
ni = i+dy[d]
nj = j+dx[d]
if ni < 0 or h <= ni:
continue
if nj < 0 or w <= nj:
continue
if li[ni][nj] == '#':
num+=1
if num == 0:
jud = 0
break
if jud == 0:
print("NO")
if jud == 1:
print("YES")
|
s491060800
|
Accepted
| 25
| 3,064
| 649
|
h,w = map(int,(input().split()))
li = []
jud = 1
for i in range(h):
li.append(list(input()))
dx = [0,1,-1,0]
dy = [1,0,0,-1]
num = 0
for i in range(h):
for j in range(w):
if li[i][j] == '#':
num=0
for d in range(len(dx)):
ni = i+dy[d]
nj = j+dx[d]
if ni < 0 or h <= ni:
continue
if nj < 0 or w <= nj:
continue
if li[ni][nj] == '#':
num+=1
if num == 0:
jud = 0
break
if jud == 0:
print("No")
if jud == 1:
print("Yes")
|
s957443785
|
p03623
|
u611090896
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 75
|
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
x,a,b = map(int,input().split())
print('A' if abs(x-a) > abs(x-b) else 'B')
|
s893258669
|
Accepted
| 17
| 2,940
| 76
|
x,a,b = map(int,input().split())
print('A' if abs(x-a) < abs(x-b) else 'B')
|
s002399267
|
p02612
|
u656803083
| 2,000
| 1,048,576
|
Wrong Answer
| 29
| 9,148
| 106
|
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())
ans = 1000
while True:
if ans - n <= 1000:
break
n += 1000
print(ans - n)
|
s874746733
|
Accepted
| 29
| 9,156
| 79
|
n = int(input())
if n % 1000 == 0:
print(0)
else:
print(1000 - (n % 1000))
|
s252663296
|
p03385
|
u587452053
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 171
|
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
def main():
s = input()
if 'a' in s and 'b' in s and 'c' in s:
print("YES")
else:
print("NO")
if __name__ == '__main__':
main()
|
s345532920
|
Accepted
| 17
| 2,940
| 171
|
def main():
s = input()
if 'a' in s and 'b' in s and 'c' in s:
print("Yes")
else:
print("No")
if __name__ == '__main__':
main()
|
s172959455
|
p02578
|
u595353654
| 2,000
| 1,048,576
|
Wrong Answer
| 253
| 50,916
| 2,386
|
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.
|
##a = int(stdin.readline().rstrip())
##b, c = [int(x) for x in stdin.readline().rstrip().split()]
##s = stdin.readline().rstrip()
##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]
##a = [[0] * 2 for _ in range(n)] a[0,0]
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
import bisect
import copy
MOD = int(1e9+7)
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
def keta(kazu):
kazu_str = str(kazu)
kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
return kazu_list
def gcd(*numbers):
return reduce(math.gcd, numbers)
def combination(m,n): # mCn
if n > m:
return 'ใใพใ'
return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))
def pow_k(x,n):
if n == 0:
return 1
K = 1
while n > 1:
if n % 2 != 0:
K *= x
x *= x
n //= 2
return K * x
def fact(n):
arr = {}
temp = n
for i in range(2,int(n**0.5)+1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
arr[i] = cnt
if temp != 1:
arr[temp] = 1
if arr == {}:
arr[n] = 1
return arr
def main():
N = int(stdin.readline().rstrip())
A = list(map(int,[int(x) for x in stdin.readline().rstrip().split()]))
A.append(INF)
ans = 0
print(A)
for i in range(1,N):
if A[i] < A[i-1]:
ans += abs(A[i-1]-A[i])
A[i] = A[i-1]
print(ans)
main()
|
s499941066
|
Accepted
| 224
| 50,736
| 2,355
|
##a = int(stdin.readline().rstrip())
##b, c = [int(x) for x in stdin.readline().rstrip().split()]
##s = stdin.readline().rstrip()
##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]
##a = [[0] * 2 for _ in range(n)] a[0,0]
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
import bisect
import copy
MOD = int(1e9+7)
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
def keta(kazu):
kazu_str = str(kazu)
kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
return kazu_list
def gcd(*numbers):
return reduce(math.gcd, numbers)
def combination(m,n): # mCn
if n > m:
return 'ใใพใ'
return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))
def pow_k(x,n):
if n == 0:
return 1
K = 1
while n > 1:
if n % 2 != 0:
K *= x
x *= x
n //= 2
return K * x
def fact(n):
arr = {}
temp = n
for i in range(2,int(n**0.5)+1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
arr[i] = cnt
if temp != 1:
arr[temp] = 1
if arr == {}:
arr[n] = 1
return arr
def main():
N = int(stdin.readline().rstrip())
A = list(map(int,[int(x) for x in stdin.readline().rstrip().split()]))
ans = 0
for i in range(1,N):
if A[i] < A[i-1]:
ans += abs(A[i-1]-A[i])
A[i] = A[i-1]
print(ans)
main()
|
s823734288
|
p03574
|
u582580413
| 2,000
| 262,144
|
Wrong Answer
| 36
| 3,064
| 631
|
You are given an H ร W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
|
h,w = map(int,input().split())
s = []
def calc(i,j,k,l):
if k==0 and l==0:
return 0
elif i+k==-1 or j+l==-1 or i+k==h or j+l==w:
return 0
elif s[i+k][j+l] == '#':
count[i][j] = count[i][j] + 1
for i in range(h):
s += [input()]
count = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
for j in range(w):
for k in range(3):
for l in range(3):
calc(i,j,k-1,l-1)
for i in range(h):
s_tmp=''
for j in range(w):
if s[i][j]=='#':
s_tmp += '#'
else:
s_tmp += str(count[i][j])
s[i]=s_tmp
print(s)
|
s296731619
|
Accepted
| 36
| 3,188
| 657
|
h,w = map(int,input().split())
s = []
def calc(i,j,k,l):
if k==0 and l==0:
return 0
elif i+k==-1 or j+l==-1 or i+k==h or j+l==w:
return 0
elif s[i+k][j+l] == '#':
count[i][j] = count[i][j] + 1
for i in range(h):
s += [input()]
count = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
for j in range(w):
for k in range(3):
for l in range(3):
calc(i,j,k-1,l-1)
for i in range(h):
s_tmp=''
for j in range(w):
if s[i][j]=='#':
s_tmp += '#'
else:
s_tmp += str(count[i][j])
s[i]=s_tmp
for i in range(h):
print(s[i])
|
s050602935
|
p03479
|
u853010060
| 2,000
| 262,144
|
Wrong Answer
| 19
| 2,940
| 186
|
As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence.
|
X, Y = map(int, input().split())
a, b = 0, 0
while True:
X = X//2
if X < 2:
break
a += 1
while True:
Y = Y//2
if Y < 2:
break
b += 1
print(b-a+1)
|
s059044611
|
Accepted
| 17
| 2,940
| 127
|
X, Y = map(int, input().split())
b = 0
while True:
Y = Y//2
if Y < X:
b += 1
break
b += 1
print(b)
|
s706899607
|
p03556
|
u757030836
| 2,000
| 262,144
|
Time Limit Exceeded
| 2,104
| 3,060
| 147
|
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
|
n =int(input())
ans =[]
for i in range(10**9):
if (i ** 0.5).is_integer() and i <= n:
ans.append(i)
print(ans[-1])
|
s349053457
|
Accepted
| 36
| 2,940
| 102
|
n = int(input())
m = 1
for i in range(1, n):
if i ** 2 > n:
break
m = i ** 2
print(m)
|
s871765720
|
p03730
|
u677312543
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 246
|
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
a, b, c = map(int, input().split())
i = a % b
init_i = i
i_list = []
while True:
print(i)
if i%b == c:
print('YES')
exit()
if i in i_list:
print('NO')
exit()
i_list.append(i)
i = (i+init_i) % b
|
s535693351
|
Accepted
| 20
| 3,060
| 128
|
a, b, c = map(int, input().split())
for i in range(1, 101):
if i*a % b == c:
print('YES')
exit()
print('NO')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.