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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s348254811 | p03047 | u143903328 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 45 | 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? | a,b = map(int,input().split())
print(b-a + 1) | s632220804 | Accepted | 17 | 2,940 | 45 | a,b = map(int,input().split())
print(a-b + 1) |
s541211025 | p02406 | u659034691 | 1,000 | 131,072 | Wrong Answer | 20 | 7,564 | 290 | In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement ... | #15dpro
n=int(input())
#s=
#print(n)
for i in range(1,n-1):
# print(i)
if i%3==0:
print(' '+str(i),end='')
else:
x=i
# print(x)
while x>0 and x%10!=3:
# print(x)
x//=10
if x%10==3:
print(' '+str(i),end='') | s562410731 | Accepted | 20 | 7,672 | 278 | #15dpro
n=int(input())
s=''
#print(n)
for i in range(1,n+1):
# print(i)
if i%3==0:
s+=' '+str(i)
else:
x=i
# print(x)
while x>0 and x%10!=3:
# print(x)
x//=10
if x%10==3:
s+=' '+str(i)
print(s) |
s521787592 | p03943 | u920387587 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 182 | 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())
count=[a,b,c]
d =max(count)
v=0
count.remove(d)
for i in range(len(count)):
v += count[i]
if v ==d :
print('YES')
else:
print('NO') | s250793551 | Accepted | 17 | 3,060 | 182 | a, b, c = map(int, input().split())
count=[a,b,c]
d =max(count)
v=0
count.remove(d)
for i in range(len(count)):
v += count[i]
if v ==d :
print('Yes')
else:
print('No') |
s538383548 | p03769 | u864197622 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 217 | We will call a string x _good_ if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example, `aa` and `bubobubo` are good; an empty string, `a`, `abcabcabc` and `abba` are not good. Eagle and Owl created a puzzle o... | def calc(n, k):
if n==1:
return str(k) + " " + str(k)
if n%2==0:
return calc(n-1, k+1) + " " + str(k) + " " + str(k)
return str(k) + " " + calc((n-1)//2, k+1) + " " + str(k)
print(calc(int(input()), 1)) | s605882678 | Accepted | 18 | 3,064 | 844 | fact = [1]
for i in range(1, 101):
fact.append(fact[-1]*i)
def C(a, b):
return fact[a]//(fact[b]*fact[a-b])
def sC(a, b):
ret = 0
for i in range(min(b, a-b) + 1):
ret += C(b, i) * C(a - b, i)
return ret
def calc(n, k):
if n<=0:
return []
i = 0
while (1<<(i+1)) -1 <... |
s337417093 | p03729 | u150641538 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 98 | You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `Y... | a,b,c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
print("Yes")
else:
print("No") | s264041995 | Accepted | 17 | 2,940 | 98 | a,b,c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
print("YES")
else:
print("NO") |
s372592767 | p03943 | u317711717 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 108 | 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... | import math
a,b,c=map(int,input().split())
l=[a,b,c]
sorted(l)
print("Yes" if l[0]+l[1]==l[2] else "No")
| s194728609 | Accepted | 17 | 2,940 | 107 | import math
a,b,c=map(int,input().split())
l=[a,b,c]
l.sort()
print("Yes" if l[0]+l[1]==l[2] else "No")
|
s199639613 | p03780 | u593590006 | 2,000 | 262,144 | Wrong Answer | 20 | 3,572 | 207 | AtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i. Because he loves big numbers, he calls a subset of the cards _good_ when the sum of the numbers written on the cards in the subset, is K or greater. Then, for each card i, he judges whether it is _unnecess... | n,k=map(int,input().split())
l=[int(i) for i in input().split()]
#sum of sub >=k
l.sort()
s=sum(l)
if s<k:
print(n)
else:
cnt=0
for i in l:
if s-i<k:
cnt+=1
print(cnt) | s576426742 | Accepted | 21 | 3,572 | 691 | N, K = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
ans = N
psum = 0
for i in range(N-1, -1, -1) :
if psum+a[i] < K :
psum += a[i]
else :
ans = min(ans, i)
print(ans)
'''
notes:
1-->we include elems that are less than k
2-->if some x is necessary all elems grtr ... |
s133794208 | p03854 | u920543723 | 2,000 | 262,144 | Wrong Answer | 234 | 13,704 | 880 | You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. | import numpy as np
import math
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()
s = li... | s598134561 | Accepted | 210 | 13,404 | 854 | import numpy as np
import math
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()
s = li... |
s075888958 | p03434 | u512099209 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 124 | 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 = list(map(int, input().split()))
a.sort()
alice = sum(a[0::2])
bob = sum(a[1::2])
print(alice - bob)
| s049587980 | Accepted | 19 | 2,940 | 136 | N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = sum(a[0::2])
bob = sum(a[1::2])
print(alice - bob)
|
s766478742 | p02613 | u529706830 | 2,000 | 1,048,576 | Wrong Answer | 143 | 9,072 | 325 | 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`,... | s = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(1,s):
ch = input()
if ch == "AC":
ac += 1
elif ch == "WA":
wa += 1
elif ch == "TLE":
tle +=1
elif ch == "RE":
re += 1
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str... | s392366567 | Accepted | 147 | 9,196 | 327 | s = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(1,s+1):
ch = input()
if ch == "AC":
ac += 1
elif ch == "WA":
wa += 1
elif ch == "TLE":
tle +=1
elif ch == "RE":
re += 1
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+s... |
s173546883 | p03501 | u600261652 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 54 | 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(min(N-A, B)) | s219421596 | Accepted | 17 | 2,940 | 54 | N, A, B = map(int, input().split())
print(min(N*A, B)) |
s078605516 | p03399 | u019578976 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 48 | You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimu... | print(min(input(),input())+min(input(),input())) | s160868467 | Accepted | 17 | 2,940 | 68 | print(min(int(input()),int(input()))+min(int(input()),int(input()))) |
s624148056 | p03457 | u065099501 | 2,000 | 262,144 | Wrong Answer | 216 | 17,684 | 512 | 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())
T = [];X = [];Y = []
for _ in range(N):
t,x,y = map(int, input().split())
T.append(t)
X.append(x)
Y.append(y)
if N == 1:
print('Yes' if T[0] == sum(X+Y) else 'No')
exit()
for i in range(N):
d = abs(X[i] + Y[i] - X[i-1] - Y[i-1])
t = T[i] - T[i-1]
if t >= d:
t... | s609952862 | Accepted | 269 | 17,596 | 406 | N = int(input())
T = [];X = [];Y = []
for _ in range(N):
t,x,y = map(int, input().split())
T.append(t)
X.append(x)
Y.append(y)
if N == 1:
print('Yes' if T[0] == sum(X+Y) else 'No')
exit()
for i in range(N):
if i == 0: continue
d = abs(X[i] + Y[i] - X[i-1] - Y[i-1])
t = T[i] - T[i-1]
... |
s637240849 | p02748 | u623687794 | 2,000 | 1,048,576 | Wrong Answer | 589 | 38,952 | 319 | You are visiting a large electronics store to buy a refrigerator and a microwave. The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen. You have M discount tic... | a,b,m=map(int,input().split())
fri=list(map(int,input().split()))
mic=list(map(int,input().split()))
wari=[list(map(int,input().split())) for i in range(m)]
fri.sort()
mic.sort()
mi=fri[0]+mic[0]
for i in range(m):
if fri[wari[i][0]-1]+mic[wari[i][1]-1]<mi:
mi=fri[wari[i][0]-1]+mic[wari[i][1]-1]
print(mi)
| s037104689 | Accepted | 466 | 38,568 | 323 | a,b,m=map(int,input().split())
fri=list(map(int,input().split()))
mic=list(map(int,input().split()))
wari=[list(map(int,input().split())) for i in range(m)]
mi=min(fri)+min(mic)
for i in range(m):
if fri[wari[i][0]-1]+mic[wari[i][1]-1]-wari[i][2]<mi:
mi=fri[wari[i][0]-1]+mic[wari[i][1]-1]-wari[i][2]
print(m... |
s499415267 | p03415 | u422272120 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 57 | 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... | print (input()[0])
print (input()[1])
print (input()[2])
| s646844144 | Accepted | 18 | 2,940 | 75 | ans = ""
ans += input()[0]
ans += input()[1]
ans += input()[2]
print (ans)
|
s945613306 | p03387 | u354638986 | 2,000 | 262,144 | Time Limit Exceeded | 2,104 | 4,592 | 530 | 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 ... | import random
data = list(map(int, input().split()))
lst = data[:]
n = 0
minimum = 1000000
for i in range(1000):
while True:
if data[0] == data[1] and data[1] == data[2]:
data = lst[:]
if n < minimum:
minimum = n
n = 0
break
f = rand... | s074097948 | Accepted | 17 | 2,940 | 143 | a, b, c = map(int, input().split())
m = max(a, b, c)
if 3*m%2 == (a+b+c)%2:
print((3*m-(a+b+c))//2)
else:
print((3*(m+1)-(a+b+c))//2)
|
s938687985 | p03455 | u345136423 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 90 | 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 !=0 or b%2!=0:
print('Odd')
else:
print('Even') | s141416918 | Accepted | 17 | 2,940 | 95 | a,b = map(int,input().split())
if a%2 !=0 and b%2!=0 :
print('Odd')
else:
print('Even')
|
s593163799 | p03044 | u642012866 | 2,000 | 1,048,576 | Wrong Answer | 706 | 47,768 | 512 | We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices... | from collections import deque
N = int(input())
ki = [[] for _ in range(N)]
for _ in range(N-1):
u, v, w = map(int, input().split())
ki[u-1].append([v-1, w])
ki[v-1].append([u-1, w])
f = [False]*N
f[0] = True
c = [0]*N
q = deque([0])
while q:
now = q.popleft()
for nxt, w in ki[now]:
if f[nx... | s712583503 | Accepted | 741 | 46,820 | 503 | from collections import deque
N = int(input())
ki = [[] for _ in range(N)]
for _ in range(N-1):
u, v, w = map(int, input().split())
ki[u-1].append([v-1, w])
ki[v-1].append([u-1, w])
f = [False]*N
f[0] = True
c = [0]*N
q = deque([0])
while q:
now = q.popleft()
for nxt, w in ki[now]:
if f[nx... |
s429949703 | p00069 | u024715419 | 1,000 | 131,072 | Wrong Answer | 40 | 5,616 | 1,073 | 縦線が n 本のあみだくじがあります。このあみだくじは以下の条件を満たしています。 * 横線は真横に引きます。斜めに引くことはありません。 * 横線は必ず隣り合った縦線同士をつなぎます。つまり、横線が縦線をまたぐことはありません。 * どの縦線についても同じ点から左右同時に横線が出ることはありません。つまり、横線が縦線を横切ることはありません。 * 当りはひとつだけです。 下図 に n = 5 のときの、あみだくじの例を示します。上側の数字は縦線の番号(左から1, 2, 3, 4, 5 ) を表します。☆が当たりです。 縦線の本数 n、選んだ縦線の番号 m、あみだくじの当りの場所、各段における横線の有無... | def check_lots(start, goal, line):
for i in range(len(line)):
for j in range(len(line[i])):
if line[i][j] == 1:
if j == start - 1:
start -= 1
elif j == start:
start += 1
return start == goal
while True:
n = int(inpu... | s202637414 | Accepted | 190 | 6,340 | 1,097 | import copy
def check_lots(start, goal, line):
for i in range(len(line)):
for j in range(len(line[i])):
if line[i][j] == 1:
if j == start - 1:
start -= 1
elif j == start:
start += 1
return start == goal
while True:
... |
s583988606 | p03543 | u121732701 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 201 | 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()
j = -1
count=0
count1=0
for i in N:
if i == j:
count+=1
elif count==3:
print("Yes")
break
j = i
count1 += 1
if count1 == 4:
print("No")
| s489181128 | Accepted | 18 | 2,940 | 93 | N = input()
if N[0]==N[1]==N[2] or N[1]==N[2]==N[3]:
print("Yes")
else:
print("No")
|
s312450699 | p03963 | u912862653 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 53 | There are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors. Find the number of the possible ways to paint the balls. | N, K = map(int, input().split())
print(K*(K-1)^(N-1)) | s377667665 | Accepted | 18 | 2,940 | 54 | N, K = map(int, input().split())
print(K*(K-1)**(N-1)) |
s700055692 | p03407 | u327248573 | 2,000 | 262,144 | Wrong Answer | 19 | 3,316 | 114 | An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan. | # -- coding: utf-8 --
A, B, C = map(int, input().split(' '))
if C <= A + B:
print('yes')
else:
print('no') | s958457647 | Accepted | 17 | 2,940 | 114 | # -- coding: utf-8 --
A, B, C = map(int, input().split(' '))
if C <= A + B:
print('Yes')
else:
print('No') |
s317612177 | p02747 | u442877951 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 122 | A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string. | S = str(input())
if "hi" in S and S.replace('hi', '') == "":
print("Yes")
else:
print("No")
print(S.replace('hi', '')) | s253528820 | Accepted | 21 | 3,316 | 335 | S = str(input())
ans = 'Yes'
from collections import Counter
SC = Counter(list(S))
h,i = 0,0
for a,b in SC.items():
if a == 'h':
h = b
elif a == 'i':
i = b
else:
ans = 'No'
break
if h == i:
for i in range(0,len(S)-1,2):
if S[i]+S[i+1] != 'hi':
ans = 'No'
break
else:
ans = 'No... |
s213348980 | p03608 | u297109012 | 2,000 | 262,144 | Wrong Answer | 2,104 | 6,692 | 918 | There are N towns in the State of Atcoder, connected by M bidirectional roads. The i-th road connects Town A_i and B_i and has a length of C_i. Joisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order). She will fly to the first town she visits, and fly back from the last town she visi... | from itertools import permutations
def warshal(N, ABCs):
dists = [[10 ** 10 for _ in range(N)] for __ in range(N)]
for i in range(N):
dists[i][i] = 0
for a, b, c in ABCs:
dists[a - 1][b - 1] = c
dists[b - 1][a - 1] = c
for s in range(N):
for e in range(N):
... | s750604869 | Accepted | 578 | 6,052 | 2,528 | from itertools import permutations
import heapq
import sys
INF = 2 ** sys.int_info.bits_per_digit
def warshall(N, ABCs):
dists = [[INF for _ in range(N)] for __ in range(N)]
for i in range(N):
dists[i][i] = 0
for a, b, c in ABCs:
dists[a - 1][b - 1] = c
dists[b - 1][a - 1] = c
... |
s556761272 | p03573 | u556477263 | 2,000 | 262,144 | Wrong Answer | 29 | 9,028 | 86 | You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers. | a,b,c = map(int,input().split())
if a != b and a == c:
print(a)
else:
print(b) | s044916852 | Accepted | 27 | 9,000 | 123 | a,b,c = map(int,input().split())
if a != b and a == c:
print(b)
elif a != b and a != c:
print(a)
else:
print(c) |
s327926076 | p03671 | u486773779 | 2,000 | 262,144 | Wrong Answer | 24 | 9,008 | 67 | Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the m... | price=list(input().split())
price.sort()
print(price[0]+price[1]) | s940180744 | Accepted | 28 | 9,036 | 55 | a,b,c=map(int,input().split())
print(a+b+c-max(a,b,c)) |
s021119765 | p02406 | u313089641 | 1,000 | 131,072 | Wrong Answer | 20 | 5,592 | 215 | In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement ... | n = int(input())
def three(n):
result = [" ", 3]
while result[-1] < n:
result.append(result[-1] + 3)
result = map(str, result)
result = " ".join(result)
return(result)
print(three(n))
| s558744215 | Accepted | 20 | 5,632 | 243 | n = int(input())
def three(n):
result = ""
counter = 3
while counter < n+1:
if "3" in str(counter) or counter % 3 == 0:
result += " {}".format(counter)
counter += 1
return(result)
print(three(n))
|
s184593284 | p02262 | u588555117 | 6,000 | 131,072 | Wrong Answer | 20 | 7,664 | 510 | 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+... |
m = 3
G = [7,4,1]
def insertion_sort(array,g):
for i in range(g,len(array)-1):
v = array[i]
j = i-g
while j>=0 and array[j] > v:
array[j+g] = array[j]
j = j-g
array[-1] += 1
array[j+g] = v
def shell_sort(array,G):
for i in G:
inserti... | s431815899 | Accepted | 17,190 | 62,964 | 594 |
G = [120001,60001,30001,15001,3001,901,601,301,91,58,31,7,4,1]
def insertion_sort(array,g):
for i in range(g,len(array)-1):
v = array[i]
j = i-g
while j>=0 and array[j] > v:
array[j+g] = array[j]
j = j-g
array[-1] += 1
array[j+g] = v
def shell_... |
s269292870 | p03920 | u619819312 | 2,000 | 262,144 | Wrong Answer | 22 | 3,316 | 178 | The problem set at _CODE FESTIVAL 20XX Finals_ consists of N problems. The score allocated to the i-th (1≦i≦N) problem is i points. Takahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve. As problems with higher scores are harder, he wants to minimize the highe... | n=int(input())
p=int(n**0.5)
t=0
for i in range(p,10**5):
if i*(i+1)//2>n:
t=i
l=t*(t+1)//2-n
break
for i in range(1,t):
if i!=l:
print(i) | s332438146 | Accepted | 22 | 3,316 | 178 | n=int(input())
p=int(n**0.5)
t=0
for i in range(10**5):
if i*(i+1)//2>n:
t=i
l=t*(t+1)//2-n
break
for i in range(1,t+1):
if i!=l:
print(i) |
s253164287 | p02402 | u239524997 | 1,000 | 131,072 | Wrong Answer | 20 | 7,532 | 157 | Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence. | a = input()
num = input()
num_1 = num.split()
s = 0
cnt = 0
for i in range(len(num_1)):
s += int(num_1[cnt])
cnt += 1
print(min(num_1),max(num_1),s) | s442910420 | Accepted | 60 | 8,716 | 236 | a = input()
num = input()
num_1 = num.split()
s = 0
cnt = 0
for i in range(len(num_1)):
s += int(num_1[cnt])
cnt += 1
b = []
cnt = 0
for i in range(len(num_1)):
b.append(int(num_1[cnt]))
cnt += 1
print(min(b),max(b),s) |
s248809457 | p03608 | u670180528 | 2,000 | 262,144 | Wrong Answer | 2,104 | 4,648 | 626 | There are N towns in the State of Atcoder, connected by M bidirectional roads. The i-th road connects Town A_i and B_i and has a length of C_i. Joisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order). She will fly to the first town she visits, and fly back from the last town she visi... | from itertools import permutations
n,m,r=map(int,input().split())
*R,=map(int,input().split())
INF=float("inf")
dist=[[INF]*n for _ in range(n)]
for i in range(n):
dist[i][i]=0
for _ in range(m):
a,b,c=map(int,input().split())
dist[a-1][b-1]=c
dist[b-1][a-1]=c
for k in range(n):
for i in range(n):
for j in rang... | s159432829 | Accepted | 504 | 22,224 | 313 | from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
from itertools import permutations
n,m,r,*L=map(int,open(0).read().split())
f=floyd_warshall(csr_matrix((L[r+2::3],(L[r::3],L[r+1::3])),(n+1,n+1)),0)
print(int(min(sum(f[s,t]for s,t in zip(o,o[1:]))for o in permutations(L[:r])))) |
s996878164 | p03545 | u546198000 | 2,000 | 262,144 | Wrong Answer | 26 | 9,020 | 289 | 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... | A = list(input())
sign = ['+','-']
for i in range(2):
for j in range(2):
for k in range(2):
if eval(A[0]+sign[i]+A[1]+sign[j]+A[2]+sign[k]+A[3]) == 7:
print('{}{}{}{}{}{}{}'.format(A[0],sign[i],A[1],sign[j],A[2],sign[k],A[3]))
exit() | s091358068 | Accepted | 28 | 9,068 | 291 | A = list(input())
sign = ['+','-']
for i in range(2):
for j in range(2):
for k in range(2):
if eval(A[0]+sign[i]+A[1]+sign[j]+A[2]+sign[k]+A[3]) == 7:
print('{}{}{}{}{}{}{}=7'.format(A[0],sign[i],A[1],sign[j],A[2],sign[k],A[3]))
exit() |
s144358796 | p03997 | u045408189 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 64 | 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*1/2)
| s538550772 | Accepted | 17 | 2,940 | 65 | a=int(input())
b=int(input())
h=int(input())
print((a+b)*h*1//2)
|
s942968784 | p03795 | u120026978 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 47 | Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant ... | n = int(input())
print(n * 800 - 200 * n // 15) | s763074134 | Accepted | 17 | 2,940 | 49 | n = int(input())
print(n * 800 - 200 * (n // 15)) |
s239392533 | p03598 | u019584841 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 165 | There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th t... | n=int(input())
k=int(input())
l=[int(x) for x in range(n)]
s=0
for i in range(n):
if abs(l[i]-k)>abs(l[i]):
s+=abs(l[i])
else:
s+=abs(l[i]-k)
print(s)
| s495708831 | Accepted | 17 | 2,940 | 132 | n = int(input())
k = int(input())
x = [int(x) for x in input().split()]
ans = 0
for i in x:
ans += min(i*2, (k-i)*2)
print(ans)
|
s484372357 | p02612 | u566371932 | 2,000 | 1,048,576 | Wrong Answer | 27 | 9,180 | 30 | We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. | s = int(input())
print(s%1000) | s661394576 | Accepted | 34 | 9,048 | 92 | s = int(input())
change = s % 1000
if change == 0:
print(0)
else:
print(1000-change) |
s509308205 | p02418 | u506705885 | 1,000 | 131,072 | Wrong Answer | 20 | 7,452 | 142 | Write a program which finds a pattern $p$ in a ring shaped text $s$. | letters=input()
letters=letters+letters
want_find=input()
print(letters)
if letters.find(want_find)>=0:
print('Yes')
else:
print('No') | s804659478 | Accepted | 50 | 7,460 | 121 | letters=input()
letters=letters+letters
want_find=input()
if want_find in letters:
print('Yes')
else:
print('No') |
s785754309 | p03433 | u748488158 | 2,000 | 262,144 | Wrong Answer | 27 | 9,164 | 87 | E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins. | N = int(input())
A = int(input())
if(N%5 <= A):
print("YES")
else:
print("NO") | s727383581 | Accepted | 26 | 8,996 | 89 | N = int(input())
A = int(input())
if(N%500 <= A):
print("Yes")
else:
print("No") |
s551111984 | p03377 | u598009172 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 90 | 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=(int(i) for i in input().split())
if a+b >= x:
print("Yes")
else :
print("No") | s411368674 | Accepted | 19 | 2,940 | 100 | a,b,x=(int(i) for i in input().split())
if a+b > x and a <= x:
print("YES")
else :
print("NO") |
s548416366 | p03610 | u801247169 | 2,000 | 262,144 | Wrong Answer | 34 | 9,356 | 145 | You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1. | s = input ()
odd_num = list()
for i in range(len(s)):
if i % 2 == 0:
odd_num.append(s[i])
answer = " ".join(odd_num)
print(answer)
| s640698906 | Accepted | 27 | 9,048 | 25 | s = input()
print(s[::2]) |
s093235346 | p03761 | u759412327 | 2,000 | 262,144 | Wrong Answer | 22 | 3,316 | 145 | Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headlin... | from collections import Counter
N = int(input())
C = Counter(input())
for n in range(N-1):
C&=Counter(input())
print(*C.elements(),sep="") | s621120230 | Accepted | 28 | 9,404 | 146 | from collections import *
N = int(input())
C = Counter(input())
for n in range(N-1):
C&=Counter(input())
print(*sorted(C.elements()),sep="") |
s468190352 | p03760 | u275685840 | 2,000 | 262,144 | Wrong Answer | 27 | 8,812 | 166 | 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 = input()
E = input()
num = 0
num_2 = 0
pw = ""
for i in list(O):
if num % 2 == 0:
pw+=i
num+=1
else:
pw+=E[num_2]
num+=1
num_2+=1
print(pw) | s277931080 | Accepted | 27 | 8,984 | 206 | O = input()
E = input()
Ol = len(O)
El = len(E)
alllen = Ol + El
num = 0
num_2 = 0
pw = ""
for i in range(alllen):
if i % 2 == 0:
pw+=O[num]
num+=1
else:
pw+=E[num_2]
num_2+=1
print(pw)
|
s628175621 | p03672 | u842747358 | 2,000 | 262,144 | Wrong Answer | 22 | 3,064 | 504 | We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by del... | def func(x):
for i_ in range(len(x)):
y = x[:i_+1]
if len(x) % len(y) != 0 or len(x) % 2 == 1:
continue
count = 0
for j_ in range(len(x)//len(y)):
if x[len(y)*j_:len(y)*(j_+1)] != y or x == y:
break
count += 1
if count =... | s335763503 | Accepted | 18 | 2,940 | 234 | S = input()
S = S[:-2]
flg = True
while flg:
flg = False
x = 0
for i in range(len(S)//2):
if S[x] != S[len(S)//2 + x]:
flg = True
S = S[:-2]
break
x += 1
print(len(S))
|
s356991525 | p03777 | u394482932 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 51 | Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or Dishonest_. In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either `H` or `D`, and carries the following information: If a=`H`, AtCo... | for s in input().upper().split():print(s[0],end='') | s532470202 | Accepted | 17 | 2,940 | 33 | s=input();print('DH'[s[0]==s[2]]) |
s671271278 | p03854 | u661977789 | 2,000 | 262,144 | Wrong Answer | 77 | 3,188 | 210 | 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()[::-1]
res = "Yes"
while s:
start = len(s)
for t in ['maerd', 'remaerd', 'esare', 'resare']:
if t == s[:len(t)]:
s = s[len(t):]
if start == len(s):
res = "No"
break
print(res) | s706564869 | Accepted | 82 | 3,188 | 200 | s = input()[::-1]
while s:
start = len(s)
for t in ['maerd', 'remaerd', 'esare', 'resare']:
if t == s[:len(t)]:
s = s[len(t):]
if start == len(s):
break
print("YNEOS"[len(s)>0::2]) |
s368155497 | p02748 | u891945807 | 2,000 | 1,048,576 | Wrong Answer | 2,114 | 124,780 | 558 | You are visiting a large electronics store to buy a refrigerator and a microwave. The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen. You have M discount tic... | import numpy as np
A,B,M = map(int,input().rstrip().split())
a = list(map(int,input().rstrip().split()))
b = list(map(int,input().rstrip().split()))
suml = [[0] * len(b)] * len(a)
print(suml)
for i in range(len(a)):
for j in range(len(b)):
suml[i][j] = a[i]+b[j]
print(suml)
sumk = [[0] * len(b)] * len(a)
for ... | s319448189 | Accepted | 602 | 27,492 | 311 | import numpy as np
A,B,M = map(int,input().rstrip().split())
a = list(map(int,input().rstrip().split()))
b = list(map(int,input().rstrip().split()))
minp = min(a) + min(b)
minpp = 10**6
for k in range(M):
i,j,c = map(int,input().rstrip().split())
minpp = min(a[i-1]+b[j-1]-c,minpp)
print(min(minp,minpp)) |
s815154340 | p03730 | u478417863 | 2,000 | 262,144 | Wrong Answer | 26 | 9,112 | 137 | 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= list(map(int, input().strip().split()))
a=A%B
f="No"
for i in range(B):
if (a*i)%B==C:
f="Yes"
break
print(f)
| s525729008 | Accepted | 30 | 9,096 | 137 | A,B,C= list(map(int, input().strip().split()))
a=A%B
f="NO"
for i in range(B):
if (a*i)%B==C:
f="YES"
break
print(f)
|
s408875937 | p03495 | u845620905 | 2,000 | 262,144 | Wrong Answer | 246 | 24,748 | 254 | 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. | k,n=map(int,input().split())
a = list(map(int,input().split()))
a=sorted(a)
d=[]
cnt=1
for i in range(k-1):
if a[i]==a[i+1]:
cnt+=1
else:
d.append(cnt)
cnt=0
d.append(cnt)
d=sorted(d)
ans=0
for i in range(len(d)-n):
ans+=d[i]
print(ans) | s056623205 | Accepted | 249 | 24,748 | 255 | k,n=map(int,input().split())
a = list(map(int,input().split()))
a=sorted(a)
d=[]
cnt=1
for i in range(k-1):
if a[i]==a[i+1]:
cnt+=1
else:
d.append(cnt)
cnt=1
d.append(cnt)
d=sorted(d)
ans=0
for i in range(len(d)-n):
ans+=d[i]
print(ans)
|
s304108262 | p03485 | u226779434 | 2,000 | 262,144 | Wrong Answer | 26 | 9,076 | 50 | You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer. | a,b = map(int,input().split())
print(((a+b)//2)+1) | s554006511 | Accepted | 27 | 8,884 | 91 | a,b =map(int,input().split())
if (a+b)%2 ==0:
print((a+b)//2)
else:
print(((a+b)//2)+1) |
s102748810 | p03672 | u277802731 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 216 | We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by del... | #66b
s = input()
for _ in range(len(s)):
if len(s)%2==0:
if s[len(s)//2:]==s[:len(s)//2]:
print(len(s)//2)
exit()
else:
s=s[:-2]
else:
s=s[:-1] | s494989334 | Accepted | 18 | 2,940 | 118 | #66b
s = input()
while True:
s = s[:-2]
i = len(s)//2
if s[:i] == s[i:]:
break
print(len(s)) |
s151027528 | p02418 | u400765446 | 1,000 | 131,072 | Wrong Answer | 20 | 5,556 | 286 | Write a program which finds a pattern $p$ in a ring shaped text $s$. | def main():
sentence = input()
phrase = input()
for i in range(len(sentence)):
if phrase in sentence:
print("Yes")
break
else:
sentence = sentence[1:] + sentence[0]
print("No")
if __name__ == '__main__':
main()
| s845062903 | Accepted | 20 | 5,560 | 188 | s = input()
p = input()
cnt = 0
for i in range(len(p)):
if p in s:
cnt = 1
break
else:
s = s[1:]+s[0]
if cnt >= 1:
print('Yes')
else:
print('No')
|
s055188373 | p03494 | u396890425 | 2,000 | 262,144 | Time Limit Exceeded | 2,104 | 2,940 | 164 | 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=input()
Numbers = list(map(int,input().split()))
ans=0
while True:
if all([x%2==0 for x in Numbers]):
ans+=1
[t/2 for t in Numbers]
print(ans) | s647154497 | Accepted | 18 | 3,060 | 150 |
n=input()
Numbers = list(map(int,input().split()))
ans=0
while all(x%2==0 for x in Numbers):
ans+=1
Numbers=[t/2 for t in Numbers]
print(ans) |
s279682271 | p02401 | u992449685 | 1,000 | 131,072 | Wrong Answer | 20 | 5,564 | 80 | 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 = input()
if '?' in a:
break
print(eval(a))
| s424748577 | Accepted | 20 | 5,552 | 85 | while(True):
a = input()
if '?' in a:
break
print(int(eval(a)))
|
s877345397 | p02255 | u755362870 | 1,000 | 131,072 | Wrong Answer | 20 | 5,600 | 321 | 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 ... | input_len = int(input())
l = input().split()
sort_line = [0 for i in range(input_len)]
for i in range(input_len):
sort_line[i] = int(l[i])
for i in range(1, input_len):
v = sort_line[i]
j = i - 1
while (j >= 0 and v < sort_line[j]):
sort_line[j+1] = sort_line[j]
j -= 1
sort_line[j + 1] = v
print(sort_line)... | s204901168 | Accepted | 30 | 5,984 | 540 | import sys
input_len = int(input())
l = input().split()
sort_line = [0 for i in range(input_len)]
for i in range(input_len):
sort_line[i] = int(l[i])
for k in range(input_len):
if (k > 0):
sys.stdout.write(" ")
sys.stdout.write(str(sort_line[k]))
print()
for i in range(1, input_len):
v = sort_line[i]
j = i ... |
s636410678 | p04029 | u763963344 | 2,000 | 262,144 | Wrong Answer | 27 | 9,140 | 121 | 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? | candy=int(input('子供の人数にたいして必要なキャンディーの数は?>'))
print(int(candy*(candy+1)/2)) | s661459698 | Accepted | 30 | 9,104 | 52 | N=int(input())
answer=int(N*(N+1)/2)
print(answer) |
s463944620 | p00711 | u661290476 | 1,000 | 131,072 | Wrong Answer | 220 | 8,268 | 806 | There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles. Write a program to count the number of black tiles which he can r... | mx = [0, 1, 0, -1]
my = [-1, 0, 1, 0]
while True:
w, h = map(int, input().split())
if w == h == 0:
break
tiles = [[i for i in input()] for j in range(h)]
ax = ay = 0
for i in range(h):
for j in range(w):
if tiles[i][j] == '@':
ax, ay = j, i
que = [(ax... | s924515397 | Accepted | 160 | 7,700 | 776 | mx = [0, 1, 0, -1]
my = [-1, 0, 1, 0]
while True:
w, h = map(int, input().split())
if w == h == 0:
break
tiles = [[i for i in input()] for j in range(h)]
ax = ay = 0
for i in range(h):
for j in range(w):
if tiles[i][j] == '@':
ax, ay = j, i
que = [(ax... |
s272015057 | p03644 | u733738237 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 119 | 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())
count = 1
while True:
n =2**count
if n <= N:
count += 1
continue
else:
break
print(count - 1) | s803991069 | Accepted | 17 | 2,940 | 122 | N = int(input())
count = 1
while True:
n =2**count
if n <= N:
count += 1
continue
else:
break
print(2**(count-1)) |
s015963591 | p02610 | u978313283 | 2,000 | 1,048,576 | Wrong Answer | 1,074 | 39,476 | 936 | We have N camels numbered 1,2,\ldots,N. Snuke has decided to make them line up in a row. The happiness of Camel i will be L_i if it is among the K_i frontmost camels, and R_i otherwise. Snuke wants to maximize the total happiness of the camels. Find the maximum possible total happiness of the camel. Solve this probl... | import heapq
T=int(input())
for t in range(T):
N=int(input())
ListL=[]
ListR=[]
ans=0
for n in range(N):
k,l,r=map(int,input().split())
ans+=min(l,r)
if min(l,r)==r:
ListL.append([k-1,abs(l-r)])
else:
ListR.append([k-1,abs(l-r)])
ListL=sort... | s057231599 | Accepted | 813 | 49,648 | 756 | import heapq
for _ in range(int(input())):
N=int(input())
ListL=[[] for _ in range(N)]
ListR=[[] for _ in range(N)]
ans=0
for _ in range(N):
k,l,r=map(int,input().split())
ans+=min(l,r)
if l>=r:
ListL[k-1].append(abs(l-r))
else:
ListR[k-1].appe... |
s724908376 | p04045 | u540290227 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 342 | 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 = map(int, input().split())
d = list(map(int, input().split()))
like = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
ans = ''
result_list = list(set(like) - set(d))
for i in str(n):
for result in result_list:
if int(i) == result == 0:
ans = ans + '0'
elif int(i) <= result:
ans = ans + ... | s561273728 | Accepted | 46 | 2,940 | 181 | n, k = map(int,input().split())
d = set(input().split())
while True:
for c in str(n):
if c in d:
break
else:
print(n)
exit()
n += 1 |
s227197565 | p03601 | u001024152 | 3,000 | 262,144 | Wrong Answer | 36 | 5,048 | 618 | Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the bea... | from fractions import gcd
A,B,C,D,E,F = map(int, input().split())
ans = {"w":114514, "s":0}
def density(water, sugar):
if water+sugar==0: return -1
return 100*sugar/(water+sugar)
G = gcd(C,D)
for a in range(F//(100*A)+1):
for b in range(F//(100*B)+1):
max_sugar = (a*A+b*B)*E
sugar = G*(max_... | s446662736 | Accepted | 25 | 3,064 | 622 | A,B,C,D,E,F = map(int, input().split())
ans = {"w":A*100, "s":0}
def density(water, sugar):
return 100*sugar/(water+sugar)
for a in range(31):
for b in range(31):
water = (a*A+b*B)*100
if water>F:
continue
max_sugar = min((a*A+b*B)*E, F-water)
for c in range(max_suga... |
s246187621 | p02936 | u704284486 | 2,000 | 1,048,576 | Wrong Answer | 2,107 | 57,708 | 400 | 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(" "))
g = [[i] for i in range(n)]
counter = [0]*n
for i in range(n-1):
s, t = map(int, input().split(" "))
g[s-1].append(t-1)
g[t-1].append(s-1)
for j in range(q):
root, plus = map(int, input().split(" "))
if root == 1:
for k in range(n):
counter[k]+=plus
else:
for ... | s822625565 | Accepted | 1,878 | 81,536 | 552 | from collections import deque
N,Q = map(int,input().split(" "))
cnt = [0 for _ in range(N)]
edge = [set() for i in range(N)]
for i in range(N-1):
a,b = map(lambda x: int(x)-1, input().split(" "))
edge[a].add(b)
edge[b].add(a)
for i in range(Q):
p,x = map(int,input().split(" "))
p -= 1
cnt[p... |
s724208871 | p02314 | u463990569 | 1,000 | 131,072 | Wrong Answer | 30 | 7,576 | 253 | Find the minimum number of coins to make change for n cents using coins of denominations d1, d2,.., dm. The coins can be used any number of times. | n, m = [int(el) for el in input().split(' ')]
c = [int(el) for el in input().split(' ')]
t = [0] + [float('inf') for _ in range(n)]
for i in range(m):
for j in range(c[i], n+1):
t[j] = min(t[j], t[j-c[i]] + 1)
print(t)
print(t[n]) | s103796803 | Accepted | 630 | 9,660 | 235 | n, m = [int(el) for el in input().split(' ')]
c = [int(el) for el in input().split(' ')]
t = [0] + [float('inf') for _ in range(n)]
for i in range(m):
for j in range(c[i], n+1):
t[j] = min(t[j], t[j-c[i]] + 1)
print(t[n]) |
s333791830 | p04029 | u442030035 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 33 | There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total? | n = int(input())
print(n*(n+1)/2) | s331332401 | Accepted | 17 | 2,940 | 35 | n = int(input())
print(n*(n+1)//2)
|
s659795303 | p00001 | u215939156 | 1,000 | 131,072 | Wrong Answer | 20 | 5,560 | 133 | There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order. | data = []
for i in range(0,10):
data.append(input())
print()
data.sort()
data.reverse()
for i in range(3):
print(data[i])
| s627573591 | Accepted | 20 | 5,600 | 133 | data = []
for i in range(0,10):
data.append(int(input()))
data.sort()
data.reverse()
for i in range(0,3):
print(data[i])
|
s902441475 | p03713 | u665415433 | 2,000 | 262,144 | Wrong Answer | 127 | 3,064 | 522 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying... | H, W = [int(i) for i in input().split()]
s = [0] * 3
ans = H * W
for h in range(H // 2 + 1, 0, -1):
s[0] = W * h
s[1] = (H - h) * (W//2)
s[2] = H * W - s[0] - s[1]
if max(s) - min(s) < ans:
ans = max(s) - min(s)
if ans == 0:
print(ans)
exit()
for w in range(W // 2 + 1, 0, -1... | s410977617 | Accepted | 406 | 3,064 | 645 | def solve(H, W):
s = [0]*3
ans = H*W
for h in range(H):
s[0] = W * h
s[1] = (H - h) * (W // 2)
s[2] = H * W - s[0] - s[1]
if max(s) - min(s) < ans:
ans = max(s) - min(s)
if ans == 0:
print(ans)
exit()
for h in range(H):
... |
s900549085 | p04029 | u336979293 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 50 | 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? | import math
N = int(input())
print((1 + N)/2*N) | s208873691 | Accepted | 17 | 2,940 | 43 | N = int(input())
print(int((1 + N)/2*N)) |
s250286233 | p02392 | u073709667 | 1,000 | 131,072 | Wrong Answer | 20 | 7,520 | 79 | 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("Yse")
else:
print("No") | s411116280 | Accepted | 20 | 7,632 | 79 | a,b,c=map(int,input().split())
if a<b<c:
print("Yes")
else:
print("No") |
s164691992 | p00613 | u471400255 | 1,000 | 131,072 | Wrong Answer | 60 | 5,772 | 147 | In the city, there are two pastry shops. One shop was very popular because its cakes are pretty tasty. However, there was a man who is displeased at the shop. He was an owner of another shop. Although cause of his shop's unpopularity is incredibly awful taste of its cakes, he never improved it. He was just growing hate... | while True:
K = int(input())
if K == 0:
break
else:
po = [int(i) for i in input().split()]
print(sum(po)/(K-1)) | s955218501 | Accepted | 50 | 5,772 | 197 | while True:
K = int(input())
if K == 0:
break
elif K == 1:
print(int(input()))
else:
po = [int(i) for i in input().split()]
print(int(sum(po)/(K-1))) |
s373611291 | p02841 | u436982376 | 2,000 | 1,048,576 | Wrong Answer | 27 | 9,056 | 118 | In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month. | m1,d1 = map(int,input().split())
m2,d2 = map(int,input().split())
if d2 == 1:
print('Yes')
else:
print('No')
| s268306588 | Accepted | 31 | 9,160 | 111 | m1,d1 = map(int,input().split())
m2,d2 = map(int,input().split())
if d2 == 1:
print(1)
else:
print(0)
|
s505021889 | p03166 | u080475902 | 2,000 | 1,048,576 | Wrong Answer | 998 | 138,044 | 575 | There is a directed graph G with N vertices and M edges. The vertices are numbered 1, 2, \ldots, N, and for each i (1 \leq i \leq M), the i-th directed edge goes from Vertex x_i to y_i. G **does not contain directed cycles**. Find the length of the longest directed path in G. Here, the length of a directed path is the... | import sys
from functools import lru_cache
sys.setrecursionlimit(10**6)
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def read():
return int(readline())
def reads():
return map(int, readline().split())
def mp(arg):
return map(int,arg.split())
n,m=reads()
link=[[]for i in range(n)]... | s997292478 | Accepted | 877 | 137,100 | 576 | import sys
from functools import lru_cache
sys.setrecursionlimit(10**6)
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def read():
return int(readline())
def reads():
return map(int, readline().split())
def mp(arg):
return map(int,arg.split())
n,m=reads()
link=[[]for i in range(n)]... |
s672748265 | p03565 | u680851063 | 2,000 | 262,144 | Wrong Answer | 28 | 3,956 | 254 | 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 = input()
t = input()
import fnmatch
for i in range(len(s) - len(t)+1):
if fnmatch.fnmatch(t, s[i:i+len(t)]):
x = s[0:i] + t + s[i+len(t):]
x = x.replace('?', 'a')
print(x.replace('?', 'a'))
else:
print('UNRESTORABLE') | s718120582 | Accepted | 27 | 3,828 | 398 | s = input()
t = input()
import fnmatch
if len(s) < len(t):
print('UNRESTORABLE')
else:
l = []
for i in range(len(s) - len(t)+1):
if fnmatch.fnmatch(t, s[i:i+len(t)]):
x = s[0:i] + t + s[i+len(t):]
l += [x.replace('?', 'a')]
else:
if len(l) == 0:
pr... |
s076929789 | p03555 | u699296734 | 2,000 | 262,144 | Wrong Answer | 24 | 8,988 | 126 | 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. | c1 = input()
c2 = input()
if c1[0] == c2[-1] and c1[1] == c2[-2] and c1[2] == c2[-3]:
print("Yes")
else:
print("No")
| s549873554 | Accepted | 26 | 8,928 | 126 | c1 = input()
c2 = input()
if c1[0] == c2[-1] and c1[1] == c2[-2] and c1[2] == c2[-3]:
print("YES")
else:
print("NO")
|
s865623372 | p03455 | u485349322 | 2,000 | 262,144 | Wrong Answer | 30 | 9,056 | 93 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | a,b=input().split()
a=int(a)
b=int(b)
if (a*b)%2==0:
print('Odd')
else:
print('Even') | s670178548 | Accepted | 27 | 9,040 | 82 | a,b=map(int,input().split())
if a*b%2==0:
print("Even")
else:
print("Odd") |
s954140976 | p03471 | u086612293 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 739 | The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situat... | #!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
def out(i, j, k):
print(i, j, k)
sys.exit()
def main():
n, y = map(int, sys.stdin.readline().split())
for i in range(y // 10000, -1, -1):
z = y - 10000 * i
if i > n:
out(-1, -1, -1)
elif z == 0:
out... | s722664052 | Accepted | 717 | 3,060 | 428 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
def main():
n, y = map(int, sys.stdin.readline().split())
for i in range(y // 10000, -1, -1):
z = y - 10000 * i
for j in range(z // 5000, -1, -1):
k = n - i - j
if z == 5000 * j + 1000 * k:
print(i, ... |
s918018009 | p02394 | u316246166 | 1,000 | 131,072 | Wrong Answer | 20 | 5,592 | 292 | Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given. | W, H, x, y, r = map(int, input().split())
if x - r < 0:
if x + r > W:
if y - r < 0:
if y + r > H:
print('Yes')
else:
print('No')
else:
print('No')
else:
print('No')
else:
print('No')
| s068336534 | Accepted | 20 | 5,596 | 146 | W, H, x, y, r = map(int, input().split())
if x - r >= 0 and x + r <= W and y - r >= 0 and y + r <= H:
print('Yes')
else:
print('No')
|
s744703677 | p02402 | u839008951 | 1,000 | 131,072 | Wrong Answer | 20 | 5,588 | 230 | Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence. | length = int(input())
arr = input().split()
iniV = int(arr[0])
mi = iniV
mx = iniV
su = iniV
for s in arr:
val = int(s)
su += val
if(val < mi):
mi = val
if(val > mx):
mx = val
print(mi, mx, su)
| s117619767 | Accepted | 20 | 6,336 | 227 | length = int(input())
arr = input().split()
iniV = int(arr[0])
mi = iniV
mx = iniV
su = 0
for s in arr:
val = int(s)
su += val
if(val < mi):
mi = val
if(val > mx):
mx = val
print(mi, mx, su)
|
s240480617 | p03197 | u257974487 | 2,000 | 1,048,576 | Wrong Answer | 648 | 3,572 | 142 | There is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i. You and Lunlun the dachshund alternately perform the following operation (starting from you): * Choose one or more apples from the tree and eat them. Here, the apples chosen a... | n = int(input())
for i in range(n):
p = int(input())
if p % 2 == 0:
continue
else:
print("first")
print("second") | s815918600 | Accepted | 198 | 3,060 | 157 | n = int(input())
for i in range(n):
p = int(input())
if p % 2 == 0:
continue
else:
print("first")
exit()
print("second") |
s477038122 | p03044 | u001024152 | 2,000 | 1,048,576 | Wrong Answer | 593 | 39,144 | 502 | We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices... | from collections import deque
N = int(input())
adj = [[] for _ in range(N)]
for _ in range(N-1):
u,v,w = map(lambda x:int(x)-1, input().split())
w += 1
adj[u].append((v,w))
adj[v].append((u,w))
visited = [False]*N
q = deque([0])
while q:
cur = q.popleft()
if visited[cur]:
continue... | s823235842 | Accepted | 747 | 43,872 | 520 | from collections import deque
N = int(input())
adj = [[] for _ in range(N)]
for _ in range(N-1):
u,v,w = map(lambda x:int(x)-1, input().split())
w += 1
adj[u].append((v,w))
adj[v].append((u,w))
visited = [False]*N
q = deque([0])
dist = [0]*N
while q:
cur = q.popleft()
if visited[cur]:
... |
s656128094 | p02402 | u297342993 | 1,000 | 131,072 | Wrong Answer | 30 | 6,724 | 170 | Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence. | input()
sum = 0
min = 9999
max = 0
for x in [int(y) for y in input().split()]:
sum += x
if min > x:
min = x
if max < x:
max = x
print(sum, min, max) | s267500743 | Accepted | 40 | 8,028 | 88 | input()
data = [int(x) for x in input().split()]
print(min(data), max(data), sum(data)) |
s724532888 | p03339 | u316386814 | 2,000 | 1,048,576 | Wrong Answer | 328 | 22,164 | 214 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of the... | import numpy
n = int(input())
s = input()
li = numpy.asarray([1 if i == 'W' else 0 for i in s])
w = numpy.cumsum(li)
e = numpy.cumsum(1 - li[::-1])[::-1]
su = w + e
ans = min(su) - 1
print(li, w, e)
print(ans)
| s870342976 | Accepted | 308 | 22,144 | 198 | import numpy
n = int(input())
s = input()
li = numpy.asarray([1 if i == 'W' else 0 for i in s])
w = numpy.cumsum(li)
e = numpy.cumsum(1 - li[::-1])[::-1]
su = w + e
ans = min(su) - 1
print(ans)
|
s990577340 | p03160 | u580697892 | 2,000 | 1,048,576 | Wrong Answer | 134 | 15,032 | 207 | There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of... | #coding: utf-8
N = int(input())
dp = [0 for _ in range(N)]
h = list(map(int, input().split()))
for i in range(2, N):
dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]))
print(dp[N-1]) | s978363702 | Accepted | 179 | 13,980 | 258 | #coding: utf-8
N = int(input())
h = list(map(int, input().split()))
dp = [float("inf") for _ in range(N)]
dp[0] = 0
for i in range(1, N):
dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
print(dp[N-1]) |
s101222454 | p03149 | u330152685 | 2,000 | 1,048,576 | Wrong Answer | 19 | 3,060 | 322 | You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974". | def checkInput(inputList):
numberList = [1,9,7,4]
result = all(num in numberList for num in inputList)
if(result):
return True
else:
return False
if __name__ == '__main__':
inp = list(map(int,input().split()))
if(checkInput(inp)):
print("Yes")
else:
print("No... | s963981789 | Accepted | 18 | 3,064 | 504 | def checkInput(inputList):
a = 0
b = 0
c = 0
d = 0
for num in inputList:
if(num == 1):
a = 1
elif(num == 9):
b = 1
elif(num == 7):
c = 1
elif(num == 4):
d = 1
if(a == 1 and b == 1 and c == 1 and d == 1):
retu... |
s624731439 | p03780 | u785578220 | 2,000 | 262,144 | Wrong Answer | 26 | 4,340 | 196 | AtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i. Because he loves big numbers, he calls a subset of the cards _good_ when the sum of the numbers written on the cards in the subset, is K or greater. Then, for each card i, he judges whether it is _unnecess... | N,K=map(int,input().split())
x=[int(p) for p in input().split()]
x.sort()
x = x[::-1]
pp=0
ans=0
print(x)
for a in x:
print(ans)
if pp+a < K:
pp+=a
ans+=1
else:
ans=0
print(ans)
| s093817847 | Accepted | 20 | 3,572 | 174 | N,K=map(int,input().split())
x=[int(p) for p in input().split()]
x.sort()
x = x[::-1]
pp=0
ans=0
for a in x:
if pp+a < K:
pp+=a
ans+=1
else:
ans=0
print(ans)
|
s438585507 | p03251 | u644778646 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 191 | Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes incli... | N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
mx = max(x)
my = min(y)
if my - mx > 1:
print("No War")
else:
print("War")
| s484709414 | Accepted | 17 | 3,064 | 314 | N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
mx = max(x)
my = min(y)
if my - mx > 0:
Z = mx
for i in range(my - mx):
Z += 1
if X < Z and Z <= Y and mx < Z and Z <= my:
print("No War")
exit()
print("War")
|
s771635560 | p02694 | u258325541 | 2,000 | 1,048,576 | Wrong Answer | 25 | 9,128 | 141 | 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())
money = 100
year = 0
while True:
if money > X:
print(year)
break
else:
money = int(money*1.01)
year += 1 | s013510115 | Accepted | 23 | 9,172 | 150 | X = int(input())
money = 100
year = 0
while True:
if money >= X:
print(year)
break
else:
money = money + int(money*0.01)
year += 1 |
s965290820 | p03493 | u511421299 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 3 | 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. | 101 | s219093657 | Accepted | 17 | 2,940 | 78 | a = input()
total = 0
for b in a:
if b == '1':
total += 1
print(total) |
s120623834 | p03139 | u128927017 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 108 | 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... | num = list(map(int, input().split()))
a = min(num[1],num[2])
b = max(0, num[0] - (num[1]+num[2]))
print(a,b) | s814257011 | Accepted | 18 | 2,940 | 107 | num = list(map(int, input().split()))
a = min(num[1],num[2])
b = max(0,(num[1]+num[2]) - num[0])
print(a,b) |
s122323060 | p03161 | u195054737 | 2,000 | 1,048,576 | Wrong Answer | 2,109 | 24,056 | 753 | There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to one of the following: Stone i + 1, i + 2, \... | import sys
import itertools
from operator import itemgetter
from fractions import gcd
from math import ceil, floor, sqrt, isinf
from copy import deepcopy
from collections import Counter, deque
import heapq
import numpy as np
from functools import reduce
sys.setrecursionlimit(200000)
input = sys.stdin.readline
# t... | s271165732 | Accepted | 1,792 | 23,092 | 276 | import numpy as np
n, k = map(int, input().split())
h = np.array([int(i) for i in input().split()])
dp = np.array([0] * n)
for i in range(1, n):
j = max(0, i-k)
dp[i] = np.min(dp[j:i] + np.abs(h[i] - h[j:i]))
print(dp[-1]) |
s172515744 | p02278 | u918276501 | 1,000 | 131,072 | Time Limit Exceeded | 40,000 | 7,700 | 778 | You are given $n$ integers $w_i (i = 0, 1, ..., n-1)$ to be sorted in ascending order. You can swap two integers $w_i$ and $w_j$. Each swap operation has a cost, which is the sum of the two integers $w_i + w_j$. You can perform the operations any number of times. Write a program which reports the minimal total cost to... | def swap(A,i,j):
A[i],A[j] = A[j],A[i]
return A
def mincost(A):
B = sorted(A)
cost = 0
for j, bj in enumerate(B):
t = 0
i = A.index(bj)
tmp_cost = 0
# swap in a cyclic group
while j != i:
t += 1
bi = B[i]
k = ... | s287242087 | Accepted | 40 | 7,828 | 777 | def swap(A,i,j):
A[i],A[j] = A[j],A[i]
return A
def mincost(A):
B = sorted(A)
cost = 0
b0 = B[0]
for i, bi in enumerate(B):
t = 0
j = A.index(bi)
tmp_cost = 0
# swap in a cyclic group
while j != i:
t += 1
bj = B[j]
... |
s412595445 | p03679 | u975676823 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 135 | 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 = map(int, input().split())
if(a - b < 0):
print("delicious")
elif(abs(a - b) <= x):
print("safe")
else:
print("dangerous")
| s934006785 | Accepted | 17 | 2,940 | 157 | x, a, b = map(int, input().split())
if(a - b >= 0):
print("delicious")
elif(abs(a - b) <= x):
print("safe")
else:
print("dangerous")
|
s187563706 | p03139 | u760961723 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 93 | 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... | N, A, B = map(int,input().split())
print(str(min(A, B)) + " " + str(max(N, A+B)-min(N,A+B))) | s824344492 | Accepted | 17 | 2,940 | 120 | N, A, B = map(int,input().split())
if N > A+B:
mini = 0
else:
mini = A+B-N
print(str(min(A, B)) + " " + str(mini)) |
s430244896 | p03493 | u703059820 | 2,000 | 262,144 | Wrong Answer | 20 | 3,316 | 73 | 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. | from collections import Counter
s = input()
count = Counter(s)
count["1"] | s943182259 | Accepted | 20 | 3,316 | 80 | from collections import Counter
s = input()
count = Counter(s)
print(count["1"]) |
s245042732 | p03694 | u687574784 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 81 | It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts. There are N houses along _TopCoDeer street_. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses. Find the minimum distance to be traveled when AtCoDeer can star... | # -*- coding: utf-8 -*-
a = list(map(int, input().split()))
print(max(a)-min(a))
| s945536801 | Accepted | 17 | 2,940 | 92 | # -*- coding: utf-8 -*-
_ = input()
a = list(map(int, input().split()))
print(max(a)-min(a)) |
s531908258 | p03943 | u950376354 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 153 | 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())
l = [a,b,c]
ld = sorted(l, reverse=True)
max = ld[0]
mix = ld[1]+ld[2]
if max==mix :
print("YES")
else:
print("NO") | s358011952 | Accepted | 18 | 3,060 | 153 | a,b,c = map(int, input().split())
l = [a,b,c]
ld = sorted(l, reverse=True)
max = ld[0]
mix = ld[1]+ld[2]
if max==mix :
print("Yes")
else:
print("No") |
s052379070 | p03759 | u373047809 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 60 | Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful. | a, b, c = map(int, input().split())
print("YNEOS"[b-a!=c-b]) | s928037196 | Accepted | 18 | 2,940 | 63 | a, b, c = map(int, input().split())
print("YNEOS"[b-a!=c-b::2]) |
s808492697 | p02936 | u753803401 | 2,000 | 1,048,576 | Wrong Answer | 2,112 | 130,548 | 562 | 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())
ab = [list(map(int, input().split())) for _ in range(n-1)]
px = [list(map(int, input().split())) for _ in range(q)]
dp = [0] * n
ls = [[] for i in range(n)]
for i in ab:
ls[i[0]-1].append(i[1]-1)
for i in px:
dp[i[0]-1] += i[1]
qq = []
for z in ls[i[0]-1]:
qq.app... | s156672881 | Accepted | 1,677 | 128,488 | 894 | def slove():
import sys
import collections
input = sys.stdin.readline
n, q = list(map(int, input().rstrip('\n').split()))
d = collections.defaultdict(list)
for i in range(n-1):
a, b = list(map(int, input().rstrip('\n').split()))
d[a] += [b]
d[b] += [a]
score = collec... |
s234359737 | p03433 | u492447501 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 66 | E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins. | N = int(input())
A = int(input())
print(((N//500)*500) + (N%500)) | s877496155 | Accepted | 18 | 2,940 | 106 | N = int(input())
A = int(input())
print("Yes" if N==(((N//500)*500) + (N%500)) and N%500 <= A else "No")
|
s048152714 | p02743 | u660018248 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 189 | Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold? | def c():
a, b,c = map(int, input().split())
ab = a*b
a_b_c = (a+b-c)**2
if ab < a_b_c:
print("Yes")
else:
print("No")
if __name__ == '__main__':
c() | s548578346 | Accepted | 18 | 2,940 | 273 | if __name__ == '__main__':
a, b, c =map(int, input().split())
ab = 4 * a * b
a_b_c = (c - (a + b))
a_b_c_2 = a_b_c ** 2
if a_b_c <= 0:
print("No")
else:
if ab < a_b_c_2:
print("Yes")
else:
print("No")
|
s432458308 | p02936 | u603958124 | 2,000 | 1,048,576 | Wrong Answer | 572 | 28,724 | 961 | 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... | from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator ... | s068167969 | Accepted | 1,123 | 283,540 | 1,462 | from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator ... |
s705442548 | p02922 | u094932051 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 316 | Takahashi's house has only one socket. Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets. One power strip with A sockets can extend one empty socket into A empty sockets. Find the minimum number of power strips required. | while True:
try:
A, B = map(int, input().split())
strip = 1
socket = A
for i in range(A+1):
if (socket < B):
strip += 1
socket += (A-1)
else:
break
print(strip)
except:
break | s914162816 | Accepted | 17 | 2,940 | 144 | import math
while True:
try:
A, B = map(int, input().split())
print(math.ceil((B-A) / (A-1)) + 1)
except:
break |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.