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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s113879557
|
p02853
|
u580093517
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 205
|
We held two competitions: Coding Contest and Robot Maneuver. In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen. DISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver. Find the total amount of money he earned.
|
x,y = map(int,input().split())
if x == 1 and y == 1:print(int(7e5))
elif 1<=x<=3 and 1<=y<=3:
print(int((8-x-y)*1e5))
elif 1<=x<=3:print(int((4-x)*1e5))
elif 1<=y<=3:print(int((4-y)*1e5))
else:print(0)
|
s950597969
|
Accepted
| 17
| 3,060
| 206
|
x,y = map(int,input().split())
if x == 1 and y == 1:print(int(10e5))
elif 1<=x<=3 and 1<=y<=3:
print(int((8-x-y)*1e5))
elif 1<=x<=3:print(int((4-x)*1e5))
elif 1<=y<=3:print(int((4-y)*1e5))
else:print(0)
|
s953800007
|
p03644
|
u514299323
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 58
|
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())
i=0
while 2**i<N:
i +=1
print(2**i)
|
s419648671
|
Accepted
| 17
| 2,940
| 101
|
N = int(input())
i=0
while 2**i<N:
i += 1
if 2**i ==N:
a =N
if 2**i>N:
a =2**(i-1)
print(a)
|
s025345866
|
p03643
|
u175590965
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 28
|
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
|
a = input()
print("ABC"+"a")
|
s315680561
|
Accepted
| 17
| 2,940
| 26
|
a = input()
print("ABC"+a)
|
s395881463
|
p03854
|
u354126779
| 2,000
| 262,144
|
Wrong Answer
| 31
| 3,188
| 418
|
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
s=input()
s=s+"0000000"
c=0
check=0
while c<len(s):
if s[c:c+5]=="dream":
if s[c+5:c+7]=="er":
if s[c+7]=="a":
c+=5
else:
c+=7
else:
c+=5
elif s[c:c+5]=="erase":
if s[c+5]=="r":
c+=6
else:
c+=5
else:
check+=1
break
if check==0:
print("YES")
else:
print("NO")
|
s360122237
|
Accepted
| 28
| 3,188
| 422
|
s=input()
n=len(s)
s=s+"0000000"
c=0
check=0
while c<n:
if s[c:c+5]=="dream":
if s[c+5:c+7]=="er":
if s[c+7]=="a":
c+=5
else:
c+=7
else:
c+=5
elif s[c:c+5]=="erase":
if s[c+5]=="r":
c+=6
else:
c+=5
else:
check+=1
break
if check==0:
print("YES")
else:
print("NO")
|
s016841068
|
p03943
|
u612635771
| 2,000
| 262,144
|
Wrong Answer
| 30
| 9,152
| 104
|
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
a = list(map(int, input().split()))
b = sorted(a)
print(b)
print("Yes" if b[0]+b[1] == b[2] else "No")
|
s534868033
|
Accepted
| 29
| 9,068
| 78
|
a, b, c = sorted(map(int, input().split()))
print("Yes" if a+b == c else "No")
|
s768370510
|
p03486
|
u502028059
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 107
|
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
s = list(input())
t = list(input())
s.sort()
t.sort()
ans = 'No'
if s[0] < t[0]:
ans = 'Yes'
print(ans)
|
s861130560
|
Accepted
| 17
| 3,060
| 143
|
s = sorted(list(input()))
t = sorted(list(input()), reverse=True)
s = "".join(s)
t = "".join(t)
ans = 'No'
if s < t:
ans = 'Yes'
print(ans)
|
s075555081
|
p02972
|
u480130675
| 2,000
| 1,048,576
|
Wrong Answer
| 276
| 10,704
| 179
|
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
|
n = int(input())
a = [int(i) for i in input().split()]
ans = [0] * n
for i in range(n, 0, -1):
if sum(ans[i - 1:n + 1:i]) % 2 != a[i - 1]:
ans[i - 1] = 1
print(*ans)
|
s395022619
|
Accepted
| 252
| 14,048
| 222
|
n = int(input())
a = [int(i) for i in input().split()]
box = [0] * n
ans = []
for i in range(n, 0, -1):
if sum(box[i - 1:n:i]) % 2 != a[i - 1]:
box[i - 1] = 1
ans.append(i)
print(len(ans))
print(*ans)
|
s563060001
|
p00296
|
u350508326
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,564
| 793
|
ใขใซใ้ซๆ กใงใฏใๆฏๅนดๅ
จๆ ก็ๅพใๅๅ ใใใฒใผใ ใ่กใฃใฆใใพใใใพใใๆ กๅบญใซ N ไบบใฎๅ
จๆ ก็ๅพใๅๅฝขใซไธฆใณใพใใๅณใฎใใใซใๅ็ๅพใฏ 0 ใใ N-1 ใพใงใฎ็ชๅทใๆธใใใใผใใฑใณใไปใใฆใใพใใ ใฒใผใ ใงใฏใใใณใ๏ผๆฌไฝฟใใๆๅใฏใผใใฑใณ 0 ็ชใฎ็ๅพใใใใณใๆใฃใฆใใพใใใใใใใไปฅไธใฎๆ้ ใ M ๅ็นฐใ่ฟใใพใใใพใใ็พๆ็นใงใใใณใๆใฃใฆใใ็ๅพใ้ฉๅฝใชๆญฃใฎๆดๆฐ a ใๅฎฃ่จใใพใใa ใๅถๆฐใฎใจใใฏๆ่จๅใใๅฅๆฐใฎใจใใฏๅๆ่จๅใใซ้ฃใฎ็ๅพใซใใใณใๆธกใใฆใใใa ็ช็ฎใซใใใณใๅใๅใฃใ็ๅพใ่ฑ่ฝใใพใใ่ฑ่ฝใใ็ๅพใฏใๆ่จๅใใง้ฃใฎ็ๅพใซใใใณใๆธกใใๅใใๆใใพใใ ใฒใผใ ใ็ตใใฃใๅพใซๅใซๆฎใฃใ็ๅพใฏใๆพ่ชฒๅพใฎๆ้คใ๏ผๅนด้ๅ
้คใใใพใใใใใใใใๆฐๅนดใฏ็ๅพๆฐใๅขใใใใใๅ
จๆ ก็ๅพใ้ใใใฎใ้ฃใใใชใฃใฆใใฆใใพใใใใใงใ็ซถๆใใญใฐใฉใใณใฐ้จใฎใใชใใฏใใทใใฅใฌใผใทใงใณใงๆ้คใๅ
้คใใใ็ๅพใๆฑใใใใญใฐใฉใ ใไฝๆใใใใ้ ผใพใใพใใใ ๆๅฎใใ็ๅพใๆ้คใๅ
้คใใใฆใใใใฉใใใ่ณชๅใใใจใใใใใซ็ญใใใใญใฐใฉใ ใไฝๆใใฆใใ ใใใ
|
#!/usr/bin/env python3
def pass_baton(n_list, current, in_data):
print(current, in_data)
if in_data % 2 != 0:
current -= in_data
while current < 0:
current += len(n_list)
return current
else:
current += in_data
while len(n_list) <= current:
current -= len(n_list)
return current
N, M, Q = map(int ,input().split(' '))
m_data = map(int, input().split(' '))
q_data = map(int, input().split(' '))
n_list = [x for x in range(N)]
baton_place = 0
for m in m_data:
baton_place = pass_baton(n_list, baton_place, m)
print(baton_place)
del n_list[baton_place]
if len(n_list) == baton_place:
baton_place = 0
for q in q_data:
if q in n_list:
print(1)
else:
print(0)
|
s128089911
|
Accepted
| 3,810
| 29,624
| 660
|
def pass_baton(n_list, current, in_data):
if in_data % 2 != 0:
current -= in_data
while current < 0:
current += len(n_list)
return current
else:
current += in_data
while len(n_list) <= current:
current -= len(n_list)
return current
N, M, Q = map(int ,input().split(' '))
m_data = map(int, input().split(' '))
q_data = map(int, input().split(' '))
n_list = [x for x in range(N)]
baton_place = 0
for m in m_data:
baton_place = pass_baton(n_list, baton_place, m)
del n_list[baton_place]
for q in q_data:
if q in n_list:
print(1)
else:
print(0)
|
s941035499
|
p03408
|
u794173881
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 292
|
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
|
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
memo = {}
for i in range(n):
if s[i] not in memo:
memo[s[i]] = 1
else:
memo[s[i]] +=1
for i in range(m):
if t[i] in memo:
memo[t[i]] -=1
print(max(memo[max(memo)],0))
|
s173401917
|
Accepted
| 18
| 3,064
| 314
|
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
memo = {}
for i in range(n):
if s[i] not in memo:
memo[s[i]] = 1
else:
memo[s[i]] +=1
for i in range(m):
if t[i] in memo:
memo[t[i]] -=1
ans=0
for i in memo:
ans = max(memo[i],ans)
print(ans)
|
s682002679
|
p03229
|
u074445770
| 2,000
| 1,048,576
|
Wrong Answer
| 264
| 7,416
| 594
|
You are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.
|
n=int(input())
a=[]
for i in range(n):
b=int(input())
a.append(b)
a.sort()
b=a
if n%2==0:
for i in range(int(n/2-1)):
a[int((n/2))+1+i]=2*a[int((n/2))+1+i]
a[i]=-2*a[i]
a[int(n/2)-1]=(-1)*a[int(n/2)-1]
print(sum(a))
else:
for i in range(int(n/2)):
a[int((n/2))+1+i]=2*a[int((n/2))+1+i]
a[i]=-2*a[i]
a[int(n/2)]=(-1)*a[int(n/2)]
a[int(n/2)-1]=a[int(n/2)-1]*0.5
b[int(n/2)+1]=0.5*b[int(n/2)+1]
b[int(n/2)]=(-1)*b[int(n/2)]
b[int(n/2)-1]=2*b[int(n/2)-1]
print(int(max(sum(b),sum(a))))
|
s376786204
|
Accepted
| 265
| 7,416
| 600
|
n=int(input())
a=[]
for i in range(n):
b=int(input())
a.append(b)
a.sort()
b=a
if n%2==0:
for i in range(int(n/2-1)):
a[int((n/2))+1+i]=2*a[int((n/2))+1+i]
a[i]=-2*a[i]
a[int(n/2)-1]=(-1)*a[int(n/2)-1]
print(sum(a))
else:
for i in range(int(n/2)):
a[int((n/2))+1+i]=2*a[int((n/2))+1+i]
a[i]=-2*a[i]
a[int(n/2)]=(-1)*a[int(n/2)]
a[int(n/2)-1]=a[int(n/2)-1]*0.5
c=sum(a)
b[int(n/2)+1]=0.5*b[int(n/2)+1]
b[int(n/2)]=(-1)*b[int(n/2)]
b[int(n/2)-1]=2*b[int(n/2)-1]
d=sum(b)
print(int(max(c,d)))
|
s115796830
|
p02612
|
u674190122
| 2,000
| 1,048,576
|
Wrong Answer
| 32
| 9,080
| 26
|
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(1000 - int(input()))
|
s581028911
|
Accepted
| 29
| 9,152
| 89
|
price = int(input())
mult, res = divmod(price, 1000)
print(0 if res == 0 else 1000 - res)
|
s342200269
|
p02615
|
u107091170
| 2,000
| 1,048,576
|
Wrong Answer
| 152
| 31,380
| 123
|
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?
|
N=int(input())
A = list(map(int, input().split()))
A.sort()
print(A)
ans = 0
for i in range(1,N):
ans += A[i]
print(ans)
|
s212285902
|
Accepted
| 178
| 32,344
| 219
|
from collections import deque
N=int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
q = deque([A[0]])
ans = 0
for i in range(1,N):
ans += q.popleft()
q.append( A[i] )
q.append( A[i] )
print(ans)
|
s310616799
|
p03623
|
u079699418
| 2,000
| 262,144
|
Wrong Answer
| 23
| 9,008
| 82
|
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
x,a,b=map(int,input().split())
if (a-x)<(b-x):
print('A')
else:
print('B')
|
s900506759
|
Accepted
| 29
| 9,012
| 88
|
x,a,b=map(int,input().split())
if abs(x-a)<abs(x-b):
print('A')
else:
print('B')
|
s542299776
|
p03457
|
u787059958
| 2,000
| 262,144
|
Wrong Answer
| 336
| 3,064
| 273
|
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())
f = True
for i in range(n):
t,x,y = map(int,input().split())
et = t
exy = x+y
et-=exy
if(et>=0):
if(et%2==0):
continue
else:
f = False
break
else:
f = False
break
if (f):
print('YES')
else:
print('NO')
|
s469504548
|
Accepted
| 339
| 3,060
| 275
|
n = int(input())
f = True
for i in range(n):
t,x,y = map(int,input().split())
et = t
exy = x+y
et-=exy
if(et>=0):
if(et%2==0):
continue
else:
f = False
break
else:
f = False
break
if (f):
print('Yes')
else:
print('No')
|
s687454648
|
p04030
|
u384657160
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,064
| 379
|
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
|
s = list(str(input()))
lis = []
a = ""
for i in range(len(s)):
if s[i] == "B":
if len(lis) == 0:
continue
else:
lis.pop()
elif s[i] == "1":
lis.append("1")
else:
lis.append("0")
for j in range(len(lis)):
a = a + lis[j]
print(int(a))
|
s660842449
|
Accepted
| 18
| 3,060
| 375
|
s = list(str(input()))
lis = []
a = ""
for i in range(len(s)):
if s[i] == "B":
if len(lis) == 0:
continue
else:
lis.pop()
elif s[i] == "1":
lis.append("1")
else:
lis.append("0")
for j in range(len(lis)):
a = a + lis[j]
print(a)
|
s859133990
|
p03469
|
u968404618
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 46
|
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.
|
s = input()
S = s[:3] + '8 '+ s[4:]
print(S)
|
s123653293
|
Accepted
| 19
| 3,060
| 48
|
s = input()
S = s[:3] + '8' + s[4:]
print(S)
|
s167184692
|
p03605
|
u905895868
| 2,000
| 262,144
|
Wrong Answer
| 31
| 8,948
| 76
|
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?
|
num_str = input()
if '9' in num_str:
print('yes')
else:
print('No')
|
s773300840
|
Accepted
| 26
| 9,032
| 222
|
num_input = int(input())
set_of_nine = set()
for i in range(9, 100, 10):
set_of_nine.add(i)
for tmp in range(90, 100, 1):
set_of_nine.add(tmp)
if num_input in set_of_nine:
print('Yes')
else:
print('No')
|
s268177244
|
p02742
|
u089230684
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 211
|
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
r,c = input().split()
r = int(r)
c = int(c)
if(r==1 or c==1):
print(1)
else:
ans = r*c/2
if r%2==1 or c%2==1:
print(math.floor(ans)+1)
else:
print(math.floor(ans))
|
s907306173
|
Accepted
| 17
| 3,060
| 153
|
h,w=input().split()
h=int(h)
w=int(w)
if h==1 or w==1:
print(1)
exit(0)
c=h*w
if c%2==0:
print(int(c/2))
else:
print(int(int(c/2)+1))
|
s772299089
|
p02613
|
u731436822
| 2,000
| 1,048,576
|
Wrong Answer
| 147
| 16,280
| 269
|
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())
Sn = []
for i in range(n):
Sn.append(input())
ac = Sn.count('AC')
wa = Sn.count('WA')
tle = Sn.count('TLE')
re = Sn.count('RE')
print('AC ร {}'.format(ac))
print('WA ร {}'.format(wa))
print('TLE ร {}'.format(tle))
print('RE ร {}'.format(re))
|
s909725373
|
Accepted
| 152
| 16,176
| 265
|
n = int(input())
Sn = []
for i in range(n):
Sn.append(input())
ac = Sn.count('AC')
wa = Sn.count('WA')
tle = Sn.count('TLE')
re = Sn.count('RE')
print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))
|
s016313324
|
p02928
|
u662449766
| 2,000
| 1,048,576
|
Wrong Answer
| 421
| 21,276
| 574
|
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 sys
input = sys.stdin.readline
def main():
N, K = [int(i) for i in input().split()]
a_list = [int(i) for i in input().split()]
cnt = 0
cnt = sum([a_list[i] > a_list[j] for i in range(N) for j in range(i, N)])
second_cnt = sum([a_list[i] > a_list[j] for i in range(N) for j in range(i)])
if K > 1:
second_cnt *= (K * (K - 1)) / 2
cnt = cnt * ((K * (K + 1)) / 2)
print((cnt + second_cnt) % (10 ** 9 + 7))
# 185297239
# 185297196.0
# 43
if __name__ == "__main__":
main()
|
s567328201
|
Accepted
| 421
| 20,784
| 494
|
import sys
input = sys.stdin.readline
def main():
N, K = [int(i) for i in input().split()]
a_list = [int(i) for i in input().split()]
cnt = 0
cnt = sum([a_list[i] > a_list[j] for i in range(N) for j in range(i, N)])
second_cnt = sum([a_list[i] > a_list[j] for i in range(N) for j in range(i)])
if K > 1:
second_cnt *= (K * (K - 1)) // 2
cnt = cnt * ((K * (K + 1)) // 2)
print((cnt + second_cnt) % (10 ** 9 + 7))
if __name__ == "__main__":
main()
|
s671850668
|
p03555
|
u007263493
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 80
|
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
|
a = list(input())
b = list(input())
b.reverse()
print('Yes' if a == b else 'No')
|
s740833358
|
Accepted
| 17
| 2,940
| 80
|
a = list(input())
b = list(input())
b.reverse()
print('YES' if a == b else 'NO')
|
s734900628
|
p02397
|
u802537549
| 1,000
| 131,072
|
Wrong Answer
| 50
| 7,480
| 131
|
Write a program which reads two integers x and y, and prints them in ascending order.
|
while True:
a, b = map(int, input().split())
if a == 0 and b == 0: break
print("{} {}".format(a, b if a > b else b, a))
|
s258980234
|
Accepted
| 50
| 7,672
| 112
|
while True:
a, b = sorted(map(int, input().split()))
if a == 0 and b == 0:
break
print(a, b)
|
s500421478
|
p02262
|
u390995924
| 6,000
| 131,072
|
Wrong Answer
| 30
| 7,760
| 543
|
Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i]) A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$. Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m โ 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements: * $1 \leq m \leq 100$ * $0 \leq G_i \leq n$ * cnt does not exceed $\lceil n^{1.5}\rceil$
|
def isort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j + g] = A[j]
j -= g
cnt += 1
A[j + g] = v
def ssort(A, n):
global cnt
cnt = 0
m = min(int(n / 3), 100) + 1
G = [3 for i in range(m - 1)]
G.append(1)
print(m)
print(" ".join([str(g) for g in G]))
for g in G:
isort(A, n, g)
n = int(input())
A = [int(input()) for _ in range(n)]
ssort(A, n)
print(cnt)
for a in A:
print(a)
|
s663356953
|
Accepted
| 19,490
| 118,472
| 595
|
import sys
def isort(A, n, g):
cnt = 0
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j + g] = A[j]
j -= g
cnt += 1
A[j + g] = v
return cnt
def ssort(A, n):
cnt = 0
G = []
h = 1
while h <= n:
G.append(h)
h = 3 * h + 1
m = len(G)
G.reverse()
print(m)
print(*G, sep = " ")
for g in G:
cnt += isort(A, n, g)
return cnt
n = int(input())
A = list(map(int, sys.stdin.readlines()))
cnt = ssort(A, n)
print(cnt)
print(*A, sep = "\n")
|
s368394806
|
p02841
|
u085186789
| 2,000
| 1,048,576
|
Wrong Answer
| 29
| 9,188
| 117
|
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month.
|
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())
if M1 == M2:
print("YES")
else:
print("NO")
|
s715046377
|
Accepted
| 30
| 9,148
| 115
|
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())
if M1 == M2:
print("0")
else:
print("1")
|
s676467974
|
p02690
|
u829416877
| 2,000
| 1,048,576
|
Wrong Answer
| 32
| 9,112
| 113
|
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.
|
X = int(input())
for i in range(100):
for j in range(100):
if i**5-j**5 == X:
print(i, j)
break
|
s826936819
|
Accepted
| 59
| 9,168
| 168
|
X = int(input())
ans = ''
for i in range(-120, 120):
for j in range(-120, 120):
if i**5-j**5 == X:
ans = i, j
break
print(' '.join(map(str,ans)))
|
s924602696
|
p03455
|
u271176141
| 2,000
| 262,144
|
Wrong Answer
| 26
| 8,920
| 187
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a,b = map(int,input().split())
if (a * b) % 2 == 0:
print("even")
else:
print("odd")
|
s882125839
|
Accepted
| 27
| 9,052
| 160
|
a,b = map(int,input().split())
def answer(a: int ,b: int) ->int:
if a * b % 2 == 0:
return "Even"
else:
return "Odd"
print(answer(a,b))
|
s202265566
|
p03693
|
u102960641
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 87
|
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
a,b,c = map(int, input().split())
print("Yes") if a*100+b*10+c % 4 ==0 else print("No")
|
s811929817
|
Accepted
| 18
| 2,940
| 83
|
a,b,c = input().split()
d = int(a+b+c)
print("YES") if d % 4 == 0 else print("NO")
|
s502885628
|
p03567
|
u644972721
| 2,000
| 262,144
|
Wrong Answer
| 31
| 9,092
| 133
|
Snuke built an online judge to hold a programming contest. When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.) Determine whether the judge can return the string `AC` as the verdict to a program.
|
s = list(input())
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "C":
print("YES")
exit()
print("NO")
|
s507173760
|
Accepted
| 28
| 9,032
| 133
|
s = list(input())
for i in range(len(s) - 1):
if s[i] == "A" and s[i + 1] == "C":
print("Yes")
exit()
print("No")
|
s232859752
|
p02747
|
u115110170
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 157
|
A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string.
|
s = input()
if len(s)%2==1:
print("No")
else:
for i in range(0,len(s)-2,2):
if s[i:i+2] == "hi":
print("No")
exit()
print("Yes")
|
s187074261
|
Accepted
| 17
| 2,940
| 115
|
s = input()
a = ""
ans = "No"
for i in range(5):
a += "hi"
if a == s:
ans = "Yes"
break
print(ans)
|
s807530908
|
p02396
|
u996758922
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,568
| 133
|
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.
|
cases = list(map(int, input().split()))
length = len(cases)
for n in range(length-1):
print("Case "+str(n+1)+": "+str(cases[n]))
|
s646810083
|
Accepted
| 140
| 7,492
| 143
|
index=1
while True:
case=input()
if int(case)==0:
break
else:
print("Case "+str(index)+": "+case)
index+=1
|
s120813656
|
p03090
|
u197300773
| 2,000
| 1,048,576
|
Wrong Answer
| 24
| 3,612
| 316
|
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved that at least one such graph exists under the constraints of this problem.
|
n=int(input())
if n % 2 == 0:
print(int(n*n/2))
for i in range(1,n):
for j in range(i+1,n+1):
if i+j != n+1:
print(i,j)
if n % 2 != 0:
print(int((n*n-n)/2))
for i in range(1,n):
for j in range(i+1,n+1):
if i+j != n:
print(i,j)
|
s646911196
|
Accepted
| 23
| 3,612
| 321
|
n=int(input())
if n % 2 == 0:
print(int(n*(n-2)/2))
for i in range(1,n):
for j in range(i+1,n+1):
if i+j != n+1:
print(i,j)
if n % 2 != 0:
print(int((n-1)**2/2))
for i in range(1,n):
for j in range(i+1,n+1):
if i+j != n:
print(i,j)
|
s037011220
|
p03149
|
u367130284
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,064
| 286
|
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".
|
l="keyence"
i=input()
if l in i:
if i.find(l)==0 or i.find(l)==-7:
print("YES")
exit()
for s in range(1,7):
if (l[:s] in i) and (l[s:] in i):
if (i.find(l[:s]) < i.find(l[s:])) and i.find(l[:s])==0:
print("YES")
exit()
print("NO")
|
s781630289
|
Accepted
| 18
| 2,940
| 79
|
if len(set(input().split())&set("1974"))==4:
print("YES")
else:
print("NO")
|
s505824336
|
p03605
|
u366644013
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 77
|
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
|
n = input()
if n[0] == 9 or n[1] == 9:
print("Yes")
else:
print("No")
|
s973534237
|
Accepted
| 18
| 2,940
| 81
|
n = input()
if n[0] == "9" or n[1] == "9":
print("Yes")
else:
print("No")
|
s815569591
|
p04031
|
u606878291
| 2,000
| 262,144
|
Wrong Answer
| 34
| 5,076
| 479
|
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (iโ j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective.
|
import math
from decimal import Decimal, ROUND_HALF_UP
def quantize(f):
return int(Decimal(str(f)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
def check(n, numbers):
average = sum(numbers) / n
average = quantize(average)
costs = [int(math.pow(n - average, 2)) for n in numbers]
return sum(costs)
def main():
N = int(input())
numbers = map(int, input().split())
print(check(n=N, numbers=numbers))
if __name__ == '__main__':
main()
|
s708502311
|
Accepted
| 33
| 5,076
| 485
|
import math
from decimal import Decimal, ROUND_HALF_UP
def quantize(f):
return int(Decimal(str(f)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
def check(n, numbers):
average = sum(numbers) / n
average = quantize(average)
costs = [int(math.pow(n - average, 2)) for n in numbers]
return sum(costs)
def main():
N = int(input())
numbers = list(map(int, input().split()))
print(check(n=N, numbers=numbers))
if __name__ == '__main__':
main()
|
s071362886
|
p02612
|
u933341648
| 2,000
| 1,048,576
|
Wrong Answer
| 26
| 9,144
| 27
|
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)
|
s543815485
|
Accepted
| 28
| 9,152
| 63
|
n = int(input())
ans = (n + 999) // 1000 * 1000 - n
print(ans)
|
s649561203
|
p03469
|
u960171798
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 93
|
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.
|
S = list(map(int, input().split("/")))
S[0] = 2018
s = "/".join([str(n) for n in S])
print(s)
|
s774459461
|
Accepted
| 17
| 2,940
| 72
|
date = [n for n in input()]
date[3]="8"
date = "".join(date)
print(date)
|
s175861124
|
p03377
|
u427984570
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 74
|
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,c = map(int,input().split())
print("YES" if 0 <= a+b-c <= a else "NO")
|
s694554453
|
Accepted
| 17
| 2,940
| 75
|
a,b,c = map(int,input().split())
print("YES" if 0 <= c - a <= b else "NO")
|
s704831747
|
p03698
|
u339199690
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 90
|
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
l = list(input())
strlen = l.__len__()
"yes" if strlen == list(set(l)).__len__() else "no"
|
s648809695
|
Accepted
| 17
| 2,940
| 96
|
l = list(input())
strlen = l.__len__()
print("no" if strlen - list(set(l)).__len__() else "yes")
|
s889429682
|
p03624
|
u811528179
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,316
| 98
|
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
|
s=input()
print(s)
for i in range(97,97+26):
if chr(i) not in s:
exit()
print('None')
|
s995581731
|
Accepted
| 17
| 3,188
| 111
|
s=input()
for i in range(97,97+26):
if chr(i) not in s:
print(chr(i))
exit()
print('None')
|
s099786628
|
p03494
|
u696240348
| 2,000
| 262,144
|
Wrong Answer
| 149
| 12,388
| 196
|
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 numpy as np
a = np.array([int(x) for x in input().split()])
count = 0
x = 0
while x == 0:
if np.all(a%2 ==0):
count+=1
a = a/2
else:
break
print(count)
|
s151133935
|
Accepted
| 149
| 12,508
| 205
|
import numpy as np
n = input()
a = np.array([int(x) for x in input().split()])
count = 0
x = 0
while x == 0:
if np.all(a%2 ==0):
count+=1
a = a/2
else:
break
print(count)
|
s845326846
|
p02262
|
u464859367
| 6,000
| 131,072
|
Wrong Answer
| 20
| 5,672
| 619
|
Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i]) A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$. Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m โ 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements: * $1 \leq m \leq 100$ * $0 \leq G_i \leq n$ * cnt does not exceed $\lceil n^{1.5}\rceil$
|
import math
N = int(input())
A = [int(input()) for i in range(N)]
def ins_sort(a, n, g):
for i in range(g, n):
count = 0
v = a[i]
j = i - g
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j -= g
count += 1
a[j+g] = v
return count
def shell_sort(a, n):
cnt = 0
*g, = []
for i in range(int(math.sqrt(n)), 0, -1):
g.append(2**i - 1)
m = len(g)
for i in range(0, m):
cnt += ins_sort(a, n, g[i])
print(m)
print(*g)
print(cnt)
for i in range(len(a)):
print(a[i])
shell_sort(A, N)
|
s086138784
|
Accepted
| 18,200
| 45,476
| 651
|
N = int(input())
A = list(int(input()) for _ in range(N))
def ins_sort(a, n, g):
count = 0
for i in range(g, n):
v = a[i]
j = i - g
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j -= g
count += 1
a[j+g] = v
return count
def shell_sort(a, n):
cnt = 0
*g, = []
h = 0
for i in range(0, n):
h = h * 3 + 1
if h > n:
break
g.insert(0, h)
m = len(g)
for i in range(0, m):
cnt += ins_sort(a, n, g[i])
print(m)
print(*g)
print(cnt)
for i in range(len(a)):
print(a[i])
shell_sort(A, N)
|
s199202680
|
p02409
|
u426534722
| 1,000
| 131,072
|
Wrong Answer
| 30
| 6,028
| 334
|
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that โv persons left. Assume that initially no person lives in the building.
|
from collections import defaultdict
m = defaultdict(int)
n = int(input())
for _ in range(n):
b, f, r, v = map(int, input().split())
m[(b, f, r)] += v
for b in range(1, 5):
for f in range(1, 4):
for r in range(1, 11):
print("", m[(b, f, r)], end="")
print("")
print("####################")
|
s264029361
|
Accepted
| 30
| 6,032
| 352
|
from collections import defaultdict
m = defaultdict(int)
n = int(input())
for _ in range(n):
b, f, r, v = map(int, input().split())
m[(b, f, r)] += v
for b in range(1, 5):
for f in range(1, 4):
for r in range(1, 11):
print("", m[(b, f, r)], end="")
print("")
if b < 4:
print("####################")
|
s293379457
|
p03436
|
u298297089
| 2,000
| 262,144
|
Wrong Answer
| 26
| 3,444
| 897
|
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares. Before Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game. When the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares. The color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is `.`; if square (i, j) is initially painted by black, s_{i, j} is `#`.
|
from collections import deque
def bfs(grid, sy, sx, target, wall):
grid[sy][sx] = wall
queue = deque([])
queue.append([sy, sx, 0])
dxy = [(1,0), (-1,0), (0,1), (0,-1)]
while queue:
y,x,cnt = queue.popleft()
for dy, dx in dxy:
y_,x_ = y+dy,x+dx
if [y_, x_] == target:
return cnt+1
if grid[y_][x_] == wall:
continue
queue.append([y_,x_,cnt+1])
grid[y_][x_] = wall
return False
H,W = map(int, input().split())
edges = ['
grid = [edges]
white = 0
for i in range(H):
s = input()
grid.append(['#'])
for j in range(W):
grid[i+1].append(s[j])
white += 1 if s[j] == '.' else 0
grid[i+1].append('#')
grid.append(edges)
ans = bfs(grid, 1, 1, [H,W], '#')
if ans == -1:
print(ans)
else:
print(white - ans - 1)
|
s946520295
|
Accepted
| 24
| 3,316
| 797
|
from collections import deque
def bfs(grid, sy, sx, target, wall):
grid[sy][sx] = wall
queue = deque([])
queue.append([sy, sx, 1])
dxy = [(1,0), (-1,0), (0,1), (0,-1)]
while queue:
y,x,cnt = queue.popleft()
for dy, dx in dxy:
y_,x_ = y+dy,x+dx
if [y_, x_] == target:
return cnt+1
if grid[y_][x_] == wall:
continue
queue.append([y_,x_,cnt+1])
grid[y_][x_] = wall
return 0
H,W = map(int, input().split())
wall = '#'
edges = [wall] * (W+2)
grid = [edges]
b_cnt = 0
for i in range(H):
s = input()
grid.append([wall] + list(s) + [wall])
b_cnt += s.count(wall)
grid.append(edges)
cost = bfs(grid, 1,1, [H,W], wall)
print(H*W - b_cnt - cost if cost else -1)
|
s740372064
|
p03493
|
u788260274
| 2,000
| 262,144
|
Wrong Answer
| 26
| 8,856
| 145
|
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
from sys import stdin
a = stdin.readline().rstrip()
count = 0
print (a[0],a[1],a[2])
for b in a:
if b == "1": count = count + 1
print(count)
|
s081135998
|
Accepted
| 28
| 9,000
| 123
|
from sys import stdin
a = stdin.readline().rstrip()
count = 0
for b in a:
if b == "1": count = count + 1
print(count)
|
s872738348
|
p02694
|
u239653493
| 2,000
| 1,048,576
|
Wrong Answer
| 23
| 9,156
| 72
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
x=int(input())
k=100
t=0
while k<=x:
k=int(k*1.01)
t+=1
print(t)
|
s130909740
|
Accepted
| 26
| 9,152
| 71
|
x=int(input())
k=100
t=0
while k<x:
k=int(k*1.01)
t+=1
print(t)
|
s628315719
|
p03069
|
u910469029
| 2,000
| 1,048,576
|
Wrong Answer
| 119
| 7,784
| 747
|
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.
|
n = int(input())
s = input()
def counting_distance(s1, s2):
count = 0
for i in range(len(s1)):
if s1[i] != s2[i]:
count += 1
return count
white = s.count('.')
black = n - white
list_dist = []
s_changed = '.' * white + '#' * black
dist_tmp = counting_distance(s, s_changed)
list_dist.append(counting_distance(s, s_changed))
if black <= white:
for i in range(white, n):
if s[i] == s_changed[i]:
dist_tmp += 1
else:
dist_tmp -= 1
list_dist.append(dist_tmp)
else:
for i in reversed(range(0, white-1)):
if s[i] == s_changed[i]:
dist_tmp += 1
else:
dist_tmp -= 1
list_dist.append(dist_tmp)
print(min(list_dist))
|
s818800810
|
Accepted
| 104
| 11,496
| 262
|
n = int(input())
s = input()
count_list = []
black = 0
white = s.count('.')
count_list.append(white)
for i in range(n):
if s[i] == '#':
black += 1
if s[i] == '.':
white -= 1
count_list.append(black + white)
print(min(count_list))
|
s732054168
|
p02865
|
u785578220
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 33
|
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
|
a = int(input())
print(a//2-a%2)
|
s140407048
|
Accepted
| 19
| 2,940
| 39
|
a = int(input())
print(a//2-(a%2==0))
|
s175163180
|
p03607
|
u238510421
| 2,000
| 262,144
|
Wrong Answer
| 523
| 25,532
| 231
|
You are playing the following game with Joisino. * Initially, you have a blank sheet of paper. * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. * Then, you are asked a question: How many numbers are written on the sheet now? The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?
|
from collections import Counter
import numpy as np
n = int(input())
a_list = []
for _ in range(n):
a_list.append(int(input()))
counter = Counter(a_list)
count = list(counter.values())
ar = np.array(count)
ar = ar % 2
ar.sum()
|
s439140810
|
Accepted
| 347
| 25,296
| 238
|
from collections import Counter
import numpy as np
n = int(input())
a_list = []
for _ in range(n):
a_list.append(int(input()))
counter = Counter(a_list)
count = list(counter.values())
ar = np.array(count)
ar = ar % 2
print(ar.sum())
|
s442448983
|
p03815
|
u065099501
| 2,000
| 262,144
|
Wrong Answer
| 27
| 9,088
| 98
|
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7. Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation: * Operation: Rotate the die 90ยฐ toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward. For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back. Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
|
x = int(input())
ans = int(x/11*2)
tmp = x%11
if tmp > 6:
ans+=2
else:
ans+=1
print(ans)
|
s727389607
|
Accepted
| 27
| 9,164
| 106
|
x = int(input())
ans = int(x/11)*2
tmp = x%11
if tmp > 6:
ans+=2
elif tmp > 0:
ans+=1
print(ans)
|
s658762318
|
p02854
|
u301624971
| 2,000
| 1,048,576
|
Wrong Answer
| 92
| 26,024
| 658
|
Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be possible as is, so he will do the following operations some number of times **before** he does the cut: * Choose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan). * Choose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen. Find the minimum amount of money needed before cutting the bar into two parts with the same length.
|
def myAnswer(N:int,A:list) -> int:
total = 0
length = len(A)
if(length % 2 == 0):
length //= 2
total = max(sum(A[:length]),sum(A[length:])) - min(sum(A[:length]),sum(A[length:]))
return total
else:
length //= 2
print(A[:length],A[length+1:],A[length])
left = sum(A[:length])
right = sum(A[length+1:])
if(left == right):
return A[length]
elif(left < right):
return right
else:
return left
def modelAnswer():
tmp=1
def main():
N = int(input())
A = list(map(int,input().split()))
print(myAnswer(N,A[:]))
if __name__ == '__main__':
main()
|
s442134533
|
Accepted
| 215
| 33,704
| 870
|
from itertools import accumulate
def myAnswer(N:int,A:list) -> int:
accum = [A[0]]
accumRev = [sum(A)]
ans = 10**10
for i in range(1,N):
accumRev.append(accumRev[-1] - A[i-1])
accum.append(accum[-1]+A[i])
for i in range(len(accum)-1):
ans = min(ans,abs(accumRev[i+1] - accum[i]))
return ans
def modelAnswer(N:int,A:list) -> int:
T1 = [A[0]]
T2 = [sum(A)]
for i in range(1,N): # O(N)
T1.append(T1[-1]+A[i])
T2.append(T2[0] - T1[i-1])
# print(T1,T2)
ans = 10**10
for i in range(len(T1)-1): # O(N/2)
# print(abs(T1[i]-T2[i+1]))
ans = min(ans,abs(T1[i]-T2[i+1]))
return ans
def main():
N = int(input())
A = list(map(int,input().split()))
# print(modelAnswer(N,A[:]))
# print("-----------------------------")
print(myAnswer(N,A[:]))
if __name__ == '__main__':
main()
|
s128769190
|
p03371
|
u455696302
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 4,500
| 460
|
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
|
A,B,C,X,Y = map(int,input().split())
minValue = float('inf')
for x in range(X+1):
for y in range(Y+1):
total = A * x + B * y
if X > x or Y > y:
if X - x > Y - y:
total += 2 * (X - x) * C
Z = 2 * (X - x)
else:
total += 2 * (Y - y) * C
Z = 2 * (X - x)
if total < minValue:
minValue = total
print(X,Y,Z)
print(minValue)
|
s423071741
|
Accepted
| 116
| 2,940
| 221
|
A,B,C,X,Y = map(int,input().split())
minValue = float('inf')
for i in range(0,100001):
total = 2 * i * C + max([0,X-i]) * A + max([0,Y-i]) * B
if minValue > total:
minValue = total
print(minValue)
|
s903096721
|
p03625
|
u813450984
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 839
|
We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
|
N = map(int, input().split())
N = list(N)
def quickSort(list):
if len(list) < 2:
return list
pivot = list[0]
less = [item for item in list[1:] if item <= pivot]
greater = [item for item in list[1:] if item > pivot]
return quickSort(less) + [pivot] + quickSort(greater)
def findRect(list):
nums = quickSort(list)
nums.reverse()
count = 0
first = 0
second = 0
for index, num in enumerate(nums):
if index + 1 >= len(nums):
continue
elif nums[index] == nums[index + 1] and nums[index] >= 1:
count += 1
if count == 1:
first = nums[index]
elif count == 2:
second = nums[index]
print(first * second)
return
if count < 2:
print("0")
findRect(N)
|
s433668221
|
Accepted
| 110
| 14,244
| 418
|
n = int(input())
sticks = list(map(int, input().split()))
sticks.append(0)
sticks.sort()
sticks.reverse()
ans = []
def find(sticks):
for i in range(n):
if sticks[i] == sticks[i+1] == sticks[i+2] and not sticks[i+3] == sticks[i]:
continue
elif sticks[i] == sticks[i+1]:
ans.append(sticks[i])
if len(ans) <= 2:
ans.append(0)
ans.append(0)
return ans[0] * ans[1]
print(find(sticks))
|
s346949797
|
p03494
|
u437638594
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 231
|
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())
As = list(map(int, input().split()))
count = 0
for i in range(N):
tmp = As[i]
tmp_count = 0
while tmp % 2 == 0:
tmp = tmp // 2
tmp_count += 1
count = min(count, tmp_count)
print(count)
|
s160537916
|
Accepted
| 19
| 2,940
| 236
|
N = int(input())
As = list(map(int, input().split()))
count = 10 ** 9
for i in range(N):
tmp = As[i]
tmp_count = 0
while tmp % 2 == 0:
tmp = tmp // 2
tmp_count += 1
count = min(count, tmp_count)
print(count)
|
s590033560
|
p02743
|
u263753244
| 2,000
| 1,048,576
|
Wrong Answer
| 36
| 5,076
| 191
|
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
|
from decimal import Decimal
a,b,c=map(int,input().split())
A=Decimal(a)*Decimal("0.5")
B=Decimal(b)*Decimal("0.5")
C=Decimal(c)*Decimal("0.5")
if A+B<C:
print("Yes")
else:
print("No")
|
s566576899
|
Accepted
| 17
| 2,940
| 134
|
a,b,c=map(int,input().split())
x=a**2 + b**2 + c**2 - 2*a*b - 2*a*c - 2*b*c
if x>0 and a+b-c<0:
print("Yes")
else:
print("No")
|
s737032013
|
p00004
|
u982618289
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,320
| 117
|
Write a program which solve a simultaneous equation: ax + by = c dx + ey = f The program should print x and y for given a, b, c, d, e and f (-1,000 โค a, b, c, d, e, f โค 1,000). You can suppose that given equation has a unique solution.
|
a, b, c, d, e, f = map(float, input().split())
x = (e*c - b*f)/(e*a - b*d)
y = (c*d - f*a)/(d*b - e *a)
print(x,y)
|
s206277125
|
Accepted
| 30
| 7,356
| 268
|
while(True):
try:
a,b,c,d,e,f=map(float,input().split(" "))
z=a*e-b*d
if(z!=0):
x=(c*e-b*f)/z
y=(a*f-c*d)/z
print("{:.3f} {:.3f}".format(x+0,y+0))
except:
break
|
s039778089
|
p03680
|
u365156087
| 2,000
| 262,144
|
Wrong Answer
| 193
| 14,328
| 218
|
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.
|
N = int(input())
A = [int(input()) for i in range(N)]
print(A)
cnt = 1
now = 1
while True:
if now == A[1]:
print(cnt+1)
break
if (cnt > N):
print(-1)
break
now = A[now-1]
print(now)
cnt += 1
|
s684087388
|
Accepted
| 166
| 13,052
| 198
|
N = int(input())
V = [int(input()) for i in range(1,N+1)]
cnt = 1
val = V[0]
while True:
if val == 2:
print(cnt)
break
if (cnt >= N):
print(-1)
break
cnt += 1
val = V[val-1]
|
s312598297
|
p02936
|
u614314290
| 2,000
| 1,048,576
|
Wrong Answer
| 1,513
| 79,924
| 1,116
|
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations.
|
import sys
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
return int(n) - 1
def input():
return next(args)
def parse(*params):
if len(params) == 1:
return params[0](next(args))
return tuple(p(v) for p, v in zip(params, next(args).split()))
def debug(*v):
if __debug__:
print(*v, file=sys.stderr)
def main():
N, Q = parse(int, int)
edges = [[] for _ in range(N)]
for _ in range(N - 1):
a, b = parse(int1, int1)
edges[a] += [b]
vals = [0] * N
for _ in range(Q):
p, x = parse(int1, int)
vals[p] += x
sum_vals = [0] * N
que = [(0, 0)]
while que:
v, x = que.pop()
sum_vals[v] += x + vals[v]
for n in edges[v]:
que.append((n, sum_vals[v]))
for v in sum_vals:
print(v)
if __name__ == '__main__':
args = iter(sys.stdin.read().split("\n"))
main()
|
s647651051
|
Accepted
| 1,517
| 96,836
| 1,267
|
import sys
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
return int(n) - 1
def input():
return next(args)
def parse(*params):
if len(params) == 1:
return params[0](next(args))
return tuple(p(v) for p, v in zip(params, next(args).split()))
def debug(*v):
if __debug__:
print(*v, file=sys.stderr)
def main():
N, Q = parse(int, int)
edges = [[] for _ in range(N + 1)]
for _ in range(N - 1):
a, b = parse(int, int)
edges[a] += [b]
edges[b] += [a]
vals = [0] * (N + 1)
for _ in range(Q):
p, x = parse(int, int)
vals[p] += x
counter = [0] * (N + 1)
que = deque()
que.append((1, 0))
alr = [False] * (N + 1)
while que:
v, x = que.pop()
alr[v] = True
counter[v] += x + vals[v]
for n in edges[v]:
if not alr[n]:
que.append((n, counter[v]))
print(*counter[1:])
if __name__ == '__main__':
args = iter(sys.stdin.read().split("\n"))
main()
|
s766013909
|
p04044
|
u819300485
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 168
|
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1โฆiโฆmin(n,m)), such that s_j = t_j for all indices j(1โฆj<i), and s_i<t_i. * s_i = t_i for all integers i(1โฆiโฆmin(n,m)), and n<m.
|
import sys
n , l = map(int,input().split())
word = []
for i in range(n):
word.append(input())
sorted(word)
for i in range(n):
sys.stdout.write(word[i])
print()
|
s218970905
|
Accepted
| 18
| 3,060
| 168
|
import sys
n , l = map(int,input().split())
word = []
for i in range(n):
word.append(input())
word.sort()
for i in range(n):
sys.stdout.write(word[i])
print()
|
s928011184
|
p03139
|
u580004585
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,064
| 354
|
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.
|
i = input().split()
all = int(i[0])
x = int(i[1])
y = int(i[2])
t = 0
max = 0
if x > y:
max = x - abs(x - y)
t = x
elif y > x:
max = y - abs(x - y)
t = y
else:
t = all
max = x
min = 0
nx = all - x
ny = all - y
if nx > ny:
nt = nx
elif ny > nx:
nt = ny
else:
nt = 0
min = abs(t - nt)
print("{0} {1}".format(max,min))
|
s235267640
|
Accepted
| 17
| 3,064
| 383
|
i = input().split()
all = int(i[0])
x = int(i[1])
y = int(i[2])
t = 0
max = 0
if x > y:
max = x - abs(x - y)
t = x
elif y > x:
max = y - abs(x - y)
t = y
else:
t = x
max = x
min = 0
nx = all - x
ny = all - y
if nx > ny:
nt = nx
elif ny > nx:
nt = ny
else:
nt = nx
if t >= nt:
min = t - nt
else:
min = 0
print("{0} {1}".format(max,min))
|
s009827752
|
p02397
|
u227984374
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,608
| 122
|
Write a program which reads two integers x and y, and prints them in ascending order.
|
x, y = map(int, input().split())
if x < y :
x, y = y, x
print(x, y)
elif y < x :
print(x, y)
else :
pass
|
s172969363
|
Accepted
| 60
| 5,616
| 208
|
while True :
x, y = map(int, input().split())
if x == 0 and y == 0 :
break
else :
if x > y :
a, b = y, x
print(a, b)
else :
print(x, y)
|
s146366900
|
p02665
|
u127873832
| 2,000
| 1,048,576
|
Wrong Answer
| 765
| 680,660
| 722
|
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.
|
from itertools import accumulate
def main():
n = int(input())
A = list(map(int, input().split()))
if n == 0:
if A[0] == 1:
return 1
else:
return -1
elif A[0] != 0:
return -1
nodes = 0
bound = list(accumulate(A[::-1]))
bound.reverse()
# print('bound: ', bound)
above = [0] * (n+1)
above[0] = 1
B = [0] * (n+1)
for i, a in enumerate(A):
if i == 0:
B[0] = 1
else:
above[i] = (above[i-1] - A[i-1]) * 2
if above[i] < 0:
return -1
B[i] = min(above[i], bound[i])
return sum(B)
main()
|
s162253528
|
Accepted
| 95
| 22,140
| 677
|
def main():
n = int(input())
A = list(map(int, input().split()))
if n == 0:
if A[0] == 1:
return 1
else:
return -1
elif A[0] != 0:
return -1
bound = [0]*(n+1)
bound[n] = A[n]
for i in range(n-1, -1, -1):
bound[i] = bound[i+1] + A[i]
B = [0] * (n+1)
for i in range(n+1):
if i == 0:
B[i] = 1
else:
above = (B[i-1] - A[i-1]) * 2
if (i < n and above <= 0) or above < 0:
return -1
B[i] = min(above, bound[i])
if B[n] < A[n]:
return -1
return sum(B)
print(main())
|
s192639842
|
p03251
|
u350049649
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 159
|
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
if min(y)-max(x)>=2:
print('No War')
else:
print('War')
|
s854090216
|
Accepted
| 18
| 3,064
| 255
|
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
if max(x)<min(y) and X<Y:
if len(set(range(max(x)+1,min(y)+1))&set(range(X+1,Y+1)))>=1:
print('No War')
else:
print('War')
else:
print('War')
|
s932710561
|
p03456
|
u698919163
| 2,000
| 262,144
|
Wrong Answer
| 21
| 2,940
| 133
|
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
a,b = map(int,input().split())
for i in range(1,10001):
if i**2 == a*b:
print('Yes')
exit()
print('No')
|
s004616631
|
Accepted
| 17
| 3,064
| 169
|
a,b = map(str,input().split())
N = int(a+b)
import sys
for i in range(1,int(N**0.5)+1):
if i**2 == N:
print('Yes')
sys.exit()
print('No')
|
s728672009
|
p03455
|
u346098332
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 96
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
def keisan(a,b):
if a * b % 2 == 0:
print("Even")
else:
print("odd")
keisan(1,21)
|
s669198351
|
Accepted
| 17
| 2,940
| 65
|
a,b=map(int,input().split())
print("Even" if a*b%2==0 else "Odd")
|
s333304074
|
p02694
|
u882616665
| 2,000
| 1,048,576
|
Wrong Answer
| 32
| 9,224
| 109
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
x = int(input())
y = 0
z = 100
if x<=z:
pass
else:
while z<x:
y+=1
x = int((x*1.01)%1)
print(y)
|
s069998148
|
Accepted
| 30
| 9,124
| 88
|
x = int(input())
y = 0
z = 100
while z<x:
y+=1
z *= 101
z //= 100
print(y)
|
s257129286
|
p03964
|
u702582248
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,060
| 281
|
AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1โฆiโฆN) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.
|
n = int(input())
T = 1
A = 1
for _ in range(n):
t, a=map(int, input().split())
if T * a == t * A:
continue
if T % t != 0:
T += t - T % t
if A < T * a // t:
A = T * a // t
else:
A += a - A % a
T = A * t // a
print(A + T)
|
s505605173
|
Accepted
| 21
| 3,060
| 271
|
n = int(input())
T = 1
A = 1
for _ in range(n):
t, a = map(int, input().split())
m = max([T // t, A // a])
for i in range(1000):
i += m
if T <= t * i and A <= a * i:
T = t * i
A = a * i
break
print(A + T)
|
s912925707
|
p02646
|
u525213537
| 2,000
| 1,048,576
|
Wrong Answer
| 24
| 9,164
| 216
|
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, a = input().split()
B, b = input().split()
T = input()
A = int(A)
a = int(a)
B = int(B)
b = int(b)
T = int(T)
distance = abs(A-B)
speed = a-b
if distance - speed * T <= 0:
print("yes")
else:
print("no")
|
s326425785
|
Accepted
| 24
| 9,060
| 216
|
A, a = input().split()
B, b = input().split()
T = input()
A = int(A)
a = int(a)
B = int(B)
b = int(b)
T = int(T)
distance = abs(A-B)
speed = a-b
if distance - speed * T <= 0:
print("YES")
else:
print("NO")
|
s074079897
|
p03565
|
u445624660
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 1,067
|
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`.
|
sd, t = input(), input()
ans = ''
for i in range(len(sd) - len(t)+1):
target = sd[i:i+len(t)]
print("target= {}".format(target))
count = 0
for j in range(len(t)):
if t[j]==target[j] or target[j]=='?':
count+=1
else:
break
if count==len(t):
tmp = sd[:i]+t+sd[len(t)+i:]
print("tmp= {}".format(tmp))
if ans=='':
ans = ''.join(['a' if i=='?' else i for i in tmp])
else:
ans = min(ans, ''.join(['a' if i=='?' else i for i in tmp]))
print('UNRESTORABLE' if ans=='' else ans)
|
s735256270
|
Accepted
| 17
| 3,064
| 562
|
s, t = input(), input()
for i in range(len(s) - len(t), -1, -1):
tt = s[i : i + len(t)]
flag = True
for j in range(len(t)):
if tt[j] == t[j] or tt[j] == "?":
continue
else:
flag = False
if flag:
ans = list(s[:i] + t + s[i + len(t) :])
for k in range(len(s)):
if ans[k] == "?":
ans[k] = "a"
print("".join(ans))
exit()
print("UNRESTORABLE")
|
s958335627
|
p03196
|
u464574147
| 2,000
| 1,048,576
|
Wrong Answer
| 2,104
| 3,060
| 187
|
There are N integers a_1, a_2, ..., a_N not less than 1. The values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \times a_2 \times ... \times a_N = P. Find the maximum possible greatest common divisor of a_1, a_2, ..., a_N.
|
'''input
3 24
'''
import math
n, p = map(int, input().strip().split())
ans = 1
i = 2
while i * i <= p:
cnt = 0
while(p % i == 0):
cnt += 1
p /= i
ans = ans * pow(i, cnt)
print(ans)
|
s162503352
|
Accepted
| 247
| 3,064
| 220
|
'''input
1 5
'''
n, p = map(int, input().strip().split())
ans = 1
i = 2
while i * i <= p:
cnt = 0
while p % i == 0:
p //= i
cnt += 1
ans = ans * pow(i, cnt // n)
i += 1
ans = ans * (p if n == 1 else 1)
print(ans)
|
s308763882
|
p03563
|
u062484507
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 212
|
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
|
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
r, g = [int(readline()) for _ in range(2)]
ans = r + (g - r) * 2
print(r, (g - r), (g - r) * 2)
|
s158567882
|
Accepted
| 17
| 2,940
| 192
|
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
r, g = [int(readline()) for _ in range(2)]
ans = r + (g - r) * 2
print(ans)
|
s175535887
|
p03711
|
u178474644
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 347
|
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 โค x < y โค 12), determine whether they belong to the same group.
|
x = input()
ls_x = x.split()
print(ls_x)
for i in range(len(ls_x)):
ls_x[i] = int(ls_x[i])
gA = [1,3,5,7,8,10,12]
gB = [4,6,9,11]
if ls_x[0] == 2 or ls_x[1] == 2:
print("No")
if ls_x[0] == gA[i] and ls_x[1] == gA[i]:
print("Yes")
else:
print("No")
if ls_x[0] == gB[i] and ls_x[1] == gB[i]:
print("Yes")
else:
("No")
|
s406901687
|
Accepted
| 17
| 3,064
| 280
|
x, y = list(map(int, input().split()))
gA = [1,3,5,7,8,10,12]
gB = [4,6,9,11]
gC = [2]
def ok(x, y, group):
return (x in group) and (y in group)
if ok(x, y, gA):
print("Yes")
elif ok(x, y, gB):
print("Yes")
elif ok(x, y, gC):
print("Yes")
else:
print("No")
|
s438158753
|
p03545
|
u734805215
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 527
|
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
#A_list =list(map(int,input().split()))
A_list = [int(x) for x in list(input())]
OP_list = ["","",""]
#current = 1
def solve(current, current_sum):
if current == 4:
return current_sum == 7
if solve(current + 1 , current_sum + A_list[current]):
OP_list[current-1] = "+"
return True
if solve(current + 1 , current_sum - A_list[current]):
OP_list[current-1] = "-"
return True
return False
solve(1,A_list[0])
print (OP_list)
|
s795800566
|
Accepted
| 17
| 3,064
| 650
|
#A_list =list(map(int,input().split()))
A_list = [int(x) for x in list(input())]
OP_list = ["","",""]
answer = ""
#current = 1
def solve(current, current_sum):
if current == 4:
return current_sum == 7
if solve(current + 1 , current_sum + A_list[current]):
OP_list[current-1] = "+"
return True
if solve(current + 1 , current_sum - A_list[current]):
OP_list[current-1] = "-"
return True
return False
solve(1,A_list[0])
answer = str(A_list[0]) + OP_list[0] + str(A_list[1]) + OP_list[1] + str(A_list[2]) + OP_list[2] + str(A_list[3]) + "=7"
print (answer)
|
s346058438
|
p03563
|
u174273188
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 123
|
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
|
def resolve():
r = int(input())
g = int(input())
print((g - r) * 2)
if __name__ == "__main__":
resolve()
|
s771002915
|
Accepted
| 21
| 3,316
| 121
|
def resolve():
r = int(input())
g = int(input())
print(2 * g - r)
if __name__ == "__main__":
resolve()
|
s654892869
|
p03377
|
u663014688
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 124
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
A,B,X = map(int,input().split())
if A < X:
print('No')
exit()
if A + B < X:
print('No')
exit()
print('Yes')
|
s434102337
|
Accepted
| 17
| 2,940
| 126
|
A,B,X = map(int,input().split())
if A > X:
print('NO')
exit()
if A + B < X:
print('NO')
exit()
print('YES')
|
s400429248
|
p04043
|
u296518383
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 97
|
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(lambda x: len(x),list(input().split())))
a.sort()
print("YES" if a==[5,5,7] else "NO")
|
s180982877
|
Accepted
| 17
| 2,940
| 78
|
a=list(map(int,input().split()))
a.sort()
print("YES" if a==[5,5,7] else "NO")
|
s614120886
|
p03455
|
u856957183
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 131
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
# coding: utf-8
# Your code here!
list_a = input().split()
print("Even") if (int(list_a[0])+int(list_a[1]))%2==0 else print("Odd")
|
s965733937
|
Accepted
| 17
| 2,940
| 131
|
# coding: utf-8
# Your code here!
list_a = input().split()
print("Even") if (int(list_a[0])*int(list_a[1]))%2==0 else print("Odd")
|
s438459100
|
p03493
|
u031543925
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 28
|
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
m = int(input().count('1'))
|
s866203391
|
Accepted
| 17
| 2,940
| 26
|
print(input().count('1'))
|
s420470789
|
p01554
|
u187648898
| 2,000
| 131,072
|
Wrong Answer
| 20
| 5,604
| 315
|
ใใ้จๅฑใงใฏICใซใผใใ็จใใฆ้ตใ้ใ้ใใใ้ปๅญ้ ใทในใใ ใ็จใใฆใใใ ใใฎใทในใใ ใฏไปฅไธใฎใใใซๅไฝใใใ ๅใฆใผใถใผใๆใคICใซใผใใๆใซใใใใจใใใฎICใซใผใใฎIDใใทในใใ ใซๆธกใใใใ ใทในใใ ใฏIDใ็ป้ฒใใใฆใใๆใๆฝ้ ใใใฆใใใชใ้้ ใใใใใงใชใใฎใชใๆฝ้ ใใใใใใใกใใปใผใธใๅบๅใใใใ IDใ็ป้ฒใใใฆใใชใๅ ดๅใฏใ็ป้ฒใใใฆใใชใใจใใใกใใปใผใธใๅบๅใใ้้ ๅใณๆฝ้ ใฏใใใชใใใชใใ ใใฆใ็พๅจใทในใใ ใซใฏNๅใฎID(U1, U2, โฆโฆ, UN)ใ็ป้ฒใใใฆใใใๆฝ้ ใใใฆใใใ MๅICใซใผใใๆใซใใใใใใใฎIDใฏใใใใ้ ็ชใซT1, T2, โฆโฆ, TMใงใใใจใใใ ใใฎๆใฎใทในใใ ใใฉใฎใใใชใกใใปใผใธใๅบๅใใใๆฑใใใ
|
N = int(input())
U = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]
opened = False
for T_i in T:
if T_i in U:
if opened == True:
print('Closed by ' + T_i)
opened = False
else:
print('Opened by ' + T_i)
opened = True
|
s691972696
|
Accepted
| 20
| 5,640
| 357
|
N = int(input())
U = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]
opened = False
for T_i in T:
if T_i in U:
if opened == True:
print('Closed by ' + T_i)
opened = False
else:
print('Opened by ' + T_i)
opened = True
else:
print('Unknown ' + T_i)
|
s792762218
|
p02678
|
u756607246
| 2,000
| 1,048,576
|
Wrong Answer
| 602
| 64,168
| 857
|
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
from itertools import dropwhile, takewhile
def main():
N, M = list(map(int, input().split()))
lis = [list(map(int, input().split())) for _ in range(M)]
#print(lis)
edge = [[] for _ in range(N+1)]
#print(edge)
for a,b in lis:
edge[a].append(b)
edge[b].append(a)
#print(edge)
ans = [0] * (N+1)
visited = {0}
stack = [1]
for i in stack:
for j in edge[i]:
if j in visited:
continue
stack.append(j)
#print(stack)
visited.add(j)
#print(visited)
ans[j]=i
print("Yes")
for k in ans[2:]:
print(k)
if __name__ == '__main__':
#start = time.time()
print(main())
#elapsed_time = time.time() - start
|
s437519415
|
Accepted
| 595
| 64,004
| 850
|
from itertools import dropwhile, takewhile
def main():
N, M = list(map(int, input().split()))
lis = [list(map(int, input().split())) for _ in range(M)]
#print(lis)
edge = [[] for _ in range(N+1)]
#print(edge)
for a,b in lis:
edge[a].append(b)
edge[b].append(a)
#print(edge)
ans = [0] * (N+1)
visited = {0}
stack = [1]
for i in stack:
for j in edge[i]:
if j in visited:
continue
stack.append(j)
#print(stack)
visited.add(j)
#print(visited)
ans[j]=i
print("Yes")
for k in ans[2:]:
print(k)
if __name__ == '__main__':
#start = time.time()
main()
#elapsed_time = time.time() - start
|
s843875014
|
p02928
|
u363315718
| 2,000
| 1,048,576
|
Wrong Answer
| 525
| 3,188
| 786
|
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 sys
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI():
return list(map(int, sys.stdin.readline().split()))
def II():
return int(sys.stdin.readline())
def LS():
return list(map(list, sys.stdin.readline().split()))
def S():
return sys.stdin.readline()[:-1]
def main():
n, k = LI()
a_s = LI()
ts = [0 for i in range(n)]
f_ts = [0 for i in range(n)]
for i in range(n):
for j in range(n):
if a_s[j] < a_s[i]:
ts[i] += 1
if j > i:
f_ts[i] += 1
sum_f = sum(f_ts)
sum_ = sum(ts)
print(f_ts, sum_f)
print(ts, sum_)
ans = (2 * (sum_f) + sum_ * (k - 1)) * k / 2 % MOD
print(int(ans))
if __name__ == "__main__":
main()
|
s871117197
|
Accepted
| 530
| 3,188
| 893
|
import sys
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI():
return list(map(int, sys.stdin.readline().split()))
def II():
return int(sys.stdin.readline())
def LS():
return list(map(list, sys.stdin.readline().split()))
def S():
return sys.stdin.readline()[:-1]
def main():
n, k = LI()
a_s = LI()
ts = [0 for i in range(n)]
f_ts = [0 for i in range(n)]
for i in range(n):
for j in range(n):
if a_s[j] < a_s[i]:
ts[i] += 1
if j > i:
f_ts[i] += 1
sum_f = sum(f_ts)
sum_ = sum(ts)
if (k - 1) % 2 == 0:
ans = (sum_f + int(sum_ * (k - 1) / 2)) % MOD
print(int(ans) % MOD * k % MOD)
else:
ans = 2 * sum_f + sum_ * (k - 1) % MOD
print(int(ans) % MOD * int(k / 2) % MOD)
if __name__ == "__main__":
main()
|
s012298457
|
p03415
|
u508273185
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 64
|
We have a 3ร3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.
|
c1 = input()
c2 = input()
c3 = input()
print(c1[0]+c2[1]+c2[2])
|
s141596240
|
Accepted
| 17
| 2,940
| 64
|
c1 = input()
c2 = input()
c3 = input()
print(c1[0]+c2[1]+c3[2])
|
s387253773
|
p03693
|
u439312138
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 107
|
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
r,g,b = map(str,input().split())
S = r + g + b
if int(S) // 4 == 0:
print("YES")
else:
print("NO")
|
s020051116
|
Accepted
| 17
| 2,940
| 103
|
r,g,b = map(str,input().split())
S = r + g + b
if int(S) % 4 == 0:
print("YES")
else:
print("NO")
|
s817354338
|
p03997
|
u696805736
| 2,000
| 262,144
|
Wrong Answer
| 39
| 3,064
| 61
|
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)
|
s680457630
|
Accepted
| 38
| 3,064
| 63
|
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h//2)
|
s609124909
|
p03699
|
u305965165
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 221
|
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
|
n = int(input())
a = [int(input()) for i in range(n)]
res = sum(a)
if res%10 !=0:
print(res)
exit()
b = sorted(list(filter(lambda x:x%10!=0, a)))
if len(b) == 0:
print(0)
exit()
print(b)
print(res-b[0])
|
s152856109
|
Accepted
| 17
| 3,060
| 212
|
n = int(input())
a = [int(input()) for i in range(n)]
res = sum(a)
if res%10 !=0:
print(res)
exit()
b = sorted(list(filter(lambda x:x%10!=0, a)))
if len(b) == 0:
print(0)
exit()
print(res-b[0])
|
s983519495
|
p02694
|
u873776333
| 2,000
| 1,048,576
|
Wrong Answer
| 21
| 9,160
| 113
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
from math import floor
X = int(input())
m = 100
d = 0
while m <= X:
d += 1
m = floor(m * 1.01)
print(d)
|
s197008908
|
Accepted
| 23
| 9,156
| 112
|
from math import floor
X = int(input())
m = 100
d = 0
while m < X:
d += 1
m = floor(m * 1.01)
print(d)
|
s900416274
|
p03720
|
u590905793
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 175
|
There are N cities and M roads. The i-th road (1โคiโคM) connects two cities a_i and b_i (1โคa_i,b_iโคN) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
|
n,m = map(int,input().split())
road = []
for i in range(m):
a,b = [int(i) for i in input().split()]
road.append([a,b])
for j in range(n):
print (road.count(n-1))
|
s479933282
|
Accepted
| 17
| 3,060
| 212
|
n,m = map(int,input().split())
road = []
for i in range(m):
a,b = [int(i) for i in input().split()]
road.append([a,b])
road = sum(road,[])
#print(road)
for j in range(n):
print (road.count(j+1))
|
s941376434
|
p03486
|
u466478199
| 2,000
| 262,144
|
Wrong Answer
| 89
| 4,848
| 129
|
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
import random
s=list(input())
t=list(input())
random.shuffle(s)
random.shuffle(t)
k=[''.join(s),''.join(t)]
k.sort()
print(k[0])
|
s442096403
|
Accepted
| 17
| 3,060
| 180
|
s=list(input())
t=list(input())
S=''.join(sorted(s))
T=''.join(sorted(t)[::-1])
L=sorted([S,T])
if S==T:
print('No')
else:
if L[0]==S:
print('Yes')
else:
print('No')
|
s976480172
|
p02646
|
u377834804
| 2,000
| 1,048,576
|
Wrong Answer
| 24
| 9,196
| 321
|
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
import sys
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
if A == B:
print('YES')
sys.exit()
elif A < B:
T = -T
posA = A + V*T
posB = B + W*T
if T >= 0:
if posA < posB:
print('YES')
else:
print('NO')
else:
if posA > posB:
print('YES')
else:
print('NO')
|
s393317460
|
Accepted
| 23
| 9,184
| 273
|
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
if A > B:
T = -T
posA = A + V*T
posB = B + W*T
if T <= 0:
if posA <= posB:
print('YES')
else:
print('NO')
else:
if posA >= posB:
print('YES')
else:
print('NO')
|
s095619844
|
p04029
|
u428855582
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 210
|
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?
|
answer =[]
for letter in input():
if letter=="1":
answer.append("1")
elif letter=="0":
answer.append("0")
elif letter=="B" and len(answer)>0:
answer.pop()
print("".join(answer))
|
s333666436
|
Accepted
| 17
| 2,940
| 49
|
print(sum([n for n in range(1, int(input())+1)]))
|
s819672172
|
p02608
|
u761087127
| 2,000
| 1,048,576
|
Wrong Answer
| 888
| 9,528
| 302
|
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 = [0 for _ in range(N+1)]
for x in range(1, int(N**0.5)+1):
for y in range(1, int(N**0.5)+1):
for z in range(1, int(N**0.5)+1):
v = x**2+y**2+z**2+x*y+y*z+z*x
if v<N:
ans[v] += 1
print(ans)
for i in range(N):
print(ans[i+1])
|
s298121094
|
Accepted
| 829
| 9,192
| 267
|
N = int(input())
ans = [0 for _ in range(10001)]
for x in range(1, 101):
for y in range(1, 101):
for z in range(1, 101):
v = x**2+y**2+z**2+x*y+y*z+z*x
if v<10001:
ans[v] += 1
for i in range(N):
print(ans[i+1])
|
s199847765
|
p02398
|
u890164142
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,636
| 96
|
Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.
|
a, b, c = [int(w) for w in input().split()]
print(len([i for i in range(a, b+1) if i % c == 0]))
|
s692824965
|
Accepted
| 20
| 7,728
| 96
|
a, b, c = [int(w) for w in input().split()]
print(len([i for i in range(a, b+1) if c % i == 0]))
|
s417269203
|
p02396
|
u563075864
| 1,000
| 131,072
|
Wrong Answer
| 190
| 5,604
| 153
|
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.
|
count = 1
while(1):
try:
n = int(input())
print("Case {}: {}".format(count,n))
count += 1
except EOFError:
break
|
s986779085
|
Accepted
| 150
| 5,604
| 126
|
count = 1
while(1):
n = int(input())
if n == 0:
break
print("Case {}: {}".format(count,n))
count += 1
|
s422147342
|
p02612
|
u940426302
| 2,000
| 1,048,576
|
Wrong Answer
| 28
| 9,072
| 40
|
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input())
print(n-1000*(n//1000))
|
s037296317
|
Accepted
| 26
| 9,116
| 68
|
n = int(input())
if n % 1000 == 0: print(0)
else:print(1000-n%1000)
|
s840298351
|
p03385
|
u903596281
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 74
|
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
S=input()
print("Yes" if S[0]==S[1] or S[0]==S[2] or S[1]==S[2] else "No")
|
s604631466
|
Accepted
| 18
| 2,940
| 74
|
S=input()
print("No" if S[0]==S[1] or S[0]==S[2] or S[1]==S[2] else "Yes")
|
s392363267
|
p03408
|
u974935538
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 273
|
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
|
N = int(input())
li1 = [input() for _ in range(N)]
li1.sort()
M = int(input())
li2 = [input() for _ in range(M)]
li2.sort()
temp = 0
for i in li1:
for j in li2:
if i == j:
temp -=1
elif i!=j:
temp +=1
ans = 0
print(max(ans,temp))
|
s482483541
|
Accepted
| 17
| 3,060
| 201
|
N = int(input())
li1 = [input() for _ in range(N)]
M = int(input())
li2 = [input() for _ in range(M)]
ans = 0
for i in set(li1):
tmp = li1.count(i) - li2.count(i)
ans = max(ans, tmp)
print(ans)
|
s562817179
|
p04029
|
u027977105
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 41
|
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
N = int(input())
a = 1/2*N*(N+1)
print(a)
|
s393157875
|
Accepted
| 17
| 2,940
| 46
|
N = int(input())
a = 1/2*N*(N+1)
print(int(a))
|
s442441198
|
p04029
|
u097700948
| 2,000
| 262,144
|
Wrong Answer
| 25
| 9,144
| 44
|
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())
ans = N*(N+1)/2
print(ans)
|
s984738100
|
Accepted
| 27
| 9,088
| 50
|
N = int(input())
ans = int(N*(N+1)/2)
print(ans)
|
s354672631
|
p03090
|
u163783894
| 2,000
| 1,048,576
|
Wrong Answer
| 30
| 9,408
| 916
|
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved that at least one such graph exists under the constraints of this problem.
|
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())
def main():
N = in_n()
ans = []
for i in range(1, N + 1):
for j in range(i + 1, N + 1):
if N % 2 == 0:
if i + j != N + 1:
ans.append((i, j))
else:
if i + j != N:
ans.append((i, j))
print('\n'.join(map(lambda a: '{} {}'.format(a[0], a[1]), ans)))
if __name__ == '__main__':
main()
|
s171873651
|
Accepted
| 26
| 9,580
| 936
|
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())
def main():
N = in_n()
ans = []
for i in range(1, N + 1):
for j in range(i + 1, N + 1):
if N % 2 == 0:
if i + j != N + 1:
ans.append((i, j))
else:
if i + j != N:
ans.append((i, j))
print(len(ans))
print('\n'.join(map(lambda a: '{} {}'.format(a[0], a[1]), ans)))
if __name__ == '__main__':
main()
|
s458311507
|
p03386
|
u188827677
| 2,000
| 262,144
|
Wrong Answer
| 2,205
| 9,104
| 107
|
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())
for i in range(a,b+1):
if i <= a+k: print(i)
elif b-k <= i: print(i)
|
s047492702
|
Accepted
| 27
| 9,136
| 164
|
a,b,k = map(int, input().split())
if b-a+1 > 2*k:
for i in range(a,a+k): print(i)
for i in range(b-k+1,b+1): print(i)
else:
for i in range(a,b+1): print(i)
|
s654721703
|
p03543
|
u672898046
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 63
|
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**?
|
i = input()
if i[-1]!=i[-2]:
print("No")
else:
print("Yes")
|
s828640213
|
Accepted
| 17
| 3,060
| 124
|
i = input()
if i[1]==i[2] and i[2]==i[-1]:
print("Yes")
elif i[0]==i[1] and i[1]==i[2]:
print("Yes")
else:
print("No")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.