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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s694272302
|
p03455
|
u400596590
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 90
|
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:
print ('odd')
else:
print('even')
|
s636180481
|
Accepted
| 17
| 2,940
| 90
|
a,b = map(int,input().split())
if a*b % 2:
print ('Odd')
else:
print('Even')
|
s613230912
|
p02416
|
u650790815
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,412
| 89
|
Write a program which reads an integer and prints sum of its digits.
|
while 1:
s = input()
if s == '0':
break
print(sum(int(n)) for n in s)
|
s960385878
|
Accepted
| 30
| 7,656
| 80
|
while 1:
s = input()
if s == '0':break
print(sum(int(n) for n in s))
|
s118763305
|
p03386
|
u244836567
| 2,000
| 262,144
|
Wrong Answer
| 2,266
| 60,324
| 188
|
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,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if (a+c-1)>(b-c-1):
for i in range(c):
print(a+i)
for i in range(c):
print(b-c+1+i)
else:
for i in range(a,b+1):
print(i)
|
s992471657
|
Accepted
| 27
| 9,116
| 188
|
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if (a+c-1)<(b-c+1):
for i in range(c):
print(a+i)
for i in range(c):
print(b-c+1+i)
else:
for i in range(a,b+1):
print(i)
|
s787960597
|
p02260
|
u663910047
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,672
| 272
|
Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 if A[j] < A[mini] 5 mini = j 6 swap A[i] and A[mini] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i ≠ mini.
|
n = int(input())
k = [int(i) for i in input().split()]
m = 0
for i in range(n):
minj = k[i]
for j in range(i,n):
if minj > k[j]:
minj = k[j]
k[j]=k[i]
m += 1
k[i] = minj
print(' '.join(map(str, k)))
print(m)
|
s294760108
|
Accepted
| 20
| 7,728
| 291
|
n = int(input())
k = [int(i) for i in input().split()]
m = 0
for i in range(n):
minj = i
for j in range(i,n):
if k[j] < k[minj]:
minj = j
x = k[i]
k[i] = k[minj]
k[minj]=x
if k[i] != k[minj]:
m += 1
print(' '.join(map(str, k)))
print(m)
|
s721279664
|
p03671
|
u145600939
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 67
|
Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
|
abc = list(map(int,input().split()))
abc.sort()
print(sum(abc[:1]))
|
s327502024
|
Accepted
| 17
| 2,940
| 58
|
a,b,c = map(int,input().split())
print(a+b+c - max(a,b,c))
|
s725739814
|
p02268
|
u662418022
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,604
| 585
|
You are given a sequence of _n_ integers S and a sequence of different _q_ integers T. Write a program which outputs C, the number of integers in T which are also in the set S.
|
# -*- coding: utf-8 -*-
def binarySearch(A, key):
left = 0
right = len(A)
while left < right:
mid = (left + right) // 2
if A[mid] == key:
return mid
elif key < mid:
right = mid
else:
left = mid + 1
return "NOT_FOUND"
if __name__ == '__main__':
n = int(input())
S = [int(s) for s in input().split(" ")]
q = int(input())
T = [int(t) for t in input().split(" ")]
count = 0
for t in T:
if binarySearch(S, t) != "NOT_FOUND":
count += 1
print(count)
|
s809489169
|
Accepted
| 270
| 16,896
| 588
|
# -*- coding: utf-8 -*-
def binarySearch(A, key):
left = 0
right = len(A)
while left < right:
mid = (left + right) // 2
if A[mid] == key:
return mid
elif key < A[mid]:
right = mid
else:
left = mid + 1
return "NOT_FOUND"
if __name__ == '__main__':
n = int(input())
S = [int(s) for s in input().split(" ")]
q = int(input())
T = [int(t) for t in input().split(" ")]
count = 0
for t in T:
if binarySearch(S, t) != "NOT_FOUND":
count += 1
print(count)
|
s640718924
|
p03610
|
u292735000
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,188
| 128
|
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
|
s_list = list(input().split())
s_out = ''
for i in range(len(s_list)):
if i % 2 != 0:
s_out += s_list[i]
print(s_out)
|
s651835966
|
Accepted
| 45
| 3,992
| 133
|
s_list = [s for s in input()]
s_out = ''
for i in range(len(s_list)):
if (i + 1) % 2 != 0:
s_out += s_list[i]
print(s_out)
|
s914371906
|
p04011
|
u642418876
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 111
|
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
|
N=int(input())
K=int(input())
X=int(input())
Y=int(input())
if N<=K:
print(X*N)
else:
print(X*N+Y*(N-K))
|
s097262126
|
Accepted
| 17
| 2,940
| 111
|
N=int(input())
K=int(input())
X=int(input())
Y=int(input())
if N<=K:
print(X*N)
else:
print(X*K+Y*(N-K))
|
s212685697
|
p03302
|
u257050137
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 71
|
You are given two integers a and b. Determine if a+b=15 or a\times b=15 or neither holds. Note that a+b=15 and a\times b=15 do not hold at the same time.
|
a, b = map(int, input().split())
print((a + b == 15) or (a * b == 15))
|
s446725131
|
Accepted
| 17
| 2,940
| 118
|
a, b = map(int, input().split())
if a + b == 15:
print('+')
elif a * b == 15:
print('*')
else:
print('x')
|
s173537535
|
p02396
|
u126478680
| 1,000
| 131,072
|
Wrong Answer
| 140
| 5,600
| 151
|
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.
|
#! python3
# print_test_cases.py
for i in range(10000):
x = int(input())
if x == 0:
break
print('Case ' + str(i) + ': ' + str(x))
|
s569468638
|
Accepted
| 140
| 5,596
| 153
|
#! python3
# print_test_cases.py
for i in range(10000):
x = int(input())
if x == 0:
break
print('Case ' + str(i+1) + ': ' + str(x))
|
s413368143
|
p03352
|
u252828980
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 38
|
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
|
n = int(input())
print((n**0.5//1)**2)
|
s270572153
|
Accepted
| 17
| 3,188
| 265
|
x = int(input())
li,p,ans = [],1,0
for b in range(2,int(x**0.5//1)+1):
while b**p<=x:
ans = max(ans,b**p)
p += 1
li.append(b**(p-1))
if b**p>x:
p = 1
break
if x <= 3:
print(x)
else:
print(max(li))
|
s788193526
|
p03836
|
u390958150
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,060
| 159
|
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
sx,sy,tx,ty = map(int,input().split())
dx = tx-sx
dy = ty-sx
ans = "R"*dx+"U"*dy+"L"*dx+"D"*dy+"D"+"R"*(dx+1)+"U"*(dy+1)+"L"+"L"*(dx+1)+"D"*(dy+1)
print(ans)
|
s093479813
|
Accepted
| 17
| 3,060
| 216
|
sx,sy,tx,ty = map(int,input().split())
tx -= sx
ty -= sy
ans = ""
ans += "U" * ty + "R" * tx
ans += "D" * ty + "L" * tx
ans += "L" + "U"*(ty+1) + "R"*(tx+1) + "D"
ans += "R" + "D"*(ty+1) + "L"*(tx+1) + "U"
print(ans)
|
s602118929
|
p02408
|
u312033355
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,596
| 230
|
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
#print(cards)
for c in ['S','H','C','D']:
for n in range (1,13):
key=c+''+str(n)
if not key in cards:
print(key)
|
s384789593
|
Accepted
| 20
| 5,600
| 231
|
n=int(input())
cards={}
for i in range(n):
card =input()
cards[card]=1
#print(cards)
for c in ['S','H','C','D']:
for n in range (1,14):
key=c+' '+str(n)
if not key in cards:
print(key)
|
s696602920
|
p03048
|
u277353449
| 2,000
| 1,048,576
|
Wrong Answer
| 20
| 2,940
| 167
|
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?
|
a,b,c,n=map(int,input().split())
d=[a,b,c]
d.sort()
e=0
for i in range(0,n//c):
n=n-c*i
for k in range(0,n//b):
n=n-b*i
if n//a==0:
e=e+1
print(e)
|
s595344304
|
Accepted
| 1,525
| 3,064
| 196
|
a,b,c,n=map(int,input().split())
d=[a,b,c]
d.sort()
a=d[0]
b=d[1]
c=d[2]
e=0
for i in range(0,n//c+1):
for k in range(0,(n-c*i)//b+1):
if ((n-c*i-b*k)%a)==0:
e=e+1
print(e)
|
s616202245
|
p03730
|
u955248595
| 2,000
| 262,144
|
Wrong Answer
| 27
| 9,100
| 142
|
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 = (int(T) for T in input().split())
Flag = False
for T in range(1,B+1):
if (T*A)%B==C:
Flag = True
print(['No','Yes'][Flag])
|
s968344147
|
Accepted
| 28
| 9,164
| 142
|
A,B,C = (int(T) for T in input().split())
Flag = False
for T in range(1,B+1):
if (T*A)%B==C:
Flag = True
print(['NO','YES'][Flag])
|
s893213739
|
p03359
|
u565204025
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 102
|
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
|
# -*- coding: utf-8 -*-
a, b = map(int,input().split())
if b > a:
print(a)
else:
print(a-1)
|
s836021710
|
Accepted
| 18
| 2,940
| 78
|
a, b = map(int,input().split())
if b >= a:
print(a)
else:
print(a-1)
|
s829936025
|
p03854
|
u223663729
| 2,000
| 262,144
|
Wrong Answer
| 92
| 3,188
| 483
|
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`.
|
def main():
s = input()
dream = False
erase = False
while s:
if s.startswith('dream'):
s = s[5:]
dream = True
erase = False
elif s.startswith('erase'):
s = s[5:]
dream = False
erase = True
elif s.startswith('er') and dream:
s = s[2:]
dream = False
elif s.startswith('r') and erase:
s = s[1:]
erase = False
else:
return False
return True
if main():
print('Yes')
else:
print('No')
|
s943934090
|
Accepted
| 62
| 24,932
| 360
|
# dfs
import sys
sys.setrecursionlimit(10**6)
C = ['dream', 'dreamer', 'erase', 'eraser']
S = input()
L = len(S)
def dfs(l):
if l == L:
return True
elif l > L:
return False
for c in C:
if S.find(c, l, l+7) == l:
if dfs(l+len(c)):
return True
return False
print('YES' if dfs(0) else 'NO')
|
s217884786
|
p03470
|
u594956556
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 149
|
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
N = int(input())
d = list(map(int, input().split()))
d.sort()
now = 0
ans = 0
for di in d:
if di > now:
ans += 1
now = di
print(ans)
|
s761017290
|
Accepted
| 17
| 2,940
| 150
|
N = int(input())
d = [int(input()) for _ in range(N)]
d.sort()
now = 0
ans = 0
for di in d:
if di > now:
ans += 1
now = di
print(ans)
|
s679622461
|
p03698
|
u011872685
| 2,000
| 262,144
|
Wrong Answer
| 29
| 8,992
| 183
|
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
data=list(input())
c=0
for i in range(0,len(data)-1):
for j in range(i+1,len(data)):
if data[i]==data[j]:
c=c+1
if c==0:
print('Yes')
else:
print('No')
|
s411746488
|
Accepted
| 29
| 9,028
| 183
|
data=list(input())
c=0
for i in range(0,len(data)-1):
for j in range(i+1,len(data)):
if data[i]==data[j]:
c=c+1
if c==0:
print('yes')
else:
print('no')
|
s775786823
|
p02386
|
u328199937
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,612
| 1,489
|
Write a program which reads $n$ dices constructed in the same way as [Dice I](description.jsp?id=ITP1_11_A), and determines whether they are all different. For the determination, use the same way as [Dice III](description.jsp?id=ITP1_11_C).
|
def north(list):
List = []
List.append(list[1])
List.append(list[5])
List.append(list[2])
List.append(list[3])
List.append(list[0])
List.append(list[4])
return List
def west(list):
List = []
List.append(list[2])
List.append(list[1])
List.append(list[5])
List.append(list[0])
List.append(list[4])
List.append(list[3])
return List
def south(list):
List = []
List.append(list[4])
List.append(list[0])
List.append(list[2])
List.append(list[3])
List.append(list[5])
List.append(list[1])
return List
def east(list):
List = []
List.append(list[3])
List.append(list[1])
List.append(list[0])
List.append(list[5])
List.append(list[4])
List.append(list[2])
return List
def sort123(DD):
D = [DD]
for i in range(0, 3):
D.append(north(D[i]))
D.append(south(west(D[0])))
D.append(south(east(D[0])))
for i in range(6):
for j in range(3):
if j == 0:
D.append(east(D[i + j]))
else:
D.append(east(D[5 + 3 * i + j]))
D.sort()
return D[0]
n = int(input())
dice = []
for i in range(n):
dice.append(sort123(list(map(int, input().split()))))
key = 0
for i in range(1, len(dice)):
if key == 1: break
for j in range(i + 1, len(dice)):
if dice[i] == dice[j]:
print('No')
key = 1
break
if key == 0:
print('Yes')
|
s221018341
|
Accepted
| 20
| 5,620
| 1,489
|
def north(list):
List = []
List.append(list[1])
List.append(list[5])
List.append(list[2])
List.append(list[3])
List.append(list[0])
List.append(list[4])
return List
def west(list):
List = []
List.append(list[2])
List.append(list[1])
List.append(list[5])
List.append(list[0])
List.append(list[4])
List.append(list[3])
return List
def south(list):
List = []
List.append(list[4])
List.append(list[0])
List.append(list[2])
List.append(list[3])
List.append(list[5])
List.append(list[1])
return List
def east(list):
List = []
List.append(list[3])
List.append(list[1])
List.append(list[0])
List.append(list[5])
List.append(list[4])
List.append(list[2])
return List
def sort123(DD):
D = [DD]
for i in range(0, 3):
D.append(north(D[i]))
D.append(south(west(D[0])))
D.append(south(east(D[0])))
for i in range(6):
for j in range(3):
if j == 0:
D.append(east(D[i + j]))
else:
D.append(east(D[5 + 3 * i + j]))
D.sort()
return D[0]
n = int(input())
dice = []
for i in range(n):
dice.append(sort123(list(map(int, input().split()))))
key = 0
for i in range(0, len(dice)):
if key == 1: break
for j in range(i + 1, len(dice)):
if dice[i] == dice[j]:
print('No')
key = 1
break
if key == 0:
print('Yes')
|
s865836808
|
p03963
|
u102960641
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 55
|
There are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors. Find the number of the possible ways to paint the balls.
|
n,k = map(int, input().split())
ans = k * pow(k-1, n-1)
|
s944974138
|
Accepted
| 17
| 2,940
| 66
|
n,k = map(int, input().split())
ans = k * pow(k-1, n-1)
print(ans)
|
s107161298
|
p03645
|
u405660020
| 2,000
| 262,144
|
Wrong Answer
| 977
| 81,444
| 486
|
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services. Help him.
|
n,m=map(int,input().split())
ab=[list(map(int, input().split())) for _ in range(m)]
graph = [[] for _ in range(n)]
for v in ab:
graph[v[0]-1].append(v[1]-1)
graph[v[1]-1].append(v[0]-1)
# print(graph)
from collections import deque
queue = deque([0])
d = [100] * n
d[0] = 0
while queue:
v = queue.popleft()
for i in graph[v]:
if d[i]==10**6:
d[i] = d[v] + 1
queue.append(i)
# print(d)
print('POSSIBLE' if d[n-1]<=2 else 'IMPOSSIBLE')
|
s672693764
|
Accepted
| 1,143
| 81,616
| 488
|
n,m=map(int,input().split())
ab=[list(map(int, input().split())) for _ in range(m)]
graph = [[] for _ in range(n)]
for v in ab:
graph[v[0]-1].append(v[1]-1)
graph[v[1]-1].append(v[0]-1)
# print(graph)
from collections import deque
queue = deque([0])
d = [10**6] * n
d[0] = 0
while queue:
v = queue.popleft()
for i in graph[v]:
if d[i]==10**6:
d[i] = d[v] + 1
queue.append(i)
# print(d)
print('POSSIBLE' if d[n-1]<=2 else 'IMPOSSIBLE')
|
s254360709
|
p03493
|
u744115306
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 97
|
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.
|
a,b,c = input()
d = 0
if a == 1:
d += 1
if b == 1:
d += 1
if c == 1:
d += 1
print(d)
|
s046568910
|
Accepted
| 17
| 2,940
| 25
|
print(input().count('1'))
|
s454381481
|
p04043
|
u843482581
| 2,000
| 262,144
|
Wrong Answer
| 30
| 9,184
| 203
|
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
A, B, C = map(int, input().split())
if A == 5 and B == 7 and C == 7:
print("YES")
elif A == 7 and B == 5 and C == 7:
print("YES")
elif A == 7 and B == 7 and C == 5:
print("YES")
else:
print("NO")
|
s126505807
|
Accepted
| 27
| 8,992
| 203
|
A, B, C = map(int, input().split())
if A == 5 and B == 5 and C == 7:
print("YES")
elif A == 5 and B == 7 and C == 5:
print("YES")
elif A == 7 and B == 5 and C == 5:
print("YES")
else:
print("NO")
|
s303094125
|
p03477
|
u492030100
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 99
|
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.
|
A,B,C,D=map(int,input().split())
print('Left' if A+B<C+D else 'Balanced' if A+B==C+D else 'Right')
|
s006986265
|
Accepted
| 18
| 2,940
| 99
|
A,B,C,D=map(int,input().split())
print('Left' if A+B>C+D else 'Balanced' if A+B==C+D else 'Right')
|
s711217427
|
p04043
|
u506422818
| 2,000
| 262,144
|
Wrong Answer
| 27
| 9,012
| 105
|
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 = input().split(" ")
a.sort()
if (a[0] == a[1] == 5) and a[2] == 7:
print("Yes")
else:
print("No")
|
s734256530
|
Accepted
| 25
| 8,856
| 93
|
a = input()
if a.count("7") ==1 and a.count("5") == 2:
print("YES")
else:
print("NO")
|
s127421233
|
p03555
|
u937303520
| 2,000
| 262,144
|
Wrong Answer
| 28
| 9,052
| 151
|
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
|
a = list(map(str, input()))
b = list(map(str, input()))
if a[0] == b[0] and a[1] == b[1] and a[2] == b[2]:
print('Yes')
else:
print('No')
|
s455817639
|
Accepted
| 28
| 9,020
| 146
|
a = list(map(str, input()))
b = list(map(str, input()))
if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:
print('YES')
else:
print('NO')
|
s705020317
|
p02841
|
u076849601
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 98
|
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month.
|
a,b=map(int,input().split())
c,d=map(int,input().split())
if a==c:
print("1")
else:
print("0")
|
s894266513
|
Accepted
| 20
| 2,940
| 94
|
a,b=map(int,input().split())
c,d=map(int,input().split())
if a==c:
print(0)
else:
print(1)
|
s261345774
|
p03456
|
u773200505
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 156
|
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.
|
# coding: utf-8
import math
string=input().split()
number=int(string[0]+string[1])
x=math.sqrt(number)
if int(x)==x:
print("yes")
else:
print("no")
|
s707169092
|
Accepted
| 17
| 3,060
| 156
|
# coding: utf-8
import math
string=input().split()
number=int(string[0]+string[1])
x=math.sqrt(number)
if int(x)==x:
print("Yes")
else:
print("No")
|
s980070292
|
p03501
|
u981931040
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 56
|
You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours.
|
N, A, B = map(int,input().split())
print(min(N + A , B))
|
s709922302
|
Accepted
| 17
| 2,940
| 57
|
N, A, B = map(int,input().split())
print(min(N * A , B))
|
s129859306
|
p03611
|
u097121858
| 2,000
| 262,144
|
Wrong Answer
| 82
| 14,564
| 321
|
You are given an integer sequence of length N, a_1,a_2,...,a_N. For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices.
|
from collections import defaultdict
n = int(input())
A = list(map(int, input().split()))
D = defaultdict(lambda: 0)
for a in A:
D[a] += 1
M = set()
highest = max(D.values())
for k, v in D.items():
if v == highest:
M.add(k)
ans = 0
for m in M:
ans = max(ans, D[m - 1] + D[m] + D[m + 1])
print(ans)
|
s583333383
|
Accepted
| 213
| 19,424
| 318
|
from collections import defaultdict
n = int(input())
A = list(map(int, input().split()))
D = defaultdict(lambda: 0)
for a in A:
D[a] += 1
ans = 0
for a in A:
ans = max(
ans,
D[a - 2] + D[a - 1] + D[a],
D[a - 1] + D[a] + D[a + 1],
D[a] + D[a + 1] + D[a + 2],
)
print(ans)
|
s440973371
|
p03813
|
u766566560
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 66
|
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise. You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise.
|
x = int(input())
if x > 1200:
print('ABC')
else:
print('ARC')
|
s942321952
|
Accepted
| 21
| 3,316
| 67
|
x = int(input())
if x < 1200:
print('ABC')
else:
print('ARC')
|
s099582096
|
p03401
|
u513081876
| 2,000
| 262,144
|
Wrong Answer
| 146
| 14,168
| 355
|
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.
|
n = int(input())
a = [int(i) for i in input().split()]
ans = [0] * n
summ = sum([abs(a[i]-a[i+1]) for i in range(n-1)])
summ += abs(a[0]) + abs(a[-1])
for i in range(1, n-1):
ans[i] = summ -abs(a[i-1]-a[i])-abs(a[i+1]-a[i])+abs(a[i-1]-a[i+1])
ans[0] = summ - abs(a[0]) -abs(a[0]-a[1]) + abs(a[1])
ans[-1] = summ - abs(a[-1]) -abs(a[-1]-a[-2])+abs(a[-2])
|
s624077086
|
Accepted
| 215
| 16,484
| 319
|
N = int(input())
A = [int(i) for i in input().split()]
A.insert(0, 0)
A.append(0)
dif_1 = [0] * (N+1)
dif_2 = [0] * N
for i in range(N+1):
dif_1[i] = abs(A[i] - A[i+1])
for i in range(N):
dif_2[i] = abs(A[i] - A[i+2])
num = sum(dif_1)
for i in range(N):
print(num - (dif_1[i] + dif_1[i+1]) + dif_2[i])
|
s690175877
|
p02612
|
u010777300
| 2,000
| 1,048,576
|
Wrong Answer
| 29
| 9,080
| 64
|
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())
if n%1000==0:
print(0)
else:
print(n//1000+1)
|
s546027674
|
Accepted
| 28
| 9,004
| 74
|
n=int(input())
if n%1000==0:
print(0)
else:
print((n//1000+1)*1000-n)
|
s552856902
|
p02386
|
u024715419
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,692
| 1,002
|
Write a program which reads $n$ dices constructed in the same way as [Dice I](description.jsp?id=ITP1_11_A), and determines whether they are all different. For the determination, use the same way as [Dice III](description.jsp?id=ITP1_11_C).
|
class dice:
def __init__(self, pip):
self.pip = pip
def move(self,dir):
if str(dir) == "E":
self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[3],self.pip[0],self.pip[5],self.pip[2]
elif str(dir) == "W":
self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[2],self.pip[5],self.pip[0],self.pip[3]
elif str(dir) == "N":
self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[1],self.pip[5],self.pip[0],self.pip[4]
elif str(dir) == "S":
self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[4],self.pip[0],self.pip[5],self.pip[1]
n = int(input())
ans = "Yes"
ds =[]
for i in range(n):
ds.append(dice(list(map(int,input().split()))))
for i in range(len(ds)-1):
for j in range(i+1,len(ds)):
d_tmp = dice(ds[j].pip)
for op in "EEENEEENEEESEEESEEENEEEN":
if ds[i].pip == d_tmp.pip:
ans = "No"
break
print(ans)
|
s132567623
|
Accepted
| 230
| 7,764
| 1,029
|
class dice:
def __init__(self, pip):
self.pip = pip
def move(self,dir):
if str(dir) == "E":
self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[3],self.pip[0],self.pip[5],self.pip[2]
elif str(dir) == "W":
self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[2],self.pip[5],self.pip[0],self.pip[3]
elif str(dir) == "N":
self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[1],self.pip[5],self.pip[0],self.pip[4]
elif str(dir) == "S":
self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[4],self.pip[0],self.pip[5],self.pip[1]
n = int(input())
ans = "Yes"
ds =[]
for i in range(n):
ds.append(dice(list(map(int,input().split()))))
for i in range(len(ds)-1):
for j in range(i+1,len(ds)):
d_tmp = dice(ds[j].pip)
for op in "EEENEEENEEESEEESEEENEEEN":
if ds[i].pip == d_tmp.pip:
ans = "No"
break
d_tmp.move(op)
print(ans)
|
s952131644
|
p03698
|
u219369949
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 139
|
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
S = input()
l = []
ans = 'Yes'
for s in S:
if s not in l:
l.append(s)
else:
ans = 'No'
break
print(ans)
|
s424654259
|
Accepted
| 18
| 2,940
| 139
|
S = input()
l = []
ans = 'yes'
for s in S:
if s not in l:
l.append(s)
else:
ans = 'no'
break
print(ans)
|
s377121196
|
p03693
|
u474925961
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 160
|
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
import sys
if sys.platform =='ios':
sys.stdin=open('input_file.txt')
r,g,b=map(int,input().split())
if (10*b+g)%4==0:
print("YES")
else:
print("NO")
|
s945198750
|
Accepted
| 17
| 2,940
| 85
|
r,g,b=map(int,input().split())
a=10*g+b
if a%4==0:
print("YES")
else:
print("NO")
|
s138311418
|
p04012
|
u397531548
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 211
|
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
|
S=input()
for X in ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]:
if int(S.count(X))%2==1:
print("NO")
break
else:
print("YES")
|
s301815486
|
Accepted
| 17
| 3,060
| 211
|
w=input()
for X in ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]:
if int(w.count(X))%2==1:
print("No")
break
else:
print("Yes")
|
s741932510
|
p03229
|
u793460864
| 2,000
| 1,048,576
|
Wrong Answer
| 270
| 7,472
| 527
|
You are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.
|
N = int(input())
A =[0]*N
for i in range(N):
A[i] = int(input())
A.sort(reverse=True)
X=0
Y=0
if N % 2 == 0:
for i in range(N//2-2):
X = X + 2*A[i] -2*A[-i-1]
X = X + A[N//2-1] -A[N//2]
print(X)
if N % 2 == 1:
for i in range(N//2-1):
X = X + 2 * A[i]
Y = Y - 2 * A[-i-1]
for i in range (N//2-2):
X = X - 2 * A[-i-1]
Y = Y + 2 * A[i]
X = X - A[N//2] - A[N//2+1]
Y = Y + A[N//2-1] + A[N//2]
print(max(X,Y))
|
s646943891
|
Accepted
| 259
| 7,472
| 519
|
N = int(input())
A =[0]*N
for i in range(N):
A[i] = int(input())
A.sort(reverse=True)
X=0
Y=0
if N % 2 == 0:
for i in range(N//2-1):
X = X + 2*A[i] -2*A[-i-1]
X = X + A[N//2-1] -A[N//2]
print(X)
if N % 2 == 1:
for i in range(N//2):
X = X + 2 * A[i]
Y = Y - 2 * A[-i-1]
for i in range (N//2-1):
X = X - 2 * A[-i-1]
Y = Y + 2 * A[i]
X = X - A[N//2] - A[N//2+1]
Y = Y + A[N//2-1] + A[N//2]
print(max(X,Y))
|
s601181407
|
p03380
|
u393352862
| 2,000
| 262,144
|
Wrong Answer
| 231
| 14,060
| 219
|
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
|
n = int(input())
A = list(map(int, input().split()))
x = max(A)
y = 1e9
x2 = x/2
for a in sorted(A):
if abs(x2 - a) < abs(x2 - y):
y = a
print(x, y, abs(x/2 - a))
else:
break
print(x, y)
|
s678147287
|
Accepted
| 98
| 14,052
| 185
|
n = int(input())
A = list(map(int, input().split()))
x = max(A)
y = 1e9
x2 = x/2
for a in sorted(A):
if abs(x2 - a) < abs(x2 - y):
y = a
else:
break
print(x, y)
|
s840797413
|
p03563
|
u222840844
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 63
|
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
|
##Rating Goal
a = int(input())
b = int(input())
print((a+b)/2)
|
s561803073
|
Accepted
| 17
| 3,064
| 61
|
##Rating Goal
a = int(input())
b = int(input())
print(2*b-a)
|
s898943731
|
p02600
|
u727787724
| 2,000
| 1,048,576
|
Wrong Answer
| 26
| 9,104
| 42
|
M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a _kyu_ (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have?
|
a=int(input())
print(max(8-(a-400)/200,1))
|
s119892741
|
Accepted
| 29
| 8,972
| 44
|
a=int(input())
print(max(8-(a-400)//200,1))
|
s667912345
|
p03555
|
u143509139
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 41
|
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
|
print('YNEOS'[input()==input()[::-1]::2])
|
s015509802
|
Accepted
| 17
| 2,940
| 41
|
print('YNEOS'[input()!=input()[::-1]::2])
|
s663674028
|
p02659
|
u653807637
| 2,000
| 1,048,576
|
Wrong Answer
| 25
| 9,168
| 78
|
Compute A \times B, truncate its fractional part, and print the result as an integer.
|
a, b = list(input().split())
a = int(a)
b = float(b) * 100
print(a * b // 100)
|
s180957384
|
Accepted
| 22
| 9,156
| 110
|
import math
a, b = map(str, input().split())
a_ = int(a)
b_ = round(100 * float(b))
print((a_ * b_) // 100)
|
s726006471
|
p03730
|
u412481017
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 182
|
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())
d=[]
i=1
while 1:
if (a*i)%b==c:
print("Yes")
break
if d.count((a*i)%b):
print("No")
break
else:
d.append((a*i)%b)
i=i+1
|
s325228314
|
Accepted
| 17
| 2,940
| 182
|
a,b,c=map(int,input().split())
d=[]
i=1
while 1:
if (a*i)%b==c:
print("YES")
break
if d.count((a*i)%b):
print("NO")
break
else:
d.append((a*i)%b)
i=i+1
|
s652649989
|
p03997
|
u698197687
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 280
|
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.
|
def calc_trapezoid_area(top_length, under_length, height):
return top_length + under_length * height / 2
if __name__=='__main__':
top_length, under_length, height = map(int, [input() for i in range(3)])
print(calc_trapezoid_area(top_length, under_length, height))
|
s579316523
|
Accepted
| 17
| 2,940
| 283
|
def calc_trapezoid_area(top_length, under_length, height):
return (top_length + under_length) * height // 2
if __name__=='__main__':
top_length, under_length, height = map(int, [input() for i in range(3)])
print(calc_trapezoid_area(top_length, under_length, height))
|
s389037806
|
p03814
|
u189487046
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,720
| 51
|
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
|
s = input()
print(s[s.index("A"):s.rindex("Z")+1])
|
s841688438
|
Accepted
| 17
| 3,500
| 50
|
s = input()
print(s.rindex("Z") - s.index("A")+1)
|
s750845006
|
p03795
|
u454557108
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 38
|
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
n = int(input())
print(n*800-n/15*200)
|
s280068374
|
Accepted
| 17
| 2,940
| 40
|
n = int(input())
print(n*800-n//15*200)
|
s135293107
|
p04043
|
u444856278
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 99
|
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
A = list(map(int,input().split()))
A.sort()
if A == [5,5,7]:
print("Yes")
else:
print("No")
|
s648148525
|
Accepted
| 16
| 2,940
| 99
|
A = list(map(int,input().split()))
A.sort()
if A == [5,5,7]:
print("YES")
else:
print("NO")
|
s816401783
|
p03997
|
u144980750
| 2,000
| 262,144
|
Wrong Answer
| 19
| 2,940
| 60
|
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()) for i in range(3)]
print((a[0]+a[1])*a[2]/2)
|
s503700972
|
Accepted
| 17
| 2,940
| 84
|
import math
a=[int(input()) for i in range(3)]
print(math.floor((a[0]+a[1])*a[2]/2))
|
s717371320
|
p03472
|
u860002137
| 2,000
| 262,144
|
Wrong Answer
| 355
| 11,980
| 348
|
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times. * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana. The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?
|
import sys
n, h = map(int, input().split())
a = []
b = []
for i in range(n):
x, y = map(int, input().split())
a.append(x)
b.append(y)
b.sort(reverse=True)
max_a = max(a)
b = [x for x in b if x > max_a]
for i, x in enumerate(b):
h -= x
if h <= 0:
print(i + 1)
sys.exit()
ans = i + 1 + h // max_a
print(ans)
|
s320453551
|
Accepted
| 248
| 13,544
| 529
|
import sys
n, h = map(int, input().split())
max_a = 0
b = []
for i in range(n):
x, y = map(int, input().split())
max_a = max(max_a, x)
b.append(y)
b = [x for x in b if x > max_a]
b.sort(reverse=True)
i = 0
if len(b) > 0:
for i, x in enumerate(b):
i += 1
h -= x
if h <= 0:
print(i)
sys.exit()
print((h + max_a - 1) // max_a + i)
|
s126803806
|
p02646
|
u571281863
| 2,000
| 1,048,576
|
Wrong Answer
| 21
| 9,172
| 125
|
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
if (B-A)>T*(V-W):
print('No')
else:
print('Yes')
|
s930864156
|
Accepted
| 22
| 9,196
| 130
|
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
if abs(B-A)<=T*(V-W):
print('YES')
else:
print('NO')
|
s793640814
|
p03730
|
u143492911
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 132
|
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())
for i in range(b):
if a*i%b==c:
print("YES")
break
else:
print("NO")
|
s083766464
|
Accepted
| 35
| 2,940
| 122
|
a,b,c=map(int,input().split())
for i in range(1,100000):
if a*i%b==c:
print("YES")
exit()
print("NO")
|
s153282662
|
p03993
|
u276115223
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 13,880
| 320
|
There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a _friendly pair_ if the following condition is met. * Rabbit i likes rabbit j and rabbit j likes rabbit i. Calculate the number of the friendly pairs.
|
N = int(input()) - 1
a = [int(s) - 1 for s in input().split()]
friends = []
for i in range(N):
print(i)
if a[a[i]] == i and ([i, a[i]] not in friends and [a[i], i] not in friends):
friends.append([i, a[i]])
print(len(friends))
|
s742687140
|
Accepted
| 83
| 13,880
| 273
|
N = int(input()) - 1
a = [int(s) - 1 for s in input().split()]
pairs = 0
for i in range(N):
if a[i] != 0 and a[a[i]] == i:
pairs += 1
a[i] = 0
a[a[i]] = 0
print(pairs)
|
s827003270
|
p02393
|
u630518143
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,596
| 209
|
Write a program which reads three integers, and prints them in ascending order.
|
nums = [int(e) for e in input().split()]
for i in range(len(nums)):
for j in range(i):
if nums[i]<nums[j]:
a = nums[i]
nums[i] = nums[j]
nums[j] = a
print(nums)
|
s935945574
|
Accepted
| 20
| 5,600
| 246
|
nums = [int(e) for e in input().split()]
for i in range(len(nums)):
for j in range(i):
if nums[i]<nums[j]:
a = nums[i]
nums[i] = nums[j]
nums[j] = a
nums_2 = " ".join(map(str, nums))
print(nums_2)
|
s617406117
|
p03797
|
u235210692
| 2,000
| 262,144
|
Wrong Answer
| 30
| 9,096
| 91
|
Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
|
n,m=[int(i) for i in input().split()]
if n>=2*m:
print(m//2)
else:
print(n+(m-2*n)//2)
|
s123918727
|
Accepted
| 29
| 9,164
| 110
|
n, m = [int(i) for i in input().split()]
if 2*n >= m:
print(m // 2)
else:
print(n + (m - 2 * n) // 4)
|
s441110721
|
p03470
|
u275934251
| 2,000
| 262,144
|
Wrong Answer
| 20
| 2,940
| 87
|
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
n=int(input())
d=[]
for i in range(n):
d.append(int(input()))
ans=set(d)
print(ans)
|
s340365486
|
Accepted
| 18
| 2,940
| 60
|
print(len(set([int(input()) for i in range(int(input()))])))
|
s122761123
|
p03377
|
u308684517
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 93
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a, b, x = map(int, input().split())
if a > x or a + b < x:
print("No")
else:
print("Yes")
|
s191360774
|
Accepted
| 17
| 2,940
| 88
|
a, b, x = map(int, input().split())
if a <= x <= a+b:
print("YES")
else:
print("NO")
|
s442114327
|
p03795
|
u426764965
| 2,000
| 262,144
|
Wrong Answer
| 28
| 9,116
| 57
|
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
n = int(input())
ans = 800 * n - 200 * n // 15
print(ans)
|
s034081008
|
Accepted
| 26
| 8,840
| 59
|
n = int(input())
ans = 800 * n - 200 * (n // 15)
print(ans)
|
s525340491
|
p02747
|
u673338219
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 3,064
| 150
|
A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string.
|
s = str(input())
if len(s)%2 != 0:
print("No")
exit()
for i in range(len(s)//2):
if s[i:i+1] != "hi":
print("No")
exit()
print("Yes")
|
s586052208
|
Accepted
| 17
| 2,940
| 163
|
s = str(input())
if len(s)%2 != 0:
print("No")
exit()
for j in range(len(s)//2):
if s[2*j] != "h" or s[2*j+1] != "i":
print("No")
exit()
print("Yes")
|
s091155822
|
p03816
|
u766684188
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 104
|
Snuke has decided to play a game using cards. He has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written. He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept. Operation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.
|
n=int(input())
a,b=n%11,n//11
if a==0:
print(b*2)
elif a<=6:
print(b*2+1)
else:
print(b*2+2)
|
s473202008
|
Accepted
| 37
| 16,500
| 50
|
input()
a=len(set(input().split()))
print(a-1+a%2)
|
s392228194
|
p04012
|
u593063683
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 204
|
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
|
#B
w = input()
dic = {chr(i+ord('a')): 0 for i in range(0, 26)}
for c in w:
dic[c] += 1
result = 'NO'
for i in range(26):
if dic[chr(i+ord('a'))] % 2 != 0: break
else: result = 'YES'
print(result)
|
s228708616
|
Accepted
| 18
| 3,060
| 218
|
#B
w = input()
dic = {chr(i+ord('a')): 0 for i in range(0, 26)}
for c in w:
dic[c] += 1
#print(dic) #
result = 'No'
for i in range(26):
if dic[chr(i+ord('a'))] % 2 != 0: break
else: result = 'Yes'
print(result)
|
s841830721
|
p02613
|
u724844363
| 2,000
| 1,048,576
|
Wrong Answer
| 157
| 16,156
| 345
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
n = int(input())
s = [str(input()) for _ in range(n)]
dic = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for i in s:
if i == 'AC':
dic['AC'] += 1
elif i == 'WA':
dic['WA'] += 1
elif i == 'TLE':
dic['TLE'] += 1
else:
dic['RE'] += 1
for i in dic:
# print(i)
print("{0} × {1}".format(i, dic[i]))
|
s236879553
|
Accepted
| 160
| 16,368
| 344
|
n = int(input())
s = [str(input()) for _ in range(n)]
dic = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for i in s:
if i == 'AC':
dic['AC'] += 1
elif i == 'WA':
dic['WA'] += 1
elif i == 'TLE':
dic['TLE'] += 1
else:
dic['RE'] += 1
for i in dic:
# print(i)
print("{0} x {1}".format(i, dic[i]))
|
s206879670
|
p04012
|
u016881126
| 2,000
| 262,144
|
Wrong Answer
| 28
| 9,340
| 324
|
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
|
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')
w = input()
import collections
c = collections.Counter(w)
print(c)
for k, v in c.items():
if v % 2 != 0:
print('No')
quit()
print('Yes')
|
s767184239
|
Accepted
| 30
| 9,308
| 315
|
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')
w = input()
import collections
c = collections.Counter(w)
for k, v in c.items():
if v % 2 != 0:
print('No')
quit()
print('Yes')
|
s703065562
|
p03737
|
u958210291
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 86
|
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
|
s1,s2,s3 = input().split()
s1 = s1[0:1]
s2 = s2[0:1]
s3 = s3[0:1]
print(s1 + s2 + s3)
|
s859310578
|
Accepted
| 17
| 2,940
| 125
|
s1,s2,s3 = input().split()
s1 = str(s1[0:1].upper())
s2 = str(s2[0:1].upper())
s3 = str(s3[0:1].upper())
print(s1 + s2 + s3)
|
s192841821
|
p02396
|
u394290028
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,568
| 109
|
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.
|
x = input().rsplit()
for i in range(len(x) - 1):
a = i + 1
print("Case "+ str(a) + ": " + str(x[i]))
|
s761699255
|
Accepted
| 80
| 6,228
| 241
|
nyuryoku = []
try:
while True:
s = input()
if s == 0:
break
nyuryoku.append(s)
except EOFError:
pass
for i in range(len(nyuryoku) - 1):
print('Case ' + str(i + 1) + ": " + str(nyuryoku[i]))
|
s500960011
|
p02646
|
u395010524
| 2,000
| 1,048,576
|
Wrong Answer
| 23
| 9,224
| 397
|
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.
|
i = list(map(int, input().split()))
j = list(map(int, input().split()))
t = int(input())
ans = "No"
if i[0] > j[0]:
i[1] = i[0] - t * i[1]
j[1] = j[0] - t * j[1]
if i[1] <= j[1]:
ans = "Yes"
elif i[0] < j[0]:
i[1] = i[0] + t * i[1]
j[1] = j[0] + t * j[1]
if i[1] >= j[1]:
ans = "Yes"
else:
ans = "Yes"
print(ans)
|
s992993837
|
Accepted
| 23
| 9,204
| 397
|
i = list(map(int, input().split()))
j = list(map(int, input().split()))
t = int(input())
ans = "NO"
if i[0] > j[0]:
i[1] = i[0] - t * i[1]
j[1] = j[0] - t * j[1]
if i[1] <= j[1]:
ans = "YES"
elif i[0] < j[0]:
i[1] = i[0] + t * i[1]
j[1] = j[0] + t * j[1]
if i[1] >= j[1]:
ans = "YES"
else:
ans = "YES"
print(ans)
|
s488872187
|
p03494
|
u731436822
| 2,000
| 262,144
|
Time Limit Exceeded
| 2,104
| 2,940
| 197
|
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()))
flag = True
count = 0
while(flag):
for i in range(N):
if A[i]%2:
flag = False
break
else:
count += 1
print(count)
|
s266307005
|
Accepted
| 18
| 3,060
| 220
|
N = int(input())
A = list(map(int,input().split()))
flag = True
count = 0
while(flag):
for i in range(N):
if A[i]%2:
flag = False
break
else:
A[i] /= 2
if flag:
count += 1
print(count)
|
s198616219
|
p03657
|
u203900263
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 86
|
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(A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0)
|
s135260611
|
Accepted
| 17
| 2,940
| 134
|
A, B = map(int, input().split())
if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
print('Possible')
else:
print('Impossible')
|
s049023993
|
p03024
|
u356532386
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 167
|
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
|
inp = input()
maru = inp.count('o')
batu = inp.count('x')
inp_length = inp.__len__()
if maru > 7 or 15 - inp_length >= 8 - maru:
print("Yes")
else:
print("No")
|
s119946520
|
Accepted
| 17
| 2,940
| 167
|
inp = input()
maru = inp.count('o')
batu = inp.count('x')
inp_length = inp.__len__()
if maru > 7 or 15 - inp_length >= 8 - maru:
print("YES")
else:
print("NO")
|
s174721360
|
p02645
|
u704158845
| 2,000
| 1,048,576
|
Wrong Answer
| 24
| 9,024
| 25
|
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.
|
s = input()
print(s[1:4])
|
s888873218
|
Accepted
| 21
| 8,900
| 25
|
s = input()
print(s[0:3])
|
s485867851
|
p03719
|
u766566560
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 87
|
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
A, B, C = map(int, input().split())
if A <= B <= C:
print('Yes')
else:
print('No')
|
s071521172
|
Accepted
| 17
| 2,940
| 88
|
A, B, C = map(int, input().split())
if A <= C <= B:
print('Yes')
else:
print('No')
|
s528610202
|
p03385
|
u556477263
| 2,000
| 262,144
|
Wrong Answer
| 25
| 8,960
| 122
|
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
li = list(input())
for i in li:
if i != 'b' or i != 'a' or i != 'c':
print('No')
exit()
print('Yes')
|
s417206471
|
Accepted
| 24
| 9,088
| 116
|
li = list(input())
if li[0] != li[1] and li[1] != li[2] and li[0] != li[2]:
print('Yes')
else:
print('No')
|
s980862566
|
p02279
|
u938045879
| 2,000
| 131,072
|
Wrong Answer
| 20
| 5,600
| 850
|
A graph _G_ = ( _V_ , _E_ ) is a data structure where _V_ is a finite set of vertices and _E_ is a binary relation on _V_ represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs). **Fig. 1** A free tree is a connnected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called "node." Your task is to write a program which reports the following information for each node _u_ of a given rooted tree _T_ : * node ID of _u_ * parent of _u_ * depth of _u_ * node type (root, internal node or leaf) * a list of chidlren of _u_ If the last edge on the path from the root _r_ of a tree _T_ to a node _x_ is ( _p_ , _x_ ), then _p_ is the **parent** of _x_ , and _x_ is a **child** of _p_. The root is the only node in _T_ with no parent. A node with no children is an **external node** or **leaf**. A nonleaf node is an **internal node** The number of children of a node _x_ in a rooted tree _T_ is called the **degree** of _x_. The length of the path from the root _r_ to a node _x_ is the **depth** of _x_ in _T_. Here, the given tree consists of _n_ nodes and evey node has a unique ID from 0 to _n_ -1. Fig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input. **Fig. 2**
|
n = int(input())
nodes = []
id_list = []
output = []
cnt = 0
for i in range(n):
id, _, *li = list(map(int, input().split(' ')))
nodes.append(li)
id_list.append(id)
def rooted_tree(id, depth, parent):
out = {}
ind = id_list.index(id)
out['node'] = id
out['parent'] = parent
out['depth'] = depth
out['c'] = nodes[ind]
if len(nodes[ind]) == 0:
out['type'] = 'leaf'
output.append(out)
return
if depth == 0:
out['type'] = 'root'
else:
out['type'] = 'internal node'
output.append(out)
for i in (nodes[ind]):
rooted_tree(i, depth+1, id)
rooted_tree(id_list[0], 0, -1)
for line in sorted(output, key=lambda x:x['node']):
print("node {}:parent = {}, depth = {}, {}, {}".format(line['node'], line['parent'], line['depth'], line['type'], line['c']))
|
s095316521
|
Accepted
| 960
| 45,904
| 790
|
n = int(input())
nodes = [0 for i in range(n)]
output = [None for i in range(n)]
cnt = 0
root = set(range(n))
for i in range(n):
id, _, *li = list(map(int, input().split(' ')))
root -= set(li)
nodes[id] = li
def rooted_tree(id, depth, parent):
out = {}
out['node'] = id
out['parent'] = parent
out['depth'] = depth
out['c'] = nodes[id]
if depth == 0:
out['type'] = 'root'
elif len(nodes[id]) == 0:
out['type'] = 'leaf'
else:
out['type'] = 'internal node'
output[id] = out
for i in (nodes[id]):
rooted_tree(i, depth+1, id)
rooted_tree(root.pop(), 0, -1)
for line in output:
print("node {}: parent = {}, depth = {}, {}, {}".format(line['node'], line['parent'], line['depth'], line['type'], line['c']))
|
s928827483
|
p02608
|
u814663076
| 2,000
| 1,048,576
|
Wrong Answer
| 1,027
| 9,392
| 627
|
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
N = ri()
f = [0] * N
for x in range(1,100+1):
for y in range(1, 100+1):
for z in range(1, 100+1):
h = x**2 + y**2 + z**2 + x*y + y*z + z*x
if h > N - 1:
continue
tmp = len(set([x, y, z]))
if tmp == 1:
f[h - 1] += 1
elif tmp == 2:
f[h - 1] += 3
else:
f[h - 1] += 6
for i in range(N):
print(f[i])
|
s190642723
|
Accepted
| 928
| 9,372
| 451
|
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
N = ri()
f = [0] * N
for x in range(1,100+1):
for y in range(1, 100+1):
for z in range(1, 100+1):
h = x**2 + y**2 + z**2 + x*y + y*z + z*x
if h > N:
continue
f[h - 1] += 1
for i in range(N):
print(f[i])
|
s182202194
|
p02842
|
u164727245
| 2,000
| 1,048,576
|
Wrong Answer
| 121
| 5,588
| 657
|
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
|
# coding: utf-8
from decimal import Decimal, ROUND_DOWN, ROUND_UP
def solve(*args: str) -> str:
n = Decimal(args[0])
rate = Decimal(1.08)
x_u = (n/rate).quantize(Decimal('0'), rounding=ROUND_UP)
x_d = (n/rate).quantize(Decimal('0'), rounding=ROUND_DOWN)
ret = ''
print(x_u, x_d)
if x_u == x_d:
ret = str(x_u)
elif (x_u*rate).quantize(Decimal('0'), rounding=ROUND_DOWN) == n:
ret = str(x_u)
elif (x_d*rate).quantize(Decimal('0'), rounding=ROUND_DOWN) == n:
ret = str(x_d)
else:
ret = ':('
return ret
if __name__ == "__main__":
print(solve(*(open(0).read().splitlines())))
|
s836838505
|
Accepted
| 42
| 5,332
| 637
|
# coding: utf-8
from decimal import Decimal, ROUND_DOWN, ROUND_UP
def solve(*args: str) -> str:
n = Decimal(args[0])
rate = Decimal(1.08)
x_u = (n/rate).quantize(Decimal('0'), rounding=ROUND_UP)
x_d = (n/rate).quantize(Decimal('0'), rounding=ROUND_DOWN)
ret = ''
if x_u == x_d:
ret = str(x_u)
elif (x_u*rate).quantize(Decimal('0'), rounding=ROUND_DOWN) == n:
ret = str(x_u)
elif (x_d*rate).quantize(Decimal('0'), rounding=ROUND_DOWN) == n:
ret = str(x_d)
else:
ret = ':('
return ret
if __name__ == "__main__":
print(solve(*(open(0).read().splitlines())))
|
s383736593
|
p03400
|
u857070771
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,316
| 195
|
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp.
|
n=int(input())
d,x=map(int,input().split())
a=[]
for _ in range(n):
a_=int(input())
a.append(a_)
for i in range(n):
for j in range(d+1):
if a[i]*j+1<=d:
print(a[i]*j+1)
x += 1
print(x)
|
s398530185
|
Accepted
| 19
| 2,940
| 176
|
n=int(input())
d,x=map(int,input().split())
a=[]
for _ in range(n):
a_=int(input())
a.append(a_)
for i in range(n):
for j in range(d+1):
if a[i]*j+1<=d:
x += 1
print(x)
|
s068402611
|
p03574
|
u074445770
| 2,000
| 262,144
|
Wrong Answer
| 27
| 3,188
| 424
|
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
|
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
dx=[1,1,1,0,0,-1,-1,-1]
dy=[-1,0,1,1,-1,-1,0,1]
for i in range(h):
for j in range(w):
if s[i][j]==".":
cnt=0
for k in range(8):
x=i+dx[k]
y=j+dy[k]
if x>=0 and y>=0 and s[i][j]=="#":
cnt+=1
s[i][j]=str(cnt)
for i in s:
print ("".join(i))
|
s107453601
|
Accepted
| 30
| 3,188
| 440
|
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
dx=[1,1,1,0,0,-1,-1,-1]
dy=[-1,0,1,1,-1,-1,0,1]
for i in range(h):
for j in range(w):
if s[i][j]==".":
cnt=0
for k in range(8):
x=i+dx[k]
y=j+dy[k]
if x>=0 and x<h and y>=0 and y<w and s[x][y]=="#":
cnt+=1
s[i][j]=str(cnt)
for i in s:
print ("".join(i))
|
s485766606
|
p03605
|
u558836062
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 75
|
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
|
N = input()
A = 0
if N.count('9') != 0:
print("YES")
else:
print('NO')
|
s939235810
|
Accepted
| 17
| 2,940
| 60
|
N = input()
if '9' in N:
print('Yes')
else:
print('No')
|
s349399684
|
p02831
|
u801701525
| 2,000
| 1,048,576
|
Time Limit Exceeded
| 2,206
| 9,192
| 101
|
Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted. We assume that a piece cannot be divided and distributed to multiple guests.
|
A, B = map(int,input().split())
while A != B:
if A > B:
A, B = B, A
A += A
print(A)
|
s391655895
|
Accepted
| 29
| 9,144
| 73
|
import math
A, B = map(int,input().split())
print((A*B)//math.gcd(A,B))
|
s489447565
|
p03599
|
u884323674
| 3,000
| 262,144
|
Wrong Answer
| 176
| 3,064
| 531
|
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the beaker. * Operation 3: Put C grams of sugar into the beaker. * Operation 4: Put D grams of sugar into the beaker. In our experimental environment, E grams of sugar can dissolve into 100 grams of water. Snuke will make sugar water with the highest possible density. The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted. We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.
|
A, B, C, D, E, F = 17, 19, 22, 26, 55, 2802
max_sugar = E * (A + B)
ab_max = (F // 100*A) + 1
max_conc = 0
result = [0, 0]
for a in range(ab_max):
for b in range(ab_max):
sugar_max = E * (a + b)
c = C * (sugar_max // C)
d = D * ((sugar_max - c) // D)
if (100*(a+b) > 0) and (100*(a+b) + c + d <= F):
conc = 100*(c + d) / (100*(a + b) + c + d)
if conc > max_conc:
max_conc = conc
result = [100*(a+b)+c+d, c+d]
print(result[0], result[1])
|
s902607655
|
Accepted
| 2,629
| 3,064
| 663
|
A, B, C, D, E, F = map(int, input().split())
ab_list = []
for a in range(F//100+1):
for b in range(F//100+1):
x = A*a + B*b
if (0 < 100*x <= F) and (x not in ab_list):
ab_list.append(x)
cd_list = []
for c in range(F+1):
for d in range(F+1):
y = C*c + D*d
if (y <= F) and (y not in cd_list):
cd_list.append(y)
max_conc = 0
result = [0, 0]
for i in ab_list:
for j in cd_list:
if (100*i + j <= F) and (j <= E*i):
conc = (100*j) / (100*i + j)
if conc >= max_conc:
max_conc = conc
result = [100*i + j, j]
print(result[0], result[1])
|
s142086407
|
p02678
|
u849756457
| 2,000
| 1,048,576
|
Wrong Answer
| 1,744
| 85,268
| 1,319
|
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
def q4():
class Room:
def __init__(self, i):
self.id = i
self.d = -1
self.next = []
self.sign = -1
def add_next(self, n):
self.next.append(n)
def print(self, tab=0, printed=[]):
if self.id in printed:
return
printed.append(self.id)
print(" " * tab + str(self.id) + f"({self.sign})")
for n in self.next:
n.print(tab + 1, list(printed))
N, M = [int(i) for i in input().split(" ")]
room_dict = {}
def get_room(i):
if i in room_dict:
return room_dict[i]
else:
room = Room(i)
room_dict[i] = room
return room
for i in range(M):
A, B = [int(i) for i in input().split(" ")]
get_room(A).add_next(get_room(B))
get_room(B).add_next(get_room(A))
d = 0
sign = -1
queue = deque([[get_room(1), d, sign]])
while queue:
room, d, sign = queue.popleft()
if room.sign != -1:
continue
room.sign = sign
room.d = d
for n in room.next:
queue.append([n, d + 1, room.id])
for i in range(2, N + 1):
print(get_room(i).sign)
q4()
|
s359341503
|
Accepted
| 1,460
| 85,432
| 1,336
|
from collections import deque
def q4():
class Room:
def __init__(self, i):
self.id = i
self.d = -1
self.next = []
self.sign = -1
def add_next(self, n):
self.next.append(n)
def print(self, tab=0, printed=[]):
if self.id in printed:
return
printed.append(self.id)
print(" " * tab + str(self.id) + f"({self.sign})")
for n in self.next:
n.print(tab + 1, list(printed))
N, M = [int(i) for i in input().split(" ")]
room_dict = {}
def get_room(i):
if i in room_dict:
return room_dict[i]
else:
room = Room(i)
room_dict[i] = room
return room
for i in range(M):
A, B = [int(i) for i in input().split(" ")]
get_room(A).add_next(get_room(B))
get_room(B).add_next(get_room(A))
d = 0
sign = -1
queue = deque([[get_room(1), d, sign]])
while queue:
room, d, sign = queue.popleft()
if room.sign != -1:
continue
room.sign = sign
room.d = d
for n in room.next:
queue.append([n, d + 1, room.id])
print("Yes")
for i in range(2, N + 1):
print(get_room(i).sign)
q4()
|
s166858273
|
p03543
|
u046136258
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 76
|
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
|
if len(list(set(input().split())))>=2:
print('Yes')
else:
print('No')
|
s578973577
|
Accepted
| 17
| 2,940
| 90
|
s=input()
if len(set(s[1:]))==1 or len(set(s[:-1]))==1:
print('Yes')
else:
print('No')
|
s450119640
|
p02742
|
u924717835
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 107
|
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
H,W = map(int,input().split())
if H % 2 == 1 and W % 2 ==1:
print((H*W+1)/2)
else:
print((H*W)/2)
|
s871884539
|
Accepted
| 17
| 2,940
| 188
|
H,W = map(int,input().split())
if H == 1 or W ==1:
print(1)
elif H % 2 == 1 and W % 2 ==1:
print(int((H*W+1)/2))
elif H ==0 or W == 0:
print(0)
else:
print(int((H*W)/2))
|
s752120134
|
p03624
|
u221401884
| 2,000
| 262,144
|
Wrong Answer
| 40
| 3,188
| 257
|
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
|
S = input()
bucket = [0] * 26
def c_to_num(c):
return ord(c) - 97
def num_to_c(num):
return chr(num+97)
for c in S:
bucket[c_to_num(c)] += 1
ret = 'None'
for i, n in enumerate(bucket):
if not n:
ret = num_to_c(i)
print(ret)
|
s141503906
|
Accepted
| 39
| 3,188
| 271
|
S = input()
bucket = [0] * 26
def c_to_num(c):
return ord(c) - 97
def num_to_c(num):
return chr(num+97)
for c in S:
bucket[c_to_num(c)] += 1
ret = 'None'
for i, n in enumerate(bucket):
if not n:
ret = num_to_c(i)
break
print(ret)
|
s086704631
|
p03386
|
u192541825
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 203
|
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
a,b,k=map(int,input().split())
list=set()
for i in range(k):
if a+i<=b:
list.add(a+i)
for i in range(k):
if b-k+i+1>=a:
list.add(b-k+i+1)
#l=list(list)
for x in list:
print(x)
|
s688432810
|
Accepted
| 18
| 3,060
| 201
|
a,b,k=map(int,input().split())
list=set()
for i in range(k):
if a+i<=b:
list.add(a+i)
for i in range(k):
if b-k+i+1>=a:
list.add(b-k+i+1)
l=sorted(list)
for x in l:
print(x)
|
s509679695
|
p03142
|
u223904637
| 2,000
| 1,048,576
|
Wrong Answer
| 2,105
| 21,756
| 317
|
There is a rooted tree (see Notes) with N vertices numbered 1 to N. Each of the vertices, except the root, has a directed edge coming from its parent. Note that the root may not be Vertex 1. Takahashi has added M new directed edges to this graph. Each of these M edges, u \rightarrow v, extends from some vertex u to its descendant v. You are given the directed graph with N vertices and N-1+M edges after Takahashi added edges. More specifically, you are given N-1+M pairs of integers, (A_1, B_1), ..., (A_{N-1+M}, B_{N-1+M}), which represent that the i-th edge extends from Vertex A_i to Vertex B_i. Restore the original rooted tree.
|
n,m=map(int,input().split())
g=[[] for i in range(n)]
for i in range(n+m-1):
a,b=map(int,input().split())
g[a-1].append(b)
for i in range(n):
if len(g[i])==0:
r=i
ans=[0]*n
q=[i]
while len(q)>0:
u=q.pop()
for v in g[u]:
ans[v-1]=u+1
q.append(v-1)
for i in ans:
print(i)
|
s247455018
|
Accepted
| 586
| 23,948
| 429
|
from collections import deque
n,m=map(int,input().split())
g=[[] for i in range(n)]
ro=[0]*n
for i in range(n+m-1):
a,b=map(int,input().split())
g[a-1].append(b)
ro[b-1]+=1
for i in range(n):
if ro[i]==0:
r=i
ans=[0]*n
q=deque([r])
while len(q)>0:
u=q.popleft()
for v in g[u]:
ro[v-1]-=1
if ro[v-1]==0:
ans[v-1]=u+1
q.append(v-1)
for i in ans:
print(i)
|
s832765461
|
p03352
|
u698771758
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 132
|
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
|
x=int(input())
b=[2,3,5,7,11,13,17,19,23,29,31]
c=[]
for i in b:
j=1
while x>j:
j*=i
c.append(j//i)
print(c[-1])
|
s916801097
|
Accepted
| 17
| 3,060
| 140
|
n=int(input())
ans=1
for i in range(2,int(n**0.5)+1):
for k in range(2,10):
if i**k>n:break
ans=max(ans,i**k)
print(ans)
|
s871758075
|
p03737
|
u580093517
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 45
|
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
|
a,b,c = input().split()
print(a[0]+b[0]+c[0])
|
s122746029
|
Accepted
| 17
| 2,940
| 55
|
a,b,c = input().split()
print((a[0]+b[0]+c[0]).upper())
|
s392081764
|
p03565
|
u449863068
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 440
|
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
|
S = list(input())
T = list(input())
ans = ""
flag = False
for i, s in enumerate(S):
count = 0
if flag:
break
for t in T:
if i + count < len(S):
if S[i+count] == "?" or s == t:
count += 1
else:
break
if count == len(T):
ans = S[:i] + T
flag = True
an = ""
for x in ans:
if x == "?":
an += "a"
else:
an += x
if flag:
print(ans)
else:
print("UNRESTORABLE")
|
s258682221
|
Accepted
| 18
| 3,064
| 408
|
S = input()
T = input()
found = []
for i in range(len(S) - len(T) + 1):
for cs, ct in zip(S[i:], T):
if cs != '?' and cs != ct:
break
else:
found.append(i)
if not found:
print("UNRESTORABLE")
exit()
ans = 'z' * 51
for i in found:
tmp = S[:i] + T + S[i+len(T):]
ans = min(ans, tmp.replace("?", "a"))
print(ans)
|
s842884074
|
p02402
|
u229478139
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,548
| 50
|
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.
|
import sys
for line in sys.stdin:
print(line)
|
s378708617
|
Accepted
| 20
| 6,584
| 82
|
n = int(input())
a = list(map(int, input().split()))
print(min(a),max(a),sum(a))
|
s819128159
|
p03944
|
u953753178
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 358
|
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
|
w, h, n = map(int, input().split())
x = 0
y = 0
for i in range(n):
xi, yi, ai = map(int, input().split())
if ai == 1 and xi > x:
x = xi
if ai == 2 and xi < w:
x = xi
if ai == 3 and yi > y:
y = yi
if ai == 4 and yi < h:
y = yi
if w <= x or h <= y:
res = 0
else:
res = (w-x) * (h-y)
print(res)
|
s633279868
|
Accepted
| 18
| 3,060
| 364
|
w, h, n = map(int, input().split())
x = 0
y = 0
for i in range(n):
xi, yi, ai = map(int, input().split())
if ai == 1 and xi > x:
x = xi
elif ai == 2 and xi < w:
w = xi
elif ai == 3 and yi > y:
y = yi
elif ai == 4 and yi < h:
h = yi
if w <= x or h <= y:
res = 0
else:
res = (w-x) * (h-y)
print(res)
|
s512110881
|
p02795
|
u130900604
| 2,000
| 1,048,576
|
Wrong Answer
| 22
| 3,316
| 68
|
We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all the squares in that column black. At least how many operations do you need in order to have N or more black squares in the grid? It is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.
|
h=int(input())
w=int(input())
m=max(h,w)
x=int(input())
print(x//m)
|
s682454724
|
Accepted
| 27
| 9,148
| 68
|
x=int(input())
y=int(input())
z=max(x,y)
print(-int(input())//z*-1)
|
s348923220
|
p03377
|
u903959844
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 114
|
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=list(map(int,input().split()))
if X <= A+B:
if X >= A:
print("Yes")
exit()
print("No")
|
s612374913
|
Accepted
| 17
| 2,940
| 114
|
A,B,X=list(map(int,input().split()))
if X <= A+B:
if X >= A:
print("YES")
exit()
print("NO")
|
s510022833
|
p03545
|
u363466395
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 484
|
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.
|
import sys
a,b,c,d = [int(x) for x in list(input())]
if a+b+c+d ==7:
print("a+b+c+d=7")
sys.exit()
if a+b+c-d ==7:
print("a+b+c-d=7")
sys.exit()
if a+b-c+d ==7:
print("a+b-c+d=7")
sys.exit()
if a+b-c-d ==7:
print("a+b-c-d=7")
sys.exit()
if a-b+c+d ==7:
print("a-b+c+d=7")
sys.exit()
if a-b+c-d ==7:
print("a-b+c-d=7")
sys.exit()
if a-b-c+d ==7:
print("a-b-c+d=7")
sys.exit()
if a-b-c-d ==7:
print("a-b-c-d=7")
sys.exit()
|
s350821938
|
Accepted
| 17
| 3,064
| 644
|
import sys
a,b,c,d = [int(x) for x in list(input())]
if a+b+c+d ==7:
print("{}+{}+{}+{}=7".format(a,b,c,d))
sys.exit()
if a+b+c-d ==7:
print("{}+{}+{}-{}=7".format(a,b,c,d))
sys.exit()
if a+b-c+d ==7:
print("{}+{}-{}+{}=7".format(a,b,c,d))
sys.exit()
if a+b-c-d ==7:
print("{}+{}-{}-{}=7".format(a,b,c,d))
sys.exit()
if a-b+c+d ==7:
print("{}-{}+{}+{}=7".format(a,b,c,d))
sys.exit()
if a-b+c-d ==7:
print("{}-{}+{}-{}=7".format(a,b,c,d))
sys.exit()
if a-b-c+d ==7:
print("{}-{}-{}+{}=7".format(a,b,c,d))
sys.exit()
if a-b-c-d ==7:
print("{}-{}-{}-{}=7".format(a,b,c,d))
sys.exit()
|
s907708692
|
p03493
|
u463898034
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 132
|
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.
|
a = list(map(int, input().split()))
count = 0
for i in a:
if i ==1:
count +=1
else :
continue
print(count)
|
s784289888
|
Accepted
| 17
| 2,940
| 208
|
a = list(input())
cnt = 0
for i in a:
if i == "1":
cnt +=1
print(cnt)
|
s483159264
|
p03573
|
u827202523
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,060
| 108
|
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.
|
def getlist():
a = input().split()
b = [int(i) for i in a]
return b
a,b,c = getlist()
print(a)
|
s230386124
|
Accepted
| 17
| 2,940
| 171
|
def getlist():
a = input().split()
b = [int(i) for i in a]
return b
a,b,c = getlist()
if a == b:
print(c)
if b == c:
print(a)
if a == c:
print(b)
|
s531015991
|
p02854
|
u091051505
| 2,000
| 1,048,576
|
Wrong Answer
| 135
| 26,764
| 146
|
Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be possible as is, so he will do the following operations some number of times **before** he does the cut: * Choose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan). * Choose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen. Find the minimum amount of money needed before cutting the bar into two parts with the same length.
|
n = int(input())
a = [int(i) for i in input().split()]
b = []
sum_a = sum(a)
cum = 0
for i in a:
cum += i
b.append(sum_a - cum)
print(min(b))
|
s216159378
|
Accepted
| 156
| 26,060
| 155
|
n = int(input())
a = [int(i) for i in input().split()]
b = []
sum_a = sum(a)
cum = 0
for i in a:
cum += i
b.append(abs(sum_a - cum * 2))
print(min(b))
|
s740719155
|
p03719
|
u335381753
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 95
|
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
a = input().split(" ")
if a[1] >= a[0] and a[2] <= a[2]:
print("yes")
else:
print("no")
|
s927807241
|
Accepted
| 17
| 2,940
| 125
|
a = input().split(" ")
A = int(a[0])
B = int(a[1])
C = int(a[2])
if A <= C and B >= C:
print("Yes")
else:
print("No")
|
s580247257
|
p00001
|
u724548524
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,600
| 83
|
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
|
m = [int(input()) for _ in range(10)]
m.sort()
[print(m[-i] for i in range(1, 4))]
|
s247209646
|
Accepted
| 20
| 5,596
| 84
|
m = [int(input()) for _ in range(10)]
m.sort()
[print(m[-i]) for i in range(1, 4)]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.