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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s716576793
|
p02612
|
u697953988
| 2,000
| 1,048,576
|
Wrong Answer
| 29
| 9,080
| 24
|
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.
|
print(int(input())%1000)
|
s882380404
|
Accepted
| 27
| 9,084
| 84
|
import math
cost=int(input())
payment=math.ceil(cost/1000)*1000
print(payment-cost)
|
s436467194
|
p03469
|
u559346857
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,068
| 21
|
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("2018"+input())
|
s469219143
|
Accepted
| 17
| 2,940
| 25
|
print("2018"+input()[4:])
|
s916922194
|
p03679
|
u181215519
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 138
|
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 :
print( "delicious" )
elif B < X :
print( "safe" )
else :
print( "dangerous" )
|
s867733484
|
Accepted
| 17
| 2,940
| 142
|
X, A, B = map( int, input().split() )
if A >= B :
print( "delicious" )
elif B - A <= X :
print( "safe" )
else :
print( "dangerous" )
|
s547005822
|
p03371
|
u482157295
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 203
|
"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.
|
cost_a,cost_b,cost_ab,num_a,num_b = map(int,input().split())
num = max(num_a,num_b)
cost1 = num * 2 * cost_ab
cost2 = cost_a * num_a + cost_b * num_b
if cost1 > cost2:
print(cost2)
else:
print(cost1)
|
s266384352
|
Accepted
| 18
| 3,064
| 584
|
cost_a,cost_b,cost_ab,num_a,num_b = map(int,input().split())
if num_a > num_b:
num_ab = num_b * 2
need_a = num_a - (num_ab // 2)
cost1 = need_a * cost_a + num_ab * cost_ab
num_ab = num_a * 2
cost3 = num_ab * cost_ab
cost1 = min(cost1,cost3)
elif num_a < num_b:
num_ab = num_a * 2
need_b = num_b - (num_ab // 2)
cost1 = need_b * cost_b + num_ab * cost_ab
num_ab = num_b * 2
cost3 = num_ab * cost_ab
cost1 = min(cost1,cost3)
else:
num_ab = num_b * 2
cost1 = num_ab * cost_ab
cost2 = cost_a * num_a + cost_b * num_b
ans = min(cost1,cost2)
print(ans)
|
s665465862
|
p02259
|
u153665391
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,620
| 299
|
Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 4 of the pseudocode.
|
n = int(input()) - 1
a = list(map(int, input().split()))
count = 0
flag = 1
while flag:
flag = 0
for i in range( n, 0, -1 ):
if a[i] < a[i-1]:
t = a[i]
a[i] = a[i-1]
a[i-1] = t
count += 1
flag = 1
print(count)
print(*a)
|
s503702943
|
Accepted
| 20
| 5,600
| 404
|
N = int(input())
A = list(map(int, input().split()))
if __name__ == '__main__':
flg = True
cnt = 0
while flg:
for i in range(N):
flg = False
for j in range(N-1, i, -1):
if A[j] < A[j-1]:
A[j], A[j-1] = A[j-1], A[j]
cnt += 1
flg = True
print(" ".join(map(str, A)))
print(cnt)
|
s137032071
|
p03139
|
u252828980
| 2,000
| 1,048,576
|
Wrong Answer
| 25
| 9,096
| 65
|
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question.
|
n,a,b = map(int,input().split())
print(min(a,b),max(n - (a+b),0))
|
s463263189
|
Accepted
| 24
| 9,056
| 116
|
n,a,b = map(int,input().split())
max1 = min(a,b)
if a+b <= n:
min1 =0
elif a+b >n:
min1 = a+b-n
print(max1,min1)
|
s305993193
|
p03433
|
u633000076
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 305
|
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
N=int(input())
a=int(input())
if N%500==0:
print("YES")
elif N<=a:
print("YES")
elif N>a:
for i in range(1,24):
if N-(500*i)<=a and N-(500*i)>=0:
print("YES")
break
else:
print("NO")
break
elif a==0 and N%500!=0:
print("NO")
|
s067300882
|
Accepted
| 18
| 2,940
| 81
|
N=int(input())
a=int(input())
if N%500<=a:
print("Yes")
else:
print("No")
|
s501853897
|
p03605
|
u115877451
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 57
|
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?
|
a=input()
if a in '9':
print('Yes')
else:
print('No')
|
s246214189
|
Accepted
| 18
| 2,940
| 57
|
a=input()
if '9' in a:
print('Yes')
else:
print('No')
|
s923448823
|
p03997
|
u871596687
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 68
|
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)
|
s118374758
|
Accepted
| 17
| 2,940
| 80
|
a = int(input())
b = int(input())
h = int(input())
S= int((a+b)*h//2)
print(S)
|
s927849221
|
p04029
|
u617203831
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 31
|
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
n=int(input())
print(n*(n+1)/2)
|
s272457530
|
Accepted
| 18
| 2,940
| 32
|
n=int(input())
print(n*(n+1)//2)
|
s064221282
|
p03433
|
u746419473
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 69
|
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
n=int(input())
a=int(input())
print("Yse" if (n%500) <= a else "No")
|
s518934529
|
Accepted
| 17
| 2,940
| 72
|
n = int(input())
a = int(input())
print("Yes" if n%500 <= a else "No")
|
s433686451
|
p04043
|
u519939795
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 99
|
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a = list(map(int, input().split()))
if sorted(a) == [5,5,7]:
print('Yes')
else:
print('NO')
|
s655138448
|
Accepted
| 17
| 2,940
| 83
|
a=list((input()))
print('YES' if a.count(('5'))==2 and a.count(('7'))==1 else 'NO')
|
s604761925
|
p04011
|
u348868667
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 122
|
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(X*N)
else:
print(X*K+Y*(N-K))
|
s330065048
|
Accepted
| 17
| 2,940
| 122
|
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N <= K:
print(X*N)
else:
print(X*K+Y*(N-K))
|
s049729898
|
p02601
|
u587370992
| 2,000
| 1,048,576
|
Wrong Answer
| 33
| 9,112
| 200
|
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
|
A, B, C = map(int, input().split())
K = int(input())
cnt = 0
while B <= A:
cnt += 1
B *= 2
while C <= B:
cnt += 1
C *= 2
print(cnt)
if cnt <= K:
print("Yes")
else:
print("No")
|
s308676287
|
Accepted
| 35
| 9,112
| 189
|
A, B, C = map(int, input().split())
K = int(input())
cnt = 0
while B <= A:
cnt += 1
B *= 2
while C <= B:
cnt += 1
C *= 2
if cnt <= K:
print("Yes")
else:
print("No")
|
s080406400
|
p01428
|
u731941832
| 2,000
| 131,072
|
Wrong Answer
| 50
| 5,588
| 1,547
|
お菓子の魔女 CHARLOTTE は _巴マミ_ とクッキーゲームを楽しんでいる.クッキーゲームは 8\times 8 の格子状に区切られたテーブルクロスの上にチーズクッキーとチョコレートクッキーを置いて行われる.各格子には高々 1 個のチョコレートクッキーまたはチーズクッキーしか置くことはできない. お菓子の魔女はチーズクッキーを, _巴マミ_ はチョコレートクッキーを交互に置いてゲームを行う.自分のクッキーを置いたあと,そのクッキーから上下左右斜めの各 8 方向について,置くクッキーとすでに置いていた自分のクッキーの間に相手のクッキーのみが直線に並んでいた場合に,その挟まれた相手のクッキーのすべてが自分のクッキーで置き換えられる.クッキーゲームのプレイヤーは自分のターンが回ってきた時,1 つ自分のクッキーを置くことができる.ただし,相手のクッキーを少なくとも 1 つ以上自分のクッキーに置き換えられなければならない.そのような置き場がない場合,自分のターンをパスをしなければならない. お菓子の魔女も _巴マミ_ も考えるのが少々苦手である.そこで,回ってきたターン毎にそのターンの中で置き換えられるクッキーの数を最大化することを考えることにした. _巴マミ_ のターンのときに置き換えられるクッキーの数を最大にするようなクッキーを置く場所の候補が複数ある場合は,より上の場所を,それでも複数ある場合はより左の場所を選択することにした.また同様に,お菓子の魔女のターンのときに候補が複数ある場合はより下の場所を,それでも複数ある場合はより右の場所を選択することにした. テーブルクロスに置かれたクッキーの状態が与えられるので,巴マミからはじめ,彼女たちがそこからクッキーゲームを行い,共に新たなクッキーが置けなくなるまでゲームを続けた時のテーブルクロスの上に置かれたクッキーの状態を求めよ.
|
def search(c,a,b):
r={'o':'x','x':'o'}
ans=0
direct=((-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1))
for d in range(8):
y,x=a,b
i,j=direct[d]
while s[y+i][x+j]==r[c]:
y+=i
x+=j
if s[y+i][x+j]==c:
ans+=max(abs(y-a),abs(x-b))
return ans
def mami():
m=0
a=b=-1
for i in range(1,9):
for j in range(1,9):
if s[i][j]=='.':
t=search('o',i,j)
if t>m:
m=t
a,b=i,j
return(a,b)
def char():
m=1
a=b=-1
for i in range(1,9):
for j in range(1,9):
if s[i][j]=='.':
t=search('x',i,j)
if t>=m:
m=t
a,b=i,j
return(a,b)
def rev(c,a,b):
#s[a][b]=c
r={'o':'x','x':'o'}
direct=((-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1))
for d in range(8):
y,x=a,b
i,j=direct[d]
while s[y+i][x+j]==r[c]:
y+=i
x+=j
if s[y+i][x+j]==c:
#i,j=direct[d]
y,x=a+i,b+j
while s[y][x]==r[c]:
s[y][x]=c
y+=i
x+=j
s[a][b]=c
s=[['.']*10]
for _ in range(8):
s.append(['.']+list(input())+['.'])
s=tuple(s+[['.']*10])
while 1:
a,b=mami()
if a>0:
rev('o',a,b)
c,d=char()
if c>0:
rev('x',c,d)
if all(i==-1for i in(a,b,c,d)):
break
for t in s:
print(*t[1:9],sep='')
|
s453343962
|
Accepted
| 40
| 5,588
| 1,553
|
def search(c,a,b):
r={'o':'x','x':'o'}
ans=0
direct=((-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1))
for d in range(8):
y,x=a,b
i,j=direct[d]
while s[y+i][x+j]==r[c]:
y+=i
x+=j
if s[y+i][x+j]==c:
ans+=max(abs(y-a),abs(x-b))
return ans
def mami():
m=0
a=b=-1
for i in range(1,9):
for j in range(1,9):
if s[i][j]=='.':
t=search('o',i,j)
if t>m:
m=t
a,b=i,j
return(a,b)
def char():
m=1
a=b=-1
for i in range(1,9):
for j in range(1,9):
if s[i][j]=='.':
t=search('x',i,j)
if t>=m:
m=t
a,b=i,j
return(a,b)
def rev(c,a,b):
#s[a][b]=c
r={'o':'x','x':'o'}
direct=((-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1))
for d in range(8):
y,x=a,b
i,j=direct[d]
while s[y+i][x+j]==r[c]:
y+=i
x+=j
if s[y+i][x+j]==c:
#i,j=direct[d]
y,x=a+i,b+j
while s[y][x]==r[c]:
s[y][x]=c
y+=i
x+=j
s[a][b]=c
s=[['.']*10]
for _ in range(8):
s.append(['.']+list(input())+['.'])
s=tuple(s+[['.']*10])
while 1:
a,b=mami()
if a>0:
rev('o',a,b)
c,d=char()
if c>0:
rev('x',c,d)
if all(i==-1for i in(a,b,c,d)):
break
for t in s[1:-1]:
print(*t[1:9],sep='')
|
s078734530
|
p03795
|
u313103408
| 2,000
| 262,144
|
Wrong Answer
| 26
| 9,092
| 41
|
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
n = int(input())
print(800*n-200*(n/15))
|
s395360560
|
Accepted
| 27
| 9,136
| 43
|
n = int(input())
print(800*n-200*(n//15))
|
s930715720
|
p03672
|
u140251125
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 107
|
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
|
# input
S = input()
for i in range(len(S)):
if S[:i] + S[:i] == S[:2 * i]:
ans = i
print(ans)
|
s408076947
|
Accepted
| 18
| 2,940
| 118
|
# input
S = input()
for i in range(len(S) // 2):
if S[:i] + S[:i] == S[:2 * i]:
ans = i
print(2 * ans)
|
s818355063
|
p02261
|
u467422569
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,604
| 626
|
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
|
def bubbleSort(C1,N):
for i in range(N):
for j in range(N-1,i,-1):
if C1[j][1] < C1[j-1][1]:
C1[j],C1[j-1] = C1[j-1],C1[j]
print(*C1)
print("Stable")
return C1[:]
def selectSort(C2,N):
for i in range(0,N):
minj = i
for j in range(i,N-1):
if C2[j][1] > C2[j+1][1]:
minj = j+1
C2[i],C2[minj] = C2[minj],C2[i]
return C2[:]
N = int(input())
C1 = input().split()
C2 = C1[:]
C1 = bubbleSort(C1,N)
C2 = selectSort(C2,N)
if C1 == C2:
print(*C2)
print("Stable")
else:
print(*C2)
print("Not Stable")
|
s971236963
|
Accepted
| 20
| 5,616
| 596
|
def bubbleSort(C1,N):
for i in range(N):
for j in range(N-1,i,-1):
if C1[j][1] < C1[j-1][1]:
C1[j],C1[j-1] = C1[j-1],C1[j]
return C1[:]
def selectSort(C2,N):
for i in range(0,N):
minj = i
for j in range(i,N):
if C2[minj][1] > C2[j][1]:
minj = j
C2[i],C2[minj] = C2[minj],C2[i]
return C2[:]
N = int(input())
C1 = input().split()
C2 = C1[:]
C1 = bubbleSort(C1,N)
C2 = selectSort(C2,N)
print(*C1)
print("Stable")
print(*C2)
if C1 == C2:
print("Stable")
else:
print("Not stable")
|
s209090095
|
p03339
|
u996434204
| 2,000
| 1,048,576
|
Wrong Answer
| 417
| 28,132
| 740
|
There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
|
n=int(input())
s=input()
e=[0 for i in range(n)]
w=[0 for i in range(n)]
if s[0]=='E':
e[0]+=1
else:
w[0]+=1
for i in range(1,n):
if s[i]=='E':
e[i]=e[i-1]+1
w[i]=w[i-1]
else:
w[i]=w[i-1]+1
e[i]=e[i-1]
print(e,w)
mn = 10**10
for i in range(n):
dire = s[i]
if dire == "E":
if i != 0 and i != n-1:
ans = w[i-1] + (e[n-1] - e[i])
elif i == 0:
ans = w[n-1] - w[i]
else:
ans = e[n-1] - 1
else:
if i != 0 and i != n-1:
ans = w[i-1] + (e[n-1] - e[i])
elif i == 0:
ans = e[n-1] - e[i]
else:
ans = w[n-1] - 1
if ans < mn:
mn = ans
print(mn)
|
s591357601
|
Accepted
| 374
| 17,804
| 711
|
n=int(input())
s=input()
e=[0 for i in range(n)]
w=[0 for i in range(n)]
if s[0]=='E':
e[0]+=1
else:
w[0]+=1
for i in range(1,n):
if s[i]=='E':
e[i]=e[i-1]+1
w[i]=w[i-1]
else:
w[i]=w[i-1]+1
e[i]=e[i-1]
mn = 10**10
for i in range(n):
dire = s[i]
if dire == "E":
if i != 0 and i != n-1:
ans = w[i-1] + (e[n-1] - e[i])
elif i == 0:
ans = e[n-1] - 1
else:
ans = w[n-1]
else:
if i != 0 and i != n-1:
ans = w[i-1] + (e[n-1] - e[i])
elif i == 0:
ans = e[n-1]
else:
ans = w[i-1]
if ans < mn:
mn = ans
print(mn)
|
s903258016
|
p03645
|
u288430479
| 2,000
| 262,144
|
Wrong Answer
| 679
| 55,556
| 238
|
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())
l =[ list(map(int,input().split())) for i in range(m)]
l1 = set([i[1] for i in l if i[0]==1])
l2 = set([i[2] for i in l if i[0]==n])
l3 = l1&l2
if len(l3)>=1:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
|
s174493742
|
Accepted
| 707
| 60,272
| 238
|
n,m = map(int,input().split())
l =[ list(map(int,input().split())) for i in range(m)]
l1 = set([i[1] for i in l if i[0]==1])
l2 = set([i[0] for i in l if i[1]==n])
l3 = l1&l2
if len(l3)>=1:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
|
s051937910
|
p02690
|
u181668771
| 2,000
| 1,048,576
|
Wrong Answer
| 24
| 9,220
| 716
|
Give a pair of integers (A, B) such that A^5-B^5 = X. It is guaranteed that there exists such a pair for the given integer X.
|
def main():
from builtins import int, map, list, print, len
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
input_list = (lambda: input().rstrip().split())
input_number = (lambda: int(input()))
input_number_list = (lambda: list(map(int, input_list())))
X = input_number()
t = []
i = 0
while True:
x = i ** 5
t.append(x)
if x > 10 ** 9:
break
i += 1
for i in range(len(t)):
for j in range(i, len(t)):
a = t[i]
b = t[j]
if a - b == X:
print(i,j)
elif a + b == X:
print(i,-j)
if __name__ == '__main__':
main()
|
s128754673
|
Accepted
| 165
| 33,216
| 559
|
def main():
from builtins import int, map, list, print, len
import sys
sys.setrecursionlimit(10 ** 6)
X = int(input())
t = []
i = 0
while True:
x = i ** 5
t.append(x)
if x > 10 ** 12:
break
i += 1
d = {}
for i in range(len(t)):
for j in range(len(t)):
d[t[i] - t[j]] = [i, j]
d[t[i] + t[j]] = [i, -j]
d[-t[i] - t[j]] = [-i, j]
d[-t[i] + t[j]] = [-i, -j]
print(d[X][0], d[X][1])
if __name__ == '__main__':
main()
|
s331733932
|
p02613
|
u994864800
| 2,000
| 1,048,576
|
Wrong Answer
| 143
| 9,088
| 144
|
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.
|
dic={'AC':0,'WA':0,'TLE':0,'RE':0}
for _ in range(int(input())) :
dic[input()]+=1
for key,val in dic.items() :
print(key+" X " +str(val))
|
s775363654
|
Accepted
| 145
| 9,192
| 141
|
dic={'AC':0,'WA':0,'TLE':0,'RE':0}
for _ in range(int(input())) :
dic[input()]+=1
for key,val in dic.items() :
print(key+" x " +str(val))
|
s536763116
|
p03997
|
u033523569
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 66
|
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)//2*h)
|
s279702862
|
Accepted
| 17
| 2,940
| 66
|
a=int(input())
b=int(input())
h=int(input())
print( (a+b)*h//2)
|
s429386004
|
p02608
|
u902380746
| 2,000
| 1,048,576
|
Wrong Answer
| 349
| 9,416
| 449
|
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
import sys
import math
import bisect
def main():
n = int(input())
A = [0] * (n + 1)
m = math.floor(math.sqrt(n))
for x in range(1, m + 1):
for y in range(1, m + 1):
for z in range(1, m + 1):
val = x*x + y*y + z*z + x*y + y*z + z*x
if val >= 1 and val <= n:
A[val-1] += 1
for i in range(1, n + 1):
print(A[i])
if __name__ == "__main__":
main()
|
s851972142
|
Accepted
| 355
| 9,212
| 471
|
import sys
import math
import bisect
def main():
n = int(input())
A = [0] * (n + 1)
m = 0
while (m + 1) ** 2 <= n:
m = m + 1
for x in range(1, m + 1):
for y in range(1, m + 1):
for z in range(1, m + 1):
val = x*x + y*y + z*z + x*y + y*z + z*x
if val >= 1 and val <= n:
A[val] += 1
for i in range(1, n + 1):
print(A[i])
if __name__ == "__main__":
main()
|
s791589318
|
p02928
|
u472534477
| 2,000
| 1,048,576
|
Wrong Answer
| 2,104
| 7,416
| 277
|
We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}. Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2. Find the inversion number of B, modulo 10^9 + 7. Here the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \leq i < j \leq K \times N - 1) such that B_i > B_j.
|
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
sum=0
for i in range(N):
for j in range(N):
if A[i]>A[j] and i>j:
sum+=math.factorial(K-1)
if A[i]>A[j] and i<j:
sum+=math.factorial(K)
print(sum % (10**9+7))
|
s195327034
|
Accepted
| 1,968
| 3,316
| 280
|
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
sumA=0
for i in range(N):
for j in range(N):
if A[i]>A[j] and i>j:
sumA+=(K-1)*K//2
if A[i]>A[j] and i<j:
sumA+=K*(K+1)//2
sumA=sumA % (10**9+7)
print(sumA)
|
s708407690
|
p03624
|
u140251125
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,188
| 281
|
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.
|
# input
S = input()
alphabet = ['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', 'None']
for i in range(len(alphabet)):
if alphabet[i] in S:
continue
else:
print(alphabet[i])
|
s301664219
|
Accepted
| 17
| 3,188
| 295
|
# input
S = input()
alphabet = ['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', 'None']
for i in range(len(alphabet)):
if alphabet[i] in S:
continue
else:
print(alphabet[i])
break
|
s540965483
|
p04039
|
u835482198
| 2,000
| 262,144
|
Time Limit Exceeded
| 2,104
| 2,940
| 136
|
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier.
|
N, K = map(int, input().split())
D = set(input())
n = N
while True:
if set(str(n)) in D:
print(n)
break
n += 1
|
s855222484
|
Accepted
| 85
| 2,940
| 145
|
N, K = map(int, input().split())
D = set(input())
n = N
while True:
if len(set(str(n)) & D) == 0:
print(n)
break
n += 1
|
s628453262
|
p03568
|
u858670323
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,060
| 118
|
We will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are _similar_ when |x_i - y_i| \leq 1 holds for all i (1 \leq i \leq N). In particular, any integer sequence is similar to itself. You are given an integer N and an integer sequence of length N, A_1, A_2, ..., A_N. How many integer sequences b_1, b_2, ..., b_N are there such that b_1, b_2, ..., b_N is similar to A and the product of all elements, b_1 b_2 ... b_N, is even?
|
n=int(input())
A=list(map(int,input().rstrip().split(' ')))
ans=1
for a in A:
if(a%2==1):
ans*=3
print(ans)
|
s696351545
|
Accepted
| 19
| 3,060
| 147
|
n=int(input())
A=list(map(int,input().rstrip().split(' ')))
Xans=1
for a in A:
if(a%2==1):
Xans*=1
else:
Xans*=2
print(3**n-Xans)
|
s872244331
|
p03609
|
u790877102
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 74
|
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
|
s = input()
ans = ""
for i in range(len(s),2):
ans += s[i]
print(ans)
|
s693391966
|
Accepted
| 17
| 2,940
| 75
|
X,t = map(int,input().split())
if X<t:
print(0)
else:
print(X-t)
|
s597453036
|
p03455
|
u727760796
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 77
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
def even_or_odd(a, b):
if a%2 == 0 or b%2 ==0:
return even
return odd
|
s178601645
|
Accepted
| 17
| 2,940
| 132
|
two_digits = input()
(a, b) = two_digits.split(' ')
if int(a) % 2 == 0 or int(b) % 2 == 0:
print('Even')
else:
print('Odd')
|
s125387261
|
p03080
|
u754985212
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 77
|
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
|
i = input()
if i.count('R') > i.count('B'):
print('Yes')
else :
print('No')
|
s887750751
|
Accepted
| 18
| 3,064
| 83
|
input()
i = input()
if i.count('R') > i.count('B'): print('Yes')
else : print('No')
|
s979287190
|
p03199
|
u218843509
| 2,000
| 1,048,576
|
Wrong Answer
| 668
| 15,408
| 2,168
|
Takahashi has an N \times N grid. The square at the i-th row and the j-th column of the grid is denoted by (i,j). Particularly, the top-left square of the grid is (1,1), and the bottom-right square is (N,N). An integer, 0 or 1, is written on M of the squares in the Takahashi's grid. Three integers a_i,b_i and c_i describe the i-th of those squares with integers written on them: the integer c_i is written on the square (a_i,b_i). Takahashi decides to write an integer, 0 or 1, on each of the remaining squares so that the condition below is satisfied. Find the number of such ways to write integers, modulo 998244353. * For all 1\leq i < j\leq N, there are even number of 1s in the square region whose top-left square is (i,i) and whose bottom-right square is (j,j).
|
from collections import Counter
import sys
MOD = 998244353
n, m = map(int, input().split())
decided = Counter()
ans = 1
d_num = 0
def kaijou(a, n):
x = 1
while n > 0:
if n & 1 == 1:
x = (x * a) % MOD
a = (a ** 2) % MOD
n >>= 1
return x
for _ in range(m):
a, b, c = map(int, input().split())
decided[(a-1) * n + b - 1] = c
if abs(a-b) >= 3:
if (b-1) * n + a - 1 not in decided:
d_num += 1
ans = (ans * 2) % MOD
decided[(b-1) * n + a - 1] = c
elif decided[(b-1) * n + a - 1] != decided[(a-1) * n + b - 1]:
print(0)
sys.exit()
ans = (ans * kaijou(2, ((n-2) * (n-3) // 2) - d_num)) % MOD
#print(ans)
for i in range(n-2):
is_empty = 0
if n*i+i not in decided:
is_empty += 1
if n*i+i+1 not in decided:
is_empty += 1
if n*i+i+n not in decided:
is_empty += 1
if n*i+i+n+1 not in decided:
is_empty += 1
if is_empty == 0:
if (decided[n*i+i] + decided[n*i+i+n+1]) % 2 != (decided[n*i+i+1] + decided[n*i+i+n]) % 2:
ans *= 0
if is_empty == 1 and n*i+i+n+1 not in decided:
decided[n*i+i+n+1] = (decided[n*i+i+1] + decided[n*i+i+n]) % 2 - decided[n*i+i]
ans = (ans * (2 ** max(0, is_empty-1))) % MOD
is_empty = 0
if n*i+i+n+1 not in decided:
is_empty += 1
if n*i+i+2 not in decided:
is_empty += 1
if n*i+i+2*n not in decided:
is_empty += 1
if is_empty == 0:
if (decided[n*i+i+2] + decided[n*i+i+n+1] + decided[n*i+i+2*n]) % 2 != 0:
ans *= 0
if is_empty == 1 and n*i+i+n+1 not in decided:
decided[n*i+i+n+1] = (decided[n*i+i+2] + decided[n*i+i+n*2]) % 2
ans = (ans * (2 ** min(0, is_empty-1))) % MOD
is_empty = 0
if n*(n-2)+(n-2) not in decided:
is_empty += 1
if n*(n-2)+(n-2)+1 not in decided:
is_empty += 1
if n*(n-2)+(n-2)+n not in decided:
is_empty += 1
if n*(n-2)+(n-2)+n+1 not in decided:
is_empty += 1
if is_empty == 0:
if (decided[n*(n-2)+(n-2)] + decided[n*(n-2)+(n-2)+n+1]) % 2 != (decided[n*(n-2)+(n-2)+1] + decided[n*(n-2)+(n-2)+n]) % 2:
ans *= 0
if is_empty == 1 and n*(n-2)+(n-2)+n+1 not in decided:
decided[n*(n-2)+(n-2)+n+1] = (decided[n*(n-2)+(n-2)+1] + decided[n*(n-2)+(n-2)+n]) % 2 - decided[n*(n-2)+(n-2)]
ans = (ans * (2 ** max(0, is_empty-1))) % MOD
print(ans)
|
s333914188
|
Accepted
| 622
| 15,416
| 1,613
|
from collections import Counter
import sys
MOD = 998244353
n, m = map(int, input().split())
d = Counter()
ans = 1
d_num = 0
def k(a, n):
x = 1
while n > 0:
if n&1 == 1:
x = (x*a) % MOD
a = (a**2) % MOD
n >>= 1
return x
for _ in range(m):
a, b, c = map(int, input().split())
d[(a-1)*n+b-1] = c
if abs(a-b) >= 3:
if (b-1)*n+a-1 not in d:
d_num += 1
d[(b-1)*n+a-1] = c
elif d[(b-1)*n+a-1] != d[(a-1)*n+b-1]:
print(0)
sys.exit()
ans = (ans*k(2, ((n-2)*(n-3)//2)-d_num))%MOD
e = 0
if 0 not in d:
e+=1
if 1 not in d:
e+=1
if n not in d:
e+=1
if n+1 not in d:
e+=1
if e == 0 and n*0+0 in d:
if (d[n*0+0]+d[n+1])%2!=(d[1]+d[n]) % 2:
ans *= 0
if e == 1 and n+1 not in d and n*0+0 in d:
d[n+1] = (d[1]+d[n])%2-d[n*0+0]
ans = (ans*(2**max(0, e-1))) % MOD
for i in range(n-2):
e = 0
if n*i+i+2 not in d:
e += 1
if n*i+i+2*n not in d:
e += 1
if e == 0 and n*i+i+n+1 in d:
if (d[n*i+i+2] + d[n*i+i+n+1] + d[n*i+i+2*n]) % 2 != 0:
ans *= 0
if e == 0 and n*i+i+n+1 not in d:
d[n*i+i+n+1] = (d[n*i+i+2] + d[n*i+i+n*2]) % 2
ans = (ans*499122177) % MOD
ans = (ans*(2 ** max(0, e-1))) % MOD
e=0
if n*(i+1)+i+2 not in d:
e += 1
if n*(i+1)+i+1+n not in d:
e += 1
if n*(i+1)+i+n+2 not in d:
e += 1
if e == 0 and n*(i+1)+i+1 in d:
if (d[n*(i+1)+i+1]+d[n*(i+1)+i+n+2]) % 2 != (d[n*(i+1)+i+2]+d[n*(i+1)+i+1+n])%2:
ans *= 0
if e == 0 and n*(i+1)+i+1 not in d:
ans = (ans*499122177) % MOD
if e == 1 and n*(i+1)+i+2+n not in d and n*(i+1)+i+1 in d:
d[n*(i+1)+i+2+n]=(d[n*(i+1)+i+2]+d[n*(i+1)+i+1+n])%2-d[n*(i+1)+i+1]
ans = (ans*(2**max(0, e-1))) % MOD
print(ans)
|
s798189391
|
p02850
|
u392319141
| 2,000
| 1,048,576
|
Wrong Answer
| 608
| 21,404
| 509
|
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colorings satisfying the condition above, construct one that uses the minimum number of colors.
|
N = int(input())
edges = [[] for _ in range(N + 1)]
for i in range(N - 1):
fr, to = map(int, input().split())
edges[fr].append(i)
edges[to].append(i)
edges.sort(key=lambda A: len(A), reverse=True)
ans = [-1] * (N - 1)
for es in edges:
canUse = set(range(1, len(es) + 1))
for i in es:
if ans[i] in canUse:
canUse.remove(ans[i])
canUse = list(canUse)
for i in es:
if ans[i] == -1:
ans[i] = canUse.pop()
print(max(ans))
print(*ans, sep='\n')
|
s229193121
|
Accepted
| 783
| 64,980
| 533
|
N = int(input())
edges = [[] for _ in range(N)]
for i in range(N - 1):
fr, to = map(lambda a: int(a) - 1, input().split())
edges[fr].append((i, to))
edges[to].append((i, fr))
ans = [-1] * (N - 1)
A = [set() for _ in range(N)]
st = [0]
while st:
now = st.pop()
s = 1
for i, to in edges[now]:
if ans[i] != -1:
continue
while s in A[now]:
s += 1
ans[i] = s
A[to].add(s)
A[now].add(s)
st.append(to)
print(max(ans))
print(*ans, sep="\n")
|
s338555113
|
p03023
|
u847605090
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 143
|
Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees, but do not print units.
|
N=input()
a=0
b=0
for i in N:
if i=='o':
a+=1
elif i=='x':
b+=1
if a>=b or a>=8:
print('YES')
else:
print('NO')
|
s453012692
|
Accepted
| 17
| 2,940
| 31
|
N=int(input())
print(180*(N-2))
|
s077568344
|
p03167
|
u697559326
| 2,000
| 1,048,576
|
Wrong Answer
| 862
| 157,428
| 1,031
|
There is a grid with H horizontal rows and W vertical columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left. For each i and j (1 \leq i \leq H, 1 \leq j \leq W), Square (i, j) is described by a character a_{i, j}. If a_{i, j} is `.`, Square (i, j) is an empty square; if a_{i, j} is `#`, Square (i, j) is a wall square. It is guaranteed that Squares (1, 1) and (H, W) are empty squares. Taro will start from Square (1, 1) and reach (H, W) by repeatedly moving right or down to an adjacent empty square. Find the number of Taro's paths from Square (1, 1) to (H, W). As the answer can be extremely large, find the count modulo 10^9 + 7.
|
import sys
input == sys.stdin.readline
def main():
mod = 10**9+7
H, W = map(int, input().split())
a = []
for _ in range(H):
a.append(input())
dp = [[0]*(W) for _ in range(H)]
dp[0][0] = 1
print(a[0][1], ".", a[0][0]==".")
for i in range(H):
for j in range(W):
if a[i][j] == ".":
if i == 0 and j == 0:
continue
elif i == 0 and a[i][j-1] == ".":
dp[i][j] += dp[i][j-1]
elif j == 0 and a[i-1][j] == ".":
dp[i][j] += dp[i-1][j]
else:
if a[i][j-1] == ".":
dp[i][j] += dp[i][j-1]
if a[i-1][j] == ".":
dp[i][j] += dp[i-1][j]
#print(*dp,sep="\n")
print(dp[H-1][W-1] % mod)
if __name__ == '__main__':
main()
|
s004327037
|
Accepted
| 860
| 157,428
| 996
|
import sys
input == sys.stdin.readline
def main():
mod = 10**9+7
H, W = map(int, input().split())
a = []
for _ in range(H):
a.append(input())
dp = [[0]*(W) for _ in range(H)]
dp[0][0] = 1
for i in range(H):
for j in range(W):
if a[i][j] == ".":
if i == 0 and j == 0:
continue
elif i == 0 and a[i][j-1] == ".":
dp[i][j] += dp[i][j-1]
elif j == 0 and a[i-1][j] == ".":
dp[i][j] += dp[i-1][j]
else:
if a[i][j-1] == ".":
dp[i][j] += dp[i][j-1]
if a[i-1][j] == ".":
dp[i][j] += dp[i-1][j]
#print(*dp,sep="\n")
print(dp[H-1][W-1] % mod)
if __name__ == '__main__':
main()
|
s446788070
|
p02844
|
u674588203
| 2,000
| 1,048,576
|
Wrong Answer
| 2,206
| 9,084
| 249
|
AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code. The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code. How many different PIN codes can he set this way? Both the lucky number and the PIN code may begin with a 0.
|
N=int(input())
S=input()
pin=set()
for i in range(N):
for j in range(i+1,N):
for k in range(i+j+1,N):
pin.add(str(S[i])+str(S[j])+str(S[k]))
# print((str(S[i])+str(S[j])+str(S[k])))
# print(pin)
print(len(pin))
|
s848771538
|
Accepted
| 159
| 9,308
| 404
|
N=int(input())
S=input()
ans=0
for i in range (1000):
tempS=S
pin=str(i).zfill(3)
t1=pin[0]
t2=pin[1]
t3=pin[2]
if tempS.count(t1)>=1:
tempS=tempS[tempS.find(t1)+1:]
else:
continue
if tempS.count(t2)>=1:
tempS=tempS[tempS.find(t2)+1:]
else:
continue
if tempS.count(t3)>=1:
ans+=1
else:
continue
print(ans)
|
s975846116
|
p03067
|
u589668184
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 140
|
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
|
p = input().split()
if (p[0] < p[1] and p[1] < p[2]):
print("yes")
elif (p[2] < p[1] and p[1] < p[0]):
print("yes")
else:
print("no")
|
s106931643
|
Accepted
| 17
| 3,060
| 138
|
a,b,c = (int(i) for i in input().split())
if (a < c and c < b):
print("Yes")
elif (b < c and c < a):
print("Yes")
else:
print("No")
|
s186398958
|
p04012
|
u257332942
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 195
|
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
|
s = input()
a = ''
count = 0
for x in s:
for y in s:
if x == y:
count += 1
if count % 2 != 0:
print('NO')
break
if count % 2 == 0:
print('YES')
|
s769693988
|
Accepted
| 30
| 9,076
| 242
|
w = input()
if len(w) % 2 != 0:
print('No')
exit()
cnt = [0]*30
for i in range(len(w)):
a = ord(w[i]) - ord('a')
cnt[a] += 1
for i in range(len(cnt)):
if cnt[i] % 2 != 0:
print('No')
exit()
print('Yes')
|
s619219062
|
p02646
|
u290014241
| 2,000
| 1,048,576
|
Wrong Answer
| 2,206
| 9,132
| 342
|
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
A, V = map(int,input().split())
B, W = map(int,input().split())
T = int(input())
c=0
if A<B:
for t in range(T+1):
if V*t+A==W*t+B:
print('Yes')
c=1
break
else:
for t in range(T+1):
if V*t-A==W*t-B:
print('Yes')
c=1
break
if c==0:
print('No')
|
s230558061
|
Accepted
| 30
| 9,148
| 271
|
A, V = map(int,input().split())
B, W = map(int,input().split())
T = int(input())
if V!=W:
t = (B-A)/(V-W)
if A>B:
t=-t
if 0<=t<=T:
print('YES')
else:
print('NO')
else:
if A!=B:
print('NO')
else:
print('YES')
|
s271821204
|
p03549
|
u021548497
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 52
|
Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
|
n, m = map(int, input().split())
print(1800*m+100*n)
|
s588014617
|
Accepted
| 17
| 2,940
| 59
|
n, m = map(int, input().split())
print((1800*m+100*n)*2**m)
|
s380471536
|
p03494
|
u675073679
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 471
|
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.
|
import sys
def main():
N = int(input())
A = list(map(int, input().split()))
ct = 0
while True:
for i in range(N):
if A[i] % 2 == 0:
A[i] = A[i] // 2
else:
print(ct)
sys.exit()
ct += 1
if __name__ == '__main__':
main()
|
s854531718
|
Accepted
| 19
| 3,060
| 475
|
import sys
def main():
N = int(input())
A = list(map(int, input().split()))
ct = 0
while True:
for i in range(N):
if A[i] % 2 == 0:
A[i] = A[i] // 2
else:
print(ct)
sys.exit()
ct += 1
if __name__ == '__main__':
main()
|
s951485496
|
p02613
|
u768636516
| 2,000
| 1,048,576
|
Wrong Answer
| 145
| 9,172
| 319
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
N = int(input())
cnt1 = 0
cnt2 = 0
cnt3 = 0
cnt4 = 0
for i in range(N):
S = input()
if S == 'AC':
cnt1 += 1
elif S == 'WA':
cnt2 += 1
elif S == 'TLE':
cnt3 += 1
else:
cnt4 += 1
print( 'AC ×' + str(cnt1) )
print( 'WA ×' + str(cnt2) )
print( 'TLE ×' + str(cnt3) )
print( 'RE ×' + str(cnt4) )
|
s847351453
|
Accepted
| 143
| 9,144
| 319
|
N = int(input())
cnt1 = 0
cnt2 = 0
cnt3 = 0
cnt4 = 0
for i in range(N):
S = input()
if S == 'AC':
cnt1 += 1
elif S == 'WA':
cnt2 += 1
elif S == 'TLE':
cnt3 += 1
else:
cnt4 += 1
print( 'AC x ' + str(cnt1) )
print( 'WA x ' + str(cnt2) )
print( 'TLE x ' + str(cnt3) )
print( 'RE x ' + str(cnt4) )
|
s098197067
|
p03695
|
u987170100
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 517
|
In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows: * Rating 1-399 : gray * Rating 400-799 : brown * Rating 800-1199 : green * Rating 1200-1599 : cyan * Rating 1600-1999 : blue * Rating 2000-2399 : yellow * Rating 2400-2799 : orange * Rating 2800-3199 : red Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not. Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i. Find the minimum and maximum possible numbers of different colors of the users.
|
N = int(input())
lst = [0] * 9
for x in [int(x) for x in input().split()]:
if x <= 399:
lst[0] = 1
elif x <= 799:
lst[1] = 1
elif x <= 1199:
lst[2] = 1
elif x <= 1599:
lst[3] = 1
elif x <= 1999:
lst[4] = 1
elif x <= 2399:
lst[5] = 1
elif x <= 2799:
lst[6] = 1
elif x <= 3199:
lst[7] = 1
else:
lst[8] += 1
a = sum(lst[:-1])
b = lst[8]
print(lst)
if 8 - a < b:
b = 8 - a
print("{0} {1}".format(a, a + b))
|
s825144189
|
Accepted
| 17
| 3,064
| 538
|
N = int(input())
lst = [0] * 9
for x in [int(x) for x in input().split()]:
if x <= 399:
lst[0] = 1
elif x <= 799:
lst[1] = 1
elif x <= 1199:
lst[2] = 1
elif x <= 1599:
lst[3] = 1
elif x <= 1999:
lst[4] = 1
elif x <= 2399:
lst[5] = 1
elif x <= 2799:
lst[6] = 1
elif x <= 3199:
lst[7] = 1
else:
lst[8] += 1
a = sum(lst[:-1])
b = lst[8]
if a == 0 and b > 0:
print("1 {0}".format(b))
else:
print("{0} {1}".format(a, a + b))
|
s259369409
|
p02608
|
u068727970
| 2,000
| 1,048,576
|
Wrong Answer
| 121
| 13,940
| 618
|
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
N = int(input())
ans = [[] for _ in range(N)]
for x in range(1, 101):
for y in range(x, 101):
for z in range(y, 101):
n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
if n > N:
break
ans[n - 1].append((x, y, z))
print(ans)
count = 0
for an in ans:
if an == []:
print(0)
else:
a = an[0]
if a[0] == a[1] and a[1] == a[2]:
print(1)
elif not a[0] == a[1] and not a[1] == a[2] and not a[2] == a[0]:
print(6)
else:
print(3)
|
s814876578
|
Accepted
| 115
| 13,104
| 680
|
N = int(input())
ans = [[] for _ in range(N)]
for x in range(1, 101):
for y in range(x, 101):
for z in range(y, 101):
n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
if n > N:
break
ans[n - 1].append((x, y, z))
count = 0
for an in ans:
if an == []:
print(0)
else:
count = 0
for a in an:
if a[0] == a[1] and a[1] == a[2]:
count += 1
elif not a[0] == a[1] and not a[1] == a[2] and not a[2] == a[0]:
count += 6
else:
count += 3
print(count)
|
s284375258
|
p03485
|
u607074939
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 53
|
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a,b = map(int, input().split())
print(int((a+b)/2)+1)
|
s561631075
|
Accepted
| 17
| 2,940
| 104
|
a,b = map(int, input().split())
if (a+b)%2 != 0:
print(int((a+b)/2)+1)
else:
print(int((a+b)/2))
|
s385722593
|
p03067
|
u629350026
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 3,064
| 100
|
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
|
a,b,c=map(int,input().split())
if (a<b and b<c) or (a>b and b>c):
print("Yes")
else:
print("No")
|
s027995485
|
Accepted
| 17
| 2,940
| 100
|
a,b,c=map(int,input().split())
if (a<c and c<b) or (a>c and c>b):
print("Yes")
else:
print("No")
|
s960337311
|
p03475
|
u518042385
| 3,000
| 262,144
|
Wrong Answer
| 88
| 3,188
| 291
|
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())
l=[]
for i in range(n-1):
l1=list(map(int,input().split()))
l.append(l1)
for i in range(n-1):
t=0
t+=l[i][1]+l[i][0]
for j in range(i+1,n-1):
if t<l[j][1]:
t=l[j][1]
t+=l[j][0]
else:
t+=l[j][2]-t%l[j][2]
t+=l[j][0]
print(t)
print(0)
|
s036741505
|
Accepted
| 97
| 3,188
| 301
|
n=int(input())
l=[]
for i in range(n-1):
l1=list(map(int,input().split()))
l.append(l1)
for i in range(n-1):
t=0
t+=l[i][1]+l[i][0]
for j in range(i+1,n-1):
if t<l[j][1]:
t=l[j][1]
t+=l[j][0]
else:
t+=(l[j][2]-t%l[j][2])%l[j][2]
t+=l[j][0]
print(t)
print(0)
|
s895470652
|
p03543
|
u434208140
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 77
|
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
|
s=list(input())
print('YES' if s[0]==s[1]==s[2] or s[1]==[2]==s[3] else 'NO')
|
s425839703
|
Accepted
| 17
| 2,940
| 78
|
s=list(input())
print('Yes' if s[0]==s[1]==s[2] or s[1]==s[2]==s[3] else 'No')
|
s814135958
|
p03795
|
u484856305
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 105
|
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
a=int(input())
total=0
for i in range(a):
total+=800
if i%15==0:
total-=200
print(total)
|
s058045342
|
Accepted
| 17
| 2,940
| 129
|
a=int(input())
total=0
count=0
for i in range(a):
total+=800
count+=1
if count%15==0:
total-=200
print(total)
|
s232631334
|
p03388
|
u415905784
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,064
| 334
|
10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th. The _score_ of a participant is the product of his/her ranks in the two contests. Process the following Q queries: * In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.
|
import math
Q = int(input())
for i in range(Q):
a, b = map(int, input().split())
sqrt = int(math.sqrt(a * b))
sub = 0 if math.sqrt(a * b) - sqrt > 0 else 1
sqrt2 = sqrt + 1 if sqrt * (sqrt + 1) < a * b else sqrt
add = min(max(sqrt2 - min(a, b) - 1, 0), max(max(a, b) - sqrt - 1, 0))
print(min(a, b) - 1 + sqrt + add - sub)
|
s653849485
|
Accepted
| 19
| 3,064
| 371
|
import math
Q = int(input())
for i in range(Q):
a, b = map(int, input().split())
sqrt = int(math.sqrt(a * b))
sqrt2 = sqrt + 1 if sqrt * (sqrt + 1) < a * b else sqrt
sub = 1 if sqrt == max(a, b) or sqrt2 == min(a, b) or sqrt * sqrt2 == a * b else 0
add = min(max(sqrt2 - min(a, b) - 1, 0), max(max(a, b) - sqrt - 1, 0))
print(min(a, b) - 1 + sqrt + add - sub)
|
s276141884
|
p03565
|
u638456847
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 696
|
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`.
|
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
s = readline()
t = readline()
ls = len(s)
lt = len(t)
if ls < lt:
print("UNRESTORABLE")
exit()
ind = -1
for i in range(ls-lt+1):
flag = True
for j,s_ in enumerate(s[i:i+lt]):
if s_ == "?":
continue
if t[j] != s_:
flag = False
if flag:
ind = i
if ind == -1:
print("UNRESTORABLE")
exit()
ans = s[:ind] + t + s[ind+lt:]
ans = ans.replace("?", "a")
print(ans)
if __name__ == "__main__":
main()
|
s891711064
|
Accepted
| 17
| 3,064
| 698
|
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
s = readline().strip()
t = readline().strip()
ls = len(s)
lt = len(t)
if ls < lt:
print("UNRESTORABLE")
exit()
ind = -1
for i in range(ls-lt+1):
flag = True
for j,t_ in enumerate(t):
if s[i+j] == "?":
continue
if t_ != s[i+j]:
flag = False
if flag:
ind = i
if ind == -1:
print("UNRESTORABLE")
exit()
ans = s[:ind] + t + s[ind+lt:]
ans = ans.replace("?", "a")
print(ans)
if __name__ == "__main__":
main()
|
s026153061
|
p04045
|
u940533000
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 512
|
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier.
|
N, K = map(str, input().split())
D = map(str, input().split())
D = set(D)
number = {'0','1','2','3','4','5','6','7','8','9'}
out = D^number
#print(out)
len_N = len(N)
res = ''
flag = 0
tmp = list(out)
for i in range(len_N):
if len(set(N[i])&out) != 0 and flag == 0:
res+=N[i]
elif len(set(N[i])&out) == 0 and flag == 0:
for j in range(len(tmp)):
if int(N[i]) < int(tmp[j]):
res += tmp[j]
flag = 1
elif flag == 1:
res += tmp[0]
print(res)
|
s143108495
|
Accepted
| 17
| 3,064
| 994
|
N, K = map(str, input().split())
D = map(str, input().split())
D = set(D)
number = {'0','1','2','3','4','5','6','7','8','9'}
out = D^number
#print(out)
out = sorted(list(out))
res_list = []
flag = 0
for i in range(len(N)):
if flag == 0:
if len(set(N[i])&set(out)) == 1:
res_list.append(N[i])
else:
tmp = -1
for j in range(len(out)):
if N[i] < out[j]:
tmp = out[j]
break
if tmp == -1:
res_list.append(out[0])
flag = 1
else:
res_list.append(tmp)
flag = 2
elif flag == 1:
tmp = -1
for j in range(len(out)):
if N[i] < out[j]:
tmp = out[j]
break
if tmp == -1:
res_list.append(out[0])
flag = 1
else:
res_list.append(tmp)
flag = 2
elif flag == 2:
res_list.append(out[0])
if flag == 1:
res_list.append(out[0])
res = ''
for i in range(len(res_list)):
res += res_list[i]
print(res)
|
s666788621
|
p03556
|
u902151549
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,184
| 136
|
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.
|
# coding: utf-8
import time
import re
import math
def main():
n=int(input())
print(math.pow(math.floor(math.sqrt(n)),2))
main()
|
s094615318
|
Accepted
| 19
| 3,184
| 141
|
# coding: utf-8
import time
import re
import math
def main():
n=int(input())
print(int(math.pow(math.floor(math.sqrt(n)),2)))
main()
|
s257850588
|
p03360
|
u880277518
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 109
|
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
|
a,b,c=list(map(int,input().split()))
k=int(input())
m=max(a,b,c)
s=sum([a,b,c])-m
print(s,m)
print(s+(m*2)*k)
|
s943997431
|
Accepted
| 17
| 2,940
| 96
|
A,B,C=list(map(int,input().split()))
K=int(input())
m=max([A,B,C])
print(sum([A,B,C])-m+m*2**K)
|
s874775837
|
p03719
|
u921826483
| 2,000
| 262,144
|
Wrong Answer
| 18
| 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 = input().split()
if c >= a and c <= b:
print("YES")
else:
print("NO")
|
s712042528
|
Accepted
| 18
| 2,940
| 95
|
a,b,c = map(int,input().split())
if c >= a and c <= b:
print("Yes")
else:
print("No")
|
s850895230
|
p02697
|
u198257719
| 2,000
| 1,048,576
|
Wrong Answer
| 76
| 9,200
| 78
|
You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive). You cannot assign the same integer to multiple playing fields. The competition consists of N rounds, each of which proceeds as follows: * For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there. * Then, each player adds 1 to its integer. If it becomes N+1, change it to 1. You want to ensure that no player fights the same opponent more than once during the N rounds. Print an assignment of integers to the playing fields satisfying this condition. It can be proved that such an assignment always exists under the constraints given.
|
N, M = map(int, input().split())
for i in range(1, M+1):
print(i, 2*M-i+1)
|
s445016590
|
Accepted
| 74
| 9,280
| 249
|
N, M = map(int, input().split())
if (M%2 == 0):
for i in range(1, M//2+1):
print(i,M+2-i)
print(M+1+i,2*M+2-i)
else:
for i in range(1, M//2+1):
print(i,M+1-i)
print(M+i,2*M+2-i)
print(M+M//2+1, 2*M-M//2+1)
|
s648324038
|
p03079
|
u735906430
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 91
|
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 = [int(x) for x in input().split(" ")]
print("Yes" if a**2 + b**2 == c**2 else "No")
|
s706365132
|
Accepted
| 17
| 2,940
| 83
|
a,b,c = [int(x) for x in input().split(" ")]
print("Yes" if a == b == c else "No")
|
s381913283
|
p03644
|
u090225501
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 42
|
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())
print(n.bit_length() - 1)
|
s642698980
|
Accepted
| 19
| 3,060
| 49
|
n = int(input())
print(2 ** (n.bit_length() - 1))
|
s414945599
|
p00001
|
u744114948
| 1,000
| 131,072
|
Wrong Answer
| 30
| 6,724
| 97
|
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
|
m=[input() for i in range(10)]
m.sort()
m.reverse()
print("{0}\n{1}\n{2}".format(m[0],m[1],m[2]))
|
s353540876
|
Accepted
| 30
| 6,724
| 125
|
#! /usr/bin/python3
m=[int(input()) for i in range(10)]
m.sort()
m.reverse()
print("{0}\n{1}\n{2}".format(m[0], m[1], m[2]))
|
s191010458
|
p03447
|
u748135969
| 2,000
| 262,144
|
Time Limit Exceeded
| 2,104
| 2,940
| 132
|
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
|
x = int(input())
a = int(input())
b = int(input())
rest_a = x - a
rest_b = 0
while rest_a >= 0:
rest_b = rest_a - b
print(rest_b)
|
s566210908
|
Accepted
| 17
| 2,940
| 100
|
x = int(input())
a = int(input())
b = int(input())
rest_a = x - a
rest_b = rest_a % b
print(rest_b)
|
s932317890
|
p02399
|
u956226421
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,708
| 135
|
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
I = input().split()
a = int(I[0])
b = int(I[1])
d = int(a / b)
r = a % b
f = float(a / b)
print(str(d) + ' ' + str(r) + ' ' + str(f))
|
s407807370
|
Accepted
| 60
| 7,700
| 153
|
I = input().split()
a = int(I[0])
b = int(I[1])
d = int(a / b)
r = a % b
f = float(a / b)
print(str(d) + ' ' + str(r) + ' ' + str("{0:.5f}".format(f)))
|
s153715048
|
p03556
|
u557494880
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 62
|
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())
import math
x = math.ceil(N**0.5)
print(x**2)
|
s206552767
|
Accepted
| 23
| 2,940
| 63
|
N = int(input())
import math
x = math.floor(N**0.5)
print(x**2)
|
s362804775
|
p03251
|
u183840468
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 3,064
| 346
|
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
n,m,x,y = [int(i) for i in input().split()]
xl = [int(i) for i in input().split()]
yl = [int(i) for i in input().split()]
x_max = max(xl)
y_min = min(yl)
z = {i for i in range(x,y+1)}
x_y_interval = {i for i in range(x_max+1,y_min+1)}
if y_min <= x_max:
print('War')
elif list(z &x_y_interval):
print('No war')
else:
print('War')
|
s994755509
|
Accepted
| 17
| 3,064
| 344
|
n,m,x,y = [int(i) for i in input().split()]
xl = [int(i) for i in input().split()]
yl = [int(i) for i in input().split()]
x_max = max(xl)
y_min = min(yl)
z = {i for i in range(x+1,y+1)}
x_y_interval = {i for i in range(x_max+1,y_min+1)}
if not x_y_interval:
print('War')
elif z &x_y_interval:
print('No War')
else:
print('War')
|
s624367477
|
p03574
|
u363466395
| 2,000
| 262,144
|
Wrong Answer
| 31
| 3,188
| 474
|
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 = [int(_) for _ in input().split()]
cbd = [list(input()) for _ in range(H)]
for i in range(H):
for j in range(W):
if cbd[i][j] == ".":
c = 0
for iw in range(i-1,i+2):
for jw in range(j-1,j+2):
if iw < 0 or H <= iw or jw < 0 or W <= jw:
continue
elif cbd[iw][jw] == "#":
c += 1
cbd[i][j] = str(c)
print(*cbd,sep="\n")
|
s523205342
|
Accepted
| 31
| 3,188
| 499
|
H, W = [int(_) for _ in input().split()]
cbd = [list(input()) for _ in range(H)]
for i in range(H):
for j in range(W):
if cbd[i][j] == ".":
c = 0
for iw in range(i-1,i+2):
for jw in range(j-1,j+2):
if iw < 0 or H <= iw or jw < 0 or W <= jw:
continue
elif cbd[iw][jw] == "#":
c += 1
cbd[i][j] = str(c)
for i in range(H):
print("".join(cbd[i]))
|
s850827990
|
p03524
|
u583507988
| 2,000
| 262,144
|
Wrong Answer
| 30
| 9,108
| 220
|
Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.
|
s=input()
n=len(s)
set=set(s)
t=len(set)
m=n//t
res=0
for i in set:
if m<=s.count(i)<m+1:
res+=1
elif s.count(i)==m+1:
continue
else:
print('NO')
exit()
if m<=res:
print('NO')
else:
print('YES')
|
s534773294
|
Accepted
| 33
| 9,284
| 581
|
s=input()
n=len(s)
set=set(s)
m=len(set)
a=s.count('a')
b=s.count('b')
c=s.count('c')
if m==1:
if n==1:
print('YES')
else:
print('NO')
elif m==2:
if n==2:
print('YES')
else:
print('NO')
else:
if n%3==0:
if a==b==c:
print('YES')
else:
print('NO')
elif n%3==2:
if (a==n//3+1 and b==n//3+1) or (c==n//3+1 and b==n//3+1) or (a==n//3+1 and c==n//3+1):
print('YES')
else:
print('NO')
else:
if (a==n//3 and b==n//3) or (c==n//3 and b==n//3) or (a==n//3 and c==n//3):
print('YES')
else:
print('NO')
|
s979144678
|
p03998
|
u288087195
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 1,363
|
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.
|
t = [input() for i in range(3)]
array1 = []
array2 = []
array3 = []
for i in range(len(t[0])):
array1.append(t[0][i])
for i in range(len(t[1])):
array2.append(t[1][i])
for i in range(len(t[2])):
array3.append(t[2][i])
who_turns = 0
a_count = 0
b_count = 0
c_count = 0
for i in range(len(array1)+len(array2)+len(array3)):
if (a_count != len(array1) and who_turns == 0):
for j in range(len(array1)):
a_count += 1
if array1[j] == "a":
continue
elif array1[j] == "b":
who_turns = 1
break
elif array1[j] == "c":
who_turns = 2
break
if (b_count != len(array2) and who_turns == 1):
for j in range(len(array2)):
b_count += 1
if array2[j] == "a":
who_turns = 0
break
elif array2[j] == "b":
continue
elif array2[j] == "c":
who_turns = 2
break
if (c_count != len(array3) and who_turns == 2):
for j in range(len(array3)):
c_count += 1
if array2[j] == "a":
who_turns = 0
break
elif array2[j] == "b":
who_turns = 1
break
elif array2[j] == "c":
continue
if a_count == len(array1):
print("a")
break
elif b_count == len(array2):
print("b")
break
elif c_count == len(array3):
print("c")
break
|
s545495910
|
Accepted
| 18
| 3,188
| 1,623
|
t = [input() for i in range(3)]
array1 = []
array2 = []
array3 = []
for i in range(len(t[0])):
array1.append(t[0][i])
for i in range(len(t[1])):
array2.append(t[1][i])
for i in range(len(t[2])):
array3.append(t[2][i])
who_turns = 0
a_count = 0
b_count = 0
c_count = 0
for i in range(len(array1)+len(array2)+len(array3)):
if who_turns ==0 :
for j in range(a_count, len(array1)):
if a_count != len(array1):
a_count = a_count +1
if array1[j] == "a":
continue
elif array1[j] == "b":
who_turns = 1
break
elif array1[j] == "c":
who_turns = 2
break
else:
break
if who_turns == 1:
for j in range(b_count,len(array2)):
if b_count != len(array2):
b_count = b_count + 1
if array2[j] == "a":
who_turns = 0
break
elif array2[j] == "b":
continue
elif array2[j] == "c":
who_turns = 2
break
else:
break
if who_turns == 2:
for j in range(c_count,len(array3)):
if c_count != len(array3):
c_count = c_count +1
if array3[j] == "a":
who_turns = 0
break
elif array3[j] == "b":
who_turns = 1
break
elif array3[j] == "c":
continue
else:
break
if who_turns == 0 and a_count == len(array1):
print("A")
break
elif who_turns == 1 and b_count == len(array2):
print("B")
break
elif who_turns == 2 and c_count == len(array3):
print("C")
break
|
s582592442
|
p02697
|
u764215612
| 2,000
| 1,048,576
|
Wrong Answer
| 82
| 9,204
| 88
|
You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive). You cannot assign the same integer to multiple playing fields. The competition consists of N rounds, each of which proceeds as follows: * For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there. * Then, each player adds 1 to its integer. If it becomes N+1, change it to 1. You want to ensure that no player fights the same opponent more than once during the N rounds. Print an assignment of integers to the playing fields satisfying this condition. It can be proved that such an assignment always exists under the constraints given.
|
n, m = map(int, input().split())
for i in range(m):
print(str(i+1) + ' ' + str(2*m-i))
|
s128451054
|
Accepted
| 87
| 9,224
| 333
|
n, m = map(int, input().split())
if m%2 == 1:
for i in range(int((m-1)/2)):
print(str(i+1) + ' ' + str(m-i))
for i in range(int((m+1)/2)):
print(str(m+i+1) + ' ' + str(2*m-i+1))
else:
for i in range(int(m/2)):
print(str(i+1) + ' ' + str(m-i+1))
for i in range(int(m/2)):
print(str(i+m+2) + ' ' + str(2*m-i+1))
|
s529156503
|
p03386
|
u411544692
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 202
|
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
A, B, K = map(int, input().split())
ans = []
for i in range(K):
ans.append(A+i)
ans.append(B-i)
ans = [a for a in ans if A <= a <= B]
ans.sort()
ans = list(set(ans))
for i in ans:
print(i)
|
s493337435
|
Accepted
| 17
| 3,060
| 202
|
A, B, K = map(int, input().split())
ans = []
for i in range(K):
ans.append(A+i)
ans.append(B-i)
ans = [a for a in ans if A <= a <= B]
ans = list(set(ans))
ans.sort()
for i in ans:
print(i)
|
s566160101
|
p03478
|
u404240078
| 2,000
| 262,144
|
Wrong Answer
| 340
| 12,636
| 319
|
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
import numpy as np
N,A,B = input().split()
N = int(N)
A = int(A)
B = int(B)
TRUE_LIST = []
list_1 = list(range(0,N+1))
print(range(len(list_1)))
for i in range(len(list_1)):
s = str(list_1[i])
arr = list(map(int,s))
t=np.sum(arr)
if A <= t and t <= B:
TRUE_LIST.append(list_1[i])
print(np.sum(TRUE_LIST))
|
s418807611
|
Accepted
| 37
| 3,572
| 245
|
N,A,B = map(int,input().split())
TRUE_LIST = []
list_1 = list(range(0,N+1))
for i in range(len(list_1)):
s = str(list_1[i])
arr = list(map(int,s))
t=sum(arr)
if A <= t and t <= B:
TRUE_LIST.append(list_1[i])
print(sum(TRUE_LIST))
|
s655823752
|
p02255
|
u722932083
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,588
| 200
|
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.
|
N = int(input())
A = list(map(int, input().split()))
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(A)
|
s020233254
|
Accepted
| 20
| 5,596
| 250
|
N = int(input())
A = list(map(int, input().split()))
for i in range(1, N):
print(' '.join(map(str, A)))
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(' '.join(map(str, A)))
|
s525696660
|
p03385
|
u810735437
| 2,000
| 262,144
|
Wrong Answer
| 40
| 5,556
| 317
|
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys
s = ''.join(sorted(input()))
print(s)
if s == 'abc':
print('Yes')
else:
print('No')
|
s210933578
|
Accepted
| 42
| 5,680
| 308
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys
s = ''.join(sorted(input()))
if s == 'abc':
print('Yes')
else:
print('No')
|
s890585072
|
p03644
|
u030726788
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 47
|
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())
x=1
while(x<=N):
x*=2
print(x)
|
s477964661
|
Accepted
| 17
| 2,940
| 69
|
N=int(input())
x=1
while(x<=N):
x*=2
if(x>N):
x/=2
print(int(x))
|
s596780101
|
p02602
|
u646083276
| 2,000
| 1,048,576
|
Wrong Answer
| 141
| 31,552
| 143
|
M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms: not given. * For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term. M-kun scored A_i in the exam at the end of the i-th term. For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is **strictly** greater than the grade for the (i-1)-th term.
|
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k, n):
if a[n-k] < a[k]: print("Yes")
else: print("No")
|
s083285232
|
Accepted
| 142
| 31,616
| 143
|
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k, n):
if a[i-k] < a[i]: print("Yes")
else: print("No")
|
s982781594
|
p02255
|
u970743870
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,772
| 308
|
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
def insertion_sort(A, N):
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(*A)
return A
N = int(input())
A = list(map(int, input().split()))
A = insertion_sort(A, N)
print(*A)
|
s939710142
|
Accepted
| 30
| 8,052
| 308
|
def insertion_sort(A, N):
for i in range(1, N):
v = A[i]
j = i - 1
print(*A)
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
return A
N = int(input())
A = list(map(int, input().split()))
A = insertion_sort(A, N)
print(*A)
|
s588283249
|
p03163
|
u456033454
| 2,000
| 1,048,576
|
Wrong Answer
| 2,113
| 163,392
| 525
|
There are N items, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), Item i has a weight of w_i and a value of v_i. Taro has decided to choose some of the N items and carry them home in a knapsack. The capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W. Find the maximum possible sum of the values of items that Taro takes home.
|
num, capacity = list(map(int, input().split()))
actions = [[0 for i in range(capacity + 1)]]
for i in range(num):
actions.append(list(map(int, input().split())))
dp = [[0 for i in range(capacity + 1)] for j in range(num + 1)]
for i in range(1, num + 1):
for w in range(capacity + 1):
if w - actions[i][0] >= 0:
if w <= capacity:
dp[i][w] = max( dp[i-1][w - actions[i][0]] + actions[i][1], dp[i-1][w] )
else:
dp[i][w] = dp[i-1][w]
print(max( dp[num] ))
|
s918780217
|
Accepted
| 1,473
| 9,588
| 360
|
def calc(num,capacity):
dp = [0]*(capacity+1)
for _ in range(num):
weight, value = map(int, input().split())
for w in range(capacity,weight - 1,-1):
tmp = dp[w - weight] + value
if dp[w] < tmp:
dp[w] = tmp
return dp[capacity]
num, capacity = map(int, input().split())
print(calc(num,capacity))
|
s026679604
|
p03457
|
u805002755
| 2,000
| 262,144
|
Wrong Answer
| 418
| 27,380
| 370
|
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
judge = "No"
l.insert(0,[0,0,0])
for i in range(n):
n_j = (l[i+1][0]-l[i][0])%2==1
xy = (l[i+1][1]+l[i+1][2])-(l[i][1]+l[i][2])
if n_j==xy%2 & n_j>=xy:
judge = "Yes"
else:
judge ="No"
break
|
s173958767
|
Accepted
| 433
| 27,380
| 396
|
n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
judge = 'No'
l.insert(0,[0,0,0])
for i in range(n):
dt = l[i+1][0]-l[i][0]
n_j = dt%2
xy = (l[i+1][1]+l[i+1][2])-(l[i][1]+l[i][2])
if n_j==xy%2 and dt>=abs(xy):
judge = 'Yes'
else:
judge ='No'
break
print(judge)
|
s491405926
|
p03214
|
u022215787
| 2,525
| 1,048,576
|
Wrong Answer
| 150
| 12,508
| 241
|
Niwango-kun is an employee of Dwango Co., Ltd. One day, he is asked to generate a thumbnail from a video a user submitted. To generate a thumbnail, he needs to select a frame of the video according to the following procedure: * Get an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the number of the frames of the video, and each a_i denotes the representation of the i-th frame of the video. * Select t-th frame whose representation a_t is nearest to the average of all frame representations. * If there are multiple such frames, select the frame with the smallest index. Find the index t of the frame he should select to generate a thumbnail.
|
n = int(input())
a_l = list(map(int, input().split()))
import numpy as np
ave_a = np.mean(a_l)
a_l2 = [ abs(a-ave_a) for a in a_l]
ans = 0
l = a_l2[0]
for idx, i in enumerate(a_l2[1:]):
if l > i:
ans = min(idx+1, ans)
print(ans)
|
s972934805
|
Accepted
| 149
| 12,440
| 207
|
n = int(input())
a_l = list(map(int, input().split()))
import numpy as np
ave_a = np.mean(a_l)
a_l2 = [ (i, abs(j-ave_a)) for i,j in enumerate(a_l) ]
a_l3 = sorted(a_l2, key=lambda x: x[1])
print(a_l3[0][0])
|
s992659846
|
p03434
|
u023958502
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 179
|
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
n = int(input())
a = list(map(int,input().split()))
a.sort()
cnt = 0
sum1 = 0
sum2 = 0
for i in range(n):
if cnt % 2 == 0:
sum1 += a[i]
else:
sum2 += a[i]
print(sum1 - sum2)
|
s787689690
|
Accepted
| 17
| 3,060
| 201
|
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
cnt = 0
sum1 = 0
sum2 = 0
for i in range(n):
if cnt % 2 == 0:
sum1 += a[i]
else:
sum2 += a[i]
cnt += 1
print(sum1 - sum2)
|
s532683711
|
p02602
|
u624281900
| 2,000
| 1,048,576
|
Wrong Answer
| 2,206
| 37,176
| 316
|
M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms: not given. * For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term. M-kun scored A_i in the exam at the end of the i-th term. For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is **strictly** greater than the grade for the (i-1)-th term.
|
n,k=map(int,input().split())
l=list(map(int,input().split()))
pr=1
t=[]
for i in range(len(l)):
if i<k:
pr*=l[i]
else:
t.append(pr)
pr*=l[i]
pr//=l[i-k]
t.append(pr)
print(t)
for i in range(len(t)-1):
if t[i]<t[i+1]:
print("Yes")
else:
print("No")
|
s882332866
|
Accepted
| 152
| 31,440
| 168
|
n,k=map(int,input().split())
l=list(map(int,input().split()))
pr=1
t=[]
for i in range(len(l)-k):
if l[i]<l[i+k]:
print("Yes")
else:
print("No")
|
s598428933
|
p02396
|
u647529925
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,404
| 101
|
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
|
for i, x in enumerate(input()):
if not x:
break
print('Case {0}: {1}'.format(i+1, x))
|
s212407857
|
Accepted
| 140
| 7,624
| 114
|
i=1
while(True):
x = int(input())
if not x:
break
print('Case {0}: {1}'.format(i, x))
i+=1
|
s223814642
|
p03079
|
u363407238
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 73
|
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
|
import sys
input = sys.stdin.readline
a, b, c = map(int, input().split())
|
s144079235
|
Accepted
| 18
| 2,940
| 91
|
a,b,c=map(int,input().split())
if a == b and b == c:
print('Yes')
else:
print('No')
|
s214678062
|
p04029
|
u582765213
| 2,000
| 262,144
|
Wrong Answer
| 31
| 8,952
| 46
|
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())
candy=N*(1+N)/2
print(candy)
|
s547471366
|
Accepted
| 28
| 9,036
| 52
|
N = int(input())
candy=(1+N)*N/2
print(int(candy))
|
s398308372
|
p03110
|
u628874030
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 254
|
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
|
def main():
N = int(input())
money = 0
for i in range(N):
X,U = input().split()
if U == 'JPY':
money +=int(X)
else:
money += float(X)*38000
print(money)
if __name__ =='__main__':
main()
|
s377880438
|
Accepted
| 17
| 2,940
| 255
|
def main():
N = int(input())
money = 0
for i in range(N):
X,U = input().split()
if U == 'JPY':
money +=int(X)
else:
money += float(X)*380000
print(money)
if __name__ =='__main__':
main()
|
s904395254
|
p03457
|
u322187839
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 395
|
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
S=input()
reverse_S=S[::-1]
while True:
if (reverse_S.find('maerd')==0 or
reverse_S.find('esare')==0
):
reverse_S=reverse_S[5:]
elif reverse_S.find('remaerd')==0:
reverse_S=reverse_S[7:]
elif reverse_S.find('resare')==0:
reverse_S=reverse_S[6:]
else:
break
if len(reverse_S)==0:
print('YES')
else:
print('NO')
|
s029067958
|
Accepted
| 377
| 11,668
| 392
|
N=int(input())
t=[0]*100003
x=[0]*100003
y=[0]*100003
for i in range(1,N+1):
t[i],x[i],y[i]=map(int, input().split())
count=0
for i in range(1,N+1):
dt=t[i]-t[i-1]
dist=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
if dist>dt:
break
else:
pass
if dist%2==dt%2:
pass
else:
break
count+=1
if count==N:
print('Yes')
else:
print('No')
|
s708929061
|
p03378
|
u644516473
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 142
|
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N. Find the minimum cost incurred before reaching the goal.
|
n, m, x = map(int, input().split())
A = map(int, input().split())
r = 0
l = 0
for a in A:
if a > x:
r += 1
else:
l += 1
print(max(r, l))
|
s884803748
|
Accepted
| 18
| 3,060
| 143
|
n, m, x = map(int, input().split())
A = map(int, input().split())
r = 0
l = 0
for a in A:
if a > x:
r += 1
else:
l += 1
print(min(r, l))
|
s166717313
|
p03523
|
u422272120
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,188
| 199
|
You are given a string S. Takahashi can insert the character `A` at any position in this string any number of times. Can he change S into `AKIHABARA`?
|
import re
s = input()
if len(s) > 9:
print ("No")
else:
p = 'A?KIHA?BA?RA?'
r = re.compile(p)
result = r.match(s)
if result:
print ("Yes")
else:
print ("No")
|
s770197594
|
Accepted
| 22
| 3,188
| 199
|
import re
s = input()
if len(s) > 9:
print ("NO")
else:
p = 'A?KIHA?BA?RA?'
r = re.compile(p)
result = r.match(s)
if result:
print ("YES")
else:
print ("NO")
|
s348814666
|
p03475
|
u170183831
| 3,000
| 262,144
|
Wrong Answer
| 20
| 3,316
| 477
|
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.
|
def solve(n, CSF):
times = [0] * n
total = 0
for i, (c, s, f) in enumerate(CSF):
if total < s:
total = s
else:
total += total % f
total += c
times[i] = total - times[i - 1]
ret = [total - times[n - i - 1] for i in range(n)]
return ret
_n = int(input())
_CSF = [map(int, input().split()) for _ in range(_n - 1)]
print(*solve(_n, _CSF), sep='\n')
|
s186085414
|
Accepted
| 64
| 3,316
| 424
|
from math import ceil
def solve(n, CSF):
times = [0] * n
for i, (c, s, f) in enumerate(CSF):
for j in range(i + 1):
if times[j] <= s:
times[j] = s
else:
times[j] = s + ceil((times[j] - s) / f) * f
times[j] += c
return times
_n = int(input())
_CSF = [map(int, input().split()) for _ in range(_n - 1)]
print(*solve(_n, _CSF), sep='\n')
|
s286072972
|
p03455
|
u241234955
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 84
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a = 3
b = 4
if a % 2 == 0 and b % 2 == 0:
print("Even")
else:
print("Odd")
|
s163437956
|
Accepted
| 18
| 2,940
| 100
|
a,b=map(int,input().split())
if a % 2 != 0 and b % 2 != 0:
print("Odd")
else:
print("Even")
|
s320498560
|
p03485
|
u428132025
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 66
|
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.
|
import math
a, b = map(int, input().split())
print(math.ceil(a+b))
|
s554399030
|
Accepted
| 17
| 2,940
| 70
|
import math
a, b = map(int, input().split())
print(math.ceil((a+b)/2))
|
s505880128
|
p03852
|
u648890761
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 134
|
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
|
s = input()
arr = ['a', 'e', 'i', 'o', 'u']
for i in arr:
if s == i:
print("vowel")
else:
print("consonant")
|
s662810874
|
Accepted
| 18
| 2,940
| 131
|
s = input()
arr = ['a', 'e', 'i', 'o', 'u']
for i in arr:
if s == i:
print("vowel")
exit(0)
print("consonant")
|
s499361529
|
p03478
|
u167908302
| 2,000
| 262,144
|
Wrong Answer
| 30
| 2,940
| 174
|
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
#coding:utf-8
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
num = sum(map(int, str(i)))
if num >= a and num <= b:
ans += num
print(ans)
|
s245744832
|
Accepted
| 31
| 2,940
| 172
|
#coding:utf-8
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
num = sum(map(int, str(i)))
if num >= a and num <= b:
ans += i
print(ans)
|
s446018240
|
p02646
|
u760569096
| 2,000
| 1,048,576
|
Wrong Answer
| 21
| 9,188
| 243
|
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v <= w:
print('No')
exit(0)
if abs(a-b)%(v-w) == 0:
f = abs(a-b//(v-w))
else:
f = abs(a-b//(v-w)+1)
if f <= t:
print('Yes')
else:
print('No')
|
s617564510
|
Accepted
| 23
| 9,196
| 239
|
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v <= w:
print('NO')
exit(0)
if abs(a-b)%(v-w) == 0:
f = abs(a-b)//(v-w)
else:
f = abs(a-b)//(v-w)+1
if f <= t:
print('YES')
else:
print('NO')
|
s398733224
|
p02238
|
u196653484
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,612
| 726
|
Depth-first search (DFS) follows the strategy to search ”deeper” in the graph whenever possible. In DFS, edges are recursively explored out of the most recently discovered vertex $v$ that still has unexplored edges leaving it. When all of $v$'s edges have been explored, the search ”backtracks” to explore edges leaving the vertex from which $v$ was discovered. This process continues until all the vertices that are reachable from the original source vertex have been discovered. If any undiscovered vertices remain, then one of them is selected as a new source and the search is repeated from that source. DFS timestamps each vertex as follows: * $d[v]$ records when $v$ is first discovered. * $f[v]$ records when the search finishes examining $v$’s adjacency list. Write a program which reads a directed graph $G = (V, E)$ and demonstrates DFS on the graph based on the following rules: * $G$ is given in an adjacency-list. Vertices are identified by IDs $1, 2,... n$ respectively. * IDs in the adjacency list are arranged in ascending order. * The program should report the discover time and the finish time for each vertex. * When there are several candidates to visit during DFS, the algorithm should select the vertex with the smallest ID. * The timestamp starts with 1.
|
n=0
t=2
def adjacent_matrix():
global n
n=int(input())
v=[]
array=[]
for i in range(n):
zero=[0 for i in range(n)]
a=list(map(int,input().split()))
a=a[2:]
for j in a:
zero[j-1]=1
array.append(zero)
return array
def dfs(array,i,d,f):
global t
for (j,x) in enumerate(array[i]):
if x == 1:
d[j] = t
t += 1
dfs(array,j,d,f)
f[i] = t
t += 1
return
def main():
array=adjacent_matrix()
print()
d=[1 for i in range(n)]
f=[1 for i in range(n)]
dfs(array,0,d,f)
for i in range(n):
print("{} {} {}".format(i+1,d[i],f[i]))
if __name__ == "__main__":
main()
|
s729735083
|
Accepted
| 20
| 5,692
| 844
|
n=0
t=1
def adjacent_matrix():
global n
n=int(input())
v=[]
array=[]
for i in range(n):
zero=[0 for i in range(n)]
a=list(map(int,input().split()))
a=a[2:]
for j in a:
zero[j-1]=1
array.append(zero)
return array
def dfs(array,i,d,f):
global t
if i == n:
return
else:
if(d[i] == 0):
d[i] = t
t += 1
for (j,x) in enumerate(array[i]):
if x == 1:
dfs(array,j,d,f)
f[i] = t
t += 1
return
def main():
array=adjacent_matrix()
d=[0 for i in range(n)]
f=[0 for i in range(n)]
for i in range(n):
dfs(array,i,d,f)
for i in range(n):
print("{} {} {}".format(i+1,d[i],f[i]))
if __name__ == "__main__":
main()
|
s216444907
|
p02394
|
u429841998
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,592
| 139
|
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.
|
W, H, x, y, r = map(int, input().split())
if x + r <= W and y + r <= H and x - r >= 0 and y - r >= 0:
print('1')
else:
print('0')
|
s188447225
|
Accepted
| 20
| 5,596
| 142
|
W, H, x, y, r = map(int, input().split())
if x + r <= W and y + r <= H and x - r >= 0 and y - r >= 0:
print('Yes')
else:
print('No')
|
s629534189
|
p03759
|
u890807039
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 71
|
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
a,b,c = map(int,input().split())
print("Yes" if (b-a)==(c-b) else "No")
|
s140776783
|
Accepted
| 17
| 2,940
| 71
|
a,b,c = map(int,input().split())
print("YES" if (b-a)==(c-b) else "NO")
|
s454031506
|
p03377
|
u903948194
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 137
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a, b, x = map(int, input().split())
if x < a:
print('No')
else:
if x > a + b:
print('No')
else:
print('Yes')
|
s740211508
|
Accepted
| 17
| 2,940
| 137
|
a, b, x = map(int, input().split())
if x < a:
print('NO')
else:
if x > a + b:
print('NO')
else:
print('YES')
|
s823068489
|
p03494
|
u760802228
| 2,000
| 262,144
|
Wrong Answer
| 25
| 3,384
| 350
|
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.
|
n = int(input())
a = list(map(int, input().split()))
ans = 0
while a[0] > 1:
for i in range(n):
if a[i] % 2 != 0:
break
else:
a[i] /= 2
print(a[i])
else:
ans += 1
continue
break;
print(ans)
|
s983714291
|
Accepted
| 19
| 3,060
| 314
|
n = int(input())
a = list(map(int, input().split()))
ans = 0
while a[0] > 1:
for i in range(n):
if a[i] % 2 != 0:
break
else:
a[i] /= 2
else:
ans += 1
continue
break;
print(ans)
|
s807330654
|
p03944
|
u599547273
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 308
|
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(" "))
x_y_a = [tuple(map(int, input().split(" "))) for i in range(n)]
x_y_min_max = [0, w, 0, h]
for x_y_a_i in x_y_a:
x, y, a = x_y_a_i
x_y_min_max[a-1] = [x, y][(a-1)//2]
print(x_y_min_max)
print((x_y_min_max[1]-x_y_min_max[0])*(x_y_min_max[3]-x_y_min_max[2]))
|
s833078968
|
Accepted
| 17
| 3,064
| 423
|
w, h, n = map(int, input().split(" "))
x_y_a = [tuple(map(int, input().split(" "))) for i in range(n)]
min_x, max_x, min_y, max_y = 0, w, 0, h
for x_y_a_i in x_y_a:
x, y, a = x_y_a_i
if a == 1:
min_x = max(min_x, x)
elif a == 2:
max_x = min(max_x, x)
elif a == 3:
min_y = max(min_y, y)
elif a == 4:
max_y = min(max_y, y)
print(max(0, max_x-min_x) * max(0, max_y-min_y))
|
s042019721
|
p03400
|
u816428863
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 173
|
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp.
|
N=int(input())
D,X=map(int,input().split())
A=[]
for i in range(N):
a=int(input())
A+=[a]
ans=0
for i in range(N):
ans+=(D-1)//A[i]+1
print(ans)
print(ans+X)
|
s943576345
|
Accepted
| 17
| 3,060
| 159
|
N=int(input())
D,X=map(int,input().split())
A=[]
for i in range(N):
a=int(input())
A+=[a]
ans=0
for i in range(N):
ans+=(D-1)//A[i]+1
print(ans+X)
|
s890578350
|
p02742
|
u628151901
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 128
|
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:
|
import math
H, W = [int(_) for _ in input().split(" ")]
if (H % 2 == 0):
print(H/2*W)
else:
print(int(H/2)*W+math.ceil(W/2))
|
s130732160
|
Accepted
| 17
| 3,060
| 169
|
import math
H, W = [int(_) for _ in input().split(" ")]
if (H == 1 or W == 1):
print(1)
elif (H % 2 == 0):
print(int(H/2*W))
else:
print(int(H/2)*W+math.ceil(W/2))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.