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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s889313206 | p03505 | u846552659 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 186 | _ButCoder Inc._ runs a programming competition site called _ButCoder_. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is calle... | # -*- coding:utf-8 -*-
import math
k,a,b = map(int, input().split())
if a >= k:
print(1)
else:
if a <= b:
print(-1)
else:
print((2*math.floor((k-a)/(a-b)))+1) | s307346955 | Accepted | 117 | 5,588 | 219 | # -*- coding:utf-8 -*-
from decimal import *
import math
k,a,b = map(int, input().split())
if a >= k:
print(1)
else:
if a <= b:
print(-1)
else:
print(2*math.ceil(Decimal(k-a)/Decimal(a-b))+1) |
s760695107 | p02613 | u359752656 | 2,000 | 1,048,576 | Wrong Answer | 140 | 16,264 | 258 | 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())
S = [input() for _ in range(N)]
A = S.count("AC")
B = S.count("WA")
C = S.count("TLE")
D = S.count("RE")
print("AC"+"×" + str(A))
print("WA"+"×" + str(B))
print("TLE"+"×" + str(C))
print("RE"+"×" + str(D))
| s100531762 | Accepted | 139 | 16,200 | 253 | N = int(input())
S = [input() for _ in range(N)]
A = S.count("AC")
B = S.count("WA")
C = S.count("TLE")
D = S.count("RE")
print("AC", "x", str(A))
print("WA", "x", str(B))
print("TLE", "x", str(C))
print("RE", "x", str(D)) |
s126226989 | p03477 | u178432859 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 129 | A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and pl... | a,b,c,d = map(int, input().split())
if a+b > c+d:
print("Left")
if a+b == c+d:
print("Balanced")
else:
print("Right") | s250807120 | Accepted | 17 | 3,060 | 131 | a,b,c,d = map(int, input().split())
if a+b > c+d:
print("Left")
elif a+b == c+d:
print("Balanced")
else:
print("Right") |
s600156150 | p03693 | u630566616 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 89 | AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this i... | r,g,b=map(int,input().split())
if (r*100+g*10+b)%4==0:
print("Yes")
else:
print("No") | s012169142 | Accepted | 17 | 2,940 | 76 | r,g,b=input().split()
if int(r+g+b)%4==0:
print("YES")
else:
print("NO") |
s551865630 | p02413 | u131984977 | 1,000 | 131,072 | Wrong Answer | 30 | 6,720 | 343 | Your task is to perform a simple table calculation. Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column. | (r, c) = [int(i) for i in input().split()]
ct = [0 for d in range(c)]
tmp = []
for rc in range(r):
tmp = [int(i) for i in input().split()]
total = 0
for cc in range(c):
ct[cc] += tmp[cc]
total += tmp[cc]
print(tmp[cc], end=' ')
print(total)
total = sum(ct)
print(' '.join([str(i)... | s497274723 | Accepted | 30 | 7,644 | 338 | r, c = [int(i) for i in input().split()]
data = []
sum_row = [0] * (c + 1)
for ri in range(r):
data.append([int(i) for i in input().split()])
data[ri].append(sum(data[ri]))
print(" ".join([str(d) for d in data[ri]]))
for ci in range(c + 1):
sum_row[ci] += data[ri][ci]
print(" ".join([str(s) f... |
s067697793 | p03567 | u357630630 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 38 | Snuke built an online judge to hold a programming contest. When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.) Determine whether the judge can return the ... | print(["Yes", "No"]["AC" in input()])
| s096809320 | Accepted | 17 | 2,940 | 38 | print(["No", "Yes"]["AC" in input()])
|
s560755927 | p02399 | u446066125 | 1,000 | 131,072 | Wrong Answer | 30 | 6,744 | 91 | Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number) | (a, b) = [int(i) for i in input().split()]
d = a // b
r = a % b
f = a / b
print(d, r, f) | s303090541 | Accepted | 30 | 6,748 | 112 | (a, b) = [int(i) for i in input().split()]
d = int(a / b)
r = a % b
f = a / b
print('%s %s %.5f' % (d, r, f)) |
s860267706 | p02612 | u243312682 | 2,000 | 1,048,576 | Wrong Answer | 31 | 9,152 | 109 | We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. | def main():
n = int(input())
ans = n % 1000
print(ans)
if __name__ == '__main__':
main() | s649547638 | Accepted | 32 | 9,144 | 176 | def main():
n = int(input())
if n % 1000 == 0:
ans = 0
else:
ans = ans = 1000 - (n % 1000)
print(ans)
if __name__ == '__main__':
main() |
s800757482 | p03370 | u644516473 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 99 | Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams o... | n, x = map(int, input().split())
m = [int(input()) for _ in range(n)]
print(sum(m) + max(m)*(x-n)) | s383233321 | Accepted | 17 | 2,940 | 103 | n, x = map(int, input().split())
m = [int(input()) for _ in range(n)]
print(n + (x - sum(m))//min(m))
|
s522223506 | p00481 | u028939600 | 8,000 | 131,072 | Wrong Answer | 70 | 8,004 | 2,003 | 今年も JOI 町のチーズ工場がチーズの生産を始め,ねずみが巣から顔を出した.JOI 町は東西南北に区画整理されていて,各区画は巣,チーズ工場,障害物,空き地のいずれかである.ねずみは巣から出発して全てのチーズ工場を訪れチーズを 1 個ずつ食べる. この町には,N 個のチーズ工場があり,どの工場も1種類のチーズだけを生産している.チーズの硬さは工場によって異なっており,硬さ 1 から N までのチーズを生産するチーズ工場がちょうど 1 つずつある. ねずみの最初の体力は 1 であり,チーズを 1 個食べるごとに体力が 1 増える.ただし,ねずみは自分の体力よりも硬いチーズを食べることはできない. ねずみは,東西南北に隣り合う区... | field = [[4,5,2],[".","X",".",".",1],[".",".",".",".","X"],[".","X","X",".","S"],[".",2,".","X","."]]
for i in range(len(field) - 1):
for j in range(len(field[1])):
if field[i+1][j] == "S":
start_x = j
start_y = i + 1
break
print(start_x,start_y)
def proceed(field,start... | s796180594 | Accepted | 8,070 | 36,896 | 1,561 | def bfs(field,H,W,start_x,start_y,tmp_N):
direction = [[-1,0],[1,0],[0,-1],[0,1]]
que = []
que.append([start_x,start_y])
INF = 1000000
min_path = [[INF] * W for i in range(H)]
min_path[start_y][start_x] = 0
while len(que) != 0:
current = que.pop(0)
for d in direction:
... |
s114685390 | p02975 | u830054172 | 2,000 | 1,048,576 | Wrong Answer | 60 | 14,212 | 296 | Snuke has N hats. The i-th hat has an integer a_i written on it. There are N camels standing in a circle. Snuke will put one of his hats on each of these camels. If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `Yes`; otherwise, print `No... | n = int(input())
a = list(map(int, input().split()))
flag = 0
even = []
odd = []
for i in a:
if i%2 == 0:
even.append(i)
else:
odd.append(i)
if n%2 == 1:
if len(odd) >= 1:
flag = 1
else:
pass
if flag == 1:
print("No")
else:
print("Yes") | s764435891 | Accepted | 52 | 14,212 | 132 | N = int(input())
a = list(map(int, input().split()))
t = 0
for a_i in a:
t ^= a_i
# print(t)
print("Yes" if t==0 else "No") |
s288286546 | p03644 | u476468228 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 83 | 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().strip())
while True:
if n & (n-1) == 0:
print(n)
break
n += 1 | s532321387 | Accepted | 18 | 2,940 | 83 | n = int(input().strip())
while True:
if n & (n-1) == 0:
print(n)
break
n -= 1 |
s114290848 | p02602 | u430928274 | 2,000 | 1,048,576 | Wrong Answer | 2,206 | 33,888 | 357 | M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms: not given. * For each of the K-th through N-th terms: the m... | n, k = map(int, input().split())
a = list(map(int, input().split()))
grade_array = []
for i in range(k,n+1) :
grade = 1
for j in range(k) :
grade *= a[i-1-j]
grade_array.append(grade)
print(grade_array)
for i in range(n-k) :
if grade_array[i+1] > grade_array[i] :
print("... | s938762923 | Accepted | 158 | 31,612 | 172 | n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k,n) :
if a[i-(k-1)-1] < a[i] :
print("Yes")
else :
print("No")
|
s338496990 | p03457 | u035445296 | 2,000 | 262,144 | Wrong Answer | 227 | 27,196 | 360 | 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... | n = int(input())
p = [list(map(int, input().split())) for _ in range(n)]
ans = 'Yes'
t_diff = 0
x_diff = 0
y_diff = 0
for i in p:
t_diff = i[0] - t_diff
x_diff = abs(i[1] - x_diff)
y_diff = abs(i[2] - y_diff)
if t_diff > x_diff + y_diff:
if (t_diff - x_diff - y_diff)%2 != 0:
ans = 'No'
break
e... | s970740688 | Accepted | 260 | 27,056 | 361 | n = int(input())
p = [list(map(int, input().split())) for _ in range(n)]
ans = 'Yes'
t_diff = 0
x_diff = 0
y_diff = 0
for i in p:
t_diff = i[0] - t_diff
x_diff = abs(i[1] - x_diff)
y_diff = abs(i[2] - y_diff)
if t_diff >= x_diff + y_diff:
if (t_diff - x_diff - y_diff)%2 != 0:
ans = 'No'
break
... |
s325786723 | p02833 | u595289165 | 2,000 | 1,048,576 | Wrong Answer | 148 | 12,504 | 220 | For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N). | import numpy as np
n = int(input())
a = len(str(n))
ans = np.zeros(a+4)
def calc(x, y):
return x // (10 * 5**y)
if n % 2 == 1:
pass
else:
for i in range(a+4):
ans[i] += calc(n, i)
print(sum(ans))
| s467840771 | Accepted | 152 | 12,388 | 201 | import numpy as np
n = int(input())
a = len(str(n))
ans = 0
def calc(x, y):
return x // (10 * 5**y)
if n % 2 == 1:
pass
else:
for i in range(a+10):
ans += calc(n, i)
print(ans)
|
s237236630 | p03081 | u047535298 | 2,000 | 1,048,576 | Wrong Answer | 2,105 | 42,656 | 718 | There are N squares numbered 1 to N from left to right. Each square has a character written on it, and Square i has a letter s_i. Besides, there is initially one golem on each square. Snuke cast Q spells to move the golems. The i-th spell consisted of two characters t_i and d_i, where d_i is `L` or `R`. When Snuke ca... | N, Q = map(int, input().split())
s = input()
golems_in = dict([(i, 1) for i in range(N+2)])
golems_in[0] = 0
golems_in[N] = 0
alphabet_to_number = {}
for i in range(N):
c = s[i]
if not c in alphabet_to_number:
alphabet_to_number[c] = [i + 1]
else:
alphabet_to_number[c].append(i + 1)
for i ... | s569540654 | Accepted | 1,718 | 17,840 | 992 | N, Q = map(int, input().split())
s = input()
td = [tuple(input().split()) for i in range(Q)]
def left_check(pos):
nowpos = pos
for t, d in td:
if(d=="L" and t==s[nowpos]):
nowpos -= 1
elif(d=="R" and t==s[nowpos]):
nowpos += 1
if(nowpos == N):
return ... |
s907724443 | p02678 | u336564899 | 2,000 | 1,048,576 | Wrong Answer | 872 | 57,928 | 632 | There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in th... | import collections
if __name__ == '__main__':
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]
ways = [[] for i in range(n+1)]
for i in l:
ways[i[0]].append(i[1])
ways[i[1]].append(i[0])
#print(ways)
q = collections.deque()
ans = ... | s579349816 | Accepted | 849 | 57,788 | 709 | import collections
if __name__ == '__main__':
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]
ways = [[] for i in range(n+1)]
for i in l:
ways[i[0]].append(i[1])
ways[i[1]].append(i[0])
#print(ways)
q = collections.deque()
ans = ... |
s701909772 | p02694 | u023185908 | 2,000 | 1,048,576 | Wrong Answer | 23 | 9,164 | 158 | 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... | import math
x = int(input())
year = 0
y = 100
t = True
while t:
year += 1
y = math.floor(y*1.01)
if y > x:
print(year)
t = False
| s304434988 | Accepted | 22 | 9,096 | 159 | import math
x = int(input())
year = 0
y = 100
t = True
while t:
year += 1
y = math.floor(y*1.01)
if y >= x:
print(year)
t = False
|
s270884872 | p03487 | u163320134 | 2,000 | 262,144 | Wrong Answer | 95 | 14,692 | 247 | You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly ... | n=int(input())
arr=list(map(int,input().split()))
cnt=[0]*(10**5+1)
ans=0
for i in range(n):
if arr[i]<=10**5:
cnt[arr[i]]+=1
else:
ans+=1
for i in range(1,10**5+1):
if cnt[i]>i:
ans+=cnt[i]-i
else:
ans+=i-cnt[i]
print(ans) | s210466589 | Accepted | 72 | 14,692 | 307 | n=int(input())
arr=list(map(int,input().split()))
cnt=[0]*(10**5+1)
ans=0
for i in range(n):
if arr[i]<=10**5:
cnt[arr[i]]+=1
else:
ans+=1
for i in range(1,10**5+1):
if cnt[i]==0:
continue
elif cnt[i]==i:
continue
elif cnt[i]>i:
ans+=cnt[i]-i
else:
ans+=cnt[i]
print(ans) |
s289282087 | p02612 | u731467249 | 2,000 | 1,048,576 | Wrong Answer | 32 | 9,144 | 32 | 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) | s879670505 | Accepted | 29 | 9,148 | 81 | N = int(input())
if N % 1000 > 0:
print(1000 - (N % 1000))
else:
print(0) |
s948325115 | p03555 | u500279510 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 120 | You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise. | a = input()
b = input()
if (a[0] == b[2]) and (a[1] == b[1]) and (a[2] == b[0]):
print('Yes')
else:
print('No') | s386158449 | Accepted | 17 | 2,940 | 120 | a = input()
b = input()
if (a[0] == b[2]) and (a[1] == b[1]) and (a[2] == b[0]):
print('YES')
else:
print('NO') |
s938395035 | p03573 | u434208140 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 60 | You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers. | s=list(map(int,input().split()))
print(sum(s)-min(s)-max(s)) | s879586350 | Accepted | 17 | 2,940 | 64 | s=list(map(int,input().split()))
print(2*min(s)+2*max(s)-sum(s)) |
s391316467 | p02409 | u908651435 | 1,000 | 131,072 | Wrong Answer | 20 | 5,620 | 293 | You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth fl... | n=int(input())
a=[[[0]*10 for i in range(3)] for j in range(4)]
for i in range(n):
b,f,r,v=map(int,input().split())
a[b-1][f-1][r-1]=v
for i in range(4):
for j in range(3):
for e in range(10):
print(' '+str(a[i][j][e]),end='')
print()
print('#'*20)
| s821301349 | Accepted | 20 | 5,620 | 311 | n=int(input())
a=[[[0]*10 for i in range(3)] for j in range(4)]
for i in range(n):
b,f,r,v=map(int,input().split())
a[b-1][f-1][r-1]+=v
for i in range(4):
for j in range(3):
for e in range(10):
print(' '+str(a[i][j][e]),end='')
print()
if i!=3:
print('#'*20)
|
s154753613 | p03861 | u492605584 | 2,000 | 262,144 | Wrong Answer | 19 | 3,188 | 65 | You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x? | a, b, x = map(int, input().split(" "))
print(int(b + 1 - a) // x) | s700891000 | Accepted | 18 | 2,940 | 126 | a, b, x = map(int, input().split(" "))
if a % x == 0:
print(int(b//x) - int(a//x) + 1)
else:
print(int(b//x) - int(a//x))
|
s794955663 | p02619 | u485319545 | 2,000 | 1,048,576 | Wrong Answer | 37 | 9,268 | 367 | Let's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to che... | d=int(input())
c=list(map(int,input().split()))
s=[]
for _ in range(d):
s_i=list(map(int,input().split()))
s.append(s_i)
for _ in range(d):
t=int(input())
dp=[0]*26
for i in range(d):
s_i = max(s[i])
index=s[i].index(max(s[i]))
dp[index]=i+1
tmp=0
for j in range(26):
tmp+=c[j... | s272653180 | Accepted | 41 | 9,084 | 393 | d=int(input())
c=list(map(int,input().split()))
s=[]
for _ in range(d):
s_i=list(map(int,input().split()))
s.append(s_i)
t=[]
for _ in range(d):
t_i=int(input())
t.append(t_i)
dp=[0]*26
ans=0
for i in range(d):
s_i = s[i][t[i]-1]
ans+=s_i
dp[t[i]-1]=i+1
tmp=0
for j in range(26):
... |
s157685306 | p04030 | u290211456 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 165 | Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this stri... | s = input()
res =[]
for i in range(len(s)):
print(res)
if s[i] == 'B':
if len(res) != 0:
res.pop(len(res)-1)
continue
res.append(s[i])
print("".join(res)) | s921366106 | Accepted | 20 | 3,060 | 153 | s = input()
res =[]
for i in range(len(s)):
if s[i] == 'B':
if len(res) != 0:
res.pop(len(res)-1)
continue
res.append(s[i])
print("".join(res)) |
s202906481 | p02678 | u377989038 | 2,000 | 1,048,576 | Wrong Answer | 22 | 9,008 | 11 | There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in th... | print("No") | s125979198 | Accepted | 681 | 38,464 | 399 | from collections import deque
print("Yes")
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
q = deque([0])
b = [0] * n
while q:
x = q.popleft()
for i in g[x]:
if b[i] != 0:
... |
s631713403 | p03377 | u698868214 | 2,000 | 262,144 | Wrong Answer | 24 | 9,160 | 77 | There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals. | A,B,X = map(int,input().split())
print("YES" if A+B == X or A == X else "NO") | s681772560 | Accepted | 23 | 9,100 | 72 | A,B,X = map(int,input().split())
print("YES" if A <= X <= A+B else "NO") |
s187027767 | p03659 | u859897687 | 2,000 | 262,144 | Wrong Answer | 182 | 24,800 | 154 | Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it. They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card. Let th... | n=int(input())
m=list(map(int,input().split()))
a=sum(m)
for i in range(1,n):
m[i]-=m[i-1]
ans=99999999
for i in m:
ans=min(ans,abs(a-i-i))
print(ans) | s336765921 | Accepted | 187 | 23,792 | 166 | n=int(input())
m=list(map(int,input().split()))
a=sum(m)
for i in range(1,n):
m[i]+=m[i-1]
ans=99999999999999
for i in m[:n-1]:
ans=min(ans,abs(a-i-i))
print(ans) |
s051852586 | p02972 | u727025296 | 2,000 | 1,048,576 | Wrong Answer | 630 | 20,664 | 699 | There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following con... | n = int(input())
a_list = list(map(int, input().split()))
a_count = len(a_list)
boll_list = [0] * n
for rev_index, a in enumerate(reversed(a_list)):
index = a_count - rev_index - 1
if (a + 1) * 2 > a_count:
boll_list[index] = a_list[index]
else:
divide_max = a_count // (index + 1)
... | s612072452 | Accepted | 806 | 17,204 | 674 | n = int(input())
a_list = list(map(int, input().split()))
a_count = len(a_list)
boll_list = [0] * n
for rev_index, a in enumerate(reversed(a_list)):
index = a_count - rev_index - 1
divide_max = a_count // (index + 1)
total = 0
for divide in range(divide_max):
total += boll_list[(index + ... |
s173396108 | p02412 | u949338836 | 1,000 | 131,072 | Wrong Answer | 30 | 6,724 | 294 | Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9 | #coding:utf-8
#1_7_B 2015.4.5
while True:
n,x = map(int,input().split())
if n == x == 0:
break
count = 0
for i in range(1 , n + 1):
for j in range(1 , n + 1):
if (x - i - j) < n and i < j < (x - i -j):
count += 1
print(count) | s097703450 | Accepted | 80 | 6,728 | 280 | #coding:utf-8
#1_7_B 2015.4.5
while True:
n,x = map(int,input().split())
if n == x == 0:
break
count = 0
for i in range(1 , n + 1):
for j in range(1 , n + 1):
if i < j < (x - i - j) <= n:
count += 1
print(count) |
s436857185 | p02853 | u629540524 | 2,000 | 1,048,576 | Wrong Answer | 30 | 9,108 | 241 | We held two competitions: Coding Contest and Robot Maneuver. In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen.... | x,y = map(int,input().split())
c = 0
if x==1:
c+=300000
elif x == 2:
c+=200000
elif x == 3:
c+=100000
if y==1:
c+=300000
elif y == 2:
c+=200000
elif y == 3:
c+=100000
if x == 1 and y == 1:
x+=400000
print(c) | s947810952 | Accepted | 27 | 9,184 | 246 | x,y = map(int,input().split())
c = 0
if x==1:
c+=300000
elif x == 2:
c+=200000
elif x == 3:
c+=100000
if y==1:
c+=300000
elif y == 2:
c+=200000
elif y == 3:
c+=100000
if x == 1 and y == 1:
c+=400000
print(c) |
s295040557 | p03006 | u906428167 | 2,000 | 1,048,576 | Wrong Answer | 20 | 3,188 | 523 | There are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i). We will collect all of these balls, by choosing two integers p and q such that p \neq 0 or q \neq 0 and then repeating the following operation: * Choose a ball remaining in the plane and collect it. Let (a, b) be the coordinat... | n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]
lst = []
for i in range(n):
for j in range(i,n):
if a[j][0]-a[i][0] <= 0 and a[j][1]-a[i][1] <= 0:
lst.append([a[i][0]-a[j][0], a[i][1]-a[j][1]])
else:
lst.append([a[j][0]-a[i][0], a[j][1]-a[i][1]])
i... | s422657711 | Accepted | 296 | 3,316 | 604 | n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]
lst = []
for i in range(n):
for j in range(i+1,n):
if a[j][0]-a[i][0] < 0:
lst.append([a[i][0]-a[j][0], a[i][1]-a[j][1]])
if a[j][0]-a[i][0] == 0:
lst.append([a[i][0]-a[j][0], abs(a[i][1]-a[j][1])])
... |
s303298925 | p04029 | u090225501 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 39 | 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((1 + n) * n / 2) | s416808396 | Accepted | 17 | 2,940 | 40 | n = int(input())
print((1 + n) * n // 2) |
s963773874 | p03386 | u048176319 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 202 | 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())
if A+K-1 >= B-K+1:
for i in range(A, B+1):
print(i)
else:
for i in range(A, A+K-1):
print(i)
for i in range(B-K+1, B):
print(i) | s383300648 | Accepted | 17 | 3,060 | 201 | A, B, K = map(int, input().split())
if A+K-1 >= B-K+1:
for i in range(A, B+1):
print(i)
else:
for i in range(A, A+K):
print(i)
for i in range(B-K+1, B+1):
print(i) |
s180023903 | p03796 | u943657163 | 2,000 | 262,144 | Wrong Answer | 2,104 | 3,464 | 78 | Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7. | n = int(input())
p = 1
for i in range(1, n+1):
p *= i
print(p % 10**9 + 7) | s038233927 | Accepted | 35 | 2,940 | 81 | n = int(input())
p, d =1, 10**9+7
for i in range(1,n+1):
p = (p*i) % d
print(p) |
s837333549 | p03360 | u706414019 | 2,000 | 262,144 | Wrong Answer | 28 | 9,084 | 90 | There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after... | A = sorted(list(map(int,input().split())))
N = int(input())
A[-1] = A[-1]**N
print(sum(A)) | s140087887 | Accepted | 25 | 9,132 | 92 | A = sorted(list(map(int,input().split())))
N = int(input())
A[-1] = A[-1]*2**N
print(sum(A)) |
s199543913 | p02411 | u748033250 | 1,000 | 131,072 | Wrong Answer | 20 | 7,528 | 549 | Write a program which reads a list of student test scores and evaluates the performance for each student. The test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, t... | while(1):
chuukan, kimatsu, saishi = map(int, input().split())
state = "None"
if chuukan == kimatsu == saishi == -1:
break
elif (chuukan or kimatsu) == -1:
state = "F"
elif (chuukan*2 + kimatsu*2)/2 >= 80:
state = "A"
elif (chuukan*2 + kimatsu*2)/2 >= 65:
state = "B"
elif (chuukan*2 + kimatsu*2)/2 >= 5... | s640170667 | Accepted | 20 | 5,596 | 452 | mid = 0
end = 0
re = 0
while(1):
mid, end, re = map(int, input().split() )
if (mid == -1) and (end == -1) and (re == -1) :
break
if (mid == -1) or (end == -1):
print("F")
elif mid + end >= 80:
print("A")
elif mid + end >= 65:
print("B")
elif mid + end >= 50:
... |
s667104354 | p02238 | u368083894 | 1,000 | 131,072 | Wrong Answer | 20 | 5,608 | 637 | Depth-first search (DFS) follows the strategy to search ”deeper” in the graph whenever possible. In DFS, edges are recursively explored out of the most recently discovered vertex $v$ that still has unexplored edges leaving it. When all of $v$'s edges have been explored, the search ”backtracks” to explore edges leaving ... |
d = None
f = None
def dfs(g, cur, time):
global d, f
d[cur] = time
for next in g[cur]:
if d[next] == 0:
time = dfs(g, next, time+1)
f[cur] = time + 1
return time + 1
def main():
global d, f
n = int(input())
g = [[] for _ in range(n)]
d = [0 for _ in range(n)]... | s886144234 | Accepted | 20 | 5,660 | 719 |
d = None
f = None
def dfs(g, cur, time):
global d, f
d[cur] = time
for next in g[cur]:
if d[next] == 0:
time = dfs(g, next, time+1)
f[cur] = time + 1
return time + 1
def main():
global d, f
n = int(input())
g = [[] for _ in range(n)]
d = [0 for _ in range(n)]... |
s096928854 | p03829 | u870518235 | 2,000 | 262,144 | Wrong Answer | 229 | 12,688 | 387 | There are N towns on a line running east-west. The towns are numbered 1 through N, in order from west to east. Each point on the line has a one- dimensional coordinate, and a point that is farther east has a greater coordinate value. The coordinate of town i is X_i. You are now at town 1, and you want to visit all the... | # -*- coding: utf-8 -*-
# Input
s = [input() for i in range(2)]
N = int(s[0].split()[0])
A = int(s[0].split()[1])
B = int(s[0].split()[2])
X = s[1].split()
F = 0
for i in range(0, N-1):
if A*(int(X[i+1]) - int(X[i])) >= B:
F = F + B
else:
F = F + A*(int(X[i+1]) - int(X[i]))
print(F)
#... | s051879414 | Accepted | 148 | 11,096 | 377 | # -*- coding: utf-8 -*-
# Input
s = [input() for i in range(2)]
N = int(s[0].split()[0])
A = int(s[0].split()[1])
B = int(s[0].split()[2])
X = s[1].split()
F = 0
for i in range(0, N-1):
if A*(int(X[i+1]) - int(X[i])) >= B:
F = F + B
else:
F = F + A*(int(X[i+1]) - int(X[i]))
# Output
p... |
s484272474 | p02390 | u356022548 | 1,000 | 131,072 | Wrong Answer | 20 | 5,580 | 242 | 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. | time = float(input("Input time in seconds: "))
day = time // (24 * 3600)
time = time % (24 * 3600)
hour = time // 3600
time %= 3600
minutes = time // 60
time %= 60
seconds = time
print("d:h:m:s-> %d:%d:%d:%d" % (day, hour, minutes, seconds))
| s667910871 | Accepted | 20 | 5,580 | 150 | S = float(input())
S = S % (24 * 3600)
hour = S // 3600
S %= 3600
minutes = S // 60
S %= 60
seconds = S
print("%d:%d:%d" % (hour, minutes, seconds))
|
s396825378 | p02694 | u919065552 | 2,000 | 1,048,576 | Wrong Answer | 21 | 9,024 | 168 | 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())
T = 100
InterestRate = 1.01
n = 0
while True:
T = int(T * InterestRate)
if T >= X:
print(n + 1)
break
n += 1
print("DONE")
| s666326895 | Accepted | 20 | 9,112 | 154 | X = int(input())
T = 100
InterestRate = 1.01
n = 0
while True:
T = int(T * InterestRate)
if T >= X:
print(n + 1)
break
n += 1
|
s119333780 | p02279 | u777299405 | 2,000 | 131,072 | Wrong Answer | 30 | 7,744 | 760 | 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... | class Tree():
def __init__(self):
self.parent = -1
self.depth = 0
self.child = []
n = int(input())
tree = [Tree() for i in range(n)]
for i in range(n):
cmd = list(map(int, input().split()))
node = tree[cmd[0]]
node.child.extend(cmd[2:])
for j in cmd[2:]:
tree[j].par... | s313479925 | Accepted | 1,390 | 42,484 | 768 | class Tree():
def __init__(self):
self.parent = -1
self.depth = 0
self.child = []
n = int(input())
tree = [Tree() for i in range(n)]
for i in range(n):
cmd = list(map(int, input().split()))
node = tree[cmd[0]]
node.child.extend(cmd[2:])
for j in cmd[2:]:
tree[j].par... |
s501369865 | p02261 | u865220118 | 1,000 | 131,072 | Wrong Answer | 20 | 5,600 | 1,087 | 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... |
A = []
B = []
C = []
LENGTH =int(input())
A = input().split()
B = A.copy()
C = A.copy()
print(A[1][1:])
def bubble (A, LENGTH):
N = 0
M = LENGTH - 1
CHANGE = 0
while N <= LENGTH -1:
M = LENGTH - 1
while M >= N + 1:
if int(A[M][1:]) < int(A[M-1][1:]):
tmp... | s456800092 | Accepted | 20 | 5,608 | 1,050 |
A = []
B = []
LENGTH =int(input())
A = input().split()
B = A.copy()
def bubble (A, LENGTH):
N = 0
M = LENGTH - 1
CHANGE = 0
while N <= LENGTH -1:
M = LENGTH - 1
while M >= N + 1:
if int(A[M][1:]) < int(A[M-1][1:]):
tmp = A[M-1]
A[M-1] = A[... |
s033881504 | p03943 | u977193988 | 2,000 | 262,144 | Wrong Answer | 19 | 3,316 | 101 | 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. Not... | A,B,C=map(int,input().split())
if A+B==C or A+C==B or B+C==A:
print('YES')
else:
print('NO') | s501679494 | Accepted | 17 | 2,940 | 101 | A,B,C=map(int,input().split())
if A+B==C or A+C==B or B+C==A:
print('Yes')
else:
print('No') |
s958037752 | p03657 | u282228874 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 118 | 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 ca... | a,b = map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
print('Possiblle')
else:
print('Impossible') | s845294338 | Accepted | 18 | 2,940 | 117 | a,b = map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
print('Possible')
else:
print('Impossible') |
s587675130 | p02257 | u696273805 | 1,000 | 131,072 | Wrong Answer | 20 | 5,664 | 291 | A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. Write a program which reads a list of _N_ integers and prints the number of prime numbers in the list. | import math
def is_prime(n):
sqrtn = math.ceil(math.sqrt(n))
for i in range(2, sqrtn):
if n % i:
return False
return n != 1
n = int(input())
answer = 0
for _ in range(0, n):
m = int(input())
if is_prime(m):
answer = answer + 1
print(answer)
| s045723232 | Accepted | 70 | 5,620 | 963 | def witness(a, n, t, u):
x = pow(a, u, n)
for _ in range(0, t):
y = (x * x) % n
if y == 1 and x != 1 and x != (n - 1):
return True
x = y
return y != 1
def is_probably_prime(n, witnesses):
t = 1
u = n >> 1
while u & 1 == 0:
t = t + 1
... |
s924735838 | p04045 | u950708010 | 2,000 | 262,144 | Wrong Answer | 24 | 2,940 | 244 | Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very ... | n,k = (int(i) for i in input().split())
d = list(int(i) for i in input().split())
def ketajudge(x):
while x != 0:
if x%10 in d:
return False
break
else:
if x//10 == 0:
return True
break
x = x//10 | s079848467 | Accepted | 48 | 2,940 | 355 | n,k = (int(i) for i in input().split())
d = list(int(i) for i in input().split())
def ketajudge(x):
while x != 0:
if x%10 in d:
return False
break
else:
if x//10 == 0:
return True
break
x = x//10
for i in range(10*n):
judge = n+i
if ketajudge(judge) == True:
... |
s107137565 | p03543 | u349444371 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 109 | We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**? | N=input()
if N.count(N[0])==4 or N[0]==N[1]==N[2] or N[1]==N[2]==N[3]:
print("YES")
else:
print("NO") | s475263705 | Accepted | 17 | 2,940 | 109 | N=input()
if N.count(N[0])==4 or N[0]==N[1]==N[2] or N[1]==N[2]==N[3]:
print("Yes")
else:
print("No") |
s240986408 | p02390 | u886726907 | 1,000 | 131,072 | Wrong Answer | 20 | 5,576 | 57 | 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. | t=int(input())
print(t//3600,t//60-60*(t//3600),t%3600)
| s505523060 | Accepted | 20 | 5,576 | 74 | t=int(input())
print("{}:{}:{}".format(t//3600,t//60-60*(t//3600),t%60))
|
s122463415 | p03997 | u636775911 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 88 | 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. | #coding:utf-8
n=[]
for i in range(3):
n.append(int(input()))
print((n[0]+n[1])*n[2]/2) | s921240536 | Accepted | 17 | 2,940 | 94 | #coding:utf-8
n=[]
for i in range(3):
n.append(int(input()))
print(int((n[0]+n[1])*n[2]/2))
|
s118053976 | p02394 | u798565376 | 1,000 | 131,072 | Wrong Answer | 20 | 5,592 | 250 | Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given. | l = list(map(int, input().split()))
W = l[0]
H = l[1]
x = l[2]
y = l[3]
r = l[4]
left_x = x - r
right_x = x + r
top_y = y + r
bottom_y = y - r
if left_x >= W and right_x <= W and top_y <= H and bottom_y >= H:
print("Yes")
else:
print("No")
| s426110934 | Accepted | 20 | 5,596 | 250 | l = list(map(int, input().split()))
W = l[0]
H = l[1]
x = l[2]
y = l[3]
r = l[4]
left_x = x - r
right_x = x + r
top_y = y + r
bottom_y = y - r
if left_x >= 0 and right_x <= W and top_y <= H and bottom_y >= 0:
print("Yes")
else:
print("No")
|
s652742818 | p03503 | u140251125 | 2,000 | 262,144 | Wrong Answer | 152 | 12,440 | 709 | Joisino is planning to open a shop in a shopping street. Each of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those ... | import math
import numpy as np
from operator import mul
# l = [int(x) for x in list(str(N))]
N = int(input())
f = [list(map(int, input().split())) for i in range(N)]
p = [list(map(int, input().split())) for i in range(N)]
c = list(range(N))
for i in range(1,2^10):
i_bin = format(i, 'b')
i_list = [int(x) for... | s735369566 | Accepted | 491 | 19,668 | 736 | import math
import numpy as np
from operator import mul
# l = [int(x) for x in list(str(N))]
N = int(input())
f = [list(map(int, input().split())) for i in range(N)]
p = [list(map(int, input().split())) for i in range(N)]
c = list(range(N))
max_p = -100**7-1
for i in range(1,2**10):
i_bin = format(i, 'b').zfill... |
s590786744 | p03351 | u951480280 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 103 | Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either ... | a,b,c,d=map(int,input().split());print("YES" if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d) else "NO") | s968356634 | Accepted | 18 | 2,940 | 103 | a,b,c,d=map(int,input().split());print("Yes" if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d) else "No") |
s981963572 | p03377 | u359856428 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 100 | 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 and x <= a + b:
print("Yes")
else:
print("No") | s035386100 | Accepted | 17 | 2,940 | 100 | a,b,x = map(int,input().split(' '))
if a <= x and x <= a + b:
print("YES")
else:
print("NO") |
s233545373 | p02612 | u585963734 | 2,000 | 1,048,576 | Wrong Answer | 29 | 9,148 | 28 | 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) | s818873784 | Accepted | 30 | 9,160 | 66 | N=int(input())
if N%1000==0:
print(0)
else:
print(1000-N%1000) |
s829664533 | p02972 | u343850880 | 2,000 | 1,048,576 | Wrong Answer | 129 | 7,276 | 464 | There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following con... | N = int(input())
in_list = [int(i) for i in input().split(' ')]
out_list = []
flag = 0
for i in range(1,len(in_list)+1):
count = 0
div_list = in_list[::i]
count += sum(div_list)
if count==in_list[i-1]:
if count!=0:
out_list.append(count)
else :
flag = 1
break
if f... | s480213448 | Accepted | 234 | 17,224 | 262 | n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]
c = []
for i in range(n,0,-1):
tmp = sum(b[i-1::i])
if tmp%2!=a[i-1]:
b[i-1] = 1
c.append(str(i))
print(len(c))
if len(c)!=0:
print(" ".join(c))
|
s672248166 | p02831 | u395620499 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 154 | Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted. We assume that a piece cannot be ... | a,b = map(int, input().split())
def lcm(n, m):
bigger = n if n > m else m
while bigger % n != 0 and bigger % m != 0:
bigger += 1
print(lcm(a,b)) | s085317354 | Accepted | 17 | 2,940 | 159 | a,b = map(int, input().split())
def gcd(n,m):
while m:
n, m = m, n % m
return n
def lcm(n,m):
return (n*m) // gcd(n,m)
print(lcm(a,b))
|
s845497244 | p03501 | u943004959 | 2,000 | 262,144 | Wrong Answer | 66 | 3,060 | 179 | You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours. | def solve():
N, A, B = list(map(int, input().split()))
if N * A > B:
print(N * A)
elif N * A < B:
print(B)
else:
print(B)
solve() | s211761793 | Accepted | 17 | 2,940 | 102 | def solve():
N, A, B = list(map(int, input().split()))
print(min(N * A, B))
solve()
|
s903886409 | p04043 | u357751375 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 91 | 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 ... | A,B,C= input().split()
Sum = A + B + C
if Sum == 17:
print('YES')
else:
print('NO') | s695385056 | Accepted | 17 | 2,940 | 106 | A,B,C= input().split()
Sum = int(A) + int(B) + int(C)
if Sum == 17:
print('YES')
else:
print('NO') |
s158983527 | p03388 | u419535209 | 2,000 | 262,144 | Time Limit Exceeded | 2,104 | 3,064 | 450 | 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 ... | # PROBLEM D
Q = int(input())
for _ in range(Q):
a, b = sorted([int(s) for s in input().split()])
c = 1
sol = 0
while True:
d = (a * b) // c
while c * d >= a * b:
d -= 1
if c > d:
break
if c < d:
sol_ = (c != a) + (d != b)
else:
... | s536053859 | Accepted | 19 | 3,064 | 337 | # PROBLEM D
Q = int(input())
for _ in range(Q):
a, b = sorted([int(s) for s in input().split()])
c_max = int((a * b) ** 0.5)
if c_max * c_max == a * b:
c_max -= 1
sol = 2 * c_max
if a <= c_max:
sol -= 1
if (c_max * c_max < a * b) and (c_max * (c_max + 1) >= a * b):
sol -=... |
s059980875 | p03816 | u973712798 | 2,000 | 262,144 | Wrong Answer | 2,103 | 70,060 | 696 | Snuke has decided to play a game using cards. He has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written. He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of... | import collections
n = int(input())
a_list = [int(i) for i in input().split()]
cnt = collections.Counter(a_list)
for key, num in cnt.items():
print(cnt)
if num == 2 or num == 1:
pass
elif num % 2 != 0 and num > 1:
cnt[key] = 1
elif num % 2 == 0 and num > 2:
c... | s086553427 | Accepted | 93 | 18,656 | 759 | import collections
n = int(input())
a_list = [int(i) for i in input().split()]
cnt = collections.Counter(a_list)
c = 0
for key, num in cnt.items():
# print(cnt)
if num == 2 or num == 1:
if num == 2:
c += 1
pass
elif num % 2 != 0 and num > 1:
cnt[key] = 1
... |
s301669510 | p02612 | u582759840 | 2,000 | 1,048,576 | Wrong Answer | 29 | 9,140 | 24 | 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. | print(int(input())%1000) | s702845282 | Accepted | 26 | 9,144 | 48 | x=int(input())%1000
print(0 if x==0 else 1000-x) |
s453191418 | p03644 | u357751375 | 2,000 | 262,144 | Wrong Answer | 27 | 9,096 | 67 | 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())
if n % 2 == 0:
print(n)
else:
print(n - 1) | s567291178 | Accepted | 28 | 9,160 | 113 | n = int(input())
ans = 1
while True:
ans *= 2
if ans > n:
ans = ans // 2
break
print(ans) |
s786586809 | p03555 | u113835532 | 2,000 | 262,144 | Wrong Answer | 28 | 8,776 | 51 | You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise. | print('Yes' if input() == input()[::-1] else 'No')
| s588563011 | Accepted | 28 | 8,828 | 51 | print('YES' if input() == input()[::-1] else 'NO')
|
s522585391 | p03090 | u406492455 | 2,000 | 1,048,576 | Wrong Answer | 25 | 3,956 | 153 | You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved... | n = int(input())
E = []
for i in range(n):
for j in range(i+1,n):
if i+j != n-1:
E.append((i,j))
for a,b in E:
print(a+1,b+1) | s026059572 | Accepted | 26 | 3,996 | 252 | n = int(input())
E = []
B = [[0]*n for i in range(n)]
for i in range(n):
for j in range(i+1,n):
if i+j != (n-n%2)-1:
E.append((i,j))
B[i][j] = 1
B[j][i] = 1
print(len(E))
for a,b in E:
print(a+1,b+1) |
s719134968 | p03998 | u813371068 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 79 | Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * ... | S={c:list(input()) for c in "abc"}
s = 'a'
while S[s]: s = S[s].pop(0)
print(s) | s067526949 | Accepted | 17 | 2,940 | 87 | S={c:list(input()) for c in "abc"}
s = 'a'
while S[s]: s = S[s].pop(0)
print(s.upper()) |
s068923056 | p03478 | u399337080 | 2,000 | 262,144 | Wrong Answer | 35 | 3,060 | 236 | Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive). | def digitSum(c):
s = str(c)
array = list(map(int, s))
return sum(array)
n, a, b = map(int,input().split())
print (n,a,b)
ans = 0
for i in range(n+1):
sm = digitSum(i)
if a <= sm <= b:
ans += i
print(ans) | s839631087 | Accepted | 35 | 3,060 | 137 | n, a, b = map(int,input().split())
ans = 0
for i in range(n+1):
if a <= sum(list(map(int, str(i)))) <= b:
ans += i
print(ans) |
s919331752 | p02821 | u223663729 | 2,000 | 1,048,576 | Wrong Answer | 631 | 41,860 | 441 | Takahashi has come to a party as a special guest. There are N ordinary guests at the party. The i-th ordinary guest has a _power_ of A_i. Takahashi has decided to perform M _handshakes_ to increase the _happiness_ of the party (let the current happiness be 0). A handshake will be performed as follows: * Takahashi c... | import numpy as np
from numpy.fft import rfft, irfft
N, M = map(int, input().split())
*A, = map(int, input().split())
B = np.zeros(2*10**5)
for a in A:
B[a] += 1
L = 2*10**5
FB = rfft(B, L)
C = np.rint(irfft(FB*FB)).astype(int)
ans = 0
for i in range(L-1, -1, -1):
c = C[i]
if not c:
continue
... | s651427451 | Accepted | 892 | 20,752 | 547 | from itertools import accumulate
from bisect import bisect_left, bisect_right
N, M = map(int, input().split())
*A, = map(int, input().split())
A.sort()
acc = list(accumulate(A[::-1]))[::-1]+[0]
def isok(x):
cnt = 0
for a in A:
cnt += N - bisect_left(A, x-a)
return cnt >= M
l = 0
r = 202020
while... |
s157970142 | p03644 | u636822224 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 59 | 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... | a=int(input())
cnt=0
if a%2==0:
cnt+=1
else:
print(cnt) | s066476133 | Accepted | 17 | 2,940 | 101 | n=int(input())
for i in range(99):
if 2**i <= n:
continue
else:
print(2**(i-1))
break |
s462991159 | p03370 | u278430856 | 2,000 | 262,144 | Wrong Answer | 19 | 3,828 | 129 | Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams o... | N, X = map(int, input().split())
gram = [int(input()) for i in range(N)]
dp = [0]*10**5
X = X - sum(gram)
print(N+(X/min(gram))) | s267169295 | Accepted | 18 | 3,828 | 130 | N, X = map(int, input().split())
gram = [int(input()) for i in range(N)]
dp = [0]*10**5
X = X - sum(gram)
print(N+(X//min(gram))) |
s276761477 | p02842 | u328755070 | 2,000 | 1,048,576 | Wrong Answer | 30 | 9,156 | 158 | 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).... | N = int(input())
senter = N // 1.08
for i in range(1000):
if senter-100+i == N:
print(senter-100+i)
break
else:
print(":(")
| s009469034 | Accepted | 29 | 9,136 | 169 | N = int(input())
senter = N // 1.08
for i in range(1000):
if int((senter-100+i) * 1.08) == N:
print(int(senter-100+i))
break
else:
print(":(")
|
s642610447 | p03712 | u626337957 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 187 | 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())
edge = ['#' for _ in range(W)]
output = edge + [list(input()) for __ in range(H)] + edge
for row in output:
row_str = ''.join(row)
print(row_str)
| s039545007 | Accepted | 18 | 3,060 | 191 | H, W = map(int, input().split())
edge = [['#'] * (W+2)]
output = edge + [['#'] + list(input()) + ['#'] for __ in range(H)] + edge
for row in output:
row_str = ''.join(row)
print(row_str)
|
s463228541 | p02608 | u089230684 | 2,000 | 1,048,576 | Time Limit Exceeded | 2,205 | 8,932 | 294 | Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N). | n = int(input())
def calc(c):
g = 0
for x in range(1, 101):
for y in range(1, 101):
for z in range(1, 101):
if (x * x) + (y * y) + (z * z) + x * y + y * z + x * z == c:
g += 1
return g
for i in range(n):
print(calc(i)) | s711255860 | Accepted | 154 | 9,296 | 298 | n = int(input())
a = [0] * (n + 1)
for x in range(1, 101):
for y in range(1, 101):
for z in range(1, 101):
c = x * x + y * y + z * z + x * y + y * z + z * x
if c <= n:
a[c] +=1
else:
break
for i in a[1:]:
print(i)
|
s541050926 | p03693 | u038290713 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 96 | AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this i... | r,g,b = map(str, input().split())
n = int(r+g+b)
if n%4 ==0:
print("Yes")
else:
print("No") | s986743445 | Accepted | 17 | 2,940 | 96 | r,g,b = map(str, input().split())
n = int(r+g+b)
if n%4 ==0:
print("YES")
else:
print("NO") |
s657245122 | p01315 | u128811851 | 8,000 | 131,072 | Wrong Answer | 70 | 6,748 | 652 | You are passionate about the popular web game "Moonlight Ranch". The purpose of this game is to grow crops in the fields, sell them to earn income, and use the income to grow the ranch. You wanted to grow your field quickly. Therefore, we decided to start by arranging the crops that can be grown in the game based on th... | while True:
amount = int(input())
if amount == 0:
break
efficiency_list = []
for _ in range(amount):
crop = input().split()
time = sum(map(int, crop[2:7]))
M = int(crop[9])
if M > 1:
for _ in range(1, M):
time += int(crop[5]) + int(... | s909968318 | Accepted | 60 | 6,732 | 617 | while True:
amount = int(input())
if amount == 0:
break
efficiency_list = []
for _ in range(amount):
crop = input().split()
time = sum(map(int, crop[2:7]))
M = int(crop[9])
if M > 1:
for _ in range(1, M):
time += int(crop[5]) + int(... |
s709753328 | p03408 | u940102677 | 2,000 | 262,144 | Wrong Answer | 29 | 3,060 | 157 | Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will ea... | a=[]
b=[]
m=0
for _ in [0]*int(input()):
a += input()
for _ in [0]*int(input()):
b += input()
for s in a:
m = max(m, a.count(s)-b.count(s))
print(m)
| s802407450 | Accepted | 18 | 3,060 | 161 | a=[]
b=[]
m=0
for _ in [0]*int(input()):
a += [input()]
for _ in [0]*int(input()):
b += [input()]
for s in a:
m = max(m, a.count(s)-b.count(s))
print(m)
|
s509099907 | p02612 | u602481141 | 2,000 | 1,048,576 | Wrong Answer | 27 | 9,088 | 44 | 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. | str = input()
int = int(str[-3:])
print(int) | s207727581 | Accepted | 27 | 9,144 | 87 | str = input()
int = int(str[-3:])
if(int == 0):
print(0)
else:
print(1000-int) |
s716848788 | p03860 | u997530672 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 35 | 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 uppe... | s = input()
print('A' + s[0] + 'C') | s239418599 | Accepted | 18 | 2,940 | 61 | a, b, c = map(str, input().split())
print(a[0] + b[0] + c[0]) |
s378194885 | p03546 | u064408584 | 2,000 | 262,144 | Wrong Answer | 31 | 3,316 | 327 | Joisino the magical girl has decided to turn every single digit that exists on this world into 1. Rewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points). She is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and... | h,w=map(int, input().split())
c=[list(map(int, input().split())) for i in range(10)]
al=[list(map(int, input().split())) for i in range(h)]
ans=0
for k in range(10):
for i in range(10):
for j in range(10):
c[i][j]=min(c[i][j],c[i][k]+c[k][j])
for i in al:
for j in i:
ans+=c[j][1]
pri... | s206472401 | Accepted | 32 | 3,316 | 359 | h,w=map(int, input().split())
c=[list(map(int, input().split())) for i in range(10)]
al=[list(map(int, input().split())) for i in range(h)]
ans=0
for k in range(10):
for i in range(10):
for j in range(10):
c[i][j]=min(c[i][j],c[i][k]+c[k][j])
ans=0
for i in al:
for j in i:
if j==-1:c... |
s123842396 | p03455 | u208713671 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 157 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | ab = list(map(int,input("a b =").split())) #1 3 5
a = ab[0]
b = ab[1]
if a*b %2 == 0:
output = "Even"
elif a*b %2 == 1:
output = "Odd"
print(output)
| s536747961 | Accepted | 17 | 2,940 | 150 | ab = list(map(int,input().split())) #1 3 5
a = ab[0]
b = ab[1]
if a*b %2 == 0:
output = "Even"
elif a*b %2 == 1:
output = "Odd"
print(output)
|
s048119426 | p03827 | u361826811 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 300 | 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... |
import sys
import itertools
# import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = readline().decode('utf8')
print(max(0, S.count('I') - S.count('D')))
| s144340651 | Accepted | 17 | 3,060 | 382 |
import sys
import itertools
# import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = readline().decode('utf8')
ans = 0
cnt=0
for i in S:
if i == 'I':
cnt += 1
else:
cnt -= 1
ans=max(ans, ... |
s553085880 | p03026 | u200785298 | 2,000 | 1,048,576 | Wrong Answer | 53 | 8,304 | 1,332 | You are given a tree with N vertices 1,2,\ldots,N, and positive integers c_1,c_2,\ldots,c_N. The i-th edge in the tree (1 \leq i \leq N-1) connects Vertex a_i and Vertex b_i. We will write a positive integer on each vertex in T and calculate our _score_ as follows: * On each edge, write the smaller of the integers ... | #!/usr/bin/env python3
import sys
def solve(N: int, a: "List[int]", b: "List[int]", C: "List[int]"):
conn = [[] for _ in range(N + 1)]
for i in range(N - 1):
conn[a[i]].append(b[i])
conn[b[i]].append(a[i])
counts = [[] for _ in range(N)]
for i in range(1, N + 1):
counts[i - 1] ... | s790441404 | Accepted | 1,576 | 8,948 | 1,573 | #!/usr/bin/env python3
import sys
#from queue import Queue
def solve(N: int, a: "List[int]", b: "List[int]", C: "List[int]"):
conn = [[] for _ in range(N)]
for i in range(N - 1):
conn[a[i] - 1].append(b[i] - 1)
conn[b[i] - 1].append(a[i] - 1)
#counts = [Queue() for _ in range(N)]
count... |
s856846287 | p03416 | u785578220 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 159 | Find the number of _palindromic numbers_ among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward. | n,k=map(int, input().split())
if n==2 or k==2:
print(0)
elif n == 1 and k == 1:print(1)
elif n == 1 or k ==1:
print(max(n,k)-2)
else:print((n-2)*(k-2)) | s981624240 | Accepted | 49 | 2,940 | 119 | k , n = map(int, input().split())
r = 0
for i in range(k,n+1):
s = str(i)
if s == s[::-1]:
r+=1
print(r) |
s107208646 | p03623 | u619458041 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 224 | Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and... | import sys
def main():
input = sys.stdin.readline
x, a, b = map(int, input().split())
if abs(a - x) >= abs(b - x):
return 'A'
else:
return 'B'
if __name__ == '__main__':
print(main())
| s046632957 | Accepted | 18 | 2,940 | 224 | import sys
def main():
input = sys.stdin.readline
x, a, b = map(int, input().split())
if abs(a - x) <= abs(b - x):
return 'A'
else:
return 'B'
if __name__ == '__main__':
print(main())
|
s726504580 | p03597 | u468972478 | 2,000 | 262,144 | Wrong Answer | 26 | 9,148 | 47 | 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())
w = int(input())
print(n - w) | s419122401 | Accepted | 26 | 9,152 | 52 | n = int(input())
w = int(input())
print(n ** 2 - w) |
s843015333 | p02678 | u838644735 | 2,000 | 1,048,576 | Wrong Answer | 648 | 68,528 | 712 | There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in th... | from collections import deque
def main():
N, M, *AB = map(int, open(0).read().split())
C = {}
for i in range(M):
a = AB[2 * i + 0] - 1
b = AB[2 * i + 1] - 1
if a not in C:
C[a] = []
C[a].append(b)
if b not in C:
C[b] = []
C[b].append(a... | s849719787 | Accepted | 624 | 68,208 | 714 | from collections import deque
def main():
N, M, *AB = map(int, open(0).read().split())
C = {}
for i in range(M):
a = AB[2 * i + 0] - 1
b = AB[2 * i + 1] - 1
if a not in C:
C[a] = []
C[a].append(b)
if b not in C:
C[b] = []
C[b].append(a... |
s408666748 | p03565 | u833963136 | 2,000 | 262,144 | Wrong Answer | 29 | 9,108 | 824 | 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 = str(input())
t = str(input())
ns = len(s)
nt = len(t)
start = -1
for j in range(ns):
if t[0] == s[j] or s[j] == '?':
i = 0
j_temp = j
is_ok = True
while i < nt:
i += 1
j_temp += 1
if j_temp >= ns:
is_ok = False
b... | s695605910 | Accepted | 27 | 8,896 | 857 | s = str(input())
t = str(input())
ns = len(s)
nt = len(t)
start = -1
for j in range(ns):
if t[0] == s[j] or s[j] == '?':
j_temp = j
i_temp = 0
is_ok = True
while i_temp < nt - 1:
i_temp += 1
j_temp += 1
if j_temp >= ns:
is_ok = Fals... |
s134773150 | p02417 | u853619096 | 1,000 | 131,072 | Wrong Answer | 20 | 7,400 | 211 | Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters. | z = input()
a = []
b = 0
for i in z:
if i.isupper():
a += i.upper()
a += i
print(a)
al = [chr(i) for i in range(97, 97 + 26)]
for i in al:
b = str(a.count(i))
print('{} : {}'.format(i,b)) | s880493515 | Accepted | 20 | 7,472 | 272 | z=''
while True:
try:
z += input()
except EOFError:
break
a = []
b = 0
for i in z:
if i.isupper():
a += i.lower()
a += i
al = [chr(i) for i in range(97, 97 + 26)]
for i in al:
b = str(a.count(i))
print('{} : {}'.format(i,b)) |
s620324978 | p03836 | u020604402 | 2,000 | 262,144 | Wrong Answer | 21 | 3,064 | 416 | Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement ... | x1,y1,x2,y2 = map(int ,input().split())
x = x2 - x1
y = y2 - y1
ans = ''
a = 'U'
b = 'D'
c = 'R'
d = 'L'
for _ in range(y):
ans += a
for _ in range(x):
ans += c
for _ in range(y):
ans += b
for _ in range(x) :
ans += d
ans += d
for _ in range(y + 1):
ans += a
for _ in range(x +1):
ans += c
ans ... | s753067154 | Accepted | 21 | 3,064 | 425 | x1,y1,x2,y2 = map(int ,input().split())
x = x2 - x1
y = y2 - y1
ans = ''
a = 'U'
b = 'D'
c = 'R'
d = 'L'
for _ in range(y):
ans += a
for _ in range(x):
ans += c
for _ in range(y):
ans += b
for _ in range(x) :
ans += d
ans += d
for _ in range(y + 1):
ans += a
for _ in range(x +1):
ans += c
ans ... |
s559205265 | p03478 | u743272507 | 2,000 | 262,144 | Wrong Answer | 24 | 3,060 | 191 | Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive). | n,a,b = map(int,input().split())
def ketawa(i):
ret = 0
while(i):
ret += i % 10
i //= 10
return ret
ret = 0
for i in range(1,n+1):
if a <= ketawa(i) <= b: ret += 1
print(ret) | s999678679 | Accepted | 24 | 2,940 | 192 | n,a,b = map(int,input().split())
def ketawa(i):
ret = 0
while(i):
ret += i % 10
i //= 10
return ret
ret = 0
for i in range(1,n+1):
if a <= ketawa(i) <= b: ret += i
print(ret)
|
s041989062 | p03433 | u248670337 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 55 | E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins. | print("YES" if int(input())%500<int(input()) else "NO") | s019963356 | Accepted | 17 | 2,940 | 56 | print("Yes" if int(input())%500<=int(input()) else "No") |
s073647755 | p03545 | u235376569 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 184 | 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 in... | import sys
a,b,c,d=input()
op=["-","+"]
for i in op:
for j in op:
for k in op:
o=a+i+b+j+c+k+d
ans=eval(o)
if ans==7:
print(o+"+=7")
sys.exit() | s898711302 | Accepted | 18 | 2,940 | 184 | import sys
a,b,c,d=input()
op=["-","+"]
for i in op:
for j in op:
for k in op:
o=a+i+b+j+c+k+d
ans=eval(o)
if ans==7:
print(o+"=7")
sys.exit()
|
s889351805 | p02603 | u605161376 | 2,000 | 1,048,576 | Wrong Answer | 25 | 9,160 | 368 | To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the n... | K = int(input())
A = list(map(int, input().split()))
sum = 1000
kabu = 0
for k in range(K):
if k+1 ==K:
sum +=kabu*A[K-1]
break
if A[k]<A[k+1] and A[k]<=sum:
S = int(sum/A[k])
sum = sum-A[k]*S
kabu +=S
elif A[k]>A[k+1] and kabu != 0:
sum = sum + kabu * A[k]
... | s868376381 | Accepted | 31 | 8,896 | 353 | K = int(input())
A = list(map(int, input().split()))
sum = 1000
kabu = 0
for k in range(K):
if k+1 ==K:
sum +=kabu*A[K-1]
break
if A[k]<A[k+1] and A[k]<=sum:
S = int(sum/A[k])
sum = sum-A[k]*S
kabu +=S
elif A[k]>A[k+1] and kabu != 0:
sum = sum + kabu * A[k]
... |
s894656930 | p03385 | u143509139 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 146 | You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`. | s = list(input())
str_list = ['abc','acb','bac','bca','cab','cba']
ans = 'No'
for l in str_list:
if s == l:
ans = 'Yes'
break
print(ans) | s617369687 | Accepted | 17 | 2,940 | 85 | s = input()
if 'a' in s and 'b' in s and 'c' in s:
print('Yes')
else:
print('No') |
s579936986 | p03352 | u685983477 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 120 | 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. | x = int(input())
ans = 1
tmp = 0
for i in range(2, x):
tmp = i
while tmp*i <= x:
ans+=1
tmp*=i
print(ans)
| s187287990 | Accepted | 17 | 2,940 | 137 | x = int(input())
ans = 1
for i in range(2, 1000):
tmp = 2
while i**tmp <= x:
ans=max(ans, i**tmp)
tmp+=1
print(ans)
|
s379929090 | p04030 | u363438602 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 224 | Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this stri... | s=input()
s=list(s)
l=[]
ls=len(s)
for i in range (ls):
if s[i]=='1':
l.append(1)
elif s[i]=='0':
l.append(0)
else:
if len(l)==0:
l=l
else:
l.pop()
print(l) | s303282895 | Accepted | 17 | 3,064 | 279 | s=input()
s=list(s)
l=[]
ls=len(s)
for i in range (ls):
if s[i]=='1':
l.append(1)
elif s[i]=='0':
l.append(0)
else:
if len(l)==0:
l=l
else:
l.pop()
ans=""
for i in range(len(l)):
ans=ans+str(l[i])
print(ans) |
s093869021 | p03494 | u844172143 | 2,000 | 262,144 | Wrong Answer | 20 | 3,064 | 428 | There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform. | N = int(input())
A = list(map(int, input().split()))
def devide(array, count):
print(array);
dividable = True
for i in array:
if ((i % 2) != 0):
dividable = False
if (dividable):
print('a')
for index, value in enumerate(array):
array[index] = value / 2
count += 1
return devide(array, count)
else:
... | s614683230 | Accepted | 18 | 3,064 | 357 | N = int(input())
A = list(map(int, input().split()))
def devide(array, count):
dividable = True
for i in array:
if ((i % 2) != 0):
dividable = False
if (dividable):
for index, value in enumerate(array):
array[index] = value / 2
count += 1
return devide(array, count)
else:
return array, count
devid... |
s810627036 | p03386 | u503901534 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 500 | 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. | l = list(map(int, input().split()))
a = l[0]
b = l[1]
c = l[2]
ss = []
ll = []
def checkK(x,y,z):
if y - x + 1 <= z:
counter = int(x)
while counter != y:
ss.append(counter)
counter = counter + 1
for i in range(len(ss)):
print(ss[i])
else:
for ... | s638481772 | Accepted | 17 | 3,064 | 529 | l = list(map(int, input().split()))
a = l[0]
b = l[1]
c = l[2]
ss = []
mm = []
ll = []
def checkK(x,y,z):
if y - x + 1 <= z *2:
counter = int(x)
while counter != y+1:
ss.append(counter)
counter = counter + 1
for i in range(len(ss)):
print(ss[i])
... |
s335354853 | p03377 | u192541825 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 89 | 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 and x<=a+b:
print("Yes")
else:
print("No") | s463988833 | Accepted | 17 | 2,940 | 89 | a,b,x=map(int,input().split())
if a<=x and x<=a+b:
print("YES")
else:
print("NO") |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.