user_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 1
value | submission_id_v0 stringlengths 10 10 | submission_id_v1 stringlengths 10 10 | cpu_time_v0 int64 10 38.3k | cpu_time_v1 int64 0 24.7k | memory_v0 int64 2.57k 1.02M | memory_v1 int64 2.57k 869k | status_v0 stringclasses 1
value | status_v1 stringclasses 1
value | improvement_frac float64 7.51 100 | input stringlengths 20 4.55k | target stringlengths 17 3.34k | code_v0_loc int64 1 148 | code_v1_loc int64 1 184 | code_v0_num_chars int64 13 4.55k | code_v1_num_chars int64 14 3.34k | code_v0_no_empty_lines stringlengths 21 6.88k | code_v1_no_empty_lines stringlengths 20 4.93k | code_same bool 1
class | relative_loc_diff_percent float64 0 79.8 | diff list | diff_only_import_comment bool 1
class | measured_runtime_v0 float64 0.01 4.45 | measured_runtime_v1 float64 0.01 4.31 | runtime_lift float64 0 359 | key list |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u118642796 | p03147 | python | s502224152 | s664932778 | 20 | 17 | 3,064 | 3,064 | Accepted | Accepted | 15 | N = int(eval(input()))
h = list(map(int,input().split()))
h = [0] + h
ans = 0
while(sum(h)>0):
for i in range(N):
if h[i] == 0 and h[i+1] > 0:
ans += 1
for i in range(N+1):
if h[i] > 0:
h[i] -= 1
print(ans) | N = int(eval(input()))
h = list(map(int,input().split()))
h = [0] + h
ans = 0
for i in range(N):
if h[i]<h[i+1]:
ans += h[i+1]-h[i]
print(ans)
| 13 | 9 | 268 | 158 | N = int(eval(input()))
h = list(map(int, input().split()))
h = [0] + h
ans = 0
while sum(h) > 0:
for i in range(N):
if h[i] == 0 and h[i + 1] > 0:
ans += 1
for i in range(N + 1):
if h[i] > 0:
h[i] -= 1
print(ans)
| N = int(eval(input()))
h = list(map(int, input().split()))
h = [0] + h
ans = 0
for i in range(N):
if h[i] < h[i + 1]:
ans += h[i + 1] - h[i]
print(ans)
| false | 30.769231 | [
"-while sum(h) > 0:",
"- for i in range(N):",
"- if h[i] == 0 and h[i + 1] > 0:",
"- ans += 1",
"- for i in range(N + 1):",
"- if h[i] > 0:",
"- h[i] -= 1",
"+for i in range(N):",
"+ if h[i] < h[i + 1]:",
"+ ans += h[i + 1] - h[i]"
] | false | 0.049977 | 0.047992 | 1.041354 | [
"s502224152",
"s664932778"
] |
u125545880 | p02690 | python | s608977971 | s211820648 | 131 | 48 | 27,160 | 9,156 | Accepted | Accepted | 63.36 | import sys
import numpy as np
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#read = sys.stdin.buffer.read
def main():
X = int(readline())
A = list(range(1, 201))
B = list(range(-201, 201))
for a in A:
for b in B:
tmp = pow(a, 5) - pow(b, 5)
if... | def main():
X = int(eval(input()))
for A in range(0, 201):
for B in range(-201, 201):
if pow(A, 5) - pow(B, 5) == X:
print((A, B))
return
if __name__ == "__main__":
main()
| 23 | 10 | 420 | 242 | import sys
import numpy as np
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
# read = sys.stdin.buffer.read
def main():
X = int(readline())
A = list(range(1, 201))
B = list(range(-201, 201))
for a in A:
for b in B:
tmp = pow(a, 5) - pow(b, 5)
if X == tmp:
... | def main():
X = int(eval(input()))
for A in range(0, 201):
for B in range(-201, 201):
if pow(A, 5) - pow(B, 5) == X:
print((A, B))
return
if __name__ == "__main__":
main()
| false | 56.521739 | [
"-import sys",
"-import numpy as np",
"-",
"-sys.setrecursionlimit(10**6)",
"-readline = sys.stdin.readline",
"-# read = sys.stdin.buffer.read",
"- X = int(readline())",
"- A = list(range(1, 201))",
"- B = list(range(-201, 201))",
"- for a in A:",
"- for b in B:",
"- ... | false | 0.037319 | 0.11293 | 0.33046 | [
"s608977971",
"s211820648"
] |
u392319141 | p02824 | python | s231900816 | s103633012 | 417 | 227 | 14,964 | 14,480 | Accepted | Accepted | 45.56 | N, M, V, P = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort(reverse=True)
def isOk(n):
if n < P:
return True
b = A[n] + M
cnt = (P - 1) * M + (N - n) * M
for a in A[P - 1: n]:
cnt += max(0, b - a)
if b >= A[P - 1] and cnt >= V * M:
... | N, M, V, P = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort(reverse=True)
def isOk(i):
x = A[i] + M
B = [x - a for a in A[max(0, P - 1): i]]
if not B:
return True
cnt = sum(B) + (P - 1) * M + (N - i) * M
return min(B) >= 0 and cnt >= M * V
ok = 0
... | 27 | 22 | 488 | 444 | N, M, V, P = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort(reverse=True)
def isOk(n):
if n < P:
return True
b = A[n] + M
cnt = (P - 1) * M + (N - n) * M
for a in A[P - 1 : n]:
cnt += max(0, b - a)
if b >= A[P - 1] and cnt >= V * M:
return True
... | N, M, V, P = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort(reverse=True)
def isOk(i):
x = A[i] + M
B = [x - a for a in A[max(0, P - 1) : i]]
if not B:
return True
cnt = sum(B) + (P - 1) * M + (N - i) * M
return min(B) >= 0 and cnt >= M * V
ok = 0
ng = N
while... | false | 18.518519 | [
"-def isOk(n):",
"- if n < P:",
"+def isOk(i):",
"+ x = A[i] + M",
"+ B = [x - a for a in A[max(0, P - 1) : i]]",
"+ if not B:",
"- b = A[n] + M",
"- cnt = (P - 1) * M + (N - n) * M",
"- for a in A[P - 1 : n]:",
"- cnt += max(0, b - a)",
"- if b >= A[P - 1] and cnt... | false | 0.098803 | 0.059288 | 1.666483 | [
"s231900816",
"s103633012"
] |
u888092736 | p02936 | python | s873098305 | s698103045 | 1,787 | 1,070 | 296,768 | 76,056 | Accepted | Accepted | 40.12 | import sys
sys.setrecursionlimit(10 ** 6)
def input():
return sys.stdin.readline().strip()
def solve():
def dfs(v):
for nv in g[v]:
if visited[nv]:
continue
visited[nv] = True
counter[nv] += counter[v]
dfs(nv)
... | import sys
def input():
return sys.stdin.readline().strip()
def solve():
N, Q = list(map(int, input().split()))
g = [set() for _ in range(N)]
for _ in range(N - 1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
g[a].add(b)
g[b].add(a)
... | 40 | 37 | 786 | 788 | import sys
sys.setrecursionlimit(10**6)
def input():
return sys.stdin.readline().strip()
def solve():
def dfs(v):
for nv in g[v]:
if visited[nv]:
continue
visited[nv] = True
counter[nv] += counter[v]
dfs(nv)
N, Q = list(map(int, i... | import sys
def input():
return sys.stdin.readline().strip()
def solve():
N, Q = list(map(int, input().split()))
g = [set() for _ in range(N)]
for _ in range(N - 1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
g[a].add(b)
g[b].add(a)
counter = [0] ... | false | 7.5 | [
"-",
"-sys.setrecursionlimit(10**6)",
"- def dfs(v):",
"- for nv in g[v]:",
"- if visited[nv]:",
"- continue",
"- visited[nv] = True",
"- counter[nv] += counter[v]",
"- dfs(nv)",
"-",
"+ stack = [0]",
"- dfs(0)",
"+ ... | false | 0.033108 | 0.093978 | 0.352298 | [
"s873098305",
"s698103045"
] |
u156815136 | p02909 | python | s494693819 | s660268036 | 36 | 19 | 5,048 | 3,060 | Accepted | Accepted | 47.22 | import itertools
import fractions
def main():
S = ['Sunny','Cloudy','Rainy']
s = eval(input())
i = 0
while True:
if s == S[i]:
break
i += 1
print((S[(i+1)%3]))
if __name__ == '__main__':
main() | Weather = ['Sunny','Cloudy','Rainy']
S = eval(input())
for i,s in enumerate(Weather):
if s == S:
print((Weather[(i+1)%3]))
| 13 | 5 | 223 | 131 | import itertools
import fractions
def main():
S = ["Sunny", "Cloudy", "Rainy"]
s = eval(input())
i = 0
while True:
if s == S[i]:
break
i += 1
print((S[(i + 1) % 3]))
if __name__ == "__main__":
main()
| Weather = ["Sunny", "Cloudy", "Rainy"]
S = eval(input())
for i, s in enumerate(Weather):
if s == S:
print((Weather[(i + 1) % 3]))
| false | 61.538462 | [
"-import itertools",
"-import fractions",
"-",
"-",
"-def main():",
"- S = [\"Sunny\", \"Cloudy\", \"Rainy\"]",
"- s = eval(input())",
"- i = 0",
"- while True:",
"- if s == S[i]:",
"- break",
"- i += 1",
"- print((S[(i + 1) % 3]))",
"-",
"-",
"-... | false | 0.16494 | 0.043546 | 3.787743 | [
"s494693819",
"s660268036"
] |
u462831976 | p02265 | python | s130480009 | s265380247 | 1,960 | 1,630 | 71,952 | 214,320 | Accepted | Accepted | 16.84 | # -*- coding: utf-8 -*-
import sys
import os
from collections import deque
N = int(sys.stdin.readline())
q = deque()
for i in range(N):
lst = sys.stdin.readline().split()
command = lst[0]
if command == 'insert':
q.appendleft(lst[1])
elif command == 'delete':
try:
... | # -*- coding: utf-8 -*-
import sys
import os
from collections import deque
N = int(sys.stdin.readline())
q = deque()
lines = sys.stdin.readlines()
for s in lines:
lst = s.split()
command = lst[0]
if command == 'insert':
q.appendleft(lst[1])
elif command == 'delete':
... | 26 | 27 | 512 | 521 | # -*- coding: utf-8 -*-
import sys
import os
from collections import deque
N = int(sys.stdin.readline())
q = deque()
for i in range(N):
lst = sys.stdin.readline().split()
command = lst[0]
if command == "insert":
q.appendleft(lst[1])
elif command == "delete":
try:
q.remove(ls... | # -*- coding: utf-8 -*-
import sys
import os
from collections import deque
N = int(sys.stdin.readline())
q = deque()
lines = sys.stdin.readlines()
for s in lines:
lst = s.split()
command = lst[0]
if command == "insert":
q.appendleft(lst[1])
elif command == "delete":
try:
q.r... | false | 3.703704 | [
"-for i in range(N):",
"- lst = sys.stdin.readline().split()",
"+lines = sys.stdin.readlines()",
"+for s in lines:",
"+ lst = s.split()"
] | false | 0.04395 | 0.120569 | 0.364525 | [
"s130480009",
"s265380247"
] |
u371223524 | p03162 | python | s029107461 | s062517134 | 1,098 | 823 | 133,848 | 45,620 | Accepted | Accepted | 25.05 | import sys
sys.setrecursionlimit(1000000)
def maxcost(li,n,i,strt,dp):
if i==(n-1):
return li[i][strt]
mx=-sys.maxsize
for l in range(3):
if l!=strt:
if dp[i+1][l]==-1:
cost=maxcost(li,n,i+1,l,dp)
dp[i+1][l]=cost
else:
... | import sys
def maxcost(li,n):
dp=[[-1 for j in range(3)] for i in range(n)]
dp[n-1][0],dp[n-1][1],dp[n-1][2]=li[n-1][0],li[n-1][1],li[n-1][2]
for i in range(n-2,-1,-1):
for j in range(3):
mx=-sys.maxsize
for k in range(3):
if j!=k:
... | 24 | 19 | 637 | 552 | import sys
sys.setrecursionlimit(1000000)
def maxcost(li, n, i, strt, dp):
if i == (n - 1):
return li[i][strt]
mx = -sys.maxsize
for l in range(3):
if l != strt:
if dp[i + 1][l] == -1:
cost = maxcost(li, n, i + 1, l, dp)
dp[i + 1][l] = cost
... | import sys
def maxcost(li, n):
dp = [[-1 for j in range(3)] for i in range(n)]
dp[n - 1][0], dp[n - 1][1], dp[n - 1][2] = li[n - 1][0], li[n - 1][1], li[n - 1][2]
for i in range(n - 2, -1, -1):
for j in range(3):
mx = -sys.maxsize
for k in range(3):
if j != ... | false | 20.833333 | [
"-sys.setrecursionlimit(1000000)",
"-",
"-def maxcost(li, n, i, strt, dp):",
"- if i == (n - 1):",
"- return li[i][strt]",
"- mx = -sys.maxsize",
"- for l in range(3):",
"- if l != strt:",
"- if dp[i + 1][l] == -1:",
"- cost = maxcost(li, n, i + 1, ... | false | 0.044682 | 0.080953 | 0.551951 | [
"s029107461",
"s062517134"
] |
u133936772 | p02579 | python | s559152826 | s067807906 | 1,125 | 963 | 259,804 | 254,024 | Accepted | Accepted | 14.4 | INF=10**6
f=lambda:list(map(int,input().split()))
h,w=f()
ch,cw=f()
dh,dw=f()
ch-=1
cw-=1
dh-=1
dw-=1
g=[eval(input()) for _ in range(h)]
from collections import *
d=[[INF]*w for _ in range(h)]
q=deque([(0,ch,cw)])
while q:
td,tx,ty=q.popleft()
if d[tx][ty]<=td: continue
d[tx][ty]=td
for dx,dy ... | INF=10**6
f=lambda:list(map(int,input().split()))
h,w=f()
ch,cw=f()
dh,dw=f()
g=[eval(input()) for _ in range(h)]
d=[[INF]*w for _ in range(h)]
from collections import *
q=deque([(0,ch-1,cw-1)])
while q:
c,x,y=q.popleft()
if d[x][y]<=c: continue
d[x][y]=c
for dx in range(-2,3):
for dy in range... | 28 | 22 | 638 | 536 | INF = 10**6
f = lambda: list(map(int, input().split()))
h, w = f()
ch, cw = f()
dh, dw = f()
ch -= 1
cw -= 1
dh -= 1
dw -= 1
g = [eval(input()) for _ in range(h)]
from collections import *
d = [[INF] * w for _ in range(h)]
q = deque([(0, ch, cw)])
while q:
td, tx, ty = q.popleft()
if d[tx][ty] <= td:
c... | INF = 10**6
f = lambda: list(map(int, input().split()))
h, w = f()
ch, cw = f()
dh, dw = f()
g = [eval(input()) for _ in range(h)]
d = [[INF] * w for _ in range(h)]
from collections import *
q = deque([(0, ch - 1, cw - 1)])
while q:
c, x, y = q.popleft()
if d[x][y] <= c:
continue
d[x][y] = c
fo... | false | 21.428571 | [
"-ch -= 1",
"-cw -= 1",
"-dh -= 1",
"-dw -= 1",
"+d = [[INF] * w for _ in range(h)]",
"-d = [[INF] * w for _ in range(h)]",
"-q = deque([(0, ch, cw)])",
"+q = deque([(0, ch - 1, cw - 1)])",
"- td, tx, ty = q.popleft()",
"- if d[tx][ty] <= td:",
"+ c, x, y = q.popleft()",
"+ if d[x]... | false | 0.036478 | 0.033245 | 1.097266 | [
"s559152826",
"s067807906"
] |
u821969418 | p02658 | python | s555238436 | s226898403 | 79 | 48 | 21,580 | 21,628 | Accepted | Accepted | 39.24 | n = int(eval(input()))
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = 1
if 0 in a:
ans = 0
print(ans)
exit()
else:
for i in a:
ans *= i
if ans > 10**18:
print((-1))
exit()
print(ans)
| n = int(eval(input()))
a = list(map(int, input().split()))
ans = 1
if 0 in a:
ans = 0
print(ans)
exit()
else:
for i in a:
ans *= i
if ans > 10**18:
print((-1))
exit()
print(ans)
| 16 | 15 | 263 | 241 | n = int(eval(input()))
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = 1
if 0 in a:
ans = 0
print(ans)
exit()
else:
for i in a:
ans *= i
if ans > 10**18:
print((-1))
exit()
print(ans)
| n = int(eval(input()))
a = list(map(int, input().split()))
ans = 1
if 0 in a:
ans = 0
print(ans)
exit()
else:
for i in a:
ans *= i
if ans > 10**18:
print((-1))
exit()
print(ans)
| false | 6.25 | [
"-a.sort(reverse=True)"
] | false | 0.036678 | 0.036835 | 0.99576 | [
"s555238436",
"s226898403"
] |
u779759600 | p02675 | python | s406200429 | s795541722 | 24 | 22 | 9,112 | 9,176 | Accepted | Accepted | 8.33 | n = int(eval(input()))
n = n % 10
if n in (2,4,5,7,9):
yomi = 'hon'
if n in (0,1,6,8):
yomi = 'pon'
if n == 3:
yomi = 'bon'
print(yomi) | n = int(eval(input()))
n = n % 10
if n in (2,4,5,7,9):
yomi = 'hon'
if n in (0,1,6,8):
yomi = 'pon'
if n == (3):
yomi = 'bon'
print(yomi) | 12 | 12 | 155 | 157 | n = int(eval(input()))
n = n % 10
if n in (2, 4, 5, 7, 9):
yomi = "hon"
if n in (0, 1, 6, 8):
yomi = "pon"
if n == 3:
yomi = "bon"
print(yomi)
| n = int(eval(input()))
n = n % 10
if n in (2, 4, 5, 7, 9):
yomi = "hon"
if n in (0, 1, 6, 8):
yomi = "pon"
if n == (3):
yomi = "bon"
print(yomi)
| false | 0 | [
"-if n == 3:",
"+if n == (3):"
] | false | 0.126067 | 0.049143 | 2.565314 | [
"s406200429",
"s795541722"
] |
u022407960 | p02278 | python | s849620404 | s884494200 | 70 | 40 | 7,888 | 7,816 | Accepted | Accepted | 42.86 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
MAX_VALUE = int(1e4 + 1)
def min_cost_sort():
ans = 0
for i in range(array_length):
if check_order[i]:
continue
current_index = i
circle_sum, circle_min, circle_size = 0, MAX_VALUE, 0
while Tr... | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
MAX_VALUE = int(1e4 + 1)
def min_cost_sort():
ans = 0
for i in range(array_length):
if check_order[i]:
continue
current_index = i
circle_sum, circle_min, circle_size = 0, MAX_VALUE, 0
while Tr... | 42 | 42 | 1,266 | 1,268 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
MAX_VALUE = int(1e4 + 1)
def min_cost_sort():
ans = 0
for i in range(array_length):
if check_order[i]:
continue
current_index = i
circle_sum, circle_min, circle_size = 0, MAX_VALUE, 0
while True:
... | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
MAX_VALUE = int(1e4 + 1)
def min_cost_sort():
ans = 0
for i in range(array_length):
if check_order[i]:
continue
current_index = i
circle_sum, circle_min, circle_size = 0, MAX_VALUE, 0
while True:
... | false | 0 | [
"- current_index = kv_reverse[current_value]",
"+ current_index = value_to_index[current_value]",
"- kv_reverse = [-1] * MAX_VALUE",
"+ value_to_index = dict()",
"- kv_reverse[compare_ans[j]] = j",
"+ value_to_index[compare_ans[j]] = j"
] | false | 0.077244 | 0.075192 | 1.027294 | [
"s849620404",
"s884494200"
] |
u616382321 | p03273 | python | s243082203 | s329680390 | 126 | 30 | 27,056 | 9,188 | Accepted | Accepted | 76.19 | import numpy as np
H, W = map(int, input().split())
mat = []
for _ in range(H):
a = list(input())
ca = [0 if i == '.' else 1 for i in a]
mat.append(ca)
amat = np.array(mat)
mask1 = []
for i in range(H):
if np.sum(amat[i]) != 0:
mask1.append(i)
amat1 = amat[mask1]
mask2 = []
for... | H, W = list(map(int, input().split()))
a = [list(eval(input())) for i in range(H)]
a = [x for x in a if '#' in x]
aT = list(zip(*a))
aT = [x for x in aT if '#' in x]
a = list(zip(*aT))
for i in a:
print((''.join(i)))
| 31 | 8 | 632 | 214 | import numpy as np
H, W = map(int, input().split())
mat = []
for _ in range(H):
a = list(input())
ca = [0 if i == "." else 1 for i in a]
mat.append(ca)
amat = np.array(mat)
mask1 = []
for i in range(H):
if np.sum(amat[i]) != 0:
mask1.append(i)
amat1 = amat[mask1]
mask2 = []
for i in range(W):
... | H, W = list(map(int, input().split()))
a = [list(eval(input())) for i in range(H)]
a = [x for x in a if "#" in x]
aT = list(zip(*a))
aT = [x for x in aT if "#" in x]
a = list(zip(*aT))
for i in a:
print(("".join(i)))
| false | 74.193548 | [
"-import numpy as np",
"-",
"-H, W = map(int, input().split())",
"-mat = []",
"-for _ in range(H):",
"- a = list(input())",
"- ca = [0 if i == \".\" else 1 for i in a]",
"- mat.append(ca)",
"-amat = np.array(mat)",
"-mask1 = []",
"-for i in range(H):",
"- if np.sum(amat[i]) != 0:",... | false | 0.250839 | 0.046699 | 5.371395 | [
"s243082203",
"s329680390"
] |
u036340997 | p02659 | python | s962145805 | s386083520 | 28 | 22 | 9,904 | 9,164 | Accepted | Accepted | 21.43 | from decimal import Decimal
ab = input().split()
a = Decimal(ab[0])
b = Decimal(ab[1])
print((int((a*b)))) | ab = input().split()
a = int(ab[0])
b = round(100*float(ab[1]))
print(((a*b)//100))
| 5 | 4 | 108 | 85 | from decimal import Decimal
ab = input().split()
a = Decimal(ab[0])
b = Decimal(ab[1])
print((int((a * b))))
| ab = input().split()
a = int(ab[0])
b = round(100 * float(ab[1]))
print(((a * b) // 100))
| false | 20 | [
"-from decimal import Decimal",
"-",
"-a = Decimal(ab[0])",
"-b = Decimal(ab[1])",
"-print((int((a * b))))",
"+a = int(ab[0])",
"+b = round(100 * float(ab[1]))",
"+print(((a * b) // 100))"
] | false | 0.159174 | 0.048532 | 3.279764 | [
"s962145805",
"s386083520"
] |
u499381410 | p03055 | python | s064149720 | s282942167 | 823 | 717 | 97,840 | 86,092 | Accepted | Accepted | 12.88 | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string
INF = float('inf')
def LI(): return list(map(int, s... | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string
INF = 10 ** 13
def LI(): return list(map(int, sys.s... | 63 | 63 | 1,503 | 1,476 | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string
INF = float("inf")
def LI():
return list(map(int, sys.stdin... | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string
INF = 10**13
def LI():
return list(map(int, sys.stdin.readl... | false | 0 | [
"-INF = float(\"inf\")",
"+INF = 10**13",
"-graph = [[] for _ in range(n)]",
"+G = [[] for _ in range(n)]",
"- graph[a - 1] += [b - 1]",
"- graph[b - 1] += [a - 1]",
"+ G[a - 1] += [b - 1]",
"+ G[b - 1] += [a - 1]",
"-def bfs(v):",
"- que = deque([v])",
"+def bfs(root):",
"+ ... | false | 0.048575 | 0.044988 | 1.079731 | [
"s064149720",
"s282942167"
] |
u879870653 | p03161 | python | s244764601 | s171515990 | 432 | 374 | 56,544 | 56,544 | Accepted | Accepted | 13.43 | N,K = list(map(int,input().split()))
L = list(map(int,input().split()))
dp = [0 for i in range(N)]
if N >= K :
for i in range(1,K+1) :
dp[i] = abs(L[i]-L[0])
for i in range(K+1,len(dp)) :
state = float("inf")
for j in range(i-K,i) :
calc = abs(L[i]-L[j]) + dp... | N,K = list(map(int,input().split()))
L = list(map(int,input().split()))
dp = [0 for i in range(N)]
if N < K :
ans = abs(min(L[1:]) - L[0])
else :
for i in range(1,K+1) :
dp[i] = abs(L[0] - L[i])
for i in range(K+1,N) :
cost = float("inf")
for j in range(i-K,i) :
... | 19 | 21 | 465 | 468 | N, K = list(map(int, input().split()))
L = list(map(int, input().split()))
dp = [0 for i in range(N)]
if N >= K:
for i in range(1, K + 1):
dp[i] = abs(L[i] - L[0])
for i in range(K + 1, len(dp)):
state = float("inf")
for j in range(i - K, i):
calc = abs(L[i] - L[j]) + dp[j]
... | N, K = list(map(int, input().split()))
L = list(map(int, input().split()))
dp = [0 for i in range(N)]
if N < K:
ans = abs(min(L[1:]) - L[0])
else:
for i in range(1, K + 1):
dp[i] = abs(L[0] - L[i])
for i in range(K + 1, N):
cost = float("inf")
for j in range(i - K, i):
ca... | false | 9.52381 | [
"-if N >= K:",
"+if N < K:",
"+ ans = abs(min(L[1:]) - L[0])",
"+else:",
"- dp[i] = abs(L[i] - L[0])",
"- for i in range(K + 1, len(dp)):",
"- state = float(\"inf\")",
"+ dp[i] = abs(L[0] - L[i])",
"+ for i in range(K + 1, N):",
"+ cost = float(\"inf\")",
"- ... | false | 0.038655 | 0.043192 | 0.894968 | [
"s244764601",
"s171515990"
] |
u131638468 | p03722 | python | s472225380 | s391337706 | 1,631 | 1,033 | 3,572 | 3,700 | Accepted | Accepted | 36.66 | n,m=list(map(int,input().split()))
edge=[list(map(int,input().split())) for i in range(m)]
node=[-float('inf') for i in range(n+1)]
node[1]=0
inf=False
for i in range(2*n+1):
change=False
for s,e,c in edge:
if node[e]<node[s]+c:
node[e]=node[s]+c
if e==n:
change=True
if i>=n an... | n,m=list(map(int,input().split()))
edge=[list(map(int,input().split())) for i in range(m)]
node=[-float('inf') for i in range(n+1)]
node[1]=0
inf=False
for i in range(2*n+1):
loop=False
for s,e,c in edge:
if node[e]<node[s]+c:
node[e]=node[s]+c
if e==n:
loop=True
if i>=n and lo... | 18 | 19 | 388 | 393 | n, m = list(map(int, input().split()))
edge = [list(map(int, input().split())) for i in range(m)]
node = [-float("inf") for i in range(n + 1)]
node[1] = 0
inf = False
for i in range(2 * n + 1):
change = False
for s, e, c in edge:
if node[e] < node[s] + c:
node[e] = node[s] + c
if... | n, m = list(map(int, input().split()))
edge = [list(map(int, input().split())) for i in range(m)]
node = [-float("inf") for i in range(n + 1)]
node[1] = 0
inf = False
for i in range(2 * n + 1):
loop = False
for s, e, c in edge:
if node[e] < node[s] + c:
node[e] = node[s] + c
if e... | false | 5.263158 | [
"- change = False",
"+ loop = False",
"- change = True",
"- if i >= n and change:",
"+ loop = True",
"+ if i >= n and loop:",
"+ break"
] | false | 0.046533 | 0.037089 | 1.254617 | [
"s472225380",
"s391337706"
] |
u809819902 | p02612 | python | s129140886 | s217177993 | 89 | 29 | 61,052 | 9,156 | Accepted | Accepted | 67.42 | n=int(eval(input()))
print((1000-n%1000 if n%1000!=0 else 0)) | n=int(eval(input()))
print((0 if n%1000==0 else 1000-n%1000)) | 2 | 2 | 54 | 54 | n = int(eval(input()))
print((1000 - n % 1000 if n % 1000 != 0 else 0))
| n = int(eval(input()))
print((0 if n % 1000 == 0 else 1000 - n % 1000))
| false | 0 | [
"-print((1000 - n % 1000 if n % 1000 != 0 else 0))",
"+print((0 if n % 1000 == 0 else 1000 - n % 1000))"
] | false | 0.036358 | 0.053186 | 0.683599 | [
"s129140886",
"s217177993"
] |
u857428111 | p03408 | python | s855029426 | s035353464 | 309 | 172 | 66,284 | 38,256 | Accepted | Accepted | 44.34 | #print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return list(map(type,input().split()))
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from fractions import gcd
... | #print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return list(map(type,input().split()))
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import de... | 26 | 24 | 626 | 598 | # print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):
return list(map(type, input().split()))
def tupin(t=int):
return tuple(pin(t))
def lispin(t=int):
return list(pin(t))
#%%code
from fra... | # print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):
return list(map(type, input().split()))
def tupin(t=int):
return tuple(pin(t))
def lispin(t=int):
return list(pin(t))
#%%code
from col... | false | 7.692308 | [
"-from fractions import gcd",
"+from collections import defaultdict",
"- a = dict()",
"+ a = defaultdict(lambda: 0)",
"- a.setdefault(t, 0)",
"- a.setdefault(s, 0)"
] | false | 0.036707 | 0.036377 | 1.009084 | [
"s855029426",
"s035353464"
] |
u102461423 | p02931 | python | s134305106 | s349765863 | 493 | 446 | 34,680 | 34,680 | Accepted | Accepted | 9.53 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import operator
N,H,W = list(map(int,readline().split()))
m = list(map(int,read().split()))
RCA = sorted(zip(m,m,m),key=operator.itemgetter(2),reverse=True)
root = list(range(H+W))
size = [... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
import operator
N,H,W = list(map(int,readline().split()))
m = list(map(int,read().split()))
RCA = sorted(zip(m,m,m),key=operator.itemgetter(2),reverse=True)
roo... | 51 | 54 | 1,103 | 1,173 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import operator
N, H, W = list(map(int, readline().split()))
m = list(map(int, read().split()))
RCA = sorted(zip(m, m, m), key=operator.itemgetter(2), reverse=True)
root = list(range(H + W))
size = [0] ... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
import operator
N, H, W = list(map(int, readline().split()))
m = list(map(int, read().split()))
RCA = sorted(zip(m, m, m), key=operator.itemgetter(2), reverse=True)
root = l... | false | 5.555556 | [
"+sys.setrecursionlimit(10**7)",
"+ if x == root[x]:",
"+ return x"
] | false | 0.053286 | 0.05391 | 0.988411 | [
"s134305106",
"s349765863"
] |
u079022693 | p02713 | python | s467428644 | s545703458 | 1,428 | 217 | 9,176 | 89,468 | Accepted | Accepted | 84.8 | from sys import stdin
from math import gcd
def main():
#入力
readline=stdin.readline
k=int(readline())
ans=0
for a in range(1,k+1):
for b in range(1,k+1):
for c in range(1,k+1):
ans+=gcd(a,gcd(b,c))
print(ans)
if __name__=="__main__":
main() | from sys import stdin
import numpy as np
def main():
#入力
readline=stdin.readline
k=int(readline())
a=np.arange(1,k+1,dtype=np.int64)
b=np.gcd.outer(np.gcd.outer(a,a),a)
print((b.sum()))
if __name__=="__main__":
main() | 15 | 13 | 318 | 257 | from sys import stdin
from math import gcd
def main():
# 入力
readline = stdin.readline
k = int(readline())
ans = 0
for a in range(1, k + 1):
for b in range(1, k + 1):
for c in range(1, k + 1):
ans += gcd(a, gcd(b, c))
print(ans)
if __name__ == "__main__":
... | from sys import stdin
import numpy as np
def main():
# 入力
readline = stdin.readline
k = int(readline())
a = np.arange(1, k + 1, dtype=np.int64)
b = np.gcd.outer(np.gcd.outer(a, a), a)
print((b.sum()))
if __name__ == "__main__":
main()
| false | 13.333333 | [
"-from math import gcd",
"+import numpy as np",
"- ans = 0",
"- for a in range(1, k + 1):",
"- for b in range(1, k + 1):",
"- for c in range(1, k + 1):",
"- ans += gcd(a, gcd(b, c))",
"- print(ans)",
"+ a = np.arange(1, k + 1, dtype=np.int64)",
"+ b ... | false | 0.049523 | 0.188782 | 0.262327 | [
"s467428644",
"s545703458"
] |
u098223184 | p03331 | python | s944794247 | s351989141 | 237 | 133 | 9,160 | 9,176 | Accepted | Accepted | 43.88 | n=int(eval(input()))
ans=10e5
for a in range(1,n//2+1):
b=n-a
ans=min(ans,sum([int(i) for i in str(a)])+sum([int(i) for i in str(b)]))
ans=min(ans,sum([int(i) for i in str(a)])+sum([int(i) for i in str(b)]))
print((int(ans))) | n=int(eval(input()))
ans=10e5
for a in range(1,n//2+1):
b=n-a
ans=min(ans,sum([int(i) for i in str(a)])+sum([int(i) for i in str(b)]))
print((int(ans)))
| 7 | 6 | 235 | 158 | n = int(eval(input()))
ans = 10e5
for a in range(1, n // 2 + 1):
b = n - a
ans = min(ans, sum([int(i) for i in str(a)]) + sum([int(i) for i in str(b)]))
ans = min(ans, sum([int(i) for i in str(a)]) + sum([int(i) for i in str(b)]))
print((int(ans)))
| n = int(eval(input()))
ans = 10e5
for a in range(1, n // 2 + 1):
b = n - a
ans = min(ans, sum([int(i) for i in str(a)]) + sum([int(i) for i in str(b)]))
print((int(ans)))
| false | 14.285714 | [
"- ans = min(ans, sum([int(i) for i in str(a)]) + sum([int(i) for i in str(b)]))"
] | false | 0.213773 | 0.09691 | 2.205897 | [
"s944794247",
"s351989141"
] |
u088552457 | p03273 | python | s106233649 | s318922157 | 142 | 74 | 72,724 | 68,572 | Accepted | Accepted | 47.89 | from functools import reduce
from decimal import *
from operator import mul
def main():
h, w = input_list()
masu = []
for _ in range(h):
line = list(eval(input()))
masu.append(line)
rows = [False] * h
cols = [False] * w
for i, m in enumerate(masu):
for j, v ... | # import sys
# input = sys.stdin.readline
import collections
import itertools
def main():
h, w = input_list()
maze = [list(eval(input())) for _ in range(h)]
ans = []
blacks = [False] * w
for m in maze:
for i, v in enumerate(m):
if v == "#":
blacks[i]... | 55 | 41 | 1,176 | 890 | from functools import reduce
from decimal import *
from operator import mul
def main():
h, w = input_list()
masu = []
for _ in range(h):
line = list(eval(input()))
masu.append(line)
rows = [False] * h
cols = [False] * w
for i, m in enumerate(masu):
for j, v in enumerate... | # import sys
# input = sys.stdin.readline
import collections
import itertools
def main():
h, w = input_list()
maze = [list(eval(input())) for _ in range(h)]
ans = []
blacks = [False] * w
for m in maze:
for i, v in enumerate(m):
if v == "#":
blacks[i] = True
... | false | 25.454545 | [
"-from functools import reduce",
"-from decimal import *",
"-from operator import mul",
"+# import sys",
"+# input = sys.stdin.readline",
"+import collections",
"+import itertools",
"- masu = []",
"- for _ in range(h):",
"- line = list(eval(input()))",
"- masu.append(line)",
... | false | 0.078288 | 0.06758 | 1.158454 | [
"s106233649",
"s318922157"
] |
u729133443 | p02982 | python | s016447402 | s688650382 | 496 | 151 | 22,404 | 12,472 | Accepted | Accepted | 69.56 | from numpy import*
n,*x=[int32(t.split())for t in open(0)]
print((sum(sum(linalg.norm(i-x,2,1)%1==0)for i in x)-n[0]>>1)) | from numpy import*
n,*x=[int32(t.split())for t in open(0)]
print((sum(triu([linalg.norm(i-x,2,1)%1==0for i in x],1)))) | 3 | 3 | 121 | 118 | from numpy import *
n, *x = [int32(t.split()) for t in open(0)]
print((sum(sum(linalg.norm(i - x, 2, 1) % 1 == 0) for i in x) - n[0] >> 1))
| from numpy import *
n, *x = [int32(t.split()) for t in open(0)]
print((sum(triu([linalg.norm(i - x, 2, 1) % 1 == 0 for i in x], 1))))
| false | 0 | [
"-print((sum(sum(linalg.norm(i - x, 2, 1) % 1 == 0) for i in x) - n[0] >> 1))",
"+print((sum(triu([linalg.norm(i - x, 2, 1) % 1 == 0 for i in x], 1))))"
] | false | 0.202736 | 0.305693 | 0.663202 | [
"s016447402",
"s688650382"
] |
u798818115 | p02928 | python | s240430830 | s906528357 | 1,196 | 1,052 | 3,188 | 3,316 | Accepted | Accepted | 12.04 | # coding: utf-8
# Your code here!
N,K=list(map(int,input().split()))
A=list(map(int,input().split()))
A=A+A
count=[0]*2*N
for i in range(N):
for j in range(i,2*N):
if A[i]>A[j]:
count[j]+=1
a=(sum(count[0:N]))
b=(sum(count[N:2*N]))
c=(int((a*K+b*K*(K-1)//2)))
print((c%(10**9... | N,K=list(map(int,input().split()))
A=list(map(int,input().split()))*2
mod=10**9+7
inside=0
for i in range(N-1):
for j in range(i+1,N):
if A[i]>A[j]:
inside+=1
outside=0
for i in range(N):
for j in range(N,2*N):
if A[i]>A[j]:
outside+=1
#print(insi... | 18 | 19 | 318 | 367 | # coding: utf-8
# Your code here!
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A = A + A
count = [0] * 2 * N
for i in range(N):
for j in range(i, 2 * N):
if A[i] > A[j]:
count[j] += 1
a = sum(count[0:N])
b = sum(count[N : 2 * N])
c = int((a * K + b * K * (K - 1) // ... | N, K = list(map(int, input().split()))
A = list(map(int, input().split())) * 2
mod = 10**9 + 7
inside = 0
for i in range(N - 1):
for j in range(i + 1, N):
if A[i] > A[j]:
inside += 1
outside = 0
for i in range(N):
for j in range(N, 2 * N):
if A[i] > A[j]:
outside += 1
# p... | false | 5.263158 | [
"-# coding: utf-8",
"-# Your code here!",
"-A = list(map(int, input().split()))",
"-A = A + A",
"-count = [0] * 2 * N",
"+A = list(map(int, input().split())) * 2",
"+mod = 10**9 + 7",
"+inside = 0",
"+for i in range(N - 1):",
"+ for j in range(i + 1, N):",
"+ if A[i] > A[j]:",
"+ ... | false | 0.039591 | 0.041119 | 0.962827 | [
"s240430830",
"s906528357"
] |
u952708174 | p02662 | python | s505642398 | s500095323 | 454 | 212 | 147,024 | 27,360 | Accepted | Accepted | 53.3 | def f_knapsack_for_all_subsets(MOD=998244353):
N, S = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
# dp[i][j]: i 番目の要素を見たとき、和が j であるような場合の数
dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
dp[0][0] = 1 # インデックスの集合が空のとき、和は 0 の 1 通り
for i, a in enumerate(A... | def f_knapsack_for_all_subsets_power_series(MOD=998244353, MAX=3010):
# 参考: https://maspypy.com/atcoder-参加感想-2020-05-31abc-169
import numpy as np
N, S = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
f = np.zeros(MAX + 1, np.int64) # 次数が S より大きな項には興味ないため、こうする
f[... | 18 | 17 | 666 | 606 | def f_knapsack_for_all_subsets(MOD=998244353):
N, S = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
# dp[i][j]: i 番目の要素を見たとき、和が j であるような場合の数
dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
dp[0][0] = 1 # インデックスの集合が空のとき、和は 0 の 1 通り
for i, a in enumerate(A):
... | def f_knapsack_for_all_subsets_power_series(MOD=998244353, MAX=3010):
# 参考: https://maspypy.com/atcoder-参加感想-2020-05-31abc-169
import numpy as np
N, S = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
f = np.zeros(MAX + 1, np.int64) # 次数が S より大きな項には興味ないため、こうする
f[0] = 1 ... | false | 5.555556 | [
"-def f_knapsack_for_all_subsets(MOD=998244353):",
"+def f_knapsack_for_all_subsets_power_series(MOD=998244353, MAX=3010):",
"+ # 参考: https://maspypy.com/atcoder-参加感想-2020-05-31abc-169",
"+ import numpy as np",
"+",
"- # dp[i][j]: i 番目の要素を見たとき、和が j であるような場合の数",
"- dp = [[0 for j in range(S +... | false | 0.048561 | 0.289563 | 0.167703 | [
"s505642398",
"s500095323"
] |
u912237403 | p00063 | python | s291445874 | s547290327 | 20 | 10 | 4,180 | 4,180 | Accepted | Accepted | 50 | import sys
c=0
for s in sys.stdin:
s=s[:-1]
if s==s[::-1]:c+=1
print(c) | import sys
c=0
for s in sys.stdin:
if s[:-1]==s[::-1][1:]:c+=1
print(c) | 6 | 5 | 83 | 78 | import sys
c = 0
for s in sys.stdin:
s = s[:-1]
if s == s[::-1]:
c += 1
print(c)
| import sys
c = 0
for s in sys.stdin:
if s[:-1] == s[::-1][1:]:
c += 1
print(c)
| false | 16.666667 | [
"- s = s[:-1]",
"- if s == s[::-1]:",
"+ if s[:-1] == s[::-1][1:]:"
] | false | 0.041018 | 0.039458 | 1.039553 | [
"s291445874",
"s547290327"
] |
u681444474 | p02995 | python | s005868457 | s558230665 | 286 | 26 | 65,516 | 9,044 | Accepted | Accepted | 90.91 | import fractions
a,b,c,d = list(map(int,input().split()))
N = b-a+1
s = fractions.gcd(c,d)
t = c*d // s
lcm_div = b//t - (a-1)//t
divc = b//c - (a-1)//c
divd = b//d - (a-1)//d
if c%d==0 or d%c==0:
w = min(c,d)
print((N-(b//w-(a-1)//w)))
else:
print((N-(divc+divd-lcm_div))) | # coding: utf-8
import math
a, b, c, d = list(map(int,input().split()))
e = int(c*d/math.gcd(c,d))
ans = b//c-(a-1)//c#cで
ans += b//d-(a-1)//d#dで
#print(ans)
ans -= b//e-(a-1)//e#両方で
print((int(b-a+1-ans))) | 13 | 12 | 287 | 212 | import fractions
a, b, c, d = list(map(int, input().split()))
N = b - a + 1
s = fractions.gcd(c, d)
t = c * d // s
lcm_div = b // t - (a - 1) // t
divc = b // c - (a - 1) // c
divd = b // d - (a - 1) // d
if c % d == 0 or d % c == 0:
w = min(c, d)
print((N - (b // w - (a - 1) // w)))
else:
print((N - (divc... | # coding: utf-8
import math
a, b, c, d = list(map(int, input().split()))
e = int(c * d / math.gcd(c, d))
ans = b // c - (a - 1) // c # cで
ans += b // d - (a - 1) // d # dで
# print(ans)
ans -= b // e - (a - 1) // e # 両方で
print((int(b - a + 1 - ans)))
| false | 7.692308 | [
"-import fractions",
"+# coding: utf-8",
"+import math",
"-N = b - a + 1",
"-s = fractions.gcd(c, d)",
"-t = c * d // s",
"-lcm_div = b // t - (a - 1) // t",
"-divc = b // c - (a - 1) // c",
"-divd = b // d - (a - 1) // d",
"-if c % d == 0 or d % c == 0:",
"- w = min(c, d)",
"- print((N ... | false | 0.119988 | 0.038966 | 3.079269 | [
"s005868457",
"s558230665"
] |
u708019102 | p02713 | python | s619832709 | s071882355 | 633 | 158 | 69,684 | 68,352 | Accepted | Accepted | 75.04 | import math
ans = 0
N = int(eval(input()))
for i in range(N):
for j in range(N):
for k in range(N):
ans += math.gcd(math.gcd(i+1,j+1),math.gcd(j+1,k+1))
print(ans) | import math
ans = 0
N = int(eval(input()))
if N <= 5:
for i in range(N):
for j in range(N):
for k in range(N):
ans += math.gcd(math.gcd(i+1,j+1),math.gcd(j+1,k+1))
else:
for i in range(N):
ans += i+1
for i in range(N-1):
for j in range(i+1,N):
a... | 8 | 19 | 188 | 519 | import math
ans = 0
N = int(eval(input()))
for i in range(N):
for j in range(N):
for k in range(N):
ans += math.gcd(math.gcd(i + 1, j + 1), math.gcd(j + 1, k + 1))
print(ans)
| import math
ans = 0
N = int(eval(input()))
if N <= 5:
for i in range(N):
for j in range(N):
for k in range(N):
ans += math.gcd(math.gcd(i + 1, j + 1), math.gcd(j + 1, k + 1))
else:
for i in range(N):
ans += i + 1
for i in range(N - 1):
for j in range(i + ... | false | 57.894737 | [
"-for i in range(N):",
"- for j in range(N):",
"- for k in range(N):",
"- ans += math.gcd(math.gcd(i + 1, j + 1), math.gcd(j + 1, k + 1))",
"+if N <= 5:",
"+ for i in range(N):",
"+ for j in range(N):",
"+ for k in range(N):",
"+ ans += math.g... | false | 0.042248 | 0.150449 | 0.280815 | [
"s619832709",
"s071882355"
] |
u633068244 | p01520 | python | s200252904 | s109710477 | 30 | 20 | 4,200 | 4,204 | Accepted | Accepted | 33.33 | n,t,e = list(map(int,input().split()))
x = list(map(int,input().split()))
for i in range(n):
if t%x[i] <= e or x[i] - t%x[i] <= e:
print(i+1)
break
else:
print(-1) | n,t,e = list(map(int,input().split()))
x = list(map(int,input().split()))
for i in range(n):
r = t%x[i]
if min(r, x[i] - r) <= e:
print(i+1)
break
else:
print(-1) | 8 | 9 | 170 | 171 | n, t, e = list(map(int, input().split()))
x = list(map(int, input().split()))
for i in range(n):
if t % x[i] <= e or x[i] - t % x[i] <= e:
print(i + 1)
break
else:
print(-1)
| n, t, e = list(map(int, input().split()))
x = list(map(int, input().split()))
for i in range(n):
r = t % x[i]
if min(r, x[i] - r) <= e:
print(i + 1)
break
else:
print(-1)
| false | 11.111111 | [
"- if t % x[i] <= e or x[i] - t % x[i] <= e:",
"+ r = t % x[i]",
"+ if min(r, x[i] - r) <= e:"
] | false | 0.096793 | 0.041743 | 2.318752 | [
"s200252904",
"s109710477"
] |
u416011173 | p02641 | python | s712317011 | s198033478 | 25 | 20 | 9,184 | 9,224 | Accepted | Accepted | 20 | # -*- coding: utf-8 -*-
# 標準入力の取得
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
# 求解処理
result = int()
a = 0
while True:
x_minus = X - a
if x_minus not in p:
result = x_minus
break
x_plus = X + a
if x_plus not in p:
result = x_plus
... | # -*- coding: utf-8 -*-
def get_input() -> tuple:
"""
標準入力を取得する.
Returns:\n
tuple: 標準入力
"""
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
return X, N, p
def main(X: int, N: int, p: list) -> None:
"""
求解処理を行う.
Args:\n
... | 22 | 47 | 370 | 839 | # -*- coding: utf-8 -*-
# 標準入力の取得
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
# 求解処理
result = int()
a = 0
while True:
x_minus = X - a
if x_minus not in p:
result = x_minus
break
x_plus = X + a
if x_plus not in p:
result = x_plus
break
a ... | # -*- coding: utf-8 -*-
def get_input() -> tuple:
"""
標準入力を取得する.
Returns:\n
tuple: 標準入力
"""
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
return X, N, p
def main(X: int, N: int, p: list) -> None:
"""
求解処理を行う.
Args:\n
X (int): 整数
... | false | 53.191489 | [
"-# 標準入力の取得",
"-X, N = list(map(int, input().split()))",
"-p = list(map(int, input().split()))",
"-# 求解処理",
"-result = int()",
"-a = 0",
"-while True:",
"- x_minus = X - a",
"- if x_minus not in p:",
"- result = x_minus",
"- break",
"- x_plus = X + a",
"- if x_plus ... | false | 0.04191 | 0.042526 | 0.985518 | [
"s712317011",
"s198033478"
] |
u952708174 | p02725 | python | s466707602 | s573857363 | 241 | 98 | 28,612 | 26,444 | Accepted | Accepted | 59.34 | def c_traveling_salesman_around_lake():
K, N = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
pos = [-(K - a) for a in A] + A[:]
diff = [abs(pos[i + 1] - pos[i]) for i in range(len(pos) - 1)]
ans = sum(diff[:N - 1])
tmp = ans
left, right = 0, N - 1
wh... | def c_traveling_salesman_around_lake():
K, N = [int(i) for i in input().split()]
A = [int(i) for i in input().split()] # ソート済
A.append(A[0] + K) # N 番の家と 1 番の家の間の距離も調べたい
return K - max(A[i + 1] - A[i] for i in range(N))
print((c_traveling_salesman_around_lake())) | 19 | 8 | 527 | 288 | def c_traveling_salesman_around_lake():
K, N = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
pos = [-(K - a) for a in A] + A[:]
diff = [abs(pos[i + 1] - pos[i]) for i in range(len(pos) - 1)]
ans = sum(diff[: N - 1])
tmp = ans
left, right = 0, N - 1
while right !... | def c_traveling_salesman_around_lake():
K, N = [int(i) for i in input().split()]
A = [int(i) for i in input().split()] # ソート済
A.append(A[0] + K) # N 番の家と 1 番の家の間の距離も調べたい
return K - max(A[i + 1] - A[i] for i in range(N))
print((c_traveling_salesman_around_lake()))
| false | 57.894737 | [
"- A = [int(i) for i in input().split()]",
"- pos = [-(K - a) for a in A] + A[:]",
"- diff = [abs(pos[i + 1] - pos[i]) for i in range(len(pos) - 1)]",
"- ans = sum(diff[: N - 1])",
"- tmp = ans",
"- left, right = 0, N - 1",
"- while right != len(diff):",
"- tmp -= diff[left... | false | 0.040742 | 0.03681 | 1.106804 | [
"s466707602",
"s573857363"
] |
u025501820 | p03329 | python | s303543782 | s915800988 | 891 | 244 | 23,960 | 52,720 | Accepted | Accepted | 72.62 | N = int(eval(input()))
money = [1]
i = 1
while True:
i *= 6
if i <= 100000:
money.append(i)
else:
break
i = 1
while True:
i *= 9
if i <= 100000:
money.append(i)
else:
break
M = len(money)
dp = [[10 ** 9 for _ in range(N + 1)] for _ in range(M ... | import sys
import math
N = int(sys.stdin.readline().rstrip())
# def create_money(i):
# money = []
# tmp = 1
# for _ in range(math.floor(math.log(N, i))):
# tmp *= i
# money.append(tmp)
# return money
# money = [1]
# money += create_money(6)
# money += create_money(9... | 33 | 37 | 600 | 811 | N = int(eval(input()))
money = [1]
i = 1
while True:
i *= 6
if i <= 100000:
money.append(i)
else:
break
i = 1
while True:
i *= 9
if i <= 100000:
money.append(i)
else:
break
M = len(money)
dp = [[10**9 for _ in range(N + 1)] for _ in range(M + 1)]
for i in range(M ... | import sys
import math
N = int(sys.stdin.readline().rstrip())
# def create_money(i):
# money = []
# tmp = 1
# for _ in range(math.floor(math.log(N, i))):
# tmp *= i
# money.append(tmp)
# return money
# money = [1]
# money += create_money(6)
# money += create_money(9)
money = [1]
for i i... | false | 10.810811 | [
"-N = int(eval(input()))",
"+import sys",
"+import math",
"+",
"+N = int(sys.stdin.readline().rstrip())",
"+# def create_money(i):",
"+# money = []",
"+# tmp = 1",
"+# for _ in range(math.floor(math.log(N, i))):",
"+# tmp *= i",
"+# money.append(tmp)",
"+# retur... | false | 0.135291 | 0.508317 | 0.266154 | [
"s303543782",
"s915800988"
] |
u376420711 | p02639 | python | s085248603 | s617656748 | 29 | 22 | 9,060 | 9,068 | Accepted | Accepted | 24.14 | l = list(map(int, input().split()))
print((l.index(0) + 1))
| print((input().split().index("0") + 1))
| 2 | 1 | 59 | 38 | l = list(map(int, input().split()))
print((l.index(0) + 1))
| print((input().split().index("0") + 1))
| false | 50 | [
"-l = list(map(int, input().split()))",
"-print((l.index(0) + 1))",
"+print((input().split().index(\"0\") + 1))"
] | false | 0.036527 | 0.07346 | 0.497236 | [
"s085248603",
"s617656748"
] |
u852690916 | p02847 | python | s178467250 | s980336613 | 170 | 17 | 38,576 | 2,940 | Accepted | Accepted | 90 | S = eval(input())
L = [ "SUN","MON","TUE","WED","THU","FRI","SAT" ]
L.reverse()
ans = 0
for i in range(len(L)):
if S == L[i]:
ans = i + 1
break
print(ans) | w=['SUN','MON','TUE','WED','THU','FRI','SAT']
S=eval(input())
i=w.index(S)
print((7 if i==0 else 7-i)) | 11 | 4 | 180 | 97 | S = eval(input())
L = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
L.reverse()
ans = 0
for i in range(len(L)):
if S == L[i]:
ans = i + 1
break
print(ans)
| w = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
S = eval(input())
i = w.index(S)
print((7 if i == 0 else 7 - i))
| false | 63.636364 | [
"+w = [\"SUN\", \"MON\", \"TUE\", \"WED\", \"THU\", \"FRI\", \"SAT\"]",
"-L = [\"SUN\", \"MON\", \"TUE\", \"WED\", \"THU\", \"FRI\", \"SAT\"]",
"-L.reverse()",
"-ans = 0",
"-for i in range(len(L)):",
"- if S == L[i]:",
"- ans = i + 1",
"- break",
"-print(ans)",
"+i = w.index(S)",
... | false | 0.0455 | 0.12145 | 0.374637 | [
"s178467250",
"s980336613"
] |
u803617136 | p02881 | python | s105451660 | s194383816 | 154 | 119 | 3,060 | 3,272 | Accepted | Accepted | 22.73 | import math
INF = 1e12
n = int(eval(input()))
cnt = INF
m = math.sqrt(n)
for i in range(1, math.ceil(m) + 1):
if n % i == 0:
j = n // i
cnt = min(cnt, i + j - 2)
else:
continue
print(cnt) | from math import ceil
def divisors(n):
res = []
for i in range(1, int(n ** 0.5) + 1):
if n % i == 0:
res.append(i)
if i != n // i:
res.append(n // i)
return res
n = int(eval(input()))
divs = divisors(n)
ans = 10 ** 12
divs.sort()
for i in rang... | 15 | 21 | 214 | 437 | import math
INF = 1e12
n = int(eval(input()))
cnt = INF
m = math.sqrt(n)
for i in range(1, math.ceil(m) + 1):
if n % i == 0:
j = n // i
cnt = min(cnt, i + j - 2)
else:
continue
print(cnt)
| from math import ceil
def divisors(n):
res = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
res.append(i)
if i != n // i:
res.append(n // i)
return res
n = int(eval(input()))
divs = divisors(n)
ans = 10**12
divs.sort()
for i in range(ceil(len(divs) ... | false | 28.571429 | [
"-import math",
"+from math import ceil",
"-INF = 1e12",
"+",
"+def divisors(n):",
"+ res = []",
"+ for i in range(1, int(n**0.5) + 1):",
"+ if n % i == 0:",
"+ res.append(i)",
"+ if i != n // i:",
"+ res.append(n // i)",
"+ return res",
"... | false | 0.053295 | 0.042247 | 1.261513 | [
"s105451660",
"s194383816"
] |
u089230684 | p03556 | python | s423160017 | s230770940 | 64 | 17 | 2,940 | 2,940 | Accepted | Accepted | 73.44 | import math
n = int(eval(input()))
while (math.sqrt(n)-float(math.floor(math.sqrt(n))))!=0.0:
n = n-1
print(n) | import math
i = int(eval(input()))
r = math.sqrt(i)
ir = int(r)
print((ir*ir))
| 8 | 10 | 118 | 85 | import math
n = int(eval(input()))
while (math.sqrt(n) - float(math.floor(math.sqrt(n)))) != 0.0:
n = n - 1
print(n)
| import math
i = int(eval(input()))
r = math.sqrt(i)
ir = int(r)
print((ir * ir))
| false | 20 | [
"-n = int(eval(input()))",
"-while (math.sqrt(n) - float(math.floor(math.sqrt(n)))) != 0.0:",
"- n = n - 1",
"-print(n)",
"+i = int(eval(input()))",
"+r = math.sqrt(i)",
"+ir = int(r)",
"+print((ir * ir))"
] | false | 0.038919 | 0.078181 | 0.497805 | [
"s423160017",
"s230770940"
] |
u927078824 | p02793 | python | s985681302 | s391688577 | 1,889 | 1,253 | 6,084 | 16,868 | Accepted | Accepted | 33.67 | import functools
import fractions
MOD = 10**9+7
def lcm_base(x, y):
return (x * y) // fractions.gcd(x, y)
def lcm(numbers):
return functools.reduce(lcm_base, numbers, 1)
def main():
n = int(eval(input()))
x = list(map(int, input().split()))
l = lcm(x)
ans = 0
for i ... | import functools
import fractions
MOD = 10**9+7
def sieve(n):
result = [0] * (n+1)
result[0] = result[1] = -1
#primes = []
for i in range(2, n+1):
if(result[i]):
continue
# primes.append(i)
result[i] = i
for j in range(i*i, n+1, i):
... | 26 | 61 | 389 | 1,212 | import functools
import fractions
MOD = 10**9 + 7
def lcm_base(x, y):
return (x * y) // fractions.gcd(x, y)
def lcm(numbers):
return functools.reduce(lcm_base, numbers, 1)
def main():
n = int(eval(input()))
x = list(map(int, input().split()))
l = lcm(x)
ans = 0
for i in range(n):
... | import functools
import fractions
MOD = 10**9 + 7
def sieve(n):
result = [0] * (n + 1)
result[0] = result[1] = -1
# primes = []
for i in range(2, n + 1):
if result[i]:
continue
# primes.append(i)
result[i] = i
for j in range(i * i, n + 1, i):
if... | false | 57.377049 | [
"-def lcm_base(x, y):",
"- return (x * y) // fractions.gcd(x, y)",
"+def sieve(n):",
"+ result = [0] * (n + 1)",
"+ result[0] = result[1] = -1",
"+ # primes = []",
"+ for i in range(2, n + 1):",
"+ if result[i]:",
"+ continue",
"+ # primes.append(i)",
"+ ... | false | 0.048561 | 0.689515 | 0.070428 | [
"s985681302",
"s391688577"
] |
u683134447 | p03140 | python | s737126195 | s029605935 | 168 | 18 | 38,384 | 3,060 | Accepted | Accepted | 89.29 | # coding: utf-8
# Your code here!
n = int(eval(input()))
al = list(eval(input()))
bl = list(eval(input()))
cl = list(eval(input()))
ans = 0
for i,j,k in zip(al,bl,cl):
a = [i,j,k]
if max(a.count(i), a.count(j), a.count(k)) == 1:
ans += 2
elif max(a.count(i), a.count(j), a.count(k)... | n = int(eval(input()))
al = list(eval(input()))
bl = list(eval(input()))
cl = list(eval(input()))
ans = 0
for a, b, c in zip(al, bl, cl):
ans += len(set([a, b, c])) - 1
print(ans) | 21 | 9 | 364 | 168 | # coding: utf-8
# Your code here!
n = int(eval(input()))
al = list(eval(input()))
bl = list(eval(input()))
cl = list(eval(input()))
ans = 0
for i, j, k in zip(al, bl, cl):
a = [i, j, k]
if max(a.count(i), a.count(j), a.count(k)) == 1:
ans += 2
elif max(a.count(i), a.count(j), a.count(k)) == 2:
... | n = int(eval(input()))
al = list(eval(input()))
bl = list(eval(input()))
cl = list(eval(input()))
ans = 0
for a, b, c in zip(al, bl, cl):
ans += len(set([a, b, c])) - 1
print(ans)
| false | 57.142857 | [
"-# coding: utf-8",
"-# Your code here!",
"-for i, j, k in zip(al, bl, cl):",
"- a = [i, j, k]",
"- if max(a.count(i), a.count(j), a.count(k)) == 1:",
"- ans += 2",
"- elif max(a.count(i), a.count(j), a.count(k)) == 2:",
"- ans += 1",
"- else:",
"- pass",
"+for a... | false | 0.041597 | 0.042952 | 0.96846 | [
"s737126195",
"s029605935"
] |
u136869985 | p03294 | python | s298904790 | s577767081 | 89 | 18 | 3,316 | 3,316 | Accepted | Accepted | 79.78 | n=eval(input())
A=list(map(int,input().split()))
t=1
for a in A:
t *= a
t -= 1
ans=0
for a in A:
ans += t % a
print(ans) | n=eval(input())
A=list(map(int,input().split()))
for i in range(int(n)):
A[i] -=1
print((sum(A))) | 10 | 5 | 131 | 97 | n = eval(input())
A = list(map(int, input().split()))
t = 1
for a in A:
t *= a
t -= 1
ans = 0
for a in A:
ans += t % a
print(ans)
| n = eval(input())
A = list(map(int, input().split()))
for i in range(int(n)):
A[i] -= 1
print((sum(A)))
| false | 50 | [
"-t = 1",
"-for a in A:",
"- t *= a",
"-t -= 1",
"-ans = 0",
"-for a in A:",
"- ans += t % a",
"-print(ans)",
"+for i in range(int(n)):",
"+ A[i] -= 1",
"+print((sum(A)))"
] | false | 0.041536 | 0.045111 | 0.920747 | [
"s298904790",
"s577767081"
] |
u948524308 | p02866 | python | s631088019 | s117010451 | 137 | 105 | 14,020 | 20,836 | Accepted | Accepted | 23.36 | N=int(eval(input()))
D=list(map(int,input().split()))
mod=998244353
if D[0]!=0:
print((0))
exit()
n=[0]*N
n[0]=1
for i in range(1,N):
if D[i]==0:
print((0))
exit()
n[D[i]]+=1
ans=1
cnt=n[0]+n[1]
for i in range(2,N):
if n[i]==0:
if cnt!=N:
... | N=int(eval(input()))
D=list(map(int,input().split()))
mod=998244353
if D[0]!=0:
print((0))
exit()
B=[0]*N
for d in D:
B[d]+=1
if B[0]!=1:
print((0))
exit()
ans=1
total=1
for i in range(1,N):
if B[i]==0:
if total!=N:
print((0))
exit()
... | 30 | 29 | 447 | 393 | N = int(eval(input()))
D = list(map(int, input().split()))
mod = 998244353
if D[0] != 0:
print((0))
exit()
n = [0] * N
n[0] = 1
for i in range(1, N):
if D[i] == 0:
print((0))
exit()
n[D[i]] += 1
ans = 1
cnt = n[0] + n[1]
for i in range(2, N):
if n[i] == 0:
if cnt != N:
... | N = int(eval(input()))
D = list(map(int, input().split()))
mod = 998244353
if D[0] != 0:
print((0))
exit()
B = [0] * N
for d in D:
B[d] += 1
if B[0] != 1:
print((0))
exit()
ans = 1
total = 1
for i in range(1, N):
if B[i] == 0:
if total != N:
print((0))
exit()
... | false | 3.333333 | [
"-n = [0] * N",
"-n[0] = 1",
"+B = [0] * N",
"+for d in D:",
"+ B[d] += 1",
"+if B[0] != 1:",
"+ print((0))",
"+ exit()",
"+ans = 1",
"+total = 1",
"- if D[i] == 0:",
"- print((0))",
"- exit()",
"- n[D[i]] += 1",
"-ans = 1",
"-cnt = n[0] + n[1]",
"-for i ... | false | 0.037362 | 0.037887 | 0.986124 | [
"s631088019",
"s117010451"
] |
u973840923 | p03208 | python | s322328254 | s132791287 | 249 | 226 | 7,384 | 11,956 | Accepted | Accepted | 9.24 | N,K = list(map(int,input().split()))
list = [int(eval(input())) for i in range(N)]
list.sort()
min_val = 10**9
for i in range(N-K+1):
min_val = min(min_val,list[i+K-1]-list[i])
print(min_val) | N,K = list(map(int,input().split()))
list = [int(eval(input())) for i in range(N)]
list.sort()
init = max(list) - min(list)
diff = [b-a for a,b in zip(list,list[K-1::])]
print((min(diff))) | 9 | 11 | 193 | 189 | N, K = list(map(int, input().split()))
list = [int(eval(input())) for i in range(N)]
list.sort()
min_val = 10**9
for i in range(N - K + 1):
min_val = min(min_val, list[i + K - 1] - list[i])
print(min_val)
| N, K = list(map(int, input().split()))
list = [int(eval(input())) for i in range(N)]
list.sort()
init = max(list) - min(list)
diff = [b - a for a, b in zip(list, list[K - 1 : :])]
print((min(diff)))
| false | 18.181818 | [
"-min_val = 10**9",
"-for i in range(N - K + 1):",
"- min_val = min(min_val, list[i + K - 1] - list[i])",
"-print(min_val)",
"+init = max(list) - min(list)",
"+diff = [b - a for a, b in zip(list, list[K - 1 : :])]",
"+print((min(diff)))"
] | false | 0.082626 | 0.038257 | 2.159796 | [
"s322328254",
"s132791287"
] |
u186974762 | p02768 | python | s707437791 | s098116472 | 198 | 67 | 12,488 | 3,064 | Accepted | Accepted | 66.16 | import numpy as np
N,a,b = np.array(input().split()).astype(int)
mod = 10**9+7
def power(x, n):
ans = 1
while(n > 0):
if(bin(n & 1) == bin(1)):
ans = ans*x%mod
x = (x*x)%mod
n = n >> 1 #ビットシフト
return ans
def fact(m, n):
val = 1
for i in range(m, n+1):... | N,a,b = [int(i) for i in input().split()]
mod = 10**9+7
def power(x, n):
ans = 1
while(n > 0):
if(bin(n & 1) == bin(1)):
ans = ans*x%mod
x = (x*x)%mod
n = n >> 1 #ビットシフト
return ans
def fact(m, n):
val = 1
for i in range(m, n+1):
val = val*i % ... | 35 | 34 | 770 | 746 | import numpy as np
N, a, b = np.array(input().split()).astype(int)
mod = 10**9 + 7
def power(x, n):
ans = 1
while n > 0:
if bin(n & 1) == bin(1):
ans = ans * x % mod
x = (x * x) % mod
n = n >> 1 # ビットシフト
return ans
def fact(m, n):
val = 1
for i in range(m, n... | N, a, b = [int(i) for i in input().split()]
mod = 10**9 + 7
def power(x, n):
ans = 1
while n > 0:
if bin(n & 1) == bin(1):
ans = ans * x % mod
x = (x * x) % mod
n = n >> 1 # ビットシフト
return ans
def fact(m, n):
val = 1
for i in range(m, n + 1):
val = val... | false | 2.857143 | [
"-import numpy as np",
"-",
"-N, a, b = np.array(input().split()).astype(int)",
"+N, a, b = [int(i) for i in input().split()]"
] | false | 0.250166 | 0.221707 | 1.128366 | [
"s707437791",
"s098116472"
] |
u387562669 | p03775 | python | s861632186 | s693678421 | 978 | 53 | 146,724 | 3,060 | Accepted | Accepted | 94.58 | import math
import operator
from itertools import *
from functools import *
def main():
#infile = open("compprog.txt", mode="r")
n = int(eval(input()))
res = -1
divisors_found = set()
for subset in powerset(prime_factors(n)):
div1 = prod(subset)
if div1 not in divisors... | import math
def main():
#infile = open("compprog.txt", mode="r")
n = int(eval(input()))
res = f(1, n)
i = 2
while i <= math.sqrt(n):
if n % i == 0:
this_f = f(i, n // i)
res = this_f if this_f < res else res
i += 1
print(res)
#infile.cl... | 58 | 23 | 1,270 | 424 | import math
import operator
from itertools import *
from functools import *
def main():
# infile = open("compprog.txt", mode="r")
n = int(eval(input()))
res = -1
divisors_found = set()
for subset in powerset(prime_factors(n)):
div1 = prod(subset)
if div1 not in divisors_found:
... | import math
def main():
# infile = open("compprog.txt", mode="r")
n = int(eval(input()))
res = f(1, n)
i = 2
while i <= math.sqrt(n):
if n % i == 0:
this_f = f(i, n // i)
res = this_f if this_f < res else res
i += 1
print(res)
# infile.close()
def ... | false | 60.344828 | [
"-import operator",
"-from itertools import *",
"-from functools import *",
"- res = -1",
"- divisors_found = set()",
"- for subset in powerset(prime_factors(n)):",
"- div1 = prod(subset)",
"- if div1 not in divisors_found:",
"- div2 = n // div1",
"- th... | false | 0.108897 | 0.044923 | 2.424055 | [
"s861632186",
"s693678421"
] |
u330661451 | p02779 | python | s140875615 | s959058990 | 98 | 90 | 36,660 | 26,812 | Accepted | Accepted | 8.16 | n = int(eval(input()))
s = set(map(int,input().split()))
ans = "YES" if n == len(s) else "NO"
print(ans)
| def main():
n = int(eval(input()))
a = list(map(int,input().split()))
s = set(a)
if n == len(s):
print("YES")
else:
print("NO")
if __name__ == '__main__':
main() | 4 | 11 | 102 | 206 | n = int(eval(input()))
s = set(map(int, input().split()))
ans = "YES" if n == len(s) else "NO"
print(ans)
| def main():
n = int(eval(input()))
a = list(map(int, input().split()))
s = set(a)
if n == len(s):
print("YES")
else:
print("NO")
if __name__ == "__main__":
main()
| false | 63.636364 | [
"-n = int(eval(input()))",
"-s = set(map(int, input().split()))",
"-ans = \"YES\" if n == len(s) else \"NO\"",
"-print(ans)",
"+def main():",
"+ n = int(eval(input()))",
"+ a = list(map(int, input().split()))",
"+ s = set(a)",
"+ if n == len(s):",
"+ print(\"YES\")",
"+ els... | false | 0.036453 | 0.037014 | 0.984857 | [
"s140875615",
"s959058990"
] |
u499381410 | p03722 | python | s853549276 | s931283775 | 335 | 193 | 45,532 | 84,144 | Accepted | Accepted | 42.39 | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from ma... | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from ma... | 70 | 70 | 1,936 | 1,939 | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import ... | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import ... | false | 0 | [
"- if n - 1 in v_nows:",
"- return \"inf\"",
"+ if u == n - 1:",
"+ return \"inf\""
] | false | 0.047319 | 0.007803 | 6.064113 | [
"s853549276",
"s931283775"
] |
u075304271 | p02796 | python | s817498535 | s585427007 | 639 | 464 | 38,300 | 27,952 | Accepted | Accepted | 27.39 | import numpy as np
import functools
import math
import scipy
import fractions
import itertools
def solve():
n = int(eval(input()))
x, l = [0]*n, [0]*n
for i in range(n):
x[i], l[i] = list(map(int, input().split()))
hoge = []
for i in range(n):
hoge.append([x[i]+l[i], x... | def solve():
n = int(eval(input()))
x, l = [0]*n, [0]*n
for i in range(n):
x[i], l[i] = list(map(int, input().split()))
hoge = []
for i in range(n):
hoge.append([x[i]+l[i], x[i]-l[i]])
hoge.sort()
t = -1000000000000000000000
ans = 0
for i in range(n):
... | 27 | 20 | 557 | 455 | import numpy as np
import functools
import math
import scipy
import fractions
import itertools
def solve():
n = int(eval(input()))
x, l = [0] * n, [0] * n
for i in range(n):
x[i], l[i] = list(map(int, input().split()))
hoge = []
for i in range(n):
hoge.append([x[i] + l[i], x[i] - l... | def solve():
n = int(eval(input()))
x, l = [0] * n, [0] * n
for i in range(n):
x[i], l[i] = list(map(int, input().split()))
hoge = []
for i in range(n):
hoge.append([x[i] + l[i], x[i] - l[i]])
hoge.sort()
t = -1000000000000000000000
ans = 0
for i in range(n):
... | false | 25.925926 | [
"-import numpy as np",
"-import functools",
"-import math",
"-import scipy",
"-import fractions",
"-import itertools",
"-",
"-"
] | false | 0.007076 | 0.037606 | 0.188159 | [
"s817498535",
"s585427007"
] |
u373047809 | p03393 | python | s391002308 | s394027347 | 40 | 26 | 4,596 | 3,892 | Accepted | Accepted | 35 | from string import*
from itertools import*
b = ascii_lowercase
s = eval(input())
if len(s) < 26:
print((s + sorted(set(b) - set(s))[0]))
else:
d = -[p*len(list(k)) for p, k in groupby([i < j for i, j in zip(s[-1::-1], s[-2::-1])])][0] - 2
print((-(d < -26) or s[:d] + sorted(set(s[d+1:]) - set(b[:ord... | from string import*;from itertools import*;b=ascii_lowercase;s=eval(input());t=s[::-1]
if len(s)<26:print((s +sorted(set(b)-set(s))[0]))
else:d=-[p*len(list(k))for p,k in groupby([i<j for i,j in zip(t,t[1:])])][0]-2;print((-(d<-26)or s[:d]+sorted(set(s[d+1:])-set(b[:ord(s[d])-97]))[0])) | 9 | 3 | 329 | 279 | from string import *
from itertools import *
b = ascii_lowercase
s = eval(input())
if len(s) < 26:
print((s + sorted(set(b) - set(s))[0]))
else:
d = (
-[
p * len(list(k))
for p, k in groupby([i < j for i, j in zip(s[-1::-1], s[-2::-1])])
][0]
- 2
)
print(... | from string import *
from itertools import *
b = ascii_lowercase
s = eval(input())
t = s[::-1]
if len(s) < 26:
print((s + sorted(set(b) - set(s))[0]))
else:
d = (
-[p * len(list(k)) for p, k in groupby([i < j for i, j in zip(t, t[1:])])][0]
- 2
)
print((-(d < -26) or s[:d] + sorted(set(... | false | 66.666667 | [
"+t = s[::-1]",
"- -[",
"- p * len(list(k))",
"- for p, k in groupby([i < j for i, j in zip(s[-1::-1], s[-2::-1])])",
"- ][0]",
"+ -[p * len(list(k)) for p, k in groupby([i < j for i, j in zip(t, t[1:])])][0]"
] | false | 0.0476 | 0.065492 | 0.726802 | [
"s391002308",
"s394027347"
] |
u268554510 | p02844 | python | s594023521 | s368230004 | 236 | 128 | 79,964 | 48,136 | Accepted | Accepted | 45.76 | N = int(eval(input()))
S = list(map(int,list(eval(input()))))
S_riv=S[::-1]
l_lis=[0]*N
r_lis=[0]*N
mat=([set([])for j in range(10)])
l_set=set([])
r_set=set([])
for i,s in enumerate(S):
l_lis[i]=l_set.copy()
l_set.add(s)
for i,s in enumerate(S_riv):
r_lis[i]=r_set.copy()
r_set.add(s)
r_li... | N = int(eval(input()))
S = list(map(int,list(eval(input()))))
S_riv=S[::-1]
l_lis=[0]*N
r_lis=[0]*N
mat=([0 for j in range(10)])
l_set=set([])
r_set=set([])
for i,s in enumerate(S):
l_lis[i]=l_set.copy()
l_set.add(s)
for i,s in enumerate(S_riv):
r_lis[i]=r_set.copy()
r_set.add(s)
r_lis.rev... | 23 | 24 | 430 | 442 | N = int(eval(input()))
S = list(map(int, list(eval(input()))))
S_riv = S[::-1]
l_lis = [0] * N
r_lis = [0] * N
mat = [set([]) for j in range(10)]
l_set = set([])
r_set = set([])
for i, s in enumerate(S):
l_lis[i] = l_set.copy()
l_set.add(s)
for i, s in enumerate(S_riv):
r_lis[i] = r_set.copy()
r_set.add... | N = int(eval(input()))
S = list(map(int, list(eval(input()))))
S_riv = S[::-1]
l_lis = [0] * N
r_lis = [0] * N
mat = [0 for j in range(10)]
l_set = set([])
r_set = set([])
for i, s in enumerate(S):
l_lis[i] = l_set.copy()
l_set.add(s)
for i, s in enumerate(S_riv):
r_lis[i] = r_set.copy()
r_set.add(s)
r_... | false | 4.166667 | [
"-mat = [set([]) for j in range(10)]",
"+mat = [0 for j in range(10)]",
"- ans += len(l_lis[i] - mat[s]) * len(r_lis[i])",
"- mat[s] = l_lis[i]",
"+ length = len(l_lis[i])",
"+ ans += (length - mat[s]) * len(r_lis[i])",
"+ mat[s] = length"
] | false | 0.037892 | 0.037832 | 1.001578 | [
"s594023521",
"s368230004"
] |
u312025627 | p02850 | python | s470896378 | s423111255 | 612 | 394 | 100,224 | 106,268 | Accepted | Accepted | 35.62 | def main():
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
N = int(readline())
R = [[int(i) for i in r.split()] for r in read().rstrip().split(b'\n')]
G = [[] for _ in range(N)]
edge = {}
ans_key = []
for a, b in R:
G[a-1].append(b-1)
... | def main():
N = int(eval(input()))
G = [[] for _ in range(N)]
edge = {}
edge_order = [0]*(N-1)
for i in range(N-1):
a, b = (int(i)-1 for i in input().split())
G[a].append(b)
G[b].append(a)
edge[a*N + b] = -1 # 辺(a,b)の色
edge_order[i] = a*N + b
#... | 49 | 55 | 1,263 | 1,395 | def main():
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
N = int(readline())
R = [[int(i) for i in r.split()] for r in read().rstrip().split(b"\n")]
G = [[] for _ in range(N)]
edge = {}
ans_key = []
for a, b in R:
G[a - 1].append(b - 1)
... | def main():
N = int(eval(input()))
G = [[] for _ in range(N)]
edge = {}
edge_order = [0] * (N - 1)
for i in range(N - 1):
a, b = (int(i) - 1 for i in input().split())
G[a].append(b)
G[b].append(a)
edge[a * N + b] = -1 # 辺(a,b)の色
edge_order[i] = a * N + b
... | false | 10.909091 | [
"- import sys",
"-",
"- readline = sys.stdin.buffer.readline",
"- read = sys.stdin.buffer.read",
"- N = int(readline())",
"- R = [[int(i) for i in r.split()] for r in read().rstrip().split(b\"\\n\")]",
"+ N = int(eval(input()))",
"- ans_key = []",
"- for a, b in R:",
"- ... | false | 0.035627 | 0.036448 | 0.977475 | [
"s470896378",
"s423111255"
] |
u780962115 | p03649 | python | s913201747 | s693660790 | 1,283 | 506 | 9,200 | 74,144 | Accepted | Accepted | 60.56 | N = int(eval(input()))
A = list(map(int, input().split()))
def is_possible(C):
res = 0
for x in A:
if x+C - N >= 0:
res += (x+ C - N)//(N+1) + 1
#print(res,C)
return int(res <= C)
l = 0 # impossible
r = 10**30 # possible
is_possible(1234567894848)
while r - l > 1:... | N = int(eval(input()))
A = list(map(int, input().split()))
def is_possible(C):
res = 0
for x in A:
if x+C - N >= 0:
res += (x+ C - N)//(N+1) + 1
#print(res,C)
return int(res <= C)
l = 0 # impossible
r = 10**30 # possible
while r - l > 1:
M = (l+r)//2
if... | 25 | 25 | 491 | 465 | N = int(eval(input()))
A = list(map(int, input().split()))
def is_possible(C):
res = 0
for x in A:
if x + C - N >= 0:
res += (x + C - N) // (N + 1) + 1
# print(res,C)
return int(res <= C)
l = 0 # impossible
r = 10**30 # possible
is_possible(1234567894848)
while r - l > 1:
M... | N = int(eval(input()))
A = list(map(int, input().split()))
def is_possible(C):
res = 0
for x in A:
if x + C - N >= 0:
res += (x + C - N) // (N + 1) + 1
# print(res,C)
return int(res <= C)
l = 0 # impossible
r = 10**30 # possible
while r - l > 1:
M = (l + r) // 2
if is_p... | false | 0 | [
"-is_possible(1234567894848)"
] | false | 0.425776 | 0.635031 | 0.67048 | [
"s913201747",
"s693660790"
] |
u644907318 | p03077 | python | s057523411 | s931681769 | 184 | 167 | 38,384 | 38,256 | Accepted | Accepted | 9.24 | N = int(eval(input()))
A = [int(eval(input())) for _ in range(5)]
a = min(A)
n=N//a
if N%a>0:
n += 1
print((5+n-1)) | N = int(eval(input()))
A = [int(eval(input())) for _ in range(5)]
a = min(A)
n = N//a
k = N%a
ans = 0
if n>0:
ans = 5+(n-1)
if k>0:
ans += 1
else:
if k>0:
ans = 5
print(ans) | 7 | 14 | 111 | 202 | N = int(eval(input()))
A = [int(eval(input())) for _ in range(5)]
a = min(A)
n = N // a
if N % a > 0:
n += 1
print((5 + n - 1))
| N = int(eval(input()))
A = [int(eval(input())) for _ in range(5)]
a = min(A)
n = N // a
k = N % a
ans = 0
if n > 0:
ans = 5 + (n - 1)
if k > 0:
ans += 1
else:
if k > 0:
ans = 5
print(ans)
| false | 50 | [
"-if N % a > 0:",
"- n += 1",
"-print((5 + n - 1))",
"+k = N % a",
"+ans = 0",
"+if n > 0:",
"+ ans = 5 + (n - 1)",
"+ if k > 0:",
"+ ans += 1",
"+else:",
"+ if k > 0:",
"+ ans = 5",
"+print(ans)"
] | false | 0.110515 | 0.037046 | 2.983188 | [
"s057523411",
"s931681769"
] |
u227082700 | p03112 | python | s814854239 | s544174276 | 1,880 | 1,733 | 14,096 | 12,804 | Accepted | Accepted | 7.82 | from bisect import bisect_left,bisect_right
a,b,q=list(map(int,input().split()))
INF=float("inf")
s=[-INF]+[int(eval(input()))for i in range(a)]+[INF]
t=[-INF]+[int(eval(input()))for i in range(b)]+[INF]
for _ in range(q):
x=int(eval(input()))
b,c=bisect_right(s,x),bisect_right(t,x)
a=INF
for i in [s[b... | from bisect import bisect_left,bisect_right
a,b,q=list(map(int,input().split()))
s=[-(10**21)]+[int(eval(input()))for _ in range(a)]+[10**21]
t=[-(10**21)]+[int(eval(input()))for _ in range(b)]+[10**21]
for _ in range(q):
x=int(eval(input()))
s1,s2=s[bisect_right(s,x)-1],s[bisect_right(s,x)]
t1,t2=t[bisect... | 13 | 13 | 399 | 455 | from bisect import bisect_left, bisect_right
a, b, q = list(map(int, input().split()))
INF = float("inf")
s = [-INF] + [int(eval(input())) for i in range(a)] + [INF]
t = [-INF] + [int(eval(input())) for i in range(b)] + [INF]
for _ in range(q):
x = int(eval(input()))
b, c = bisect_right(s, x), bisect_right(t, ... | from bisect import bisect_left, bisect_right
a, b, q = list(map(int, input().split()))
s = [-(10**21)] + [int(eval(input())) for _ in range(a)] + [10**21]
t = [-(10**21)] + [int(eval(input())) for _ in range(b)] + [10**21]
for _ in range(q):
x = int(eval(input()))
s1, s2 = s[bisect_right(s, x) - 1], s[bisect_r... | false | 0 | [
"-INF = float(\"inf\")",
"-s = [-INF] + [int(eval(input())) for i in range(a)] + [INF]",
"-t = [-INF] + [int(eval(input())) for i in range(b)] + [INF]",
"+s = [-(10**21)] + [int(eval(input())) for _ in range(a)] + [10**21]",
"+t = [-(10**21)] + [int(eval(input())) for _ in range(b)] + [10**21]",
"- b, ... | false | 0.051306 | 0.037762 | 1.358676 | [
"s814854239",
"s544174276"
] |
u608088992 | p03112 | python | s179823187 | s085122410 | 636 | 572 | 12,220 | 23,488 | Accepted | Accepted | 10.06 | import sys
from bisect import bisect_left
def solve():
input = sys.stdin.readline
A, B, Q = list(map(int, input().split()))
S = [int(eval(input())) for _ in range(A)]
T = [int(eval(input())) for _ in range(B)]
for _ in range(Q):
x = int(eval(input()))
si = bisect_left(S, x... | import sys
from bisect import bisect_left
def solve():
input = sys.stdin.readline
A, B, Q = list(map(int, input().split()))
S = [int(eval(input())) for _ in range(A)]
T = [int(eval(input())) for _ in range(B)]
Ans = [0] * Q
for i in range(Q):
x = int(eval(input()))
si... | 28 | 24 | 943 | 911 | import sys
from bisect import bisect_left
def solve():
input = sys.stdin.readline
A, B, Q = list(map(int, input().split()))
S = [int(eval(input())) for _ in range(A)]
T = [int(eval(input())) for _ in range(B)]
for _ in range(Q):
x = int(eval(input()))
si = bisect_left(S, x)
... | import sys
from bisect import bisect_left
def solve():
input = sys.stdin.readline
A, B, Q = list(map(int, input().split()))
S = [int(eval(input())) for _ in range(A)]
T = [int(eval(input())) for _ in range(B)]
Ans = [0] * Q
for i in range(Q):
x = int(eval(input()))
si, ti = bis... | false | 14.285714 | [
"- for _ in range(Q):",
"+ Ans = [0] * Q",
"+ for i in range(Q):",
"- si = bisect_left(S, x)",
"- ti = bisect_left(T, x)",
"- minLength = 10**20",
"- both_left = 10**20",
"- both_right = 10**20",
"- s_t = 10**20",
"- t_s = 10**20",
"+ ... | false | 0.093388 | 0.079599 | 1.173221 | [
"s179823187",
"s085122410"
] |
u813125722 | p02772 | python | s007331163 | s797056951 | 22 | 17 | 3,064 | 2,940 | Accepted | Accepted | 22.73 | N = int(eval(input()))#.split()
A = input().split()
den = False
for i in range(N):
if int(A[i]) % 2 == 0:
if int(A[i]) % 3 != 0 and int(A[i]) % 5 != 0:
print("DENIED")
exit(0)
den = True
if not den:
print("APPROVED")
| N = int(eval(input()))
A = input().split()
for i in range(N):
if int(A[i])%2==0:
if int(A[i])%3!=0 and int(A[i])%5!=0:
print("DENIED")
exit(0)
print("APPROVED")
| 11 | 11 | 273 | 204 | N = int(eval(input())) # .split()
A = input().split()
den = False
for i in range(N):
if int(A[i]) % 2 == 0:
if int(A[i]) % 3 != 0 and int(A[i]) % 5 != 0:
print("DENIED")
exit(0)
den = True
if not den:
print("APPROVED")
| N = int(eval(input()))
A = input().split()
for i in range(N):
if int(A[i]) % 2 == 0:
if int(A[i]) % 3 != 0 and int(A[i]) % 5 != 0:
print("DENIED")
exit(0)
print("APPROVED")
| false | 0 | [
"-N = int(eval(input())) # .split()",
"+N = int(eval(input()))",
"-den = False",
"- den = True",
"-if not den:",
"- print(\"APPROVED\")",
"+print(\"APPROVED\")"
] | false | 0.099703 | 0.048147 | 2.07081 | [
"s007331163",
"s797056951"
] |
u706695185 | p04013 | python | s786525837 | s820461247 | 414 | 306 | 94,684 | 94,556 | Accepted | Accepted | 26.09 | N,A=list(map(int, input().split()))
x=list(map(int, input().split()))
dp = [[[0]*(51*51) for _ in range(N+1)] for _ in range(N+1)]
# dp[j][k][s]
for j in range(N+1):
for k in range(N+1):
for s in range(51*51):
if j==0 and k==0 and s==0:
dp[j][k][s] = 1
elif j... | N,A=list(map(int, input().split()))
x=list(map(int, input().split()))
dp = [[[0]*(51*51) for _ in range(N+1)] for _ in range(N+1)]
# dp[j][k][s]
for j in range(N+1):
for k in range(j+1):
for s in range(51*51):
if j==0 and k==0 and s==0:
dp[j][k][s] = 1
elif j... | 20 | 20 | 624 | 624 | N, A = list(map(int, input().split()))
x = list(map(int, input().split()))
dp = [[[0] * (51 * 51) for _ in range(N + 1)] for _ in range(N + 1)]
# dp[j][k][s]
for j in range(N + 1):
for k in range(N + 1):
for s in range(51 * 51):
if j == 0 and k == 0 and s == 0:
dp[j][k][s] = 1
... | N, A = list(map(int, input().split()))
x = list(map(int, input().split()))
dp = [[[0] * (51 * 51) for _ in range(N + 1)] for _ in range(N + 1)]
# dp[j][k][s]
for j in range(N + 1):
for k in range(j + 1):
for s in range(51 * 51):
if j == 0 and k == 0 and s == 0:
dp[j][k][s] = 1
... | false | 0 | [
"- for k in range(N + 1):",
"+ for k in range(j + 1):"
] | false | 0.100165 | 0.173851 | 0.576153 | [
"s786525837",
"s820461247"
] |
u816587940 | p02713 | python | s823300449 | s058357926 | 1,811 | 837 | 9,176 | 111,960 | Accepted | Accepted | 53.78 | from math import gcd
k=int(eval(input()))
ans=0
for a in range(1,k+1):
for b in range(1,k+1):
for c in range(1,k+1):
ans+=gcd(gcd(a,b),c)
print(ans)
| from math import gcd
from numba import jit
@jit
def calc():
k=int(eval(input()))
ans=0
for a in range(1,k+1):
for b in range(1,k+1):
d=gcd(a,b)
for c in range(1,k+1):
ans+=gcd(d,c)
print(ans)
calc() | 8 | 14 | 162 | 239 | from math import gcd
k = int(eval(input()))
ans = 0
for a in range(1, k + 1):
for b in range(1, k + 1):
for c in range(1, k + 1):
ans += gcd(gcd(a, b), c)
print(ans)
| from math import gcd
from numba import jit
@jit
def calc():
k = int(eval(input()))
ans = 0
for a in range(1, k + 1):
for b in range(1, k + 1):
d = gcd(a, b)
for c in range(1, k + 1):
ans += gcd(d, c)
print(ans)
calc()
| false | 42.857143 | [
"+from numba import jit",
"-k = int(eval(input()))",
"-ans = 0",
"-for a in range(1, k + 1):",
"- for b in range(1, k + 1):",
"- for c in range(1, k + 1):",
"- ans += gcd(gcd(a, b), c)",
"-print(ans)",
"+",
"+@jit",
"+def calc():",
"+ k = int(eval(input()))",
"+ an... | false | 0.042121 | 0.037277 | 1.129946 | [
"s823300449",
"s058357926"
] |
u754022296 | p02838 | python | s594663136 | s996699102 | 664 | 333 | 122,808 | 48,840 | Accepted | Accepted | 49.85 | n = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for j in range(61):
c = 0
for i in A:
if i>>j & 1:
c += 1
ans += 2**j*((n-c)*c)
print((ans%(10**9+7))) | import numpy as np
MOD = 10 ** 9 + 7
N = int(eval(input()))
A = np.array(list(map(int, input().split())),np.int64)
answer = 0
for n in range(63):
B = (A >> n) & 1
x = np.count_nonzero(B)
y = N - x
x *= y
for _ in range(n):
x *= 2
x %= MOD
answer += x
answer... | 10 | 19 | 186 | 336 | n = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for j in range(61):
c = 0
for i in A:
if i >> j & 1:
c += 1
ans += 2**j * ((n - c) * c)
print((ans % (10**9 + 7)))
| import numpy as np
MOD = 10**9 + 7
N = int(eval(input()))
A = np.array(list(map(int, input().split())), np.int64)
answer = 0
for n in range(63):
B = (A >> n) & 1
x = np.count_nonzero(B)
y = N - x
x *= y
for _ in range(n):
x *= 2
x %= MOD
answer += x
answer %= MOD
print(answer)
| false | 47.368421 | [
"-n = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-ans = 0",
"-for j in range(61):",
"- c = 0",
"- for i in A:",
"- if i >> j & 1:",
"- c += 1",
"- ans += 2**j * ((n - c) * c)",
"-print((ans % (10**9 + 7)))",
"+import numpy as np",
"+",
"+MOD = 10... | false | 0.042487 | 0.216778 | 0.195993 | [
"s594663136",
"s996699102"
] |
u457901067 | p02642 | python | s010507661 | s564611692 | 1,432 | 605 | 39,340 | 33,164 | Accepted | Accepted | 57.75 | import sys
import numpy as np
#from numba import njit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
#@njit('(i4[::1],)', cache=True)
def solve(A):
count = np.zeros(10**6 + 10, np.int32)
for x in A:
if count[x] > 1:
c... | #maspyさんを参考に
import sys
#import numpy as np
#from numba import njit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# この最適化がよくわからん。Numpyループなら行けるらしい
# 400msくらいは最低でもかかるけど、N=10^5でも2でも変わらんと言う
#@njit('(i4[::1],)', cache=True)
def solve(A):
# エラトステネス古... | 23 | 44 | 494 | 1,053 | import sys
import numpy as np
# from numba import njit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# @njit('(i4[::1],)', cache=True)
def solve(A):
count = np.zeros(10**6 + 10, np.int32)
for x in A:
if count[x] > 1:
continue
... | # maspyさんを参考に
import sys
# import numpy as np
# from numba import njit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# この最適化がよくわからん。Numpyループなら行けるらしい
# 400msくらいは最低でもかかるけど、N=10^5でも2でも変わらんと言う
# @njit('(i4[::1],)', cache=True)
def solve(A):
# エラトステネス古いって値側のバリエ... | false | 47.727273 | [
"+# maspyさんを参考に",
"-import numpy as np",
"+# import numpy as np",
"+# この最適化がよくわからん。Numpyループなら行けるらしい",
"+# 400msくらいは最低でもかかるけど、N=10^5でも2でも変わらんと言う",
"+ # エラトステネス古いって値側のバリエーションとして配列をとるんや",
"+ # maxA = 10**6って言うのがポイントっぽいなあ。。",
"-A = np.array(read().split(), np.int32)[1:]",
"-print((solve(A)))",
"... | false | 0.514634 | 0.419847 | 1.225765 | [
"s010507661",
"s564611692"
] |
u590241855 | p02554 | python | s594855744 | s515571672 | 498 | 386 | 9,176 | 10,884 | Accepted | Accepted | 22.49 | n = int(eval(input()))
mod = int(1e9+7)
have_any = 1
not_have_0 = 1
not_have_9 = 1
not_have_09 = 1
for _ in range(n):
have_any *= 10
have_any %= mod
not_have_0 *= 9
not_have_0 %= mod
not_have_09 *= 8
not_have_09 %= mod
not_have_9 = not_have_0
ans = have_any - not_have... | n = int(eval(input()))
mod = 10**9 + 7
ans = 10**n - 9**n * 2 + 8**n
ans %= mod
print(ans)
| 24 | 8 | 368 | 95 | n = int(eval(input()))
mod = int(1e9 + 7)
have_any = 1
not_have_0 = 1
not_have_9 = 1
not_have_09 = 1
for _ in range(n):
have_any *= 10
have_any %= mod
not_have_0 *= 9
not_have_0 %= mod
not_have_09 *= 8
not_have_09 %= mod
not_have_9 = not_have_0
ans = have_any - not_have_0 - not_have_9 + not_have... | n = int(eval(input()))
mod = 10**9 + 7
ans = 10**n - 9**n * 2 + 8**n
ans %= mod
print(ans)
| false | 66.666667 | [
"-mod = int(1e9 + 7)",
"-have_any = 1",
"-not_have_0 = 1",
"-not_have_9 = 1",
"-not_have_09 = 1",
"-for _ in range(n):",
"- have_any *= 10",
"- have_any %= mod",
"- not_have_0 *= 9",
"- not_have_0 %= mod",
"- not_have_09 *= 8",
"- not_have_09 %= mod",
"-not_have_9 = not_hav... | false | 0.204626 | 0.144936 | 1.411837 | [
"s594855744",
"s515571672"
] |
u784022244 | p03786 | python | s586921845 | s249362240 | 432 | 116 | 23,116 | 86,024 | Accepted | Accepted | 73.15 | import numpy as np
N=int(eval(input()))
A=list(map(int, input().split()))
A=sorted(A, reverse=True)
#print(now) #普通に全部食える
cum=np.cumsum(A[::-1])[::-1]
adds=[-1]*(N)
adds[0]=cum[0]
for i in range(1,N):
if cum[i]*2>=A[i-1]:
adds[i]=adds[i-1]
else:
adds[i]=cum[i]
#print(A)
#pr... | N=int(eval(input()))
A=list(map(int, input().split()))
A=sorted(A)
ans=1
now=A[0]
sums=A[0]
for i in range(N-1):
if 2*sums>=A[i+1]:
ans+=1
#now+=A[i+1]
else:
ans=1
#now=A[i+1]
sums+=A[i+1]
print(ans) | 24 | 17 | 397 | 255 | import numpy as np
N = int(eval(input()))
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
# print(now) #普通に全部食える
cum = np.cumsum(A[::-1])[::-1]
adds = [-1] * (N)
adds[0] = cum[0]
for i in range(1, N):
if cum[i] * 2 >= A[i - 1]:
adds[i] = adds[i - 1]
else:
adds[i] = cum[i]
# prin... | N = int(eval(input()))
A = list(map(int, input().split()))
A = sorted(A)
ans = 1
now = A[0]
sums = A[0]
for i in range(N - 1):
if 2 * sums >= A[i + 1]:
ans += 1
# now+=A[i+1]
else:
ans = 1
# now=A[i+1]
sums += A[i + 1]
print(ans)
| false | 29.166667 | [
"-import numpy as np",
"-",
"-A = sorted(A, reverse=True)",
"-# print(now) #普通に全部食える",
"-cum = np.cumsum(A[::-1])[::-1]",
"-adds = [-1] * (N)",
"-adds[0] = cum[0]",
"-for i in range(1, N):",
"- if cum[i] * 2 >= A[i - 1]:",
"- adds[i] = adds[i - 1]",
"+A = sorted(A)",
"+ans = 1",
"+... | false | 0.82749 | 0.057172 | 14.473816 | [
"s586921845",
"s249362240"
] |
u186838327 | p04020 | python | s371517552 | s700993614 | 510 | 177 | 49,752 | 9,176 | Accepted | Accepted | 65.29 | n = int(eval(input()))
A = [int(eval(input())) for _ in range(n)]
ans = 0
temp = 0
for i in range(n):
ans += (A[i]+temp)//2
if A[i] != 0:
temp = (A[i]+temp)%2
else:
temp = 0
print(ans) | n = int(eval(input()))
temp = 0
ans = 0
for i in range(n):
a = int(eval(input()))
if a != 0:
q, r = divmod(a+temp, 2)
ans += q
temp = r
else:
temp = 0
print(ans)
| 11 | 12 | 210 | 205 | n = int(eval(input()))
A = [int(eval(input())) for _ in range(n)]
ans = 0
temp = 0
for i in range(n):
ans += (A[i] + temp) // 2
if A[i] != 0:
temp = (A[i] + temp) % 2
else:
temp = 0
print(ans)
| n = int(eval(input()))
temp = 0
ans = 0
for i in range(n):
a = int(eval(input()))
if a != 0:
q, r = divmod(a + temp, 2)
ans += q
temp = r
else:
temp = 0
print(ans)
| false | 8.333333 | [
"-A = [int(eval(input())) for _ in range(n)]",
"+temp = 0",
"-temp = 0",
"- ans += (A[i] + temp) // 2",
"- if A[i] != 0:",
"- temp = (A[i] + temp) % 2",
"+ a = int(eval(input()))",
"+ if a != 0:",
"+ q, r = divmod(a + temp, 2)",
"+ ans += q",
"+ temp = r"
... | false | 0.034461 | 0.036633 | 0.94069 | [
"s371517552",
"s700993614"
] |
u491550356 | p02678 | python | s920334869 | s913219443 | 703 | 528 | 65,008 | 65,008 | Accepted | Accepted | 24.89 | N, M = map(int, input().split())
AB = [tuple(map(int,input().split())) for i in range(M)]
es = [[] for _ in range(N)]
for a, b in AB:
es[a-1].append(b-1)
es[b-1].append(a-1)
ans = [-1] * N
ans[0] = 0
from collections import deque
que = deque([])
que.append(0)
while que:
s = que.popleft... | import sys
input = sys.stdin.readline
N, M = map(int, input().split())
AB = [tuple(map(int,input().split())) for i in range(M)]
es = [[] for _ in range(N)]
for a, b in AB:
es[a-1].append(b-1)
es[b-1].append(a-1)
ans = [-1] * N
ans[0] = 0
from collections import deque
que = deque([])
que.ap... | 25 | 28 | 465 | 507 | N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(M)]
es = [[] for _ in range(N)]
for a, b in AB:
es[a - 1].append(b - 1)
es[b - 1].append(a - 1)
ans = [-1] * N
ans[0] = 0
from collections import deque
que = deque([])
que.append(0)
while que:
s = que.popleft()
for v... | import sys
input = sys.stdin.readline
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(M)]
es = [[] for _ in range(N)]
for a, b in AB:
es[a - 1].append(b - 1)
es[b - 1].append(a - 1)
ans = [-1] * N
ans[0] = 0
from collections import deque
que = deque([])
que.append(0)
whi... | false | 10.714286 | [
"+import sys",
"+",
"+input = sys.stdin.readline"
] | false | 0.040675 | 0.0367 | 1.108335 | [
"s920334869",
"s913219443"
] |
u576432509 | p03031 | python | s671691816 | s074220557 | 53 | 45 | 3,064 | 3,064 | Accepted | Accepted | 15.09 | def fbit(k,n):
t=[]
kk=k
for i in range(n):
t.append(kk%2)
kk=int(kk/2)
return t
n,m=list(map(int,input().split()))
s=[]
for i in range(m):
si=[]
for j in range(n):
si.append(0)
s.append(si)
for j in range(m):
str=input().split()
... |
import itertools
n,m=list(map(int,input().split()))
ks=[]
for i in range(m):
ksi=list(map(int,input().split()))
ks.append(ksi)
p=list(map(int,input().split()))
icnt=0
for i in itertools.product([0,1], repeat=n):
yn=""
mcnt=0
for j in range(m):
ksum=0
for k in r... | 41 | 25 | 774 | 510 | def fbit(k, n):
t = []
kk = k
for i in range(n):
t.append(kk % 2)
kk = int(kk / 2)
return t
n, m = list(map(int, input().split()))
s = []
for i in range(m):
si = []
for j in range(n):
si.append(0)
s.append(si)
for j in range(m):
str = input().split()
k_m = i... | import itertools
n, m = list(map(int, input().split()))
ks = []
for i in range(m):
ksi = list(map(int, input().split()))
ks.append(ksi)
p = list(map(int, input().split()))
icnt = 0
for i in itertools.product([0, 1], repeat=n):
yn = ""
mcnt = 0
for j in range(m):
ksum = 0
for k in ra... | false | 39.02439 | [
"-def fbit(k, n):",
"- t = []",
"- kk = k",
"- for i in range(n):",
"- t.append(kk % 2)",
"- kk = int(kk / 2)",
"- return t",
"-",
"+import itertools",
"-s = []",
"+ks = []",
"- si = []",
"- for j in range(n):",
"- si.append(0)",
"- s.append(si)"... | false | 0.048679 | 0.041838 | 1.16351 | [
"s671691816",
"s074220557"
] |
u813102292 | p03212 | python | s027210062 | s440798496 | 481 | 222 | 67,032 | 43,752 | Accepted | Accepted | 53.85 | N = int(eval(input()))
M = len(str(N))
def nsin(X,n):
if(int(X/n)):
return nsin(int(X/n),n)+str(X%n)
return str(X%n)
res = 0
for m in range(3,M+1):
for i in range(3 ** m):
tri = nsin(i, 3).zfill(m)
nl = []
if tri.count('0') > 0 and tri.count('1') > 0 and tri.co... | N = int(eval(input()))
M = len(str(N))
res = [0]
def dfs(x):
# 長さがMになったら終了
if len(x) > M:
return
if x.count('3') > 0 and x.count('5') > 0 and x.count('7') > 0 and int(x) <= N:
res[0] += 1
dfs(x + '3')
dfs(x + '5')
dfs(x + '7')
return
dfs('3')
dfs('5')
dfs('7'... | 26 | 19 | 661 | 340 | N = int(eval(input()))
M = len(str(N))
def nsin(X, n):
if int(X / n):
return nsin(int(X / n), n) + str(X % n)
return str(X % n)
res = 0
for m in range(3, M + 1):
for i in range(3**m):
tri = nsin(i, 3).zfill(m)
nl = []
if tri.count("0") > 0 and tri.count("1") > 0 and tri.c... | N = int(eval(input()))
M = len(str(N))
res = [0]
def dfs(x):
# 長さがMになったら終了
if len(x) > M:
return
if x.count("3") > 0 and x.count("5") > 0 and x.count("7") > 0 and int(x) <= N:
res[0] += 1
dfs(x + "3")
dfs(x + "5")
dfs(x + "7")
return
dfs("3")
dfs("5")
dfs("7")
print((res[... | false | 26.923077 | [
"+res = [0]",
"-def nsin(X, n):",
"- if int(X / n):",
"- return nsin(int(X / n), n) + str(X % n)",
"- return str(X % n)",
"+def dfs(x):",
"+ # 長さがMになったら終了",
"+ if len(x) > M:",
"+ return",
"+ if x.count(\"3\") > 0 and x.count(\"5\") > 0 and x.count(\"7\") > 0 and int(x... | false | 0.145636 | 0.049748 | 2.927459 | [
"s027210062",
"s440798496"
] |
u875291233 | p02868 | python | s203229277 | s986726874 | 1,025 | 881 | 79,708 | 78,044 | Accepted | Accepted | 14.05 | """
双対セグ木
アクセスは0-indexed, 内部のツリーは 1-indexed
つまりすべての和は tree[0]
関数は閉区間
作用素は右から作用とする
引数:
N: 処理する区間の長さ
compose: 作用素を合成させる関数 (max, min, __add__,ラムダ式,関数定義など)
UNIT: 恒等作用素
funcval(x,f) = f(x)
"""
class segment_tree:
def __init__(self, N, compose, funcval, UNIT=None):
self.compose =... | """
双対セグ木
アクセスは0-indexed, 内部のツリーは 1-indexed
つまりすべての和は tree[0]
関数は閉区間
作用素は右から作用とする
引数:
N: 処理する区間の長さ
compose: 作用素を合成させる関数 (max, min, __add__,ラムダ式,関数定義など)
UNIT: 恒等作用素
funcval(x,f) = f(x)
"""
class segment_tree:
def __init__(self, N, compose, funcval, UNIT=None):
self.compose =... | 114 | 114 | 2,776 | 2,778 | """
双対セグ木
アクセスは0-indexed, 内部のツリーは 1-indexed
つまりすべての和は tree[0]
関数は閉区間
作用素は右から作用とする
引数:
N: 処理する区間の長さ
compose: 作用素を合成させる関数 (max, min, __add__,ラムダ式,関数定義など)
UNIT: 恒等作用素
funcval(x,f) = f(x)
"""
class segment_tree:
def __init__(self, N, compose, funcval, UNIT=None):
self.compose = compose
... | """
双対セグ木
アクセスは0-indexed, 内部のツリーは 1-indexed
つまりすべての和は tree[0]
関数は閉区間
作用素は右から作用とする
引数:
N: 処理する区間の長さ
compose: 作用素を合成させる関数 (max, min, __add__,ラムダ式,関数定義など)
UNIT: 恒等作用素
funcval(x,f) = f(x)
"""
class segment_tree:
def __init__(self, N, compose, funcval, UNIT=None):
self.compose = compose
... | false | 0 | [
"- self.thrust(L)",
"- self.thrust(R - 1)",
"+ # self.thrust(L)",
"+ # self.thrust(R-1)"
] | false | 0.124304 | 0.112283 | 1.107063 | [
"s203229277",
"s986726874"
] |
u181215519 | p03834 | python | s249213332 | s756250899 | 21 | 17 | 2,940 | 2,940 | Accepted | Accepted | 19.05 | s = list( map( str, input().split(",") ) )
print(( s[0] + " " + s[1] + " " + s[2] )) | print(( input().replace( ",", " " ) )) | 2 | 1 | 84 | 36 | s = list(map(str, input().split(",")))
print((s[0] + " " + s[1] + " " + s[2]))
| print((input().replace(",", " ")))
| false | 50 | [
"-s = list(map(str, input().split(\",\")))",
"-print((s[0] + \" \" + s[1] + \" \" + s[2]))",
"+print((input().replace(\",\", \" \")))"
] | false | 0.066675 | 0.087713 | 0.760153 | [
"s249213332",
"s756250899"
] |
u207241407 | p03200 | python | s380428949 | s671556453 | 112 | 33 | 5,096 | 3,500 | Accepted | Accepted | 70.54 | import sys
s = [x for x in sys.stdin.readline().rstrip()]
black = float("inf")
ans = 0
for i in range(len(s)):
if s[i] == "B" and black > i:
black = i
elif s[i] == "W" and black != float("inf"):
ans += i - black
black += 1
print(ans) | import sys
def main():
s = sys.stdin.readline().rstrip()
black = 0
ans = 0
for i in s:
if i == "B":
black = black + 1
else:
ans = ans + black
print(ans)
return
if __name__ == "__main__":
main() | 15 | 22 | 283 | 290 | import sys
s = [x for x in sys.stdin.readline().rstrip()]
black = float("inf")
ans = 0
for i in range(len(s)):
if s[i] == "B" and black > i:
black = i
elif s[i] == "W" and black != float("inf"):
ans += i - black
black += 1
print(ans)
| import sys
def main():
s = sys.stdin.readline().rstrip()
black = 0
ans = 0
for i in s:
if i == "B":
black = black + 1
else:
ans = ans + black
print(ans)
return
if __name__ == "__main__":
main()
| false | 31.818182 | [
"-s = [x for x in sys.stdin.readline().rstrip()]",
"-black = float(\"inf\")",
"-ans = 0",
"-for i in range(len(s)):",
"- if s[i] == \"B\" and black > i:",
"- black = i",
"- elif s[i] == \"W\" and black != float(\"inf\"):",
"- ans += i - black",
"- black += 1",
"-print(an... | false | 0.037861 | 0.03696 | 1.024359 | [
"s380428949",
"s671556453"
] |
u588341295 | p02948 | python | s321799252 | s040604168 | 1,215 | 407 | 105,772 | 24,796 | Accepted | Accepted | 66.5 | # -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): r... | # -*- coding: utf-8 -*-
import sys
from heapq import heappush, heappop
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): re... | 122 | 40 | 3,446 | 1,002 | # -*- coding: utf-8 -*-
import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1):
return int(-(-x // y))
def INT():
return int(eval(inp... | # -*- coding: utf-8 -*-
import sys
from heapq import heappush, heappop
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1):
return int(-(-x // y))
... | false | 67.213115 | [
"+from heapq import heappush, heappop",
"-",
"-",
"-class SegTreeIndex:",
"- \"\"\"",
"- 以下のクエリを処理する",
"- 1.update: i番目の値をxに更新する",
"- 2.get_val: 区間[l, r)の値とindex(同値があった場合は一番左)を得る",
"- \"\"\"",
"-",
"- def __init__(self, n, func, init):",
"- \"\"\"",
"- :param... | false | 0.340027 | 0.187858 | 1.810016 | [
"s321799252",
"s040604168"
] |
u323680411 | p04045 | python | s943728726 | s788603791 | 337 | 45 | 2,940 | 2,940 | Accepted | Accepted | 86.65 | N, K = list(map(int, input().split()))
D = list(map(int, input().split()))
n = N
while True:
flg = False
for Di in D:
if str(Di) in str(n):
flg = True
if not flg:
break
n += 1
print(n) | N, K = list(map(int, input().split()))
D = list(map(int, input().split()))
n = N
while True:
i = n
while i != 0:
if i % 10 in D:
break
i = i // 10
if i == 0:
break
n += 1
print(n) | 15 | 16 | 239 | 243 | N, K = list(map(int, input().split()))
D = list(map(int, input().split()))
n = N
while True:
flg = False
for Di in D:
if str(Di) in str(n):
flg = True
if not flg:
break
n += 1
print(n)
| N, K = list(map(int, input().split()))
D = list(map(int, input().split()))
n = N
while True:
i = n
while i != 0:
if i % 10 in D:
break
i = i // 10
if i == 0:
break
n += 1
print(n)
| false | 6.25 | [
"- flg = False",
"- for Di in D:",
"- if str(Di) in str(n):",
"- flg = True",
"- if not flg:",
"+ i = n",
"+ while i != 0:",
"+ if i % 10 in D:",
"+ break",
"+ i = i // 10",
"+ if i == 0:"
] | false | 0.15259 | 0.039526 | 3.860455 | [
"s943728726",
"s788603791"
] |
u580273604 | p02695 | python | s342527382 | s558770443 | 1,309 | 1,116 | 25,496 | 12,516 | Accepted | Accepted | 14.74 | import itertools
from operator import mul
from functools import reduce
def combinations_count(n, r):
r = min(r, n - r)
numer = reduce(mul, list(range(n, n - r, -1)), 1)
denom = reduce(mul, list(range(1, r + 1)), 1)
return numer // denom
N,M,Q=list(map(int,input().split()))
a=[0]*Q;b=[0]*Q... | import itertools
N,M,Q=list(map(int,input().split()))
a=[0]*Q;b=[0]*Q;c=[0]*Q;d=[0]*Q
for i in range(Q):
a[i],b[i],c[i],d[i]=list(map(int,input().split()))
l=list(range(1,M+1))
i=0;D=[]
for v in itertools.combinations_with_replacement(l, N):
D.append(0)
for j in range(Q):
if v[b[j]-1]-v[a[j]-1]==c... | 31 | 15 | 680 | 348 | import itertools
from operator import mul
from functools import reduce
def combinations_count(n, r):
r = min(r, n - r)
numer = reduce(mul, list(range(n, n - r, -1)), 1)
denom = reduce(mul, list(range(1, r + 1)), 1)
return numer // denom
N, M, Q = list(map(int, input().split()))
a = [0] * Q
b = [0] *... | import itertools
N, M, Q = list(map(int, input().split()))
a = [0] * Q
b = [0] * Q
c = [0] * Q
d = [0] * Q
for i in range(Q):
a[i], b[i], c[i], d[i] = list(map(int, input().split()))
l = list(range(1, M + 1))
i = 0
D = []
for v in itertools.combinations_with_replacement(l, N):
D.append(0)
for j in range(Q)... | false | 51.612903 | [
"-from operator import mul",
"-from functools import reduce",
"-",
"-",
"-def combinations_count(n, r):",
"- r = min(r, n - r)",
"- numer = reduce(mul, list(range(n, n - r, -1)), 1)",
"- denom = reduce(mul, list(range(1, r + 1)), 1)",
"- return numer // denom",
"-",
"-h = combination... | false | 0.07482 | 0.065701 | 1.1388 | [
"s342527382",
"s558770443"
] |
u188827677 | p02695 | python | s936034408 | s414316109 | 1,093 | 958 | 21,472 | 9,140 | Accepted | Accepted | 12.35 | from itertools import combinations_with_replacement
n,m,q = list(map(int, input().split()))
abcd = [list(map(int, input().split())) for _ in range(q)]
nums = list(combinations_with_replacement(list(range(1,m+1)), n))
ans = 0
for i in nums:
t = 0
for j in abcd:
s = i[j[1]-1] - i[j[0]-1]
if s == ... | from itertools import combinations_with_replacement
n,m,q = list(map(int, input().split()))
abcd = [list(map(int, input().split())) for _ in range(q)]
nums = list(range(1, m+1))
ans = 0
for i in combinations_with_replacement(nums, n):
t = 0
for j in abcd:
if i[j[1]-1] - i[j[0]-1] == j[2]:
t += ... | 15 | 13 | 363 | 351 | from itertools import combinations_with_replacement
n, m, q = list(map(int, input().split()))
abcd = [list(map(int, input().split())) for _ in range(q)]
nums = list(combinations_with_replacement(list(range(1, m + 1)), n))
ans = 0
for i in nums:
t = 0
for j in abcd:
s = i[j[1] - 1] - i[j[0] - 1]
... | from itertools import combinations_with_replacement
n, m, q = list(map(int, input().split()))
abcd = [list(map(int, input().split())) for _ in range(q)]
nums = list(range(1, m + 1))
ans = 0
for i in combinations_with_replacement(nums, n):
t = 0
for j in abcd:
if i[j[1] - 1] - i[j[0] - 1] == j[2]:
... | false | 13.333333 | [
"-nums = list(combinations_with_replacement(list(range(1, m + 1)), n))",
"+nums = list(range(1, m + 1))",
"-for i in nums:",
"+for i in combinations_with_replacement(nums, n):",
"- s = i[j[1] - 1] - i[j[0] - 1]",
"- if s == j[2]:",
"+ if i[j[1] - 1] - i[j[0] - 1] == j[2]:"
] | false | 0.05979 | 0.053648 | 1.114478 | [
"s936034408",
"s414316109"
] |
u782685137 | p03363 | python | s798632921 | s304756187 | 243 | 217 | 26,720 | 41,144 | Accepted | Accepted | 10.7 | n = int(eval(input()))
a = list(map(int, input().split()))
s = [0]*(n+1)
for i in range(n):
s[i+1] = s[i] + a[i]
s = sorted(s)
r = 0
k = 0
for i in range(n):
if s[i] == s[i+1]:
k += 1
else:
r += (k+1)*k//2
k = 0
r += (k+1)*k//2
print(r) | n = int(eval(input()))
a = list(map(int, input().split()))
s = [0]*(n+1)
for i in range(n):
s[i+1] = s[i] + a[i]
dic = {}
for i in s:
if i in dic:
dic[i] += 1
else:
dic[i] = 1
r = 0
for d in list(dic.values()):
r += d*(d-1)//2
print(r) | 16 | 15 | 281 | 269 | n = int(eval(input()))
a = list(map(int, input().split()))
s = [0] * (n + 1)
for i in range(n):
s[i + 1] = s[i] + a[i]
s = sorted(s)
r = 0
k = 0
for i in range(n):
if s[i] == s[i + 1]:
k += 1
else:
r += (k + 1) * k // 2
k = 0
r += (k + 1) * k // 2
print(r)
| n = int(eval(input()))
a = list(map(int, input().split()))
s = [0] * (n + 1)
for i in range(n):
s[i + 1] = s[i] + a[i]
dic = {}
for i in s:
if i in dic:
dic[i] += 1
else:
dic[i] = 1
r = 0
for d in list(dic.values()):
r += d * (d - 1) // 2
print(r)
| false | 6.25 | [
"-s = sorted(s)",
"+dic = {}",
"+for i in s:",
"+ if i in dic:",
"+ dic[i] += 1",
"+ else:",
"+ dic[i] = 1",
"-k = 0",
"-for i in range(n):",
"- if s[i] == s[i + 1]:",
"- k += 1",
"- else:",
"- r += (k + 1) * k // 2",
"- k = 0",
"-r += (k + ... | false | 0.06575 | 0.04718 | 1.3936 | [
"s798632921",
"s304756187"
] |
u391875425 | p03090 | python | s294144414 | s579512461 | 1,845 | 628 | 44,764 | 3,976 | Accepted | Accepted | 65.96 | N = int(eval(input()))
ans = []
lis = []
for i in range(N):
lis.append(i + 1)
if N % 2 == 0:
M = (N - 2) * N // 2
for i in range(1, N):
for j in range(1, N):
if j != i and i != lis[-j]:
if sorted([i, lis[-j]]) not in ans:
ans.append(sorted([... | N = int(eval(input()))
ans = []
lis = []
for i in range(N):
lis.append(i + 1)
if N % 2 == 0:
M = (N - 2) * N // 2
for i in range(1, N):
for j in range(1, N):
if j != i and i != lis[-j]:
tmp = sorted([i, lis[-j]])
if tmp not in ans:
... | 27 | 29 | 780 | 808 | N = int(eval(input()))
ans = []
lis = []
for i in range(N):
lis.append(i + 1)
if N % 2 == 0:
M = (N - 2) * N // 2
for i in range(1, N):
for j in range(1, N):
if j != i and i != lis[-j]:
if sorted([i, lis[-j]]) not in ans:
ans.append(sorted([i, lis[-j]]... | N = int(eval(input()))
ans = []
lis = []
for i in range(N):
lis.append(i + 1)
if N % 2 == 0:
M = (N - 2) * N // 2
for i in range(1, N):
for j in range(1, N):
if j != i and i != lis[-j]:
tmp = sorted([i, lis[-j]])
if tmp not in ans:
ans.... | false | 6.896552 | [
"- if sorted([i, lis[-j]]) not in ans:",
"- ans.append(sorted([i, lis[-j]]))",
"+ tmp = sorted([i, lis[-j]])",
"+ if tmp not in ans:",
"+ ans.append(tmp)",
"- if sorted([i, lis[-j]]) not in ans:",
"- ... | false | 0.040921 | 0.076893 | 0.532186 | [
"s294144414",
"s579512461"
] |
u943057856 | p02994 | python | s939357036 | s272692014 | 19 | 17 | 3,316 | 2,940 | Accepted | Accepted | 10.53 | N,L = list(map(int,input().split()))
l = list([L+x-1 for x in range(1,N+1)])
print((sum(l)-min(l,key=abs))) | N,L = list(map(int,input().split()))
apple_list = list([L+x-1 for x in range(1,N+1)])
print((sum(apple_list) - min(apple_list,key=abs))) | 3 | 3 | 108 | 136 | N, L = list(map(int, input().split()))
l = list([L + x - 1 for x in range(1, N + 1)])
print((sum(l) - min(l, key=abs)))
| N, L = list(map(int, input().split()))
apple_list = list([L + x - 1 for x in range(1, N + 1)])
print((sum(apple_list) - min(apple_list, key=abs)))
| false | 0 | [
"-l = list([L + x - 1 for x in range(1, N + 1)])",
"-print((sum(l) - min(l, key=abs)))",
"+apple_list = list([L + x - 1 for x in range(1, N + 1)])",
"+print((sum(apple_list) - min(apple_list, key=abs)))"
] | false | 0.070613 | 0.045165 | 1.563445 | [
"s939357036",
"s272692014"
] |
u600402037 | p02996 | python | s111746924 | s316214711 | 783 | 612 | 53,696 | 62,368 | Accepted | Accepted | 21.84 | import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
AB = [lr() for _ in range(N)]
AB.sort(key=lambda x: x[1])
answer = 'Yes'
time = 0
for i in range(N):
if time + AB[i][0] > AB[i][1]:
answer = 'No'
time += AB[i][... | import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
AB = np.array([lr() for _ in range(N)])
AB = AB[np.argsort(AB[:, 1])]
A = AB[:, 0]
B = AB[:, 1]
bl = np.all(A.cumsum() <= B)
print(('Yes' if bl else 'No'))
#... | 17 | 15 | 340 | 319 | import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
AB = [lr() for _ in range(N)]
AB.sort(key=lambda x: x[1])
answer = "Yes"
time = 0
for i in range(N):
if time + AB[i][0] > AB[i][1]:
answer = "No"
time += AB[i][0]
print(answer... | import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
AB = np.array([lr() for _ in range(N)])
AB = AB[np.argsort(AB[:, 1])]
A = AB[:, 0]
B = AB[:, 1]
bl = np.all(A.cumsum() <= B)
print(("Yes" if bl else "No"))
#
| false | 11.764706 | [
"+import numpy as np",
"-AB = [lr() for _ in range(N)]",
"-AB.sort(key=lambda x: x[1])",
"-answer = \"Yes\"",
"-time = 0",
"-for i in range(N):",
"- if time + AB[i][0] > AB[i][1]:",
"- answer = \"No\"",
"- time += AB[i][0]",
"-print(answer)",
"+AB = np.array([lr() for _ in range(N)]... | false | 0.060365 | 0.336331 | 0.179482 | [
"s111746924",
"s316214711"
] |
u726615467 | p03287 | python | s563321310 | s785518741 | 145 | 133 | 17,464 | 19,244 | Accepted | Accepted | 8.28 | # encoding: utf-8
N, M = list(map(int, input().split()))
d_sym = {}
sym = 0
# refresh
ans = 0
for A in map(int, input().split()):
sym = (sym + A) % M
#
if sym == 0: ans += 1
#
if str(sym) in list(d_sym.keys()): d_sym[str(sym)] += 1
else: d_sym[str(sym)] = 1
print((int(ans +... | N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
tab_sum = [0]
sum_tmp = 0
for Ai in A:
sum_tmp += Ai
tab_sum.append(sum_tmp)
cnt = {}
for item in tab_sum:
key = str(item % M)
cnt.setdefault(key, 0)
cnt[key] += 1
ans = 0
for key, val in list(cnt.ite... | 18 | 21 | 369 | 361 | # encoding: utf-8
N, M = list(map(int, input().split()))
d_sym = {}
sym = 0
# refresh
ans = 0
for A in map(int, input().split()):
sym = (sym + A) % M
#
if sym == 0:
ans += 1
#
if str(sym) in list(d_sym.keys()):
d_sym[str(sym)] += 1
else:
d_sym[str(sym)] = 1
print((int(ans... | N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
tab_sum = [0]
sum_tmp = 0
for Ai in A:
sum_tmp += Ai
tab_sum.append(sum_tmp)
cnt = {}
for item in tab_sum:
key = str(item % M)
cnt.setdefault(key, 0)
cnt[key] += 1
ans = 0
for key, val in list(cnt.items()):
ans += val * (... | false | 14.285714 | [
"-# encoding: utf-8",
"-d_sym = {}",
"-sym = 0",
"-# refresh",
"+A = list(map(int, input().split()))",
"+tab_sum = [0]",
"+sum_tmp = 0",
"+for Ai in A:",
"+ sum_tmp += Ai",
"+ tab_sum.append(sum_tmp)",
"+cnt = {}",
"+for item in tab_sum:",
"+ key = str(item % M)",
"+ cnt.setdef... | false | 0.036361 | 0.036661 | 0.991825 | [
"s563321310",
"s785518741"
] |
u624475441 | p03805 | python | s368839748 | s806535592 | 1,795 | 28 | 141,808 | 3,064 | Accepted | Accepted | 98.44 | n,m=list(map(int,input().split()))
e=[[]for _ in[0]*-~n]
for _ in[0]*m:
a,b=list(map(int,input().split()))
e[a]+=[b]
e[b]+=[a]
candy=[[1]]
for _ in[0]*~-n:
tmp=[]
for c in candy:
for next in e[c[-1]]:
tmp+=[c+[next]]
candy=tmp
print((sum(c==set(range(1,n+1))for c... | from itertools import permutations
N, M = list(map(int, input().split()))
edges = set()
for _ in range(M):
a, b = list(map(int, input().split()))
edges.add((a, b))
edges.add((b, a))
cnt = 0
for p in permutations(list(range(2, N + 1))):
cnt += all(move in edges for move in zip((1,) + p, p))
... | 14 | 13 | 327 | 313 | n, m = list(map(int, input().split()))
e = [[] for _ in [0] * -~n]
for _ in [0] * m:
a, b = list(map(int, input().split()))
e[a] += [b]
e[b] += [a]
candy = [[1]]
for _ in [0] * ~-n:
tmp = []
for c in candy:
for next in e[c[-1]]:
tmp += [c + [next]]
candy = tmp
print((sum(c ==... | from itertools import permutations
N, M = list(map(int, input().split()))
edges = set()
for _ in range(M):
a, b = list(map(int, input().split()))
edges.add((a, b))
edges.add((b, a))
cnt = 0
for p in permutations(list(range(2, N + 1))):
cnt += all(move in edges for move in zip((1,) + p, p))
print(cnt)
| false | 7.142857 | [
"-n, m = list(map(int, input().split()))",
"-e = [[] for _ in [0] * -~n]",
"-for _ in [0] * m:",
"+from itertools import permutations",
"+",
"+N, M = list(map(int, input().split()))",
"+edges = set()",
"+for _ in range(M):",
"- e[a] += [b]",
"- e[b] += [a]",
"-candy = [[1]]",
"-for _ in ... | false | 0.038439 | 0.043487 | 0.883908 | [
"s368839748",
"s806535592"
] |
u561231954 | p02736 | python | s000544908 | s588373019 | 1,699 | 786 | 76,124 | 31,092 | Accepted | Accepted | 53.74 | import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
fact2 = [0] * 1000011
def cnt2(n):
if n%2 == 1:
return 0
else:
fact2[n] = 1 + fact2[n//2]
return fact2[n]
factorial = [0,0]
for i in range(2,1000010):
factorial... | import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
def nxor(x,n,k):
if (n&k) == k:
return x
else:
return 0
def main():
n = int(eval(input()))
a = [int(i) - 1 for i in list(eval(input()))]
cumxor = 0
... | 56 | 42 | 1,132 | 812 | import sys
INF = 10**9
MOD = 10**9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
fact2 = [0] * 1000011
def cnt2(n):
if n % 2 == 1:
return 0
else:
fact2[n] = 1 + fact2[n // 2]
return fact2[n]
factorial = [0, 0]
for i in range(2, 1000010):
factorial.append(fa... | import sys
INF = 10**9
MOD = 10**9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
def nxor(x, n, k):
if (n & k) == k:
return x
else:
return 0
def main():
n = int(eval(input()))
a = [int(i) - 1 for i in list(eval(input()))]
cumxor = 0
amod = [i % 2 for i ... | false | 25 | [
"-fact2 = [0] * 1000011",
"-def cnt2(n):",
"- if n % 2 == 1:",
"+def nxor(x, n, k):",
"+ if (n & k) == k:",
"+ return x",
"+ else:",
"- else:",
"- fact2[n] = 1 + fact2[n // 2]",
"- return fact2[n]",
"-",
"-",
"-factorial = [0, 0]",
"-for i in range(2, 10000... | false | 1.413268 | 0.037662 | 37.525252 | [
"s000544908",
"s588373019"
] |
u488401358 | p02635 | python | s268271159 | s814802048 | 1,719 | 1,150 | 107,040 | 82,008 | Accepted | Accepted | 33.1 | S,K=input().split()
K=int(K)
K=min(K,300)
mod=998244353
a=[]
val=0
for i in range(len(S)):
if S[i]=="0":
a.append(val)
val=0
else:
val+=1
if val!=0:
a.append(val)
m=len(a)
K=min(sum(a),K)
dp=[[0 for i in range(K+1)] for j in range(K+1)]
for j in range(K+1):
... | S,K=input().split()
K=int(K)
K=min(K,300)
mod=998244353
a=[]
val=0
for i in range(len(S)):
if S[i]=="0":
a.append(val)
val=0
else:
val+=1
if val!=0:
a.append(val)
m=len(a)
K=min(sum(a),K)
dp=[[0 for i in range(K+1)] for j in range(K+1)]
for j in range(K+1):
... | 40 | 42 | 854 | 906 | S, K = input().split()
K = int(K)
K = min(K, 300)
mod = 998244353
a = []
val = 0
for i in range(len(S)):
if S[i] == "0":
a.append(val)
val = 0
else:
val += 1
if val != 0:
a.append(val)
m = len(a)
K = min(sum(a), K)
dp = [[0 for i in range(K + 1)] for j in range(K + 1)]
for j in range... | S, K = input().split()
K = int(K)
K = min(K, 300)
mod = 998244353
a = []
val = 0
for i in range(len(S)):
if S[i] == "0":
a.append(val)
val = 0
else:
val += 1
if val != 0:
a.append(val)
m = len(a)
K = min(sum(a), K)
dp = [[0 for i in range(K + 1)] for j in range(K + 1)]
for j in range... | false | 4.761905 | [
"- ndp[j][k] = sum(dp[j + l][k] for l in range(max(0, M), K - j + 1)) + sum(",
"- dp[j][k + l] for l in range(1, min(K - k, -M) + 1)",
"- )",
"- ndp[j][k] %= mod",
"+ for l in range(max(0, M), K - j + 1):",
"+ ndp[j][k] = (ndp[j][k]... | false | 0.05749 | 0.169991 | 0.338193 | [
"s268271159",
"s814802048"
] |
u970523279 | p02862 | python | s423293514 | s594015544 | 204 | 176 | 40,044 | 38,512 | Accepted | Accepted | 13.73 | MOD = 10**9 + 7
def nck(n, k):
numer, denom = 1, 1
for i in range(k):
numer = numer * (n - i) % MOD
denom = denom * (k - i) % MOD
return numer * pow(denom, MOD-2, MOD) % MOD
x, y = list(map(int, input().split()))
# (1, 2) 動く回数をm回、(2, 1) 動く回数をn回とする
n = -1
for m in range(min(x//1, ... | def nck(n, k):
numer, denom = 1, 1
for i in range(k):
numer = numer * (n-i) % MOD
denom = denom * (k-i) % MOD
return numer * pow(denom, MOD-2, MOD) % MOD
x, y = list(map(int, input().split()))
MOD = 10 ** 9 + 7
i = 2 * y - x
j = 2 * x - y
if i % 3 != 0 or j % 3 != 0 or i < 0 or... | 22 | 17 | 483 | 402 | MOD = 10**9 + 7
def nck(n, k):
numer, denom = 1, 1
for i in range(k):
numer = numer * (n - i) % MOD
denom = denom * (k - i) % MOD
return numer * pow(denom, MOD - 2, MOD) % MOD
x, y = list(map(int, input().split()))
# (1, 2) 動く回数をm回、(2, 1) 動く回数をn回とする
n = -1
for m in range(min(x // 1, y //... | def nck(n, k):
numer, denom = 1, 1
for i in range(k):
numer = numer * (n - i) % MOD
denom = denom * (k - i) % MOD
return numer * pow(denom, MOD - 2, MOD) % MOD
x, y = list(map(int, input().split()))
MOD = 10**9 + 7
i = 2 * y - x
j = 2 * x - y
if i % 3 != 0 or j % 3 != 0 or i < 0 or j < 0:
... | false | 22.727273 | [
"-MOD = 10**9 + 7",
"-",
"-",
"-# (1, 2) 動く回数をm回、(2, 1) 動く回数をn回とする",
"-n = -1",
"-for m in range(min(x // 1, y // 2) + 1):",
"- rx = x - m",
"- ry = y - 2 * m",
"- if rx == ry * 2:",
"- n = ry",
"- break",
"-if n == -1:",
"+MOD = 10**9 + 7",
"+i = 2 * y - x",
"+j =... | false | 0.096517 | 0.084848 | 1.137525 | [
"s423293514",
"s594015544"
] |
u221940831 | p02880 | python | s698306495 | s375639858 | 30 | 27 | 9,160 | 9,156 | Accepted | Accepted | 10 | num = int(eval(input()))
for i in range(1, 10):
for j in range(1, 10):
if (i * j) / num == 1:
print("Yes")
exit()
print("No") | num = int(eval(input()))
i = 1
while i <= 9:
j = 1
while j <= 9:
if (i * j) / num == 1:
print("Yes")
exit()
else:
j += 1
i += 1
print("No") | 9 | 15 | 138 | 214 | num = int(eval(input()))
for i in range(1, 10):
for j in range(1, 10):
if (i * j) / num == 1:
print("Yes")
exit()
print("No")
| num = int(eval(input()))
i = 1
while i <= 9:
j = 1
while j <= 9:
if (i * j) / num == 1:
print("Yes")
exit()
else:
j += 1
i += 1
print("No")
| false | 40 | [
"-for i in range(1, 10):",
"- for j in range(1, 10):",
"+i = 1",
"+while i <= 9:",
"+ j = 1",
"+ while j <= 9:",
"+ else:",
"+ j += 1",
"+ i += 1"
] | false | 0.038212 | 0.037082 | 1.030481 | [
"s698306495",
"s375639858"
] |
u968166680 | p03078 | python | s009975667 | s636086784 | 812 | 139 | 218,396 | 77,780 | Accepted | Accepted | 82.88 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
X, Y, Z, K = list(map(int, readline().split()))
A = list(map(int, readline().split()))
B = list(map(int, readline().split()... | import sys
from heapq import heappush, heappop
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
X, Y, Z, K = list(map(int, readline().split()))
A = list(map(int, readline().split()))
... | 38 | 43 | 709 | 1,209 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def main():
X, Y, Z, K = list(map(int, readline().split()))
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
C = list... | import sys
from heapq import heappush, heappop
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def main():
X, Y, Z, K = list(map(int, readline().split()))
A = list(map(int, readline().split()))
B = list(map(in... | false | 11.627907 | [
"+from heapq import heappush, heappop",
"- AB = []",
"- for a in A:",
"- for b in B:",
"- AB.append(a + b)",
"- AB.sort(reverse=True)",
"- AB = AB[:K]",
"- ABC = []",
"- for ab in AB:",
"- for c in C:",
"- ABC.append(ab + c)",
"- ABC.sor... | false | 0.096135 | 0.111834 | 0.859618 | [
"s009975667",
"s636086784"
] |
u670180528 | p03166 | python | s057391663 | s253183094 | 1,163 | 635 | 191,000 | 112,804 | Accepted | Accepted | 45.4 | import sys
from functools import lru_cache
sys.setrecursionlimit(524287)
n,m,*l = list(map(int,open(0).read().split()))
pas = [[] for _ in range(n)]
for x,y in zip(l[::2],l[1::2]):
pas[x-1].append(y-1)
INF = float("inf")
done = [-INF]*n
@lru_cache(maxsize = None)
def dfs(t):
if done[t] >= 0:
pass
... | import sys
sys.setrecursionlimit(524287)
n,m,*l = list(map(int,open(0).read().split()))
pas = [[] for _ in range(n)]
for x,y in zip(l[::2],l[1::2]):
pas[x-1].append(y-1)
INF = float("inf")
done = [-INF]*n
def dfs(t):
if done[t] >= 0:
pass
elif pas[t]:
done[t] = max(dfs(s) for s in pas[t]) + 1
... | 23 | 21 | 453 | 393 | import sys
from functools import lru_cache
sys.setrecursionlimit(524287)
n, m, *l = list(map(int, open(0).read().split()))
pas = [[] for _ in range(n)]
for x, y in zip(l[::2], l[1::2]):
pas[x - 1].append(y - 1)
INF = float("inf")
done = [-INF] * n
@lru_cache(maxsize=None)
def dfs(t):
if done[t] >= 0:
... | import sys
sys.setrecursionlimit(524287)
n, m, *l = list(map(int, open(0).read().split()))
pas = [[] for _ in range(n)]
for x, y in zip(l[::2], l[1::2]):
pas[x - 1].append(y - 1)
INF = float("inf")
done = [-INF] * n
def dfs(t):
if done[t] >= 0:
pass
elif pas[t]:
done[t] = max(dfs(s) for s... | false | 8.695652 | [
"-from functools import lru_cache",
"-@lru_cache(maxsize=None)"
] | false | 0.086691 | 0.084997 | 1.01993 | [
"s057391663",
"s253183094"
] |
u799164835 | p03160 | python | s153436122 | s540351309 | 162 | 117 | 13,908 | 20,520 | Accepted | Accepted | 27.78 | N = int(eval(input()))
h = list(map(int, input().split()))
INF = 1000 * 1000 * 1000
dp = [INF] * N
def absoluteDiff(a, b):
if a > b:
return a - b
else:
return b - a
dp[0] = 0
dp[1] = absoluteDiff(h[0], h[1])
for i in range(0, N - 2):
dp[i + 1] = min(dp[i + 1], dp[i] + absoluteDiff(h[i], h[i + 1])... | INF=int('fffFFFFffffFFFF',16)
n=int(eval(input()))
h=list(map(int,input().split()))
dp=[INF] * n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2])
print((dp[n-1])) | 18 | 12 | 464 | 234 | N = int(eval(input()))
h = list(map(int, input().split()))
INF = 1000 * 1000 * 1000
dp = [INF] * N
def absoluteDiff(a, b):
if a > b:
return a - b
else:
return b - a
dp[0] = 0
dp[1] = absoluteDiff(h[0], h[1])
for i in range(0, N - 2):
dp[i + 1] = min(dp[i + 1], dp[i] + absoluteDiff(h[i], ... | INF = int("fffFFFFffffFFFF", 16)
n = int(eval(input()))
h = list(map(int, input().split()))
dp = [INF] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2])
print((dp[n - 1]))
| false | 33.333333 | [
"-N = int(eval(input()))",
"+INF = int(\"fffFFFFffffFFFF\", 16)",
"+n = int(eval(input()))",
"-INF = 1000 * 1000 * 1000",
"-dp = [INF] * N",
"-",
"-",
"-def absoluteDiff(a, b):",
"- if a > b:",
"- return a - b",
"- else:",
"- return b - a",
"-",
"-",
"+dp = [INF] * n"... | false | 0.034471 | 0.036364 | 0.947939 | [
"s153436122",
"s540351309"
] |
u440566786 | p03088 | python | s785582680 | s460259937 | 247 | 211 | 45,936 | 42,608 | Accepted | Accepted | 14.57 | import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
N=int(eval(input()))
dp=[[[[0]*4 for _ in range(4)] for _ in range(4)] for _ in range(N+1)]
# initialize(n=3)
NG={(0,1,2),(1,0,2),(0,2,1)}
from itertools import product
fo... | import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
N=int(eval(input()))
dp=[[[[0]*4 for _ in range(4)] for _ in range(4)] for _ in range(N+1)]
# initialize(n=3)
NG={(0,1,2),(1,0,2),(0,2,1)}
from itertools import product
fo... | 29 | 30 | 863 | 896 | import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = sys.stdin.readline
def resolve():
N = int(eval(input()))
dp = [[[[0] * 4 for _ in range(4)] for _ in range(4)] for _ in range(N + 1)]
# initialize(n=3)
NG = {(0, 1, 2), (1, 0, 2), (0, 2, 1)}
from itertools imp... | import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = sys.stdin.readline
def resolve():
N = int(eval(input()))
dp = [[[[0] * 4 for _ in range(4)] for _ in range(4)] for _ in range(N + 1)]
# initialize(n=3)
NG = {(0, 1, 2), (1, 0, 2), (0, 2, 1)}
from itertools imp... | false | 3.333333 | [
"+ dp[n][j][k][l] %= MOD"
] | false | 0.058886 | 0.06433 | 0.915376 | [
"s785582680",
"s460259937"
] |
u944325914 | p02623 | python | s242703658 | s918774879 | 366 | 292 | 47,496 | 50,704 | Accepted | Accepted | 20.22 | import bisect
n,m,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a_sum=[]
b_sum=[]
a_sum.append(0)
b_sum.append(0)
for i in range(n):
a_sum.append(a_sum[i]+a[i])
for j in range(m):
b_sum.append(b_sum[j]+b[j])
ans=0
for x in range(n+1):
timeco... | n,m,k=list(map(int,input().split()))
from itertools import accumulate
from bisect import bisect_right
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ac=[0]+list(accumulate(a))
bc=[0]+list(accumulate(b))
temp=0
for i in range(n+1):
if ac[i]<=k:
count=i
count+=bisect_ri... | 22 | 15 | 475 | 374 | import bisect
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_sum = []
b_sum = []
a_sum.append(0)
b_sum.append(0)
for i in range(n):
a_sum.append(a_sum[i] + a[i])
for j in range(m):
b_sum.append(b_sum[j] + b[j])
ans = 0
for x in range(n + 1):
... | n, m, k = list(map(int, input().split()))
from itertools import accumulate
from bisect import bisect_right
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ac = [0] + list(accumulate(a))
bc = [0] + list(accumulate(b))
temp = 0
for i in range(n + 1):
if ac[i] <= k:
count = i
c... | false | 31.818182 | [
"-import bisect",
"+n, m, k = list(map(int, input().split()))",
"+from itertools import accumulate",
"+from bisect import bisect_right",
"-n, m, k = list(map(int, input().split()))",
"-a_sum = []",
"-b_sum = []",
"-a_sum.append(0)",
"-b_sum.append(0)",
"-for i in range(n):",
"- a_sum.append(a... | false | 0.0652 | 0.047691 | 1.367123 | [
"s242703658",
"s918774879"
] |
u542932305 | p03835 | python | s001466692 | s753601876 | 1,601 | 1,450 | 2,940 | 2,940 | Accepted | Accepted | 9.43 | k, s = list(map(int, input().split()))
count = 0
for x in range(k+1):
for y in range(k+1):
z = s-x-y
if z < 0:
break
if z <= k:
count += 1
print(count) | k, s = list(map(int, input().split()))
count = 0
for x in range(k+1):
for y in range(k+1):
z = s-x-y
if 0 <= z <= k:
count += 1
print(count) | 12 | 10 | 210 | 177 | k, s = list(map(int, input().split()))
count = 0
for x in range(k + 1):
for y in range(k + 1):
z = s - x - y
if z < 0:
break
if z <= k:
count += 1
print(count)
| k, s = list(map(int, input().split()))
count = 0
for x in range(k + 1):
for y in range(k + 1):
z = s - x - y
if 0 <= z <= k:
count += 1
print(count)
| false | 16.666667 | [
"- if z < 0:",
"- break",
"- if z <= k:",
"+ if 0 <= z <= k:"
] | false | 0.045501 | 0.046221 | 0.984414 | [
"s001466692",
"s753601876"
] |
u130900604 | p02804 | python | s271288806 | s740422337 | 550 | 335 | 17,544 | 70,340 | Accepted | Accepted | 39.09 | MOD=10**9+7
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
a.sort(reverse=True)
fact = [1]
fact_inv = [1]
mod=10**9+7
for i in range(10**5+1):
new_fact = fact[-1]*(i+1)%mod
fact.append(new_fact)
fact_inv.append(pow(new_fact,mod-2,mod))
def mod_comb_k(n,k,mod):
... | MOD=10**9+7
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
a.sort(reverse=True)
#前計算
fact = [1]
fact_inv = [1]
mod=10**9+7
for i in range(n+1):
new_fact = fact[-1]*(i+1)%mod
fact.append(new_fact)
fact_inv.append(pow(new_fact,mod-2,mod))
def mod_comb_k(n,k,mod):
re... | 30 | 29 | 551 | 547 | MOD = 10**9 + 7
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=True)
fact = [1]
fact_inv = [1]
mod = 10**9 + 7
for i in range(10**5 + 1):
new_fact = fact[-1] * (i + 1) % mod
fact.append(new_fact)
fact_inv.append(pow(new_fact, mod - 2, mod))
def mod_comb_k(n, k, m... | MOD = 10**9 + 7
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=True)
# 前計算
fact = [1]
fact_inv = [1]
mod = 10**9 + 7
for i in range(n + 1):
new_fact = fact[-1] * (i + 1) % mod
fact.append(new_fact)
fact_inv.append(pow(new_fact, mod - 2, mod))
def mod_comb_k(n, k,... | false | 3.333333 | [
"+# 前計算",
"-for i in range(10**5 + 1):",
"+for i in range(n + 1):",
"+# 前計算終わり",
"-# print(c,a)"
] | false | 1.856095 | 0.039242 | 47.298271 | [
"s271288806",
"s740422337"
] |
u633105820 | p03298 | python | s999449713 | s674966235 | 1,631 | 596 | 56,660 | 103,940 | Accepted | Accepted | 63.46 | def run(n, s):
'''
文字列sを半分に分けて、右半分を逆順に並び替える
さらに色の塗分けを逆にすると、左半分と右半分は
同じになる
'''
sl = s[0:n]
sr = s[n:2*n][::-1]
dic = {}
keys = []
cnt = 0
for i in range(2**n):
red, blue, red2, blue2 = '', '', '', ''
bits = bin(2**n+i)[3:]
for j in ran... | def run(n, s):
'''
文字列sを半分に分けて、右半分を逆順に並び替える
さらに色の塗分けを逆にすると、左半分と右半分は
同じになる
'''
sl = s[0:n]
sr = s[n:2*n][::-1]
keys1 = [c[0]+'-'+c[1] for c in comb(sl)]
keys2 = [c[0]+'-'+c[1] for c in comb(sr)]
dict = {}
for key1 in keys1:
if key1 in dict:
d... | 101 | 48 | 2,095 | 925 | def run(n, s):
"""
文字列sを半分に分けて、右半分を逆順に並び替える
さらに色の塗分けを逆にすると、左半分と右半分は
同じになる
"""
sl = s[0:n]
sr = s[n : 2 * n][::-1]
dic = {}
keys = []
cnt = 0
for i in range(2**n):
red, blue, red2, blue2 = "", "", "", ""
bits = bin(2**n + i)[3:]
for j in range(n):
... | def run(n, s):
"""
文字列sを半分に分けて、右半分を逆順に並び替える
さらに色の塗分けを逆にすると、左半分と右半分は
同じになる
"""
sl = s[0:n]
sr = s[n : 2 * n][::-1]
keys1 = [c[0] + "-" + c[1] for c in comb(sl)]
keys2 = [c[0] + "-" + c[1] for c in comb(sr)]
dict = {}
for key1 in keys1:
if key1 in dict:
dict... | false | 52.475248 | [
"- dic = {}",
"- keys = []",
"+ keys1 = [c[0] + \"-\" + c[1] for c in comb(sl)]",
"+ keys2 = [c[0] + \"-\" + c[1] for c in comb(sr)]",
"+ dict = {}",
"+ for key1 in keys1:",
"+ if key1 in dict:",
"+ dict[key1] += 1",
"+ else:",
"+ dict[key1] = ... | false | 0.038662 | 0.007618 | 5.074967 | [
"s999449713",
"s674966235"
] |
u200887663 | p02994 | python | s217953002 | s693075637 | 22 | 17 | 3,444 | 3,060 | Accepted | Accepted | 22.73 | n,l=list(map(int,input().split()))
import copy
apple_l=[]
pie=0
deli=[]
for i in range(1,n+1):
pie+=l+i-1
deli.append(l+i-1)
ans={}
ans2=[]
for j in range(1,n+1):
deli2=copy.copy(deli)
deli2.remove(l+j-1)
ans[abs(sum(deli2)-pie)]=sum(deli2)
ans2.append(abs(sum(deli2)-pie))
print((ans[min(an... | n,l=list(map(int,input().split()))
mngap=[1,abs(l+1-1)]
for i in range(2,n+1):
if mngap[1]>abs(l+i-1):
mngap=[i,abs(l+i-1)]
total=0
for i in range(1,n+1):
total+=l+i-1
print((total-(l+mngap[0]-1))) | 18 | 11 | 321 | 209 | n, l = list(map(int, input().split()))
import copy
apple_l = []
pie = 0
deli = []
for i in range(1, n + 1):
pie += l + i - 1
deli.append(l + i - 1)
ans = {}
ans2 = []
for j in range(1, n + 1):
deli2 = copy.copy(deli)
deli2.remove(l + j - 1)
ans[abs(sum(deli2) - pie)] = sum(deli2)
ans2.append(ab... | n, l = list(map(int, input().split()))
mngap = [1, abs(l + 1 - 1)]
for i in range(2, n + 1):
if mngap[1] > abs(l + i - 1):
mngap = [i, abs(l + i - 1)]
total = 0
for i in range(1, n + 1):
total += l + i - 1
print((total - (l + mngap[0] - 1)))
| false | 38.888889 | [
"-import copy",
"-",
"-apple_l = []",
"-pie = 0",
"-deli = []",
"+mngap = [1, abs(l + 1 - 1)]",
"+for i in range(2, n + 1):",
"+ if mngap[1] > abs(l + i - 1):",
"+ mngap = [i, abs(l + i - 1)]",
"+total = 0",
"- pie += l + i - 1",
"- deli.append(l + i - 1)",
"-ans = {}",
"-a... | false | 0.050879 | 0.046127 | 1.103026 | [
"s217953002",
"s693075637"
] |
u057415180 | p02983 | python | s837353876 | s011210615 | 74 | 48 | 3,060 | 3,060 | Accepted | Accepted | 35.14 | l, r = list(map(int, input().split()))
ans = 2019
for i in range(l, r):
for j in range(l+1, r+1):
tmp = i*j % 2019
if ans > tmp:
ans = tmp
if ans == 0:
print(ans)
exit(0)
print(ans) | l, r = list(map(int, input().split()))
ans = 2019
for i in range(l, r):
for j in range(i+1, r+1):
tmp = i*j % 2019
if ans > tmp:
ans = tmp
if ans == 0:
print(ans)
exit(0)
print(ans) | 12 | 11 | 251 | 249 | l, r = list(map(int, input().split()))
ans = 2019
for i in range(l, r):
for j in range(l + 1, r + 1):
tmp = i * j % 2019
if ans > tmp:
ans = tmp
if ans == 0:
print(ans)
exit(0)
print(ans)
| l, r = list(map(int, input().split()))
ans = 2019
for i in range(l, r):
for j in range(i + 1, r + 1):
tmp = i * j % 2019
if ans > tmp:
ans = tmp
if ans == 0:
print(ans)
exit(0)
print(ans)
| false | 8.333333 | [
"- for j in range(l + 1, r + 1):",
"+ for j in range(i + 1, r + 1):"
] | false | 0.059836 | 0.035405 | 1.690043 | [
"s837353876",
"s011210615"
] |
u057109575 | p02937 | python | s333158984 | s702759079 | 252 | 117 | 53,360 | 80,144 | Accepted | Accepted | 53.57 | from collections import defaultdict
from bisect import bisect_left
s = eval(input())
t = eval(input())
if set(s) >= set(t):
d = defaultdict(list)
for i, x in enumerate(s * 2):
d[x].append(i)
ans = 0
cur = 0
N = len(s)
for x in t:
cur_new = d[x][bisect_left(d... | from collections import defaultdict
from bisect import bisect_right
s = eval(input())
t = eval(input())
indices = defaultdict(list)
for i, v in enumerate(s):
indices[v].append(i)
cnt = 0
cur = -1
mod = len(s)
flag = False
for v in t:
if v not in indices:
flag = True
break
... | 22 | 33 | 426 | 558 | from collections import defaultdict
from bisect import bisect_left
s = eval(input())
t = eval(input())
if set(s) >= set(t):
d = defaultdict(list)
for i, x in enumerate(s * 2):
d[x].append(i)
ans = 0
cur = 0
N = len(s)
for x in t:
cur_new = d[x][bisect_left(d[x], cur)]
an... | from collections import defaultdict
from bisect import bisect_right
s = eval(input())
t = eval(input())
indices = defaultdict(list)
for i, v in enumerate(s):
indices[v].append(i)
cnt = 0
cur = -1
mod = len(s)
flag = False
for v in t:
if v not in indices:
flag = True
break
i = bisect_right(i... | false | 33.333333 | [
"-from bisect import bisect_left",
"+from bisect import bisect_right",
"-if set(s) >= set(t):",
"- d = defaultdict(list)",
"- for i, x in enumerate(s * 2):",
"- d[x].append(i)",
"- ans = 0",
"- cur = 0",
"- N = len(s)",
"- for x in t:",
"- cur_new = d[x][bisect_le... | false | 0.037301 | 0.037928 | 0.983476 | [
"s333158984",
"s702759079"
] |
u947883560 | p02816 | python | s761510577 | s488092211 | 1,952 | 1,405 | 148,564 | 145,964 | Accepted | Accepted | 28.02 | #!/usr/bin/env python3
import sys
INF = float("inf")
B = 10**7+7
MOD = 10**9+7
# https://tjkendev.github.io/procon-library/python/string/rolling_hash.html
class RollingHash():
def __init__(self, s, base, mod):
self.mod = mod
self.pw = pw = [1]*(len(s)+1)
l = len(s)
... | #!/usr/bin/env python3
import sys
INF = float("inf")
# https://tjkendev.github.io/procon-library/python/string/rolling_hash.html
base = 37
mod = 10**9 + 9
pw = None
def rolling_hash(s):
l = len(s)
h = [0]*(l + 1)
v = 0
for i in range(l):
h[i+1] = v = (v * base + s[i]) % mod... | 122 | 96 | 3,210 | 2,491 | #!/usr/bin/env python3
import sys
INF = float("inf")
B = 10**7 + 7
MOD = 10**9 + 7
# https://tjkendev.github.io/procon-library/python/string/rolling_hash.html
class RollingHash:
def __init__(self, s, base, mod):
self.mod = mod
self.pw = pw = [1] * (len(s) + 1)
l = len(s)
self.h = h ... | #!/usr/bin/env python3
import sys
INF = float("inf")
# https://tjkendev.github.io/procon-library/python/string/rolling_hash.html
base = 37
mod = 10**9 + 9
pw = None
def rolling_hash(s):
l = len(s)
h = [0] * (l + 1)
v = 0
for i in range(l):
h[i + 1] = v = (v * base + s[i]) % mod
return h
... | false | 21.311475 | [
"-B = 10**7 + 7",
"-MOD = 10**9 + 7",
"-class RollingHash:",
"- def __init__(self, s, base, mod):",
"- self.mod = mod",
"- self.pw = pw = [1] * (len(s) + 1)",
"- l = len(s)",
"- self.h = h = [0] * (l + 1)",
"- v = 0",
"- for i in range(l):",
"- ... | false | 0.041593 | 0.050558 | 0.822677 | [
"s761510577",
"s488092211"
] |
u388927326 | p03684 | python | s042261609 | s777524458 | 1,719 | 1,234 | 123,296 | 45,376 | Accepted | Accepted | 28.21 | #!/usr/bin/env python3
import heapq
def main():
n = int(eval(input()))
nodes = []
for i in range(n):
xi, yi = list(map(int, input().split()))
nodes.append((i, xi, yi))
adj = [[] for i in range(n)]
nodes.sort(key=(lambda x: x[1]))
for j in range(n):
i = no... | #!/usr/bin/env python3
import heapq
def main():
n = int(eval(input()))
nodes = []
for i in range(n):
xi, yi = list(map(int, input().split()))
nodes.append((i, xi, yi))
adj = [[] for i in range(n)]
nodesx = sorted(nodes, key=(lambda x: x[1]))
for j in range(n - 1):... | 55 | 48 | 1,339 | 1,157 | #!/usr/bin/env python3
import heapq
def main():
n = int(eval(input()))
nodes = []
for i in range(n):
xi, yi = list(map(int, input().split()))
nodes.append((i, xi, yi))
adj = [[] for i in range(n)]
nodes.sort(key=(lambda x: x[1]))
for j in range(n):
i = nodes[j][0]
... | #!/usr/bin/env python3
import heapq
def main():
n = int(eval(input()))
nodes = []
for i in range(n):
xi, yi = list(map(int, input().split()))
nodes.append((i, xi, yi))
adj = [[] for i in range(n)]
nodesx = sorted(nodes, key=(lambda x: x[1]))
for j in range(n - 1):
i1 = ... | false | 12.727273 | [
"- nodes.sort(key=(lambda x: x[1]))",
"- for j in range(n):",
"- i = nodes[j][0]",
"- if j - 1 >= 0:",
"- i1 = nodes[j - 1][0]",
"- adj[i].append(i1)",
"- if j + 1 < n:",
"- i1 = nodes[j + 1][0]",
"- adj[i].append(i1)",
"- n... | false | 0.057547 | 0.036273 | 1.586516 | [
"s042261609",
"s777524458"
] |
u312025627 | p03426 | python | s764300216 | s715152936 | 388 | 346 | 88,552 | 69,216 | Accepted | Accepted | 10.82 | def main():
import sys
input = sys.stdin.buffer.readline
read = sys.stdin.read
H, W, D = (int(i) for i in input().split())
R = [r for r in read().rstrip().split('\n')]
A = [[int(i) for i in r.split()] for r in R[:H]]
B = [0]*(H*W+1)
pos = {A[i][j]: (i+1, j+1) for i in range(H) ... | def main():
import sys
input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
H, W, D = (int(i) for i in input().split())
R = [r for r in read().rstrip().split(b'\n')]
A = [[int(i) for i in r.split()] for r in R[:H]]
B = [0]*(H*W+1)
pos = {A[i][j]: (i+1, j+1) for i in r... | 24 | 24 | 647 | 655 | def main():
import sys
input = sys.stdin.buffer.readline
read = sys.stdin.read
H, W, D = (int(i) for i in input().split())
R = [r for r in read().rstrip().split("\n")]
A = [[int(i) for i in r.split()] for r in R[:H]]
B = [0] * (H * W + 1)
pos = {A[i][j]: (i + 1, j + 1) for i in range(H)... | def main():
import sys
input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
H, W, D = (int(i) for i in input().split())
R = [r for r in read().rstrip().split(b"\n")]
A = [[int(i) for i in r.split()] for r in R[:H]]
B = [0] * (H * W + 1)
pos = {A[i][j]: (i + 1, j + 1) for i in ... | false | 0 | [
"- read = sys.stdin.read",
"+ read = sys.stdin.buffer.read",
"- R = [r for r in read().rstrip().split(\"\\n\")]",
"+ R = [r for r in read().rstrip().split(b\"\\n\")]"
] | false | 0.037691 | 0.132511 | 0.284435 | [
"s764300216",
"s715152936"
] |
u906501980 | p03161 | python | s439668751 | s819640056 | 1,803 | 1,449 | 13,980 | 15,848 | Accepted | Accepted | 19.63 | def main():
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
dp = [None]*n
dp[0], dp[1] = 0, abs(h[0]-h[1])
for i in range(2, n):
di = 10**9
hi = h[i]
for j in range(max(0, i-k), i):
dj = dp[j] + abs(h[j]-hi)
if di >... | def main():
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
m = [0 if i<k else i-k for i in range(2, n)]
dp = [None]*n
dp[0], dp[1] = 0, abs(h[0]-h[1])
for i, (hi, mi) in enumerate(zip(h[2:], m), 2):
di = 10**9
for dj, hj in zip(dp[mi:i], h[mi:i... | 17 | 17 | 424 | 479 | def main():
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
dp = [None] * n
dp[0], dp[1] = 0, abs(h[0] - h[1])
for i in range(2, n):
di = 10**9
hi = h[i]
for j in range(max(0, i - k), i):
dj = dp[j] + abs(h[j] - hi)
if di > d... | def main():
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
m = [0 if i < k else i - k for i in range(2, n)]
dp = [None] * n
dp[0], dp[1] = 0, abs(h[0] - h[1])
for i, (hi, mi) in enumerate(zip(h[2:], m), 2):
di = 10**9
for dj, hj in zip(dp[mi:i], h[mi:i... | false | 0 | [
"+ m = [0 if i < k else i - k for i in range(2, n)]",
"- for i in range(2, n):",
"+ for i, (hi, mi) in enumerate(zip(h[2:], m), 2):",
"- hi = h[i]",
"- for j in range(max(0, i - k), i):",
"- dj = dp[j] + abs(h[j] - hi)",
"- if di > dj:",
"- d... | false | 0.045251 | 0.097562 | 0.463816 | [
"s439668751",
"s819640056"
] |
u197615397 | p02317 | python | s163927107 | s756373303 | 180 | 150 | 18,696 | 18,740 | Accepted | Accepted | 16.67 | import sys
from bisect import bisect_left
N = int(eval(input()))
dp = [float("inf")]*N
result = -1
for n in map(int, sys.stdin.readlines()):
i = bisect_left(dp, n)
dp[i] = n
result = i if i > result else result
print((result+1)) | import sys
from bisect import bisect_left
N = int(eval(input()))
dp = []
append = dp.append
result = -1
for n in map(int, sys.stdin.readlines()):
i = bisect_left(dp, n)
if i > result:
append(n)
result += 1
else:
dp[i] = n
print((result+1)) | 13 | 17 | 247 | 286 | import sys
from bisect import bisect_left
N = int(eval(input()))
dp = [float("inf")] * N
result = -1
for n in map(int, sys.stdin.readlines()):
i = bisect_left(dp, n)
dp[i] = n
result = i if i > result else result
print((result + 1))
| import sys
from bisect import bisect_left
N = int(eval(input()))
dp = []
append = dp.append
result = -1
for n in map(int, sys.stdin.readlines()):
i = bisect_left(dp, n)
if i > result:
append(n)
result += 1
else:
dp[i] = n
print((result + 1))
| false | 23.529412 | [
"-dp = [float(\"inf\")] * N",
"+dp = []",
"+append = dp.append",
"- dp[i] = n",
"- result = i if i > result else result",
"+ if i > result:",
"+ append(n)",
"+ result += 1",
"+ else:",
"+ dp[i] = n"
] | false | 0.038715 | 0.039762 | 0.973658 | [
"s163927107",
"s756373303"
] |
u601018334 | p04006 | python | s575079212 | s628069923 | 1,975 | 1,820 | 3,316 | 3,316 | Accepted | Accepted | 7.85 | N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a.copy()
cost = sum(s_cost)
for k in range(1,N):
for i in range(N):
if s_cost[i] > a[(i-k)%N] :
s_cost[i] = a[(i-k)%N]
if cost > k*x + sum(s_cost):
cost = k*x + sum(s_cost)
else:
... |
def solve_():
import itertools
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a.copy()
cost = sum(s_cost)
for k, i in itertools.product(list(range(1, N)), list(range(N))):
s_cost[i] = a[(i - k) % N] if s_cost[i] > a[(i - k) % N] else s_cost... | 14 | 16 | 343 | 427 | N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a.copy()
cost = sum(s_cost)
for k in range(1, N):
for i in range(N):
if s_cost[i] > a[(i - k) % N]:
s_cost[i] = a[(i - k) % N]
if cost > k * x + sum(s_cost):
cost = k * x + sum(s_cost)
else:
... | def solve_():
import itertools
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a.copy()
cost = sum(s_cost)
for k, i in itertools.product(list(range(1, N)), list(range(N))):
s_cost[i] = a[(i - k) % N] if s_cost[i] > a[(i - k) % N] else s_cost[i]
... | false | 12.5 | [
"-N, x = list(map(int, input().split()))",
"-a = list(map(int, input().split()))",
"-s_cost = a.copy()",
"-cost = sum(s_cost)",
"-for k in range(1, N):",
"- for i in range(N):",
"- if s_cost[i] > a[(i - k) % N]:",
"- s_cost[i] = a[(i - k) % N]",
"- if cost > k * x + sum(s_cos... | false | 0.047376 | 0.0598 | 0.792251 | [
"s575079212",
"s628069923"
] |
u744695362 | p02755 | python | s784320877 | s773038776 | 23 | 19 | 2,940 | 2,940 | Accepted | Accepted | 17.39 | a,b = list(map(int,input().split()))
c = -1
for i in range(20000):
if int(i*0.08) == a and int(i*0.1) == b :
c = i
break
print(c) | a,b = list(map(int,input().split()))
c = -1
for i in range(10000):
if int(i*0.08) == a and int(i*0.1) == b :
c = i
break
print(c) | 7 | 7 | 154 | 154 | a, b = list(map(int, input().split()))
c = -1
for i in range(20000):
if int(i * 0.08) == a and int(i * 0.1) == b:
c = i
break
print(c)
| a, b = list(map(int, input().split()))
c = -1
for i in range(10000):
if int(i * 0.08) == a and int(i * 0.1) == b:
c = i
break
print(c)
| false | 0 | [
"-for i in range(20000):",
"+for i in range(10000):"
] | false | 0.047326 | 0.045981 | 1.029233 | [
"s784320877",
"s773038776"
] |
u721316601 | p03239 | python | s321392787 | s037579593 | 874 | 18 | 21,260 | 3,064 | Accepted | Accepted | 97.94 | import numpy as np
N, T = list(map(int, input().split()))
s = np.array([])
for i in range(N):
s = np.append(s, np.array(list(map(int, input().split()))))
s = s.reshape((N, 2))
pos = np.where(s[:, 1] <= T)
if pos[0].shape == (0,):
print('TLE')
else:
print((int(np.sort(s[pos], axis=0)[... | N, T = list(map(int, input().split()))
ct = []
for i in range(N):
ct.append(list(map(int, input().split())))
ct.sort()
ans = 'TLE'
for i in range(N):
if ct[i][1] <= T:
ans = ct[i][0]
break
print(ans) | 18 | 14 | 326 | 239 | import numpy as np
N, T = list(map(int, input().split()))
s = np.array([])
for i in range(N):
s = np.append(s, np.array(list(map(int, input().split()))))
s = s.reshape((N, 2))
pos = np.where(s[:, 1] <= T)
if pos[0].shape == (0,):
print("TLE")
else:
print((int(np.sort(s[pos], axis=0)[0][0])))
| N, T = list(map(int, input().split()))
ct = []
for i in range(N):
ct.append(list(map(int, input().split())))
ct.sort()
ans = "TLE"
for i in range(N):
if ct[i][1] <= T:
ans = ct[i][0]
break
print(ans)
| false | 22.222222 | [
"-import numpy as np",
"-",
"-s = np.array([])",
"+ct = []",
"- s = np.append(s, np.array(list(map(int, input().split()))))",
"-s = s.reshape((N, 2))",
"-pos = np.where(s[:, 1] <= T)",
"-if pos[0].shape == (0,):",
"- print(\"TLE\")",
"-else:",
"- print((int(np.sort(s[pos], axis=0)[0][0]... | false | 0.358919 | 0.033619 | 10.676092 | [
"s321392787",
"s037579593"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.