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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s753495109
|
p02262
|
u153665391
| 6,000 | 131,072 |
Wrong Answer
| 20 | 7,724 | 503 |
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(A, g, cnt):
for i in range(g, len(A)):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j -g
cnt += 1
print(cnt)
A[j+g] = v
return cnt
def shell(A):
G = [4, 1]
m = 2
cnt = 0
for i in range(m):
cnt = insertion(A, G[i], cnt)
print(m)
print(*G)
print(cnt)
for i in A:
print(int(i))
n = int(input())
A = [input() for i in range(n)]
shell(A)
|
s775974106
|
Accepted
| 18,090 | 45,508 | 678 |
N = int(input())
A = [int(input()) for i in range(N)]
def insertion_sort(A, N, diff, cnt):
for i in range(diff, N):
tmp_num = A[i]
j = i - diff
while j >= 0 and A[j] > tmp_num:
A[j+diff] = A[j]
j = j - diff
cnt += 1
A[j+diff] = tmp_num
return cnt
if __name__ == "__main__":
cnt = 0
diffs = []
h = 1
while h <= N:
diffs.append(h)
h = h*3 + 1
diffs.reverse()
diffs_cnt = len(diffs)
for diff in diffs:
cnt = insertion_sort(A, N, diff, cnt)
print(diffs_cnt)
print(" ".join(map(str, diffs)))
print(cnt)
for num in A:
print(num)
|
s113383017
|
p03962
|
u506910932
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 74 |
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.
|
# coding: utf-8
# Your code here!
l = list(input().split())
print(set(l))
|
s298512120
|
Accepted
| 17 | 2,940 | 79 |
# coding: utf-8
# Your code here!
l = list(input().split())
print(len(set(l)))
|
s491791284
|
p02612
|
u410956928
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 9,140 | 30 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input())
print(n%1000)
|
s668583733
|
Accepted
| 28 | 9,148 | 71 |
n = int(input())
if n%1000==0:
print(0)
else:
print(1000 - n%1000)
|
s437275718
|
p02612
|
u344813796
| 2,000 | 1,048,576 |
Wrong Answer
| 30 | 9,144 | 29 |
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)
|
s704818940
|
Accepted
| 30 | 9,100 | 66 |
n=int(input())
if n%1000!=0:
print(1000-n%1000)
else:
print(0)
|
s804440034
|
p03370
|
u870518235
| 2,000 | 262,144 |
Wrong Answer
| 27 | 8,968 | 128 |
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
|
N, X = map(int, input().split())
m = [int(input()) for _ in range(N)]
ans = len(m)
X = X - sum(m)
ans = X // min(m)
print(ans)
|
s444597497
|
Accepted
| 32 | 9,096 | 130 |
N, X = map(int, input().split())
m = [int(input()) for _ in range(N)]
ans = len(m)
X = X - sum(m)
ans += X // min(m)
print(ans)
|
s582731943
|
p03543
|
u559313689
| 2,000 | 262,144 |
Wrong Answer
| 24 | 9,020 | 120 |
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
|
def answer(N: int) -> int:
answer = len([N])
if answer <= 2:
print('Yes')
else:
print('No')
|
s283033601
|
Accepted
| 28 | 8,984 | 98 |
N=list(input())
if N[0]==N[1]==N[2] or N[1]==N[2]==N[3]:
print('Yes')
else:
print('No')
|
s707850254
|
p03962
|
u101627912
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 164 |
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.
|
# coding: utf-8
a,b,c=list(map(int,input().split()))
if a==b or b==c or c==a:
if a==b==c:
print("3")
else:
print("2")
else:
print("1")
|
s175469440
|
Accepted
| 20 | 2,940 | 138 |
# coding: utf-8
a,b,c=list(map(int,input().split()))
if a==b==c:
print(1)
elif a==b or b==c or c==a:
print(2)
else:
print(3)
|
s528356000
|
p02612
|
u104935308
| 2,000 | 1,048,576 |
Wrong Answer
| 26 | 9,152 | 134 |
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.
|
def main():
N = input()
if len(N)<4:
print(int(N))
else:
print(int(N[len(N)-2:]))
if __name__ == "__main__":
main()
|
s139646361
|
Accepted
| 29 | 9,204 | 195 |
def main():
N = input()
if int(N)%1000==0:
print("0")
return
if len(N)<4:
print(1000 - int(N))
else:
print(1000 - int(N[len(N)-3:]))
if __name__ == "__main__":
main()
|
s424413939
|
p02409
|
u853165039
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,608 | 411 |
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.
|
b = 4
f = 3
r = 10
bfrv = [[[0 for c in range(r)] for b in range(f)] for a in range(b)]
n = int(input())
for i in range(n):
bi, fi, ri, vi = map(int, input().split())
bfrv[bi - 1][fi - 1][ri - 1] = bfrv[bi - 1][fi - 1][ri - 1] + vi
for x in range(b):
for y in range(f):
s = ""
for z in range(r):
s = " ".join(map(str, bfrv[x][y]))
print(s)
print("#" * 20)
|
s877419488
|
Accepted
| 30 | 7,708 | 363 |
data = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int(input())
for _ in range(n):
(b, f, r, v) = [int(i) for i in input().split()]
data[b - 1][f - 1][r - 1] += v
for b in range(4):
for f in range(3):
for r in range(10):
print('', data[b][f][r], end='')
print()
if b < 3:
print('#' * 20)
|
s524470403
|
p02239
|
u885889402
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,784 | 502 |
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by IDs $1, 2, ... n$.
|
T = [0]
def curshort(N,k,m,P,n):
for i in range(1,n+1):
if P[i]==-1 and N[k][i]==1:
P[i] = m+1
curshort(N,i,m+1,P,n)
n = int(input())
A = [[0 for j in range(n+1)] for i in range(n+1)]
for i in range(n):
vec = input().split()
u = int(vec[0])
k = int(vec[1])
nodes = vec[2:]
for i in range(int(k)):
v = int(nodes[i])
A[u][v] = 1
P=[-1 for i in range(n+1)]
P[1] = 0
curshort(A,1,0,P,n)
for i in range(1,n+1):
print(i,P[i])
|
s027851595
|
Accepted
| 60 | 7,808 | 626 |
def breathSerch(P,N):
n=len(P)-1
m=1
QQ=[N[1]]
while(QQ != []):
R=[]
for Q in QQ:
for i in range(1,n+1):
if Q[i]==1 and P[i]==-1:
P[i]=m
R.append(N[i])
QQ = R
m=m+1
n = int(input())
A = [[0 for j in range(n+1)] for i in range(n+1)]
for i in range(n):
vec = input().split()
u = int(vec[0])
k = int(vec[1])
nodes = vec[2:]
for i in range(int(k)):
v = int(nodes[i])
A[u][v] = 1
P=[-1 for i in range(n+1)]
P[1]=0
breathSerch(P,A)
for i in range(1,n+1):
print(i,P[i])
|
s512670203
|
p03680
|
u672475305
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 7,208 | 261 |
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())
lst = [int(input()) for i in range(n)]
done = []
cnt = 0
button = 0
while True:
c = lst[button]
if c in done:
print(-1)
exit()
else:
done.append(c)
cnt += 1
button = lst[button]-1
print(cnt)
|
s391904055
|
Accepted
| 366 | 7,852 | 276 |
n = int(input())
lst = [0]
lst += [int(input()) for i in range(n)]
cnt = 1
flashed = lst[1]
while True:
if flashed == 2:
print(cnt)
break
elif cnt <= 10**6:
flashed = lst[flashed]
cnt += 1
else:
print(-1)
break
|
s313804995
|
p03129
|
u131405882
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,064 | 75 |
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
|
N,K= map(int,input().split())
if N > K*2:
print('YES')
else:
print('NO')
|
s915240546
|
Accepted
| 17 | 2,940 | 78 |
N,K= map(int,input().split())
if N >= K*2-1:
print('YES')
else:
print('NO')
|
s755981420
|
p03679
|
u994988729
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 116 |
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<=b:
print("delicious")
elif b-a<=x:
print("safe")
else:
print("dangerous")
|
s486034442
|
Accepted
| 20 | 3,316 | 141 |
X, A, B = map(int, input().split())
if B <= A:
print("delicious")
elif B <= A + X:
print("safe")
else:
print("dangerous")
|
s550324950
|
p03449
|
u639426108
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 259 |
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
|
N = int(input())
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))
ans = 0
if N == 1:
print(x_list[0] + y_list[0])
else:
for i in range(1, N+1):
a = sum(x_list[0:i]) + sum(y_list[i:N+1])
if ans < a:
ans = a
print(ans)
|
s747980590
|
Accepted
| 17 | 3,060 | 254 |
N = int(input())
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))
ans = 0
if N == 1:
print(x_list[0] + y_list[0])
else:
for i in range(N):
a = sum(x_list[0:i+1]) + sum(y_list[i:N])
if ans < a:
ans = a
print(ans)
|
s062272374
|
p02647
|
u680872090
| 2,000 | 1,048,576 |
Wrong Answer
| 2,206 | 32,324 | 272 |
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 = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
for _ in range(k):
new_a = [0]*n
for i, v in enumerate(a):
for j in range(i-v, i+v+1):
if 0<=j<n:
new_a[j] += 1
#print(a)
a = new_a
print(a)
|
s256778864
|
Accepted
| 1,361 | 50,136 | 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)
|
s332978938
|
p03377
|
u705418271
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,124 | 79 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a,b,x=map(int,input().split())
if a<=x<=a+b:
print("Yes")
else:
print("No")
|
s817070043
|
Accepted
| 31 | 9,124 | 79 |
a,b,x=map(int,input().split())
if a<=x<=a+b:
print("YES")
else:
print("NO")
|
s610939330
|
p02613
|
u682894596
| 2,000 | 1,048,576 |
Wrong Answer
| 159 | 16,112 | 299 |
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())
a = 0
w = 0
t = 0
r = 0
x = [0]*N
for i in range(N):
x[i] = input()
if x[i] == "AC":
a += 1
elif x[i] == "WA":
w += 0
elif x[i] == "TLE":
t += 0
else:
r += 0
print("AC x " + str(a))
print("WA x " + str(w))
print("TLE x " + str(t))
print("RE x " + str(r))
|
s985663865
|
Accepted
| 161 | 15,976 | 299 |
N = int(input())
a = 0
w = 0
t = 0
r = 0
x = [0]*N
for i in range(N):
x[i] = input()
if x[i] == "AC":
a += 1
elif x[i] == "WA":
w += 1
elif x[i] == "TLE":
t += 1
else:
r += 1
print("AC x " + str(a))
print("WA x " + str(w))
print("TLE x " + str(t))
print("RE x " + str(r))
|
s632682397
|
p03448
|
u500279510
| 2,000 | 262,144 |
Wrong Answer
| 51 | 3,060 | 243 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a):
for j in range(b):
for k in range(c):
t = 500*i + 100*j + 50*k
if t == x:
ans += 1
print(ans)
|
s121530621
|
Accepted
| 54 | 3,064 | 255 |
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(0,a+1):
for j in range(0,b+1):
for k in range(0,c+1):
t = 500*i + 100*j + 50*k
if t == x:
ans += 1
print(ans)
|
s996556128
|
p03578
|
u780709476
| 2,000 | 262,144 |
Wrong Answer
| 204 | 46,432 | 257 |
Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems. Determine whether Rng can complete the problem set without creating new candidates of problems.
|
n = int(input())
d = {}
for i in input().split():
if i in d:
d[i] += 1
else:
d[i] = 1
m = int(input())
for i in input().split():
if i in d and d[i] > 0:
d[i] -= 1
else:
print("No")
exit()
print("Yes")
|
s272979508
|
Accepted
| 251 | 46,432 | 273 |
import sys
n = int(input())
d = {}
for i in input().split():
if i in d:
d[i] += 1
else:
d[i] = 1
m = int(input())
for i in input().split():
if i in d and d[i] > 0:
d[i] -= 1
else:
print("NO")
sys.exit()
print("YES")
|
s432532326
|
p04029
|
u256868077
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 31 |
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
N=int(input())
print(N*(N-1)/2)
|
s086362809
|
Accepted
| 18 | 2,940 | 63 |
n=int(input())
ans=0
for i in range(1,n+1):
ans+=i
print(ans)
|
s500260338
|
p03485
|
u089622972
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,060 | 154 |
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 sys
a, b = [int(x) for x in sys.stdin.readline().strip().split(" ")]
if (a + b) % 2 == 1:
print((a + b + 1) / 2)
else:
print((a + b) / 2)
|
s575975227
|
Accepted
| 17 | 2,940 | 156 |
import sys
a, b = [int(x) for x in sys.stdin.readline().strip().split(" ")]
if (a + b) % 2 == 1:
print((a + b + 1) // 2)
else:
print((a + b) // 2)
|
s787872469
|
p02613
|
u088488125
| 2,000 | 1,048,576 |
Wrong Answer
| 146 | 9,212 | 235 |
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=0
wa=0
tle=0
re=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("WA x",ac)
print("WA x", wa)
print("TLE x", tle)
print("RE x", re)
|
s938885116
|
Accepted
| 150 | 9,204 | 235 |
n=int(input())
ac=0
wa=0
tle=0
re=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)
|
s210372370
|
p02401
|
u677096240
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,556 | 87 |
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:
s = input()
try:
print(eval(s))
except:
break
|
s940289498
|
Accepted
| 20 | 5,552 | 92 |
while True:
s = input()
try:
print(int(eval(s)))
except:
break
|
s226212327
|
p02412
|
u204883389
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,740 | 204 |
Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9
|
import itertools
while True:
(n, x) = [int(i) for i in input().split()]
if n == x == 0:
break
print([1 if sum(nums) == x else 0 for nums in itertools.combinations(range(1, n + 1), 3)])
|
s457920033
|
Accepted
| 990 | 7,728 | 301 |
while True:
n, x = [int(i) for i in input().split()]
if n == x == 0:
break
count = 0
for s in range(1, n - 1):
for m in range(s + 1, n):
for e in range(m + 1, n + 1):
if x == sum([s, m, e]):
count += 1
print(count)
|
s713374183
|
p02411
|
u389610071
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,724 | 368 |
Write a program which reads a list of student test scores and evaluates the performance for each student. The test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1. The final performance of a student is evaluated by the following procedure: * If the student does not take the midterm or final examination, the student's grade shall be F. * If the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A. * If the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B. * If the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C. * If the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C. * If the total score of the midterm and final examination is less than 30, the student's grade shall be F.
|
while True:
(m, f, r) = [int(i) for i in input().split()]
R = ""
s = m + f
if ((m == -1 or f == -1) or (s < 30)):
R = "F"
if 80 <= s:
R = "A"
if (65 < s <= 80):
R = "B"
if (50 < s <= 65) or (r <= 50):
R = "C"
if (30 < s <= 50):
R = "D"
if m == f == r == -1:
break
print(R)
|
s004058109
|
Accepted
| 30 | 6,724 | 321 |
while True:
(m, f, r) = [int(i) for i in input().split()]
if m == f == r == -1:
break
s = m + f
if m == -1 or f == -1 or s < 30:
print('F')
elif s < 50 and r < 50:
print('D')
elif s < 65:
print('C')
elif s < 80:
print('B')
else:
print('A')
|
s422962110
|
p03387
|
u668503853
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 115 |
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()))
m=max(a)
s=sum(a)
if (m*3-s)&0:
print((m*3-s)//2)
else:
print(((m+1)*3-s)//2)
|
s136787440
|
Accepted
| 17 | 2,940 | 82 |
a,b,c=map(int,input().split())
x=max(a,b,c)
m=3*x-a-b-c
if m&1:
m+=3
print(m//2)
|
s966637173
|
p03377
|
u247465867
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 69 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
A, B, X = map(int, input().split())
print("Yes" if A+B > X else "No")
|
s084085500
|
Accepted
| 17 | 2,940 | 84 |
A, B, X = map(int, input().split())
print("YES" if (A+B > X) and (A <= X) else "NO")
|
s839429419
|
p03338
|
u367117210
| 2,000 | 1,048,576 |
Wrong Answer
| 19 | 3,064 | 221 |
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.
|
n = int(input())
s = input()
both = 0
for i in range(1, n):
a = list(set(s[0:i]))
b = list(set(s[i:n]))
print(a,b)
botht = 0
for al in a:
if(al in b):
botht += 1
if(both < botht):
both = botht
print(both)
|
s953046995
|
Accepted
| 19 | 3,060 | 209 |
n = int(input())
s = input()
both = 0
for i in range(1, n):
a = list(set(s[0:i]))
b = list(set(s[i:n]))
botht = 0
for al in a:
if(al in b):
botht += 1
if(both < botht):
both = botht
print(both)
|
s868504859
|
p02844
|
u762540523
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,188 | 300 |
AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code. The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code. How many different PIN codes can he set this way? Both the lucky number and the PIN code may begin with a 0.
|
n=int(input())
s=input()
ans=0
fi=lambda x,y:x.find(str(y))
for i in range(10):
f1=fi(s,i)
if f1==-1:
continue
s1=s[f1+1:]
for j in range(10):
f2=fi(s1,j)
if f2==-1:
continue
s2=s1[f2+1:]
for k in range(10):
f3=fi(s1,k)
if f3>0:
ans+=1
print(ans)
|
s095794964
|
Accepted
| 18 | 3,188 | 301 |
n=int(input())
s=input()
ans=0
fi=lambda x,y:x.find(str(y))
for i in range(10):
f1=fi(s,i)
if f1==-1:
continue
s1=s[f1+1:]
for j in range(10):
f2=fi(s1,j)
if f2==-1:
continue
s2=s1[f2+1:]
for k in range(10):
f3=fi(s2,k)
if f3>=0:
ans+=1
print(ans)
|
s469466285
|
p02613
|
u942356554
| 2,000 | 1,048,576 |
Wrong Answer
| 148 | 9,208 | 350 |
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_c = 0
wa_c = 0
tle_c = 0
re_c = 0
for i in range(n):
s = input()
if s == "AC":
ac_c += 1
elif s == "WA":
wa_c += 1
elif s == "TLE":
tle_c += 1
else:
re_c +=1
print("AC" + "x" + str(ac_c))
print("AC" + "x" + str(wa_c))
print("AC" + "x" + str(tle_c))
print("AC" + "x" + str(re_c))
|
s722349693
|
Accepted
| 143 | 9,232 | 380 |
n = int(input())
ac_c = 0
wa_c = 0
tle_c = 0
re_c = 0
for i in range(n):
s = input()
if s == "AC":
ac_c += 1
elif s == "WA":
wa_c += 1
elif s == "TLE":
tle_c += 1
else:
re_c +=1
print("AC" +" "+ "x"+" " + str(ac_c))
print("WA" +" "+ "x"+" "+ str(wa_c))
print("TLE" +" "+ "x"+" "+ str(tle_c))
print("RE" +" "+ "x"+" "+ str(re_c))
|
s318606634
|
p02409
|
u106285852
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,540 | 2,106 |
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.
|
roomDict = {}
for b in range(1, 4 + 1):
for f in range(1, 3 + 1):
for r in range(1, 10 + 1):
roomNum = b * 10 + f * 10 + r
roomDict[roomNum] = 0
n = int(input())
for i in range(n):
input_b, input_f, input_r, input_v = map(int, input().split())
roomNum = input_b * 10 + input_f * 10 + input_r
numOfPeople = roomDict[roomNum]
roomDict[roomNum] = numOfPeople + input_v
for b in range(1, 4 + 1):
for f in range(1, 3 + 1):
for r in range(1, 10 + 1):
roomNum = b * 10 + f * 10 + r
print(" {0}".format(roomDict[roomNum]), end='')
print('')
print("####################")
|
s090857807
|
Accepted
| 20 | 7,776 | 546 |
room = [[[0 for a in range(10)] for b in range(3)] for c in range(4)]
n = int(input())
for cnt0 in range(n):
a,b,c,d = map(int,input().split())
room[a-1][b-1][c-1]+=d
for cnt1 in range(4):
for cnt2 in range(3):
for cnt3 in range(10):
# OutputPrit
print(" "+str(room[cnt1][cnt2][cnt3]),end="")
# ??????
print ()
if cnt1<3:
print("#"*20)
|
s137441826
|
p03555
|
u617659131
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 184 |
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.
|
c = input()
d = input()
roll_c = []
roll_d = []
for i in range(len(c)):
roll_c.append(c[-1])
roll_d.append(d[-1])
if c == roll_d and d == roll_c:
print("YES")
else:
print("NO")
|
s962735304
|
Accepted
| 17 | 3,060 | 181 |
c1 = list(input())
c2 = list(input())
c2_alta = [0 for i in range(3)]
c2_alta[0] = c2[-1]
c2_alta[1] = c2[1]
c2_alta[-1] = c2[0]
if c1 == c2_alta:
print("YES")
else:
print("NO")
|
s756846001
|
p02255
|
u387437217
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,524 | 174 |
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
n=int(input())
A=list(map(int,input().split()))
for i in range(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(A)
|
s230305738
|
Accepted
| 30 | 8,036 | 175 |
n=int(input())
A=list(map(int,input().split()))
for i in range(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(*A)
|
s650457683
|
p02646
|
u960611411
| 2,000 | 1,048,576 |
Wrong Answer
| 22 | 9,180 | 184 |
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
[a,v] = list(map(int, input().split()))
[b,w] = list(map(int, input().split()))
t = int(input())
Acoor = a + v*t
Bcoor = b + w*t
if Acoor>=Bcoor:
print('Yes')
else:
print('No')
|
s942642879
|
Accepted
| 24 | 9,208 | 400 |
[a,v] = list(map(int, input().split()))
[b,w] = list(map(int, input().split()))
t = int(input())
if v>w:
if abs(a-b) % (v-w) == 0:
tRE = abs(a - b) // (v - w)
if tRE<=t:
print('YES')
else:
print('NO')
else:
tRE = abs(a - b) / (v - w)
if tRE<t:
print('YES')
else:
print('NO')
else:
print('NO')
|
s903078957
|
p03944
|
u106181248
| 2,000 | 262,144 |
Wrong Answer
| 32 | 3,316 | 655 |
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.
|
import itertools
w, h, n = map(int,input().split())
now = [[1]*w]*h
li = [list(map(int,input().split())) for i in range(n)]
for x in li:
if x[2]==1:
for i in range(h):
now[i] = [0]*x[0] + [1]*(w-x[0])
if x[2]==2:
for i in range(h):
now[i] = [1]*(w-x[0]) + [0]*x[0]
if x[2]==3:
for i in range(x[1]):
now[i] = [0]*w
if x[2]==4:
for i in range(x[1],h):
now[i] = [0]*w
for i in now:
print(i)
print(sum(list(itertools.chain.from_iterable(now))))
|
s846193807
|
Accepted
| 70 | 3,188 | 670 |
import itertools
w, h, n = map(int,input().split())
now = [[1]*w]*h
li = [list(map(int,input().split())) for i in range(n)]
for x in li:
if x[2]==1:
for i in range(h):
for j in range(x[0]):
now[i][j] = 0
if x[2]==2:
for i in range(h):
for j in range(w-x[0]):
now[i][x[0]+j] = 0
if x[2]==3:
for i in range(x[1]):
now[i] = [0]*w
if x[2]==4:
for i in range(x[1],h):
now[i] = [0]*w
print(sum(list(itertools.chain.from_iterable(now))))
|
s277016739
|
p02600
|
u488219351
| 2,000 | 1,048,576 |
Wrong Answer
| 23 | 9,176 | 305 |
M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a _kyu_ (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have?
|
x = int(input())
if x<=400 and 599<=x:
print(8)
if x<=600 and 799<=x:
print(7)
if x<=800 and 999<=x:
print(6)
if x<=1000 and 1199<=x:
print(5)
if x<=1200 and 1399<=x:
print(4)
if x<=1400 and 1599<=x:
print(3)
if x<=1500 and 1799<=x:
print(2)
if x<=1600 and 1999<=x:
print(1)
exit()
|
s392073316
|
Accepted
| 28 | 9,192 | 299 |
x = int(input())
if 400<=x and x<=599:
print(8)
if 600<=x and x<=799:
print(7)
if 800<=x and x<=999:
print(6)
if 1000<=x and x<=1199:
print(5)
if 1200<=x and x<=1399:
print(4)
if 1400<=x and x<=1599:
print(3)
if 1600<=x and x<=1799:
print(2)
if 1800<=x and x<=1999:
print(1)
exit()
|
s950855289
|
p03861
|
u368796742
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 50 |
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
a,b,c = map(int,input().split())
print((b-a+1)//c)
|
s394926442
|
Accepted
| 17 | 2,940 | 54 |
a,b,c = map(int,input().split())
print(b//c-(a-1)//c)
|
s195361978
|
p02743
|
u372102441
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,064 | 380 |
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
|
#n = int(input())
#l = list(map(int, input().split()))
import sys
input = sys.stdin.readline
a, b, c = list(map(int, input().split()))
def sqrt(x):
x**=1/2
return x
print(a**(1/2),b**(1/2),c**(1/2))
if sqrt(a)+sqrt(b)<sqrt(c):
print("yes")
else:
print("No")
|
s570045196
|
Accepted
| 34 | 5,076 | 438 |
#n = int(input())
#l = list(map(int, input().split()))
import sys
input = sys.stdin.readline
from decimal import Decimal
a, b, c = list(map(int, input().split()))
def sq(x):
x=Decimal(x**2)
return x
#print(a**(1/2),b**(1/2),c**(1/2))
if c-a-b>0 and 2*(a*b+b*c+c*a)<sq(a)+sq(b)+sq(c):
print("Yes")
else:
print("No")
|
s950858500
|
p03478
|
u518064858
| 2,000 | 262,144 |
Wrong Answer
| 37 | 2,940 | 156 |
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
n,a,b=map(int,input().split())
c=0
for i in range(1,n+1):
x=list(str(i))
s=0
for y in x:
s+=int(y)
if a<=s<=b:
c+=1
print(c)
|
s725433528
|
Accepted
| 38 | 2,940 | 156 |
n,a,b=map(int,input().split())
c=0
for i in range(1,n+1):
x=list(str(i))
s=0
for y in x:
s+=int(y)
if a<=s<=b:
c+=i
print(c)
|
s627257145
|
p03587
|
u333139319
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 77 |
Snuke prepared 6 problems for a upcoming programming contest. For each of those problems, Rng judged whether it can be used in the contest or not. You are given a string S of length 6. If the i-th character of s is `1`, it means that the i-th problem prepared by Snuke is accepted to be used; `0` means that the problem is not accepted. How many problems prepared by Snuke are accepted to be used in the contest?
|
s=input()
a=0
for i in range(len(s)):
if s[i]==1:
a=a+1
print(a)
|
s376264090
|
Accepted
| 17 | 2,940 | 32 |
s = input()
print(s.count("1"))
|
s658796848
|
p02393
|
u239524997
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,244 | 58 |
Write a program which reads three integers, and prints them in ascending order.
|
abc = input ()
num_abc = abc.split()
print(num_abc.sort())
|
s827126887
|
Accepted
| 30 | 7,384 | 91 |
abc = input ()
num_abc = abc.split()
num_abc.sort()
print(num_abc[0],num_abc[1],num_abc[2])
|
s757649512
|
p02690
|
u842797390
| 2,000 | 1,048,576 |
Wrong Answer
| 24 | 9,400 | 369 |
Give a pair of integers (A, B) such that A^5-B^5 = X. It is guaranteed that there exists such a pair for the given integer X.
|
import math
x = int(input())
xx = math.ceil(x ** 0.2)
for i in range(xx + 1):
for j in range(xx + 1):
if (i == j):
continue
elif (x % (i - j) == 0) and (x == ((i ** 5) - (j ** 5))):
print(i, j)
break
elif (x % (i + j) == 0) and ( x == ((i ** 5) + (j ** 5))):
print(i, -j)
break
|
s914477630
|
Accepted
| 21 | 9,100 | 420 |
import math
x = int(input())
def check(x):
i = 1
while True:
for j in range(i):
if (i == j):
continue
elif (x % (i - j) == 0) and (x == ((i ** 5) - (j ** 5))):
print(i, j)
return
elif (x % (i + j) == 0) and ( x == ((i ** 5) + (j ** 5))):
print(i, -j)
return
i = i + 1
check(x)
|
s438153863
|
p03891
|
u796731633
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 161 |
A 3×3 grid with a integer written in each square, is called a magic square if and only if the integers in each row, the integers in each column, and the integers in each diagonal (from the top left corner to the bottom right corner, and from the top right corner to the bottom left corner), all add up to the same sum. You are given the integers written in the following three squares in a magic square: * The integer A at the upper row and left column * The integer B at the upper row and middle column * The integer C at the middle row and middle column Determine the integers written in the remaining squares in the magic square. It can be shown that there exists a unique magic square consistent with the given information.
|
a = int(input())
b = int(input())
c = int(input())
l = [
[a, b, -a-b],
[-2*a-b-2*c, c, 2*a+b+c],
[a+b+2*c, -b-c, -a-c]
]
for i in l:
print(*i)
|
s456240976
|
Accepted
| 17 | 3,060 | 180 |
a = int(input())
b = int(input())
c = int(input())
s = 3 * c
l = [
[a, b, s-a-b],
[2*s-2*a-b-2*c, c, 2*a+b+c-s],
[a+b+2*c-s, s-b-c, s-a-c]
]
for i in l:
print(*i)
|
s303874551
|
p03524
|
u815763296
| 2,000 | 262,144 |
Wrong Answer
| 40 | 10,044 | 505 |
Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.
|
import sys
from collections import Counter
S = list(input())
N = len(S)
S = Counter(S)
if len(S) == 1:
if N < 3:
print("Yes")
sys.exit()
else:
print("No")
sys.exit()
if len(S) == 2:
if N < 3:
print("Yes")
sys.exit()
else:
print("No")
sys.exit()
if N <= 3:
print("Yes")
sys.exit()
abc = []
for i in S.values():
abc.append(i)
abc.sort(reverse=True)
if abc[2]*2+2 >= abc[0]:
print("Yes")
else:
print("No")
|
s722311373
|
Accepted
| 39 | 10,004 | 450 |
import sys
from collections import Counter
S = list(input())
N = len(S)
S = Counter(S)
if len(S) == 1:
if N == 1:
print("YES")
sys.exit()
else:
print("NO")
sys.exit()
if len(S) == 2:
if N == 2:
print("YES")
sys.exit()
else:
print("NO")
sys.exit()
a = S["a"]
b = S["b"]
c = S["c"]
M = max(a, b, c)
m = min(a, b, c)
if (M-m) <= 1:
print("YES")
else:
print("NO")
|
s167988430
|
p02694
|
u723345499
| 2,000 | 1,048,576 |
Wrong Answer
| 22 | 9,104 | 135 |
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())
m = 100
cnt = 0
while 1:
cnt += 1
m = math.floor(m * 1.01)
if m > x:
break
print(cnt)
|
s219986055
|
Accepted
| 23 | 9,164 | 136 |
import math
x = int(input())
m = 100
cnt = 0
while 1:
cnt += 1
m = math.floor(m * 1.01)
if m >= x:
break
print(cnt)
|
s569249789
|
p03997
|
u003928116
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 61 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h/2)
|
s396694530
|
Accepted
| 17 | 2,940 | 62 |
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h//2)
|
s486948032
|
p02399
|
u385274266
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,580 | 48 |
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
a,b=map(int,input().split())
print(a//b,a%b,a/b)
|
s716206357
|
Accepted
| 20 | 7,588 | 74 |
a,b=map(int,input().split())
print('{0} {1} {2:.5f}'.format(a//b,a%b,a/b))
|
s395989976
|
p02281
|
u567380442
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,812 | 2,843 |
Binary trees are defined recursively. A binary tree _T_ is a structure defined on a finite set of nodes that either * contains no nodes, or * is composed of three disjoint sets of nodes: \- a root node. \- a binary tree called its left subtree. \- a binary tree called its right subtree. Your task is to write a program which perform tree walks (systematically traverse all nodes in a tree) based on the following algorithms: 1. Print the root, the left subtree and right subtree (preorder). 2. Print the left subtree, the root and right subtree (inorder). 3. Print the left subtree, right subtree and the root (postorder). Here, the given binary tree consists of _n_ nodes and evey node has a unique ID from 0 to _n_ -1.
|
class Tree():
def __init__(self):
self.nodes = {}
self.nodes[-1] = None
def add_node(self, id):
if id not in self.nodes:
self.nodes[id] = Node(id)
def add_child(self, parent_id, left_id, right_id):
self.add_node(parent_id)
self.add_node(left_id)
self.add_node(right_id)
self.nodes[parent_id].add_child(self.nodes[left_id], self.nodes[right_id])
class Node():
def __init__(self, id):
self.id = id
self.parent = self.left = self.right = None
self.depth = self.height = 0
def add_child(self, left, right):
self.left = left
self.right = right
self.update_height()
for child in self.children():
child.parent = self
child.update_depth()
def update_height(self):
if self.degree():
self.height = max([child.height + 1 for child in self.children()])
if self.parent:
self.parent.update_height()
def update_depth(self):
self.depth = self.parent.depth + 1
for child in self.children():
child.update_depth()
def nodetype(self):
if self.parent:
if self.degree():
return 'internal node'
else:
return 'leaf'
else:
return 'root'
def degree(self):
return len(self.children())
def children(self):
return [child for child in [self.left, self.right] if child]
def sibling(self):
if self.parent and self.parent.degree() == 2:
if self.parent.left == self:
return self.parent.right.id
else:
return self.parent.left.id
else:
return -1
def __str__(self):
return 'node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(
self.id,
self.parent.id if self.parent else - 1,
self.sibling(),
self.degree(),
self.depth,
self.height,
self.nodetype())
def walk(self, order):
orders = {'Preorder':[self, self.left, self.right], 'Inorder':[self.left, self, self.right], 'Postorder':[self.left, self.right, self]}
for node in orders[order]:
if node == self:
yield node
elif node:
for childnode in node.walk(order):
yield childnode
tree = Tree()
n = int(input())
for i in range(n):
id, left, right = map(int, input().split())
tree.add_child(id, left, right)
orders = ['Preorder', 'Inorder', 'Postorder']
for order in orders:
print(order)
print(*[node.id for node in tree.nodes[0].walk(order)])
|
s250478426
|
Accepted
| 30 | 6,828 | 2,984 |
class Tree():
def __init__(self):
self.nodes = {}
self.nodes[-1] = None
def add_node(self, id):
if id not in self.nodes:
self.nodes[id] = Node(id)
def add_child(self, parent_id, left_id, right_id):
self.add_node(parent_id)
self.add_node(left_id)
self.add_node(right_id)
self.nodes[parent_id].add_child(self.nodes[left_id], self.nodes[right_id])
def root(self):
for node in self.nodes.values():
if node and node.nodetype() == 'root':
return node
class Node():
def __init__(self, id):
self.id = id
self.parent = self.left = self.right = None
self.depth = self.height = 0
def add_child(self, left, right):
self.left = left
self.right = right
self.update_height()
for child in self.children():
child.parent = self
child.update_depth()
def update_height(self):
if self.degree():
self.height = max([child.height + 1 for child in self.children()])
if self.parent:
self.parent.update_height()
def update_depth(self):
self.depth = self.parent.depth + 1
for child in self.children():
child.update_depth()
def nodetype(self):
if self.parent:
if self.degree():
return 'internal node'
else:
return 'leaf'
else:
return 'root'
def degree(self):
return len(self.children())
def children(self):
return [child for child in [self.left, self.right] if child]
def sibling(self):
if self.parent and self.parent.degree() == 2:
if self.parent.left == self:
return self.parent.right.id
else:
return self.parent.left.id
else:
return -1
def __str__(self):
return 'node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(
self.id,
self.parent.id if self.parent else - 1,
self.sibling(),
self.degree(),
self.depth,
self.height,
self.nodetype())
def walk(self, order):
orders = {'Preorder':[self, self.left, self.right], 'Inorder':[self.left, self, self.right], 'Postorder':[self.left, self.right, self]}
for node in orders[order]:
if node == self:
yield node
elif node:
for childnode in node.walk(order):
yield childnode
tree = Tree()
n = int(input())
for i in range(n):
id, left, right = map(int, input().split())
tree.add_child(id, left, right)
orders = ['Preorder', 'Inorder', 'Postorder']
for order in orders:
print(order)
print('',*[node.id for node in tree.root().walk(order)])
|
s710848360
|
p02417
|
u455877373
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,544 | 73 |
Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.
|
s = input()
for i in range(97,123):
print(chr(i),':',s.count(chr(i)))
|
s594475343
|
Accepted
| 20 | 5,556 | 95 |
import sys
s=sys.stdin.read().lower()
for i in range(97,123):print(chr(i),':',s.count(chr(i)))
|
s807908024
|
p03388
|
u923270446
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,176 | 191 |
10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th. The _score_ of a participant is the product of his/her ranks in the two contests. Process the following Q queries: * In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.
|
import math
q=int(input())
for i in range(q):
a,b=map(int,input().split())
if abs(a-b)<2:print(min(a,b)*2-2)
else:
s=int(math.sqrt(a*b))
if s**2+2>=a*b:print(2*s-2)
else:print(2*s-1)
|
s676508219
|
Accepted
| 28 | 9,192 | 203 |
import math
q=int(input())
for i in range(q):
a,b=map(int,input().split())
if abs(a-b)<2:print(min(a,b)*2-2)
else:
s=int(math.ceil(math.sqrt(a*b)))-1
if s**2+s<a*b:print(2*s-1)
else:print(2*s-2)
|
s180579195
|
p03377
|
u811436126
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 146 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a, b, x = map(int, input().split())
if a > x:
print('No')
elif a == x:
print('Yes')
else:
print('Yes') if x - a < b else print('No')
|
s815764139
|
Accepted
| 17 | 2,940 | 147 |
a, b, x = map(int, input().split())
if a > x:
print('NO')
elif a == x:
print('YES')
else:
print('YES') if x - a <= b else print('NO')
|
s341784131
|
p02615
|
u207464563
| 2,000 | 1,048,576 |
Wrong Answer
| 227 | 50,136 | 212 |
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?
|
import numpy as np
N = int(input())
comfort = list(map(int,input().split()))
comfort_reverse = np.sort(comfort)[::-1]
print(comfort_reverse)
ans = 0
for i in range(N-1):
ans += comfort_reverse[i]
print(ans)
|
s338392138
|
Accepted
| 239 | 49,796 | 252 |
import numpy as np
N = int(input())
comfort = list(map(int,input().split()))
comfort_reverse = np.sort(comfort)[::-1]
ans = comfort_reverse[0]
if N > 2:
for i in range(N-2):
num = i // 2 + 1
ans += comfort_reverse[num]
print(ans)
|
s950113572
|
p03555
|
u740767776
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 129 |
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.
|
s1 = list(input())
s2 = list(input())
if s1[0] == s2[2] and s1[1] == s2[2] and s1[2] == s2[0]:
print("YES")
else:
print("NO")
|
s501660716
|
Accepted
| 17 | 3,060 | 129 |
s1 = list(input())
s2 = list(input())
if s1[0] == s2[2] and s1[1] == s2[1] and s1[2] == s2[0]:
print("YES")
else:
print("NO")
|
s114860942
|
p03673
|
u315485238
| 2,000 | 262,144 |
Wrong Answer
| 92 | 26,180 | 84 |
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.
|
n=int(input())
A=list(map(int,input().split()))
print(A[(n+1)%2::2][::-1]+A[n%2::2])
|
s028764822
|
Accepted
| 54 | 24,260 | 79 |
n=int(input())
A=input().split()
print(' '.join(A[(n+1)%2::2][::-1]+A[n%2::2]))
|
s957820398
|
p03448
|
u426108351
| 2,000 | 262,144 |
Wrong Answer
| 52 | 3,060 | 258 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for k in range(a):
for l in range(b):
for m in range(c):
total = 500 * k + 100 * l + 50 * m
if total == x:
ans += 1
print(ans)
|
s876185834
|
Accepted
| 56 | 3,060 | 264 |
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for k in range(a+1):
for l in range(b+1):
for m in range(c+1):
total = 500 * k + 100 * l + 50 * m
if total == x:
ans += 1
print(ans)
|
s059955194
|
p03457
|
u371686382
| 2,000 | 262,144 |
Wrong Answer
| 893 | 3,572 | 227 |
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())
x = y = 0
for _ in range(N):
print(_)
t, _x, _y = map(int, input().split())
dist = abs(_y - y) + abs(_x - x)
if dist > t or (t - dist) % 2 == 1:
print('no')
quit()
print('yes')
|
s700013006
|
Accepted
| 356 | 3,060 | 214 |
N = int(input())
x = y = 0
for _ in range(N):
t, _x, _y = map(int, input().split())
dist = abs(_y - y) + abs(_x - x)
if dist > t or (t - dist) % 2 == 1:
print('No')
quit()
print('Yes')
|
s669190136
|
p02841
|
u405137387
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 111 |
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month.
|
m1, d1=map(int, input().split())
m2,d2=map(int, input().split())
if m1 != m2:
print(1)
else:
print(1)
|
s690236935
|
Accepted
| 17 | 2,940 | 111 |
m1, d1=map(int, input().split())
m2,d2=map(int, input().split())
if m1 != m2:
print(1)
else:
print(0)
|
s335590645
|
p03494
|
u315485238
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 183 |
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
N=int(input())
A = list(map(int, input().split()))
answer = 0
while True:
if sum([a%2==0 for a in A])==0:
answer +=1
A = [a//2 for a in A]
else:
break
print(answer)
|
s806885452
|
Accepted
| 18 | 3,060 | 195 |
N=int(input())
A = list(map(int, input().split()))
answer = 0
while True:
if sum([a%2 for a in A])==0:
answer +=1
A = [a//2 for a in A]
continue
else:
break
print(answer)
|
s926362330
|
p02612
|
u620098028
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,140 | 109 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N = int(input())
if N % 1000 == 0:
print(0)
else:
cnt = (N // 1000) + 1
ans = 1000 * cnt - N
print(N)
|
s037042094
|
Accepted
| 29 | 9,152 | 109 |
N = int(input())
if N % 1000 == 0:
print(0)
else:
cnt = N // 1000 + 1
ans = cnt * 1000 - N
print(ans)
|
s706121577
|
p03816
|
u405256066
| 2,000 | 262,144 |
Wrong Answer
| 51 | 14,948 | 209 |
Snuke has decided to play a game using cards. He has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written. He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept. Operation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.
|
from sys import stdin
from collections import Counter
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
s = len(set(A))
if s % 2 == 0:
print(s)
else:
print(s-1)
|
s308322454
|
Accepted
| 48 | 14,120 | 177 |
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
s = len(set(A))
if s % 2 != 0:
print(s)
else:
print(s-1)
|
s262592738
|
p03813
|
u717626627
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 65 |
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise. You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise.
|
a = int(input())
if a > 1200:
print('ABC')
else:
print('ARC')
|
s670538835
|
Accepted
| 17 | 2,940 | 64 |
a = int(input())
if a< 1200:
print('ABC')
else:
print('ARC')
|
s227097661
|
p02694
|
u752236842
| 2,000 | 1,048,576 |
Wrong Answer
| 2,205 | 9,024 | 91 |
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?
|
# -*- coding: utf-8 -*-
X=int(input())
i=0
while(i<X):
d=int(i*1.01)
i+=1
print(i)
|
s664528313
|
Accepted
| 24 | 9,040 | 89 |
x = int(input())
d = 100
y = 0
while d < x:
d = int(d * 1.01)
y += 1
print(y)
|
s302177575
|
p03369
|
u708255304
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 84 |
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
|
S = input()
cnt = 0
for i in range(3):
if S[i] == "o":
cnt += 1
print(700+cnt)
|
s463719161
|
Accepted
| 17 | 2,940 | 89 |
S = input()
cnt = 0
for i in range(3):
if S[i] == "o":
cnt += 1
print(700+cnt*100)
|
s661012148
|
p03720
|
u426108351
| 2,000 | 262,144 |
Wrong Answer
| 22 | 3,444 | 264 |
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
|
import collections
N, M = map(int, input().split())
toshi = []
for i in range(M):
a, b = map(int, input().split())
toshi.append(a)
toshi.append(b)
toshicount = collections.Counter(toshi)
print(toshicount)
for i in range(N):
print(toshicount[i+1])
|
s281215706
|
Accepted
| 20 | 3,316 | 246 |
import collections
N, M = map(int, input().split())
toshi = []
for i in range(M):
a, b = map(int, input().split())
toshi.append(a)
toshi.append(b)
toshicount = collections.Counter(toshi)
for i in range(N):
print(toshicount[i+1])
|
s092484883
|
p03377
|
u050641473
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 101 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
A, B, X = map(int, input().split())
if X <= A + B - 1 and X >= A:
print("Yes")
else:
print("No")
|
s095018042
|
Accepted
| 17 | 3,064 | 101 |
A, B, X = map(int, input().split())
if X <= A + B - 1 and X >= A:
print("YES")
else:
print("NO")
|
s090949699
|
p03993
|
u993642190
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 19,680 | 401 |
There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a _friendly pair_ if the following condition is met. * Rabbit i likes rabbit j and rabbit j likes rabbit i. Calculate the number of the friendly pairs.
|
N = int(input())
li = [int(i) for i in input().split()]
tupple = []
for i in range(N) :
s = str(i+1) + ' ' + str(li[i])
tupple.append(s)
c = 0
print(tupple)
for tup in tupple :
t = tup.split()
needle = t[1] + ' ' + t[0]
if needle in tupple :
print(tup)
print(needle)
c += 1
print(c//2)
|
s831621815
|
Accepted
| 72 | 13,880 | 196 |
N = int(input())
li = [int(i) for i in input().split()]
c = 0
for i in range(1,N+1) :
if (i == li[li[i-1]-1]) :
c += 1
print(c//2)
|
s607394985
|
p03455
|
u680004123
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 87 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a,b = map(int, input().split())
if a * b % 2 == 0:
print("0dd")
else:
print("Even")
|
s283464868
|
Accepted
| 17 | 2,940 | 77 |
a,b = map(int, input().split())
print("Even") if (a*b)%2==0 else print("Odd")
|
s213214683
|
p03997
|
u529518602
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 75 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a = int(input())
b = int(input())
h = int(input())
print((a + b) * h / 2)
|
s446442928
|
Accepted
| 18 | 2,940 | 80 |
a = int(input())
b = int(input())
h = int(input())
print(int((a + b) * h / 2))
|
s038172818
|
p02380
|
u444576298
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,700 | 235 |
For given two sides of a triangle _a_ and _b_ and the angle _C_ between them, calculate the following properties: * S: Area of the triangle * L: The length of the circumference of the triangle * h: The height of the triangle with side a as a bottom edge
|
#coding: utf-8
import math
a, b, C = (float(i) for i in input().split())
C = math.pi * C / 180
S = a * b * math.sin(C) / 2
h = b * math.sin(C)
L = a + b + math.sqrt(a**2 + b ** 2 - 2 * a * b * math.cos(C))
print(S)
print(h)
print(L)
|
s078891780
|
Accepted
| 20 | 5,708 | 287 |
#coding: utf-8
import math
a, b, C = (float(i) for i in input().split())
C = math.pi * C / 180
S = a * b * math.sin(C) / 2
h = b * math.sin(C)
L = a + b + math.sqrt(a**2 + b ** 2 - 2 * a * b * math.cos(C))
print("{:.8f}".format(S))
print("{:.8f}".format(L))
print("{:.8f}".format(h))
|
s423234111
|
p03110
|
u077671720
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 194 |
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?
|
def main():
y = 0
N = int(input())
for _ in range(N):
x = float(input().strip().split(' ')[0])
y += x
print(y)
return
if __name__ == '__main__':
main()
|
s445839553
|
Accepted
| 18 | 2,940 | 317 |
def main():
y = 0
N = int(input())
for _ in range(N):
t = input()
x = float(t.strip().split(' ')[0])
u = t.strip().split(' ')[1]
if u == 'BTC':
y += 380000.0 * x
else:
y += x
print(y)
return
if __name__ == '__main__':
main()
|
s900802066
|
p03555
|
u147571984
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 74 |
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.
|
s1 = input()
s2 = input()
s2 = s2[::-1]
print('Yes' if s1 == s2 else 'No')
|
s098105793
|
Accepted
| 17 | 2,940 | 74 |
s1 = input()
s2 = input()
s2 = s2[::-1]
print('YES' if s1 == s2 else 'NO')
|
s551590613
|
p03486
|
u993642190
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 168 |
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
s = list(input())
t = list(input())
s2 = ''.join(sorted(s))
t2 = ''.join(sorted(t,reverse=True))
print([s2,t2])
if (s2 < t2) :
print("Yes")
else :
print("No")
|
s080370347
|
Accepted
| 18 | 2,940 | 153 |
s = list(input())
t = list(input())
s2 = ''.join(sorted(s))
t2 = ''.join(sorted(t,reverse=True))
if (s2 < t2) :
print("Yes")
else :
print("No")
|
s155226019
|
p03861
|
u473633103
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 75 |
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
a,b,x = map(int,input().split())
print(b//x-a//x+1 if a==0 else b//x-a//x)
|
s900621244
|
Accepted
| 18 | 2,940 | 101 |
# coding: utf-8
# Your code here!
a,b,x = map(int,input().split())
ans = b//x - (a-1)//x
print(ans)
|
s374033285
|
p03852
|
u626337957
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 91 |
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
|
c = input()
for c in ['a', 'i', 'u', 'e', 'o']:
print('vowel')
else:
print('consonant')
|
s687683675
|
Accepted
| 17 | 2,940 | 91 |
c = input()
if c in ['a', 'i', 'u', 'e', 'o']:
print('vowel')
else:
print('consonant')
|
s502678999
|
p03695
|
u223663729
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 158 |
In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows: * Rating 1-399 : gray * Rating 400-799 : brown * Rating 800-1199 : green * Rating 1200-1599 : cyan * Rating 1600-1999 : blue * Rating 2000-2399 : yellow * Rating 2400-2799 : orange * Rating 2800-3199 : red Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not. Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i. Find the minimum and maximum possible numbers of different colors of the users.
|
n, *A = map(int, open(0).read().split())
c = [0]*9
for a in A:
c[min(8, a//400)] += 1
cmin = max(1, 8-c.count(0))
cmax = min(8, cmin+c[8])
print(cmin, cmax)
|
s666902864
|
Accepted
| 18 | 3,060 | 162 |
n, *A = map(int, open(0).read().split())
c = [0]*9
for a in A:
c[min(8, a//400)] += 1
cl = 8-c[:-1].count(0)
cmin = max(1, cl)
cmax = cl+c[8]
print(cmin, cmax)
|
s710723664
|
p03573
|
u637918426
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 133 |
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
|
A, B, C = map(int, input().split())
if A != B:
if A != C:
print('A')
else:
print('B')
else:
print('C')
|
s010872766
|
Accepted
| 17 | 2,940 | 127 |
A, B, C = map(int, input().split())
if A != B:
if A != C:
print(A)
else:
print(B)
else:
print(C)
|
s396762517
|
p03377
|
u492447501
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 82 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
A,B,X = map(int, input().split())
if A==X:
print("YES")
else:
print("NO")
|
s848559852
|
Accepted
| 17 | 2,940 | 134 |
import sys
A,B,X = map(int, input().split())
for b in range(B+1):
if X==A+b:
print("YES")
sys.exit()
print("NO")
|
s765050269
|
p02606
|
u592246102
| 2,000 | 1,048,576 |
Wrong Answer
| 25 | 9,148 | 68 |
How many multiples of d are there among the integers between L and R (inclusive)?
|
a = list(map(int, input().split()))
b = a[1]-a[0]
print(int(b/a[2]))
|
s770200064
|
Accepted
| 29 | 8,796 | 95 |
a = a, b, c, = map(int, input().split())
bc = int(b/c)
ac = int((a-1)/c)
ans = bc-ac
print(ans)
|
s559131142
|
p03712
|
u019578976
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 170 |
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
|
N, M = map(int,input().split())
a = []
for i in range(N):
a.append(input())
print(a)
print("#"*(M+2))
for i,b in enumerate(a):
print("#"+a[i]+"#")
print("#"*(M+2))
|
s742372676
|
Accepted
| 17 | 3,060 | 161 |
N, M = map(int,input().split())
a = []
for i in range(N):
a.append(input())
print("#"*(M+2))
for i,b in enumerate(a):
print("#"+a[i]+"#")
print("#"*(M+2))
|
s093314733
|
p03163
|
u625963200
| 2,000 | 1,048,576 |
Wrong Answer
| 2,104 | 10,468 | 227 |
There are N items, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), Item i has a weight of w_i and a value of v_i. Taro has decided to choose some of the N items and carry them home in a knapsack. The capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W. Find the maximum possible sum of the values of items that Taro takes home.
|
N,W=map(int,input().split())
WV=[list(map(int,input().split())) for _ in range(N)]
dp=[-1]*(W+1)
dp[0]=0
for w,v in WV:
for i in range(W-w,-1,-1):
if dp[i]!=-1:
dp[i+w]=max(dp[i+w],dp[i]+v)
print(dp)
print(max(dp))
|
s393449650
|
Accepted
| 320 | 21,668 | 206 |
import numpy as np
N,W=map(int,input().split())
WV=[list(map(int,input().split())) for _ in range(N)]
dp=np.zeros(W+1,int)
for i in range(N):
w,v=WV[i]
dp[w:]=np.maximum(dp[w:],dp[:-w]+v)
print(dp[-1])
|
s954420974
|
p03448
|
u000842852
| 2,000 | 262,144 |
Wrong Answer
| 53 | 3,060 | 224 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans =0
for i in range(A):
for j in range(B):
for k in range(C):
tmp = 500*i + 100*j +50*k
if X == tmp:
ans +=1
print(ans)
|
s099308486
|
Accepted
| 55 | 3,060 | 225 |
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans =0
for i in range(A+1):
for j in range(B+1):
for k in range(C+1):
tmp = 500*i + 100*j + 50*k
if X == tmp:
ans +=1
print(ans)
|
s047377136
|
p02612
|
u346207191
| 2,000 | 1,048,576 |
Wrong Answer
| 32 | 9,136 | 40 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N=int(input())
a=N//1000
print(N-1000*a)
|
s486527951
|
Accepted
| 24 | 9,080 | 69 |
N=int(input())
a=N%1000
if a==0:
print(0)
else:
print(1000-a)
|
s288119179
|
p02694
|
u767438459
| 2,000 | 1,048,576 |
Time Limit Exceeded
| 2,205 | 9,076 | 106 |
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?
|
# -*- coding: utf-8 -*-
X = int(input())
n = 1
Y = 100 ** (n-1)
while Y < X:
n += 1
else:
print(n)
|
s539377005
|
Accepted
| 22 | 9,148 | 105 |
# -*- coding: utf-8 -*-
X = int(input())
n = 0
m = 100
while m < X:
n += 1
m += m//100
print(n)
|
s119361489
|
p03160
|
u117428186
| 2,000 | 1,048,576 |
Wrong Answer
| 103 | 20,524 | 189 |
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
n=int(input())
lst=list(map(int,input().split()))
dp=[0 for i in range(n)]
dp[1]=abs(lst[0]-lst[1])
for i in range(2,len(lst)):
dp[i]=min(dp[i-1]+lst[i-1],dp[i-2]+lst[i-2])
print(dp[n-1])
|
s459787234
|
Accepted
| 124 | 20,448 | 214 |
n=int(input())
lst=list(map(int,input().split()))
dp=[0 for i in range(n)]
dp[1]=abs(lst[0]-lst[1])
for i in range(2,len(lst)):
dp[i]=min(dp[i-1]+abs(lst[i]-lst[i-1]),dp[i-2]+abs(lst[i]-lst[i-2]))
print(dp[n-1])
|
s189876142
|
p03944
|
u955251526
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 322 |
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())
u, d = 0, h
l, r = 0, w
for _ in range(n):
x, y, a = map(int, input().split())
if a == 1:
l = max(l, x)
if a == 2:
r = min(r, x)
if a == 3:
u = max(u, y)
if a == 4:
d = min(d, y)
print(u, d, l, r)
print(max(0, (d-u)) * max(0, (r-l)))
|
s275251427
|
Accepted
| 18 | 3,064 | 304 |
w, h, n = map(int, input().split())
u, d = 0, h
l, r = 0, w
for _ in range(n):
x, y, a = map(int, input().split())
if a == 1:
l = max(l, x)
if a == 2:
r = min(r, x)
if a == 3:
u = max(u, y)
if a == 4:
d = min(d, y)
print(max(0, (d-u)) * max(0, (r-l)))
|
s210953273
|
p03712
|
u131406572
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 144 |
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
|
h,w=map(int,input().split())
a=[input() for i in range(h)]
print(a)
print("#"*(w+2))
for i in range(h):
print("#"+a[i]+"#")
print("#"*(w+2))
|
s249390122
|
Accepted
| 17 | 3,060 | 145 |
h,w=map(int,input().split())
a=[input() for i in range(h)]
#print(a)
print("#"*(w+2))
for i in range(h):
print("#"+a[i]+"#")
print("#"*(w+2))
|
s566810528
|
p02850
|
u502731482
| 2,000 | 1,048,576 |
Wrong Answer
| 373 | 24,644 | 502 |
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.
|
from collections import deque
n = int(input())
k = 0
data = [[] for _ in range(n)]
ans_index = []
for i in range(n - 1):
a, b = map(int, input().split())
a -= 1
b -= 1
data[a].append(b)
ans_index.append(b)
q = deque([0])
color = [0] * n
print(data)
while q:
cur = q.popleft()
c = 1
for x in data[cur]:
if c == color[cur]:
c += 1
color[x] = c
c += 1
q.append(x)
print(max(color))
for i in ans_index:
print(color[i])
|
s786350609
|
Accepted
| 349 | 23,168 | 490 |
from collections import deque
n = int(input())
k = 0
data = [[] for _ in range(n)]
ans_index = []
for i in range(n - 1):
a, b = map(int, input().split())
a -= 1
b -= 1
data[a].append(b)
ans_index.append(b)
q = deque([0])
color = [0] * n
while q:
cur = q.popleft()
c = 1
for x in data[cur]:
if c == color[cur]:
c += 1
color[x] = c
c += 1
q.append(x)
print(max(color))
for i in ans_index:
print(color[i])
|
s502308665
|
p03860
|
u316603606
| 2,000 | 262,144 |
Wrong Answer
| 28 | 8,832 | 53 |
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
A,x,C = input ().split ()
n = x[:1]
print ('A',n,'C')
|
s515109192
|
Accepted
| 27 | 8,964 | 53 |
A,x,C = input ().split ()
n = x[:1]
print ('A'+n+'C')
|
s317632795
|
p04044
|
u475675023
| 2,000 | 262,144 |
Wrong Answer
| 226 | 36,980 | 370 |
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
|
n,l=map(int,input().split())
s=[input() for _ in range(n)]
t=[]
t.append(s[0])
for i in range(1,n):
t.append(s[i])
for j in reversed(range(len(t)-1)):
print(t)
for k in range(l):
if not t[j][:k+1]==t[j+1][:k+1]:
print(t[j][k],t[j+1][k])
if ord(t[j][k])>ord(t[j+1][k]):
t[j],t[j+1]=t[j+1],t[j]
break
print("".join(t))
|
s721389493
|
Accepted
| 17 | 3,060 | 85 |
n,l=map(int,input().split())
s=[input() for _ in range(n)]
s.sort()
print("".join(s))
|
s822133850
|
p03005
|
u689745846
| 2,000 | 1,048,576 |
Wrong Answer
| 21 | 3,316 | 67 |
Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
|
k,n = map(int,input().split())
if n == 1: print(0)
else: print(n-k)
|
s344610177
|
Accepted
| 17 | 2,940 | 67 |
k,n = map(int,input().split())
if n == 1: print(0)
else: print(k-n)
|
s827626388
|
p03545
|
u087356957
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 1,281 |
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.
|
from sys import stdin
ABCD = stdin.readline().rstrip()
A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])
def func1(ABCD,k):
if k==len(ABCD)-1:
return [[ABCD[k]],["-"+ABCD[k]]]
prev_output = func1(ABCD,k+1)
output = []
if k==0:
for ele in prev_output:
temp = [ABCD[k]]
temp.extend(ele)
output.append(temp)
return output
for ele in prev_output:
temp = [ABCD[k]]
temp.extend(ele)
output.append(temp)
temp = ["-"+ABCD[k]]
temp.extend(ele)
output.append(temp)
return output
def search_combi(combinations):
for combi in combinations:
tot_sum = 0
for ele in combi:
tot_sum+=int(ele)
if tot_sum==7:
return combi
combinations = func1(ABCD,0)
#print("search_copmbi:",search_combi(combinations))
def make_answer(numbers):
output_string=""
for i,num in enumerate(numbers):
num_int = int(num)
if i==0:
output_string += num
else:
if num_int<0:
output_string += "-"+num[1]
else:
output_string += "+"+num
return output_string
print(make_answer(search_combi(combinations)))
|
s549589230
|
Accepted
| 17 | 3,064 | 1,286 |
from sys import stdin
ABCD = stdin.readline().rstrip()
A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])
def func1(ABCD,k):
if k==len(ABCD)-1:
return [[ABCD[k]],["-"+ABCD[k]]]
prev_output = func1(ABCD,k+1)
output = []
if k==0:
for ele in prev_output:
temp = [ABCD[k]]
temp.extend(ele)
output.append(temp)
return output
for ele in prev_output:
temp = [ABCD[k]]
temp.extend(ele)
output.append(temp)
temp = ["-"+ABCD[k]]
temp.extend(ele)
output.append(temp)
return output
def search_combi(combinations):
for combi in combinations:
tot_sum = 0
for ele in combi:
tot_sum+=int(ele)
if tot_sum==7:
return combi
combinations = func1(ABCD,0)
#print("search_copmbi:",search_combi(combinations))
def make_answer(numbers):
output_string=""
for i,num in enumerate(numbers):
num_int = int(num)
if i==0:
output_string += num
else:
if num_int<0:
output_string += "-"+num[1]
else:
output_string += "+"+num
return output_string+"=7"
print(make_answer(search_combi(combinations)))
|
s172282954
|
p03796
|
u872030436
| 2,000 | 262,144 |
Wrong Answer
| 230 | 4,020 | 60 |
Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
|
N = int(input())
import math
math.factorial(N) % (10**9+7)
|
s016921735
|
Accepted
| 233 | 3,972 | 68 |
N = int(input())
import math
print(math.factorial(N) % (10**9+7))
|
s146238931
|
p00031
|
u546285759
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,636 | 241 |
祖母が天秤を使っています。天秤は、二つの皿の両方に同じ目方のものを載せると釣合い、そうでない場合には、重い方に傾きます。10 個の分銅の重さは、軽い順に 1g, 2g, 4g, 8g, 16g, 32g, 64g, 128g, 256g, 512g です。 祖母は、「1kg くらいまでグラム単位で量れるのよ。」と言います。「じゃあ、試しに、ここにあるジュースの重さを量ってよ」と言ってみると、祖母は左の皿にジュースを、右の皿に 8g と64g と128g の分銅を載せて釣合わせてから、「分銅の目方の合計は 200g だから、ジュースの目方は 200g ね。どう、正しいでしょう?」と答えました。 左の皿に載せる品物の重さを与えるので、天秤で与えられた重みの品物と釣合わせるときに、右の皿に載せる分銅を軽い順に出力するプログラムを作成して下さい。ただし、量るべき品物の重さは、すべての分銅の重さの合計 (=1023g) 以下とします。
|
while True:
try:
weight = int(input())
except:
break
g = []
while weight != 1:
weight, b = divmod(weight, 2)
g.append(b)
g.append(weight)
print(*[pow(2*g[i], i) for i in range(len(g))])
|
s088526161
|
Accepted
| 20 | 7,512 | 249 |
while True:
try:
weight = int(input())
except:
break
g = []
while weight != 1:
weight, b = divmod(weight, 2)
g.append(b)
g.append(weight)
print(*[pow(2*g[i], i) for i in range(len(g)) if g[i]])
|
s518907606
|
p02613
|
u757777793
| 2,000 | 1,048,576 |
Wrong Answer
| 139 | 16,276 | 217 |
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.
|
rows = int(input())
x = [input() for i in range(rows)]
print("AC × {}".format(x.count('AC')))
print("WA × {}".format(x.count('WA')))
print("TLE × {}".format(x.count('TLE')))
print("RE × {}".format(x.count('RE')))
|
s492877794
|
Accepted
| 139 | 16,132 | 212 |
rows = int(input())
x = [input() for i in range(rows)]
print("AC x {}".format(x.count('AC')))
print("WA x {}".format(x.count('WA')))
print("TLE x {}".format(x.count('TLE')))
print("RE x {}".format(x.count('RE')))
|
s463207529
|
p03386
|
u193264896
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,316 | 344 |
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.
|
import sys
from collections import Counter
readline = sys.stdin.buffer.readline
MOD = 10**9+7
def main():
A, B, K = map(int, readline().split())
left = set(list(range(A, min(A+K, B+1))))
right = set(list(range(B, max(B-K, A-1), -1)))
ans = left | right
for i in ans:
print(i)
if __name__ == '__main__':
main()
|
s289270943
|
Accepted
| 20 | 3,316 | 365 |
import sys
from collections import Counter
readline = sys.stdin.buffer.readline
MOD = 10**9+7
def main():
A, B, K = map(int, readline().split())
left = set(list(range(A, min(A+K, B+1))))
right = set(list(range(B, max(B-K, A-1), -1)))
ans = list(left | right)
ans.sort()
for i in ans:
print(i)
if __name__ == '__main__':
main()
|
s554305810
|
p03361
|
u716530146
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 546 |
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`. However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black. Determine if square1001 can achieve his objective.
|
h,w = map(int,input().split())
s =[[i for i in input()] for j in range(h)]
for i in range(h):
for j in range(w):
if s[i][j]=='#':
flag = 0
for di in range(-1,2):
for dj in range(-1,2):
if di!=0 and (dj==-1 or dj==1):
# print(1)
continue
if di==0 and dj ==0:
continue
if not (0<=i+di<h and 0<=j+dj<w):
# print(2)
continue
if s[i+di][j+dj]=='#':
flag = 1
if flag ==0:
print('No')
break
else:
continue
break
else:
continue
break
else:
print('Yes')
|
s868723192
|
Accepted
| 28 | 3,064 | 520 |
h,w = map(int,input().split())
s =[[i for i in input()] for j in range(h)]
for i in range(h):
for j in range(w):
if s[i][j]=='#':
flag = 0
for di in range(-1,2):
for dj in range(-1,2):
if di!=0 and (dj==-1 or dj==1):
# print(1)
continue
if di==0 and dj ==0:
continue
if not (0<=i+di<h and 0<=j+dj<w):
# print(2)
continue
if s[i+di][j+dj]=='#':
flag = 1
if flag ==0:
print('No')
break
else:
continue
break
else:
print('Yes')
|
s081988001
|
p00760
|
u766477342
| 8,000 | 131,072 |
Wrong Answer
| 50 | 6,720 | 340 |
A wise king declared a new calendar. "Tomorrow shall be the first day of the calendar, that is, the day 1 of the month 1 of the year 1. Each year consists of 10 months, from month 1 through month 10, and starts from a _big month_. A common year shall start with a big month, followed by _small months_ and big months one after another. Therefore the first month is a big month, the second month is a small month, the third a big month, ..., and the 10th and last month a small one. A big month consists of 20 days and a small month consists of 19 days. However years which are multiples of three, that are year 3, year 6, year 9, and so on, shall consist of 10 big months and no small month." Many years have passed since the calendar started to be used. For celebration of the millennium day (the year 1000, month 1, day 1), a royal lottery is going to be organized to send gifts to those who have lived as many days as the number chosen by the lottery. Write a program that helps people calculate the number of days since their birthdate to the millennium day.
|
M = [20, 19]
Y = sum(M) * 5
for i in range(int(input())):
res = 0
y,m,d = list(map(int,input().split()))
for y_2 in range(1000-1, y, -1):
res += Y if y_2 % 3 != 0 else 200
for m_2 in range(10, m, -1):
res += M[m_2 % 2] if y % 3 != 0 else 20
res += (M[m%2] if y % 3 != 0 else 20) - d +1
print(res)
|
s458008786
|
Accepted
| 50 | 6,724 | 340 |
M = [19, 20]
Y = sum(M) * 5
for i in range(int(input())):
res = 0
y,m,d = list(map(int,input().split()))
for y_2 in range(1000-1, y, -1):
res += Y if y_2 % 3 != 0 else 200
for m_2 in range(10, m, -1):
res += M[m_2 % 2] if y % 3 != 0 else 20
res += (M[m%2] if y % 3 != 0 else 20) - d +1
print(res)
|
s676124527
|
p03637
|
u379142263
| 2,000 | 262,144 |
Wrong Answer
| 80 | 14,612 | 432 |
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
|
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
n = int(input())
a = list(map(int,input().split()))
li = []
li2 = []
li4 = []
for i in range(n):
if a[i]%4 == 0:
li4.append(a[i])
elif a[i]%2 == 0:
li2.append(a[i])
else:
li.append(a[i])
if len(li4)>len(li):
print("Yes")
else:
print("No")
|
s937166697
|
Accepted
| 73 | 14,636 | 437 |
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
n = int(input())
a = list(map(int,input().split()))
n1 = 0
n2 = 0
n4 = 0
for i in range(n):
if a[i]%4 == 0:
n4+=1
elif a[i]%2 == 0:
n2 +=1
else:
n1+=1
if n2 == 1:
n2 = 0
if n4*2 + n2 >= n or n4*2 + 1 == n:
print("Yes")
else:
print("No")
|
s236058486
|
p03409
|
u064246852
| 2,000 | 262,144 |
Wrong Answer
| 344 | 11,892 | 516 |
On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.
|
n = int(input())
red = []
blue = []
for i in range(n):
red.append(list(map(int,input().split())))
for i in range(n):
blue.append(list(map(int,input().split())))
red.sort(reverse = True)
blue.sort(reverse = True)
print(red)
print(blue)
ans = 0
for i in range(n):
redx,redy = red[i][0],red[i][1]
for j in range(len(blue)):
print(blue)
bluex,bluey = blue[j][0],blue[j][1]
if redx < bluex and redy < bluey:
ans += 1
blue.pop(0)
break
print(ans)
|
s131090007
|
Accepted
| 20 | 3,064 | 476 |
n = int(input())
red = []
blue = []
for i in range(n):
red.append(list(map(int,input().split())))
for i in range(n):
blue.append(list(map(int,input().split())))
red.sort(reverse = True)
blue.sort(key=lambda x:x[1])
ans = 0
for i in range(n):
redx,redy = red[i][0],red[i][1]
for j in range(len(blue)):
bluex,bluey = blue[j][0],blue[j][1]
if redx < bluex and redy < bluey:
ans += 1
blue.pop(j)
break
print(ans)
|
s340614252
|
p04029
|
u801864018
| 2,000 | 262,144 |
Wrong Answer
| 28 | 8,920 | 91 |
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 = 3
print(N *(N + 1) // 2)
N = 10
print(N * (N + 1) // 2)
N = 1
print(N * (N + 1) // 2)
|
s809539838
|
Accepted
| 24 | 9,136 | 60 |
N = int(input())
candy = int(N * (N + 1) / 2)
print(candy)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.