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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u317423698 | p02732 | python | s778252123 | s083390161 | 316 | 194 | 40,864 | 32,196 | Accepted | Accepted | 38.61 | import sys
from collections import Counter
from functools import lru_cache
c = None
@lru_cache(maxsize=200000)
def _num_of_ways_to_choose(x):
v = c[x]
return (v * (v - 1)) // 2
def resolve(in_, out):
n = int(in_.readline())
a = tuple(map(int, in_.readline().split()))
global c
... | import sys
from collections import Counter
c = None
def resolve(in_, out):
n = int(in_.readline())
a = tuple(map(int, in_.readline().split()))
c = dict(Counter(a))
total = sum(v * (v - 1) // 2 for v in c.values())
for ai in a:
ans = total - (c[ai] - 1)
print(ans, ... | 32 | 24 | 681 | 434 | import sys
from collections import Counter
from functools import lru_cache
c = None
@lru_cache(maxsize=200000)
def _num_of_ways_to_choose(x):
v = c[x]
return (v * (v - 1)) // 2
def resolve(in_, out):
n = int(in_.readline())
a = tuple(map(int, in_.readline().split()))
global c
c = dict(Count... | import sys
from collections import Counter
c = None
def resolve(in_, out):
n = int(in_.readline())
a = tuple(map(int, in_.readline().split()))
c = dict(Counter(a))
total = sum(v * (v - 1) // 2 for v in c.values())
for ai in a:
ans = total - (c[ai] - 1)
print(ans, file=out)
def m... | false | 25 | [
"-from functools import lru_cache",
"-",
"-",
"-@lru_cache(maxsize=200000)",
"-def _num_of_ways_to_choose(x):",
"- v = c[x]",
"- return (v * (v - 1)) // 2",
"- global c",
"- _num_of_ways_to_choose.cache_clear()",
"- total = sum(map(_num_of_ways_to_choose, c.keys()))",
"+ total ... | false | 0.103405 | 0.108836 | 0.950101 | [
"s778252123",
"s083390161"
] |
u163320134 | p02632 | python | s387846324 | s150296080 | 1,531 | 1,395 | 227,552 | 241,796 | Accepted | Accepted | 8.88 | mod=10**9+7
k=int(eval(input()))
s=eval(input())
l=len(s)
fact=[1]
for i in range(1,k+l+1):
fact.append((fact[-1]*i)%mod)
revfact=[]
for i in range(k+l+1):
revfact.append(pow(fact[i],mod-2,mod))
pow1=[1]
pow2=[1]
for i in range(1,k+l+1):
pow1.append((pow1[-1]*25)%mod)
pow2.append((pow2[-1]*26)%mod... | mod=10**9+7
k=int(eval(input()))
s=eval(input())
l=len(s)
fact=[1]
for i in range(1,k+l+1):
fact.append((fact[-1]*i)%mod)
revfact=[]
for i in range(k+l+1):
revfact.append(pow(fact[i],mod-2,mod))
pows=[1]
for i in range(1,k+l+1):
pows.append((pows[-1]*25)%mod)
ans=0
for i in range(l,l+k+1):
ans+=f... | 25 | 18 | 506 | 378 | mod = 10**9 + 7
k = int(eval(input()))
s = eval(input())
l = len(s)
fact = [1]
for i in range(1, k + l + 1):
fact.append((fact[-1] * i) % mod)
revfact = []
for i in range(k + l + 1):
revfact.append(pow(fact[i], mod - 2, mod))
pow1 = [1]
pow2 = [1]
for i in range(1, k + l + 1):
pow1.append((pow1[-1] * 25) % ... | mod = 10**9 + 7
k = int(eval(input()))
s = eval(input())
l = len(s)
fact = [1]
for i in range(1, k + l + 1):
fact.append((fact[-1] * i) % mod)
revfact = []
for i in range(k + l + 1):
revfact.append(pow(fact[i], mod - 2, mod))
pows = [1]
for i in range(1, k + l + 1):
pows.append((pows[-1] * 25) % mod)
ans = ... | false | 28 | [
"-pow1 = [1]",
"-pow2 = [1]",
"+pows = [1]",
"- pow1.append((pow1[-1] * 25) % mod)",
"- pow2.append((pow2[-1] * 26) % mod)",
"+ pows.append((pows[-1] * 25) % mod)",
"-for i in range(k + l):",
"- coef1 = (pow1[k - i] * pow2[i]) % mod",
"- if i <= k:",
"- coef2 = (fact[k + l - ... | false | 0.040373 | 0.039864 | 1.01276 | [
"s387846324",
"s150296080"
] |
u994988729 | p03450 | python | s537285540 | s640632665 | 1,224 | 909 | 69,572 | 69,636 | Accepted | Accepted | 25.74 | N, M = list(map(int, input().split()))
e_IN = [[] for _ in range(N+1)]
e_OUT = [[] for _ in range(N+1)]
for _ in range(M):
l, r, d = list(map(int, input().split()))
e_OUT[l].append((r, d))
e_IN[r].append((l, d))
posx = [-1] * (N + 1)
def dfs(v):
# 0<=x<=10**9に注意
node = [v]
p... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
N, M = list(map(int, readline().split()))
e_IN = [[] for _ in range(N+1)]
e_OUT = [[] for _ in range(N+1)]
for _ in range(M):
l, r, d = list(map(int, read... | 50 | 56 | 1,020 | 1,179 | N, M = list(map(int, input().split()))
e_IN = [[] for _ in range(N + 1)]
e_OUT = [[] for _ in range(N + 1)]
for _ in range(M):
l, r, d = list(map(int, input().split()))
e_OUT[l].append((r, d))
e_IN[r].append((l, d))
posx = [-1] * (N + 1)
def dfs(v):
# 0<=x<=10**9に注意
node = [v]
posx[v] = 0
... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
N, M = list(map(int, readline().split()))
e_IN = [[] for _ in range(N + 1)]
e_OUT = [[] for _ in range(N + 1)]
for _ in range(M):
l, r, d = list(map(int, readline().split... | false | 10.714286 | [
"-N, M = list(map(int, input().split()))",
"+import sys",
"+",
"+read = sys.stdin.buffer.read",
"+readline = sys.stdin.buffer.readline",
"+readlines = sys.stdin.buffer.readlines",
"+sys.setrecursionlimit(10**7)",
"+N, M = list(map(int, readline().split()))",
"- l, r, d = list(map(int, input().spl... | false | 0.094284 | 0.038138 | 2.472199 | [
"s537285540",
"s640632665"
] |
u609061751 | p03033 | python | s188711126 | s405322120 | 1,885 | 1,633 | 69,600 | 69,604 | Accepted | Accepted | 13.37 | import sys
input = lambda : sys.stdin.readline().rstrip()
from heapq import heappush, heappop
running = []
events = []
delete = set()
n, q = list(map(int, input().split()))
for _ in range(n):
s, t, x = list(map(int, input().split()))
time = max(s - x, 0)
if t - x < 0:
continue
... | def main():
import sys
input = lambda : sys.stdin.readline().rstrip()
from heapq import heappush, heappop
running = []
events = []
delete = set()
n, q = list(map(int, input().split()))
for _ in range(n):
s, t, x = list(map(int, input().split()))
time = ma... | 44 | 48 | 1,040 | 1,203 | import sys
input = lambda: sys.stdin.readline().rstrip()
from heapq import heappush, heappop
running = []
events = []
delete = set()
n, q = list(map(int, input().split()))
for _ in range(n):
s, t, x = list(map(int, input().split()))
time = max(s - x, 0)
if t - x < 0:
continue
events.append((s ... | def main():
import sys
input = lambda: sys.stdin.readline().rstrip()
from heapq import heappush, heappop
running = []
events = []
delete = set()
n, q = list(map(int, input().split()))
for _ in range(n):
s, t, x = list(map(int, input().split()))
time = max(s - x, 0)
... | false | 8.333333 | [
"-import sys",
"+def main():",
"+ import sys",
"-input = lambda: sys.stdin.readline().rstrip()",
"-from heapq import heappush, heappop",
"+ input = lambda: sys.stdin.readline().rstrip()",
"+ from heapq import heappush, heappop",
"-running = []",
"-events = []",
"-delete = set()",
"-n, q... | false | 0.046404 | 0.045978 | 1.009277 | [
"s188711126",
"s405322120"
] |
u992910889 | p03546 | python | s595410889 | s234950282 | 197 | 33 | 14,644 | 3,444 | Accepted | Accepted | 83.25 | from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()
def resolve():
H, W = list(map(int, input().split()))
graph = [[i for i in list(map(int, input().split()))] for... | import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()
def resolve():
# 最短経路問題で使われるアルゴリズムの1つ。
# グラフ上の全ての頂点間の最短経路を探す
# 負の閉路(辺の重みの和が負になるような閉路)がない限り、負の辺があっても使える。
# 負の閉路を持つ場合は'NEGATIVE CYCLE'を、そうでない場合には(i,j)成分に
# 頂点iから頂点jへの最短経路の距離を格納するdist_lis... | 32 | 63 | 787 | 1,867 | from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
import sys
sys.setrecursionlimit(10**5 + 10)
def input():
return sys.stdin.readline().strip()
def resolve():
H, W = list(map(int, input().split()))
graph = [[i for i in list(map(int, input().split()))] for _ in range(10... | import sys
sys.setrecursionlimit(10**5 + 10)
def input():
return sys.stdin.readline().strip()
def resolve():
# 最短経路問題で使われるアルゴリズムの1つ。
# グラフ上の全ての頂点間の最短経路を探す
# 負の閉路(辺の重みの和が負になるような閉路)がない限り、負の辺があっても使える。
# 負の閉路を持つ場合は'NEGATIVE CYCLE'を、そうでない場合には(i,j)成分に
# 頂点iから頂点jへの最短経路の距離を格納するdist_listをprintする関数
... | false | 49.206349 | [
"-from scipy.sparse import csr_matrix",
"-from scipy.sparse.csgraph import floyd_warshall",
"+ # 最短経路問題で使われるアルゴリズムの1つ。",
"+ # グラフ上の全ての頂点間の最短経路を探す",
"+ # 負の閉路(辺の重みの和が負になるような閉路)がない限り、負の辺があっても使える。",
"+ # 負の閉路を持つ場合は'NEGATIVE CYCLE'を、そうでない場合には(i,j)成分に",
"+ # 頂点iから頂点jへの最短経路の距離を格納するdist_listをpri... | false | 0.568569 | 0.043032 | 13.212777 | [
"s595410889",
"s234950282"
] |
u517910772 | p04045 | python | s516519647 | s888813293 | 66 | 59 | 3,060 | 2,940 | Accepted | Accepted | 10.61 | numbers = {str(i) for i in range(10)}
N, K = list(map(int, input().split()))
*D, = list(map(str, input().split()))
D = set(D)
available = numbers - D
ans = 0
for i in range(N, 100000):
nums = set(str(i))
if nums <= available:
print(i)
break
| def problem_c():
N, K = list(map(int, input().split()))
D = list(map(str, input().split()))
numbers = {str(i) for i in range(10)}
availables = set(numbers) - set(D)
for i in range(N, 100000):
nums = set(str(i))
if nums <= availables:
print(i)
return... | 11 | 14 | 263 | 342 | numbers = {str(i) for i in range(10)}
N, K = list(map(int, input().split()))
(*D,) = list(map(str, input().split()))
D = set(D)
available = numbers - D
ans = 0
for i in range(N, 100000):
nums = set(str(i))
if nums <= available:
print(i)
break
| def problem_c():
N, K = list(map(int, input().split()))
D = list(map(str, input().split()))
numbers = {str(i) for i in range(10)}
availables = set(numbers) - set(D)
for i in range(N, 100000):
nums = set(str(i))
if nums <= availables:
print(i)
return
########... | false | 21.428571 | [
"-numbers = {str(i) for i in range(10)}",
"-N, K = list(map(int, input().split()))",
"-(*D,) = list(map(str, input().split()))",
"-D = set(D)",
"-available = numbers - D",
"-ans = 0",
"-for i in range(N, 100000):",
"- nums = set(str(i))",
"- if nums <= available:",
"- print(i)",
"- ... | false | 0.116699 | 0.048419 | 2.4102 | [
"s516519647",
"s888813293"
] |
u367130284 | p02949 | python | s390815377 | s126011158 | 1,480 | 944 | 50,140 | 46,920 | Accepted | Accepted | 36.22 | import sys
input=sys.stdin.readline #危険!基本オフにしろ!
def BELLMANFORD(point,n,d,p):
cost = [-float("inf")]*(n+1) #infじゃないと閉路検出がうまくいかない
cost[point]= 0
for i in range(n-1): #経路の長さは最大n-1であるため
for now,lis in list(d.items()):
for nex,c in lis:
... | import sys
input=sys.stdin.readline #危険!基本オフにしろ!
def BELLMANFORD(point,n,d,p):
cost = [-float("inf")]*(n+1) #infじゃないと閉路検出がうまくいかない
cost[point]= 0
for i in range(n-1): #経路の長さは最大n-1であるため
for nownode,nextnode,c in d:
if cost[nextnode]<cost[no... | 46 | 38 | 1,247 | 1,100 | import sys
input = sys.stdin.readline # 危険!基本オフにしろ!
def BELLMANFORD(point, n, d, p):
cost = [-float("inf")] * (n + 1) # infじゃないと閉路検出がうまくいかない
cost[point] = 0
for i in range(n - 1): # 経路の長さは最大n-1であるため
for now, lis in list(d.items()):
for nex, c in lis:
if cost[nex] < ... | import sys
input = sys.stdin.readline # 危険!基本オフにしろ!
def BELLMANFORD(point, n, d, p):
cost = [-float("inf")] * (n + 1) # infじゃないと閉路検出がうまくいかない
cost[point] = 0
for i in range(n - 1): # 経路の長さは最大n-1であるため
for nownode, nextnode, c in d:
if cost[nextnode] < cost[nownode] + c - p:
... | false | 17.391304 | [
"- for now, lis in list(d.items()):",
"- for nex, c in lis:",
"- if cost[nex] < cost[now] + c - p:",
"- cost[nex] = cost[now] + c - p",
"+ for nownode, nextnode, c in d:",
"+ if cost[nextnode] < cost[nownode] + c - p:",
"+ ... | false | 0.037971 | 0.037452 | 1.013849 | [
"s390815377",
"s126011158"
] |
u606045429 | p02834 | python | s701678020 | s071885652 | 362 | 311 | 32,500 | 31,732 | Accepted | Accepted | 14.09 | from collections import deque
N, T, A, *AB = list(map(int, open(0).read().split()))
E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
E[a].append(b)
E[b].append(a)
takahashi = [-1] * (N + 1)
takahashi[T] = 0
Q = deque([T])
while Q:
a = Q.popleft()
for b in E[a]:
... | from collections import deque
N, u, v, *AB = list(map(int, open(0).read().split()))
E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
E[a].append(b)
E[b].append(a)
def solve(s):
D = [-1] * (N + 1)
D[s] = 0
Q = deque([s])
while Q:
a = Q.popleft()
... | 37 | 28 | 737 | 540 | from collections import deque
N, T, A, *AB = list(map(int, open(0).read().split()))
E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
E[a].append(b)
E[b].append(a)
takahashi = [-1] * (N + 1)
takahashi[T] = 0
Q = deque([T])
while Q:
a = Q.popleft()
for b in E[a]:
if takahashi[b] !... | from collections import deque
N, u, v, *AB = list(map(int, open(0).read().split()))
E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
E[a].append(b)
E[b].append(a)
def solve(s):
D = [-1] * (N + 1)
D[s] = 0
Q = deque([s])
while Q:
a = Q.popleft()
for b in E[a]:
... | false | 24.324324 | [
"-N, T, A, *AB = list(map(int, open(0).read().split()))",
"+N, u, v, *AB = list(map(int, open(0).read().split()))",
"-takahashi = [-1] * (N + 1)",
"-takahashi[T] = 0",
"-Q = deque([T])",
"-while Q:",
"- a = Q.popleft()",
"- for b in E[a]:",
"- if takahashi[b] != -1:",
"- co... | false | 0.047053 | 0.036505 | 1.288941 | [
"s701678020",
"s071885652"
] |
u340781749 | p03295 | python | s749781064 | s854585960 | 740 | 424 | 33,868 | 17,016 | Accepted | Accepted | 42.7 | n, m = list(map(int, input().split()))
ab = []
for i in range(m):
a, b = list(map(int, input().split()))
ab.append((a - 1, 2, i))
ab.append((b - 1, 1, i))
ab.sort()
ans = 0
separated = [False] * m
buf = set()
for island, ab, i in ab:
if ab == 1:
if separated[i]:
contin... | n, m = list(map(int, input().split()))
disputes = []
for i in range(m):
a, b = list(map(int, input().split()))
disputes.append((b, a))
disputes.sort()
ans = 0
most_right_bridge = 0
for b, a in disputes:
if most_right_bridge <= a:
ans += 1
most_right_bridge = b
print(ans)
| 23 | 13 | 480 | 300 | n, m = list(map(int, input().split()))
ab = []
for i in range(m):
a, b = list(map(int, input().split()))
ab.append((a - 1, 2, i))
ab.append((b - 1, 1, i))
ab.sort()
ans = 0
separated = [False] * m
buf = set()
for island, ab, i in ab:
if ab == 1:
if separated[i]:
continue
else... | n, m = list(map(int, input().split()))
disputes = []
for i in range(m):
a, b = list(map(int, input().split()))
disputes.append((b, a))
disputes.sort()
ans = 0
most_right_bridge = 0
for b, a in disputes:
if most_right_bridge <= a:
ans += 1
most_right_bridge = b
print(ans)
| false | 43.478261 | [
"-ab = []",
"+disputes = []",
"- ab.append((a - 1, 2, i))",
"- ab.append((b - 1, 1, i))",
"-ab.sort()",
"+ disputes.append((b, a))",
"+disputes.sort()",
"-separated = [False] * m",
"-buf = set()",
"-for island, ab, i in ab:",
"- if ab == 1:",
"- if separated[i]:",
"- ... | false | 0.046914 | 0.046002 | 1.019829 | [
"s749781064",
"s854585960"
] |
u512212329 | p02837 | python | s382335135 | s960580520 | 1,206 | 377 | 3,064 | 3,064 | Accepted | Accepted | 68.74 | n = int(eval(input()))
g = [[-1] * n for _ in range(n)] # Graph for testimonies.
for i in range(n):
m = int(eval(input()))
for _ in range(m):
x, y = [int(z) for z in input().split()]
x -= 1 # Zero-indexed.
g[i][x] = y # Person i says that person x is honest or not.
ans = set... | def main():
n = int(eval(input()))
ttn = [[-1] * n for _ in range(n)] # Testimonies.
for i in range(n):
a = int(eval(input()))
for j in range(a):
x, y = [int(z) for z in input().split()]
x -= 1
ttn[i][x] = y # i says that x is honest guy or not.
... | 29 | 30 | 890 | 908 | n = int(eval(input()))
g = [[-1] * n for _ in range(n)] # Graph for testimonies.
for i in range(n):
m = int(eval(input()))
for _ in range(m):
x, y = [int(z) for z in input().split()]
x -= 1 # Zero-indexed.
g[i][x] = y # Person i says that person x is honest or not.
ans = set()
for bb ... | def main():
n = int(eval(input()))
ttn = [[-1] * n for _ in range(n)] # Testimonies.
for i in range(n):
a = int(eval(input()))
for j in range(a):
x, y = [int(z) for z in input().split()]
x -= 1
ttn[i][x] = y # i says that x is honest guy or not.
ans ... | false | 3.333333 | [
"-n = int(eval(input()))",
"-g = [[-1] * n for _ in range(n)] # Graph for testimonies.",
"-for i in range(n):",
"- m = int(eval(input()))",
"- for _ in range(m):",
"- x, y = [int(z) for z in input().split()]",
"- x -= 1 # Zero-indexed.",
"- g[i][x] = y # Person i says tha... | false | 0.046695 | 0.130196 | 0.358651 | [
"s382335135",
"s960580520"
] |
u600402037 | p02774 | python | s826162880 | s058518382 | 1,407 | 1,104 | 34,340 | 32,328 | Accepted | Accepted | 21.54 | # coding: utf-8
import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# neg, zero, posに分けて、二分探索
N, K = lr()
A = np.array(lr()); A.sort()
neg = A[A<0]
zero = A[A==0]
pos = A[A>0]
def check(x):
'''x以下の積がK個以上あるならTrue... | # coding: utf-8
import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# neg, zero, posに分けて、二分探索
N, K = lr()
A = np.array(lr()); A.sort()
neg = A[A<0]
zero = A[A==0]
pos = A[A>0]
def check(x):
'''x以下の積がK個以上あるならTrue... | 36 | 36 | 782 | 784 | # coding: utf-8
import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# neg, zero, posに分けて、二分探索
N, K = lr()
A = np.array(lr())
A.sort()
neg = A[A < 0]
zero = A[A == 0]
pos = A[A > 0]
def check(x):
"""x以下の積がK個以上あるならTrueを返す"""
... | # coding: utf-8
import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# neg, zero, posに分けて、二分探索
N, K = lr()
A = np.array(lr())
A.sort()
neg = A[A < 0]
zero = A[A == 0]
pos = A[A > 0]
def check(x):
"""x以下の積がK個以上あるならTrueを返す"""
... | false | 0 | [
"-ok = 10**20",
"-ng = -(10**20)",
"+ok = 10**18",
"+ng = -(10**18) - 1"
] | false | 0.284165 | 0.647556 | 0.438827 | [
"s826162880",
"s058518382"
] |
u297574184 | p03987 | python | s705097307 | s215093690 | 1,089 | 297 | 98,896 | 37,984 | Accepted | Accepted | 72.73 | class BIT_index:
def __init__(self, n):
self.BIT_prev = [n] * (n + 1)
self.BIT_next = [n] * (n + 1)
self.n = n
def __addElement(self, BIT, idx):
value = idx
idx += 1
while idx > 0:
BIT[idx] = min(BIT[idx], value)
idx -= idx & -i... | N = int(eval(input()))
As = list(map(int, input().split()))
iAs = [0] * (N + 1)
for i, A in enumerate(As):
iAs[A] = i
ans = 0
iLs = list(range(N + 1))
iRs = list(range(N + 1))
for A in reversed(list(range(1, N + 1))):
iA = iAs[A]
iL, iR = iLs[iA], iRs[iA]
ans += A * (iA - iL + 1) * (iR - ... | 46 | 18 | 1,182 | 374 | class BIT_index:
def __init__(self, n):
self.BIT_prev = [n] * (n + 1)
self.BIT_next = [n] * (n + 1)
self.n = n
def __addElement(self, BIT, idx):
value = idx
idx += 1
while idx > 0:
BIT[idx] = min(BIT[idx], value)
idx -= idx & -idx
def... | N = int(eval(input()))
As = list(map(int, input().split()))
iAs = [0] * (N + 1)
for i, A in enumerate(As):
iAs[A] = i
ans = 0
iLs = list(range(N + 1))
iRs = list(range(N + 1))
for A in reversed(list(range(1, N + 1))):
iA = iAs[A]
iL, iR = iLs[iA], iRs[iA]
ans += A * (iA - iL + 1) * (iR - iA + 1)
iLs... | false | 60.869565 | [
"-class BIT_index:",
"- def __init__(self, n):",
"- self.BIT_prev = [n] * (n + 1)",
"- self.BIT_next = [n] * (n + 1)",
"- self.n = n",
"-",
"- def __addElement(self, BIT, idx):",
"- value = idx",
"- idx += 1",
"- while idx > 0:",
"- BIT[... | false | 0.038249 | 0.034619 | 1.104849 | [
"s705097307",
"s215093690"
] |
u764604930 | p02701 | python | s990306807 | s044565832 | 289 | 263 | 35,520 | 35,704 | Accepted | Accepted | 9 | num=eval(input(""))
li=[]
while(num!=0):
li.append(eval(input()))
num-=1
a=set(li)
print((len(a))) | """write your code in method solve"""
def solve():
number=int(eval(input()))
items=[]
for i in range(number):
item=eval(input())
items.append(item)
a=set(items)
print((len(a)))
return
solve() | 7 | 13 | 100 | 234 | num = eval(input(""))
li = []
while num != 0:
li.append(eval(input()))
num -= 1
a = set(li)
print((len(a)))
| """write your code in method solve"""
def solve():
number = int(eval(input()))
items = []
for i in range(number):
item = eval(input())
items.append(item)
a = set(items)
print((len(a)))
return
solve()
| false | 46.153846 | [
"-num = eval(input(\"\"))",
"-li = []",
"-while num != 0:",
"- li.append(eval(input()))",
"- num -= 1",
"-a = set(li)",
"-print((len(a)))",
"+\"\"\"write your code in method solve\"\"\"",
"+",
"+",
"+def solve():",
"+ number = int(eval(input()))",
"+ items = []",
"+ for i in... | false | 0.046872 | 0.045354 | 1.033477 | [
"s990306807",
"s044565832"
] |
u596276291 | p03860 | python | s605009377 | s832393661 | 24 | 20 | 3,316 | 3,316 | Accepted | Accepted | 16.67 | from collections import defaultdict
def main():
S = eval(input())
print(("A{0}C".format(S.split()[1][0])))
if __name__ == '__main__':
main()
| from collections import defaultdict
def main():
print(("A{0}C".format(input().split()[1][0])))
if __name__ == '__main__':
main()
| 10 | 9 | 158 | 147 | from collections import defaultdict
def main():
S = eval(input())
print(("A{0}C".format(S.split()[1][0])))
if __name__ == "__main__":
main()
| from collections import defaultdict
def main():
print(("A{0}C".format(input().split()[1][0])))
if __name__ == "__main__":
main()
| false | 10 | [
"- S = eval(input())",
"- print((\"A{0}C\".format(S.split()[1][0])))",
"+ print((\"A{0}C\".format(input().split()[1][0])))"
] | false | 0.034979 | 0.039764 | 0.879673 | [
"s605009377",
"s832393661"
] |
u779455925 | p03078 | python | s673260521 | s917176202 | 733 | 471 | 148,240 | 82,388 | Accepted | Accepted | 35.74 | # input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
X,Y,Z,K=list(map(int,input().split()))
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)
lst=[]
for... | from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
from heapq import *
import copy
X,Y,Z,K=list(map(int,input().split()))
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sor... | 25 | 38 | 539 | 1,076 | # input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
X, Y, Z, K = list(map(int, input().split()))
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
lst ... | from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
from heapq import *
import copy
X, Y, Z, K = list(map(int, input().split()))
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C ... | false | 34.210526 | [
"-# input = sys.stdin.readline",
"+from fractions import gcd",
"+from math import factorial",
"+from itertools import *",
"+import copy",
"+dic = {A[0] + B[0] + C[0]: [\"0_0_0\"]}",
"+usedlst = set([\"0_0_0\"])",
"-for a in A:",
"- for b in B:",
"- lst.append(a + b)",
"-lst.sort(revers... | false | 0.060367 | 0.051714 | 1.167326 | [
"s673260521",
"s917176202"
] |
u284854859 | p03177 | python | s448643570 | s298984808 | 585 | 502 | 42,092 | 41,324 | Accepted | Accepted | 14.19 | import sys
input = sys.stdin.readline
def matDot(A,B,MOD):
N,M,L = len(A),len(A[0]),len(B[0])
res = [[0]*L for i in range(N)]
for i in range(N):
for j in range(L):
s = 0
for k in range(M):
s = (s + A[i][k]*B[k][j]) % MOD
res[i][... | import sys
input = sys.stdin.readline
def matDot(A,B,MOD):
N,M,L = len(A),len(A[0]),len(B[0])
res = [[0]*L for i in range(N)]
for i in range(N):
for j in range(L):
s = 0
for k in range(M):
s = (s + A[i][k]*B[k][j]) % MOD
res[i][... | 46 | 50 | 884 | 982 | import sys
input = sys.stdin.readline
def matDot(A, B, MOD):
N, M, L = len(A), len(A[0]), len(B[0])
res = [[0] * L for i in range(N)]
for i in range(N):
for j in range(L):
s = 0
for k in range(M):
s = (s + A[i][k] * B[k][j]) % MOD
res[i][j] = s
... | import sys
input = sys.stdin.readline
def matDot(A, B, MOD):
N, M, L = len(A), len(A[0]), len(B[0])
res = [[0] * L for i in range(N)]
for i in range(N):
for j in range(L):
s = 0
for k in range(M):
s = (s + A[i][k] * B[k][j]) % MOD
res[i][j] = s
... | false | 8 | [
"-n, k = list(map(int, input().split()))",
"-mod = 10**9 + 7",
"-a = []",
"-for i in range(n):",
"- a.append(tuple(map(int, input().split())))",
"-b = matPow(a, k, mod)",
"-ans = 0",
"-for i in range(n):",
"- for j in range(n):",
"- ans = (ans + b[i][j]) % mod",
"-print(ans)",
"+d... | false | 0.046801 | 0.056611 | 0.826704 | [
"s448643570",
"s298984808"
] |
u909643606 | p03566 | python | s248689433 | s490579025 | 26 | 17 | 3,064 | 3,064 | Accepted | Accepted | 34.62 | def calc_area(v_end, v_start, v_max, dt):
kouten_v = (v_end + v_start + dt) / 2
kouten_t = kouten_v - v_start
kouten_t_limit1 = max(v_max - v_start, 0)
kouten_t_limit2 = min(v_end + dt - v_max, dt)
if 0 < kouten_t < dt:
area = (v_start + kouten_v) * kouten_t / 2
area += (v_en... | #区間ごとの面積を計算する
def calc_area(v_end, v_start, v_max, dt):
kouten_v = (v_end + v_start + dt) / 2
kouten_t = kouten_v - v_start
if 0 < kouten_t < dt:
area = (v_start + kouten_v) * kouten_t / 2 #左側
area += (v_end + kouten_v) * (dt - kouten_t) / 2 #右側
area -= max(0, (kouten_v - v_... | 38 | 38 | 1,133 | 1,168 | def calc_area(v_end, v_start, v_max, dt):
kouten_v = (v_end + v_start + dt) / 2
kouten_t = kouten_v - v_start
kouten_t_limit1 = max(v_max - v_start, 0)
kouten_t_limit2 = min(v_end + dt - v_max, dt)
if 0 < kouten_t < dt:
area = (v_start + kouten_v) * kouten_t / 2
area += (v_end + kout... | # 区間ごとの面積を計算する
def calc_area(v_end, v_start, v_max, dt):
kouten_v = (v_end + v_start + dt) / 2
kouten_t = kouten_v - v_start
if 0 < kouten_t < dt:
area = (v_start + kouten_v) * kouten_t / 2 # 左側
area += (v_end + kouten_v) * (dt - kouten_t) / 2 # 右側
area -= max(0, (kouten_v - v_max)... | false | 0 | [
"+# 区間ごとの面積を計算する",
"- kouten_t_limit1 = max(v_max - v_start, 0)",
"- kouten_t_limit2 = min(v_end + dt - v_max, dt)",
"- area = (v_start + kouten_v) * kouten_t / 2",
"- area += (v_end + kouten_v) * (dt - kouten_t) / 2",
"- area -= (kouten_t_limit2 - kouten_t_limit1) * max(0, (kou... | false | 0.044142 | 0.070531 | 0.62586 | [
"s248689433",
"s490579025"
] |
u191874006 | p02598 | python | s989947935 | s210656001 | 290 | 168 | 92,268 | 104,292 | Accepted | Accepted | 42.07 | #!/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
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
def f(x):
cnt = 0
for i in a:
cnt += (i-1) // x
if cnt > k:
return False
return True
ok = 10**9
ng = 0
while ok - ng > 1:
mid = (ok + ng) // 2
i... | 40 | 21 | 907 | 381 | #!/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
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
def f(x):
cnt = 0
for i in a:
cnt += (i - 1) // x
if cnt > k:
return False
return True
ok = 10**9
ng = 0
while ok - ng > 1:
mid = (ok + ng) // 2
if f(mid):
ok = m... | false | 47.5 | [
"-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.038474 | 0.081947 | 0.469502 | [
"s989947935",
"s210656001"
] |
u537782349 | p03338 | python | s678704130 | s566458175 | 43 | 20 | 3,064 | 3,064 | Accepted | Accepted | 53.49 | a = int(eval(input()))
b = eval(input())
ans = 0
for i in range(1, a-1):
c = b[:i]
d = b[i:]
e = 0
f = []
for j in range(len(c)):
for k in range(len(d)):
if c[j] == d[k] and c[j] not in f:
e += 1
f.append(c[j])
break
... | a = int(eval(input()))
b = list(eval(input()))
c = 0
for i in range(a):
d = {}
e = {}
for j in range(0, min(i+1, a)):
if b[j] not in d:
d[b[j]] = 1
for j in range(i+1, a):
if b[j] in d and b[j] not in e:
e[b[j]] = 1
c = max(c, len(e))
print(c)
| 16 | 15 | 341 | 307 | a = int(eval(input()))
b = eval(input())
ans = 0
for i in range(1, a - 1):
c = b[:i]
d = b[i:]
e = 0
f = []
for j in range(len(c)):
for k in range(len(d)):
if c[j] == d[k] and c[j] not in f:
e += 1
f.append(c[j])
break
ans = max... | a = int(eval(input()))
b = list(eval(input()))
c = 0
for i in range(a):
d = {}
e = {}
for j in range(0, min(i + 1, a)):
if b[j] not in d:
d[b[j]] = 1
for j in range(i + 1, a):
if b[j] in d and b[j] not in e:
e[b[j]] = 1
c = max(c, len(e))
print(c)
| false | 6.25 | [
"-b = eval(input())",
"-ans = 0",
"-for i in range(1, a - 1):",
"- c = b[:i]",
"- d = b[i:]",
"- e = 0",
"- f = []",
"- for j in range(len(c)):",
"- for k in range(len(d)):",
"- if c[j] == d[k] and c[j] not in f:",
"- e += 1",
"- f... | false | 0.079116 | 0.068279 | 1.158723 | [
"s678704130",
"s566458175"
] |
u512212329 | p02660 | python | s427472443 | s333738431 | 190 | 124 | 9,320 | 9,448 | Accepted | Accepted | 34.74 | from itertools import accumulate
from collections import defaultdict
def main():
n = int(eval(input()))
prime_counter = defaultdict(int)
acc = tuple(accumulate(list(range(1, 42)))) # 10^12 < 2^39
def facs():
yield 2
for x in range(10 ** 6):
yield x * 2 + 3
... | from itertools import accumulate
from collections import defaultdict
def main():
n = int(eval(input()))
prime_counter = defaultdict(int)
acc = tuple(accumulate(list(range(1, 42)))) # 10^12 < 2^39
def facs():
yield 2
for x in range(10 ** 6):
yield x * 2 + 3
... | 36 | 35 | 790 | 754 | from itertools import accumulate
from collections import defaultdict
def main():
n = int(eval(input()))
prime_counter = defaultdict(int)
acc = tuple(accumulate(list(range(1, 42)))) # 10^12 < 2^39
def facs():
yield 2
for x in range(10**6):
yield x * 2 + 3
for fac in f... | from itertools import accumulate
from collections import defaultdict
def main():
n = int(eval(input()))
prime_counter = defaultdict(int)
acc = tuple(accumulate(list(range(1, 42)))) # 10^12 < 2^39
def facs():
yield 2
for x in range(10**6):
yield x * 2 + 3
for fac in f... | false | 2.777778 | [
"- while fac * fac <= n:",
"- if n % fac == 0:",
"- n //= fac",
"- prime_counter[fac] += 1",
"- else:",
"- break",
"+ while n % fac == 0:",
"+ n //= fac",
"+ prime_counter[fac] += 1",
"+ i... | false | 0.271702 | 0.035847 | 7.579433 | [
"s427472443",
"s333738431"
] |
u135389999 | p02773 | python | s468811184 | s666332549 | 1,309 | 801 | 96,984 | 45,040 | Accepted | Accepted | 38.81 | n = int(eval(input()))
l_d = {}
max_n = 0
max_w = []
for i in range(n):
n = str(eval(input()))
if n in l_d:
l_d[n] += 1
if l_d[n] > max_n:
max_w = []
max_w.append(n)
max_n = l_d[n]
elif l_d[n] == max_n:
max_w.append(n)
els... | import collections
n = int(eval(input()))
l = []
for i in range(n):
l.append(str(eval(input())))
c = collections.Counter(l)
c = c.most_common()
max_l = c[0][1]
ans = []
for i in c:
if i[1] == max_l:
ans.append(i[0])
else:
break
ans.sort()
for i in ans:
print(i) | 22 | 19 | 442 | 301 | n = int(eval(input()))
l_d = {}
max_n = 0
max_w = []
for i in range(n):
n = str(eval(input()))
if n in l_d:
l_d[n] += 1
if l_d[n] > max_n:
max_w = []
max_w.append(n)
max_n = l_d[n]
elif l_d[n] == max_n:
max_w.append(n)
else:
l_d... | import collections
n = int(eval(input()))
l = []
for i in range(n):
l.append(str(eval(input())))
c = collections.Counter(l)
c = c.most_common()
max_l = c[0][1]
ans = []
for i in c:
if i[1] == max_l:
ans.append(i[0])
else:
break
ans.sort()
for i in ans:
print(i)
| false | 13.636364 | [
"+import collections",
"+",
"-l_d = {}",
"-max_n = 0",
"-max_w = []",
"+l = []",
"- n = str(eval(input()))",
"- if n in l_d:",
"- l_d[n] += 1",
"- if l_d[n] > max_n:",
"- max_w = []",
"- max_w.append(n)",
"- max_n = l_d[n]",
"- el... | false | 0.087345 | 0.101386 | 0.86151 | [
"s468811184",
"s666332549"
] |
u602702913 | p02398 | python | s502808222 | s307685973 | 70 | 20 | 7,704 | 5,596 | Accepted | Accepted | 71.43 |
a,b,c=list(map(int,input().split()))
x=0
for i in range(a,b+1):
if c%i==0:
x+=1
print(x) | a,b,c=list(map(int,input().split()))
y=0
for x in range(a,b+1):
if c%x==0:
y+=1
print(y)
| 7 | 11 | 99 | 114 | a, b, c = list(map(int, input().split()))
x = 0
for i in range(a, b + 1):
if c % i == 0:
x += 1
print(x)
| a, b, c = list(map(int, input().split()))
y = 0
for x in range(a, b + 1):
if c % x == 0:
y += 1
print(y)
| false | 36.363636 | [
"-x = 0",
"-for i in range(a, b + 1):",
"- if c % i == 0:",
"- x += 1",
"-print(x)",
"+y = 0",
"+for x in range(a, b + 1):",
"+ if c % x == 0:",
"+ y += 1",
"+print(y)"
] | false | 0.037485 | 0.038166 | 0.982156 | [
"s502808222",
"s307685973"
] |
u670180528 | p03295 | python | s243314904 | s691112087 | 219 | 141 | 25,312 | 25,132 | Accepted | Accepted | 35.62 | n,m,*t=list(map(int,open(0).read().split()))
c=d=0
for b,a in sorted([(b,a)for a,b in zip(*[iter(t)]*2)]):
if a>d:c+=1;d=b-1
print(c) | n,m,*t=list(map(int,open(0).read().split()));r=[n+1]*(n+1)
for a,b in zip(*[iter(t)]*2):
r[a]=min(r[a],b)
a=0;cur=n+1
for i in range(n+1):
cur=min(cur, r[i])
if i==cur:
cur=r[i]
a+=1
print(a) | 5 | 10 | 132 | 201 | n, m, *t = list(map(int, open(0).read().split()))
c = d = 0
for b, a in sorted([(b, a) for a, b in zip(*[iter(t)] * 2)]):
if a > d:
c += 1
d = b - 1
print(c)
| n, m, *t = list(map(int, open(0).read().split()))
r = [n + 1] * (n + 1)
for a, b in zip(*[iter(t)] * 2):
r[a] = min(r[a], b)
a = 0
cur = n + 1
for i in range(n + 1):
cur = min(cur, r[i])
if i == cur:
cur = r[i]
a += 1
print(a)
| false | 50 | [
"-c = d = 0",
"-for b, a in sorted([(b, a) for a, b in zip(*[iter(t)] * 2)]):",
"- if a > d:",
"- c += 1",
"- d = b - 1",
"-print(c)",
"+r = [n + 1] * (n + 1)",
"+for a, b in zip(*[iter(t)] * 2):",
"+ r[a] = min(r[a], b)",
"+a = 0",
"+cur = n + 1",
"+for i in range(n + 1):"... | false | 0.043842 | 0.035886 | 1.221694 | [
"s243314904",
"s691112087"
] |
u970197315 | p03910 | python | s177507277 | s531006693 | 625 | 22 | 187,168 | 3,316 | Accepted | Accepted | 96.48 | # B - Exactly N points
n=int(eval(input()))
if n==1:
print((1))
exit()
t=0
acc=[]
for i in range(1,n+1):
t+=i
acc.append(t)
max_v=-1
for i in range(len(acc)-1):
if acc[i]<n<=acc[i+1]:
max_v=i+2
break
ans=[]
ans.append(max_v)
cur=max_v
vv=acc[i+1]
vv-=cur
s=max_v... | n=int(eval(input()))
c=0
for i in range(1,n+1):
if i*(i+1)//2>=n:
c=i
break
for i in range(c,0,-1):
if i<=n:
print(i)
n-=i | 37 | 10 | 575 | 145 | # B - Exactly N points
n = int(eval(input()))
if n == 1:
print((1))
exit()
t = 0
acc = []
for i in range(1, n + 1):
t += i
acc.append(t)
max_v = -1
for i in range(len(acc) - 1):
if acc[i] < n <= acc[i + 1]:
max_v = i + 2
break
ans = []
ans.append(max_v)
cur = max_v
vv = acc[i + 1]
vv... | n = int(eval(input()))
c = 0
for i in range(1, n + 1):
if i * (i + 1) // 2 >= n:
c = i
break
for i in range(c, 0, -1):
if i <= n:
print(i)
n -= i
| false | 72.972973 | [
"-# B - Exactly N points",
"-if n == 1:",
"- print((1))",
"- exit()",
"-t = 0",
"-acc = []",
"+c = 0",
"- t += i",
"- acc.append(t)",
"-max_v = -1",
"-for i in range(len(acc) - 1):",
"- if acc[i] < n <= acc[i + 1]:",
"- max_v = i + 2",
"+ if i * (i + 1) // 2 >= n:"... | false | 0.143352 | 0.037147 | 3.85903 | [
"s177507277",
"s531006693"
] |
u970197315 | p02803 | python | s237141903 | s452845073 | 300 | 226 | 9,332 | 9,472 | Accepted | Accepted | 24.67 | from collections import deque
def bfs(sy,sx):
q=deque([[sy,sx]])
visited[sy][sx]=0
while q:
y,x=q.popleft()
for dy,dx in ([1,0],[-1,0],[0,1],[0,-1]):
ny,nx=y+dy,x+dx
if ny<0 or ny>h-1 or nx<0 or nx>w-1 or path[ny][nx]=="#":continue
if path[ny][nx]=="." and visited[ny][nx]==-1:
... | from collections import deque
def bfs(y,x):
q=deque([(y,x)])
visited[y][x]=0
while q:
cy,cx=q.popleft()
for dy,dx in [(1,0),(-1,0),(0,1),(0,-1)]:
ny,nx=cy+dy,cx+dx
if 0<=ny<h and 0<=nx<w and visited[ny][nx]==-1:
if s[ny][nx]=="#":continue
visited[ny][nx]=visited[cy][c... | 34 | 31 | 809 | 726 | from collections import deque
def bfs(sy, sx):
q = deque([[sy, sx]])
visited[sy][sx] = 0
while q:
y, x = q.popleft()
for dy, dx in ([1, 0], [-1, 0], [0, 1], [0, -1]):
ny, nx = y + dy, x + dx
if ny < 0 or ny > h - 1 or nx < 0 or nx > w - 1 or path[ny][nx] == "#":
... | from collections import deque
def bfs(y, x):
q = deque([(y, x)])
visited[y][x] = 0
while q:
cy, cx = q.popleft()
for dy, dx in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
ny, nx = cy + dy, cx + dx
if 0 <= ny < h and 0 <= nx < w and visited[ny][nx] == -1:
if ... | false | 8.823529 | [
"-def bfs(sy, sx):",
"- q = deque([[sy, sx]])",
"- visited[sy][sx] = 0",
"+def bfs(y, x):",
"+ q = deque([(y, x)])",
"+ visited[y][x] = 0",
"- y, x = q.popleft()",
"- for dy, dx in ([1, 0], [-1, 0], [0, 1], [0, -1]):",
"- ny, nx = y + dy, x + dx",
"- ... | false | 0.03774 | 0.039527 | 0.954799 | [
"s237141903",
"s452845073"
] |
u989345508 | p02665 | python | s990737459 | s486879983 | 674 | 89 | 650,744 | 20,136 | Accepted | Accepted | 86.8 | from itertools import accumulate
n=int(eval(input()))
a=list(map(int,input().split()))
c=list(accumulate(a))
b=[0]*(n+1)
#大きくしすぎてしまう場合がある
#いや上限を考えろや
def f():
global n,a,b
for i in range(n+1):
if i==0:
b[0]=min(c[n]-c[0],1)
else:
b[i]=min(2*(b[i-1]-a[i-1]),c[n... | n,*a=list(map(int,open(0).read().split()))
t,v=sum(a),[1]
for q in a:
v+=[min(2*(v[-1]-q),t:=t-q)]
if v[-1]<0:print((-1));exit()
print((sum(v))) | 26 | 6 | 519 | 147 | from itertools import accumulate
n = int(eval(input()))
a = list(map(int, input().split()))
c = list(accumulate(a))
b = [0] * (n + 1)
# 大きくしすぎてしまう場合がある
# いや上限を考えろや
def f():
global n, a, b
for i in range(n + 1):
if i == 0:
b[0] = min(c[n] - c[0], 1)
else:
b[i] = min(2 * (... | n, *a = list(map(int, open(0).read().split()))
t, v = sum(a), [1]
for q in a:
v += [min(2 * (v[-1] - q), t := t - q)]
if v[-1] < 0:
print((-1))
exit()
print((sum(v)))
| false | 76.923077 | [
"-from itertools import accumulate",
"-",
"-n = int(eval(input()))",
"-a = list(map(int, input().split()))",
"-c = list(accumulate(a))",
"-b = [0] * (n + 1)",
"-# 大きくしすぎてしまう場合がある",
"-# いや上限を考えろや",
"-def f():",
"- global n, a, b",
"- for i in range(n + 1):",
"- if i == 0:",
"- ... | false | 0.042428 | 0.069944 | 0.606598 | [
"s990737459",
"s486879983"
] |
u498487134 | p03780 | python | s881060162 | s311433104 | 1,338 | 1,079 | 39,536 | 39,536 | Accepted | Accepted | 19.36 | def main():
def I(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))
N,K=MI()
a=LI()#下位の連続するn枚が不要なはず
a.sort()
for i in range(N):#K以上ならば必要
if a[i]>=K:
a=a[:i]
break
... | def I(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))
def main():
N,K=MI()
a=LI()#下位の連続するn枚が不要なはず
a.sort()
for i in range(N):#K以上ならば必要
if a[i]>=K:
a=a[:i]
break
N=len(a... | 55 | 61 | 1,175 | 1,201 | def main():
def I():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def LI():
return list(map(int, input().split()))
N, K = MI()
a = LI() # 下位の連続するn枚が不要なはず
a.sort()
for i in range(N): # K以上ならば必要
if a[i] >= K:
a = a[... | def I():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def LI():
return list(map(int, input().split()))
def main():
N, K = MI()
a = LI() # 下位の連続するn枚が不要なはず
a.sort()
for i in range(N): # K以上ならば必要
if a[i] >= K:
a = a[:i]
break... | false | 9.836066 | [
"+def I():",
"+ return int(eval(input()))",
"+",
"+",
"+def MI():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def LI():",
"+ return list(map(int, input().split()))",
"+",
"+",
"- def I():",
"- return int(eval(input()))",
"-",
"- def MI():",
"- ... | false | 0.03728 | 0.038636 | 0.96492 | [
"s881060162",
"s311433104"
] |
u671889550 | p02572 | python | s133930038 | s486409401 | 232 | 117 | 49,684 | 94,196 | Accepted | Accepted | 49.57 | import numpy as np
n = int(eval(input()))
a = np.array(list(map(int, input().split())), dtype = 'object')
mod = 10**9 + 7
sq_sum_a = sum(a)**2
sum_sq_a = sum(a**2)
sum_cross = (sq_sum_a - sum_sq_a) // 2
ans = sum_cross % mod
# xy = ((x + y)**2 - (x**2 + y**2)) // 2
print(ans) | n = int(eval(input()))
a = list(map(int, input().split()))
mod = 10**9+7
sq_sum_a = sum(a)**2
sum_sq_a = sum([x**2 for x in a])
sum_cross = (sq_sum_a - sum_sq_a) // 2
ans = sum_cross % mod
print(ans) | 14 | 11 | 287 | 211 | import numpy as np
n = int(eval(input()))
a = np.array(list(map(int, input().split())), dtype="object")
mod = 10**9 + 7
sq_sum_a = sum(a) ** 2
sum_sq_a = sum(a**2)
sum_cross = (sq_sum_a - sum_sq_a) // 2
ans = sum_cross % mod
# xy = ((x + y)**2 - (x**2 + y**2)) // 2
print(ans)
| n = int(eval(input()))
a = list(map(int, input().split()))
mod = 10**9 + 7
sq_sum_a = sum(a) ** 2
sum_sq_a = sum([x**2 for x in a])
sum_cross = (sq_sum_a - sum_sq_a) // 2
ans = sum_cross % mod
print(ans)
| false | 21.428571 | [
"-import numpy as np",
"-",
"-a = np.array(list(map(int, input().split())), dtype=\"object\")",
"+a = list(map(int, input().split()))",
"-sum_sq_a = sum(a**2)",
"+sum_sq_a = sum([x**2 for x in a])",
"-# xy = ((x + y)**2 - (x**2 + y**2)) // 2"
] | false | 0.218522 | 0.095781 | 2.281479 | [
"s133930038",
"s486409401"
] |
u236720912 | p03448 | python | s354584009 | s694427253 | 54 | 18 | 3,188 | 3,064 | Accepted | Accepted | 66.67 | A = int(eval(input()))
B = int(eval(input()))
C = int(eval(input()))
X = int(eval(input()))
counter = 0
for i in range(0, A+1):
for n in range(0, B+1):
for t in range(0, C+1):
total = 500 * i + 100 * n + 50 * t
if total == X:
counter += 1
print(counter) ... | A = int(eval(input()))
B = int(eval(input()))
C = int(eval(input()))
X = int(eval(input()))
counter = 0
for i in range(0, A+1):
ans = X - 500 * i
if ans > 0:
for n in range(0, B+1):
ans1 = ans - 100 * n
if ans1 > 0 and (ans1 / 50) <= C:
counter += 1
... | 13 | 18 | 299 | 412 | A = int(eval(input()))
B = int(eval(input()))
C = int(eval(input()))
X = int(eval(input()))
counter = 0
for i in range(0, A + 1):
for n in range(0, B + 1):
for t in range(0, C + 1):
total = 500 * i + 100 * n + 50 * t
if total == X:
counter += 1
print(counter)
| A = int(eval(input()))
B = int(eval(input()))
C = int(eval(input()))
X = int(eval(input()))
counter = 0
for i in range(0, A + 1):
ans = X - 500 * i
if ans > 0:
for n in range(0, B + 1):
ans1 = ans - 100 * n
if ans1 > 0 and (ans1 / 50) <= C:
counter += 1
... | false | 27.777778 | [
"- for n in range(0, B + 1):",
"- for t in range(0, C + 1):",
"- total = 500 * i + 100 * n + 50 * t",
"- if total == X:",
"+ ans = X - 500 * i",
"+ if ans > 0:",
"+ for n in range(0, B + 1):",
"+ ans1 = ans - 100 * n",
"+ if ans1 > 0... | false | 0.087359 | 0.036941 | 2.364814 | [
"s354584009",
"s694427253"
] |
u391875425 | p03556 | python | s494261745 | s653499320 | 67 | 17 | 3,188 | 3,064 | Accepted | Accepted | 74.63 | N = int(eval(input()))
for i in range(N,0,-1):
if int(i**(1/2)) == i**(1/2):
print(i)
break | import math
print((int(math.sqrt(int(eval(input()))))**2)) | 5 | 2 | 109 | 51 | N = int(eval(input()))
for i in range(N, 0, -1):
if int(i ** (1 / 2)) == i ** (1 / 2):
print(i)
break
| import math
print((int(math.sqrt(int(eval(input())))) ** 2))
| false | 60 | [
"-N = int(eval(input()))",
"-for i in range(N, 0, -1):",
"- if int(i ** (1 / 2)) == i ** (1 / 2):",
"- print(i)",
"- break",
"+import math",
"+",
"+print((int(math.sqrt(int(eval(input())))) ** 2))"
] | false | 0.040198 | 0.038696 | 1.038812 | [
"s494261745",
"s653499320"
] |
u027622859 | p03944 | python | s967221912 | s637949189 | 449 | 356 | 19,492 | 21,548 | Accepted | Accepted | 20.71 | import numpy as np
W, H, N = list(map(int, input().split()))
x = []
y = []
a = []
for _ in range(N):
b, c, d = list(map(int, input().split()))
x.append(b)
y.append(c)
a.append(d)
A = np.zeros((H, W))
for i in range(N):
if a[i] == 1:
for j in range(x[i]):
for k in ... | import numpy as np
w, h, n = list(map(int, input().split()))
xy = np.zeros((w,h))
xya = [[int(a) for a in input().split()] for _ in range(n)]
for i in range(n):
if xya[i][2]==1:
for x in range(xya[i][0]):
xy[x][:h] = 1
elif xya[i][2] == 2:
for x in range(xya[i][0], w):
... | 31 | 21 | 714 | 650 | import numpy as np
W, H, N = list(map(int, input().split()))
x = []
y = []
a = []
for _ in range(N):
b, c, d = list(map(int, input().split()))
x.append(b)
y.append(c)
a.append(d)
A = np.zeros((H, W))
for i in range(N):
if a[i] == 1:
for j in range(x[i]):
for k in range(H):
... | import numpy as np
w, h, n = list(map(int, input().split()))
xy = np.zeros((w, h))
xya = [[int(a) for a in input().split()] for _ in range(n)]
for i in range(n):
if xya[i][2] == 1:
for x in range(xya[i][0]):
xy[x][:h] = 1
elif xya[i][2] == 2:
for x in range(xya[i][0], w):
... | false | 32.258065 | [
"-W, H, N = list(map(int, input().split()))",
"-x = []",
"-y = []",
"-a = []",
"-for _ in range(N):",
"- b, c, d = list(map(int, input().split()))",
"- x.append(b)",
"- y.append(c)",
"- a.append(d)",
"-A = np.zeros((H, W))",
"-for i in range(N):",
"- if a[i] == 1:",
"- ... | false | 0.311396 | 0.57075 | 0.545591 | [
"s967221912",
"s637949189"
] |
u312025627 | p02856 | python | s053846100 | s913933795 | 859 | 255 | 47,832 | 42,748 | Accepted | Accepted | 70.31 | def main():
M = int(eval(input()))
ans = 0
dc_sum = 0
for i in range(M):
d, c = (int(i) for i in input().split())
dc_sum += d*c
ans += c
if dc_sum % 9 == 0:
print((ans - 1 + dc_sum//9 - 1))
else:
print((ans - 1 + dc_sum//9))
if __name__ == ... | def main():
import sys
input = sys.stdin.buffer.readline
M = int(eval(input()))
ans = 0
dc_sum = 0
for i in range(M):
d, c = (int(i) for i in input().split())
dc_sum += d*c
ans += c
if dc_sum % 9 == 0:
print((ans - 1 + dc_sum//9 - 1))
else:
... | 16 | 18 | 334 | 389 | def main():
M = int(eval(input()))
ans = 0
dc_sum = 0
for i in range(M):
d, c = (int(i) for i in input().split())
dc_sum += d * c
ans += c
if dc_sum % 9 == 0:
print((ans - 1 + dc_sum // 9 - 1))
else:
print((ans - 1 + dc_sum // 9))
if __name__ == "__main_... | def main():
import sys
input = sys.stdin.buffer.readline
M = int(eval(input()))
ans = 0
dc_sum = 0
for i in range(M):
d, c = (int(i) for i in input().split())
dc_sum += d * c
ans += c
if dc_sum % 9 == 0:
print((ans - 1 + dc_sum // 9 - 1))
else:
pr... | false | 11.111111 | [
"+ import sys",
"+",
"+ input = sys.stdin.buffer.readline"
] | false | 0.14957 | 0.042436 | 3.524574 | [
"s053846100",
"s913933795"
] |
u790372061 | p03073 | python | s863360383 | s239850916 | 44 | 31 | 10,852 | 3,188 | Accepted | Accepted | 29.55 | from itertools import zip_longest
S = eval(input())
ans = 0
for curr, next in list(zip_longest(S, S[1:]))[::2]:
if curr == '0': ans += 1
if next == '1': ans += 1
print((min(ans, len(S) - ans))) | from itertools import zip_longest, islice
S = eval(input())
ans = 0
for curr, next in islice(zip_longest(S, S[1:]), 0, None, 2):
if curr == '0': ans += 1
if next == '1': ans += 1
print((min(ans, len(S) - ans))) | 10 | 10 | 201 | 218 | from itertools import zip_longest
S = eval(input())
ans = 0
for curr, next in list(zip_longest(S, S[1:]))[::2]:
if curr == "0":
ans += 1
if next == "1":
ans += 1
print((min(ans, len(S) - ans)))
| from itertools import zip_longest, islice
S = eval(input())
ans = 0
for curr, next in islice(zip_longest(S, S[1:]), 0, None, 2):
if curr == "0":
ans += 1
if next == "1":
ans += 1
print((min(ans, len(S) - ans)))
| false | 0 | [
"-from itertools import zip_longest",
"+from itertools import zip_longest, islice",
"-for curr, next in list(zip_longest(S, S[1:]))[::2]:",
"+for curr, next in islice(zip_longest(S, S[1:]), 0, None, 2):"
] | false | 0.043499 | 0.043626 | 0.997079 | [
"s863360383",
"s239850916"
] |
u371467115 | p03331 | python | s653898249 | s511276618 | 431 | 18 | 3,060 | 2,940 | Accepted | Accepted | 95.82 | n=int(eval(input()))
ans=n
for i in range(1,n):
l=[int(j) for j in list(str(i))]
m=[int(k) for k in list(str(abs(n-i)))]
if ans>sum(l)+sum(m):
ans=sum(l)+sum(m)
print(ans) | # A
NL = list(map(int, list(eval(input()))))
if NL[0] == 1 and sum(NL) == 1:
print((10))
else:
print((sum(NL)))
#copy code | 8 | 8 | 182 | 128 | n = int(eval(input()))
ans = n
for i in range(1, n):
l = [int(j) for j in list(str(i))]
m = [int(k) for k in list(str(abs(n - i)))]
if ans > sum(l) + sum(m):
ans = sum(l) + sum(m)
print(ans)
| # A
NL = list(map(int, list(eval(input()))))
if NL[0] == 1 and sum(NL) == 1:
print((10))
else:
print((sum(NL)))
# copy code
| false | 0 | [
"-n = int(eval(input()))",
"-ans = n",
"-for i in range(1, n):",
"- l = [int(j) for j in list(str(i))]",
"- m = [int(k) for k in list(str(abs(n - i)))]",
"- if ans > sum(l) + sum(m):",
"- ans = sum(l) + sum(m)",
"-print(ans)",
"+# A",
"+NL = list(map(int, list(eval(input()))))",
... | false | 0.230328 | 0.006536 | 35.238551 | [
"s653898249",
"s511276618"
] |
u562935282 | p02929 | python | s642032765 | s643079733 | 153 | 117 | 6,964 | 5,096 | Accepted | Accepted | 23.53 | mod = 10 ** 9 + 7
n = int(eval(input()))
s = eval(input())
t = list([1 if x == 'B' else 0 for x in s])
t = tuple((tt - df) % 2 for tt, df in zip(t, reversed(list(range(n * 2)))))
# print(t)
ans = 1
zeros = 0
ones = 0
for tt in t:
if tt == 0:
zeros += 1
else:
if zeros == 0:
... | mod = 10 ** 9 + 7
n = int(eval(input()))
s = eval(input())
t = [(ind % 2) ^ (ss == 'W') for ind, ss in enumerate(s)]
# print(t)
ans = 1
zeros = 0
for tt in t:
if tt == 0:
zeros += 1
else:
if zeros == 0:
print((0))
exit()
ans = ans * zeros % mod
... | 32 | 27 | 541 | 436 | mod = 10**9 + 7
n = int(eval(input()))
s = eval(input())
t = list([1 if x == "B" else 0 for x in s])
t = tuple((tt - df) % 2 for tt, df in zip(t, reversed(list(range(n * 2)))))
# print(t)
ans = 1
zeros = 0
ones = 0
for tt in t:
if tt == 0:
zeros += 1
else:
if zeros == 0:
print((0))
... | mod = 10**9 + 7
n = int(eval(input()))
s = eval(input())
t = [(ind % 2) ^ (ss == "W") for ind, ss in enumerate(s)]
# print(t)
ans = 1
zeros = 0
for tt in t:
if tt == 0:
zeros += 1
else:
if zeros == 0:
print((0))
exit()
ans = ans * zeros % mod
zeros -= 1
if... | false | 15.625 | [
"-t = list([1 if x == \"B\" else 0 for x in s])",
"-t = tuple((tt - df) % 2 for tt, df in zip(t, reversed(list(range(n * 2)))))",
"+t = [(ind % 2) ^ (ss == \"W\") for ind, ss in enumerate(s)]",
"-ones = 0",
"- ans *= zeros",
"- ans %= mod",
"+ ans = ans * zeros % mod",
"- o... | false | 0.037576 | 0.036067 | 1.041859 | [
"s642032765",
"s643079733"
] |
u729133443 | p02782 | python | s020740723 | s108847248 | 1,151 | 772 | 161,452 | 161,268 | Accepted | Accepted | 32.93 | class Factorial:
def __init__(self,n,mod):
self.f=[1]
self.mod=mod
for i in range(1,n+1):
self.f.append(self.f[-1]*i%mod)
self.i=[pow(self.f[-1],mod-2,mod)]
for i in range(1,n+1)[::-1]:
self.i.append(self.i[-1]*i%mod)
self.i.reverse()
... | class Factorial:
def __init__(self,n,mod):
self.f=f=[0]*(n+1)
f[0]=b=1
self.mod=mod
for i in range(1,n+1):f[i]=b=b*i%mod
self.inv=inv=[0]*(n+1)
inv[n]=b=pow(self.f[n],mod-2,mod)
for i in range(n,0,-1):inv[i-1]=b=b*i%mod
def factorial(self,i):
... | 21 | 23 | 693 | 711 | class Factorial:
def __init__(self, n, mod):
self.f = [1]
self.mod = mod
for i in range(1, n + 1):
self.f.append(self.f[-1] * i % mod)
self.i = [pow(self.f[-1], mod - 2, mod)]
for i in range(1, n + 1)[::-1]:
self.i.append(self.i[-1] * i % mod)
... | class Factorial:
def __init__(self, n, mod):
self.f = f = [0] * (n + 1)
f[0] = b = 1
self.mod = mod
for i in range(1, n + 1):
f[i] = b = b * i % mod
self.inv = inv = [0] * (n + 1)
inv[n] = b = pow(self.f[n], mod - 2, mod)
for i in range(n, 0, -1):
... | false | 8.695652 | [
"- self.f = [1]",
"+ self.f = f = [0] * (n + 1)",
"+ f[0] = b = 1",
"- self.f.append(self.f[-1] * i % mod)",
"- self.i = [pow(self.f[-1], mod - 2, mod)]",
"- for i in range(1, n + 1)[::-1]:",
"- self.i.append(self.i[-1] * i % mod)",
"- se... | false | 0.043102 | 0.044307 | 0.972795 | [
"s020740723",
"s108847248"
] |
u214617707 | p03546 | python | s571779114 | s213664297 | 47 | 40 | 3,444 | 3,444 | Accepted | Accepted | 14.89 | H, W = list(map(int, input().split()))
c = [[0]*10 for i in range(10)]
for i in range(10):
a = list(map(int, input().split()))
for j in range(10):
c[i][j] = a[j]
A = [[0]*W for i in range(H)]
for i in range(H):
a = list(map(int, input().split()))
for j in range(W):
A[i][j... | H, W = list(map(int, input().split()))
C = [[] for i in range(10)]
A = [[] for i in range(H)]
for i in range(10):
c = list(map(int, input().split()))
C[i] = c
for i in range(H):
a = list(map(int, input().split()))
A[i] = a
for k in range(10):
for i in range(10):
for j in range... | 28 | 23 | 647 | 504 | H, W = list(map(int, input().split()))
c = [[0] * 10 for i in range(10)]
for i in range(10):
a = list(map(int, input().split()))
for j in range(10):
c[i][j] = a[j]
A = [[0] * W for i in range(H)]
for i in range(H):
a = list(map(int, input().split()))
for j in range(W):
A[i][j] = a[j]
for... | H, W = list(map(int, input().split()))
C = [[] for i in range(10)]
A = [[] for i in range(H)]
for i in range(10):
c = list(map(int, input().split()))
C[i] = c
for i in range(H):
a = list(map(int, input().split()))
A[i] = a
for k in range(10):
for i in range(10):
for j in range(10):
... | false | 17.857143 | [
"-c = [[0] * 10 for i in range(10)]",
"+C = [[] for i in range(10)]",
"+A = [[] for i in range(H)]",
"- a = list(map(int, input().split()))",
"- for j in range(10):",
"- c[i][j] = a[j]",
"-A = [[0] * W for i in range(H)]",
"+ c = list(map(int, input().split()))",
"+ C[i] = c",
"... | false | 0.037221 | 0.038331 | 0.971028 | [
"s571779114",
"s213664297"
] |
u072053884 | p02266 | python | s416854074 | s243675541 | 90 | 70 | 8,392 | 8,352 | Accepted | Accepted | 22.22 | import collections
S1 = collections.deque()
S2 = collections.deque()
S3 = collections.deque()
for i, j in enumerate(eval(input())):
if j == '\\':
S1.append(i)
elif j == '/':
if S1:
left_edge = S1.pop()
new_puddle = i - left_edge
while True:
... | import collections
import sys
S1 = collections.deque()
S2 = collections.deque()
S3 = collections.deque()
for i, j in enumerate(sys.stdin.readline()):
if j == '\\':
S1.append(i)
elif j == '/':
if S1:
left_edge = S1.pop()
new_puddle = i - left_edge
... | 31 | 32 | 712 | 737 | import collections
S1 = collections.deque()
S2 = collections.deque()
S3 = collections.deque()
for i, j in enumerate(eval(input())):
if j == "\\":
S1.append(i)
elif j == "/":
if S1:
left_edge = S1.pop()
new_puddle = i - left_edge
while True:
if... | import collections
import sys
S1 = collections.deque()
S2 = collections.deque()
S3 = collections.deque()
for i, j in enumerate(sys.stdin.readline()):
if j == "\\":
S1.append(i)
elif j == "/":
if S1:
left_edge = S1.pop()
new_puddle = i - left_edge
while True:
... | false | 3.125 | [
"+import sys",
"-for i, j in enumerate(eval(input())):",
"+for i, j in enumerate(sys.stdin.readline()):"
] | false | 0.047062 | 0.046738 | 1.006936 | [
"s416854074",
"s243675541"
] |
u761320129 | p03816 | python | s136280600 | s273825882 | 81 | 57 | 16,380 | 18,656 | Accepted | Accepted | 29.63 | from collections import Counter
N = eval(input())
CARDS = list(map(int, input().split()))
hist = Counter(CARDS)
dup = N - len(hist)
eat = (dup+1)/2
print(N - eat*2) | from collections import Counter
N = int(eval(input()))
src = list(map(int,input().split()))
ctr = Counter(src)
even = len([a for a in list(ctr.values()) if a%2==0])
ans = len(ctr)
if even%2:
ans -= 1
print(ans) | 7 | 9 | 161 | 210 | from collections import Counter
N = eval(input())
CARDS = list(map(int, input().split()))
hist = Counter(CARDS)
dup = N - len(hist)
eat = (dup + 1) / 2
print(N - eat * 2)
| from collections import Counter
N = int(eval(input()))
src = list(map(int, input().split()))
ctr = Counter(src)
even = len([a for a in list(ctr.values()) if a % 2 == 0])
ans = len(ctr)
if even % 2:
ans -= 1
print(ans)
| false | 22.222222 | [
"-N = eval(input())",
"-CARDS = list(map(int, input().split()))",
"-hist = Counter(CARDS)",
"-dup = N - len(hist)",
"-eat = (dup + 1) / 2",
"-print(N - eat * 2)",
"+N = int(eval(input()))",
"+src = list(map(int, input().split()))",
"+ctr = Counter(src)",
"+even = len([a for a in list(ctr.values())... | false | 0.037118 | 0.058993 | 0.629192 | [
"s136280600",
"s273825882"
] |
u908372127 | p02915 | python | s938389237 | s578315962 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
p=input().rstrip()
p=int(p)
print((p**3)) | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
p=input().rstrip()
print((int(p)**3))
| 7 | 7 | 115 | 113 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
p = input().rstrip()
p = int(p)
print((p**3))
| import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
p = input().rstrip()
print((int(p) ** 3))
| false | 0 | [
"-p = int(p)",
"-print((p**3))",
"+print((int(p) ** 3))"
] | false | 0.043187 | 0.048637 | 0.88795 | [
"s938389237",
"s578315962"
] |
u102960641 | p02624 | python | s338061198 | s523843051 | 75 | 36 | 64,788 | 9,312 | Accepted | Accepted | 52 | import math
n = int(eval(input()))
ans = 0
SQRT = int(n ** 0.5)
for m in range(1,int(n ** 0.5) + 1):
ans += m * (m + int(n/m)) * (int(n/m) + 1 - m)
ans -= SQRT * (SQRT+1) * (2*SQRT+1) // 6
print(ans)
| n = int(eval(input()))
ans = 0
SQRT = int(n ** 0.5)
for m in range(1,SQRT + 1):
b = int(n/m)
ans += m * (m + b) * (b + 1 - m)
ans -= SQRT * (SQRT+1) * (2*SQRT+1) // 6
print(ans) | 9 | 8 | 207 | 186 | import math
n = int(eval(input()))
ans = 0
SQRT = int(n**0.5)
for m in range(1, int(n**0.5) + 1):
ans += m * (m + int(n / m)) * (int(n / m) + 1 - m)
ans -= SQRT * (SQRT + 1) * (2 * SQRT + 1) // 6
print(ans)
| n = int(eval(input()))
ans = 0
SQRT = int(n**0.5)
for m in range(1, SQRT + 1):
b = int(n / m)
ans += m * (m + b) * (b + 1 - m)
ans -= SQRT * (SQRT + 1) * (2 * SQRT + 1) // 6
print(ans)
| false | 11.111111 | [
"-import math",
"-",
"-for m in range(1, int(n**0.5) + 1):",
"- ans += m * (m + int(n / m)) * (int(n / m) + 1 - m)",
"+for m in range(1, SQRT + 1):",
"+ b = int(n / m)",
"+ ans += m * (m + b) * (b + 1 - m)"
] | false | 0.041971 | 0.042218 | 0.994161 | [
"s338061198",
"s523843051"
] |
u112002050 | p04043 | python | s706555479 | s949785547 | 43 | 39 | 3,064 | 3,064 | Accepted | Accepted | 9.3 | phrases = [ int(i) for i in input().split() ]
if phrases.count(5) == 2 and 5 in phrases:
print("YES")
else:
print("NO") | phrases = [ int(i) for i in input().split() ]
if phrases.count(5) == 2 and 7 in phrases:
print("YES")
else:
print("NO") | 5 | 5 | 125 | 125 | phrases = [int(i) for i in input().split()]
if phrases.count(5) == 2 and 5 in phrases:
print("YES")
else:
print("NO")
| phrases = [int(i) for i in input().split()]
if phrases.count(5) == 2 and 7 in phrases:
print("YES")
else:
print("NO")
| false | 0 | [
"-if phrases.count(5) == 2 and 5 in phrases:",
"+if phrases.count(5) == 2 and 7 in phrases:"
] | false | 0.04276 | 0.104435 | 0.409438 | [
"s706555479",
"s949785547"
] |
u843175622 | p03674 | python | s451057067 | s835380675 | 1,096 | 774 | 23,988 | 20,200 | Accepted | Accepted | 29.38 |
from collections import defaultdict
n = int(eval(input())) + 1
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
# 1を一つだけ選ぶやつは重複する可能性
d = defaultdict(int)
left = right = 0
for i in range(n):
if d[a[i]] > 0:
right = i
left = a.index(a[i])
break
d[a[i]] += 1
fac ... | n = int(eval(input())) + 1
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
# 1を一つだけ選ぶやつは重複する可能性
d = [False] * (n + 1)
left = right = 0
for i in range(n):
if d[a[i]]:
right = i
left = a.index(a[i])
break
d[a[i]] = True
fac = [1] * (n + 1)
for i in range(1, n + 1... | 40 | 37 | 785 | 692 | from collections import defaultdict
n = int(eval(input())) + 1
a = list(map(int, input().split()))
mod = 10**9 + 7
# 1を一つだけ選ぶやつは重複する可能性
d = defaultdict(int)
left = right = 0
for i in range(n):
if d[a[i]] > 0:
right = i
left = a.index(a[i])
break
d[a[i]] += 1
fac = [1] * (n + 1)
for i in... | n = int(eval(input())) + 1
a = list(map(int, input().split()))
mod = 10**9 + 7
# 1を一つだけ選ぶやつは重複する可能性
d = [False] * (n + 1)
left = right = 0
for i in range(n):
if d[a[i]]:
right = i
left = a.index(a[i])
break
d[a[i]] = True
fac = [1] * (n + 1)
for i in range(1, n + 1):
fac[i] = fac[i -... | false | 7.5 | [
"-from collections import defaultdict",
"-",
"-d = defaultdict(int)",
"+d = [False] * (n + 1)",
"- if d[a[i]] > 0:",
"+ if d[a[i]]:",
"- d[a[i]] += 1",
"+ d[a[i]] = True",
"- ans = c(n, i) - (c(left_len + 1 + right_len, i) - c(left_len + right_len, i))",
"+ ans = c(n, i) - c(left... | false | 0.037596 | 0.035892 | 1.047482 | [
"s451057067",
"s835380675"
] |
u077291787 | p03308 | python | s873746638 | s885445947 | 21 | 17 | 3,060 | 2,940 | Accepted | Accepted | 19.05 | # ABC102B - Maximum Difference
n = int(eval(input()))
lst = list(map(int, input().rstrip().split()))
max_dif = 0
for i in range(n):
for j in range(n):
max_dif = max(max_dif, abs(lst[i] - lst[j]))
print(max_dif) | # ABC102B - Maximum Difference
# Better ver.
n = int(eval(input()))
lst = sorted(list(map(int, input().rstrip().split())))
print((lst[-1] - lst[0])) | 10 | 5 | 231 | 144 | # ABC102B - Maximum Difference
n = int(eval(input()))
lst = list(map(int, input().rstrip().split()))
max_dif = 0
for i in range(n):
for j in range(n):
max_dif = max(max_dif, abs(lst[i] - lst[j]))
print(max_dif)
| # ABC102B - Maximum Difference
# Better ver.
n = int(eval(input()))
lst = sorted(list(map(int, input().rstrip().split())))
print((lst[-1] - lst[0]))
| false | 50 | [
"+# Better ver.",
"-lst = list(map(int, input().rstrip().split()))",
"-max_dif = 0",
"-for i in range(n):",
"- for j in range(n):",
"- max_dif = max(max_dif, abs(lst[i] - lst[j]))",
"-print(max_dif)",
"+lst = sorted(list(map(int, input().rstrip().split())))",
"+print((lst[-1] - lst[0]))"
] | false | 0.040093 | 0.07644 | 0.524494 | [
"s873746638",
"s885445947"
] |
u821432765 | p03029 | python | s193170823 | s234866779 | 172 | 17 | 38,256 | 2,940 | Accepted | Accepted | 90.12 | a,p=list(map(int,input().split()))
print(((a*3+p)//2)) | A, P = [int(i) for i in input().split()]
print(((A*3+P)//2)) | 2 | 2 | 47 | 59 | a, p = list(map(int, input().split()))
print(((a * 3 + p) // 2))
| A, P = [int(i) for i in input().split()]
print(((A * 3 + P) // 2))
| false | 0 | [
"-a, p = list(map(int, input().split()))",
"-print(((a * 3 + p) // 2))",
"+A, P = [int(i) for i in input().split()]",
"+print(((A * 3 + P) // 2))"
] | false | 0.136283 | 0.039405 | 3.458487 | [
"s193170823",
"s234866779"
] |
u604774382 | p02393 | python | s080182263 | s853892623 | 30 | 20 | 6,724 | 4,200 | Accepted | Accepted | 33.33 | #coding:utf-8
import sys
abc=sys.stdin.readline()
nums=abc.split( ' ' )
for i in range( len( nums) ):
nums[i] = int( nums[i] )
nums.sort()
print(( "{} {} {}".format( nums[0], nums[1], nums[2] ) )) | import sys
nums = [ int( val ) for val in sys.stdin.readline().split( " " ) ]
nums = sorted( nums )
print(( "{:d} {:d} {:d}".format( nums[0], nums[1], nums[2] ) )) | 9 | 5 | 205 | 167 | # coding:utf-8
import sys
abc = sys.stdin.readline()
nums = abc.split(" ")
for i in range(len(nums)):
nums[i] = int(nums[i])
nums.sort()
print(("{} {} {}".format(nums[0], nums[1], nums[2])))
| import sys
nums = [int(val) for val in sys.stdin.readline().split(" ")]
nums = sorted(nums)
print(("{:d} {:d} {:d}".format(nums[0], nums[1], nums[2])))
| false | 44.444444 | [
"-# coding:utf-8",
"-abc = sys.stdin.readline()",
"-nums = abc.split(\" \")",
"-for i in range(len(nums)):",
"- nums[i] = int(nums[i])",
"-nums.sort()",
"-print((\"{} {} {}\".format(nums[0], nums[1], nums[2])))",
"+nums = [int(val) for val in sys.stdin.readline().split(\" \")]",
"+nums = sorted(n... | false | 0.086017 | 0.039837 | 2.159221 | [
"s080182263",
"s853892623"
] |
u829249049 | p02647 | python | s397571647 | s154913610 | 395 | 340 | 169,632 | 168,644 | Accepted | Accepted | 13.92 | N,K=list(map(int,input().split()))
A=list(map(int,input().split()))
imos=[0 for i in range(N+1)]
for t in range(K):
for i in range(N):
l=max(0,i-A[i])
r=min(N,i+A[i]+1)
imos[l]+=1
imos[r]-=1
for i in range(0,N):
imos[i+1]+=imos[i]
A[i]=imos[i]
imos=[0 for i in range(N+1)]
... | N,K=list(map(int,input().split()))
A=list(map(int,input().split()))
imos=[0 for i in range(N+1)]
zero=[0 for i in range(N+1)]
ANS=[str(N)]*N
if K>=40:
ans=" ".join(ANS)
print(ans)
else:
for t in range(K):
for i in range(N):
l=max(0,i-A[i])
r=min(N,i+A[i]+1)
imos[l]+=1
imo... | 20 | 23 | 430 | 504 | N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
imos = [0 for i in range(N + 1)]
for t in range(K):
for i in range(N):
l = max(0, i - A[i])
r = min(N, i + A[i] + 1)
imos[l] += 1
imos[r] -= 1
for i in range(0, N):
imos[i + 1] += imos[i]
A... | N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
imos = [0 for i in range(N + 1)]
zero = [0 for i in range(N + 1)]
ANS = [str(N)] * N
if K >= 40:
ans = " ".join(ANS)
print(ans)
else:
for t in range(K):
for i in range(N):
l = max(0, i - A[i])
r = min(... | false | 13.043478 | [
"-for t in range(K):",
"+zero = [0 for i in range(N + 1)]",
"+ANS = [str(N)] * N",
"+if K >= 40:",
"+ ans = \" \".join(ANS)",
"+ print(ans)",
"+else:",
"+ for t in range(K):",
"+ for i in range(N):",
"+ l = max(0, i - A[i])",
"+ r = min(N, i + A[i] + 1)",
... | false | 0.042202 | 0.04176 | 1.010588 | [
"s397571647",
"s154913610"
] |
u838644735 | p03645 | python | s953258359 | s358897601 | 571 | 186 | 19,024 | 46,660 | Accepted | Accepted | 67.43 | def solve():
N, M = map(int, input().split())
FROM_1 = set()
TO_N = set()
for i in range(M):
a, b = map(int, input().split())
if a == 1:
FROM_1.add(b)
elif a == N:
TO_N.add(b)
if b == 1:
FROM_1.add(a)
elif b == N:
... | def solve():
N, M, *AB = map(int, open(0).read().split())
FROM_1 = set()
TO_N = set()
for i in range(M):
a, b = AB[2*i], AB[2*i + 1]
if a == 1:
FROM_1.add(b)
elif a == N:
TO_N.add(b)
if b == 1:
FROM_1.add(a)
elif b =... | 19 | 19 | 466 | 472 | def solve():
N, M = map(int, input().split())
FROM_1 = set()
TO_N = set()
for i in range(M):
a, b = map(int, input().split())
if a == 1:
FROM_1.add(b)
elif a == N:
TO_N.add(b)
if b == 1:
FROM_1.add(a)
elif b == N:
TO... | def solve():
N, M, *AB = map(int, open(0).read().split())
FROM_1 = set()
TO_N = set()
for i in range(M):
a, b = AB[2 * i], AB[2 * i + 1]
if a == 1:
FROM_1.add(b)
elif a == N:
TO_N.add(b)
if b == 1:
FROM_1.add(a)
elif b == N:
... | false | 0 | [
"- N, M = map(int, input().split())",
"+ N, M, *AB = map(int, open(0).read().split())",
"- a, b = map(int, input().split())",
"+ a, b = AB[2 * i], AB[2 * i + 1]"
] | false | 0.041935 | 0.144138 | 0.290938 | [
"s953258359",
"s358897601"
] |
u693716675 | p02935 | python | s693728122 | s199164351 | 20 | 17 | 3,060 | 2,940 | Accepted | Accepted | 15 | n = int(eval(input()))
a = [int(i) for i in input().split()]
a.sort()
s = a[0]
for i in range(n):
s = (s+a[i])/2
print(s) | ### 138-c
n = int(eval(input()))
v = [int(i) for i in input().split()]
v.sort()
ans = v[0]
for i in range(1,n):
ans = (ans+v[i])/2
print(ans) | 9 | 9 | 129 | 148 | n = int(eval(input()))
a = [int(i) for i in input().split()]
a.sort()
s = a[0]
for i in range(n):
s = (s + a[i]) / 2
print(s)
| ### 138-c
n = int(eval(input()))
v = [int(i) for i in input().split()]
v.sort()
ans = v[0]
for i in range(1, n):
ans = (ans + v[i]) / 2
print(ans)
| false | 0 | [
"+### 138-c",
"-a = [int(i) for i in input().split()]",
"-a.sort()",
"-s = a[0]",
"-for i in range(n):",
"- s = (s + a[i]) / 2",
"-print(s)",
"+v = [int(i) for i in input().split()]",
"+v.sort()",
"+ans = v[0]",
"+for i in range(1, n):",
"+ ans = (ans + v[i]) / 2",
"+print(ans)"
] | false | 0.101776 | 0.039794 | 2.557549 | [
"s693728122",
"s199164351"
] |
u416011173 | p02576 | python | s739053569 | s167032959 | 31 | 28 | 9,084 | 9,160 | Accepted | Accepted | 9.68 | # -*- coding: utf-8 -*-
# モジュールのインポート
import math
# 標準入力を取得
N, X, T = list(map(int, input().split()))
# 求解処理
ans = math.ceil(N / X) * T
# 結果出力
print(ans)
| # -*- coding: utf-8 -*-
# モジュールのインポート
import math
def get_input() -> tuple:
"""
標準入力を取得する.
Returns:\n
tuple: 標準入力
"""
N, X, T = list(map(int, input().split()))
return N, X, T
def main(N: int, X: int, T: int) -> None:
"""
メイン処理.
Args:\n
N (... | 12 | 39 | 168 | 629 | # -*- coding: utf-8 -*-
# モジュールのインポート
import math
# 標準入力を取得
N, X, T = list(map(int, input().split()))
# 求解処理
ans = math.ceil(N / X) * T
# 結果出力
print(ans)
| # -*- coding: utf-8 -*-
# モジュールのインポート
import math
def get_input() -> tuple:
"""
標準入力を取得する.
Returns:\n
tuple: 標準入力
"""
N, X, T = list(map(int, input().split()))
return N, X, T
def main(N: int, X: int, T: int) -> None:
"""
メイン処理.
Args:\n
N (int): 作るたこ焼きの個数(1 <= N <=... | false | 69.230769 | [
"-# 標準入力を取得",
"-N, X, T = list(map(int, input().split()))",
"-# 求解処理",
"-ans = math.ceil(N / X) * T",
"-# 結果出力",
"-print(ans)",
"+",
"+def get_input() -> tuple:",
"+ \"\"\"",
"+ 標準入力を取得する.",
"+ Returns:\\n",
"+ tuple: 標準入力",
"+ \"\"\"",
"+ N, X, T = list(map(int, inpu... | false | 0.0513 | 0.049296 | 1.040661 | [
"s739053569",
"s167032959"
] |
u657361950 | p02412 | python | s510809367 | s346931570 | 460 | 30 | 5,596 | 5,596 | Accepted | Accepted | 93.48 |
while True:
arr = list(map(int, input().split()))
n = arr[0]
x = arr[1]
if n == 0 and x == 0:
break
ans = 0
for i in range(1, n + 1):
for j in range(i + 1, n + 1):
for k in range(j + 1, n + 1):
if i + j + k == x:
ans += 1
print(ans)
|
def subset_sum(n,a,s):
cnt=0
for i in range(n):
r=s-a[i]
j=i+1
k=n-1
while j<k:
t=a[j]+a[k]
if t<r:
j+=1
elif t>r:
k-=1
else:
cnt+=1
j+=1
k-=1
return cnt
while True:
n,s=list(map(int,input().split()))
if n==0 and s==0:
break
a=[0]*n
for i in ran... | 16 | 28 | 274 | 362 | while True:
arr = list(map(int, input().split()))
n = arr[0]
x = arr[1]
if n == 0 and x == 0:
break
ans = 0
for i in range(1, n + 1):
for j in range(i + 1, n + 1):
for k in range(j + 1, n + 1):
if i + j + k == x:
ans += 1
print(... | def subset_sum(n, a, s):
cnt = 0
for i in range(n):
r = s - a[i]
j = i + 1
k = n - 1
while j < k:
t = a[j] + a[k]
if t < r:
j += 1
elif t > r:
k -= 1
else:
cnt += 1
j +... | false | 42.857143 | [
"+def subset_sum(n, a, s):",
"+ cnt = 0",
"+ for i in range(n):",
"+ r = s - a[i]",
"+ j = i + 1",
"+ k = n - 1",
"+ while j < k:",
"+ t = a[j] + a[k]",
"+ if t < r:",
"+ j += 1",
"+ elif t > r:",
"+ ... | false | 0.074401 | 0.035563 | 2.09206 | [
"s510809367",
"s346931570"
] |
u762420987 | p03137 | python | s394119156 | s183485932 | 114 | 105 | 13,968 | 13,968 | Accepted | Accepted | 7.89 | N, M = list(map(int, input().split()))
Xlist = sorted(list(map(int, input().split())))
Llist = []
for i in range(M - 1):
Llist.append(Xlist[i + 1] - Xlist[i])
Llist.sort()
print((sum(Llist[:M - N]) if N < M else 0))
| N, M = list(map(int, input().split()))
Xlist = sorted(list(map(int, input().split())))
sbn = sorted([abs(Xlist[i + 1] - Xlist[i]) for i in range(M - 1)])[::-1]
if N >= M:
print((0))
else:
print((sum(sbn[N - 1:])))
| 7 | 7 | 218 | 218 | N, M = list(map(int, input().split()))
Xlist = sorted(list(map(int, input().split())))
Llist = []
for i in range(M - 1):
Llist.append(Xlist[i + 1] - Xlist[i])
Llist.sort()
print((sum(Llist[: M - N]) if N < M else 0))
| N, M = list(map(int, input().split()))
Xlist = sorted(list(map(int, input().split())))
sbn = sorted([abs(Xlist[i + 1] - Xlist[i]) for i in range(M - 1)])[::-1]
if N >= M:
print((0))
else:
print((sum(sbn[N - 1 :])))
| false | 0 | [
"-Llist = []",
"-for i in range(M - 1):",
"- Llist.append(Xlist[i + 1] - Xlist[i])",
"-Llist.sort()",
"-print((sum(Llist[: M - N]) if N < M else 0))",
"+sbn = sorted([abs(Xlist[i + 1] - Xlist[i]) for i in range(M - 1)])[::-1]",
"+if N >= M:",
"+ print((0))",
"+else:",
"+ print((sum(sbn[N ... | false | 0.039103 | 0.044259 | 0.883489 | [
"s394119156",
"s183485932"
] |
u334712262 | p02816 | python | s363269442 | s127555888 | 859 | 649 | 120,744 | 125,844 | Accepted | Accepted | 24.45 | # -*- coding: utf-8 -*-
import sys
from collections import Counter, defaultdict
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline
def read_int():
return int(buff_readline())
def read_int_n():
return list(map(int, buff_readline().split()))
class RollingHash():
"""
... | # -*- coding: utf-8 -*-
import sys
from collections import Counter, defaultdict
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline
def read_int():
return int(buff_readline())
def read_int_n():
return list(map(int, buff_readline().split()))
class RollingHash():
"""
... | 104 | 105 | 2,580 | 2,573 | # -*- coding: utf-8 -*-
import sys
from collections import Counter, defaultdict
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline
def read_int():
return int(buff_readline())
def read_int_n():
return list(map(int, buff_readline().split()))
class RollingHash:
"""
Original code... | # -*- coding: utf-8 -*-
import sys
from collections import Counter, defaultdict
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline
def read_int():
return int(buff_readline())
def read_int_n():
return list(map(int, buff_readline().split()))
class RollingHash:
"""
Original code... | false | 0.952381 | [
"+ a = a[:] + a[:]",
"+ h = bh.calc(0, N)",
"- if ah.calc(k, N) == bh.calc(0, N - k) and ah.calc(0, k) == bh.calc(N - k, N):",
"+ if ah.calc(k, N + k) == h:"
] | false | 0.044858 | 0.045476 | 0.986406 | [
"s363269442",
"s127555888"
] |
u747602774 | p03569 | python | s453681770 | s724856809 | 74 | 68 | 8,736 | 3,316 | Accepted | Accepted | 8.11 | S = eval(input())
N = len(S)
ans = []
check = []
for i in range(N):
if S[i] != 'x':
ans.append(S[i])
check.append(i)
if len(ans) == 0:
print((0))
exit()
if ans != ans[::-1]:
print((-1))
exit()
if len(ans)%2:
cl,cr = check[len(ans)//2],check[len(ans)//2]
else:
... | S = eval(input())
N = len(S)
l = 0
r = N-1
ans = 0
while l < r:
if S[l] == S[r]:
l += 1
r -= 1
elif S[l] == 'x':
l += 1
ans += 1
elif S[r] == 'x':
r -= 1
ans += 1
else:
print((-1))
exit()
print(ans)
| 31 | 20 | 596 | 291 | S = eval(input())
N = len(S)
ans = []
check = []
for i in range(N):
if S[i] != "x":
ans.append(S[i])
check.append(i)
if len(ans) == 0:
print((0))
exit()
if ans != ans[::-1]:
print((-1))
exit()
if len(ans) % 2:
cl, cr = check[len(ans) // 2], check[len(ans) // 2]
else:
cl, cr =... | S = eval(input())
N = len(S)
l = 0
r = N - 1
ans = 0
while l < r:
if S[l] == S[r]:
l += 1
r -= 1
elif S[l] == "x":
l += 1
ans += 1
elif S[r] == "x":
r -= 1
ans += 1
else:
print((-1))
exit()
print(ans)
| false | 35.483871 | [
"-ans = []",
"-check = []",
"-for i in range(N):",
"- if S[i] != \"x\":",
"- ans.append(S[i])",
"- check.append(i)",
"-if len(ans) == 0:",
"- print((0))",
"- exit()",
"-if ans != ans[::-1]:",
"- print((-1))",
"- exit()",
"-if len(ans) % 2:",
"- cl, cr = chec... | false | 0.04403 | 0.06215 | 0.708451 | [
"s453681770",
"s724856809"
] |
u261103969 | p02695 | python | s726656474 | s759660721 | 1,168 | 672 | 9,092 | 23,164 | Accepted | Accepted | 42.47 | from itertools import combinations_with_replacement as comb_rplc
n, m, q = list(map(int, input().split()))
# reqは[[a1,b1,c1,d1],[a2,b2,c2,d2]……]が入ったリストのリストです
req = [list(map(int, input().split())) for _ in range(q)]
ans = 0
# seqは長さnのタプルです
for seq in comb_rplc(list(range(1, m + 1)), n):
score = 0
fo... | from collections import deque
# 数列の点数を計算する関数
def calc(seq):
score = 0
for a, b, c, d in req:
if seq[b - 1] - seq[a - 1] == c:
score += d
return score
n, m, q = list(map(int, input().split()))
req = [list(map(int, input().split())) for _ in range(q)]
ans = 0
que =... | 17 | 39 | 489 | 771 | from itertools import combinations_with_replacement as comb_rplc
n, m, q = list(map(int, input().split()))
# reqは[[a1,b1,c1,d1],[a2,b2,c2,d2]……]が入ったリストのリストです
req = [list(map(int, input().split())) for _ in range(q)]
ans = 0
# seqは長さnのタプルです
for seq in comb_rplc(list(range(1, m + 1)), n):
score = 0
for a, b, c, ... | from collections import deque
# 数列の点数を計算する関数
def calc(seq):
score = 0
for a, b, c, d in req:
if seq[b - 1] - seq[a - 1] == c:
score += d
return score
n, m, q = list(map(int, input().split()))
req = [list(map(int, input().split())) for _ in range(q)]
ans = 0
que = deque()
# 数列の1番目、[1]~... | false | 56.410256 | [
"-from itertools import combinations_with_replacement as comb_rplc",
"+from collections import deque",
"+",
"+# 数列の点数を計算する関数",
"+def calc(seq):",
"+ score = 0",
"+ for a, b, c, d in req:",
"+ if seq[b - 1] - seq[a - 1] == c:",
"+ score += d",
"+ return score",
"+",
"... | false | 0.134772 | 0.006977 | 19.315389 | [
"s726656474",
"s759660721"
] |
u077291787 | p02767 | python | s503792099 | s986295984 | 21 | 18 | 3,060 | 2,940 | Accepted | Accepted | 14.29 | # C - Rally
def main():
N, *X = list(map(int, open(0).read().split()))
left, right = min(X), max(X)
ans = min(sum([(x - p) ** 2 for x in X]) for p in range(left, right + 1))
print(ans)
if __name__ == "__main__":
main()
| # C - Rally
def main():
N, *X = list(map(int, open(0).read().split()))
calc = lambda x, p: (x - p) ** 2
P = sum(X) // N
ans = min(sum(calc(x, p) for x in X) for p in range(P - 2, P + 2))
print(ans)
if __name__ == "__main__":
main()
| 10 | 11 | 249 | 262 | # C - Rally
def main():
N, *X = list(map(int, open(0).read().split()))
left, right = min(X), max(X)
ans = min(sum([(x - p) ** 2 for x in X]) for p in range(left, right + 1))
print(ans)
if __name__ == "__main__":
main()
| # C - Rally
def main():
N, *X = list(map(int, open(0).read().split()))
calc = lambda x, p: (x - p) ** 2
P = sum(X) // N
ans = min(sum(calc(x, p) for x in X) for p in range(P - 2, P + 2))
print(ans)
if __name__ == "__main__":
main()
| false | 9.090909 | [
"- left, right = min(X), max(X)",
"- ans = min(sum([(x - p) ** 2 for x in X]) for p in range(left, right + 1))",
"+ calc = lambda x, p: (x - p) ** 2",
"+ P = sum(X) // N",
"+ ans = min(sum(calc(x, p) for x in X) for p in range(P - 2, P + 2))"
] | false | 0.105322 | 0.044449 | 2.369526 | [
"s503792099",
"s986295984"
] |
u724687935 | p02683 | python | s118042296 | s829846362 | 83 | 30 | 9,224 | 9,332 | Accepted | Accepted | 63.86 | import sys
N, M, X = list(map(int, input().split()))
A = [None] * N
C = [None] * N
for i, s in enumerate(sys.stdin.readlines()):
C[i], *A[i] = list(map(int, s.split()))
ans = 10 ** 8
for i in range(1 << N):
k = 0
v = 0
S = [0] * M
while (i >> k) > 0:
if (i >> k) & 1:
... | import sys
sys.setrecursionlimit(10 ** 6)
def dfs(n, v, m):
global N, M, X
rst = 10 ** 8
if n == N:
if all(x >= X for x in m):
rst = v
else:
nv = v + C[n]
nm = tuple(m[i] + A[n][i] for i in range(M))
rst = min(dfs(n + 1, v, m), dfs(n + 1, nv, nm... | 29 | 26 | 536 | 581 | import sys
N, M, X = list(map(int, input().split()))
A = [None] * N
C = [None] * N
for i, s in enumerate(sys.stdin.readlines()):
C[i], *A[i] = list(map(int, s.split()))
ans = 10**8
for i in range(1 << N):
k = 0
v = 0
S = [0] * M
while (i >> k) > 0:
if (i >> k) & 1:
for j in rang... | import sys
sys.setrecursionlimit(10**6)
def dfs(n, v, m):
global N, M, X
rst = 10**8
if n == N:
if all(x >= X for x in m):
rst = v
else:
nv = v + C[n]
nm = tuple(m[i] + A[n][i] for i in range(M))
rst = min(dfs(n + 1, v, m), dfs(n + 1, nv, nm))
return rs... | false | 10.344828 | [
"+",
"+sys.setrecursionlimit(10**6)",
"+",
"+",
"+def dfs(n, v, m):",
"+ global N, M, X",
"+ rst = 10**8",
"+ if n == N:",
"+ if all(x >= X for x in m):",
"+ rst = v",
"+ else:",
"+ nv = v + C[n]",
"+ nm = tuple(m[i] + A[n][i] for i in range(M))",
... | false | 0.038859 | 0.046265 | 0.839911 | [
"s118042296",
"s829846362"
] |
u279493135 | p03645 | python | s375376438 | s545799987 | 928 | 741 | 93,788 | 58,448 | Accepted | Accepted | 20.15 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
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... | 49 | 34 | 1,301 | 926 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
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 | 30.612245 | [
"-from itertools import permutations, combinations, product, accumulate",
"+from itertools import accumulate, permutations, combinations, product",
"+from bisect import bisect, bisect_left",
"-from bisect import bisect",
"-mod = 10**9 + 7",
"+MOD = 10**9 + 7",
"-ab = [LIST() for _ in range(M)]",
"-",
... | false | 0.041045 | 0.044467 | 0.923048 | [
"s375376438",
"s545799987"
] |
u361826811 | p02898 | python | s725495602 | s662511945 | 264 | 181 | 19,488 | 19,524 | Accepted | Accepted | 31.44 | """
author : halo2halo
date : 9, Jan, 2020
"""
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
# N = int(readline())
# D = [int(d) for d in readline().split()]
import numpy as np
N, K = list(map(int,... | """
author : halo2halo
date : 9, Jan, 2020
"""
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
# N = int(readline())
# D = [int(d) for d in readline().split()]
import numpy as np
N, K = list(map(int,... | 22 | 23 | 436 | 444 | """
author : halo2halo
date : 9, Jan, 2020
"""
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
# N = int(readline())
# D = [int(d) for d in readline().split()]
import numpy as np
N, K = list(map(int, readline().split()))
... | """
author : halo2halo
date : 9, Jan, 2020
"""
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
# N = int(readline())
# D = [int(d) for d in readline().split()]
import numpy as np
N, K = list(map(int, readline().split()))
... | false | 4.347826 | [
"-ha = np.array(h)",
"-print((np.count_nonzero(ha >= 0)))",
"+# ha = np.array(h)",
"+print((len([x for x in h if x >= 0])))"
] | false | 0.712471 | 0.041027 | 17.365843 | [
"s725495602",
"s662511945"
] |
u078349616 | p02633 | python | s318663147 | s615620725 | 29 | 23 | 9,148 | 9,156 | Accepted | Accepted | 20.69 | X = int(eval(input()))
theta, k = 0, 0
while theta != 360:
theta += X
k += 1
if theta > 360:
theta -= 360
print(k) | X = int(eval(input()))
theta, k = 0, 0
while theta % 360 != 0 or theta == 0:
theta += X
k += 1
print(k) | 9 | 6 | 137 | 110 | X = int(eval(input()))
theta, k = 0, 0
while theta != 360:
theta += X
k += 1
if theta > 360:
theta -= 360
print(k)
| X = int(eval(input()))
theta, k = 0, 0
while theta % 360 != 0 or theta == 0:
theta += X
k += 1
print(k)
| false | 33.333333 | [
"-while theta != 360:",
"+while theta % 360 != 0 or theta == 0:",
"- if theta > 360:",
"- theta -= 360"
] | false | 0.046052 | 0.081951 | 0.561946 | [
"s318663147",
"s615620725"
] |
u488401358 | p03306 | python | s896863706 | s592821523 | 770 | 540 | 77,984 | 71,420 | Accepted | Accepted | 29.87 | n,m=list(map(int,input().split()))
edge=[[] for i in range(n)]
for i in range(m):
u,v,s=list(map(int,input().split()))
edge[u-1].append((v-1,s))
edge[v-1].append((u-1,s))
ans=[1 for i in range(n)]
pm=[True]*n
used=[False]*n
used[0]=True
que=[0]
while que:
u=que.pop()
for v,s in ed... | import sys
input=sys.stdin.readline
n,m=list(map(int,input().split()))
edge=[[] for i in range(n)]
for i in range(m):
u,v,s=list(map(int,input().split()))
edge[u-1].append((v-1,s))
edge[v-1].append((u-1,s))
ans=[1 for i in range(n)]
pm=[True]*n
used=[False]*n
used[0]=True
que=[0]
whil... | 100 | 104 | 2,397 | 2,440 | n, m = list(map(int, input().split()))
edge = [[] for i in range(n)]
for i in range(m):
u, v, s = list(map(int, input().split()))
edge[u - 1].append((v - 1, s))
edge[v - 1].append((u - 1, s))
ans = [1 for i in range(n)]
pm = [True] * n
used = [False] * n
used[0] = True
que = [0]
while que:
u = que.pop()... | import sys
input = sys.stdin.readline
n, m = list(map(int, input().split()))
edge = [[] for i in range(n)]
for i in range(m):
u, v, s = list(map(int, input().split()))
edge[u - 1].append((v - 1, s))
edge[v - 1].append((u - 1, s))
ans = [1 for i in range(n)]
pm = [True] * n
used = [False] * n
used[0] = True... | false | 3.846154 | [
"+import sys",
"+",
"+input = sys.stdin.readline"
] | false | 0.042732 | 0.043436 | 0.983799 | [
"s896863706",
"s592821523"
] |
u345621867 | p02813 | python | s438902047 | s751766995 | 66 | 46 | 10,868 | 13,972 | Accepted | Accepted | 30.3 | import itertools as it
N = int(eval(input()))
Q = []
P = []
Q = list(map(int, input().split()))
P = list(map(int, input().split()))
Jun = []
box = [i+1 for i in range(N)]
for num in it.permutations(Q):
num = list(num)
Jun.append(num)
Jun = sorted(Jun)
for i, num in enumerate(Jun):
if Q == num... | import itertools as it
N = int(eval(input()))
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))
a = 0
b = 0
array = list(it.permutations(i for i in range(1,N+1)))
for i,ar in enumerate(array):
if ar == P:
a = i
if ar == Q:
b = i
print((abs(a-b))) | 20 | 13 | 383 | 296 | import itertools as it
N = int(eval(input()))
Q = []
P = []
Q = list(map(int, input().split()))
P = list(map(int, input().split()))
Jun = []
box = [i + 1 for i in range(N)]
for num in it.permutations(Q):
num = list(num)
Jun.append(num)
Jun = sorted(Jun)
for i, num in enumerate(Jun):
if Q == num:
a ... | import itertools as it
N = int(eval(input()))
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
a = 0
b = 0
array = list(it.permutations(i for i in range(1, N + 1)))
for i, ar in enumerate(array):
if ar == P:
a = i
if ar == Q:
b = i
print((abs(a - b)))
| false | 35 | [
"-Q = []",
"-P = []",
"-Q = list(map(int, input().split()))",
"-P = list(map(int, input().split()))",
"-Jun = []",
"-box = [i + 1 for i in range(N)]",
"-for num in it.permutations(Q):",
"- num = list(num)",
"- Jun.append(num)",
"-Jun = sorted(Jun)",
"-for i, num in enumerate(Jun):",
"- ... | false | 0.046863 | 0.035853 | 1.307089 | [
"s438902047",
"s751766995"
] |
u894258749 | p03252 | python | s392303940 | s309626528 | 951 | 189 | 13,184 | 41,840 | Accepted | Accepted | 80.13 | import numpy as np
S = eval(input())
T = eval(input())
F = -np.ones(26,dtype=np.int)
G = -np.ones(26,dtype=np.int)
for i in range(len(S)):
s = ord(S[i])-ord('a')
t = ord(T[i])-ord('a')
if F[s] < 0:
F[s] = t
elif F[s] != t:
print('No')
exit()
if G[t] < 0:
... | from collections import defaultdict
class CountUp:
def __init__(self, start=0):
self.index = start-1
def __call__(self):
self.index += 1
return self.index
S = eval(input())
T = eval(input())
N = len(S)
Sdic = defaultdict(CountUp())
Tdic = defaultdict(CountUp())
for i in r... | 23 | 22 | 397 | 433 | import numpy as np
S = eval(input())
T = eval(input())
F = -np.ones(26, dtype=np.int)
G = -np.ones(26, dtype=np.int)
for i in range(len(S)):
s = ord(S[i]) - ord("a")
t = ord(T[i]) - ord("a")
if F[s] < 0:
F[s] = t
elif F[s] != t:
print("No")
exit()
if G[t] < 0:
G[t] =... | from collections import defaultdict
class CountUp:
def __init__(self, start=0):
self.index = start - 1
def __call__(self):
self.index += 1
return self.index
S = eval(input())
T = eval(input())
N = len(S)
Sdic = defaultdict(CountUp())
Tdic = defaultdict(CountUp())
for i in range(N):
... | false | 4.347826 | [
"-import numpy as np",
"+from collections import defaultdict",
"+",
"+",
"+class CountUp:",
"+ def __init__(self, start=0):",
"+ self.index = start - 1",
"+",
"+ def __call__(self):",
"+ self.index += 1",
"+ return self.index",
"+",
"-F = -np.ones(26, dtype=np.int)... | false | 0.164565 | 0.034976 | 4.70507 | [
"s392303940",
"s309626528"
] |
u373274281 | p03112 | python | s589498011 | s997548521 | 1,954 | 1,712 | 78,220 | 16,160 | Accepted | Accepted | 12.38 | import bisect
A, B, Q = list(map(int, input().split()))
INF = 10 ** 18
s = [-INF] + [int(eval(input())) for i in range(A)] + [INF]
t = [-INF] + [int(eval(input())) for i in range(B)] + [INF]
for q in range(Q):
x = int(eval(input()))
b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
res = INF
... | import sys
from bisect import bisect_left
a,b,q = list(map(int, sys.stdin.readline().split()))
S = []
for _ in range(a):
S.append(int(sys.stdin.readline()))
T = []
for _ in range(b):
T.append(int(sys.stdin.readline()))
X = []
for _ in range(q):
X.append(int(sys.stdin.readline()))
INF = 10 ** 11
def... | 14 | 55 | 463 | 1,190 | import bisect
A, B, Q = list(map(int, input().split()))
INF = 10**18
s = [-INF] + [int(eval(input())) for i in range(A)] + [INF]
t = [-INF] + [int(eval(input())) for i in range(B)] + [INF]
for q in range(Q):
x = int(eval(input()))
b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
res = INF
fo... | import sys
from bisect import bisect_left
a, b, q = list(map(int, sys.stdin.readline().split()))
S = []
for _ in range(a):
S.append(int(sys.stdin.readline()))
T = []
for _ in range(b):
T.append(int(sys.stdin.readline()))
X = []
for _ in range(q):
X.append(int(sys.stdin.readline()))
INF = 10**11
def dfs(d... | false | 74.545455 | [
"-import bisect",
"+import sys",
"+from bisect import bisect_left",
"-A, B, Q = list(map(int, input().split()))",
"-INF = 10**18",
"-s = [-INF] + [int(eval(input())) for i in range(A)] + [INF]",
"-t = [-INF] + [int(eval(input())) for i in range(B)] + [INF]",
"-for q in range(Q):",
"- x = int(eval... | false | 0.043016 | 0.087286 | 0.492809 | [
"s589498011",
"s997548521"
] |
u145950990 | p03041 | python | s333959638 | s510294583 | 171 | 24 | 38,256 | 8,996 | Accepted | Accepted | 85.96 | n,k = list(map(int,input().split()))
s = eval(input())
print((s[:k-1]+s[k-1].lower()+s[k:])) | n,k = list(map(int,input().split()))
s = list(eval(input()))
s[k-1] = s[k-1].lower()
print((''.join(s))) | 3 | 5 | 80 | 95 | n, k = list(map(int, input().split()))
s = eval(input())
print((s[: k - 1] + s[k - 1].lower() + s[k:]))
| n, k = list(map(int, input().split()))
s = list(eval(input()))
s[k - 1] = s[k - 1].lower()
print(("".join(s)))
| false | 40 | [
"-s = eval(input())",
"-print((s[: k - 1] + s[k - 1].lower() + s[k:]))",
"+s = list(eval(input()))",
"+s[k - 1] = s[k - 1].lower()",
"+print((\"\".join(s)))"
] | false | 0.038209 | 0.046098 | 0.828858 | [
"s333959638",
"s510294583"
] |
u037430802 | p03775 | python | s423886055 | s381382398 | 48 | 43 | 2,940 | 3,060 | Accepted | Accepted | 10.42 | N = int(eval(input()))
a = 1
i = 2
while i * i <= N:
if N % i == 0:
a = i
i += 1
b = N // a
print((max(len(str(a)), len(str(b))))) |
N = int(eval(input()))
ans = 11
a = 1
i = 1
while i * i <= N:
if N % i == 0:
a = i
b = N//a
ans = min(ans, len(str((max(a,b)))))
i += 1
print(ans) | 11 | 14 | 150 | 188 | N = int(eval(input()))
a = 1
i = 2
while i * i <= N:
if N % i == 0:
a = i
i += 1
b = N // a
print((max(len(str(a)), len(str(b)))))
| N = int(eval(input()))
ans = 11
a = 1
i = 1
while i * i <= N:
if N % i == 0:
a = i
b = N // a
ans = min(ans, len(str((max(a, b)))))
i += 1
print(ans)
| false | 21.428571 | [
"+ans = 11",
"-i = 2",
"+i = 1",
"+ b = N // a",
"+ ans = min(ans, len(str((max(a, b)))))",
"-b = N // a",
"-print((max(len(str(a)), len(str(b)))))",
"+print(ans)"
] | false | 0.057447 | 0.058425 | 0.983265 | [
"s423886055",
"s381382398"
] |
u312025627 | p03038 | python | s970427477 | s399556817 | 479 | 420 | 26,988 | 65,080 | Accepted | Accepted | 12.32 | def main():
N, M = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
bcs = [[int(i) for i in input().split()] for _ in range(M)]
A.sort()
bcs.sort(reverse=True,key=lambda c:c[1])
cards = []
for b,c in bcs:
for i in range(b):
cards.append(c... | def main():
import sys
input = sys.stdin.buffer.readline
# from heapq import heappop, heappush
N, M = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
A.sort(reverse=True)
BC = [[int(i) for i in input().split()] for j in range(M)]
BC.sort(key=lambda p: p[1]... | 27 | 26 | 675 | 671 | def main():
N, M = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
bcs = [[int(i) for i in input().split()] for _ in range(M)]
A.sort()
bcs.sort(reverse=True, key=lambda c: c[1])
cards = []
for b, c in bcs:
for i in range(b):
cards.append(c)
... | def main():
import sys
input = sys.stdin.buffer.readline
# from heapq import heappop, heappush
N, M = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
A.sort(reverse=True)
BC = [[int(i) for i in input().split()] for j in range(M)]
BC.sort(key=lambda p: p[1], rever... | false | 3.703704 | [
"+ import sys",
"+",
"+ input = sys.stdin.buffer.readline",
"+ # from heapq import heappop, heappush",
"- bcs = [[int(i) for i in input().split()] for _ in range(M)]",
"- A.sort()",
"- bcs.sort(reverse=True, key=lambda c: c[1])",
"- cards = []",
"- for b, c in bcs:",
"+ ... | false | 0.040427 | 0.134893 | 0.299697 | [
"s970427477",
"s399556817"
] |
u028973125 | p02819 | python | s386831234 | s764129653 | 185 | 114 | 38,896 | 25,980 | Accepted | Accepted | 38.38 | import sys
from pprint import pprint
import math
def is_prime(x):
if x == 1: return False
for k in range(2, int(math.sqrt(x)) + 1):
if x % k == 0:
return False
return True
def solve(x):
for i in range(x, 10**6):
if is_prime(i):
print(i)
... | import sys
X = int(sys.stdin.readline())
exists = set()
for i in range(2, X + 10**5 + 1):
if i in exists:
continue
exists.add(i)
if X <= i:
# print(exists)
print(i)
sys.exit()
for j in range(i+i, X + 10**5 + 1, i):
exists.add(j) | 22 | 15 | 419 | 300 | import sys
from pprint import pprint
import math
def is_prime(x):
if x == 1:
return False
for k in range(2, int(math.sqrt(x)) + 1):
if x % k == 0:
return False
return True
def solve(x):
for i in range(x, 10**6):
if is_prime(i):
print(i)
ret... | import sys
X = int(sys.stdin.readline())
exists = set()
for i in range(2, X + 10**5 + 1):
if i in exists:
continue
exists.add(i)
if X <= i:
# print(exists)
print(i)
sys.exit()
for j in range(i + i, X + 10**5 + 1, i):
exists.add(j)
| false | 31.818182 | [
"-from pprint import pprint",
"-import math",
"-",
"-def is_prime(x):",
"- if x == 1:",
"- return False",
"- for k in range(2, int(math.sqrt(x)) + 1):",
"- if x % k == 0:",
"- return False",
"- return True",
"-",
"-",
"-def solve(x):",
"- for i in range... | false | 0.035262 | 0.082653 | 0.426629 | [
"s386831234",
"s764129653"
] |
u191394596 | p03160 | python | s065663811 | s584630541 | 1,024 | 158 | 287,328 | 13,980 | Accepted | Accepted | 84.57 | import sys
from functools import lru_cache
sys.setrecursionlimit(10**6)
INF = sys.maxsize
N = int(input().strip())
h = [int(x) for x in input().split()]
@lru_cache()
def solve(i):
if i >= N - 1:
return 0
return min(
solve(i + 1) + abs(h[i] - h[i + 1]) if i + 1 < N else INF,
solve... | import sys
INF = sys.maxsize
N = int(input().strip())
h = [int(x) for x in input().split()]
memo = [INF] * N
for i in range(N - 1, -1, -1):
if i == N -1:
memo[i] = 0
else:
memo[i] = min(
memo[i + 1] + abs(h[i] - h[i + 1]) if i + 1 < N else INF,
memo[i + 2] + abs(h[i] - h[i + 2... | 20 | 19 | 398 | 395 | import sys
from functools import lru_cache
sys.setrecursionlimit(10**6)
INF = sys.maxsize
N = int(input().strip())
h = [int(x) for x in input().split()]
@lru_cache()
def solve(i):
if i >= N - 1:
return 0
return min(
solve(i + 1) + abs(h[i] - h[i + 1]) if i + 1 < N else INF,
solve(i + ... | import sys
INF = sys.maxsize
N = int(input().strip())
h = [int(x) for x in input().split()]
memo = [INF] * N
for i in range(N - 1, -1, -1):
if i == N - 1:
memo[i] = 0
else:
memo[i] = min(
memo[i + 1] + abs(h[i] - h[i + 1]) if i + 1 < N else INF,
memo[i + 2] + abs(h[i] - ... | false | 5 | [
"-from functools import lru_cache",
"-sys.setrecursionlimit(10**6)",
"-",
"-",
"-@lru_cache()",
"-def solve(i):",
"- if i >= N - 1:",
"- return 0",
"- return min(",
"- solve(i + 1) + abs(h[i] - h[i + 1]) if i + 1 < N else INF,",
"- solve(i + 2) + abs(h[i] - h[i + 2]) i... | false | 0.037472 | 0.13411 | 0.279412 | [
"s065663811",
"s584630541"
] |
u191874006 | p03142 | python | s903061718 | s075141909 | 549 | 472 | 71,472 | 70,832 | Accepted | Accepted | 14.03 | #!/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
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... | 45 | 57 | 1,130 | 1,393 | #!/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
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... | false | 21.052632 | [
"+\"\"\"",
"+[トポロジカルソート]",
"+⇒入次数0の頂点からスタートし、その番号を1とする.",
"+ 1から出ている有向辺をすべて削除",
"+ 入次数0になった頂点の番号を2とし、2から出ている有向辺をすべて削除",
"+ 入次数0になった頂点の番号を3とし、...を繰り返す",
"+常に入次数が0になった頂点を選択してその1つ前を親とするため、",
"+出来上がったグラフの各頂点の親は、そのグラフで最も近い親(距離1)",
"+つまり、後から足されたM本の辺ではない",
"+よって、トポロジカルソートによって得られるグラフが元の木である.",
"+\"\"\... | false | 0.111763 | 0.05676 | 1.96904 | [
"s903061718",
"s075141909"
] |
u930705402 | p03061 | python | s703336881 | s328591932 | 891 | 168 | 88,696 | 107,072 | Accepted | Accepted | 81.14 | from math import gcd
class SEGTree:
def __init__(self,n):
self.Unit=0
i=1
while(i<n):
i*=2
self.SEG=[self.Unit]*(2*i-1)
self.d=i
def update(self,i,x):
i+=self.d-1
self.SEG[i]=x
while i>0:
i=(i-1)//2
... | from math import gcd
class SparseTable:
def __init__(self,arr,N,op,e):
self.A=arr
self.N=N
self.Unit=e
self.Op=op
self.K=N.bit_length()-1
self.pow2=[1]
for i in range(self.K):
self.pow2.append(self.pow2[-1]*2)
self.ST=[[self.Unit... | 37 | 35 | 938 | 1,015 | from math import gcd
class SEGTree:
def __init__(self, n):
self.Unit = 0
i = 1
while i < n:
i *= 2
self.SEG = [self.Unit] * (2 * i - 1)
self.d = i
def update(self, i, x):
i += self.d - 1
self.SEG[i] = x
while i > 0:
i = (... | from math import gcd
class SparseTable:
def __init__(self, arr, N, op, e):
self.A = arr
self.N = N
self.Unit = e
self.Op = op
self.K = N.bit_length() - 1
self.pow2 = [1]
for i in range(self.K):
self.pow2.append(self.pow2[-1] * 2)
self.ST ... | false | 5.405405 | [
"-class SEGTree:",
"- def __init__(self, n):",
"- self.Unit = 0",
"- i = 1",
"- while i < n:",
"- i *= 2",
"- self.SEG = [self.Unit] * (2 * i - 1)",
"- self.d = i",
"+class SparseTable:",
"+ def __init__(self, arr, N, op, e):",
"+ self.A... | false | 0.047095 | 0.080422 | 0.585591 | [
"s703336881",
"s328591932"
] |
u606045429 | p02793 | python | s921273359 | s811304491 | 1,512 | 581 | 6,076 | 6,072 | Accepted | Accepted | 61.57 | from fractions import gcd
mod = 10 ** 9 + 7
N, *A = list(map(int, open(0).read().split()))
L = 1
for a in A:
L *= a // gcd(L, a)
print((sum(L // a for a in A) % mod)) | from fractions import gcd
mod = 10 ** 9 + 7
N, *A = list(map(int, open(0).read().split()))
L = 1
for a in A:
L *= a // gcd(L, a)
L %= mod
print((sum(L * pow(a, mod - 2, mod) % mod for a in A) % mod)) | 11 | 13 | 176 | 212 | from fractions import gcd
mod = 10**9 + 7
N, *A = list(map(int, open(0).read().split()))
L = 1
for a in A:
L *= a // gcd(L, a)
print((sum(L // a for a in A) % mod))
| from fractions import gcd
mod = 10**9 + 7
N, *A = list(map(int, open(0).read().split()))
L = 1
for a in A:
L *= a // gcd(L, a)
L %= mod
print((sum(L * pow(a, mod - 2, mod) % mod for a in A) % mod))
| false | 15.384615 | [
"-print((sum(L // a for a in A) % mod))",
"+L %= mod",
"+print((sum(L * pow(a, mod - 2, mod) % mod for a in A) % mod))"
] | false | 0.046114 | 0.046559 | 0.990442 | [
"s921273359",
"s811304491"
] |
u539367121 | p02732 | python | s403688155 | s605389641 | 306 | 220 | 34,364 | 32,180 | Accepted | Accepted | 28.1 | def main():
N=int(eval(input()))
A=[int(a) for a in input().split()]
Acnt, Aprob={}, {}
for a in A:
Acnt[a] = Acnt.get(a, 0) + 1
sumA=0
for k, a in list(Acnt.items()):
Aprob[k]=a*(a-1)//2
sumA+=Aprob[k]
#Acnt=[A.count(n) for n in range(N+1)]
#Aprob=[Acnt[n]*(Acnt[n]-1)//2 for n in... | def main():
N=int(eval(input()))
A=[int(a) for a in input().split()]
cnt={}
for a in A:
cnt[a] = cnt.get(a, 0) + 1
prob=0
for a in list(cnt.values()):
prob+=a*(a-1)//2
for a in A:
print((prob-(cnt[a]-1)))
main()
| 20 | 15 | 438 | 247 | def main():
N = int(eval(input()))
A = [int(a) for a in input().split()]
Acnt, Aprob = {}, {}
for a in A:
Acnt[a] = Acnt.get(a, 0) + 1
sumA = 0
for k, a in list(Acnt.items()):
Aprob[k] = a * (a - 1) // 2
sumA += Aprob[k]
# Acnt=[A.count(n) for n in range(N+1)]
# A... | def main():
N = int(eval(input()))
A = [int(a) for a in input().split()]
cnt = {}
for a in A:
cnt[a] = cnt.get(a, 0) + 1
prob = 0
for a in list(cnt.values()):
prob += a * (a - 1) // 2
for a in A:
print((prob - (cnt[a] - 1)))
main()
| false | 25 | [
"- Acnt, Aprob = {}, {}",
"+ cnt = {}",
"- Acnt[a] = Acnt.get(a, 0) + 1",
"- sumA = 0",
"- for k, a in list(Acnt.items()):",
"- Aprob[k] = a * (a - 1) // 2",
"- sumA += Aprob[k]",
"- # Acnt=[A.count(n) for n in range(N+1)]",
"- # Aprob=[Acnt[n]*(Acnt[n]-1)//2 f... | false | 0.037117 | 0.035861 | 1.035024 | [
"s403688155",
"s605389641"
] |
u539969758 | p02550 | python | s129888844 | s411434845 | 157 | 64 | 18,308 | 15,828 | Accepted | Accepted | 59.24 | N, X, M = list(map(int, input().split()))
candicate = [pow(i, 2, M) for i in range(M)]
ans = 0
now = X
A = [0]
X2 = pow(X, 2, M)
d = dict()
flag = True
for i in range(1, N+1):
if i == 1:
A.append(X)
else:
nxt = candicate[A[i-1]]
if d.get(nxt) == None:
... | N,X,M = list(map(int,input().split()))
ans = X
A = X
TF = True
srt = 1000000
retu = [X]
d = dict()
d[X] = 0
loop = X
flag = False
for i in range(N-1):
if TF:
A = A**2 % M
if d.get(A) != None:
srt = d[A]
goal = i
TF = False
if TF:
... | 51 | 35 | 894 | 627 | N, X, M = list(map(int, input().split()))
candicate = [pow(i, 2, M) for i in range(M)]
ans = 0
now = X
A = [0]
X2 = pow(X, 2, M)
d = dict()
flag = True
for i in range(1, N + 1):
if i == 1:
A.append(X)
else:
nxt = candicate[A[i - 1]]
if d.get(nxt) == None:
if nxt == 0:
... | N, X, M = list(map(int, input().split()))
ans = X
A = X
TF = True
srt = 1000000
retu = [X]
d = dict()
d[X] = 0
loop = X
flag = False
for i in range(N - 1):
if TF:
A = A**2 % M
if d.get(A) != None:
srt = d[A]
goal = i
TF = False
if TF:
retu.appe... | false | 31.372549 | [
"-candicate = [pow(i, 2, M) for i in range(M)]",
"-ans = 0",
"-now = X",
"-A = [0]",
"-X2 = pow(X, 2, M)",
"+ans = X",
"+A = X",
"+TF = True",
"+srt = 1000000",
"+retu = [X]",
"-flag = True",
"-for i in range(1, N + 1):",
"- if i == 1:",
"- A.append(X)",
"+d[X] = 0",
"+loop =... | false | 0.087598 | 0.104976 | 0.834456 | [
"s129888844",
"s411434845"
] |
u579699847 | p03774 | python | s234305006 | s137180155 | 303 | 149 | 21,592 | 12,432 | Accepted | Accepted | 50.83 | import numpy as np,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
ab = np.array([LI() for _ in range(N)],dtype=int)
cd = np.array([LI() for _ in range(M)],dtype=int)
for x in ab:
vector = np.sum(np.abs(cd-x),axis=1).tolist()
print((vector.index(min(vector))+1))
| import numpy as np,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
ab = np.array([LI() for _ in range(N)])
cd = np.array([LI() for _ in range(M)])
for x in ab:
print((np.argmin(np.sum(np.abs(cd-x),axis=1))+1))
| 8 | 7 | 313 | 255 | import numpy as np, sys
def LI():
return list(map(int, sys.stdin.readline().rstrip().split()))
N, M = LI()
ab = np.array([LI() for _ in range(N)], dtype=int)
cd = np.array([LI() for _ in range(M)], dtype=int)
for x in ab:
vector = np.sum(np.abs(cd - x), axis=1).tolist()
print((vector.index(min(vector)) ... | import numpy as np, sys
def LI():
return list(map(int, sys.stdin.readline().rstrip().split()))
N, M = LI()
ab = np.array([LI() for _ in range(N)])
cd = np.array([LI() for _ in range(M)])
for x in ab:
print((np.argmin(np.sum(np.abs(cd - x), axis=1)) + 1))
| false | 12.5 | [
"-ab = np.array([LI() for _ in range(N)], dtype=int)",
"-cd = np.array([LI() for _ in range(M)], dtype=int)",
"+ab = np.array([LI() for _ in range(N)])",
"+cd = np.array([LI() for _ in range(M)])",
"- vector = np.sum(np.abs(cd - x), axis=1).tolist()",
"- print((vector.index(min(vector)) + 1))",
"+... | false | 0.206155 | 0.494352 | 0.417021 | [
"s234305006",
"s137180155"
] |
u190405389 | p02721 | python | s433856469 | s148548247 | 343 | 305 | 91,112 | 57,464 | Accepted | Accepted | 11.08 | n,k,c = list(map(int, input().split()))
s = eval(input())
# 計算途中はi=0~n-1日とする
# [a,b] i日までで、限界まで働くとa回働けてb日まで働けない
pre = [[0,0] for i in range(n)]
if s[0]=='o':
pre[0]=[1,c]
for j in range(c):
if 1+j < n:
pre[1+j] = pre[0] + []
for i in range(1,n):
if pre[i]==[0,0]:
... | # 解説
n,k,c = list(map(int, input().split()))
s = eval(input())
l = [0 for i in range(n)]
r = [-1 for i in range(n)]
a = 1
b = -1
for i in range(n):
if s[i]=='o' and b<i:
l[i]=a
a+=1
b=i+c
if a>k:
break
a = k
b = n
for i in range(n):
if s[-i-1]... | 58 | 31 | 1,350 | 477 | n, k, c = list(map(int, input().split()))
s = eval(input())
# 計算途中はi=0~n-1日とする
# [a,b] i日までで、限界まで働くとa回働けてb日まで働けない
pre = [[0, 0] for i in range(n)]
if s[0] == "o":
pre[0] = [1, c]
for j in range(c):
if 1 + j < n:
pre[1 + j] = pre[0] + []
for i in range(1, n):
if pre[i] == [0, 0]:
... | # 解説
n, k, c = list(map(int, input().split()))
s = eval(input())
l = [0 for i in range(n)]
r = [-1 for i in range(n)]
a = 1
b = -1
for i in range(n):
if s[i] == "o" and b < i:
l[i] = a
a += 1
b = i + c
if a > k:
break
a = k
b = n
for i in range(n):
if s[-i - 1] == "o"... | false | 46.551724 | [
"+# 解説",
"-# 計算途中はi=0~n-1日とする",
"-# [a,b] i日までで、限界まで働くとa回働けてb日まで働けない",
"-pre = [[0, 0] for i in range(n)]",
"-if s[0] == \"o\":",
"- pre[0] = [1, c]",
"- for j in range(c):",
"- if 1 + j < n:",
"- pre[1 + j] = pre[0] + []",
"-for i in range(1, n):",
"- if pre[i] == [0,... | false | 0.047022 | 0.168177 | 0.2796 | [
"s433856469",
"s148548247"
] |
u597374218 | p02628 | python | s519708458 | s808043047 | 30 | 27 | 9,108 | 9,252 | Accepted | Accepted | 10 | N, K = list(map(int, input().split()))
p = sorted(map(int, input().split()))
print((sum(p[:K]))) | N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
print((sum(sorted(p)[0:K]))) | 3 | 3 | 90 | 97 | N, K = list(map(int, input().split()))
p = sorted(map(int, input().split()))
print((sum(p[:K])))
| N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
print((sum(sorted(p)[0:K])))
| false | 0 | [
"-p = sorted(map(int, input().split()))",
"-print((sum(p[:K])))",
"+p = list(map(int, input().split()))",
"+print((sum(sorted(p)[0:K])))"
] | false | 0.040126 | 0.043442 | 0.923654 | [
"s519708458",
"s808043047"
] |
u645250356 | p03338 | python | s545362865 | s101812412 | 295 | 137 | 64,748 | 72,744 | Accepted | Accepted | 53.56 | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
... | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, ... | 23 | 25 | 563 | 616 | from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, fractions, pprint
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")
def inp():
return int(sys.stdin.readline())
def inpl():
return list(map(int, sys.stdin.read... | from collections import Counter, defaultdict, deque
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
import sys, math, itertools, fractions, pprint
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")
def inp():
return int(sys.stdin.readline())
def inpl():
return ... | false | 8 | [
"-from heapq import heappop, heappush, heapify",
"-import sys, bisect, math, itertools, fractions, pprint",
"+from heapq import heappop, heappush",
"+from bisect import bisect_left, bisect_right",
"+import sys, math, itertools, fractions, pprint",
"-s = list(eval(input()))",
"+s = eval(input())",
"-fo... | false | 0.045602 | 0.037956 | 1.201461 | [
"s545362865",
"s101812412"
] |
u810288681 | p02813 | python | s585055497 | s919290708 | 36 | 29 | 8,308 | 8,052 | Accepted | Accepted | 19.44 | import itertools
n = int(eval(input()))
p = tuple(list(map(int, input().split())))
q = tuple(list(map(int, input().split())))
po = 0
qo = 0
l = sorted(list(itertools.permutations(list(range(1,n+1)))))
for i in range(len(l)):
if l[i] == p:
po = i
if l[i]== q:
qo = i
print((abs(po-qo))... | import itertools
n = int(eval(input()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
l = sorted(itertools.permutations([i for i in range(1,n+1)]))
print((abs(l.index(tuple(p))-l.index(tuple(q))))) | 13 | 6 | 307 | 220 | import itertools
n = int(eval(input()))
p = tuple(list(map(int, input().split())))
q = tuple(list(map(int, input().split())))
po = 0
qo = 0
l = sorted(list(itertools.permutations(list(range(1, n + 1)))))
for i in range(len(l)):
if l[i] == p:
po = i
if l[i] == q:
qo = i
print((abs(po - qo)))
| import itertools
n = int(eval(input()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
l = sorted(itertools.permutations([i for i in range(1, n + 1)]))
print((abs(l.index(tuple(p)) - l.index(tuple(q)))))
| false | 53.846154 | [
"-p = tuple(list(map(int, input().split())))",
"-q = tuple(list(map(int, input().split())))",
"-po = 0",
"-qo = 0",
"-l = sorted(list(itertools.permutations(list(range(1, n + 1)))))",
"-for i in range(len(l)):",
"- if l[i] == p:",
"- po = i",
"- if l[i] == q:",
"- qo = i",
"-... | false | 0.144619 | 0.039514 | 3.659948 | [
"s585055497",
"s919290708"
] |
u475584892 | p02947 | python | s425714066 | s960863462 | 392 | 362 | 72,540 | 64,220 | Accepted | Accepted | 7.65 | def slove():
import sys
import collections
input = sys.stdin.readline
n = int(input().rstrip('\n'))
s = ["".join(sorted(list(str(input().rstrip('\n'))))) for _ in range(n)]
s = collections.Counter(s).most_common()
t = 0
for i, v in s:
for j in range(v-1, 0, -1):
... | def slove():
import sys
import collections
input = sys.stdin.readline
n = int(input().rstrip('\n'))
s = collections.Counter(["".join(sorted(list(str(input().rstrip('\n'))))) for _ in range(n)])
cnt = 0
for k, v in list(s.items()):
for i in range(1, v):
cnt += i
... | 16 | 15 | 391 | 374 | def slove():
import sys
import collections
input = sys.stdin.readline
n = int(input().rstrip("\n"))
s = ["".join(sorted(list(str(input().rstrip("\n"))))) for _ in range(n)]
s = collections.Counter(s).most_common()
t = 0
for i, v in s:
for j in range(v - 1, 0, -1):
t ... | def slove():
import sys
import collections
input = sys.stdin.readline
n = int(input().rstrip("\n"))
s = collections.Counter(
["".join(sorted(list(str(input().rstrip("\n"))))) for _ in range(n)]
)
cnt = 0
for k, v in list(s.items()):
for i in range(1, v):
cnt ... | false | 6.25 | [
"- s = [\"\".join(sorted(list(str(input().rstrip(\"\\n\"))))) for _ in range(n)]",
"- s = collections.Counter(s).most_common()",
"- t = 0",
"- for i, v in s:",
"- for j in range(v - 1, 0, -1):",
"- t += j",
"- print(t)",
"+ s = collections.Counter(",
"+ [\"... | false | 0.04975 | 0.047391 | 1.049792 | [
"s425714066",
"s960863462"
] |
u653837719 | p02982 | python | s241680855 | s342988543 | 21 | 17 | 3,316 | 3,064 | Accepted | Accepted | 19.05 | import math
n, d = list(map(int, input().split()))
x = []
cnt = 0
sum = 0
for _ in range(n):
tmp = list(map(int, input().split()))
x.append(tmp)
for i in range(n):
for j in range(i + 1, n):
sum = 0
for k in range(d):
sum += (x[i][k] - x[j][k]) ** 2
distan... | n, d = list(map(int, input().split()))
x = []
cnt = 0
sum = 0
for _ in range(n):
tmp = list(map(int, input().split()))
x.append(tmp)
for i in range(n):
for j in range(i + 1, n):
sum = 0
for k in range(d):
sum += (x[i][k] - x[j][k]) ** 2
distance = sum ** 0.5... | 20 | 18 | 405 | 386 | import math
n, d = list(map(int, input().split()))
x = []
cnt = 0
sum = 0
for _ in range(n):
tmp = list(map(int, input().split()))
x.append(tmp)
for i in range(n):
for j in range(i + 1, n):
sum = 0
for k in range(d):
sum += (x[i][k] - x[j][k]) ** 2
distance = math.sqrt(s... | n, d = list(map(int, input().split()))
x = []
cnt = 0
sum = 0
for _ in range(n):
tmp = list(map(int, input().split()))
x.append(tmp)
for i in range(n):
for j in range(i + 1, n):
sum = 0
for k in range(d):
sum += (x[i][k] - x[j][k]) ** 2
distance = sum**0.5
if dist... | false | 10 | [
"-import math",
"-",
"- distance = math.sqrt(sum)",
"+ distance = sum**0.5"
] | false | 0.040012 | 0.041601 | 0.961818 | [
"s241680855",
"s342988543"
] |
u018679195 | p02784 | python | s038218660 | s703101201 | 55 | 41 | 13,964 | 13,964 | Accepted | Accepted | 25.45 | H,N= list(map(int,input().split()))
A=list(map(int,input().split()))
x=0
for i in range(N):
x=x+A[i]
if x>=H:
print("Yes")
else:
print("No") | hn = list(map(int,input().split()))
h,n = hn
a = list(map(int,input().split()))
h -= sum(a)
if h > 0:
print ("No")
else:
print ("Yes") | 12 | 8 | 166 | 149 | H, N = list(map(int, input().split()))
A = list(map(int, input().split()))
x = 0
for i in range(N):
x = x + A[i]
if x >= H:
print("Yes")
else:
print("No")
| hn = list(map(int, input().split()))
h, n = hn
a = list(map(int, input().split()))
h -= sum(a)
if h > 0:
print("No")
else:
print("Yes")
| false | 33.333333 | [
"-H, N = list(map(int, input().split()))",
"-A = list(map(int, input().split()))",
"-x = 0",
"-for i in range(N):",
"- x = x + A[i]",
"-if x >= H:",
"+hn = list(map(int, input().split()))",
"+h, n = hn",
"+a = list(map(int, input().split()))",
"+h -= sum(a)",
"+if h > 0:",
"+ print(\"No\... | false | 0.092853 | 0.040794 | 2.276134 | [
"s038218660",
"s703101201"
] |
u864197622 | p03465 | python | s595430936 | s872118946 | 572 | 467 | 5,436 | 9,164 | Accepted | Accepted | 18.36 | N = int(eval(input()))
A = [int(a) for a in input().split()]
s = 1
for a in A:
s |= s << a
for i in range((sum(A)+1)//2, sum(A)+1):
if s & (1<<i):
print(i)
break | N = int(eval(input()))
A = [int(a) for a in input().split()]
s = 1
for a in A:
s |= s << a
ss = bin(s)
for i in range((sum(A)+1)//2, sum(A)+1):
if ss[-i-1] == "1":
print(i)
break | 10 | 11 | 189 | 207 | N = int(eval(input()))
A = [int(a) for a in input().split()]
s = 1
for a in A:
s |= s << a
for i in range((sum(A) + 1) // 2, sum(A) + 1):
if s & (1 << i):
print(i)
break
| N = int(eval(input()))
A = [int(a) for a in input().split()]
s = 1
for a in A:
s |= s << a
ss = bin(s)
for i in range((sum(A) + 1) // 2, sum(A) + 1):
if ss[-i - 1] == "1":
print(i)
break
| false | 9.090909 | [
"+ss = bin(s)",
"- if s & (1 << i):",
"+ if ss[-i - 1] == \"1\":"
] | false | 0.035048 | 0.035517 | 0.986785 | [
"s595430936",
"s872118946"
] |
u709304134 | p02714 | python | s098200696 | s456946050 | 1,906 | 1,631 | 9,460 | 9,468 | Accepted | Accepted | 14.43 | from collections import Counter
N = int(eval(input()))
S = eval(input())
#c = Counter(S)
#print (c.most_common())
#ls = list(c.values())
ans = S.count('R') * S.count('G') * S.count('B')
for i in range(N):
for j in range(1,N):
a = i + j
b = i + j + j
if (b >= N):
b... | from collections import Counter
N = int(eval(input()))
S = eval(input())
ans = S.count('R') * S.count('G') * S.count('B')
for i in range(N):
for j in range(1,N):
if (i-j<0 or i+j>=N):
break
l = S[i-j]
m = S[i]
r = S[i+j]
if l!=m and m!=r and r!=l:
... | 29 | 15 | 653 | 340 | from collections import Counter
N = int(eval(input()))
S = eval(input())
# c = Counter(S)
# print (c.most_common())
# ls = list(c.values())
ans = S.count("R") * S.count("G") * S.count("B")
for i in range(N):
for j in range(1, N):
a = i + j
b = i + j + j
if b >= N:
break
... | from collections import Counter
N = int(eval(input()))
S = eval(input())
ans = S.count("R") * S.count("G") * S.count("B")
for i in range(N):
for j in range(1, N):
if i - j < 0 or i + j >= N:
break
l = S[i - j]
m = S[i]
r = S[i + j]
if l != m and m != r and r != l... | false | 48.275862 | [
"-# c = Counter(S)",
"-# print (c.most_common())",
"-# ls = list(c.values())",
"- a = i + j",
"- b = i + j + j",
"- if b >= N:",
"+ if i - j < 0 or i + j >= N:",
"- else:",
"- l = S[i]",
"- m = S[a]",
"- r = S[b]",
"- ... | false | 0.035497 | 0.040534 | 0.87573 | [
"s098200696",
"s456946050"
] |
u869917163 | p02755 | python | s640962227 | s633989087 | 20 | 18 | 3,060 | 3,060 | Accepted | Accepted | 10 | A, B = list(map(int, input().split()))
for i in range(1, 10001):
if int(i*0.08) == A and int(i*0.1) == B:
print(i)
break
else:
print((-1)) | import sys
A,B = list(map(int,input().split()))
for i in range(1,1251):
C_8 = int(i*0.08)
C_10 = int(i*0.1)
if C_8 == A and C_10 == B:
print(i)
sys.exit()
print((-1)) | 7 | 10 | 160 | 182 | A, B = list(map(int, input().split()))
for i in range(1, 10001):
if int(i * 0.08) == A and int(i * 0.1) == B:
print(i)
break
else:
print((-1))
| import sys
A, B = list(map(int, input().split()))
for i in range(1, 1251):
C_8 = int(i * 0.08)
C_10 = int(i * 0.1)
if C_8 == A and C_10 == B:
print(i)
sys.exit()
print((-1))
| false | 30 | [
"+import sys",
"+",
"-for i in range(1, 10001):",
"- if int(i * 0.08) == A and int(i * 0.1) == B:",
"+for i in range(1, 1251):",
"+ C_8 = int(i * 0.08)",
"+ C_10 = int(i * 0.1)",
"+ if C_8 == A and C_10 == B:",
"- break",
"-else:",
"- print((-1))",
"+ sys.exit()",
... | false | 0.04832 | 0.047995 | 1.00679 | [
"s640962227",
"s633989087"
] |
u045091221 | p03282 | python | s084605329 | s998952151 | 39 | 33 | 9,704 | 9,928 | Accepted | Accepted | 15.38 | import re
S = eval(input())
K = int(eval(input()))
m = re.match(r'\A(1+)([1-9]*)\Z', S)
if m:
print(('1' if len(m.group(1)) >= K else m.group(2)[0]))
else:
print((S[0]))
| import re
S = eval(input())
K = int(eval(input()))
m = re.match(r'\A(1*)([1-9]*)\Z', S)
print(('1' if len(m.group(1)) >= K else m.group(2)[0]))
| 10 | 7 | 173 | 138 | import re
S = eval(input())
K = int(eval(input()))
m = re.match(r"\A(1+)([1-9]*)\Z", S)
if m:
print(("1" if len(m.group(1)) >= K else m.group(2)[0]))
else:
print((S[0]))
| import re
S = eval(input())
K = int(eval(input()))
m = re.match(r"\A(1*)([1-9]*)\Z", S)
print(("1" if len(m.group(1)) >= K else m.group(2)[0]))
| false | 30 | [
"-m = re.match(r\"\\A(1+)([1-9]*)\\Z\", S)",
"-if m:",
"- print((\"1\" if len(m.group(1)) >= K else m.group(2)[0]))",
"-else:",
"- print((S[0]))",
"+m = re.match(r\"\\A(1*)([1-9]*)\\Z\", S)",
"+print((\"1\" if len(m.group(1)) >= K else m.group(2)[0]))"
] | false | 0.044335 | 0.042889 | 1.033708 | [
"s084605329",
"s998952151"
] |
u562935282 | p02959 | python | s367712261 | s706196317 | 188 | 113 | 18,476 | 18,624 | Accepted | Accepted | 39.89 | n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i, bb in enumerate(b):
use = min(a[i], b[i])
ans += use
a[i] -= use
b[i] -= use
if b[i] == 0:
continue
use = min(a[i + 1], b[i])
ans += use
a[i + 1] -= us... | def main():
N = int(eval(input()))
*a, = list(map(int, input().split()))
*b, = list(map(int, input().split()))
b += [0]
total_beaten = 0
carry = 0
for beat, number in zip(b, a):
by_prev = min(number, carry)
total_beaten += by_prev
number -= by_prev
... | 19 | 24 | 330 | 474 | n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i, bb in enumerate(b):
use = min(a[i], b[i])
ans += use
a[i] -= use
b[i] -= use
if b[i] == 0:
continue
use = min(a[i + 1], b[i])
ans += use
a[i + 1] -= use
print(ans)
| def main():
N = int(eval(input()))
(*a,) = list(map(int, input().split()))
(*b,) = list(map(int, input().split()))
b += [0]
total_beaten = 0
carry = 0
for beat, number in zip(b, a):
by_prev = min(number, carry)
total_beaten += by_prev
number -= by_prev
by_curr... | false | 20.833333 | [
"-n = int(eval(input()))",
"-a = list(map(int, input().split()))",
"-b = list(map(int, input().split()))",
"-ans = 0",
"-for i, bb in enumerate(b):",
"- use = min(a[i], b[i])",
"- ans += use",
"- a[i] -= use",
"- b[i] -= use",
"- if b[i] == 0:",
"- continue",
"- use = ... | false | 0.037536 | 0.038316 | 0.979631 | [
"s367712261",
"s706196317"
] |
u411203878 | p04034 | python | s210894232 | s749763129 | 614 | 388 | 66,904 | 91,496 | Accepted | Accepted | 36.81 | n, m = (int(x) for x in input().split())
ab = []
for _ in range(m):
a, b = (int(x) for x in input().split())
ab.append([a-1, b-1])
box = [1]*n
red = [0]*n
red[0] = 1
for x,y in ab:
if 0 < red[x]:
red[y] = 1
box[x] -= 1
box[y] += 1
if box[x] == 0:
red[x] = ... | N,M = list(map(int,input().split()))
XY = [list(map(int,input().split())) for _ in range(M)]
ball_count = [1]*N
red_ball_cand = [0]*N
red_ball_cand[0] = 1
for i in range(M):
x,y = XY[i]
x,y = x-1,y-1
if 0 < red_ball_cand[x]:
red_ball_cand[y] = 1
ball_count[x] -= 1
... | 21 | 21 | 338 | 425 | n, m = (int(x) for x in input().split())
ab = []
for _ in range(m):
a, b = (int(x) for x in input().split())
ab.append([a - 1, b - 1])
box = [1] * n
red = [0] * n
red[0] = 1
for x, y in ab:
if 0 < red[x]:
red[y] = 1
box[x] -= 1
box[y] += 1
if box[x] == 0:
red[x] = 0
print((sum(re... | N, M = list(map(int, input().split()))
XY = [list(map(int, input().split())) for _ in range(M)]
ball_count = [1] * N
red_ball_cand = [0] * N
red_ball_cand[0] = 1
for i in range(M):
x, y = XY[i]
x, y = x - 1, y - 1
if 0 < red_ball_cand[x]:
red_ball_cand[y] = 1
ball_count[x] -= 1
ball_count[y]... | false | 0 | [
"-n, m = (int(x) for x in input().split())",
"-ab = []",
"-for _ in range(m):",
"- a, b = (int(x) for x in input().split())",
"- ab.append([a - 1, b - 1])",
"-box = [1] * n",
"-red = [0] * n",
"-red[0] = 1",
"-for x, y in ab:",
"- if 0 < red[x]:",
"- red[y] = 1",
"- box[x] -... | false | 0.037642 | 0.03836 | 0.981289 | [
"s210894232",
"s749763129"
] |
u285681431 | p02850 | python | s608353904 | s302411641 | 371 | 304 | 23,148 | 92,004 | Accepted | Accepted | 18.06 | import sys
from collections import deque
n = int(eval(input()))
G = [[] for _ in range(n + 1)]
G_order = []
# a<bが保証されている、aを親、bを子とする
for i in range(n - 1):
a, b = [int(x) - 1 for x in input().split()]
G[a].append(b)
G_order.append(b)
# どこでも良いが、ここでは0をrootとする
que = deque([0])
# 各頂点と「親」を結ぶ辺の色... | from collections import deque
N = int(eval(input()))
# 有向グラフと見る、G[親] = [子1, 子2, ...]
G = [[] for _ in range(N + 1)]
# 子ノードを記録、これで辺の番号を管理
G_order = []
# a<bが保証されている、aを親、bを子とする
for i in range(N - 1):
a, b = [int(x) - 1 for x in input().split()]
G[a].append(b)
G_order.append(b)
# どこでも良いが、ここでは0をr... | 43 | 44 | 798 | 860 | import sys
from collections import deque
n = int(eval(input()))
G = [[] for _ in range(n + 1)]
G_order = []
# a<bが保証されている、aを親、bを子とする
for i in range(n - 1):
a, b = [int(x) - 1 for x in input().split()]
G[a].append(b)
G_order.append(b)
# どこでも良いが、ここでは0をrootとする
que = deque([0])
# 各頂点と「親」を結ぶ辺の色
# 頂点0をrootとするのでC... | from collections import deque
N = int(eval(input()))
# 有向グラフと見る、G[親] = [子1, 子2, ...]
G = [[] for _ in range(N + 1)]
# 子ノードを記録、これで辺の番号を管理
G_order = []
# a<bが保証されている、aを親、bを子とする
for i in range(N - 1):
a, b = [int(x) - 1 for x in input().split()]
G[a].append(b)
G_order.append(b)
# どこでも良いが、ここでは0をrootとする
que = d... | false | 2.272727 | [
"-import sys",
"-n = int(eval(input()))",
"-G = [[] for _ in range(n + 1)]",
"+N = int(eval(input()))",
"+# 有向グラフと見る、G[親] = [子1, 子2, ...]",
"+G = [[] for _ in range(N + 1)]",
"+# 子ノードを記録、これで辺の番号を管理",
"-for i in range(n - 1):",
"+for i in range(N - 1):",
"-# 頂点0をrootとするのでC[0]=0で確定, 他を調べる",
"-colo... | false | 0.035212 | 0.033133 | 1.062761 | [
"s608353904",
"s302411641"
] |
u186838327 | p03627 | python | s956189975 | s593564226 | 319 | 95 | 67,608 | 18,060 | Accepted | Accepted | 70.22 | n = int(eval(input()))
A = list(map(int, input().split()))
d = {}
for i in range(n):
if A[i] not in d:
d[A[i]] = 1
else:
d[A[i]] += 1
#print(d)
L = []
for k, v in list(d.items()):
if v >= 2:
L.append([k, v])
L.sort(reverse=True)
if len(L) == 0:
print((0))
elif l... | n = int(eval(input()))
A =list(map(int, input().split()))
d = {}
for i in range(n):
if A[i] not in d:
d[A[i]] = 1
else:
d[A[i]] += 1
ans = 0
l = []
for k, v in list(d.items()):
if v >= 4:
ans = max(ans, k**2)
l.append(k)
elif v >= 2:
l.append(k)
... | 27 | 24 | 498 | 447 | n = int(eval(input()))
A = list(map(int, input().split()))
d = {}
for i in range(n):
if A[i] not in d:
d[A[i]] = 1
else:
d[A[i]] += 1
# print(d)
L = []
for k, v in list(d.items()):
if v >= 2:
L.append([k, v])
L.sort(reverse=True)
if len(L) == 0:
print((0))
elif len(L) == 1:
i... | n = int(eval(input()))
A = list(map(int, input().split()))
d = {}
for i in range(n):
if A[i] not in d:
d[A[i]] = 1
else:
d[A[i]] += 1
ans = 0
l = []
for k, v in list(d.items()):
if v >= 4:
ans = max(ans, k**2)
l.append(k)
elif v >= 2:
l.append(k)
else:
... | false | 11.111111 | [
"-# print(d)",
"-L = []",
"+ans = 0",
"+l = []",
"- if v >= 2:",
"- L.append([k, v])",
"-L.sort(reverse=True)",
"-if len(L) == 0:",
"- print((0))",
"-elif len(L) == 1:",
"- if L[0][1] < 4:",
"- print((0))",
"+ if v >= 4:",
"+ ans = max(ans, k**2)",
"+ ... | false | 0.041575 | 0.201923 | 0.205895 | [
"s956189975",
"s593564226"
] |
u943057856 | p02989 | python | s341418451 | s188676742 | 84 | 76 | 14,428 | 14,428 | Accepted | Accepted | 9.52 | k=int(eval(input()))
d=sorted(list(map(int,input().split())))
ans=0
for i in range(d[int(len(d)/2)-1]+1,d[int(len(d)/2)]+1):
ans+=1
print(ans) | n=int(eval(input()))
a=sorted(list(map(int,input().split())))
p=a[n//2-1]
q=a[n//2]
print((q-p)) | 6 | 5 | 145 | 92 | k = int(eval(input()))
d = sorted(list(map(int, input().split())))
ans = 0
for i in range(d[int(len(d) / 2) - 1] + 1, d[int(len(d) / 2)] + 1):
ans += 1
print(ans)
| n = int(eval(input()))
a = sorted(list(map(int, input().split())))
p = a[n // 2 - 1]
q = a[n // 2]
print((q - p))
| false | 16.666667 | [
"-k = int(eval(input()))",
"-d = sorted(list(map(int, input().split())))",
"-ans = 0",
"-for i in range(d[int(len(d) / 2) - 1] + 1, d[int(len(d) / 2)] + 1):",
"- ans += 1",
"-print(ans)",
"+n = int(eval(input()))",
"+a = sorted(list(map(int, input().split())))",
"+p = a[n // 2 - 1]",
"+q = a[n ... | false | 0.0365 | 0.036632 | 0.996392 | [
"s341418451",
"s188676742"
] |
u014333473 | p02860 | python | s102585598 | s119211374 | 26 | 23 | 9,160 | 9,148 | Accepted | Accepted | 11.54 | n=int(eval(input()));s=eval(input());print(('No' if n%2!=0 or s[:n//2]!=s[n//2:] else 'Yes')) | n=int(eval(input()));s=eval(input());print(('No'if s[:n//2]!=s[n//2:] else'Yes')) | 1 | 1 | 80 | 67 | n = int(eval(input()))
s = eval(input())
print(("No" if n % 2 != 0 or s[: n // 2] != s[n // 2 :] else "Yes"))
| n = int(eval(input()))
s = eval(input())
print(("No" if s[: n // 2] != s[n // 2 :] else "Yes"))
| false | 0 | [
"-print((\"No\" if n % 2 != 0 or s[: n // 2] != s[n // 2 :] else \"Yes\"))",
"+print((\"No\" if s[: n // 2] != s[n // 2 :] else \"Yes\"))"
] | false | 0.046099 | 0.046872 | 0.9835 | [
"s102585598",
"s119211374"
] |
u054514819 | p03361 | python | s244633745 | s529470753 | 185 | 65 | 39,152 | 64,928 | Accepted | Accepted | 64.86 | H, W = list(map(int, input().split()))
Map = [list(str(eval(input()))) for _ in range(H)]
dirc = ((0, 1), (1, 0), (-1, 0), (0, -1))
ans = 'Yes'
for h in range(H):
for w in range(W):
if Map[h][w]=='#':
for y, x in dirc:
if h+y<0 or h+y>=H or w+x<0 or w+x>=W:
... | import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
H, W = mapint()
query = [list(eval(input())) for _ in range(H)]
def check():
for h in range(H):
for w in range(W):
if query[h][w]=='.':
... | 17 | 28 | 451 | 714 | H, W = list(map(int, input().split()))
Map = [list(str(eval(input()))) for _ in range(H)]
dirc = ((0, 1), (1, 0), (-1, 0), (0, -1))
ans = "Yes"
for h in range(H):
for w in range(W):
if Map[h][w] == "#":
for y, x in dirc:
if h + y < 0 or h + y >= H or w + x < 0 or w + x >= W:
... | import sys
def input():
return sys.stdin.readline().strip()
def mapint():
return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
H, W = mapint()
query = [list(eval(input())) for _ in range(H)]
def check():
for h in range(H):
for w in range(W):
if query[h][w] == ".":
... | false | 39.285714 | [
"-H, W = list(map(int, input().split()))",
"-Map = [list(str(eval(input()))) for _ in range(H)]",
"-dirc = ((0, 1), (1, 0), (-1, 0), (0, -1))",
"-ans = \"Yes\"",
"-for h in range(H):",
"- for w in range(W):",
"- if Map[h][w] == \"#\":",
"- for y, x in dirc:",
"- i... | false | 0.040453 | 0.036673 | 1.103062 | [
"s244633745",
"s529470753"
] |
u969850098 | p02888 | python | s979145663 | s333179290 | 1,699 | 735 | 51,360 | 44,076 | Accepted | Accepted | 56.74 | from bisect import bisect_left
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-2):
a = L[i]
for j in range(i+1, N-1):
k = bisect_left(L[j+1:], a + L[j])
ans += k
print(ans)
... | from bisect import bisect_left
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-2):
a = L[i]
for j in range(i+1, N-1):
k = bisect_left(L, a + L[j])
ans += (k - (j + 1))
print(ans)... | 19 | 19 | 356 | 362 | from bisect import bisect_left
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N - 2):
a = L[i]
for j in range(i + 1, N - 1):
k = bisect_left(L[j + 1 :], a + L[j])
ans += k
print(ans)
if __name__ =... | from bisect import bisect_left
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N - 2):
a = L[i]
for j in range(i + 1, N - 1):
k = bisect_left(L, a + L[j])
ans += k - (j + 1)
print(ans)
if __name__ ... | false | 0 | [
"- k = bisect_left(L[j + 1 :], a + L[j])",
"- ans += k",
"+ k = bisect_left(L, a + L[j])",
"+ ans += k - (j + 1)"
] | false | 0.037218 | 0.060055 | 0.619722 | [
"s979145663",
"s333179290"
] |
u936985471 | p02901 | python | s934412773 | s428996287 | 1,094 | 619 | 9,172 | 9,244 | Accepted | Accepted | 43.42 | import sys
readline = sys.stdin.readline
N,M = list(map(int,readline().split()))
INF = 10 ** 9
dp = [INF] * (2 ** N)
dp[0] = 0
for i in range(M):
a,b = list(map(int,readline().split()))
C = list(map(int,readline().split()))
key = 0
for c in C:
key += (1 << (c - 1))
for j in range(len(dp) -... | import sys
readline = sys.stdin.readline
N,M = list(map(int,readline().split()))
INF = 10 ** 9
dp = [INF] * (2 ** N)
dp[0] = 0
for i in range(M):
a,b = list(map(int,readline().split()))
C = list(map(int,readline().split()))
key = 0
for c in C:
key += (1 << (c - 1))
for j in range(len(dp) -... | 23 | 24 | 464 | 481 | import sys
readline = sys.stdin.readline
N, M = list(map(int, readline().split()))
INF = 10**9
dp = [INF] * (2**N)
dp[0] = 0
for i in range(M):
a, b = list(map(int, readline().split()))
C = list(map(int, readline().split()))
key = 0
for c in C:
key += 1 << (c - 1)
for j in range(len(dp) - 1... | import sys
readline = sys.stdin.readline
N, M = list(map(int, readline().split()))
INF = 10**9
dp = [INF] * (2**N)
dp[0] = 0
for i in range(M):
a, b = list(map(int, readline().split()))
C = list(map(int, readline().split()))
key = 0
for c in C:
key += 1 << (c - 1)
for j in range(len(dp) - 1... | false | 4.166667 | [
"- dp[j | key] = min(dp[j | key], dp[j] + a)",
"+ if dp[j | key] > dp[j] + a:",
"+ dp[j | key] = dp[j] + a"
] | false | 0.066361 | 0.107883 | 0.615119 | [
"s934412773",
"s428996287"
] |
u022407960 | p02281 | python | s566306840 | s496793240 | 40 | 20 | 7,872 | 7,852 | Accepted | Accepted | 50 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1
output:
Preorder
0 1 2 3 4 5 6 7 8
Inorder
2 1 3 0 6 5 7 4 8
Postorder
2 3 1 6 7 5 8 4 0
"""
import sys
class Node(object):
def __init__(self):
# i... | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1
output:
Preorder
0 1 2 3 4 5 6 7 8
Inorder
2 1 3 0 6 5 7 4 8
Postorder
2 3 1 6 7 5 8 4 0
"""
import sys
class Node(object):
def __init__(self):
# i... | 123 | 124 | 2,621 | 2,628 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1
output:
Preorder
0 1 2 3 4 5 6 7 8
Inorder
2 1 3 0 6 5 7 4 8
Postorder
2 3 1 6 7 5 8 4 0
"""
import sys
class Node(object):
def __init__(self):
# init node as a single leaf node.
... | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1
output:
Preorder
0 1 2 3 4 5 6 7 8
Inorder
2 1 3 0 6 5 7 4 8
Postorder
2 3 1 6 7 5 8 4 0
"""
import sys
class Node(object):
def __init__(self):
# init node as a single leaf node.
... | false | 0.806452 | [
"+ root_node = node_list[root_idx]",
"- pre_parse(node_list[root_idx])",
"+ pre_parse(root_node)",
"- in_parse(node_list[root_idx])",
"+ in_parse(root_node)",
"- post_parse(node_list[root_idx])",
"+ post_parse(root_node)"
] | false | 0.032639 | 0.037594 | 0.868188 | [
"s566306840",
"s496793240"
] |
u745087332 | p03608 | python | s948438642 | s913628819 | 347 | 216 | 7,104 | 7,104 | Accepted | Accepted | 37.75 | # coding:utf-8
import sys
import heapq
import itertools
from collections import defaultdict
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 LS(): return sys.stdin.readline().split()... | # coding:utf-8
import sys
import heapq
import itertools
from collections import defaultdict
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 LS(): return sys.stdin.readline().split()... | 56 | 61 | 1,222 | 1,319 | # coding:utf-8
import sys
import heapq
import itertools
from collections import defaultdict
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 LS():
return sys.stdin.readline().spl... | # coding:utf-8
import sys
import heapq
import itertools
from collections import defaultdict
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 LS():
return sys.stdin.readline().spl... | false | 8.196721 | [
"+ visited = set()",
"+ if hv in visited:",
"+ continue",
"+ visited.add(hv)"
] | false | 0.046706 | 0.044416 | 1.051561 | [
"s948438642",
"s913628819"
] |
u141610915 | p03096 | python | s263266438 | s352716912 | 561 | 488 | 74,700 | 73,896 | Accepted | Accepted | 13.01 | import sys
from bisect import bisect_left as bl
from bisect import bisect_right as br
input = sys.stdin.readline
N = int(eval(input()))
table = [[] for _ in range(2 * pow(10, 5) + 1)]
a = []
t = 0
mod = 10 ** 9 + 7
for i in range(N):
x = int(eval(input()))
if t != x:
table[x].append(i)
t = x
... | import sys
from bisect import bisect_right as br
from bisect import bisect_left as bl
input = sys.stdin.readline
N = int(eval(input()))
mod = 10 ** 9 + 7
a = []
for _ in range(N): a.append(int(eval(input())))
t = 0
table = [[] for _ in range(max(a) + 1)]
for i in range(N):
if a[i] != t:
t = a[i]
... | 29 | 34 | 656 | 808 | import sys
from bisect import bisect_left as bl
from bisect import bisect_right as br
input = sys.stdin.readline
N = int(eval(input()))
table = [[] for _ in range(2 * pow(10, 5) + 1)]
a = []
t = 0
mod = 10**9 + 7
for i in range(N):
x = int(eval(input()))
if t != x:
table[x].append(i)
t = x
... | import sys
from bisect import bisect_right as br
from bisect import bisect_left as bl
input = sys.stdin.readline
N = int(eval(input()))
mod = 10**9 + 7
a = []
for _ in range(N):
a.append(int(eval(input())))
t = 0
table = [[] for _ in range(max(a) + 1)]
for i in range(N):
if a[i] != t:
t = a[i]
... | false | 14.705882 | [
"+from bisect import bisect_right as br",
"-from bisect import bisect_right as br",
"-table = [[] for _ in range(2 * pow(10, 5) + 1)]",
"+mod = 10**9 + 7",
"+for _ in range(N):",
"+ a.append(int(eval(input())))",
"-mod = 10**9 + 7",
"+table = [[] for _ in range(max(a) + 1)]",
"- x = int(eval(i... | false | 0.114198 | 0.037824 | 3.019204 | [
"s263266438",
"s352716912"
] |
u496821919 | p02609 | python | s681901985 | s208957294 | 657 | 605 | 9,800 | 9,404 | Accepted | Accepted | 7.91 | from copy import copy
def popcount(x):
return bin(x).count("1")
def f(x):
if x == 0:
return 0
return f(x%popcount(x))+1
n = int(eval(input()))
x = eval(input())
xx = int(x,2)
p = x.count("1")
stand1 = xx%(p+1)
if p != 1:
stand2 = xx%(p-1)
for i in range(n):
if x[i] == "1... | def popcount(x):
return bin(x).count("1")
def f(x):
if x == 0:
return 0
return f(x%popcount(x))+1
n = int(eval(input()))
x = eval(input())
xx = int(x,2)
p = x.count("1")
stand1 = xx%(p+1)
if p != 1:
stand2 = xx%(p-1)
for i in range(n):
if x[i] == "1":
if p != 1:
... | 31 | 29 | 582 | 545 | from copy import copy
def popcount(x):
return bin(x).count("1")
def f(x):
if x == 0:
return 0
return f(x % popcount(x)) + 1
n = int(eval(input()))
x = eval(input())
xx = int(x, 2)
p = x.count("1")
stand1 = xx % (p + 1)
if p != 1:
stand2 = xx % (p - 1)
for i in range(n):
if x[i] == "1":... | def popcount(x):
return bin(x).count("1")
def f(x):
if x == 0:
return 0
return f(x % popcount(x)) + 1
n = int(eval(input()))
x = eval(input())
xx = int(x, 2)
p = x.count("1")
stand1 = xx % (p + 1)
if p != 1:
stand2 = xx % (p - 1)
for i in range(n):
if x[i] == "1":
if p != 1:
... | false | 6.451613 | [
"-from copy import copy",
"-",
"-",
"- k = copy(stand2)",
"+ k = stand2",
"- k = copy(stand1)",
"+ k = stand1"
] | false | 0.046742 | 0.044321 | 1.054622 | [
"s681901985",
"s208957294"
] |
u624475441 | p03681 | python | s267120237 | s626387242 | 400 | 28 | 4,736 | 3,064 | Accepted | Accepted | 93 | from math import factorial
MOD = 10**9 + 7
n, m = list(map(int, input().split()))
if n == m:
print((2 * factorial(n)**2 % MOD))
elif n - 1 == m:
print((n * factorial(m)**2 % MOD))
elif n == m - 1:
print((m * factorial(n)**2 % MOD))
else:
print((0)) | def factorial(n):
ans = 1
for i in range(2, n + 1):
ans = ans * i % 1000000007
return ans
n, m = list(map(int, input().split()))
MOD = 10**9 + 7
if n == m:
print((2 * factorial(n) ** 2 % MOD))
elif abs(n - m) == 1:
print((factorial(min(m, n)) ** 2 * max(m, n) % MOD))
else:
pr... | 11 | 13 | 260 | 316 | from math import factorial
MOD = 10**9 + 7
n, m = list(map(int, input().split()))
if n == m:
print((2 * factorial(n) ** 2 % MOD))
elif n - 1 == m:
print((n * factorial(m) ** 2 % MOD))
elif n == m - 1:
print((m * factorial(n) ** 2 % MOD))
else:
print((0))
| def factorial(n):
ans = 1
for i in range(2, n + 1):
ans = ans * i % 1000000007
return ans
n, m = list(map(int, input().split()))
MOD = 10**9 + 7
if n == m:
print((2 * factorial(n) ** 2 % MOD))
elif abs(n - m) == 1:
print((factorial(min(m, n)) ** 2 * max(m, n) % MOD))
else:
print((0))
| false | 15.384615 | [
"-from math import factorial",
"+def factorial(n):",
"+ ans = 1",
"+ for i in range(2, n + 1):",
"+ ans = ans * i % 1000000007",
"+ return ans",
"+",
"+n, m = list(map(int, input().split()))",
"-n, m = list(map(int, input().split()))",
"-elif n - 1 == m:",
"- print((n * factor... | false | 0.154995 | 0.038611 | 4.014335 | [
"s267120237",
"s626387242"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.