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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u775681539 | p02803 | python | s816787681 | s105956384 | 353 | 249 | 3,440 | 45,404 | Accepted | Accepted | 29.46 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque
INF = 100000
dir = ((1, 0), (-1, 0), (0, 1), (0, -1))
def main():
H, W = list(map(int, readline().split()))
maze = []
for _ in range(H):
s = ... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque
dir = ((-1, 0), (1, 0), (0, -1), (0, 1))
def main():
h, w = list(map(int, readline().split()))
grid = []
for _ in range(h):
grid.append(readl... | 52 | 44 | 1,471 | 1,393 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque
INF = 100000
dir = ((1, 0), (-1, 0), (0, 1), (0, -1))
def main():
H, W = list(map(int, readline().split()))
maze = []
for _ in range(H):
s = readline(... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque
dir = ((-1, 0), (1, 0), (0, -1), (0, 1))
def main():
h, w = list(map(int, readline().split()))
grid = []
for _ in range(h):
grid.append(readline().rst... | false | 15.384615 | [
"-INF = 100000",
"-dir = ((1, 0), (-1, 0), (0, 1), (0, -1))",
"+dir = ((-1, 0), (1, 0), (0, -1), (0, 1))",
"- H, W = list(map(int, readline().split()))",
"- maze = []",
"- for _ in range(H):",
"- s = readline().rstrip().decode()",
"- maze.append(s)",
"-",
"- def bfs(si, s... | false | 0.05738 | 0.084143 | 0.681933 | [
"s816787681",
"s105956384"
] |
u094191970 | p03645 | python | s538976579 | s646685073 | 549 | 434 | 38,320 | 38,320 | Accepted | Accepted | 20.95 | from sys import stdin
nii=lambda:list(map(int,stdin.readline().split()))
n,m=nii()
tree=[[] for i in range(n)]
for i in range(m):
a,b=nii()
a-=1
b-=1
tree[a].append(b)
tree[b].append(a)
for i in tree[0]:
for j in tree[i]:
if j==n-1:
print('POSSIBLE')
exit()
print('IMPOSS... | from sys import stdin
nii=lambda:list(map(int,stdin.readline().split()))
def main():
n,m=nii()
tree=[[] for i in range(n)]
for i in range(m):
a,b=nii()
a-=1
b-=1
tree[a].append(b)
tree[b].append(a)
for i in tree[0]:
for j in tree[i]:
if j==n-1:
print('PO... | 19 | 23 | 320 | 399 | from sys import stdin
nii = lambda: list(map(int, stdin.readline().split()))
n, m = nii()
tree = [[] for i in range(n)]
for i in range(m):
a, b = nii()
a -= 1
b -= 1
tree[a].append(b)
tree[b].append(a)
for i in tree[0]:
for j in tree[i]:
if j == n - 1:
print("POSSIBLE")
... | from sys import stdin
nii = lambda: list(map(int, stdin.readline().split()))
def main():
n, m = nii()
tree = [[] for i in range(n)]
for i in range(m):
a, b = nii()
a -= 1
b -= 1
tree[a].append(b)
tree[b].append(a)
for i in tree[0]:
for j in tree[i]:
... | false | 17.391304 | [
"-n, m = nii()",
"-tree = [[] for i in range(n)]",
"-for i in range(m):",
"- a, b = nii()",
"- a -= 1",
"- b -= 1",
"- tree[a].append(b)",
"- tree[b].append(a)",
"-for i in tree[0]:",
"- for j in tree[i]:",
"- if j == n - 1:",
"- print(\"POSSIBLE\")",
"- ... | false | 0.045428 | 0.108827 | 0.417432 | [
"s538976579",
"s646685073"
] |
u591808161 | p02551 | python | s691351514 | s957413185 | 1,591 | 188 | 12,576 | 77,904 | Accepted | Accepted | 88.18 | import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I... | import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I... | 96 | 96 | 2,664 | 2,658 | import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
input = sys.stdin.readline
def RD():
return input().rstrip()
def F():
return float(input().rstrip())
def I... | import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
input = sys.stdin.readline
def RD():
return input().rstrip()
def F():
return float(input().rstrip())
def I... | false | 0 | [
"- Y.add(xmin + 1, -(b - 2 - temp))",
"+ Y.add(x + 1, -(b - 2 - temp))",
"- X.add(ymin + 1, -(b - 2 - temp))",
"+ X.add(y + 1, -(b - 2 - temp))"
] | false | 0.070666 | 0.042922 | 1.646357 | [
"s691351514",
"s957413185"
] |
u144913062 | p03805 | python | s625421342 | s879059588 | 214 | 182 | 44,124 | 39,792 | Accepted | Accepted | 14.95 | N, M = list(map(int, input().split()))
G = [[0] * N for _ in range(N)]
for _ in range(M):
a, b = [int(x)-1 for x in input().split()]
G[a][b] = G[b][a] = 1
visited = [False] * N
def dfs(v):
visited[v] = True
if all(visited):
visited[v] = False
return 1
ret = 0
for ... | from itertools import permutations
import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))
connected = [[False] * (N+1) for _ in range(N+1)]
for _ in range(M):
a, b = list(map(int, input().split()))
connected[a][b] = connected[b][a] = True
ans = 0
for perm in permutations(list(ra... | 23 | 19 | 488 | 500 | N, M = list(map(int, input().split()))
G = [[0] * N for _ in range(N)]
for _ in range(M):
a, b = [int(x) - 1 for x in input().split()]
G[a][b] = G[b][a] = 1
visited = [False] * N
def dfs(v):
visited[v] = True
if all(visited):
visited[v] = False
return 1
ret = 0
for u in range(N... | from itertools import permutations
import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))
connected = [[False] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
a, b = list(map(int, input().split()))
connected[a][b] = connected[b][a] = True
ans = 0
for perm in permutations(list(range(2,... | false | 17.391304 | [
"+from itertools import permutations",
"+import sys",
"+",
"+input = sys.stdin.readline",
"-G = [[0] * N for _ in range(N)]",
"+connected = [[False] * (N + 1) for _ in range(N + 1)]",
"- a, b = [int(x) - 1 for x in input().split()]",
"- G[a][b] = G[b][a] = 1",
"-visited = [False] * N",
"-",
... | false | 0.072284 | 0.080416 | 0.89888 | [
"s625421342",
"s879059588"
] |
u672475305 | p03546 | python | s044715429 | s776600013 | 34 | 31 | 3,188 | 3,064 | Accepted | Accepted | 8.82 | h,w = list(map(int,input().split()))
C = []
for i in range(10):
C.append(list(map(int,input().split())))
def warshall_floyd(d):
for k in range(10):
for i in range(10):
for j in range(10):
d[i][j] = min(d[i][j], d[i][k] + d[k][j])
return d
trans_map = warsh... | h,w = list(map(int,input().split()))
C = []
for i in range(10):
C.append(list(map(int,input().split())))
def warshall_floyd(d):
for k in range(10):
for i in range(10):
for j in range(10):
d[i][j] = min(d[i][j], d[i][k] + d[k][j])
return d
trans_map = war... | 25 | 23 | 540 | 518 | h, w = list(map(int, input().split()))
C = []
for i in range(10):
C.append(list(map(int, input().split())))
def warshall_floyd(d):
for k in range(10):
for i in range(10):
for j in range(10):
d[i][j] = min(d[i][j], d[i][k] + d[k][j])
return d
trans_map = warshall_floyd... | h, w = list(map(int, input().split()))
C = []
for i in range(10):
C.append(list(map(int, input().split())))
def warshall_floyd(d):
for k in range(10):
for i in range(10):
for j in range(10):
d[i][j] = min(d[i][j], d[i][k] + d[k][j])
return d
trans_map = warshall_floyd... | false | 8 | [
"-for i in range(h):",
"- line = list(map(int, input().split()))",
"- for j in range(w):",
"- num = line[j]",
"- if num == -1:",
"+for _ in range(h):",
"+ A = list(map(int, input().split()))",
"+ for a in A:",
"+ if a == -1:",
"- ans += trans_map[num][1]",
... | false | 0.046968 | 0.037987 | 1.23644 | [
"s044715429",
"s776600013"
] |
u186838327 | p03379 | python | s342074630 | s862293045 | 420 | 209 | 93,780 | 141,096 | Accepted | Accepted | 50.24 | n = int(eval(input()))
l = list(map(int, input().split()))
m = sorted(l)
for i in range(n):
if l[i] <= m[n//2-1]:
print((m[n//2]))
else:
print((m[n//2-1]))
| n = int(input())
X = list(map(int, input().split()))
import copy
Y = copy.copy(X)
L = []
U = []
X.sort()
for i in range(n):
if i < n//2:
L.append(X[i])
else:
U.append(X[i])
#print(L)
#print(U)
L_ = set(L)
U_ = set(U)
ans = [0]*n
for i, y in enumerate(Y):
if y in L_:... | 9 | 27 | 167 | 402 | n = int(eval(input()))
l = list(map(int, input().split()))
m = sorted(l)
for i in range(n):
if l[i] <= m[n // 2 - 1]:
print((m[n // 2]))
else:
print((m[n // 2 - 1]))
| n = int(input())
X = list(map(int, input().split()))
import copy
Y = copy.copy(X)
L = []
U = []
X.sort()
for i in range(n):
if i < n // 2:
L.append(X[i])
else:
U.append(X[i])
# print(L)
# print(U)
L_ = set(L)
U_ = set(U)
ans = [0] * n
for i, y in enumerate(Y):
if y in L_:
ans[i] = U... | false | 66.666667 | [
"-n = int(eval(input()))",
"-l = list(map(int, input().split()))",
"-m = sorted(l)",
"+n = int(input())",
"+X = list(map(int, input().split()))",
"+import copy",
"+",
"+Y = copy.copy(X)",
"+L = []",
"+U = []",
"+X.sort()",
"- if l[i] <= m[n // 2 - 1]:",
"- print((m[n // 2]))",
"+... | false | 0.039516 | 0.092571 | 0.426875 | [
"s342074630",
"s862293045"
] |
u532966492 | p03053 | python | s364083308 | s363843255 | 999 | 869 | 178,560 | 178,560 | Accepted | Accepted | 13.01 | H,W = list(map(int,input().split()))
A = [list(str(eval(input()))) for i in range(H)]
black = []
cnt = 0
for i in range(H):
for j in range(W):
if A[i][j] == "#":
black.append([i,j])
length = len(black)
while (length < H*W):
gray = []
for l in black:
... | H,W = list(map(int,input().split()))
A = [list(str(eval(input()))) for i in range(H)]
black = []
cnt = 0
for i in range(H):
for j in range(W):
if A[i][j] == "#":
black.append([i,j])
length = len(black)
while (length < H*W):
gray = []
for l in black:
... | 45 | 44 | 1,116 | 1,088 | H, W = list(map(int, input().split()))
A = [list(str(eval(input()))) for i in range(H)]
black = []
cnt = 0
for i in range(H):
for j in range(W):
if A[i][j] == "#":
black.append([i, j])
length = len(black)
while length < H * W:
gray = []
for l in black:
if l[1] != 0:
c... | H, W = list(map(int, input().split()))
A = [list(str(eval(input()))) for i in range(H)]
black = []
cnt = 0
for i in range(H):
for j in range(W):
if A[i][j] == "#":
black.append([i, j])
length = len(black)
while length < H * W:
gray = []
for l in black:
if l[1] != 0:
c... | false | 2.222222 | [
"- c1 = (l[0], l[1] - 1)",
"+ c1 = [l[0], l[1] - 1]",
"- c2 = (l[0], l[1] + 1)",
"+ c2 = [l[0], l[1] + 1]",
"- c3 = (l[0] - 1, l[1])",
"+ c3 = [l[0] - 1, l[1]]",
"- c4 = (l[0] + 1, l[1])",
"+ c4 = [l[0] + 1, l[1]]"... | false | 0.036078 | 0.038571 | 0.935352 | [
"s364083308",
"s363843255"
] |
u072949274 | p02947 | python | s162020228 | s620164308 | 881 | 684 | 69,208 | 69,336 | Accepted | Accepted | 22.36 | n = int(eval(input()))
s = []
for _ in range(n):
s += [''.join(map(str, (sorted(list(str(eval(input())))))))]
import collections
c = collections.Counter(s)
from math import factorial
ans = 0
for x in list(c.values()):
if x >= 2:
ans += factorial(x)//(factorial(x-2)*2)
print(ans)... | n = int(eval(input()))
s = []
for _ in range(n):
s += [''.join(map(str, (sorted(list(str(eval(input())))))))]
import collections
c = collections.Counter(s)
ans = 0
for x in list(c.values()):
ans += x*(x-1)//2
print(ans)
| 19 | 16 | 303 | 231 | n = int(eval(input()))
s = []
for _ in range(n):
s += ["".join(map(str, (sorted(list(str(eval(input())))))))]
import collections
c = collections.Counter(s)
from math import factorial
ans = 0
for x in list(c.values()):
if x >= 2:
ans += factorial(x) // (factorial(x - 2) * 2)
print(ans)
| n = int(eval(input()))
s = []
for _ in range(n):
s += ["".join(map(str, (sorted(list(str(eval(input())))))))]
import collections
c = collections.Counter(s)
ans = 0
for x in list(c.values()):
ans += x * (x - 1) // 2
print(ans)
| false | 15.789474 | [
"-from math import factorial",
"-",
"- if x >= 2:",
"- ans += factorial(x) // (factorial(x - 2) * 2)",
"+ ans += x * (x - 1) // 2"
] | false | 0.087499 | 0.086835 | 1.007638 | [
"s162020228",
"s620164308"
] |
u457554982 | p02862 | python | s982348303 | s848752833 | 318 | 224 | 42,668 | 42,668 | Accepted | Accepted | 29.56 | [x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
print((0))
else:
n=int((x+y)/3)
r=y-n
if r<0 or r>n:
print((0))
else:
if r>n-r:
r=n-r
mod=1000000007
kaijo=[1]
for i in range(1,n+1):
kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
gyakugen=[pow(kaijo[n-r],mod-2,mod)]
... | [x,y]=list(map(int,input().split()))
#nCrのmodを求める
def nCrmod(n,r,mod):
if r<0 or r>n:
ans=0
else:
if r>n-r:
r=n-r
kaijo=[1] #階乗リスト作成
for i in range(1,n+1):
kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]≡i!となる。
gyakugen=[pow(kaijo[n-r],mod-2,mod)] #逆限リスト作成
for i in reversed(list(range(1,n-... | 21 | 26 | 490 | 567 | [x, y] = list(map(int, input().split()))
if ((x % 3) + (y % 3)) % 3 != 0:
print((0))
else:
n = int((x + y) / 3)
r = y - n
if r < 0 or r > n:
print((0))
else:
if r > n - r:
r = n - r
mod = 1000000007
kaijo = [1]
for i in range(1, n + 1):
... | [x, y] = list(map(int, input().split()))
# nCrのmodを求める
def nCrmod(n, r, mod):
if r < 0 or r > n:
ans = 0
else:
if r > n - r:
r = n - r
kaijo = [1] # 階乗リスト作成
for i in range(1, n + 1):
kaijo.append(kaijo[-1] * i % mod) # これで、kaijo[i]≡i!となる。
gyakuge... | false | 19.230769 | [
"+# nCrのmodを求める",
"+def nCrmod(n, r, mod):",
"+ if r < 0 or r > n:",
"+ ans = 0",
"+ else:",
"+ if r > n - r:",
"+ r = n - r",
"+ kaijo = [1] # 階乗リスト作成",
"+ for i in range(1, n + 1):",
"+ kaijo.append(kaijo[-1] * i % mod) # これで、kaijo[i]≡i!と... | false | 0.426672 | 0.179762 | 2.373543 | [
"s982348303",
"s848752833"
] |
u685263709 | p03295 | python | s954799155 | s955639973 | 696 | 459 | 65,240 | 29,848 | Accepted | Accepted | 34.05 | N, M = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(M)]
A = sorted(A, key=lambda x: x[1])
count = 0
x = 0
for a in A:
if a[0] > x:
x = a[1] - 1
count += 1
print(count)
| N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(M)]
ans = 0
AB = sorted(AB, key=lambda x: x[1])
last = 0
for i, v in enumerate(AB):
if last < v[0]:
last = v[1]-1
ans += 1
print(ans) | 13 | 14 | 252 | 256 | N, M = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(M)]
A = sorted(A, key=lambda x: x[1])
count = 0
x = 0
for a in A:
if a[0] > x:
x = a[1] - 1
count += 1
print(count)
| N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(M)]
ans = 0
AB = sorted(AB, key=lambda x: x[1])
last = 0
for i, v in enumerate(AB):
if last < v[0]:
last = v[1] - 1
ans += 1
print(ans)
| false | 7.142857 | [
"-A = [list(map(int, input().split())) for i in range(M)]",
"-A = sorted(A, key=lambda x: x[1])",
"-count = 0",
"-x = 0",
"-for a in A:",
"- if a[0] > x:",
"- x = a[1] - 1",
"- count += 1",
"-print(count)",
"+AB = [list(map(int, input().split())) for i in range(M)]",
"+ans = 0",... | false | 0.048303 | 0.039926 | 1.209796 | [
"s954799155",
"s955639973"
] |
u133936772 | p02571 | python | s202053438 | s153171974 | 63 | 49 | 9,080 | 9,112 | Accepted | Accepted | 22.22 | s,t=eval(input()),eval(input())
l=len(t)
print((l-max(sum(s[i+j]==t[j] for j in range(l)) for i in range(len(s)-l+1)))) | s,t=eval(input()),eval(input())
print((min(sum(c!=d for c,d in zip(s[i:],t)) for i in range(len(s)-len(t)+1)))) | 3 | 2 | 107 | 98 | s, t = eval(input()), eval(input())
l = len(t)
print((l - max(sum(s[i + j] == t[j] for j in range(l)) for i in range(len(s) - l + 1))))
| s, t = eval(input()), eval(input())
print((min(sum(c != d for c, d in zip(s[i:], t)) for i in range(len(s) - len(t) + 1))))
| false | 33.333333 | [
"-l = len(t)",
"-print((l - max(sum(s[i + j] == t[j] for j in range(l)) for i in range(len(s) - l + 1))))",
"+print((min(sum(c != d for c, d in zip(s[i:], t)) for i in range(len(s) - len(t) + 1))))"
] | false | 0.049323 | 0.047438 | 1.039722 | [
"s202053438",
"s153171974"
] |
u124605948 | p03425 | python | s090644428 | s060841459 | 160 | 138 | 9,656 | 10,136 | Accepted | Accepted | 13.75 | from itertools import combinations
from functools import reduce
n = int(eval(input()))
x = [0 for _ in range(5)]
for _ in range(n):
s = eval(input())
if s[0] == "M":
x[0] += 1
if s[0] == "A":
x[1] += 1
if s[0] == "R":
x[2] += 1
if s[0] == "C":
x[3] += 1... | from collections import Counter
import itertools
n = int(eval(input()))
s = [input()[0] for _ in range(n)]
cnt = Counter(s)
ans = 0
for x, y, z in itertools.combinations("MARCH", 3):
ans += cnt[x] * cnt[y] * cnt[z]
print(ans) | 26 | 11 | 485 | 235 | from itertools import combinations
from functools import reduce
n = int(eval(input()))
x = [0 for _ in range(5)]
for _ in range(n):
s = eval(input())
if s[0] == "M":
x[0] += 1
if s[0] == "A":
x[1] += 1
if s[0] == "R":
x[2] += 1
if s[0] == "C":
x[3] += 1
if s[0] =... | from collections import Counter
import itertools
n = int(eval(input()))
s = [input()[0] for _ in range(n)]
cnt = Counter(s)
ans = 0
for x, y, z in itertools.combinations("MARCH", 3):
ans += cnt[x] * cnt[y] * cnt[z]
print(ans)
| false | 57.692308 | [
"-from itertools import combinations",
"-from functools import reduce",
"+from collections import Counter",
"+import itertools",
"-x = [0 for _ in range(5)]",
"-for _ in range(n):",
"- s = eval(input())",
"- if s[0] == \"M\":",
"- x[0] += 1",
"- if s[0] == \"A\":",
"- x[1]... | false | 0.040914 | 0.137986 | 0.296508 | [
"s090644428",
"s060841459"
] |
u255317651 | p02240 | python | s776226114 | s114596695 | 770 | 710 | 23,732 | 126,980 | Accepted | Accepted | 7.79 | # -*- coding: utf-8 -*-
"""
Created on Sat Jul 14 10:14:13 2018
ALDS1_11_D
@author: maezawa
"""
n, m = list(map(int, input().split()))
v = [-1 for _ in range(n)]
stack = []
adj = [[] for _ in range(n)]
for i in range(m):
s, t = list(map(int, input().split()))
adj[s].append(t)
adj[t].append(s)... | # -*- coding: utf-8 -*-
"""
Created on Sat Jul 14 10:14:13 2018
ALDS1_11_D
@author: maezawa
"""
import sys
sys.setrecursionlimit(1000000)
n, m = list(map(int, input().split()))
v = [-1 for _ in range(n)]
stack = []
adj = [[] for _ in range(n)]
for i in range(m):
s, t = list(map(int, input().split()))... | 48 | 43 | 1,077 | 927 | # -*- coding: utf-8 -*-
"""
Created on Sat Jul 14 10:14:13 2018
ALDS1_11_D
@author: maezawa
"""
n, m = list(map(int, input().split()))
v = [-1 for _ in range(n)]
stack = []
adj = [[] for _ in range(n)]
for i in range(m):
s, t = list(map(int, input().split()))
adj[s].append(t)
adj[t].append(s)
# print(*adj, ... | # -*- coding: utf-8 -*-
"""
Created on Sat Jul 14 10:14:13 2018
ALDS1_11_D
@author: maezawa
"""
import sys
sys.setrecursionlimit(1000000)
n, m = list(map(int, input().split()))
v = [-1 for _ in range(n)]
stack = []
adj = [[] for _ in range(n)]
for i in range(m):
s, t = list(map(int, input().split()))
adj[s].ap... | false | 10.416667 | [
"+import sys",
"+",
"+sys.setrecursionlimit(1000000)",
"- stack.append(u)",
"- while stack:",
"- current = stack[-1]",
"- v[current] = color",
"- # print(u, current, stack)",
"- flag = 0",
"- for k in adj[current]:",
"- if v[k] > 0:",
"- ... | false | 0.045207 | 0.04838 | 0.934404 | [
"s776226114",
"s114596695"
] |
u879870653 | p03031 | python | s284570978 | s325471207 | 34 | 30 | 3,188 | 3,064 | Accepted | Accepted | 11.76 | N,M = list(map(int,input().split()))
S = []
for i in range(M) :
B = list(map(int,input().split()))[1:]
for i in range(len(B)) :
B[i] -= 1
S.append(B)
P = list(map(int,input().split()))
ans = 0
for bit in range((1 << N)) :
A = []
for k in range(N) :
if bit & (1 << k) :... | N,M = list(map(int,input().split()))
S = []
for i in range(M) :
L = list(map(int,input().split()))[1:]
for j in range(len(L)) :
L[j] -= 1
S.append(L)
P = list(map(int,input().split()))
ans = 0
for bit in range(1 << N) :
A = []
for k in range(N) :
if bit & (1 << k)... | 27 | 28 | 584 | 558 | N, M = list(map(int, input().split()))
S = []
for i in range(M):
B = list(map(int, input().split()))[1:]
for i in range(len(B)):
B[i] -= 1
S.append(B)
P = list(map(int, input().split()))
ans = 0
for bit in range((1 << N)):
A = []
for k in range(N):
if bit & (1 << k):
A.ap... | N, M = list(map(int, input().split()))
S = []
for i in range(M):
L = list(map(int, input().split()))[1:]
for j in range(len(L)):
L[j] -= 1
S.append(L)
P = list(map(int, input().split()))
ans = 0
for bit in range(1 << N):
A = []
for k in range(N):
if bit & (1 << k):
A.appe... | false | 3.571429 | [
"- B = list(map(int, input().split()))[1:]",
"- for i in range(len(B)):",
"- B[i] -= 1",
"- S.append(B)",
"+ L = list(map(int, input().split()))[1:]",
"+ for j in range(len(L)):",
"+ L[j] -= 1",
"+ S.append(L)",
"-for bit in range((1 << N)):",
"+for bit in range(1 <... | false | 0.085217 | 0.042849 | 1.988766 | [
"s284570978",
"s325471207"
] |
u753803401 | p02868 | python | s329211145 | s707361823 | 1,726 | 1,209 | 68,828 | 98,268 | Accepted | Accepted | 29.95 | import sys
class SegTreeMin:
def __init__(self, n, max_v):
self.n = n
n2 = 1
while n2 < n:
n2 <<= 1
self.n2 = n2
self.tree = [max_v] * (n2 << 1)
self.INF = max_v
def update(self, i, x):
i += self.n2
self.tree[i] = x
... | import sys
class AlgSegmentTreeMin:
def __init__(self, n, default_value):
self.Nelem = n
self.default_value = default_value
self.size = 1 << (n.bit_length())
self.data = [default_value] * (2 * self.size)
def build(self, raw_data):
for i, x in enumerate(raw_d... | 60 | 65 | 1,474 | 1,824 | import sys
class SegTreeMin:
def __init__(self, n, max_v):
self.n = n
n2 = 1
while n2 < n:
n2 <<= 1
self.n2 = n2
self.tree = [max_v] * (n2 << 1)
self.INF = max_v
def update(self, i, x):
i += self.n2
self.tree[i] = x
while i >... | import sys
class AlgSegmentTreeMin:
def __init__(self, n, default_value):
self.Nelem = n
self.default_value = default_value
self.size = 1 << (n.bit_length())
self.data = [default_value] * (2 * self.size)
def build(self, raw_data):
for i, x in enumerate(raw_data):
... | false | 7.692308 | [
"-class SegTreeMin:",
"- def __init__(self, n, max_v):",
"- self.n = n",
"- n2 = 1",
"- while n2 < n:",
"- n2 <<= 1",
"- self.n2 = n2",
"- self.tree = [max_v] * (n2 << 1)",
"- self.INF = max_v",
"+class AlgSegmentTreeMin:",
"+ def __init... | false | 0.048443 | 0.048066 | 1.007851 | [
"s329211145",
"s707361823"
] |
u498487134 | p02780 | python | s147467544 | s620392458 | 266 | 99 | 71,792 | 98,864 | Accepted | Accepted | 62.78 | N,K=list(map(int,input().split()))
p=list(map(int,input().split()))
S=[0]*(N+1)
for i in range(N):
S[i+1]=S[i]+p[i]
ans=0
for i in range(K,N+1):
temp=S[i]-S[i-K]
ans=max(ans,temp)
print(((ans+K)/2))
| import sys
input = sys.stdin.readline
def I(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))
def main():
mod=10**9+7
N,K=MI()
P=LI()
S=[0]*(N+1)
for i in range(N):
S[i+1]=S[i]+P[i]
... | 17 | 25 | 234 | 445 | N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
S = [0] * (N + 1)
for i in range(N):
S[i + 1] = S[i] + p[i]
ans = 0
for i in range(K, N + 1):
temp = S[i] - S[i - K]
ans = max(ans, temp)
print(((ans + K) / 2))
| import sys
input = sys.stdin.readline
def I():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def LI():
return list(map(int, input().split()))
def main():
mod = 10**9 + 7
N, K = MI()
P = LI()
S = [0] * (N + 1)
for i in range(N):
S[i + 1] = S[i... | false | 32 | [
"-N, K = list(map(int, input().split()))",
"-p = list(map(int, input().split()))",
"-S = [0] * (N + 1)",
"-for i in range(N):",
"- S[i + 1] = S[i] + p[i]",
"-ans = 0",
"-for i in range(K, N + 1):",
"- temp = S[i] - S[i - K]",
"- ans = max(ans, temp)",
"-print(((ans + K) / 2))",
"+import... | false | 0.032996 | 0.043243 | 0.763036 | [
"s147467544",
"s620392458"
] |
u726615467 | p02959 | python | s484758379 | s825839977 | 343 | 201 | 18,624 | 19,156 | Accepted | Accepted | 41.4 | inf = 10 ** 18
P = 10 ** 9 + 7
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_all = sum(A)
xi = min(A[0], B[0])
A[0] -= xi
B[0] -= xi
for i in range(N):
yi = min(B[i], A[i + 1])
A[1 + i] -= yi
B[i] -= yi
#
if i < N - 1:
x... | N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
left = min(A[i], B[i])
A[i] -= left
B[i] -= left
ans += left
right = min(A[i + 1], B[i])
A[i + 1] -= right
B[i] -= right
ans += right
print(ans) | 44 | 16 | 836 | 309 | inf = 10**18
P = 10**9 + 7
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_all = sum(A)
xi = min(A[0], B[0])
A[0] -= xi
B[0] -= xi
for i in range(N):
yi = min(B[i], A[i + 1])
A[1 + i] -= yi
B[i] -= yi
#
if i < N - 1:
xi = min(A[1 + i], B[1 + i... | N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
left = min(A[i], B[i])
A[i] -= left
B[i] -= left
ans += left
right = min(A[i + 1], B[i])
A[i + 1] -= right
B[i] -= right
ans += right
print(ans)
| false | 63.636364 | [
"-inf = 10**18",
"-P = 10**9 + 7",
"-A_all = sum(A)",
"-xi = min(A[0], B[0])",
"-A[0] -= xi",
"-B[0] -= xi",
"+ans = 0",
"- yi = min(B[i], A[i + 1])",
"- A[1 + i] -= yi",
"- B[i] -= yi",
"- #",
"- if i < N - 1:",
"- xi = min(A[1 + i], B[1 + i])",
"- A[1 + i] -=... | false | 0.048331 | 0.037652 | 1.283625 | [
"s484758379",
"s825839977"
] |
u072717685 | p03160 | python | s120715877 | s490514541 | 113 | 103 | 13,980 | 14,108 | Accepted | Accepted | 8.85 | def main():
n = int(eval(input()))
h = list(map(int,input().split()))
dp = [0] * n
dp[1] = abs(h[0]-h[1])
for i in range(2, n):
dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))
print((dp[n-1]))
if __name__ == '__main__':
main() | def main():
n = int(eval(input()))
h = tuple(map(int, input().split()))
dp = [0] * n
dp[1] = abs(h[0] - h[1])
for i1 in range(2, n):
dp[i1] = min(dp[i1-2]+abs(h[i1]-h[i1-2]),dp[i1-1]+abs(h[i1]-h[i1-1]))
print((dp[n - 1]))
if __name__ == '__main__':
main()
| 11 | 12 | 287 | 297 | def main():
n = int(eval(input()))
h = list(map(int, input().split()))
dp = [0] * n
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[n - 1]))
if __name__ == "__main__":
main()
| def main():
n = int(eval(input()))
h = tuple(map(int, input().split()))
dp = [0] * n
dp[1] = abs(h[0] - h[1])
for i1 in range(2, n):
dp[i1] = min(
dp[i1 - 2] + abs(h[i1] - h[i1 - 2]), dp[i1 - 1] + abs(h[i1] - h[i1 - 1])
)
print((dp[n - 1]))
if __name__ == "__main__"... | false | 8.333333 | [
"- h = list(map(int, input().split()))",
"+ h = tuple(map(int, input().split()))",
"- for i in range(2, n):",
"- dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))",
"+ for i1 in range(2, n):",
"+ dp[i1] = min(",
"+ dp[i1 - 2] + abs(h[i1]... | false | 0.153233 | 0.046767 | 3.276486 | [
"s120715877",
"s490514541"
] |
u596276291 | p03739 | python | s578062451 | s493301785 | 89 | 82 | 14,708 | 14,588 | Accepted | Accepted | 7.87 | from collections import defaultdict
def solve(pre_is_positive, total, ans, a_list):
for a in a_list:
total += a
if pre_is_positive:
if total == 0:
ans += 1
total = -1
elif total > 0:
ans += abs(total) + 1
... | from collections import defaultdict
def solve(pre_is_positive, a_list):
total = 0
ans = 0
for a in a_list:
total += a
if pre_is_positive and total >= 0:
ans += abs(total) + 1
total = -1
elif not pre_is_positive and total <= 0:
ans += ... | 45 | 27 | 1,167 | 601 | from collections import defaultdict
def solve(pre_is_positive, total, ans, a_list):
for a in a_list:
total += a
if pre_is_positive:
if total == 0:
ans += 1
total = -1
elif total > 0:
ans += abs(total) + 1
total... | from collections import defaultdict
def solve(pre_is_positive, a_list):
total = 0
ans = 0
for a in a_list:
total += a
if pre_is_positive and total >= 0:
ans += abs(total) + 1
total = -1
elif not pre_is_positive and total <= 0:
ans += abs(total) +... | false | 40 | [
"-def solve(pre_is_positive, total, ans, a_list):",
"+def solve(pre_is_positive, a_list):",
"+ total = 0",
"+ ans = 0",
"- if pre_is_positive:",
"- if total == 0:",
"- ans += 1",
"- total = -1",
"- elif total > 0:",
"- ... | false | 0.008565 | 0.138793 | 0.061711 | [
"s578062451",
"s493301785"
] |
u879870653 | p04034 | python | s401801576 | s073441865 | 437 | 372 | 29,044 | 4,760 | Accepted | Accepted | 14.87 | N,M = list(map(int,input().split()))
L = list(list(map(int,input().split())) for i in range(M))
A = [1 for i in range(N+1)]
red = [0 for i in range(N+1)]
red[1] = 1
ans = 1
for i in range(M) :
A[L[i][0]] -= 1
A[L[i][1]] += 1
if red[L[i][0]] == 1 :
red[L[i][1]] = 1
if A[L[i][0]] ... | N,M = list(map(int,input().split()))
L = [1 for i in range(N)]
R = [0 for i in range(N)]
R[0] = 1
for i in range(M) :
x,y = list(map(int,input().split()))
x -= 1
y -= 1
L[x] -= 1
L[y] += 1
if R[x] == 1 and R[y] == 0 :
R[y] = 1
if L[x] == 0 and R[x]... | 19 | 24 | 385 | 362 | N, M = list(map(int, input().split()))
L = list(list(map(int, input().split())) for i in range(M))
A = [1 for i in range(N + 1)]
red = [0 for i in range(N + 1)]
red[1] = 1
ans = 1
for i in range(M):
A[L[i][0]] -= 1
A[L[i][1]] += 1
if red[L[i][0]] == 1:
red[L[i][1]] = 1
if A[L[i][0]] == 0:
... | N, M = list(map(int, input().split()))
L = [1 for i in range(N)]
R = [0 for i in range(N)]
R[0] = 1
for i in range(M):
x, y = list(map(int, input().split()))
x -= 1
y -= 1
L[x] -= 1
L[y] += 1
if R[x] == 1 and R[y] == 0:
R[y] = 1
if L[x] == 0 and R[x] == 1:
R[x] = 0
print((sum... | false | 20.833333 | [
"-L = list(list(map(int, input().split())) for i in range(M))",
"-A = [1 for i in range(N + 1)]",
"-red = [0 for i in range(N + 1)]",
"-red[1] = 1",
"-ans = 1",
"+L = [1 for i in range(N)]",
"+R = [0 for i in range(N)]",
"+R[0] = 1",
"- A[L[i][0]] -= 1",
"- A[L[i][1]] += 1",
"- if red[L... | false | 0.069322 | 0.071666 | 0.967292 | [
"s401801576",
"s073441865"
] |
u352394527 | p00502 | python | s700415696 | s550188389 | 1,150 | 670 | 6,172 | 6,168 | Accepted | Accepted | 41.74 | INF = 10 ** 20
d, n = list(map(int,input().split()))
temp = [int(eval(input())) for i in range(d)]
temp.insert(0,0)
alst = []
blst = []
clst = []
for i in range(n):
a,b,c = list(map(int,input().split()))
alst.append(a)
blst.append(b)
clst.append(c)
dp = [[0] * n for i in range(d + 1)]
for i in ... | INF = 10 ** 20
def main():
d, n = list(map(int,input().split()))
temp = [int(eval(input())) for i in range(d)]
temp.insert(0,0)
alst = []
blst = []
clst = []
for i in range(n):
a,b,c = list(map(int,input().split()))
alst.append(a)
blst.append(b)
clst.append(c)
dp = [[0] ... | 26 | 32 | 575 | 725 | INF = 10**20
d, n = list(map(int, input().split()))
temp = [int(eval(input())) for i in range(d)]
temp.insert(0, 0)
alst = []
blst = []
clst = []
for i in range(n):
a, b, c = list(map(int, input().split()))
alst.append(a)
blst.append(b)
clst.append(c)
dp = [[0] * n for i in range(d + 1)]
for i in range(... | INF = 10**20
def main():
d, n = list(map(int, input().split()))
temp = [int(eval(input())) for i in range(d)]
temp.insert(0, 0)
alst = []
blst = []
clst = []
for i in range(n):
a, b, c = list(map(int, input().split()))
alst.append(a)
blst.append(b)
clst.appe... | false | 18.75 | [
"-d, n = list(map(int, input().split()))",
"-temp = [int(eval(input())) for i in range(d)]",
"-temp.insert(0, 0)",
"-alst = []",
"-blst = []",
"-clst = []",
"-for i in range(n):",
"- a, b, c = list(map(int, input().split()))",
"- alst.append(a)",
"- blst.append(b)",
"- clst.append(c)... | false | 0.038896 | 0.039151 | 0.99349 | [
"s700415696",
"s550188389"
] |
u346812984 | p03294 | python | s724566619 | s724188096 | 24 | 18 | 3,316 | 3,316 | Accepted | Accepted | 25 | N = int(eval(input()))
A = list([int(x) - 1 for x in input().split()])
print((sum(A)))
| N = int(eval(input()))
A = list(map(int, input().split()))
ans = sum(A) - N
print(ans)
| 4 | 4 | 88 | 84 | N = int(eval(input()))
A = list([int(x) - 1 for x in input().split()])
print((sum(A)))
| N = int(eval(input()))
A = list(map(int, input().split()))
ans = sum(A) - N
print(ans)
| false | 0 | [
"-A = list([int(x) - 1 for x in input().split()])",
"-print((sum(A)))",
"+A = list(map(int, input().split()))",
"+ans = sum(A) - N",
"+print(ans)"
] | false | 0.038871 | 0.039313 | 0.988766 | [
"s724566619",
"s724188096"
] |
u744920373 | p03061 | python | s300370485 | s409616412 | 1,972 | 240 | 14,632 | 14,196 | Accepted | Accepted | 87.83 | import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return list(map(int, sys.stdin.readline().split()))
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): ret... | import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return list(map(int, sys.stdin.readline().split()))
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): ret... | 94 | 42 | 2,357 | 1,149 | import sys
sys.setrecursionlimit(10**8)
def ii():
return int(sys.stdin.readline())
def mi():
return list(map(int, sys.stdin.readline().split()))
def li():
return list(map(int, sys.stdin.readline().split()))
def li2(N):
return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
de... | import sys
sys.setrecursionlimit(10**8)
def ii():
return int(sys.stdin.readline())
def mi():
return list(map(int, sys.stdin.readline().split()))
def li():
return list(map(int, sys.stdin.readline().split()))
def li2(N):
return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
de... | false | 55.319149 | [
"-from functools import reduce",
"+def gcd(a, b):",
"+ if a < b:",
"+ a, b = b, a",
"+ if b == 0:",
"+ return a",
"+ r = a % b",
"+ return gcd(b, r)",
"-def segfunc(a, b):",
"- if a == 0 or b == 0:",
"- return max(a, b)",
"- if a < b:",
"- a, b =... | false | 0.042833 | 0.050519 | 0.847853 | [
"s300370485",
"s409616412"
] |
u608088992 | p02996 | python | s404019705 | s063972010 | 859 | 500 | 41,204 | 41,196 | Accepted | Accepted | 41.79 | import sys
from operator import itemgetter
def solve():
input = sys.stdin.readline
N = int(eval(input()))
W = [[int(w) for w in input().split()] for _ in range(N)]
W.sort()
W.sort(key = itemgetter(1))
time = 0
for i, w in enumerate(W):
if time + w[0] > w[1]:
... | import sys
from operator import itemgetter
def solve():
input = sys.stdin.readline
N = int(eval(input()))
work = [[int(i) for i in input().split()] for _ in range(N)]
work.sort(key = itemgetter(1))
currentTime = 0
for i in range(N):
a, b = work[i]
if a + currentTime <... | 22 | 22 | 468 | 490 | import sys
from operator import itemgetter
def solve():
input = sys.stdin.readline
N = int(eval(input()))
W = [[int(w) for w in input().split()] for _ in range(N)]
W.sort()
W.sort(key=itemgetter(1))
time = 0
for i, w in enumerate(W):
if time + w[0] > w[1]:
print("No")
... | import sys
from operator import itemgetter
def solve():
input = sys.stdin.readline
N = int(eval(input()))
work = [[int(i) for i in input().split()] for _ in range(N)]
work.sort(key=itemgetter(1))
currentTime = 0
for i in range(N):
a, b = work[i]
if a + currentTime <= b:
... | false | 0 | [
"- W = [[int(w) for w in input().split()] for _ in range(N)]",
"- W.sort()",
"- W.sort(key=itemgetter(1))",
"- time = 0",
"- for i, w in enumerate(W):",
"- if time + w[0] > w[1]:",
"+ work = [[int(i) for i in input().split()] for _ in range(N)]",
"+ work.sort(key=itemgetter... | false | 0.070158 | 0.038207 | 1.836277 | [
"s404019705",
"s063972010"
] |
u227082700 | p03211 | python | s017383425 | s183020362 | 19 | 17 | 2,940 | 2,940 | Accepted | Accepted | 10.53 | s=eval(input());minn=1000
for i in range(len(s)-2):minn=min(abs(int(s[i:i+3])-753),minn)
print(minn) | s=eval(input())
n=len(s)
ans=10**10
for i in range(n-2):
m=int(s[i:i+3])
ans=min(ans,abs(m-753))
print(ans)
| 3 | 7 | 96 | 112 | s = eval(input())
minn = 1000
for i in range(len(s) - 2):
minn = min(abs(int(s[i : i + 3]) - 753), minn)
print(minn)
| s = eval(input())
n = len(s)
ans = 10**10
for i in range(n - 2):
m = int(s[i : i + 3])
ans = min(ans, abs(m - 753))
print(ans)
| false | 57.142857 | [
"-minn = 1000",
"-for i in range(len(s) - 2):",
"- minn = min(abs(int(s[i : i + 3]) - 753), minn)",
"-print(minn)",
"+n = len(s)",
"+ans = 10**10",
"+for i in range(n - 2):",
"+ m = int(s[i : i + 3])",
"+ ans = min(ans, abs(m - 753))",
"+print(ans)"
] | false | 0.06237 | 0.056497 | 1.103944 | [
"s017383425",
"s183020362"
] |
u855199458 | p02242 | python | s074360151 | s886236182 | 30 | 20 | 7,812 | 8,248 | Accepted | Accepted | 33.33 | # -*- coding: utf-8 -*-
N = int(eval(input()))
INF = float("inf")
adj = [[INF]*N for _ in range(N)]
for n in range(N):
inp = tuple(map(int, input().split()))
assert n == inp[0]
for i in range(inp[1]):
adj[inp[0]][inp[2*i+2]] = inp[2*i+3]
not_MST = list(range(1, N))
MST = [0]
costs =... | # -*- coding: utf-8 -*-
from heapq import heappush, heappop
N = int(eval(input()))
INF = float("inf")
adj = []
for _ in range(N):
inp = tuple(map(int, input().split()))
adj.append(tuple(zip(inp[2::2], inp[3::2])))
checked = [False for _ in range(N)]
d = [float("inf") for _ in range(N)]
d[0] = 0
... | 42 | 29 | 879 | 663 | # -*- coding: utf-8 -*-
N = int(eval(input()))
INF = float("inf")
adj = [[INF] * N for _ in range(N)]
for n in range(N):
inp = tuple(map(int, input().split()))
assert n == inp[0]
for i in range(inp[1]):
adj[inp[0]][inp[2 * i + 2]] = inp[2 * i + 3]
not_MST = list(range(1, N))
MST = [0]
costs = {n: IN... | # -*- coding: utf-8 -*-
from heapq import heappush, heappop
N = int(eval(input()))
INF = float("inf")
adj = []
for _ in range(N):
inp = tuple(map(int, input().split()))
adj.append(tuple(zip(inp[2::2], inp[3::2])))
checked = [False for _ in range(N)]
d = [float("inf") for _ in range(N)]
d[0] = 0
heap = [[0, 0]]... | false | 30.952381 | [
"+from heapq import heappush, heappop",
"+",
"-adj = [[INF] * N for _ in range(N)]",
"+adj = []",
"+for _ in range(N):",
"+ inp = tuple(map(int, input().split()))",
"+ adj.append(tuple(zip(inp[2::2], inp[3::2])))",
"+checked = [False for _ in range(N)]",
"+d = [float(\"inf\") for _ in range(N)... | false | 0.042528 | 0.046176 | 0.921 | [
"s074360151",
"s886236182"
] |
u607865971 | p03221 | python | s929756064 | s937516170 | 1,004 | 737 | 77,176 | 38,652 | Accepted | Accepted | 26.59 | import sys
import collections
import itertools
import math
import re
from collections import Counter
from collections import deque
import bisect
MOD = 10 ** 9 + 7
N, M = [int(x) for x in input().split()]
KenList = [[] for _ in range(N)]
PYlist = [None] * M
for i in range(M):
P, Y = [int(x) fo... | import sys
import collections
import itertools
import math
import re
from collections import Counter
from collections import deque
MOD = 10 ** 9 + 7
N, M = [int(x) for x in input().split()]
PYC = []
for i in range(M):
p, y = [int(x) for x in input().split()]
PYC.append((p, y, i))
PYC = sort... | 50 | 35 | 952 | 581 | import sys
import collections
import itertools
import math
import re
from collections import Counter
from collections import deque
import bisect
MOD = 10**9 + 7
N, M = [int(x) for x in input().split()]
KenList = [[] for _ in range(N)]
PYlist = [None] * M
for i in range(M):
P, Y = [int(x) for x in input().split()]
... | import sys
import collections
import itertools
import math
import re
from collections import Counter
from collections import deque
MOD = 10**9 + 7
N, M = [int(x) for x in input().split()]
PYC = []
for i in range(M):
p, y = [int(x) for x in input().split()]
PYC.append((p, y, i))
PYC = sorted(PYC)
city = {}
pCou... | false | 30 | [
"-import bisect",
"-KenList = [[] for _ in range(N)]",
"-PYlist = [None] * M",
"+PYC = []",
"- P, Y = [int(x) for x in input().split()]",
"- P = P - 1",
"- PYlist[i] = (P, Y)",
"- KenList[P].append((i, Y))",
"-for i in range(N):",
"- KenList[i] = sorted(KenList[i], key=lambda x: x[1... | false | 0.037889 | 0.038031 | 0.996252 | [
"s929756064",
"s937516170"
] |
u766477342 | p00723 | python | s921254402 | s189692167 | 190 | 60 | 6,804 | 6,792 | Accepted | Accepted | 68.42 |
def reverse(s):
return ''.join(list(reversed(s)))
m = int(eval(input()))
for i in range(m):
d = eval(input())
_set = set()
for i in range(len(d)-1):
w1 = d[:i+1]
w2 = d[i+1:]
_set.add(w1 + w2)
_set.add(w2 + w1)
_set.add(reverse(w1) + reverse(w2))
... | m = int(eval(input()))
for i in range(m):
d = eval(input())
_set = set()
for i in range(len(d)-1):
w1 = d[:i+1]
w2 = d[i+1:]
w1_r = w1[::-1]
w2_r = w2[::-1]
_set.add(w1 + w2)
_set.add(w2 + w1)
_set.add(w1_r+w2_r)
_set.add(w2_r+w1_... | 22 | 20 | 520 | 454 | def reverse(s):
return "".join(list(reversed(s)))
m = int(eval(input()))
for i in range(m):
d = eval(input())
_set = set()
for i in range(len(d) - 1):
w1 = d[: i + 1]
w2 = d[i + 1 :]
_set.add(w1 + w2)
_set.add(w2 + w1)
_set.add(reverse(w1) + reverse(w2))
... | m = int(eval(input()))
for i in range(m):
d = eval(input())
_set = set()
for i in range(len(d) - 1):
w1 = d[: i + 1]
w2 = d[i + 1 :]
w1_r = w1[::-1]
w2_r = w2[::-1]
_set.add(w1 + w2)
_set.add(w2 + w1)
_set.add(w1_r + w2_r)
_set.add(w2_r + w1_r)... | false | 9.090909 | [
"-def reverse(s):",
"- return \"\".join(list(reversed(s)))",
"-",
"-",
"+ w1_r = w1[::-1]",
"+ w2_r = w2[::-1]",
"- _set.add(reverse(w1) + reverse(w2))",
"- _set.add(reverse(w2) + reverse(w1))",
"- _set.add(w1 + reverse(w2))",
"- _set.add(w2 + reverse(w... | false | 0.035239 | 0.0369 | 0.954992 | [
"s921254402",
"s189692167"
] |
u777923818 | p03576 | python | s747866212 | s094909899 | 1,133 | 504 | 3,188 | 47,068 | Accepted | Accepted | 55.52 | # -*- coding: utf-8 -*-
from itertools import product, combinations
from operator import itemgetter
def inpl(): return tuple(map(int, input().split()))
N, K = inpl()
X = []
Y = []
Px = []
Py = []
for i in range(N):
x, y = inpl()
X.append(x)
Y.append(y)
Px.append((x, i))
Py.append((... | # -*- coding: utf-8 -*-
from itertools import product, combinations
from operator import itemgetter
def inpl(): return tuple(map(int, input().split()))
N, K = inpl()
X = []
Y = []
Px = []
Py = []
for i in range(N):
x, y = inpl()
X.append(x)
Y.append(y)
Px.append((x, i))
Py.append((... | 41 | 41 | 880 | 880 | # -*- coding: utf-8 -*-
from itertools import product, combinations
from operator import itemgetter
def inpl():
return tuple(map(int, input().split()))
N, K = inpl()
X = []
Y = []
Px = []
Py = []
for i in range(N):
x, y = inpl()
X.append(x)
Y.append(y)
Px.append((x, i))
Py.append((y, i))
X =... | # -*- coding: utf-8 -*-
from itertools import product, combinations
from operator import itemgetter
def inpl():
return tuple(map(int, input().split()))
N, K = inpl()
X = []
Y = []
Px = []
Py = []
for i in range(N):
x, y = inpl()
X.append(x)
Y.append(y)
Px.append((x, i))
Py.append((y, i))
X =... | false | 0 | [
"+ if (dX[r] - dX[l] < K - 1) or (dY[u] - dY[d] < K - 1):",
"+ continue",
"- continue",
"- if (dX[r] - dX[l] < K - 1) or (dY[u] - dY[d] < K - 1):"
] | false | 0.037335 | 0.038314 | 0.974442 | [
"s747866212",
"s094909899"
] |
u790710233 | p03722 | python | s429028259 | s792617916 | 1,634 | 370 | 3,316 | 46,316 | Accepted | Accepted | 77.36 | n, m = list(map(int, input().split()))
edges = []
for _ in range(m):
a, b, c = list(map(int, input().split()))
a -= 1
b -= 1
edges.append((a, b, -c))
init_v = 0
INF = float('inf')
dist = [INF]*n
dist[init_v] = 0
negative_cycle = 0
for i in range(2*n):
for v, v2, c in edges:
i... | n, m = list(map(int, input().split()))
edges = []
forward_edges = [[] for _ in range(n)]
for _ in range(m):
a, b, c = list(map(int, input().split()))
a -= 1
b -= 1
edges.append((a, b, -c))
forward_edges[a].append(b)
stack = [0]
can_reach = [0]*n
while stack:
v = stack.pop()
if... | 25 | 45 | 521 | 949 | n, m = list(map(int, input().split()))
edges = []
for _ in range(m):
a, b, c = list(map(int, input().split()))
a -= 1
b -= 1
edges.append((a, b, -c))
init_v = 0
INF = float("inf")
dist = [INF] * n
dist[init_v] = 0
negative_cycle = 0
for i in range(2 * n):
for v, v2, c in edges:
if dist[v2] <... | n, m = list(map(int, input().split()))
edges = []
forward_edges = [[] for _ in range(n)]
for _ in range(m):
a, b, c = list(map(int, input().split()))
a -= 1
b -= 1
edges.append((a, b, -c))
forward_edges[a].append(b)
stack = [0]
can_reach = [0] * n
while stack:
v = stack.pop()
if can_reach[v]... | false | 44.444444 | [
"+forward_edges = [[] for _ in range(n)]",
"-init_v = 0",
"-INF = float(\"inf\")",
"+ forward_edges[a].append(b)",
"+stack = [0]",
"+can_reach = [0] * n",
"+while stack:",
"+ v = stack.pop()",
"+ if can_reach[v]:",
"+ continue",
"+ can_reach[v] = 1",
"+ for v2 in forward_... | false | 0.101573 | 0.062938 | 1.613866 | [
"s429028259",
"s792617916"
] |
u629540524 | p03456 | python | s433931872 | s532244932 | 149 | 17 | 14,424 | 3,060 | Accepted | Accepted | 88.59 | import numpy as np
a,b = input().split()
n = np.sqrt(int(a+b))
if n.is_integer() == True:
print('Yes')
else:
print('No') | a,b = input().split()
n = int(a+b)**0.5
if n.is_integer() == True:
print('Yes')
else:
print('No') | 7 | 6 | 134 | 110 | import numpy as np
a, b = input().split()
n = np.sqrt(int(a + b))
if n.is_integer() == True:
print("Yes")
else:
print("No")
| a, b = input().split()
n = int(a + b) ** 0.5
if n.is_integer() == True:
print("Yes")
else:
print("No")
| false | 14.285714 | [
"-import numpy as np",
"-",
"-n = np.sqrt(int(a + b))",
"+n = int(a + b) ** 0.5"
] | false | 0.215189 | 0.056344 | 3.819202 | [
"s433931872",
"s532244932"
] |
u194894739 | p03212 | python | s816764419 | s496693616 | 73 | 38 | 3,060 | 3,060 | Accepted | Accepted | 47.95 | N = int(eval(input()))
ans = 0
p = [0]
while p:
k = p.pop()
if k > N:
continue
if '7' in str(k) and '5' in str(k) and '3' in str(k):
ans += 1
p.extend([k*10+3, k*10+5, k*10+7])
print(ans)
| import sys
sys.setrecursionlimit(10**5)
N = int(input())
def rec(num, use):
if num > N:
return 0
i = 0
if (use == 0b111):
i = 1
return rec(num*10+7, use | 0b100)\
+ rec(num*10+5, use | 0b010)\
+ rec(num*10+3, use | 0b001)\
+ i
print(rec(0,0... | 12 | 18 | 226 | 323 | N = int(eval(input()))
ans = 0
p = [0]
while p:
k = p.pop()
if k > N:
continue
if "7" in str(k) and "5" in str(k) and "3" in str(k):
ans += 1
p.extend([k * 10 + 3, k * 10 + 5, k * 10 + 7])
print(ans)
| import sys
sys.setrecursionlimit(10**5)
N = int(input())
def rec(num, use):
if num > N:
return 0
i = 0
if use == 0b111:
i = 1
return (
rec(num * 10 + 7, use | 0b100)
+ rec(num * 10 + 5, use | 0b010)
+ rec(num * 10 + 3, use | 0b001)
+ i
)
print(rec... | false | 33.333333 | [
"-N = int(eval(input()))",
"-ans = 0",
"-p = [0]",
"-while p:",
"- k = p.pop()",
"- if k > N:",
"- continue",
"- if \"7\" in str(k) and \"5\" in str(k) and \"3\" in str(k):",
"- ans += 1",
"- p.extend([k * 10 + 3, k * 10 + 5, k * 10 + 7])",
"-print(ans)",
"+import sys... | false | 0.044546 | 0.037085 | 1.201199 | [
"s816764419",
"s496693616"
] |
u646203242 | p02813 | python | s472144239 | s199053841 | 199 | 183 | 45,040 | 45,168 | Accepted | Accepted | 8.04 | import itertools
n=int(eval(input()))
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
o=0
h=0
u=list(itertools.permutations(list(range(1,n+1))))
for i in range(len(u)):
if u[i]==p:
h=i
for i in range(len(u)):
if u[i]==q:
o=i
print((abs(h-o)))
| import itertools
n=int(eval(input()))
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
o=0
h=0
u=list(itertools.permutations(list(range(1,n+1))))
for i in range(len(u)):
if u[i]==p:
h=i
if u[i]==q:
o=i
print((abs(h-o))) | 14 | 13 | 286 | 260 | import itertools
n = int(eval(input()))
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
o = 0
h = 0
u = list(itertools.permutations(list(range(1, n + 1))))
for i in range(len(u)):
if u[i] == p:
h = i
for i in range(len(u)):
if u[i] == q:
o = i
print((abs(h - o)))
| import itertools
n = int(eval(input()))
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
o = 0
h = 0
u = list(itertools.permutations(list(range(1, n + 1))))
for i in range(len(u)):
if u[i] == p:
h = i
if u[i] == q:
o = i
print((abs(h - o)))
| false | 7.142857 | [
"-for i in range(len(u)):"
] | false | 0.046312 | 0.04615 | 1.00351 | [
"s472144239",
"s199053841"
] |
u989345508 | p03625 | python | s087922056 | s028697417 | 186 | 153 | 17,684 | 17,680 | Accepted | Accepted | 17.74 | n=int(eval(input()))
b=sorted([int(i) for i in input().split()],reverse=True)
def groupby(a):
a2=[[a[0],1]]
for i in range(1,len(a)):
if a2[-1][0]==a[i]:
a2[-1][1]+=1
else:
a2.append([a[i],1])
return a2
A=groupby(b)
l=len(A)
B=[]
for i in range(l):
A... | n=int(eval(input()))
a=sorted(list(map(int,input().split())),reverse=True)
x,y=0,0
def groupby(a):
a2=[[a[0],1]]
for i in range(1,len(a)):
if a2[-1][0]==a[i]:
a2[-1][1]+=1
else:
a2.append([a[i],1])
return a2
b=groupby(a)
l=len(b)
for i in range(l):
i... | 31 | 25 | 604 | 529 | n = int(eval(input()))
b = sorted([int(i) for i in input().split()], reverse=True)
def groupby(a):
a2 = [[a[0], 1]]
for i in range(1, len(a)):
if a2[-1][0] == a[i]:
a2[-1][1] += 1
else:
a2.append([a[i], 1])
return a2
A = groupby(b)
l = len(A)
B = []
for i in range... | n = int(eval(input()))
a = sorted(list(map(int, input().split())), reverse=True)
x, y = 0, 0
def groupby(a):
a2 = [[a[0], 1]]
for i in range(1, len(a)):
if a2[-1][0] == a[i]:
a2[-1][1] += 1
else:
a2.append([a[i], 1])
return a2
b = groupby(a)
l = len(b)
for i in ra... | false | 19.354839 | [
"-b = sorted([int(i) for i in input().split()], reverse=True)",
"+a = sorted(list(map(int, input().split())), reverse=True)",
"+x, y = 0, 0",
"-A = groupby(b)",
"-l = len(A)",
"-B = []",
"+b = groupby(a)",
"+l = len(b)",
"- A[i][1] = min(A[i][1] // 2, 2)",
"- if A[i][1] != 0:",
"- B... | false | 0.071544 | 0.124531 | 0.574504 | [
"s087922056",
"s028697417"
] |
u332385682 | p03721 | python | s273534865 | s542611834 | 232 | 161 | 14,940 | 5,800 | Accepted | Accepted | 30.6 | import sys
from collections import Counter
def solve():
N, K = list(map(int, input().split()))
cntr = Counter()
for i in range(N):
ai, bi = list(map(int, sys.stdin.readline().split()))
cntr[ai] += bi
cntr = sorted(cntr.items())
# print(cntr)
cnt = 0
for a... | import sys
def solve():
N, K = list(map(int, input().split()))
cnt = [0]*(10**5 + 1)
for i in range(N):
ai, bi = list(map(int, sys.stdin.readline().split()))
cnt[ai] += bi
tot = 0
for i, cnti in enumerate(cnt):
tot += cnti
if tot >= K:
... | 26 | 22 | 449 | 382 | import sys
from collections import Counter
def solve():
N, K = list(map(int, input().split()))
cntr = Counter()
for i in range(N):
ai, bi = list(map(int, sys.stdin.readline().split()))
cntr[ai] += bi
cntr = sorted(cntr.items())
# print(cntr)
cnt = 0
for a, b in cntr:
... | import sys
def solve():
N, K = list(map(int, input().split()))
cnt = [0] * (10**5 + 1)
for i in range(N):
ai, bi = list(map(int, sys.stdin.readline().split()))
cnt[ai] += bi
tot = 0
for i, cnti in enumerate(cnt):
tot += cnti
if tot >= K:
print(i)
... | false | 15.384615 | [
"-from collections import Counter",
"- cntr = Counter()",
"+ cnt = [0] * (10**5 + 1)",
"- cntr[ai] += bi",
"- cntr = sorted(cntr.items())",
"- # print(cntr)",
"- cnt = 0",
"- for a, b in cntr:",
"- cnt += b",
"- if cnt >= K:",
"- print(a)",
"+ ... | false | 0.041939 | 0.046988 | 0.892548 | [
"s273534865",
"s542611834"
] |
u583507988 | p02971 | python | s255073733 | s342055714 | 361 | 322 | 19,092 | 91,036 | Accepted | Accepted | 10.8 | n=int(eval(input()))
a=[int(eval(input())) for i in range(n)]
c=sorted(a)
b=max(a)
for i in range(n):
if a[i]==b:
print((c[n-2]))
else:
print(b) | n=int(eval(input()))
a=[int(eval(input())) for _ in range(n)]
b=sorted(a)
if b[n-1]==b[n-2]:
for i in a:
print((b[n-1]))
else:
for i in a:
if i==b[n-1]:
print((b[n-2]))
else:
print((b[n-1])) | 9 | 12 | 150 | 211 | n = int(eval(input()))
a = [int(eval(input())) for i in range(n)]
c = sorted(a)
b = max(a)
for i in range(n):
if a[i] == b:
print((c[n - 2]))
else:
print(b)
| n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
b = sorted(a)
if b[n - 1] == b[n - 2]:
for i in a:
print((b[n - 1]))
else:
for i in a:
if i == b[n - 1]:
print((b[n - 2]))
else:
print((b[n - 1]))
| false | 25 | [
"-a = [int(eval(input())) for i in range(n)]",
"-c = sorted(a)",
"-b = max(a)",
"-for i in range(n):",
"- if a[i] == b:",
"- print((c[n - 2]))",
"- else:",
"- print(b)",
"+a = [int(eval(input())) for _ in range(n)]",
"+b = sorted(a)",
"+if b[n - 1] == b[n - 2]:",
"+ for ... | false | 0.102012 | 0.092391 | 1.104127 | [
"s255073733",
"s342055714"
] |
u576432509 | p02947 | python | s261291356 | s873424168 | 814 | 374 | 10,588 | 17,928 | Accepted | Accepted | 54.05 | n=int(eval(input()))
slist=[]
for i in range(n):
s10=eval(input())
si=[]
for ii in range(10):
si.append(s10[ii])
si.sort()
stmp=""
for ii in range(10):
stmp=stmp+si[ii]
slist.append(stmp)
slist.sort()
icnt=0
i=0
while i<=n-2:
j=i+1
jcnt=0
... |
n=int(eval(input()))
st=dict()
for i in range(n):
si=list(eval(input()))
si.sort()
si="".join(si)
if si in st:
st[si]+=1
else:
st[si]=1
icnt=0
for i in list(st.values()):
if i>1:
icnt+=i*(i-1)//2
print(icnt)
| 30 | 19 | 502 | 279 | n = int(eval(input()))
slist = []
for i in range(n):
s10 = eval(input())
si = []
for ii in range(10):
si.append(s10[ii])
si.sort()
stmp = ""
for ii in range(10):
stmp = stmp + si[ii]
slist.append(stmp)
slist.sort()
icnt = 0
i = 0
while i <= n - 2:
j = i + 1
jcnt = 0
... | n = int(eval(input()))
st = dict()
for i in range(n):
si = list(eval(input()))
si.sort()
si = "".join(si)
if si in st:
st[si] += 1
else:
st[si] = 1
icnt = 0
for i in list(st.values()):
if i > 1:
icnt += i * (i - 1) // 2
print(icnt)
| false | 36.666667 | [
"-slist = []",
"+st = dict()",
"- s10 = eval(input())",
"- si = []",
"- for ii in range(10):",
"- si.append(s10[ii])",
"+ si = list(eval(input()))",
"- stmp = \"\"",
"- for ii in range(10):",
"- stmp = stmp + si[ii]",
"- slist.append(stmp)",
"-slist.sort()",
... | false | 0.039297 | 0.037042 | 1.060898 | [
"s261291356",
"s873424168"
] |
u263830634 | p02939 | python | s027774041 | s092413191 | 269 | 165 | 153,808 | 12,424 | Accepted | Accepted | 38.66 | import sys
sys.setrecursionlimit(10 ** 7)
S = ['0'] + list(eval(input()))
def g(i):
if i == 0:
return 0
if i == 1:
return 1
if i == 2:
if S[2] == S[1]:
return 1
else:
return 2
if S[i] == S[i - 1]:
return g(i - 3) ... | S = ['0'] + list(eval(input()))
ans_lst = [0] * (len(S) + 10)
ans_lst[0] = 0
ans_lst[1] = 1
ans_lst[2] = 1 if S[2] == S[1] else 2
for i in range(3, len(S)):
if S[i] == S[i - 1]:
ans_lst[i] = max(ans_lst[i], ans_lst[i - 3] + 2)
else:
ans_lst[i] = max(ans_lst[i], ans_lst[i - 1] + 1)
... | 21 | 14 | 417 | 343 | import sys
sys.setrecursionlimit(10**7)
S = ["0"] + list(eval(input()))
def g(i):
if i == 0:
return 0
if i == 1:
return 1
if i == 2:
if S[2] == S[1]:
return 1
else:
return 2
if S[i] == S[i - 1]:
return g(i - 3) + 2
if S[i] != S[i - 1... | S = ["0"] + list(eval(input()))
ans_lst = [0] * (len(S) + 10)
ans_lst[0] = 0
ans_lst[1] = 1
ans_lst[2] = 1 if S[2] == S[1] else 2
for i in range(3, len(S)):
if S[i] == S[i - 1]:
ans_lst[i] = max(ans_lst[i], ans_lst[i - 3] + 2)
else:
ans_lst[i] = max(ans_lst[i], ans_lst[i - 1] + 1)
print((ans_lst... | false | 33.333333 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**7)",
"-",
"-",
"-def g(i):",
"- if i == 0:",
"- return 0",
"- if i == 1:",
"- return 1",
"- if i == 2:",
"- if S[2] == S[1]:",
"- return 1",
"- else:",
"- return 2",
"+ans_lst = [... | false | 0.040343 | 0.074157 | 0.544018 | [
"s027774041",
"s092413191"
] |
u968166680 | p02549 | python | s855986451 | s400244451 | 256 | 103 | 70,192 | 75,204 | Accepted | Accepted | 59.77 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 998244353
class BIT:
def __init__(self, n):
self.n = n
self.data = [0] * (n + 1)
self.step = pow(2, n.bit_length() - 1)
de... | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 998244353
def main():
N, K, *LR = list(map(int, read().split()))
interval = [(l, r) for l, r in zip(*[iter(LR)] * 2)]
dp = [0] * (N + 2)
dp... | 56 | 32 | 1,159 | 654 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 998244353
class BIT:
def __init__(self, n):
self.n = n
self.data = [0] * (n + 1)
self.step = pow(2, n.bit_length() - 1)
def add(self, i, x=1... | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 998244353
def main():
N, K, *LR = list(map(int, read().split()))
interval = [(l, r) for l, r in zip(*[iter(LR)] * 2)]
dp = [0] * (N + 2)
dp[1] = 1
dp[2] ... | false | 42.857143 | [
"-class BIT:",
"- def __init__(self, n):",
"- self.n = n",
"- self.data = [0] * (n + 1)",
"- self.step = pow(2, n.bit_length() - 1)",
"-",
"- def add(self, i, x=1):",
"- i += 1",
"- while i <= self.n:",
"- self.data[i] += x",
"- i +=... | false | 0.041813 | 0.044823 | 0.93285 | [
"s855986451",
"s400244451"
] |
u127499732 | p03837 | python | s179466889 | s497385531 | 315 | 63 | 9,352 | 9,288 | Accepted | Accepted | 80 | def main():
n, m, *abc = list(map(int, open(0).read().split()))
d = [[float("Inf")] * (n + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
d[i][i] = 0
for a, b, c in zip(*[iter(abc)] * 3):
d[a][b] = c
d[b][a] = c
for k in range(1, n + 1):
for i in r... | import heapq
def dijkstra(n, s, g):
h = [(0, s)]
heapq.heapify(h)
cost = [float("Inf")] * (n + 1) # cost: i -> j
cost[s] = 0
while h:
c, v = heapq.heappop(h)
if c > cost[v]:
continue
for d, u in g[v]:
d_s_u = d + cost[v]
... | 26 | 42 | 595 | 873 | def main():
n, m, *abc = list(map(int, open(0).read().split()))
d = [[float("Inf")] * (n + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
d[i][i] = 0
for a, b, c in zip(*[iter(abc)] * 3):
d[a][b] = c
d[b][a] = c
for k in range(1, n + 1):
for i in range(1, n + 1):... | import heapq
def dijkstra(n, s, g):
h = [(0, s)]
heapq.heapify(h)
cost = [float("Inf")] * (n + 1) # cost: i -> j
cost[s] = 0
while h:
c, v = heapq.heappop(h)
if c > cost[v]:
continue
for d, u in g[v]:
d_s_u = d + cost[v]
if d_s_u < cost[... | false | 38.095238 | [
"+import heapq",
"+",
"+",
"+def dijkstra(n, s, g):",
"+ h = [(0, s)]",
"+ heapq.heapify(h)",
"+ cost = [float(\"Inf\")] * (n + 1) # cost: i -> j",
"+ cost[s] = 0",
"+ while h:",
"+ c, v = heapq.heappop(h)",
"+ if c > cost[v]:",
"+ continue",
"+ ... | false | 0.041893 | 0.036053 | 1.161957 | [
"s179466889",
"s497385531"
] |
u934442292 | p02802 | python | s278545023 | s313570513 | 293 | 91 | 14,896 | 21,340 | Accepted | Accepted | 68.94 | N, M = list(map(int, input().split()))
p = [0] * M
S = [0] * M
for i in range(M):
line = input().split()
p[i] = int(line[0])
S[i] = line[1]
AC = [False for _ in range(N)]
WA = [0 for _ in range(N)]
for i in range(M):
if AC[p[i] - 1]:
pass
else:
if S[i] == "AC":
... | import sys
input = sys.stdin.readline
def main():
N, M = list(map(int, input().split()))
P = [0] * M
S = [""] * M
for i in range(M):
PS = input().split()
P[i], S[i] = int(PS[0]), PS[1]
AC = [False] * (N + 1)
WA = [0] * (N + 1)
n_AC = 0
n_WA = 0
fo... | 26 | 32 | 515 | 583 | N, M = list(map(int, input().split()))
p = [0] * M
S = [0] * M
for i in range(M):
line = input().split()
p[i] = int(line[0])
S[i] = line[1]
AC = [False for _ in range(N)]
WA = [0 for _ in range(N)]
for i in range(M):
if AC[p[i] - 1]:
pass
else:
if S[i] == "AC":
AC[p[i] - ... | import sys
input = sys.stdin.readline
def main():
N, M = list(map(int, input().split()))
P = [0] * M
S = [""] * M
for i in range(M):
PS = input().split()
P[i], S[i] = int(PS[0]), PS[1]
AC = [False] * (N + 1)
WA = [0] * (N + 1)
n_AC = 0
n_WA = 0
for p, s in zip(P, S... | false | 18.75 | [
"-N, M = list(map(int, input().split()))",
"-p = [0] * M",
"-S = [0] * M",
"-for i in range(M):",
"- line = input().split()",
"- p[i] = int(line[0])",
"- S[i] = line[1]",
"-AC = [False for _ in range(N)]",
"-WA = [0 for _ in range(N)]",
"-for i in range(M):",
"- if AC[p[i] - 1]:",
... | false | 0.040506 | 0.061953 | 0.653811 | [
"s278545023",
"s313570513"
] |
u614314290 | p02960 | python | s001927664 | s281881807 | 1,039 | 712 | 162,312 | 66,268 | Accepted | Accepted | 31.47 | import sys
sys.setrecursionlimit(1000000)
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque, Counter as cnt
# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def ... | import sys
sys.setrecursionlimit(1000000)
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque, Counter as cnt
# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def ... | 59 | 60 | 1,552 | 1,594 | import sys
sys.setrecursionlimit(1000000)
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque, Counter as cnt
# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps... | import sys
sys.setrecursionlimit(1000000)
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque, Counter as cnt
# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps... | false | 1.666667 | [
"- dp = [[mod(0) for _ in range(13)] for _ in range(len(S) + 1)]",
"- dp[0][0].v = 1",
"+ dp = [[0 for _ in range(13)] for _ in range(len(S) + 1)]",
"+ dp[0][0] = 1",
"+ dp[i][(n * 10 + m) % 13] %= MOD"
] | false | 0.042951 | 0.037222 | 1.153926 | [
"s001927664",
"s281881807"
] |
u819135704 | p03600 | python | s426307654 | s555113660 | 1,407 | 386 | 38,356 | 38,124 | Accepted | Accepted | 72.57 | from numpy import *
N = int(eval(input()))
A = array([input().split() for _ in range(N)], dtype=int64).reshape(N,N)
fill_diagonal(A, 10**9)
ans = 0
for i in range(N):
for j in range(i+1,N):
d = min(A[i]+A[j])
if A[i][j] < d:
ans += A[i][j]
elif d < A[i][j]:
print((-1))
ex... | import numpy as np
N = int(eval(input()))
A = np.array([input().split() for _ in range(N)], dtype=np.int64)
np.fill_diagonal(A, 10**9)
ans = 0
for i in range(N):
for j in range(i+1,N):
d = np.min(A[i]+A[j])
if A[i][j] < d:
ans += A[i][j]
elif d < A[i][j]:
print((-1))
exit... | 17 | 17 | 331 | 329 | from numpy import *
N = int(eval(input()))
A = array([input().split() for _ in range(N)], dtype=int64).reshape(N, N)
fill_diagonal(A, 10**9)
ans = 0
for i in range(N):
for j in range(i + 1, N):
d = min(A[i] + A[j])
if A[i][j] < d:
ans += A[i][j]
elif d < A[i][j]:
pri... | import numpy as np
N = int(eval(input()))
A = np.array([input().split() for _ in range(N)], dtype=np.int64)
np.fill_diagonal(A, 10**9)
ans = 0
for i in range(N):
for j in range(i + 1, N):
d = np.min(A[i] + A[j])
if A[i][j] < d:
ans += A[i][j]
elif d < A[i][j]:
print(... | false | 0 | [
"-from numpy import *",
"+import numpy as np",
"-A = array([input().split() for _ in range(N)], dtype=int64).reshape(N, N)",
"-fill_diagonal(A, 10**9)",
"+A = np.array([input().split() for _ in range(N)], dtype=np.int64)",
"+np.fill_diagonal(A, 10**9)",
"- d = min(A[i] + A[j])",
"+ d = n... | false | 0.4262 | 0.247061 | 1.725078 | [
"s426307654",
"s555113660"
] |
u548976218 | p02713 | python | s522641089 | s688467588 | 1,326 | 454 | 73,892 | 69,356 | Accepted | Accepted | 65.76 | n = int(eval(input()))
def gcd(a,b):
while b:
a, b = b, a % b
return a
ans = 0
if n == 1:
ans = 1
else:
for i in range(n):
i = i + 1
for j in range(n):
j = j + 1
for k in range(n):
k = k + 1
ij = gcd(i,j)
... | import math
n = int(eval(input()))
ans = 0
if n == 1:
ans = 1
else:
for i in range(n):
i = i + 1
for j in range(n):
j = j + 1
for k in range(n):
k = k + 1
ij = math.gcd(i,j)
ans = ans + math.gcd(ij,k)
print... | 21 | 17 | 367 | 320 | n = int(eval(input()))
def gcd(a, b):
while b:
a, b = b, a % b
return a
ans = 0
if n == 1:
ans = 1
else:
for i in range(n):
i = i + 1
for j in range(n):
j = j + 1
for k in range(n):
k = k + 1
ij = gcd(i, j)
... | import math
n = int(eval(input()))
ans = 0
if n == 1:
ans = 1
else:
for i in range(n):
i = i + 1
for j in range(n):
j = j + 1
for k in range(n):
k = k + 1
ij = math.gcd(i, j)
ans = ans + math.gcd(ij, k)
print(ans)
| false | 19.047619 | [
"+import math",
"+",
"-",
"-",
"-def gcd(a, b):",
"- while b:",
"- a, b = b, a % b",
"- return a",
"-",
"-",
"- ij = gcd(i, j)",
"- ans = ans + gcd(ij, k)",
"+ ij = math.gcd(i, j)",
"+ ans = ans + math.gcd(ij, k)"
] | false | 0.044542 | 0.121672 | 0.366081 | [
"s522641089",
"s688467588"
] |
u509621775 | p02936 | python | s109985071 | s545095226 | 1,101 | 974 | 58,220 | 58,512 | Accepted | Accepted | 11.53 | from sys import stdin, setrecursionlimit
def main():
setrecursionlimit(2000001)
current, q = [int(x) for x in stdin.readline().split()]
tree = [[] for _ in range(current + 1)]
for _ in range(current - 1):
a, b = [int(x) for x in stdin.readline().split()]
tree[a].append(b... | from sys import stdin, setrecursionlimit
from collections import deque
def main():
setrecursionlimit(2000001)
n, q = [int(x) for x in stdin.readline().split()]
tree = [[] for _ in range(n + 1)]
for _ in range(n - 1):
a, b = [int(x) for x in stdin.readline().split()]
tre... | 37 | 38 | 875 | 893 | from sys import stdin, setrecursionlimit
def main():
setrecursionlimit(2000001)
current, q = [int(x) for x in stdin.readline().split()]
tree = [[] for _ in range(current + 1)]
for _ in range(current - 1):
a, b = [int(x) for x in stdin.readline().split()]
tree[a].append(b)
tree[... | from sys import stdin, setrecursionlimit
from collections import deque
def main():
setrecursionlimit(2000001)
n, q = [int(x) for x in stdin.readline().split()]
tree = [[] for _ in range(n + 1)]
for _ in range(n - 1):
a, b = [int(x) for x in stdin.readline().split()]
tree[a].append(b)
... | false | 2.631579 | [
"+from collections import deque",
"- current, q = [int(x) for x in stdin.readline().split()]",
"- tree = [[] for _ in range(current + 1)]",
"- for _ in range(current - 1):",
"+ n, q = [int(x) for x in stdin.readline().split()]",
"+ tree = [[] for _ in range(n + 1)]",
"+ for _ in range(... | false | 0.038093 | 0.046282 | 0.82307 | [
"s109985071",
"s545095226"
] |
u888092736 | p02947 | python | s431559693 | s175850918 | 1,625 | 557 | 74,740 | 22,500 | Accepted | Accepted | 65.72 | from collections import defaultdict, Counter
N = int(eval(input()))
dic = defaultdict(int)
ans = 0
for _ in range(N):
elem = [(k, v) for k, v in list(Counter(eval(input())).items())]
elem = tuple(sorted(elem))
ans += dic[elem]
dic[elem] += 1
print(ans)
| from collections import defaultdict
N = int(eval(input()))
dic = defaultdict(int)
ans = 0
for _ in range(N):
elem = str(sorted(eval(input())))
ans += dic[elem]
dic[elem] += 1
print(ans)
| 12 | 11 | 264 | 198 | from collections import defaultdict, Counter
N = int(eval(input()))
dic = defaultdict(int)
ans = 0
for _ in range(N):
elem = [(k, v) for k, v in list(Counter(eval(input())).items())]
elem = tuple(sorted(elem))
ans += dic[elem]
dic[elem] += 1
print(ans)
| from collections import defaultdict
N = int(eval(input()))
dic = defaultdict(int)
ans = 0
for _ in range(N):
elem = str(sorted(eval(input())))
ans += dic[elem]
dic[elem] += 1
print(ans)
| false | 8.333333 | [
"-from collections import defaultdict, Counter",
"+from collections import defaultdict",
"- elem = [(k, v) for k, v in list(Counter(eval(input())).items())]",
"- elem = tuple(sorted(elem))",
"+ elem = str(sorted(eval(input())))"
] | false | 0.036519 | 0.035775 | 1.020803 | [
"s431559693",
"s175850918"
] |
u700805562 | p02862 | python | s025153403 | s139359611 | 1,104 | 110 | 127,572 | 9,048 | Accepted | Accepted | 90.04 | def cmb(n, r, mod):
if (r < 0 or r > n):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7
nums = 10**6 # 制約に合わせよう
g1, g2, inverse = [1, 1] , [1, 1], [0, 1]
for num in range(2, nums + 1):
g1.append((g1[-1] * num) % mod)
inverse.append((-inverse[mod... | def nCr(n, r, mod):
x, y = 1, 1
for r_ in range(1, r+1):
x = x*(n+1-r_)%mod
y = y*r_%mod
return x*pow(y, mod-2, mod)%mod
x, y = list(map(int, input().split()))
mod = 10**9+7
if (x+y)%3 or 2*x<y or 2*y<x:
print((0))
else:
print((nCr((x+y)//3,(2*x-y)//3, mod))) | 20 | 13 | 527 | 298 | def cmb(n, r, mod):
if r < 0 or r > n:
return 0
r = min(r, n - r)
return g1[n] * g2[r] * g2[n - r] % mod
mod = 10**9 + 7
nums = 10**6 # 制約に合わせよう
g1, g2, inverse = [1, 1], [1, 1], [0, 1]
for num in range(2, nums + 1):
g1.append((g1[-1] * num) % mod)
inverse.append((-inverse[mod % num] * (m... | def nCr(n, r, mod):
x, y = 1, 1
for r_ in range(1, r + 1):
x = x * (n + 1 - r_) % mod
y = y * r_ % mod
return x * pow(y, mod - 2, mod) % mod
x, y = list(map(int, input().split()))
mod = 10**9 + 7
if (x + y) % 3 or 2 * x < y or 2 * y < x:
print((0))
else:
print((nCr((x + y) // 3, (2... | false | 35 | [
"-def cmb(n, r, mod):",
"- if r < 0 or r > n:",
"- return 0",
"- r = min(r, n - r)",
"- return g1[n] * g2[r] * g2[n - r] % mod",
"+def nCr(n, r, mod):",
"+ x, y = 1, 1",
"+ for r_ in range(1, r + 1):",
"+ x = x * (n + 1 - r_) % mod",
"+ y = y * r_ % mod",
"+ ... | false | 1.640913 | 0.067157 | 24.43405 | [
"s025153403",
"s139359611"
] |
u229478139 | p02397 | python | s677357399 | s642467654 | 60 | 50 | 5,616 | 5,616 | Accepted | Accepted | 16.67 | while True:
tmp=sorted(map(int,input().split()))
if tmp[0] == 0 and tmp[1]==0:
break
print((tmp[0], tmp[1]))
| while True:
x, y = list(map(int, input().split()))
if x == 0 and y == 0:
break
if x > y:
x, y = y, x
print(('{} {}'.format(x, y)))
| 5 | 7 | 131 | 161 | while True:
tmp = sorted(map(int, input().split()))
if tmp[0] == 0 and tmp[1] == 0:
break
print((tmp[0], tmp[1]))
| while True:
x, y = list(map(int, input().split()))
if x == 0 and y == 0:
break
if x > y:
x, y = y, x
print(("{} {}".format(x, y)))
| false | 28.571429 | [
"- tmp = sorted(map(int, input().split()))",
"- if tmp[0] == 0 and tmp[1] == 0:",
"+ x, y = list(map(int, input().split()))",
"+ if x == 0 and y == 0:",
"- print((tmp[0], tmp[1]))",
"+ if x > y:",
"+ x, y = y, x",
"+ print((\"{} {}\".format(x, y)))"
] | false | 0.038387 | 0.038802 | 0.989316 | [
"s677357399",
"s642467654"
] |
u562935282 | p03761 | python | s362169146 | s978816062 | 25 | 18 | 3,892 | 3,064 | Accepted | Accepted | 28 | import string
INF = float('inf')
n = int(eval(input()))
ss = [eval(input()) for _ in range(n)]
ans_d = {c: INF for c in string.ascii_lowercase} # AtoZ
for s in ss:
d = {c: 0 for c in string.ascii_lowercase} # AtoZ
for c in s:
d[c] += 1
for c in string.ascii_lowercase:
ans_d... | def main():
orda = ord('a')
N = int(eval(input()))
ctr = [50] * 26
for _ in range(N):
s = eval(input())
t = [0] * 26
for c in s:
i = ord(c) - orda
t[i] += 1
for i, cnt in enumerate(t):
ctr[i] = min(ctr[i], cnt)
a... | 19 | 41 | 416 | 798 | import string
INF = float("inf")
n = int(eval(input()))
ss = [eval(input()) for _ in range(n)]
ans_d = {c: INF for c in string.ascii_lowercase} # AtoZ
for s in ss:
d = {c: 0 for c in string.ascii_lowercase} # AtoZ
for c in s:
d[c] += 1
for c in string.ascii_lowercase:
ans_d[c] = min(ans_d... | def main():
orda = ord("a")
N = int(eval(input()))
ctr = [50] * 26
for _ in range(N):
s = eval(input())
t = [0] * 26
for c in s:
i = ord(c) - orda
t[i] += 1
for i, cnt in enumerate(t):
ctr[i] = min(ctr[i], cnt)
ans = ""
for i, c... | false | 53.658537 | [
"-import string",
"+def main():",
"+ orda = ord(\"a\")",
"+ N = int(eval(input()))",
"+ ctr = [50] * 26",
"+ for _ in range(N):",
"+ s = eval(input())",
"+ t = [0] * 26",
"+ for c in s:",
"+ i = ord(c) - orda",
"+ t[i] += 1",
"+ for... | false | 0.172706 | 0.047419 | 3.642085 | [
"s362169146",
"s978816062"
] |
u545368057 | p02798 | python | s376441569 | s292537852 | 1,525 | 963 | 3,188 | 174,628 | Accepted | Accepted | 36.85 | from itertools import combinations
n = int(eval(input()))
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
even = [] #偶数番目で表になる
odd = [] #奇数番目で表になる
for i,(a,b) in enumerate(zip(As,Bs)):
if i%2 == 0:
even.append(a)
odd.append(b)
else:
even.append... | n = int(eval(input()))
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
INF = 1<<20
dp = [[INF] * 55 for i in range(1<<n)]
dp[0][0] = 0
for b in range(1<<n):
# 使ったカードの枚数
bitcnt = bin(b).count("1")
cur = bitcnt
rest = []
for i in range(n):
# i番目のbi... | 66 | 38 | 1,538 | 899 | from itertools import combinations
n = int(eval(input()))
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
even = [] # 偶数番目で表になる
odd = [] # 奇数番目で表になる
for i, (a, b) in enumerate(zip(As, Bs)):
if i % 2 == 0:
even.append(a)
odd.append(b)
else:
even.append(b)
... | n = int(eval(input()))
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
INF = 1 << 20
dp = [[INF] * 55 for i in range(1 << n)]
dp[0][0] = 0
for b in range(1 << n):
# 使ったカードの枚数
bitcnt = bin(b).count("1")
cur = bitcnt
rest = []
for i in range(n):
# i番目のbitが立っているかの判定
... | false | 42.424242 | [
"-from itertools import combinations",
"-",
"-even = [] # 偶数番目で表になる",
"-odd = [] # 奇数番目で表になる",
"-for i, (a, b) in enumerate(zip(As, Bs)):",
"- if i % 2 == 0:",
"- even.append(a)",
"- odd.append(b)",
"- else:",
"- even.append(b)",
"- odd.append(a)",
"-",
"-... | false | 0.044605 | 0.047097 | 0.947101 | [
"s376441569",
"s292537852"
] |
u389910364 | p03719 | python | s134876227 | s299169188 | 24 | 22 | 3,568 | 3,572 | Accepted | Accepted | 8.33 | import functools
import os
import sys
sys.setrecursionlimit(10000)
INF = float('inf')
def inp():
return int(input())
def inpf():
return float(input())
def inps():
return input()
def inl():
return list(map(int, input().split()))
def inlf():
return list(map(float,... | import functools
import os
import sys
sys.setrecursionlimit(10000)
INF = float('inf')
def inp():
return int(eval(input()))
def inpf():
return float(eval(input()))
def inps():
return eval(input())
def inl():
return list(map(int, input().split()))
def inlf():
retu... | 80 | 71 | 1,297 | 979 | import functools
import os
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
def inp():
return int(input())
def inpf():
return float(input())
def inps():
return input()
def inl():
return list(map(int, input().split()))
def inlf():
return list(map(float, input().split()))
def in... | import functools
import os
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
def inp():
return int(eval(input()))
def inpf():
return float(eval(input()))
def inps():
return eval(input())
def inl():
return list(map(int, input().split()))
def inlf():
return list(map(float, input().... | false | 11.25 | [
"- return int(input())",
"+ return int(eval(input()))",
"- return float(input())",
"+ return float(eval(input()))",
"- return input()",
"+ return eval(input())",
"-def debug(fn):",
"- if not os.getenv(\"LOCAL\"):",
"- return fn",
"+def Yesif(cond):",
"+ print((\"Ye... | false | 0.056404 | 0.035563 | 1.586061 | [
"s134876227",
"s299169188"
] |
u340040203 | p02628 | python | s388505495 | s969856624 | 33 | 28 | 9,132 | 9,252 | Accepted | Accepted | 15.15 | n, k = list(map(int, input().split()))
p = sorted(list(map(int, input().split())))
print((sum(p[:k]))) | import sys
input = lambda: sys.stdin.readline().rstrip()
def main():
n, k = list(map(int, input().split()))
p = sorted(list(map(int, input().split())))
print((sum(p[:k])))
if __name__ == '__main__':
main() | 3 | 11 | 96 | 226 | n, k = list(map(int, input().split()))
p = sorted(list(map(int, input().split())))
print((sum(p[:k])))
| import sys
input = lambda: sys.stdin.readline().rstrip()
def main():
n, k = list(map(int, input().split()))
p = sorted(list(map(int, input().split())))
print((sum(p[:k])))
if __name__ == "__main__":
main()
| false | 72.727273 | [
"-n, k = list(map(int, input().split()))",
"-p = sorted(list(map(int, input().split())))",
"-print((sum(p[:k])))",
"+import sys",
"+",
"+input = lambda: sys.stdin.readline().rstrip()",
"+",
"+",
"+def main():",
"+ n, k = list(map(int, input().split()))",
"+ p = sorted(list(map(int, input()... | false | 0.100536 | 0.043556 | 2.308189 | [
"s388505495",
"s969856624"
] |
u235210692 | p02838 | python | s001140189 | s692050996 | 1,953 | 1,726 | 65,708 | 60,376 | Accepted | Accepted | 11.62 | #D問題
#ビットごとに考えられる
k=10**9+7
anslist=[]
n=int(eval(input()))
a=[format(int(i), '060b') for i in input().split()]
d=[]
for i in range(60):
b=[j[59-i] for j in a]
c=b.count("0")*b.count("1")
d.append(c*2**(i)%k)
ans=0
for i in d:
ans+=i
print((ans%k)) | n=int(eval(input()))
a=[int(i) for i in input().split()]
a_bin=[]
for i in a:
a_bin.append(format(i, '#062b')[2:])
def get_keta_num(keta,a_list):
zero=0
one=0
for i in a_list:
if i[-keta]=="0":
zero+=1
else:
one+=1
return zero*one
ans... | 20 | 26 | 280 | 419 | # D問題
# ビットごとに考えられる
k = 10**9 + 7
anslist = []
n = int(eval(input()))
a = [format(int(i), "060b") for i in input().split()]
d = []
for i in range(60):
b = [j[59 - i] for j in a]
c = b.count("0") * b.count("1")
d.append(c * 2 ** (i) % k)
ans = 0
for i in d:
ans += i
print((ans % k))
| n = int(eval(input()))
a = [int(i) for i in input().split()]
a_bin = []
for i in a:
a_bin.append(format(i, "#062b")[2:])
def get_keta_num(keta, a_list):
zero = 0
one = 0
for i in a_list:
if i[-keta] == "0":
zero += 1
else:
one += 1
return zero * one
ans = ... | false | 23.076923 | [
"-# D問題",
"-# ビットごとに考えられる",
"-k = 10**9 + 7",
"-anslist = []",
"-a = [format(int(i), \"060b\") for i in input().split()]",
"-d = []",
"-for i in range(60):",
"- b = [j[59 - i] for j in a]",
"- c = b.count(\"0\") * b.count(\"1\")",
"- d.append(c * 2 ** (i) % k)",
"+a = [int(i) for i in i... | false | 0.039086 | 0.00745 | 5.246338 | [
"s001140189",
"s692050996"
] |
u940533000 | p03294 | python | s780384304 | s685505144 | 154 | 31 | 9,380 | 9,264 | Accepted | Accepted | 79.87 | N = int(eval(input()))
a = list(map(int, input().split()))
a.sort(reverse=True)
# ユークリッドの互除法により最大公約数を求める
ans = 0
val1, val2 = a[0], a[1]
while 1:
if val1 % val2 == 0:
ans = a[0]*a[1]//val2
break
else:
tmp = val2
val2 = val1 % val2
val1 = tmp
for i in range(2, N):
val1, val2 ... | N = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(N):
ans += a[i]-1
print(ans) | 34 | 7 | 567 | 113 | N = int(eval(input()))
a = list(map(int, input().split()))
a.sort(reverse=True)
# ユークリッドの互除法により最大公約数を求める
ans = 0
val1, val2 = a[0], a[1]
while 1:
if val1 % val2 == 0:
ans = a[0] * a[1] // val2
break
else:
tmp = val2
val2 = val1 % val2
val1 = tmp
for i in range(2, N):
... | N = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(N):
ans += a[i] - 1
print(ans)
| false | 79.411765 | [
"-a.sort(reverse=True)",
"-# ユークリッドの互除法により最大公約数を求める",
"-val1, val2 = a[0], a[1]",
"-while 1:",
"- if val1 % val2 == 0:",
"- ans = a[0] * a[1] // val2",
"- break",
"- else:",
"- tmp = val2",
"- val2 = val1 % val2",
"- val1 = tmp",
"-for i in range(2, N):... | false | 0.082793 | 0.037259 | 2.222132 | [
"s780384304",
"s685505144"
] |
u812576525 | p03309 | python | s473832819 | s733828483 | 259 | 238 | 26,016 | 26,708 | Accepted | Accepted | 8.11 | N = int(eval(input()))
A = list(map(int,input().split()))
#Bi = Ai - iなる数列Bを作成し、ソートした数列の変化点となる値をxとする。これが、悲しさを最小値とする’b’となる。
B = []
for i in range(N):
b = A[i] -(i + 1)
B.append(b)
B = sorted(B,reverse = False)
x = B[N//2]
ans = 0
for i in range(N):
ans += abs(A[i]-(x + i + 1))
print(ans) | n = int(eval(input()))
a = list(map(int,input().split()))
aa = []
for i in range(n):
aa.append(a[i]-i)
b = (sorted(aa)[n//2])
ans = 0
for i in range(n):
ans += abs(a[i]-(b+i))
print(ans) | 17 | 11 | 313 | 199 | N = int(eval(input()))
A = list(map(int, input().split()))
# Bi = Ai - iなる数列Bを作成し、ソートした数列の変化点となる値をxとする。これが、悲しさを最小値とする’b’となる。
B = []
for i in range(N):
b = A[i] - (i + 1)
B.append(b)
B = sorted(B, reverse=False)
x = B[N // 2]
ans = 0
for i in range(N):
ans += abs(A[i] - (x + i + 1))
print(ans)
| n = int(eval(input()))
a = list(map(int, input().split()))
aa = []
for i in range(n):
aa.append(a[i] - i)
b = sorted(aa)[n // 2]
ans = 0
for i in range(n):
ans += abs(a[i] - (b + i))
print(ans)
| false | 35.294118 | [
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-# Bi = Ai - iなる数列Bを作成し、ソートした数列の変化点となる値をxとする。これが、悲しさを最小値とする’b’となる。",
"-B = []",
"-for i in range(N):",
"- b = A[i] - (i + 1)",
"- B.append(b)",
"-B = sorted(B, reverse=False)",
"-x = B[N // 2]",
"+n = int(eval(input()))",
... | false | 0.040713 | 0.047447 | 0.858069 | [
"s473832819",
"s733828483"
] |
u620868411 | p03776 | python | s275933544 | s246653261 | 58 | 19 | 5,976 | 3,064 | Accepted | Accepted | 67.24 | # -*- coding: utf-8 -*-
from statistics import mean
from math import factorial as fact
n,a,b = list(map(int, input().split()))
v = sorted([int(x) for x in input().split()], reverse=True)
sel = v[:a]
print((mean(sel)))
vn = v.count(sel[-1])
na = sel.count(sel[-1])
nb = min(b-a, vn-na)
# print(na,nb,vn,len(... | # -*- coding: utf-8 -*-
from math import factorial as fact
def comb(n,r):
return fact(n) // (fact(r)*fact(n-r))
n,a,b = list(map(int, input().split()))
vl = list(map(int, input().split()))
vl.sort(reverse=True)
res_avg = sum(vl[:a])/a
res_cnt = 0
last_v = vl[a-1]
cnt_all = 0
for v in vl:
if v=... | 23 | 28 | 537 | 605 | # -*- coding: utf-8 -*-
from statistics import mean
from math import factorial as fact
n, a, b = list(map(int, input().split()))
v = sorted([int(x) for x in input().split()], reverse=True)
sel = v[:a]
print((mean(sel)))
vn = v.count(sel[-1])
na = sel.count(sel[-1])
nb = min(b - a, vn - na)
# print(na,nb,vn,len(sel),se... | # -*- coding: utf-8 -*-
from math import factorial as fact
def comb(n, r):
return fact(n) // (fact(r) * fact(n - r))
n, a, b = list(map(int, input().split()))
vl = list(map(int, input().split()))
vl.sort(reverse=True)
res_avg = sum(vl[:a]) / a
res_cnt = 0
last_v = vl[a - 1]
cnt_all = 0
for v in vl:
if v == ... | false | 17.857143 | [
"-from statistics import mean",
"+",
"+def comb(n, r):",
"+ return fact(n) // (fact(r) * fact(n - r))",
"+",
"+",
"-v = sorted([int(x) for x in input().split()], reverse=True)",
"-sel = v[:a]",
"-print((mean(sel)))",
"-vn = v.count(sel[-1])",
"-na = sel.count(sel[-1])",
"-nb = min(b - a, vn... | false | 0.048008 | 0.042362 | 1.13329 | [
"s275933544",
"s246653261"
] |
u025501820 | p02691 | python | s130708676 | s497339686 | 328 | 219 | 73,760 | 61,436 | Accepted | Accepted | 33.23 | from collections import defaultdict
N = int(eval(input()))
A = list(map(int, input().split()))
cnt1 = defaultdict(int)
cnt2 = defaultdict(int)
for i in range(N):
cnt1[A[i] + i + 1] += 1
cnt2[i + 1 - A[i]] += 1
ans = 0
for k, v in list(cnt1.items()):
ans += v * cnt2[k]
print(ans) | from collections import defaultdict
N = int(eval(input()))
A = list(map(int, input().split()))
cnt = defaultdict(int)
ans = 0
for i, x in enumerate(A, 1):
# print(i, x)
ans += cnt[i - x]
cnt[x + i] += 1
print(ans) | 12 | 10 | 290 | 228 | from collections import defaultdict
N = int(eval(input()))
A = list(map(int, input().split()))
cnt1 = defaultdict(int)
cnt2 = defaultdict(int)
for i in range(N):
cnt1[A[i] + i + 1] += 1
cnt2[i + 1 - A[i]] += 1
ans = 0
for k, v in list(cnt1.items()):
ans += v * cnt2[k]
print(ans)
| from collections import defaultdict
N = int(eval(input()))
A = list(map(int, input().split()))
cnt = defaultdict(int)
ans = 0
for i, x in enumerate(A, 1):
# print(i, x)
ans += cnt[i - x]
cnt[x + i] += 1
print(ans)
| false | 16.666667 | [
"-cnt1 = defaultdict(int)",
"-cnt2 = defaultdict(int)",
"-for i in range(N):",
"- cnt1[A[i] + i + 1] += 1",
"- cnt2[i + 1 - A[i]] += 1",
"+cnt = defaultdict(int)",
"-for k, v in list(cnt1.items()):",
"- ans += v * cnt2[k]",
"+for i, x in enumerate(A, 1):",
"+ # print(i, x)",
"+ an... | false | 0.050244 | 0.048208 | 1.042232 | [
"s130708676",
"s497339686"
] |
u695811449 | p02635 | python | s337134145 | s834839181 | 2,706 | 996 | 177,108 | 73,068 | Accepted | Accepted | 63.19 | import sys
input = sys.stdin.readline
S,K=input().split()
K=int(K)
mod=998244353
LEN=len(S)
ONES=[]
Z=0
for s in S:
if s=="0":
Z+=1
else:
ONES.append(Z)
if ONES==[]:
print((1))
sys.exit()
O=len(ONES)
Z=ONES[-1]
DP=[[0]*(O+1) for i in range(min(O,K)+1)]
DP[0... | import sys
input = sys.stdin.readline
S,K=input().split()
K=int(K)
mod=998244353
LEN=len(S)
ONES=[]
Z=0
for s in S:
if s=="0":
Z+=1
else:
ONES.append(Z)
if ONES==[]:
print((1))
sys.exit()
O=len(ONES)
Z=ONES[-1]
DP=[[0]*(O+1) for i in range(min(O,K)+1)]
DP[0... | 52 | 52 | 907 | 941 | import sys
input = sys.stdin.readline
S, K = input().split()
K = int(K)
mod = 998244353
LEN = len(S)
ONES = []
Z = 0
for s in S:
if s == "0":
Z += 1
else:
ONES.append(Z)
if ONES == []:
print((1))
sys.exit()
O = len(ONES)
Z = ONES[-1]
DP = [[0] * (O + 1) for i in range(min(O, K) + 1)]
DP... | import sys
input = sys.stdin.readline
S, K = input().split()
K = int(K)
mod = 998244353
LEN = len(S)
ONES = []
Z = 0
for s in S:
if s == "0":
Z += 1
else:
ONES.append(Z)
if ONES == []:
print((1))
sys.exit()
O = len(ONES)
Z = ONES[-1]
DP = [[0] * (O + 1) for i in range(min(O, K) + 1)]
DP... | false | 0 | [
"- NDP[i + max(0, oku - c)][c + j - oku] += DP[i][j]",
"+ NDP[i + max(0, oku - c)][c + j - oku] = (",
"+ NDP[i + max(0, oku - c)][c + j - oku] + DP[i][j]",
"+ ) % mod"
] | false | 0.086539 | 0.216619 | 0.399497 | [
"s337134145",
"s834839181"
] |
u863397945 | p03035 | python | s013730400 | s787293059 | 26 | 24 | 9,096 | 9,164 | Accepted | Accepted | 7.69 | A,B = list(map(int,input().split()))
if A >= 13:
print(B)
elif 6<=A<=12:
print((B//2))
else:
print("0") | #! python3
# solve127A.py
age,cost = list(map(int,input().split()))
if age <= 5:
cost = 0
elif 6 <= age <= 12:
cost = cost//2
elif 7 <= age:
cost = cost
print(cost) | 8 | 13 | 110 | 186 | A, B = list(map(int, input().split()))
if A >= 13:
print(B)
elif 6 <= A <= 12:
print((B // 2))
else:
print("0")
| #! python3
# solve127A.py
age, cost = list(map(int, input().split()))
if age <= 5:
cost = 0
elif 6 <= age <= 12:
cost = cost // 2
elif 7 <= age:
cost = cost
print(cost)
| false | 38.461538 | [
"-A, B = list(map(int, input().split()))",
"-if A >= 13:",
"- print(B)",
"-elif 6 <= A <= 12:",
"- print((B // 2))",
"-else:",
"- print(\"0\")",
"+#! python3",
"+# solve127A.py",
"+age, cost = list(map(int, input().split()))",
"+if age <= 5:",
"+ cost = 0",
"+elif 6 <= age <= 12... | false | 0.038747 | 0.044372 | 0.873223 | [
"s013730400",
"s787293059"
] |
u997521090 | p03704 | python | s522790611 | s630154944 | 16 | 14 | 3,060 | 2,936 | Accepted | Accepted | 12.5 | import itertools as ite
import math
import random
INF = 10 ** 18
MOD = 10 ** 9 + 7
def func(diff, cnt9, cnt0):
if cnt9 <= 0:
return (diff == 0)
num = int("9" * cnt9 + "0" * cnt0)
return sum(func(diff + i * num, cnt9 - 2, cnt0 + 1) * (9 - abs(i) + 1 - (cnt0 < 1)) for i in range(-9, 10) i... | import itertools as ite
import math
import random
INF = 10 ** 18
MOD = 10 ** 9 + 7
def func(diff, cnt9, cnt0):
if cnt9 <= 0:
return (diff == 0)
num = int("9" * cnt9 + "0" * cnt0)
return sum(func(diff + i * num, cnt9 - 2, cnt0 + 1) * (9 - abs(i) + 1 - (cnt0 < 1)) for i in range(-9, 10) i... | 20 | 19 | 477 | 455 | import itertools as ite
import math
import random
INF = 10**18
MOD = 10**9 + 7
def func(diff, cnt9, cnt0):
if cnt9 <= 0:
return diff == 0
num = int("9" * cnt9 + "0" * cnt0)
return sum(
func(diff + i * num, cnt9 - 2, cnt0 + 1) * (9 - abs(i) + 1 - (cnt0 < 1))
for i in range(-9, 10)
... | import itertools as ite
import math
import random
INF = 10**18
MOD = 10**9 + 7
def func(diff, cnt9, cnt0):
if cnt9 <= 0:
return diff == 0
num = int("9" * cnt9 + "0" * cnt0)
return sum(
func(diff + i * num, cnt9 - 2, cnt0 + 1) * (9 - abs(i) + 1 - (cnt0 < 1))
for i in range(-9, 10)
... | false | 5 | [
"- MUL = 1 if d % 2 == 1 else 10",
"- ans += func(D, d, 0) * MUL",
"+ ans += func(D, d, 0) * (10 - d % 2 * 9)"
] | false | 0.041754 | 0.041907 | 0.996343 | [
"s522790611",
"s630154944"
] |
u306033313 | p02536 | python | s848795689 | s400853575 | 417 | 384 | 11,156 | 11,004 | Accepted | Accepted | 7.91 | class UnionFind:
def __init__(self, n):
self.r = [-1 for i in range(n)]
def root(self, x):
if self.r[x] < 0:
return x
self.r[x] = self.root(self.r[x])
return self.r[x]
def unite(self, x, y):
x = self.root(x)
y = self.root(y)
... | #self.r[x] means root of "x" if "x" isn't root, else number of elements
class UnionFind():
def __init__(self, n):
self.r = [-1 for i in range(n)]
#use in add-method
def root(self, x):
if self.r[x] < 0: #"x" is root
return x
self.r[x] = self.root(self.r[x])
... | 38 | 34 | 830 | 788 | class UnionFind:
def __init__(self, n):
self.r = [-1 for i in range(n)]
def root(self, x):
if self.r[x] < 0:
return x
self.r[x] = self.root(self.r[x])
return self.r[x]
def unite(self, x, y):
x = self.root(x)
y = self.root(y)
if x == y:
... | # self.r[x] means root of "x" if "x" isn't root, else number of elements
class UnionFind:
def __init__(self, n):
self.r = [-1 for i in range(n)]
# use in add-method
def root(self, x):
if self.r[x] < 0: # "x" is root
return x
self.r[x] = self.root(self.r[x])
retu... | false | 10.526316 | [
"+# self.r[x] means root of \"x\" if \"x\" isn't root, else number of elements",
"+ # use in add-method",
"- if self.r[x] < 0:",
"+ if self.r[x] < 0: # \"x\" is root",
"- def unite(self, x, y):",
"+ # add new path",
"+ def add(self, x, y):",
"- if self.r[x] < self.r[y... | false | 0.048104 | 0.043665 | 1.101654 | [
"s848795689",
"s400853575"
] |
u626337957 | p03031 | python | s795190706 | s685666458 | 41 | 29 | 3,064 | 3,188 | Accepted | Accepted | 29.27 | N, M = list(map(int, input().split()))
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))
ans = 0
for i in range(2**N):
cnt = 0
for j in range(M):
count = 0
for k in ks[j][1::]:
if (i >> k-1)&1 == 1:
count += 1
... | N, M = list(map(int, input().split()))
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))
def check(ar):
cnt = 0
for j in range(M):
count = 0
for k in ks[j][1::]:
if ar[k-1] == 1:
count += 1
if count%2 == p... | 17 | 27 | 409 | 587 | N, M = list(map(int, input().split()))
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))
ans = 0
for i in range(2**N):
cnt = 0
for j in range(M):
count = 0
for k in ks[j][1::]:
if (i >> k - 1) & 1 == 1:
count += 1
if ... | N, M = list(map(int, input().split()))
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))
def check(ar):
cnt = 0
for j in range(M):
count = 0
for k in ks[j][1::]:
if ar[k - 1] == 1:
count += 1
if count % 2 == p[j]:
... | false | 37.037037 | [
"-ans = 0",
"-for i in range(2**N):",
"+",
"+",
"+def check(ar):",
"- if (i >> k - 1) & 1 == 1:",
"+ if ar[k - 1] == 1:",
"- if cnt == M:",
"- ans += 1",
"+ return cnt == M",
"+",
"+",
"+def dfs(n, ar):",
"+ if n == 0:",
"+ if check(ar):",
"... | false | 0.037801 | 0.042562 | 0.88813 | [
"s795190706",
"s685666458"
] |
u738898077 | p02659 | python | s659530673 | s559299484 | 25 | 22 | 9,168 | 9,172 | Accepted | Accepted | 12 | from math import floor
a,b = input().split()
c = ""
for i in b:
if i!=".":
c+=i
# print(c)
c = int(c)
# b = int(float(b)*100)
a = int(a)
print(((a*c)//100)) | a,b = input().split()
b = float(b)+0.009
a = int(a)
b = int(b*100)
print(((a*b)//100)) | 11 | 5 | 176 | 88 | from math import floor
a, b = input().split()
c = ""
for i in b:
if i != ".":
c += i
# print(c)
c = int(c)
# b = int(float(b)*100)
a = int(a)
print(((a * c) // 100))
| a, b = input().split()
b = float(b) + 0.009
a = int(a)
b = int(b * 100)
print(((a * b) // 100))
| false | 54.545455 | [
"-from math import floor",
"-",
"-c = \"\"",
"-for i in b:",
"- if i != \".\":",
"- c += i",
"-# print(c)",
"-c = int(c)",
"-# b = int(float(b)*100)",
"+b = float(b) + 0.009",
"-print(((a * c) // 100))",
"+b = int(b * 100)",
"+print(((a * b) // 100))"
] | false | 0.048271 | 0.112367 | 0.429581 | [
"s659530673",
"s559299484"
] |
u678167152 | p03181 | python | s872434283 | s652547670 | 647 | 291 | 43,536 | 106,408 | Accepted | Accepted | 55.02 | import sys,os,io
input = sys.stdin.readline
# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for i in range(N-1):
a,b = list(map(int, input().split()))
edge[a-1].append(b-1)
edge[b-1].append(a-1)
def dfs(start):
stack = [s... | import sys,os,io
# input = sys.stdin.readline
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for i in range(N-1):
a,b = list(map(int, input().split()))
edge[a-1].append(b-1)
edge[b-1].append(a-1)
def dfs(start):
stack = [s... | 66 | 66 | 1,527 | 1,527 | import sys, os, io
input = sys.stdin.readline
# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for i in range(N - 1):
a, b = list(map(int, input().split()))
edge[a - 1].append(b - 1)
edge[b - 1].append(a - 1)
def dfs(start):
... | import sys, os, io
# input = sys.stdin.readline
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for i in range(N - 1):
a, b = list(map(int, input().split()))
edge[a - 1].append(b - 1)
edge[b - 1].append(a - 1)
def dfs(start):
... | false | 0 | [
"-input = sys.stdin.readline",
"-# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline",
"+# input = sys.stdin.readline",
"+input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline"
] | false | 0.047114 | 0.122063 | 0.385978 | [
"s872434283",
"s652547670"
] |
u948911484 | p02845 | python | s799293107 | s612917655 | 423 | 222 | 23,984 | 23,736 | Accepted | Accepted | 47.52 | import copy
n = int(eval(input()))
a = list(map(int,input().split()))
dp = [[0,0,0] for _ in range(n+1)]
mod = 10**9+7
ans = 1
for i in range(1,n+1):
dp[i] = copy.copy(dp[i-1])
for j in range(3):
if dp[i-1][j] == a[i-1]:
dp[i][j] += 1
break
dp[i].sort(reverse=True)
for i in range(n):
... | n = int(eval(input()))
a = list(map(int,input().split()))
mod = 10**9+7
dp = [[0]*3 for _ in range(n+1)]
ans = 1
for i in range(n):
ans *= dp[i].count(a[i])
ans %= mod
for j in range(3):
dp[i+1][j] = dp[i][j]
if dp[i][j] == a[i]:
dp[i+1][j] += 1
a[i] = -1
... | 16 | 14 | 360 | 325 | import copy
n = int(eval(input()))
a = list(map(int, input().split()))
dp = [[0, 0, 0] for _ in range(n + 1)]
mod = 10**9 + 7
ans = 1
for i in range(1, n + 1):
dp[i] = copy.copy(dp[i - 1])
for j in range(3):
if dp[i - 1][j] == a[i - 1]:
dp[i][j] += 1
break
dp[i].sort(reverse... | n = int(eval(input()))
a = list(map(int, input().split()))
mod = 10**9 + 7
dp = [[0] * 3 for _ in range(n + 1)]
ans = 1
for i in range(n):
ans *= dp[i].count(a[i])
ans %= mod
for j in range(3):
dp[i + 1][j] = dp[i][j]
if dp[i][j] == a[i]:
dp[i + 1][j] += 1
a[i] = -1
p... | false | 12.5 | [
"-import copy",
"-",
"-dp = [[0, 0, 0] for _ in range(n + 1)]",
"+dp = [[0] * 3 for _ in range(n + 1)]",
"-for i in range(1, n + 1):",
"- dp[i] = copy.copy(dp[i - 1])",
"+for i in range(n):",
"+ ans *= dp[i].count(a[i])",
"+ ans %= mod",
"- if dp[i - 1][j] == a[i - 1]:",
"- ... | false | 0.051303 | 0.044311 | 1.157779 | [
"s799293107",
"s612917655"
] |
u055941944 | p04044 | python | s720826943 | s028057063 | 20 | 18 | 3,060 | 3,060 | Accepted | Accepted | 10 | # -*- coding utf-8 -*-
n,l=map(int,input().split())
s =[str(input()) for i in range(n)]
s.sort()
print(*s,sep="")
| # -*- coding utf-8 -*-
n,l=list(map(int,input().split()))
s=[]
for i in range(n):
X=str(eval(input()))
s.append(X)
f=sorted(s)
ans=''.join(f)
print(ans)
| 9 | 11 | 126 | 161 | # -*- coding utf-8 -*-
n, l = map(int, input().split())
s = [str(input()) for i in range(n)]
s.sort()
print(*s, sep="")
| # -*- coding utf-8 -*-
n, l = list(map(int, input().split()))
s = []
for i in range(n):
X = str(eval(input()))
s.append(X)
f = sorted(s)
ans = "".join(f)
print(ans)
| false | 18.181818 | [
"-n, l = map(int, input().split())",
"-s = [str(input()) for i in range(n)]",
"-s.sort()",
"-print(*s, sep=\"\")",
"+n, l = list(map(int, input().split()))",
"+s = []",
"+for i in range(n):",
"+ X = str(eval(input()))",
"+ s.append(X)",
"+f = sorted(s)",
"+ans = \"\".join(f)",
"+print(an... | false | 0.035019 | 0.03637 | 0.962857 | [
"s720826943",
"s028057063"
] |
u462434199 | p03283 | python | s060100330 | s824490560 | 1,508 | 727 | 66,896 | 66,896 | Accepted | Accepted | 51.79 | import numpy as np
import sys
n, m, q = list(map(int, input().split()))
ab = np.array(sys.stdin.read().split(), np.int)
a = ab[:m*2].reshape(m, 2)
b = ab[m*2:].reshape(q, 2)
x=np.zeros((501, 501), dtype=np.int)
np.add.at(x, (a[:, 0], a[:, 1]), 1)
np.cumsum(x, axis=0, out=x)
np.cumsum(x, axis=1, out=x)
... | import numpy as np
import sys
n, m, q = list(map(int, input().split()))
ab = np.array(sys.stdin.read().split(), np.int)
a = ab[:m*2].reshape(m, 2)
b = ab[m*2:].reshape(q, 2)
x=np.zeros((501, 501), dtype=np.int)
np.add.at(x, (a[:, 0], a[:, 1]), 1)
np.cumsum(x, axis=0, out=x)
np.cumsum(x, axis=1, out=x)
... | 24 | 18 | 478 | 456 | import numpy as np
import sys
n, m, q = list(map(int, input().split()))
ab = np.array(sys.stdin.read().split(), np.int)
a = ab[: m * 2].reshape(m, 2)
b = ab[m * 2 :].reshape(q, 2)
x = np.zeros((501, 501), dtype=np.int)
np.add.at(x, (a[:, 0], a[:, 1]), 1)
np.cumsum(x, axis=0, out=x)
np.cumsum(x, axis=1, out=x)
for i in... | import numpy as np
import sys
n, m, q = list(map(int, input().split()))
ab = np.array(sys.stdin.read().split(), np.int)
a = ab[: m * 2].reshape(m, 2)
b = ab[m * 2 :].reshape(q, 2)
x = np.zeros((501, 501), dtype=np.int)
np.add.at(x, (a[:, 0], a[:, 1]), 1)
np.cumsum(x, axis=0, out=x)
np.cumsum(x, axis=1, out=x)
ans = (
... | false | 25 | [
"+ans = (",
"+ x[b[:, 1], b[:, 1]]",
"+ - x[b[:, 1], b[:, 0] - 1]",
"+ - x[b[:, 0] - 1, b[:, 1]]",
"+ + x[b[:, 0] - 1, b[:, 0] - 1]",
"+)",
"- v1 = b[i][0]",
"- v2 = b[i][1]",
"- a1 = x[v2, v2]",
"- a2 = x[v2, v1 - 1]",
"- a3 = x[v1 - 1, v2]",
"- a4 = x[v1 - 1, v1... | false | 0.560264 | 0.460304 | 1.21716 | [
"s060100330",
"s824490560"
] |
u189487046 | p02934 | python | s962997295 | s067322302 | 150 | 17 | 12,488 | 2,940 | Accepted | Accepted | 88.67 | import numpy as np
n = int(eval(input()))
al = list(map(int, input().split()))
reverse_list = []
for a in al:
reverse_list.append(1/a)
print((1/sum(reverse_list)))
| n = int(eval(input()))
al = list(map(int, input().split()))
reverse_list = []
for a in al:
reverse_list.append(1/a)
print((1/sum(reverse_list)))
| 10 | 8 | 172 | 150 | import numpy as np
n = int(eval(input()))
al = list(map(int, input().split()))
reverse_list = []
for a in al:
reverse_list.append(1 / a)
print((1 / sum(reverse_list)))
| n = int(eval(input()))
al = list(map(int, input().split()))
reverse_list = []
for a in al:
reverse_list.append(1 / a)
print((1 / sum(reverse_list)))
| false | 20 | [
"-import numpy as np",
"-"
] | false | 0.060302 | 0.035996 | 1.675236 | [
"s962997295",
"s067322302"
] |
u562016607 | p03166 | python | s224378088 | s174475371 | 1,313 | 567 | 153,036 | 35,180 | Accepted | Accepted | 56.82 | import sys
sys.setrecursionlimit(10**6)
N,M=list(map(int,input().split()))
G=[set() for i in range(N)]
for i in range(M):
x,y=list(map(int,input().split()))
G[x-1].add(y-1)
dp=[-1 for i in range(N)]
def search(k):
if dp[k]!=-1:
return dp[k]
res=0
for r in G[k]:
if search... | from collections import deque
N,M=list(map(int,input().split()))
G=[set() for i in range(N)]
for i in range(M):
x,y=list(map(int,input().split()))
G[x-1].add(y-1)
K=[0 for i in range(N)]
for i in range(N):
for p in G[i]:
K[p]+=1
q=deque(i for i in range(N) if K[i]==0)
res=[]
while q:
... | 21 | 25 | 453 | 570 | import sys
sys.setrecursionlimit(10**6)
N, M = list(map(int, input().split()))
G = [set() for i in range(N)]
for i in range(M):
x, y = list(map(int, input().split()))
G[x - 1].add(y - 1)
dp = [-1 for i in range(N)]
def search(k):
if dp[k] != -1:
return dp[k]
res = 0
for r in G[k]:
... | from collections import deque
N, M = list(map(int, input().split()))
G = [set() for i in range(N)]
for i in range(M):
x, y = list(map(int, input().split()))
G[x - 1].add(y - 1)
K = [0 for i in range(N)]
for i in range(N):
for p in G[i]:
K[p] += 1
q = deque(i for i in range(N) if K[i] == 0)
res = []... | false | 16 | [
"-import sys",
"+from collections import deque",
"-sys.setrecursionlimit(10**6)",
"-dp = [-1 for i in range(N)]",
"-",
"-",
"-def search(k):",
"- if dp[k] != -1:",
"- return dp[k]",
"- res = 0",
"- for r in G[k]:",
"- if search(r) + 1 > res:",
"- res = searc... | false | 0.036111 | 0.035608 | 1.014126 | [
"s224378088",
"s174475371"
] |
u350248178 | p02834 | python | s984765490 | s150382458 | 739 | 641 | 85,280 | 36,256 | Accepted | Accepted | 13.26 | n,u,v=[int(j) for j in input().split()]
u,v=u-1,v-1
l=[[] for i in range(n)]
for i in range(n-1):
a,b=[int(j)-1 for j in input().split()]
l[a].append(b)
l[b].append(a)
k=[10**18 for i in range(n)]
from collections import deque
q=deque([u])
k[u]=0
s=set()
while q:
p=q.popleft()
s.add(p)... | n,u,v=[int(j) for j in input().split()]
u,v=u-1,v-1
l=[[] for i in range(n)]
for i in range(n-1):
a,b=[int(j)-1 for j in input().split()]
l[a].append(b)
l[b].append(a)
k=[10**18 for i in range(n)]
from collections import deque
q=deque([u])
k[u]=0
s=set()
while q:
p=q.popleft()
s.add(p)... | 41 | 39 | 772 | 760 | n, u, v = [int(j) for j in input().split()]
u, v = u - 1, v - 1
l = [[] for i in range(n)]
for i in range(n - 1):
a, b = [int(j) - 1 for j in input().split()]
l[a].append(b)
l[b].append(a)
k = [10**18 for i in range(n)]
from collections import deque
q = deque([u])
k[u] = 0
s = set()
while q:
p = q.popl... | n, u, v = [int(j) for j in input().split()]
u, v = u - 1, v - 1
l = [[] for i in range(n)]
for i in range(n - 1):
a, b = [int(j) - 1 for j in input().split()]
l[a].append(b)
l[b].append(a)
k = [10**18 for i in range(n)]
from collections import deque
q = deque([u])
k[u] = 0
s = set()
while q:
p = q.popl... | false | 4.878049 | [
"-ll = []",
"- ll.append(i)",
"- ans = max(ans, k2[i])",
"+ if ans < k2[i]:",
"+ ans = k2[i]"
] | false | 0.039479 | 0.037704 | 1.047072 | [
"s984765490",
"s150382458"
] |
u700805562 | p02720 | python | s809366278 | s077140046 | 99 | 77 | 7,204 | 6,132 | Accepted | Accepted | 22.22 | K = int(eval(input()))
def cal():
count = 9
d = [[1,2,3,4,5,6,7,8,9]]
for i in range(10**9):
d_ = []
for j in range(len(d[i])):
a = str(d[i][j])
if a[-1]=="0":
for k in [0, 1]:
d_.append(int(a)*10+k)
... | from collections import deque
k = int(eval(input()))
if k <= 9: print(k)
que = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
count = 9
while count <= k:
X = que.popleft()
if X%10==0: check=[0, 1]
elif X%10==9: check=[8, 9]
else: check = [X%10-1, X%10, X%10+1]
for i in check:
que.append(X*10+... | 35 | 16 | 997 | 408 | K = int(eval(input()))
def cal():
count = 9
d = [[1, 2, 3, 4, 5, 6, 7, 8, 9]]
for i in range(10**9):
d_ = []
for j in range(len(d[i])):
a = str(d[i][j])
if a[-1] == "0":
for k in [0, 1]:
d_.append(int(a) * 10 + k)
... | from collections import deque
k = int(eval(input()))
if k <= 9:
print(k)
que = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
count = 9
while count <= k:
X = que.popleft()
if X % 10 == 0:
check = [0, 1]
elif X % 10 == 9:
check = [8, 9]
else:
check = [X % 10 - 1, X % 10, X % 10 + 1]
... | false | 54.285714 | [
"-K = int(eval(input()))",
"+from collections import deque",
"-",
"-def cal():",
"- count = 9",
"- d = [[1, 2, 3, 4, 5, 6, 7, 8, 9]]",
"- for i in range(10**9):",
"- d_ = []",
"- for j in range(len(d[i])):",
"- a = str(d[i][j])",
"- if a[-1] == \"0\":... | false | 0.041401 | 0.042739 | 0.968708 | [
"s809366278",
"s077140046"
] |
u758815106 | p02873 | python | s158980919 | s626495690 | 321 | 277 | 32,460 | 32,500 | Accepted | Accepted | 13.71 | S = list(eval(input()))
# ><は0でいいのか
# 同様に S[0]==<とS[-1]==>も0でいい
# 制約的にNlogNくらいまでは十分許容範囲だし><は0で埋めてindex保持、そこから単調増加で組むのが良さそう?
# 3回ループさせる形で実装してみる
tmp = [-1] * (len(S) + 1)
for i in range(len(S) - 1):
if S[i] == ">" and S[i + 1] == "<":
tmp[i + 1] = 0
if S[0] == "<":
tmp[0] =... | S = list(eval(input()))
ls = len(S)
a = [0] * (len(S) + 1)
for i in range(ls):
if S[i] == "<":
a[i + 1] = max(a[i + 1], a[i] + 1)
for i in range(ls - 1, -1, -1):
if S[i] == ">":
a[i] = max(a[i], a[i + 1] + 1)
print((sum(a))) | 30 | 15 | 578 | 275 | S = list(eval(input()))
# ><は0でいいのか
# 同様に S[0]==<とS[-1]==>も0でいい
# 制約的にNlogNくらいまでは十分許容範囲だし><は0で埋めてindex保持、そこから単調増加で組むのが良さそう?
# 3回ループさせる形で実装してみる
tmp = [-1] * (len(S) + 1)
for i in range(len(S) - 1):
if S[i] == ">" and S[i + 1] == "<":
tmp[i + 1] = 0
if S[0] == "<":
tmp[0] = 0
if S[-1] == ">":
tmp[... | S = list(eval(input()))
ls = len(S)
a = [0] * (len(S) + 1)
for i in range(ls):
if S[i] == "<":
a[i + 1] = max(a[i + 1], a[i] + 1)
for i in range(ls - 1, -1, -1):
if S[i] == ">":
a[i] = max(a[i], a[i + 1] + 1)
print((sum(a)))
| false | 50 | [
"-# ><は0でいいのか",
"-# 同様に S[0]==<とS[-1]==>も0でいい",
"-# 制約的にNlogNくらいまでは十分許容範囲だし><は0で埋めてindex保持、そこから単調増加で組むのが良さそう?",
"-# 3回ループさせる形で実装してみる",
"-tmp = [-1] * (len(S) + 1)",
"-for i in range(len(S) - 1):",
"- if S[i] == \">\" and S[i + 1] == \"<\":",
"- tmp[i + 1] = 0",
"-if S[0] == \"<\":",
... | false | 0.042849 | 0.047681 | 0.898658 | [
"s158980919",
"s626495690"
] |
u010321082 | p02847 | python | s433992374 | s232087849 | 161 | 19 | 38,256 | 3,060 | Accepted | Accepted | 88.2 | str=eval(input())
if(str=='SAT'):
print('1')
elif(str=='SUN'):
print('7')
elif(str=='MON'):
print('6')
elif(str=='TUE'):
print('5')
elif(str=='WED'):
print('4')
elif(str=='THU'):
print('3')
else:
print('2') | s=eval(input())
if s=='SAT':
print((1))
elif s=='SUN':
print((7))
elif s=='MON':
print((6))
elif s=='TUE':
print((5))
elif s=='WED':
print((4))
elif s=='THU':
print((3))
else:
print((2)) | 15 | 15 | 221 | 187 | str = eval(input())
if str == "SAT":
print("1")
elif str == "SUN":
print("7")
elif str == "MON":
print("6")
elif str == "TUE":
print("5")
elif str == "WED":
print("4")
elif str == "THU":
print("3")
else:
print("2")
| s = eval(input())
if s == "SAT":
print((1))
elif s == "SUN":
print((7))
elif s == "MON":
print((6))
elif s == "TUE":
print((5))
elif s == "WED":
print((4))
elif s == "THU":
print((3))
else:
print((2))
| false | 0 | [
"-str = eval(input())",
"-if str == \"SAT\":",
"- print(\"1\")",
"-elif str == \"SUN\":",
"- print(\"7\")",
"-elif str == \"MON\":",
"- print(\"6\")",
"-elif str == \"TUE\":",
"- print(\"5\")",
"-elif str == \"WED\":",
"- print(\"4\")",
"-elif str == \"THU\":",
"- print(\"3... | false | 0.03865 | 0.037477 | 1.031293 | [
"s433992374",
"s232087849"
] |
u703461446 | p02912 | python | s487011146 | s168170036 | 1,832 | 157 | 14,480 | 14,180 | Accepted | Accepted | 91.43 | def calc(N, M, A):
if (N == 1):
return A[0] // (2 ** M)
A.sort(key=lambda a: -a)
B = [A]
for _ in range(M):
i = 0
m = B[0][0] if B[0] else -1
for j in range(1, len(B)):
if (B[j] and B[j][0] > m):
i = j
m = B[j][0]
... | import heapq
def calc(N, M, A):
if (N == 1):
return A[0] // (2 ** M)
H = []
for a in A:
heapq.heappush(H, -a)
for _ in range(M):
a = (-heapq.heappop(H)) // 2
heapq.heappush(H, -a)
return -sum(H)
(N, M) = tuple([int(s) for s in input().split(' ')])
A ... | 24 | 17 | 629 | 377 | def calc(N, M, A):
if N == 1:
return A[0] // (2**M)
A.sort(key=lambda a: -a)
B = [A]
for _ in range(M):
i = 0
m = B[0][0] if B[0] else -1
for j in range(1, len(B)):
if B[j] and B[j][0] > m:
i = j
m = B[j][0]
p = B[i].pop... | import heapq
def calc(N, M, A):
if N == 1:
return A[0] // (2**M)
H = []
for a in A:
heapq.heappush(H, -a)
for _ in range(M):
a = (-heapq.heappop(H)) // 2
heapq.heappush(H, -a)
return -sum(H)
(N, M) = tuple([int(s) for s in input().split(" ")])
A = [int(s) for s in... | false | 29.166667 | [
"+import heapq",
"+",
"+",
"- A.sort(key=lambda a: -a)",
"- B = [A]",
"+ H = []",
"+ for a in A:",
"+ heapq.heappush(H, -a)",
"- i = 0",
"- m = B[0][0] if B[0] else -1",
"- for j in range(1, len(B)):",
"- if B[j] and B[j][0] > m:",
"- ... | false | 0.167684 | 0.036785 | 4.558505 | [
"s487011146",
"s168170036"
] |
u348805958 | p02609 | python | s512831497 | s087084582 | 271 | 218 | 95,160 | 91,252 | Accepted | Accepted | 19.56 | #!python3
import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from functools import lru_cache
@lru_cache(maxsize=2*10**5)
def f2(x):
if x == 0: return 0
y = bin(x).count("1")
return 1 + f2(x % y)
def resolve():
N = int(input())
W = 16
S = input()
cnt... | #!python3
import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from functools import lru_cache
@lru_cache(maxsize=2*10**5)
def f2(x):
if x == 0: return 0
y = bin(x).count("1")
return 1 + f2(x % y)
def resolve():
N = int(input())
S = input()
cnt0 = S.count(... | 49 | 51 | 890 | 969 | #!python3
import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from functools import lru_cache
@lru_cache(maxsize=2 * 10**5)
def f2(x):
if x == 0:
return 0
y = bin(x).count("1")
return 1 + f2(x % y)
def resolve():
N = int(input())
W = 16
S = input()
cnt0 = S.... | #!python3
import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from functools import lru_cache
@lru_cache(maxsize=2 * 10**5)
def f2(x):
if x == 0:
return 0
y = bin(x).count("1")
return 1 + f2(x % y)
def resolve():
N = int(input())
S = input()
cnt0 = S.count("1")
... | false | 3.921569 | [
"- W = 16",
"- dc[k] = (x, v, y)",
"- ans = []",
"- for i, si in enumerate(S):",
"- cnt, v, n = dc[si]",
"+ dc[k] = (x, v, y, [1, N - 1])",
"+ ans = [0] * N",
"+ for i in reversed(range(N)):",
"+ si = S[i]",
"+ cnt, v, n, m1 = dc[si]",
"- ... | false | 0.043445 | 0.036528 | 1.189352 | [
"s512831497",
"s087084582"
] |
u357751375 | p03086 | python | s720094497 | s562728128 | 30 | 23 | 9,060 | 8,996 | Accepted | Accepted | 23.33 | s = eval(input())
a = ['A','C','G','T']
c = 0
j = 0
for i in range(len(s)):
if s[i] in a:
j += 1
else:
if j > c:
c = j
j = 0
if j > c:
print(j)
else:
print(c) | s = eval(input())
acgt = ['A','C','G','T']
ans = 0
p = 0
for i in range(len(s)):
if s[i] in acgt:
p += 1
else:
ans = max(ans,p)
p = 0
print((max(ans,p))) | 17 | 11 | 226 | 187 | s = eval(input())
a = ["A", "C", "G", "T"]
c = 0
j = 0
for i in range(len(s)):
if s[i] in a:
j += 1
else:
if j > c:
c = j
j = 0
if j > c:
print(j)
else:
print(c)
| s = eval(input())
acgt = ["A", "C", "G", "T"]
ans = 0
p = 0
for i in range(len(s)):
if s[i] in acgt:
p += 1
else:
ans = max(ans, p)
p = 0
print((max(ans, p)))
| false | 35.294118 | [
"-a = [\"A\", \"C\", \"G\", \"T\"]",
"-c = 0",
"-j = 0",
"+acgt = [\"A\", \"C\", \"G\", \"T\"]",
"+ans = 0",
"+p = 0",
"- if s[i] in a:",
"- j += 1",
"+ if s[i] in acgt:",
"+ p += 1",
"- if j > c:",
"- c = j",
"- j = 0",
"-if j > c:",
"- ... | false | 0.080037 | 0.038347 | 2.087183 | [
"s720094497",
"s562728128"
] |
u864197622 | p02794 | python | s042440401 | s460839209 | 1,763 | 1,352 | 49,344 | 58,844 | Accepted | Accepted | 23.31 | N = int(eval(input()))
X = [[] for i in range(N)]
for i in range(N-1):
x, y = list(map(int, input().split()))
X[x-1].append(y-1)
X[y-1].append(x-1)
P = [-1] * N
DE = [0] * N
Q = [0]
while Q:
i = Q.pop()
for a in X[i][::-1]:
if a != P[i]:
P[a] = i
DE[a]... | N = int(eval(input()))
X = [[] for i in range(N)]
for i in range(N-1):
x, y = list(map(int, input().split()))
X[x-1].append(y-1)
X[y-1].append(x-1)
P = [-1] * N
DE = [0] * N
Q = [0]
while Q:
i = Q.pop()
for a in X[i][::-1]:
if a != P[i]:
P[a] = i
DE[a]... | 60 | 64 | 1,240 | 1,316 | N = int(eval(input()))
X = [[] for i in range(N)]
for i in range(N - 1):
x, y = list(map(int, input().split()))
X[x - 1].append(y - 1)
X[y - 1].append(x - 1)
P = [-1] * N
DE = [0] * N
Q = [0]
while Q:
i = Q.pop()
for a in X[i][::-1]:
if a != P[i]:
P[a] = i
DE[a] = DE[... | N = int(eval(input()))
X = [[] for i in range(N)]
for i in range(N - 1):
x, y = list(map(int, input().split()))
X[x - 1].append(y - 1)
X[y - 1].append(x - 1)
P = [-1] * N
DE = [0] * N
Q = [0]
while Q:
i = Q.pop()
for a in X[i][::-1]:
if a != P[i]:
P[a] = i
DE[a] = DE[... | false | 6.25 | [
"+BC = [0] * (1 << M)",
"+for m in range(1, 1 << M):",
"+ a = m & (-m)",
"+ BC[m] = BC[m ^ a] + 1",
"- CC[N - 1 - bin(Z[m]).count(\"1\")] += 1 if bin(m).count(\"1\") % 2 == 0 else -1",
"+ CC[N - 1 - bin(Z[m]).count(\"1\")] += 1 if BC[m] % 2 == 0 else -1"
] | false | 0.036679 | 0.100784 | 0.363935 | [
"s042440401",
"s460839209"
] |
u941753895 | p03363 | python | s595736374 | s657299610 | 1,537 | 295 | 41,312 | 41,316 | Accepted | Accepted | 80.81 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
de... | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
de... | 62 | 57 | 1,218 | 1,114 | import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI():
return [int(x) ... | import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI():
return [int(x) ... | false | 8.064516 | [
"-# nCr -- START --",
"-def nCr(n, r):",
"- if n < r:",
"- return 0",
"- return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))",
"-",
"-",
"- for x in l:",
"- if x[0] == 0:",
"- ans += x[1]",
"- if x[1] > 1:",
"- ans += nCr(... | false | 0.039768 | 0.03867 | 1.028397 | [
"s595736374",
"s657299610"
] |
u513081876 | p03804 | python | s254973561 | s243300331 | 24 | 22 | 3,064 | 3,064 | Accepted | Accepted | 8.33 | N, M = list(map(int, input().split()))
A = [eval(input()) for i in range(N)]
B = [eval(input()) for i in range(M)]
ans = 'No'
for i in range(N - M + 1):
for j in range(N - M + 1):
check = 0
for ind, s in enumerate(B):
#print(s)
#print(A[i + ind][j])
... | N, M = list(map(int, input().split()))
A = [eval(input()) for i in range(N)]
B = [eval(input()) for i in range(M)]
check = 0
for i in range(N - M + 1):
for j in range(N - M + 1):
bb = []
for k in range(M):
bb.append(A[i + k][j:j+M])
if bb == B:
check = 1
... | 19 | 17 | 421 | 360 | N, M = list(map(int, input().split()))
A = [eval(input()) for i in range(N)]
B = [eval(input()) for i in range(M)]
ans = "No"
for i in range(N - M + 1):
for j in range(N - M + 1):
check = 0
for ind, s in enumerate(B):
# print(s)
# print(A[i + ind][j])
if s != A[i ... | N, M = list(map(int, input().split()))
A = [eval(input()) for i in range(N)]
B = [eval(input()) for i in range(M)]
check = 0
for i in range(N - M + 1):
for j in range(N - M + 1):
bb = []
for k in range(M):
bb.append(A[i + k][j : j + M])
if bb == B:
check = 1
if check ... | false | 10.526316 | [
"-ans = \"No\"",
"+check = 0",
"- check = 0",
"- for ind, s in enumerate(B):",
"- # print(s)",
"- # print(A[i + ind][j])",
"- if s != A[i + ind][j : j + M]:",
"- check = 1",
"- if check == 0:",
"- ans = \"Yes\"",
"-p... | false | 0.03613 | 0.036011 | 1.003292 | [
"s254973561",
"s243300331"
] |
u456033454 | p03163 | python | s992123924 | s228441168 | 1,081 | 630 | 173,320 | 171,400 | Accepted | Accepted | 41.72 | n, weightMax = list(map(int, input().split()))
itemList = [[0 for _ in range(weightMax+1)] for _ in range(n+1)]
for i in range(n):
w,v = list(map(int, input().split()))
for j in reversed(list(range(weightMax+1))):
if j-w >= 0:
itemList[i+1][j] = max([itemList[i][j],itemList[i][j-w] +... | n, max_weight = list(map(int, input().split()))
dp = [[0 for _ in range(max_weight+1)] for _ in range(n+1)]
for i in range(n):
weight, value = list(map(int,input().split()))
for w in range(max_weight+1):
if w >= weight:
dp[i+1][w] = max(dp[i][w-weight] + value, dp[i][w])
els... | 11 | 11 | 400 | 371 | n, weightMax = list(map(int, input().split()))
itemList = [[0 for _ in range(weightMax + 1)] for _ in range(n + 1)]
for i in range(n):
w, v = list(map(int, input().split()))
for j in reversed(list(range(weightMax + 1))):
if j - w >= 0:
itemList[i + 1][j] = max([itemList[i][j], itemList[i][j ... | n, max_weight = list(map(int, input().split()))
dp = [[0 for _ in range(max_weight + 1)] for _ in range(n + 1)]
for i in range(n):
weight, value = list(map(int, input().split()))
for w in range(max_weight + 1):
if w >= weight:
dp[i + 1][w] = max(dp[i][w - weight] + value, dp[i][w])
e... | false | 0 | [
"-n, weightMax = list(map(int, input().split()))",
"-itemList = [[0 for _ in range(weightMax + 1)] for _ in range(n + 1)]",
"+n, max_weight = list(map(int, input().split()))",
"+dp = [[0 for _ in range(max_weight + 1)] for _ in range(n + 1)]",
"- w, v = list(map(int, input().split()))",
"- for j in ... | false | 0.089953 | 0.047582 | 1.890476 | [
"s992123924",
"s228441168"
] |
u073852194 | p03326 | python | s755430597 | s242884941 | 231 | 38 | 42,224 | 9,300 | Accepted | Accepted | 83.55 | N,M = list(map(int,input().split()))
cake = [list(map(int,input().split())) for _ in range(N)]
ans = 0
for i in range(8):
sign = [0,0,0]
for j in range(3):
sign[j] = (i>>j & 1)
cake_i = []
for k in range(N):
s = 0
for j in range(3):
s += cake[k][j]*(1-2*s... | N, M = list(map(int, input().split()))
C = [tuple(map(int, input().split())) for _ in range(N)]
res = 0
for i in range(8):
D = [0 for _ in range(N)]
for j in range(N):
x, y, z = C[j]
if (i >> 0) & 1:
D[j] += x
else:
D[j] -= x
if (i >> 1) & 1... | 18 | 25 | 434 | 535 | N, M = list(map(int, input().split()))
cake = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(8):
sign = [0, 0, 0]
for j in range(3):
sign[j] = i >> j & 1
cake_i = []
for k in range(N):
s = 0
for j in range(3):
s += cake[k][j] * (1 - 2 * sig... | N, M = list(map(int, input().split()))
C = [tuple(map(int, input().split())) for _ in range(N)]
res = 0
for i in range(8):
D = [0 for _ in range(N)]
for j in range(N):
x, y, z = C[j]
if (i >> 0) & 1:
D[j] += x
else:
D[j] -= x
if (i >> 1) & 1:
D... | false | 28 | [
"-cake = [list(map(int, input().split())) for _ in range(N)]",
"-ans = 0",
"+C = [tuple(map(int, input().split())) for _ in range(N)]",
"+res = 0",
"- sign = [0, 0, 0]",
"- for j in range(3):",
"- sign[j] = i >> j & 1",
"- cake_i = []",
"- for k in range(N):",
"- s = 0",
... | false | 0.03632 | 0.034223 | 1.061287 | [
"s755430597",
"s242884941"
] |
u556594202 | p02596 | python | s250391788 | s650443041 | 335 | 264 | 9,160 | 8,992 | Accepted | Accepted | 21.19 | K = int(eval(input()))
rest = 7%K
count=1
while (count<=K):
if rest == 0:
print(count)
exit()
count +=1
rest = (rest%K*10%K + 7%K)%K
print((-1))
| K = int(eval(input()))
rest = 7%K
count=1
while (count<=K):
if rest == 0:
print(count)
exit()
count +=1
rest = (rest%K*10 + 7)%K
print((-1)) | 10 | 10 | 174 | 169 | K = int(eval(input()))
rest = 7 % K
count = 1
while count <= K:
if rest == 0:
print(count)
exit()
count += 1
rest = (rest % K * 10 % K + 7 % K) % K
print((-1))
| K = int(eval(input()))
rest = 7 % K
count = 1
while count <= K:
if rest == 0:
print(count)
exit()
count += 1
rest = (rest % K * 10 + 7) % K
print((-1))
| false | 0 | [
"- rest = (rest % K * 10 % K + 7 % K) % K",
"+ rest = (rest % K * 10 + 7) % K"
] | false | 0.132846 | 0.138948 | 0.956087 | [
"s250391788",
"s650443041"
] |
u285891772 | p03495 | python | s967849554 | s637480232 | 136 | 115 | 34,840 | 34,832 | Accepted | Accepted | 15.44 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter,... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter,... | 29 | 26 | 998 | 998 | import sys, re
from collections import deque, defaultdict, Counter
from math import (
ceil,
sqrt,
hypot,
factorial,
pi,
sin,
cos,
tan,
asin,
acos,
atan,
radians,
degrees,
log2,
)
from itertools import (
accumulate,
permutations,
combinations,
combi... | import sys, re
from collections import deque, defaultdict, Counter
from math import (
ceil,
sqrt,
hypot,
factorial,
pi,
sin,
cos,
tan,
asin,
acos,
atan,
radians,
degrees,
log2,
)
from itertools import (
accumulate,
permutations,
combinations,
combi... | false | 10.344828 | [
"-C = Counter(A)",
"-n = sorted(list(C.values()))",
"-print((sum(n[: len(n) - K])))",
"+cnt = sorted(list(Counter(A).values()), reverse=True)",
"+print((sum(cnt[K:])))"
] | false | 0.041625 | 0.03819 | 1.089953 | [
"s967849554",
"s637480232"
] |
u597374218 | p02659 | python | s552766308 | s586650615 | 27 | 22 | 9,996 | 9,124 | Accepted | Accepted | 18.52 | import decimal
A,B=input().split()
print((int(int(A)*decimal.Decimal(B)))) | A,B=list(map(int,input().replace(".","").split()))
print((A*B//100)) | 3 | 2 | 74 | 61 | import decimal
A, B = input().split()
print((int(int(A) * decimal.Decimal(B))))
| A, B = list(map(int, input().replace(".", "").split()))
print((A * B // 100))
| false | 33.333333 | [
"-import decimal",
"-",
"-A, B = input().split()",
"-print((int(int(A) * decimal.Decimal(B))))",
"+A, B = list(map(int, input().replace(\".\", \"\").split()))",
"+print((A * B // 100))"
] | false | 0.037676 | 0.036371 | 1.035854 | [
"s552766308",
"s586650615"
] |
u038408819 | p02690 | python | s769396187 | s687801814 | 267 | 40 | 9,128 | 9,160 | Accepted | Accepted | 85.02 | x = int(eval(input()))
for i in range(1000):
#for j in range(10)
#print(i ** 5)
for j in range(1000):
#print(i ** 5 - j ** 5)
if i ** 5 - j ** 5 == x:
print((i, j))
quit()
elif i ** 5 - (-j) ** 5 == x:
print((i, -j))
quit()... | x = int(eval(input()))
for a in range(-118, 119 + 1):
for b in range(-119, 118 + 1):
if a ** 5 - b ** 5 == x:
print((a, b))
break
else:
continue
break | 19 | 9 | 485 | 202 | x = int(eval(input()))
for i in range(1000):
# for j in range(10)
# print(i ** 5)
for j in range(1000):
# print(i ** 5 - j ** 5)
if i**5 - j**5 == x:
print((i, j))
quit()
elif i**5 - (-j) ** 5 == x:
print((i, -j))
quit()
elif (-... | x = int(eval(input()))
for a in range(-118, 119 + 1):
for b in range(-119, 118 + 1):
if a**5 - b**5 == x:
print((a, b))
break
else:
continue
break
| false | 52.631579 | [
"-for i in range(1000):",
"- # for j in range(10)",
"- # print(i ** 5)",
"- for j in range(1000):",
"- # print(i ** 5 - j ** 5)",
"- if i**5 - j**5 == x:",
"- print((i, j))",
"- quit()",
"- elif i**5 - (-j) ** 5 == x:",
"- print((i, -j... | false | 0.08347 | 0.152489 | 0.547381 | [
"s769396187",
"s687801814"
] |
u600402037 | p02970 | python | s436351966 | s868253822 | 19 | 17 | 2,940 | 2,940 | Accepted | Accepted | 10.53 | n, d = list(map(int, input().split()))
cover = 2 * d + 1
answer = n // cover
if n % cover:
answer += 1
print(answer) | import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, D = lr()
# 2 * D + 1
answer = (N + 2 * D) // (2 * D + 1)
print(answer)
| 6 | 10 | 125 | 204 | n, d = list(map(int, input().split()))
cover = 2 * d + 1
answer = n // cover
if n % cover:
answer += 1
print(answer)
| import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, D = lr()
# 2 * D + 1
answer = (N + 2 * D) // (2 * D + 1)
print(answer)
| false | 40 | [
"-n, d = list(map(int, input().split()))",
"-cover = 2 * d + 1",
"-answer = n // cover",
"-if n % cover:",
"- answer += 1",
"+import sys",
"+",
"+sr = lambda: sys.stdin.readline().rstrip()",
"+ir = lambda: int(sr())",
"+lr = lambda: list(map(int, sr().split()))",
"+N, D = lr()",
"+# 2 * D +... | false | 0.05073 | 0.054039 | 0.938765 | [
"s436351966",
"s868253822"
] |
u644907318 | p03030 | python | s293099800 | s754811827 | 168 | 64 | 38,256 | 62,840 | Accepted | Accepted | 61.9 | N = int(eval(input()))
A = [[i]+input().split() for i in range(N)]
A = [[A[i][0],A[i][1],int(A[i][2])] for i in range(N)]
A = sorted(A,key=lambda x:x[2],reverse=True)
A = sorted(A,key=lambda x:x[1])
for i in range(N):
j,_,_ = A[i]
print((j+1)) | N=int(eval(input()))
A = []
for i in range(N):
s,p = input().split()
p = int(p)
A.append((s,p,i+1))
A = sorted(A,key=lambda x:x[1],reverse=True)
A = sorted(A,key=lambda x:x[0])
for i in range(N):
s,p,k = A[i]
print(k) | 8 | 11 | 250 | 241 | N = int(eval(input()))
A = [[i] + input().split() for i in range(N)]
A = [[A[i][0], A[i][1], int(A[i][2])] for i in range(N)]
A = sorted(A, key=lambda x: x[2], reverse=True)
A = sorted(A, key=lambda x: x[1])
for i in range(N):
j, _, _ = A[i]
print((j + 1))
| N = int(eval(input()))
A = []
for i in range(N):
s, p = input().split()
p = int(p)
A.append((s, p, i + 1))
A = sorted(A, key=lambda x: x[1], reverse=True)
A = sorted(A, key=lambda x: x[0])
for i in range(N):
s, p, k = A[i]
print(k)
| false | 27.272727 | [
"-A = [[i] + input().split() for i in range(N)]",
"-A = [[A[i][0], A[i][1], int(A[i][2])] for i in range(N)]",
"-A = sorted(A, key=lambda x: x[2], reverse=True)",
"-A = sorted(A, key=lambda x: x[1])",
"+A = []",
"- j, _, _ = A[i]",
"- print((j + 1))",
"+ s, p = input().split()",
"+ p = i... | false | 0.113038 | 0.118708 | 0.952234 | [
"s293099800",
"s754811827"
] |
u983918956 | p03805 | python | s710428095 | s585998685 | 37 | 28 | 3,064 | 3,064 | Accepted | Accepted | 24.32 | def multival(): return list(map(int,input().split()))
def data(N=1): return [list(map(int,input().split())) for _ in range(N)]
mod = 10**9 + 7
inf = float("inf")
N,M = multival()
nemat = [[0]*N for _ in range(N)]
ans = 0
for _ in range(M):
a,b = multival()
a -= 1; b-= 1
nemat[a][b] = 1
nema... | N,M = list(map(int,input().split()))
ad = [[0]*N for _ in range(N)]
for _ in range(M):
a,b = list(map(int,input().split()))
a -= 1; b -= 1
ad[a][b] = 1
ad[b][a] = 1
ans = 0
def dfs(v=0,d=0,visited=[1]+[0]*(N-1)):
if d == N-1:
global ans
ans += 1
return
fo... | 29 | 24 | 781 | 500 | def multival():
return list(map(int, input().split()))
def data(N=1):
return [list(map(int, input().split())) for _ in range(N)]
mod = 10**9 + 7
inf = float("inf")
N, M = multival()
nemat = [[0] * N for _ in range(N)]
ans = 0
for _ in range(M):
a, b = multival()
a -= 1
b -= 1
nemat[a][b] = 1... | N, M = list(map(int, input().split()))
ad = [[0] * N for _ in range(N)]
for _ in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
ad[a][b] = 1
ad[b][a] = 1
ans = 0
def dfs(v=0, d=0, visited=[1] + [0] * (N - 1)):
if d == N - 1:
global ans
ans += 1
return
... | false | 17.241379 | [
"-def multival():",
"- return list(map(int, input().split()))",
"+N, M = list(map(int, input().split()))",
"+ad = [[0] * N for _ in range(N)]",
"+for _ in range(M):",
"+ a, b = list(map(int, input().split()))",
"+ a -= 1",
"+ b -= 1",
"+ ad[a][b] = 1",
"+ ad[b][a] = 1",
"+ans =... | false | 0.036744 | 0.039134 | 0.938948 | [
"s710428095",
"s585998685"
] |
u556225812 | p03241 | python | s589787796 | s342791964 | 559 | 21 | 40,044 | 3,064 | Accepted | Accepted | 96.24 | N, M = list(map(int, input().split()))
x = M//N
max = 1
for i in range(x, 0, -1):
mod = M - (N-1)*i
if mod%i == 0:
max = i
break
print(max) | import math
N, M = list(map(int, input().split()))
ulim = M//N
mid = int(math.sqrt(M))
if ulim >= mid:
ans = []
for i in range(1, mid+1):
if M%i == 0:
ans.append(i)
if M//i <= ulim:
ans.append(M//i)
print((max(ans)))
else:
for i in reversed... | 9 | 18 | 165 | 394 | N, M = list(map(int, input().split()))
x = M // N
max = 1
for i in range(x, 0, -1):
mod = M - (N - 1) * i
if mod % i == 0:
max = i
break
print(max)
| import math
N, M = list(map(int, input().split()))
ulim = M // N
mid = int(math.sqrt(M))
if ulim >= mid:
ans = []
for i in range(1, mid + 1):
if M % i == 0:
ans.append(i)
if M // i <= ulim:
ans.append(M // i)
print((max(ans)))
else:
for i in reversed(list... | false | 50 | [
"+import math",
"+",
"-x = M // N",
"-max = 1",
"-for i in range(x, 0, -1):",
"- mod = M - (N - 1) * i",
"- if mod % i == 0:",
"- max = i",
"- break",
"-print(max)",
"+ulim = M // N",
"+mid = int(math.sqrt(M))",
"+if ulim >= mid:",
"+ ans = []",
"+ for i in rang... | false | 0.122177 | 0.042388 | 2.882313 | [
"s589787796",
"s342791964"
] |
u340040203 | p02600 | python | s625398460 | s421433151 | 32 | 28 | 9,164 | 9,156 | Accepted | Accepted | 12.5 | import sys
input = lambda: sys.stdin.readline().rstrip()
def main():
x = int(eval(input()))
if 400 <= x and x <=599:
print((8))
elif 600 <= x and x <= 799:
print((7))
elif 800 <= x and x <= 999:
print((6))
elif 1000 <= x and x <= 1199:
print((5))
eli... | import sys
input = lambda: sys.stdin.readline().rstrip()
def main():
print((10 - int(eval(input())) // 200))
if __name__ == '__main__':
main() | 24 | 8 | 563 | 171 | import sys
input = lambda: sys.stdin.readline().rstrip()
def main():
x = int(eval(input()))
if 400 <= x and x <= 599:
print((8))
elif 600 <= x and x <= 799:
print((7))
elif 800 <= x and x <= 999:
print((6))
elif 1000 <= x and x <= 1199:
print((5))
elif 1200 <= ... | import sys
input = lambda: sys.stdin.readline().rstrip()
def main():
print((10 - int(eval(input())) // 200))
if __name__ == "__main__":
main()
| false | 66.666667 | [
"- x = int(eval(input()))",
"- if 400 <= x and x <= 599:",
"- print((8))",
"- elif 600 <= x and x <= 799:",
"- print((7))",
"- elif 800 <= x and x <= 999:",
"- print((6))",
"- elif 1000 <= x and x <= 1199:",
"- print((5))",
"- elif 1200 <= x and x <= 1... | false | 0.116436 | 0.143627 | 0.810681 | [
"s625398460",
"s421433151"
] |
u987164499 | p03031 | python | s984523982 | s821611125 | 44 | 27 | 3,188 | 3,064 | Accepted | Accepted | 38.64 | from sys import stdin
from itertools import combinations_with_replacement,product
n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]
p = list(map(int,stdin.readline().rstrip().split()))
hai = [0,1]
hai = list(product(hai, repeat=... | n,m = list(map(int,input().split()))
li = [list(map(int,input().split()))[1:] for _ in range(m)]
p = list(map(int,input().split()))
ans = 0
for i in range(1 << n):
switch = set()
for j in range(n):
if (i >> j)&1:
switch.add(j+1)
for k in range(m):
point = 0
f... | 25 | 21 | 643 | 476 | from sys import stdin
from itertools import combinations_with_replacement, product
n, m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int, stdin.readline().rstrip().split())) for _ in range(m)]
p = list(map(int, stdin.readline().rstrip().split()))
hai = [0, 1]
hai = list(product(hai, repeat=n))
... | n, m = list(map(int, input().split()))
li = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(1 << n):
switch = set()
for j in range(n):
if (i >> j) & 1:
switch.add(j + 1)
for k in range(m):
point = 0
for l ... | false | 16 | [
"-from sys import stdin",
"-from itertools import combinations_with_replacement, product",
"-",
"-n, m = [int(x) for x in stdin.readline().rstrip().split()]",
"-li = [list(map(int, stdin.readline().rstrip().split())) for _ in range(m)]",
"-p = list(map(int, stdin.readline().rstrip().split()))",
"-hai = ... | false | 0.046923 | 0.007264 | 6.459633 | [
"s984523982",
"s821611125"
] |
u489959379 | p03640 | python | s121218869 | s127024700 | 391 | 27 | 44,508 | 3,828 | Accepted | Accepted | 93.09 | import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
H, W = list(map(int, input().split()))
n = int(eval(input()))
A = list(map(int, input().split()))
B = []
for i in range(n):
for _ in range(A[i]):
B.append(i + 1)
... | import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
H, W = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
grid = [[0 for _ in range(W)] for _ in range(H)]
h, w = 0, 0
for i in range(n):
cnt = A... | 36 | 31 | 757 | 654 | import sys
sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
H, W = list(map(int, input().split()))
n = int(eval(input()))
A = list(map(int, input().split()))
B = []
for i in range(n):
for _ in range(A[i]):
B.append(i + 1)
res = [[0] * W for ... | import sys
sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
H, W = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
grid = [[0 for _ in range(W)] for _ in range(H)]
h, w = 0, 0
for i in range(n):
cnt = A[i]
while cn... | false | 13.888889 | [
"- H, W = list(map(int, input().split()))",
"- n = int(eval(input()))",
"+ H, W = map(int, input().split())",
"+ n = int(input())",
"- B = []",
"+ grid = [[0 for _ in range(W)] for _ in range(H)]",
"+ h, w = 0, 0",
"- for _ in range(A[i]):",
"- B.append(i + 1)"... | false | 0.043994 | 0.037134 | 1.184726 | [
"s121218869",
"s127024700"
] |
u992910889 | p02753 | python | s231364084 | s059842556 | 216 | 184 | 38,384 | 38,256 | Accepted | Accepted | 14.81 | def resolve():
s=list(eval(input()))
if len(set(s))==1:
print('No')
else:
print('Yes')
resolve() | import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()
def resolve():
s = str(eval(input()))
if len(set(s))==1:
print('No')
else:
print('Yes')
resolve() | 8 | 13 | 126 | 238 | def resolve():
s = list(eval(input()))
if len(set(s)) == 1:
print("No")
else:
print("Yes")
resolve()
| import sys
sys.setrecursionlimit(10**5 + 10)
def input():
return sys.stdin.readline().strip()
def resolve():
s = str(eval(input()))
if len(set(s)) == 1:
print("No")
else:
print("Yes")
resolve()
| false | 38.461538 | [
"+import sys",
"+",
"+sys.setrecursionlimit(10**5 + 10)",
"+",
"+",
"+def input():",
"+ return sys.stdin.readline().strip()",
"+",
"+",
"- s = list(eval(input()))",
"+ s = str(eval(input()))"
] | false | 0.077039 | 0.051881 | 1.484898 | [
"s231364084",
"s059842556"
] |
u345966487 | p03172 | python | s413933118 | s473124091 | 479 | 320 | 117,744 | 92,464 | Accepted | Accepted | 33.19 | #!/usr/bin/env python3
import copy
import sys
MOD = 1000000007 # type: int
def debug(s):
print(s)
def solve(N: int, K: int, a: "List[int]"):
dp = [[0] * (K + 1) for _ in range(N + 1)]
dp[0][0] = 1
for i in range(1, N + 1):
ai = a[i - 1]
dp[i][0] = 1
for k i... | #!/usr/bin/env python3
import copy
import sys
import numpy as np
MOD = 1000000007 # type: int
def debug(s):
print(s)
def solve(N: int, K: int, a):
dp = np.zeros((N + 1, K + 1), dtype=np.int64)
dp[0, 0] = 1
for i in range(1, N + 1):
ai = a[i - 1]
ndp = np.cumsum(dp[... | 41 | 39 | 976 | 844 | #!/usr/bin/env python3
import copy
import sys
MOD = 1000000007 # type: int
def debug(s):
print(s)
def solve(N: int, K: int, a: "List[int]"):
dp = [[0] * (K + 1) for _ in range(N + 1)]
dp[0][0] = 1
for i in range(1, N + 1):
ai = a[i - 1]
dp[i][0] = 1
for k in range(1, K + 1)... | #!/usr/bin/env python3
import copy
import sys
import numpy as np
MOD = 1000000007 # type: int
def debug(s):
print(s)
def solve(N: int, K: int, a):
dp = np.zeros((N + 1, K + 1), dtype=np.int64)
dp[0, 0] = 1
for i in range(1, N + 1):
ai = a[i - 1]
ndp = np.cumsum(dp[i - 1, :])
... | false | 4.878049 | [
"+import numpy as np",
"-def solve(N: int, K: int, a: \"List[int]\"):",
"- dp = [[0] * (K + 1) for _ in range(N + 1)]",
"- dp[0][0] = 1",
"+def solve(N: int, K: int, a):",
"+ dp = np.zeros((N + 1, K + 1), dtype=np.int64)",
"+ dp[0, 0] = 1",
"- dp[i][0] = 1",
"- for k in ran... | false | 0.272939 | 0.338794 | 0.805619 | [
"s413933118",
"s473124091"
] |
u525065967 | p02608 | python | s042799069 | s897180568 | 525 | 461 | 9,048 | 9,324 | Accepted | Accepted | 12.19 | n = int(eval(input()))
f = [0]*(n+1)
for x in range(1, n):
if x*x >= n: break
for y in range(1, n):
if y*y >= n: break
if x*y >= n: break
for z in range(1, n):
if z*z >= n: break
k = x*x + y*y + z*z + x*y + y*z + z*x
if 1 <= k <= n: f[k] += 1... | n = int(eval(input()))
f = [0]*(n+1)
for x in range(1, 100):
for y in range(1, 100):
for z in range(1, 100):
k = x*x + y*y + z*z + x*y + y*z + z*x
if k <= n: f[k] += 1
for i in range(n): print((f[i+1]))
| 12 | 8 | 352 | 238 | n = int(eval(input()))
f = [0] * (n + 1)
for x in range(1, n):
if x * x >= n:
break
for y in range(1, n):
if y * y >= n:
break
if x * y >= n:
break
for z in range(1, n):
if z * z >= n:
break
k = x * x + y * y + z * z... | n = int(eval(input()))
f = [0] * (n + 1)
for x in range(1, 100):
for y in range(1, 100):
for z in range(1, 100):
k = x * x + y * y + z * z + x * y + y * z + z * x
if k <= n:
f[k] += 1
for i in range(n):
print((f[i + 1]))
| false | 33.333333 | [
"-for x in range(1, n):",
"- if x * x >= n:",
"- break",
"- for y in range(1, n):",
"- if y * y >= n:",
"- break",
"- if x * y >= n:",
"- break",
"- for z in range(1, n):",
"- if z * z >= n:",
"- break",
"+for x ... | false | 0.041762 | 1.807819 | 0.023101 | [
"s042799069",
"s897180568"
] |
u477977638 | p02713 | python | s817066379 | s284460836 | 487 | 46 | 70,596 | 9,176 | Accepted | Accepted | 90.55 | import sys
read = sys.stdin.buffer.read
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**9)
#from functools import lru_cache
def RD(): return sys.stdin.read()
def II(): return int(eval(input()))
def MI(): return list(map(int,input().split()))
def MF(): return list(m... | import sys
read = sys.stdin.buffer.read
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**9)
#from functools import lru_cache
def RD(): return sys.stdin.read()
def II(): return int(eval(input()))
def MI(): return list(map(int,input().split()))
def MF(): return list(m... | 43 | 45 | 798 | 812 | import sys
read = sys.stdin.buffer.read
# input = sys.stdin.readline
# input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**9)
# from functools import lru_cache
def RD():
return sys.stdin.read()
def II():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def MF():
... | import sys
read = sys.stdin.buffer.read
# input = sys.stdin.readline
# input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**9)
# from functools import lru_cache
def RD():
return sys.stdin.read()
def II():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def MF():
... | false | 4.444444 | [
"- li = [[0] * (k + 1) for i in range(k + 1)]",
"+ li = [0] * (k + 1)",
"- for c in range(1, k + 1):",
"- d = math.gcd(a, b)",
"- ans += math.gcd(d, c)",
"+ li[math.gcd(a, b)] += 1",
"+ for i in range(1, k + 1):",
"+ for c in range(1,... | false | 0.150634 | 0.07161 | 2.103529 | [
"s817066379",
"s284460836"
] |
u369142620 | p03211 | python | s293067263 | s588388501 | 191 | 18 | 13,836 | 2,940 | Accepted | Accepted | 90.58 | import numpy as np
def getNearestValue(list, num):
"""
概要: リストからある値に最も近い値を返却する関数
@param list: データ配列
@param num: 対象値
@return 対象値に最も近い値
"""
# リスト要素と対象値の差分を計算し最小値のインデックスを取得
idx = np.abs(np.asarray(list) - num).argmin()
return list[idx]
judge = 753
S = int(eval(inpu... | N = str(eval(input()))
doN = len(N)-2
strN = list(str(N))
minv = 20000000000
for i in range(doN):
judN=strN[i]+strN[i+1]+strN[i+2]
minv = min(minv,abs(753-int(judN)))
print(minv)
| 33 | 10 | 592 | 192 | import numpy as np
def getNearestValue(list, num):
"""
概要: リストからある値に最も近い値を返却する関数
@param list: データ配列
@param num: 対象値
@return 対象値に最も近い値
"""
# リスト要素と対象値の差分を計算し最小値のインデックスを取得
idx = np.abs(np.asarray(list) - num).argmin()
return list[idx]
judge = 753
S = int(eval(input()))
tmp = S
lst ... | N = str(eval(input()))
doN = len(N) - 2
strN = list(str(N))
minv = 20000000000
for i in range(doN):
judN = strN[i] + strN[i + 1] + strN[i + 2]
minv = min(minv, abs(753 - int(judN)))
print(minv)
| false | 69.69697 | [
"-import numpy as np",
"-",
"-",
"-def getNearestValue(list, num):",
"- \"\"\"",
"- 概要: リストからある値に最も近い値を返却する関数",
"- @param list: データ配列",
"- @param num: 対象値",
"- @return 対象値に最も近い値",
"- \"\"\"",
"- # リスト要素と対象値の差分を計算し最小値のインデックスを取得",
"- idx = np.abs(np.asarray(list) - num).a... | false | 0.273521 | 0.037199 | 7.353002 | [
"s293067263",
"s588388501"
] |
u476383383 | p02948 | python | s968148655 | s224759631 | 488 | 281 | 27,740 | 27,680 | Accepted | Accepted | 42.42 | from heapq import *
from collections import defaultdict
n, m = list(map(int, input().split()))
jobs = defaultdict(list)
for _ in range(n):
a, b = list(map(int, input().split()))
jobs[a].append(-b)
result = 0
pool = []
for i in range(1, m+1):
for j in jobs[i]:
heappush(pool, j)
if... | import sys
from collections import defaultdict
from heapq import *
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
def main():
""" main """
N,M = list(map(int, input().split()))
job_list = defaultdict(list)
for _ in range(N):
a, b = list(map(int, input().split()))
... | 18 | 26 | 374 | 580 | from heapq import *
from collections import defaultdict
n, m = list(map(int, input().split()))
jobs = defaultdict(list)
for _ in range(n):
a, b = list(map(int, input().split()))
jobs[a].append(-b)
result = 0
pool = []
for i in range(1, m + 1):
for j in jobs[i]:
heappush(pool, j)
if 0 < len(pool... | import sys
from collections import defaultdict
from heapq import *
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
def main():
"""main"""
N, M = list(map(int, input().split()))
job_list = defaultdict(list)
for _ in range(N):
a, b = list(map(int, input().split()))
job_list[a].a... | false | 30.769231 | [
"+import sys",
"+from collections import defaultdict",
"-from collections import defaultdict",
"-n, m = list(map(int, input().split()))",
"-jobs = defaultdict(list)",
"-for _ in range(n):",
"- a, b = list(map(int, input().split()))",
"- jobs[a].append(-b)",
"-result = 0",
"-pool = []",
"-f... | false | 0.043919 | 0.045291 | 0.969712 | [
"s968148655",
"s224759631"
] |
u860002137 | p03665 | python | s415767735 | s060384012 | 323 | 283 | 21,848 | 20,712 | Accepted | Accepted | 12.38 | from collections import deque
import numpy as np
from functools import lru_cache
nCr = {}
@lru_cache(maxsize=None)
def cmb(n, r):
if r == 0 or r == n:
return 1
if r == 1:
return n
if (n, r) in nCr:
return nCr[(n, r)]
nCr[(n, r)] = cmb(n-1, r) + cmb(n-1, r-1)
... | from collections import deque
import numpy as np
nCr = {}
def cmb(n, r):
if r == 0 or r == n:
return 1
if r == 1:
return n
if (n, r) in nCr:
return nCr[(n, r)]
nCr[(n, r)] = cmb(n-1, r) + cmb(n-1, r-1)
return nCr[(n, r)]
N, P = list(map(int, input().spli... | 40 | 38 | 774 | 715 | from collections import deque
import numpy as np
from functools import lru_cache
nCr = {}
@lru_cache(maxsize=None)
def cmb(n, r):
if r == 0 or r == n:
return 1
if r == 1:
return n
if (n, r) in nCr:
return nCr[(n, r)]
nCr[(n, r)] = cmb(n - 1, r) + cmb(n - 1, r - 1)
return n... | from collections import deque
import numpy as np
nCr = {}
def cmb(n, r):
if r == 0 or r == n:
return 1
if r == 1:
return n
if (n, r) in nCr:
return nCr[(n, r)]
nCr[(n, r)] = cmb(n - 1, r) + cmb(n - 1, r - 1)
return nCr[(n, r)]
N, P = list(map(int, input().split()))
A = n... | false | 5 | [
"-from functools import lru_cache",
"-@lru_cache(maxsize=None)"
] | false | 0.343431 | 0.19573 | 1.754619 | [
"s415767735",
"s060384012"
] |
u761529120 | p03209 | python | s795902803 | s989043886 | 176 | 65 | 38,384 | 69,280 | Accepted | Accepted | 63.07 | def L(N, X):
if N == 0:
return 1
a = 2 ** (N + 1) - 3
b = 2 ** N - 1
if X == 1:
return 0
elif X <= a + 1:
return L(N-1, X-1)
elif X == a + 2:
return b + 1
elif X <= 2 * a + 2:
return b + 1 + L(N-1, X-a-2)
else:
return b * 2 ... | def L(N):
if N == 0:
return 1
return 3 + 2 * L(N-1)
def P(N):
if N == 0:
return 1
return 1 + 2 * P(N-1)
def A(N,X):
res = 0
if N == 0:
return 1
if X == 1:
return 0
if 1 < X <= L(N-1) + 1:
res = A(N-1,X-1)
elif L(N-1) + 2 == X:... | 24 | 32 | 439 | 631 | def L(N, X):
if N == 0:
return 1
a = 2 ** (N + 1) - 3
b = 2**N - 1
if X == 1:
return 0
elif X <= a + 1:
return L(N - 1, X - 1)
elif X == a + 2:
return b + 1
elif X <= 2 * a + 2:
return b + 1 + L(N - 1, X - a - 2)
else:
return b * 2 + 1
de... | def L(N):
if N == 0:
return 1
return 3 + 2 * L(N - 1)
def P(N):
if N == 0:
return 1
return 1 + 2 * P(N - 1)
def A(N, X):
res = 0
if N == 0:
return 1
if X == 1:
return 0
if 1 < X <= L(N - 1) + 1:
res = A(N - 1, X - 1)
elif L(N - 1) + 2 == X:... | false | 25 | [
"-def L(N, X):",
"+def L(N):",
"- a = 2 ** (N + 1) - 3",
"- b = 2**N - 1",
"+ return 3 + 2 * L(N - 1)",
"+",
"+",
"+def P(N):",
"+ if N == 0:",
"+ return 1",
"+ return 1 + 2 * P(N - 1)",
"+",
"+",
"+def A(N, X):",
"+ res = 0",
"+ if N == 0:",
"+ ret... | false | 0.038602 | 0.038674 | 0.998136 | [
"s795902803",
"s989043886"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.