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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s180462476
|
p03658
|
u094565093
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 93 |
Snuke has N sticks. The length of the i-th stick is l_i. Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy.
|
N,K=map(int,input().split())
L=list(map(int,input().split()))
L.sort()
L.reverse()
sum(L[:K])
|
s346017162
|
Accepted
| 17 | 2,940 | 100 |
N,K=map(int,input().split())
L=list(map(int,input().split()))
L.sort()
L.reverse()
print(sum(L[:K]))
|
s367240726
|
p03079
|
u749638140
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 143 |
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
|
s = input().split(' ')
maxNum = max(s)
s.remove(maxNum)
if(int(s[0])**2 + int(s[1])**2 == int(maxNum)**2):
print('Yes')
else:
print('No')
|
s438299299
|
Accepted
| 17 | 2,940 | 133 |
import sys
s = input().split(' ')
if(float(s[0]) == float(s[1]) and float(s[0]) == float(s[2])):
print('Yes')
else:
print('No')
|
s248424948
|
p02614
|
u243061947
| 1,000 | 1,048,576 |
Wrong Answer
| 133 | 9,208 | 1,379 |
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
|
import itertools
import copy
def red_gyou(c, gyou, W):
for i in range(W):
c[gyou][i] = 0
def red_retsu(c, retsu, H):
for j in range(H):
c[j][retsu] = 0
def blacks(c, H):
black = 0
for i in range(H):
black += sum(c[i])
return black
H, W, K = map(int, input().split())
c = []
for i in range(H):
gyou = []
colors = input()
for color in colors:
if color == '#':
gyou.append(1) # black
else:
gyou.append(0) # white
c.append(gyou)
tate = list(range(H))
yoko = list(range(W))
answer = 0
for i in range(H+1):
red_tate = list(itertools.combinations(tate, i))
for j in range(W+1):
red_yoko = list(itertools.combinations(yoko, j))
if not i and j:
for ry in red_tate:
cc = copy.deepcopy(c)
for jj in ry:
red_retsu(cc, jj, W)
if blacks(cc, H) == K:
answer += 1
continue
elif i and not j:
for rt in red_yoko:
cc = copy.deepcopy(c)
for ii in rt:
red_gyou(cc, ii, H)
if blacks(cc, H) == K:
answer += 1
continue
elif not i and not j:
continue
for rt in red_tate:
for ry in red_yoko:
cc = copy.deepcopy(c)
for ii in rt:
red_gyou(cc, ii, W)
for jj in ry:
red_retsu(cc, jj, H)
if blacks(cc, H) == K:
answer += 1
print(answer)
|
s329902394
|
Accepted
| 133 | 9,348 | 828 |
import itertools
import copy
def row(c, i, H, W):
for j in range(W):
c[i][j] = 0
def column(c, j, H, W):
for i in range(H):
c[i][j] = 0
def blacks(c, H, W):
black = 0
for row in c:
black += sum(row)
return black
H, W, K = map(int, input().split())
c = []
for i in range(H):
c.append([])
string = input()
for color in string:
if color == '#':
c[-1].append(1)
else:
c[-1].append(0)
height = list(itertools.product([0, 1], repeat=H))
weight = list(itertools.product([0, 1], repeat=W))
answer = 0
for tate in height:
for yoko in weight:
cc = copy.deepcopy(c)
for i in range(len(tate)):
if tate[i]:
row(cc, i, H, W)
for j in range(len(yoko)):
if yoko[j]:
column(cc, j, H, W)
if blacks(cc, H, W) == K:
answer += 1
print(answer)
|
s366374584
|
p03048
|
u276115223
| 2,000 | 1,048,576 |
Time Limit Exceeded
| 2,206 | 9,164 | 290 |
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?
|
R, G, B, N = [int(i) for i in input().split()]
bingo = 0
for r in range(0, 3001):
for g in range(0, 3001):
b = (N -(R * r + G * g)) // B
if b >= 0 and R * r + G * g + B * b == N:
bingo += 1
print(bingo)
|
s797639854
|
Accepted
| 1,985 | 9,128 | 345 |
R, G, B, N = [int(i) for i in input().split()]
bingo = 0
for r in range(N + 1):
if R * r > N:
break
for g in range(N + 1):
b = (N - (R * r + G * g)) // B
if b < 0:
break
elif R * r + G * g + B * b == N:
bingo += 1
print(bingo)
|
s513969417
|
p02602
|
u537976628
| 2,000 | 1,048,576 |
Wrong Answer
| 149 | 31,568 | 139 |
M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms: not given. * For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term. M-kun scored A_i in the exam at the end of the i-th term. For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is **strictly** greater than the grade for the (i-1)-th term.
|
n, k = map(int, input().split())
al = list(map(int, input().split()))
for i in range(k, n):
print('yes' if al[i] > al[i - k] else 'No')
|
s319376172
|
Accepted
| 150 | 31,604 | 139 |
n, k = map(int, input().split())
al = list(map(int, input().split()))
for i in range(k, n):
print('Yes' if al[i] > al[i - k] else 'No')
|
s280353169
|
p02393
|
u306530296
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,716 | 106 |
Write a program which reads three integers, and prints them in ascending order.
|
nums = input().split()
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])
if a < b < c:
print(a, b, c)
|
s904265928
|
Accepted
| 30 | 6,728 | 293 |
nums = input().split()
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])
if a <= b <= c:
print(a, b, c)
elif a <= c <= b:
print(a, c, b)
elif b <= a <= c:
print(b, a, c)
elif b <= c <= a:
print(b, c, a)
elif c <= a <= b:
print(c, a, b)
else:
print(c, b, a)
|
s748256364
|
p02854
|
u049574854
| 2,000 | 1,048,576 |
Wrong Answer
| 164 | 26,220 | 399 |
Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be possible as is, so he will do the following operations some number of times **before** he does the cut: * Choose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan). * Choose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen. Find the minimum amount of money needed before cutting the bar into two parts with the same length.
|
N = int(input())
A = list(map(int, input().split()))
Asum = sum(A)
s=0
t=0
for i,Ai in enumerate(A):
s+=Ai
if s == Asum/2:
print(0)
exit()
if s >= Asum/2:
s = i
break
for i,Ai in enumerate(A[::-1]):
t+=Ai
if t >= Asum/2:
t = i
break
ans1 = sum(A[:s])-(Asum-sum(A[:s]))
ans2 = sum(A[:t])-(Asum-sum(A[:t]))
print(min(ans1,ans2))
|
s207123056
|
Accepted
| 173 | 26,220 | 421 |
N = int(input())
A = list(map(int, input().split()))
Asum = sum(A)
s=0
t=0
for i,Ai in enumerate(A):
s+=Ai
if s == Asum/2:
print(0)
exit()
if s >= Asum/2:
s = i
break
for i,Ai in enumerate(A[::-1]):
t+=Ai
if t >= Asum/2:
t = i
break
ans1 = abs(sum(A[:s])-(Asum-sum(A[:s])))
ans2 = abs(sum(A[::-1][:t])-(Asum-sum(A[::-1][:t])))
print(min(ans1,ans2))
|
s664698034
|
p03049
|
u218843509
| 2,000 | 1,048,576 |
Wrong Answer
| 34 | 3,188 | 449 |
Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
|
import sys
def input():
return sys.stdin.readline()[:-1]
n = int(input())
xa, bx, bxa = 0, 0, 0
ans = 0
for _ in range(n):
s = input()
for i in range(len(s)-1):
if s[i] == "A" and s[i+1] == "B":
ans += 1
if s[0] == "B":
if s[-1] == "A":
bxa += 1
else:
bx += 1
elif s[-1] == "A":
xa += 1
#print(xa, bx, bxa)
ans += bxa-1
if bxa > 0:
if xa > 0:
xa -= 1
ans += 1
if bx > 0:
bx -= 1
ans += 1
ans += min(xa, bx)
print(ans)
|
s194973213
|
Accepted
| 44 | 3,064 | 365 |
n = int(input())
xa, bx, bxa = 0, 0, 0
ans = 0
for _ in range(n):
s = input()
for i in range(len(s)-1):
if s[i] == "A" and s[i+1] == "B":
ans += 1
if s[0] == "B":
if s[-1] == "A":
bxa += 1
else:
bx += 1
elif s[-1] == "A":
xa += 1
if xa == bx:
if xa == 0:
print(ans+max(0, bxa-1))
else:
print(ans+xa+bxa)
else:
print(ans+bxa+min(xa, bx))
|
s076580330
|
p03997
|
u095094246
| 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)
|
s720569726
|
Accepted
| 17 | 2,940 | 66 |
a=int(input())
b=int(input())
h=int(input())
print(int((a+b)*h/2))
|
s220579739
|
p03719
|
u071916806
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 121 |
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if c>=a:
if c<=b:
print('Yes')
else:
print('No')
print('No')
|
s838689436
|
Accepted
| 17 | 2,940 | 129 |
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if c>=a:
if c<=b:
print('Yes')
else:
print('No')
else:
print('No')
|
s030587877
|
p03131
|
u858670323
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 118 |
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
|
k,a,b = map(int,input().split())
dif = b-a
if b<=2:
print(k)
else:
ans = dif*(k//2)
ans += (k%2==1)
print(ans)
|
s944972498
|
Accepted
| 17 | 2,940 | 147 |
k,a,b = map(int,input().split())
dif = b-a
if dif<=2:
print(k+1)
else:
ans = a
k -= (a-1)
ans += dif*(k//2)
ans += (k%2==1)
print(ans)
|
s485221792
|
p03644
|
u705617253
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 90 |
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
n = int(input())
result = 0
while n % 2 == 0:
n //= 2
result += 1
print(result)
|
s396425337
|
Accepted
| 18 | 2,940 | 316 |
def calculate_dived_by_two(n):
count = 0
while n % 2 == 0:
count += 1
n //= 2
return count
n = int(input())
result = 1
max_count = 0
for i in range(1, n + 1):
count = calculate_dived_by_two(i)
if count > max_count:
max_count = count
result = i
print(result)
|
s450412172
|
p03813
|
u607920888
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 98 |
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.
|
sumeke=input()
sumeke=int(sumeke)
sumeke=1200
if sumeke >= 1200:
print("ARC")
else:
print("ABC")
|
s380588038
|
Accepted
| 18 | 2,940 | 85 |
sumeke=input()
sumeke=int(sumeke)
if sumeke < 1200:
print("ABC")
else:
print("ARC")
|
s216241623
|
p02612
|
u318909153
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,048 | 50 |
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.
|
dash =int(input())
otsuri=dash%1000
print(otsuri)
|
s460092788
|
Accepted
| 29 | 9,160 | 115 |
dash =int(input())
otsuri1=dash%1000
if otsuri1==0:
print(0)
else:
otsuri2=1000-otsuri1
print(otsuri2)
|
s409116248
|
p03592
|
u687574784
| 2,000 | 262,144 |
Wrong Answer
| 1,140 | 17,968 | 206 |
We have a grid with N rows and M columns of squares. Initially, all the squares are white. There is a button attached to each row and each column. When a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa. When a button attached to a column is pressed, the colors of all the squares in that column are inverted. Takahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.
|
n,m,k = list(map(int, input().split()))
for i in range(n+1):
for j in range(m+1):
print(i, j, i*m+j*n-2*i*j)
if i*m+j*n-2*i*j==k:
print('Yes')
exit()
print('No')
|
s187594238
|
Accepted
| 258 | 9,152 | 171 |
n,m,k = list(map(int, input().split()))
for i in range(n+1):
for j in range(m+1):
if i*m+j*n-2*i*j==k:
print('Yes')
exit()
print('No')
|
s188292404
|
p02614
|
u233254147
| 1,000 | 1,048,576 |
Wrong Answer
| 139 | 9,352 | 861 |
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
|
import itertools
import copy
h, w, k = map(int, input().split())
cs = []
for i in range(h):
cs.append(list(input()))
# print(cs)
hpatterns = []
for i in range(h + 1):
hpatterns += list(itertools.combinations(range(h), i))
wpatterns = []
for i in range(w + 1):
wpatterns += list(itertools.combinations(range(w), i))
# print(hpatterns)
# print(wpatterns)
c = 0
for hpattern in hpatterns:
for wpattern in wpatterns:
black = 0
cs2 = copy.deepcopy(cs)
for pi in range(len(hpattern)):
cs2[pi] = ['' for k in range(w)]
for pj in range(len(wpattern)):
for s in range(len(cs2)):
cs2[s][pj] = ''
# print(hpattern, wpattern, cs2)
for s in cs2:
black += s.count('#')
if black == k:
c += 1
print(c)
|
s770171116
|
Accepted
| 135 | 9,304 | 837 |
import itertools
import copy
h, w, k = map(int, input().split())
cs = []
for i in range(h):
cs.append(list(input()))
# print(cs)
hpatterns = []
for i in range(h + 1):
hpatterns += list(itertools.combinations(range(h), i))
wpatterns = []
for i in range(w + 1):
wpatterns += list(itertools.combinations(range(w), i))
# print(hpatterns)
# print(wpatterns)
c = 0
for hpattern in hpatterns:
for wpattern in wpatterns:
black = 0
cs2 = copy.deepcopy(cs)
for pi in hpattern:
cs2[pi] = ['' for k in range(w)]
for pj in wpattern:
for s in range(len(cs2)):
cs2[s][pj] = ''
# print(wpattern, hpattern, cs2)
for s in cs2:
black += s.count('#')
if black == k:
c += 1
print(c)
|
s791669860
|
p02402
|
u328199937
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,588 | 233 |
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.
|
N = int(input())
num = input()
list = num.split()
print(list[1])
max = sum = min = int(list[0])
for x in range(N - 1):
a = int(list[x + 1])
if a > max: max = a
elif a < min: min = a
sum += a
print(min, max, sum)
|
s567766829
|
Accepted
| 20 | 6,340 | 219 |
N = int(input())
num = input()
list = num.split()
max = sum = min = int(list[0])
for x in range(N - 1):
a = int(list[x + 1])
if a > max: max = a
elif a < min: min = a
sum += a
print(min, max, sum)
|
s696395293
|
p03457
|
u519078363
| 2,000 | 262,144 |
Wrong Answer
| 399 | 27,380 | 365 |
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())
txy = [list(map(int, input().split())) for _ in range(n)]
t, x, y = 0, 0, 0
flag = True
for nt, nx, ny in txy:
dt = nt - t
dx = nx - x
dy = ny - y
if (dt < dx + dy) or ((dx + dy) % 2 != dt % 2):
flag = False
break
else:
t = nx
x = nx
y = ny
if flag:
print('YES')
else:
print('NO')
|
s955981064
|
Accepted
| 408 | 27,380 | 343 |
n = int(input())
txy = [list(map(int, input().split())) for _ in range(n)]
t, x, y = 0, 0, 0
flag = True
for nt, nx, ny in txy:
dt = nt - t
dx = nx - x
dy = ny - y
if (dt < dx + dy) or ((dx + dy) % 2 != dt % 2):
flag = False
break
t = nt
x = nx
y = ny
if flag:
print('Yes')
else:
print('No')
|
s604092434
|
p03997
|
u377036395
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 70 |
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)
|
s723851152
|
Accepted
| 17 | 2,940 | 76 |
a = int(input())
b = int(input())
h = int(input())
print(int((a + b)*h/2))
|
s898003821
|
p03543
|
u790877102
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,192 | 744 |
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
|
n = int(input())
s = []
for i in range(4):
s.append(n//(10**i)-(n//(10**(i+1)))*10)
s.reverse()
if s[0]+s[1]+s[2]+s[3]==7:
print(s[0],"+",s[1],"+",s[2],"+",s[3],"=7",sep="")
elif s[0]+s[1]+s[2]-s[3]==7:
print(s[0],"+",[1],"+",s[2],"-",s[3],"=7",sep="")
elif s[0]+s[1]-s[2]+s[3]==7:
print(s[0],"+",s[1],"-",s[2],"+",s[3],"=7",sep="")
elif s[0]+s[1]-s[2]-s[3]==7:
print(s[0],"+",s[1],"-",s[2],"-",s[3],"=7",sep="")
elif s[0]-s[1]+s[2]+s[3]==7:
print(s[0],"-",s[1],"+",s[2],"+",s[3],"=7",sep="")
elif s[0]-s[1]+s[2]-s[3]==7:
print(s[0],"-",s[1],"+",s[2],"-",s[3],"=7",sep="")
elif s[0]-s[1]-s[2]+s[3]==7:
print(s[0],"-",s[1],"-",s[2],"+",s[3],"=7",sep="")
elif s[0]-s[1]-s[2]-s[3]==7:
print(s[0],"-",s[1],"-",s[2],"-",s[3],"=7",sep="")
|
s575829100
|
Accepted
| 17 | 2,940 | 98 |
n = list(input())
if n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:
print("Yes")
else:
print("No")
|
s882917912
|
p03672
|
u309141201
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,064 | 288 |
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
|
S = list(input())
answer = 0
while True:
if len(S) >= 1:
S.pop(-1)
print(S[0:len(S)//2])
print(S[len(S)//2+1:-1])
if S[0:len(S)//2] == S[len(S)//2:-1]:
answer = len(S)-1
break
else:
break
# print(S)
print(answer)
|
s782099129
|
Accepted
| 18 | 3,060 | 292 |
S = list(input())
answer = 0
while True:
if len(S) >= 1:
S.pop(-1)
# print(S[0:len(S)//2])
# print(S[len(S)//2+1:-1])
if S[0:len(S)//2] == S[len(S)//2:-1]:
answer = len(S)-1
break
else:
break
# print(S)
print(answer)
|
s219560346
|
p03501
|
u604655161
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 165 |
You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours.
|
def ABC_80_A():
N,A,B = map(int, input().split())
if A*N >= B:
print(A*N)
else:
print(B)
if __name__ == '__main__':
ABC_80_A()
|
s107797788
|
Accepted
| 18 | 2,940 | 165 |
def ABC_80_A():
N,A,B = map(int, input().split())
if A*N <= B:
print(A*N)
else:
print(B)
if __name__ == '__main__':
ABC_80_A()
|
s732502268
|
p03436
|
u520158330
| 2,000 | 262,144 |
Wrong Answer
| 46 | 3,952 | 649 |
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares. Before Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game. When the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares. The color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is `.`; if square (i, j) is initially painted by black, s_{i, j} is `#`.
|
import queue
H,W = map(int,input().split())
temp = [[-1 for j in range(W+2)]]
B = temp+[[] for i in range(H)]+temp
dot = 0
for i in range(1,H+1):
S = input()
B[i].append(-1)
for s in S:
if s==".":
B[i].append(H*W)
dot += 1
else:
B[i].append(-1)
B[i].append(-1)
Q = queue.Queue()
Q.put((1,1))
B[1][1]=1
min_root = dot
while(not Q.empty()):
x,y = Q.get()
L = [[x-1,y],[x+1,y],[x,y-1],[x,y+1]]
move = B[x][y]+1
for dx,dy in L:
if move < B[dx][dy]:
Q.put((dx,dy))
B[dx][dy] = move
print(B,dot-B[H][W])
|
s269530929
|
Accepted
| 46 | 3,952 | 723 |
import queue
H,W = map(int,input().split())
temp = [[-1 for j in range(W+2)]]
B = temp+[[] for i in range(H)]+temp
dot = 0
for i in range(1,H+1):
S = input()
B[i].append(-1)
for s in S:
if s==".":
B[i].append(H*W)
dot += 1
else:
B[i].append(-1)
B[i].append(-1)
Q = queue.Queue()
Q.put((1,1))
B[1][1]=1
min_root = dot
isok = False
while(not Q.empty()):
y,x = Q.get()
L = [[y-1,x],[y+1,x],[y,x-1],[y,x+1]]
move = B[y][x]+1
for dy,dx in L:
if move < B[dy][dx]:
Q.put((dy,dx))
B[dy][dx] = move
if dy==H and dx==W: isok=True
if isok:
print(dot-B[H][W])
else:
print(-1)
|
s117254082
|
p03457
|
u168489836
| 2,000 | 262,144 |
Wrong Answer
| 549 | 89,356 | 250 |
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())
time_space = [(int(x) for x in input().split()) for i in range(n)]
pos = [0,0]
for t, x, y in time_space:
if (t - abs(x - pos[0]))%2 != abs(y-pos[1]):
print('No')
exit()
else:
pos = [x, y]
print('Yes')
|
s005832845
|
Accepted
| 335 | 3,060 | 162 |
n = int(input())
for i in range(n):
t, x, y = [int(x) for x in input().split()]
if (x+y) > t or (x+y+t)%2:
print('No')
exit()
print('Yes')
|
s263842578
|
p02255
|
u294922877
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,612 | 485 |
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
def insertion_sort(args):
results = []
for i in range(0, len(args)):
v = args[i]
j = i - 1
while (j >= 0 and args[j] > v):
args[j+1] = args[j]
j -= 1
args[j+1] = v
results.append(args[:])
return results
if __name__ == '__main__':
n = int(input())
args = list(map(int, input().split()))[0:n]
results = insertion_sort(args)
for result in results:
print(result)
|
s840605134
|
Accepted
| 20 | 5,672 | 505 |
def insertion_sort(args):
results = []
for i in range(0, len(args)):
v = args[i]
j = i - 1
while (j >= 0 and args[j] > v):
args[j+1] = args[j]
j -= 1
args[j+1] = v
results.append(args[:])
return results
if __name__ == '__main__':
n = int(input())
args = list(map(int, input().split()))[0:n]
results = insertion_sort(args)
for result in results:
print(' '.join(map(str, result)))
|
s634986635
|
p02255
|
u530663965
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,616 | 790 |
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.
|
import sys
ERROR_INPUT = 'input is invalid'
def main():
n = get_length()
arr = get_array(length=n)
print(arr)
insetionSort(li=arr, length=n)
return 0
def get_length():
n = int(input())
if n < 0 or n > 100:
print(ERROR_INPUT)
sys.exit(1)
else:
return n
def get_array(length):
nums = input().split(' ')
return [str2int(string=n) for n in nums]
def str2int(string):
n = int(string)
if n < 0 or n > 1000:
print(ERROR_INPUT)
sys.exit(1)
else:
return n
def insetionSort(li, length):
for i in range(1, length):
v = li[i]
j = i - 1
while j >= 0 and li[j] > v:
li[j + 1] = li[j]
j -= 1
li[j + 1] = v
print(li)
main()
|
s252527810
|
Accepted
| 20 | 5,976 | 670 |
import sys
ERROR_INPUT = 'input is invalid'
def main():
n = get_length()
arr = get_array(length=n)
insetionSort(li=arr, length=n)
return 0
def get_length():
n = int(input())
if n < 0 or n > 100:
print(ERROR_INPUT)
sys.exit(1)
else:
return n
def get_array(length):
nums = input().split(' ')
return [str2int(string=n) for n in nums]
def str2int(string):
n = int(string)
if n < 0 or n > 1000:
print(ERROR_INPUT)
sys.exit(1)
else:
return n
def insetionSort(li, length):
for n in range(0, length):
print(*(sorted(li[0:n + 1]) + li[n + 1:length]))
main()
|
s916323100
|
p03067
|
u970809473
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 111 |
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
|
a,b,c = map(int, input().split())
if (b > a and b < c) or (b < a and b > c):
print('Yes')
else:
print('No')
|
s990406192
|
Accepted
| 17 | 2,940 | 112 |
a,b,c = map(int, input().split())
if (c > a and b > c) or (c < a and b < c):
print('Yes')
else:
print('No')
|
s462214206
|
p03360
|
u562935282
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 90 |
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
|
abc = map(int, input().split())
k = int(input())
print(max(abc) * (2 ** k - 1) + sum(abc))
|
s292640566
|
Accepted
| 17 | 2,940 | 132 |
x = tuple(map(int, input().split()))
k = int(input())
# max(x) * (2 ** k) + sum(x) - max(x)
print(sum(x) + max(x) * ((1 << k) - 1))
|
s773062937
|
p02408
|
u962381052
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,624 | 334 |
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.
|
epochs = int(input())
patterns = ['S', 'H', 'C', 'D']
checker = {pattern: [True]*13 for pattern in patterns}
for i in range(epochs):
pattern, num = input().split()
num = int(num)
checker[pattern][num-1] = False
for pattern in patterns:
for i in range(13):
if checker[pattern][i]:
print(pattern, i)
|
s873146408
|
Accepted
| 20 | 7,668 | 337 |
epochs = int(input())
patterns = ['S', 'H', 'C', 'D']
checker = {pattern: [True]*13 for pattern in patterns}
for i in range(epochs):
pattern, num = input().split()
num = int(num)
checker[pattern][num-1] = False
for pattern in patterns:
for i in range(13):
if checker[pattern][i]:
print(pattern, i+1)
|
s435508244
|
p03997
|
u881100099
| 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,b,h=[int(input()) for i in range(1,4)]
s=(a+b)*h/2
print(s)
|
s649297889
|
Accepted
| 17 | 2,940 | 66 |
a,b,h=[int(input()) for i in range(1,4)]
s=int((a+b)*h/2)
print(s)
|
s235299426
|
p03131
|
u662482238
| 2,000 | 1,048,576 |
Wrong Answer
| 2,104 | 3,064 | 346 |
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
|
k,a,b = list(map(int,input().split()))
mon = 0
bis = 1
if(a <= b-1):
for i in range(k):
bis = bis + 1
else:
for i in range(k):
if(mon == 1):
mon = 0
bis = bis + b
elif(bis >= a and i < k-1):
mon = 1
bis = bis - a
else:
bis = bis + 1
print(bis)
|
s034485065
|
Accepted
| 18 | 3,064 | 150 |
k,a,b = list(map(int,input().split()))
bis = 0
if(b-a <= 2):
bis = k + 1
else:
bis = a + int((k-(a-1)) / 2) * (b-a) + (k-(a-1)) % 2
print(bis)
|
s077243825
|
p00062
|
u737311644
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,588 | 202 |
次のような数字のパターンを作ることを考えます。 4 8 2 3 1 0 8 3 7 6 2 0 5 4 1 8 1 0 3 2 5 9 5 9 9 1 3 7 4 4 4 8 0 4 1 8 8 2 8 4 9 6 0 0 2 5 6 0 2 1 6 2 7 8 5 このパターンは以下の規則に従っています。 A B C という数字の並びにおいて、C は A + B の 1 の位の数字である。たとえば、 9 5 4 では、9 + 5 = 14 の 1 の位の数字、すなわち 4 が 9 と 5 の斜め下に並べられます。また、 2 3 5 では、2 + 3 = 5 の 1 の位の数字、すなわち 5 が 2 と 3 の斜め下に並べられます。 一番上の行の 10 個の整数を読み込んで、一番下の行の 1 個の数を出力するプログラムを作成してください。
|
b = input()
a=list(b)
for i in range(10):
a[i]=int(a[i])
n=9
for i in range(10):
d = 1
for j in range(n):
c=a[j]+a[d]
c=c%10
a[j]=c
d+=1
n-=1
print(a[0])
|
s743339396
|
Accepted
| 20 | 5,592 | 352 |
while True:
try:
b = input()
a=list(b)
for i in range(10):
a[i]=int(a[i])
n=9
for i in range(10):
d = 1
for j in range(n):
c=a[j]+a[d]
c=c%10
a[j]=c
d+=1
n-=1
print(a[0])
except:break
|
s043103671
|
p03385
|
u254871849
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 184 |
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
import sys
s = sys.stdin.readline().rstrip()
def main():
return 'Yes' if ''.join(list(reversed(s))) == 'abc' else 'No'
if __name__ == '__main__':
ans = main()
print(ans)
|
s233169173
|
Accepted
| 17 | 2,940 | 176 |
import sys
s = sys.stdin.readline().rstrip()
s = ''.join(sorted(s))
def main():
ans = 'Yes' if s == 'abc' else 'No'
print(ans)
if __name__ == '__main__':
main()
|
s577180088
|
p03563
|
u620945921
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 37 |
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
|
n=int(input())
print((23-5)*60/(n-1))
|
s151691110
|
Accepted
| 18 | 2,940 | 45 |
r=int(input())
g=int(input())
print(2*g-r)
|
s830722650
|
p02394
|
u077284614
| 1,000 | 131,072 |
Wrong Answer
| 40 | 7,588 | 125 |
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.
|
W, H, x, y, r = map(int,input().split())
if (x-r)>=0 and (x+r)<=W and (y-r)<=0 and (y+r)<=H:
print("Yes")
else:
print("No")
|
s500206666
|
Accepted
| 30 | 7,680 | 125 |
W, H, x, y, r = map(int,input().split())
if (x-r)>=0 and (x+r)<=W and (y-r)>=0 and (y+r)<=H:
print("Yes")
else:
print("No")
|
s721655361
|
p03502
|
u593227551
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 71 |
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
|
a = input()
b = str(a)
ans = 0
for c in b:
ans += int(c)
print(ans)
|
s184613480
|
Accepted
| 18 | 2,940 | 110 |
a = input()
ans = 0
for c in a:
ans += int(c)
if int(a) % ans == 0:
print("Yes")
else:
print("No")
|
s161480348
|
p02409
|
u405758695
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,616 | 289 |
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
|
n=int(input())
tou=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]
print(len(tou))
for _ in range(n):
b,f,r,v=map(int, input().split())
tou[b-1][f-1][r-1]+=v
for i in range(4):
for j in range(3):
print(*tou[i][j])
if i!=3: print('#'*20)
|
s702671234
|
Accepted
| 20 | 5,624 | 288 |
n=int(input())
tou=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for _ in range(n):
b,f,r,v=map(int, input().split())
tou[b-1][f-1][r-1]+=v
for i in range(4):
for j in range(3):
print(' ', end='')
print(*tou[i][j])
if i!=3: print('#'*20)
|
s664802154
|
p03711
|
u353652911
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 133 |
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
|
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,8,11]
print("YES" if (x in a and y in a) or (x in b and y in b) else "NO")
|
s445845990
|
Accepted
| 17 | 2,940 | 83 |
s="0ACABABAABABA"
x,y=map(int,input().split())
print("Yes" if s[x]==s[y] else "No")
|
s223428675
|
p03575
|
u694810977
| 2,000 | 262,144 |
Wrong Answer
| 42 | 3,444 | 743 |
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i. An edge whose removal disconnects the graph is called a _bridge_. Find the number of the edges that are bridges among the M edges.
|
N,M = map(int,input().split())
list_a = []
list_b = []
g = [[0 for i in range(N)] for j in range(N)]
for i in range(M):
a,b = map(int,input().split())
list_a.append(a-1)
list_b.append(b-1)
g[a-1][b-1] = 1
g[b-1][a-1] = 1
def dfs(v):
seen[v] = 1
ret = 1
for v2 in range(N):
if g[v][v2] == 1 and seen[v2] == 0:
print(v,v2,seen,"####")
dfs(v2)
if seen == [1] * N:
ret = 0
return ret
ans = 0
for i in range(M):
seen = [0] * N
g[list_a[i]][list_b[i]] = 0
g[list_b[i]][list_a[i]] = 0
ans += dfs(0)
g[list_a[i]][list_b[i]] = 1
g[list_b[i]][list_a[i]] = 1
print(ans)
|
s788096906
|
Accepted
| 28 | 3,188 | 719 |
N,M = map(int,input().split())
list_a = []
list_b = []
g = [[0 for i in range(N)] for j in range(N)]
for i in range(M):
a,b = map(int,input().split())
list_a.append(a-1)
list_b.append(b-1)
g[a-1][b-1] = 1
g[b-1][a-1] = 1
def dfs(v):
seen[v] = 1
ret = 1
for v2 in range(N):
if g[v][v2] == 1 and seen[v2] == 0:
dfs(v2)
if seen == [1] * N:
ret = 0
return ret
ans = 0
for i in range(M):
seen = [0] * N
g[list_a[i]][list_b[i]] = 0
g[list_b[i]][list_a[i]] = 0
ans += dfs(0)
g[list_a[i]][list_b[i]] = 1
g[list_b[i]][list_a[i]] = 1
print(ans)
|
s034833689
|
p03493
|
u925836726
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 228 |
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
def main():
s = list(input())
count = 0
if(s[0] == '1'):
count += 1
if(s[0] == '1'):
count += 1
if(s[0] == '1'):
count += 1
print(count)
if __name__ == '__main__':
main()
|
s788163653
|
Accepted
| 17 | 3,060 | 228 |
def main():
s = list(input())
count = 0
if(s[0] == '1'):
count += 1
if(s[1] == '1'):
count += 1
if(s[2] == '1'):
count += 1
print(count)
if __name__ == '__main__':
main()
|
s117478892
|
p03455
|
u296101474
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 25 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
print(input().count('1'))
|
s427714314
|
Accepted
| 17 | 2,940 | 93 |
a, b = map(int, input().split())
if (a*b) % 2 == 0:
print('Even')
else:
print('Odd')
|
s624415036
|
p03455
|
u286491117
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 96 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a,b = map(int,input().split())
if (a*b) % 2 == 0:
print("even")
else:
print("odd")
|
s022094589
|
Accepted
| 17 | 2,940 | 96 |
a,b = map(int,input().split())
if (a*b) % 2 == 0:
print("Even")
else:
print("Odd")
|
s605099335
|
p03546
|
u163783894
| 2,000 | 262,144 |
Wrong Answer
| 182 | 40,708 | 222 |
Joisino the magical girl has decided to turn every single digit that exists on this world into 1. Rewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points). She is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive). You are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows: * If A_{i,j}≠-1, the square contains a digit A_{i,j}. * If A_{i,j}=-1, the square does not contain a digit. Find the minimum total amount of MP required to turn every digit on this wall into 1 in the end.
|
import numpy as np
from scipy.sparse.csgraph import shortest_path
H, W, *t = map(int, open(0).read().split())
c = np.array(t[:100]).reshape((10, 10))
A = np.array(t[100:])
print(np.sum(shortest_path(c)[:, 1][A[A >= 0]]))
|
s282896275
|
Accepted
| 181 | 40,636 | 192 |
from numpy import *
from scipy.sparse.csgraph import *
H,W,*t=map(int,open(0).read().split())
c=array(t[:100]).reshape((10,10))
A=array(t[100:])
print(int(sum(shortest_path(c)[:,1][A[A>=0]])))
|
s432631915
|
p03228
|
u242525751
| 2,000 | 1,048,576 |
Wrong Answer
| 21 | 3,316 | 343 |
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person. Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.
|
a, b, k = map(int, input().split())
turn_a = 1
for i in range(k):
if turn_a == 1:
if a % 2 == 1:
b = b + (a-1)/2
a = (a-1)/2
else:
b = b + a/2
a = a/2
turn_a = 0
else:
if b % 2 == 1:
a = a + (b-1)/2
b = (b-1)/2
else:
a = a + b/2
b = b/2
turn_a = 1
print(a, b)
|
s218579338
|
Accepted
| 22 | 3,316 | 353 |
a, b, k = map(int, input().split())
turn_a = 1
for i in range(k):
if turn_a == 1:
if a % 2 == 1:
b = b + (a-1)/2
a = (a-1)/2
else:
b = b + a/2
a = a/2
turn_a = 0
else:
if b % 2 == 1:
a = a + (b-1)/2
b = (b-1)/2
else:
a = a + b/2
b = b/2
turn_a = 1
print(int(a), int(b))
|
s317971768
|
p03574
|
u196675341
| 2,000 | 262,144 |
Wrong Answer
| 33 | 3,700 | 693 |
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
|
h,w = map(int,input().strip().split(' '))
data = [input() for i in range(h)]
for i in range(h):
data[i] = list(data[i])
dxy =[(-1,0),(-1,-1),(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,1)]
ans = [[ 0 for i in range(w)] for j in range(h)]
print(data)
for x in range(h):
for y in range(w):
print(x, y)
if data[x][y] == '#':
ans[x][y] = '#'
continue
c = 0
for dx, dy in dxy:
if x+dx < 0 or x+dx > h-1 or y+dy < 0 or y+dy > w-1:
continue
if data[x+dx][y+dy] == '#':
c += 1
ans[x][y] = c
for row in ans:
print(''.join(list(map(str,row))))
|
s453784228
|
Accepted
| 31 | 3,064 | 661 |
h,w = map(int,input().strip().split(' '))
data = [input() for i in range(h)]
for i in range(h):
data[i] = list(data[i])
dxy =[(-1,0),(-1,-1),(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,1)]
ans = [[ 0 for i in range(w)] for j in range(h)]
for x in range(h):
for y in range(w):
if data[x][y] == '#':
ans[x][y] = '#'
continue
c = 0
for dx, dy in dxy:
if x+dx < 0 or x+dx > h-1 or y+dy < 0 or y+dy > w-1:
continue
if data[x+dx][y+dy] == '#':
c += 1
ans[x][y] = c
for row in ans:
print(''.join(list(map(str,row))))
|
s712703713
|
p02413
|
u745846646
| 1,000 | 131,072 |
Wrong Answer
| 20 | 6,720 | 460 |
Your task is to perform a simple table calculation. Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.
|
(r, c) = [int(i) for i in input().split()]
table = []
for rc in range(r):
table.append([int(i) for i in input().split()])
table.append([0 for _ in range(c + 1)])
for rc in range(r):
row_total = 0
for cc in range(c):
table[r][cc] += table[rc][cc]
row_total = table[rc][cc]
table[rc].append(row_total)
table[rc][c] += row_total
for row in table:
for column in row:
print(column, end=' ')
print()
|
s556199452
|
Accepted
| 20 | 7,852 | 366 |
rc = [int(i) for i in input().split()]
data = []
for i in range(rc[0]):
sum_c = [int(i) for i in input().split()]
sum_c.append(sum(sum_c))
data += [sum_c]
print(" ".join(map(str,sum_c)))
hoge = [[row[i] for row in data] for i in range(rc[1])]
sum_r = [sum(hoge[i]) for i in range(rc[1])]
sum_r.append(sum(sum_r))
print(" ".join(map(str,sum_r)))
|
s788309363
|
p03761
|
u239342230
| 2,000 | 262,144 |
Wrong Answer
| 23 | 3,316 | 347 |
Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains. Find the longest string that can be created regardless of which string among S_1,...,S_n the headline contains. If there are multiple such strings, find the lexicographically smallest one among them.
|
from collections import Counter
n=int(input())
S=[input() for _ in range(n)]
base=sorted(set(''.join(S)))
arr=[10**7]*len(base)
dic=dict(zip(base,arr))
for i in range(n):
s=Counter(S[i])
for k in dic.keys():
dic[k]=min(dic[k],s[k])
if sum(dic.values())==0:
print("")
else:
for x,y in dic.items():
print(x*y,end="")
|
s131090722
|
Accepted
| 22 | 3,316 | 234 |
from collections import Counter
n=int(input())
S=[Counter(input()) for _ in range(n)]
s=S[0]
for i in range(n):
for k,v in s.items():
s[k]=min(S[i][k],s[k])
s=sorted(s.items())
ans=''
for k,v in s:
ans+=k*v
print(ans)
|
s899269022
|
p02255
|
u227438830
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,604 | 234 |
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 = [int(i) for i in input().split()]
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(" ".join(map(str, A)))
|
s913035679
|
Accepted
| 20 | 7,748 | 261 |
N = int(input())
A = [int(i) for i in input().split()]
for i in range(1, N):
print(" ".join(map(str, A)))
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(" ".join(map(str, A)))
|
s399673499
|
p02612
|
u729272006
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 9,132 | 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.
|
a = input()
a = int(a)
print(1000 - a)
|
s748226825
|
Accepted
| 25 | 9,152 | 125 |
a = input()
a = int(a)
b = a
cnt = 0
while True:
b -= 1000
cnt +=1
if b <= 0:
break
print(cnt*1000 - a)
|
s621854007
|
p02608
|
u966207392
| 2,000 | 1,048,576 |
Wrong Answer
| 2,206 | 8,992 | 327 |
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
import math
N = int(input())
for i in range(1, N+1):
cnt = 0
if i < 6:
print(0)
for x in range(1, int(math.sqrt(i))):
for y in range(1, int(math.sqrt(i))):
for z in range(1, int(math.sqrt(i))):
if ((x+y+z)**2)-x*y-y*z-z*x == i:
cnt += 1
print(cnt)
|
s128687756
|
Accepted
| 825 | 9,256 | 301 |
N = int(input())
lis = [0]*N
for x in range(1, 100):
for y in range(1, 100):
for z in range(1, 100):
ans = x**2 + y**2 + z**2 + x*y + y*z + z*x -1
if ans >= N:
pass
else:
lis[ans] += 1
for i in range(N):
print(lis[i])
|
s082510413
|
p00015
|
u197615397
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,748 | 418 |
A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647. Your task is to write a program which reads two integers (more than or equal to zero), and prints a sum of these integers. If given integers or the sum have more than 80 digits, print "overflow".
|
N = int(input())
import re
for _ in [0]*N:
a = tuple(map(int, input().zfill(100)))
b = tuple(map(int, input().zfill(100)))
result = []
prev = 0
for i in range(1, 80):
n = int(a[-i]) + int(b[-i]) + prev
result.append(n%10)
prev = n // 10
if a[-81] + b[-81] + prev > 0:
print("overflow")
else:
print(re.sub(r"^0+", "", "".join(map(str, result[::-1]))))
|
s107341087
|
Accepted
| 30 | 7,868 | 410 |
N = int(input())
import re
for _ in [0]*N:
a = input().zfill(100)
b = input().zfill(100)
result = []
prev = 0
for i in range(1, 81):
n = int(a[-i]) + int(b[-i]) + prev
result.append(n%10)
prev = n // 10
if prev > 0 or int(a[:-80]) + int(b[:-80]) > 0:
print("overflow")
else:
result = "".join(map(str, result[::-1]))
print(int(result))
|
s311772218
|
p03672
|
u239342230
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 180 |
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
|
S=input()
N=len(S)-1
for i in range(0,N):
s=S[0:N-i]
print(s)
n=len(s)
if n%2==0:
if s[0:int(n/2)]==s[int(n/2):n]:
print(N-i)
exit()
|
s173326425
|
Accepted
| 18 | 2,940 | 171 |
S=input()
N=len(S)-1
i=0
while(True):
s=S[0:N-i]
n=len(s)
if n%2==0:
if s[0:int(n/2)]==s[int(n/2):n]:
print(N-i)
break
i+=1
|
s470761099
|
p03485
|
u597374218
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 45 |
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a,b=map(int,input().split())
print(-~(a+b)/2)
|
s319991661
|
Accepted
| 25 | 9,156 | 66 |
import math
a,b=map(int,input().split())
print(math.ceil((a+b)/2))
|
s387339330
|
p04030
|
u610232844
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,060 | 199 |
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
|
s = list(map(str,input().split()))
l = []
for i in s:
if i == '0':
l.append(i)
elif i == '1':
l.append(i)
elif i == 'B' and len(l) != 0:
l.pop(-1)
print(''.join(l))
|
s063412665
|
Accepted
| 18 | 3,064 | 192 |
s = list(map(str,input()))
l = []
for i in s:
if i == '0':
l.append(i)
elif i == '1':
l.append(i)
elif i == 'B' and len(l) != 0:
l.pop(-1)
print(''.join(l))
|
s406418573
|
p03110
|
u016393440
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,064 | 368 |
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?
|
a = int(input())
i = 0
b = []
for i in range(a):
b.append(input().split())
print(b)
money_bit_all = 0
money_all = 0
for i in range(a):
money_bit = 0
if 'BTC' in b[i]:
money_bit = 380000.0 * float(b[i][0])
money_bit_all = money_bit_all + money_bit
else:
money_all = money_all + float(b[i][0])
print(money_all + money_bit_all)
|
s707078223
|
Accepted
| 19 | 3,064 | 359 |
a = int(input())
i = 0
b = []
for i in range(a):
b.append(input().split())
money_bit_all = 0
money_all = 0
for i in range(a):
money_bit = 0
if 'BTC' in b[i]:
money_bit = 380000.0 * float(b[i][0])
money_bit_all = money_bit_all + money_bit
else:
money_all = money_all + float(b[i][0])
print(money_all + money_bit_all)
|
s342760274
|
p03407
|
u631277801
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,316 | 495 |
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
a,b,c = li()
if a+b <= c:
print("Yes")
else:
print("No")
|
s120360777
|
Accepted
| 18 | 3,064 | 495 |
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
a,b,c = li()
if a+b >= c:
print("Yes")
else:
print("No")
|
s995927371
|
p03836
|
u827874033
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,064 | 468 |
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
sx,sy,tx,ty = list(map(int, input().split()))
result = ""
dy = ty-sy
dx = tx-sx
for i in range(dy):
result += "U"
for i in range(dx):
result += "R"
for i in range(dy+1):
result += "D"
for i in range(dx):
result += "L"
result += "L"
for i in range(dy+1):
result += "U"
for i in range(dx+1):
result += "R"
result += "D"
result += "R"
for i in range(dy+1):
result += "D"
for i in range(dx+1):
result += "L"
result += "U"
print(result)
|
s700379059
|
Accepted
| 19 | 3,064 | 466 |
sx,sy,tx,ty = list(map(int, input().split()))
result = ""
dy = ty-sy
dx = tx-sx
for i in range(dy):
result += "U"
for i in range(dx):
result += "R"
for i in range(dy):
result += "D"
for i in range(dx):
result += "L"
result += "L"
for i in range(dy+1):
result += "U"
for i in range(dx+1):
result += "R"
result += "D"
result += "R"
for i in range(dy+1):
result += "D"
for i in range(dx+1):
result += "L"
result += "U"
print(result)
|
s676346491
|
p03067
|
u742385708
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 111 |
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
|
N = list(map(int, input().split()))
if (N[0] > N[2]) and (N[1] < N[2]):
print("Yes")
else:
print("No")
|
s173497869
|
Accepted
| 17 | 3,060 | 150 |
N = list(map(int, input().split()))
if ((N[0] > N[2]) and (N[1] < N[2])) or ((N[0] < N[2]) and (N[1] > N[2])):
print("Yes")
else:
print("No")
|
s660122274
|
p03610
|
u795733769
| 2,000 | 262,144 |
Wrong Answer
| 25 | 8,936 | 124 |
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
|
s = list(input().split())
ans = []
for i in range(len(s)):
if i % 2 == 0:
ans.append(s[i])
print(''.join(ans))
|
s166561600
|
Accepted
| 37 | 9,804 | 116 |
s = list(input())
ans = []
for i in range(len(s)):
if i % 2 == 0:
ans.append(s[i])
print(''.join(ans))
|
s094610412
|
p02796
|
u216015528
| 2,000 | 1,048,576 |
Wrong Answer
| 217 | 40,988 | 387 |
In a factory, there are N robots placed on a number line. Robot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative. We want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect. Here, for each i (1 \leq i \leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints. Find the maximum number of robots that we can keep.
|
def main():
import sys
readline = sys.stdin.readline
N = int(readline())
XL = [list(map(int, readline().split())) for _ in [0] * N]
arm = [(x + length, x + length) for x, length in XL]
arm.sort()
time, ans = 0, 0
for i in range(N):
end, start = arm[i]
if time <= start:
ans += 1
time = end
print(ans)
main()
|
s118059754
|
Accepted
| 239 | 40,996 | 1,178 |
def resolve():
import sys
readline = sys.stdin.readline
N = int(readline())
XL = [list(map(int, readline().split())) for _ in [0] * N]
t = [(x + length, x - length) for x, length in XL]
t.sort()
time = -float('inf')
ans = 0
for i in range(N):
end, start = t[i]
if time <= start:
ans += 1
time = end
print(ans)
if __name__ == "__main__":
resolve()
|
s803367770
|
p02401
|
u580227385
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,552 | 77 |
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 1:
n = input()
if "?" in n:
break
print(eval(n))
|
s744376711
|
Accepted
| 20 | 5,552 | 80 |
while 1:
n = input()
if "?" in n:
break
print(int(eval(n)))
|
s017000593
|
p00002
|
u748033250
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,648 | 62 |
Write a program which computes the digit number of sum of two integers a and b.
|
a, b = map(int, input().split())
c = a+b
print( len(str(c)) )
|
s989193433
|
Accepted
| 30 | 7,524 | 101 |
while (1):
try:
a, b = map(int, input().split())
except:
break
c = a+b
print( len(str(c)) )
|
s178650863
|
p04029
|
u535659144
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 33 |
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
x = int(input())
print(x*(x+1)/2)
|
s255246630
|
Accepted
| 18 | 2,940 | 38 |
x = int(input())
print(int(x*(x+1)/2))
|
s718257456
|
p03457
|
u586564705
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 151 |
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())
for i in range(N):
t,x,y = map(int,input().split())
if (x + y) > t or (x + y + t)%2 != 2:
print("NO")
exit()
print("YES")
|
s162003951
|
Accepted
| 329 | 3,060 | 150 |
N = int(input())
for i in range(N):
t,x,y = map(int,input().split())
if (x + y) > t or (x + y + t)%2 != 0:
print("No")
exit()
print("Yes")
|
s680869818
|
p03455
|
u356499208
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 74 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
def judge():
if a*b % 2 == 0:
return 'Even'
else:
return 'Odd'
|
s969720088
|
Accepted
| 17 | 2,940 | 88 |
a, b = map(int, input().split())
if a*b % 2 == 0:
print('Even')
else:
print('Odd')
|
s043068698
|
p03583
|
u810735437
| 2,000 | 262,144 |
Wrong Answer
| 233 | 5,804 | 791 |
You are given an integer N. Find a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w. If there are multiple solutions, any of them will be accepted.
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import re
import string
N = int(input())
def get_a(N):
a = 1
while True:
if N < 4 * a:
return a, 4*a-N, N*a
a += 1
def get_b(N1, N2):
b = 1
while True:
if N2 < b * N1:
return b, b*N1-N2, b*N2
b += 1
def gcd(a, b):
while b:
a, b = b, a % b
return a
def solve(N):
a, N1, N2 = get_a(N)
print("a,N1,N2 = ", a, N1, N2)
b, N1, N2 = get_b(N1, N2)
print("b,N1,N2 = ", b, N1, N2)
g = gcd(N1,N2)
N1 //= g
N2 //= g
print(a, b, N2)
for N in range(1, 100):
solve(N)
solve(N)
|
s321387889
|
Accepted
| 369 | 5,408 | 606 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import re
import string
N = int(input())
def gcd(a, b):
while b:
a, b = b, a % b
return a
def solve(N):
for a in range(1, 3501):
N1 = 4*a - N
N2 = N * a
if N1 < 0: continue
for b in range(1, 3501):
N3 = b * N1 - N2
N4 = b * N2
if N4 > 0 and N3 > 0 and N4 % N3 == 0:
print(a, b, N4//N3)
return
solve(N)
|
s502780277
|
p03089
|
u169696482
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 181 |
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
|
n = int(input())
B = list(map(int, input().split()))
flag = False
for i in range(n):
if B[i]+1 > i:
flag = True
if flag:
print(-1)
else:
for j in range(n):
print(B[j])
|
s379200780
|
Accepted
| 18 | 3,064 | 407 |
n = int(input())
B = list(map(int, input().split()))
A = []
C = []
flag = True
j = 0
if max(B) > n:
flag = False
if flag:
while j < n:
A = []
for i in range(n-j):
if B[i] == i+1:
A.append(i+1)
if A ==[]:
flag = False
break
else:
C.append(B[max(A)-1])
del B[max(A)-1]
j += 1
if flag:
for k in range(1, n+1):
print(C[-k])
else:
print(-1)
|
s507949972
|
p00013
|
u463990569
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,564 | 228 |
This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top- right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. We can simulate the movement (comings and goings) of the cars as follow: * An entry of a car is represented by its number. * An exit of a car is represented by 0 For example, a sequence 1 6 0 8 10 demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks.
|
garage = []
cars = []
while True:
num = int(input())
if num == 0:
cars.append(garage.pop())
else:
garage.append(num)
print(garage)
if not garage:
break
[print(car) for car in cars]
|
s230114530
|
Accepted
| 20 | 7,608 | 167 |
garage = []
while True:
try:
car = int(input())
except:
break
if car == 0:
print(garage.pop())
else:
garage.append(car)
|
s747533809
|
p03478
|
u825528847
| 2,000 | 262,144 |
Wrong Answer
| 40 | 3,412 | 123 |
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())
for i in range(1, N+1):
if A <= sum(int(x) for x in str(i)) <= B:
print(i)
|
s435035717
|
Accepted
| 33 | 3,064 | 142 |
N, A, B = map(int, input().split())
cnt = 0
for i in range(1, N+1):
if A <= sum(int(x) for x in str(i)) <= B:
cnt += i
print(cnt)
|
s580472003
|
p03679
|
u970809473
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 125 |
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.
|
a,b,c = map(int, input().split())
if c >= b:
print('delicious')
elif c - b <= a:
print('safe')
else:
print('dangerous')
|
s372456256
|
Accepted
| 17 | 2,940 | 126 |
a,b,c = map(int, input().split())
if b >= c:
print('delicious')
elif c - b <= a:
print('safe')
else:
print('dangerous')
|
s553651139
|
p03740
|
u497952650
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 73 |
Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally.
|
X,Y = map(int,input().split())
print("Alice" if abs(X-Y)>=1 else "Bob")
|
s756333487
|
Accepted
| 17 | 2,940 | 77 |
X,Y = map(int,input().split())
print("Brown" if abs(X-Y) <= 1 else "Alice")
|
s872654002
|
p02614
|
u350093546
| 1,000 | 1,048,576 |
Wrong Answer
| 52 | 9,136 | 439 |
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
|
import itertools
h,w,k=map(int,input().split())
lst=[list(input()) for i in range(h)]
lst2=[lst[i] for i in range(h)]
pin=0
for i in range(h):
pin+=lst[i].count('#')
ans=0
for hei in itertools.product(range(2),repeat=h):
for wid in itertools.product(range(2),repeat=w):
cnt=0
for i in range(h):
for j in range(w):
if hei[i]==1 and wid[j]==1 and lst[i][j]=="#":
cnt+=1
if cnt==k:
ans+=1
|
s804884750
|
Accepted
| 53 | 9,048 | 456 |
import itertools
h,w,k=map(int,input().split())
lst=[list(input()) for i in range(h)]
lst2=[lst[i] for i in range(h)]
pin=0
for i in range(h):
pin+=lst[i].count('#')
ans=0
for hei in itertools.product(range(2),repeat=h):
for wid in itertools.product(range(2),repeat=w):
cnt=0
for i in range(h):
for j in range(w):
if hei[i]==1 and wid[j]==1 and lst[i][j]=="#":
cnt+=1
if cnt==k:
ans+=1
print(ans)
|
s907264777
|
p02842
|
u282813849
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,080 | 136 |
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
|
x = int(input())
b = x//1.08
x1 = int(b*1.08)
x2 = int((b+1)*1.08)
if x1 == x:
print(b)
elif x2 == x:
print(b+1)
else:
print(-1)
|
s093944639
|
Accepted
| 28 | 9,160 | 142 |
x = int(input())
b = int(x/1.08)
x1 = int(b*1.08)
x2 = int((b+1)*1.08)
if x1 == x:
print(b)
elif x2 == x:
print(b+1)
else:
print(":(")
|
s994623067
|
p02390
|
u359372421
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,580 | 91 |
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
|
x = int(input())
s = x % 60
x //= 60
m = x % 60
m //= 60
print("{}:{}:{}".format(x, m, s))
|
s500590808
|
Accepted
| 20 | 5,584 | 91 |
x = int(input())
s = x % 60
x //= 60
m = x % 60
x //= 60
print("{}:{}:{}".format(x, m, s))
|
s278085208
|
p03796
|
u878138257
| 2,000 | 262,144 |
Wrong Answer
| 52 | 2,940 | 75 |
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())
k = 1
for i in range(1,n+1):
k = k**i
print(k%(10**9+7))
|
s004575840
|
Accepted
| 36 | 2,940 | 75 |
n = int(input())
k = 1
for i in range(1,n+1):
k = k*i%(10**9+7)
print(k)
|
s202192605
|
p03563
|
u215315599
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,064 | 651 |
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
|
import sys
S = input()
T = input()
cnt = 0
i = 0
j = 0
while j < len(S):
if T[-i] == S[-j] or S[-j] == "?":
i += 1
cnt += 1
else:
i, cnt = 0, 0
j += 1
if i == len(T) and (T[-i] == S[-j] or S[-j] == "?"):
l = 0
for l in range(len(S)):
if S[l] == "?" and (l <= len(S)-j-1 or len(S)-j-1+len(T) < l):
print("a",end="")
elif S[l] == "?":
print(T[-cnt+1],end="")
cnt -= 1
else:
print(S[l],end="")
print()
sys.exit()
print("UNRESTORABLE")
|
s148685840
|
Accepted
| 17 | 2,940 | 46 |
R = int(input())
G = int(input())
print(2*G-R)
|
s963258038
|
p02396
|
u656368260
| 1,000 | 131,072 |
Wrong Answer
| 130 | 7,548 | 94 |
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
|
while True:
a=int(input())
if a == 0:
break
print("Case 1: {0}".format(a))
|
s068874101
|
Accepted
| 140 | 7,476 | 112 |
i=1
while True:
a=int(input())
if a == 0:
break
print("Case {0}: {1}".format(i,a))
i=i+1
|
s132276031
|
p00015
|
u553148578
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,588 | 145 |
A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647. Your task is to write a program which reads two integers (more than or equal to zero), and prints a sum of these integers. If given integers or the sum have more than 80 digits, print "overflow".
|
n = int(input())
for i in range(n):
x = int(input())
y = int(input())
ans = x + y
if(ans <= 10**80):
print(ans)
else:
print("overflow")
|
s346899812
|
Accepted
| 20 | 5,592 | 144 |
n = int(input())
for i in range(n):
x = int(input())
y = int(input())
ans = x + y
if(ans < 10**80):
print(ans)
else:
print("overflow")
|
s406152127
|
p03698
|
u238940874
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 74 |
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
s=input()
if len(s) == len(set(s)):
print('Yes')
else:
print('No')
|
s970119278
|
Accepted
| 17 | 2,940 | 74 |
s=input()
if len(s) == len(set(s)):
print('yes')
else:
print('no')
|
s576730326
|
p02612
|
u233932118
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,084 | 34 |
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)
|
s992895918
|
Accepted
| 27 | 9,068 | 65 |
n=int(input())
c=n%1000
if c==0:
print(0)
else:
print(1000-c)
|
s178727641
|
p04031
|
u201234972
| 2,000 | 262,144 |
Wrong Answer
| 22 | 3,060 | 200 |
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective.
|
N = int( input())
A = list( map( int, input().split()))
ans = 10**6
for i in range(N):
a = A[i]
cost = 0
for j in range(N):
cost += (A[j]-a)**2
ans = min( ans, cost)
print(ans)
|
s961908747
|
Accepted
| 26 | 2,940 | 196 |
N = int( input())
A = list( map( int, input().split()))
ans = 10**6
for a in range(-100, 101):
cost = 0
for j in range(N):
cost += (A[j]-a)**2
ans = min( ans, cost)
print(ans)
|
s803471691
|
p03671
|
u368796742
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 57 |
Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
|
l = list(map(int,input().split()))
print(sum(l)-2*max(l))
|
s890991092
|
Accepted
| 17 | 2,940 | 56 |
l = list(map(int,input().split()))
print(sum(l)-max(l))
|
s817634350
|
p03672
|
u190405389
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 181 |
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
|
s = input()
if len(s) % 2 != 0:
s = s[:len(s)-1]
for i in range(len(s)//2):
if s[:len(s)//2-i] == s[len(s)//2-i:len(s)-2*i]:
print(s[:len(s)//2-i])
exit()
|
s046794598
|
Accepted
| 17 | 2,940 | 203 |
s = input()
if len(s) % 2 != 0:
s = s[:len(s)-1]
else:
s = s[:len(s)-2]
for i in range(len(s)//2):
if s[:len(s)//2-i] == s[len(s)//2-i:len(s)-2*i]:
print(len(s)-2*i)
exit()
|
s926195461
|
p02412
|
u299798926
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,724 | 303 |
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
|
while 1 :
n,x=[int(i) for i in input().split()]
count=0
if n==x==0:
break
for i in range(1,n+1):
for j in range(i+1,n+1):
for k in range(j+1,n+1):
if i+j+k==x:
print(i,j,k)
count=count+1
print(count)
|
s248087317
|
Accepted
| 540 | 7,632 | 270 |
while 1 :
n,x=[int(i) for i in input().split()]
count=0
if n==x==0:
break
for i in range(1,n+1):
for j in range(i+1,n+1):
for k in range(j+1,n+1):
if i+j+k==x:
count=count+1
print(count)
|
s222599923
|
p03472
|
u189575640
| 2,000 | 262,144 |
Wrong Answer
| 489 | 21,992 | 458 |
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times. * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana. The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?
|
from sys import exit
from math import floor
N,H = [int(n) for n in input().split()]
ab = [(0,0)]*N
maxa = 0
ans = 0
for i in range(N):
ab[i] = tuple(int(n) for n in input().split())
maxa = max(maxa, ab[i][0])
ab = sorted(ab,key= lambda x:-x[1])
for katana in ab:
if katana[1] > maxa:
H-=katana[1]
ans+=1
if(H<=0): break
else:
break
if(H<=0):
print(ans)
else:
print(ans + floor(H/maxa))
|
s812452372
|
Accepted
| 509 | 21,992 | 456 |
from sys import exit
from math import ceil
N,H = [int(n) for n in input().split()]
ab = [(0,0)]*N
maxa = 0
ans = 0
for i in range(N):
ab[i] = tuple(int(n) for n in input().split())
maxa = max(maxa, ab[i][0])
ab = sorted(ab,key= lambda x:-x[1])
for katana in ab:
if katana[1] > maxa:
H-=katana[1]
ans+=1
if(H<=0): break
else:
break
if(H<=0):
print(ans)
else:
print(ans + ceil(H/maxa))
|
s165265643
|
p03795
|
u306142032
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 60 |
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
n = int(input())
x = 800*n
y = 800 * (n // 15)
print(x-y)
|
s180477763
|
Accepted
| 17 | 2,940 | 60 |
n = int(input())
x = 800*n
y = 200 * (n // 15)
print(x-y)
|
s558580870
|
p03449
|
u440061288
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 184 |
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())
a = [[int(i) for i in input().split()] for i in range(2)]
print(a)
ans = 0
for i in range(n):
ans = max(ans,(sum(a[0][0:i+1])+sum(a[1][i:n])))
print(ans)
|
s370692528
|
Accepted
| 18 | 3,060 | 174 |
n = int(input())
a = [[int(i) for i in input().split()] for i in range(2)]
ans = 0
for i in range(n):
ans = max(ans,(sum(a[0][0:i+1])+sum(a[1][i:n])))
print(ans)
|
s072888435
|
p03730
|
u818349438
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 133 |
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
a,b,c = map(int,input().split())
ok = False
for i in range(1,10**4):
if a*i %b == c:ok = True
if ok:print('Yes')
else:print('No')
|
s689773776
|
Accepted
| 19 | 2,940 | 133 |
a,b,c = map(int,input().split())
ok = False
for i in range(1,10**4):
if a*i %b == c:ok = True
if ok:print('YES')
else:print('NO')
|
s334173357
|
p03457
|
u485979475
| 2,000 | 262,144 |
Wrong Answer
| 511 | 21,156 | 436 |
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())
timeline=[[0,0,0]]
for i in range(n):
temp=list(input().rstrip().split())
temp2=[]
for element in temp:
temp2.append(int(element))
timeline.append(temp2)
i=0
flag=True
while i<n and flag:
dif=[timeline[i+1][0]-timeline[i][0],timeline[i+1][1]-timeline[i][1],timeline[i+1][2]-timeline[i][2]]
if dif[0]<dif[1]+dif[2] or (dif[1]+dif[2]-dif[0])%2 ==1 :
flag=False
i+=1
if flag:
print("YES")
else:
print("NO")
|
s867149199
|
Accepted
| 488 | 21,156 | 455 |
n=int(input())
timeline=[[0,0,0]]
for i in range(n):
temp=list(input().rstrip().split())
temp2=[]
for element in temp:
temp2.append(int(element))
timeline.append(temp2)
i=0
flag=True
output="Yes"
while i<n and flag:
dif=[timeline[i+1][0]-timeline[i][0],timeline[i+1][1]-timeline[i][1],timeline[i+1][2]-timeline[i][2]]
if dif[0]<abs(dif[1])+abs(dif[2]) or (dif[0]-abs(dif[1])-abs(dif[2]))%2 ==1 :
flag=False
output="No"
i+=1
print(output)
|
s150123296
|
p03380
|
u599547273
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 14,732 | 523 |
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
|
from bisect import bisect
from math import factorial as f
def combi(n, k):
if n < k:
return 0
return f(n) // f(n-k) // f(k)
N = int(input())
A = list(map(int, input().split()))
A.sort()
max_pair = None
max_num = 0
for a in A[::-1]:
x = bisect(A, a//2)
# print(a, A[x])
if combi(a, A[x]) > max_num:
max_num = combi(a, A[x])
max_pair = (a, A[x])
if x+1 < N and combi(a, A[x+1]) > max_num:
max_num = combi(a, A[x+1])
max_pair = (a, A[x+1])
print(max_pair)
|
s603053995
|
Accepted
| 104 | 14,428 | 140 |
N = int(input())
A = list(map(int, input().split()))
*else_A, max_A = sorted(A)
print(max_A, min(else_A, key=lambda a: abs(max_A/2 - a) ))
|
s211018223
|
p01304
|
u025180675
| 8,000 | 131,072 |
Wrong Answer
| 70 | 5,624 | 1,016 |
平安京は、道が格子状になっている町として知られている。 平安京に住んでいるねこのホクサイは、パトロールのために毎日自宅から町はずれの秘密の場所まで行かなければならない。しかし、毎日同じ道を通るのは飽きるし、後を付けられる危険もあるので、ホクサイはできるだけ毎日異なる経路を使いたい。その一方で、ホクサイは面倒臭がりなので、目的地から遠ざかるような道は通りたくない。 平安京のあちこちの道にはマタタビが落ちていて、ホクサイはマタタビが落ちている道を通ることができない。そのような道を通るとめろめろになってしまうからである。幸いなことに、交差点にはマタタビは落ちていない。 ホクサイは、自宅から秘密の場所までの可能な経路の数を知りたい。ここで、ホクサイの自宅は (0, 0) にあり、秘密の場所は(gx, gy)にある。道は x = i (i は整数), y = j (j は整数) に格子状に敷かれている。
|
L = int(input().strip())
for _ in range(0,L):
gx,gy = map(int,input().strip().split(" "))
heiankyo = [[0 for j in range(0,gx+1)] for i in range(0,gy+1)]
heiankyo[0][0] = 1
P = int(input())
matatabi = []
for p in range(P):
x1,y1,x2,y2 = map(int,input().strip().split(" "))
l = [[x1,y1],[x2,y2]]
l.sort()
matatabi.append(l)
for i in range(1,gy+1):
if not [[i-1,0],[i,0]] in matatabi:
heiankyo[i][0] = heiankyo[i-1][0]
for j in range(1,gx+1):
if not [[0,j-1],[0,j]] in matatabi:
heiankyo[0][j] = heiankyo[0][j-1]
for i in range(1,gy+1):
for j in range(1,gx+1):
if not [[i-1,j],[i,j]] in matatabi:
heiankyo[i][j] = heiankyo[i][j] + heiankyo[i-1][j]
if not [[i,j-1],[i,j]] in matatabi:
heiankyo[i][j] = heiankyo[i][j] + heiankyo[i][j-1]
if heiankyo[gy][gx] == 0:
print("Miserable Hokusai!")
else:
print(heiankyo[gy][gx])
|
s955730726
|
Accepted
| 60 | 5,620 | 1,016 |
L = int(input().strip())
for _ in range(0,L):
gx,gy = map(int,input().strip().split(" "))
heiankyo = [[0 for j in range(0,gx+1)] for i in range(0,gy+1)]
heiankyo[0][0] = 1
P = int(input())
matatabi = []
for p in range(P):
x1,y1,x2,y2 = map(int,input().strip().split(" "))
l = [[y1,x1],[y2,x2]]
l.sort()
matatabi.append(l)
for i in range(1,gy+1):
if not [[i-1,0],[i,0]] in matatabi:
heiankyo[i][0] = heiankyo[i-1][0]
for j in range(1,gx+1):
if not [[0,j-1],[0,j]] in matatabi:
heiankyo[0][j] = heiankyo[0][j-1]
for i in range(1,gy+1):
for j in range(1,gx+1):
if not [[i-1,j],[i,j]] in matatabi:
heiankyo[i][j] = heiankyo[i][j] + heiankyo[i-1][j]
if not [[i,j-1],[i,j]] in matatabi:
heiankyo[i][j] = heiankyo[i][j] + heiankyo[i][j-1]
if heiankyo[gy][gx] == 0:
print("Miserable Hokusai!")
else:
print(heiankyo[gy][gx])
|
s435314330
|
p03696
|
u614550445
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,188 | 607 |
You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of `(`, X and `)` in this order is also a correct bracket sequence. * If X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence. * Every correct bracket sequence can be derived from the rules above. Find the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one.
|
from itertools import combinations
from itertools import product
import bisect
import math
N = int(input())
S = input()
l = 0
ans = ''
tmp = ''
for s in S:
if s == '(':
if l >= 0:
tmp += '('
l += 1
elif l < 0:
tmp = '(' * (-l) + tmp
ans += tmp
tmp = '('
l = 1
elif s == ')':
tmp += ')'
l -= 1
if l == 0:
ans += tmp
tmp = ''
print(ans, tmp)
else:
if l > 0:
tmp += ')' * l
elif l < 0:
tmp = '('*(-l) + tmp
ans += tmp
print(ans)
|
s412506032
|
Accepted
| 17 | 2,940 | 144 |
N = int(input())
S = input()
s = S[:]
while '()' in s:
s = s.replace('()', '')
ans = '(' * s.count(')') + S + ')' * s.count('(')
print(ans)
|
s641679542
|
p03494
|
u939702463
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 175 |
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())
array = map(int, input().split())
ans = 999999
for a in array:
cnt = 0
while(a % 2 == 1):
cnt += 1
a = a / 2
ans = min(ans, cnt)
print(ans)
|
s218195567
|
Accepted
| 20 | 2,940 | 175 |
n = int(input())
array = map(int, input().split())
ans = 999999
for a in array:
cnt = 0
while(a % 2 == 0):
cnt += 1
a = a / 2
ans = min(ans, cnt)
print(ans)
|
s211435174
|
p03957
|
u022832318
| 1,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 197 |
This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters. Mr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way. You are given a string s consisting of uppercase English letters. Determine whether the string `CF` can be obtained from the string s by deleting some characters.
|
def main():
s=input()
x = s.find("C")
y = s.find("F")
if x<0 or y<0:
print("No")
return 0
while x<len(s):
if s[x]=="F":
print("YES")
return 0
x+=1
main()
|
s277352600
|
Accepted
| 17 | 3,060 | 215 |
def main():
s=input()
x = s.find("C")
y = s.find("F")
if x<0 or y<0:
print("No")
return 0
while x<len(s):
if s[x]=="F":
print("Yes")
return 0
x+=1
print("No")
main()
|
s930220445
|
p03943
|
u821989875
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 148 |
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
# -*- coding: utf-8 -*-
nums = list(int(i) for i in input().split())
nums.sort()
if nums[2] == nums[1] + nums[0]:
print("YES")
else:
print("NO")
|
s475224004
|
Accepted
| 17 | 2,940 | 148 |
# -*- coding: utf-8 -*-
nums = list(int(i) for i in input().split())
nums.sort()
if nums[2] == nums[1] + nums[0]:
print("Yes")
else:
print("No")
|
s105668125
|
p03854
|
u129492036
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,188 | 159 |
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
S = input()
partstrs = ["eraser", "erase", "dreamer", "dream"]
for s in partstrs:
S = S.replace(s , "")
if S=="":
print("Yes")
else:
print("No")
|
s083763716
|
Accepted
| 21 | 3,188 | 164 |
S = input()
partstrs = ["eraser", "erase", "dreamer", "dream"]
for s in partstrs:
S = S.replace(s , "")
if S=="":
print("YES")
else:
print("NO")
|
s949291132
|
p04044
|
u508405635
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,060 | 122 |
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 = []
for i in range(N):
S.append(input())
S = ''.join(S)
print(''.join(sorted(S)))
|
s269072141
|
Accepted
| 18 | 3,060 | 116 |
N, L = map(int, input().split())
S = []
for i in range(N):
S.append(input())
S.sort
print(''.join(sorted(S)))
|
s379253133
|
p03470
|
u497049044
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 106 |
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
N = int(input())
d = [int(input()) for i in range(N)]
print(list(set(d)))
e = list(set(d))
print(len(e))
|
s793703921
|
Accepted
| 17 | 2,940 | 109 |
N = int(input())
d = [int(input()) for i in range(N)]
# print(list(set(d)))
e = list(set(d))
print(len(e))
|
s750240455
|
p03997
|
u957872856
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 69 |
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)
|
s009531321
|
Accepted
| 17 | 2,940 | 80 |
a = int(input())
b = int(input())
h = int(input())
s = (a+b)*h / 2
print(int(s))
|
s206187914
|
p03470
|
u142211940
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 72 |
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
N = int(input())
arr = [int(input()) for _ in range(N)]
print(set(arr))
|
s517866626
|
Accepted
| 17 | 2,940 | 77 |
N = int(input())
arr = [int(input()) for _ in range(N)]
print(len(set(arr)))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.