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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s888979543 | p03712 | u874741582 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 130 | 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())
l=[str(input()) for i in range(h)]
p="*"
print(p*(w+2))
for j in l:
print(p+j+p)
print(p*(w+2)) | s559420197 | Accepted | 17 | 3,060 | 130 | h,w = map(int,input().split())
l=[str(input()) for i in range(h)]
p="#"
print(p*(w+2))
for j in l:
print(p+j+p)
print(p*(w+2)) |
s838631681 | p03415 | u921826483 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 263 | We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bot... | a = input()
b = input()
c = input()
A = [0]*3
ca = 0
cb = 0
cc = 0
for d in a:
ca +=1
if(ca == 1):
A[0] = d
for e in b:
cb +=1
if(cb == 1):
A[1] = e
for f in c:
cc +=1
if(cc == 1):
A[2] = f
print(A[0]+A[1]+A[2]) | s904175149 | Accepted | 18 | 2,940 | 61 | a = input()
b = input()
c = input()
print(a[0] + b[1] + c[2]) |
s842787354 | p03760 | u717265305 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 167 | Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the... | o, e = [list(input()) for _ in range(2)]
ans = []
for i in range(len(o)):
ans.append(o[i])
if len(o)==len(e):
ans.append(e[i])
for j in ans:
print(j, end='') | s458311336 | Accepted | 17 | 3,060 | 163 | o, e = [list(input()) for _ in range(2)]
ans = ''
for i in range(len(o)):
ans += o[i]
if i == len(o)-1 and len(o) != len(e):
break
ans += e[i]
print(ans) |
s825760202 | p03730 | u572373398 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 145 | 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 objecti... | a, b, c = map(int, input().split())
for i in range(a, a * b + 1, a):
if i % b == c:
print('Yes')
break
else:
print('No') | s222867377 | Accepted | 17 | 2,940 | 151 | a, b, c = map(int, input().split())
for i in range(1, 1001):
n = i * a
if n % b == c:
print('YES')
break
else:
print('NO') |
s386768518 | p03455 | u030410515 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 95 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | a,b = map(int,input().split())
c = a*b % 2
if c == 0:
print("even")
else:
print("odd")
| s620907948 | Accepted | 17 | 3,064 | 95 | a,b = map(int,input().split())
c = a*b % 2
if c == 0:
print("Even")
else:
print("Odd")
|
s326166764 | p02936 | u441254033 | 2,000 | 1,048,576 | Wrong Answer | 1,291 | 36,896 | 445 | Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operati... | n, q = map(int, input().split())
ki = [0] * (n + 1)
for i in range(n - 1):
a, b = map(int, input().split())
ki[b] = a
# print("ki=",ki)
c = [0] * (n + 1)
for i in range(q):
p, x = map(int, input().split())
c[p] += x
# print("c=",c)
の点数を足す
for i in range(1, n + 1):
c[i] += c[ki[i]]
# print(c)
... | s424542170 | Accepted | 1,599 | 232,312 | 804 | import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
N, Q = map(int,input().split())
# AB = [[int(x) for x in input().split()] for _ in range(N-1)]
graph = [[] for _ in range(N+1)]
for _ in range(N-1):
a, b = map(int, input().split())
graph[a].append(b)
graph[b].append(a)
# print(grap... |
s348854577 | p03544 | u839857256 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 197 | It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2) | n = int(input())
l0 = 2
l1 = 1
if n == 1:
print(l0)
elif n == 2:
print(l1)
else:
ans = 0
for i in range(n-2):
ans = l0 + l1
l0 = l1
l1 = ans
print(ans)
| s650954091 | Accepted | 17 | 2,940 | 170 | n = int(input())
l0 = 2
l1 = 1
if n == 1:
print(l1)
else:
ans = 0
for i in range(n-1):
ans = l0 + l1
l0 = l1
l1 = ans
print(ans)
|
s270541083 | p02663 | u938350027 | 2,000 | 1,048,576 | Wrong Answer | 24 | 9,172 | 9 | In this problem, we use the 24-hour clock. Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying? | print(-1) | s168845289 | Accepted | 23 | 9,188 | 284 |
def main():
line = list(map(int,input().split()))
H1 = line[0]
M1 = line[1]
H2 = line[2]
M2 = line[3]
K = line[4]
h = H2-H1
m = M2 - M1
if m < 0:
h -= 1
m %= 60
k = h*60+m-K
print(k)
if __name__ == "__main__":
main()
|
s451568966 | p03625 | u763741681 | 2,000 | 262,144 | Wrong Answer | 2,104 | 14,252 | 348 | We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle. |
N=int(input())
A=list(map(int,input().split()))
A.sort
max1=0
max2=0
max3=0
max4=0
for i in range(0,len(A)):
if A.count(A[i])>=2:
a=max1
b=max2
c=max3
max1=A[i]
max2=a
max3=b
max4=c
print(max1*max4) | s925086317 | Accepted | 131 | 14,252 | 386 |
N=int(input())
A=list(map(int,input().split()))
A.sort()
max1=0
max2=0
if A[0]==A[1]:
a=max1
max1=A[0]
max2=a
for i in range(2,len(A)-1):
if A[i]==A[i+1] and (A[i]!=A[i-1] or A[i]==A[i-1]==A[i-2]):
a=max1
max1=A[i]
max2=a
print(max1*max2) |
s451207218 | p02259 | u192145025 | 1,000 | 131,072 | Wrong Answer | 20 | 5,592 | 403 | Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, in... | def sort(A, exchange):
for i in range(0, len(A) - 1):
if modify_order(A, i) == 0:
break
def modify_order(A, i):
exchange = 0
for j in range(len(A) - 1, i, -1):
if A[j - 1] > A[j]:
A[j - 1], A[j] = A[j], A[j - 1]
exchange = exchange + 1
n = int(input())
... | s546740047 | Accepted | 20 | 5,612 | 420 | n = int(input())
s = list(map(int, input().strip().split(' ')))
e = int()
e = 0
flag = True
while flag:
flag = False
for i in range(n - 1, 0, -1):
if s[i] < s[i - 1]:
s[i - 1], s[i] = s[i], s[i - 1]
e = e + 1
flag = True
for i in range(0 , len... |
s221272717 | p03380 | u065446124 | 2,000 | 262,144 | Wrong Answer | 2,104 | 14,300 | 183 | Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. | from math import factorial
n=int(input())
a=list(map(int,input().split()))
def comb(n,r):
return factorial(n)//factorial(n-r)//factorial(r)
print(max([comb(max(a),i) for i in a])) | s382583818 | Accepted | 65 | 14,428 | 150 | n=int(input())
a=list(map(int,input().split()))
n=max(a)
a.remove(n)
t=n
for i in a:
if(t>abs(n/2-i)):
t=abs(n/2-i)
r=i
print(n,r) |
s879870127 | p03436 | u829895669 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 550 | We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player re... | H,W = map(int, input().split())
S = [input() for i in range(H)]
queue = [(0,0,1)]
done ={(0,0)}
count = sum(row.count("#") for row in S)
def bfs(x,y,c):
if(x<0 or y<0 or x>-W or y>=H or S[y][x]=="#"):
return
if(x,y) in done:
return
queue.append((x,y,c+1))
done.add((x,y))
dx =... | s306383799 | Accepted | 27 | 3,444 | 550 | H,W = map(int, input().split())
S = [input() for i in range(H)]
queue = [(0,0,1)]
done ={(0,0)}
count = sum(row.count("#") for row in S)
def bfs(x,y,c):
if(x<0 or y<0 or x>=W or y>=H or S[y][x]=="#"):
return
if(x,y) in done:
return
queue.append((x,y,c+1))
done.add((x,y))
dx =... |
s625212102 | p04025 | u298297089 | 2,000 | 262,144 | Wrong Answer | 25 | 3,060 | 202 | Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (... | n = int(input())
a = list(map(int,input().split()))
mn = min(a)
mx = max(a)+1
ans = 0
for i in range(mn, mx):
cost = 0
for aa in a:
cost += (i - aa)**2
if ans > cost:
ans = cost
print(ans) | s443620439 | Accepted | 25 | 3,064 | 206 | n = int(input())
a = list(map(int,input().split()))
mn = min(a)
mx = max(a)+1
ans = 10**9
for i in range(mn, mx):
cost = 0
for aa in a:
cost += (i - aa)**2
if ans > cost:
ans = cost
print(ans) |
s243892007 | p02902 | u581187895 | 2,000 | 1,048,576 | Wrong Answer | 499 | 9,560 | 1,264 | Given is a directed graph G with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i. It is guaranteed that the graph contains no self-loops or multiple edges. Determine whether there exists an induced subgraph (see Notes) of G such that the in-degr... |
from collections import deque
def resolve():
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
a, b = map(lambda x: int(x) - 1, input().split())
G[a].append(b)
shortest = N + 1
res = []
for s in range(N):
dist = [-1] * N
pre = [-1] *... | s787032546 | Accepted | 450 | 9,712 | 1,271 |
from collections import deque
def resolve():
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
a, b = map(lambda x: int(x) - 1, input().split())
G[a].append(b)
shortest = N + 1
res = []
for s in range(N):
dist = [-1] * N
pre = [-1] *... |
s087947406 | p04029 | u442948527 | 2,000 | 262,144 | Wrong Answer | 28 | 8,996 | 31 | There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total? | n=int(input())
print(n*(n+1)/2) | s868245365 | Accepted | 28 | 9,084 | 32 | n=int(input())
print(n*(n+1)//2) |
s613167997 | p04011 | u055941944 | 2,000 | 262,144 | Wrong Answer | 21 | 3,316 | 149 | There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee. | from collections import Counter
w=list(str(input()))
h=set(w)
for i in h:
if w.count(i)%2!=0:
print("No")
exit()
print("Yes")
| s345408134 | Accepted | 18 | 2,940 | 176 | # -*- coding utf-8 -*-
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n <= k :
print(n*x)
elif k < n :
ans = (k*x) + (y*(n-k))
print(ans)
|
s709969964 | p04043 | u971328381 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 128 | 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 ... | l=(int,input().split())
f=len([i for i in l if i == 5])==2
s=len([i for i in l if i == 7])==1
print( 'YES' if f and s else 'NO') | s487509300 | Accepted | 17 | 3,064 | 225 | def k(a,i1,i2):
if(a==7):
i1 = i1+1
if(a==5):
i2 = i2+1
return i1,i2
a,b,c=map(int,input().split())
i1=0
i2=0
i1,i2 = k(a,i1,i2)
i1,i2 = k(b,i1,i2)
i1,i2 = k(c,i1,i2)
print('YES' if i1==1 and i2==2 else 'NO') |
s187617687 | p03139 | u926678805 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 69 | We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answ... | # coding: utf-8
n,a,b=map(int,input().split())
print(min(a,b),a+b-n)
| s057550645 | Accepted | 17 | 2,940 | 75 | # coding: utf-8
n,a,b=map(int,input().split())
print(min(a,b),max(a+b-n,0)) |
s246552390 | p03485 | u515231557 | 2,000 | 262,144 | Wrong Answer | 27 | 9,108 | 120 | You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer. | a, b = (int(x) for x in input().split(' '))
s = (a + b) % 2
t = (a + b) / 2
if s == 0:
print(t)
else:
print(t+0.5) | s030709652 | Accepted | 26 | 9,080 | 88 | import math
a, b = (int(t) for t in input().split())
x = (a + b) / 2
print(math.ceil(x)) |
s513952512 | p03679 | u386819480 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 146 | Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Ot... | x,a,b = (int(_) for _ in input().split())
if b <= a:
print('delicious')
elif a < b <= x:
print('safe')
elif b > x:
print('dangerous') | s950242041 | Accepted | 17 | 3,060 | 150 | x,a,b = (int(_) for _ in input().split())
if b <= a:
print('delicious')
elif a < b <= a+x:
print('safe')
elif b > a+x:
print('dangerous') |
s902681079 | p03470 | u006167882 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 197 | An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you h... | N = int(input())
d = []
for i in range(N):
d.append(int(input()))
mochi = []
for i in range(N):
if mochi.count(d[i]) == 0:
print(d[i])
mochi.append(d[i])
print(len(mochi)) | s669681616 | Accepted | 17 | 3,060 | 190 | N = int(input())
d = []
for i in range(N):
d.append(int(input()))
mochi = []
for i in range(N):
if mochi.count(d[i]) == 0:
mochi.append(d[i])
print("{}".format(len(mochi))) |
s076622891 | p02390 | u921541953 | 1,000 | 131,072 | Wrong Answer | 30 | 7,532 | 154 | Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively. | second = int(input('Input second:'))
h = second // 3600
m = second % 3600 // 60
s = second - (h * 3600) - (m * 60)
print(("{0}:{1}:{2}").format(h, m, s)) | s363783012 | Accepted | 20 | 7,608 | 141 | second = int(input())
h = second // 3600
m = (second - (h * 3600)) // 60
s = second - (h * 3600) - (m * 60)
print('{}:{}:{}'.format(h, m, s)) |
s500555599 | p02262 | u657361950 | 6,000 | 131,072 | Wrong Answer | 20 | 5,616 | 568 | 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+... | import sys
def print_arr(arr):
for i in range(len(arr)):
sys.stdout.write(str(arr[i]))
if i != len(arr) - 1:
sys.stdout.write(' ')
print()
def insertion_sort(arr, n, g):
cnt = 0
for i in range(g, n):
v = arr[i]
j = i - g
while j >= 0 and arr[j] > v:
arr[j + g] = arr[j]
j = j - g
cnt += 1
a... | s325395904 | Accepted | 19,200 | 45,480 | 817 | import sys
def print_arr(arr):
for i in range(len(arr)):
sys.stdout.write(str(arr[i]))
if i != len(arr) - 1:
sys.stdout.write(' ')
print()
def insertion_sort(arr, g):
n = len(arr)
cnt = 0
for i in range(n):
key = arr[i]
j = i - g
while j >= 0 and arr[j] > key:
arr[j + g] = arr[j]
j -= g
cnt... |
s998897350 | p02392 | u373340964 | 1,000 | 131,072 | Wrong Answer | 20 | 5,584 | 89 | Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No". | a, b, c = map(int, input().split())
if a < b < c:
print("yes")
else:
print("no")
| s420512853 | Accepted | 20 | 5,588 | 89 | a, b, c = map(int, input().split())
if a < b < c:
print("Yes")
else:
print("No")
|
s787306288 | p03730 | u967822229 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 153 | 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 objecti... | A,B,C = map(int, input().split())
sum=A
while sum % B != 0:
sum = sum + A
if sum%B==C:
print("Yes")
break
else:
print("No") | s256027692 | Accepted | 17 | 2,940 | 185 | def gcd(x, y):
if x<y: gcd(y, x)
while y:
x, y = y, x%y
return x
A, B, C = map(int, input().split())
if C % gcd(A, B) == 0:
print('YES')
else:
print('NO') |
s694272261 | p03456 | u609738635 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 171 | AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number. | a,b = map(str, input().split())
c = int(a+b)
flag = False
for i in range(1000):
if i**2 == c:
flag = True
exit(0)
print("Yes") if flag else print("No") | s252849294 | Accepted | 17 | 2,940 | 88 | a, b = input().split()
x = int(a + b)
print('Yes' if (x ** 0.5).is_integer() else 'No' ) |
s055571741 | p03457 | u987164499 | 2,000 | 262,144 | Wrong Answer | 2,230 | 2,004,572 | 613 | AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1... | from sys import stdin
import statistics
from math import factorial
import math
n = int(stdin.readline().rstrip())
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
from itertools import combinations
lin = list(combinations(li,2))
lis = []
for i in range(len(lin)):
a = (lin[i][1][1]-li... | s530267149 | Accepted | 420 | 21,512 | 728 | from sys import stdin
from itertools import combinations
from math import factorial
import numpy as np
import math
n = int(stdin.readline().rstrip())
t = [0]*n
x = [0]*n
y = [0]*n
for i in range(n):
t[i],x[i],y[i] = [int(x) for x in stdin.readline().rstrip().split()]
t = [0] + t
x = [0] + x
y = [0] + y
if n == ... |
s605669799 | p03352 | u013408661 | 2,000 | 1,048,576 | Time Limit Exceeded | 2,109 | 119,576 | 183 | You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2. | num=[]
for i in range(32):
stack=i*i
while stack<=1000:
num.append(stack)
stack*=i
num.sort()
num.reverse()
n=int(input())
for i in num:
if i<=n:
print(i)
exit() | s413110219 | Accepted | 17 | 3,060 | 186 | num=[1]
for i in range(2,32):
stack=i*i
while stack<=1000:
num.append(stack)
stack*=i
num.sort()
num.reverse()
n=int(input())
for i in num:
if i<=n:
print(i)
exit() |
s470887907 | p03645 | u340643636 | 2,000 | 262,144 | Wrong Answer | 726 | 30,648 | 317 | In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk... | d={}
n,m = map(int,input().split())
for _ in range(m):
i,j = map(int,input().split())
if j in d:
d[j].append(i)
else:
d[j]=[i]
flag=0
if n in d:
for item in d[n]:
if item in d and '1' in d[item]:
flag=1
break
print('POSSIBLE' if flag else 'IMPOSSIBLE')
| s046414188 | Accepted | 569 | 18,428 | 254 | a=[]
b={}
n,m = map(int,input().split())
for _ in range(m):
i,j = map(int,input().split())
if i==1:
a.append(j)
elif j==n:
b[i]=1
for i in a:
if i in b:
print('POSSIBLE')
break
else:
print('IMPOSSIBLE') |
s615523287 | p03644 | u579475320 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 81 | 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... | n = int(input())
for p in range(n):
i = 2 ** p
if i > n:
break
print(i)
| s597682634 | Accepted | 16 | 2,940 | 96 | m = int(input())
a = 1
for c in range(7):
if (2 ** c) > m:
break
a = (2 ** c)
print(a)
|
s662542906 | p03827 | u905582793 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 133 | 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 duri... | n=int(input())
s=input()
ans=0
x=0
for i in range(n):
if s[i]=="I":
x+=1
if s[i]=="D":
x-=1
ans=max(ans,x)
print(ans) | s361704446 | Accepted | 18 | 3,060 | 131 | n=int(input())
s=input()
ans=0
x=0
for i in range(n):
if s[i]=="I":
x+=1
if s[i]=="D":
x-=1
ans=max(ans,x)
print(ans) |
s322482061 | p04031 | u375695365 | 2,000 | 262,144 | Wrong Answer | 21 | 3,316 | 324 | Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (... | import collections
n=int(input())
a=list(map(int,input().split() ))
absa=[]
za=[]
for i in range(n):
za.append(a[i]-(i+1))
#print(za)
#print(sum(za))
za.sort()
if n%2==1:
b=za[n//2]
else:
b=(za[n//2-1]+za[n//2])//2
#print(b)
for i in range(n):
absa.append(abs(a[i]-(b+(i+1))))
#print(absa)
print(sum(abs... | s382936832 | Accepted | 26 | 3,060 | 213 | n=int(input())
a=list(map(int,input().split()))
ans=10**9
ab=0
for i in range(-100,101):
count=0
for j in range(n):
count+=abs(a[j]-i)**2
if ans>count:
ans=count
ab=i
print(ans) |
s410959616 | p03635 | u329706129 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 47 | In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city? | n, m = map(int, input().split())
print(n-1*m-1) | s836331858 | Accepted | 17 | 2,940 | 58 | n, m = map(int, input().split())
print((n - 1) * (m - 1))
|
s172824369 | p02612 | u544165032 | 2,000 | 1,048,576 | Wrong Answer | 32 | 9,024 | 59 | 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())
while N >= 1000:
N = N - 1000
print(N) | s145087669 | Accepted | 29 | 9,092 | 73 | N = int(input())
while N > 1000:
N = N - 1000
else:
print(1000-N) |
s907605610 | p03047 | u097317219 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 98 | Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? | import math
N,K = map(int,input().split())
ans = math.factorial(N) / math.factorial(K)
print(ans)
| s718413285 | Accepted | 17 | 2,940 | 48 | N,K = map(int,input().split())
print(N - K + 1)
|
s157857422 | p03673 | u653807637 | 2,000 | 262,144 | Wrong Answer | 2,104 | 26,020 | 194 | You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations. | # encoding:utf-8
n = int(input())
ary = list(map(int, input().split()))
print(ary)
out = []
for i in range(n):
out.append(ary[i])
out.reverse()
out = list(map(str, out))
print(" ".join(out)) | s962739374 | Accepted | 91 | 34,372 | 374 | # encoding:utf-8
n = int(input())
ary = input().split()
if n % 2 == 0:
out = [i for i in range(2, n+1, 2)]
out.reverse()
out.extend([i for i in range(1, n, 2)])
out_str = [str(ary[i-1]) for i in out]
else:
out = [i for i in range(1, n + 1, 2)]
out.reverse()
out.extend([i for i in range(2, n, 2)])
out_str = [st... |
s922230711 | p03597 | u095094246 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 50 | We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black? | n=int(input())
a=int(input())
print(max(n*2-a, 0)) | s758810829 | Accepted | 17 | 2,940 | 51 | n=int(input())
a=int(input())
print(max(n**2-a, 0)) |
s742559190 | p03971 | u163320134 | 2,000 | 262,144 | Wrong Answer | 116 | 4,016 | 310 | There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from t... | n,a,b=map(int,input().split())
s=input()
cnt1=0
cnt2=0
for i in range(n):
if s[i]=='a':
if cnt1+cnt2<=a+b:
cnt1+=1
print('Yes')
else:
print('No')
elif s[i]=='b':
if cnt1+cnt2<=a+b and cnt2<b:
cnt2+=1
print('Yes')
else:
print('No')
else:
print('No') | s561123023 | Accepted | 118 | 4,016 | 308 | n,a,b=map(int,input().split())
s=input()
cnt1=0
cnt2=0
for i in range(n):
if s[i]=='a':
if cnt1+cnt2<a+b:
cnt1+=1
print('Yes')
else:
print('No')
elif s[i]=='b':
if cnt1+cnt2<a+b and cnt2<b:
cnt2+=1
print('Yes')
else:
print('No')
else:
print('No') |
s329108882 | p03854 | u637289184 | 2,000 | 262,144 | Wrong Answer | 29 | 9,016 | 369 | You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. | s = input()
s=s[::-1]
A=["dream","dreamer","erase","eraser"]
for i in range(len(A)):
A[i]=A[i][::-1]
i=0
while True:
if len(s)==i:
print("Yes")
break
elif s[i:i+5]==A[0]:
i+=5
elif s[i:7]==A[1]:
i+=7
elif s[i:i+5]==A[2]:
i+=5
elif s[i:i+6]==A[3]:
... | s912664822 | Accepted | 38 | 9,200 | 298 | s = input()
s=s[::-1]
i=0
ans="YES"
while True:
if len(s)==i:
break
elif s[i:i+5]=="maerd":
i+=5
elif s[i:i+7]=="remaerd":
i+=7
elif s[i:i+5]=='esare':
i+=5
elif s[i:i+6]=='resare':
i+=6
else:
ans="NO"
break
print(ans) |
s660407913 | p03720 | u551437236 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 182 | There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city? | n, m = map(int, input().split())
ll = [0] + [ 0 for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
ll[a] += 1
ll[b] += 1
for l in ll[1:]:
print()
| s234370183 | Accepted | 17 | 2,940 | 183 | n, m = map(int, input().split())
ll = [0] + [ 0 for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
ll[a] += 1
ll[b] += 1
for l in ll[1:]:
print(l)
|
s872933182 | p03493 | u142930449 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 154 | Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble. | a = input()
counter = 0
if a[0] == 1:
counter = counter + 1
if a[1] == 1:
counter = counter + 1
if a[2] == 1:
counter = counter + 1
print(counter) | s745266427 | Accepted | 19 | 3,064 | 160 | a = input()
counter = 0
if a[0] == '1':
counter = counter + 1
if a[1] == '1':
counter = counter + 1
if a[2] == '1':
counter = counter + 1
print(counter) |
s949735041 | p02645 | u549646027 | 2,000 | 1,048,576 | Wrong Answer | 22 | 9,084 | 53 | When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him. | S = input()
print (type(S), S) | s409517849 | Accepted | 22 | 9,080 | 49 | S = input()
print (S[0:3]) |
s754131046 | p03861 | u761062383 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 365 | You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x? | a, b, x = [int(i) for i in input().split()]
if a == b:
if a % x == 0:
print(1)
else:
print(0)
else:
n = b - a + 1
if n < x:
if a // x == b // x:
print(0)
else:
print(1)
else:
if b // x == (b - (b % x)) // x:
print(n // x)
... | s948503755 | Accepted | 18 | 2,940 | 112 | def resolve():
a, b, x = [int(i) for i in input().split()]
print((b // x) - ((a - 1) // x))
resolve()
|
s134425530 | p03228 | u941634132 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 232 | In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other pe... | #!/usr/bin/env python3
A, B, K = map(int,input().split())
for i in range(K):
if A % 2 == 1:
A -= 1
B += A / 2
A -= A / 2
if B % 2 == 1:
B -= 1
A += B / 2
B = B / 2
print(A, B)
| s253429693 | Accepted | 17 | 2,940 | 306 | #!/usr/bin/env python3
A, B, K = map(int,input().split())
for i in range(K):
if i % 2 == 0:
if A % 2 == 1:
A -= 1
B += A / 2
A -= A / 2
else:
if B % 2 == 1:
B -= 1
A += B / 2
B = B / 2
print(int(A),int(B))
|
s456112174 | p03997 | u243159381 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 62 | You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid. | a=int(input())
b=int(input())
h=int(input())
print((a+b)*h/2)
| s965010170 | Accepted | 17 | 2,940 | 71 | a=int(input())
b=int(input())
h=int(input())
ans=(a+b)*h//2
print(ans)
|
s846823423 | p02694 | u593442720 | 2,000 | 1,048,576 | Wrong Answer | 23 | 9,152 | 82 | 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 abo... | x = int(input())
a = 100
i = 0
while a <= x:
i += 1
a = int(a * 1.01)
print(i) | s799445138 | Accepted | 23 | 9,156 | 81 | x = int(input())
a = 100
i = 0
while a < x:
i += 1
a = int(a * 1.01)
print(i) |
s887504171 | p02612 | u967484343 | 2,000 | 1,048,576 | Wrong Answer | 30 | 9,140 | 33 | We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. | a = int(input())
print(a % 1000) | s581525779 | Accepted | 27 | 9,156 | 77 | a = int(input())
b = a % 1000
if b == 0:
print(0)
else:
print(1000 - b) |
s406705251 | p03457 | u599547273 | 2,000 | 262,144 | Wrong Answer | 325 | 21,156 | 368 | AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1... | # Relative rela
import sys
n = int(input())
txy_list = [[int(n) for n in input().split()] for i in range(n)]
before_x, before_y = 0, 0
for t, x, y in txy_list:
rela_x, rela_y = x - before_x, y - before_y
remaining = t - abs(rela_x) + abs(rela_y)
if 0 <= remaining and remaining % 2 == 0:
before_x, before_y = x, y... | s564579303 | Accepted | 333 | 17,408 | 213 | n = int(input())
txy = [tuple(map(int, input().split(" "))) for i in range(n)]
for txy_i in txy:
t, x, y = txy_i
remain = t - x - y
if not (0 <= remain and remain % 2 == 0):
print("No")
exit()
print("Yes") |
s583402908 | p03434 | u139716791 | 2,000 | 262,144 | Wrong Answer | 150 | 12,500 | 291 | 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 c... | # -*- coding: utf-8 -*-
import numpy
import scipy
N = int(input())
A = list(map(int, input().split()))
print(A)
A_sort = sorted(A, reverse=True)
print(A_sort)
alice = bob = 0
for i, a in enumerate(A_sort):
if i%2 == 0:
alice += a
else:
bob += a
print(alice - bob) | s421988596 | Accepted | 150 | 12,508 | 294 | # -*- coding: utf-8 -*-
import numpy
import scipy
N = int(input())
A = list(map(int, input().split()))
#print(A)
A_sort = sorted(A, reverse=True)
#print(A_sort)
alice = bob = 0
for i, a in enumerate(A_sort):
if i%2 == 0:
alice += a
else:
bob += a
print(alice - bob) |
s918233906 | p02613 | u557190902 | 2,000 | 1,048,576 | Wrong Answer | 148 | 9,028 | 347 | Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`,... | n = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in range(n):
s = input()
if s == "AC":
c0 += 1
if s == "WA":
c1 += 1
if s == "TLE":
c2 += 1
if s == "RE":
c3 += 1
print("AC" + "×" + str(c0))
print("WA" + "×" + str(c1))
print("TLE" + "×" + str(c2))
prin... | s931055619 | Accepted | 150 | 9,136 | 406 | n = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in range(n):
s = input()
if s == "AC":
c0 += 1
if s == "WA":
c1 += 1
if s == "TLE":
c2 += 1
if s == "RE":
c3 += 1
print('AC x ',end='')
print(c0)
print('WA x ',end='')
print(c1)
print('TLE x ',end='')
p... |
s516130251 | p03387 | u458725980 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 521 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be ... | def solve():
ABC = list(sorted(map(int, input().split())))
A, B, C = ABC[0], ABC[1], ABC[2]
count = 0
a, amod = divmod((C-A),2)
b, bmod = divmod((C-B),2)
A += a * 2
B += b * 2
if C == A and C == B:
return a + b
elif C > A and C > B:
return a + b
elif C ... | s139197049 | Accepted | 17 | 3,064 | 507 | def solve():
ABC = list(sorted(map(int, input().split())))
A, B, C = ABC[0], ABC[1], ABC[2]
a, amod = divmod((C-A),2)
b, bmod = divmod((C-B),2)
A += a * 2
B += b * 2
if C == A and C == B:
return a + b
elif C > A and C > B:
return a + b + 1
elif C > A and C == ... |
s557042623 | p03129 | u623819879 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 75 | Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1. | n,k=map(int,input().split())
if n>2*k-1:
print('YES')
else:
print('NO') | s362806280 | Accepted | 18 | 2,940 | 75 | n,k=map(int,input().split())
if n>2*k-2:
print('YES')
else:
print('NO') |
s192037684 | p02612 | u248556072 | 2,000 | 1,048,576 | Wrong Answer | 31 | 9,144 | 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) | s523145113 | Accepted | 25 | 9,156 | 82 | N = int(input())
if N%1000 == 0:
print(N%1000)
else:
print(1000-(N%1000)) |
s988339774 | p03394 | u761320129 | 2,000 | 262,144 | Wrong Answer | 36 | 4,196 | 348 | Nagase is a top student in high school. One day, she's analyzing some properties of special sets of positive integers. She thinks that a set S = \\{a_{1}, a_{2}, ..., a_{N}\\} of **distinct** positive integers is called **special** if for all 1 \leq i \leq N, the gcd (greatest common divisor) of a_{i} and the sum of t... | N = int(input())
ans = [1]
total = 1
for n in range(30001):
if (n%2 == 0) ^ (n%3 == 0):
ans.append(n)
total += n
if len(ans) == N: break
if total%2 == 0:
i = N - 1
while ans[i]%3 > 0:
i -= 1
ans[i] += 3
if total%3 == 0:
i = N - 1
while ans[i]%2 > 0:
i -= 1
... | s631683095 | Accepted | 45 | 4,588 | 795 | N = int(input())
if N == 3:
print('2 5 63')
exit()
ans = []
total = 0
for n in range(1,30001):
if n%2 == 0 or n%3 == 0:
ans.append(n)
total += n
if len(ans) == N: break
if total%6 == 1:
i = N - 1
while ans[i]%3 > 0:
i -= 1
ans[i] += 3
i = N - 1
while ans[i]%... |
s335675898 | p03455 | u030726788 | 2,000 | 262,144 | Wrong Answer | 19 | 3,316 | 109 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | a,b = map(int,input().split())
if(a%2==1):
print("Odd")
elif(b%2==1):
print("Odd")
else:
print("Even")
| s720448810 | Accepted | 17 | 2,940 | 113 | a,b = map(int,input().split())
if((a%2)==0):
print("Even")
elif((b%2)==0):
print("Even")
else:
print("Odd") |
s094303916 | p03388 | u201660334 | 2,000 | 262,144 | Wrong Answer | 18 | 3,188 | 952 | 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 ... | import math
q = int(input())
a = []
for i in range(q):
a.append(list(map(int, input().split())))
for i in range(q):
b = 2 * int(math.sqrt(a[i][0] * a[i][1])) - 1
while True:
status = True
if b % 2 == 0:
if (b // 2 + (a[i][0] <= b // 2)) * (b // 2 + 2 - (a[i][1] >= b//2 + 2)) < a... | s157158698 | Accepted | 19 | 3,188 | 960 | import math
q = int(input())
a = []
for i in range(q):
a.append(list(map(int, input().split())))
for i in range(q):
b = max(2 * int(math.sqrt(a[i][0] * a[i][1])) - 3, 0)
while True:
status = True
if b % 2 == 0:
if (b // 2 + (a[i][0] <= b // 2)) * (b // 2 + 2 - (a[i][1] >= b//2 +... |
s029728455 | p02255 | u452220492 | 1,000 | 131,072 | Wrong Answer | 20 | 5,600 | 222 | Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key ... | n = int(input())
a = [int(i) for i in input().split()]
for i in range(1, n):
j = i
while a[j - 1] > a[j] and j > 0:
a[j], a[j - 1] = a[j - 1], a[j]
j -= 1
print(" ".join([str(i) for i in a]))
| s737718681 | Accepted | 20 | 5,608 | 259 | n = int(input())
a = [int(i) for i in input().split()]
print(" ".join([str(i) for i in a]))
for i in range(1, n):
j = i
while a[j - 1] > a[j] and j > 0:
a[j], a[j - 1] = a[j - 1], a[j]
j -= 1
print(" ".join([str(i) for i in a]))
|
s565422226 | p03054 | u016128476 | 2,000 | 1,048,576 | Wrong Answer | 2,140 | 520,756 | 1,405 | We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, there is a piece, which is initially placed at square (s_r,s_c). Takahashi and Aoki will play a game, where each player has a st... | h, w, n = [int(i) for i in input().split()]
sr, sc = [int(i) for i in input().split()]
s = input()
t = input()
def move(strt, sr, sc):
if strt == 'L':
return sr, sc - 1
if strt == 'R':
return sr, sc + 1
if strt == 'U':
return sr - 1, sc
if strt == 'D':
return sr + 1, sc... | s431565123 | Accepted | 976 | 42,216 | 1,613 | h, w, n = [int(i) for i in input().split()]
sr, sc = [int(i) for i in input().split()]
s = input()
t = input()
dpx = [None for _ in range(n*2+1)]
dpy = [None for _ in range(n*2+1)]
dpx[0] = (1, w+1)
dpy[0] = (1, h+1)
# search safety region from tail
for i in range(1,n*2+1):
is_t = i % 2 == 1
strategy = t[-1... |
s831937155 | p03524 | u860002137 | 2,000 | 262,144 | Wrong Answer | 36 | 9,364 | 136 | Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible. | from collections import Counter
s = input()
c = Counter(s)
print("YES" if sum([x % 2 == 1 for x in list(c.values())]) <= 1 else "NO") | s720054679 | Accepted | 43 | 9,416 | 200 | from collections import Counter
s = input()
d = {
"a": 0,
"b": 0,
"c": 0
}
for x in s:
d[x] += 1
result = list(d.values())
print("YES" if max(result) - min(result) <= 1 else "NO") |
s776680238 | p03605 | u129978636 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 133 | It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N? | N = list(input())
l = len(N)
for i in range(l):
if(N[i] == '9'):
print('yes')
exit()
else:
continue
print('No') | s919285890 | Accepted | 18 | 2,940 | 35 | print(['No','Yes']['9' in input()]) |
s536893713 | p03377 | u391819434 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 55 | There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals. | A,B,X=map(int,input().split());print("YNeos"[A+B<X::2]) | s529867381 | Accepted | 18 | 2,940 | 66 | A,B,X=map(int,input().split());print("NYOE S"[(A+B>=X)*(A<=X)::2]) |
s203561697 | p03644 | u402467563 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 113 | 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... | N=int(input())
tmp=1
flag=True
while flag:
tmp=tmp*2
print(tmp)
if tmp>=N:
flag=False
print(int(tmp/2)) | s161020683 | Accepted | 17 | 3,060 | 149 | N=int(input())
k=[1,2,4,8,16,32,64]
ans=-1
for i in range(1,len(k)):
if k[i]>N:
ans=i-1
break
if ans==-1:
print(64)
else:
print(k[ans]) |
s682555387 | p02244 | u799595944 | 1,000 | 131,072 | Wrong Answer | 30 | 6,348 | 1,240 | The goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure. For a given chess board where $k$ queens are already placed, find the so... | import copy
n = int(input())
dotsa = []
for _ in range(n):
y,x = map(int,input().split(" "))
dotsa.append([y,x])
pattern = []
pattern.append(dotsa)
for y in range(8):
nextpattern = []
#print("#######")
#print(pattern)
for pat in pattern:
#print(";;;;;;;;;;;;;;;;;;;;;")
#prin... | s485697932 | Accepted | 50 | 5,660 | 1,557 | import itertools
def hand_in_answer(v):
base = [".", ".", ".", ".", ".", ".", ".", "."]
for i in range(8):
tmp = base.copy()
tmp[v[i]] = "Q"
print("".join(tmp))
def ifGoodPosition(position, v):
yo = position[0]
xo = position[1]
x = xo
y = yo
x += 1
y += 1
... |
s710114091 | p03556 | u581603131 | 2,000 | 262,144 | Wrong Answer | 1,327 | 3,060 | 98 | 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())
ans = 1
for i in range(1,31623):
if N >= i**2:
ans = 2**i
print(2**i) | s326700744 | Accepted | 38 | 2,940 | 121 | N = int(input())
ans = 1
for i in range(1,31623):
if N >= i**2:
ans = i**2
else:
break
print(ans) |
s257410449 | p02697 | u664907598 | 2,000 | 1,048,576 | Wrong Answer | 77 | 9,168 | 112 | You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing fi... | n,m = map(int,input().split())
if n % 2 == 1:
for i in range(m):
print(*[i+1,n-i-1])
else:
print(1) | s222336264 | Accepted | 80 | 9,284 | 322 | n,m = map(int,input().split())
if m % 2 == 0:
for i in range(m // 2):
print(*[i+1,m + 1 - i])
for i in range(m // 2):
print(*[ m + 2 + i, 2 * m + 1 - i])
else:
for i in range((m - 1) // 2 ):
print(*[i + 1, m -i])
for i in range((m+1) // 2):
print(*[m + 1 + i, 2 * m + 1 -i... |
s516180713 | p03449 | u301043830 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 288 | We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You ... | N = int(input())
A1 = map(int, input().split())
A2 = map(int, input().split())
A2_sum = list()
sum = 0
for a2 in A2 :
sum += a2
A2_sum.append(sum)
max_score = 0
for i, a1 in enumerate(A1) :
if a1 + A2_sum[i] > max_score :
max_score = a1 + A2_sum[i]
print(max_score) | s146867750 | Accepted | 17 | 3,064 | 408 | N = int(input())
A1 = map(int, input().split())
A2 = map(int, input().split()[::-1])
A1_sum = list()
sum = 0
for a1 in A1 :
sum += a1
A1_sum.append(sum)
A2_sum = list()
sum = 0
for a2 in A2 :
sum += a2
A2_sum.append(sum)
A2_sum = A2_sum[::-1]
max_score = 0
for i, a1_sum in enumerate(A1_sum) :
if a... |
s397634466 | p02398 | u093488647 | 1,000 | 131,072 | Wrong Answer | 20 | 5,584 | 187 | Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. | data = input().split()
a = int(data[0])
b = int(data[1])
c = int(data[2])
if a < b or a < 1 or c > 10000:
exit()
cnt = 0
for num in range(a,b):
if (c%num) == 0:
cnt += 1
print(cnt)
| s413959089 | Accepted | 20 | 5,596 | 189 | data = input().split()
a = int(data[0])
b = int(data[1])
c = int(data[2])
if a > b or a < 1 or c > 10000:
exit()
cnt = 0
for num in range(a,b+1):
if (c%num) == 0:
cnt += 1
print(cnt)
|
s021884109 | p03712 | u678167152 | 2,000 | 262,144 | Wrong Answer | 30 | 9,120 | 153 | 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())
S = [0]*(H+2)
S[0] = '*'*(W+2)
S[H+1] = '*'*(W+2)
for h in range(1,H+1):
S[h] = '*' + input() + '*'
print(*S,sep='\n') | s390911382 | Accepted | 26 | 9,032 | 153 | H, W = map(int, input().split())
S = [0]*(H+2)
S[0] = '#'*(W+2)
S[H+1] = '#'*(W+2)
for h in range(1,H+1):
S[h] = '#' + input() + '#'
print(*S,sep='\n') |
s234911525 | p03501 | u222841610 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 61 | You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours. | n,a,b = map(int,input().split())
print(n*a if n*a > b else b) | s645792791 | Accepted | 17 | 2,940 | 62 | n,a,b = map(int,input().split())
print(n*a if n*a <= b else b) |
s977300319 | p02401 | u279483260 | 1,000 | 131,072 | Wrong Answer | 30 | 5,600 | 269 | Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part. | while True:
a, op, b = input().split()
a = int(a)
b = int(b)
if op == '+':
print(a + b)
elif op == '-':
print(a - b)
elif op == '*':
print(a * b)
elif op == '/':
print(a / b)
elif op == '?':
break
| s586889297 | Accepted | 20 | 5,592 | 280 | while True:
a, op, b = input().split()
if op == '+':
print(int(a) + int(b))
elif op == '-':
print(int(a) - int(b))
elif op == '*':
print(int(a) * int(b))
elif op == '/':
print(int(a) // int(b))
elif op == '?':
break
|
s507000307 | p03845 | u457423258 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 191 | Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes d... | n = int(input())
t=list(map(int,input().split()))
m=int(input())
ans=0
for j in range(n):
ans+=t[j]
for i in range(m):
p,x=map(int,input().split())
ans=ans-t[p-1]+x
print(ans) | s407848929 | Accepted | 18 | 3,064 | 195 | n = int(input())
t=list(map(int,input().split()))
m=int(input())
ans=0
for j in range(n):
ans+=t[j]
for i in range(m):
y=ans
p,x=map(int,input().split())
y=y-t[p-1]+x
print(y) |
s940553636 | p03352 | u348285568 | 2,000 | 1,048,576 | Wrong Answer | 20 | 2,940 | 200 | You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2. | n = int(input())
ans = 0
for i in range(n):
for j in range(2,n):
if n>=i**j >ans:
ans = i**j
print(ans,i,j)
elif i**j > n:
break
print(ans)
| s969182101 | Accepted | 20 | 3,060 | 396 | import math
N=int(input())
def beki(x):
b=2
while b <= math.sqrt(x):
p=2
while b**p <=x:
if b**p == x:
return True
break
else:
p+=1
else:
b+=1
else:
return False
while N>=2:
if beki(N)==Tr... |
s004394511 | p03457 | u226912938 | 2,000 | 262,144 | Wrong Answer | 415 | 11,816 | 497 | AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1... | def odd_even(a, b):
if a % 2 == b % 2:
return True
else:
return False
n = int(input())
T, X, Y = [0], [0], [0]
for _ in range(n):
t, x, y = map(int, input().split())
T.append(t)
X.append(x)
Y.append(y)
ans = 'Yes'
for i in range(1,n+1):
t_dif = T[i] - T[i-1]
x_dif = ab... | s785948716 | Accepted | 409 | 11,816 | 497 | def odd_even(a, b):
if a % 2 == b % 2:
return True
else:
return False
n = int(input())
T, X, Y = [0], [0], [0]
for _ in range(n):
t, x, y = map(int, input().split())
T.append(t)
X.append(x)
Y.append(y)
ans = 'Yes'
for i in range(1,n+1):
t_dif = T[i] - T[i-1]
x_dif = ab... |
s743515295 | p03611 | u503901534 | 2,000 | 262,144 | Wrong Answer | 2,104 | 14,008 | 254 | You are given an integer sequence of length N, a_1,a_2,...,a_N. For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices. | n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(len(a)):
s = 0
for j in range(len(a)):
if abs(a[i]-a[j]) < 3:
s = s + 1
else:
None
b.append(s)
print(max(b))
| s953599371 | Accepted | 102 | 13,964 | 332 | n = int(input())
a = list(map(int,input().split()))
aa = []
amax = max(a) + 100
for i in range(amax + 1):
aa.append(0)
for i in range(len(a)):
aa[a[i]] = aa[a[i]] + 1
kouho = 1
for j in range(len(aa) - 2):
if kouho < aa[j] + aa[j + 1] + aa[j + 2]:
kouho = aa[j] + aa[j + 1] + aa[j + 2]
p... |
s852931604 | p03050 | u785644520 | 2,000 | 1,048,576 | Wrong Answer | 2,107 | 2,940 | 209 | Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied: * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds. Find all favorite numbers and print the sum of those. | def main():
N = int(input())
ans = 0
for m in range(1, N+1):
if N % (m + 1) != 0:
pass
else:
ans += m
print(ans)
if __name__ == '__main__':
main()
| s256838655 | Accepted | 118 | 3,272 | 472 | from math import floor, sqrt
def main():
N = int(input())
divs = divisor(N)
ans = 0
for i in divs:
m = i - 1
if m == 0:
continue
if N // m == N % m:
ans += m
print(ans)
def divisor(N):
divs = []
sup = floor(sqrt(N))
for i in range(1, su... |
s037724655 | p02261 | u152639966 | 1,000 | 131,072 | Wrong Answer | 30 | 6,340 | 663 | 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 Bubbl... | import copy
n=int(input())
s=input().split(' ')
s1=[]
s2=[]
s1=copy.deepcopy(s)
s2=copy.deepcopy(s)
def Bubble_Sort(n,s1):
m=0
flag=1
while flag:
flag=0
for i in range(1,n):
j=n-i
if int(s1[j][1])<int(s1[j-1][1]):
a=s1[j]
s1[j]=s1[j-1]
s1[j-1]=a
m+=1
flag=1
b=s1
return(b)
def Selec... | s659365534 | Accepted | 30 | 6,344 | 683 | import copy
n=int(input())
s=input().split(' ')
s1=[]
s2=[]
s1=copy.deepcopy(s)
s2=copy.deepcopy(s)
def Bubble_Sort(n,s1):
m=0
flag=1
while flag:
flag=0
for i in range(1,n):
j=n-i
if int(s1[j][1])<int(s1[j-1][1]):
a=s1[j]
s1[j]=s1[j-1]
s1[j-1]=a
m+=1
flag=1
b=s1
return(b)
def Selec... |
s100911720 | p02274 | u269488240 | 1,000 | 131,072 | Wrong Answer | 20 | 7,744 | 744 | For a given sequence $A = \\{a_0, a_1, ... a_{n-1}\\}$, the number of pairs $(i, j)$ where $a_i > a_j$ and $i < j$, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program: bubbleSort(A) cnt = 0 // the number of inver... | a = list(map(int, input().split()))
def merge_and_count(a, b):
i, j = 0, 0
count = 0
m = []
while i < len(a) and j < len(b):
if a[i] <= b[j]:
m.append(a[i])
i += 1
else:
count += len(a)-i
m.append(b[j])
j += 1
if i < len(a... | s096039908 | Accepted | 2,430 | 30,764 | 694 | input()
a = list(map(int, input().split()))
def merge_and_count(a, b):
i, j = 0, 0
count = 0
m = []
while i < len(a) and j < len(b):
if a[i] <= b[j]:
m.append(a[i])
i += 1
else:
count += len(a)-i
m.append(b[j])
j += 1
if i... |
s962111636 | p03434 | u759412327 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 98 | 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 c... | N = int(input())
a = sorted(list(map(int,input().split())),reverse=True)
print(sum(a)-sum(a[::2])) | s918610340 | Accepted | 27 | 9,020 | 98 | N = int(input())
A = sorted(list(map(int,input().split())))[::-1]
print(sum(A[0::2])-sum(A[1::2])) |
s478833222 | p03606 | u429029348 | 2,000 | 262,144 | Wrong Answer | 20 | 3,060 | 97 | Joisino is working as a receptionist at a theater. The theater has 100000 seats, numbered from 1 to 100000. According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive). How many people are sitting at the theater now? | n=int(input())
s=0
for i in range(n):
l=list(map(int,input().split()))
s+=len(l)
print(s) | s992627286 | Accepted | 20 | 2,940 | 92 | n=int(input())
s=0
for i in range(n):
l,r=map(int,input().split())
s+=r-l+1
print(s) |
s144122009 | p03778 | u106297876 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 121 | 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 min... | W,a,b = map(int,input().split())
A = min(a,b)
B = max(a,b)
print(A,B)
if B-A >= W:
ans = B-A-W
else:
ans = 0
print(ans) | s838660286 | Accepted | 18 | 2,940 | 111 | W,a,b = map(int,input().split())
A = min(a,b)
B = max(a,b)
if B-A >= W:
ans = B-A-W
else:
ans = 0
print(ans) |
s062988719 | p03636 | u280552586 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 46 | The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way. | s = input()
print(s[0], len(s), s[-1], sep='') | s680418186 | Accepted | 18 | 3,064 | 48 | s = input()
print(s[0]+str(len(s[1:-1]))+s[-1])
|
s265345524 | p03377 | u075303794 | 2,000 | 262,144 | Wrong Answer | 20 | 2,940 | 120 | There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals. | a,b,x = map(int, input().split())
if a > x:
print('No')
else:
if a + b < x:
print('No')
else:
print('Yes') | s817484180 | Accepted | 17 | 2,940 | 120 | a,b,x = map(int, input().split())
if a > x:
print('NO')
else:
if a + b < x:
print('NO')
else:
print('YES') |
s432211231 | p03229 | u905582793 | 2,000 | 1,048,576 | Wrong Answer | 217 | 9,556 | 369 | You are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like. | import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
a.sort()
b = []
c = []
for i in range(n):
if i%2:
b.append(a[i//2])
c.append(a[i//2+(n+1)//2])
else:
b.append(a[i//2+n//2])
c.append(a[i//2])
ansb = 0
ansc = 0
for i in range(n-1):
ansb += abs(b[i+1]-b[i])... | s140934539 | Accepted | 222 | 9,556 | 437 | import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
a.sort()
b = []
c = []
for i in range(n):
if i%2:
b.append(a[i//2])
c.append(a[i//2+(n+1)//2])
else:
b.append(a[i//2+n//2])
c.append(a[i//2])
if n>=3 and n%2:
b[-1],b[2] = b[2],b[-1]
c[0],c[-3] = c[-3],c[... |
s065059447 | p03577 | u445624660 | 2,000 | 262,144 | Wrong Answer | 24 | 8,976 | 25 | Rng is going to a festival. The name of the festival is given to you as a string S, which ends with `FESTIVAL`, from input. Answer the question: "Rng is going to a festival of what?" Output the answer. Here, assume that the name of "a festival of s" is a string obtained by appending `FESTIVAL` to the end of s. For ex... | print(input()+"FESTIVAL") | s208148902 | Accepted | 28 | 8,968 | 19 | print(input()[:-8]) |
s942719734 | p04031 | u357949405 | 2,000 | 262,144 | Wrong Answer | 23 | 3,064 | 246 | Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (... | n = int(input())
a = list(map(int, input().split()))
max_a = max(a)
min_a = min(a)
sum_a = max(a) * len(a)
ans = 0
for i in range(min_a, max_a):
s = sum([(j-i)**2 for j in a])
if sum_a > s:
sum_a = s
ans = i
print(ans) | s927205245 | Accepted | 23 | 3,060 | 191 | n = int(input())
a = list(map(int, input().split()))
ans = sum([i**2 for i in a])
for i in range(-100, 100+1):
s = sum([(j-i)**2 for j in a])
if ans > s:
ans = s
print(ans) |
s767209791 | p03360 | u546853743 | 2,000 | 262,144 | Wrong Answer | 32 | 9,040 | 91 | There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after... | s=list(map(int,input().split()))
k=int(input())
s.sort()
m=1
m *= s[2]*k
print(m+s[0]+s[1]) | s389332115 | Accepted | 27 | 9,056 | 98 | s=list(map(int,input().split()))
k=int(input())
s.sort()
m=1
m *= (s[2]*(2**k))
print(m+s[0]+s[1]) |
s570394637 | p03502 | u716949516 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 220 | An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number. |
if __name__ == '__main__':
n = int(input())
m = n
div = 0
while n != 0 :
div += n % 10
n = n // 10
if m % div == 0 :
print('YES')
else :
print('NO') | s653999712 | Accepted | 17 | 2,940 | 220 |
if __name__ == '__main__':
n = int(input())
m = n
div = 0
while n != 0 :
div += n % 10
n = n // 10
if m % div == 0 :
print('Yes')
else :
print('No') |
s934670528 | p03377 | u354925116 | 2,000 | 262,144 | Wrong Answer | 19 | 3,316 | 93 | There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals. | a, b, x = map(int, input().split())
if a <= x <= a+b:
print('yes')
else:
print('NO')
| s290561069 | Accepted | 19 | 3,316 | 93 | a, b, x = map(int, input().split())
if a <= x <= a+b:
print('YES')
else:
print('NO')
|
s966000099 | p02612 | u154960594 | 2,000 | 1,048,576 | Wrong Answer | 28 | 8,996 | 41 | 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-((n//1000)*1000))
| s591608541 | Accepted | 31 | 9,152 | 84 | n=int(input())
if(n%1000==0):
print(0)
else:
rem=1000-n%1000
print(rem)
|
s339815224 | p02697 | u825541307 | 2,000 | 1,048,576 | Wrong Answer | 73 | 9,224 | 77 | You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing fi... | N,M = map(int,input().split())
for i in range(M):
print(i + 1, 2 * M - i) | s101177306 | Accepted | 74 | 9,276 | 279 | N,M = map(int,input().split())
if M % 2 == 1:
for i in range(M // 2):
print(1 + i, M - i)
for i in range(M - M // 2):
print(M + 1 + i, 2 * M + 1 - i)
else:
for i in range(M // 2):
print(1 + i, M + 1 - i)
print(M + 2 + i, 2 * M + 1 - i) |
s132385495 | p03495 | u105302073 | 2,000 | 262,144 | Wrong Answer | 529 | 41,988 | 417 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
nums = {}
for a in A:
if a in nums:
nums[a] += 1
else:
nums[a] = 1
sorted_nums = list(sorted(nums.items(), key=lambda x: x[1]))
nums_len = len(sorted_nums)
ans = 0
if nums_len > K:
for i in range(nums_len - K):
... | s948472292 | Accepted | 211 | 40,068 | 362 | N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
nums = {}
for a in A:
if a in nums:
nums[a] += 1
else:
nums[a] = 1
sorted_nums = list(sorted(nums.items(), key=lambda x: x[1]))
nums_len = len(sorted_nums)
ans = 0
if nums_len > K:
for i in range(nums_len - K):
... |
s669308871 | p02612 | u858742833 | 2,000 | 1,048,576 | Wrong Answer | 28 | 9,140 | 69 | 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())
return N % 1000
print(main())
| s939835691 | Accepted | 33 | 9,144 | 87 | def main():
N = int(input())
return (1000 - (N % 1000)) % 1000
print(main())
|
s947404896 | p03387 | u288430479 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 161 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be ... | l = sorted(map(int,input().split()))[::-1]
a = l[0]
b = l[1]
c = l[2]
s = 0
s += b-a
c += (b-a)
if (a-c)%2==0:
s += (a-c)//2
else:
s += (a-c-1)//2+1
print(s) | s803859509 | Accepted | 17 | 3,060 | 161 | l = sorted(map(int,input().split()))[::-1]
a = l[0]
b = l[1]
c = l[2]
s = 0
s += a-b
c += (a-b)
if (a-c)%2==0:
s += (a-c)//2
else:
s += (a-c-1)//2+2
print(s) |
s060539995 | p03486 | u246809151 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 90 | 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()
if sorted(s) < sorted(t):
print('Yes')
else:
print('No')
| s748138441 | Accepted | 18 | 2,940 | 104 | s = input()
t = input()
if sorted(s) < sorted(t, reverse=True):
print('Yes')
else:
print('No')
|
s248245934 | p02842 | u667084803 | 2,000 | 1,048,576 | Wrong Answer | 32 | 2,940 | 106 | Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer).... | X = int(input())
for i in range(50000):
if int(i*1.05) == X:
print(i)
break
else:
print(':(') | s920516555 | Accepted | 31 | 3,060 | 106 | X = int(input())
for i in range(50000):
if int(i*1.08) == X:
print(i)
break
else:
print(':(') |
s358502267 | p02690 | u556610039 | 2,000 | 1,048,576 | Wrong Answer | 290 | 9,112 | 291 | Give a pair of integers (A, B) such that A^5-B^5 = X. It is guaranteed that there exists such a pair for the given integer X. | num = int(input())
list = [i ** 5 for i in range(1000)]
ans = []
for a in range(1000):
for b in range(1000):
if list[a] - list[b] == num:
ans = [a, b]
break
if list[a] + list[b] == num:
ans = [a, b * (-1)]
break
print(ans) | s553091406 | Accepted | 285 | 9,228 | 311 | num = int(input())
list = [i ** 5 for i in range(1000)]
ans = []
for a in range(1000):
for b in range(1000):
if list[a] - list[b] == num:
ans = [a, b]
break
if list[a] + list[b] == num:
ans = [a, b * (-1)]
break
print(' '.join(map(str, ans))) |
s897574618 | p02646 | u221301671 | 2,000 | 1,048,576 | Wrong Answer | 21 | 9,192 | 339 | 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 ... | a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if a > b:
aa = a - t * v
bb = b - t * w
if aa > bb:
print('No')
else:
print('Yes')
elif a < b:
aa = a + t * v
bb = b + t * w
if aa < bb:
print('No')
else:
print('Yes')
else... | s562694094 | Accepted | 22 | 9,188 | 339 | a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if a > b:
aa = a - t * v
bb = b - t * w
if aa > bb:
print('NO')
else:
print('YES')
elif a < b:
aa = a + t * v
bb = b + t * w
if aa < bb:
print('NO')
else:
print('YES')
else... |
s649403770 | p03435 | u266874640 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 347 | We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) ... | c = [list(map(int,input().split())) for i in range(3)]
x = c[0][0]
for i in range(x+1):
a1 = i
b1 = x-i
a2 = c[1][0] - b1
a3 = c[2][0] - b1
b2 = c[0][1] - a1
b3 = c[0][2] - a1
if a2 + b2 == c[1][1] and a2 + b3 == c[1][2] and a3 + b2 == c[2][1] and a3 + b3 == c[2][2]:
print("Yes")
... | s607254535 | Accepted | 17 | 3,064 | 344 | c = [list(map(int,input().split())) for i in range(3)]
x = c[0][0]
for i in range(x+1):
a1 = i
b1 = x-i
a2 = c[1][0] - b1
a3 = c[2][0] - b1
b2 = c[0][1] - a1
b3 = c[0][2] - a1
if a2 + b2 == c[1][1] and a2 + b3 == c[1][2] and a3 + b2 == c[2][1] and a3 + b3 == c[2][2]:
print("Yes")
... |
s917663298 | p03371 | u656330453 | 2,000 | 262,144 | Wrong Answer | 306 | 5,148 | 469 | "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 curr... | a,b,c,x,y=map(int, input().split())
mc=min(a,b,c)
mp=max(x,y)
cost=10000000000
if mc==c:
for i in range(mp):
cost_=(mp-i)*2*c+min(a,b)*i
if cost_ >= cost:
print(cost)
else:
cost=cost_
if mc==a:
for i in range(x):
cost_=(x-i)*a+b*(y-i)+c*2*i
if cost_ >= cost:
print(cost)
els... | s130211993 | Accepted | 119 | 3,060 | 166 | a,b,c,x,y=map(int, input().split())
max_=max(x,y)
cost=100000000000
for i in range(max_+1):
cost_=i*2*c+a*max(0,x-i)+b*max(0,y-i)
cost=min(cost_,cost)
print(cost) |
s607545801 | p03565 | u096616343 | 2,000 | 262,144 | Wrong Answer | 2,104 | 50,292 | 132 | E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One mo... | S = list(input())
T = list(input())
lenS = len(S)
lenT = len(T)
if lenS < lenT:
for _ in range(10 ** 7):
print("UNRESTORABLE") | s474315752 | Accepted | 17 | 3,064 | 733 | S = list(input())
T = list(input())
lenS = len(S)
lenT = len(T)
if lenS < lenT:
print("UNRESTORABLE")
else:
end = False
for i in range(lenS - lenT, -1, -1):
cnt = 0
for j in range(lenT):
if S[i + j] == T[j] or S[i + j] == "?":
cnt += 1
else:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.