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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s583056028
|
p03494
|
u991087410
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 212
|
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())
count = 0
COUNT = 0
A = [int(i) for i in input().split()]
while 1:
for i in range(N):
if A[i]%2==0:
A[i]/=2
count+=1
if count == N:
COUNT+=1
else:
break
print(COUNT)
|
s159097165
|
Accepted
| 19
| 3,060
| 224
|
N = int(input())
A = [int(i) for i in input().split()]
count = 0
COUNT = 0
while 1:
for i in range(N):
if A[i]%2==0:
A[i]/=2
count+=1
if count == N:
COUNT+=1
count=0
else:
break
print(COUNT)
|
s557026352
|
p02397
|
u821624310
| 1,000
| 131,072
|
Wrong Answer
| 50
| 7,520
| 143
|
Write a program which reads two integers x and y, and prints them in ascending order.
|
x = 1
y = 1
while not(x == 0 and y == 0):
x, y = map(int, input().split())
if x <= y:
print(x, y)
else:
print(y, x)
|
s999514891
|
Accepted
| 50
| 7,644
| 182
|
x, y = map(int, input().split())
while 1:
if x == 0 and y == 0:
break
if x < y:
print(x, y)
else:
print(y, x)
x, y = map(int, input().split())
|
s487867670
|
p03555
|
u674347990
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 138
|
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.
|
row1 = input()
row2 = input()
if row1[0] == row2[2] and row1[1] == row2[1] and row1[2] == row2[0]:
print("Yes")
else:
print("No")
|
s755310145
|
Accepted
| 17
| 2,940
| 138
|
row1 = input()
row2 = input()
if row1[0] == row2[2] and row1[1] == row2[1] and row1[2] == row2[0]:
print("YES")
else:
print("NO")
|
s314120406
|
p03635
|
u230621983
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 50
|
In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?
|
n,m = map(int, input().split())
print((n-1)*(m-2))
|
s508652320
|
Accepted
| 17
| 2,940
| 50
|
n,m = map(int, input().split())
print((n-1)*(m-1))
|
s799580663
|
p03719
|
u601018334
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 135
|
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
def solve():
a, b, c = list(map(int, input().split()))
if a <= c and c<=b :
print("YES")
else:
print("NO")
|
s205784593
|
Accepted
| 18
| 2,940
| 142
|
def solve():
a, b, c = list(map(int, input().split()))
if a <= c and c<=b :
print("Yes")
else:
print("No")
solve()
|
s641105713
|
p02274
|
u150984829
| 1,000
| 131,072
|
Wrong Answer
| 30
| 5,600
| 265
|
For a given sequence $A = \\{a_0, a_1, ... a_{n-1}\\}$, the number of pairs $(i, j)$ where $a_i > a_j$ and $i < j$, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program: bubbleSort(A) cnt = 0 // the number of inversions for i = 0 to A.length-1 for j = A.length-1 downto i+1 if A[j] < A[j-1] swap(A[j], A[j-1]) cnt++ return cnt For the given sequence $A$, print the number of inversions of $A$. Note that you should not use the above program, which brings Time Limit Exceeded.
|
def m(L,R):
T=[];global c
for l in L[::-1]:
while R and R[-1]>l:T+=[R.pop()];c-=1
T+=[l]
return R+T[::-1]
def d(A):
l=len(A);global c;c+=l
s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A
c=-int(input())-2
print(*d(list(map(int,input().split()))))
print(c)
|
s542791574
|
Accepted
| 1,240
| 27,488
| 315
|
def g(A,l,m,r):
global c
L,R=A[l:m]+[1e9],A[m:r]+[1e9]
i=j=0
for k in range(l,r):
if L[i]<R[j]:A[k]=L[i];i+=1;c+=j
else:A[k]=R[j];j+=1
def s(A,l,r):
if l+1<r:m=(l+r)//2;s(A,l,m);s(A,m,r);g(A,l,m,r)
def m():
n,A=int(input()),list(map(int,input().split()))
s(A,0,n);print(c)
if'__main__'==__name__:c=0;m()
|
s344189922
|
p03502
|
u488178971
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 124
|
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.
|
#ABC 080 B - Harshad Number
n = int(input())
if n/sum([int(c) for c in str(n)]) ==0:
print('Yes')
else:
print('No')
|
s928400014
|
Accepted
| 17
| 2,940
| 117
|
# 080 B
N =str(input())
ans =0
for i in N:
ans+=int(i)
if int(N)%ans==0:
print('Yes')
else:
print('No')
|
s441883030
|
p03360
|
u732870425
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 95
|
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
|
a, b, c = map(int, input().split())
k = int(input())
print(max(a,b,c)**(2*k)+a+b+c-max(a,b,c))
|
s088534449
|
Accepted
| 17
| 2,940
| 95
|
a, b, c = map(int, input().split())
k = int(input())
print(max(a,b,c)*(2**k)+a+b+c-max(a,b,c))
|
s809130336
|
p03719
|
u798181098
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 88
|
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 <= c <= b:
print("YES")
else:
print("NO")
|
s826432146
|
Accepted
| 17
| 2,940
| 88
|
[a, b, c] = map(int, input().split())
if a <= c <= b:
print("Yes")
else:
print("No")
|
s642215148
|
p03377
|
u277802731
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 79
|
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.
|
#94a
a,b,x=map(int,input().split())
print('YES' if (a<=x and a+b<=x) else 'NO')
|
s160391355
|
Accepted
| 17
| 2,940
| 80
|
#94a
a,b,x=map(int,input().split())
print('YES' if (a<=x and a+b>=x) else 'NO')
|
s711525682
|
p03597
|
u290326033
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 44
|
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-A)
|
s210266973
|
Accepted
| 18
| 2,940
| 47
|
N = int(input())
A = int(input())
print(N**2-A)
|
s805211066
|
p03090
|
u538632589
| 2,000
| 1,048,576
|
Wrong Answer
| 24
| 3,612
| 216
|
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved that at least one such graph exists under the constraints of this problem.
|
n = int(input())
if n % 2 == 0:
k = 1+n
s = k*(n//2-1)
else:
k = n
s = k*(n//2)
for i in range(1, n+1):
for j in range(i+1, n+1):
if i+j == k:
continue
print(*[i, j])
|
s214123698
|
Accepted
| 22
| 3,720
| 281
|
n = int(input())
if n % 2 == 0:
k = 1+n
s = k*(n//2-1)
else:
k = n
s = k*(n//2)
ans = []
for i in range(1, n+1):
for j in range(i+1, n+1):
if i+j == k:
continue
ans.append("{} {}".format(i, j))
print(len(ans))
print(*ans, sep='\n')
|
s621173021
|
p03501
|
u304561065
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 81
|
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())
p1=N*A
if p1>=B:
print(p1)
else:
print(B)
|
s266747272
|
Accepted
| 17
| 2,940
| 81
|
N,A,B=map(int,input().split())
p1=N*A
if p1<=B:
print(p1)
else:
print(B)
|
s856488928
|
p03455
|
u860546679
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 69
|
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())
print("No") if a*b%2>0 else print("Yes")
|
s336805714
|
Accepted
| 17
| 2,940
| 71
|
a,b=map(int,input().split())
print("Odd") if a*b%2>0 else print("Even")
|
s781682309
|
p02412
|
u514853553
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,560
| 236
|
Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9
|
i=0
while(True):
a=list(map(int,input().split()))
if(a[0]==0 and a[1]==0):
break
for x in range(2,a[0]):
sum=a[1]-x
for y in range(2,x):
if (sum-y<a[0]):
i+=1
print(i)
|
s243521410
|
Accepted
| 70
| 7,668
| 258
|
while(True):
i=0
a=list(map(int,input().split()))
if(a[0]==0 and a[1]==0):
break
for x in range(2,a[0]):
sum=a[1]-x
for y in range(1,x):
if (sum-y<a[0]+1 and sum-y>x):
i+=1
print(i)
|
s382600656
|
p03545
|
u701658616
| 2,000
| 262,144
|
Wrong Answer
| 26
| 8,984
| 204
|
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
a = input()
for x in range(1<<3):
s = a[0]
print(x)
for i in range(3):
if x & (1<<i):
s += '+'
else:
s += '-'
s += a[i+1]
if eval(s) == 7:
print(s + '=7')
exit()
|
s372036516
|
Accepted
| 29
| 8,964
| 193
|
a = input()
for x in range(1<<3):
s = a[0]
for i in range(3):
if x & (1<<i):
s += '+'
else:
s += '-'
s += a[i+1]
if eval(s) == 7:
print(s + '=7')
exit()
|
s859408773
|
p02678
|
u149991748
| 2,000
| 1,048,576
|
Wrong Answer
| 2,226
| 592,172
| 2,184
|
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.
|
def get_target_min_index(min_index, distance, unsearched_nodes):
start = 0
while True:
index = distance.index(min_index, start)
found = index in unsearched_nodes
if found:
return index
else:
start = index + 1
N, M = map(int, input().split())
route_list = [[0 for i in range(N)] for j in range(N)]
for i in range(M):
a,b = map(int, input().split())
route_list[a-1][b-1] = 1
route_list[b-1][a-1] = 1
unsearched_nodes = list(range(N))
distance = [float('inf') for i in range(N)]
distance[0] = 0
previous_nodes = [-1] * N
while(len(unsearched_nodes) != 0):
posible_min_distance = float('inf')
for node_index in unsearched_nodes:
if posible_min_distance > distance[node_index]:
posible_min_distance = distance[node_index]
target_min_index = get_target_min_index(posible_min_distance, distance, unsearched_nodes)
unsearched_nodes.remove(target_min_index)
target_edge = route_list[target_min_index]
for index, route_dis in enumerate(target_edge):
if route_dis != 0:
if distance[index] > (distance[ target_min_index] + route_dis):
distance[index] = distance[ target_min_index] + route_dis
previous_nodes[index] = target_min_index
ans = 0
for i in range(1,N):
if previous_nodes[i] == -1:
ans = 1
if ans == 0:
for i in range(N):
if i == 0:
print('yes')
else:
print(previous_nodes[i]+1)
else:
print("no")
|
s166039907
|
Accepted
| 655
| 42,764
| 423
|
N, M = map(int, input().split())
route = [[] for _ in range(N)]
sign = [0]*N
#print(route)
for i in range(M):
a,b = map(int, input().split())
route[a-1].append(b-1)
route[b-1].append(a-1)
#print(route)
marked = {0}
q = [0]
for i in q:
for j in route[i]:
if j in marked:
continue
q.append(j)
marked.add(j)
sign[j] = i+1
print('Yes')
[print(i) for i in sign[1:]]
|
s736404657
|
p03544
|
u989345508
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 67
|
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
|
n=int(input())
k,l=2,1
for i in range(n-1):
k,l=k+l,k
print(l)
|
s866687122
|
Accepted
| 17
| 2,940
| 54
|
k,l=-1,2
for i in [0]*int(input()):k,l=l,k+l
print(l)
|
s188339196
|
p00586
|
u075836834
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,388
| 78
|
Compute A + B.
|
while True:
try:
x,y=input().split()
print(x+y)
except EOFError:
break
|
s899842666
|
Accepted
| 20
| 7,656
| 87
|
while True:
try:
x,y=map(int,input().split())
print(x+y)
except EOFError:
break
|
s407691866
|
p03433
|
u797016134
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 87
|
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
n = int(input())
a = int(input())
if (n-a)%500:
print("No")
else:
print("Yes")
|
s590932597
|
Accepted
| 17
| 2,940
| 72
|
n = int(input())
a = int(input())
print("Yes" if n % 500 <= a else "No")
|
s334467328
|
p03997
|
u307418002
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 85
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a = int( input() )
b = int( input() )
h = int( input() )
print( ( a + b ) * h / 2 )
|
s725593337
|
Accepted
| 17
| 2,940
| 91
|
a = int( input() )
b = int( input() )
h = int( input() )
print( int( ( a + b ) * h / 2) )
|
s725293072
|
p03370
|
u877428733
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 157
|
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
|
N,X = map(int,input().split())
n = []
A = 0
for i in range(N):
i = input()
X -= int(i)
A += 1
n.append(int(i))
A = X // min(n)
print(A)
|
s388095708
|
Accepted
| 18
| 2,940
| 158
|
N,X = map(int,input().split())
n = []
A = 0
for i in range(N):
i = input()
X -= int(i)
A += 1
n.append(int(i))
A += X // min(n)
print(A)
|
s193369341
|
p02409
|
u239237743
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,636
| 573
|
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.
|
count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
b_list=[]
f_list=[]
r_list=[]
v_list=[]
while n > 0:
b, f, r, v = map(int, input().split())
b_list.append(b)
f_list.append(f)
r_list.append(r)
v_list.append(v)
n = n-1
for (blist,flist,rlist,vlist) in zip(b_list,f_list,r_list,v_list):
count[blist-1][flist-1][rlist-1] = count[blist-1][flist-1][rlist-1] + vlist
for i in range(0, 4):
for j in range(0, 3):
for k in range(0, 10):
print("",count[i][j][k],end="")
print()
print("####################")
|
s688853885
|
Accepted
| 20
| 5,648
| 588
|
count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
b_list=[]
f_list=[]
r_list=[]
v_list=[]
while n > 0:
b, f, r, v = map(int, input().split())
b_list.append(b)
f_list.append(f)
r_list.append(r)
v_list.append(v)
n = n-1
for (blist,flist,rlist,vlist) in zip(b_list,f_list,r_list,v_list):
count[blist-1][flist-1][rlist-1] = count[blist-1][flist-1][rlist-1] + vlist
for i in range(0, 4):
for j in range(0, 3):
for k in range(0, 10):
print("",count[i][j][k],end="")
print()
if i != 3:
print("####################")
|
s614365799
|
p00011
|
u301729341
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,564
| 389
|
Let's play Amidakuji. In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines. In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom. Your task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., w are assigne to the vertical lines from left to right.
|
w = int(input())
n = int(input())
Ami = []
Num = []
for i in range(n):
Ami.append(list(map(int,input().split(","))))
print(Ami)
for i in range(1,w+1):
pos = i
for j in range(n):
if pos == Ami[j][0]:
pos = Ami[j][1]
elif pos == Ami[j][1]:
pos = Ami[j][0]
Num.append([pos,i])
Num = sorted(Num)
for k in range(0,w):
print(Num[k][1])
|
s663472564
|
Accepted
| 20
| 7,640
| 378
|
w = int(input())
n = int(input())
Ami = []
Num = []
for i in range(n):
Ami.append(list(map(int,input().split(","))))
for i in range(1,w+1):
pos = i
for j in range(n):
if pos == Ami[j][0]:
pos = Ami[j][1]
elif pos == Ami[j][1]:
pos = Ami[j][0]
Num.append([pos,i])
Num = sorted(Num)
for k in range(0,w):
print(Num[k][1])
|
s544775473
|
p02742
|
u143492911
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,064
| 223
|
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
import math
# A = [list(map(int, input().split())) for _ in range(3)]
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
h, w = map(int, input().split())
print(math.ceil(h*w))
|
s873728387
|
Accepted
| 17
| 2,940
| 258
|
import math
# A = [list(map(int, input().split())) for _ in range(3)]
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
h, w = map(int, input().split())
print(1) if min(h, w) == 1 else print(math.ceil((h*w)/2))
|
s106489017
|
p03386
|
u426649993
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 305
|
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.
|
if __name__ == "__main__":
a, b, k = map(int, input().split())
output = dict()
for i in range(k):
if a<= a+i <= b:
output[a+i] = a+i
for i in range(-k+1,1):
if a<= a+i <= b:
output[b+i] = b+i
for o in output.keys():
print(o)
|
s623052765
|
Accepted
| 18
| 3,060
| 279
|
def main():
A, B, K = map(int, input().split())
ans = list()
ans.extend(range(A, A+K))
ans.extend(range(B, B-K, -1))
ans = list(set(ans))
ans.sort()
for a in ans:
if A <= a <= B:
print(a)
if __name__ == "__main__":
main()
|
s061685957
|
p02534
|
u097491875
| 2,000
| 1,048,576
|
Wrong Answer
| 29
| 9,140
| 50
|
You are given an integer K. Print the string obtained by repeating the string `ACL` K times and concatenating them. For example, if K = 3, print `ACLACLACL`.
|
import sys
k = int(input())
ans = 'ACL'*k
print(k)
|
s697096904
|
Accepted
| 28
| 9,024
| 63
|
import sys
k = int(sys.stdin.readline().strip())
print('ACL'*k)
|
s687130089
|
p02664
|
u692054751
| 2,000
| 1,048,576
|
Wrong Answer
| 24
| 9,344
| 41
|
For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
|
T = input()
T.replace('?', 'D')
print(T)
|
s623400012
|
Accepted
| 77
| 10,852
| 380
|
T = list(input())
if len(T) == 1:
print('D')
exit()
if T[0] == '?':
if T[1] == 'P':
T[0] = 'D'
else:
T[0] = 'P'
for i in range(1, len(T)-1):
if T[i] == '?':
if T[i - 1] == 'D' and (T[i + 1] == 'D' or T[i + 1] == '?'):
T[i] = 'P'
else:
T[i] = 'D'
if T[-1] == '?':
T[-1] = 'D'
print(''.join(T))
|
s791841052
|
p03433
|
u736546944
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 116
|
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
N = int(input())
A = int(input())
while N > 500:
N -= 500
print(N)
if N <= A:
print("YES")
else:
print("NO")
|
s037473188
|
Accepted
| 17
| 2,940
| 106
|
N = int(input())
A = int(input())
while N >= 500:
N -= 500
if N <= A:
print("Yes")
else:
print("No")
|
s031267720
|
p03657
|
u055687574
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 132
|
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())
if a + b % 3 == 0 or a % 3 == 0 or a % b == 0:
print("Possible")
else:
print("Imposible")
|
s059818846
|
Accepted
| 17
| 2,940
| 135
|
a, b = map(int, input().split())
if (a + b) % 3 == 0 or a % 3 == 0 or b % 3 == 0:
print("Possible")
else:
print("Impossible")
|
s412325792
|
p03711
|
u334624175
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 265
|
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.
|
lst1 = ["1","3","5","7","8","10","12"]
lst2 = ["4","6","9","11"]
lst3 = ["2"]
def samelst_judge(x,y):
if x in lst1:
if y in lst1:
print("Yes")
elif x in lst2:
if y in lst2:
print("Yes")
else:
print("No")
|
s606561434
|
Accepted
| 17
| 2,940
| 213
|
lst1 = [1,3,5,7,8,10,12]
lst2 = [4,6,9,11]
lst3 = [2]
x, y = [int(n) for n in input().split()]
if x in lst1 and y in lst1:
print("Yes")
elif x in lst2 and y in lst2:
print("Yes")
else:
print("No")
|
s444242546
|
p03846
|
u920543723
| 2,000
| 262,144
|
Wrong Answer
| 181
| 23,408
| 426
|
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
|
import numpy as np
import math
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()
n = int(input())
A = iarr()
s = set(A)
if len(A)//2==len(s): print(pow(2, len(A)//2, int(1e9+7)))
else: print(0)
|
s716810726
|
Accepted
| 187
| 23,412
| 426
|
import numpy as np
import math
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()
n = int(input())
A = iarr()
s = set(A)
if sum(A)==2*sum(s): print(pow(2, len(A)//2, int(1e9+7)))
else: print(0)
|
s939465591
|
p03548
|
u311333072
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 94
|
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person. At most how many people can sit on the seat?
|
a=list(map(int,input().split()))
a[0]=a[0]-a[2]-a[2]
#print(a[0])
print(int(a[0]/(a[1]+a[2])))
|
s057396213
|
Accepted
| 17
| 2,940
| 89
|
a=list(map(int,input().split()))
a[0]=a[0]-a[2]
#print(a[0])
print(int(a[0]/(a[1]+a[2])))
|
s578206400
|
p02669
|
u163783894
| 2,000
| 1,048,576
|
Wrong Answer
| 21
| 9,084
| 7
|
You start with the number 0 and you want to reach the number N. You can change the number, paying a certain amount of coins, with the following operations: * Multiply the number by 2, paying A coins. * Multiply the number by 3, paying B coins. * Multiply the number by 5, paying C coins. * Increase or decrease the number by 1, paying D coins. You can perform these operations in arbitrary order and an arbitrary number of times. What is the minimum number of coins you need to reach N? **You have to solve T testcases.**
|
input()
|
s582286848
|
Accepted
| 426
| 11,340
| 668
|
from collections import deque
from collections import defaultdict
import math
t = int(input())
def solve(n):
if dist[n] != float('inf'):
return dist[n]
if n == 0:
return 0
if n == 1:
return d
ans = float('inf')
for x,cost in ([5,c],[3,b],[2,a]):
e = 0
if n%x:
e = 1
y = n%x
ans = min(ans,solve(n//x) + cost + (e*d*y))
if e ==1:
ans = min(ans,solve(n//x+1) + cost + ((x-y)*d))
dist[n] = min(ans,n*d)
return dist[n]
for i in range(t):
n,a,b,c,d, = list(map(int,input().split()))
dist = defaultdict(lambda: float('inf'))
print(solve(n))
|
s150024573
|
p03943
|
u024612773
| 2,000
| 262,144
|
Wrong Answer
| 23
| 3,064
| 80
|
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
a,b,c=map(int,input().split())
print("YES" if a+b+c == 2*max((a,b,c)) else "NO")
|
s626905735
|
Accepted
| 22
| 3,064
| 80
|
a,b,c=map(int,input().split())
print("Yes" if a+b+c == 2*max((a,b,c)) else "No")
|
s628238227
|
p02612
|
u227085629
| 2,000
| 1,048,576
|
Wrong Answer
| 27
| 9,096
| 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)
|
s469626800
|
Accepted
| 25
| 9,124
| 72
|
n = int(input())
if n%1000 == 0:
print(0)
else:
print(1000-(n%1000))
|
s894957115
|
p03672
|
u017810624
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 111
|
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
|
a=input()
if len(a)%2==1:a=a[:-1]
while a[0:int(len(a)/2)]!=a[int((len(a)/2)):len(a)]:
a=a[:-2]
print(len(a))
|
s534354757
|
Accepted
| 17
| 3,060
| 125
|
a=input()
if len(a)%2==1:a=a[:-1]
else:a=a[:-2]
while a[0:int(len(a)/2)]!=a[int((len(a)/2)):len(a)]:
a=a[:-2]
print(len(a))
|
s458703653
|
p02261
|
u096922415
| 1,000
| 131,072
|
Wrong Answer
| 40
| 8,128
| 2,819
|
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
|
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_C&lang=jp
sample_input = list(range(3))
sample_input[0] = '''5
H4 C9 S4 D2 C3'''
sample_input[1] = '''2
S1 H1'''
sample_input[2] = ''''''
give_sample_input = None
if give_sample_input is not None:
sample_input_list = sample_input[give_sample_input].split('\n')
def input():
return sample_input_list.pop(0)
# main
import copy
def swap_list_item(lst, i, j):
tmp = lst[i]
lst[i] = lst[j]
lst[j] = tmp
class Card:
number = None
mark = None
def __init__(self, str_card):
self.number = int(str_card[1])
self.mark = str_card[0]
pass
def __eq__(self, other):
return self.number == other.number
def __lt__(self, other):
return self.number < other.number
def to_str(self):
return self.mark + str(self.number)
def selection_sort(list_of_data):
num_of_data = len(list_of_data)
for i in range(num_of_data):
minj = i
for j in range(i, num_of_data):
if list_of_data[minj] > list_of_data[j]:
minj = j
if not minj == i:
swap_list_item(list_of_data, i, minj)
def bubble_sort(list_of_data):
flag = True
while flag:
flag = False
n = num_of_data - 1
while n >= 1:
if list_of_data[n] < list_of_data[n-1]:
swap_list_item(list_of_data, n, n-1)
flag = True
n -= 1
def get_mark_order_info(card_list, number):
result = ''
for card in card_list:
if card.number == number:
result += card.mark
return result
def print_card_list(card_list):
output = ''
for card in card_list:
output += card.to_str() + ' '
output.rstrip()
print(output)
num_of_data = int(input())
data_list_str = input().split()
data_cards = [Card(str) for str in data_list_str]
data_cards_bubble = copy.copy(data_cards)
data_cards_selection = copy.copy(data_cards)
mark_order_info = []
for number in [n+1 for n in range(13)]:
mark_order_info.append(get_mark_order_info(data_cards, number))
bubble_sort(data_cards_bubble)
selection_sort(data_cards_selection)
mark_order_info_bubble = []
for number in [n+1 for n in range(13)]:
mark_order_info_bubble.append(get_mark_order_info(data_cards_bubble, number))
mark_order_info_selection = []
for number in [n+1 for n in range(13)]:
mark_order_info_selection.append(get_mark_order_info(data_cards_selection, number))
print_card_list(data_cards_bubble)
if (mark_order_info == mark_order_info_bubble):
print('Stable')
else:
print('Not Stable')
print_card_list(data_cards_selection)
if (mark_order_info == mark_order_info_selection):
print('Stable')
else:
print('Not Stable')
|
s984464367
|
Accepted
| 30
| 8,232
| 2,844
|
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_C&lang=jp
sample_input = list(range(3))
sample_input[0] = '''5
H4 C9 S4 D2 C3'''
sample_input[1] = '''2
S1 H1'''
sample_input[2] = '''5
H4 C9 S4 D2 C3'''
give_sample_input = None
if give_sample_input is not None:
sample_input_list = sample_input[give_sample_input].split('\n')
def input():
return sample_input_list.pop(0)
# main
import copy
def swap_list_item(lst, i, j):
tmp = lst[i]
lst[i] = lst[j]
lst[j] = tmp
class Card:
number = None
mark = None
def __init__(self, str_card):
self.number = int(str_card[1])
self.mark = str_card[0]
pass
def __eq__(self, other):
return self.number == other.number
def __lt__(self, other):
return self.number < other.number
def to_str(self):
return self.mark + str(self.number)
def selection_sort(list_of_data):
num_of_data = len(list_of_data)
for i in range(num_of_data):
minj = i
for j in range(i, num_of_data):
if list_of_data[minj] > list_of_data[j]:
minj = j
if not minj == i:
swap_list_item(list_of_data, i, minj)
def bubble_sort(list_of_data):
flag = True
while flag:
flag = False
n = num_of_data - 1
while n >= 1:
if list_of_data[n] < list_of_data[n-1]:
swap_list_item(list_of_data, n, n-1)
flag = True
n -= 1
def get_mark_order_info(card_list, number):
result = ''
for card in card_list:
if card.number == number:
result += card.mark
return result
def print_card_list(card_list):
output = ''
for card in card_list:
output += card.to_str() + ' '
output = output.rstrip()
print(output)
num_of_data = int(input())
data_list_str = input().split()
data_cards = [Card(str) for str in data_list_str]
data_cards_bubble = copy.copy(data_cards)
data_cards_selection = copy.copy(data_cards)
mark_order_info = []
for number in [n+1 for n in range(13)]:
mark_order_info.append(get_mark_order_info(data_cards, number))
bubble_sort(data_cards_bubble)
selection_sort(data_cards_selection)
mark_order_info_bubble = []
for number in [n+1 for n in range(13)]:
mark_order_info_bubble.append(get_mark_order_info(data_cards_bubble, number))
mark_order_info_selection = []
for number in [n+1 for n in range(13)]:
mark_order_info_selection.append(get_mark_order_info(data_cards_selection, number))
print_card_list(data_cards_bubble)
if (mark_order_info == mark_order_info_bubble):
print('Stable')
else:
print('Not stable')
print_card_list(data_cards_selection)
if (mark_order_info == mark_order_info_selection):
print('Stable')
else:
print('Not stable')
|
s802344257
|
p03854
|
u254871849
| 2,000
| 262,144
|
Wrong Answer
| 21
| 3,956
| 337
|
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
s = input()
def reverse(string):
return ''.join(reversed(string))
def split_and_join(string, word):
return ''.join(string.split(word))
reversed_s = reverse(s)
ls = ["eraser", "dreamer", "erase", "dream"]
for word in ls:
reversed_word = reverse(word)
reversed_s = split_and_join(reversed_s, reversed_word)
print(reversed_s)
|
s671370708
|
Accepted
| 71
| 3,316
| 372
|
import sys
t = set('dream, dreamer, erase, eraser'.split(', '))
def obtainable(s):
while True:
for i in range(5, 8):
if s[-i:] in t:
s = s[:-i]
break
else:
return False
if not s:
return True
s = sys.stdin.readline().rstrip()
def main():
print("YES" if obtainable(s) else "NO")
if __name__ == '__main__':
main()
|
s121724249
|
p03131
|
u171366497
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 165
|
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
|
k,a,b=map(int,input().split())
if a+2>=b:print(k+1)
elif a>=k:print(k+1)
else:
k-=a-1
ans=a+(b-a)*k//2
if k%2==1:print(ans+1)
elif k%2==0:print(ans)
|
s238199344
|
Accepted
| 17
| 3,064
| 194
|
K,A,B=map(int,input().split())
if A+2>=B:
print(1+K)
else:
if K<=A-1:
print(1+K)
else:
K-=A-1
ans=A
ans=A+(B-A)*(K//2)+K%2
print(ans)
|
s881221618
|
p02280
|
u088372268
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,620
| 2,135
|
A rooted binary tree is a tree with a root node in which every node has at most two children. Your task is to write a program which reads a rooted binary tree _T_ and prints the following information for each node _u_ of _T_ : * node ID of _u_ * parent of _u_ * sibling of _u_ * the number of children of _u_ * depth of _u_ * height of _u_ * node type (root, internal node or leaf) If two nodes have the same parent, they are **siblings**. Here, if _u_ and _v_ have the same parent, we say _u_ is a sibling of _v_ (vice versa). The height of a node in a tree is the number of edges on the longest simple downward path from the node to a leaf. Here, the given binary tree consists of _n_ nodes and evey node has a unique ID from 0 to _n_ -1.
|
class Node:
def __init__(self, parent=-1, left=-1, right=-1):
self.parent = parent
self.left = left
self.right = right
n = int(input())
binary_tree = [Node() for i in range(n)]
h, d = [0 for j in range(n)], [0 for k in range(n)]
def set_height(u):
h1 = h2 = 0
if binary_tree[u].right != -1:
h1 = set_height(binary_tree[u].right) + 1
if binary_tree[u].left != -1:
h2 = set_height(binary_tree[u].left) + 1
h[u] = max(h1, h2)
return h[u]
def set_depth(u, dep):
d[u] = dep
if binary_tree[u].right != -1:
set_depth(binary_tree[u].right, dep+1)
if binary_tree[u].left != -1:
set_depth(binary_tree[u].left, dep+1)
return d[u]
def set_sibling(u):
if binary_tree[binary_tree[u].parent].left != u:
return binary_tree[binary_tree[u].parent].left
else:
return binary_tree[binary_tree[u].parent].right
def set_degree(u):
cnt = 0
if binary_tree[u].left != -1:
cnt += 1
if binary_tree[u].right != -1:
cnt += 1
return cnt
def set_type(u):
if binary_tree[u].parent == -1:
return "root"
elif binary_tree[u].left == -1 and binary_tree[u].right == -1:
return "leaf"
else:
return "internal node"
def main():
for i in range(n):
idx, left, right = map(int, input().split())
binary_tree[idx].left = left
binary_tree[idx].right = right
if left != -1:
binary_tree[left].parent = idx
if right != -1:
binary_tree[right].parent = idx
root_idx = 0
for i in range(n):
if binary_tree[i].parent == -1:
root_idx = i
break
set_height(root_idx)
set_depth(0, 0)
for i in range(n):
print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, "
"height = {}, type = {}".format(i, binary_tree[i].parent,
set_sibling(i), set_degree(i), d[i], h[i], set_type(i)))
if __name__ == '__main__':
main()
|
s236768600
|
Accepted
| 20
| 5,624
| 2,135
|
class Node:
def __init__(self, parent=-1, left=-1, right=-1):
self.parent = parent
self.left = left
self.right = right
n = int(input())
binary_tree = [Node() for i in range(n)]
h, d = [0 for j in range(n)], [0 for k in range(n)]
def set_height(u):
h1 = h2 = 0
if binary_tree[u].right != -1:
h1 = set_height(binary_tree[u].right) + 1
if binary_tree[u].left != -1:
h2 = set_height(binary_tree[u].left) + 1
h[u] = max(h1, h2)
return h[u]
def set_depth(u, dep):
d[u] = dep
if binary_tree[u].right != -1:
set_depth(binary_tree[u].right, dep+1)
if binary_tree[u].left != -1:
set_depth(binary_tree[u].left, dep+1)
return d[u]
def set_sibling(u):
if binary_tree[binary_tree[u].parent].left != u:
return binary_tree[binary_tree[u].parent].left
else:
return binary_tree[binary_tree[u].parent].right
def set_degree(u):
cnt = 0
if binary_tree[u].left != -1:
cnt += 1
if binary_tree[u].right != -1:
cnt += 1
return cnt
def set_type(u):
if binary_tree[u].parent == -1:
return "root"
elif binary_tree[u].left == -1 and binary_tree[u].right == -1:
return "leaf"
else:
return "internal node"
def main():
for i in range(n):
idx, left, right = map(int, input().split())
binary_tree[idx].left = left
binary_tree[idx].right = right
if left != -1:
binary_tree[left].parent = idx
if right != -1:
binary_tree[right].parent = idx
root_idx = 0
for i in range(n):
if binary_tree[i].parent == -1:
root_idx = i
break
set_height(root_idx)
set_depth(root_idx, 0)
for i in range(n):
print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, "
"height = {}, {}".format(i, binary_tree[i].parent,
set_sibling(i), set_degree(i), d[i], h[i], set_type(i)))
if __name__ == '__main__':
main()
|
s236629696
|
p03351
|
u748135969
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 108
|
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
a, b, c, d = map(int, input().split())
if abs(b-a) < d and abs(c-b) < d:
print('Yes')
else:
print('No')
|
s994100100
|
Accepted
| 18
| 2,940
| 138
|
a, b, c, d = map(int, input().split())
if (abs(a - c) <= d or (abs(a - b) <= d and abs(b - c) <= d )):
print('Yes')
else:
print('No')
|
s227463579
|
p03501
|
u419963262
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 43
|
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(n*a,b)
|
s623726580
|
Accepted
| 18
| 2,940
| 49
|
n,a,b=map(int,input().split())
print(min(n*a,b))
|
s192514223
|
p03502
|
u572142121
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 129
|
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())
sum=0
for i in range(len(str(N))) :
sum+=(N%10)
N /=10
if (N%sum) == 0:
print('Yes')
else:
print('No')
|
s610892700
|
Accepted
| 17
| 2,940
| 140
|
N=int(input())
S=N
n=str(N)
sum=0
for i in range(len(n)) :
sum+=(N%10)
N =N//10
if S%sum == 0:
print('Yes')
else:
print('No')
|
s211198937
|
p03502
|
u207799478
| 2,000
| 262,144
|
Wrong Answer
| 103
| 4,208
| 716
|
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.
|
import math
import string
def readints():
return list(map(int, input().split()))
def nCr(n, r):
return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
def has_duplicates2(seq):
seen = []
for item in seq:
if not(item in seen):
seen.append(item)
return len(seq) != len(seen)
def divisor(n):
divisor = []
for i in range(1, n+1):
if n % i == 0:
divisor.append(i)
return divisor
# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = input()
print(n)
print(sum(map(int, n)))
x = sum(map(int, n))
print(int(n)/x)
if int(n) % sum(map(int, n)) == 0:
print('Yes')
exit()
else:
print('No')
|
s916157731
|
Accepted
| 66
| 4,212
| 721
|
import math
import string
def readints():
return list(map(int, input().split()))
def nCr(n, r):
return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
def has_duplicates2(seq):
seen = []
for item in seq:
if not(item in seen):
seen.append(item)
return len(seq) != len(seen)
def divisor(n):
divisor = []
for i in range(1, n+1):
if n % i == 0:
divisor.append(i)
return divisor
# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = input()
# print(n)
#print(sum(map(int, n)))
x = sum(map(int, n))
# print(int(n)/x)
if int(n) % sum(map(int, n)) == 0:
print('Yes')
exit()
else:
print('No')
|
s655254486
|
p03456
|
u133886644
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 151
|
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 sys
input = sys.stdin.readline
N, M, = map(int, input().split())
t = N * M
c = t ** 0.5
if c == int(c):
print("Yes")
else:
print("No")
|
s239453353
|
Accepted
| 17
| 3,060
| 166
|
import sys
input = sys.stdin.readline
N, M, = map(int, input().split())
t = int(str(N) + str(M))
c = t ** 0.5
if int(c) == c:
print("Yes")
else:
print("No")
|
s983119989
|
p02866
|
u116233709
| 2,000
| 1,048,576
|
Wrong Answer
| 100
| 14,396
| 207
|
Given is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition: * For every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.
|
n=int(input())
d=list(map(int,input().split()))
c=[0]*n
ans=0
for i in range(0,n):
c[d[i]]+=1
if d[0]!=0 or c[0]!=1:
print(0)
else:
for j in range(2,n):
ans*=c[j]**c[j-1]
print(ans)
|
s676348455
|
Accepted
| 190
| 14,396
| 265
|
n=int(input())
d=list(map(int,input().split()))
x=max(d)
li=[0]*(x+1)
for i in range(n):
li[d[i]]+=1
if d[0]!=0 or li[0]!=1:
print(0)
else:
ans=1
for i in range(2,len(li)):
ans*=pow(li[i-1],li[i],998244353)
print(ans%998244353)
|
s905931279
|
p02831
|
u225510395
| 2,000
| 1,048,576
|
Wrong Answer
| 47
| 3,060
| 176
|
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.
|
S = input().split()
A = int(S[0])
B = int(S[1])
C = 0
for i in range(1,1000000,1):
if A > B:
C = A * i
else:
C = B *i
if C % B == 0:
print(C)
break
|
s998730444
|
Accepted
| 53
| 3,060
| 223
|
S = input().split()
A = int(S[0])
B = int(S[1])
C = 0
D = 0
for i in range(1,100000,1):
if A > B:
C = A * i
else:
C = B *i
if A > B:
D = B
else:
D = A
if C % D == 0:
print(C)
break
|
s233872519
|
p04039
|
u993435350
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 427
|
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier.
|
N,K = map(int,input().split())
D = list(map(int,input().split()))
nD = sorted([i for i in range(10) if i not in D])
con = 5
s = ""
M = list(set(str(N)))
flag = 0
for i in M:
if i in D:
flag = 1
break
else:
print(N)
if flag == 1:
while con > 0:
if con == 5 and nD[0] == 0:
s += str(nD[1])
else:
s += str(nD[0])
num = int(s)
if num >= N:
break
con -= 1
print(num)
|
s094846693
|
Accepted
| 69
| 3,060
| 263
|
N,K = map(int,input().split())
D = list(map(int,input().split()))
flag = False
inf = 10 ** 6
while flag == False:
for i in range(N,inf):
L = str(i)
for j in L:
if int(j) in D:
break
else:
print(i)
flag = True
break
|
s473661489
|
p03456
|
u893661063
| 2,000
| 262,144
|
Wrong Answer
| 46
| 9,164
| 160
|
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
a, b = map(str, input().split())
s = a + b
s = int(s)
print (s)
ans = 0
for i in range(s):
if i**2 == s:
print ("Yes")
exit()
print ("No")
|
s414320916
|
Accepted
| 51
| 9,136
| 149
|
a, b = map(str, input().split())
s = a + b
s = int(s)
ans = 0
for i in range(s):
if i**2 == s:
print ("Yes")
exit()
print ("No")
|
s067544789
|
p03351
|
u516579758
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 92
|
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
a,b,c,d=map(int,input().split())
if a-b<d and b-c<d:
print('YES')
else:
print('NO')
|
s041120288
|
Accepted
| 17
| 2,940
| 119
|
a,b,c,d=map(int,input().split())
if abs(a-b)<=d and abs(b-c)<=d or abs(a-c)<=d:
print('Yes')
else:
print('No')
|
s365951545
|
p02406
|
u869667855
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,496
| 116
|
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; }
|
i = 1
n = int(input())
while i <= n:
if i % 3 == 0:
print(' ' , i)
elif i % 10 == 3:
print(' ' , i)
i = i + 1
|
s357845308
|
Accepted
| 40
| 8,200
| 206
|
i = 1
n = int(input())
while i <= n:
x = i
if x % 3 == 0:
print('' , i , end = '')
else:
while x:
if x % 10 == 3:
print('' , i , end = '')
break
x = int(x / 10)
i = i + 1
print('')
|
s768362427
|
p03494
|
u833492079
| 2,000
| 262,144
|
Time Limit Exceeded
| 2,108
| 2,940
| 173
|
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 = [int(i) for i in input().split()]
ans=1000000000
for i in a:
print(i)
count=0
while i%2==0:
count+=1
ans = min(ans, count)
print(ans)
|
s691500655
|
Accepted
| 25
| 3,060
| 283
|
import sys
def p(s):
sys.stderr.write(str(s)+"\n")
n = int(input())
a = [int(i) for i in input().split()]
ans=1000000000
for i in a:
p(i)
count=0
while i%2==0:
count+=1
if count>ans:
break
i /= 2
p("i="+str(i))
ans = min(ans, count)
print(ans)
|
s800246207
|
p03379
|
u812576525
| 2,000
| 262,144
|
Wrong Answer
| 250
| 25,224
| 157
|
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
|
N = int(input())
A = list(map(int,input().split()))
for i in range(1,N + 1):
if i < N//2 + 1:
print(A[N//2])
else:
print(A[N//2 -1])
|
s094781138
|
Accepted
| 315
| 25,220
| 175
|
N = int(input())
A = list(map(int,input().split()))
B = sorted(A)
X = B[N//2-1]
Y = B[N//2]
for i in range(N):
if A[i] <= X:
print(Y)
else:
print(X)
|
s473276368
|
p03573
|
u946370443
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 69
|
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.
|
A,B,C=input().split()
print("A"if B==C else "B"if A==C else "C")
|
s846768995
|
Accepted
| 17
| 2,940
| 78
|
A, B, C = map(int, input().split())
print(A if B == C else B if A == C else C)
|
s521961768
|
p03909
|
u386089355
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 183
|
There is a grid with H rows and W columns. The square at the i-th row and j-th column contains a string S_{i,j} of length 5. The rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from `A` through the W-th letter of the alphabet. Exactly one of the squares in the grid contains the string `snuke`. Find this square and report its location. For example, the square at the 6-th row and 8-th column should be reported as `H6`.
|
h, w = map(int, input().split())
ls = [input().split() for _ in range(h)]
for i in range(h):
for j in range(w):
if ls[i][j] == 'snuke':
print(chr(65 + i) + str(j + 1))
break
|
s413003919
|
Accepted
| 16
| 3,060
| 183
|
h, w = map(int, input().split())
ls = [input().split() for _ in range(h)]
for i in range(h):
for j in range(w):
if ls[i][j] == 'snuke':
print(chr(65 + j) + str(i + 1))
break
|
s165446570
|
p03997
|
u826557401
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 86
|
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())
area = (a + b) * h /2
print(area)
|
s125876858
|
Accepted
| 18
| 2,940
| 91
|
a = int(input())
b = int(input())
h = int(input())
area = int((a + b) * h /2)
print(area)
|
s935804794
|
p03601
|
u200030766
| 3,000
| 262,144
|
Wrong Answer
| 794
| 3,064
| 411
|
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=map(int, input().split())
wans=0
sans=0
for i in range(31):
for j in range(31):
for k in range(31):
for l in range(31):
w=100*A*i+100*B*j
s=C*k+D*l
if s*100<=(s+w)*E and sans*(s+w)<=s*(sans+wans) and w+s<=F:
sans=s
wans=w
print(sans,sans+wans)
|
s491045069
|
Accepted
| 1,339
| 3,064
| 696
|
A, B, C, D, E, F=map(int, input().split())
wans=0
sans=0
for i in range(31):
w=100*A*i
s=0
if s+w>F:
break
for j in range(31):
w=100*A*i+100*B*j
s=0
if s+w>F:
break
for k in range(3001):
w=100*A*i+100*B*j
s=C*k
if s+w>F:
break
for l in range(3001):
w=100*A*i+100*B*j
s=C*k+D*l
if s+w>F:
break
if w!=0 and s*(100+E)<=(s+w)*E and sans*(s+w)<=s*(sans+wans) and w+s<=F:
sans=s
wans=w
print(sans+wans,sans)
|
s897927927
|
p02694
|
u264053222
| 2,000
| 1,048,576
|
Wrong Answer
| 25
| 9,208
| 86
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
x = int(input())
y = 101
ans = 1
while y < x:
y *= 101
x *= 100
++ans
print(ans)
|
s209308078
|
Accepted
| 24
| 9,156
| 89
|
x = int(input())
y = 101
ans = 1
while y < x:
y = y * 101 // 100
ans += 1
print(ans)
|
s469773225
|
p03351
|
u934788990
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 137
|
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
a,b,c,d=map(int,input().split())
if abs(a-b)<=d and abs(b-c)<=d:
print('Yes')
if abs(a-c)<=d:
print('Yes')
else:
print('No')
|
s784949243
|
Accepted
| 21
| 3,316
| 139
|
a,b,c,d=map(int,input().split())
if abs(a-b)<=d and abs(b-c)<=d:
print('Yes')
elif abs(a-c)<=d:
print('Yes')
else:
print('No')
|
s001545028
|
p02678
|
u167360450
| 2,000
| 1,048,576
|
Wrong Answer
| 862
| 38,968
| 1,410
|
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())
res = {}
for i in range(m):
a,b = map(int,input().split())
res.setdefault(a,[]).append(b)
res.setdefault(b,[]).append(a)
dist =[0] * (n+1)
sirusi = [0] * (n+1)
dist[1] = -1
que = deque([])
ique = deque([])
x = res.pop(1)
#print(x)
que.append(x)
ique.append(1)
d = 1
#print(len(que))
while(len(que)>0):
data = que.popleft()
index = ique.popleft()
#print(data)
ind = 0
for i in data:
#print(int(i))
if dist[int(i)] == 0 :
# print("d")
# print(index)
dist[i] = d
sirusi[i] = index
que.append(res.pop(i))
ique.append(int(i))
ind += 1
d = d + 1
#
# while(len(next) > 0):
# data = next.pop()
# print("data = ",end="")
# print(data)
# if(not(type(data) is int)):
# print("not int")
# dist[data[i]] = d
# print("res[data[i]] = ")
# #print(res[data[i]])
# next.append(res.pop(data[i]))
# else:
# print("int")
# dist[data] = d
# print("res = ",end="")
# print(res[data])
# next.append(res[data])
#
# d = d +1
#print(dist)
for i in sirusi:
print(i)
|
s937664877
|
Accepted
| 794
| 39,072
| 1,445
|
from collections import deque
n,m = map(int,input().split())
res = {}
for i in range(m):
a,b = map(int,input().split())
res.setdefault(a,[]).append(b)
res.setdefault(b,[]).append(a)
dist =[0] * (n+1)
sirusi = [0] * (n+1)
dist[1] = -1
que = deque([])
ique = deque([])
x = res.pop(1)
#print(x)
que.append(x)
ique.append(1)
d = 1
#print(len(que))
while(len(que)>0):
data = que.popleft()
index = ique.popleft()
#print(data)
ind = 0
for i in data:
#print(int(i))
if dist[int(i)] == 0 :
# print("d")
# print(index)
dist[i] = d
sirusi[i] = index
que.append(res.pop(i))
ique.append(int(i))
ind += 1
d = d + 1
#
# while(len(next) > 0):
# data = next.pop()
# print("data = ",end="")
# print(data)
# if(not(type(data) is int)):
# print("not int")
# dist[data[i]] = d
# print("res[data[i]] = ")
# #print(res[data[i]])
# next.append(res.pop(data[i]))
# else:
# print("int")
# dist[data] = d
# print("res = ",end="")
# print(res[data])
# next.append(res[data])
#
# d = d +1
#print(dist)
print("Yes")
for i in range(2,len(sirusi)):
print(sirusi[i])
|
s002466257
|
p02255
|
u232404920
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,588
| 222
|
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
n = int(input())
a = list(map(int, input().split()))
for i in range(1, n):
v = a[i]
j = i - 1
while j >= 0 and v < a[j]:
a[j+1] = a[j]
j -= 1
a[j+1] = v
print(' '.join(map(str, a)))
|
s695144014
|
Accepted
| 20
| 5,600
| 252
|
n = int(input())
a = list(map(int, input().split()))
print(' '.join(map(str, a)))
for i in range(1, n):
v = a[i]
j = i - 1
while j >= 0 and v < a[j]:
a[j+1] = a[j]
j -= 1
a[j+1] = v
print(' '.join(map(str, a)))
|
s821650990
|
p02645
|
u306260540
| 2,000
| 1,048,576
|
Wrong Answer
| 19
| 8,952
| 24
|
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.
|
n = input()
print(n[:2])
|
s700173063
|
Accepted
| 24
| 9,012
| 25
|
n = input()
print(n[:3])
|
s797898434
|
p03409
|
u792670114
| 2,000
| 262,144
|
Wrong Answer
| 25
| 3,188
| 343
|
On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.
|
N = int(input())
ABs = []
for i in range(N):
a, b = map(int, input().split())
ABs.append((a, b))
CDs = []
for i in range(N):
c, d = map(int, input().split())
CDs.append((c, d))
Ds = [set() for i in range(N)]
for i in range(N):
a, b = ABs[i]
for j in range(N):
c, d = CDs[j]
if a < c and b < d:
Ds[i].add(j)
print(Ds)
|
s666573139
|
Accepted
| 19
| 3,064
| 428
|
N = int(input())
ABs = []
for i in range(N):
a, b = map(int, input().split())
ABs.append((a, b))
CDs = []
for i in range(N):
c, d = map(int, input().split())
CDs.append((c, d))
ABs.sort()
CDs.sort()
r = 0
s = set()
for c, d in CDs:
ma, mb = -1, -1
for a, b in ABs:
if a < c and b < d and b > mb and (a, b) not in s:
ma, mb = a, b
if not ma < 0:
r += 1
s.add((ma, mb))
#print(ma, mb)
print(r)
|
s114495308
|
p03644
|
u411544692
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,060
| 76
|
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(7):
if 2**i <= N < 2**(i+1):
print(i)
|
s290111684
|
Accepted
| 17
| 2,940
| 79
|
N = int(input())
for i in range(7):
if 2**i <= N < 2**(i+1):
print(2**i)
|
s557507229
|
p03679
|
u826263061
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 136
|
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
|
x, a, b = list(map(int, input().split()))
if a-b <= 0:
print('delicious')
elif a-b <= x:
print('safe')
else:
print('dangerous')
|
s913990600
|
Accepted
| 19
| 3,064
| 138
|
x, a, b = list(map(int, input().split()))
if -a+b <= 0:
print('delicious')
elif -a+b <= x:
print('safe')
else:
print('dangerous')
|
s889992498
|
p04011
|
u460129720
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,316
| 143
|
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.
|
from collections import Counter
w = input()
cnt = Counter(w)
ans = 'Yes'
for i in cnt.values():
if i % 2 !=0:
ans = 'No'
print(ans)
|
s021851350
|
Accepted
| 19
| 2,940
| 159
|
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
c = 0
for i in range(1,N+1):
if i <= K:
c += X
else:
c +=Y
print(c)
|
s962139716
|
p03455
|
u314211032
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 119
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a, b = [int(i) for i in input().split()]
if bin(a)[0] == '1' or bin(b)[0] == '1':
print('Even')
else:
print('Odd')
|
s234588793
|
Accepted
| 17
| 2,940
| 125
|
a, b = [int(i) for i in input().split()]
if bin(a)[-1] == '0' or bin(b)[-1] == '0':
print('Even')
else:
print('Odd')
|
s945993383
|
p02646
|
u247114740
| 2,000
| 1,048,576
|
Wrong Answer
| 24
| 9,180
| 200
|
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if(v == w):
print('NO')
exit()
x = abs(a - b)
if(t <= (x // (v - w))):
print('YES')
else:
print('NO')
|
s334152945
|
Accepted
| 21
| 9,212
| 376
|
def funct(a, b, v, w, t):
x = abs(a - b)
s = v - w
if(s <= 0): return False
else:
if(x // (v - w) < t or (x % (v - w) == 0 and x // (v - w) <= t)):
return True
else: return False
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if(funct(a, b, v, w, t)):
print('YES')
else:
print('NO')
|
s543959186
|
p04043
|
u028294979
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 362
|
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.
|
print("input the number of syllables: ")
A, B, C = map(int, input().split())
if A and B and C >= 1:
if A and B and C <= 10:
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')
|
s919628500
|
Accepted
| 17
| 2,940
| 366
|
#print("input the number of syllables: ")
A, B, C = map(int, input().split())
if A and B and C >= 1:
if A and B and C <= 10:
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')
|
s116440563
|
p02612
|
u225627564
| 2,000
| 1,048,576
|
Wrong Answer
| 30
| 9,156
| 52
|
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.
|
str = input()
result = int(str) % 1000
print(result)
|
s557484070
|
Accepted
| 27
| 9,140
| 125
|
import math
price = int(input())
payment = math.ceil(float(price) / 1000) * 1000
result = payment - price
print(int(result))
|
s484623996
|
p03574
|
u215743476
| 2,000
| 262,144
|
Wrong Answer
| 34
| 3,188
| 686
|
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 = []
for i in range(h):
s.append(input())
t = [['']*w for i in range(h)]
print(t.count)
dx = [0, 0, 1, -1, 1, 1, -1, -1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
for y in range(h):
for x in range(w):
if s[y][x] == '#':
t[y][x] = '#'
else:
count = 0
for i in range(8):
if x + dx[i] < 0 or x + dx[i] >= w or y + dy[i] < 0 or y + dy[i] >= h:
continue
nx = x + dx[i]
ny = y + dy[i]
if s[ny][nx] == '#':
count += 1
t[y][x] = str(count)
for i in range(len(t)):
print(''.join(t[i]))
|
s072467818
|
Accepted
| 35
| 3,188
| 688
|
h, w = map(int, input().split())
s = []
for i in range(h):
s.append(input())
t = [['']*w for i in range(h)]
# print(t.count)
dx = [0, 0, 1, -1, 1, 1, -1, -1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
for y in range(h):
for x in range(w):
if s[y][x] == '#':
t[y][x] = '#'
else:
count = 0
for i in range(8):
if x + dx[i] < 0 or x + dx[i] >= w or y + dy[i] < 0 or y + dy[i] >= h:
continue
nx = x + dx[i]
ny = y + dy[i]
if s[ny][nx] == '#':
count += 1
t[y][x] = str(count)
for i in range(len(t)):
print(''.join(t[i]))
|
s048139608
|
p03455
|
u529958747
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 97
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a,b = list(map(int, input().split()))
if a*b/2 % 2 == 0:
print("even")
else:
print("odd")
|
s004325590
|
Accepted
| 18
| 2,940
| 97
|
a,b = list(map(int, input().split()))
if a*b/2 % 2 == 0:
print("Even")
else:
print("Odd")
|
s019698481
|
p03999
|
u733738237
| 2,000
| 262,144
|
Wrong Answer
| 45
| 3,188
| 258
|
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
|
from itertools import product
s=list(input())
cnt=0
pl=list(product(['','+'],repeat=len(s)-1))
for j in pl:
for _ in range(len(s)):
l=[s[0]]
for i in range(len(s)-1):
l.append(j[i])
l.append(s[i+1])
print(l)
a="".join(l)
cnt+=eval(a)
print(cnt)
|
s752153095
|
Accepted
| 43
| 3,060
| 248
|
from itertools import product
s=list(input())
cnt=0
pl=list(product(['','+'],repeat=len(s)-1))
for j in pl:
for _ in range(len(s)):
l=[s[0]]
for i in range(len(s)-1):
l.append(j[i])
l.append(s[i+1])
a="".join(l)
cnt+=eval(a)
print(cnt)
|
s650702275
|
p02393
|
u706217959
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,600
| 298
|
Write a program which reads three integers, and prints them in ascending order.
|
def main():
n = input().split()
a = int(n[0])
b = int(n[1])
c = int(n[2])
if (a > c):
temp = a
a = c
c = temp
if (a > b):
temp = b
b = a
a = temp
print("{0} {1} {2}".format(a,b,c))
if __name__ == '__main__':
main()
|
s536046873
|
Accepted
| 20
| 5,600
| 363
|
def main():
n = input().split()
a = int(n[0])
b = int(n[1])
c = int(n[2])
if (a > b):
temp = a
a = b
b = temp
if (b > c):
temp = b
b = c
c = temp
if (a > b):
temp = a
a = b
b = temp
print("{0} {1} {2}".format(a,b,c))
if __name__ == '__main__':
main()
|
s357198454
|
p03999
|
u539517139
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 150
|
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
|
s=input()
l=len(s)
x=[0]*l
for i in range(l):
for j in range(i,l):
x[j]+=int(s[i])*(i+1)
a=0
for i in range(l):
a+=x[i]*(10**(l-i-1))
print(a)
|
s360333984
|
Accepted
| 18
| 3,060
| 219
|
s=input()
l=len(s)
x=[0]*l
for i in range(l):
for j in range(i,l):
if j-i>0:
x[j]+=int(s[i])*(2**i)*(2**(j-i-1))
else:
x[j]+=int(s[i])*(2**i)
a=0
for i in range(l):
a+=x[i]*(10**(l-i-1))
print(a)
|
s822294870
|
p03455
|
u284854859
| 2,000
| 262,144
|
Wrong Answer
| 20
| 2,940
| 232
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
x,y = map(int,input().split())
k = 100
if y < 10:
k = 10
if y >99:
k = 1000
c = y + x * k
print(c)
for i in range(0,11000):
if c == i ** 2:
print('Yes')
k = 0
if k != 0:
print('No')
|
s950196969
|
Accepted
| 17
| 2,940
| 83
|
x,y = map(int,input().split())
if x*y %2 == 0:
print('Even')
else:
print('Odd')
|
s203429865
|
p03305
|
u327466606
| 2,000
| 1,048,576
|
Wrong Answer
| 2,111
| 72,368
| 519
|
Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains. Two currencies are used in the country: yen and snuuk. Any train fare can be paid by both yen and snuuk. The fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk. In a city with a money exchange office, you can change 1 yen into 1 snuuk. However, when you do a money exchange, you have to change all your yen into snuuk. That is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk. Currently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year. Kenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling. It is acceptable to do the exchange in City s or City t. Kenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange. For each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years. You can assume that the trip finishes within the year.
|
import scipy.sparse as ss
n,m,s,t = map(int,input().split())
s,t = s-1,t-1
Gs = ss.dok_matrix((n,n),int)
Gt = ss.dok_matrix((n,n),int)
for _ in range(m):
u,v,a,b = map(int,input().split())
u,v = u-1,v-1
Gs[u,v] = a
Gs[v,u] = a
Gt[u,v] = b
Gt[v,u] = b
Ds = ss.csgraph.dijkstra(Gs, indices = s)
Dt = ss.csgraph.dijkstra(Gt, indices = t)
D = Ds+Dt
D = sorted(((cost, i) for i,cost in enumerate(D)), reverse=True)
print(D)
for i in range(n):
while D[-1][1] < i:
D.pop()
print(int(10**15 - D[-1][0]))
|
s116460711
|
Accepted
| 1,688
| 104,236
| 901
|
import heapq as hq
# adj list graph
def dijkstra(adj, costs, s):
N = len(adj)
q = [(0,s)]
dist = [float('inf')]*N
dist[s] = 0
prev = [None]*N
while q:
c, u = hq.heappop(q)
if c > dist[u]:
continue
for v in adj[u]:
if dist[v] > dist[u] + costs[(u,v)]:
dist[v] = dist[u] + costs[(u,v)]
prev[v] = u
hq.heappush(q, (dist[v], v))
return prev, dist
n,m,s,t = map(int,input().split())
s,t = s-1,t-1
G = [list() for _ in range(n)]
Cs = dict()
Ct = dict()
for _ in range(m):
u,v,a,b = map(int,input().split())
u,v = u-1,v-1
G[u].append(v)
G[v].append(u)
Cs[(u,v)] = a
Cs[(v,u)] = a
Ct[(u,v)] = b
Ct[(v,u)] = b
Ds = dijkstra(G, Cs, s)[1]
Dt = dijkstra(G, Ct, t)[1]
D = sorted(((a+b, i) for i,(a,b) in enumerate(zip(Ds,Dt))), reverse=True)
for i in range(n):
while D[-1][1] < i:
D.pop()
print(int(10**15 - D[-1][0]))
|
s415796771
|
p03448
|
u033606236
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 683
|
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.
|
import sys
Money_500 = int(input())
Money_100 = int(input())
Money_50 = int(input())
Amount = int(input())
Count = 0
if Amount % 50 != 0 or Amount / 1 == 0 or Amount < 50 :
print(Count)
print('break')
sys.exit()
if Money_500 >= Amount / 500 and Amount % 500 == 0:
Count += 1
for i in range(0,Money_500+1):
if Amount < i * 500 and i >= 1:
break
if ( Amount - ( i * 500 )) >= 100:
for x in range(0,Money_100+1):
if ( Amount - ( i * 500 )) - (x * 100) < 0 and i >= 1:
break
if ( Amount - (i * 500 ) - ( x * 100 )) / 50 <= Money_50 :
Count += 1
print ( Count )
|
s029094769
|
Accepted
| 19
| 3,188
| 496
|
import sys
Money_500 = int(input())
Money_100 = int(input())
Money_50 = int(input())
Amount = int(input())
Count = 0
if Amount % 50 != 0 or Amount / 1 == 0 or Amount < 50 :
print(Count)
sys.exit()
for i in range(0,Money_500+1):
if Amount < i * 500 :
break
for x in range(0,Money_100+1):
if ( Amount - ( i * 500 )) - (x * 100) < 0 :
break
if ( Amount - (i * 500 ) - ( x * 100 )) / 50 <= Money_50 :
Count += 1
print ( Count )
|
s773234980
|
p03827
|
u695079172
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 180
|
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
|
n = int(input())
s = input()
mx = n
current = n
for c in s:
if c == "I":
current += 1
elif c == "D":
current -= 1
if current > mx:
mx = current
print(mx)
|
s213077210
|
Accepted
| 17
| 2,940
| 177
|
n = int(input())
s = input()
mx = 0
current = 0
for c in s:
if c == "I":
current += 1
elif c == "D":
current -= 1
if current > mx:
mx = current
print(mx)
|
s402327850
|
p03360
|
u722189950
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 100
|
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
|
ABC = list(map(int, input().split()))
K = int(input())
print(max(ABC) * K + (sum(ABC) - max(ABC)))
|
s456751163
|
Accepted
| 17
| 2,940
| 103
|
ABC = list(map(int, input().split()))
K = int(input())
print(max(ABC) * 2**K + (sum(ABC) - max(ABC)))
|
s626244528
|
p02389
|
u345673705
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,572
| 45
|
Write a program which calculates the area and perimeter of a given rectangle.
|
x, y = map(int, input().split())
x*y
2*(x+y)
|
s394278168
|
Accepted
| 20
| 5,580
| 53
|
x, y = map(int, input().split())
print(x*y, 2*(x+y))
|
s600315125
|
p02865
|
u208958463
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 100
|
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
|
a = int(input())
value = 0
if a%2 == 0:
value = a/2-1
else:
value = a/2
print(value)
|
s538941183
|
Accepted
| 18
| 2,940
| 120
|
a = int(input())
value = 0
if a%2 == 0:
value = round(a/2-1)
else:
value = round((a+1)/2-1)
print(value)
|
s792631942
|
p00586
|
u501510481
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,352
| 91
|
Compute A + B.
|
import sys
for line in sys.stdin:
items = line.split()
print( items[0] + items[1] )
|
s785638364
|
Accepted
| 30
| 7,648
| 101
|
import sys
for line in sys.stdin:
items = line.split()
print( int(items[0]) + int(items[1]) )
|
s228283012
|
p02694
|
u802341442
| 2,000
| 1,048,576
|
Wrong Answer
| 21
| 9,304
| 285
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
import math
x = int(input())
n = 16 // (math.log10(1.01))
a = 100
cnt = 0
while a <= x:
cnt += 1
a = math.floor(a * 1.01)
'''
for i in range(1, math.floor(n)+1):
a = math.floor(a * 1.01)
cnt += 1
if a >= x:
break
else:
continue
'''
print(cnt)
|
s174603168
|
Accepted
| 21
| 9,304
| 284
|
import math
x = int(input())
n = 16 // (math.log10(1.01))
a = 100
cnt = 0
while a < x:
cnt += 1
a = math.floor(a * 1.01)
'''
for i in range(1, math.floor(n)+1):
a = math.floor(a * 1.01)
cnt += 1
if a >= x:
break
else:
continue
'''
print(cnt)
|
s663828629
|
p00478
|
u546285759
| 8,000
| 131,072
|
Wrong Answer
| 20
| 7,636
| 76
|
あなたは N 個の指輪を持っている.どの指輪にも,アルファベットの大文字 10 文字からなる文字列が刻印されている.指輪には文字列の最初と最後がつながった形で文字が刻印されている.指輪に刻印された文字列を逆順に読む心配はない. 探したい文字列が与えられたとき,その文字列を含む指輪が何個あるかを求めるプログラムを作成せよ.
|
s=input()
print(sum(len(2*input().split(s))>1 for _ in range(int(input()))))
|
s559509560
|
Accepted
| 20
| 7,652
| 78
|
s=input()
print(sum(len((2*input()).split(s))>1 for _ in range(int(input()))))
|
s336217118
|
p03478
|
u689780189
| 2,000
| 262,144
|
Wrong Answer
| 37
| 2,940
| 236
|
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
N, A, B = map(int, input().split())
cnt = 0
for i in range(1, N + 1):
total = 0
str_i = str(i)
len_i = len(str_i)
for l in range(len_i):
total += int(str_i[l])
if A <= total <= B:
cnt += 1
print(cnt)
|
s755633518
|
Accepted
| 28
| 3,060
| 209
|
N, A, B = map(int, input().split())
All = 0
for i in range(1, N + 1):
total = 0
j = i
while j != 0:
total += j % 10
j = j // 10
if A <= total <= B:
All += i
print(All)
|
s729561134
|
p02612
|
u768199898
| 2,000
| 1,048,576
|
Wrong Answer
| 29
| 9,152
| 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())
num = N// 1000
mode = N % 1000
if mode == 0:
print(num)
else:
print(num + 1)
|
s904434960
|
Accepted
| 29
| 9,188
| 112
|
N = int(input())
num = N// 1000
mode = N % 1000
if mode == 0:
print(0)
else:
print((num + 1) * 1000 - N)
|
s148585574
|
p03543
|
u366886346
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 150
|
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**?
|
n=int(input())
a=n//1000
b=n//100-a*10
d=n%10
c=n%100-d
if a==b and b==c:
print("Yes")
elif b==c and c==d:
print("Yes")
else:
print("No")
|
s568740936
|
Accepted
| 17
| 2,940
| 162
|
n=int(input())
a=n//1000
b=(n//100)-(a*10)
d=n%10
c=((n%100)-d)//10
if a==b and b==c:
print("Yes")
elif b==c and c==d:
print("Yes")
else:
print("No")
|
s587930362
|
p03379
|
u626337957
| 2,000
| 262,144
|
Wrong Answer
| 334
| 25,228
| 161
|
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
|
N = int(input())
A = list(map(int, input().split()))
B = A.copy()
B.sort()
for num in A:
if B[N//2] >= num:
print(B[N//2])
else:
print(B[N//2-1])
|
s632285245
|
Accepted
| 343
| 25,224
| 160
|
N = int(input())
A = list(map(int, input().split()))
B = A.copy()
B.sort()
for num in A:
if B[N//2] > num:
print(B[N//2])
else:
print(B[N//2-1])
|
s807369332
|
p02841
|
u314365592
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 166
|
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.
|
month_1, day_1 = input().split()
month_2, day_2 = input().split()
int_month_1 = int(month_1)
int_month_2 = int(month_2)
if int_month_1 == int_month_2:
print(1)
|
s219249893
|
Accepted
| 18
| 2,940
| 186
|
month_1, day_1 = input().split()
month_2, day_2 = input().split()
int_month_1 = int(month_1)
int_month_2 = int(month_2)
if int_month_1 == int_month_2:
print('0')
else:
print('1')
|
s272099889
|
p04029
|
u821251381
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 34
|
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
N = int(input())
print(N*(N-1)//2)
|
s879289905
|
Accepted
| 17
| 2,940
| 34
|
N = int(input())
print(N*(N+1)//2)
|
s214453689
|
p02389
|
u733357255
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,600
| 179
|
Write a program which calculates the area and perimeter of a given rectangle.
|
l = input().split()
'''
a = int(l[0])
b = int(l[1])
'''
l = list(map(int,l))
a = l[0]*l[1]
b = 2*(l[0]*l[1])
print(a,b)
|
s180436515
|
Accepted
| 20
| 5,596
| 179
|
l = input().split()
'''
a = int(l[0])
b = int(l[1])
'''
l = list(map(int,l))
a = l[0]*l[1]
b = 2*(l[0]+l[1])
print(a,b)
|
s165308871
|
p02665
|
u210369205
| 2,000
| 1,048,576
|
Wrong Answer
| 105
| 20,136
| 623
|
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.
|
N = int(input())
A = list(map(int,input().split()))
k = sum(A)
c = 1
aa = 1
ans = 1
if A[0] != 0:
print(-1)
else:
for i in range(1,N + 1):
c *= 2
if A[i] > c:
aa = 0
break
elif A[i] == c:
if i != N - 1:
aa = 0
break
else:
ans += c
else:
c -= A[i]
k -= A[i]
ans += A[i]
if c >= k:
c = k
ans += c
if aa == 0:
print(-1)
else:
print(ans)
|
s777259675
|
Accepted
| 106
| 19,972
| 1,308
|
N = int(input())
A = list(map(int,input().split()))
k = sum(A)
c = 1
aa = 1
ans = 1
if A[0] != 0:
aa = 2
if N != 0:
print(-1)
else:
if A[0] == 1:
print(1)
else:
print(-1)
else:
for i in range(1,N + 1):
c *= 2
if A[i] > c:
aa = 0
break
elif A[i] == c:
if i != N:
aa = 0
break
else:
ans += c
else:
c -= A[i]
k -= A[i]
ans += A[i]
if c >= k:
c = k
ans += c
if aa == 0:
print(-1)
elif aa == 1:
print(ans)
|
s489553482
|
p03997
|
u798260206
| 2,000
| 262,144
|
Wrong Answer
| 20
| 9,080
| 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())
ans = (a+b)*h/2
print(ans)
|
s840977161
|
Accepted
| 19
| 8,852
| 81
|
a = int(input())
b= int(input())
h = int(input())
ans = (a+b)*h//2
print(ans)
|
s418392979
|
p04039
|
u802963389
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 166
|
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier.
|
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n+1, 10**6):
for j in str(i):
if j in a:
break
print(i)
exit()
|
s729193441
|
Accepted
| 112
| 2,940
| 180
|
n, k = map(int, input().split())
a = list(input().split())
for i in range(n, 10**6):
if all([j not in a for j in str(i)]):
# print([j for j in str(i)])
print(i)
exit()
|
s627522397
|
p03643
|
u643840641
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 20
|
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
|
print("ABC",input())
|
s605171187
|
Accepted
| 17
| 2,940
| 20
|
print("ABC"+input())
|
s353036612
|
p03415
|
u045408189
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 57
|
We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.
|
a=input()
b=input()
c=input()
print('a[0]'+'b[1]'+'c[2]')
|
s835475068
|
Accepted
| 17
| 2,940
| 52
|
a=input()[0]
b=input()[1]
c=input()[2]
print(a+b+c)
|
s000342792
|
p03644
|
u956257368
| 2,000
| 262,144
|
Wrong Answer
| 59
| 3,060
| 189
|
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())
dict = {}
for i in range(1, N+1):
n = float(i)
cnt = 0
while n/2>0.0:
if n%2 == 0.0:
cnt += 1
n = n/2
dict[i] = cnt
print(dict)
|
s821713364
|
Accepted
| 190
| 12,508
| 254
|
N = int(input())
dict = {}
for i in range(1, N+1):
n = float(i)
cnt = 0
while n/2>0.0:
if n%2 == 0.0:
cnt += 1
n = n/2
dict[i] = cnt
import numpy as np
print(list(dict.keys())[np.argmax(list(dict.values()))])
|
s585186034
|
p04043
|
u642874916
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 104
|
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 == 5:
print('YES')
else:
print('NO')
|
s904254358
|
Accepted
| 17
| 2,940
| 122
|
L = sorted(list(map(int, input().split())))
if L[0] == 5 and L[1] == 5 and L[2] == 7:
print('YES')
else:
print('NO')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.