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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s713181494
|
p03597
|
u191423660
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 412 |
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
|
N = int(input())
sum = 0
flag = 0
a = int(N / 7)
re = N % 7
if re == 0:
print('Yes')
flag += 1
else:
for i in range(a+1):
sum = 7 * i
# print(sum)
while sum<N:
sum += 4
# print(sum)
if sum == N:
print('Yse')
flag += 1
if flag == 1:
break
if flag == 0:
print('No')
|
s691845926
|
Accepted
| 17 | 2,940 | 213 |
N = int(input())
A = int(input())
ans = (N * N) - A
print(str(ans))
|
s629752751
|
p03048
|
u597622207
| 2,000 | 1,048,576 |
Wrong Answer
| 2,205 | 9,116 | 310 |
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 = map(int, input().split())
count = 0
for r in range(N//R+1):
for g in range(N//G):
n_b = (N - r*R - g*G)
if n_b % B == 0 and n_b >= 0:
count += 1
print(count)
|
s510672965
|
Accepted
| 1,019 | 9,216 | 528 |
R, G, B, N = map(int, input().split())
count = 0
for r in range(N//R+1):
rest = N - r*R
for g in range(rest//G+1):
n_b = (rest - g*G)
if n_b % B == 0 and n_b >= 0:
count += 1
print(count)
|
s562155833
|
p02308
|
u662418022
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,116 | 2,539 |
For given a circle $c$ and a line $l$, print the coordinates of the cross points of them.
|
# -*- coding: utf-8 -*-
import collections
import math
class Vector2(collections.namedtuple("Vector2", ["x", "y"])):
def __add__(self, other):
return Vector2(self.x + other.x, self.y + other.y)
def __sub__(self, other):
return Vector2(self.x - other.x, self.y - other.y)
def __mul__(self, scalar):
return Vector2(self.x * scalar, self.y * scalar)
def __neg__(self):
return Vector2(-self.x, -self.y)
def __pos__(self):
return Vector2(+self.x, +self.y)
def __abs__(self): # norm
return math.sqrt(float(self.x * self.x + self.y * self.y))
def dot(self, other): # dot product
return self.x * other.x + self.y * other.y
def cross(self, other): # cross product
return self.x * other.y - self.y * other.x
def getDistanceSP(segment, point):
p = point
p1, p2 = segment
if (p2 - p1).dot(p - p1) < 0:
return abs(p - p1)
if (p1 - p2).dot(p - p2) < 0:
return abs(p - p2)
return abs((p2 - p1).cross(p - p1)) / abs(p2 - p1)
def getDistance(s1, s2):
a, b = s1
c, d = s2
if intersect(s1, s2): # intersect
return 0
return min(getDistanceSP(s1, c), getDistanceSP(s1, d), getDistanceSP(s2, a), getDistanceSP(s2, b))
def ccw(p0, p1, p2):
a = p1 - p0
b = p2 - p0
if a.cross(b) > 0:
return 1 # COUNTER_CLOCKWISE
elif a.cross(b) < 0:
return -1 # CLOCKWISE
elif a.dot(b) < 0:
return 2 # ONLINE_BACK
elif abs(a) < abs(b):
return -2 # ONLINE_FRONT
else:
return 0 # ON_SEGMENT
def intersect(s1, s2):
a, b = s1
c, d = s2
return ccw(a, b, c) * ccw(a, b, d) <= 0 and ccw(c, d, a) * ccw(c, d, b) <= 0
def project(l, p):
p1, p2 = l
base = p2 - p1
hypo = p - p1
return p1 + base * (hypo.dot(base) / abs(base)**2)
class Circle():
def __init__(self, c, r):
self.c = c
self.r = r
def getCrossPoints(c, l):
pr = project(l, c.c)
p1, p2 = l
e = (p2 - p1) * (1 / abs(p2 - p1))
base = math.sqrt(c.r**2 - abs(pr - c.c)**2)
return [pr + e * base, pr - e * base]
if __name__ == '__main__':
a, b, r = map(int, input().split())
c = Circle(Vector2(a, b), r)
n = int(input())
for _ in range(n):
ps = list(map(int, input().split()))
l = [Vector2(ps[0], ps[1]), Vector2(ps[2], ps[3])]
ans = getCrossPoints(c, l)
ans = sorted(ans, key=lambda x: (x.x, x.y))
print(ans[0].x, ans[0].y, ans[1].x, ans[1].y)
|
s944433383
|
Accepted
| 30 | 6,192 | 2,804 |
# -*- coding: utf-8 -*-
import collections
import math
class Vector2(collections.namedtuple("Vector2", ["x", "y"])):
def __add__(self, other):
return Vector2(self.x + other.x, self.y + other.y)
def __sub__(self, other):
return Vector2(self.x - other.x, self.y - other.y)
def __mul__(self, scalar):
return Vector2(self.x * scalar, self.y * scalar)
def __neg__(self):
return Vector2(-self.x, -self.y)
def __pos__(self):
return Vector2(+self.x, +self.y)
def __abs__(self): # norm
return math.sqrt(float(self.x * self.x + self.y * self.y))
def __truediv__(self, scalar):
return Vector2(self.x/scalar, self.y/scalar)
def abs2(self):
return float(self.x * self.x + self.y * self.y)
def dot(self, other): # dot product
return self.x * other.x + self.y * other.y
def cross(self, other): # cross product
return self.x * other.y - self.y * other.x
def getDistanceSP(segment, point):
p = point
p1, p2 = segment
if (p2 - p1).dot(p - p1) < 0:
return abs(p - p1)
if (p1 - p2).dot(p - p2) < 0:
return abs(p - p2)
return abs((p2 - p1).cross(p - p1)) / abs(p2 - p1)
def getDistance(s1, s2):
a, b = s1
c, d = s2
if intersect(s1, s2): # intersect
return 0
return min(getDistanceSP(s1, c), getDistanceSP(s1, d), getDistanceSP(s2, a), getDistanceSP(s2, b))
def ccw(p0, p1, p2):
a = p1 - p0
b = p2 - p0
if a.cross(b) > 0:
return 1 # COUNTER_CLOCKWISE
elif a.cross(b) < 0:
return -1 # CLOCKWISE
elif a.dot(b) < 0:
return 2 # ONLINE_BACK
elif abs(a) < abs(b):
return -2 # ONLINE_FRONT
else:
return 0 # ON_SEGMENT
def intersect(s1, s2):
a, b = s1
c, d = s2
return ccw(a, b, c) * ccw(a, b, d) <= 0 and ccw(c, d, a) * ccw(c, d, b) <= 0
def project(l, p):
p1, p2 = l
base = p2 - p1
hypo = p - p1
return p1 + base * (hypo.dot(base) / abs(base)**2)
class Circle():
def __init__(self, c, r):
self.c = c
self.r = r
def getCrossPoints(c, l):
pr = project(l, c.c)
p1, p2 = l
e = (p2 - p1) / abs(p2 - p1)
base = math.sqrt(c.r*c.r - (pr - c.c).abs2())
return [pr + e * base, pr - e * base]
if __name__ == '__main__':
a, b, r = map(int, input().split())
c = Circle(Vector2(a, b), r)
n = int(input())
res = []
for _ in range(n):
ps = list(map(int, input().split()))
l = [Vector2(ps[0], ps[1]), Vector2(ps[2], ps[3])]
ans = getCrossPoints(c, l)
ans = sorted(ans, key=lambda x: (x.x, x.y))
res.append(ans)
for ans in res:
print("{:.8f} {:.8f} {:.8f} {:.8f}".format(ans[0].x, ans[0].y, ans[1].x, ans[1].y))
|
s317448122
|
p03759
|
u449998745
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 96 |
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
a,b,c=map(int,input().split())
print(a,b,c)
if b-a==c-b:
print("YES")
else:
print("NO")
|
s053705803
|
Accepted
| 17 | 2,940 | 82 |
a,b,c=map(int,input().split())
if b-a==c-b:
print("YES")
else:
print("NO")
|
s083812808
|
p03854
|
u568789901
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,188 | 146 |
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`.
|
words=["eraser","erase","dreanmer","dream"]
S=input()
for i in range(4):
S=S.strip(words[i])
if S=="":
print("Yes")
else:
print("No")
|
s457666843
|
Accepted
| 19 | 3,188 | 162 |
words=["eraser","erase","dreamer","dream"]
S=input()
for i in range(0,4):
S=S.replace(words[i],"",len(S)//4)
if S=="":
print("YES")
else:
print("NO")
|
s066374176
|
p02420
|
u656153606
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,556 | 226 |
Your task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck. The deck of cards is represented by a string as follows. abcdeefab The first character and the last character correspond to the card located at the bottom of the deck and the card on the top of the deck respectively. For example, a shuffle with h = 4 to the above deck, moves the first 4 characters "abcd" to the end of the remaining characters "eefab", and generates the following deck: eefababcd You can repeat such shuffle operations. Write a program which reads a deck (a string) and a sequence of h, and prints the final state (a string).
|
while True:
cards = input()
if cards == "-":
break
m = int(input())
for i in range(m):
h = int(input())
for j in range(h):
cards = cards[h:] + cards[:h]
print(cards)
|
s248344657
|
Accepted
| 20 | 7,656 | 190 |
while True:
cards = input()
if cards == "-":
break
m = int(input())
for i in range(m):
h = int(input())
cards = cards[h:] + cards[:h]
print(cards)
|
s968352359
|
p03448
|
u967822229
| 2,000 | 262,144 |
Wrong Answer
| 49 | 3,060 | 209 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
A, B, C, X = [int(input()) for i in range(4)]
ans = 0
for i in range(0, A):
for j in range(0, B):
for k in range(0, C):
if (i*500 + j*100 + k*50)==X:
ans+=1
print(ans)
|
s927581669
|
Accepted
| 50 | 3,060 | 215 |
A, B, C, X = [int(input()) for i in range(4)]
ans = 0
for i in range(0, A+1):
for j in range(0, B+1):
for k in range(0, C+1):
if (i*500 + j*100 + k*50)==X:
ans+=1
print(ans)
|
s986611383
|
p03644
|
u633914031
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 48 |
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())
n=0
while N>2**n:
n+=1
print(n)
|
s851559396
|
Accepted
| 17 | 2,940 | 56 |
N=int(input())
n=0
while N>=2**n:
n+=1
print(2**(n-1))
|
s270499282
|
p03545
|
u099300899
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 420 |
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
# -*- coding: utf-8 -*-
num = [int(i) for i in input()]
print(num)
for s in range(2**3):
total = num[0]
op = [""] * 3
for i in range(3):
if (s >> i & 1):
total += num[i+1]
op[i] = "+"
else:
total -= num[i+1]
op[i] = "-"
if (total == 7):
print("{}{}{}{}{}{}{}=7".format(num[0],op[0],num[1],op[1],num[2],op[2],num[3]))
break
|
s300419589
|
Accepted
| 18 | 3,064 | 410 |
# -*- coding: utf-8 -*-
num = [int(i) for i in input()]
for s in range(2**3):
total = num[0]
op = [""] * 3
for i in range(3):
if (s >> i & 1):
total += num[i+1]
op[i] = "+"
else:
total -= num[i+1]
op[i] = "-"
if (total == 7):
print("{}{}{}{}{}{}{}=7".format(num[0],op[0],num[1],op[1],num[2],op[2],num[3]))
break
|
s692514980
|
p03730
|
u468431843
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 146 |
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`.
|
# -*- coding: utf-8 -*- #
a, b, c = map(int, input().split())
ans = "No"
for i in range(b):
if (a*i)%b == c:
ans = "Yes"
print(ans)
|
s290389115
|
Accepted
| 17 | 2,940 | 146 |
# -*- coding: utf-8 -*- #
a, b, c = map(int, input().split())
ans = "NO"
for i in range(b):
if (a*i)%b == c:
ans = "YES"
print(ans)
|
s091792177
|
p02614
|
u559126797
| 1,000 | 1,048,576 |
Wrong Answer
| 50 | 9,324 | 444 |
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 copy
H, W, K = map(int, input().split())
C = [list(input()) for _ in range(H)]
ans = 0
for i in range(1<<H):
D = copy.deepcopy(C)
for h in range(H):
if (i>>h & 1):
for l in range(W):
D[h][l] = '.'
print(D)
print()
for j in range(1<<W):
k = 0
for w in range(W):
if not (j>>w & 1):
for m in range(H):
if D[m][w] == '#':
k += 1
if k == K:
ans += 1
print(ans)
|
s171003979
|
Accepted
| 45 | 9,356 | 423 |
import copy
H, W, K = map(int, input().split())
C = [list(input()) for _ in range(H)]
ans = 0
for i in range(1<<H):
D = copy.deepcopy(C)
for h in range(H):
if (i>>h & 1):
for l in range(W):
D[h][l] = '.'
for j in range(1<<W):
k = 0
for w in range(W):
if not (j>>w & 1):
for m in range(H):
if D[m][w] == '#':
k += 1
if k == K:
ans += 1
print(ans)
|
s391323173
|
p02612
|
u896451538
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,148 | 31 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input())
print(n%1000)
|
s775601836
|
Accepted
| 31 | 9,148 | 75 |
n = int(input())
if n%1000==0:
print(0)
else:
print(1000-(n%1000))
|
s395618316
|
p03475
|
u903959844
| 3,000 | 262,144 |
Wrong Answer
| 3,156 | 3,064 | 439 |
A railroad running from west to east in Atcoder Kingdom is now complete. There are N stations on the railroad, numbered 1 through N from west to east. Tomorrow, the opening ceremony of the railroad will take place. On this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i to Station i+1 in C_i seconds. No other trains will be operated. The first train from Station i to Station i+1 will depart Station i S_i seconds after the ceremony begins. Thereafter, there will be a train that departs Station i every F_i seconds. Here, it is guaranteed that F_i divides S_i. That is, for each Time t satisfying S_i≤t and t%F_i=0, there will be a train that departs Station i t seconds after the ceremony begins and arrives at Station i+1 t+C_i seconds after the ceremony begins, where A%B denotes A modulo B, and there will be no other trains. For each i, find the earliest possible time we can reach Station N if we are at Station i when the ceremony begins, ignoring the time needed to change trains.
|
N=int(input())
C=[]
S=[]
F=[]
for i in range(N-1):
a = input().split()
C.append(int(a[0]))
S.append(int(a[1]))
F.append(int(a[2]))
Time_list=[]
for i in range(N):
cnt=0
for j in range(i,N-1):
if cnt <= S[j]:
cnt = S[j] + C[j]
else:
x=0
while cnt > S[j] + x:
x += F[j]
cnt = C[j] + S[j] + x
Time_list.append(cnt)
print(Time_list)
|
s550128040
|
Accepted
| 96 | 3,188 | 436 |
N=int(input())
C=[]
S=[]
F=[]
for i in range(N-1):
a = input().split()
C.append(int(a[0]))
S.append(int(a[1]))
F.append(int(a[2]))
for i in range(N-1):
cnt=0
for j in range(i,N-1):
if cnt <= S[j]:
cnt = S[j] + C[j]
else:
if (cnt - S[j]) % F[j] == 0:
cnt += C[j]
else:
cnt += F[j] - (cnt % F[j]) + C[j]
print(cnt)
print(0)
|
s704859905
|
p03712
|
u865413330
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 214 |
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
|
H, W = map(int, input().split())
pics = [input() for i in range(H)]
for i in range(H+2):
if i == 0:
print("#"*(W+2))
if i == H+1:
print("#"*(W+2))
else:
print("#"+pics[i-1]+"#")
|
s342440605
|
Accepted
| 17 | 3,060 | 147 |
H, W = map(int, input().split())
pics = [input() for i in range(H)]
print("#"*(W+2))
for i in range(H):
print("#"+pics[i]+"#")
print("#"*(W+2))
|
s203846654
|
p03151
|
u057109575
| 2,000 | 1,048,576 |
Wrong Answer
| 82 | 18,356 | 196 |
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his _readiness_ for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination. Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness. For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions: * The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal. * For every i, B_i \leq C_i holds. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
|
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if (sum(a) < sum(b)):
print(-1)
x = 0
for i in range(n):
if a[i] < b[i]:
x += 1
print(x)
|
s810673900
|
Accepted
| 126 | 18,292 | 385 |
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [a[i] - b[i] for i in range(n)]
c.sort()
neg = [v for v in c if v < 0]
total = sum(neg)
num = len(neg)
if sum(c) < 0:
print(-1)
elif num == 0:
print(0)
else:
for v in reversed(c[num:]):
total += v
num += 1
if total >= 0:
break
print(num)
|
s747091178
|
p03681
|
u578953945
| 2,000 | 262,144 |
Wrong Answer
| 2,191 | 1,440,388 | 428 |
Snuke has N dogs and M monkeys. He wants them to line up in a row. As a Japanese saying goes, these dogs and monkeys are on bad terms. _("ken'en no naka", literally "the relationship of dogs and monkeys", means a relationship of mutual hatred.)_ Snuke is trying to reconsile them, by arranging the animals so that there are neither two adjacent dogs nor two adjacent monkeys. How many such arrangements there are? Find the count modulo 10^9+7 (since animals cannot understand numbers larger than that). Here, dogs and monkeys are both distinguishable. Also, two arrangements that result from reversing each other are distinguished.
|
M,D=map(int,input().split())
import itertools
MI=min(M,D)
MX=max(M,D)
#A=len(list(itertools.permutations(range(MX), MX)))
#B=len(list(itertools.permutations(range(MI), MI)))
#C=len(list(itertools.permutations(range(MX+1), MI)))
import math
print(math.factorial(MX) * len(list(itertools.permutations(range(MX+1), MI))) - len(list(itertools.permutations(range(MI), MI))))
print(len(list(itertools.permutations(range(MX+1), MI))))
|
s798673290
|
Accepted
| 702 | 5,180 | 287 |
M,D=map(int,input().split())
MX = 10**9+7
import math
if abs(M - D) >= 2:
print(0)
elif abs(M - D) == 1:
ANS=math.factorial(M) * math.factorial(D)
if ANS >= MX:
ANS %= MX
print(ANS)
else:
ANS=math.factorial(M)
#if ANS >= MX:
# ANS %= MX
print((ANS * ANS * 2) % MX)
|
s070593248
|
p03473
|
u278143034
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,096 | 139 |
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
|
M = int(input())
total = M + 24
print(total)
|
s986763950
|
Accepted
| 28 | 9,156 | 147 |
M = int(input())
total = (24 - M) + 24
print(total)
|
s821719898
|
p02612
|
u258731634
| 2,000 | 1,048,576 |
Wrong Answer
| 33 | 9,128 | 29 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
a=int(input())
print(a%1000)
|
s836572824
|
Accepted
| 25 | 9,144 | 71 |
a=int(input())
if a%1000==0:
print(0)
else:
print(1000-a%1000)
|
s280155138
|
p03547
|
u333190709
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 40 |
In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`, `D`, `E` or `F`. When X and Y are seen as hexadecimal numbers, which is larger?
|
x, y = input().split()
print(max(x, y))
|
s198700477
|
Accepted
| 17 | 3,060 | 114 |
x, y = input().split()
if (ord(x) > ord(y)):
print('>')
elif (ord(x) < ord(y)):
print('<')
else:
print('=')
|
s157976127
|
p03456
|
u307159845
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 161 |
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
import math
a, b = map(str,input().split())
c = int(a+ b)
#print(math.sqrt(c))
if isinstance(math.sqrt(c), int) == True:
print('Yes')
else:
print('No')
|
s378861105
|
Accepted
| 18 | 2,940 | 138 |
import math
a, b = map(str,input().split())
c = int(a+ b)
if math.sqrt(c).is_integer() == True:
print('Yes')
else:
print('No')
|
s192053730
|
p03826
|
u623349537
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 66 |
There are two rectangles. The lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B. The lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D. Print the area of the rectangle with the larger area. If the two rectangles have equal areas, print that area.
|
A, B, C, D = map(int, input().split())
print(max(A, B), max(C, D))
|
s745278499
|
Accepted
| 17 | 2,940 | 60 |
A, B, C, D = map(int, input().split())
print(max(A*B, C* D))
|
s070144994
|
p02260
|
u756595712
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,640 | 285 |
Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 if A[j] < A[mini] 5 mini = j 6 swap A[i] and A[mini] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i ≠ mini.
|
length = int(input())
eles = [int(l) for l in input().split()]
times = 0
for i in range(length-1):
_min = i
for j in range(i, length):
if eles[j] < eles[_min]:
_min = j
eles[i], eles[_min] = eles[_min], eles[i]
times += 1
print(*eles)
print(times)
|
s669512360
|
Accepted
| 20 | 7,720 | 311 |
length = int(input())
eles = [int(l) for l in input().split()]
times = 0
for i in range(length-1):
_min = i
for j in range(i, length):
if eles[j] < eles[_min]:
_min = j
if i != _min:
eles[i], eles[_min] = eles[_min], eles[i]
times += 1
print(*eles)
print(times)
|
s104683647
|
p03400
|
u983181637
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 221 |
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp.
|
n = int(input())
d, x = map(int, input().split())
ans = 0
for i in range(n):
a = int(input())
j = 0
while True:
if j*a + 1 <= d:
ans += 1
j += 1
else:
break
print(ans+n+x)
|
s503955479
|
Accepted
| 17 | 2,940 | 217 |
n = int(input())
d, x = map(int, input().split())
ans = 0
for _ in range(n):
a = int(input())
j = 0
while True:
if j*a + 1 <= d:
ans += 1
j += 1
else:
break
print(ans+x)
|
s734068412
|
p03371
|
u857330600
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 271 |
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
|
a,b,c,x,y=map(int,input().split())
sum=0
if a+b>=2*c:
sum+=2*c*min(x,y)
x-=min(x,y)
y-=min(x,y)
if x==0:
if b>=2*c:
sum+=2*c*y
else:
sum+=b*y
elif y==0:
if a>=2*c:
sum+=2*c*x
else:
sum+=a*x
else:
sum+=a*x+b*y
print(sum)
|
s929876091
|
Accepted
| 17 | 3,064 | 269 |
a,b,c,x,y=map(int,input().split())
sum=0
tmp=min(x,y)
if a+b>=2*c:
sum+=2*c*tmp
x-=tmp
y-=tmp
if x==0:
if b>=2*c:
sum+=2*c*y
else:
sum+=b*y
elif y==0:
if a>=2*c:
sum+=2*c*x
else:
sum+=a*x
else:
sum+=a*x+b*y
print(sum)
|
s611681203
|
p03643
|
u403984573
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 33 |
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
|
N=int,input()
print("ABC"+str(N))
|
s568667697
|
Accepted
| 18 | 2,940 | 21 |
print("ABC"+input())
|
s996462288
|
p03814
|
u409974118
| 2,000 | 262,144 |
Wrong Answer
| 41 | 10,396 | 174 |
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
|
s = list(input())
sa = s.index("A")
m = [i for i, x in enumerate(s) if x == 'Z']
mz = int(m[-1])
p = (s[sa:mz])
print(len(p))
|
s101129997
|
Accepted
| 39 | 10,396 | 178 |
s = list(input())
sa = s.index("A")
m = [i for i, x in enumerate(s) if x == 'Z']
mz = int(m[-1])+1
p = (s[sa:mz])
print(len(p))
|
s842795521
|
p04043
|
u707690642
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 271 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
input_text = input()
input_ = input_text.split()
cou5 = 0
cou7 = 0
for i in ([int(j) for j in input_]):
if int(i) == 5:
cou5 += 1
elif int(i) == 7:
cou7 += 1
if cou5 == 2 and cou7 == 1:
result = "Yes"
else :
result = "No"
print(result)
|
s705137694
|
Accepted
| 17 | 3,060 | 271 |
input_text = input()
input_ = input_text.split()
cou5 = 0
cou7 = 0
for i in ([int(j) for j in input_]):
if int(i) == 5:
cou5 += 1
elif int(i) == 7:
cou7 += 1
if cou5 == 2 and cou7 == 1:
result = "YES"
else :
result = "NO"
print(result)
|
s068182819
|
p02402
|
u527848444
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,724 | 105 |
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.
|
sum = 0
max = -10000000
min = 10000000
input()
for i in [int(x) for x in input().split()]:
print(i)
|
s097493200
|
Accepted
| 40 | 8,028 | 141 |
input()
nums = [int(i) for i in input().split()]
maximum = max(nums)
minimum = min(nums)
total = sum(nums)
print(minimum, maximum, total)
|
s245565380
|
p03997
|
u514826602
| 2,000 | 262,144 |
Wrong Answer
| 40 | 3,064 | 396 |
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 = list(input().strip())
B = list(input().strip())
C = list(input().strip())
current = A
currentName = 'A'
while True:
if len(current) == 0:
break
card = current.pop(0)
if card is 'a':
current = A
currentName = 'A'
elif card is 'b':
current = B
currentName = 'B'
else:
current = C
currentName = 'C'
print(currentName)
|
s331420461
|
Accepted
| 38 | 3,064 | 116 |
a = int(input().strip())
b = int(input().strip())
h = int(input().strip())
area = int((a + b) * h / 2)
print(area)
|
s300001777
|
p03587
|
u786020649
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,144 | 42 |
Snuke prepared 6 problems for a upcoming programming contest. For each of those problems, Rng judged whether it can be used in the contest or not. You are given a string S of length 6. If the i-th character of s is `1`, it means that the i-th problem prepared by Snuke is accepted to be used; `0` means that the problem is not accepted. How many problems prepared by Snuke are accepted to be used in the contest?
|
print(sum(list(map(int,input().split()))))
|
s074664002
|
Accepted
| 28 | 9,152 | 40 |
print(sum(list(map(int,list(input())))))
|
s269389116
|
p03160
|
u077296371
| 2,000 | 1,048,576 |
Wrong Answer
| 144 | 14,712 | 215 |
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
n=int(input())
f=[0]*n
a=list(map(int,input().split()))
f[0]=0
f[1]=abs(a[0]-a[1])
for i in range(2,n):
a1=abs(a[i]-a[i-2])
b=abs(a[i]-a[i-1])
f[i]=min((f[i-2]+a1),(f[i-1]+b))
print(f)
print(f[n-1])
|
s187820322
|
Accepted
| 128 | 14,696 | 201 |
n=int(input())
f=[0]*n
a=list(map(int,input().split()))
f[0]=0
f[1]=abs(a[0]-a[1])
for i in range(2,n):
a1=abs(a[i]-a[i-2])
b=abs(a[i]-a[i-1])
f[i]=min((f[i-2]+a1),(f[i-1]+b))
print(f[n-1])
|
s201987273
|
p03861
|
u779170803
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 375 |
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
a,b,x=INTM()
if a>=1:
cta=a//x
else:
cta=0
ctb=b//x
print(ctb-cta)
if __name__ == '__main__':
do()
|
s172228505
|
Accepted
| 17 | 3,064 | 383 |
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
a,b,x=INTM()
if a>=1:
cta=(a-1)//x+1
else:
cta=0
ctb=b//x+1
print(ctb-cta)
if __name__ == '__main__':
do()
|
s099996538
|
p03568
|
u629350026
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 135 |
We will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are _similar_ when |x_i - y_i| \leq 1 holds for all i (1 \leq i \leq N). In particular, any integer sequence is similar to itself. You are given an integer N and an integer sequence of length N, A_1, A_2, ..., A_N. How many integer sequences b_1, b_2, ..., b_N are there such that b_1, b_2, ..., b_N is similar to A and the product of all elements, b_1 b_2 ... b_N, is even?
|
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
if a[i]%2==0:
ans=ans+3
else:
ans=ans+2
print(ans)
|
s123422774
|
Accepted
| 17 | 2,940 | 129 |
n=int(input())
a=list(map(int,input().split()))
ans=3**n
cnt=0
for i in range(n):
if a[i]%2==0:
cnt=cnt+1
print(ans-2**cnt)
|
s299714767
|
p03778
|
u514894322
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 105 |
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
|
w,a,b = map(int,input().split())
if b > w+a:
print(b-w+a)
elif a > w+b:
print(a-w+b)
else:
print(0)
|
s472061286
|
Accepted
| 18 | 2,940 | 106 |
w,a,b = map(int,input().split())
if b > w+a:
print(b-w-a)
elif a > w+b:
print(a-w-b)
else:
print(0)
|
s035943504
|
p02694
|
u641722141
| 2,000 | 1,048,576 |
Wrong Answer
| 23 | 9,172 | 120 |
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
a =int(input())
b = 100
count = 0
while True:
b = int(b + (b* 0.01))
count += 1
if b <= a:
break
print(count)
|
s425980799
|
Accepted
| 26 | 9,116 | 117 |
X = int(input())
depo = 100
count = 0
while depo < X:
depo = int(depo + depo * 0.01)
count += 1
print(count)
|
s758768632
|
p02865
|
u007698380
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 65 |
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
|
n=int(input())
if n%2==0:
print(n//2)
else:
print(n//2-1)
|
s602008253
|
Accepted
| 17 | 2,940 | 74 |
n = int(input())
if n%2 == 0:
print(int(n/2)-1)
else:
print(int(n/2))
|
s260968819
|
p03846
|
u843981036
| 2,000 | 262,144 |
Wrong Answer
| 120 | 14,008 | 507 |
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
|
import sys
def test(a):
if len(a) % 2:
if a[0]:
return False
del a[0]
for i in range(0, len(a) - 2, 2):
if a[i] != a[i + 1] or a[i + 2] - a[i] != 2:
return False
return True
input()
a = sorted(list(map(int, input().split())))
print(a)
if a[:2] == [0, 0]:
print(0)
sys.exit(0)
if a == [0] or a == [1, 1]:
print(1)
sys.exit(0)
elif a == [0, 1, 1]:
print(2)
sys.exit(0)
print(2 ** round(len(a)/2) if test(a) else 0)
|
s990113196
|
Accepted
| 105 | 14,008 | 520 |
import sys
def test(a):
if len(a) % 2:
if a[0]:
return False
del a[0]
for i in range(0, len(a) - 2, 2):
if a[i] != a[i + 1] or a[i + 2] - a[i] != 2:
return False
return True
input()
a = sorted(list(map(int, input().split())))
if a[:2] == [0, 0]:
print(0)
sys.exit(0)
elif a == [0]:
print(1)
sys.exit(0)
elif a == [0, 1, 1] or a == [1, 1]:
print(2)
sys.exit(0)
print((2 ** round(len(a) / 2)) % (10 ** 9 + 7) if test(a) else 0)
|
s067985509
|
p03853
|
u714300041
| 2,000 | 262,144 |
Wrong Answer
| 23 | 3,444 | 237 |
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
|
H, W = map(int, input().split())
C = [list(input()) for _ in range(H)]
C2 = [["-"]*W for _ in range(2*H)]
print(C)
for h in range(2*H):
for w in range(W):
C2[h][w] = C[h//2][w]
for i in range(2*H):
print("".join(C2[i]))
|
s928649915
|
Accepted
| 23 | 3,316 | 228 |
H, W = map(int, input().split())
C = [list(input()) for _ in range(H)]
C2 = [["-"]*W for _ in range(2*H)]
for h in range(2*H):
for w in range(W):
C2[h][w] = C[h//2][w]
for i in range(2*H):
print("".join(C2[i]))
|
s327735580
|
p03386
|
u288430479
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 124 |
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
a,b,c = map(int,input().split())
l = []
for i in range(c):
l.append(a+i)
l.append(b-c)
l = set(l)
for i in l:
print(i)
|
s090971043
|
Accepted
| 19 | 3,060 | 176 |
a,b,c = map(int,input().split())
l = []
for i in range(c):
d = a+i
e = b-i
if d<=b and a<=e:
l.append(a+i)
l.append(b-i)
l = sorted(set(l))
for i in l:
print(i)
|
s895238083
|
p02261
|
u308033440
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,532 | 1,059 |
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
|
def BubbleSort(C,N):
for i in range (0,N,1):
for j in range(N-1,i-1,-1):
if int(C[j][1:2]) < int(C[j-1][1:2]):
tmp = C[j]
C[j] = C[j-1]
C[j-1] = tmp
print(' '.join(C))
def SelectionSort(C,N):
for i in range(0,N,1):
minj = i
for j in range(i,N,1):
if int(C[j][1:2]) < int(C[minj][1:2]):
minj = j
tmp = C[i]
C[i] = C[minj]
C[minj] = tmp
print(' '.join(C))
def isStable(inp, out,N):
for i in range(0,N):
for j in range(i+1,N):
for a in range(0,N):
for b in range(a+1,N):
# print("inp(i,j):",inp[i],inp[j],"out(b,a):",out[b],out[a]+"\n")
if int(inp[i][1]) == int(inp[j][1]) and inp[i] == out[b] and inp[j] == out[a]:
print('Not stable')
return
print('Stable')
|
s521199493
|
Accepted
| 20 | 5,608 | 895 |
def BubbleSort(C,N):
for i in range (0,N,1):
for j in range(N-1,i,-1):
if int(C[j][1:2]) < int(C[j-1][1:2]):
tmp = C[j]
C[j] = C[j-1]
C[j-1] = tmp
print(' '.join(C))
def SelectionSort(C,N):
for i in range(0,N,1):
minj = i
for j in range(i,N,1):
if int(C[j][1:2]) < int(C[minj][1:2]):
minj = j
tmp = C[i]
C[i] = C[minj]
C[minj] = tmp
print(' '.join(C))
N = int(input())
A = list(input().split())
Bubble_A = A.copy()
Selection_A = A.copy()
BubbleSort(Bubble_A,N)
print("Stable")
SelectionSort(Selection_A,N)
flag = True
for Bubble,Selection in zip(Bubble_A,Selection_A):
if Bubble != Selection:
flag = False
if flag :
print("Stable")
else:
print("Not stable")
|
s350180509
|
p03597
|
u357630630
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 63 |
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
|
N, A = map(int, [input() for _ in range(2)])
print(N ** N - A)
|
s926881940
|
Accepted
| 18 | 2,940 | 63 |
N, A = map(int, [input() for _ in range(2)])
print(N ** 2 - A)
|
s750028747
|
p03860
|
u434282696
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 29 |
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
s=input()
print('A'+s[0]+'C')
|
s076246076
|
Accepted
| 17 | 2,940 | 43 |
s1,s,s2=input().split()
print('A'+s[0]+'C')
|
s796391858
|
p03089
|
u623687794
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 195 |
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())
l=list(map(int,input().split()))
ans=[]
for i in range(n)[::-1]:
if l[i]==i+1:
a=l.pop(i)
ans.append(a)
if l!=[]:
print(-1)
else:
for i in range(n):
print(ans[i])
|
s156603188
|
Accepted
| 18 | 3,060 | 286 |
n=int(input())
l=list(map(int,input().split()))
ans=[]
for i in range(n)[::-1]:
for j in range(i+1)[::-1]:
if l[j]==j+1:
a=l.pop(j)
ans.append(a)
break
if j==0 and l[j]!=1:
break
if l!=[]:
print(-1)
else:
for i in range(n)[::-1]:
print(ans[i])
|
s756377355
|
p03556
|
u941753895
| 2,000 | 262,144 |
Time Limit Exceeded
| 2,104 | 2,940 | 133 |
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
|
N=int(input())
a=1
while True:
b=a*a
if N==b:
print(b)
break
elif N<b:
print((a-1)*(a-1))
break
|
s627767769
|
Accepted
| 17 | 2,940 | 80 |
import math
N=int(input())
print(int(math.sqrt(N))*int(math.sqrt(N)))
|
s035093961
|
p03854
|
u743154453
| 2,000 | 262,144 |
Wrong Answer
| 24 | 6,516 | 169 |
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`.
|
import re
text = input()
matche_str = re.compile(r'^(dream|dreamer|erase|eraser)+$')
mo = matche_str.search(text)
if mo != None:
print('yes')
else:
print('no')
|
s313502373
|
Accepted
| 24 | 6,516 | 169 |
import re
text = input()
matche_str = re.compile(r'^(dream|dreamer|erase|eraser)+$')
mo = matche_str.search(text)
if mo != None:
print('YES')
else:
print('NO')
|
s219962959
|
p02694
|
u372187342
| 2,000 | 1,048,576 |
Wrong Answer
| 23 | 9,176 | 207 |
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
import math
x = int(input())
a = 100
cnt = 0
#file = open('test.txt', 'w')
while a <= x:
a = a*1.01
a = int(a)
b = str(a)
# file.write(b + '\n')
cnt = cnt + 1
#file.close()
print(cnt)
|
s428409623
|
Accepted
| 25 | 9,176 | 206 |
import math
x = int(input())
a = 100
cnt = 0
#file = open('test.txt', 'w')
while a < x:
a = a*1.01
a = int(a)
b = str(a)
# file.write(b + '\n')
cnt = cnt + 1
#file.close()
print(cnt)
|
s956464634
|
p03964
|
u138486156
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 3,444 | 680 |
AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.
|
n = int(input())
a = [tuple(map(int, input().split())) for _ in range(n)]
s, t = a[0][0], a[0][1]
for i in range(1, n):
if a[i][0] < a[i][1]:
j = 1
while True:
if a[i][0]*j < s or a[i][1]*j < t:
pass
else:
s = a[i][0]*j
break
j += 1
t = j*a[i][1]
elif a[i][0] > a[i][1]:
j = 1
while True:
if a[i][1]*j < t or a[i][0]*j < s:
pass
else:
t = a[i][1]*j
break
j += 1
s = j*a[i][0]
else:
s, t = max(s, t), max(s,t)
print(s, t)
print(s+t)
|
s299124007
|
Accepted
| 22 | 3,060 | 215 |
n = int(input())
a = [tuple(map(int, input().split())) for _ in range(n)]
s, t = 1, 1
for i in range(0, n):
j = max((s+a[i][0]-1)//a[i][0], (t+a[i][1]-1)//a[i][1])
s, t = a[i][0]*j, a[i][1]*j
print(s+t)
|
s067541641
|
p04011
|
u246661425
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 106 |
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
|
n = int(input())
x = int(input())
k = int(input())
y = int(input())
print(x*n + y*(n-k) if n > k else n*x)
|
s076102193
|
Accepted
| 17 | 2,940 | 107 |
n = int(input())
k = int(input())
x = int(input())
y = int(input())
print(k*x + y*(n-k) if n > k else x*n)
|
s206253898
|
p03643
|
u823044869
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 42 |
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
|
number=input()
print('ABC'.join(number))
|
s140244129
|
Accepted
| 17 | 2,940 | 36 |
number=input()
print("ABC"+number)
|
s565333587
|
p03485
|
u949315872
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,220 | 172 |
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
import sys
input = sys.stdin.readline
#-------------
a,b = map(int,input().split())
#-------------
x = (a+b)/2
y = x//1
mod = x%1
if mod == 0:
print(y)
else:
print(y+1)
|
s454069010
|
Accepted
| 22 | 9,172 | 182 |
import sys
input = sys.stdin.readline
#-------------
a,b = map(int,input().split())
#-------------
x = (a+b)/2
y = x//1
mod = x%1
if mod == 0:
print(int(y))
else:
print(int(y+1))
|
s686089965
|
p04043
|
u014333473
| 2,000 | 262,144 |
Wrong Answer
| 29 | 8,892 | 70 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a,b,c=input().split();print('NYOE S'[a=='5' and b=='7' and c=='5'::2])
|
s636538587
|
Accepted
| 24 | 8,908 | 61 |
a=input().replace('5','');print('NYOE S'[a.count('7')==1::2])
|
s469657766
|
p03097
|
u346851130
| 2,000 | 1,048,576 |
Wrong Answer
| 1,187 | 39,256 | 1,785 |
You are given integers N,\ A and B. Determine if there exists a permutation (P_0,\ P_1,\ ...\ P_{2^N-1}) of (0,\ 1,\ ...\ 2^N-1) that satisfies all of the following conditions, and create one such permutation if it exists. * P_0=A * P_{2^N-1}=B * For all 0 \leq i < 2^N-1, the binary representations of P_i and P_{i+1} differ by exactly one bit.
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def trace(bits, idx, history):
if idx == len(bits):
history.append(bits[:])
elif idx == len(bits) - 1:
history.append(bits[:])
bits[idx] = 1 - bits[idx]
history.append(bits[:])
else:
trace(bits, idx + 1, history)
bits[idx] = 1 - bits[idx]
trace(bits, idx + 1, history)
def down(bits, idx, count, history):
if idx == len(bits):
history.append(bits[:])
elif idx == len(bits) - 1:
history.append(bits[:])
bits[idx] = 1 - bits[idx]
history.append(bits[:])
elif count > 0:
trace(bits, idx + 2, history)
bits[idx] = 1 - bits[idx]
trace(bits, idx + 2, history)
bits[idx + 1] = 1 - bits[idx + 1]
trace(bits, idx + 2, history)
bits[idx] = 1 - bits[idx]
down(bits, idx + 2, count - 2, history)
else:
trace(bits, idx + 2, history)
bits[idx + 1] = 1 - bits[idx + 1]
trace(bits, idx + 2, history)
bits[idx ] = 1 - bits[idx ]
trace(bits, idx + 2, history)
bits[idx + 1] = 1 - bits[idx + 1]
down(bits, idx + 2, count - 2, history)
def main():
n, a, b = map(int, input().split())
x = a ^ b
count = 0
remain = 0
mapper = [-1] * n
for i in range(n):
if (x >> i) & 0x1 != 0:
mapper[count] = i
count += 1
else:
remain += 1
mapper[-remain] = i
if count % 2 == 0:
print('NO', flush=True)
return
bits = [0] * n
history = []
trace(bits, 1, history)
bits[0] = 1
down(bits, 1, count - 1, history)
for i in range(len(history)):
v = history[i][:]
for j, m in enumerate(mapper):
history[i][n - m - 1] = v[j]
history = [str(a ^ int(''.join(str(v) for v in h), 2)) for h in history]
print(' '.join(history), flush=True)
if __name__ == '__main__':
main()
|
s516514500
|
Accepted
| 1,134 | 39,252 | 1,812 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def trace(bits, idx, history):
if idx == len(bits):
history.append(bits[:])
elif idx == len(bits) - 1:
history.append(bits[:])
bits[idx] = 1 - bits[idx]
history.append(bits[:])
else:
trace(bits, idx + 1, history)
bits[idx] = 1 - bits[idx]
trace(bits, idx + 1, history)
def down(bits, idx, count, history):
if idx == len(bits):
history.append(bits[:])
elif idx == len(bits) - 1:
history.append(bits[:])
bits[idx] = 1 - bits[idx]
history.append(bits[:])
elif count > 0:
trace(bits, idx + 2, history)
bits[idx] = 1 - bits[idx]
trace(bits, idx + 2, history)
bits[idx + 1] = 1 - bits[idx + 1]
trace(bits, idx + 2, history)
bits[idx] = 1 - bits[idx]
down(bits, idx + 2, count - 2, history)
else:
trace(bits, idx + 2, history)
bits[idx + 1] = 1 - bits[idx + 1]
trace(bits, idx + 2, history)
bits[idx ] = 1 - bits[idx ]
trace(bits, idx + 2, history)
bits[idx + 1] = 1 - bits[idx + 1]
down(bits, idx + 2, count - 2, history)
def main():
n, a, b = map(int, input().split())
x = a ^ b
count = 0
remain = 0
mapper = [-1] * n
for i in range(n):
if (x >> i) & 0x1 != 0:
mapper[count] = i
count += 1
else:
remain += 1
mapper[-remain] = i
if count % 2 == 0:
print('NO', flush=True)
return
bits = [0] * n
history = []
trace(bits, 1, history)
bits[0] = 1
down(bits, 1, count - 1, history)
for i in range(len(history)):
v = history[i][:]
for j, m in enumerate(mapper):
history[i][n - m - 1] = v[j]
history = [str(a ^ int(''.join(str(v) for v in h), 2)) for h in history]
print('YES', flush=True)
print(' '.join(history), flush=True)
if __name__ == '__main__':
main()
|
s987648599
|
p03388
|
u102960641
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 334 |
10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th. The _score_ of a participant is the product of his/her ranks in the two contests. Process the following Q queries: * In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.
|
import math
def near_sqrt(a,b):
c = a * b
d = math.floor(math.sqrt(c))
if d*(d+1) <= c:
return d
else:
return (d-1)
q = int(input())
for i in range(q):
a,b = map(int, input().split())
c = near_sqrt(a,b)
if (a*b)%(c+1) == 0:
print(math.floor((a*b)/(c+1))+c-2)
else:
print(math.floor((a*b)/(c+1))+c-1)
|
s317902769
|
Accepted
| 19 | 3,064 | 350 |
import math
def near_sqrt(a,b):
c = a * b
d = math.floor(math.sqrt(c))
if d*(d+1) < c:
return d
else:
return (d-1)
q = int(input())
for i in range(q):
a,b = map(int, input().split())
c = near_sqrt(a,b)
d = (a*b)%(c+1)
if d == 0 and a!=b:
print(math.floor((a*b)/(c+1))+c-2)
else:
print(math.floor((a*b)/(c+1))+c-1)
|
s958308136
|
p03759
|
u252210202
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 89 |
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
a, b, c=map(int, input().split())
if b-a==c-b:
print('Yes')
else:
print('No')
|
s363267054
|
Accepted
| 17 | 2,940 | 89 |
a, b, c=map(int, input().split())
if b-a==c-b:
print('YES')
else:
print('NO')
|
s785351056
|
p04029
|
u140342018
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 233 |
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
def func(s):
for i in range(len(s)-1):
if s[i]==s[i+1]:
return i+1, i+2
for i in range(len(s)-2):
if s[i]==s[i+2]:
return i+1, i+3
return -1,-1
s = input()
a,b = func(s)
print(a,b)
|
s390204122
|
Accepted
| 17 | 2,940 | 69 |
n = int(input())
sum = 0
for i in range(n):
sum += i+1
print(sum)
|
s696933614
|
p03476
|
u210827208
| 2,000 | 262,144 |
Wrong Answer
| 1,005 | 5,108 | 441 |
We say that a odd number N is _similar to 2017_ when both N and (N+1)/2 are prime. You are given Q queries. In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.
|
import math
q=int(input())
N=[0]*(10**5+1)
N[3]=1
N[2]=1
S=[]
for i in range(5,10**5+1,2):
flag=True
for j in range(3,int(math.sqrt(i))+1,2):
if i%j==0:
flag=False
break
if flag:
N[i]=1
X=[0]*(10**5+1)
X[2]=1
cnt=0
for i in range(3,10**5+1,2):
if N[i]==1 and N[(i+1)//2]==1:
cnt+=1
X[i]=cnt
Q=[]
for i in range(q):
l,r=map(int,input().split())
print(X[l]-X[r-2])
|
s166048391
|
Accepted
| 1,005 | 4,980 | 441 |
import math
q=int(input())
N=[0]*(10**5+1)
N[3]=1
N[2]=1
S=[]
for i in range(5,10**5+1,2):
flag=True
for j in range(3,int(math.sqrt(i))+1,2):
if i%j==0:
flag=False
break
if flag:
N[i]=1
X=[0]*(10**5+1)
X[2]=1
cnt=0
for i in range(3,10**5+1,2):
if N[i]==1 and N[(i+1)//2]==1:
cnt+=1
X[i]=cnt
Q=[]
for i in range(q):
l,r=map(int,input().split())
print(X[r]-X[l-2])
|
s070603106
|
p02396
|
u706217959
| 1,000 | 131,072 |
Wrong Answer
| 80 | 5,912 | 323 |
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.
|
def main():
data = []
while 1:
n = int(input())
data.append(n)
if n == 0:
break
for i in range(0,9999):
d_val = data[i]
if d_val != 0:
print("Case{0}:{1}".format(i+1,d_val))
else:
break
if __name__ == '__main__':
main()
|
s508864377
|
Accepted
| 90 | 5,904 | 497 |
def main():
data = []
while 1:
n = input().split()
ans = int(n[0])
if ans == 0:
break
data.append(ans)
length = len(data)
what_large = length > 10000
if what_large:
print("Too Large")
else:
for i in range(len(data)):
d_val = data[i]
if d_val != 0:
print("Case {0}: {1}".format(i+1,d_val))
else:
break
if __name__ == '__main__':
main()
|
s160085065
|
p02262
|
u809233245
| 6,000 | 131,072 |
Wrong Answer
| 20 | 5,604 | 535 |
Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i]) A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$. Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m − 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements: * $1 \leq m \leq 100$ * $0 \leq G_i \leq n$ * cnt does not exceed $\lceil n^{1.5}\rceil$
|
def insertion_sort(a, n, g, cnt):
for i in range(g, n):
v = a[i]
j = i - g
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j = j -g
cnt += 1
a[j+g] = v
return cnt
def shell_sort(a, n):
cnt = 0
g = [40, 13, 4, 1]
print(len(g))
print(' '.join(map(str, g)))
for i in range(len(g)):
cnt = insertion_sort(a, n, g[i], cnt)
print(cnt)
n = int(input())
a = [int(input()) for _ in range(n)]
shell_sort(a, n)
for num in a:
print(num)
|
s905309964
|
Accepted
| 18,290 | 45,520 | 628 |
def insertion_sort(a, n, g, cnt):
for i in range(g, n):
v = a[i]
j = i - g
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j = j -g
cnt += 1
a[j+g] = v
return cnt
def shell_sort(a, n):
cnt = 0
h = 1
g = []
while h <= n:
g.insert(0, h)
h = 3 * h + 1
for i in range(len(g)):
if g[i] <= len(a):
cnt = insertion_sort(a, n, g[i], cnt)
print(len(g))
print(' '.join(map(str, g)))
print(cnt)
n = int(input())
a = [int(input()) for _ in range(n)]
shell_sort(a, n)
for num in a:
print(num)
|
s405183447
|
p02262
|
u766163292
| 6,000 | 131,072 |
Wrong Answer
| 30 | 7,804 | 1,037 |
Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i]) A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$. Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m − 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements: * $1 \leq m \leq 100$ * $0 \leq G_i \leq n$ * cnt does not exceed $\lceil n^{1.5}\rceil$
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def generate_intervals(n):
a = 1
yield a
while a <= n // 9:
yield a
a = 3 * a + 1
class Sort(object):
def __init__(self, array, num):
self.a = array
self.n = num
self.cnt = 0
self.gs = list(reversed(list(generate_intervals(self.n))))
self.m = len(self.gs)
def insertionsort(self, g):
for i in range(g, self.n):
v = self.a[i]
j = i - g
while j >= 0 and self.a[j] > v:
self.a[j + g] = self.a[j]
j = j - g
self.cnt += 1
self.a[j + g] = v
def shellsort(self):
for i in range(0, self.m):
self.insertionsort(self.gs[i])
def main():
n = int(input())
a = [int(input()) for i in range(n)]
s = Sort(a, n)
s.shellsort()
print(s.m)
print(" ".join(map(str, s.gs)))
print(s.cnt)
for i in range(n):
print(s.a[i])
if __name__ == "__main__":
main()
|
s158342318
|
Accepted
| 23,210 | 47,500 | 832 |
#!/usr/bin/env python3
def construct_gs(n):
gs = []
g = 1
while g <= n:
gs.append(g)
g = 3 * g + 1
return gs[::-1]
def shell_sort(xs, n):
global cnt
cnt = 0
gs = construct_gs(n)
m = len(gs)
def insertion_sort(g):
global cnt
for i in range(g, n):
v = xs[i]
j = i - g
while j >= 0 and xs[j] > v:
xs[j + g] = xs[j]
j = j - g
cnt += 1
xs[j + g] = v
for g in gs:
insertion_sort(g)
return m, gs, cnt, xs
def main():
n = int(input())
xs = [int(input()) for _ in range(n)]
m, gs, cnt, xs = shell_sort(xs, n)
print(m)
print(" ".join(map(str, gs)))
print(cnt)
for x in xs:
print(x)
if __name__ == '__main__':
main()
|
s165659508
|
p02420
|
u539789745
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 285 |
Your task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck. The deck of cards is represented by a string as follows. abcdeefab The first character and the last character correspond to the card located at the bottom of the deck and the card on the top of the deck respectively. For example, a shuffle with h = 4 to the above deck, moves the first 4 characters "abcd" to the end of the remaining characters "eefab", and generates the following deck: eefababcd You can repeat such shuffle operations. Write a program which reads a deck (a string) and a sequence of h, and prints the final state (a string).
|
def main():
while True:
S = input()
if S == "-":
break
n_shuffle = int(input())
hs = [int(input()) for _ in range(n_shuffle)]
for h in hs:
S = S[-h:] + S[:-h]
print(S)
if __name__ == "__main__":
main()
|
s768434677
|
Accepted
| 20 | 5,600 | 283 |
def main():
while True:
S = input()
if S == "-":
break
n_shuffle = int(input())
hs = [int(input()) for _ in range(n_shuffle)]
for h in hs:
S = S[h:] + S[:h]
print(S)
if __name__ == "__main__":
main()
|
s932778365
|
p04029
|
u155251346
| 2,000 | 262,144 |
Wrong Answer
| 27 | 8,980 | 40 |
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
N = input()
print(1/2*int(N)*(int(N)+1))
|
s944725295
|
Accepted
| 29 | 9,004 | 55 |
N = input()
answer = int(N)*(int(N)+1)//2
print(answer)
|
s048411641
|
p03569
|
u131881594
| 2,000 | 262,144 |
Wrong Answer
| 42 | 9,276 | 128 |
We have a string s consisting of lowercase English letters. Snuke can perform the following operation repeatedly: * Insert a letter `x` to any position in s of his choice, including the beginning and end of s. Snuke's objective is to turn s into a palindrome. Determine whether the objective is achievable. If it is achievable, find the minimum number of operations required.
|
s=input()
temp=""
for c in s:
if c!="x": temp+=c
if temp!=temp[::-1]: print(-1)
elif len(temp)==0: print(0)
else:
pass
|
s944798811
|
Accepted
| 59 | 9,208 | 237 |
s=input()
l,r=0,len(s)-1
ans=0
while l<r:
if s[l]==s[r]:
l+=1
r-=1
elif s[l]=="x":
l+=1
ans+=1
elif s[r]=="x":
r-=1
ans+=1
else:
print(-1)
exit()
print(ans)
|
s731404759
|
p03407
|
u814986259
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 76 |
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.
|
a,b,c=map(int,input().split())
if a+b <c:
print("Yes")
else:
print("No")
|
s714500567
|
Accepted
| 17 | 2,940 | 76 |
a,b,c=map(int,input().split())
if a+b <c:
print("No")
else:
print("Yes")
|
s609841527
|
p03672
|
u238084414
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 220 |
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()
for i in range(1, len(S)):
s = S[:-i]
print(s)
M = set(s)
f = True
for m in M:
print(s.count(m)%2)
if s.count(m)%2 != 0:
f = False
break
if f:
print(len(S) - i)
exit()
|
s668629269
|
Accepted
| 17 | 2,940 | 105 |
S = input()
while True:
S = S[:-2]
if S[:len(S)//2] == S[len(S)//2 : ]:
print(len(S))
exit()
|
s786170695
|
p04043
|
u086172144
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 84 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a=sorted(list(map(int,input().split())))
if a==[5,5,7]:print("Yes")
else:print("No")
|
s225438741
|
Accepted
| 17 | 2,940 | 84 |
a=sorted(list(map(int,input().split())))
if a==[5,5,7]:print("YES")
else:print("NO")
|
s699392543
|
p03433
|
u050698451
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 119 |
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
N = int(input())
A = int(input())
num = int(N/500)
res = N - 500*num
if A < res:
print('False')
else:
print('True')
|
s513636938
|
Accepted
| 17 | 2,940 | 115 |
N = int(input())
A = int(input())
num = int(N/500)
res = N - 500*num
if A < res:
print('No')
else:
print('Yes')
|
s304537954
|
p03434
|
u757274384
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 95 |
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
N = int(input())
A = list(map(int, input().split()))
A.sort()
print(sum(A[::2]) - sum(A[1::2]))
|
s789617895
|
Accepted
| 17 | 2,940 | 108 |
N = int(input())
A = list(map(int, input().split()))
A.sort()
A.reverse()
print(sum(A[::2]) - sum(A[1::2]))
|
s599194061
|
p03379
|
u541610817
| 2,000 | 262,144 |
Wrong Answer
| 384 | 26,772 | 250 |
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
|
def main():
N = int(input())
X = [int(_) for _ in input().split()]
Y = sorted(X)
mid = (Y[(N-1)//2] + Y[N//2]) / 2
for i in range(N):
print(Y[N//2] if X[i] <= mid else print(Y[(N-1)//2]))
return
if __name__ == '__main__':
main()
|
s881705649
|
Accepted
| 348 | 26,772 | 244 |
def main():
N = int(input())
X = [int(_) for _ in input().split()]
Y = sorted(X)
mid = (Y[(N-1)//2] + Y[N//2]) / 2
for i in range(N):
print(Y[N//2] if X[i] <= mid else Y[(N-1)//2])
return
if __name__ == '__main__':
main()
|
s529192140
|
p03737
|
u748311048
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 48 |
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
|
S=input().split()
print(S[0][0]+S[1][0]+S[2][0])
|
s943334969
|
Accepted
| 18 | 2,940 | 59 |
S=input().split()
print(str.upper(S[0][0]+S[1][0]+S[2][0]))
|
s976607436
|
p03575
|
u652150585
| 2,000 | 262,144 |
Wrong Answer
| 61 | 3,444 | 367 |
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())
edges = [list(map(int, input().split())) for i in range(m)]
count = 0
print(n,m,edges)
for x in edges:
l = list(range(n))
print(l)
for y in edges:
if y != x:
l = [l[y[0]-1] if l[i] == l[y[1]-1] else l[i] for i in range(n)]
print(l)
if len(set(l)) != 1:
count += 1
print(count)
|
s887010855
|
Accepted
| 44 | 3,064 | 318 |
n, m = map(int, input().split())
edges = [list(map(int, input().split())) for i in range(m)]
count = 0
for x in edges:
l = list(range(n))
for y in edges:
if y != x:
l = [l[y[0]-1] if l[i] == l[y[1]-1] else l[i] for i in range(n)]
if len(set(l)) != 1:
count += 1
print(count)
|
s816469469
|
p02612
|
u813286880
| 2,000 | 1,048,576 |
Wrong Answer
| 26 | 9,168 | 222 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
def main():
N = int(input())
ans = 0
if N < 1000:
ans = 1
else:
ans = int(N / 1000)
if N % 1000 > 0:
ans += 1
print(f'{ans}')
if __name__ == '__main__':
main()
|
s303932451
|
Accepted
| 26 | 9,172 | 295 |
def main():
N = int(input())
remainder = N % 1000
quotient = int(N / 1000)
ans = 0
if N < 1000:
ans = 1000 - N
elif remainder == 0:
ans = 0
elif remainder > 0:
ans = 1000 - remainder
print(f'{ans}')
if __name__ == '__main__':
main()
|
s041706043
|
p03827
|
u395816772
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 135 |
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
|
n = int(input())
s = input()
ans = 0
for i in range(n):
if s[i] == 'I':
ans += 1
else:
ans -= 1
print(ans)
|
s789623626
|
Accepted
| 18 | 3,060 | 270 |
n = int(input())
s = input()
ans = []
if s[0] == 'I':
ans.append(1)
else:
ans.append(-1)
for i in range(1,n):
if s[i] == 'I':
ans.append(ans[i-1] +1)
else:
ans.append(ans[i-1] -1)
if max(ans) < 0:
print('0')
else:
print(max(ans))
|
s179495514
|
p03089
|
u888337853
| 2,000 | 1,048,576 |
Wrong Answer
| 39 | 5,196 | 658 |
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.
|
import sys
# import re
import math
import collections
import bisect
# import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
# ===CODE===
def main():
n = ni()
a = na()
for i, ai in enumerate(a):
if ai > i + 1:
print(-1)
exit(0)
else:
print(ai)
if __name__ == '__main__':
main()
|
s757550130
|
Accepted
| 37 | 5,092 | 876 |
import sys
# import re
import math
import collections
import bisect
# import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
# ===CODE===
def main():
n = ni()
a = na()
ans = []
while len(a) > 0:
flg = True
for i in range(len(a) - 1, -1, -1):
if i + 1 == a[i]:
ans.append(i + 1)
del a[i]
flg = False
break
if flg:
print(-1)
exit(0)
for i in range(n-1,-1,-1) :
print(ans[i])
if __name__ == '__main__':
main()
|
s591020842
|
p02279
|
u882992966
| 2,000 | 131,072 |
Wrong Answer
| 70 | 7,816 | 1,350 |
A graph _G_ = ( _V_ , _E_ ) is a data structure where _V_ is a finite set of vertices and _E_ is a binary relation on _V_ represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs). **Fig. 1** A free tree is a connnected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called "node." Your task is to write a program which reports the following information for each node _u_ of a given rooted tree _T_ : * node ID of _u_ * parent of _u_ * depth of _u_ * node type (root, internal node or leaf) * a list of chidlren of _u_ If the last edge on the path from the root _r_ of a tree _T_ to a node _x_ is ( _p_ , _x_ ), then _p_ is the **parent** of _x_ , and _x_ is a **child** of _p_. The root is the only node in _T_ with no parent. A node with no children is an **external node** or **leaf**. A nonleaf node is an **internal node** The number of children of a node _x_ in a rooted tree _T_ is called the **degree** of _x_. The length of the path from the root _r_ to a node _x_ is the **depth** of _x_ in _T_. Here, the given tree consists of _n_ nodes and evey node has a unique ID from 0 to _n_ -1. Fig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input. **Fig. 2**
|
import sys
class Node(object):
def __init__(self, parent_id=-1, depth=0, children=[]):
self.parent_id = parent_id
self.depth = depth
self.children = children
if __name__ == "__main__":
lines = sys.stdin.readlines()
node_list = [None] * int(lines[0])
child_parent_map = [None] * int(lines[0])
# Create the list of Node
for line in lines[1:]:
node_id, _, *children = [int(x) for x in line.strip().split(" ")]
node_list[node_id] = Node(children=children)
for child in children:
child_parent_map[child] = node_id
# Set the parent_id of each node
for node_id, node in enumerate(node_list):
if child_parent_map[node_id] is not None:
node.parent_id = child_parent_map[node_id]
# Set the depth of each node
for node_id, node in enumerate(node_list):
current_id = node_id
current_depth = 0
while True:
if current_id == 0:
node.depth = current_depth
break
else:
current_id = node_list[current_id].parent_id
current_depth += 1
# Output
for node_id, node in enumerate(node_list):
print("node %d: parent = %d, depth = %d, leaf, %s" % (node_id, node.parent_id, node.depth, node.children))
|
s817089488
|
Accepted
| 1,090 | 45,508 | 1,627 |
#!/usr/bin/env python3
import sys
class Node(object):
def __init__(self, parent_id=-1, depth=0, children=[]):
self.parent_id = parent_id
self.depth = depth
self.children = children
if __name__ == "__main__":
lines = sys.stdin.readlines()
node_list = [None] * int(lines[0])
child_parent_map = [None] * int(lines[0])
# Create the list of Node
for line in lines[1:]:
node_id, _, *children = [int(x) for x in line.strip().split(" ")]
node_list[node_id] = Node(children=children)
for child in children:
child_parent_map[child] = node_id
# Set the parent_id of each node
for node_id, node in enumerate(node_list):
if child_parent_map[node_id] is not None:
node.parent_id = child_parent_map[node_id]
# Set the depth of each node
for node_id, node in enumerate(node_list):
current_id = node_id
current_depth = 0
while True:
# if current_id == 0:
if node_list[current_id].parent_id == -1:
node.depth = current_depth
break
else:
current_id = node_list[current_id].parent_id
current_depth += 1
# Output
for node_id, node in enumerate(node_list):
if node.parent_id == -1:
node_type = "root"
elif len(node.children) == 0:
node_type = "leaf"
else:
node_type = "internal node"
print("node %d: parent = %d, depth = %d, %s, %s" % (node_id, node.parent_id, node.depth, node_type, node.children))
|
s224811468
|
p02258
|
u110280195
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,032 | 196 |
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen. Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
|
from collections import defaultdict
import math
if __name__ == '__main__' :
n = int(input())
R = [int(input()) for i in range(n)]
tmp = [max(R[i+1::]) - R[i] for i in range(n-1)]
|
s536207920
|
Accepted
| 590 | 14,060 | 298 |
from collections import defaultdict
import math
if __name__ == '__main__' :
n = int(input())
R = [int(input()) for i in range(n)]
maxv = R[1]-R[0]
minv = min(R[0],R[1])
for j in range(2,n):
maxv = max(maxv,R[j]-minv)
minv = min(minv,R[j])
print(maxv)
|
s239922025
|
p03578
|
u463655976
| 2,000 | 262,144 |
Wrong Answer
| 340 | 67,808 | 294 |
Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems. Determine whether Rng can complete the problem set without creating new candidates of problems.
|
import sys
from collections import Counter
input()
D = map(int, input().split())
input()
T = map(int, input().split())
CD = Counter(D)
CT = Counter(T)
for x in CD:
c = CT.get(x)
if not c is None and CD[x] <= c:
pass
else:
break
else:
print("YES")
sys.exit()
print("NO")
|
s732471256
|
Accepted
| 324 | 67,808 | 290 |
import sys
from collections import Counter
input()
D = map(int, input().split())
input()
T = map(int, input().split())
CD = Counter(D)
CT = Counter(T)
for x in CT:
c = CD.get(x)
if not c is None and CT[x] <= c:
pass
else:
break
else:
print("YES")
sys.exit()
print("NO")
|
s597755111
|
p02612
|
u135632715
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,084 | 53 |
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.
|
x = int(input())
while x<=0:
x -=1000
print(abs(x))
|
s441571916
|
Accepted
| 28 | 9,088 | 57 |
x = int(input())
while x > 0:
x -= 1000
print(abs(x))
|
s194886732
|
p02406
|
u027874809
| 1,000 | 131,072 |
Wrong Answer
| 10 | 5,580 | 67 |
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
|
n = int(input())
for x in range(3, n+1, 3):
print(x, end=' ')
|
s420920564
|
Accepted
| 20 | 5,632 | 135 |
n = int(input())
result = ''
for x in range(3, n+1):
if x % 3 == 0 or '3' in str(x):
result += (' '+str(x))
print(result)
|
s914699215
|
p03471
|
u598229387
| 2,000 | 262,144 |
Wrong Answer
| 313 | 2,940 | 220 |
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
n,y=map(int, input().split())
for i in range(y//10000+1):
for j in range(y//5000+1):
if 10000*i + 5000*j +1000*(n-i-j) == y:
print(i,j,n-i-j)
break
else:
continue
break
|
s349319000
|
Accepted
| 681 | 3,060 | 188 |
n,y=map(int,input().split())
ans=[-1,-1,-1]
for i in range(n+1):
for j in range(n+1-i):
if y-i*10000-j*5000==1000*(n-i-j):
ans=[i,j,n-i-j]
print(*ans)
|
s741325838
|
p03592
|
u314050667
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 198 |
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.
|
import sys
n,m,k = map(int, input().split())
for a in range(n):
if n-2*a == 0:
continue
b = ((k-a*m))/(n-2*a)
if (b >= 0) and (b <= m) and (b%1 == 0):
print("YES")
sys.exit()
print("NO")
|
s593547787
|
Accepted
| 18 | 3,060 | 198 |
import sys
n,m,k = map(int, input().split())
for a in range(n):
if n-2*a == 0:
continue
b = ((k-a*m))/(n-2*a)
if (b >= 0) and (b <= m) and (b%1 == 0):
print("Yes")
sys.exit()
print("No")
|
s956104083
|
p02743
|
u731448038
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 127 |
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
|
a, b, c = map(int, input().split())
import math
if math.sqrt(a)+math.sqrt(b)>math.sqrt(c):
print('Yes')
else:
print('No')
|
s323062736
|
Accepted
| 17 | 3,060 | 147 |
a, b, c = map(int, input().split())
import math
if (a+b)>=c:
print('No')
elif 4*a*b<c**2-2*c*(a+b)+(a+b)**2:
print('Yes')
else:
print('No')
|
s449781422
|
p03657
|
u991567869
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 116 |
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
|
a, b = map(int, input().split())
if a%3 == 0 or b %3 == 0 or (a + b)%3 == 0:
print("Yes")
else:
print("No")
|
s115351364
|
Accepted
| 17 | 2,940 | 129 |
a, b = map(int, input().split())
if a%3 == 0 or b %3 == 0 or (a + b)%3 == 0:
print("Possible")
else:
print("Impossible")
|
s234781689
|
p02742
|
u750651325
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 2,940 | 101 |
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
H, W = map(int, input().split())
x = H * W
if x % 2 == 0:
print(x/2)
else:
print(x//2 + 1)
|
s967589246
|
Accepted
| 17 | 2,940 | 167 |
H, W = map(int, input().split())
x = H * W
if H == 1 or W == 1:
print(1)
else:
if x % 2 == 0:
print(int(x/2))
else:
print(int(x//2 + 1))
|
s593142802
|
p03400
|
u624475441
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 92 |
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp.
|
N=int(input())
D,X=map(int,input().split())
print(1+sum((D-1)//int(input())for _ in[0]*N)+X)
|
s641956943
|
Accepted
| 17 | 2,940 | 92 |
N=int(input())
D,X=map(int,input().split())
print(sum(1+(D-1)//int(input())for _ in[0]*N)+X)
|
s818684033
|
p03379
|
u606045429
| 2,000 | 262,144 |
Wrong Answer
| 306 | 25,620 | 187 |
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
|
N = int(input())
X = [int(i) for i in input().split()]
Y = sorted(X)
a = Y[-1 + N // 2]
b = Y[N // 2]
print(a, b)
for Xi in X:
if Xi <= a:
print(b)
else:
print(a)
|
s003559196
|
Accepted
| 321 | 26,772 | 175 |
N = int(input())
X = [int(i) for i in input().split()]
Y = sorted(X)
a = Y[-1 + N // 2]
b = Y[N // 2]
for Xi in X:
if Xi <= a:
print(b)
else:
print(a)
|
s599124524
|
p03943
|
u108377418
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 318 |
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.
|
def main():
list = [int(x) for x in input().split()]
sum = list[0] + list[1] + list[2]
max = list[0]
if max <= list[1]:
max = list[1]
if max <= list[2]:
max = list[2]
if max * 2 == sum:
print("YES")
else:
print("NO")
if __name__ == "__main__":
main()
|
s619810631
|
Accepted
| 17 | 2,940 | 191 |
def main():
a, b, c = map(int, input().split() )
if a == b + c or b == c + a or c == a + b:
print("Yes")
else:
print("No")
if __name__ == "__main__":
main()
|
s098650238
|
p02669
|
u073852194
| 2,000 | 1,048,576 |
Wrong Answer
| 417 | 30,192 | 863 |
You start with the number 0 and you want to reach the number N. You can change the number, paying a certain amount of coins, with the following operations: * Multiply the number by 2, paying A coins. * Multiply the number by 3, paying B coins. * Multiply the number by 5, paying C coins. * Increase or decrease the number by 1, paying D coins. You can perform these operations in arbitrary order and an arbitrary number of times. What is the minimum number of coins you need to reach N? **You have to solve T testcases.**
|
import sys
sys.setrecursionlimit(2147483647)
from functools import lru_cache
@lru_cache(maxsize=None)
def solve(n, a, b, c, d):
if n == 0:
return 0
if n == 1:
return d
res = 10**18
res = min(res, d * n)
res = min(res, d * (n - n // 2 * 2) + a + solve(n // 2, a, b, c, d))
res = min(res, d * (n - n // 3 * 3) + b + solve(n // 3, a, b, c, d))
res = min(res, d * (n - n // 5 * 5) + c + solve(n // 5, a, b, c, d))
res = min(res, d * (n - (n + 2 - 1) // 2 * 2 + a + solve((n + 2 - 1) // 2, a, b, c, d)))
res = min(res, d * (n - (n + 3 - 1) // 3 * 3 + b + solve((n + 3 - 1) // 3, a, b, c, d)))
res = min(res, d * (n - (n + 5 - 1) // 5 * 5 + c + solve((n + 5 - 1) // 5, a, b, c, d)))
return res
T = int(input())
for _ in range(T):
N, A, B, C, D = map(int, input().split())
print(solve(N, A, B, C, D))
|
s519900789
|
Accepted
| 409 | 29,620 | 863 |
import sys
sys.setrecursionlimit(2147483647)
from functools import lru_cache
@lru_cache(maxsize=None)
def solve(n, a, b, c, d):
if n == 0:
return 0
if n == 1:
return d
res = 10**18
res = min(res, d * n)
res = min(res, d * (n - n // 2 * 2) + a + solve(n // 2, a, b, c, d))
res = min(res, d * (n - n // 3 * 3) + b + solve(n // 3, a, b, c, d))
res = min(res, d * (n - n // 5 * 5) + c + solve(n // 5, a, b, c, d))
res = min(res, d * ((n + 2 - 1) // 2 * 2 - n) + a + solve((n + 2 - 1) // 2, a, b, c, d))
res = min(res, d * ((n + 3 - 1) // 3 * 3 - n) + b + solve((n + 3 - 1) // 3, a, b, c, d))
res = min(res, d * ((n + 5 - 1) // 5 * 5 - n) + c + solve((n + 5 - 1) // 5, a, b, c, d))
return res
T = int(input())
for _ in range(T):
N, A, B, C, D = map(int, input().split())
print(solve(N, A, B, C, D))
|
s807309984
|
p02646
|
u025463382
| 2,000 | 1,048,576 |
Wrong Answer
| 22 | 9,184 | 189 |
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
a,v = map(int,input().split())
b,u = map(int,input().split())
t = int(input())
if v >= u:
print('NO')
quit()
dis = (u-v) * t
f = abs(a-b)
if f <= dis:
print('YES')
else:
print('NO')
|
s266552961
|
Accepted
| 24 | 9,208 | 189 |
a,u = map(int,input().split())
b,v = map(int,input().split())
t = int(input())
if v >= u:
print('NO')
quit()
dis = (u-v) * t
f = abs(a-b)
if f <= dis:
print('YES')
else:
print('NO')
|
s367479676
|
p03828
|
u790877102
| 2,000 | 262,144 |
Wrong Answer
| 36 | 3,064 | 278 |
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.
|
n = int(input())
s = [2]
q = 1
for i in range(n):
if i<3:
continue
t = []
for j in range(len(s)):
t.append((i)%s[j])
if 0 in t:
q = 3
else:
s.append(i)
x = 1
for i in range(len(s)):
m = 0
for j in range(10):
m += n//(s[i]**(j+1))
x *= m+1
print(x%(10**9+7))
|
s980826413
|
Accepted
| 37 | 3,064 | 281 |
n = int(input())
s = [2]
q = 1
for i in range(n+1):
if i<3:
continue
t = []
for j in range(len(s)):
t.append((i)%s[j])
if 0 in t:
q = 3
else:
s.append(i)
x = 1
for i in range(len(s)):
m = 0
for j in range(10):
m += n//(s[i]**(j+1))
x *= m+1
print(x%(10**9+7))
|
s930198857
|
p02659
|
u582759840
| 2,000 | 1,048,576 |
Wrong Answer
| 24 | 9,156 | 75 |
Compute A \times B, truncate its fractional part, and print the result as an integer.
|
inputs = input().split(' ')
a,b = int(inputs[0]), float(inputs[1])
int(a*b)
|
s806768885
|
Accepted
| 26 | 10,084 | 132 |
import math
from decimal import Decimal
inputs = input().split(' ')
a,b = int(inputs[0]), Decimal(inputs[1])
print(math.floor(a*b))
|
s083375198
|
p03696
|
u174273188
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 232 |
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.
|
def resolve():
s = input()
tmp = s
while "()" in tmp:
tmp.replace("()", "")
l = tmp.count("(")
r = tmp.count(")")
ans = "(" * r + s + ")" * l
print(ans)
if __name__ == "__main__":
resolve()
|
s379318144
|
Accepted
| 17 | 3,060 | 380 |
def resolve():
n = int(input())
s = input()
l, r = 0, 0
for c in s:
if c == "(":
l += 1
elif l > 0 and c == ")":
l -= 1
for c in s[::-1]:
if c == ")":
r += 1
elif r > 0 and c == "(":
r -= 1
ans = "(" * r + s + ")" * l
print(ans)
if __name__ == "__main__":
resolve()
|
s629698894
|
p03644
|
u777028980
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 173 |
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())
if(n<=64):
print(64)
elif(n<=32):
print(32)
elif(n<=16):
print(16)
elif(n<=8):
print(8)
elif(n<=4):
print(4)
elif(n<=2):
print(2)
else:
print(1)
|
s716392065
|
Accepted
| 18 | 2,940 | 175 |
n=int(input())
if(n>=64):
print(64)
elif(n>=32):
print(32)
elif(n>=16):
print(16)
elif(n>=8):
print(8)
elif(n>=4):
print(4)
elif(n>=2):
print(2)
else:
print(1)
|
s503536821
|
p02606
|
u558115145
| 2,000 | 1,048,576 |
Wrong Answer
| 26 | 9,072 | 82 |
How many multiples of d are there among the integers between L and R (inclusive)?
|
c=0
a,b,d=map(int,input().split())
for i in range(a,b):
if i%d==0: c+=1
print(c)
|
s836854846
|
Accepted
| 26 | 9,104 | 84 |
c=0
a,b,d=map(int,input().split())
for i in range(a,b+1):
if i%d==0: c+=1
print(c)
|
s812785636
|
p03386
|
u629350026
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 135 |
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
a,b,k=map(int,input().split())
ans=[]
for i in range(0,k):
ans.append(a+i)
ans.append(b-i)
ans=list(set(ans))
ans.sort()
print(ans)
|
s962037988
|
Accepted
| 17 | 3,060 | 183 |
a,b,k=map(int,input().split())
ans=[]
i=0
while i<k and a+i<=b-i:
ans.append(a+i)
ans.append(b-i)
i=i+1
ans=list(set(ans))
ans.sort()
for i in range(0,len(ans)):
print(ans[i])
|
s308881438
|
p03303
|
u802963389
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,188 | 253 |
You are given a string S consisting of lowercase English letters. We will write down this string, starting a new line after every w letters. Print the string obtained by concatenating the letters at the beginnings of these lines from top to bottom.
|
# B - Acrostic
# https://atcoder.jp/contests/soundhound2018-summer-qual/tasks/soundhound2018_summer_qual_b
S = input()
w = int(input())
sp = [S[i: i+w] for i in range(0, len(S), w)]
for s in sp:
print(s)
|
s337148875
|
Accepted
| 17 | 2,940 | 274 |
# B - Acrostic
# https://atcoder.jp/contests/soundhound2018-summer-qual/tasks/soundhound2018_summer_qual_b
S = input()
w = int(input())
sp = [S[i: i+w] for i in range(0, len(S), w)]
ans = "".join(s[0] for s in sp)
print(ans)
|
s439435444
|
p03131
|
u227085629
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 126 |
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
|
k,a,b = map(int,input().split())
if a >= b+2:
print(k+1)
else:
d = k-(a-1)
e = a
e += (b-a)*d//2
e += d%2
print(e)
|
s709229483
|
Accepted
| 17 | 3,060 | 128 |
k,a,b = map(int,input().split())
if a >= b-2:
print(k+1)
else:
d = k-(a-1)
e = a
e += (b-a)*(d//2)
e += d%2
print(e)
|
s500723011
|
p03080
|
u217530935
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 213 |
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
|
N = int(input())
s = str(input())
print(s)
cntA = 0
cntB = 0
for i in s:
if i == "R":
cntA = cntA + 1
else:
cntB = cntB + 1
if cntA > cntB:
print("Yes")
else:
print("No")
|
s355290940
|
Accepted
| 17 | 2,940 | 204 |
N = int(input())
s = str(input())
cntA = 0
cntB = 0
for i in s:
if i == "R":
cntA = cntA + 1
else:
cntB = cntB + 1
if cntA > cntB:
print("Yes")
else:
print("No")
|
s677080537
|
p03545
|
u766566560
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 238 |
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
S = input()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])
if A + B + C + D == 7 or A - B - C - D == 7 or A + B + C - D == 7 or A - B + C + D == 7 or A - B - C + D == 7 or A - B + C - D == 7 or A + B - C + D == 7:
print('YES')
|
s305716506
|
Accepted
| 17 | 3,064 | 786 |
S = input()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])
if A + B + C + D == 7:
print(S[0] + '+' + S[1] + '+' + S[2] + '+' + S[3] + '=' + '7')
elif A - B - C - D == 7:
print(S[0] + '-' + S[1] + '-' + S[2] + '-' + S[3] + '=' + '7')
elif A + B - C - D == 7:
print(S[0] + '+' + S[1] + '-' + S[2] + '-' + S[3] + '=' + '7')
elif A - B + C + D == 7:
print(S[0] + '-' + S[1] + '+' + S[2] + '+' + S[3] + '=' + '7')
elif A - B - C + D == 7:
print(S[0] + '-' + S[1] + '-' + S[2] + '+' + S[3] + '=' + '7')
elif A - B + C - D == 7:
print(S[0] + '-' + S[1] + '+' + S[2] + '-' + S[3] + '=' + '7')
elif A + B - C + D == 7:
print(S[0] + '+' + S[1] + '-' + S[2] + '+' + S[3] + '=' + '7')
elif A + B + C - D == 7:
print(S[0] + '+' + S[1] + '+' + S[2] + '-' + S[3] + '=' + '7')
|
s293499945
|
p03486
|
u272495679
| 2,000 | 262,144 |
Wrong Answer
| 30 | 8,908 | 236 |
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
s = input()
t = input()
s_list = list(s)
t_list = list(t)
s_sorted = sorted(s_list)
t_sorted = sorted(t_list)
s_joined = ''.join(s_sorted)
t_joined = ''.join(t_sorted)
if s_joined < t_joined:
print("Yes")
else:
print("No")
|
s257179234
|
Accepted
| 28 | 9,056 | 250 |
s = input()
t = input()
s_list = list(s)
t_list = list(t)
s_sorted = sorted(s_list)
t_sorted = sorted(t_list, reverse=True)
s_joined = ''.join(s_sorted)
t_joined = ''.join(t_sorted)
if s_joined < t_joined:
print("Yes")
else:
print("No")
|
s664442922
|
p03712
|
u759412327
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 160 |
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
|
H,W = list(map(int,input().split()))
a = [input() for i in range(H)]
for i in range(H+2):
if i==0 or i==H+1:
"#"*(W+2)
else:
print("#"+a[i-1]+"#")
|
s452567045
|
Accepted
| 25 | 9,084 | 109 |
H,W = map(int,input().split())
print((W+2)*"#")
for h in range(H):
print("#"+input()+"#")
print((W+2)*"#")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.