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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u485435834 | p03478 | python | s549076952 | s569874756 | 33 | 28 | 2,940 | 2,940 | Accepted | Accepted | 15.15 | N, A, B = list(map(int, input().split()))
num = 0
for i in range(1, N + 1):
if A <= sum(int(n) for n in str(i)) <= B:
num += i
print(num)
| N, A, B = list(map(int, input().split()))
print((sum(i for i in range(1, N+1) if A <= sum(map(int, str(i))) <= B)))
| 6 | 2 | 155 | 109 | N, A, B = list(map(int, input().split()))
num = 0
for i in range(1, N + 1):
if A <= sum(int(n) for n in str(i)) <= B:
num += i
print(num)
| N, A, B = list(map(int, input().split()))
print((sum(i for i in range(1, N + 1) if A <= sum(map(int, str(i))) <= B)))
| false | 66.666667 | [
"-num = 0",
"-for i in range(1, N + 1):",
"- if A <= sum(int(n) for n in str(i)) <= B:",
"- num += i",
"-print(num)",
"+print((sum(i for i in range(1, N + 1) if A <= sum(map(int, str(i))) <= B)))"
] | false | 0.05557 | 0.056126 | 0.990092 | [
"s549076952",
"s569874756"
] |
u619144316 | p02695 | python | s116016315 | s161490771 | 1,139 | 926 | 39,552 | 9,216 | Accepted | Accepted | 18.7 | import numpy as np
import itertools
N ,M ,Q = list(map(int,input().split(' ')))
ABCD = []
for _ in range(Q):
ABCD.append(list(map(int,input().split())))
ALL = list(itertools.combinations_with_replacement(list(range(1,M+1)), N))
MAX = 0
for row in ALL:
SUM = 0
for a,b,c,d in ABCD:
if (... | import itertools
N,M,Q = list(map(int,input().split()))
ABCD = []
for _ in range(Q):
a,b,c,d = list(map(int,input().split()))
ABCD.append(tuple([a-1,b-1,c,d]))
A = list(range(1,M+1))
MAX = 0
for L in itertools.combinations_with_replacement(A,N):
SUM = 0
for a,b,c,d in ABCD:
if L... | 18 | 19 | 394 | 384 | import numpy as np
import itertools
N, M, Q = list(map(int, input().split(" ")))
ABCD = []
for _ in range(Q):
ABCD.append(list(map(int, input().split())))
ALL = list(itertools.combinations_with_replacement(list(range(1, M + 1)), N))
MAX = 0
for row in ALL:
SUM = 0
for a, b, c, d in ABCD:
if (row[b ... | import itertools
N, M, Q = list(map(int, input().split()))
ABCD = []
for _ in range(Q):
a, b, c, d = list(map(int, input().split()))
ABCD.append(tuple([a - 1, b - 1, c, d]))
A = list(range(1, M + 1))
MAX = 0
for L in itertools.combinations_with_replacement(A, N):
SUM = 0
for a, b, c, d in ABCD:
... | false | 5.263158 | [
"-import numpy as np",
"-N, M, Q = list(map(int, input().split(\" \")))",
"+N, M, Q = list(map(int, input().split()))",
"- ABCD.append(list(map(int, input().split())))",
"-ALL = list(itertools.combinations_with_replacement(list(range(1, M + 1)), N))",
"+ a, b, c, d = list(map(int, input().split()))"... | false | 0.117055 | 0.107319 | 1.09072 | [
"s116016315",
"s161490771"
] |
u926678805 | p03290 | python | s397858580 | s587314716 | 266 | 47 | 3,064 | 3,064 | Accepted | Accepted | 82.33 | d,g=list(map(int,input().split()))
data=[]
cp=[]
for i in range(1,d+1):
p,c=list(map(int,input().split()))
data.append(p)
cp.append(c)
a=99999999
for i in range(1024):
ct=0
ans=0
tmp=data[:]
for j in range(d):
if i&(1<<j):
ct+=100*(j+1)*data[j]+cp[j]
... | d,g=list(map(int,input().split()))
data=[]
for i in range(d):
p,c=list(map(int,input().split()))
data.append((p,c))
n=0
mn=99999999
while n<2**d:
point=0
count=0
for i in range(d):
if n&(1<<i):
point+=data[i][0]*100*(i+1)+data[i][1]
count+=data[i][0]
... | 32 | 32 | 620 | 755 | d, g = list(map(int, input().split()))
data = []
cp = []
for i in range(1, d + 1):
p, c = list(map(int, input().split()))
data.append(p)
cp.append(c)
a = 99999999
for i in range(1024):
ct = 0
ans = 0
tmp = data[:]
for j in range(d):
if i & (1 << j):
ct += 100 * (j + 1) * ... | d, g = list(map(int, input().split()))
data = []
for i in range(d):
p, c = list(map(int, input().split()))
data.append((p, c))
n = 0
mn = 99999999
while n < 2**d:
point = 0
count = 0
for i in range(d):
if n & (1 << i):
point += data[i][0] * 100 * (i + 1) + data[i][1]
... | false | 0 | [
"-cp = []",
"-for i in range(1, d + 1):",
"+for i in range(d):",
"- data.append(p)",
"- cp.append(c)",
"-a = 99999999",
"-for i in range(1024):",
"- ct = 0",
"- ans = 0",
"- tmp = data[:]",
"- for j in range(d):",
"- if i & (1 << j):",
"- ct += 100 * (j + ... | false | 0.039788 | 0.057133 | 0.696417 | [
"s397858580",
"s587314716"
] |
u948524308 | p03836 | python | s884957197 | s281533857 | 19 | 17 | 3,188 | 3,064 | Accepted | Accepted | 10.53 | sx,sy,tx,ty=list(map(int,input().split()))
r1=["R"]
for i in range(tx-sx-1):
r1.append("R")
for i in range(ty-sy):
r1.append("U")
for i in range(tx - sx):
r1.append("L")
for i in range(ty - sy):
r1.append("D")
r1.append("D")
for i in range(tx-sx+1):
r1.append("R")
for i ... | sx,sy,tx,ty=list(map(int,input().split()))
r1=["R"]*(tx-sx)
r1.append("U"*(ty-sy))
r1.append("L"*(tx - sx))
r1.append("D"*(ty - sy))
r1.append("D")
r1.append("R"*(tx-sx+1))
r1.append("U"*(ty-sy+1))
r1.append("LU")
r1.append("L"*(tx-sx+1))
r1.append("D"*(ty-sy+1))
r1.append("R")
print... | 35 | 25 | 508 | 328 | sx, sy, tx, ty = list(map(int, input().split()))
r1 = ["R"]
for i in range(tx - sx - 1):
r1.append("R")
for i in range(ty - sy):
r1.append("U")
for i in range(tx - sx):
r1.append("L")
for i in range(ty - sy):
r1.append("D")
r1.append("D")
for i in range(tx - sx + 1):
r1.append("R")
for i in range(ty... | sx, sy, tx, ty = list(map(int, input().split()))
r1 = ["R"] * (tx - sx)
r1.append("U" * (ty - sy))
r1.append("L" * (tx - sx))
r1.append("D" * (ty - sy))
r1.append("D")
r1.append("R" * (tx - sx + 1))
r1.append("U" * (ty - sy + 1))
r1.append("LU")
r1.append("L" * (tx - sx + 1))
r1.append("D" * (ty - sy + 1))
r1.append("R... | false | 28.571429 | [
"-r1 = [\"R\"]",
"-for i in range(tx - sx - 1):",
"- r1.append(\"R\")",
"-for i in range(ty - sy):",
"- r1.append(\"U\")",
"-for i in range(tx - sx):",
"- r1.append(\"L\")",
"-for i in range(ty - sy):",
"- r1.append(\"D\")",
"+r1 = [\"R\"] * (tx - sx)",
"+r1.append(\"U\" * (ty - sy))... | false | 0.038064 | 0.038385 | 0.991634 | [
"s884957197",
"s281533857"
] |
u408071652 | p02863 | python | s666754631 | s456687954 | 126 | 115 | 74,236 | 73,568 | Accepted | Accepted | 8.73 | import sys
# \n
def input():
return sys.stdin.readline().rstrip()
def main():
N, T = list(map(int, input().split()))
dp = [0] * (T + 1)
AB = []
for k in range(N):
a, b = list(map(int, input().split()))
AB.append((a, b))
AB.sort()
maxdp = 0
f... | import sys
# \n
def input():
return sys.stdin.readline().rstrip()
def main():
N, T = list(map(int, input().split()))
dp = [0] * (T + 1)
AB = []
for k in range(N):
a, b = list(map(int, input().split()))
AB.append((a, b))
AB.sort()
maxdp = 0
temp =0
... | 33 | 31 | 594 | 632 | import sys
# \n
def input():
return sys.stdin.readline().rstrip()
def main():
N, T = list(map(int, input().split()))
dp = [0] * (T + 1)
AB = []
for k in range(N):
a, b = list(map(int, input().split()))
AB.append((a, b))
AB.sort()
maxdp = 0
for i in range(N):
a,... | import sys
# \n
def input():
return sys.stdin.readline().rstrip()
def main():
N, T = list(map(int, input().split()))
dp = [0] * (T + 1)
AB = []
for k in range(N):
a, b = list(map(int, input().split()))
AB.append((a, b))
AB.sort()
maxdp = 0
temp = 0
for i in range(N... | false | 6.060606 | [
"+ temp = 0",
"+ temp += a",
"- for j in range(T - 1, a - 1, -1):",
"+ for j in range(min(T - 1, temp + 1), a - 1, -1):"
] | false | 0.036286 | 0.036133 | 1.004246 | [
"s666754631",
"s456687954"
] |
u330661451 | p02954 | python | s449804399 | s359190394 | 215 | 123 | 4,984 | 10,484 | Accepted | Accepted | 42.79 | s = input() + "R"
v = [0 for i in range(len(s)-1)]
even = 0
odd = 0
lrpos = 0
lr = "R"
for i in range(len(s)):
if lr != s[i]:
if lr == "R":
if even == odd:
v[i-1] += even
v[i] += odd
else:
v[i] += even
... | s = eval(input())
ans = [0] * len(s)
cnt = 1
prev = -1
for i in range(1,len(s)+1):
if i == len(s) or s[i] != s[i-1]:
if s[i-1] == "L":
ans[prev-1] += cnt // 2
ans[prev] += (cnt+1) // 2
else:
ans[i] += cnt // 2
ans[i-1] += (cnt+1) // 2
... | 37 | 18 | 739 | 405 | s = input() + "R"
v = [0 for i in range(len(s) - 1)]
even = 0
odd = 0
lrpos = 0
lr = "R"
for i in range(len(s)):
if lr != s[i]:
if lr == "R":
if even == odd:
v[i - 1] += even
v[i] += odd
else:
v[i] += even
v[i - 1] += od... | s = eval(input())
ans = [0] * len(s)
cnt = 1
prev = -1
for i in range(1, len(s) + 1):
if i == len(s) or s[i] != s[i - 1]:
if s[i - 1] == "L":
ans[prev - 1] += cnt // 2
ans[prev] += (cnt + 1) // 2
else:
ans[i] += cnt // 2
ans[i - 1] += (cnt + 1) // 2
... | false | 51.351351 | [
"-s = input() + \"R\"",
"-v = [0 for i in range(len(s) - 1)]",
"-even = 0",
"-odd = 0",
"-lrpos = 0",
"-lr = \"R\"",
"-for i in range(len(s)):",
"- if lr != s[i]:",
"- if lr == \"R\":",
"- if even == odd:",
"- v[i - 1] += even",
"- v[i] += odd... | false | 0.035905 | 0.057529 | 0.624122 | [
"s449804399",
"s359190394"
] |
u797673668 | p02266 | python | s265637083 | s286566733 | 80 | 70 | 8,152 | 8,416 | Accepted | Accepted | 12.5 | def marge_ponds(lx, area_of_pond):
global ponds
if ponds:
lp = ponds.pop()
if lp[0] > lx:
return marge_ponds(lx, area_of_pond + lp[1])
else:
ponds.append(lp)
return area_of_pond
terrains = input().strip()
x, last_x, ponds = 0, [], []
for terra... | from collections import deque
def marge_ponds(lx, area_of_pond):
global ponds
if ponds and ponds[-1][0] > lx:
return marge_ponds(lx, area_of_pond + ponds.pop()[1])
return area_of_pond
terrains = input().strip()
x, last_x, ponds = 0, deque(), deque()
for terrain in terrains:
if... | 27 | 25 | 704 | 641 | def marge_ponds(lx, area_of_pond):
global ponds
if ponds:
lp = ponds.pop()
if lp[0] > lx:
return marge_ponds(lx, area_of_pond + lp[1])
else:
ponds.append(lp)
return area_of_pond
terrains = input().strip()
x, last_x, ponds = 0, [], []
for terrain in terrains:... | from collections import deque
def marge_ponds(lx, area_of_pond):
global ponds
if ponds and ponds[-1][0] > lx:
return marge_ponds(lx, area_of_pond + ponds.pop()[1])
return area_of_pond
terrains = input().strip()
x, last_x, ponds = 0, deque(), deque()
for terrain in terrains:
if terrain == "\\... | false | 7.407407 | [
"+from collections import deque",
"+",
"+",
"- if ponds:",
"- lp = ponds.pop()",
"- if lp[0] > lx:",
"- return marge_ponds(lx, area_of_pond + lp[1])",
"- else:",
"- ponds.append(lp)",
"+ if ponds and ponds[-1][0] > lx:",
"+ return marge_pon... | false | 0.037472 | 0.037078 | 1.010625 | [
"s265637083",
"s286566733"
] |
u175034939 | p03681 | python | s094965174 | s328118697 | 702 | 41 | 5,112 | 3,064 | Accepted | Accepted | 94.16 | import math
n,m = list(map(int,input().split()))
a = 1000000007
if not (0 <= abs(n-m) <= 1):
print((0))
exit()
if n == m:
num = 2
else:
num = 1
print((num*math.factorial(n)*math.factorial(m) % a)) | n,m = list(map(int,input().split()))
a = 10**9+7
if m > n:
n,m = m,n
if not (0 <= n-m <= 1):
print((0))
exit()
if n == m:
num = 2
n = 1
else:
num = 1
t = 1
for i in range(1,m+1):
t *= i
t %= a
print((num*t*t*n%a)) | 12 | 18 | 214 | 254 | import math
n, m = list(map(int, input().split()))
a = 1000000007
if not (0 <= abs(n - m) <= 1):
print((0))
exit()
if n == m:
num = 2
else:
num = 1
print((num * math.factorial(n) * math.factorial(m) % a))
| n, m = list(map(int, input().split()))
a = 10**9 + 7
if m > n:
n, m = m, n
if not (0 <= n - m <= 1):
print((0))
exit()
if n == m:
num = 2
n = 1
else:
num = 1
t = 1
for i in range(1, m + 1):
t *= i
t %= a
print((num * t * t * n % a))
| false | 33.333333 | [
"-import math",
"-",
"-a = 1000000007",
"-if not (0 <= abs(n - m) <= 1):",
"+a = 10**9 + 7",
"+if m > n:",
"+ n, m = m, n",
"+if not (0 <= n - m <= 1):",
"+ n = 1",
"-print((num * math.factorial(n) * math.factorial(m) % a))",
"+t = 1",
"+for i in range(1, m + 1):",
"+ t *= i",
"+ ... | false | 0.165802 | 0.040907 | 4.053167 | [
"s094965174",
"s328118697"
] |
u077291787 | p03354 | python | s021626256 | s049900920 | 582 | 529 | 90,944 | 90,168 | Accepted | Accepted | 9.11 | # ARC097D - Equals (ABC097D)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
def dfs(v: int, color: int) -> None:
seen[v] = 1 # make vertex v searched
group[v] = color
for u in G[v]: # search vertices available from v recursively
if not seen[u]: # skip if alread... | # ARC097D - Equals
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
def dfs(v: int, color: int) -> None:
group[v] = color # make vertex v searched
for u in G[v]: # search vertices available from v recursively
if not group[u]: # skip if already searched
df... | 37 | 36 | 1,075 | 1,025 | # ARC097D - Equals (ABC097D)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
def dfs(v: int, color: int) -> None:
seen[v] = 1 # make vertex v searched
group[v] = color
for u in G[v]: # search vertices available from v recursively
if not seen[u]: # skip if already searched
... | # ARC097D - Equals
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
def dfs(v: int, color: int) -> None:
group[v] = color # make vertex v searched
for u in G[v]: # search vertices available from v recursively
if not group[u]: # skip if already searched
dfs(u, color)
... | false | 2.702703 | [
"-# ARC097D - Equals (ABC097D)",
"+# ARC097D - Equals",
"- seen[v] = 1 # make vertex v searched",
"- group[v] = color",
"+ group[v] = color # make vertex v searched",
"- if not seen[u]: # skip if already searched",
"+ if not group[u]: # skip if already searched",
"- globa... | false | 0.074596 | 0.041191 | 1.810983 | [
"s021626256",
"s049900920"
] |
u919633157 | p03478 | python | s952362722 | s423943985 | 35 | 29 | 3,060 | 2,940 | Accepted | Accepted | 17.14 | n,a,b=list(map(int,input().split()))
cnt=0
for i in range(1,n+1):
if a<=sum(list(map(int,str(i))))<=b:
cnt+=i
print(cnt) | n,a,b=list(map(int,input().split()))
cnt=0
for i in range(1,n+1):
if a<=sum(map(int,str(i)))<=b:
cnt+=i
print(cnt) | 6 | 6 | 131 | 125 | n, a, b = list(map(int, input().split()))
cnt = 0
for i in range(1, n + 1):
if a <= sum(list(map(int, str(i)))) <= b:
cnt += i
print(cnt)
| n, a, b = list(map(int, input().split()))
cnt = 0
for i in range(1, n + 1):
if a <= sum(map(int, str(i))) <= b:
cnt += i
print(cnt)
| false | 0 | [
"- if a <= sum(list(map(int, str(i)))) <= b:",
"+ if a <= sum(map(int, str(i))) <= b:"
] | false | 0.03458 | 0.033854 | 1.021438 | [
"s952362722",
"s423943985"
] |
u883048396 | p03401 | python | s167602198 | s723922605 | 185 | 171 | 16,192 | 16,192 | Accepted | Accepted | 7.57 | iN = int(eval(input()))
aA = [0] + [int(_) for _ in input().split()] + [0]
iAll = sum([abs(aA[i+1]-aA[i]) for i in range(iN+1)])
print(("\n".join([str( iAll - abs(aA[i-1]-aA[i]) - abs(aA[i]-aA[i+1]) + abs(aA[i-1]-aA[i+1])) for i in range(1,iN+1)])))
| #mapってそんなに速ないんけ?
iN = int(eval(input()))
aA = [0] + [int(_) for _ in input().split()] + [0]
iAll = sum([abs(aA[i+1]-aA[i]) for i in range(iN+1)])
print(("\n".join(map(str,[iAll - abs(aA[i-1]-aA[i]) - abs(aA[i]-aA[i+1]) + abs(aA[i-1]-aA[i+1]) for i in range(1,iN+1)]))))
| 4 | 5 | 253 | 274 | iN = int(eval(input()))
aA = [0] + [int(_) for _ in input().split()] + [0]
iAll = sum([abs(aA[i + 1] - aA[i]) for i in range(iN + 1)])
print(
(
"\n".join(
[
str(
iAll
- abs(aA[i - 1] - aA[i])
- abs(aA[i] - aA[i + 1])
... | # mapってそんなに速ないんけ?
iN = int(eval(input()))
aA = [0] + [int(_) for _ in input().split()] + [0]
iAll = sum([abs(aA[i + 1] - aA[i]) for i in range(iN + 1)])
print(
(
"\n".join(
map(
str,
[
iAll
- abs(aA[i - 1] - aA[i])
... | false | 20 | [
"+# mapってそんなに速ないんけ?",
"- [",
"- str(",
"+ map(",
"+ str,",
"+ [",
"- )",
"- for i in range(1, iN + 1)",
"- ]",
"+ for i in range(1, iN + 1)",
"+ ],",
"+... | false | 0.104958 | 0.101177 | 1.037372 | [
"s167602198",
"s723922605"
] |
u476604182 | p02955 | python | s668017813 | s719733946 | 297 | 256 | 45,276 | 42,860 | Accepted | Accepted | 13.8 | N, K = list(map(int, input().split()))
A = [int(c) for c in input().split()]
S = sum(A)
pls = []
for i in range(1,S):
if i*i>S:
break
if S%i==0:
pls += [i]
pls += [S//i]
pls.sort(reverse=True)
for p in pls:
B = []
for i in range(N):
B += [A[i]%p]
B.sort()
for j in r... | N,K,*A = list(map(int, open(0).read().split()))
pls = []
S = sum(A)
for i in range(1,int(S**0.5)+1):
if S%i==0:
pls.append(i)
pls.append(S//i)
pls.sort()
ans = 0
for p in pls:
B = [a%p for a in A]
B.sort()
i = 0
j = N-1
cnt = K
while i<N:
if B[i]!=0:
break
i += 1
... | 42 | 47 | 786 | 727 | N, K = list(map(int, input().split()))
A = [int(c) for c in input().split()]
S = sum(A)
pls = []
for i in range(1, S):
if i * i > S:
break
if S % i == 0:
pls += [i]
pls += [S // i]
pls.sort(reverse=True)
for p in pls:
B = []
for i in range(N):
B += [A[i] % p]
B.sort()... | N, K, *A = list(map(int, open(0).read().split()))
pls = []
S = sum(A)
for i in range(1, int(S**0.5) + 1):
if S % i == 0:
pls.append(i)
pls.append(S // i)
pls.sort()
ans = 0
for p in pls:
B = [a % p for a in A]
B.sort()
i = 0
j = N - 1
cnt = K
while i < N:
if B[i] != 0... | false | 10.638298 | [
"-N, K = list(map(int, input().split()))",
"-A = [int(c) for c in input().split()]",
"+N, K, *A = list(map(int, open(0).read().split()))",
"+pls = []",
"-pls = []",
"-for i in range(1, S):",
"- if i * i > S:",
"- break",
"+for i in range(1, int(S**0.5) + 1):",
"- pls += [i]",
"-... | false | 0.037056 | 0.117175 | 0.316242 | [
"s668017813",
"s719733946"
] |
u745087332 | p03208 | python | s551704674 | s626495195 | 193 | 133 | 18,164 | 7,384 | Accepted | Accepted | 31.09 | # coding:utf-8
import sys
from collections import Counter
input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7
def inpl(): return list(map(int, input().split()))
N, K = inpl()
H = []
for i in range(N):
H.append(int(eval(input())))
C = Counter(H)
H2 = sorted(H)
S = [0]
fo... | # coding:utf-8
import sys
input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7
def inpl(): return list(map(int, input().split()))
N, K = inpl()
H = [int(eval(input())) for _ in range(N)]
H.sort()
ans = INF
for i in range(N - K + 1):
ans = min(ans, H[i + K - 1] - H[i])
print(... | 34 | 22 | 530 | 319 | # coding:utf-8
import sys
from collections import Counter
input = sys.stdin.readline
INF = float("inf")
MOD = 10**9 + 7
def inpl():
return list(map(int, input().split()))
N, K = inpl()
H = []
for i in range(N):
H.append(int(eval(input())))
C = Counter(H)
H2 = sorted(H)
S = [0]
for i in range(N - 1):
S.... | # coding:utf-8
import sys
input = sys.stdin.readline
INF = float("inf")
MOD = 10**9 + 7
def inpl():
return list(map(int, input().split()))
N, K = inpl()
H = [int(eval(input())) for _ in range(N)]
H.sort()
ans = INF
for i in range(N - K + 1):
ans = min(ans, H[i + K - 1] - H[i])
print(ans)
| false | 35.294118 | [
"-from collections import Counter",
"-H = []",
"-for i in range(N):",
"- H.append(int(eval(input())))",
"-C = Counter(H)",
"-H2 = sorted(H)",
"-S = [0]",
"-for i in range(N - 1):",
"- S.append(S[-1] + H2[i + 1] - H2[i])",
"-# print(H2)",
"+H = [int(eval(input())) for _ in range(N)]",
"+H... | false | 0.171266 | 0.045294 | 3.78119 | [
"s551704674",
"s626495195"
] |
u761989513 | p03448 | python | s238255380 | s587134064 | 50 | 18 | 2,940 | 3,060 | Accepted | Accepted | 64 | a, b, c, x = list(map(int, [eval(input()) for i in range(4)]))
ans = 0
for A in range(a + 1):
for B in range(b + 1):
for C in range(c + 1):
if 500 * A + 100 * B + 50 * C == x:
ans += 1
print(ans) | a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
x = int(eval(input()))
ans = 0
for A in range(a + 1):
for B in range(b + 1):
C = (x - 500 * A - 100 * B) // 50
if 0 <= C <= c:
ans += 1
print(ans) | 8 | 11 | 210 | 233 | a, b, c, x = list(map(int, [eval(input()) for i in range(4)]))
ans = 0
for A in range(a + 1):
for B in range(b + 1):
for C in range(c + 1):
if 500 * A + 100 * B + 50 * C == x:
ans += 1
print(ans)
| a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
x = int(eval(input()))
ans = 0
for A in range(a + 1):
for B in range(b + 1):
C = (x - 500 * A - 100 * B) // 50
if 0 <= C <= c:
ans += 1
print(ans)
| false | 27.272727 | [
"-a, b, c, x = list(map(int, [eval(input()) for i in range(4)]))",
"+a = int(eval(input()))",
"+b = int(eval(input()))",
"+c = int(eval(input()))",
"+x = int(eval(input()))",
"- for C in range(c + 1):",
"- if 500 * A + 100 * B + 50 * C == x:",
"- ans += 1",
"+ ... | false | 0.107562 | 0.054549 | 1.971859 | [
"s238255380",
"s587134064"
] |
u223133214 | p02803 | python | s413681966 | s472358171 | 314 | 284 | 49,116 | 47,580 | Accepted | Accepted | 9.55 | h, w = list(map(int, input().split()))
def cl(sx, sy, m):
Z = -1
dist = [[Z for i in range(w)] for j in range(h)]
for i in range(h):
for j in range(w):
if m[i][j] == '#':
dist[i][j] = -1
def bfs():
q = []
q.insert(0, (sx, sy))
di... | from collections import deque
h, w = list(map(int, input().split()))
S = [list(eval(input())) for _ in range(h)]
INF = 10010001001
way = [[0, 1], [0, -1], [1, 0], [-1, 0]]
ans = 0
for sy in range(h):
for sx in range(w):
dist = [[INF] * w for _ in range(h)]
dist[sy][sx] = 0
if S[s... | 34 | 32 | 968 | 1,008 | h, w = list(map(int, input().split()))
def cl(sx, sy, m):
Z = -1
dist = [[Z for i in range(w)] for j in range(h)]
for i in range(h):
for j in range(w):
if m[i][j] == "#":
dist[i][j] = -1
def bfs():
q = []
q.insert(0, (sx, sy))
dist[sy][sx] =... | from collections import deque
h, w = list(map(int, input().split()))
S = [list(eval(input())) for _ in range(h)]
INF = 10010001001
way = [[0, 1], [0, -1], [1, 0], [-1, 0]]
ans = 0
for sy in range(h):
for sx in range(w):
dist = [[INF] * w for _ in range(h)]
dist[sy][sx] = 0
if S[sy][sx] == "... | false | 5.882353 | [
"+from collections import deque",
"+",
"-",
"-",
"-def cl(sx, sy, m):",
"- Z = -1",
"- dist = [[Z for i in range(w)] for j in range(h)]",
"- for i in range(h):",
"- for j in range(w):",
"- if m[i][j] == \"#\":",
"- dist[i][j] = -1",
"-",
"- def bf... | false | 0.123389 | 0.049161 | 2.509918 | [
"s413681966",
"s472358171"
] |
u827202523 | p03355 | python | s179581224 | s919742508 | 82 | 46 | 68,952 | 10,904 | Accepted | Accepted | 43.9 | import sys
from collections import defaultdict, deque, Counter
import math
# import copy
from bisect import bisect_left, bisect_right
# import heapq
# sys.setrecursionlimit(1000000)
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(eval(input()))
getList = l... | import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)
# input aliases
input = sys.stdin.readline
getS = lambda: input()... | 67 | 51 | 1,255 | 1,002 | import sys
from collections import defaultdict, deque, Counter
import math
# import copy
from bisect import bisect_left, bisect_right
# import heapq
# sys.setrecursionlimit(1000000)
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(eval(input()))
getList = lambda: list(map(i... | import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
ge... | false | 23.880597 | [
"+import math",
"+import copy",
"+from heapq import heappush, heappop, heapify",
"+from functools import cmp_to_key",
"+from bisect import bisect_left, bisect_right",
"-import math",
"-# import copy",
"-from bisect import bisect_left, bisect_right",
"-",
"-# import heapq",
"-INF = 10**20",
"+I... | false | 0.127782 | 0.1688 | 0.757001 | [
"s179581224",
"s919742508"
] |
u127499732 | p03078 | python | s104255003 | s518327783 | 791 | 35 | 4,852 | 5,360 | Accepted | Accepted | 95.58 | def main():
import heapq
x, y, z, k, *abc = map(int, open(0).read().split())
a = abc[:x]
b = abc[x:x + y]
c = abc[x + y:]
d = []
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
h = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]
heapq.heapify(h)
ans = ... | def main():
import heapq
x, y, z, k, *abc = map(int, open(0).read().split())
a = abc[:x]
b = abc[x:x + y]
c = abc[x + y:]
s = set()
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
h = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]
heapq.heapify(h)
ans... | 31 | 31 | 827 | 827 | def main():
import heapq
x, y, z, k, *abc = map(int, open(0).read().split())
a = abc[:x]
b = abc[x : x + y]
c = abc[x + y :]
d = []
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
h = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]
heapq.heapify(h)
ans = []
for _ i... | def main():
import heapq
x, y, z, k, *abc = map(int, open(0).read().split())
a = abc[:x]
b = abc[x : x + y]
c = abc[x + y :]
s = set()
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
h = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]
heapq.heapify(h)
ans = []
for ... | false | 0 | [
"- d = []",
"+ s = set()",
"- if (i + p, j + q, k + r) not in d:",
"- d.append((i + p, j + q, k + r))",
"+ if (i + p, j + q, k + r) not in s:",
"+ s.add((i + p, j + q, k + r))"
] | false | 0.045528 | 0.035432 | 1.284939 | [
"s104255003",
"s518327783"
] |
u062147869 | p03233 | python | s029494490 | s504610832 | 1,271 | 890 | 64,752 | 58,460 | Accepted | Accepted | 29.98 | import sys
N=int(eval(input()))
A=0
B=0
table=[]
for i in range(N):
a,b=list(map(int,input().split()))
table.append((a,i))
table.append((b,i))
A+=a
B+=b
ans=min(A,B)
table.sort()
num=0
for i in range(N):
num+=table[i][0]
L=[0]*N
#print(table)
for i in range(N):
c,j=table[i... | import sys
input = sys.stdin.readline
N=int(eval(input()))
A=0
B=0
table=[]
for i in range(N):
a,b=list(map(int,input().split()))
table.append((a,i))
table.append((b,i))
A+=a
B+=b
ans=min(A,B)
table.sort()
num=0
for i in range(N):
num+=table[i][0]
L=[0]*N
#print(table)
for i i... | 37 | 38 | 662 | 690 | import sys
N = int(eval(input()))
A = 0
B = 0
table = []
for i in range(N):
a, b = list(map(int, input().split()))
table.append((a, i))
table.append((b, i))
A += a
B += b
ans = min(A, B)
table.sort()
num = 0
for i in range(N):
num += table[i][0]
L = [0] * N
# print(table)
for i in range(N):
... | import sys
input = sys.stdin.readline
N = int(eval(input()))
A = 0
B = 0
table = []
for i in range(N):
a, b = list(map(int, input().split()))
table.append((a, i))
table.append((b, i))
A += a
B += b
ans = min(A, B)
table.sort()
num = 0
for i in range(N):
num += table[i][0]
L = [0] * N
# print(ta... | false | 2.631579 | [
"+input = sys.stdin.readline"
] | false | 0.086621 | 0.118316 | 0.732117 | [
"s029494490",
"s504610832"
] |
u747602774 | p03945 | python | s408870824 | s625340058 | 49 | 40 | 3,956 | 3,188 | Accepted | Accepted | 18.37 | li=list(eval(input()))
ans=0
for n in range(len(li)-1):
if li[n]!=li[n+1]:
ans+=1
print(ans) | s = eval(input())
n = len(s)
t = s[0]
ans = 0
for i in range(n):
if s[i] != t:
ans += 1
t = s[i]
print(ans) | 6 | 9 | 97 | 129 | li = list(eval(input()))
ans = 0
for n in range(len(li) - 1):
if li[n] != li[n + 1]:
ans += 1
print(ans)
| s = eval(input())
n = len(s)
t = s[0]
ans = 0
for i in range(n):
if s[i] != t:
ans += 1
t = s[i]
print(ans)
| false | 33.333333 | [
"-li = list(eval(input()))",
"+s = eval(input())",
"+n = len(s)",
"+t = s[0]",
"-for n in range(len(li) - 1):",
"- if li[n] != li[n + 1]:",
"+for i in range(n):",
"+ if s[i] != t:",
"+ t = s[i]"
] | false | 0.04254 | 0.041804 | 1.017607 | [
"s408870824",
"s625340058"
] |
u969190727 | p03033 | python | s311044356 | s315594273 | 1,893 | 1,691 | 125,324 | 127,856 | Accepted | Accepted | 10.67 | import sys
input = sys.stdin.readline
n,q=list(map(int,input().split()))
import heapq
S=[]
D=dict()
for i in range(n):
s,t,x=list(map(int,input().split()))
S.append((1,x,max(0,s-x)))
S.append((-1,x,max(0,t-x)))
D[x]=False
S.sort(key=lambda x:x[2])
X=[]
cur=0
for i in range(q):
d=int(eval(input(... | import sys
input = sys.stdin.buffer.readline
n,q=list(map(int,input().split()))
import heapq
S=[]
D=dict()
for i in range(n):
s,t,x=list(map(int,input().split()))
S.append((1,x,max(0,s-x)))
S.append((-1,x,max(0,t-x)))
D[x]=False
S.sort(key=lambda x:x[2])
X=[]
cur=0
for i in range(q):
d=int(eval... | 35 | 35 | 632 | 639 | import sys
input = sys.stdin.readline
n, q = list(map(int, input().split()))
import heapq
S = []
D = dict()
for i in range(n):
s, t, x = list(map(int, input().split()))
S.append((1, x, max(0, s - x)))
S.append((-1, x, max(0, t - x)))
D[x] = False
S.sort(key=lambda x: x[2])
X = []
cur = 0
for i in rang... | import sys
input = sys.stdin.buffer.readline
n, q = list(map(int, input().split()))
import heapq
S = []
D = dict()
for i in range(n):
s, t, x = list(map(int, input().split()))
S.append((1, x, max(0, s - x)))
S.append((-1, x, max(0, t - x)))
D[x] = False
S.sort(key=lambda x: x[2])
X = []
cur = 0
for i ... | false | 0 | [
"-input = sys.stdin.readline",
"+input = sys.stdin.buffer.readline"
] | false | 0.043543 | 0.038908 | 1.119138 | [
"s311044356",
"s315594273"
] |
u931462344 | p03043 | python | s873833806 | s455741103 | 59 | 51 | 3,060 | 3,060 | Accepted | Accepted | 13.56 | n, k = list(map(int, input().split()))
ans = 0
for i in range(1,n+1):
tmp = i
cnt = 0
while tmp < k:
tmp *= 2
cnt += 1
ans += (1/n) * pow((1/2), cnt)
print(ans) | N, K = list(map(int, input().split()))
ans = 0
for i in range(1, N+1):
tmp = i
cnt = 0
while tmp < K:
tmp *= 2
cnt += 1
ans += (1/N)*(1/2)**cnt
print(ans) | 10 | 11 | 195 | 191 | n, k = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
tmp = i
cnt = 0
while tmp < k:
tmp *= 2
cnt += 1
ans += (1 / n) * pow((1 / 2), cnt)
print(ans)
| N, K = list(map(int, input().split()))
ans = 0
for i in range(1, N + 1):
tmp = i
cnt = 0
while tmp < K:
tmp *= 2
cnt += 1
ans += (1 / N) * (1 / 2) ** cnt
print(ans)
| false | 9.090909 | [
"-n, k = list(map(int, input().split()))",
"+N, K = list(map(int, input().split()))",
"-for i in range(1, n + 1):",
"+for i in range(1, N + 1):",
"- while tmp < k:",
"+ while tmp < K:",
"- ans += (1 / n) * pow((1 / 2), cnt)",
"+ ans += (1 / N) * (1 / 2) ** cnt"
] | false | 0.081109 | 0.070387 | 1.152331 | [
"s873833806",
"s455741103"
] |
u075012704 | p03223 | python | s959655200 | s030623736 | 635 | 237 | 61,272 | 13,696 | Accepted | Accepted | 62.68 | from collections import deque
N = int(eval(input()))
A = deque(sorted([int(eval(input())) for i in range(N)]))
X = deque([A.popleft()])
ans = 0
for i in range(N - 1):
# Aのどちらから取り出してXのどちらに入れるか
left_left = abs(X[0] - A[0])
left_right = abs(X[-1] - A[0])
right_left = abs(X[0] - A[-1])
right... | N = int(eval(input()))
A = sorted([int(eval(input())) for i in range(N)])
if N % 2 == 0:
X = [-2] * ((N - 2) // 2) + [-1, 1] + [2] * ((N - 2) // 2)
ans = sum([a * x for a, x in zip(A, X)])
print(ans)
else:
X1 = [-2] * ((N - 2) // 2 + 1) + [1, 1] + [2] * ((N - 2) // 2)
X2 = [-2] * ((N - 2) ... | 30 | 13 | 794 | 476 | from collections import deque
N = int(eval(input()))
A = deque(sorted([int(eval(input())) for i in range(N)]))
X = deque([A.popleft()])
ans = 0
for i in range(N - 1):
# Aのどちらから取り出してXのどちらに入れるか
left_left = abs(X[0] - A[0])
left_right = abs(X[-1] - A[0])
right_left = abs(X[0] - A[-1])
right_right = ab... | N = int(eval(input()))
A = sorted([int(eval(input())) for i in range(N)])
if N % 2 == 0:
X = [-2] * ((N - 2) // 2) + [-1, 1] + [2] * ((N - 2) // 2)
ans = sum([a * x for a, x in zip(A, X)])
print(ans)
else:
X1 = [-2] * ((N - 2) // 2 + 1) + [1, 1] + [2] * ((N - 2) // 2)
X2 = [-2] * ((N - 2) // 2) + [-... | false | 56.666667 | [
"-from collections import deque",
"-",
"-A = deque(sorted([int(eval(input())) for i in range(N)]))",
"-X = deque([A.popleft()])",
"-ans = 0",
"-for i in range(N - 1):",
"- # Aのどちらから取り出してXのどちらに入れるか",
"- left_left = abs(X[0] - A[0])",
"- left_right = abs(X[-1] - A[0])",
"- right_left = a... | false | 0.044688 | 0.14573 | 0.30665 | [
"s959655200",
"s030623736"
] |
u970197315 | p02820 | python | s020800873 | s846095935 | 118 | 105 | 13,428 | 3,444 | Accepted | Accepted | 11.02 | # ABC149 D
si = lambda: eval(input())
ni = lambda: int(eval(input()))
nm = lambda: list(map(int, input().split()))
nl = lambda: list(map(int, input().split()))
n,k=nm()
r,s,p=nm()
t=si()
l=[[] for i in range(k)]
ans=0
for i in range(n):
j=(i+1)%k
l[j].append(t[i:i+1])
same_flg=False
for ll in ... | n,k=list(map(int,input().split()))
r,s,p=list(map(int,input().split()))
t=eval(input())
ans=0
S=""
for i in range(n):
if i-k>=0:
if t[i]==t[i-k]:
if t[i]=="r":
if S[i-k]=="p":
S+="r"
elif S[i-k]=="r":
S+="p"
ans+=p
elif t[i]=="s":
... | 54 | 38 | 1,227 | 682 | # ABC149 D
si = lambda: eval(input())
ni = lambda: int(eval(input()))
nm = lambda: list(map(int, input().split()))
nl = lambda: list(map(int, input().split()))
n, k = nm()
r, s, p = nm()
t = si()
l = [[] for i in range(k)]
ans = 0
for i in range(n):
j = (i + 1) % k
l[j].append(t[i : i + 1])
same_flg = False
for... | n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = eval(input())
ans = 0
S = ""
for i in range(n):
if i - k >= 0:
if t[i] == t[i - k]:
if t[i] == "r":
if S[i - k] == "p":
S += "r"
elif S[i - k] == "r":
... | false | 29.62963 | [
"-# ABC149 D",
"-si = lambda: eval(input())",
"-ni = lambda: int(eval(input()))",
"-nm = lambda: list(map(int, input().split()))",
"-nl = lambda: list(map(int, input().split()))",
"-n, k = nm()",
"-r, s, p = nm()",
"-t = si()",
"-l = [[] for i in range(k)]",
"+n, k = list(map(int, input().split())... | false | 0.036748 | 0.036748 | 1.000008 | [
"s020800873",
"s846095935"
] |
u991567869 | p03909 | python | s734212253 | s733200319 | 29 | 24 | 9,152 | 9,180 | Accepted | Accepted | 17.24 | h, w = list(map(int, input().split()))
s = []
for i in range(h):
S = list(input().split())
s.append(S)
for i in range(h):
for j in range(w):
if s[i][j] == "snuke":
l = chr(ord("A") + j)
print((l + str(i + 1)))
exit() | h, w = list(map(int, input().split()))
for i in range(h):
s = input().split()
for j in range(w):
if s[j] == "snuke":
l = chr(ord("A") + j)
print((l + str(i + 1)))
exit() | 13 | 9 | 278 | 222 | h, w = list(map(int, input().split()))
s = []
for i in range(h):
S = list(input().split())
s.append(S)
for i in range(h):
for j in range(w):
if s[i][j] == "snuke":
l = chr(ord("A") + j)
print((l + str(i + 1)))
exit()
| h, w = list(map(int, input().split()))
for i in range(h):
s = input().split()
for j in range(w):
if s[j] == "snuke":
l = chr(ord("A") + j)
print((l + str(i + 1)))
exit()
| false | 30.769231 | [
"-s = []",
"- S = list(input().split())",
"- s.append(S)",
"-for i in range(h):",
"+ s = input().split()",
"- if s[i][j] == \"snuke\":",
"+ if s[j] == \"snuke\":"
] | false | 0.142125 | 0.03961 | 3.588113 | [
"s734212253",
"s733200319"
] |
u981931040 | p04044 | python | s947926239 | s789107177 | 20 | 17 | 3,060 | 3,060 | Accepted | Accepted | 15 | N ,L = list(map(int , input().split()))
s=sorted([eval(input()) for i in range(N)])
print(("".join(s)))
| N, L = list(map(int,input().split()))
S = list(eval(input()) for _ in range(N))
S.sort()
print(("".join(S))) | 4 | 4 | 94 | 97 | N, L = list(map(int, input().split()))
s = sorted([eval(input()) for i in range(N)])
print(("".join(s)))
| N, L = list(map(int, input().split()))
S = list(eval(input()) for _ in range(N))
S.sort()
print(("".join(S)))
| false | 0 | [
"-s = sorted([eval(input()) for i in range(N)])",
"-print((\"\".join(s)))",
"+S = list(eval(input()) for _ in range(N))",
"+S.sort()",
"+print((\"\".join(S)))"
] | false | 0.066738 | 0.07047 | 0.947045 | [
"s947926239",
"s789107177"
] |
u699089116 | p02780 | python | s819067999 | s008562102 | 241 | 126 | 75,784 | 31,892 | Accepted | Accepted | 47.72 | n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
p = list([x * (x+1) /2 /x for x in p])
for i in range(1, n):
p[i] = p[i-1] + p[i]
m = p[k-1]
for i in range(k, n):
a = p[i] - p[i-k]
if m < a:
m = a
print(m) | from itertools import accumulate
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
A = list(accumulate(P))
largest = A[K-1]
point = 0
for i in range(K, N):
if largest < A[i] - A[i-K]:
largest = A[i] - A[i-K]
point = i
ans = 0
for j in range(point - K + 1, po... | 15 | 19 | 269 | 385 | n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
p = list([x * (x + 1) / 2 / x for x in p])
for i in range(1, n):
p[i] = p[i - 1] + p[i]
m = p[k - 1]
for i in range(k, n):
a = p[i] - p[i - k]
if m < a:
m = a
print(m)
| from itertools import accumulate
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
A = list(accumulate(P))
largest = A[K - 1]
point = 0
for i in range(K, N):
if largest < A[i] - A[i - K]:
largest = A[i] - A[i - K]
point = i
ans = 0
for j in range(point - K + 1, point + 1):
... | false | 21.052632 | [
"-n, k = list(map(int, input().split()))",
"-p = list(map(int, input().split()))",
"-p = list([x * (x + 1) / 2 / x for x in p])",
"-for i in range(1, n):",
"- p[i] = p[i - 1] + p[i]",
"-m = p[k - 1]",
"-for i in range(k, n):",
"- a = p[i] - p[i - k]",
"- if m < a:",
"- m = a",
"-... | false | 0.047052 | 0.047049 | 1.000061 | [
"s819067999",
"s008562102"
] |
u279493135 | p03687 | python | s011844494 | s027106303 | 55 | 38 | 5,712 | 5,200 | Accepted | Accepted | 30.91 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_upp... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_upp... | 29 | 26 | 925 | 894 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase... | false | 10.344828 | [
"-N = len(s)",
"-se = set(s)",
"-for x in se: # xとの距離を調べる",
"- tmp = 0",
"+for x in set(s): # xとの距離を調べる"
] | false | 0.132768 | 0.041873 | 3.170733 | [
"s011844494",
"s027106303"
] |
u231189826 | p02721 | python | s294220246 | s027932446 | 780 | 390 | 32,388 | 22,396 | Accepted | Accepted | 50 | import copy
N,K,C = list(map(int, input().split()))
S = list(eval(input()))
count = 0
mae = [0]*K
ushiro = [0]*K
hi = 0
youso = 0
S_copy = copy.deepcopy(S)
while True:
if S_copy[hi] == 'o':
mae[youso] = hi+1
youso += 1
if youso == K:
break
for i in range(... | import copy
N,K,C = list(map(int, input().split()))
S = list(eval(input()))
mae = [0]*K
ushiro = [0]*K
hi = 0
youso = 0
while True:
if S[hi] == 'o':
mae[youso] = hi+1
youso += 1
if youso == K:
break
hi += C
hi += 1
hi = N-1
youso = 0
while True:... | 57 | 42 | 955 | 577 | import copy
N, K, C = list(map(int, input().split()))
S = list(eval(input()))
count = 0
mae = [0] * K
ushiro = [0] * K
hi = 0
youso = 0
S_copy = copy.deepcopy(S)
while True:
if S_copy[hi] == "o":
mae[youso] = hi + 1
youso += 1
if youso == K:
break
for i in range(C):
... | import copy
N, K, C = list(map(int, input().split()))
S = list(eval(input()))
mae = [0] * K
ushiro = [0] * K
hi = 0
youso = 0
while True:
if S[hi] == "o":
mae[youso] = hi + 1
youso += 1
if youso == K:
break
hi += C
hi += 1
hi = N - 1
youso = 0
while True:
if S[hi... | false | 26.315789 | [
"-count = 0",
"-S_copy = copy.deepcopy(S)",
"- if S_copy[hi] == \"o\":",
"+ if S[hi] == \"o\":",
"- for i in range(C):",
"- if hi + 1 + i <= N - 1:",
"- S_copy[hi + 1 + i] = \"x\"",
"+ hi += C",
"-hi = 0",
"+hi = N - 1",
"-S_copy = copy.deepcopy(S)",... | false | 0.044515 | 0.042614 | 1.044592 | [
"s294220246",
"s027932446"
] |
u633068244 | p00112 | python | s417437011 | s032928741 | 960 | 40 | 4,972 | 4,976 | Accepted | Accepted | 95.83 | while 1:
n = eval(input())
if n == 0: break
que = sorted([int(input()) for i in range(n)])
print(sum([sum(que[:i]) for i in range(1,n)])) | while 1:
n = eval(input())
if n == 0: break
q = sorted([int(input()) for i in range(n)])
t = [0]*n
for i in range(1,n):
t[i] = t[i-1] + q[i-1]
print(sum(t)) | 5 | 8 | 142 | 168 | while 1:
n = eval(input())
if n == 0:
break
que = sorted([int(input()) for i in range(n)])
print(sum([sum(que[:i]) for i in range(1, n)]))
| while 1:
n = eval(input())
if n == 0:
break
q = sorted([int(input()) for i in range(n)])
t = [0] * n
for i in range(1, n):
t[i] = t[i - 1] + q[i - 1]
print(sum(t))
| false | 37.5 | [
"- que = sorted([int(input()) for i in range(n)])",
"- print(sum([sum(que[:i]) for i in range(1, n)]))",
"+ q = sorted([int(input()) for i in range(n)])",
"+ t = [0] * n",
"+ for i in range(1, n):",
"+ t[i] = t[i - 1] + q[i - 1]",
"+ print(sum(t))"
] | false | 0.10335 | 0.038511 | 2.68365 | [
"s417437011",
"s032928741"
] |
u169350228 | p02665 | python | s858159143 | s031819425 | 411 | 111 | 99,996 | 87,064 | Accepted | Accepted | 72.99 | import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
def main():
n = int(ipt())
a = [... | import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
def main():
n = int(ipt())
a = [... | 46 | 37 | 913 | 713 | import math
# import numpy as np
import queue
from collections import deque, defaultdict
import heapq
from sys import stdin, setrecursionlimit
# from scipy.sparse.csgraph import dijkstra
# from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
def main():
n = int(ipt())
a = [int(i... | import math
# import numpy as np
import queue
from collections import deque, defaultdict
import heapq
from sys import stdin, setrecursionlimit
# from scipy.sparse.csgraph import dijkstra
# from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
def main():
n = int(ipt())
a = [int(i... | false | 19.565217 | [
"- if n == 0 and a[0] == 0:",
"- print((-1))",
"- exit()",
"- elif n == 0 and a[0] == 1:",
"- print((1))",
"- exit()",
"- elif n == 0 and a[0] > 1:",
"- print((-1))",
"- exit()",
"- ans = a[0]",
"+ ans = 0"
] | false | 0.037186 | 0.043112 | 0.862548 | [
"s858159143",
"s031819425"
] |
u192154323 | p02695 | python | s179548525 | s988822385 | 1,184 | 578 | 22,928 | 9,228 | Accepted | Accepted | 51.18 | import itertools
n,m,q = list(map(int,input().split()))
num_ls = [[0,0,0,0] for _ in range(q)]
for i in range(q):
num_ls[i] = list(map(int,input().split()))
a_base = [i for i in range(1,m+1)]
a_ls = []
for A in itertools.combinations_with_replacement(a_base, n):
istarget = True
for i in range(n-1... | N,M,Q = list(map(int,input().split()))
req_ls = []
l_ind_ls = [0] * Q
r_ind_ls = [0] * Q
diff_ls = [0] * Q
point_ls = [0] * Q
for i in range(Q):
l_ind_ls[i], r_ind_ls[i], diff_ls[i], point_ls[i] = list(map(int, input().split()))
l_ind_ls[i] -= 1
r_ind_ls[i] -= 1
def score(ls):
tmp = 0
... | 23 | 31 | 601 | 730 | import itertools
n, m, q = list(map(int, input().split()))
num_ls = [[0, 0, 0, 0] for _ in range(q)]
for i in range(q):
num_ls[i] = list(map(int, input().split()))
a_base = [i for i in range(1, m + 1)]
a_ls = []
for A in itertools.combinations_with_replacement(a_base, n):
istarget = True
for i in range(n -... | N, M, Q = list(map(int, input().split()))
req_ls = []
l_ind_ls = [0] * Q
r_ind_ls = [0] * Q
diff_ls = [0] * Q
point_ls = [0] * Q
for i in range(Q):
l_ind_ls[i], r_ind_ls[i], diff_ls[i], point_ls[i] = list(map(int, input().split()))
l_ind_ls[i] -= 1
r_ind_ls[i] -= 1
def score(ls):
tmp = 0
for l_ind... | false | 25.806452 | [
"-import itertools",
"+N, M, Q = list(map(int, input().split()))",
"+req_ls = []",
"+l_ind_ls = [0] * Q",
"+r_ind_ls = [0] * Q",
"+diff_ls = [0] * Q",
"+point_ls = [0] * Q",
"+for i in range(Q):",
"+ l_ind_ls[i], r_ind_ls[i], diff_ls[i], point_ls[i] = list(map(int, input().split()))",
"+ l_i... | false | 0.247594 | 0.119973 | 2.06374 | [
"s179548525",
"s988822385"
] |
u375616706 | p03722 | python | s105976148 | s807868248 | 1,958 | 621 | 3,572 | 3,308 | Accepted | Accepted | 68.28 | import sys
def input(): return sys.stdin.readline().strip()
N, M = (list)(list(map(int, input().split())))
edge = []
for _ in range(M):
edge.append((list)(list(map(int, input().split()))))
inf = 10**15
d = [inf]*(N+1)
d[1] = 0
ans = inf
for i in range(N):
update = False
for a, b,... | # -*- coding: utf-8 -*-
"""
・ベルマンフォード
"""
import sys
def input(): return sys.stdin.readline().strip()
sys.setrecursionlimit(10 ** 9)
N, M = list(map(int, input().split()))
edges = [None] * M
for i in range(M):
a, b, c = list(map(int, input().split()))
# 0-indexed
# コストの正負を逆転させれば最短経路問題として... | 45 | 44 | 802 | 1,056 | import sys
def input():
return sys.stdin.readline().strip()
N, M = (list)(list(map(int, input().split())))
edge = []
for _ in range(M):
edge.append((list)(list(map(int, input().split()))))
inf = 10**15
d = [inf] * (N + 1)
d[1] = 0
ans = inf
for i in range(N):
update = False
for a, b, c in edge:
... | # -*- coding: utf-8 -*-
"""
・ベルマンフォード
"""
import sys
def input():
return sys.stdin.readline().strip()
sys.setrecursionlimit(10**9)
N, M = list(map(int, input().split()))
edges = [None] * M
for i in range(M):
a, b, c = list(map(int, input().split()))
# 0-indexed
# コストの正負を逆転させれば最短経路問題として処理できる
edge... | false | 2.222222 | [
"+# -*- coding: utf-8 -*-",
"+\"\"\"",
"+・ベルマンフォード",
"+\"\"\"",
"-N, M = (list)(list(map(int, input().split())))",
"-edge = []",
"-for _ in range(M):",
"- edge.append((list)(list(map(int, input().split()))))",
"-inf = 10**15",
"-d = [inf] * (N + 1)",
"-d[1] = 0",
"-ans = inf",
"-for i in ... | false | 0.065431 | 0.044631 | 1.466062 | [
"s105976148",
"s807868248"
] |
u127499732 | p03163 | python | s751142390 | s189246643 | 382 | 285 | 118,512 | 40,048 | Accepted | Accepted | 25.39 | def main():
from collections import deque
n,w=list(map(int,input().split()))
item=deque([list(map(int,input().split())) for _ in range(n)])
DP=[[0]*(w+1) for _ in range(n+1)]
for i in range(1,n+1):
itemNow=item.popleft()
weight=itemNow[0]
value=itemNow[1]
for j in range(w+1):
i... | def main():
import sys
num,capacity=list(map(int,input().split()))
items=tuple([list(map(int,sys.stdin.readline().split())) for _ in range(num)])
DP=[-1]*(capacity+1)
DP[0]=0
for item in items:
weight=item[0]
value=item[1]
left=capacity-weight
for i in range(left,-1,-1):
if ... | 19 | 18 | 498 | 452 | def main():
from collections import deque
n, w = list(map(int, input().split()))
item = deque([list(map(int, input().split())) for _ in range(n)])
DP = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
itemNow = item.popleft()
weight = itemNow[0]
value = itemNo... | def main():
import sys
num, capacity = list(map(int, input().split()))
items = tuple([list(map(int, sys.stdin.readline().split())) for _ in range(num)])
DP = [-1] * (capacity + 1)
DP[0] = 0
for item in items:
weight = item[0]
value = item[1]
left = capacity - weight
... | false | 5.263158 | [
"- from collections import deque",
"+ import sys",
"- n, w = list(map(int, input().split()))",
"- item = deque([list(map(int, input().split())) for _ in range(n)])",
"- DP = [[0] * (w + 1) for _ in range(n + 1)]",
"- for i in range(1, n + 1):",
"- itemNow = item.popleft()",
"-... | false | 0.040429 | 0.142317 | 0.284079 | [
"s751142390",
"s189246643"
] |
u638456847 | p02689 | python | s327310458 | s624720829 | 217 | 154 | 44,920 | 30,268 | Accepted | Accepted | 29.03 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
N,M = list(map(int, readline().split()))
H = [int(i) for i in readline().split()]
ab = list(map(int, read().split()))
E = [[] for _ in range(N+1)]
for i, (a, b) in enumerate(zip(*[... | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
N,M = list(map(int, readline().split()))
H = [int(i) for i in readline().split()]
ab = list(map(int, read().split()))
E = [0] * N
for i, (a, b) in enumerate(zip(*[iter(ab)]*2)):
... | 32 | 27 | 696 | 577 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
N, M = list(map(int, readline().split()))
H = [int(i) for i in readline().split()]
ab = list(map(int, read().split()))
E = [[] for _ in range(N + 1)]
for i, (a, b) in enumerate(zip(*[iter(ab... | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
N, M = list(map(int, readline().split()))
H = [int(i) for i in readline().split()]
ab = list(map(int, read().split()))
E = [0] * N
for i, (a, b) in enumerate(zip(*[iter(ab)] * 2)):
i... | false | 15.625 | [
"- E = [[] for _ in range(N + 1)]",
"+ E = [0] * N",
"- E[a].append(b)",
"- E[b].append(a)",
"+ if H[b - 1] > E[a - 1]:",
"+ E[a - 1] = H[b - 1]",
"+ if H[a - 1] > E[b - 1]:",
"+ E[b - 1] = H[a - 1]",
"- for i in range(1, N + 1):",
"- ... | false | 0.055496 | 0.041719 | 1.330244 | [
"s327310458",
"s624720829"
] |
u760569096 | p02585 | python | s016039883 | s132281743 | 489 | 427 | 80,996 | 78,812 | Accepted | Accepted | 12.68 | n,k = list(map(int, input().split()))
p = list(map(int, input().split()))
c = list(map(int, input().split()))
r = -10**9
for i in range(n):
ans=c[i]
e =[ans]
f = i
a = 1
while a<k:
i = p[i]-1
if i == f:
break
a+=1
ans+=c[i]
e.append(ans)
if e[-1]>0 and a<k:
w ... | n,k = list(map(int, input().split()))
p = list(map(int, input().split()))
c = list(map(int, input().split()))
g = []
for i in range(n):
ans=c[i]
e =[ans]
f = i
a = 1
while a<k:
i = p[i]-1
if i == f:
break
a+=1
ans+=c[i]
e.append(ans)
if e[-1]>0 and a<k:
w = k%... | 27 | 26 | 483 | 485 | n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
c = list(map(int, input().split()))
r = -(10**9)
for i in range(n):
ans = c[i]
e = [ans]
f = i
a = 1
while a < k:
i = p[i] - 1
if i == f:
break
a += 1
ans += c[i]
e.append(a... | n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
c = list(map(int, input().split()))
g = []
for i in range(n):
ans = c[i]
e = [ans]
f = i
a = 1
while a < k:
i = p[i] - 1
if i == f:
break
a += 1
ans += c[i]
e.append(ans)
... | false | 3.703704 | [
"-r = -(10**9)",
"+g = []",
"- g = y",
"+ g.append(y)",
"- g = max(e)",
"- r = max(r, g)",
"-print(r)",
"+ g.append(max(e))",
"+print((max(g)))"
] | false | 0.042239 | 0.042115 | 1.002955 | [
"s016039883",
"s132281743"
] |
u299791633 | p02683 | python | s798523519 | s395248324 | 105 | 96 | 9,264 | 9,344 | Accepted | Accepted | 8.57 | import itertools
n, m, x = list(map(int, input().split()))
books=[]
results=[]
for i in range(n):
books.append(list(map(int, input().split())))
# 全ての本を買ってもXwo満たせないアルゴリズムがあるか検査
for i in range(m):
skill=0
for j in books:
skill+=j[i+1]
if skill<x:
print((-1))
exit()
... | import itertools
n, m, x = list(map(int, input().split()))
result=[]
books=[]
tmp=[]
for i in range(n):
books.append(list(map(int, input().split())))
tmp.append(i)
# 参考書の選択パターン作成
patterns=[]
for i in range(n):
patterns.append(itertools.combinations(tmp,i+1))
# 全ての参考書を購入しても条件を満たせないときは-1
for a... | 46 | 41 | 1,095 | 961 | import itertools
n, m, x = list(map(int, input().split()))
books = []
results = []
for i in range(n):
books.append(list(map(int, input().split())))
# 全ての本を買ってもXwo満たせないアルゴリズムがあるか検査
for i in range(m):
skill = 0
for j in books:
skill += j[i + 1]
if skill < x:
print((-1))
exit()
# 本... | import itertools
n, m, x = list(map(int, input().split()))
result = []
books = []
tmp = []
for i in range(n):
books.append(list(map(int, input().split())))
tmp.append(i)
# 参考書の選択パターン作成
patterns = []
for i in range(n):
patterns.append(itertools.combinations(tmp, i + 1))
# 全ての参考書を購入しても条件を満たせないときは-1
for arg i... | false | 10.869565 | [
"+result = []",
"-results = []",
"+tmp = []",
"-# 全ての本を買ってもXwo満たせないアルゴリズムがあるか検査",
"-for i in range(m):",
"- skill = 0",
"- for j in books:",
"- skill += j[i + 1]",
"- if skill < x:",
"+ tmp.append(i)",
"+# 参考書の選択パターン作成",
"+patterns = []",
"+for i in range(n):",
"+ pat... | false | 0.037183 | 0.036725 | 1.01248 | [
"s798523519",
"s395248324"
] |
u761320129 | p03822 | python | s203932637 | s576534583 | 637 | 241 | 123,792 | 121,392 | Accepted | Accepted | 62.17 | import sys
sys.setrecursionlimit(10**8)
N = int(eval(input()))
A = [int(eval(input()))-1 for i in range(N-1)]
wins = [[] for _ in range(N)]
for i,a in enumerate(A):
wins[a].append(i+1)
depth = [-1] * N
def dep(v):
if len(wins[v])==0: return 0
if depth[v] >= 0:
return depth[v]
ds ... | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
N = int(eval(input()))
A = [int(eval(input()))-1 for i in range(N-1)]
wins = [[] for _ in range(N)]
for i,a in enumerate(A):
wins[a].append(i+1)
def depth(v):
if len(wins[v])==0: return 0
res = []
for u in wins[v]:
... | 24 | 22 | 515 | 443 | import sys
sys.setrecursionlimit(10**8)
N = int(eval(input()))
A = [int(eval(input())) - 1 for i in range(N - 1)]
wins = [[] for _ in range(N)]
for i, a in enumerate(A):
wins[a].append(i + 1)
depth = [-1] * N
def dep(v):
if len(wins[v]) == 0:
return 0
if depth[v] >= 0:
return depth[v]
... | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
N = int(eval(input()))
A = [int(eval(input())) - 1 for i in range(N - 1)]
wins = [[] for _ in range(N)]
for i, a in enumerate(A):
wins[a].append(i + 1)
def depth(v):
if len(wins[v]) == 0:
return 0
res = []
for u in wins[v]:
... | false | 8.333333 | [
"+input = sys.stdin.readline",
"-depth = [-1] * N",
"-def dep(v):",
"+def depth(v):",
"- if depth[v] >= 0:",
"- return depth[v]",
"- ds = []",
"- for w in wins[v]:",
"- ds.append(dep(w))",
"- ds.sort(reverse=True)",
"+ res = []",
"+ for u in wins[v]:",
"+ ... | false | 0.037482 | 0.143353 | 0.261467 | [
"s203932637",
"s576534583"
] |
u958053648 | p02779 | python | s242170063 | s713629469 | 138 | 105 | 33,996 | 33,996 | Accepted | Accepted | 23.91 | from collections import Counter
N=int(eval(input()))
A=list(map(int, input().split()))
B=Counter(A)
if N==len(B):
print('YES')
else:
print('NO') | from collections import Counter
N=int(eval(input()))
A=list(map(int, input().split()))
B=Counter(A)
if len(A)==len(B):
print('YES')
else:
print('NO') | 8 | 8 | 147 | 152 | from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
B = Counter(A)
if N == len(B):
print("YES")
else:
print("NO")
| from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
B = Counter(A)
if len(A) == len(B):
print("YES")
else:
print("NO")
| false | 0 | [
"-if N == len(B):",
"+if len(A) == len(B):"
] | false | 0.042496 | 0.04127 | 1.029726 | [
"s242170063",
"s713629469"
] |
u573754721 | p02768 | python | s779423326 | s866452583 | 174 | 150 | 38,512 | 3,064 | Accepted | Accepted | 13.79 | def nCr(n, r):
mod=10**9+7
r = min(r, n-r)
numer = denom = 1
for i in range(1, r+1):
numer = numer * (n+1-i) % mod
denom = denom * i % mod
return numer * pow(denom, mod-2, mod) % mod
n,a,b=list(map(int,input().split()))
s=pow(2,n,10**9+7)
ans=s-1-nCr(n,a)-nCr(n,b)
whi... | mod=10**9+7
def nCr(n, r):
r = min(r, n-r)
numer = denom = 1
for i in range(1, r+1):
numer = numer * (n+1-i) % mod
denom = denom * i % mod
return numer * pow(denom, mod-2, mod) % mod
n,a,b=list(map(int,input().split()))
f=pow(2, n, mod)-1-nCr(n,a)-nCr(n,b)
while f<0:
f+=... | 15 | 14 | 352 | 327 | def nCr(n, r):
mod = 10**9 + 7
r = min(r, n - r)
numer = denom = 1
for i in range(1, r + 1):
numer = numer * (n + 1 - i) % mod
denom = denom * i % mod
return numer * pow(denom, mod - 2, mod) % mod
n, a, b = list(map(int, input().split()))
s = pow(2, n, 10**9 + 7)
ans = s - 1 - nCr(... | mod = 10**9 + 7
def nCr(n, r):
r = min(r, n - r)
numer = denom = 1
for i in range(1, r + 1):
numer = numer * (n + 1 - i) % mod
denom = denom * i % mod
return numer * pow(denom, mod - 2, mod) % mod
n, a, b = list(map(int, input().split()))
f = pow(2, n, mod) - 1 - nCr(n, a) - nCr(n, b... | false | 6.666667 | [
"+mod = 10**9 + 7",
"+",
"+",
"- mod = 10**9 + 7",
"-s = pow(2, n, 10**9 + 7)",
"-ans = s - 1 - nCr(n, a) - nCr(n, b)",
"-while ans < 0:",
"- ans += 10**9 + 7",
"-print(ans)",
"+f = pow(2, n, mod) - 1 - nCr(n, a) - nCr(n, b)",
"+while f < 0:",
"+ f += mod",
"+print(f)"
] | false | 0.133413 | 0.334152 | 0.399259 | [
"s779423326",
"s866452583"
] |
u508732591 | p02315 | python | s727860527 | s072653558 | 790 | 680 | 25,496 | 25,488 | Accepted | Accepted | 13.92 | N,W = list(map(int, input().split()))
dp = [[0]*(W+1) for y in range(N+1)]
for i in range(1,N+1):
v, w = list(map(int, input().split()))
for j in range(W+1):
if j < w:
dp[i][j] = dp[i-1][j]
else:
dp[i][j] = max(dp[i-1][j],dp[i-1][j-w]+v)
print((dp[N][W])) | N,W = list(map(int, input().split()))
dp = [[0]*(W+1) for y in range(N+1)]
for i in range(1,N+1):
v, w = list(map(int, input().split()))
dp[i][0:w] = dp[i-1][0:w]
for j in range(w, W+1):
dp[i][j] = max(dp[i-1][j], dp[i-1][j-w]+v)
print((dp[N][W])) | 12 | 10 | 302 | 264 | N, W = list(map(int, input().split()))
dp = [[0] * (W + 1) for y in range(N + 1)]
for i in range(1, N + 1):
v, w = list(map(int, input().split()))
for j in range(W + 1):
if j < w:
dp[i][j] = dp[i - 1][j]
else:
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v)
print((dp[N... | N, W = list(map(int, input().split()))
dp = [[0] * (W + 1) for y in range(N + 1)]
for i in range(1, N + 1):
v, w = list(map(int, input().split()))
dp[i][0:w] = dp[i - 1][0:w]
for j in range(w, W + 1):
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v)
print((dp[N][W]))
| false | 16.666667 | [
"- for j in range(W + 1):",
"- if j < w:",
"- dp[i][j] = dp[i - 1][j]",
"- else:",
"- dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v)",
"+ dp[i][0:w] = dp[i - 1][0:w]",
"+ for j in range(w, W + 1):",
"+ dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w... | false | 0.116007 | 0.04111 | 2.821855 | [
"s727860527",
"s072653558"
] |
u869790980 | p02787 | python | s646037224 | s150023573 | 682 | 381 | 33,948 | 33,512 | Accepted | Accepted | 44.13 | hh,n = list(map(int,input().split(' ')))
spells = [list(map(int, input().split(' '))) for _ in range(n)]
h = {}
h[0] = 0
#h[health] = cost in points
for health in range(1, hh+1):
for u,v in spells:
h[health] = min(h[health] if health in h else +float('inf'), h[max(0,health - u)] + v)
print(h[hh]) | hh,n = list(map(int,input().split(' ')))
spells = [list(map(int, input().split(' '))) for _ in range(n)]
h = [+float('inf')] * (hh+1)
h[0] = 0
for health in range(1, hh+1):
for u,v in spells: h[health] = min(h[health], h[max(0,health - u)] + v)
print(h[hh]) | 11 | 8 | 307 | 261 | hh, n = list(map(int, input().split(" ")))
spells = [list(map(int, input().split(" "))) for _ in range(n)]
h = {}
h[0] = 0
# h[health] = cost in points
for health in range(1, hh + 1):
for u, v in spells:
h[health] = min(
h[health] if health in h else +float("inf"), h[max(0, health - u)] + v
... | hh, n = list(map(int, input().split(" ")))
spells = [list(map(int, input().split(" "))) for _ in range(n)]
h = [+float("inf")] * (hh + 1)
h[0] = 0
for health in range(1, hh + 1):
for u, v in spells:
h[health] = min(h[health], h[max(0, health - u)] + v)
print(h[hh])
| false | 27.272727 | [
"-h = {}",
"+h = [+float(\"inf\")] * (hh + 1)",
"-# h[health] = cost in points",
"- h[health] = min(",
"- h[health] if health in h else +float(\"inf\"), h[max(0, health - u)] + v",
"- )",
"+ h[health] = min(h[health], h[max(0, health - u)] + v)"
] | false | 0.106451 | 0.094463 | 1.126908 | [
"s646037224",
"s150023573"
] |
u528470578 | p03167 | python | s517421191 | s422565998 | 181 | 161 | 122,720 | 122,672 | Accepted | Accepted | 11.05 | MOD = int(1e9) + 7
H, W = list(map(int, input().split()))
maze = [list(eval(input())) for _ in range(H)]
dp = [[0 for i in range(W)] for j in range(H)]
dp[0][0] = 1
for i in range(H):
for j in range(W):
if i + 1 < H and maze[i+1][j] == ".":
dp[i+1][j] += dp[i][j]
dp[i+1][j... | H, W = list(map(int, input().split()))
g = [list(eval(input())) for _ in range(H)]
mod = int(1e9) + 7
dp = [[0 for i in range(W)] for j in range(H)]
dp[0][0] = 1
for i in range(H):
for j in range(W):
if g[i][j] == "#":
continue
if i + 1 < H:
dp[i+1][j] += dp[i][j] %... | 15 | 14 | 451 | 404 | MOD = int(1e9) + 7
H, W = list(map(int, input().split()))
maze = [list(eval(input())) for _ in range(H)]
dp = [[0 for i in range(W)] for j in range(H)]
dp[0][0] = 1
for i in range(H):
for j in range(W):
if i + 1 < H and maze[i + 1][j] == ".":
dp[i + 1][j] += dp[i][j]
dp[i + 1][j] %= ... | H, W = list(map(int, input().split()))
g = [list(eval(input())) for _ in range(H)]
mod = int(1e9) + 7
dp = [[0 for i in range(W)] for j in range(H)]
dp[0][0] = 1
for i in range(H):
for j in range(W):
if g[i][j] == "#":
continue
if i + 1 < H:
dp[i + 1][j] += dp[i][j] % mod
... | false | 6.666667 | [
"-MOD = int(1e9) + 7",
"-maze = [list(eval(input())) for _ in range(H)]",
"+g = [list(eval(input())) for _ in range(H)]",
"+mod = int(1e9) + 7",
"- if i + 1 < H and maze[i + 1][j] == \".\":",
"- dp[i + 1][j] += dp[i][j]",
"- dp[i + 1][j] %= MOD",
"- if j + 1 < W and... | false | 0.048246 | 0.046566 | 1.036089 | [
"s517421191",
"s422565998"
] |
u263830634 | p02996 | python | s516852542 | s750777914 | 1,528 | 474 | 78,296 | 31,836 | Accepted | Accepted | 68.98 | N = int(eval(input()))
lst = []
for _ in range(N):
A, B = list(map(int, input().split()))
lst += [[B, A]]
lst.sort()
t = 0
for i in range(N):
t += lst[i][1] #仕事に使う時間をプラス
if t > lst[i][0]: #制限時間と比較
print ('No')
exit()
print ('Yes')
| import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7
N = int(eval(input()))
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key = lambda x: x[1]) #締め切りが早い順位ソート
tmp = 0
for a, b in AB:
if tmp + a <= b:
tmp += a
else:
print ('No')... | 16 | 18 | 269 | 347 | N = int(eval(input()))
lst = []
for _ in range(N):
A, B = list(map(int, input().split()))
lst += [[B, A]]
lst.sort()
t = 0
for i in range(N):
t += lst[i][1] # 仕事に使う時間をプラス
if t > lst[i][0]: # 制限時間と比較
print("No")
exit()
print("Yes")
| import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
MOD = 10**9 + 7
N = int(eval(input()))
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[1]) # 締め切りが早い順位ソート
tmp = 0
for a, b in AB:
if tmp + a <= b:
tmp += a
else:
print("No")
exit()
prin... | false | 11.111111 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"+sys.setrecursionlimit(10**9)",
"+MOD = 10**9 + 7",
"-lst = []",
"-for _ in range(N):",
"- A, B = list(map(int, input().split()))",
"- lst += [[B, A]]",
"-lst.sort()",
"-t = 0",
"-for i in range(N):",
"- t += lst[i][1] # 仕事に使う時間をプ... | false | 0.083439 | 0.035926 | 2.322544 | [
"s516852542",
"s750777914"
] |
u586960661 | p03171 | python | s101489539 | s148815335 | 1,816 | 329 | 164,488 | 112,988 | Accepted | Accepted | 81.88 | def fun(i,j):
# print(i,j)
if i>j or i>=n or j<0:
return 0
elif i==j:
dp[i][j]=arr[i]
return dp[i][j]
else:
if dp[i][j]==0:
dp[i][j]=max(arr[i]+min(fun(i+1,j-1),fun(i+2,j)),arr[j]+min(fun(i+1,j-1),fun(i,j-2)))
return dp[i][j]
n=int(eval(input()))
dp=[0]*n
for i in range(n):
dp[i]=[0]*n
... | def fun(i,j):
# print(i,j)
if i>j or i>=n or j<0:
return 0
elif i==j:
dp[i][j]=arr[i]
return dp[i][j]
else:
if dp[i][j]==0:
dp[i][j]=max(arr[i]+min(fun(i+1,j-1),fun(i+2,j)),arr[j]+min(fun(i+1,j-1),fun(i,j-2)))
return dp[i][j]
n=int(eval(input()))
dp=[0]*n
for i in range(n):
dp[i]=[0]*n
... | 17 | 26 | 378 | 567 | def fun(i, j):
# print(i,j)
if i > j or i >= n or j < 0:
return 0
elif i == j:
dp[i][j] = arr[i]
return dp[i][j]
else:
if dp[i][j] == 0:
dp[i][j] = max(
arr[i] + min(fun(i + 1, j - 1), fun(i + 2, j)),
arr[j] + min(fun(i + 1, j -... | def fun(i, j):
# print(i,j)
if i > j or i >= n or j < 0:
return 0
elif i == j:
dp[i][j] = arr[i]
return dp[i][j]
else:
if dp[i][j] == 0:
dp[i][j] = max(
arr[i] + min(fun(i + 1, j - 1), fun(i + 2, j)),
arr[j] + min(fun(i + 1, j -... | false | 34.615385 | [
"-print((2 * fun(0, n - 1) - sum(arr)))",
"+for i in range(n - 1, -1, -1):",
"+ for j in range(i, n, 1):",
"+ if i == j:",
"+ dp[i][j] = arr[i]",
"+ else:",
"+ dp[i][j] = max(arr[i] - dp[i + 1][j], arr[j] - dp[i][j - 1])",
"+ # print(dp[i])",
"+print((dp... | false | 0.037803 | 0.087473 | 0.432164 | [
"s101489539",
"s148815335"
] |
u242525751 | p03089 | python | s647013117 | s388784222 | 193 | 171 | 38,640 | 38,768 | Accepted | Accepted | 11.4 | n = int(eval(input()))
b = list(map(int, input().split()))
for i in range(n):
if b[i] > i+1:
print((-1))
break
else:
ans = []
while len(b) > 1:
# print(ans,b)
c = len(ans)
f = b[0]
for i in range(1, len(b))[::-1]:
if b[i] == i + 1:
# print("check", b[i:])
... | n = int(eval(input()))
b = list(map(int, input().split()))
for i in range(n):
if b[i] > i+1:
print((-1))
break
else:
ans = []
while len(b) > 0:
f = b[0]
for i in range(len(b))[::-1]:
if b[i] == i + 1:
ans.append(b.pop(i))
break
for i in range(n)[::-1]:
... | 34 | 17 | 760 | 325 | n = int(eval(input()))
b = list(map(int, input().split()))
for i in range(n):
if b[i] > i + 1:
print((-1))
break
else:
ans = []
while len(b) > 1:
# print(ans,b)
c = len(ans)
f = b[0]
for i in range(1, len(b))[::-1]:
if b[i] == i + 1:
... | n = int(eval(input()))
b = list(map(int, input().split()))
for i in range(n):
if b[i] > i + 1:
print((-1))
break
else:
ans = []
while len(b) > 0:
f = b[0]
for i in range(len(b))[::-1]:
if b[i] == i + 1:
ans.append(b.pop(i))
break
... | false | 50 | [
"- while len(b) > 1:",
"- # print(ans,b)",
"- c = len(ans)",
"+ while len(b) > 0:",
"- for i in range(1, len(b))[::-1]:",
"+ for i in range(len(b))[::-1]:",
"- # print(\"check\", b[i:])",
"- else:",
"- for i in range(1, len... | false | 0.080801 | 0.041325 | 1.955261 | [
"s647013117",
"s388784222"
] |
u620084012 | p03943 | python | s650172711 | s235201742 | 162 | 17 | 38,256 | 2,940 | Accepted | Accepted | 89.51 | a, b, c = list(map(int,input().split()))
if a+b==c or b+c==a or c+a==b:
print("Yes")
else:
print("No")
| a, b, c = list(map(int,input().split()))
if a==b+c or b==a+c or c==b+a:
print("Yes")
else:
print("No")
| 5 | 5 | 109 | 109 | a, b, c = list(map(int, input().split()))
if a + b == c or b + c == a or c + a == b:
print("Yes")
else:
print("No")
| a, b, c = list(map(int, input().split()))
if a == b + c or b == a + c or c == b + a:
print("Yes")
else:
print("No")
| false | 0 | [
"-if a + b == c or b + c == a or c + a == b:",
"+if a == b + c or b == a + c or c == b + a:"
] | false | 0.123408 | 0.043221 | 2.855294 | [
"s650172711",
"s235201742"
] |
u225388820 | p02910 | python | s685901405 | s681683449 | 19 | 17 | 3,060 | 3,060 | Accepted | Accepted | 10.53 | s=eval(input())
n=len(s)
ans=0
for i in range(0,n,2):
if s[i]=='L':
ans+=1
for i in range(1,n,2):
if s[i]=='R':
ans+=1
if ans==0:
print('Yes')
else:
print('No') | s=eval(input())
n=len(s)
ans=True
for i in range(0,n,2):
if s[i]=='L':
ans=False
for i in range(1,n,2):
if s[i]=='R':
ans=False
if ans:
print('Yes')
else:
print('No')
| 13 | 13 | 198 | 205 | s = eval(input())
n = len(s)
ans = 0
for i in range(0, n, 2):
if s[i] == "L":
ans += 1
for i in range(1, n, 2):
if s[i] == "R":
ans += 1
if ans == 0:
print("Yes")
else:
print("No")
| s = eval(input())
n = len(s)
ans = True
for i in range(0, n, 2):
if s[i] == "L":
ans = False
for i in range(1, n, 2):
if s[i] == "R":
ans = False
if ans:
print("Yes")
else:
print("No")
| false | 0 | [
"-ans = 0",
"+ans = True",
"- ans += 1",
"+ ans = False",
"- ans += 1",
"-if ans == 0:",
"+ ans = False",
"+if ans:"
] | false | 0.048963 | 0.048204 | 1.015733 | [
"s685901405",
"s681683449"
] |
u745087332 | p04034 | python | s968570661 | s981903457 | 418 | 200 | 4,656 | 4,596 | Accepted | Accepted | 52.15 | # coding:utf-8
INF = float('inf')
def inpl(): return list(map(int, input().split()))
N, M = inpl()
# move = [inpl() for _ in range(M)]
ans = [0 for _ in range(N)]
ans[0] = 1
box = [1 for _ in range(N)]
# print(ans, box)
for i in range(M):
# x, y = move[i]
x, y = inpl()
box[x - 1] -= ... | # coding:utf-8
import sys
INF = float('inf')
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()... | 28 | 40 | 487 | 748 | # coding:utf-8
INF = float("inf")
def inpl():
return list(map(int, input().split()))
N, M = inpl()
# move = [inpl() for _ in range(M)]
ans = [0 for _ in range(N)]
ans[0] = 1
box = [1 for _ in range(N)]
# print(ans, box)
for i in range(M):
# x, y = move[i]
x, y = inpl()
box[x - 1] -= 1
box[y - 1]... | # coding:utf-8
import sys
INF = float("inf")
MOD = 10**9 + 7
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LI_():
return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF():
return [float(x) for x in sys.stdin.readline().split()]
def LS():
return sys.stdin.readline... | false | 30 | [
"+import sys",
"+",
"+MOD = 10**9 + 7",
"-def inpl():",
"- return list(map(int, input().split()))",
"+def LI():",
"+ return [int(x) for x in sys.stdin.readline().split()]",
"-N, M = inpl()",
"-# move = [inpl() for _ in range(M)]",
"-ans = [0 for _ in range(N)]",
"-ans[0] = 1",
"-box = [1... | false | 0.043091 | 0.062677 | 0.687506 | [
"s968570661",
"s981903457"
] |
u857759499 | p03574 | python | s882129027 | s385801341 | 151 | 21 | 12,508 | 3,188 | Accepted | Accepted | 86.09 | from sys import stdin
import numpy as np
input = stdin.readline
h,w = list(map(int,input().split()))
s = (np.array([list(input().strip()) for _ in range(h)])=="#")
ans = np.zeros((h+2,w+2),dtype=np.uint8)
for i,j in [(-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)]:
ans[1+i:h+1+i,1+j:w+1+j] += s
ans = a... | def main():
from sys import stdin
input = stdin.readline
h,w = list(map(int,input().split()))
s = []
sa = s.append
sa(list("."*(w+2)))
for _ in range(h):
sa(["."]+list(input().strip())+["."])
sa(list("."*(w+2)))
for i in range(1,h+1):
for j in range(1,w+1):
if s[i][j] == ".":... | 12 | 21 | 393 | 543 | from sys import stdin
import numpy as np
input = stdin.readline
h, w = list(map(int, input().split()))
s = np.array([list(input().strip()) for _ in range(h)]) == "#"
ans = np.zeros((h + 2, w + 2), dtype=np.uint8)
for i, j in [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)]:
ans[1 + i : h + 1 ... | def main():
from sys import stdin
input = stdin.readline
h, w = list(map(int, input().split()))
s = []
sa = s.append
sa(list("." * (w + 2)))
for _ in range(h):
sa(["."] + list(input().strip()) + ["."])
sa(list("." * (w + 2)))
for i in range(1, h + 1):
for j in range(... | false | 42.857143 | [
"-from sys import stdin",
"-import numpy as np",
"+def main():",
"+ from sys import stdin",
"-input = stdin.readline",
"-h, w = list(map(int, input().split()))",
"-s = np.array([list(input().strip()) for _ in range(h)]) == \"#\"",
"-ans = np.zeros((h + 2, w + 2), dtype=np.uint8)",
"-for i, j in [... | false | 0.310398 | 0.085945 | 3.611579 | [
"s882129027",
"s385801341"
] |
u816631826 | p03239 | python | s723429597 | s156285939 | 21 | 18 | 3,064 | 3,060 | Accepted | Accepted | 14.29 | x=list(map(int,input().split()))
ww=[]
min=x[1]
flag=0
min2=100000
for i in range(x[0]):
ww.append([])
ww[i] = list(map(int, input().split()))
if ww[i][1]<=min:
if ww[i][0]<min2:
min2=ww[i][0]
else:
flag+=1
if flag== x[0]:
print("TLE")
else:
p... | N , T = list(map(int, input().split()))
l =[]
for index in range(N):
n , t =list(map(int ,input().split()))
l .append([n,t])
ans = []
for elt in l :
if elt[1]<=T :
ans.append(elt[0])
if ans == []:
print("TLE")
else:
print((min(ans)))
| 22 | 13 | 331 | 261 | x = list(map(int, input().split()))
ww = []
min = x[1]
flag = 0
min2 = 100000
for i in range(x[0]):
ww.append([])
ww[i] = list(map(int, input().split()))
if ww[i][1] <= min:
if ww[i][0] < min2:
min2 = ww[i][0]
else:
flag += 1
if flag == x[0]:
print("TLE")
else:
print(... | N, T = list(map(int, input().split()))
l = []
for index in range(N):
n, t = list(map(int, input().split()))
l.append([n, t])
ans = []
for elt in l:
if elt[1] <= T:
ans.append(elt[0])
if ans == []:
print("TLE")
else:
print((min(ans)))
| false | 40.909091 | [
"-x = list(map(int, input().split()))",
"-ww = []",
"-min = x[1]",
"-flag = 0",
"-min2 = 100000",
"-for i in range(x[0]):",
"- ww.append([])",
"- ww[i] = list(map(int, input().split()))",
"- if ww[i][1] <= min:",
"- if ww[i][0] < min2:",
"- min2 = ww[i][0]",
"- el... | false | 0.035712 | 0.035665 | 1.00131 | [
"s723429597",
"s156285939"
] |
u102461423 | p03822 | python | s895306286 | s815454261 | 678 | 400 | 231,984 | 28,244 | Accepted | Accepted | 41 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N-1)]
graph = [[] for _ in range(N+1)]
for i,x in enumerate(A,2):
graph[x].append(i)
def dfs(x):
arr = [dfs(y) for y in graph[x]]
if not arr:
return 0
... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,*P = list(map(int,read().split()))
graph = [[] for _ in range(N+1)]
for i,x in enumerate(P,2):
graph[i].append(x)
graph[x].append(i)
root = 1
parent = [0] * (N+1)
order = []
st... | 20 | 37 | 411 | 768 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N - 1)]
graph = [[] for _ in range(N + 1)]
for i, x in enumerate(A, 2):
graph[x].append(i)
def dfs(x):
arr = [dfs(y) for y in graph[x]]
if not arr:
return 0
arr.sor... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, *P = list(map(int, read().split()))
graph = [[] for _ in range(N + 1)]
for i, x in enumerate(P, 2):
graph[i].append(x)
graph[x].append(i)
root = 1
parent = [0] * (N + 1)
order = []
stack = [ro... | false | 45.945946 | [
"-input = sys.stdin.readline",
"-sys.setrecursionlimit(10**7)",
"-N = int(eval(input()))",
"-A = [int(eval(input())) for _ in range(N - 1)]",
"+read = sys.stdin.buffer.read",
"+readline = sys.stdin.buffer.readline",
"+readlines = sys.stdin.buffer.readlines",
"+N, *P = list(map(int, read().split()))",
... | false | 0.037623 | 0.071408 | 0.526864 | [
"s895306286",
"s815454261"
] |
u796942881 | p03137 | python | s372490875 | s077499743 | 111 | 83 | 13,840 | 14,968 | Accepted | Accepted | 25.23 | N, M = list(map(int, input().split()))
X = [int(i) for i in input().split()]
X.sort()
D = [X[i+1] - X[i] for i in range(M - 1)]
D.sort()
print((0 if M <= N else sum(D[:M-N])))
| N, M = list(map(int, input().split()))
X = list(set([int(i) for i in input().split()]))
X.sort()
D = [X[i+1] - X[i] for i in range(M - 1)]
D.sort()
print((0 if M <= N else sum(D[:M-N])))
| 10 | 10 | 181 | 192 | N, M = list(map(int, input().split()))
X = [int(i) for i in input().split()]
X.sort()
D = [X[i + 1] - X[i] for i in range(M - 1)]
D.sort()
print((0 if M <= N else sum(D[: M - N])))
| N, M = list(map(int, input().split()))
X = list(set([int(i) for i in input().split()]))
X.sort()
D = [X[i + 1] - X[i] for i in range(M - 1)]
D.sort()
print((0 if M <= N else sum(D[: M - N])))
| false | 0 | [
"-X = [int(i) for i in input().split()]",
"+X = list(set([int(i) for i in input().split()]))"
] | false | 0.034932 | 0.085235 | 0.409833 | [
"s372490875",
"s077499743"
] |
u119148115 | p02609 | python | s809911169 | s134507908 | 182 | 162 | 134,748 | 126,140 | Accepted | Accepted | 10.99 | import sys
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし
def S(): r... | import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし
N = I()
X = LI2()
X.reverse()
if N == 1 and len(X) == 1 and X[0] == 0:
print(1)
exit()
def popcount(n):
res = 0
m = n.bit_length()
for i in range(... | 82 | 71 | 1,844 | 1,353 | import sys
sys.setrecursionlimit(10**7)
def I():
return int(sys.stdin.readline().rstrip())
def MI():
return map(int, sys.stdin.readline().rstrip().split())
def LI():
return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり
def LI2():
return list(map(int, sys.stdin.readline().rstrip(... | import sys
def I():
return int(sys.stdin.readline().rstrip())
def LI2():
return list(map(int, sys.stdin.readline().rstrip())) # 空白なし
N = I()
X = LI2()
X.reverse()
if N == 1 and len(X) == 1 and X[0] == 0:
print(1)
exit()
def popcount(n):
res = 0
m = n.bit_length()
for i in range(m):
... | false | 13.414634 | [
"-",
"-sys.setrecursionlimit(10**7)",
"-def MI():",
"- return map(int, sys.stdin.readline().rstrip().split())",
"-",
"-",
"-def LI():",
"- return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり",
"-",
"-",
"-",
"-",
"-def S():",
"- return sys.stdin.readline().rstrip(... | false | 4.170107 | 1.463838 | 2.84875 | [
"s809911169",
"s134507908"
] |
u446711904 | p02802 | python | s866716767 | s376880191 | 291 | 207 | 37,260 | 18,084 | Accepted | Accepted | 28.87 | n,m=list(map(int,input().split()))
if m==0:
print((0,0))
import sys
sys.exit()
p=[list(input().split()) for _ in range(m)]
correct=set([p[i][0] for i in range(m) if p[i][1]=='AC'])
sum_wa=0
data=[0]*n
for i in range(m):
if p[i][0] in correct and data[int(p[i][0])-1]==0:
if p[i... | n,m=list(map(int,input().split()))
data=[0]*n
s=set()
for i in range(m):
p,a=input().split()
p=int(p)-1
if p in s:
continue
else:
if a=='WA':
data[p]-=1
else:
data[p]*=-1
s.add(p)
print((len(s),sum([data[i] for i in range(n)... | 21 | 18 | 424 | 329 | n, m = list(map(int, input().split()))
if m == 0:
print((0, 0))
import sys
sys.exit()
p = [list(input().split()) for _ in range(m)]
correct = set([p[i][0] for i in range(m) if p[i][1] == "AC"])
sum_wa = 0
data = [0] * n
for i in range(m):
if p[i][0] in correct and data[int(p[i][0]) - 1] == 0:
i... | n, m = list(map(int, input().split()))
data = [0] * n
s = set()
for i in range(m):
p, a = input().split()
p = int(p) - 1
if p in s:
continue
else:
if a == "WA":
data[p] -= 1
else:
data[p] *= -1
s.add(p)
print((len(s), sum([data[i] for i in rang... | false | 14.285714 | [
"-if m == 0:",
"- print((0, 0))",
"- import sys",
"-",
"- sys.exit()",
"-p = [list(input().split()) for _ in range(m)]",
"-correct = set([p[i][0] for i in range(m) if p[i][1] == \"AC\"])",
"-sum_wa = 0",
"+s = set()",
"- if p[i][0] in correct and data[int(p[i][0]) - 1] == 0:",
"- ... | false | 0.036931 | 0.035637 | 1.036329 | [
"s866716767",
"s376880191"
] |
u072717685 | p03557 | python | s678711990 | s522360391 | 303 | 230 | 29,124 | 44,168 | Accepted | Accepted | 24.09 | from bisect import bisect
from itertools import accumulate
def main():
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ainb = [bisect(b, ea) for ea in a]
bc = [n -... | import sys
read = sys.stdin.read
#readlines = sys.stdin.readlines
from bisect import bisect, bisect_left
from itertools import accumulate
def main():
data = list(map(int, read().split()))
n = data[0]
a = data[1:n + 1]
b = data[n + 1: n * 2 + 1]
c = data[n * 2 + 1:]
a.sort()
b.sor... | 23 | 22 | 565 | 545 | from bisect import bisect
from itertools import accumulate
def main():
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ainb = [bisect(b, ea) for ea in a]
bc = [n - bisect(c... | import sys
read = sys.stdin.read
# readlines = sys.stdin.readlines
from bisect import bisect, bisect_left
from itertools import accumulate
def main():
data = list(map(int, read().split()))
n = data[0]
a = data[1 : n + 1]
b = data[n + 1 : n * 2 + 1]
c = data[n * 2 + 1 :]
a.sort()
b.sort()
... | false | 4.347826 | [
"-from bisect import bisect",
"+import sys",
"+",
"+read = sys.stdin.read",
"+# readlines = sys.stdin.readlines",
"+from bisect import bisect, bisect_left",
"- n = int(eval(input()))",
"- a = list(map(int, input().split()))",
"- b = list(map(int, input().split()))",
"- c = list(map(int... | false | 0.049943 | 0.041611 | 1.20023 | [
"s678711990",
"s522360391"
] |
u600402037 | p02936 | python | s877529134 | s151378563 | 1,893 | 869 | 238,868 | 89,420 | Accepted | Accepted | 54.09 | import sys
sys.setrecursionlimit(10 ** 7)
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, Q = lr()
edges = [[] for _ in range(N+1)]
for _ in range(N-1):
a, b = lr()
edges[a].append(b)
edges[b].append(a)
counter = [0] * (N+1)
fo... | import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# クエリでは根だけにカウンターの値を足して、最後に上から足していく(imos法みたいに)
N, Q = lr()
graph = [[] for _ in range(N+1)]
for _ in range(N-1):
a, b = lr()
graph[a].append(b)
graph[b].append(a)
counter = ... | 34 | 32 | 622 | 713 | import sys
sys.setrecursionlimit(10**7)
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, Q = lr()
edges = [[] for _ in range(N + 1)]
for _ in range(N - 1):
a, b = lr()
edges[a].append(b)
edges[b].append(a)
counter = [0] * (N + 1)
for _ in range(... | import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# クエリでは根だけにカウンターの値を足して、最後に上から足していく(imos法みたいに)
N, Q = lr()
graph = [[] for _ in range(N + 1)]
for _ in range(N - 1):
a, b = lr()
graph[a].append(b)
graph[b].append(a)
counter = [0] * (N + 1... | false | 5.882353 | [
"-sys.setrecursionlimit(10**7)",
"+# クエリでは根だけにカウンターの値を足して、最後に上から足していく(imos法みたいに)",
"-edges = [[] for _ in range(N + 1)]",
"+graph = [[] for _ in range(N + 1)]",
"- edges[a].append(b)",
"- edges[b].append(a)",
"-counter = [0] * (N + 1)",
"+ graph[a].append(b)",
"+ graph[b].append(a)",
"... | false | 0.038373 | 0.037364 | 1.027013 | [
"s877529134",
"s151378563"
] |
u191874006 | p02614 | python | s312283597 | s545035825 | 104 | 78 | 69,580 | 68,432 | Accepted | Accepted | 25 | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from... | #!/usr/bin/env python3
h, w, k = list(map(int, input().split()))
c = [eval(input()) for _ in range(h)]
ans = 0
for i in range(1<<h):
for j in range(1<<w):
cnt = 0
for y in range(h):
for x in range(w):
if (i >> y & 1) or (j >> x & 1):
cont... | 51 | 18 | 1,458 | 439 | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collectio... | #!/usr/bin/env python3
h, w, k = list(map(int, input().split()))
c = [eval(input()) for _ in range(h)]
ans = 0
for i in range(1 << h):
for j in range(1 << w):
cnt = 0
for y in range(h):
for x in range(w):
if (i >> y & 1) or (j >> x & 1):
continue
... | false | 64.705882 | [
"-import sys",
"-import math",
"-from bisect import bisect_right as br",
"-from bisect import bisect_left as bl",
"-",
"-sys.setrecursionlimit(2147483647)",
"-from heapq import heappush, heappop, heappushpop",
"-from collections import defaultdict",
"-from itertools import accumulate",
"-from coll... | false | 0.064395 | 0.084438 | 0.762638 | [
"s312283597",
"s545035825"
] |
u753803401 | p02899 | python | s904851948 | s611180242 | 536 | 392 | 70,956 | 67,960 | Accepted | Accepted | 26.87 | def slove():
import sys
input = sys.stdin.readline
n = int(input().rstrip('\n'))
a = [[v, i + 1] for i, v in enumerate(list(map(int, input().rstrip('\n').split())))]
a.sort()
print((*[a[i][1] for i in range(n)]))
if __name__ == '__main__':
slove()
| import sys
def solve():
readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
ans = []
for i, v in enumerate(a):
ans.append([i, v])
ans.sort(key=lambda x: x[1])
ls = []
for i in range(n):
ls.a... | 11 | 20 | 286 | 402 | def slove():
import sys
input = sys.stdin.readline
n = int(input().rstrip("\n"))
a = [[v, i + 1] for i, v in enumerate(list(map(int, input().rstrip("\n").split())))]
a.sort()
print((*[a[i][1] for i in range(n)]))
if __name__ == "__main__":
slove()
| import sys
def solve():
readline = sys.stdin.buffer.readline
mod = 10**9 + 7
n = int(readline())
a = list(map(int, readline().split()))
ans = []
for i, v in enumerate(a):
ans.append([i, v])
ans.sort(key=lambda x: x[1])
ls = []
for i in range(n):
ls.append(ans[i][0] ... | false | 45 | [
"-def slove():",
"- import sys",
"+import sys",
"- input = sys.stdin.readline",
"- n = int(input().rstrip(\"\\n\"))",
"- a = [[v, i + 1] for i, v in enumerate(list(map(int, input().rstrip(\"\\n\").split())))]",
"- a.sort()",
"- print((*[a[i][1] for i in range(n)]))",
"+",
"+def s... | false | 0.065775 | 0.037153 | 1.770389 | [
"s904851948",
"s611180242"
] |
u036104576 | p03033 | python | s206434237 | s139071572 | 1,981 | 1,641 | 203,304 | 105,452 | Accepted | Accepted | 17.16 | import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdi... | import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdi... | 66 | 67 | 1,424 | 1,423 | import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
#... | import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
#... | false | 1.492537 | [
"+cnt[INF] = 1",
"- while len(q) > 1 and cnt[q[0]] == 0:",
"+ while cnt[q[0]] == 0:"
] | false | 0.143667 | 0.008281 | 17.348467 | [
"s206434237",
"s139071572"
] |
u034777138 | p02898 | python | s215141449 | s139359092 | 54 | 48 | 11,912 | 11,908 | Accepted | Accepted | 11.11 |
inputA = list(map(int,input().split()))
inputB = list(map(int,input().split()))
humancount = inputA[0]
talllimit = inputA[1]
anser = 0
for count in range(0,humancount):
if inputB[count] >= talllimit:
anser += 1
print(anser) | ip= list(map(int, input().split()))
N = ip[0]
K = ip[1]
h = list(map(int, input().split()))
ans = 0
for tall in h:
if tall >= K:
ans +=1
print(ans) | 14 | 12 | 255 | 173 | inputA = list(map(int, input().split()))
inputB = list(map(int, input().split()))
humancount = inputA[0]
talllimit = inputA[1]
anser = 0
for count in range(0, humancount):
if inputB[count] >= talllimit:
anser += 1
print(anser)
| ip = list(map(int, input().split()))
N = ip[0]
K = ip[1]
h = list(map(int, input().split()))
ans = 0
for tall in h:
if tall >= K:
ans += 1
print(ans)
| false | 14.285714 | [
"-inputA = list(map(int, input().split()))",
"-inputB = list(map(int, input().split()))",
"-humancount = inputA[0]",
"-talllimit = inputA[1]",
"-anser = 0",
"-for count in range(0, humancount):",
"- if inputB[count] >= talllimit:",
"- anser += 1",
"-print(anser)",
"+ip = list(map(int, in... | false | 0.082243 | 0.091643 | 0.897434 | [
"s215141449",
"s139359092"
] |
u720721463 | p03524 | python | s861647423 | s509982767 | 83 | 70 | 67,536 | 67,664 | Accepted | Accepted | 15.66 | s = eval(input())
na = nb = nc = 0
for c in s:
if c == 'a':
na += 1
if c == 'b':
nb += 1
if c == 'c':
nc += 1
if max(abs(na-nb), max( abs(na - nc), abs(nb - nc))) > 1:
print("NO")
else:
print("YES")
| s = eval(input())
na = nb = nc = 0
for c in s:
if c == 'a':
na += 1
if c == 'b':
nb += 1
if c == 'c':
nc += 1
if abs(na - nb) < 2 and abs(na - nc) < 2 and abs(nb - nc) < 2:
print("YES")
else:
print("NO")
| 15 | 15 | 231 | 236 | s = eval(input())
na = nb = nc = 0
for c in s:
if c == "a":
na += 1
if c == "b":
nb += 1
if c == "c":
nc += 1
if max(abs(na - nb), max(abs(na - nc), abs(nb - nc))) > 1:
print("NO")
else:
print("YES")
| s = eval(input())
na = nb = nc = 0
for c in s:
if c == "a":
na += 1
if c == "b":
nb += 1
if c == "c":
nc += 1
if abs(na - nb) < 2 and abs(na - nc) < 2 and abs(nb - nc) < 2:
print("YES")
else:
print("NO")
| false | 0 | [
"-if max(abs(na - nb), max(abs(na - nc), abs(nb - nc))) > 1:",
"+if abs(na - nb) < 2 and abs(na - nc) < 2 and abs(nb - nc) < 2:",
"+ print(\"YES\")",
"+else:",
"-else:",
"- print(\"YES\")"
] | false | 0.040031 | 0.038604 | 1.036981 | [
"s861647423",
"s509982767"
] |
u844646164 | p03450 | python | s815573152 | s726477978 | 1,671 | 606 | 133,264 | 88,572 | Accepted | Accepted | 63.73 |
import sys
sys.setrecursionlimit(10**5)
class UnionFind():
def __init__(self, n):
self.n = n
self.root = [-1]*(n+1)
self.rnk = [0]*(n+1)
self.weight = [0]*(n+1)
def Find_Root(self, x):
if(self.root[x] < 0):
return x
else:
r = ... | import sys
sys.setrecursionlimit(10**5)
class UnionFind():
def __init__(self, n):
self.n = n
self.root = [-1]*(n+1)
self.rnk = [0]*(n+1)
self.weight = [0]*(n+1)
def Find_Root(self, x):
if(self.root[x] < 0):
return x
else:
r = se... | 59 | 53 | 1,568 | 1,500 | import sys
sys.setrecursionlimit(10**5)
class UnionFind:
def __init__(self, n):
self.n = n
self.root = [-1] * (n + 1)
self.rnk = [0] * (n + 1)
self.weight = [0] * (n + 1)
def Find_Root(self, x):
if self.root[x] < 0:
return x
else:
r = s... | import sys
sys.setrecursionlimit(10**5)
class UnionFind:
def __init__(self, n):
self.n = n
self.root = [-1] * (n + 1)
self.rnk = [0] * (n + 1)
self.weight = [0] * (n + 1)
def Find_Root(self, x):
if self.root[x] < 0:
return x
else:
r = s... | false | 10.169492 | [
"-n, m = list(map(int, input().split()))",
"-if m == 0:",
"- print(\"Yes\")",
"- exit()",
"-lrd = [list(map(int, input().split())) for _ in range(m)]",
"-uf = UnionFind(n)",
"-for l, r, d in lrd:",
"- if uf.isSameGroup(l, r) == False:",
"+N, M = list(map(int, input().split()))",
"+uf = Un... | false | 0.043462 | 0.0436 | 0.996831 | [
"s815573152",
"s726477978"
] |
u584083761 | p02726 | python | s488827200 | s181898902 | 1,969 | 1,339 | 3,444 | 3,444 | Accepted | Accepted | 32 | n,x,y = list(map(int, input().split()))
ans = [0]*(n)
for i in range(n-1):
for j in range(i+1, n):
r1 = min(j-i, (abs(x-i-1) + 1 + abs(y-j-1) ), (abs(y-i-1) + 1 + abs(x-j-1) ) )
ans[r1] += 1
for i in ans[1:]:
print(i) | n,x,y = list(map(int, input().split()))
ans = [0]*(n)
for i in range(n-1):
for j in range(i+1, n):
#r1 = min(j-i, (abs(x-i-1) + 1 + abs(y-j-1) ), (abs(y-i-1) + 1 + abs(x-j-1) ) )
r1 = min(j - i, (abs(x - i - 1) + 1 + abs(y - j - 1)))
ans[r1] += 1
for i in ans[1:]:
print(i) | 10 | 11 | 254 | 319 | n, x, y = list(map(int, input().split()))
ans = [0] * (n)
for i in range(n - 1):
for j in range(i + 1, n):
r1 = min(
j - i,
(abs(x - i - 1) + 1 + abs(y - j - 1)),
(abs(y - i - 1) + 1 + abs(x - j - 1)),
)
ans[r1] += 1
for i in ans[1:]:
print(i)
| n, x, y = list(map(int, input().split()))
ans = [0] * (n)
for i in range(n - 1):
for j in range(i + 1, n):
# r1 = min(j-i, (abs(x-i-1) + 1 + abs(y-j-1) ), (abs(y-i-1) + 1 + abs(x-j-1) ) )
r1 = min(j - i, (abs(x - i - 1) + 1 + abs(y - j - 1)))
ans[r1] += 1
for i in ans[1:]:
print(i)
| false | 9.090909 | [
"- r1 = min(",
"- j - i,",
"- (abs(x - i - 1) + 1 + abs(y - j - 1)),",
"- (abs(y - i - 1) + 1 + abs(x - j - 1)),",
"- )",
"+ # r1 = min(j-i, (abs(x-i-1) + 1 + abs(y-j-1) ), (abs(y-i-1) + 1 + abs(x-j-1) ) )",
"+ r1 = min(j - i, (abs(x - i - 1... | false | 0.037999 | 0.045892 | 0.828006 | [
"s488827200",
"s181898902"
] |
u150984829 | p02283 | python | s108276761 | s527537306 | 3,900 | 3,540 | 63,248 | 63,328 | Accepted | Accepted | 9.23 | import sys
class Node:
__slots__ = ['key', 'left', 'right']
def __init__(self, key):
self.key = key
self.left = self.right = None
class BST:
__slots__ = ['root']
def __init__(self):
self.root = None
def insert(self, key):
x, y = self.root, None
... | import sys
class Node:
__slots__ = ['key', 'left', 'right']
def __init__(self, key):
self.key = key
self.left = self.right = None
root = None
def insert(key):
global root
x, y = root, None
while x is not None: x, y = x.left if key < x.key else x.right, x
if y is ... | 31 | 27 | 974 | 760 | import sys
class Node:
__slots__ = ["key", "left", "right"]
def __init__(self, key):
self.key = key
self.left = self.right = None
class BST:
__slots__ = ["root"]
def __init__(self):
self.root = None
def insert(self, key):
x, y = self.root, None
while x ... | import sys
class Node:
__slots__ = ["key", "left", "right"]
def __init__(self, key):
self.key = key
self.left = self.right = None
root = None
def insert(key):
global root
x, y = root, None
while x is not None:
x, y = x.left if key < x.key else x.right, x
if y is No... | false | 12.903226 | [
"-class BST:",
"- __slots__ = [\"root\"]",
"-",
"- def __init__(self):",
"- self.root = None",
"-",
"- def insert(self, key):",
"- x, y = self.root, None",
"- while x != None:",
"- x, y = x.left if key < x.key else x.right, x",
"- if y == None:",
... | false | 0.084735 | 0.044645 | 1.897967 | [
"s108276761",
"s527537306"
] |
u736729525 | p02554 | python | s872605673 | s098205537 | 1,595 | 33 | 239,088 | 9,304 | Accepted | Accepted | 97.93 | import sys
def test(N):
answer = 0
for i in range(1, 10**N):
s = ("%0" + str(N) +"d") % i
if "0" in s and "9" in s:
#print(s)
answer += 1
return answer
def solve(N):
MOD = 10**9+7
dp = [[0, 0, 0, 0] for i in range(N+1)]
dp[0] = [1, 0, 0, 0]... | import sys
def test(N):
MOD = 10**9+7
U = (pow(10, N, MOD) - 1)%MOD
notA = (pow(9, N, MOD) - 1)% MOD
notB = (pow(9, N, MOD) - 1)% MOD
A = (U - notA) % MOD
B = (U - notB) % MOD
AnorB = (pow(8, N, MOD) - 1)%MOD
AorB = (U - AnorB) % MOD
AandB = (A+B-AorB) %MOD
#print(f"... | 30 | 35 | 730 | 897 | import sys
def test(N):
answer = 0
for i in range(1, 10**N):
s = ("%0" + str(N) + "d") % i
if "0" in s and "9" in s:
# print(s)
answer += 1
return answer
def solve(N):
MOD = 10**9 + 7
dp = [[0, 0, 0, 0] for i in range(N + 1)]
dp[0] = [1, 0, 0, 0]
A... | import sys
def test(N):
MOD = 10**9 + 7
U = (pow(10, N, MOD) - 1) % MOD
notA = (pow(9, N, MOD) - 1) % MOD
notB = (pow(9, N, MOD) - 1) % MOD
A = (U - notA) % MOD
B = (U - notB) % MOD
AnorB = (pow(8, N, MOD) - 1) % MOD
AorB = (U - AnorB) % MOD
AandB = (A + B - AorB) % MOD
# print... | false | 14.285714 | [
"- answer = 0",
"- for i in range(1, 10**N):",
"- s = (\"%0\" + str(N) + \"d\") % i",
"- if \"0\" in s and \"9\" in s:",
"- # print(s)",
"- answer += 1",
"- return answer",
"+ MOD = 10**9 + 7",
"+ U = (pow(10, N, MOD) - 1) % MOD",
"+ notA = (po... | false | 0.493833 | 0.037152 | 13.29214 | [
"s872605673",
"s098205537"
] |
u794910686 | p03127 | python | s199680594 | s759819982 | 330 | 72 | 23,112 | 14,224 | Accepted | Accepted | 78.18 | import numpy as np
N=int(eval(input()))
# A=list(map(int,input().split()))
A=[int(i) for i in input().split()]
A=np.array(sorted(A))
while np.any(A[:-1]>0):
try:
m=sorted(list(A[A>0]))[0]
A=list(A[1:]%m)
A.append(m)
A=np.array(A)
except:
continue
print(m)... | def gcd(a,b):
while b!=0:
a,b=b,a%b
return a
N=int(eval(input()))
# A=list(map(int,input().split()))
A=[int(i) for i in input().split()]
m=0
for a in A:
m=gcd(a,m)
print(m) | 16 | 13 | 315 | 200 | import numpy as np
N = int(eval(input()))
# A=list(map(int,input().split()))
A = [int(i) for i in input().split()]
A = np.array(sorted(A))
while np.any(A[:-1] > 0):
try:
m = sorted(list(A[A > 0]))[0]
A = list(A[1:] % m)
A.append(m)
A = np.array(A)
except:
continue
print(... | def gcd(a, b):
while b != 0:
a, b = b, a % b
return a
N = int(eval(input()))
# A=list(map(int,input().split()))
A = [int(i) for i in input().split()]
m = 0
for a in A:
m = gcd(a, m)
print(m)
| false | 18.75 | [
"-import numpy as np",
"+def gcd(a, b):",
"+ while b != 0:",
"+ a, b = b, a % b",
"+ return a",
"+",
"-A = np.array(sorted(A))",
"-while np.any(A[:-1] > 0):",
"- try:",
"- m = sorted(list(A[A > 0]))[0]",
"- A = list(A[1:] % m)",
"- A.append(m)",
"- ... | false | 0.221363 | 0.044978 | 4.921577 | [
"s199680594",
"s759819982"
] |
u380524497 | p03546 | python | s157932128 | s063874666 | 32 | 29 | 3,064 | 3,188 | Accepted | Accepted | 9.38 | h, w = list(map(int, input().split()))
edges = [[] for i in range(10)]
for _from in range(10):
line = list(map(int, input().split()))
for to in range(10):
if _from == to:
continue
cost = line[to]
edges[_from].append([to, cost])
cost_to_1 = [10**5] * 10
cost_to... | import heapq
h, w = list(map(int, input().split()))
costs = []
for i in range(10):
line = list(map(int, input().split()))
costs.append(line)
mini_cost_to_1_from = [10**4] * 10
mini_cost_to_1_from[1] = 0
for num in range(10):
if num == 1:
continue
seen = [False] * 10
todo ... | 50 | 53 | 1,183 | 1,152 | h, w = list(map(int, input().split()))
edges = [[] for i in range(10)]
for _from in range(10):
line = list(map(int, input().split()))
for to in range(10):
if _from == to:
continue
cost = line[to]
edges[_from].append([to, cost])
cost_to_1 = [10**5] * 10
cost_to_1[1] = 0
for nu... | import heapq
h, w = list(map(int, input().split()))
costs = []
for i in range(10):
line = list(map(int, input().split()))
costs.append(line)
mini_cost_to_1_from = [10**4] * 10
mini_cost_to_1_from[1] = 0
for num in range(10):
if num == 1:
continue
seen = [False] * 10
todo = []
for to in ... | false | 5.660377 | [
"+import heapq",
"+",
"-edges = [[] for i in range(10)]",
"-for _from in range(10):",
"+costs = []",
"+for i in range(10):",
"- for to in range(10):",
"- if _from == to:",
"- continue",
"- cost = line[to]",
"- edges[_from].append([to, cost])",
"-cost_to_1 = [... | false | 0.039905 | 0.050318 | 0.793049 | [
"s157932128",
"s063874666"
] |
u309977459 | p03681 | python | s551031113 | s197474362 | 710 | 46 | 5,180 | 7,060 | Accepted | Accepted | 93.52 | from math import factorial as F
N, M = list(map(int, input().split()))
N, M = min(N, M), max(N, M)
mod = 10**9+7
if M-N > 1:
print((0))
elif M-N == 1:
print((F(M)*F(N) % mod))
else:
print((F(M)**2*2 % mod))
| N, M = list(map(int, input().split()))
N, M = min(N, M), max(N, M)
mod = 10**9+7
g = [1, 1]
for i in range(2, M+1):
g.append((g[-1] * i) % mod)
if M-N > 1:
print((0))
elif M-N == 1:
print((g[M]*g[N] % mod))
else:
print((g[M]**2*2 % mod))
| 11 | 14 | 218 | 257 | from math import factorial as F
N, M = list(map(int, input().split()))
N, M = min(N, M), max(N, M)
mod = 10**9 + 7
if M - N > 1:
print((0))
elif M - N == 1:
print((F(M) * F(N) % mod))
else:
print((F(M) ** 2 * 2 % mod))
| N, M = list(map(int, input().split()))
N, M = min(N, M), max(N, M)
mod = 10**9 + 7
g = [1, 1]
for i in range(2, M + 1):
g.append((g[-1] * i) % mod)
if M - N > 1:
print((0))
elif M - N == 1:
print((g[M] * g[N] % mod))
else:
print((g[M] ** 2 * 2 % mod))
| false | 21.428571 | [
"-from math import factorial as F",
"-",
"+g = [1, 1]",
"+for i in range(2, M + 1):",
"+ g.append((g[-1] * i) % mod)",
"- print((F(M) * F(N) % mod))",
"+ print((g[M] * g[N] % mod))",
"- print((F(M) ** 2 * 2 % mod))",
"+ print((g[M] ** 2 * 2 % mod))"
] | false | 0.043171 | 0.040479 | 1.066507 | [
"s551031113",
"s197474362"
] |
u011062360 | p03805 | python | s304056056 | s409137496 | 28 | 21 | 3,188 | 3,064 | Accepted | Accepted | 25 | from itertools import permutations
n, m = list(map(int, input().split()))
list_AB = [ list(map(int,input().split(" "))) for i in range(m)]
list_MAP = [[0]*n for _ in range(n)]
list_N = [i for i in range(2, n+1)]
for a, b in list_AB:
list_MAP[a-1][b-1] = 1
list_MAP[b-1][a-1] = 1
ans = 0
for l in p... | n, m = list(map(int, input().split()))
list_MAP = [[0]*n for _ in range(n)]
for _ in range(m):
a, b = list(map(int, input().split()))
list_MAP[a-1][b-1] = 1
list_MAP[b-1][a-1] = 1
dp = [[0]*n for _ in range(1<<n)]
dp[1][0] = 1
for num in range(1<<n):
for v in range(n):
if num & (1<<v... | 25 | 20 | 516 | 551 | from itertools import permutations
n, m = list(map(int, input().split()))
list_AB = [list(map(int, input().split(" "))) for i in range(m)]
list_MAP = [[0] * n for _ in range(n)]
list_N = [i for i in range(2, n + 1)]
for a, b in list_AB:
list_MAP[a - 1][b - 1] = 1
list_MAP[b - 1][a - 1] = 1
ans = 0
for l in per... | n, m = list(map(int, input().split()))
list_MAP = [[0] * n for _ in range(n)]
for _ in range(m):
a, b = list(map(int, input().split()))
list_MAP[a - 1][b - 1] = 1
list_MAP[b - 1][a - 1] = 1
dp = [[0] * n for _ in range(1 << n)]
dp[1][0] = 1
for num in range(1 << n):
for v in range(n):
if num & (... | false | 20 | [
"-from itertools import permutations",
"-",
"-list_AB = [list(map(int, input().split(\" \"))) for i in range(m)]",
"-list_N = [i for i in range(2, n + 1)]",
"-for a, b in list_AB:",
"+for _ in range(m):",
"+ a, b = list(map(int, input().split()))",
"-ans = 0",
"-for l in permutations(list_N, n - ... | false | 0.044716 | 0.037186 | 1.202479 | [
"s304056056",
"s409137496"
] |
u463655976 | p03559 | python | s208319882 | s160478110 | 575 | 328 | 43,892 | 22,720 | Accepted | Accepted | 42.96 | N = int(eval(input()))
L = []
L.extend(((int(x), 3) for x in input().split()))
L.extend(((int(x), 2) for x in input().split()))
L.extend(((int(x), 1) for x in input().split()))
L = sorted(L, reverse=True)
cnt_C = 0
cnt_B = 0
cnt_A = 0
for x, i in L:
if i == 1:
cnt_C += 1
elif i == 2... | N = int(eval(input()))
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
cur_l = 0
cur_r = 0
p = 0
for cur_mid in B:
while cur_l < len(A):
if A[cur_l] >= cur_mid:
break
cur_l += 1
while cur_r < len(C):
... | 21 | 21 | 398 | 430 | N = int(eval(input()))
L = []
L.extend(((int(x), 3) for x in input().split()))
L.extend(((int(x), 2) for x in input().split()))
L.extend(((int(x), 1) for x in input().split()))
L = sorted(L, reverse=True)
cnt_C = 0
cnt_B = 0
cnt_A = 0
for x, i in L:
if i == 1:
cnt_C += 1
elif i == 2:
cnt_B += cn... | N = int(eval(input()))
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
cur_l = 0
cur_r = 0
p = 0
for cur_mid in B:
while cur_l < len(A):
if A[cur_l] >= cur_mid:
break
cur_l += 1
while cur_r < len(C):
if cur_mid... | false | 0 | [
"-L = []",
"-L.extend(((int(x), 3) for x in input().split()))",
"-L.extend(((int(x), 2) for x in input().split()))",
"-L.extend(((int(x), 1) for x in input().split()))",
"-L = sorted(L, reverse=True)",
"-cnt_C = 0",
"-cnt_B = 0",
"-cnt_A = 0",
"-for x, i in L:",
"- if i == 1:",
"- cnt_... | false | 0.035886 | 0.040258 | 0.891406 | [
"s208319882",
"s160478110"
] |
u891847179 | p02726 | python | s892031915 | s046778614 | 1,618 | 1,133 | 3,444 | 3,444 | Accepted | Accepted | 29.98 | N, X, Y = list(map(int, input().split()))
res = [0] * N
for j in range(1, N + 1):
for i in range(1, j):
if i == X and Y == j:
key = 1
else:
key = int(min(j - i, abs(X - i) + abs(Y - j) + 1))
res[key] += 1
for i in range(1, N):
print((res[i])) | N, X, Y = list(map(int, input().split()))
res = [0] * N
for j in range(1, N + 1):
for i in range(1, j):
res[min(j - i, abs(X - i) + abs(Y - j) + 1)] += 1
for i in range(1, N):
print((res[i]))
| 12 | 8 | 308 | 214 | N, X, Y = list(map(int, input().split()))
res = [0] * N
for j in range(1, N + 1):
for i in range(1, j):
if i == X and Y == j:
key = 1
else:
key = int(min(j - i, abs(X - i) + abs(Y - j) + 1))
res[key] += 1
for i in range(1, N):
print((res[i]))
| N, X, Y = list(map(int, input().split()))
res = [0] * N
for j in range(1, N + 1):
for i in range(1, j):
res[min(j - i, abs(X - i) + abs(Y - j) + 1)] += 1
for i in range(1, N):
print((res[i]))
| false | 33.333333 | [
"- if i == X and Y == j:",
"- key = 1",
"- else:",
"- key = int(min(j - i, abs(X - i) + abs(Y - j) + 1))",
"- res[key] += 1",
"+ res[min(j - i, abs(X - i) + abs(Y - j) + 1)] += 1"
] | false | 0.035707 | 0.037946 | 0.941003 | [
"s892031915",
"s046778614"
] |
u371763408 | p03637 | python | s379116677 | s087373955 | 96 | 73 | 14,480 | 11,480 | Accepted | Accepted | 23.96 | n=int(eval(input()))
A=list(map(int,input().split()))
four=list([x for x in A if x%4==0])
even=list([x for x in A if x%2==0])
odd=list([x for x in A if x%2==1])
# print(len(even))
# print(len(odd))
# print(len(four))
#全ての成分が偶数
if len(even)==len(A):
print('Yes')
exit()
#4の倍数が奇数の半分以上ある(切り下げ)かつ2の倍数が偶数個かつ... | #強い人のコード
N=int(eval(input()))
ans='Yes'
odd=0
four=0
for x in map(int,input().split()):
if x%2==1:
odd+=1
elif x%4==0:
four+=1
#4の倍数+1が奇数の数より少ないとダメ
if four+1<odd:
ans='No'
#4の倍数+1が奇数と同じかつその合計が全体より少ないとダメ(ひとつ奇数が余ることになる)
elif four+1==odd and odd+four<N:
ans='No'
print(ans)
| 28 | 17 | 714 | 313 | n = int(eval(input()))
A = list(map(int, input().split()))
four = list([x for x in A if x % 4 == 0])
even = list([x for x in A if x % 2 == 0])
odd = list([x for x in A if x % 2 == 1])
# print(len(even))
# print(len(odd))
# print(len(four))
# 全ての成分が偶数
if len(even) == len(A):
print("Yes")
exit()
# 4の倍数が奇数の半分以上ある(... | # 強い人のコード
N = int(eval(input()))
ans = "Yes"
odd = 0
four = 0
for x in map(int, input().split()):
if x % 2 == 1:
odd += 1
elif x % 4 == 0:
four += 1
# 4の倍数+1が奇数の数より少ないとダメ
if four + 1 < odd:
ans = "No"
# 4の倍数+1が奇数と同じかつその合計が全体より少ないとダメ(ひとつ奇数が余ることになる)
elif four + 1 == odd and odd + four < N:
... | false | 39.285714 | [
"-n = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-four = list([x for x in A if x % 4 == 0])",
"-even = list([x for x in A if x % 2 == 0])",
"-odd = list([x for x in A if x % 2 == 1])",
"-# print(len(even))",
"-# print(len(odd))",
"-# print(len(four))",
"-# 全ての成分が偶数",
"-if len(ev... | false | 0.042519 | 0.04707 | 0.903309 | [
"s379116677",
"s087373955"
] |
u077291787 | p03317 | python | s904821327 | s115720406 | 40 | 17 | 13,812 | 3,060 | Accepted | Accepted | 57.5 | # ABC099C - Minimization
from math import ceil
N, K = list(map(int, input().rstrip().split()))
_ = list(map(int, input().rstrip().split()))
print((1 + ceil((N - K) / (K - 1)))) | # ARC099C - Minimization
from math import ceil
N, K = list(map(int, input().rstrip().split()))
print((1 + ceil((N - K) / (K - 1)))) | 6 | 5 | 180 | 134 | # ABC099C - Minimization
from math import ceil
N, K = list(map(int, input().rstrip().split()))
_ = list(map(int, input().rstrip().split()))
print((1 + ceil((N - K) / (K - 1))))
| # ARC099C - Minimization
from math import ceil
N, K = list(map(int, input().rstrip().split()))
print((1 + ceil((N - K) / (K - 1))))
| false | 16.666667 | [
"-# ABC099C - Minimization",
"+# ARC099C - Minimization",
"-_ = list(map(int, input().rstrip().split()))"
] | false | 0.036634 | 0.037942 | 0.965546 | [
"s904821327",
"s115720406"
] |
u063091489 | p00033 | python | s420909763 | s878795451 | 20 | 10 | 4,232 | 4,220 | Accepted | Accepted | 50 |
N = int(input())
for c in range(N):
B = [0]
C = [0]
def dfs(depth):
if depth == 10:
return True
res = False
if B[-1] < A[depth]:
B.append(A[depth])
res |= dfs(depth+1)
del B[-1]
if C... | N = int(input())
def dfs(depth, l, r):
if depth == 10:
return True
res = False
if l < A[depth]:
res |= dfs(depth+1, A[depth], r)
if r < A[depth]:
res |= dfs(depth+1, l, A[depth])
return res
for c in range(N):
A = list(map(int, input().split(" ")))
prin... | 27 | 16 | 545 | 361 | N = int(input())
for c in range(N):
B = [0]
C = [0]
def dfs(depth):
if depth == 10:
return True
res = False
if B[-1] < A[depth]:
B.append(A[depth])
res |= dfs(depth + 1)
del B[-1]
if C[-1] < A[depth]:
C.append(A[dep... | N = int(input())
def dfs(depth, l, r):
if depth == 10:
return True
res = False
if l < A[depth]:
res |= dfs(depth + 1, A[depth], r)
if r < A[depth]:
res |= dfs(depth + 1, l, A[depth])
return res
for c in range(N):
A = list(map(int, input().split(" ")))
print("YES" ... | false | 40.740741 | [
"+",
"+",
"+def dfs(depth, l, r):",
"+ if depth == 10:",
"+ return True",
"+ res = False",
"+ if l < A[depth]:",
"+ res |= dfs(depth + 1, A[depth], r)",
"+ if r < A[depth]:",
"+ res |= dfs(depth + 1, l, A[depth])",
"+ return res",
"+",
"+",
"- B = [0]... | false | 0.090277 | 0.153656 | 0.587524 | [
"s420909763",
"s878795451"
] |
u010110540 | p03805 | python | s770426551 | s625321131 | 30 | 18 | 3,064 | 3,064 | Accepted | Accepted | 40 | import itertools
N, M = list(map(int, input().split()))
adj_matrix = [[0]* N for _ in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
adj_matrix[a-1][b-1] = 1
adj_matrix[b-1][a-1] = 1
cnt = 0
for each in itertools.permutations(list(range(N))):
if each[0] != 0:
... | #bid DP
N, M = list(map(int, input().split()))
g = [[] for i in range(N)] #隣接リスト
for i in range(M):
a, b = list(map(int, input().split()))
g[a-1].append(b-1)
g[b-1].append(a-1)
memo = {}
All_used = (1 << N) -1
def dfs(v, used):
if used == All_used:
return 1
key = (v... | 21 | 34 | 435 | 615 | import itertools
N, M = list(map(int, input().split()))
adj_matrix = [[0] * N for _ in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
adj_matrix[a - 1][b - 1] = 1
adj_matrix[b - 1][a - 1] = 1
cnt = 0
for each in itertools.permutations(list(range(N))):
if each[0] != 0:
break... | # bid DP
N, M = list(map(int, input().split()))
g = [[] for i in range(N)] # 隣接リスト
for i in range(M):
a, b = list(map(int, input().split()))
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
memo = {}
All_used = (1 << N) - 1
def dfs(v, used):
if used == All_used:
return 1
key = (v, used)
... | false | 38.235294 | [
"-import itertools",
"-",
"+# bid DP",
"-adj_matrix = [[0] * N for _ in range(N)]",
"+g = [[] for i in range(N)] # 隣接リスト",
"- adj_matrix[a - 1][b - 1] = 1",
"- adj_matrix[b - 1][a - 1] = 1",
"-cnt = 0",
"-for each in itertools.permutations(list(range(N))):",
"- if each[0] != 0:",
"- ... | false | 0.046998 | 0.037033 | 1.269091 | [
"s770426551",
"s625321131"
] |
u600402037 | p02728 | python | s619059058 | s105008913 | 1,615 | 1,387 | 125,104 | 125,232 | Accepted | Accepted | 14.12 | # coding: utf-8
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# 全方位木DP、葉側と根側
N = ir()
graph = [[] for _ in range(N+1)] # 1-indexed
for _ in range(N-1):
a, b = lr()
graph[a].append(b)
graph[b].append(a)
MOD = 10 ** 9 ... | # coding: utf-8
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# 全方位木DP、葉側と根側
N = ir()
graph = [[] for _ in range(N+1)] # 1-indexed
for _ in range(N-1):
a, b = lr()
graph[a].append(b)
graph[b].append(a)
MOD = 10 ** 9 ... | 67 | 66 | 1,690 | 1,660 | # coding: utf-8
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# 全方位木DP、葉側と根側
N = ir()
graph = [[] for _ in range(N + 1)] # 1-indexed
for _ in range(N - 1):
a, b = lr()
graph[a].append(b)
graph[b].append(a)
MOD = 10**9 + 7
fact = [1] ... | # coding: utf-8
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# 全方位木DP、葉側と根側
N = ir()
graph = [[] for _ in range(N + 1)] # 1-indexed
for _ in range(N - 1):
a, b = lr()
graph[a].append(b)
graph[b].append(a)
MOD = 10**9 + 7
fact = [1] ... | false | 1.492537 | [
"-size_up[1] = 0",
"-dp_up[1] = 1"
] | false | 0.037391 | 0.037591 | 0.994691 | [
"s619059058",
"s105008913"
] |
u811733736 | p00181 | python | s444167361 | s023462450 | 80 | 60 | 7,744 | 7,700 | Accepted | Accepted | 25 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0181
"""
import sys
from sys import stdin
input = stdin.readline
def Cond(m, n, mid, books):
if max(books) > mid:
return False
rem = mid
while books:
while rem >= books[0]:
r... | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0181
"""
import sys
from sys import stdin
input = stdin.readline
def Cond(m, n, mid, books):
if max(books) > mid:
return False
rem = mid
while books:
while rem >= books[0]:
r... | 59 | 59 | 1,137 | 1,136 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0181
"""
import sys
from sys import stdin
input = stdin.readline
def Cond(m, n, mid, books):
if max(books) > mid:
return False
rem = mid
while books:
while rem >= books[0]:
rem -= books[0]
... | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0181
"""
import sys
from sys import stdin
input = stdin.readline
def Cond(m, n, mid, books):
if max(books) > mid:
return False
rem = mid
while books:
while rem >= books[0]:
rem -= books[0]
... | false | 0 | [
"- for i in range(100):",
"+ for i in range(50):"
] | false | 0.046067 | 0.043554 | 1.057697 | [
"s444167361",
"s023462450"
] |
u969850098 | p02720 | python | s635408131 | s652578827 | 234 | 205 | 17,012 | 17,004 | Accepted | Accepted | 12.39 | from collections import deque
K = int(eval(input()))
que = deque(['1', '2', '3', '4', '5', '6', '7', '8', '9'])
while K:
if K == 1:
ans = que.popleft()
break
K -= 1
v = que.popleft()
if v[-1] == '0':
que.append(v + '0')
que.append(v + '1')
elif v[-1] =... | from collections import deque
def main():
K = int(eval(input()))
que = deque(['1', '2', '3', '4', '5', '6', '7', '8', '9'])
while K:
if K == 1:
ans = que.popleft()
break
K -= 1
v = que.popleft()
if v[-1] == '0':
que.append(... | 23 | 28 | 534 | 667 | from collections import deque
K = int(eval(input()))
que = deque(["1", "2", "3", "4", "5", "6", "7", "8", "9"])
while K:
if K == 1:
ans = que.popleft()
break
K -= 1
v = que.popleft()
if v[-1] == "0":
que.append(v + "0")
que.append(v + "1")
elif v[-1] == "9":
... | from collections import deque
def main():
K = int(eval(input()))
que = deque(["1", "2", "3", "4", "5", "6", "7", "8", "9"])
while K:
if K == 1:
ans = que.popleft()
break
K -= 1
v = que.popleft()
if v[-1] == "0":
que.append(v + "0")
... | false | 17.857143 | [
"-K = int(eval(input()))",
"-que = deque([\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"])",
"-while K:",
"- if K == 1:",
"- ans = que.popleft()",
"- break",
"- K -= 1",
"- v = que.popleft()",
"- if v[-1] == \"0\":",
"- que.append(v + \"0\")",
"- ... | false | 0.056107 | 0.067579 | 0.830241 | [
"s635408131",
"s652578827"
] |
u598296382 | p02713 | python | s208234853 | s672143910 | 304 | 190 | 75,448 | 72,456 | Accepted | Accepted | 37.5 | import math
k = int(eval(input()))
ab = []
ans = 0
for a in range(1,k+1):
for b in range(1,k+1):
if a % b == 0:
ab.append(b)
elif b % a == 0:
ab.append(a)
else:
ab.append(math.gcd(a, b))
for i in ab:
for c in range(1,k+1):
if ... | import math
k = int(eval(input()))
ab = []
ans = 0
for a in range(1,k+1):
for b in range(1,k+1):
ab.append(math.gcd(a, b))
for i in ab:
for c in range(1,k+1):
ans += math.gcd(i, c)
print(ans) | 24 | 14 | 459 | 225 | import math
k = int(eval(input()))
ab = []
ans = 0
for a in range(1, k + 1):
for b in range(1, k + 1):
if a % b == 0:
ab.append(b)
elif b % a == 0:
ab.append(a)
else:
ab.append(math.gcd(a, b))
for i in ab:
for c in range(1, k + 1):
if i % c ==... | import math
k = int(eval(input()))
ab = []
ans = 0
for a in range(1, k + 1):
for b in range(1, k + 1):
ab.append(math.gcd(a, b))
for i in ab:
for c in range(1, k + 1):
ans += math.gcd(i, c)
print(ans)
| false | 41.666667 | [
"- if a % b == 0:",
"- ab.append(b)",
"- elif b % a == 0:",
"- ab.append(a)",
"- else:",
"- ab.append(math.gcd(a, b))",
"+ ab.append(math.gcd(a, b))",
"- if i % c == 0:",
"- ans += c",
"- elif c % i == 0:",
"- ... | false | 0.158146 | 0.123617 | 1.279319 | [
"s208234853",
"s672143910"
] |
u564589929 | p02762 | python | s901545329 | s924417521 | 1,333 | 1,082 | 37,808 | 19,612 | Accepted | Accepted | 18.83 | import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline ####
int1 = lambda x: int(x) - 1
def II(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))
def LI(): return list(map(int, input().split()))
def LI1(): retur... | import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline ####
int1 = lambda x: int(x) - 1
def II(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))
def LI(): return list(map(int, input().split()))
def LI1(): retur... | 109 | 95 | 2,682 | 2,263 | import sys
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline ####
int1 = lambda x: int(x) - 1
def II():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def MI1():
return list(map(int1, input().split()))
def LI():
return list(map(int, input().split()))
def... | import sys
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline ####
int1 = lambda x: int(x) - 1
def II():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def MI1():
return list(map(int1, input().split()))
def LI():
return list(map(int, input().split()))
def... | false | 12.844037 | [
"- # blocks = [[0] * n for _ in range(n)]",
"- blocks = {}",
"+ blocks = [0] * n",
"- # blocks[c][d] += 1",
"- # blocks[d][c] += 1",
"- blocks.setdefault(c, [])",
"- blocks[c].append(d)",
"- blocks.setdefault(d, [])",
"- blocks[d].append(c)",
"+ ... | false | 0.066516 | 0.073939 | 0.899612 | [
"s901545329",
"s924417521"
] |
u509405951 | p02713 | python | s671177211 | s669867314 | 316 | 217 | 68,760 | 89,552 | Accepted | Accepted | 31.33 | def euclid(a, b):
while b:
a, b = b, a%b
return a
K = int(eval(input()))
count=0
for i in range(1, K+1):
for j in range(i, K+1):
for k in range(j, K+1):
if i == j and j == k:
kake = 1
elif i == j or j == k or i == k:
kake = 3
else:
kake... | import numpy as np
K = int(eval(input()))
x = np.arange(1, K + 1)
nums = np.gcd.outer(np.gcd.outer(x, x), x)
print((np.sum(nums))) | 20 | 7 | 381 | 130 | def euclid(a, b):
while b:
a, b = b, a % b
return a
K = int(eval(input()))
count = 0
for i in range(1, K + 1):
for j in range(i, K + 1):
for k in range(j, K + 1):
if i == j and j == k:
kake = 1
elif i == j or j == k or i == k:
kake = ... | import numpy as np
K = int(eval(input()))
x = np.arange(1, K + 1)
nums = np.gcd.outer(np.gcd.outer(x, x), x)
print((np.sum(nums)))
| false | 65 | [
"-def euclid(a, b):",
"- while b:",
"- a, b = b, a % b",
"- return a",
"-",
"+import numpy as np",
"-count = 0",
"-for i in range(1, K + 1):",
"- for j in range(i, K + 1):",
"- for k in range(j, K + 1):",
"- if i == j and j == k:",
"- kake = 1",... | false | 0.162446 | 0.3985 | 0.407643 | [
"s671177211",
"s669867314"
] |
u321035578 | p02813 | python | s670677544 | s401910312 | 185 | 27 | 38,384 | 8,052 | Accepted | Accepted | 85.41 | def main():
n=int(eval(input()))
p=list(map(int,input().split()))
q=list(map(int,input().split()))
fact = [1]
for i in range(1,9):
fact.append(i*fact[i-1])
tmp = []
for i in range(n):
tmp.append(i+1)
i=0
ansp = caldict(fact,i,p,tmp)
tmp = []
for i... | import itertools
def main():
n=int(eval(input()))
p=list(map(int,input().split()))
q=list(map(int,input().split()))
perm = list(itertools.permutations(list(range(1,n+1))) )
ansp = perm.index(tuple(p))
# qq = list(itertools.permutations(q) )
ansq = perm.index(tuple(q))
print(... | 31 | 15 | 674 | 364 | def main():
n = int(eval(input()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
fact = [1]
for i in range(1, 9):
fact.append(i * fact[i - 1])
tmp = []
for i in range(n):
tmp.append(i + 1)
i = 0
ansp = caldict(fact, i, p, tmp)
tmp = []
... | import itertools
def main():
n = int(eval(input()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
perm = list(itertools.permutations(list(range(1, n + 1))))
ansp = perm.index(tuple(p))
# qq = list(itertools.permutations(q) )
ansq = perm.index(tuple(q))
print((... | false | 51.612903 | [
"+import itertools",
"+",
"+",
"- fact = [1]",
"- for i in range(1, 9):",
"- fact.append(i * fact[i - 1])",
"- tmp = []",
"- for i in range(n):",
"- tmp.append(i + 1)",
"- i = 0",
"- ansp = caldict(fact, i, p, tmp)",
"- tmp = []",
"- for i in range(n):",... | false | 0.081117 | 0.04655 | 1.742575 | [
"s670677544",
"s401910312"
] |
u541055501 | p02611 | python | s866362139 | s095896323 | 77 | 32 | 73,264 | 9,204 | Accepted | Accepted | 58.44 | for _ in range(int(eval(input()))):
n=int(eval(input()))
print((sum([n**j*[[0,765144583,346175634,347662323,5655049,184117322,927321758,444014759,542573865,237315285,417297686,471090892,183023413,660103155,727008098,869418286],[539588932,729548371,700407153,404391958,962779130,184117322,927321758,444014759,54257386... | t,*n=list(map(int,open(0)))
for k in n:print((sum(k**j*[0,765144583,346175634,347662323,5655049,184117322,927321758,444014759,542573865,237315285,417297686,471090892,183023413,660103155,727008098,869418286,539588932,729548371,700407153,404391958,962779130,184117322,927321758,444014759,542573865,237315285,417297686,471... | 3 | 2 | 419 | 402 | for _ in range(int(eval(input()))):
n = int(eval(input()))
print(
(
sum(
[
n**j
* [
[
0,
765144583,
346175634,
... | t, *n = list(map(int, open(0)))
for k in n:
print(
(
sum(
k**j
* [
0,
765144583,
346175634,
347662323,
5655049,
184117322,
9... | false | 33.333333 | [
"-for _ in range(int(eval(input()))):",
"- n = int(eval(input()))",
"+t, *n = list(map(int, open(0)))",
"+for k in n:",
"- [",
"- n**j",
"- * [",
"- [",
"- 0,",
"- 7... | false | 0.037462 | 0.075438 | 0.496585 | [
"s866362139",
"s095896323"
] |
u520276780 | p02793 | python | s254919047 | s290817275 | 1,892 | 1,542 | 5,612 | 6,500 | Accepted | Accepted | 18.5 | n = int(eval(input()))
a = list(map(int, input().split( )))
#最小公倍数でよいか?
#全てのjについてAiBiはAjで割り切れる
#計算時間は?
from fractions import gcd
mod =10**9+7
#これが邪魔だったらしい
"""
def lcd(x,y):
g = gcd(x,y)
return x*y//g
"""
ag = 1
for i in range(n):
ag = ag*a[i]//gcd(ag,a[i])
ans = 0
for i in range(n):
... | #最初のを試したところ、python のほうが早かった
#メモリが問題になるせいか?
#こちらでは?
from fractions import gcd
import random
n = int(eval(input()))
a = list(map(int, input().split( )))
random.shuffle(a)
#最小公倍数でよいか?
#全てのjについてAiBiはAjで割り切れる
#計算時間は?
mod =10**9+7
ag1 = 1
for i in range(n//2):
ag1 = ag1*a[i]//gcd(ag1,a[i])
ag2 = 1
... | 26 | 39 | 361 | 612 | n = int(eval(input()))
a = list(map(int, input().split()))
# 最小公倍数でよいか?
# 全てのjについてAiBiはAjで割り切れる
# 計算時間は?
from fractions import gcd
mod = 10**9 + 7
# これが邪魔だったらしい
"""
def lcd(x,y):
g = gcd(x,y)
return x*y//g
"""
ag = 1
for i in range(n):
ag = ag * a[i] // gcd(ag, a[i])
ans = 0
for i in range(n):
ans += a... | # 最初のを試したところ、python のほうが早かった
# メモリが問題になるせいか?
# こちらでは?
from fractions import gcd
import random
n = int(eval(input()))
a = list(map(int, input().split()))
random.shuffle(a)
# 最小公倍数でよいか?
# 全てのjについてAiBiはAjで割り切れる
# 計算時間は?
mod = 10**9 + 7
ag1 = 1
for i in range(n // 2):
ag1 = ag1 * a[i] // gcd(ag1, a[i])
ag2 = 1
for i i... | false | 33.333333 | [
"+# 最初のを試したところ、python のほうが早かった",
"+# メモリが問題になるせいか?",
"+# こちらでは?",
"+from fractions import gcd",
"+import random",
"+",
"+random.shuffle(a)",
"-from fractions import gcd",
"-",
"-# これが邪魔だったらしい",
"-\"\"\"",
"-def lcd(x,y):",
"- g = gcd(x,y)",
"- return x*y//g",
"-\"\"\"",
"-ag = 1"... | false | 0.133481 | 0.183138 | 0.728854 | [
"s254919047",
"s290817275"
] |
u612975321 | p02991 | python | s998426967 | s981964661 | 737 | 304 | 42,456 | 42,328 | Accepted | Accepted | 58.75 | import copy
import sys
input = sys.stdin.readline
n, m = list(map(int,input().split()))
graph = [[] for i in range(n+1)]
for i in range(m):
u, v = list(map(int,input().split()))
graph[u].append(v)
s, g = list(map(int,input().split()))
INF = 10**7
ans = [[INF, INF, INF] for i in range(n+1)]
q = [s... | # 頂点を3回ずつに持つ (x歩目の着地)
# 最短路
import sys
input = sys.stdin.readline
N,M = list(map(int,input().split()))
if M == 0:
print((-1))
exit()
edge = [[] for _ in range(N+1)]
for _ in range(M):
u,v = list(map(int,input().split()))
edge[u].append(v)
S,T = list(map(int,input().split()))
INF = 10 ** 9
dist... | 29 | 34 | 602 | 594 | import copy
import sys
input = sys.stdin.readline
n, m = list(map(int, input().split()))
graph = [[] for i in range(n + 1)]
for i in range(m):
u, v = list(map(int, input().split()))
graph[u].append(v)
s, g = list(map(int, input().split()))
INF = 10**7
ans = [[INF, INF, INF] for i in range(n + 1)]
q = [s]
d = 0... | # 頂点を3回ずつに持つ (x歩目の着地)
# 最短路
import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))
if M == 0:
print((-1))
exit()
edge = [[] for _ in range(N + 1)]
for _ in range(M):
u, v = list(map(int, input().split()))
edge[u].append(v)
S, T = list(map(int, input().split()))
INF = 10**9
dist = ... | false | 14.705882 | [
"-import copy",
"+# 頂点を3回ずつに持つ (x歩目の着地)",
"+# 最短路",
"-n, m = list(map(int, input().split()))",
"-graph = [[] for i in range(n + 1)]",
"-for i in range(m):",
"+N, M = list(map(int, input().split()))",
"+if M == 0:",
"+ print((-1))",
"+ exit()",
"+edge = [[] for _ in range(N + 1)]",
"+for ... | false | 0.192989 | 0.046503 | 4.150039 | [
"s998426967",
"s981964661"
] |
u597374218 | p02641 | python | s824913988 | s488452484 | 25 | 21 | 9,188 | 9,180 | Accepted | Accepted | 16 | X,N=list(map(int,input().split()))
p=list(map(int,input().split()))
diff=100
for x in range(102):
if x not in p and abs(X-x)<diff:
diff=abs(X-x)
ans=x
print(ans) | X,N=list(map(int,input().split()))
p=list(map(int,input().split()))
diff=99
for x in range(102):
if x not in p and abs(X-x)<diff:
diff=abs(X-x)
ans=x
print(ans) | 8 | 8 | 182 | 181 | X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
diff = 100
for x in range(102):
if x not in p and abs(X - x) < diff:
diff = abs(X - x)
ans = x
print(ans)
| X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
diff = 99
for x in range(102):
if x not in p and abs(X - x) < diff:
diff = abs(X - x)
ans = x
print(ans)
| false | 0 | [
"-diff = 100",
"+diff = 99"
] | false | 0.032496 | 0.035723 | 0.909671 | [
"s824913988",
"s488452484"
] |
u813098295 | p04045 | python | s346796503 | s466035436 | 134 | 42 | 5,380 | 3,060 | Accepted | Accepted | 68.66 | def main():
N, K = list(map(int, input().split()))
D = input().split()
for i in range(N, N*10):
if len(set(list(str(i))) & set(D)) == 0:
print(i)
break
main() | n, k = list(map(int, input().split()))
d = [ int(x) for x in input().split() ]
def is_ok(x):
while x != 0:
if x % 10 in d:
return False
x //= 10
return True
money = n
while True:
if is_ok(n):
print(n)
break
n += 1
| 10 | 16 | 214 | 285 | def main():
N, K = list(map(int, input().split()))
D = input().split()
for i in range(N, N * 10):
if len(set(list(str(i))) & set(D)) == 0:
print(i)
break
main()
| n, k = list(map(int, input().split()))
d = [int(x) for x in input().split()]
def is_ok(x):
while x != 0:
if x % 10 in d:
return False
x //= 10
return True
money = n
while True:
if is_ok(n):
print(n)
break
n += 1
| false | 37.5 | [
"-def main():",
"- N, K = list(map(int, input().split()))",
"- D = input().split()",
"- for i in range(N, N * 10):",
"- if len(set(list(str(i))) & set(D)) == 0:",
"- print(i)",
"- break",
"+n, k = list(map(int, input().split()))",
"+d = [int(x) for x in input().... | false | 0.076295 | 0.041081 | 1.85718 | [
"s346796503",
"s466035436"
] |
u690536347 | p02695 | python | s874267351 | s961873780 | 1,066 | 594 | 9,136 | 9,132 | Accepted | Accepted | 44.28 | from itertools import combinations_with_replacement
N, M, Q = list(map(int, input().split()))
l = [tuple(map(int, input().split())) for _ in range(Q)]
ans = 0
for A in combinations_with_replacement(list(range(1, M+1)), N):
v = 0
for a, b, c, d in l:
if A[b-1]-A[a-1]==c:
v += d
a... | from itertools import combinations_with_replacement
N, M, Q = list(map(int, input().split()))
l = [tuple(map(int, input().split())) for _ in range(Q)]
ans = 0
for A in combinations_with_replacement(list(range(1, M+1)), N):
ans = max(ans, sum(d for a, b, c, d in l if A[b-1]-A[a-1]==c))
print(ans)
| 11 | 7 | 337 | 295 | from itertools import combinations_with_replacement
N, M, Q = list(map(int, input().split()))
l = [tuple(map(int, input().split())) for _ in range(Q)]
ans = 0
for A in combinations_with_replacement(list(range(1, M + 1)), N):
v = 0
for a, b, c, d in l:
if A[b - 1] - A[a - 1] == c:
v += d
... | from itertools import combinations_with_replacement
N, M, Q = list(map(int, input().split()))
l = [tuple(map(int, input().split())) for _ in range(Q)]
ans = 0
for A in combinations_with_replacement(list(range(1, M + 1)), N):
ans = max(ans, sum(d for a, b, c, d in l if A[b - 1] - A[a - 1] == c))
print(ans)
| false | 36.363636 | [
"- v = 0",
"- for a, b, c, d in l:",
"- if A[b - 1] - A[a - 1] == c:",
"- v += d",
"- ans = max(ans, v)",
"+ ans = max(ans, sum(d for a, b, c, d in l if A[b - 1] - A[a - 1] == c))"
] | false | 0.236641 | 0.157454 | 1.502925 | [
"s874267351",
"s961873780"
] |
u790710233 | p03804 | python | s434232109 | s391781484 | 24 | 20 | 3,060 | 3,064 | Accepted | Accepted | 16.67 | n, m = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(n)]
b = [list(eval(input())) for _ in range(m)]
for i in range(n):
for j in range(n):
if j+m <= n and i+m <= n:
if [a[i+k][j:j+m] for k in range(m)] == b:
print('Yes')
exit()
... | n, m = list(map(int, input().split()))
a = [eval(input()) for _ in range(n)]
b = [eval(input()) for _ in range(m)]
for i in range(n):
for j in range(n):
if a[i][j] == b[0][0]:
if j+m <= n and i+m <= n:
if [a[i+k][j:j+m] for k in range(m)] == b:
print... | 12 | 13 | 326 | 362 | n, m = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(n)]
b = [list(eval(input())) for _ in range(m)]
for i in range(n):
for j in range(n):
if j + m <= n and i + m <= n:
if [a[i + k][j : j + m] for k in range(m)] == b:
print("Yes")
exit()
... | n, m = list(map(int, input().split()))
a = [eval(input()) for _ in range(n)]
b = [eval(input()) for _ in range(m)]
for i in range(n):
for j in range(n):
if a[i][j] == b[0][0]:
if j + m <= n and i + m <= n:
if [a[i + k][j : j + m] for k in range(m)] == b:
print... | false | 7.692308 | [
"-a = [list(eval(input())) for _ in range(n)]",
"-b = [list(eval(input())) for _ in range(m)]",
"+a = [eval(input()) for _ in range(n)]",
"+b = [eval(input()) for _ in range(m)]",
"- if j + m <= n and i + m <= n:",
"- if [a[i + k][j : j + m] for k in range(m)] == b:",
"- ... | false | 0.047862 | 0.046499 | 1.029325 | [
"s434232109",
"s391781484"
] |
u888092736 | p02572 | python | s930384176 | s651117335 | 175 | 160 | 31,764 | 31,268 | Accepted | Accepted | 8.57 | from itertools import accumulate
N, *A = list(map(int, open(0).read().split()))
MOD = 1_000_000_007
acc = list(accumulate(A, initial=0))
ans = 0
for i in range(1, N):
ans += A[i - 1] * (acc[N] - acc[i])
ans %= MOD
print(ans)
| from itertools import accumulate
N = int(eval(input()))
A = list(map(int, input().split()))
MOD = 1_000_000_007
acc = list(accumulate(A, initial=0))
ans = 0
for i in range(N):
ans += A[i] * (acc[N] - acc[i + 1])
ans %= MOD
print(ans)
| 12 | 13 | 241 | 251 | from itertools import accumulate
N, *A = list(map(int, open(0).read().split()))
MOD = 1_000_000_007
acc = list(accumulate(A, initial=0))
ans = 0
for i in range(1, N):
ans += A[i - 1] * (acc[N] - acc[i])
ans %= MOD
print(ans)
| from itertools import accumulate
N = int(eval(input()))
A = list(map(int, input().split()))
MOD = 1_000_000_007
acc = list(accumulate(A, initial=0))
ans = 0
for i in range(N):
ans += A[i] * (acc[N] - acc[i + 1])
ans %= MOD
print(ans)
| false | 7.692308 | [
"-N, *A = list(map(int, open(0).read().split()))",
"+N = int(eval(input()))",
"+A = list(map(int, input().split()))",
"-for i in range(1, N):",
"- ans += A[i - 1] * (acc[N] - acc[i])",
"+for i in range(N):",
"+ ans += A[i] * (acc[N] - acc[i + 1])"
] | false | 0.048024 | 0.038222 | 1.25645 | [
"s930384176",
"s651117335"
] |
u347640436 | p02973 | python | s754346449 | s291214538 | 257 | 229 | 8,828 | 11,756 | Accepted | Accepted | 10.89 | from collections import deque
from bisect import bisect_left
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
t = deque([A[0]])
for a in A[1:]:
if a <= t[0]:
t.appendleft(a)
else:
t[bisect_left(t, a) - 1] = a
print((len(t)))
| from bisect import bisect_right
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
t = [-A[0]]
for a in A[1:]:
if a <= -t[-1]:
t.append(-a)
else:
t[bisect_right(t, -a)] = -a
print((len(t)))
| 13 | 12 | 266 | 228 | from collections import deque
from bisect import bisect_left
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
t = deque([A[0]])
for a in A[1:]:
if a <= t[0]:
t.appendleft(a)
else:
t[bisect_left(t, a) - 1] = a
print((len(t)))
| from bisect import bisect_right
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
t = [-A[0]]
for a in A[1:]:
if a <= -t[-1]:
t.append(-a)
else:
t[bisect_right(t, -a)] = -a
print((len(t)))
| false | 7.692308 | [
"-from collections import deque",
"-from bisect import bisect_left",
"+from bisect import bisect_right",
"-t = deque([A[0]])",
"+t = [-A[0]]",
"- if a <= t[0]:",
"- t.appendleft(a)",
"+ if a <= -t[-1]:",
"+ t.append(-a)",
"- t[bisect_left(t, a) - 1] = a",
"+ t[b... | false | 0.035727 | 0.037322 | 0.957272 | [
"s754346449",
"s291214538"
] |
u124498235 | p03417 | python | s534435093 | s048271128 | 23 | 17 | 3,060 | 3,060 | Accepted | Accepted | 26.09 | n, m = list(map(int, input().split()))
if n == 1 and m == 1:
print((1))
elif n == 1:
print((m-2))
elif m == 1:
print((n-2))
else:
print(((m-2)*(n-2))) | n, m = list(map(int, input().split()))
if n == 1 and m == 1:
print((1))
exit()
if n == 1 or m == 1:
print((max(max(n,m)-2,0)))
elif n == 2 or m == 2:
print((0))
else:
print(((n-2)*(m-2)))
| 9 | 11 | 152 | 194 | n, m = list(map(int, input().split()))
if n == 1 and m == 1:
print((1))
elif n == 1:
print((m - 2))
elif m == 1:
print((n - 2))
else:
print(((m - 2) * (n - 2)))
| n, m = list(map(int, input().split()))
if n == 1 and m == 1:
print((1))
exit()
if n == 1 or m == 1:
print((max(max(n, m) - 2, 0)))
elif n == 2 or m == 2:
print((0))
else:
print(((n - 2) * (m - 2)))
| false | 18.181818 | [
"-elif n == 1:",
"- print((m - 2))",
"-elif m == 1:",
"- print((n - 2))",
"+ exit()",
"+if n == 1 or m == 1:",
"+ print((max(max(n, m) - 2, 0)))",
"+elif n == 2 or m == 2:",
"+ print((0))",
"- print(((m - 2) * (n - 2)))",
"+ print(((n - 2) * (m - 2)))"
] | false | 0.082667 | 0.039737 | 2.080347 | [
"s534435093",
"s048271128"
] |
u439396449 | p04013 | python | s034740150 | s577037004 | 279 | 221 | 5,972 | 21,156 | Accepted | Accepted | 20.79 | from itertools import product
N, A = list(map(int, input().split()))
x = [int(x) for x in input().split()]
X = max(max(x), A)
dp = [[0 for _ in range(2 * N * X + 1)] for _ in range(N + 1)]
dp[0][N * X] = 1
for j, t in product(list(range(1, N + 1)), list(range(2 * N * X + 1))):
y = x[j - 1] - A
if ... | from collections import defaultdict
N, A = list(map(int, input().split()))
x = [int(x) for x in input().split()]
for i in range(N):
x[i] -= A
X = max(max(x), A)
dp = [defaultdict(int) for _ in range(N + 1)]
dp[0][0] = 1
for i in range(N):
for j in range(-N * X, N * X + 1):
if - N * X <= ... | 16 | 18 | 478 | 461 | from itertools import product
N, A = list(map(int, input().split()))
x = [int(x) for x in input().split()]
X = max(max(x), A)
dp = [[0 for _ in range(2 * N * X + 1)] for _ in range(N + 1)]
dp[0][N * X] = 1
for j, t in product(list(range(1, N + 1)), list(range(2 * N * X + 1))):
y = x[j - 1] - A
if t - y < 0 or ... | from collections import defaultdict
N, A = list(map(int, input().split()))
x = [int(x) for x in input().split()]
for i in range(N):
x[i] -= A
X = max(max(x), A)
dp = [defaultdict(int) for _ in range(N + 1)]
dp[0][0] = 1
for i in range(N):
for j in range(-N * X, N * X + 1):
if -N * X <= j - x[i] <= N * ... | false | 11.111111 | [
"-from itertools import product",
"+from collections import defaultdict",
"+for i in range(N):",
"+ x[i] -= A",
"-dp = [[0 for _ in range(2 * N * X + 1)] for _ in range(N + 1)]",
"-dp[0][N * X] = 1",
"-for j, t in product(list(range(1, N + 1)), list(range(2 * N * X + 1))):",
"- y = x[j - 1] - A"... | false | 0.043278 | 0.039874 | 1.085371 | [
"s034740150",
"s577037004"
] |
u281303342 | p03634 | python | s402945772 | s064556406 | 1,400 | 1,080 | 131,632 | 146,028 | Accepted | Accepted | 22.86 | import sys
sys.setrecursionlimit(1000000)
N = int(eval(input()))
X = [[] for _ in range(N)]
for i in range(N-1):
a,b,c = list(map(int,input().split()))
X[a-1].append((b-1,c))
X[b-1].append((a-1,c))
cost = [-1]*N
def calc(i,c):
# 指定の頂点までのコストを代入
cost[i] = c
# 頂点から移動できる頂点があれば
... | import sys
sys.setrecursionlimit(1000000)
def dfs(n,p,d):
visited[n] = True
dist[n] = d
for (i,c) in A[n]:
if i != p and not visited[i]:
dfs(i,n,d+c)
N = int(eval(input()))
A = [[] for _ in range(N)]
for _ in range(N-1):
a,b,c = list(map(int,input().split()))
A[a-... | 29 | 29 | 553 | 577 | import sys
sys.setrecursionlimit(1000000)
N = int(eval(input()))
X = [[] for _ in range(N)]
for i in range(N - 1):
a, b, c = list(map(int, input().split()))
X[a - 1].append((b - 1, c))
X[b - 1].append((a - 1, c))
cost = [-1] * N
def calc(i, c):
# 指定の頂点までのコストを代入
cost[i] = c
# 頂点から移動できる頂点があれば
... | import sys
sys.setrecursionlimit(1000000)
def dfs(n, p, d):
visited[n] = True
dist[n] = d
for (i, c) in A[n]:
if i != p and not visited[i]:
dfs(i, n, d + c)
N = int(eval(input()))
A = [[] for _ in range(N)]
for _ in range(N - 1):
a, b, c = list(map(int, input().split()))
A[a... | false | 0 | [
"-N = int(eval(input()))",
"-X = [[] for _ in range(N)]",
"-for i in range(N - 1):",
"- a, b, c = list(map(int, input().split()))",
"- X[a - 1].append((b - 1, c))",
"- X[b - 1].append((a - 1, c))",
"-cost = [-1] * N",
"-def calc(i, c):",
"- # 指定の頂点までのコストを代入",
"- cost[i] = c",
"- ... | false | 0.036758 | 0.03836 | 0.958238 | [
"s402945772",
"s064556406"
] |
u186838327 | p03634 | python | s596760087 | s713510094 | 745 | 660 | 80,304 | 76,464 | Accepted | Accepted | 11.41 | import sys
input = sys.stdin.readline
n =int(eval(input()))
edge = [[] for _ in range(n)]
for i in range(n-1):
a, b, c = list(map(int, input().split()))
a, b = a-1, b-1
edge[a].append((c, b))
edge[b].append((c, a))
q, k = list(map(int, input().split()))
k -= 1
import heapq
INF = 10**18... | import sys
input = sys.stdin.buffer.readline
n = int(eval(input()))
edge = [[] for _ in range(n)]
for i in range(n-1):
a,b,c = list(map(int, input().split()))
a, b = a-1, b-1
edge[a].append((c, b))
edge[b].append((c, a))
q, k = list(map(int, input().split()))
k -= 1
import heapq
INF = ... | 43 | 41 | 976 | 975 | import sys
input = sys.stdin.readline
n = int(eval(input()))
edge = [[] for _ in range(n)]
for i in range(n - 1):
a, b, c = list(map(int, input().split()))
a, b = a - 1, b - 1
edge[a].append((c, b))
edge[b].append((c, a))
q, k = list(map(int, input().split()))
k -= 1
import heapq
INF = 10**18
def di... | import sys
input = sys.stdin.buffer.readline
n = int(eval(input()))
edge = [[] for _ in range(n)]
for i in range(n - 1):
a, b, c = list(map(int, input().split()))
a, b = a - 1, b - 1
edge[a].append((c, b))
edge[b].append((c, a))
q, k = list(map(int, input().split()))
k -= 1
import heapq
INF = 10**18
... | false | 4.651163 | [
"-input = sys.stdin.readline",
"+input = sys.stdin.buffer.readline",
"-def dijkstra_heap(s, edge):",
"+def dijkstra_heap(s, edge, n):",
"-d = dijkstra_heap(k, edge)",
"-# print(d)",
"+d = dijkstra_heap(k, edge, n)"
] | false | 0.043306 | 0.120521 | 0.359325 | [
"s596760087",
"s713510094"
] |
u779805689 | p02620 | python | s828653806 | s818419823 | 574 | 515 | 84,832 | 76,536 | Accepted | Accepted | 10.28 | def f(a,d,T):
try:
return T[d:].index(a)+d
except ValueError:
return len(T)
from random import randint
A=26
D=int(eval(input()))
C=[0]+list(map(int,input().split())) #減る満足度のベース
S=[0]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度
for i in range(1,D+1):
S[i]=[0]+list(map(int,inpu... | def f(a,d,T):
try:
return T[d+1:].index(a)+(d+1)
except ValueError:
return len(T)
def g(a,d,T):
try:
return T[:d].index(a)
except ValueError:
return 0
A=26
D=int(eval(input()))
C=[0]+list(map(int,input().split())) #減る満足度のベース
S=[0]*(D+1) #S[d][i] :(d+1... | 63 | 61 | 1,110 | 1,117 | def f(a, d, T):
try:
return T[d:].index(a) + d
except ValueError:
return len(T)
from random import randint
A = 26
D = int(eval(input()))
C = [0] + list(map(int, input().split())) # 減る満足度のベース
S = [0] * (D + 1) # S[d][i] :(d+1)日目にコンテストiを開催した時の満足度
for i in range(1, D + 1):
S[i] = [0] + lis... | def f(a, d, T):
try:
return T[d + 1 :].index(a) + (d + 1)
except ValueError:
return len(T)
def g(a, d, T):
try:
return T[:d].index(a)
except ValueError:
return 0
A = 26
D = int(eval(input()))
C = [0] + list(map(int, input().split())) # 減る満足度のベース
S = [0] * (D + 1) # ... | false | 3.174603 | [
"- return T[d:].index(a) + d",
"+ return T[d + 1 :].index(a) + (d + 1)",
"-from random import randint",
"+def g(a, d, T):",
"+ try:",
"+ return T[:d].index(a)",
"+ except ValueError:",
"+ return 0",
"+",
"-L = [[0] * (A + 1) for _ in range(D + 1)]",
"-for x in r... | false | 0.12143 | 0.050809 | 2.389909 | [
"s828653806",
"s818419823"
] |
u572122511 | p02694 | python | s060607851 | s255744351 | 23 | 20 | 9,168 | 9,164 | Accepted | Accepted | 13.04 | X = int(eval(input()))
save = 100
count = 0
while save < X:
save += int(save * 0.01)
count += 1
print(count) | X = int(eval(input()))
m = 100
count = 0
while m < X:
m *= 1.01
m = int(m)
count += 1
print(count) | 8 | 9 | 122 | 113 | X = int(eval(input()))
save = 100
count = 0
while save < X:
save += int(save * 0.01)
count += 1
print(count)
| X = int(eval(input()))
m = 100
count = 0
while m < X:
m *= 1.01
m = int(m)
count += 1
print(count)
| false | 11.111111 | [
"-save = 100",
"+m = 100",
"-while save < X:",
"- save += int(save * 0.01)",
"+while m < X:",
"+ m *= 1.01",
"+ m = int(m)"
] | false | 0.038445 | 0.037802 | 1.01702 | [
"s060607851",
"s255744351"
] |
u477977638 | p02865 | python | s851081623 | s727823644 | 164 | 65 | 38,384 | 61,928 | Accepted | Accepted | 60.37 | import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')
import math
#import numpy as np
#import operator
#import bisect
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collecti... | import sys
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(map(float,input().split()))
def LI(): return list(map(int,in... | 39 | 30 | 896 | 539 | import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines
# rstrip().decode('utf-8')
import math
# import numpy as np
# import operator
# import bisect
# from heapq import heapify,heappop,heappush
# from math import gcd
# from fractions import gcd
# from collections... | import sys
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(map(float, input().split()))
def LI():
r... | false | 23.076923 | [
"-read = sys.stdin.buffer.read",
"-inputs = sys.stdin.buffer.readlines",
"-# rstrip().decode('utf-8')",
"-import math",
"+# sys.setrecursionlimit(10**9)",
"+# from functools import lru_cache",
"+def RD():",
"+ return sys.stdin.read()",
"-# import numpy as np",
"-# import operator",
"-# import... | false | 0.045353 | 0.117431 | 0.386214 | [
"s851081623",
"s727823644"
] |
u860002137 | p02735 | python | s928611467 | s384087652 | 205 | 39 | 42,352 | 3,188 | Accepted | Accepted | 80.98 | from collections import deque
h, w = list(map(int, input().split()))
s = [list(map(str, input().rstrip())) for _ in range(h)]
dp = [[10001] * w for _ in range(h)]
if s[0][0] == "#":
dp[0][0] = 1
else:
dp[0][0] = 0
moves = [[1, 0], [0, 1]]
for y in range(h):
for x in range(w):
fo... | h, w = list(map(int, input().split()))
s = [list(map(str, input().rstrip())) for _ in range(h)]
dp = [[10001] * w for _ in range(h)]
if s[0][0] == "#":
dp[0][0] = 1
else:
dp[0][0] = 0
moves = [[1, 0], [0, 1]]
for y in range(h):
for x in range(w):
for m in moves:
ny, nx... | 27 | 25 | 644 | 611 | from collections import deque
h, w = list(map(int, input().split()))
s = [list(map(str, input().rstrip())) for _ in range(h)]
dp = [[10001] * w for _ in range(h)]
if s[0][0] == "#":
dp[0][0] = 1
else:
dp[0][0] = 0
moves = [[1, 0], [0, 1]]
for y in range(h):
for x in range(w):
for m in moves:
... | h, w = list(map(int, input().split()))
s = [list(map(str, input().rstrip())) for _ in range(h)]
dp = [[10001] * w for _ in range(h)]
if s[0][0] == "#":
dp[0][0] = 1
else:
dp[0][0] = 0
moves = [[1, 0], [0, 1]]
for y in range(h):
for x in range(w):
for m in moves:
ny, nx = y + m[0], x + m[... | false | 7.407407 | [
"-from collections import deque",
"-"
] | false | 0.052374 | 0.035927 | 1.457785 | [
"s928611467",
"s384087652"
] |
u090068671 | p02642 | python | s493559920 | s499728455 | 861 | 604 | 100,864 | 99,944 | Accepted | Accepted | 29.85 | from collections import defaultdict
def resolve():
N = int(eval(input()))
A = list(map(int, input().split()))
a_max = max(A)+1
B = defaultdict(int)
for i in range(N):
a = A[i]
if B[a]>1:
B[a] = 2
else:
for j in range(a, a_max, a):
B[j] += 1
Y = 0
for a in A:
if B[a]==1:
Y+=... | def resolve():
N = int(eval(input()))
A = list(map(int, input().split()))
a_max = max(A)+1
B = {}
for i in range(N):
a = A[i]
if a not in list(B.keys()):
for j in range(a, a_max, a):
B[j] = False
B[a] = True
else:
B[a] = False
Y = list(B.values()).count(True)
print(Y)
resolve() | 20 | 16 | 337 | 307 | from collections import defaultdict
def resolve():
N = int(eval(input()))
A = list(map(int, input().split()))
a_max = max(A) + 1
B = defaultdict(int)
for i in range(N):
a = A[i]
if B[a] > 1:
B[a] = 2
else:
for j in range(a, a_max, a):
... | def resolve():
N = int(eval(input()))
A = list(map(int, input().split()))
a_max = max(A) + 1
B = {}
for i in range(N):
a = A[i]
if a not in list(B.keys()):
for j in range(a, a_max, a):
B[j] = False
B[a] = True
else:
B[a] = F... | false | 20 | [
"-from collections import defaultdict",
"-",
"-",
"- B = defaultdict(int)",
"+ B = {}",
"- if B[a] > 1:",
"- B[a] = 2",
"+ if a not in list(B.keys()):",
"+ for j in range(a, a_max, a):",
"+ B[j] = False",
"+ B[a] = True",
"- ... | false | 0.043793 | 0.038161 | 1.147583 | [
"s493559920",
"s499728455"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.