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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s421109137
|
p03080
|
u077141270
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 147
|
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
|
from sys import stdin
N= int(input())
l = input()
print(l.count("R"))
if N - l.count("R") < l.count("R"):
print("Yes")
else:
print("No")
|
s368846215
|
Accepted
| 17
| 2,940
| 123
|
from sys import stdin
N= int(input())
l = input()
if l.count("B") < l.count("R"):
print("Yes")
else:
print("No")
|
s495256648
|
p03943
|
u369212307
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 124
|
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.
|
pack = [int(i) for i in input().split()]
pack.sort()
if pack[2] == pack[0] + pack[1]:
print("YES")
else:
print("NO")
|
s213106841
|
Accepted
| 17
| 2,940
| 124
|
pack = [int(i) for i in input().split()]
pack.sort()
if pack[2] == pack[0] + pack[1]:
print("Yes")
else:
print("No")
|
s654216560
|
p03644
|
u586577600
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 60
|
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())
ans = 1
while ans <= n: ans *= 2
print(ans)
|
s591828559
|
Accepted
| 18
| 2,940
| 64
|
n = int(input())
ans = 1
while ans <= n: ans *= 2
print(ans//2)
|
s905032383
|
p03474
|
u175590965
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 123
|
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
|
a,b = map(int,input().split())
s = str(input())
if s.count('_') == 1 and s[a]== '_':
print("Yes")
else:
print("No")
|
s057931615
|
Accepted
| 17
| 2,940
| 123
|
a,b = map(int,input().split())
s = str(input())
if s.count('-') == 1 and s[a]== '-':
print("Yes")
else:
print("No")
|
s844036134
|
p02614
|
u139132412
| 1,000
| 1,048,576
|
Wrong Answer
| 56
| 9,072
| 283
|
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
|
h, w, k = map(int, input().split())
grid = [input() for _ in range(h)]
ans = 0
for i in range(1<<h):
for j in range(1<<w):
count = 0
for x in range(h):
for y in range(w):
if grid[x][y] == '#':
count += 1
if count == k:
ans += 1
print(ans)
|
s669796718
|
Accepted
| 42
| 9,124
| 459
|
def main():
h, w, k = map(int, input().split())
C = [list(input()) for _ in range(h)]
result = 0
for i in range(1 << h):
for j in range(1 << w):
cnt = 0
for n in range(h):
if i >> n & 1:
continue
for m in range(w):
if j >> m & 1:
continue
if C[n][m] == '#':
cnt += 1
if cnt == k:
result += 1
print(result)
if __name__ == "__main__":
main()
|
s075534129
|
p03711
|
u941438707
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 139
|
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
|
x,y=input().split()
a=(1,3,5,7,8,10,12)
b=(4,6,9,11)
if (x in a and y in a) and (x in b and y in b):
print("Yes")
else:
print("No")
|
s075673494
|
Accepted
| 18
| 3,060
| 152
|
x,y = map(int,input().split(" "))
a=(1,3,5,7,8,10,12)
b=(4,6,9,11)
if (x in a and y in a) or (x in b and y in b):
print("Yes")
else:
print("No")
|
s893488570
|
p02612
|
u040298438
| 2,000
| 1,048,576
|
Wrong Answer
| 30
| 9,144
| 32
|
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input())
print(n % 1000)
|
s008332373
|
Accepted
| 27
| 9,160
| 80
|
n = int(input())
if n % 1000 == 0:
print(0)
else:
print(1000 - n % 1000)
|
s240367558
|
p03470
|
u735008991
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 56
|
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
print(set([int(input()) for i in range(int(input())) ]))
|
s748564931
|
Accepted
| 20
| 3,316
| 61
|
print(len(set([int(input()) for i in range(int(input())) ])))
|
s525769243
|
p03657
|
u819710930
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 91
|
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
|
a,b=map(int,input().split())
print('Impossible' if (a%3 or b%3 or (a+b)%3) else 'Possible')
|
s020456228
|
Accepted
| 17
| 2,940
| 91
|
a,b=map(int,input().split())
print('Impossible' if a%3 and b%3 and (a+b)%3 else 'Possible')
|
s339282439
|
p03130
|
u670180528
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 73
|
There are four towns, numbered 1,2,3 and 4. Also, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally. No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads. Determine if we can visit all the towns by traversing each of the roads exactly once.
|
I=input;s=I()+I()+I();print("YNEOS"[any(s.count(x)>1for x in "1234")::2])
|
s992310088
|
Accepted
| 17
| 2,940
| 72
|
I=input;s=I()+I()+I();print("YNEOS"[any(s.count(x)>2for x in"1234")::2])
|
s512986206
|
p03854
|
u668503853
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,188
| 129
|
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`.
|
if input().replace("dream","").replace("dreamer","").replace("erase","").replace("eraser",""):
print("YES")
else:
print("NO")
|
s580515564
|
Accepted
| 19
| 3,188
| 124
|
s=input().replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
print("YES" if s=="" else "NO")
|
s185134908
|
p02678
|
u333139319
| 2,000
| 1,048,576
|
Wrong Answer
| 2,206
| 39,572
| 736
|
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.
|
import collections
[n,m] = [int(i) for i in input().split()]
def BFS(s,G,num):
ls = []
check = [0] * num
marker = [-1] * num
check[0] = 1
ls += G[s]
for i in G[s]:
marker[i] = s
while(len(ls)):
now = ls.pop(0)
if check[now] == 1:
continue
else:
#print(now)
check[now] = 1
ls += G[now]
for i in G[now]:
if marker[i] == -1:
marker[i] = now
return marker
dic = collections.defaultdict(list)
for i in range(m):
[a,b] = [int(i)-1 for i in input().split()]
dic[a].append(b)
dic[b].append(a)
ans = BFS(0,dic,n)
for i in range(1,n):
print("Yes")
print(ans[i]+1)
|
s862960989
|
Accepted
| 881
| 39,420
| 753
|
import collections
[n,m] = [int(i) for i in input().split()]
def BFS(s,G,num):
ls = collections.deque()
check = [0] * num
marker = [-1] * num
check[0] = 1
ls += G[s]
for i in G[s]:
marker[i] = s
while(len(ls)):
now = ls.popleft()
if check[now] == 1:
continue
else:
#print(now)
check[now] = 1
ls += G[now]
for i in G[now]:
if marker[i] == -1:
marker[i] = now
return marker
dic = collections.defaultdict(list)
for i in range(m):
[a,b] = [int(i)-1 for i in input().split()]
dic[a].append(b)
dic[b].append(a)
ans = BFS(0,dic,n)
print("Yes")
for i in range(1,n):
print(ans[i]+1)
|
s495326951
|
p02393
|
u597483031
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,576
| 98
|
Write a program which reads three integers, and prints them in ascending order.
|
target_list=map(int,input().split())
arrangement_list=sorted(target_list)
print(arrangement_list)
|
s865997558
|
Accepted
| 20
| 5,540
| 32
|
print(*sorted(input().split()))
|
s505445243
|
p02408
|
u804558166
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,596
| 244
|
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.
|
n=int(input())
cards = {}
for i in range(n):
card=input()
cards[card]=1
for c in ['S', 'H', 'C', 'D']:
for n in range(1, 14):
key = c+' '+ str(n)
if not key in cards:
print(key)
|
s525537714
|
Accepted
| 20
| 5,596
| 244
|
n=int(input())
cards = {}
for i in range(n):
card=input()
cards[card]=1
for c in ['S', 'H', 'C', 'D']:
for n in range(1, 14):
key = c+' '+ str(n)
if not key in cards:
print(key)
|
s911958970
|
p02606
|
u643861155
| 2,000
| 1,048,576
|
Wrong Answer
| 29
| 9,080
| 123
|
How many multiples of d are there among the integers between L and R (inclusive)?
|
def A_Q(L,R,d):
count = 0
for num in range(L,R+1):
if num % d == 0:
count += 1
return count
|
s678502879
|
Accepted
| 29
| 9,156
| 129
|
li = list(map(int,input().split()))
count = 0
for num in range(li[0],li[1]+1):
if num % li[2] == 0:
count += 1
print(count)
|
s205112043
|
p04029
|
u271176141
| 2,000
| 262,144
|
Wrong Answer
| 24
| 9,084
| 125
|
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?
|
child_num = input("子供の数")
child_num = int(child_num)
candy_num = int((child_num**2 + child_num) / 2)
print(candy_num)
|
s164790954
|
Accepted
| 24
| 9,088
| 113
|
child_num = int(input())
candy_num = int((child_num**2 + child_num) / 2)
print(candy_num)
|
s691664023
|
p03759
|
u710398282
| 2,000
| 262,144
|
Wrong Answer
| 25
| 9,064
| 114
|
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
a, b, c = map(int, input().split())
d1 = b - a
d2 = c - b
if (d1 == d2):
print("Yes")
else:
print("No")
|
s891903918
|
Accepted
| 30
| 9,096
| 114
|
a, b, c = map(int, input().split())
d1 = b - a
d2 = c - b
if (d1 == d2):
print("YES")
else:
print("NO")
|
s178110146
|
p03150
|
u314188085
| 2,000
| 1,048,576
|
Wrong Answer
| 27
| 8,992
| 170
|
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
|
S = input()
k = 'keyence'
Srev = S[::-1]
krev = k[::-1]
ans = 'No'
for i in range(8):
if S[:i]==k[:i] and Srev[:(7-i)]==krev[:(7-i)]:
ans = 'Yes'
print(ans)
|
s351137488
|
Accepted
| 30
| 8,912
| 170
|
S = input()
k = 'keyence'
Srev = S[::-1]
krev = k[::-1]
ans = 'NO'
for i in range(8):
if S[:i]==k[:i] and Srev[:(7-i)]==krev[:(7-i)]:
ans = 'YES'
print(ans)
|
s965512846
|
p03798
|
u893063840
| 2,000
| 262,144
|
Wrong Answer
| 152
| 7,808
| 702
|
Snuke, who loves animals, built a zoo. There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1. There are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies. Snuke cannot tell the difference between these two species, and asked each animal the following question: "Are your neighbors of the same species?" The animal numbered i answered s_i. Here, if s_i is `o`, the animal said that the two neighboring animals are of the same species, and if s_i is `x`, the animal said that the two neighboring animals are of different species. More formally, a sheep answered `o` if the two neighboring animals are both sheep or both wolves, and answered `x` otherwise. Similarly, a wolf answered `x` if the two neighboring animals are both sheep or both wolves, and answered `o` otherwise. Snuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print `-1`.
|
from itertools import permutations
n = int(input())
s = input()
bl = False
for ef, el in permutations([1, -1], 2):
zoo = [0] * n
zoo[0] = ef
zoo[-1] = el
for i, e in enumerate(s):
if e == "o":
if zoo[i] == 1:
nxt = zoo[i-1]
else:
nxt = -zoo[i-1]
else:
if zoo[i] == 1:
nxt = -zoo[i-1]
else:
nxt = zoo[i-1]
if i < n - 1:
zoo[i+1] = nxt
elif nxt == zoo[0]:
bl = True
break
if bl:
break
if bl:
ans = ["S" if e == 1 else "W" for e in zoo]
print(*ans, sep="")
else:
print(-1)
|
s118130979
|
Accepted
| 250
| 8,400
| 696
|
from itertools import product
n = int(input())
s = input()
bl = False
for ef, el in product([1, -1], repeat=2):
zoo = [0] * n
zoo[0] = ef
zoo[-1] = el
for i, e in enumerate(s):
if e == "o":
if zoo[i] == 1:
nxt = zoo[i-1]
else:
nxt = -zoo[i-1]
else:
if zoo[i] == 1:
nxt = -zoo[i-1]
else:
nxt = zoo[i-1]
if i < n - 2:
zoo[i+1] = nxt
elif nxt != zoo[(i+1)%n]:
break
else:
bl = True
break
if bl:
ans = ["S" if e == 1 else "W" for e in zoo]
print(*ans, sep="")
else:
print(-1)
|
s217250341
|
p02645
|
u909359131
| 2,000
| 1,048,576
|
Wrong Answer
| 20
| 9,016
| 37
|
When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him.
|
def adana(text):
return text[0:3]
|
s483341221
|
Accepted
| 21
| 9,028
| 25
|
S = input()
print(S[0:3])
|
s705219295
|
p02646
|
u087414215
| 2,000
| 1,048,576
|
Wrong Answer
| 22
| 9,192
| 241
|
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
dis = abs(a-b)
vdis = v-w
if vdis<=0:
print("no")
exit()
print(dis)
print(vdis)
time = dis/vdis
print(time)
if time <= t:
print("yes")
else:
print("no")
|
s607248907
|
Accepted
| 23
| 9,032
| 206
|
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
if v<=w:
print("NO")
exit()
dis = abs(a-b)
vdis = v-w
time = dis/vdis
if time <= t:
print("YES")
else:
print("NO")
|
s794623647
|
p03485
|
u439312138
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 46
|
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
x,y = map(int,input().split())
print(int(x*y))
|
s861046979
|
Accepted
| 18
| 2,940
| 57
|
x,y = map(int,input().split())
print(( x + y + 1 ) // 2)
|
s448334766
|
p03455
|
u311669106
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 84
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a,b=map(int,input().split())
if (a+b)%2==0:
print("Even")
else:
print("Odd")
|
s927503132
|
Accepted
| 20
| 3,316
| 86
|
a,b=map(int,input().split())
c=a*b
if c%2==0:
print("Even")
else:
print("Odd")
|
s132409342
|
p02396
|
u556326323
| 1,000
| 131,072
|
Wrong Answer
| 130
| 7,332
| 119
|
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
|
for i in range(1, 10000):
a = input()
if a != '':
print("Case %d: %s" % (i, a))
else:
break
|
s001520104
|
Accepted
| 130
| 7,388
| 98
|
for i in range(1, 10001):
a = input()
if a == "0": break
print("Case %d: %s" % (i, a))
|
s931845384
|
p00444
|
u355726239
| 1,000
| 131,072
|
Wrong Answer
| 30
| 6,724
| 192
|
太郎君はよくJOI雑貨店で買い物をする. JOI雑貨店には硬貨は500円,100円,50円,10円,5円,1円が十分な数だけあり,いつも最も枚数が少なくなるようなおつりの支払い方をする.太郎君がJOI雑貨店で買い物をしてレジで1000円札を1枚出した時,もらうおつりに含まれる硬貨の枚数を求めるプログラムを作成せよ. 例えば入力例1の場合は下の図に示すように,4を出力しなければならない.
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
x = 1000 - int(input())
coins = [500, 100, 50, 10, 5, 1]
ret = 0
for coin in coins:
n = x//coin
x = x - n*coin
ret += n
print(ret)
|
s166631472
|
Accepted
| 30
| 6,724
| 264
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
coins = [500, 100, 50, 10, 5, 1]
while True:
x = 1000 - int(input())
if x == 1000:
break
ret = 0
for coin in coins:
n = x//coin
x = x - n*coin
ret += n
print(ret)
|
s903466535
|
p03493
|
u681110193
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 87
|
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
s=list(input())
count=0
for i in range(3):
if s[i]==1:
count+=1
print(count)
|
s159343881
|
Accepted
| 18
| 2,940
| 90
|
s=list(input())
count=0
for i in range(3):
if s[i]=='1':
count+=1
print(count)
|
s479499915
|
p02608
|
u958125678
| 2,000
| 1,048,576
|
Wrong Answer
| 159
| 9,132
| 381
|
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] * (n + 1)
for x in range(1, n):
if x * x >= n:
break
for y in range(1, n):
if x * x + y * y + x * y >= n:
break
for z in range(1, n):
key = x * x + y * y + z * z + x * y + y * z + z * x
if key > n:
break
ans[key] += 1
for i in range(n + 1):
print(ans[i])
|
s200070327
|
Accepted
| 168
| 9,060
| 375
|
n = int(input())
ans = [0] * (n)
for x in range(1, n):
if x * x > n:
break
for y in range(1, n):
if x * x + y * y + x * y > n:
break
for z in range(1, n):
key = x * x + y * y + z * z + x * y + y * z + z * x
if key > n:
break
ans[key - 1] += 1
for i in range(n):
print(ans[i])
|
s710416114
|
p03079
|
u346395915
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,064
| 71
|
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
|
a,b,c = map(int,input().split())
print("YES" if a == b == c else "NO")
|
s528825953
|
Accepted
| 17
| 2,940
| 71
|
a,b,c = map(int,input().split())
print("Yes" if a == b == c else "No")
|
s458237908
|
p03699
|
u609738635
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 544
|
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?
|
# -*- coding: utf-8 -*-
def main(N,S):
flag = True
S = sorted(S, reverse=True)
ttl = sum(S)
tmp = 0
if(ttl%10==0):
for i in range(N+1):
if(i==N):
flag = False
break
if(S[i]%10!=0):
tmp = S[i]
break
else:
continue
print(ttl-tmp) if flag else print(0)
if __name__ == '__main__':
N = int(input())
S = []
for i in range(N):
S.append(int(input()))
main(N,S)
|
s254446419
|
Accepted
| 17
| 3,064
| 538
|
# -*- coding: utf-8 -*-
def main(N,S):
flag = True
S = sorted(S)
ttl = sum(S)
tmp = 0
if(ttl%10==0):
for i in range(N+1):
if(i==N):
flag = False
break
if(S[i]%10!=0):
tmp = S[i]
break
else:
continue
print(ttl-tmp) if flag else print(0)
if __name__ == '__main__':
N = int(input())
S = []
for i in range(N):
S.append(int(input()))
main(N,S)
|
s698705843
|
p03095
|
u268793453
| 2,000
| 1,048,576
|
Wrong Answer
| 20
| 3,316
| 192
|
You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings. Here, a subsequence of a string is a concatenation of **one or more** characters from the string without changing the order.
|
from collections import defaultdict
S = input()
p = 10 ** 9 + 7
D = defaultdict(int)
for s in S:
D[s] += 1
ans = 1
for k, v in D.items():
ans *= (v + 1)
ans %= p
print(ans - 1)
|
s386568518
|
Accepted
| 32
| 3,444
| 204
|
from collections import defaultdict
n = input()
S = input()
p = 10 ** 9 + 7
D = defaultdict(int)
for s in S:
D[s] += 1
ans = 1
for k, v in D.items():
ans *= (v + 1)
ans %= p
print(ans - 1)
|
s996031183
|
p02678
|
u667084803
| 2,000
| 1,048,576
|
Wrong Answer
| 2,206
| 43,396
| 669
|
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 collections import deque
N, M = map(int, input().split())
path = [[] for i in range(N)]
for i in range(M):
a, b = map(int, input().split())
path[a-1] += [b-1]
path[b-1] += [a-1]
next_vec = deque()
for v in path[0]:
next_vec.append([0, v])
visited = [1] + [0] * (N-1)
parent = [-1] + [0] * (N-1)
while next_vec:
u, v = next_vec.pop()
print(u,v)
visited[v] = 1
parent[v] = u
for w in path[v]:
if visited[w] == 0:
next_vec.append([v,w])
ans_flag = 1
for i in visited:
if i == 0:
ans_flag = 0
if ans_flag:
print('Yes')
for i in range(1,N):
print(parent[i]+1)
else:
print('No')
|
s565543137
|
Accepted
| 755
| 35,476
| 744
|
from collections import deque
N, M = map(int, input().split())
path = [[] for i in range(N)]
for i in range(M):
a, b = map(int, input().split())
path[a-1] += [b-1]
path[b-1] += [a-1]
next_vec = [0]
visited = [1] + [0] * (N-1)
parent = [-1] + [0] * (N-1)
flag = 1
while next_vec:
current_vec = next_vec[:]
next_vec = []
while current_vec:
u = current_vec.pop()
visited[u] = 1
for v in path[u]:
if visited[v] == 0:
visited[v] = 1
parent[v] = u
next_vec.append(v)
ans_flag = 1
for i in visited:
if i == 0:
ans_flag = 0
if ans_flag:
print('Yes')
for i in range(1,N):
print(parent[i]+1)
else:
print('No')
|
s144225800
|
p03448
|
u642012866
| 2,000
| 262,144
|
Wrong Answer
| 48
| 3,316
| 244
|
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
A = int(input())
B = int(input())
C = int(input())
X = int(input())
result = 0
sum = 0
for i in range(A):
for j in range(B):
for k in range(C):
if 500*A + 100*B + 50*C == X:
result += 1
print(result)
|
s071170187
|
Accepted
| 51
| 3,060
| 243
|
A = int(input())
B = int(input())
C = int(input())
X = int(input())
result = 0
for i in range(A+1):
for j in range(B+1):
for k in range(C+1):
if 500*i + 100*j + 50*k == X:
result += 1
print(result)
|
s457703246
|
p03959
|
u814986259
| 2,000
| 262,144
|
Wrong Answer
| 267
| 29,028
| 821
|
Mountaineers Mr. Takahashi and Mr. Aoki recently trekked across a certain famous mountain range. The mountain range consists of N mountains, extending from west to east in a straight line as Mt. 1, Mt. 2, ..., Mt. N. Mr. Takahashi traversed the range from the west and Mr. Aoki from the east. The height of Mt. i is h_i, but they have forgotten the value of each h_i. Instead, for each i (1 ≤ i ≤ N), they recorded the maximum height of the mountains climbed up to the time they reached the peak of Mt. i (including Mt. i). Mr. Takahashi's record is T_i and Mr. Aoki's record is A_i. We know that the height of each mountain h_i is a positive integer. Compute the number of the possible sequences of the mountains' heights, modulo 10^9 + 7. Note that the records may be incorrect and thus there may be no possible sequence of the mountains' heights. In such a case, output 0.
|
N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))
M = [[-1, 10**9] for i in range(N)]
for i in range(N):
if i == 0:
M[i][0] = T[i]
else:
if T[i] != T[i-1]:
M[i][0] = T[i]
else:
M[i][1] = T[i]
for i in range(N-1, -1, -1):
if i == N-1:
if M[i][0] != -1 and M[i][0] != A[i]:
print(0)
exit(0)
else:
M[i][0] = A[i]
else:
if A[i] != A[i+1]:
if M[i][0] != -1 and M[i][0] != A[i]:
print(0)
exit(0)
else:
M[i][0] = A[i]
else:
M[i][1] = min(M[i][1], A[i])
print(M)
ans = 1
mod = (10 ** 9) + 7
for x, y in M:
if x == -1:
ans *= y
ans %= mod
print(ans)
|
s908706168
|
Accepted
| 223
| 21,744
| 794
|
N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))
H = [[-1, 10**9] for i in range(N)]
prev = 0
for i, x in enumerate(T):
if prev != x:
if H[i][0] < 0:
H[i][0] = x
elif H[i][0] != x:
print(0)
exit(0)
prev = x
H[i][1] = min(H[i][1], x)
prev = 0
for i in range(N-1, -1, -1):
x = A[i]
if prev != x:
if H[i][0] < 0:
if H[i][1] >= x:
H[i][0] = x
else:
print(0)
exit(0)
elif H[i][0] != x:
print(0)
exit(0)
prev = x
H[i][1] = min(H[i][1], x)
ans = 1
mod = 10**9 + 7
for x, y in H:
if x > 0:
continue
else:
ans *= y
ans %= mod
print(ans)
|
s516616730
|
p02853
|
u546686251
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,064
| 442
|
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 > 3 and Y > 3:
print(0)
elif (X == 3 and Y > 3) or (Y == 3 and X > 3):
print(100000)
elif (X == 3 and Y == 3) or (X == 2 and Y > 3) or (Y == 2 and X > 3):
print(200000)
elif X == 1 and Y == 1:
print(700000)
elif (X == 1 and Y == 3) or (Y == 1 and X == 3) or (Y == 2 and X == 2):
print(400000)
elif (X == 2 and Y == 3) or (Y == 2 and X == 3):
print(500000)
else:
print(400000)
|
s194352859
|
Accepted
| 17
| 3,064
| 554
|
X, Y = map(int, input().split())
if X > 3 and Y > 3:
print(0)
elif (X == 3 and Y > 3) or (Y == 3 and X > 3):
print(100000)
elif (X == 3 and Y == 3) or (X == 2 and Y > 3) or (Y == 2 and X > 3):
print(200000)
elif X == 1 and Y == 1:
print(1000000)
elif (X == 1 and Y == 3) or (Y == 1 and X == 3) or (Y == 2 and X == 2):
print(400000)
elif (X == 2 and Y == 1) or (Y == 2 and X == 1):
print(500000)
elif (X == 1 and Y > 3) or (Y == 1 and X > 3) or (X == 3 and Y == 2) or (Y == 3 and X == 2):
print(300000)
else:
print(400000)
|
s250219088
|
p03556
|
u713314489
| 2,000
| 262,144
|
Wrong Answer
| 30
| 3,060
| 160
|
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
|
from math import sqrt
n = int(input())
for i in range(n,1,-1):
if sqrt(i).is_integer():
print(int(sqrt(i)))
break
else:
continue
|
s045070186
|
Accepted
| 30
| 3,064
| 149
|
from math import sqrt
n = int(input())
for i in range(n,0,-1):
if sqrt(i).is_integer():
print(i)
break
else:
continue
|
s621357722
|
p03992
|
u667024514
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 44
|
This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the first 4 letters and last 8 letters in the string s.
|
s = str(input())
print(s[0:3] + " " + s[4:])
|
s314708391
|
Accepted
| 17
| 2,940
| 45
|
s = str(input())
print(s[0:4] + " " + s[4:])
|
s059707430
|
p03474
|
u088488125
| 2,000
| 262,144
|
Wrong Answer
| 31
| 9,016
| 179
|
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
|
a,b=map(int, input().split())
s=input()
flag=True
for i in range(a+b+1):
if s[a]!="-":
flag=False
elif not s[i].isdigit():
flag=False
print("Yes" if flag else "No")
|
s782062123
|
Accepted
| 26
| 9,172
| 185
|
a,b=map(int, input().split())
s=input()
flag=True
for i in range(a+b+1):
if s[a]!="-":
flag=False
elif i!=a and not s[i].isdigit():
flag=False
print("Yes" if flag else "No")
|
s765379553
|
p00168
|
u025180675
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,596
| 350
|
一郎君の家の裏山には観音堂があります。この観音堂まではふもとから 30 段の階段があり、一郎君は、毎日のように観音堂まで遊びに行きます。一郎君は階段を1足で3段まで上がることができます。遊んでいるうちに階段の上り方の種類(段の飛ばし方の個数)が非常にたくさんあることに気がつきました。 そこで、一日に 10 種類の上り方をし、すべての上り方を試そうと考えました。しかし数学を熟知しているあなたはそんなことでは一郎君の寿命が尽きてしまうことを知っているはずです。 一郎君の計画が実現不可能であることを一郎君に納得させるために、階段の段数 n を入力とし、一日に 10 種類の上り方をするとして、一郎君がすべての上り方を実行するのに要する年数を出力するプログラムを作成してください。一年は 365 日として計算してください。一日でも必要なら一年とします。365 日なら 1 年であり、366 日なら 2 年となります。
|
while True:
n = int(input().strip())
if n == 0:
break
elif n == 1:
print(1)
elif n == 2:
print(2)
else:
lst = [0 for i in range(0,n+1)]
lst[0] = 1
lst[1] = 1
lst[2] = 2
for i in range(0,n-2):
lst[i+3] = lst[i+2] + lst[i+1] + lst[i]
print(lst[n])
|
s500108271
|
Accepted
| 20
| 5,604
| 442
|
def NtoY(N):
D = (N-1)//10 + 1
Y = (D-1)//365 + 1
return(Y)
while True:
n = int(input().strip())
if n == 0:
break
elif n == 1:
print(NtoY(1))
elif n == 2:
print(NtoY(2))
else:
lst = [0 for i in range(0,n+1)]
lst[0] = 1
lst[1] = 1
lst[2] = 2
for i in range(0,n-2):
lst[i+3] = lst[i+2] + lst[i+1] + lst[i]
print(NtoY(lst[n]))
|
s753521226
|
p03386
|
u830054172
| 2,000
| 262,144
|
Wrong Answer
| 2,185
| 1,217,040
| 127
|
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 = list(map(int,input().split()))
l = [i for i in range(b+1) if i>=a]
ansl = l[:k]+l[-k:]
for j in set(ansl):
print(j)
|
s819795556
|
Accepted
| 17
| 3,060
| 182
|
a,b,k = list(map(int,input().split()))
l = [i for i in range(a,a+k) if a<= i and b>=i]+[i for i in range(b, b-k, -1) if a<= i and b>=i]
ll = sorted(set(l))
for i in ll:
print(i)
|
s457888896
|
p03567
|
u849229491
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 71
|
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())
if 'AC' in s:
print('Yes')
else:
print('No')
|
s547112008
|
Accepted
| 17
| 2,940
| 65
|
s = input()
if 'AC' in s:
print('Yes')
else:
print('No')
|
s849200015
|
p03574
|
u856169020
| 2,000
| 262,144
|
Wrong Answer
| 266
| 13,216
| 669
|
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
|
import numpy as np
H, W = map(int, input().split())
m = np.zeros((H,W))
bomb = []
for h in range(H):
row = list(str(input()))
for w in range(W):
if row[w] == "#":
bomb.append((h, w))
for h, w in bomb:
if h!=0 and w!=0:
m[h-1, w-1] += 1
if h!=0:
m[h-1, w] += 1
if h!=0 and w!=W-1:
m[h-1, w+1] += 1
if w!=0:
m[h, w-1] += 1
if w!=W-1:
m[h, w+1] += 1
if h!=H-1 and w!=0:
m[h+1, w-1] += 1
if h!=H-1:
m[h+1, w] += 1
if h!=H-1 and w!=W-1:
m[h+1, w+1] += 1
for h in range(H):
for w in range(W):
if (h, w) in bomb:
print("#", end="")
else:
print(m[h, w], end="")
print("", end="\n")
|
s407386270
|
Accepted
| 258
| 12,892
| 674
|
import numpy as np
H, W = map(int, input().split())
m = np.zeros((H,W))
bomb = []
for h in range(H):
row = list(str(input()))
for w in range(W):
if row[w] == "#":
bomb.append((h, w))
for h, w in bomb:
if h!=0 and w!=0:
m[h-1, w-1] += 1
if h!=0:
m[h-1, w] += 1
if h!=0 and w!=W-1:
m[h-1, w+1] += 1
if w!=0:
m[h, w-1] += 1
if w!=W-1:
m[h, w+1] += 1
if h!=H-1 and w!=0:
m[h+1, w-1] += 1
if h!=H-1:
m[h+1, w] += 1
if h!=H-1 and w!=W-1:
m[h+1, w+1] += 1
for h in range(H):
for w in range(W):
if (h, w) in bomb:
print("#", end="")
else:
print(int(m[h, w]), end="")
print("", end="\n")
|
s600007115
|
p03997
|
u231198419
| 2,000
| 262,144
|
Wrong Answer
| 28
| 8,992
| 56
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a,b,h=[int(input()) for i in range(3)]
print((a+b)*h/2)
|
s779402153
|
Accepted
| 27
| 8,984
| 57
|
a,b,h=[int(input()) for i in range(3)]
print((a+b)*h//2)
|
s247888661
|
p02399
|
u777277984
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,596
| 56
|
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
a, b = map(int, input().split())
print(a//b, a%b, a/b)
|
s073463857
|
Accepted
| 20
| 5,600
| 82
|
a, b = map(int, input().split())
print("{0} {1} {2:.5f}".format(a//b, a%b, a/b))
|
s489555634
|
p03486
|
u635339675
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 623
|
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.
|
a=[i for i in input()]
b=[i for i in input()]
a=sorted(a)
b=sorted(b)
b=b[::-1]
print(a)
print(b)
aa=set(a)
bb=set(b)
if aa==bb and len(b)<=len(a):
print("No")
elif aa==bb and len(b)>len(a):
print("Yes")
else:
hantei=True
if len(a)<=len(b):
for i in range(len(a)):
if a[i]>b[i]:
hantei=False
print("ha")
break
elif a[i]<b[i]:
hantei=True
print("haa")
break
else:
hantei=False
for i in range(len(b)):
if a[i]>b[i]:
hantei=False
print("haaa")
break
elif a[i]<b[i]:
hantei=True
print("haaaa")
break
if hantei == True:
print("Yes")
else:
print("No")
|
s950062475
|
Accepted
| 18
| 3,064
| 420
|
a=[i for i in input()]
b=[i for i in input()]
a=sorted(a)
b=sorted(b)
b=b[::-1]
#print(a)
#print(b)
hantei=True
if len(a)<len(b):
for i in range(len(a)):
if a[i]>b[i]:
hantei=False
break
elif a[i]<b[i]:
hantei=True
break
else:
hantei=False
for i in range(len(b)):
if a[i]>b[i]:
hantei=False
break
elif a[i]<b[i]:
hantei=True
break
if hantei == True:
print("Yes")
else:
print("No")
|
s945029044
|
p04043
|
u506858457
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 91
|
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
A=list(map(int,input().split()))
A.sort
if A==[7,5,5]:
print('YES')
else:
print('NO')
|
s736745274
|
Accepted
| 17
| 2,940
| 101
|
A=list(map(int,input().split()))
A.sort()
#print(A)
if A==[5,5,7]:
print('YES')
else:
print('NO')
|
s221225008
|
p03448
|
u432226259
| 2,000
| 262,144
|
Wrong Answer
| 234
| 4,292
| 297
|
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
A_500 = int(input())
B_100 = int(input())
C_50 = int(input())
X = int(input())
count = 0
for i in range(0, A_500 + 1):
for j in range(0, B_100 + 1):
for k in range(0, C_50 + 1):
print(str(i) + ',' + str(j) + ',' + str(k))
if X == i * 500 + j * 100 + k * 50:
count += 1
print(count)
|
s162205018
|
Accepted
| 51
| 3,060
| 250
|
A_500 = int(input())
B_100 = int(input())
C_50 = int(input())
X = int(input())
count = 0
for i in range(0, A_500 + 1):
for j in range(0, B_100 + 1):
for k in range(0, C_50 + 1):
if X == i * 500 + j * 100 + k * 50:
count += 1
print(count)
|
s660441030
|
p02612
|
u283751459
| 2,000
| 1,048,576
|
Wrong Answer
| 32
| 9,140
| 30
|
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input())
print(n%1000)
|
s392622570
|
Accepted
| 33
| 9,160
| 74
|
n = int(input())
if n%1000 == 0:
print(0)
else:
print((1000-(n%1000)))
|
s738769282
|
p03388
|
u425287928
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 152
|
10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th. The _score_ of a participant is the product of his/her ranks in the two contests. Process the following Q queries: * In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.
|
import math
n = int(input())
for _ in range(n):
a,b = input().split(" ")
a,b = sorted([int(a), int(b)])
c = int((a*b)**0.5)
print(2*c-1-(a==b))
|
s930705295
|
Accepted
| 18
| 3,060
| 173
|
import math
n = int(input())
for _ in range(n):
a,b = input().split(" ")
a,b = sorted([int(a), int(b)])
c = math.ceil((a*b)**0.5)-1
print(2*c-(a!=b)-(c*(c+1)>=a*b))
|
s283251199
|
p03089
|
u963120252
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 203
|
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
|
n = int(input())
b = map(int, input().split())
a = [range(1, _n + 1) for _n in range(1, n + 1)]
for i, _b in enumerate(b):
if _b in a[i]:
print(_b)
else:
print(-1)
break
|
s840443041
|
Accepted
| 17
| 2,940
| 178
|
n = int(input())
b = []
for _b in list(map(int, input().split())):
if _b > len(b) + 1:
print('-1')
exit()
b.insert(_b - 1, str(_b))
print('\n'.join(b))
|
s854046156
|
p03854
|
u860002137
| 2,000
| 262,144
|
Wrong Answer
| 23
| 6,516
| 112
|
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`.
|
import re
s = input()
m = re.match(r"^(dream|dreamer|erase|eraser)+$", s)
print("No" if m is None else "Yes")
|
s340690799
|
Accepted
| 23
| 6,516
| 112
|
import re
s = input()
m = re.match(r"^(dream|dreamer|erase|eraser)+$", s)
print("NO" if m is None else "YES")
|
s538994556
|
p03696
|
u455642216
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 149
|
You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of `(`, X and `)` in this order is also a correct bracket sequence. * If X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence. * Every correct bracket sequence can be derived from the rules above. Find the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one.
|
N=int(input())
S=input()
x=0
y=0
for i in S:
if i=="(":
x+=1
else:
if x<=0:
y+=1
else:
x-=1
|
s376227080
|
Accepted
| 17
| 2,940
| 170
|
N=int(input())
S=input()
x=0
y=0
for i in S:
if i=="(":
x+=1
else:
if x<=0:
y+=1
else:
x-=1
print("("*y+S+")"*x)
|
s500859893
|
p02972
|
u970899068
| 2,000
| 1,048,576
|
Wrong Answer
| 48
| 7,148
| 59
|
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
|
n=int(input())
a=list(map(int, input().split()))
print(0)
|
s010345243
|
Accepted
| 289
| 14,076
| 222
|
n=int(input())
a=list(map(int, input().split()))
b=[0]*n
c=[]
for i in range(1,n+1):
if sum(b[n-i:n+1:n+1-i])%2==a[n-i]:
pass
else:
b[n-i]=1
c.append(n-i+1)
print(len(c))
print(*c)
|
s327471455
|
p03377
|
u636162168
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 89
|
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+b<=x and a<x:
print("Yes")
else:
print("No")
|
s437204918
|
Accepted
| 17
| 2,940
| 127
|
a,b,x=map(int,input().split())
if a<=x:
if a+b>=x:
print("YES")
else:
print("NO")
else:
print("NO")
|
s553504445
|
p03470
|
u291373585
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 233
|
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
length = int(input())
mochi = [int(input()) for i in range(length)]
sorted_mochi = sorted(mochi,reverse=True)
stage = 0
for i in range(0,length-1):
if sorted_mochi[i] > sorted_mochi[i+1]:
stage +=1
else:
pass
print(stage)
|
s045982225
|
Accepted
| 19
| 3,060
| 86
|
N = int(input())
a = []
for i in range(N):
a.append(int(input()))
print(len(set(a)))
|
s297811139
|
p03047
|
u583455893
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 78
|
Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers?
|
n, k = list(int(x) for x in input('n k').split())
ans = n - (k - 1)
print(ans)
|
s938439373
|
Accepted
| 17
| 2,940
| 144
|
n, k = list(int(x) for x in input().split())
ans = 0
for i in range(1, n + 1):
x = i + (k - 1)
if x <= n:
ans += 1
print(ans)
|
s212864833
|
p04043
|
u345710188
| 2,000
| 262,144
|
Wrong Answer
| 30
| 9,072
| 128
|
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
A, B, C = map(int, input().split())
fsf = [A, B, C]
if fsf.count(5) == 2 & fsf.count(7) == 1:
print("YES")
else:
print("NO")
|
s884196668
|
Accepted
| 23
| 8,812
| 136
|
A, B, C = map(int, input().split())
fsf = [A, B, C]
if (fsf.count(5) == 2) & (fsf.count(7) == 1):
print("YES")
else:
print("NO")
|
s946490567
|
p03470
|
u911472374
| 2,000
| 262,144
|
Wrong Answer
| 105
| 27,128
| 209
|
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
import numpy as np
n = int(input())
d = [int(input()) for _ in range(n)]
i0 = 101
count = 0
d.sort()
d.reverse()
for i in range(0, n - 1):
if i0 > d[i]:
count += 1
i0 = d[i]
print(count)
|
s673534740
|
Accepted
| 108
| 27,152
| 226
|
import numpy as np
n = int(input())
d = [int(input()) for _ in range(n)]
i0 = 101
count = 0
d.sort()
d.reverse()
for i in range(0, n):
# print(i, d[i])
if i0 > d[i]:
count += 1
i0 = d[i]
print(count)
|
s831705723
|
p00100
|
u873482706
| 1,000
| 131,072
|
Wrong Answer
| 40
| 7,548
| 273
|
There is data on sales of your company. Your task is to write a program which identifies good workers. The program should read a list of data where each item includes the employee ID _i_ , the amount of sales _q_ and the corresponding unit price _p_. Then, the program should print IDs of employees whose total sales proceeds (i.e. sum of p × q) is greater than or equal to 1,000,000 in the order of inputting. If there is no such employees, the program should print "NA". You can suppose that _n_ < 4000, and each employee has an unique ID. The unit price _p_ is less than or equal to 1,000,000 and the amount of sales _q_ is less than or equal to 100,000.
|
while True:
N = int(input())
if N == 0:
break
fla = False
for n in range(N):
num, p, q = map(int, input().split())
if p*q >= 1000000:
print(num)
fla = True
else:
if not fla:
print('NA')
|
s839327334
|
Accepted
| 30
| 7,916
| 479
|
while True:
N = int(input())
if N == 0:
break
d = {}
for n in range(N):
num, p, q = map(int, input().split())
if num in d:
d[num][1] += (p*q)
else:
d[num] = [n, p*q]
else:
fla = False
for k, v in sorted(d.items(), key=lambda x: x[1][0]):
if v[1] >= 1000000:
print(k)
fla = True
else:
if not fla:
print('NA')
|
s191802442
|
p02612
|
u620945921
| 2,000
| 1,048,576
|
Wrong Answer
| 24
| 9,136
| 38
|
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.
|
x=int(input())
#print(x)
print(x%1000)
|
s790807739
|
Accepted
| 35
| 9,160
| 89
|
x=int(input())
while x>=1000:
x=x-1000
if x>0:
print(1000-x)
else:
print(0)
|
s018766032
|
p03644
|
u366886346
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 92
|
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())
for i in range(n):
if 2**(i+1)>n:
ans=i
break
print(ans)
|
s924607685
|
Accepted
| 17
| 2,940
| 95
|
n=int(input())
for i in range(n):
if 2**(i+1)>n:
ans=i
break
print(2**ans)
|
s945329750
|
p03573
|
u441320782
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 117
|
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
|
x = list(map(int,input().split()))
result = None
for i in set(x):
if x.count(i)>1:
result = i
print(result)
|
s718729656
|
Accepted
| 17
| 2,940
| 118
|
x = list(map(int,input().split()))
result = None
for i in set(x):
if x.count(i)==1:
result = i
print(result)
|
s146688739
|
p03369
|
u256786023
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 62
|
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
|
def A(S):
ret=700
ret+=S.count("o")*100
return ret
|
s620898754
|
Accepted
| 17
| 2,940
| 126
|
def main(func):
ret=func(input())
print(ret)
def A(S):
ret=700
ret+=S.count("o")*100
return ret
main(A)
|
s742362790
|
p03730
|
u339537294
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 135
|
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
a,b,c = map(int,input().split())
N=[]
x=0
while x in N:
N.append(a%b)
x=a%b
if c in N:
print("yes")
else:
print("no")
|
s409130847
|
Accepted
| 17
| 2,940
| 186
|
a,b,c = map(int,input().split())
N=[]
x=0
while True:
if x%b not in N:
N.append(x%b)
else:
break
x=x+a
if c in N:
print("YES")
else:
print("NO")
|
s727394017
|
p02612
|
u738430530
| 2,000
| 1,048,576
|
Wrong Answer
| 33
| 8,948
| 28
|
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(1000%N)
|
s993221214
|
Accepted
| 30
| 9,004
| 83
|
N=int(input())
1<=N<=10000
if((N%1000)==0):
print("0")
else:
print(1000-(N%1000))
|
s780273033
|
p02263
|
u869924057
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,596
| 370
|
An expression is given in a line. Two consequtive symbols (operand or operator) are separated by a space character. You can assume that +, - and * are given as the operator and an operand is a positive integer less than 106
|
inputs = input().split(" ")
stack = []
for str in inputs:
if str.isdigit():
stack.append(int(str))
else:
b = stack.pop()
a = stack.pop()
if str == '+':
stack.append(a + b)
print(stack)
elif str == '-':
stack.append(a - b)
print(stack)
elif str == '*':
stack.append(a * b)
print(stack)
print(stack.pop())
|
s301554837
|
Accepted
| 20
| 5,596
| 313
|
inputs = input().split(" ")
stack = []
for str in inputs:
if str.isdigit():
stack.append(int(str))
else:
b = stack.pop()
a = stack.pop()
if str == '+':
stack.append(a + b)
elif str == '-':
stack.append(a - b)
elif str == '*':
stack.append(a * b)
print(stack.pop())
|
s359851333
|
p03729
|
u391819434
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 66
|
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
|
A,B,C=input().split();print('YNeos'[A[-1]!=B[0]or B[-1]!=C[0]::2])
|
s801758548
|
Accepted
| 17
| 2,940
| 66
|
A,B,C=input().split();print('YNEOS'[A[-1]!=B[0]or B[-1]!=C[0]::2])
|
s715079351
|
p03089
|
u802977614
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 177
|
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
|
n=int(input())
b=list(map(int,input().split()))
ans=[]
for i in range(n):
tmp=i+1
if b[i]<=tmp:
ans.append(tmp)
else:
print(-1)
exit()
for i in ans:
print(i)
|
s689927995
|
Accepted
| 18
| 3,064
| 352
|
n=int(input())
b=list(map(int,input().split()))
s_b=sorted(list(set(b)),reverse=True)
if 1 not in s_b:
print(-1)
exit()
ans=[]
for itr in range(n):
for j in s_b:
if len(b)>=j:
if b[j-1]==j:
b.pop(j-1)
ans.append(j)
break
if j==1:
print(-1)
exit()
ans.reverse()
for i in range(n):
print(ans[i])
|
s922702730
|
p03997
|
u735975757
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 78
|
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())
s = ((a + b)*h)/2
print(s)
|
s348413072
|
Accepted
| 17
| 2,940
| 69
|
a = int(input())
b = int(input())
h = int(input())
print((a+b)*h//2)
|
s477220184
|
p02409
|
u313089641
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,604
| 541
|
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.
|
N = int(input())
n = [input().split() for _ in range(N)]
all_info = [[["0" for _ in range(10)] for _ in range(3)] for _ in range(4)]
def change_room(info):
info = [int(i) for i in info]
info_dic = {"all_info": all_info,
"buil": info[0]-1,
"loc" : info[1]-1,
"room": info[2]-1,
"num" : str(info[3])}
exec("all_info[buil][loc][room] = num", info_dic)
for i in n:
change_room(i)
for i in all_info:
for j in i:
print(" ".join(j))
print("#"*20)
|
s248061329
|
Accepted
| 20
| 5,612
| 612
|
N = int(input())
n = [input().split() for _ in range(N)]
all_info = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
def change_room(info):
info = [int(i) for i in info]
info_dic = {"all_info": all_info,
"buil": info[0]-1,
"loc" : info[1]-1,
"room": info[2]-1,
"num" : info[3]}
exec("all_info[buil][loc][room] += num", info_dic)
for i in n:
change_room(i)
for num, i in enumerate(all_info):
for j in i:
j = [str(i) for i in j]
print(" " + (" ".join(j)))
if num < 3:
print("#"*20)
|
s740834730
|
p03556
|
u587589241
| 2,000
| 262,144
|
Wrong Answer
| 36
| 2,940
| 109
|
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
|
n=int(input())
r=int(n**0.5)
ans=1
for i in range(r+1):
if i**2>ans:
ans=i**2
print(ans)
print(r)
|
s239780301
|
Accepted
| 36
| 2,940
| 100
|
n=int(input())
r=int(n**0.5)
ans=1
for i in range(r+1):
if i**2>ans:
ans=i**2
print(ans)
|
s426508693
|
p03636
|
u459233539
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 65
|
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
s = str(input())
ans = s[0] + str(len(s) - 1) + s[-1]
print(ans)
|
s550534361
|
Accepted
| 17
| 2,940
| 56
|
s = input()
ans = s[0]+ str(len(s) - 2)+s[-1]
print(ans)
|
s449766846
|
p03456
|
u321354941
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 171
|
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
import math
input_str = str(input()).split(" ")
a = input_str[0]
b = input_str[1]
ab_text = int(a+b)
if (ab_text**(1/2))**2 == ab_text:
print("yes")
else:
print("no")
|
s560542320
|
Accepted
| 17
| 3,060
| 163
|
input_str = str(input()).split(" ")
a = input_str[0]
b = input_str[1]
ab_text = int(a+b)
if int(ab_text**(1/2))**2 == ab_text:
print("Yes")
else:
print("No")
|
s970534645
|
p03623
|
u580362735
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 62
|
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
x,a,b = map(int,input().split())
print(min(abs(x-a),abs(x-b)))
|
s178517479
|
Accepted
| 17
| 2,940
| 80
|
x,a,b = map(int,input().split())
print('A') if abs(x-a)<abs(x-b) else print('B')
|
s802187729
|
p03997
|
u006425112
| 2,000
| 262,144
|
Wrong Answer
| 19
| 2,940
| 84
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
import sys
a = int(input())
b = int(input())
h = int(input())
print((a+b) * h / 2)
|
s292396275
|
Accepted
| 17
| 2,940
| 89
|
import sys
a = int(input())
b = int(input())
h = int(input())
print(int((a+b) * h / 2))
|
s711096388
|
p03860
|
u414877092
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 29
|
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
s=input()
print("A"+s[0]+"C")
|
s895689624
|
Accepted
| 17
| 2,940
| 40
|
s=input().split()
print("A"+s[1][0]+"C")
|
s229824024
|
p03434
|
u453968283
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 162
|
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
N=int(input())
a = [int(i) for i in input().split()]
a.sort()
p1=a[0:N:2]
p2=a[1:N:2]
sum1=0
sum2=0
for i in p1:
sum1+=i
for i in p2:
sum2+=i
print(sum1-sum2)
|
s132562312
|
Accepted
| 17
| 3,064
| 174
|
N=int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
p1=a[0:N:2]
p2=a[1:N:2]
sum1=0
sum2=0
for i in p1:
sum1+=i
for i in p2:
sum2+=i
print(sum1-sum2)
|
s241518451
|
p03149
|
u081193942
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 72
|
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".
|
n = input().split(" ")
print("YES" if set(n) == {1, 7, 9, 4} else "NO")
|
s697365421
|
Accepted
| 17
| 2,940
| 81
|
n = input().split(" ")
print("YES" if set(n) == {"1", "7", "9", "4"} else "NO")
|
s725162546
|
p02388
|
u293957970
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,508
| 12
|
Write a program which calculates the cube of a given integer x.
|
print(2^3)
|
s571942490
|
Accepted
| 20
| 5,572
| 29
|
x = int(input())
print(x**3)
|
s231136528
|
p03502
|
u290211456
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 146
|
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
|
n = int(input())
n2 = n
summ = 0
while n > 0:
mod = n % 10
summ += mod
n = n//10
print(n2)
if n2 % summ == 0:
print("Yes")
else:
print("No")
|
s652325345
|
Accepted
| 17
| 2,940
| 154
|
s_n = input()
ll = len(s_n)
s_int = int(s_n)
nn = 0
for i in range(ll):
nn += int(s_n[i])
if(s_int % nn == 0):
print("Yes")
else:
print("No")
|
s821832611
|
p02406
|
u800997102
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,584
| 132
|
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
|
n=int(input())
for i in range(1,n):
if i%3==0:
print(i,end=" ")
elif str(i).find("3")>-1:
print(i,end=" ")
|
s963517833
|
Accepted
| 30
| 6,164
| 192
|
n=int(input())
for i in range(1,n+1):
if i%3==0:
print(" ",end="")
print(i,end="")
elif str(i).find("3")>-1:
print(" ",end="")
print(i,end="")
print()
|
s969376044
|
p02258
|
u922633376
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,584
| 162
|
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen. Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
|
minv = -1000000000
maxv = 1000000000
for _ in range(int(input())) :
num = int(input())
maxv = max(maxv,num - minv)
minv = min(minv,num)
print(maxv)
|
s644576761
|
Accepted
| 580
| 5,612
| 163
|
maxv = -10000000000
minv = 10000000000
for _ in range(int(input())) :
num = int(input())
maxv = max(maxv,num - minv)
minv = min(minv,num)
print(maxv)
|
s972511872
|
p03854
|
u412481017
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,188
| 421
|
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`.
|
word=input()
wordList=["dream","dreamer","erase","eraser"]
while 1:
if word[len(word)-5:]==wordList[0]:
word=word[:len(word)-5]
elif word[len(word)-7:]==wordList[1]:
word=word[:len(word)-7]
elif word[len(word)-5:]==wordList[2]:
word=word[:len(word)-5]
elif word[len(word)-7:]==wordList[3]:
word=word[:len(word)-7]
else:
print("false")
break
if word=="":
print("true")
break
|
s303586259
|
Accepted
| 74
| 3,188
| 417
|
word=input()
wordList=["dream","dreamer","erase","eraser"]
while 1:
if word[len(word)-5:]==wordList[0]:
word=word[:len(word)-5]
elif word[len(word)-7:]==wordList[1]:
word=word[:len(word)-7]
elif word[len(word)-5:]==wordList[2]:
word=word[:len(word)-5]
elif word[len(word)-6:]==wordList[3]:
word=word[:len(word)-6]
else:
print("NO")
break
if word=="":
print("YES")
break
|
s729470840
|
p02601
|
u102655885
| 2,000
| 1,048,576
|
Wrong Answer
| 35
| 9,168
| 210
|
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
|
a,b,c = map(lambda x: int(x), input().split())
k = int(input())
for _ in range(k):
if b < a:
b = 2 * b
continue
if c < b:
c = 2 * c
continue
print('Yes')
print('No')
|
s037565703
|
Accepted
| 32
| 9,188
| 371
|
import sys
def main():
a,b,c = map(lambda x: int(x), input().split())
k = int(input())
for _ in range(k):
if b <= a:
b = 2 * b
continue
if c <= b:
c = 2 * c
continue
print('Yes')
return
if (a < b) & (b < c):
print('Yes')
return
print('No')
if __name__ == '__main__':
main()
|
s493263282
|
p03699
|
u413165887
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 283
|
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())
s = [int(input()) for _ in range(n)]
sum_s = sum(s)
if sum_s%10==0:
s = sorted(s)
for i in range(n):
if s[i]%10==0:
sum_s -= s[i]
break
if sum_s%10==0:
print(0)
else:
print(sum_s)
else:
print(sum_s)
|
s829767677
|
Accepted
| 17
| 3,060
| 283
|
n = int(input())
s = [int(input()) for _ in range(n)]
sum_s = sum(s)
if sum_s%10==0:
s = sorted(s)
for i in range(n):
if s[i]%10!=0:
sum_s -= s[i]
break
if sum_s%10==0:
print(0)
else:
print(sum_s)
else:
print(sum_s)
|
s892354121
|
p00763
|
u509278866
| 8,000
| 131,072
|
Wrong Answer
| 27,380
| 12,648
| 2,727
|
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1. Figure D-1: A sample railway network Suppose you are going to station D from station A. Obviously, the path with the shortest distance is A->B->D. However, the path with the shortest distance does not necessarily mean the minimum cost. Assume the lines A-B, B-C, and C-D are operated by one railway company, and the line B-D is operated by another company. In this case, the path A->B->C->D may cost less than A->B->D. One of the reasons is that the fare is not proportional to the distance. Usually, the longer the distance is, the fare per unit distance is lower. If one uses lines of more than one railway company, the fares charged by these companies are simply added together, and consequently the total cost may become higher although the distance is shorter than the path using lines of only one company. In this problem, a railway network including multiple railway companies is given. The fare table (the rule to calculate the fare from the distance) of each company is also given. Your task is, given the starting point and the goal point, to write a program that computes the path with the least total fare.
|
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
class WarshallFloyd():
def __init__(self, e, n):
self.E = e
self.N = n
def search(self):
n = self.N
nl = list(range(n))
d = [[inf] * n for _ in nl]
for k,v in self.E.items():
for b,c in v:
d[k][b] = c
for i in nl:
for j in nl:
if i == j:
continue
for k in nl:
if i != k and j != k and d[j][k] > d[j][i] + d[i][k]:
d[j][k] = d[j][i] + d[i][k]
return d
def main():
rr = []
def f(n,m,c,s,g):
ms = [LI() for _ in range(m)]
ps = LI()
qrs = [([0] + LI(),LI()) for _ in range(c)]
ec = collections.defaultdict(lambda: collections.defaultdict(list))
for x,y,d,cc in ms:
ec[cc][x].append((y,d))
ec[cc][y].append((x,d))
nl = list(range(n+1))
ad = [[inf] * (n+1) for _ in nl]
for cc,v in ec.items():
q, r = qrs[cc-1]
wf = WarshallFloyd(v, n+1)
d = wf.search()
w = [0]
for i in range(1, len(q)):
w.append(w[-1] + (q[i]-q[i-1]) * r[i-1])
for i in nl:
for j in nl:
dk = d[i][j]
if dk == inf:
continue
ri = bisect.bisect_left(q, dk) - 1
dw = w[ri] + r[ri] * (dk - q[ri])
if ad[i][j] > dw:
ad[i][j] = dw
ae = collections.defaultdict(list)
for i in nl:
ai = ad[i]
for j in nl:
if ai[j] < inf:
ae[i].append((j, ai[j]))
awf = WarshallFloyd(ae, n+1)
awd = awf.search()
r = awd[s][g]
if r == inf:
return -1
return r
while True:
n,m,c,s,g = LI()
if n == 0 and m == 0:
break
rr.append(f(n,m,c,s,g))
return '\n'.join(map(str, rr))
print(main())
|
s033039590
|
Accepted
| 27,740
| 12,668
| 3,470
|
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
class WarshallFloyd():
def __init__(self, e, n):
self.E = e
self.N = n
def search(self):
n = self.N
nl = list(range(n))
d = [[inf] * n for _ in nl]
for k,v in self.E.items():
for b,c in v:
if d[k][b] > c:
d[k][b] = c
for i in nl:
for j in nl:
if i == j:
continue
for k in nl:
if i != k and j != k and d[j][k] > d[j][i] + d[i][k]:
d[j][k] = d[j][i] + d[i][k]
d[j][k] = d[j][i] + d[i][k]
return d
def main():
rr = []
def f(n,m,c,s,g):
ms = [LI() for _ in range(m)]
ps = LI()
qrs = [([0] + LI(),LI()) for _ in range(c)]
ec = collections.defaultdict(lambda: collections.defaultdict(list))
for x,y,d,cc in ms:
ec[cc][x].append((y,d))
ec[cc][y].append((x,d))
nl = list(range(n+1))
ad = [[inf] * (n+1) for _ in nl]
for cc,v in ec.items():
q, r = qrs[cc-1]
wf = WarshallFloyd(v, n+1)
d = wf.search()
w = [0]
for i in range(1, len(q)):
w.append(w[-1] + (q[i]-q[i-1]) * r[i-1])
for i in nl:
for j in nl:
dk = d[i][j]
if dk == inf:
continue
ri = bisect.bisect_left(q, dk) - 1
dw = w[ri] + r[ri] * (dk - q[ri])
if ad[i][j] > dw:
ad[i][j] = dw
ae = collections.defaultdict(list)
for i in nl:
ai = ad[i]
for j in nl:
if ai[j] < inf:
ae[i].append((j, ai[j]))
awf = WarshallFloyd(ae, n+1)
awd = awf.search()
r = awd[s][g]
def search(s):
d = collections.defaultdict(lambda: inf)
d[s] = 0
q = []
heapq.heappush(q, (0, s))
v = collections.defaultdict(bool)
while len(q):
k, u = heapq.heappop(q)
if v[u]:
continue
v[u] = True
for uv, ud in ae[u]:
if v[uv]:
continue
vd = k + ud
if d[uv] > vd:
d[uv] = vd
heapq.heappush(q, (vd, uv))
return d
dkr = search(s)[g]
if r == inf:
return -1
return r
while True:
n,m,c,s,g = LI()
if n == 0 and m == 0:
break
rr.append(f(n,m,c,s,g))
return '\n'.join(map(str, rr))
print(main())
|
s421289578
|
p03139
|
u999989620
| 2,000
| 1,048,576
|
Wrong Answer
| 30
| 9,112
| 73
|
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question.
|
n, a, b = map(int, input().split(' '))
print(f'{min(a,b)} {abs(a+b-n)}')
|
s798261666
|
Accepted
| 30
| 9,092
| 75
|
n, a, b = map(int, input().split(' '))
print(f'{min(a,b)} {max(0,a+b-n)}')
|
s955794092
|
p03597
|
u862296914
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 46
|
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
|
N = int(input())
A = int(input())
print(N^2-A)
|
s482394809
|
Accepted
| 17
| 2,940
| 47
|
N = int(input())
A = int(input())
print(N**2-A)
|
s072908623
|
p03545
|
u761154175
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 446
|
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.
|
abcd = list(input())
a,b,c,d = map(int, abcd)
res = ""
if a + b + c + d == 7:
res = "a+b+c+d=7"
elif a + b + c - d == 7:
res = "a+b+c-d=7"
elif a + b - c + d == 7:
res = "a+b-c+d=7"
elif a + b - c - d == 7:
res = "a+b-c-d=7"
elif a +- b + c + d == 7:
res = "a-b+c+d=7"
elif a - b + c - d == 7:
res = "a-b+c-d=7"
elif a - b - c + d == 7:
res = "a-b-c+d=7"
elif a - b - c - d == 7:
res = "a-b-c-d=7"
print(res)
|
s611529634
|
Accepted
| 17
| 3,064
| 710
|
abcd = list(input())
a,b,c,d = map(int, abcd)
res = ""
if a + b + c + d == 7:
res = str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7"
elif a + b + c - d == 7:
res = str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7"
elif a + b - c + d == 7:
res = str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7"
elif a + b - c - d == 7:
res = str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7"
elif a +- b + c + d == 7:
res = str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7"
elif a - b + c - d == 7:
res = str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7"
elif a - b - c + d == 7:
res = str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7"
elif a - b - c - d == 7:
res = str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7"
print(res)
|
s579965576
|
p02612
|
u054931633
| 2,000
| 1,048,576
|
Wrong Answer
| 30
| 8,996
| 99
|
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.
|
import sys
n=int(input())
for i in range(10):
n=n-1000
if n<0:
print(n+1000)
sys.exit()
|
s640519557
|
Accepted
| 30
| 9,076
| 107
|
import sys
n=int(input())
for i in range(10):
n=n-1000
if n<=0:
print(1000-(n+1000))
sys.exit()
|
s558642432
|
p03434
|
u606001175
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 235
|
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
n = int(input())
ls = list(map(int, input().split()))
ls.sort()
ls.reverse()
lsa = []
lsb = []
for i in range(n):
if i // 2 == 0:
lsa += [ls[i]]
else:
lsb += [ls[i]]
a = sum(lsa)
b = sum(lsb)
c = a - b
print(c)
|
s132115449
|
Accepted
| 18
| 3,060
| 233
|
n = int(input())
ls = list(map(int, input().split()))
ls.sort()
ls.reverse()
lsa = []
lsb = []
for i in range(n):
if i % 2 == 0:
lsa += [ls[i]]
else:
lsb += [ls[i]]
a = sum(lsa)
b = sum(lsb)
c = a - b
print(c)
|
s404367742
|
p02612
|
u715435591
| 2,000
| 1,048,576
|
Wrong Answer
| 28
| 9,100
| 101
|
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())
r = N % 1000
if r == 0:
print(0)
else:
q = (N // 1000) + 1
print(q*1000 - r)
|
s685236285
|
Accepted
| 28
| 9,160
| 100
|
N = int(input())
r = N % 1000
if not r:
print(0)
else:
q = N // 1000
print((q+1) * 1000 - N)
|
s878329158
|
p03434
|
u669770658
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 223
|
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
def card_game():
n = int(input())
a_li = [int(i) for i in input().split()]
a_li.sort()
return sum([i for i in a_li[::2]]) - sum([i for i in a_li[1::2]])
if __name__ == '__main__':
print(card_game())
|
s165851371
|
Accepted
| 18
| 3,060
| 384
|
def card_game():
n = int(input())
a_li = [int(i) for i in input().split()]
ans = 0
turn_switch = True
li = sorted(a_li, reverse=True)
for i in li:
if turn_switch:
ans += i
turn_switch = False
else:
ans -= i
turn_switch = True
return ans
if __name__ == '__main__':
print(card_game())
|
s510435544
|
p03567
|
u644907318
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 161
|
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 = input().split()
flag = 0
for i in range(len(S)-2+1):
if S[i:i+2]=="AC":
flag = 1
break
if flag==1:
print("Yes")
else:
print("No")
|
s518706059
|
Accepted
| 17
| 2,940
| 161
|
S = input().strip()
flag = 0
for i in range(len(S)-2+1):
if S[i:i+2]=="AC":
flag = 1
break
if flag==1:
print("Yes")
else:
print("No")
|
s350144632
|
p03006
|
u167681750
| 2,000
| 1,048,576
|
Wrong Answer
| 34
| 3,064
| 340
|
There are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i). We will collect all of these balls, by choosing two integers p and q such that p \neq 0 or q \neq 0 and then repeating the following operation: * Choose a ball remaining in the plane and collect it. Let (a, b) be the coordinates of this ball. If we collected a ball at coordinates (a - p, b - q) in the previous operation, the cost of this operation is 0. Otherwise, including when this is the first time to do this operation, the cost of this operation is 1. Find the minimum total cost required to collect all the balls when we optimally choose p and q.
|
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
s_xy = set(xy)
count = 0
for i in range(n-1):
for j in range(i+1, n):
ix, iy = xy[i]
jx, jy = xy[j]
p, q = jx - jy, jy - jx
tc = sum((x-p,y-q) in s_xy for x, y in s_xy)
count = max(count, tc)
print(n-count)
|
s900193938
|
Accepted
| 34
| 3,064
| 292
|
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
s_xy = set(xy)
count = 0
for i in range(n-1):
for j in range(i+1, n):
p, q = xy[j][0] - xy[i][0], xy[j][1] - xy[i][1]
count = max(count, sum((x-p,y-q) in s_xy for x, y in s_xy))
print(n - count)
|
s510984441
|
p03447
|
u407158193
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 12
|
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
|
7477
549
593
|
s229245817
|
Accepted
| 17
| 2,940
| 73
|
x = int(input())
a = int(input())
b = int(input())
print(int((x - a)%b))
|
s472875697
|
p04030
|
u247465867
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 295
|
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?
|
#2019/10/22
s = open(0).read()
display = []
for i in s:
if i == "0":
display.append("0")
elif i == "1":
display.append("1")
else:
if display == []:
continue
else:
display.pop(-1)
#print(display)
ans="".join(display)
print(ans)
|
s260633339
|
Accepted
| 17
| 3,060
| 308
|
#2019/10/22
#s = open(0).read()
s = input()
display = []
for i in s:
if i == "0":
display.append("0")
elif i == "1":
display.append("1")
else:
if display == []:
continue
else:
display.pop(-1)
#print(display)
ans="".join(display)
print(ans)
|
s011687519
|
p03494
|
u944460773
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 182
|
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(len(a)):
if a[i] % 2 == 0:
a[i] = a[i] / 2
else:
break;
ans += 1
print(ans)
|
s618863456
|
Accepted
| 20
| 3,060
| 211
|
n = int(input())
a = list(map(int, input().split()))
ans = 100000000
for i in range(len(a)):
tmp = 0
while a[i] % 2 == 0 and tmp < ans:
a[i] = a[i] / 2
tmp += 1
ans = tmp
print(ans)
|
s760970395
|
p03214
|
u482157295
| 2,525
| 1,048,576
|
Wrong Answer
| 17
| 3,064
| 295
|
Niwango-kun is an employee of Dwango Co., Ltd. One day, he is asked to generate a thumbnail from a video a user submitted. To generate a thumbnail, he needs to select a frame of the video according to the following procedure: * Get an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the number of the frames of the video, and each a_i denotes the representation of the i-th frame of the video. * Select t-th frame whose representation a_t is nearest to the average of all frame representations. * If there are multiple such frames, select the frame with the smallest index. Find the index t of the frame he should select to generate a thumbnail.
|
n = int(input())
numlist = list(map(int, input().split()))
cal = 0
for i in numlist:
cal = cal + i
ave = cal / (n)
dummy = abs(numlist[0]-ave)
index = 0
count = 0
for j in numlist:
kyori = abs(j-ave)
if dummy > kyori:
dummy = kyori
index = count
count = count + 1
print(index+1)
|
s852018064
|
Accepted
| 17
| 3,060
| 294
|
n = int(input())
numlist = list(map(int, input().split()))
cal = 0
for i in numlist:
cal = cal + i
ave = cal / (n)
dummy = abs(numlist[0]-ave)
index = 0
count = 0
for j in numlist:
kyori = abs(j-ave)
if dummy > kyori:
dummy = kyori
index = count
count = count + 1
print(index)
|
s302690807
|
p02613
|
u772705651
| 2,000
| 1,048,576
|
Wrong Answer
| 147
| 16,488
| 384
|
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.
|
import collections
judgement = []
while True:
try:
judgement.append(input())
except:
break
counter = collections.Counter(judgement)
n_ac = counter.get('AC', 0)
n_ma = counter.get('MA', 0)
n_tle = counter.get('TLE', 0)
n_re = counter.get('RE', 0)
print('AC x {}'.format(n_ac))
print('MA x {}'.format(n_ma))
print('TLE x {}'.format(n_tle))
print('RE x {}'.format(n_re))
|
s196977756
|
Accepted
| 148
| 16,460
| 387
|
import collections
judgement = []
while True:
try:
judgement.append(input())
except:
break
counter = collections.Counter(judgement)
n_ac = counter.get('AC', 0)
n_wa = counter.get('WA', 0)
n_tle = counter.get('TLE', 0)
n_re = counter.get('RE', 0)
print('AC x {}'.format(n_ac))
print('WA x {}'.format(n_wa))
print('TLE x {}'.format(n_tle))
print('RE x {}'.format(n_re))
|
s872858023
|
p03547
|
u054717609
| 2,000
| 262,144
|
Wrong Answer
| 33
| 4,336
| 147
|
In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`, `D`, `E` or `F`. When X and Y are seen as hexadecimal numbers, which is larger?
|
import random
g=random.randint(10,15)
h=random.randint(10,15)
x=g
y=h
if(x<y):
print("<")
elif(x>y):
print(">")
else:
print("=")
|
s030345621
|
Accepted
| 18
| 3,064
| 453
|
s1,s2=input().split(" ")
s1=s1.lower()
s2=s2.lower()
flag=0
if(len(s1)>len(s2)):
a=len(s2)
else:
a=len(s1)
for i in range(0,a):
if(s1[i]==s2[i]):
flag=flag+1
elif(s1[i]>s2[i]):
print('>')
break;
elif(s1[i]<s2[i]):
print('<')
break;
if(flag==a):
if(len(s1)>len(s2)):
print(">")
elif(len(s1)<len(s2)):
print("<")
else:
print("=")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.