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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s491982335
|
p03130
|
u580362735
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 209 |
There are four towns, numbered 1,2,3 and 4. Also, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally. No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads. Determine if we can visit all the towns by traversing each of the roads exactly once.
|
list_ = [[int(x) for x in input().split()] for i in range(3)]
count = [0]*4
for i in range(3):
count[list_[i][0]-1]+=1
count[list_[i][1]-1]+=1
print(count)
if 3 in count:
print('NO')
else:
print('YES')
|
s950566932
|
Accepted
| 18 | 2,940 | 197 |
list_ = [[int(x) for x in input().split()] for i in range(3)]
count = [0]*4
for i in range(3):
count[list_[i][0]-1]+=1
count[list_[i][1]-1]+=1
if 3 in count:
print('NO')
else:
print('YES')
|
s796935965
|
p03679
|
u693933222
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 121 |
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
|
x,a,b= map(int,input().split())
if(a<x):
print("delicious")
elif(a+x > b):
print("safe")
else:
print("dangerous")
|
s523350755
|
Accepted
| 17 | 2,940 | 121 |
x,a,b= map(int,input().split())
if(b<=a):
print("delicious")
elif(b<=a+x):
print("safe")
else:
print("dangerous")
|
s268954150
|
p03944
|
u007550226
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 271 |
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
|
W,H,N = map(int,input().split())
xl = yd = 0
xr = W
yu = H
for _ in range(N):
X,Y,A = map(int,input().split())
if A == 1:xl = max(X,xl)
elif A == 2:xr = min(X,xr)
elif A == 3:yd = max(Y,yd)
elif A == 4:zyu = min(Y,yu)
print(max(0,((xr-xl) * (yu-yd))))
|
s950194721
|
Accepted
| 18 | 3,064 | 281 |
W,H,N = map(int,input().split())
xl = yd = 0
xr = W
yu = H
for _ in range(N):
X,Y,A = map(int,input().split())
if A == 1:xl = max(X,xl)
elif A == 2:xr = min(X,xr)
elif A == 3:yd = max(Y,yd)
elif A == 4:yu = min(Y,yu)
s = max(0,(xr-xl)) * max(0,(yu-yd))
print(s)
|
s091069624
|
p03997
|
u674064321
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 73 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a, b, h = (int(input()) for _ in range(3))
print(a * h + (b - a) * h / 2)
|
s720431809
|
Accepted
| 16 | 2,940 | 70 |
a, b, h = (int(input()) for u in range(3))
print(int((a + b) * h / 2))
|
s938632500
|
p02409
|
u506705885
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,768 | 774 |
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.
|
import sys
write=sys.stdout.write
buildings=[[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]]]
for i in range(0,4):
for j in range(0,3):
for k in range(0,10):
buildings[i][j].append(0)
informations=int(input())
for i in range(0,informations):
information=[]
information=input().split()
information[0]=int(information[0])
information[1]=int(information[1])
information[2]=int(information[2])
information[3]=int(information[3])
buildings[information[0]-1][information[1]-1][information[2]-1]+=information[3]
for i in range(0,4):
for j in range(0,3):
for k in range(0,10):
write(str(buildings[i][j][k]))
print()
if i !=3:
for j in range(0,10):
write('#')
print()
|
s799726549
|
Accepted
| 20 | 5,632 | 342 |
buildings=[[[0 for i in range(10)]for m in range(3)]for k in range(4)]
x=int(input())
for i in range(x):
a,b,c,d=map(int,input().split())
buildings[a-1][b-1][c-1]+=d
for i in range(4):
for j in range(3):
for k in range(10):
print("",buildings[i][j][k],end="")
print()
if i!=3:
print("#"*20)
|
s413888936
|
p04029
|
u302292660
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 96 |
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?
|
def gokei(x):
if x<=0:
return 0
p = x + gokei(x-1)
return p
n = int(input())
gokei(n)
|
s044117283
|
Accepted
| 17 | 3,060 | 103 |
def gokei(x):
if x<=0:
return 0
p = x + gokei(x-1)
return p
n = int(input())
print(gokei(n))
|
s894124381
|
p03067
|
u885523920
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 100 |
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
|
A,B,C=map(int,input().split())
pr='yes'
if (A-B)*(C-B)>=0:
pr='no'
else:
pass
print(pr)
|
s644132175
|
Accepted
| 17 | 2,940 | 96 |
A,B,C=map(int,input().split())
pr='Yes'
if (A-C)*(B-C)>=0:
pr='No'
else:
pass
print(pr)
|
s671109570
|
p02363
|
u967553879
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,336 | 737 |
import copy
INF = 10**10
v, e = map(int, input().split())
M = [[INF]*v for i in range(v)]
for i in range(v):
M[i][i] = 0
for i in range(e):
s, t, d = map(int, input().split())
M[s][t] = d
ans = copy.deepcopy(M)
for k in range(v):
for i in range(v):
for j in range(v):
if k == 0:
ans[i][j] = M[i][j]
else:
ans[i][j] = min(ans[i][j], ans[i][k]+ans[k][j])
flag = False
for line in ans:
if any([i < 0 for i in line]):
flag = True
break
else:
line = ['INF' if tmp == INF else tmp for tmp in line]
if flag:
print('NEGATIVE CYCLE')
else:
print(*line)
|
s775414661
|
Accepted
| 880 | 7,204 | 768 |
import copy
INF = 10**10
v, e = map(int, input().split())
M = [[INF]*v for i in range(v)]
for i in range(v):
M[i][i] = 0
for i in range(e):
s, t, d = map(int, input().split())
M[s][t] = d
ans = copy.deepcopy(M)
for k in range(v):
for i in range(v):
if ans[i][k] == INF:
continue
for j in range(v):
if ans[k][j] == INF:
continue
ans[i][j] = min(ans[i][j], ans[i][k]+ans[k][j])
flag = False
for i in range(v):
if ans[i][i] < 0:
flag = True
break
if flag:
print('NEGATIVE CYCLE')
else:
for line in ans:
line = ['INF' if tmp == INF else tmp for tmp in line]
print(*line)
|
|
s966319975
|
p03379
|
u128646083
| 2,000 | 262,144 |
Wrong Answer
| 404 | 25,472 | 177 |
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())
x=list(map(int,input().split()))
x.sort()
for i in range(n):
if(i<n//2):
print('{0}'.format(x[n//2]))
else:
print('{0}'.format(x[n//2-1]))
|
s082689213
|
Accepted
| 407 | 25,620 | 186 |
n=int(input())
x=list(map(int,input().split()))
z=sorted(x)
for i in range(n):
if(x[i]<z[n//2]):
print('{0}'.format(z[n//2]))
else:
print('{0}'.format(z[n//2-1]))
|
s821069549
|
p02612
|
u223663729
| 2,000 | 1,048,576 |
Wrong Answer
| 26 | 9,040 | 31 |
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)
|
s220036489
|
Accepted
| 27 | 9,084 | 80 |
N = int(input())
if N % 1000 == 0:
print(0)
else:
print(1000-N % 1000)
|
s997343952
|
p03680
|
u581603131
| 2,000 | 262,144 |
Wrong Answer
| 199 | 7,084 | 195 |
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.
|
N = int(input())
a = [int(input()) for i in range(N)]
anow = 1
count = 0
for i in range(N):
anow = a[anow-1]
count += 1
if anow == 2:
break
print('count' if anow==2 else '-1')
|
s058995551
|
Accepted
| 193 | 7,084 | 193 |
N = int(input())
a = [int(input()) for i in range(N)]
anow = 1
count = 0
for i in range(N):
anow = a[anow-1]
count += 1
if anow == 2:
break
print(count if anow==2 else '-1')
|
s558604041
|
p03447
|
u333731247
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 65 |
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
|
X=int(input())
A=int(input())
B=int(input())
print(int((X-A)/B))
|
s152541590
|
Accepted
| 17 | 2,940 | 65 |
X=int(input())
A=int(input())
B=int(input())
print(int((X-A)%B))
|
s938996468
|
p02613
|
u078168851
| 2,000 | 1,048,576 |
Wrong Answer
| 146 | 9,208 | 295 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
n = int(input())
ac, wa, tle, re = 0, 0, 0, 0;
for i in range(n):
s = input()
if s == 'AC':
ac += 1
elif s == 'WA':
wa += 1
elif s == 'TLE':
tle += 1
else:
re += 1
print('AC ×', ac)
print('WA ×', wa)
print('TLE ×', tle)
print('RE ×', re)
|
s529324566
|
Accepted
| 152 | 9,208 | 303 |
n = int(input())
ac, wa, tle, re = 0, 0, 0, 0;
for i in range(n):
s = input()
if s == 'AC':
ac += 1
elif s == 'WA':
wa += 1
elif s == 'TLE':
tle += 1
else:
re += 1
print('AC', 'x', ac)
print('WA', 'x', wa)
print('TLE', 'x', tle)
print('RE', 'x', re)
|
s815245593
|
p03636
|
u549161102
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 95 |
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
s = input()
she = s[0]
srev = s[::-1]
stai = srev[0]
long = len(s) - 2
print('she''long''stai')
|
s667290035
|
Accepted
| 18 | 2,940 | 74 |
s = input()
a = s[0]
b = s[-1]
long = len(s) - 2
print(a + str(long) + b)
|
s135390459
|
p03759
|
u755180064
| 2,000 | 262,144 |
Wrong Answer
| 28 | 8,956 | 176 |
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
def main():
t = list(map(int, input().split()))
if t[1] - t[0] == t[2] - t[1]:
print('Yes')
else:
print('No')
if __name__ == '__main__':
main()
|
s274137139
|
Accepted
| 23 | 9,016 | 176 |
def main():
t = list(map(int, input().split()))
if t[1] - t[0] == t[2] - t[1]:
print('YES')
else:
print('NO')
if __name__ == '__main__':
main()
|
s182972608
|
p02255
|
u197615397
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,616 | 312 |
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
def insertionSort(a):
n = len(a)
for i in range(1, n):
v = a[i]
j = i-1
while j>=0 and a[j]>v:
a[j+1] = a[j]
j-=1
a[j+1] = v
print(" ".join([str(i) for i in a]))
n = input()
a = [int(s) for s in input().split(" ")]
insertionSort(a)
|
s818104819
|
Accepted
| 20 | 5,980 | 184 |
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
j = i
while j >= 1 and a[j-1] > a[j]:
a[j-1], a[j] = a[j], a[j-1]
j -= 1
print(*a)
|
s982248925
|
p02853
|
u143051858
| 2,000 | 1,048,576 |
Wrong Answer
| 31 | 9,028 | 203 |
We held two competitions: Coding Contest and Robot Maneuver. In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen. DISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver. Find the total amount of money he earned.
|
a = list(map(int,input().split()))
ans = 0
for v in a:
if v == 1:
ans += 30000
elif v == 2:
ans += 20000
else:
ans += 10000
if sum(a) == 2:
ans += 40000
print(ans)
|
s608567634
|
Accepted
| 32 | 9,172 | 214 |
a = list(map(int,input().split()))
ans = 0
for v in a:
if v == 1:
ans += 300000
elif v == 2:
ans += 200000
elif v == 3:
ans += 100000
if sum(a) == 2:
ans += 400000
print(ans)
|
s967999983
|
p03387
|
u411158173
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 269 |
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
|
L = [int(i) for i in input().split()]
count = 0
L.sort()
while L[2]-L[0] >= 2:
L[0] += 2
count += 1
while L[2]-L[1] >= 2:
L[1] += 2
count += 1
L.sort()
print(L)
if L[0] != L[1]:
count += 2
else:
if L[0] != L[2]:
count += 1
print(count)
|
s840981586
|
Accepted
| 17 | 3,064 | 260 |
L = [int(i) for i in input().split()]
count = 0
L.sort()
while L[2]-L[0] >= 2:
L[0] += 2
count += 1
while L[2]-L[1] >= 2:
L[1] += 2
count += 1
L.sort()
if L[0] != L[1]:
count += 2
else:
if L[0] != L[2]:
count += 1
print(count)
|
s644966758
|
p03623
|
u695079172
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 126 |
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
x,a,b = map(int,input().split())
answer = 0
if abs(x-a) >= abs(x-b):
answer = "a"
else:
answer = "b"
print(answer.upper())
|
s146222208
|
Accepted
| 17 | 2,940 | 74 |
x,a,b = map(int,input().split())
print("B" if abs(x-a)>abs(x-b) else "A")
|
s525314784
|
p03711
|
u960513073
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 145 |
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.
|
a = [4,6,9, 11]
x,y = list(map(int, input().split()))
if x ==2 or y ==2:
print("No")
elif x in a and y in a:
print("Yes")
else:
print("No")
|
s952728369
|
Accepted
| 17 | 3,060 | 206 |
a = [4,6,9, 11]
b = [1,3,5,7,8,10,12]
x,y = list(map(int, input().split()))
if x ==2 or y ==2:
print("No")
elif x in a and y in a:
print("Yes")
elif x in b and y in b:
print("Yes")
else:
print("No")
|
s429835291
|
p03673
|
u581187895
| 2,000 | 262,144 |
Wrong Answer
| 2,105 | 21,488 | 198 |
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
|
import sys
input = sys.stdin.readline
from collections import deque
n = int(input())
q = deque(list(input().split()))
s = ""
for i in range(n):
s += q.popleft()
s[::-1]
print(" ".join(s))
|
s224860345
|
Accepted
| 170 | 24,512 | 201 |
from collections import deque
N = int(input())
S = input().split()
B = deque()
for i in range(N):
if i%2==0:
B.append(S[i])
else:
B.appendleft(S[i])
if N%2 == 1:
B.reverse()
print(*B)
|
s082454982
|
p03214
|
u227082700
| 2,525 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 141 |
Niwango-kun is an employee of Dwango Co., Ltd. One day, he is asked to generate a thumbnail from a video a user submitted. To generate a thumbnail, he needs to select a frame of the video according to the following procedure: * Get an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the number of the frames of the video, and each a_i denotes the representation of the i-th frame of the video. * Select t-th frame whose representation a_t is nearest to the average of all frame representations. * If there are multiple such frames, select the frame with the smallest index. Find the index t of the frame he should select to generate a thumbnail.
|
n=int(input());a=list(map(int,input().split()));ave=sum(a)//n;minn=0
for i in range(1,n):
if abs(a[minn]-ave)>abs(a[i]-ave):minn=i
print(i)
|
s451370517
|
Accepted
| 30 | 9,116 | 154 |
n=int(input())
a=list(map(int,input().split()))
ave=sum(a)/n
m=10**10
ans=0
for i in a:
if m>abs(ave-i):
m=abs(ave-i)
ans=i
print(a.index(ans))
|
s260211736
|
p03377
|
u090325904
| 2,000 | 262,144 |
Wrong Answer
| 153 | 14,428 | 153 |
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.
|
# coding : utf-8
import numpy as np
A = input().split()
A = [int(i) for i in A]
if(A[0] < A[2] and A[0]+A[1] > A[2]):
print("Yes")
else:
print("No")
|
s402815365
|
Accepted
| 630 | 21,772 | 150 |
# coding : utf-8
import numpy as np
A = [int(i) for i in input().split()]
if A[0] <= A[2] and A[0] + A[1] >= A[2]:
print("YES")
else:
print("NO")
|
s449873932
|
p03555
|
u694810977
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 137 |
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
|
a = []
b = []
a = str(input())
b = str(input())
if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:
print("Yes")
else:
print("No")
|
s585949336
|
Accepted
| 17 | 2,940 | 137 |
a = []
b = []
a = str(input())
b = str(input())
if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:
print("YES")
else:
print("NO")
|
s193164729
|
p02613
|
u935139749
| 2,000 | 1,048,576 |
Wrong Answer
| 140 | 16,128 | 345 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
# -*- coding: utf-8 -*-
TestCase = int(input())
str_list = []
str_list = [input() for _ in range(TestCase)]
print("{} {}".format("AC ×",str_list.count('AC')))
print("{} {}".format("WA ×",str_list.count('WA')))
print("{} {}".format("TLE ×",str_list.count('TLE')))
print("{} {}".format("RE ×",str_list.count('RE')))
|
s935314700
|
Accepted
| 141 | 16,296 | 211 |
a = int(input())
str_list = []
str_list = [input() for _ in range(a)]
print("AC x",str_list.count("AC"))
print("WA x",str_list.count("WA"))
print("TLE x",str_list.count("TLE"))
print("RE x",str_list.count("RE"))
|
s920975187
|
p02613
|
u562147608
| 2,000 | 1,048,576 |
Wrong Answer
| 156 | 9,216 | 328 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
a = int(input())
i = 0
o = 0
p = 0
s = 0
l = 0
while i < a :
b = input()
if b == "AC" :
o = o + 1
if b == "WA" :
p = p + 1
if b == "TLE" :
s = s + 1
if b == "RE" :
l = l + 1
i = i + 1
print("AC" , "*" , o)
print("WA" , "*" , p)
print("TLE" , "*" , s)
print("RE" , "*" , l)
|
s642835012
|
Accepted
| 154 | 9,212 | 328 |
a = int(input())
i = 0
o = 0
p = 0
s = 0
l = 0
while i < a :
b = input()
if b == "AC" :
o = o + 1
if b == "WA" :
p = p + 1
if b == "TLE" :
s = s + 1
if b == "RE" :
l = l + 1
i = i + 1
print("AC" , "x" , o)
print("WA" , "x" , p)
print("TLE" , "x" , s)
print("RE" , "x" , l)
|
s657035523
|
p03027
|
u427344224
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,064 | 592 |
Consider the following arithmetic progression with n terms: * x, x + d, x + 2d, \ldots, x + (n-1)d What is the product of all terms in this sequence? Compute the answer modulo 1\ 000\ 003. You are given Q queries of this form. In the i-th query, compute the answer in case x = x_i, d = d_i, n = n_i.
|
class FactMod:
def __init__(self, n, mod):
self.mod = mod
self.f = [1] * (n + 1)
for i in range(1, n + 1):
self.f[i] = self.f[i - 1] * i % mod
self.inv = [pow(self.f[-1], mod - 2, mod)]
for i in reversed(range(1, n + 1)):
self.inv.append(self.inv[-1] * i % mod)
self.inv.reverse()
def fact(self, n):
"""
:return: n!
"""
return self.f[n]
def comb(self, n, r):
"""
:return: nCr
"""
return self.f[n] * self.inv[n - r] * self.inv[r] % self.mod
|
s342708013
|
Accepted
| 1,487 | 102,468 | 1,101 |
class FactMod:
def __init__(self, n, mod):
self.mod = mod
self.f = [1] * (n + 1)
for i in range(1, n + 1):
self.f[i] = self.f[i - 1] * i % mod
self.inv = [pow(self.f[-1], mod - 2, mod)]
for i in reversed(range(1, n + 1)):
self.inv.append(self.inv[-1] * i % mod)
self.inv.reverse()
def fact(self, n):
"""
:return: n!
"""
return self.f[n]
Q = int(input())
items = []
for i in range(Q):
items.append(tuple(map(int, input().split())))
mod = 10 ** 6 + 3
fact_mod = FactMod(mod - 1, mod)
for x, d, n in items:
if d == 0:
print(pow(x, n, mod))
elif x == 0:
print(0)
else:
invd = pow(d, mod - 2, mod)
xd = x * invd % mod
if n - 1 + xd >= mod:
print(0)
continue
dn = pow(d, n, mod)
print(fact_mod.fact(xd + n - 1) * fact_mod.inv[xd - 1] % mod * dn % mod)
|
s594494572
|
p03386
|
u057079894
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 27,600 | 147 |
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
a, b, k = map(int,input().split())
for i in range(1, min(a + k + 1, b + 1)):
print(i)
for i in range(max(b - k, a + k + 1, b + 1)):
print(i)
|
s482110577
|
Accepted
| 17 | 3,060 | 144 |
a, b, k = map(int,input().split())
for i in range(a, min(a + k, b + 1)):
print(i)
for i in range(max(b - k + 1, a + k), b + 1):
print(i)
|
s287086250
|
p04043
|
u596668473
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 101 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a = list(map(int,input().split(" ")))
b = [5,7,5]
if b == a.sort():
print("YES")
else:
print("NO")
|
s015381282
|
Accepted
| 17 | 2,940 | 102 |
a = list(map(int,input().split(" ")))
b = [5,5,7]
a.sort()
if b == a:
print("YES")
else:
print("NO")
|
s558938571
|
p04045
|
u842689614
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 678 |
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_str, K=input().split()
N_digit=list(map(int,list(N_str)))
D=sorted(list(map(int,input().split())))
l_digit=[n>D[-1] for n in N_digit]
if any(l_digit):
N_n=l_digit.index(True)
if not any([n<D[-1] for n in N_digit[0:N_n]]):
out=[str(D[0]) for i in range(len(N_digit)+1)]
else:
out=[str(D[[n<=D[j] for j in range(int(K))].index(True)]) for n in N_digit[0:N_n]] + [str(D[0]) for n in N_digit[N_n:]]
for k in range(N_n-1,-1,-1):
if N_digit[k]<D[-1]:
out[k]=str(D[[N_digit[k]<D[j] for j in range(int(K))].index(True)])
break
else:
out=[str(D[[n<=D[j] for j in range(int(K))].index(True)]) for n in N_digit]
print(int("".join(out)))
|
s013525221
|
Accepted
| 20 | 3,064 | 1,007 |
N_str, K=input().split()
K=10-int(K)
N_digit=list(map(int,list(N_str)))
D=sorted(list(map(int,input().split())))
D=[d for d in range(10) if d not in D]
l_digit=[n>D[-1] for n in N_digit]
if any(l_digit):
N_n=l_digit.index(True)
if not any([n is not D[-1] for n in N_digit[0:N_n]]):
out=list(str(D[1] if D[0]==0 else D[0]))
out+=[str(D[0]) for i in range(len(N_digit))]
else:
flag=False
out=[]
for i in range(N_n):
if not flag:
for j in range(K):
if D[j]>=N_digit[i]:
out.append(str(D[j]))
if D[j]!=N_digit[i]:
flag=True
break
else:
out.append(str(D[0]))
for i in range(N_n,len(N_digit)):
out.append(str(D[0]))
else:
out=[]
flag=False
for n in N_digit:
if not flag:
for j in range(K):
if D[j]>=n:
out.append(str(D[j]))
if D[j]>n:
flag=True
break
else:
out.append(str(D[0]))
print(int("".join(out)))
|
s461351859
|
p00331
|
u724548524
| 1,000 | 262,144 |
Wrong Answer
| 20 | 5,580 | 87 |
太陽が現れることを「日の出」、隠れることを「日の入り」と呼びますが、その厳密な時刻は太陽が地平線に対してどのような位置にある時でしょうか。 下の図のように、太陽を円、地平線を直線で表すことにします。このとき、太陽の「日の出」「日の入り」の時刻は、太陽を表す円の上端が地平線を表す直線と一致する瞬間とされています。日の出の時刻を過ぎ、円の上端が直線より上にある時間帯が昼間、円が直線の下へ完全に隠れている時間帯が夜間となります。 ある時刻の地平線から太陽の中心までの高さと、太陽の半径を入力とし、その時刻が「昼間」か、「日の出または日の入り」か、「夜間」かを出力するプログラムを作成せよ。
|
h, r = map(int, input().split())
if h + r < 0:print(-1)
else:print(0 if h == r else 1)
|
s700660774
|
Accepted
| 20 | 5,584 | 91 |
h, r = map(int, input().split())
if h + r < 0:print(-1)
else:print(0 if h + r == 0 else 1)
|
s125507070
|
p04031
|
u006657459
| 2,000 | 262,144 |
Wrong Answer
| 36 | 5,232 | 157 |
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective.
|
from statistics import median
N = int(input())
a = [int(ai) for ai in input().split()]
med = median(set(a))
ret = sum([(ai - med)**2 for ai in a])
print(ret)
|
s723040085
|
Accepted
| 151 | 12,428 | 191 |
import numpy as np
import math
N = input()
a = np.array([int(ai) for ai in input().split()])
m = np.mean(a)
a1 = (a - math.floor(m))**2
a2 = (a - math.ceil(m))**2
print(min(sum(a1), sum(a2)))
|
s553694769
|
p03762
|
u875054522
| 2,000 | 262,144 |
Wrong Answer
| 20 | 5,108 | 130 |
On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
|
o = input()
e = input()
for i in range(min(len(o),len(e))):
print('%s%s' % (o[i],e[i]), end='')
if len(o)>len(e): print(o[-1])
|
s411621766
|
Accepted
| 176 | 18,624 | 377 |
n, m = map(int, input().split())
x_list = tuple(map(int, input().split()))
y_list = tuple(map(int, input().split()))
mod = 10 ** 9 + 7
x_sum = 0
for i in range(1, n + 1):
x_sum += ((i - 1) * x_list[i - 1] - (n - i) * x_list[i - 1]) % mod
y_sum = 0
for i in range(1, m + 1):
y_sum += ((i - 1) * y_list[i - 1] - (m - i) * y_list[i - 1]) % mod
print(x_sum * y_sum % mod )
|
s745909149
|
p02255
|
u890722286
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,636 | 272 |
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())
numbers = list(map(int, input().split()))
for i in range(1, n):
key = numbers[i]
j = i - 1
while 0 <= j and key < numbers[j]:
numbers[j+1] = numbers[j]
j -= 1
numbers[j+1] = key
print(' '.join(str(x) for x in numbers))
|
s347402887
|
Accepted
| 20 | 7,768 | 313 |
n = int(input())
numbers = list(map(int, input().split()))
print(' '.join(str(x) for x in numbers))
for i in range(1, n):
key = numbers[i]
j = i - 1
while 0 <= j and key < numbers[j]:
numbers[j+1] = numbers[j]
j -= 1
numbers[j+1] = key
print(' '.join(str(x) for x in numbers))
|
s039703153
|
p03485
|
u735233212
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 96 |
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a, b = map(int, input().split())
if ((a+b)%2 == 1):
print((a+b+1)/2)
else:
print((a+b)/2)
|
s909847096
|
Accepted
| 17 | 2,940 | 108 |
a, b = map(int, input().split())
if ((a+b)%2 == 1):
print(int((a+b+1)/2))
else:
print(int((a+b)/2))
|
s272640087
|
p02389
|
u022579771
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,656 | 132 |
Write a program which calculates the area and perimeter of a given rectangle.
|
s = input()
input_str = s.split(" ")
x = int(input_str[0])
y = int(input_str[1])
print(x * y)
print(2 * (x + y))
|
s481727069
|
Accepted
| 20 | 7,660 | 145 |
s = input()
input_str = s.split(" ")
x = int(input_str[0])
y = int(input_str[1])
print("{0} {1}".format(x * y, 2 * (x + y)))
|
s170892076
|
p03943
|
u668352391
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 127 |
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(lambda x: int(x), input().split())
lis = [a, b, c]
lis.sort()
if a + b == c:
print('Yes')
else:
print('No')
|
s408801838
|
Accepted
| 17 | 2,940 | 142 |
a, b, c = map(lambda x: int(x), input().split())
lis = [a, b, c]
lis.sort()
if lis[0] + lis[1] == lis[2]:
print('Yes')
else:
print('No')
|
s890530819
|
p03457
|
u128661070
| 2,000 | 262,144 |
Wrong Answer
| 406 | 11,820 | 381 |
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
# -*- coding:utf-8 -*-
n = int(input())
t, x, y = [0], [0], [0]
for i in range(n):
t_i, x_i, y_i = map(int, input().strip().split())
t.append(t_i)
x.append(x_i)
y.append(y_i)
can = "YES"
for i in range(n):
dt = t[i+1] - t[i]
dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
can = "NO" if dt < dist else "YES"
can = "NO" if dist % 2 != dt % 2 else "YES"
print(can)
|
s875626098
|
Accepted
| 415 | 11,732 | 373 |
# -*- coding:utf-8 -*-
n = int(input())
t, x, y = [0], [0], [0]
for i in range(n):
t_i, x_i, y_i = map(int, input().strip().split())
t.append(t_i)
x.append(x_i)
y.append(y_i)
can = "Yes"
for i in range(n):
dt = t[i+1] - t[i]
dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
if (dt < dist):
can = "No"
if(dist % 2 != dt % 2):
can = "No"
print(can)
|
s173773794
|
p03827
|
u225388820
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 139 |
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()
d=[0]*n
for i in range(1,n):
if s[i]=="I":
d[i]=d[i-1]+1
else:
d[i]=d[i-1]-1
print(max(d))
|
s411530054
|
Accepted
| 17 | 2,940 | 141 |
n=int(input())
s=input()
d=[0]*(n+1)
for i in range(n):
if s[i]=="I":
d[i]=d[i-1]+1
else:
d[i]=d[i-1]-1
print(max(d))
|
s433964984
|
p02747
|
u337626942
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 72 |
A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string.
|
s=input()
s.replace("hi", "")
if s=="":
print("Yes")
else:
print("No")
|
s427002488
|
Accepted
| 17 | 2,940 | 80 |
s=input()
for i in range(6):
if s=="hi" *i:
print("Yes")
exit()
print("No")
|
s813464803
|
p03435
|
u395287676
| 2,000 | 262,144 |
Wrong Answer
| 45 | 5,076 | 645 |
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct.
|
from fractions import Fraction
def is_integer(fraction):
return fraction.numerator % fraction.denominator == 0
def main(*args, **kwargs):
"""Write Codes for contest here."""
grid = []
for i in range(3):
grid.append(list(map(int, input().split())))
for b_sum in range(1, 301):
a1 = Fraction(Fraction(sum(grid[0]), b_sum), 3)
a2 = Fraction(Fraction(sum(grid[1]), b_sum), 3)
a3 = Fraction(Fraction(sum(grid[2]), b_sum), 3)
if is_integer(a1) and is_integer(a2) and is_integer(a3) and 0 <= a1 <= 100 and 0 <= a2 <= 100 and 0 <= a3 <= 100:
print('Yes')
print('No')
main()
|
s438279931
|
Accepted
| 244 | 3,064 | 1,149 |
def main(*args, **kwargs):
"""Write Codes for contest here."""
grid = []
for i in range(3):
grid.append(list(map(int, input().split())))
#for b_sum in range(1, 301):
# a1 = Fraction(Fraction(sum(grid[0]), b_sum), 3)
# a2 = Fraction(Fraction(sum(grid[1]), b_sum), 3)
# a3 = Fraction(Fraction(sum(grid[2]), b_sum), 3)
# if is_integer(a1) and is_integer(a2) and is_integer(a3) and 0 <= a1 <= 100 and 0 <= a2 <= 100 and 0 <= a3 <= 100:
# print('Yes')
for a1 in range(0, 101):
b1_1 = grid[0][0] - a1
b2_1 = grid[0][1] - a1
b3_1 = grid[0][2] - a1
for a2 in range(0, 101):
b1_2 = grid[1][0] - a2
b2_2 = grid[1][1] - a2
b3_2 = grid[1][2] - a2
for a3 in range(0, 101):
b1_3 = grid[2][0] - a3
b2_3 = grid[2][1] - a3
b3_3 = grid[2][2] - a3
# Check the condition
if b1_1 == b1_2 == b1_3 and b2_1 == b2_2 == b2_3 and b3_1 == b3_2 == b3_3:
print('Yes')
return
print('No')
return
main()
|
s120722567
|
p03644
|
u750651325
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 101 |
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())
a = 0
for i in range(N):
if i % 2== 0:
a = i
print(a)
|
s957354360
|
Accepted
| 17 | 3,060 | 195 |
N = int(input())
a = 0
if N == 1:
print(1)
elif N <4:
print(2)
elif N<8:
print(4)
elif N<16:
print(8)
elif N<32:
print(16)
elif N<64:
print(32)
elif N<=100:
print(64)
|
s791130027
|
p03992
|
u532966492
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 32 |
This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the first 4 letters and last 8 letters in the string s.
|
s=input()
print(s[:4]+" "+s[5:])
|
s697458295
|
Accepted
| 17 | 2,940 | 32 |
s=input()
print(s[:4]+" "+s[4:])
|
s867816465
|
p03130
|
u668503853
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 130 |
There are four towns, numbered 1,2,3 and 4. Also, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally. No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads. Determine if we can visit all the towns by traversing each of the roads exactly once.
|
R=[int(x) for x in input().split() for _ in range(3)]
ans="YES"
for r in R:
if R.count(r)==3 :
ans="NO"
break
print(ans)
|
s613047333
|
Accepted
| 17 | 2,940 | 131 |
C=[0,0,0,0]
for _ in range(3):
a,b=map(int,input().split())
C[a-1]+=1
C[b-1]+=1
if 3 in C:
print("NO")
else:
print("YES")
|
s956523720
|
p03090
|
u436335113
| 2,000 | 1,048,576 |
Wrong Answer
| 23 | 3,336 | 2,536 |
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 == 3:
print("1 3")
print("2 3")
if n == 4:
print("1 2")
print("1 3")
print("2 4")
print("3 4")
if n >= 5:
if n % 2 == 0:
for i in range(1, n):
for j in range(i+1, n+1):
if i + j != n+1:
print(str(i)+" "+str(j))
if n % 2 == 1:
for i in range(1, n-1):
for j in range(i+1, n):
if i + j != n:
print(str(i)+" "+str(j))
for i in range(1, n):
print(str(i)+" "+str(n))
# for ptn1 in range(2 ** 5):
# ptn_str1 = format(ptn1, '05b')
# p1 = []
# for i, p in enumerate(ptn_str1):
# if p == '1':
# p1.append(i+2)
# for ptn2 in range(2 ** 4):
# ptn_str2 = format(ptn2, '04b')
# p2 = []
# for j, q in enumerate(ptn_str2):
# p2.append(j+3)
# for ptn3 in range(2 ** 3):
# ptn_str3 = format(ptn3, '03b')
# p3 = []
# for k, r in enumerate(ptn_str3):
# if r == '1':
# p3.append(k+4)
# for ptn4 in range(2 ** 2):
# ptn_str4 = format(ptn4, '02b')
# p4 = []
# for l, s in enumerate(ptn_str4):
# p4.append(l+5)
# adds = [0, 0, 0, 0, 0, 0]
# for x in p1:
# adds[0] += x
# adds[x-1] += 1
# for y in p2:
# adds[1] += y
# adds[y-1] += 2
# adds[z-1] += 3
# if adds[4]+6 == adds[5]+5:
# # print("adds5&6"+ptn_str1+"/"+ptn_str2+"/"+ptn_str3+"/"+ptn_str4)
# adds[4] += 6
# adds[5] += 5
# equal = True
# for s in adds:
# equal = False
# break
# if equal is True:
# print(eq)
# print(ptn_str1)
# print(ptn_str2)
# print(ptn_str3)
# print(ptn_str4)
|
s747918289
|
Accepted
| 23 | 3,588 | 2,804 |
n = int(input())
if n == 3:
print("2")
print("1 3")
print("2 3")
if n == 4:
print("4")
print("1 2")
print("1 3")
print("2 4")
print("3 4")
if n >= 5:
ans = []
if n % 2 == 0:
for i in range(1, n):
for j in range(i+1, n+1):
if i + j != n+1:
ans.append(str(i)+" "+str(j))
# print(str(i)+" "+str(j))
if n % 2 == 1:
for i in range(1, n-1):
for j in range(i+1, n):
if i + j != n:
ans.append(str(i)+" "+str(j))
# print(str(i)+" "+str(j))
for i in range(1, n):
ans.append(str(i)+" "+str(n))
# print(str(i)+" "+str(n))
ans_len = len(ans)
print(ans_len)
for a in ans:
print(a)
# for ptn1 in range(2 ** 5):
# ptn_str1 = format(ptn1, '05b')
# p1 = []
# for i, p in enumerate(ptn_str1):
# if p == '1':
# p1.append(i+2)
# for ptn2 in range(2 ** 4):
# ptn_str2 = format(ptn2, '04b')
# p2 = []
# for j, q in enumerate(ptn_str2):
# p2.append(j+3)
# for ptn3 in range(2 ** 3):
# ptn_str3 = format(ptn3, '03b')
# p3 = []
# for k, r in enumerate(ptn_str3):
# if r == '1':
# p3.append(k+4)
# for ptn4 in range(2 ** 2):
# ptn_str4 = format(ptn4, '02b')
# p4 = []
# for l, s in enumerate(ptn_str4):
# p4.append(l+5)
# adds = [0, 0, 0, 0, 0, 0]
# for x in p1:
# adds[0] += x
# adds[x-1] += 1
# for y in p2:
# adds[1] += y
# adds[y-1] += 2
# adds[z-1] += 3
# if adds[4]+6 == adds[5]+5:
# # print("adds5&6"+ptn_str1+"/"+ptn_str2+"/"+ptn_str3+"/"+ptn_str4)
# adds[4] += 6
# adds[5] += 5
# equal = True
# for s in adds:
# equal = False
# break
# if equal is True:
# print(eq)
# print(ptn_str1)
# print(ptn_str2)
# print(ptn_str3)
# print(ptn_str4)
|
s518662753
|
p02262
|
u867503285
| 6,000 | 131,072 |
Wrong Answer
| 20 | 7,732 | 569 |
Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i]) A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$. Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m − 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements: * $1 \leq m \leq 100$ * $0 \leq G_i \leq n$ * cnt does not exceed $\lceil n^{1.5}\rceil$
|
def insertion_sort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j + g] = A[j]
j -= g
cnt += 1
A[j + g] = v
def shell_sort(A, n):
G = []
i = 1
while i < n:
G[0:0] = [i]
i = i * 3 + 1
for g in G:
insertion_sort(A, n, g)
return len(G), G
N = int(input())
a = [int(input()) for i in range(N)]
cnt = 0
m, Gl = shell_sort(a, N)
print(m, ' '.join(str(g) for g in Gl), '\n'.join(str(e) for e in a), sep='\n')
|
s552868506
|
Accepted
| 21,490 | 127,972 | 575 |
def insertion_sort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j + g] = A[j]
j -= g
cnt += 1
A[j + g] = v
def shell_sort(A, n):
G = []
i = 1
while i <= n:
G[0:0] = [i]
i = i * 3 + 1
for g in G:
insertion_sort(A, n, g)
return len(G), G
N = int(input())
a = [int(input()) for i in range(N)]
cnt = 0
m, Gl = shell_sort(a, N)
print(m, ' '.join(str(g) for g in Gl), cnt, '\n'.join(str(e) for e in a), sep='\n')
|
s389925529
|
p02288
|
u255317651
| 2,000 | 131,072 |
Wrong Answer
| 20 | 5,672 | 797 |
A binary heap which satisfies max-heap property is called max-heap. In a max- heap, for every node $i$ other than the root, $A Write a program which reads an array and constructs a max-heap from the array based on the following pseudo code. $maxHeapify(A, i)$ move the value of $A[i]$ down to leaves to make a sub-tree of node $i$ a max-heap. Here, $H$ is the size of the heap. 1 maxHeapify(A, i) 2 l = left(i) 3 r = right(i) 4 // select the node which has the maximum value 5 if l ≤ H and A[l] > A[i] 6 largest = l 7 else 8 largest = i 9 if r ≤ H and A[r] > A[largest] 10 largest = r 11 12 if largest ≠ i // value of children is larger than that of i 13 swap A[i] and A[largest] 14 maxHeapify(A, largest) // call recursively The following procedure buildMaxHeap(A) makes $A$ a max-heap by performing maxHeapify in a bottom-up manner. 1 buildMaxHeap(A) 2 for i = H/2 downto 1 3 maxHeapify(A, i)
|
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 9 13:21:18 2018
ALDS1-9b
@author: maezawa
"""
import math
h = int(input())
a = list(map(int,input().split()))
def parent(node):
return math.floor(node/2)
def left(node):
return 2*node
def right(node):
return 2*node+1
def max_heapify(a, i):
l = left(i)
r = right(i)
if l <= h and a[l-1] > a[i-1]:
largest = l
else:
largest = i
if r <= h and a[r-1] > a[largest-1]:
largest = r
if largest != i:
a[i-1], a[largest-1] = a[largest-1], a[i-1]
max_heapify(a, largest)
def build_max_heap(a):
for i in list(range(1,h//2))[::-1]:
max_heapify(a, i)
#print(a)
build_max_heap(a)
for i in range(h):
print(' {}'.format(a[i]),end = '')
|
s406153676
|
Accepted
| 1,730 | 63,776 | 807 |
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 9 13:21:18 2018
ALDS1-9b
@author: maezawa
"""
import math
h = int(input())
a = list(map(int,input().split()))
def parent(node):
return math.floor(node/2)
def left(node):
return 2*node
def right(node):
return 2*node+1
def max_heapify(a, i):
l = left(i)
r = right(i)
if l <= h and a[l-1] > a[i-1]:
largest = l
else:
largest = i
if r <= h and a[r-1] > a[largest-1]:
largest = r
if largest != i:
a[i-1], a[largest-1] = a[largest-1], a[i-1]
max_heapify(a, largest)
def build_max_heap(a):
for i in list(range(1,h//2+1))[::-1]:
max_heapify(a, i)
#print(a)
build_max_heap(a)
for i in range(h):
print(' {}'.format(a[i]),end = '')
print()
|
s553482135
|
p02612
|
u837340160
| 2,000 | 1,048,576 |
Wrong Answer
| 34 | 9,132 | 33 |
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)
|
s912730299
|
Accepted
| 33 | 9,132 | 92 |
N = int(input())
if N % 1000 == 0:
print(0)
else:
print((N // 1000 + 1) * 1000 - N)
|
s092676336
|
p02388
|
u967268722
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,504 | 36 |
Write a program which calculates the cube of a given integer x.
|
def function(x):
return x ** 3
|
s413289148
|
Accepted
| 20 | 5,576 | 24 |
print(int(input())**3)
|
s238192575
|
p02613
|
u799978560
| 2,000 | 1,048,576 |
Wrong Answer
| 150 | 16,084 | 312 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
##B
N = int(input())
S = list(input() for i in range(N))
a=0
b=0
c=0
d=0
for i in S:
if i =="AC":
a +=1
elif i =="WA":
b +=1
elif i =="TLE":
c +=1
elif i =="RE":
d +=1
print("AC × "+ str(a))
print("WA × "+ str(b))
print("TLE × "+ str(c))
print("RE × "+ str(d))
|
s026403572
|
Accepted
| 149 | 16,024 | 308 |
##B
N = int(input())
S = list(input() for i in range(N))
a=0
b=0
c=0
d=0
for i in S:
if i =="AC":
a +=1
elif i =="WA":
b +=1
elif i =="TLE":
c +=1
elif i =="RE":
d +=1
print("AC x "+ str(a))
print("WA x "+ str(b))
print("TLE x "+ str(c))
print("RE x "+ str(d))
|
s021935325
|
p03080
|
u143051858
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 8,936 | 83 |
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
|
s = input()
if s.count('B') < s.count('R'):
print('Yes')
else:
print('No')
|
s069755212
|
Accepted
| 26 | 9,104 | 100 |
N = int(input())
s = input()
if s.count('B') < s.count('R'):
print('Yes')
else:
print('No')
|
s019697951
|
p03068
|
u102278909
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 184 |
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.
|
# coding: utf-8
import sys
input = sys.stdin.readline
N = int(input())
S = input()
K = int(input())
moji = S[K - 1]
for s in S:
print("*" if s != moji else s, end="")
print()
|
s137622442
|
Accepted
| 17 | 2,940 | 189 |
# coding: utf-8
import sys
input = sys.stdin.readline
N = int(input())
S = input()[:-1]
K = int(input())
moji = S[K - 1]
for s in S:
print("*" if s != moji else s, end="")
print()
|
s393604376
|
p03386
|
u405660020
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 216 |
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
a, b, k = map(int, input().split())
numlist=[]
for i in range(k):
numlist.append(a+i)
for i in range(k)[::-1]:
numlist.append(b-i)
numset=set(numlist)
numlist=list(numset)
for item in numlist:
print(item)
|
s408097698
|
Accepted
| 17 | 3,060 | 209 |
a, b, k = map(int, input().split())
numlist=[]
if k>b-a:
k=b-a+1
for i in range(k):
numlist.append(a+i)
numlist.append(b-i)
numlist=sorted(list(set(numlist)))
for item in numlist:
print(item)
|
s911569399
|
p04031
|
u281303342
| 2,000 | 262,144 |
Wrong Answer
| 26 | 3,176 | 211 |
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective.
|
N = int(input())
A = list(map(int,input().split()))
S = 100000000
for i in range(-100,101):
T = 0
for j in range(N):
T += (A[j] - i)**2
print("i",i,"T",T)
if S > T:
S = T
print(S)
|
s115241696
|
Accepted
| 26 | 3,060 | 521 |
# python 3.4.3
import sys
input = sys.stdin.readline
# -------------------------------------------------------------
# library
# -------------------------------------------------------------
# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
A = list(map(int,input().split()))
Ans = 10**8
for x in range(-100,100+1):
ans = 0
for i in range(N):
ans += (A[i] - x)**2
Ans = min(Ans,ans)
print(Ans)
|
s073194742
|
p03408
|
u690037900
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,316 | 288 |
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
|
import collections
L01=collections.defaultdict(dict)
N=int(input())
L1=list(input() for _ in range(N))
M=int(input())
L2=list(input() for _ in range(M))
for i in set(L1):
L01[i]=L1.count(i)
for i in set(L2):
L01[i]=-L2.count(i)
print(L01[max(L01)] if int(L01[max(L01)])>=0 else 0)
|
s489861487
|
Accepted
| 26 | 3,444 | 262 |
from collections import defaultdict
b = defaultdict(int)
r = defaultdict(int)
n = int(input())
for i in range(n):
b[input()] += 1
m = int(input())
for i in range(m):
r[input()] += 1
ans = 0
for k, v in b.items():
ans = max(ans, v - r[k])
print(ans)
|
s091262132
|
p03778
|
u209918867
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,316 | 50 |
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
|
w,a,b=map(int,input().split());print(max(b-w+a,0))
|
s751491928
|
Accepted
| 17 | 2,940 | 94 |
w,a,b=map(int,input().split())
if a<=b<=a+w or b<=a<=b+w:print(0)
else:print(max(b-a-w,a-b-w))
|
s644780613
|
p04039
|
u222668979
| 2,000 | 262,144 |
Wrong Answer
| 71 | 3,444 | 314 |
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.
|
from itertools import product
n, k = map(int, input().split())
d = set(range(10)) - set(map(int, input().split()))
for i in product(d | set([0]), repeat=len(str(n)) + 1):
i = int("".join(str(j) for j in i))
print(i, d)
if (i >= n) and all(int(k) in d for k in str(i)):
print(i)
break
|
s379410335
|
Accepted
| 97 | 2,940 | 200 |
n, k = map(int, input().split())
d = set(range(10)) - set(map(int, input().split()))
i = n
while True:
if (i >= n) and all(int(j) in d for j in str(i)):
print(i)
break
i += 1
|
s033703121
|
p03545
|
u905872604
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,192 | 1,412 |
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.
|
N = input()
H = [int(N[0]), int(N[1]), int(N[2]), int(N[3])]
print(H)
A = H[0]
B = H[1]
C = H[2]
D = H[3]
# A = N[0], B = N[1], C = N[2], D = N[3]
# a = N[0], b = N[1], c = N[2], d = N[3]
# A = int(a), B = int(b), C = int(c), D = int(d)
c1 = {'op1':'+', 'op2':'+', 'op3':'+'}
c2 = {'op1':'+', 'op2':'+', 'op3':'-'}
c3 = {'op1':'+', 'op2':'-', 'op3':'+'}
c4 = {'op1':'+', 'op2':'-', 'op3':'-'}
c5 = {'op1':'-', 'op2':'+', 'op3':'+'}
c6 = {'op1':'-', 'op2':'+', 'op3':'-'}
c7 = {'op1':'-', 'op2':'-', 'op3':'+'}
c8 = {'op1':'-', 'op2':'+', 'op3':'+'}
if A+B+C+D == 7:
print(str(A) + c1['op1'] + str(B) + c1['op2'] + str(C) + c1['op3'] + str(D) + '= 7')
elif A+B+C-D == 7:
print(str(A) + c2['op1'] + str(B) + c2['op2'] + str(C) + c2['op3'] + str(D) + '= 7')
elif A+B-C+D == 7:
print(str(A) + c3['op1'] + str(B) + c3['op2'] + str(C) + c3['op3'] + str(D) + '= 7')
elif A+B-C-D == 7:
print(str(A) + c4['op1'] + str(B) + c4['op2'] + str(C) + c4['op3'] + str(D) + '= 7')
elif A-B+C+D == 7:
print(str(A) + c5['op1'] + str(B) + c5['op2'] + str(C) + c5['op3'] + str(D) + '= 7')
elif A-B+C-D == 7:
print(str(A) + c6['op1'] + str(B) + c6['op2'] + str(C) + c6['op3'] + str(D) + '= 7')
elif A-B-C+D == 7:
print(str(A) + c7['op1'] + str(B) + c7['op2'] + str(C) + c7['op3'] + str(D) + '= 7')
elif A-B-C-D == 7:
print(str(A) + c8['op1'] + str(B) + c8['op2'] + str(C) + c8['op3'] + str(D) + '= 7')
|
s781276800
|
Accepted
| 17 | 3,192 | 1,395 |
N = input()
H = [int(N[0]), int(N[1]), int(N[2]), int(N[3])]
A = H[0]
B = H[1]
C = H[2]
D = H[3]
# A = N[0], B = N[1], C = N[2], D = N[3]
# a = N[0], b = N[1], c = N[2], d = N[3]
# A = int(a), B = int(b), C = int(c), D = int(d)
c1 = {'op1':'+', 'op2':'+', 'op3':'+'}
c2 = {'op1':'+', 'op2':'+', 'op3':'-'}
c3 = {'op1':'+', 'op2':'-', 'op3':'+'}
c4 = {'op1':'+', 'op2':'-', 'op3':'-'}
c5 = {'op1':'-', 'op2':'+', 'op3':'+'}
c6 = {'op1':'-', 'op2':'+', 'op3':'-'}
c7 = {'op1':'-', 'op2':'-', 'op3':'+'}
c8 = {'op1':'-', 'op2':'+', 'op3':'+'}
if A+B+C+D == 7:
print(str(A) + c1['op1'] + str(B) + c1['op2'] + str(C) + c1['op3'] + str(D) + '=7')
elif A+B+C-D == 7:
print(str(A) + c2['op1'] + str(B) + c2['op2'] + str(C) + c2['op3'] + str(D) + '=7')
elif A+B-C+D == 7:
print(str(A) + c3['op1'] + str(B) + c3['op2'] + str(C) + c3['op3'] + str(D) + '=7')
elif A+B-C-D == 7:
print(str(A) + c4['op1'] + str(B) + c4['op2'] + str(C) + c4['op3'] + str(D) + '=7')
elif A-B+C+D == 7:
print(str(A) + c5['op1'] + str(B) + c5['op2'] + str(C) + c5['op3'] + str(D) + '=7')
elif A-B+C-D == 7:
print(str(A) + c6['op1'] + str(B) + c6['op2'] + str(C) + c6['op3'] + str(D) + '=7')
elif A-B-C+D == 7:
print(str(A) + c7['op1'] + str(B) + c7['op2'] + str(C) + c7['op3'] + str(D) + '=7')
elif A-B-C-D == 7:
print(str(A) + c8['op1'] + str(B) + c8['op2'] + str(C) + c8['op3'] + str(D) + '=7')
|
s934961922
|
p02268
|
u300946041
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,624 | 577 |
You are given a sequence of _n_ integers S and a sequence of different _q_ integers T. Write a program which outputs C, the number of integers in T which are also in the set S.
|
# encording: utf-8
_ = int(input())
ns = [int(e) for e in input().split()]
_ = int(input())
qs = [int(e) for e in input().split()]
def binary_search(q, ns):
left = 0
right = len(qs)
while left < right:
mid = (left + right) // 2
target = ns[mid]
if q == target:
return True
elif q < target:
right = mid
else:
left = mid + 1
return False
def main(ns, qs):
total = 0
for q in qs:
if binary_search(q, ns):
total += 1
return total
print(main(ns, qs))
|
s821159524
|
Accepted
| 290 | 18,928 | 534 |
_ = int(input())
ns = [int(e) for e in input().split()]
_ = int(input())
qs = [int(e) for e in input().split()]
def binary_search(q, ns):
left = 0
right = len(ns)
while left < right:
mid = (left + right) // 2
if q == ns[mid]:
return True
elif ns[mid] < q:
left = mid + 1
else:
right = mid
return False
def main(ns, qs):
total = 0
for q in qs:
if binary_search(q, ns):
total += 1
return total
print(main(ns, qs))
|
s753378418
|
p03089
|
u388415336
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 320 |
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
|
sequence_size = int(input())
sequence = list(map(int, input().split()))
sequence.sort()
if max(sequence) > sequence_size:
print("-1")
else:
for index in range(sequence_size - 1):
if sequence[index] <= index + 1:
print(sequence[index])
else:
print("-1")
break
|
s126689874
|
Accepted
| 18 | 3,060 | 370 |
size = int(input())
sequence = list(map(int, input().split()))
answer = []
while len(sequence):
if not any(sequence[i] == i + 1 for i in range(len(sequence))):
print(-1)
exit()
for i in reversed(range(len(sequence))):
if sequence[i] == i + 1:
answer.append(sequence[i])
sequence.pop(i)
break
for ans in reversed(answer):
print(ans)
|
s633875211
|
p03380
|
u041075929
| 2,000 | 262,144 |
Wrong Answer
| 98 | 14,428 | 408 |
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
|
import sys, os
f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
sys.stdin = open('./input.txt', 'r')
def solve():
n = f()[0]
a = f()
a = sorted(a)
mx = a[-1]
midiff = abs(mx//2 - a[0])
minum = a[0]
for i in a:
if abs(i - mx//2) < midiff:
midiff = abs(mx//2 - i)
minum = i
print(mx, midiff)
solve()
|
s491146452
|
Accepted
| 104 | 14,052 | 409 |
import sys, os
f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
sys.stdin = open('./input.txt', 'r')
def solve():
n = f()[0]
a = f()
a = sorted(a)
mx = a[-1]
midiff = abs(mx/2 - a[0])
minum = a[0]
for i in a[:-1]:
if abs(i - mx/2) < midiff:
midiff = abs(mx/2 - i)
minum = i
print(mx, minum)
solve()
|
s947760619
|
p04029
|
u030626972
| 2,000 | 262,144 |
Wrong Answer
| 22 | 3,444 | 74 |
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())
sum = 0
for i in range(n):
sum += i
print (sum)
|
s860686673
|
Accepted
| 18 | 2,940 | 74 |
n = int(input())
sum = 0
for i in range(1,n+1):
sum += i
print (sum)
|
s697852309
|
p04029
|
u113835532
| 2,000 | 262,144 |
Wrong Answer
| 25 | 8,956 | 33 |
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?
|
i = int(input())
print((i+1)*i/2)
|
s309105604
|
Accepted
| 29 | 8,916 | 38 |
i = int(input())
print(int((i+1)*i/2))
|
s688583085
|
p03385
|
u637175065
| 2,000 | 262,144 |
Wrong Answer
| 91 | 8,524 | 709 |
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def main():
s = [_ for _ in S()]
s.sort
if s == ['a', 'b', 'c']:
return 'Yes'
return 'No'
print(main())
|
s409729786
|
Accepted
| 42 | 5,460 | 711 |
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def main():
s = [_ for _ in S()]
s.sort()
if s == ['a', 'b', 'c']:
return 'Yes'
return 'No'
print(main())
|
s511379924
|
p03385
|
u142211940
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 55 |
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
N=input()
A=len(set(N))
print("YES" if A ==3 else "NO")
|
s612239035
|
Accepted
| 17 | 2,940 | 55 |
N=input()
A=len(set(N))
print("Yes" if A ==3 else "No")
|
s553060675
|
p03371
|
u371763408
| 2,000 | 262,144 |
Wrong Answer
| 70 | 3,064 | 226 |
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
|
a,b,c,x,y=map(int,input().split())
ans=0
if c < (a+b)//2:
cnt=0
while x>0 and y>0:
x-=0.5
y-=0.5
cnt+=1
ans+=c*cnt
if c < a//2 and x:
ans+=c*x*2
elif c<b//2 and y:
ans+=c*y*2
else:
ans+=a*x
ans+=b*y
|
s364368890
|
Accepted
| 18 | 2,940 | 92 |
a,b,c,x,y=map(int,input().split())
print(min(x*a+y*b,2*x*c+b*max(0,y-x),2*y*c+a*max(0,x-y)))
|
s877760272
|
p03457
|
u102902647
| 2,000 | 262,144 |
Wrong Answer
| 369 | 21,156 | 656 |
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
N = int(input())
plans = [[0, 0, 0]]
for i in range(N):
plans.append([int(ii) for ii in input().split()])
Yes_flag = True
for i in range(N):
if (abs(plans[i+1][1] - plans[i][1]) + abs(plans[i+1][2] - plans[i][2])) <= (plans[i+1][0] - plans[i][0]):
Yes_flag = False
break
for i in range(1, N+1):
if plans[i][0] % 2 == 0:
if (plans[i][1] + plans[i][2]) % 2 != 0:
Yes_flag = False
break
else:
if (plans[i][1] + plans[i][2]) % 2 == 0:
Yes_flag = False
break
if Yes_flag:
print('Yes')
else:
print('No')
|
s952917191
|
Accepted
| 428 | 21,156 | 737 |
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 9 01:39:56 2018
@author: Yuki
"""
N = int(input())
plans = [[0, 0, 0]]
for i in range(N):
plans.append([int(ii) for ii in input().split()])
Yes_flag = True
for i in range(N):
if (abs(plans[i+1][1] - plans[i][1]) + abs(plans[i+1][2] - plans[i][2])) > (plans[i+1][0] - plans[i][0]):
Yes_flag = False
break
for i in range(1, N+1):
if plans[i][0] % 2 == 0:
if (plans[i][1] + plans[i][2]) % 2 != 0:
Yes_flag = False
break
else:
if (plans[i][1] + plans[i][2]) % 2 == 0:
Yes_flag = False
break
if Yes_flag:
print('Yes')
else:
print('No')
|
s837149104
|
p03563
|
u319984556
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 37 |
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
|
print(-(int(input())+int(input()))/2)
|
s104407317
|
Accepted
| 17 | 2,940 | 35 |
print(-int(input())+2*int(input()))
|
s037977753
|
p03433
|
u305847048
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 81 |
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
n=int(input())
a=int(input())
if n%500+a>=n :
print("Yes")
else :
print("No")
|
s410048375
|
Accepted
| 17 | 2,940 | 79 |
n=int(input())
a=int(input())
if n%500<=a :
print("Yes")
else :
print("No")
|
s548797045
|
p03068
|
u120691615
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 184 |
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.
|
n = int(input())
s = str(input())
k = int(input())
x = s[k-1]
ans = ""
print(x)
for i in range(n):
if s[i] != x:
ans += "*"
if s[i] == x:
ans += s[i]
print(ans)
|
s164960960
|
Accepted
| 17 | 3,064 | 175 |
n = int(input())
s = str(input())
k = int(input())
x = s[k-1]
ans = ""
for i in range(n):
if s[i] != x:
ans += "*"
if s[i] == x:
ans += s[i]
print(ans)
|
s374104576
|
p03387
|
u572142121
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 160 |
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
|
A=list(map(int,input().split()))
Fi=sorted(A)[2]
Se=sorted(A)[1]
Th=sorted(A)[0]
if (Se-Th)%2 == 0:
ans=(2*Fi-Se-Th)/2
else:
ans=(2*Fi-Se-Th+3)/2
print(ans)
|
s003385592
|
Accepted
| 17 | 3,060 | 164 |
A=list(map(int,input().split()))
Fi=sorted(A)[2]
Se=sorted(A)[1]
Th=sorted(A)[0]
if (Se-Th)%2 == 0:
ans=(2*Fi-Se-Th)//2
else:
ans=(2*Fi-Se-Th+3)//2
print(ans)
|
s642722113
|
p03110
|
u492030100
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 210 |
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
|
N=int(input())
kanes=[[u for u in input().split()] for _ in range(N)]
anss=0
for kane in kanes:
if kane[1]=='BTC':
anss+=int(float(kane[0])*380000)
else:
anss+=int(kane[0])
print(anss)
|
s708858702
|
Accepted
| 17 | 3,060 | 207 |
N=int(input())
kanes=[[u for u in input().split()] for _ in range(N)]
anss=0
for kane in kanes:
if kane[1]=='BTC':
anss+=float(kane[0])*380000
else:
anss+=float(kane[0])
print(anss)
|
s715094040
|
p03351
|
u658993896
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 157 |
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.
|
ans='No'
a=list(map(int,input().split()))
if abs(a[0]-a[1]) < a[3] and abs(a[1]-a[2]) <a[3]:
ans='Yes'
elif abs(a[0]-a[2])<a[3]:
ans='Yes'
print(ans)
|
s555161481
|
Accepted
| 17 | 3,060 | 160 |
ans='No'
a=list(map(int,input().split()))
if abs(a[0]-a[1]) <= a[3] and abs(a[1]-a[2]) <=a[3]:
ans='Yes'
elif abs(a[0]-a[2])<=a[3]:
ans='Yes'
print(ans)
|
s023330481
|
p03795
|
u459511441
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,144 | 64 |
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
N = int(input())
x = N * 800
y = (x // 15) * 200
print(x - y)
|
s688711642
|
Accepted
| 29 | 9,136 | 64 |
N = int(input())
x = N * 800
y = (N // 15) * 200
print(x - y)
|
s594934809
|
p03110
|
u765590009
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 258 |
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
|
n = int(input())
a = []
for i in range(n) :
a_r = [num for num in input().split()]
a.append(a_r)
sum = 0
for tmp in a :
if tmp[1] == "BTC" :
sum += int(380000.0*float(tmp[0]))
else :
sum += int(tmp[0])
print(sum)
|
s676342596
|
Accepted
| 18 | 3,060 | 257 |
n = int(input())
a = []
for i in range(n) :
a_r = [num for num in input().split()]
a.append(a_r)
sum = 0.0
for tmp in a :
if tmp[1] == "BTC" :
sum += 380000.0*float(tmp[0])
else :
sum += float(tmp[0])
print(sum)
|
s004917558
|
p03797
|
u695079172
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 2,940 | 262 |
Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
|
s,c = map(int,input().split(" "))
counter = 0
for i in range(s):
if c >= 2 and s >= 1:
s -= 1
c -= 2
counter += 1
if s == 0 and c >= 2:
c -= 2
s += 1
if s == 0 and c <= 1:
break
print(counter)
|
s133327222
|
Accepted
| 17 | 2,940 | 432 |
def main():
n,m = map(int,input().split())
s = n
c = m
scc = 0
take = min(s,c//2)
scc += take
s -= take
c -= take * 2
take = c // 4
scc += take
print(scc)
if __name__ == '__main__':
main()
|
s409308159
|
p03963
|
u444238096
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 202 |
There are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors. Find the number of the possible ways to paint the balls.
|
n, k = (int(i) for i in input().split())
first = n*k
if n==1:
print(first)
else:
secound =(k-1)**(n-1)
goukei=first*secound
print(goukei)
|
s959859501
|
Accepted
| 17 | 3,064 | 151 |
n, k = (int(i) for i in input().split())
first = n*k
if n==1:
print(first)
else:
secound =(k-1)**(n-1)
goukei=k*secound
print(goukei)
|
s229936303
|
p03485
|
u022871813
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 119 |
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a,b=map(int,input().split())
c =a + b
if c%2 == 1:
d = int((a + b)/2) + 1
print(d)
else:
print((a + b/2))
|
s998697564
|
Accepted
| 19 | 3,316 | 121 |
a,b=map(int,input().split())
if (a + b)%2 == 1:
d = int((a + b)/2) + 1
print(d)
else:
print(int((a + b)/2))
|
s076800565
|
p03157
|
u895515293
| 2,000 | 1,048,576 |
Wrong Answer
| 447 | 44,456 | 1,558 |
There is a grid with H rows and W columns, where each square is painted black or white. You are given H strings S_1, S_2, ..., S_H, each of length W. If the square at the i-th row from the top and the j-th column from the left is painted black, the j-th character in the string S_i is `#`; if that square is painted white, the j-th character in the string S_i is `.`. Find the number of pairs of a black square c_1 and a white square c_2 that satisfy the following condition: * There is a path from the square c_1 to the square c_2 where we repeatedly move to a vertically or horizontally adjacent square through an alternating sequence of black and white squares: black, white, black, white...
|
from collections import deque
H,W=map(int, input().split())
instr = [input() for _ in range(H)]
memo = [[[0,0] for _ in range(W)] for _ in range(H)]
res = 0
for i in range(1, W):
fromB, fromW = memo[0][i-1]
if instr[0][i-1] == '#':
if instr[0][i] == '.':
memo[0][i][0] = fromB + 1
memo[0][i][1] = fromW
res += fromB + 1
else:
if instr[0][i] == '#':
memo[0][i][0] = fromB
memo[0][i][1] = fromW + 1
res += fromW + 1
for i in range(1, H):
for j in range(0, W):
fromB1, fromW1 = memo[i-1][j]
fromB2, fromW2 = memo[i][j-1]
counted = 1
if instr[i-1][j] == '#':
if instr[i][j] == '.':
memo[i][j][0] += fromB1 + counted
memo[i][j][1] += fromW1
res += fromB1 + counted
counted = 0
else:
if instr[i][j] == '#':
memo[i][j][0] += fromB1
memo[i][j][1] += fromW1 + counted
res += fromW1 + counted
counted = 0
if j >= 1:
if instr[i][j-1] == '#':
if instr[i][j] == '.':
memo[i][j][0] += fromB2 + counted
memo[i][j][1] += fromW2
res += fromB2 + counted
else:
if instr[i][j] == '#':
memo[i][j][0] += fromB2
memo[i][j][1] += fromW2 + counted
res += fromW2 + counted
# print(memo)
print(res)
|
s158249998
|
Accepted
| 565 | 21,504 | 832 |
from collections import deque
H,W=map(int, input().split())
inl=[input() for _ in range(H)]
checked = set([])
lis = [(1,0),(0,1),(-1,0),(0,-1)]
def bfs(i,j):
fifo = deque([])
fifo.append((i,j))
checked.add((i,j))
cntBlack = 0
cntWhite = 0
while fifo:
i,j = fifo.popleft()
if inl[i][j] == '.':
cntWhite += 1
else:
cntBlack += 1
for di,dj in lis:
if i+di >= 0 and i+di < H and j+dj >= 0 and j+dj < W and \
not (i+di, j+dj) in checked \
and inl[i][j] != inl[i+di][j+dj]:
checked.add((i+di, j+dj))
fifo.append((i+di, j+dj))
return cntBlack*cntWhite
res = 0
for i in range(H):
for j in range(W):
if not (i,j) in checked:
res += bfs(i,j)
print(res)
|
s298852000
|
p02694
|
u750958070
| 2,000 | 1,048,576 |
Wrong Answer
| 23 | 9,280 | 74 |
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())
X/=100
n = math.log(X, 1.01)
print(int(n))
|
s405503630
|
Accepted
| 20 | 9,160 | 139 |
X = int(input())
original = 100
n = 0
while True:
n+=1
original = int(original * 1.01)
if original >= X:
break
print(n)
|
s415209842
|
p02647
|
u815559330
| 2,000 | 1,048,576 |
Wrong Answer
| 2,206 | 32,072 | 256 |
We have N bulbs arranged on a number line, numbered 1 to N from left to right. Bulb i is at coordinate i. Each bulb has a non-negative integer parameter called intensity. When there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5. Initially, the intensity of Bulb i is A_i. We will now do the following operation K times in a row: * For each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i. Find the intensity of each bulb after the K operations.
|
N,K=map(int,input().split())
A=list(map(int,input().split()))
b=0
for _ in range(K):
B=[]
for i in range(len(A)):
for j in range(len(A)):
if A[j]-abs(i-j)>=0:
b+=1
B.append(b)
b=0
A=B
print(A)
|
s895996176
|
Accepted
| 1,370 | 50,188 | 306 |
N, K = map(int, input().split())
import numpy as np
A = np.array(input().split(), dtype=int)
I = np.arange(0, N)
for i in range(K):
X = np.zeros(N + 1, int)
np.add.at(X, np.maximum(0, I - A), 1)
np.add.at(X, np.minimum(N, I + A + 1), -1)
A = X.cumsum()[:-1]
if np.all(A == N):
break
print(*A)
|
s136139590
|
p03435
|
u086612293
| 2,000 | 262,144 |
Wrong Answer
| 212 | 3,188 | 971 |
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct.
|
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
def main():
c = tuple(tuple(map(int, line.split())) for line in sys.stdin.readlines())
for i in range(101):
b = [c[0][0] - i]
if b[0] < 0:
continue
for j in range(101 - i):
b.append(c[1][1] - j)
if b[1] < 0:
continue
for k in range(101 - i - j):
b.append(c[2][2] - k)
if b[2] < 0:
continue
a = (i, j, k)
flg = False
for l in range(3):
for m in range(3):
if a[l] + b[m] != c[l][m]:
flg = True
break
if flg == True:
break
else:
print('Yes')
sys.exit()
else:
print('No')
if __name__ == '__main__':
main()
|
s217132271
|
Accepted
| 18 | 3,064 | 387 |
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
def main():
c = tuple(tuple(map(int, line.split())) for line in sys.stdin.readlines())
csum = sum((sum(ci) for ci in c))
trace = sum((cij for i, ci in enumerate(c) for j, cij in enumerate(ci) if i == j))
if csum == 3 * trace:
print('Yes')
else:
print('No')
if __name__ == '__main__':
main()
|
s844005755
|
p03711
|
u951684192
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 228 |
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.
|
a,b = map(int,input().split())
if a in {1,3,5,7,8,10,12} and b in {1,3,5,7,8,10,12}:
print("Yes")
if a in{2} and b in {2}:
print("Yes")
if a in {4,6,9,11} and b in {4,6,9,11}:
print("Yes")
else:
print("No")
|
s403299564
|
Accepted
| 17 | 3,060 | 232 |
a,b = map(int,input().split())
if a in {1,3,5,7,8,10,12} and b in {1,3,5,7,8,10,12}:
print("Yes")
elif a in{2} and b in {2}:
print("Yes")
elif a in {4,6,9,11} and b in {4,6,9,11}:
print("Yes")
else:
print("No")
|
s906040028
|
p03370
|
u102113963
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 164 |
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.
|
s = input()
n, x = map(int, s.split())
a = []
total = 0
for i in range(n):
b = int( input() )
a.append(b)
total += b
x-=b
ans = n
ans += x / n
print(ans)
|
s994028725
|
Accepted
| 18 | 3,060 | 166 |
s = input()
n, x = map(int, s.split())
a = []
total = 0
for i in range(n):
b = int( input() )
a.append(b)
x -= b
ans = n
ans += (x / min(a))
print(int(ans))
|
s679851420
|
p02850
|
u902430070
| 2,000 | 1,048,576 |
Wrong Answer
| 397 | 39,572 | 936 |
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colorings satisfying the condition above, construct one that uses the minimum number of colors.
|
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
m = map(int,read().split())
AB = list(zip(m,m))
graph = [[] for _ in range(N+1)]
for a,b in AB:
graph[a].append(b)
graph[b].append(a)
root = 1
parent = [0] * (N+1)
order = []
stack = [root]
while stack:
x = stack.pop()
order.append(x)
for y in graph[x]:
if y == parent[x]:
continue
parent[y] = x
stack.append(y)
print(order,parent)
color = [-1] * (N+1)
for x in order:
ng = color[x]
c = 1
for y in graph[x]:
if y == parent[x]:
continue
if c == ng:
c += 1
color[y] = c
c += 1
answer = []
append = answer.append
for a,b in AB:
if parent[a] == b:
append(color[a])
else:
append(color[b])
K = max(answer)
print(K)
print('\n'.join(map(str,answer)))
|
s279285937
|
Accepted
| 358 | 38,292 | 1,005 |
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
m = map(int,read().split())
AB = list(zip(m,m))
graph = [[] for _ in range(N+1)]
for a,b in AB:
graph[a].append(b)
graph[b].append(a)
#print(a,b)
#print(graph)
root = 1
parent = [0] * (N+1)
order = []
stack = [root]
#print(stack)
while stack:
x = stack.pop()
order.append(x)
for y in graph[x]:
if y == parent[x]:
continue
parent[y] = x
stack.append(y)
#print(order,parent)
color = [-1] * (N+1)
for x in order:
ng = color[x]
c = 1
for y in graph[x]:
if y == parent[x]:
continue
if c == ng:
c += 1
color[y] = c
c += 1
#print(color)
answer = []
append = answer.append
for a,b in AB:
if parent[a] == b:
append(color[a])
else:
append(color[b])
K = max(answer)
print(K)
print('\n'.join(map(str,answer)))
|
s764495838
|
p02608
|
u271670678
| 2,000 | 1,048,576 |
Wrong Answer
| 2,205 | 9,120 | 375 |
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
def main():
n = int(input())
for i in range(n):
calc(i)
def calc(n):
count = 0
for x in range(1, n + 1):
for y in range(1, n + 1):
for z in range(1, n + 1):
if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == n:
count += 1
print(count)
return
if __name__ == '__main__':
main()
|
s945171759
|
Accepted
| 876 | 50,604 | 443 |
from collections import Counter
import math
def main():
n = int(input())
ans = []
for x in range(1, int(math.sqrt(n+1))+1):
for y in range(1, int((math.sqrt(n+1)))+1):
for z in range(1, int((math.sqrt(n+1)))+1):
ans.append(x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x)
counter = Counter(ans)
for i in range(1, n+1):
print(counter[i])
if __name__ == '__main__':
main()
|
s734270995
|
p03608
|
u152061705
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 8,012 | 2,124 |
There are N towns in the State of Atcoder, connected by M bidirectional roads. The i-th road connects Town A_i and B_i and has a length of C_i. Joisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order). She will fly to the first town she visits, and fly back from the last town she visits, but for the rest of the trip she will have to travel by road. If she visits the towns in the order that minimizes the distance traveled by road, what will that distance be?
|
from itertools import product
def closest_path_lens(idx___neigh_idxes__dists, idx1):
INF = 100001 * 201 * 200
n = len(idx___neigh_idxes__dists)
idx___visited = [False] * n
idx___dist = [INF] * n
idx___dist[idx1] = 0
for _ in range(n):
curr_idx = -1
curr_dist = INF
for idx, dist in enumerate(idx___dist):
if dist < curr_dist and not idx___visited[idx]:
curr_idx = idx
curr_dist = dist
idx___visited[curr_idx] = True
for neigh_idx, dist in idx___neigh_idxes__dists[curr_idx]:
# print(curr_dist, dist)
idx___dist[neigh_idx] = min(idx___dist[neigh_idx], curr_dist + dist)
return idx___dist
def is_valid(path):
town_idx___visited = [0] * len(list(path))
zero_dists = 0
for curr_idx, (idx, dist) in enumerate(path):
if dist == 0:
zero_dists += 1
else:
town_idx___visited[idx] = 1
town_idx___visited[curr_idx] = 1
if zero_dists > 1:
return False
elif sum(town_idx___visited) != len(town_idx___visited):
return False
else:
return True
towns_nr, roads_nr, towns_to_visit_nr = (int(x) for x in input().split())
towns_to_visit = [(int(x) - 1) for x in input().split()]
town_idx___neigh_idxes__dists = [set() for _ in range(towns_nr)]
for road_idx in range(roads_nr):
idx1, idx2, dist = (int(x) for x in input().split())
idx1 -= 1
idx2 -= 1
town_idx___neigh_idxes__dists[idx1].add((idx2, dist))
town_idx___neigh_idxes__dists[idx2].add((idx1, dist))
ttv_idx___ttv_idx__dist = []
for ttv in towns_to_visit:
town_idx___dist = closest_path_lens(town_idx___neigh_idxes__dists, ttv)
print(town_idx___dist)
ttv_idx___dist = [town_idx___dist[idx] for idx in towns_to_visit]
ttv_idx___ttv_idx__dist.append(list(enumerate(ttv_idx___dist)))
ans = 100001 * 201 * 200
for path in product(*ttv_idx___ttv_idx__dist):
if is_valid(path):
dists = [x[1] for x in path]
# print(dists)
# print(path)
ans = min(ans, sum(dists))
print(ans)
|
s833192135
|
Accepted
| 296 | 8,012 | 1,862 |
from itertools import permutations
def closest_path_lens(idx___neigh_idxes__dists, idx1):
INF = 100001 * 201 * 200
nodes_nr = len(idx___neigh_idxes__dists)
idx___visited = [False] * nodes_nr
idx___dist = [INF] * nodes_nr
idx___dist[idx1] = 0
for _ in range(nodes_nr):
curr_idx = -1
curr_dist = INF
for idx, dist in enumerate(idx___dist):
if dist < curr_dist and not idx___visited[idx]:
curr_idx = idx
curr_dist = dist
idx___visited[curr_idx] = True
for neigh_idx, dist in idx___neigh_idxes__dists[curr_idx]:
# print(curr_dist, dist)
idx___dist[neigh_idx] = min(idx___dist[neigh_idx], curr_dist + dist)
return idx___dist
towns_nr, roads_nr, towns_to_visit_nr = (int(x) for x in input().split())
towns_to_visit = [(int(x) - 1) for x in input().split()]
town_idx___neigh_idxes__dists = [set() for _ in range(towns_nr)]
for road_idx in range(roads_nr):
idx1, idx2, dist = (int(x) for x in input().split())
idx1 -= 1
idx2 -= 1
town_idx___neigh_idxes__dists[idx1].add((idx2, dist))
town_idx___neigh_idxes__dists[idx2].add((idx1, dist))
ttv_idx___ttv_idx__dist = []
for ttv in towns_to_visit:
town_idx___dist = closest_path_lens(town_idx___neigh_idxes__dists, ttv)
# print(town_idx___dist)
ttv_idx___dist = [town_idx___dist[idx] for idx in towns_to_visit]
# print(ttv_idx___dist)
ttv_idx___ttv_idx__dist.append(ttv_idx___dist)
ans = 100001 * 201 * 200
for path in permutations(list(range(towns_to_visit_nr))):
curr_ans = 0
curr_idx = path[0]
for ttv_idx in path:
# print(curr_idx, ttv_idx)
curr_ans += ttv_idx___ttv_idx__dist[curr_idx][ttv_idx]
curr_idx = ttv_idx
# print(curr_ans)
# print('\n')
ans = min(ans, curr_ans)
print(ans)
|
s963201235
|
p03470
|
u166621202
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 80 |
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
N = int(input())
d = [input for i in range(N)]
dd = list(set(d))
print(len(dd))
|
s630268395
|
Accepted
| 17 | 2,940 | 88 |
N = int(input())
d = [int(input()) for i in range(N)]
dd = list(set(d))
print(len(dd))
|
s692113340
|
p03593
|
u707124227
| 2,000 | 262,144 |
Wrong Answer
| 22 | 3,316 | 924 |
We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the top and j-th column from the left. In this matrix, each a_{ij} is a lowercase English letter. Snuke is creating another H-by-W matrix, A', by freely rearranging the elements in A. Here, he wants to satisfy the following condition: * Every row and column in A' can be read as a palindrome. Determine whether he can create a matrix satisfying the condition.
|
h,w=map(int,input().split())
a=[input() for _ in range(h)]
from collections import defaultdict
d=defaultdict(lambda:0)
for ai in a:
for aij in ai:
d[aij]+=1
print(d)
if h%2==0 and w%2==0:
print('Yes' if all(v%4==0 for v in d.values()) else 'No')
elif h%2==0 and w%2==1:
c=0
for v in d.values():
if v%4==0:
pass
elif v%2==0:
c+=1
else:
print('No')
exit()
print('Yes' if c<=h//2 else 'No')
elif h%2==1 and w%2==0:
c=0
for v in d.values():
if v%4==0:
pass
elif v%2==0:
c+=1
else:
print('No')
exit()
print('Yes' if c<=w//2 else 'No')
else:
ce=0
co=0
for v in d.values():
if v%4==0:
pass
elif v%2==0:
ce+=1
else:
co+=1
print('Yes' if ce<=h//2+w//2 and co==1 else 'No')
|
s816987097
|
Accepted
| 23 | 3,380 | 915 |
h,w=map(int,input().split())
a=[input() for _ in range(h)]
from collections import defaultdict
d=defaultdict(lambda:0)
for ai in a:
for aij in ai:
d[aij]+=1
if h%2==0 and w%2==0:
print('Yes' if all(v%4==0 for v in d.values()) else 'No')
elif h%2==0 and w%2==1:
c=0
for v in d.values():
if v%4==0:
pass
elif v%2==0:
c+=1
else:
print('No')
exit()
print('Yes' if c<=h//2 else 'No')
elif h%2==1 and w%2==0:
c=0
for v in d.values():
if v%4==0:
pass
elif v%2==0:
c+=1
else:
print('No')
exit()
print('Yes' if c<=w//2 else 'No')
else:
ce=0
co=0
for v in d.values():
if v%4==0:
pass
elif v%2==0:
ce+=1
else:
co+=1
print('Yes' if ce<=h//2+w//2 and co==1 else 'No')
|
s912999460
|
p03493
|
u409254176
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 84 |
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
a=list(input())
b=0
for i in range(3):
if a[i]==0:
b=b+0
else :
b=b+1
print(b)
|
s027501011
|
Accepted
| 28 | 9,004 | 46 |
s=int(input())
print(s%10+s//10%10+s//100%10)
|
s665235573
|
p03377
|
u379692329
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 93 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
A, B, X = [int(x) for x in input().split()]
print("YES" if (A >= X and (A+B) <= X) else "NO")
|
s712997614
|
Accepted
| 17 | 2,940 | 93 |
A, B, X = [int(x) for x in input().split()]
print("YES" if (A <= X and X <= (A+B)) else "NO")
|
s270558318
|
p03827
|
u528720841
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 139 |
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()
ans = 0
a = 0
for i in list(S):
if i=="I":
ans += 1
a = max(ans, a)
else:
ans -= 1
print(ans)
|
s906588765
|
Accepted
| 17 | 2,940 | 137 |
N=int(input())
S=input()
ans = 0
a = 0
for i in list(S):
if i=="I":
ans += 1
a = max(ans, a)
else:
ans -= 1
print(a)
|
s783878751
|
p02406
|
u973203074
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,592 | 260 |
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; }
|
from sys import stdout
n = int(input())
for i in range(n + 1):
x = i
if x % 3 == 0:
stdout.write(" " + str(i))
else:
while x != 0:
if x % 10 == 3:
stdout.write(" " + str(i))
x //= 10
print()
|
s816559949
|
Accepted
| 20 | 5,724 | 303 |
from sys import stdout
n = int(input())
i = 1
while True:
x = i
if x % 3 == 0:
stdout.write(" " + str(i))
else:
while x:
if x % 10 == 3:
stdout.write(" " + str(i))
break
x //= 10
i += 1
if i > n: break
print()
|
s940954103
|
p02613
|
u069699931
| 2,000 | 1,048,576 |
Wrong Answer
| 138 | 16,200 | 273 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
N=int(input())
S= [input() for i in range(N)]
AC_len=int(S.count('AC'))
WA_len=int(S.count('WA'))
TLE_len=int(S.count('TLE'))
RE_len=int(S.count('RE'))
print('AC X'+' '+str(AC_len))
print('WA X'+' '+str(WA_len))
print('TLE X'+' '+str(TLE_len))
print('RE X'+' '+str(RE_len))
|
s679154842
|
Accepted
| 139 | 16,164 | 273 |
N=int(input())
S= [input() for i in range(N)]
AC_len=int(S.count('AC'))
WA_len=int(S.count('WA'))
TLE_len=int(S.count('TLE'))
RE_len=int(S.count('RE'))
print('AC x'+' '+str(AC_len))
print('WA x'+' '+str(WA_len))
print('TLE x'+' '+str(TLE_len))
print('RE x'+' '+str(RE_len))
|
s213960912
|
p03485
|
u389910364
| 2,000 | 262,144 |
Wrong Answer
| 23 | 3,568 | 1,169 |
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
import functools
import os
INF = float('inf')
def inp():
return int(input())
def inpf():
return float(input())
def inps():
return input()
def inl():
return list(map(int, input().split()))
def inlf():
return list(map(float, input().split()))
def inls():
return input().split()
def inpm(line):
return [inp() for _ in range(line)]
def inpfm(line):
return [inpf() for _ in range(line)]
def inpsm(line):
return [inps() for _ in range(line)]
def inlm(line):
return [inl() for _ in range(line)]
def inlfm(line):
return [inlf() for _ in range(line)]
def inlsm(line):
return [inls() for _ in range(line)]
def debug(fn):
if not os.getenv('LOCAL'):
return fn
@functools.wraps(fn)
def wrapper(*args, **kwargs):
print('DEBUG: {}({}) -> '.format(
fn.__name__,
', '.join(
list(map(str, args)) +
['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
)
), end='')
ret = fn(*args, **kwargs)
print(ret)
return ret
return wrapper
a, b = inl()
import math
math.ceil((a + b) / 2)
|
s123377575
|
Accepted
| 17 | 2,940 | 84 |
import math
a, b = list(map(int, input().split()))
print(math.ceil((a + b) / 2))
|
s048823406
|
p03545
|
u547608423
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 396 |
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
ABCD=input()
answer=[ABCD[0],"-",ABCD[1],"-",ABCD[2],"-",ABCD[3]]
for i in range(8):
pat=str(bin(i))[2:].rjust(3,"0")
sum=int(ABCD[0])
for j in range(3):
if pat[j]=="0":
sum-=int(ABCD[j+1])
answer[2*j+1]="-"
else:
sum+=int(ABCD[j+1])
answer[2*j+1]="+"
if sum==7:
print("".join(map(str,answer)))
break
|
s469388341
|
Accepted
| 18 | 3,064 | 401 |
ABCD=input()
answer=[ABCD[0],"-",ABCD[1],"-",ABCD[2],"-",ABCD[3]]
for i in range(8):
pat=str(bin(i))[2:].rjust(3,"0")
sum=int(ABCD[0])
for j in range(3):
if pat[j]=="0":
sum-=int(ABCD[j+1])
answer[2*j+1]="-"
else:
sum+=int(ABCD[j+1])
answer[2*j+1]="+"
if sum==7:
print("".join(map(str,answer))+"=7")
break
|
s769175382
|
p03433
|
u268470352
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 95 |
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 2018 % 500 <= 218:
print('YES')
else:
print('No')
|
s932180044
|
Accepted
| 18 | 2,940 | 81 |
n = int(input())
a = int(input())
print('Yes') if n % 500 <= a else print('No')
|
s948974937
|
p03795
|
u958210291
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 38 |
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
N = int(input())
print(N*800 - N*200)
|
s346594694
|
Accepted
| 17 | 2,940 | 42 |
N = int(input())
print(N*800 - N//15*200)
|
s203115713
|
p02401
|
u957680575
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,440 | 258 |
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
|
while True:
A, B, C = map(str, input().split())
a = int(A)
b = int(C)
if B=="?":
break
elif B=="+":
print(a+b)
elif B==("-"):
print(a-b)
elif B=="*":
print(a*b)
elif B==("/"):
print(a*b)
|
s873359450
|
Accepted
| 20 | 7,512 | 259 |
while True:
A, B, C = map(str, input().split())
a = int(A)
b = int(C)
if B=="?":
break
elif B=="+":
print(a+b)
elif B==("-"):
print(a-b)
elif B=="*":
print(a*b)
elif B==("/"):
print(a//b)
|
s467673564
|
p03544
|
u243572357
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 86 |
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())
a, b, c = 2, 1, 0
for i in range(n):
a, b, c = b, c, (a+b)
print(a)
|
s156902795
|
Accepted
| 17 | 2,940 | 74 |
n = int(input())
a, b = 2, 1
for i in range(n):
a, b = b, (a+b)
print(a)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.