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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u978313283 | p03160 | python | s460568070 | s844290286 | 144 | 130 | 13,980 | 14,028 | Accepted | Accepted | 9.72 | INF=10**15
N=int(eval(input()))
h=list(map(int,input().split()))
dp=[INF for i in range(N)]
dp[0]=0
for i in range(1,N):
if i>1:
dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
else:
dp[i]=dp[i-1]+abs(h[i]-h[i-1])
print((dp[N-1])) | N=int(eval(input()))
H=list(map(int,input().split()))
Cost=[0 for i in range(N)]
Cost[1]=abs(H[1]-H[0])
for i in range(2,N):
Cost[i]=min(Cost[i-2] + abs(H[i]-H[i-2]), Cost[i-1] + abs(H[i]-H[i-1]))
print((Cost[N-1])) | 11 | 7 | 269 | 217 | INF = 10**15
N = int(eval(input()))
h = list(map(int, input().split()))
dp = [INF for i in range(N)]
dp[0] = 0
for i in range(1, N):
if i > 1:
dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
else:
dp[i] = dp[i - 1] + abs(h[i] - h[i - 1])
print((dp[N - 1]))
| N = int(eval(input()))
H = list(map(int, input().split()))
Cost = [0 for i in range(N)]
Cost[1] = abs(H[1] - H[0])
for i in range(2, N):
Cost[i] = min(
Cost[i - 2] + abs(H[i] - H[i - 2]), Cost[i - 1] + abs(H[i] - H[i - 1])
)
print((Cost[N - 1]))
| false | 36.363636 | [
"-INF = 10**15",
"-h = list(map(int, input().split()))",
"-dp = [INF for i in range(N)]",
"-dp[0] = 0",
"-for i in range(1, N):",
"- if i > 1:",
"- dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))",
"- else:",
"- dp[i] = dp[i - 1] + abs(h[i] - h[i -... | false | 0.041336 | 0.036959 | 1.118411 | [
"s460568070",
"s844290286"
] |
u298297089 | p02804 | python | s350898184 | s752195164 | 614 | 447 | 15,988 | 22,932 | Accepted | Accepted | 27.2 | class Factorial:
def __init__(self, n, mod=10**9+7):
self.fac = [0] * (n+1)
self.ifac = [0] * (n+1)
self.fac[0] = 1
self.ifac[0] = 1
self.mod = mod
modmod = self.mod - 2
for i in range(n):
self.fac[i+1] = self.fac[i] * (i+1) % self.mod
... | from itertools import accumulate
class Factorial:
def __init__(self, n, mod=10**9+7):
self.fac = [0] * (n+1)
self.ifac = [0] * (n+1)
self.fac[0] = 1
self.ifac[0] = 1
self.mod = mod
modmod = self.mod - 2
for i in range(n):
self.fac[i+1] ... | 45 | 46 | 1,256 | 1,328 | class Factorial:
def __init__(self, n, mod=10**9 + 7):
self.fac = [0] * (n + 1)
self.ifac = [0] * (n + 1)
self.fac[0] = 1
self.ifac[0] = 1
self.mod = mod
modmod = self.mod - 2
for i in range(n):
self.fac[i + 1] = self.fac[i] * (i + 1) % self.mod
... | from itertools import accumulate
class Factorial:
def __init__(self, n, mod=10**9 + 7):
self.fac = [0] * (n + 1)
self.ifac = [0] * (n + 1)
self.fac[0] = 1
self.ifac[0] = 1
self.mod = mod
modmod = self.mod - 2
for i in range(n):
self.fac[i + 1] = ... | false | 2.173913 | [
"+from itertools import accumulate",
"+",
"+",
"- mn, mx = 0, 0",
"- for i in range(k, n + 1):",
"- mx = (mx + a[i - 1] * fact.comb(i - 1, k - 1)) % mod",
"- mn = (mn + a[n - i] * fact.comb(i - 1, k - 1)) % mod",
"- ans = mx - mn",
"- if ans < 0:",
"- ans += mod",
... | false | 0.036616 | 0.03665 | 0.999067 | [
"s350898184",
"s752195164"
] |
u936985471 | p03618 | python | s866031905 | s823307126 | 78 | 30 | 3,500 | 3,560 | Accepted | Accepted | 61.54 | a=eval(input())
dic={}
for i in range(len(a)):
s=a[i]
if s in dic:
dic[s]=dic[s]+1
else:
dic[s]=1
sum=0
for val in list(dic.values()):
if val>1:
sum=sum+(val-1)*val//2
print(((len(a)*(len(a)-1))//2-sum+1)) | import sys
readline = sys.stdin.readline
A = readline().rstrip()
from collections import Counter
counter = Counter(A)
ans = 1 + (len(A) * (len(A) - 1)) // 2
for val in list(counter.values()):
ans -= (val * (val - 1)) // 2
print(ans) | 15 | 14 | 229 | 248 | a = eval(input())
dic = {}
for i in range(len(a)):
s = a[i]
if s in dic:
dic[s] = dic[s] + 1
else:
dic[s] = 1
sum = 0
for val in list(dic.values()):
if val > 1:
sum = sum + (val - 1) * val // 2
print(((len(a) * (len(a) - 1)) // 2 - sum + 1))
| import sys
readline = sys.stdin.readline
A = readline().rstrip()
from collections import Counter
counter = Counter(A)
ans = 1 + (len(A) * (len(A) - 1)) // 2
for val in list(counter.values()):
ans -= (val * (val - 1)) // 2
print(ans)
| false | 6.666667 | [
"-a = eval(input())",
"-dic = {}",
"-for i in range(len(a)):",
"- s = a[i]",
"- if s in dic:",
"- dic[s] = dic[s] + 1",
"- else:",
"- dic[s] = 1",
"-sum = 0",
"-for val in list(dic.values()):",
"- if val > 1:",
"- sum = sum + (val - 1) * val // 2",
"-print(((... | false | 0.061434 | 0.057096 | 1.075969 | [
"s866031905",
"s823307126"
] |
u581603131 | p03338 | python | s405712986 | s411296864 | 20 | 18 | 3,064 | 3,060 | Accepted | Accepted | 10 | N = int(eval(input()))
S = eval(input())
s = set(S)
count = 0
maxx = 0
for i in range(N): #切断場所
for k in range(i):
if S[k] in S[:i] and S[k] in S[i:] and S[k] not in S[:k]:
count += 1
maxx = max(maxx, count)
count = 0
print(maxx) | N = int(eval(input()))
S = eval(input())
print((max(len(set(S[:i])&set(S[i:])) for i in range(N)))) | 12 | 3 | 260 | 87 | N = int(eval(input()))
S = eval(input())
s = set(S)
count = 0
maxx = 0
for i in range(N): # 切断場所
for k in range(i):
if S[k] in S[:i] and S[k] in S[i:] and S[k] not in S[:k]:
count += 1
maxx = max(maxx, count)
count = 0
print(maxx)
| N = int(eval(input()))
S = eval(input())
print((max(len(set(S[:i]) & set(S[i:])) for i in range(N))))
| false | 75 | [
"-s = set(S)",
"-count = 0",
"-maxx = 0",
"-for i in range(N): # 切断場所",
"- for k in range(i):",
"- if S[k] in S[:i] and S[k] in S[i:] and S[k] not in S[:k]:",
"- count += 1",
"- maxx = max(maxx, count)",
"- count = 0",
"-print(maxx)",
"+print((max(len(set(S[:i]) & set... | false | 0.061865 | 0.047444 | 1.303948 | [
"s405712986",
"s411296864"
] |
u645250356 | p03379 | python | s980558238 | s304987442 | 457 | 194 | 86,656 | 33,712 | Accepted | Accepted | 57.55 | from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
de... | 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, ... | 18 | 17 | 529 | 467 | from collections import Counter, defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
def inp():
return int(sys.stdin.readline())
def inpl():
return list(map(int, sys.stdin.readline().split()))
def inpl_str():
return list(sys.stdin.... | 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 | 5.555556 | [
"-import sys, heapq, bisect, math, itertools, string, queue",
"+from heapq import heappop, heappush",
"+from bisect import bisect_left, bisect_right",
"+import sys, math, itertools, fractions, pprint",
"+INF = float(\"inf\")",
"-def inpl_str():",
"- return list(sys.stdin.readline().split())",
"-",
... | false | 0.047786 | 0.053245 | 0.897487 | [
"s980558238",
"s304987442"
] |
u489061952 | p02983 | python | s776279965 | s121919995 | 1,038 | 72 | 3,060 | 3,060 | Accepted | Accepted | 93.06 | l, r = (int(x) for x in input().split())
tmpmin = 2019
if r-l >= 2019:
print((0))
else:
for i in range(l, r):
for j in range(l+1, r+1):
tmp = (i*j)%2019
if tmp < tmpmin:
tmpmin = tmp
if tmpmin == 0:
break
print(t... | import sys
l, r = (int(x) for x in input().split())
tmpmin = 2019
if r-l >= 2019:
print((0))
else:
for i in range(l, r):
for j in range(l+1, r+1):
tmp = (i*j)%2019
if tmp < tmpmin:
tmpmin = tmp
if tmpmin == 0:
print(... | 13 | 15 | 324 | 376 | l, r = (int(x) for x in input().split())
tmpmin = 2019
if r - l >= 2019:
print((0))
else:
for i in range(l, r):
for j in range(l + 1, r + 1):
tmp = (i * j) % 2019
if tmp < tmpmin:
tmpmin = tmp
if tmpmin == 0:
break
print(tmp... | import sys
l, r = (int(x) for x in input().split())
tmpmin = 2019
if r - l >= 2019:
print((0))
else:
for i in range(l, r):
for j in range(l + 1, r + 1):
tmp = (i * j) % 2019
if tmp < tmpmin:
tmpmin = tmp
if tmpmin == 0:
print(t... | false | 13.333333 | [
"+import sys",
"+",
"- break",
"+ print(tmpmin)",
"+ sys.exit()"
] | false | 0.047847 | 0.007281 | 6.571448 | [
"s776279965",
"s121919995"
] |
u353797797 | p02734 | python | s464078252 | s873638586 | 1,845 | 966 | 3,316 | 3,444 | Accepted | Accepted | 47.64 | import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in ... | import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in ... | 27 | 24 | 689 | 634 | import sys
sys.setrecursionlimit(10**6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II():
return int(sys.stdin.readline())
def MI():
return map(int, sys.stdin.readline().split())
def LI():
return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number):
return [... | import sys
sys.setrecursionlimit(10**6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II():
return int(sys.stdin.readline())
def MI():
return map(int, sys.stdin.readline().split())
def LI():
return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number):
return [... | false | 11.111111 | [
"- dp[i] %= md",
"- ans %= md",
"- print(ans)",
"+ print(ans % md)"
] | false | 0.036961 | 0.073853 | 0.500473 | [
"s464078252",
"s873638586"
] |
u477320129 | p03244 | python | s196727849 | s434725782 | 126 | 101 | 30,624 | 27,536 | Accepted | Accepted | 19.84 | #!/usr/bin/env python3
import sys
def solve(n: int, v: "List[int]"):
from collections import Counter
a = sorted(list(Counter(v[::2]).items()), key=lambda x: (x[1], x[0]))
b = sorted(list(Counter(v[1::2]).items()), key=lambda x: (x[1], x[0]))
if a[-1][0] != b[-1][0]:
return n - a[-1][1... | #!/usr/bin/env python3
import sys
def solve(n: int, v: "List[int]"):
from collections import Counter
a = Counter(v[::2]).most_common()
b = Counter(v[1::2]).most_common()
if a[0][0] != b[0][0]:
return n - a[0][1] - b[0][1]
a = a + [(0, 0)]
b = b + [(0, 0)]
return n - max... | 34 | 34 | 937 | 869 | #!/usr/bin/env python3
import sys
def solve(n: int, v: "List[int]"):
from collections import Counter
a = sorted(list(Counter(v[::2]).items()), key=lambda x: (x[1], x[0]))
b = sorted(list(Counter(v[1::2]).items()), key=lambda x: (x[1], x[0]))
if a[-1][0] != b[-1][0]:
return n - a[-1][1] - b[-1... | #!/usr/bin/env python3
import sys
def solve(n: int, v: "List[int]"):
from collections import Counter
a = Counter(v[::2]).most_common()
b = Counter(v[1::2]).most_common()
if a[0][0] != b[0][0]:
return n - a[0][1] - b[0][1]
a = a + [(0, 0)]
b = b + [(0, 0)]
return n - max(a[0][1] + ... | false | 0 | [
"- a = sorted(list(Counter(v[::2]).items()), key=lambda x: (x[1], x[0]))",
"- b = sorted(list(Counter(v[1::2]).items()), key=lambda x: (x[1], x[0]))",
"- if a[-1][0] != b[-1][0]:",
"- return n - a[-1][1] - b[-1][1]",
"- a = [(0, 0)] + a",
"- b = [(0, 0)] + b",
"- return n - max(... | false | 0.050936 | 0.051967 | 0.98015 | [
"s196727849",
"s434725782"
] |
u046187684 | p02948 | python | s246775767 | s438915401 | 434 | 397 | 25,876 | 25,840 | Accepted | Accepted | 8.53 | import heapq
def solve(string):
n, m, *ab = list(map(int, string.split()))
ab = sorted([(a, b) for a, b in zip(*[iter(ab)] * 2)])
hq = []
index, cap, count = 0, 1, m
ans = 0
while index < n:
_a, _b = ab[index]
if _a > m:
break
if _a <= cap:
... | import heapq
def solve(string):
n, m, *ab = list(map(int, string.split()))
ab = sorted([(a, b) for a, b in zip(*[iter(ab)] * 2)])
hq, index, cap, count, ans = [], 0, 1, m, 0
while index < n:
_a, _b = ab[index]
if _a > m:
break
if _a <= cap:
h... | 30 | 25 | 770 | 739 | import heapq
def solve(string):
n, m, *ab = list(map(int, string.split()))
ab = sorted([(a, b) for a, b in zip(*[iter(ab)] * 2)])
hq = []
index, cap, count = 0, 1, m
ans = 0
while index < n:
_a, _b = ab[index]
if _a > m:
break
if _a <= cap:
heapq... | import heapq
def solve(string):
n, m, *ab = list(map(int, string.split()))
ab = sorted([(a, b) for a, b in zip(*[iter(ab)] * 2)])
hq, index, cap, count, ans = [], 0, 1, m, 0
while index < n:
_a, _b = ab[index]
if _a > m:
break
if _a <= cap:
heapq.heappus... | false | 16.666667 | [
"- hq = []",
"- index, cap, count = 0, 1, m",
"- ans = 0",
"+ hq, index, cap, count, ans = [], 0, 1, m, 0",
"- if len(hq) > 0:",
"- ans += -heapq.heappop(hq)",
"+ ans += -heapq.heappop(hq) if len(hq) > 0 else 0",
"- for _ in range(count):",
"- ... | false | 0.049962 | 0.048878 | 1.022182 | [
"s246775767",
"s438915401"
] |
u352394527 | p00486 | python | s558273012 | s579607281 | 610 | 510 | 25,180 | 25,128 | Accepted | Accepted | 16.39 | from bisect import bisect_left as bl
INF = 10 ** 20
def main():
w, h = list(map(int, input().split()))
n = int(eval(input()))
xlst = []
ylst = []
appx = xlst.append
appy = ylst.append
for i in range(n):
x, y = list(map(int,input().split()))
appx(x)
appy(y)
sorted_x... | from bisect import bisect_left as bl
INF = 10 ** 20
def main():
w, h = list(map(int, input().split()))
n = int(eval(input()))
xlst = []
ylst = []
appx = xlst.append
appy = ylst.append
for i in range(n):
x, y = list(map(int,input().split()))
appx(x)
appy(y)
sorted_x... | 103 | 101 | 1,953 | 2,197 | from bisect import bisect_left as bl
INF = 10**20
def main():
w, h = list(map(int, input().split()))
n = int(eval(input()))
xlst = []
ylst = []
appx = xlst.append
appy = ylst.append
for i in range(n):
x, y = list(map(int, input().split()))
appx(x)
appy(y)
sorte... | from bisect import bisect_left as bl
INF = 10**20
def main():
w, h = list(map(int, input().split()))
n = int(eval(input()))
xlst = []
ylst = []
appx = xlst.append
appy = ylst.append
for i in range(n):
x, y = list(map(int, input().split()))
appx(x)
appy(y)
sorte... | false | 1.941748 | [
"+ xllen = (",
"+ (accx - cum_sum_xlst[plx - 1] * 2 - clx * (n - plx * 2)) * 2",
"+ if plx != 0",
"+ else (accx - clx * n) * 2",
"+ )",
"+ xrlen = (",
"+ (accx - cum_sum_xlst[prx - 1] * 2 - crx * (n - prx * 2)) * 2",
"+ if prx != 0",
"+ else (accx -... | false | 0.049416 | 0.126658 | 0.390151 | [
"s558273012",
"s579607281"
] |
u022407960 | p02317 | python | s102506287 | s202113611 | 220 | 180 | 19,524 | 19,504 | Accepted | Accepted | 18.18 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
5
5
1
3
2
4
or
3
1
1
1
output:
3
or
1
"""
import sys
from bisect import bisect_left
def solve():
dis_rec = [float('inf')] * array_length
dis_rec[0] = array[0]
length = 1
for j in range(1, array_length):
... | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
5
5
1
3
2
4
or
3
1
1
1
output:
3
or
1
"""
import sys
from bisect import bisect_left
def solve():
dis_rec = [float('inf')] * array_length
dis_rec[0] = array[0]
length = 1
for i, ele in enumerate(array,... | 50 | 52 | 722 | 709 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
5
5
1
3
2
4
or
3
1
1
1
output:
3
or
1
"""
import sys
from bisect import bisect_left
def solve():
dis_rec = [float("inf")] * array_length
dis_rec[0] = array[0]
length = 1
for j in range(1, array_length):
if dis_rec[length - 1] < array[j]:... | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
5
5
1
3
2
4
or
3
1
1
1
output:
3
or
1
"""
import sys
from bisect import bisect_left
def solve():
dis_rec = [float("inf")] * array_length
dis_rec[0] = array[0]
length = 1
for i, ele in enumerate(array, 1):
if dis_rec[length - 1] < ele:
... | false | 3.846154 | [
"- for j in range(1, array_length):",
"- if dis_rec[length - 1] < array[j]:",
"- dis_rec[length] = array[j]",
"+ for i, ele in enumerate(array, 1):",
"+ if dis_rec[length - 1] < ele:",
"+ dis_rec[length] = ele",
"- position = bisect_left(dis_rec, arra... | false | 0.033608 | 0.036648 | 0.917053 | [
"s102506287",
"s202113611"
] |
u426534722 | p02265 | python | s519753224 | s632321766 | 2,170 | 1,660 | 45,944 | 69,732 | Accepted | Accepted | 23.5 | import sys
from collections import deque
readline = sys.stdin.readline
dq = deque()
for _ in range(int(eval(input()))):
ss = readline().strip()
if ss == "deleteFirst":
del dq[0]
elif ss == "deleteLast":
del dq[-1]
else:
c, s = ss.split()
s = int(s)
if... | import sys
from collections import deque
readline = sys.stdin.readline
dq = deque()
for _ in range(int(eval(input()))):
c = readline().split()
if c[0] == "deleteFirst":
del dq[0]
elif c[0] == "deleteLast":
del dq[-1]
else:
if c[0] == "insert":
dq.appendlef... | 20 | 18 | 458 | 429 | import sys
from collections import deque
readline = sys.stdin.readline
dq = deque()
for _ in range(int(eval(input()))):
ss = readline().strip()
if ss == "deleteFirst":
del dq[0]
elif ss == "deleteLast":
del dq[-1]
else:
c, s = ss.split()
s = int(s)
if c == "inser... | import sys
from collections import deque
readline = sys.stdin.readline
dq = deque()
for _ in range(int(eval(input()))):
c = readline().split()
if c[0] == "deleteFirst":
del dq[0]
elif c[0] == "deleteLast":
del dq[-1]
else:
if c[0] == "insert":
dq.appendleft(c[1])
... | false | 10 | [
"- ss = readline().strip()",
"- if ss == \"deleteFirst\":",
"+ c = readline().split()",
"+ if c[0] == \"deleteFirst\":",
"- elif ss == \"deleteLast\":",
"+ elif c[0] == \"deleteLast\":",
"- c, s = ss.split()",
"- s = int(s)",
"- if c == \"insert\":",
"- ... | false | 0.041613 | 0.036963 | 1.125799 | [
"s519753224",
"s632321766"
] |
u994988729 | p03682 | python | s902557857 | s926251682 | 1,527 | 1,118 | 47,048 | 45,240 | Accepted | Accepted | 26.78 | import heapq
N = int(eval(input()))
town = []
for i in range(N):
x, y = list(map(int, input().split()))
town.append((x, y, i))
uf = [i for i in range(N)] #uf[i]==iであれば根
def root(x):
if x == uf[x]:
return x
else:
r = root(uf[x])
uf[x] = r
return r
... | from operator import itemgetter
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
class UF_tree:
def __init__(self, n):
self.root = [-1] * (n + 1) # -1ならそのノードが根,で絶対値が木の要素数
self.rank = [0] * (n + 1)
def find(self, x): # xの根となる要素番号を返す
if self.root... | 51 | 64 | 1,023 | 1,622 | import heapq
N = int(eval(input()))
town = []
for i in range(N):
x, y = list(map(int, input().split()))
town.append((x, y, i))
uf = [i for i in range(N)] # uf[i]==iであれば根
def root(x):
if x == uf[x]:
return x
else:
r = root(uf[x])
uf[x] = r
return r
def isSame(x, y):
... | from operator import itemgetter
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
class UF_tree:
def __init__(self, n):
self.root = [-1] * (n + 1) # -1ならそのノードが根,で絶対値が木の要素数
self.rank = [0] * (n + 1)
def find(self, x): # xの根となる要素番号を返す
if self.root[x] < 0:
... | false | 20.3125 | [
"-import heapq",
"+from operator import itemgetter",
"+import sys",
"-N = int(eval(input()))",
"-town = []",
"-for i in range(N):",
"- x, y = list(map(int, input().split()))",
"- town.append((x, y, i))",
"-uf = [i for i in range(N)] # uf[i]==iであれば根",
"+input = sys.stdin.buffer.readline",
... | false | 0.037829 | 0.037702 | 1.003381 | [
"s902557857",
"s926251682"
] |
u338225045 | p03495 | python | s216074603 | s502775487 | 119 | 99 | 24,748 | 24,996 | Accepted | Accepted | 16.81 | N, K = list(map( int, input().split() ))
A = list( map( int, input().split() ) )
numAppeared = [0] * (N+1)
for i in A:
numAppeared[i] += 1
numAppeared.sort( reverse=True )
print(( sum( numAppeared[i] for i in range(K,N) ) )) | N, K = list(map( int, input().split() ))
A = list( map( int, input().split() ) )
numAppeared = [0] * (N+1)
for i in A:
numAppeared[i] += 1
numAppeared.sort( reverse=True )
# print( sum( numAppeared[i] for i in range(K,N) ) )
print(( sum( numAppeared[K:N] ) )) | 11 | 12 | 234 | 270 | N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
numAppeared = [0] * (N + 1)
for i in A:
numAppeared[i] += 1
numAppeared.sort(reverse=True)
print((sum(numAppeared[i] for i in range(K, N))))
| N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
numAppeared = [0] * (N + 1)
for i in A:
numAppeared[i] += 1
numAppeared.sort(reverse=True)
# print( sum( numAppeared[i] for i in range(K,N) ) )
print((sum(numAppeared[K:N])))
| false | 8.333333 | [
"-print((sum(numAppeared[i] for i in range(K, N))))",
"+# print( sum( numAppeared[i] for i in range(K,N) ) )",
"+print((sum(numAppeared[K:N])))"
] | false | 0.194023 | 0.041688 | 4.65414 | [
"s216074603",
"s502775487"
] |
u294520705 | p02995 | python | s051485701 | s014027158 | 35 | 18 | 5,088 | 3,064 | Accepted | Accepted | 48.57 | import fractions
import sys
input = sys.stdin.readline# 最小公倍数
def lcm(x, y):
return (x * y) // fractions.gcd(x, y)
a, b, c, d = list(map(int, input().split()))
e = lcm(c, d)
#print("e: {}".format(e))
#print("c: {} - {}".format(b // c, (a - 1) // c))
#print("d: {} - {}".format(b // d, (a - 1) // d))
... | import sys
import math
input = sys.stdin.readline# 最小公倍数
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(x, y):
return (x * y) // gcd(x, y)
a, b, c, d = list(map(int, input().split()))
e = lcm(c, d)
#print("e: {}".format(e))
#print("c: {} - {}".format(b // c, (a - 1) ... | 20 | 26 | 655 | 714 | import fractions
import sys
input = sys.stdin.readline # 最小公倍数
def lcm(x, y):
return (x * y) // fractions.gcd(x, y)
a, b, c, d = list(map(int, input().split()))
e = lcm(c, d)
# print("e: {}".format(e))
# print("c: {} - {}".format(b // c, (a - 1) // c))
# print("d: {} - {}".format(b // d, (a - 1) // d))
# prin... | import sys
import math
input = sys.stdin.readline # 最小公倍数
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(x, y):
return (x * y) // gcd(x, y)
a, b, c, d = list(map(int, input().split()))
e = lcm(c, d)
# print("e: {}".format(e))
# print("c: {} - {}".format(b // c, (a - 1) // c))
# pri... | false | 23.076923 | [
"-import fractions",
"+import math",
"+def gcd(a, b):",
"+ while b:",
"+ a, b = b, a % b",
"+ return a",
"+",
"+",
"- return (x * y) // fractions.gcd(x, y)",
"+ return (x * y) // gcd(x, y)"
] | false | 0.098318 | 0.072998 | 1.346853 | [
"s051485701",
"s014027158"
] |
u021548497 | p03137 | python | s671956416 | s368038359 | 164 | 112 | 13,960 | 13,832 | Accepted | Accepted | 31.71 | import sys
import heapq
inf = 10**6
n, m = list(map(int, input().split()))
if n >= m:
print((0))
sys.exit()
a = [int(x) for x in input().split()]
a.sort()
count = []
heapq.heapify(count)
for i in range(m-1):
heapq.heappush(count, -a[i+1]+a[i])
ans = 0
for j in range(n-1):
ans -= heapq.hea... | m, n = list(map(int, input().split()))
a = [int(x) for x in input().split()]
a.sort()
b = [a[i+1]-a[i] for i in range(n-1)]
b.sort(reverse=True)
print((a[-1]-a[0]-sum(b[:min([m-1, n-1])]))) | 22 | 7 | 360 | 188 | import sys
import heapq
inf = 10**6
n, m = list(map(int, input().split()))
if n >= m:
print((0))
sys.exit()
a = [int(x) for x in input().split()]
a.sort()
count = []
heapq.heapify(count)
for i in range(m - 1):
heapq.heappush(count, -a[i + 1] + a[i])
ans = 0
for j in range(n - 1):
ans -= heapq.heappop(c... | m, n = list(map(int, input().split()))
a = [int(x) for x in input().split()]
a.sort()
b = [a[i + 1] - a[i] for i in range(n - 1)]
b.sort(reverse=True)
print((a[-1] - a[0] - sum(b[: min([m - 1, n - 1])])))
| false | 68.181818 | [
"-import sys",
"-import heapq",
"-",
"-inf = 10**6",
"-n, m = list(map(int, input().split()))",
"-if n >= m:",
"- print((0))",
"- sys.exit()",
"+m, n = list(map(int, input().split()))",
"-count = []",
"-heapq.heapify(count)",
"-for i in range(m - 1):",
"- heapq.heappush(count, -a[i ... | false | 0.041218 | 0.037157 | 1.10929 | [
"s671956416",
"s368038359"
] |
u951289777 | p04044 | python | s953528864 | s681705309 | 19 | 17 | 3,064 | 3,060 | Accepted | Accepted | 10.53 |
n_and_l = eval(input())
n, l = list(map(int, n_and_l.split()))
text = []
for num in range(0, n):
text.append(eval(input()))
for object in range(1, n):
for compare in range(0, object):
if text[object] < text[compare]:
tmp = text[object]
text[object] = text[c... | num, len = list(map(int, input().split()))
strings = []
for n in range(num):
strings.append(eval(input()))
strings.sort()
print((''.join(strings))) | 25 | 9 | 434 | 148 | n_and_l = eval(input())
n, l = list(map(int, n_and_l.split()))
text = []
for num in range(0, n):
text.append(eval(input()))
for object in range(1, n):
for compare in range(0, object):
if text[object] < text[compare]:
tmp = text[object]
text[object] = text[compare]
tex... | num, len = list(map(int, input().split()))
strings = []
for n in range(num):
strings.append(eval(input()))
strings.sort()
print(("".join(strings)))
| false | 64 | [
"-n_and_l = eval(input())",
"-n, l = list(map(int, n_and_l.split()))",
"-text = []",
"-for num in range(0, n):",
"- text.append(eval(input()))",
"-for object in range(1, n):",
"- for compare in range(0, object):",
"- if text[object] < text[compare]:",
"- tmp = text[object]",
... | false | 0.059799 | 0.04174 | 1.432634 | [
"s953528864",
"s681705309"
] |
u583276018 | p02701 | python | s711530004 | s842592362 | 331 | 269 | 35,192 | 35,456 | Accepted | Accepted | 18.73 | stock = {}
for _ in range(int(eval(input()))):
s = eval(input())
try:
stock[s] += 1
except KeyError:
stock[s] = 1
print((len(stock))) | n = int(eval(input()))
stock = []
for _ in range(n):
stock.append(eval(input()))
print((len(set(stock))))
| 8 | 5 | 140 | 98 | stock = {}
for _ in range(int(eval(input()))):
s = eval(input())
try:
stock[s] += 1
except KeyError:
stock[s] = 1
print((len(stock)))
| n = int(eval(input()))
stock = []
for _ in range(n):
stock.append(eval(input()))
print((len(set(stock))))
| false | 37.5 | [
"-stock = {}",
"-for _ in range(int(eval(input()))):",
"- s = eval(input())",
"- try:",
"- stock[s] += 1",
"- except KeyError:",
"- stock[s] = 1",
"-print((len(stock)))",
"+n = int(eval(input()))",
"+stock = []",
"+for _ in range(n):",
"+ stock.append(eval(input()))",... | false | 0.086307 | 0.079461 | 1.086156 | [
"s711530004",
"s842592362"
] |
u492994678 | p03029 | python | s044938053 | s215217305 | 19 | 17 | 2,940 | 3,064 | Accepted | Accepted | 10.53 | A,P = list(map(int,input().split()))
a=((P + A * 3) // 2)
print(a) | A,P = list(map(int,input().split()))
print(((P + A * 3) // 2))
| 6 | 2 | 68 | 56 | A, P = list(map(int, input().split()))
a = (P + A * 3) // 2
print(a)
| A, P = list(map(int, input().split()))
print(((P + A * 3) // 2))
| false | 66.666667 | [
"-a = (P + A * 3) // 2",
"-print(a)",
"+print(((P + A * 3) // 2))"
] | false | 0.039559 | 0.038579 | 1.025419 | [
"s044938053",
"s215217305"
] |
u693953100 | p02915 | python | s915946910 | s126442915 | 20 | 17 | 3,316 | 2,940 | Accepted | Accepted | 15 | n = int(eval(input()))
print((n**3)) | def solve():
n = int(eval(input()))
print((n**3))
if __name__ == "__main__":
solve() | 2 | 5 | 29 | 92 | n = int(eval(input()))
print((n**3))
| def solve():
n = int(eval(input()))
print((n**3))
if __name__ == "__main__":
solve()
| false | 60 | [
"-n = int(eval(input()))",
"-print((n**3))",
"+def solve():",
"+ n = int(eval(input()))",
"+ print((n**3))",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ solve()"
] | false | 0.047612 | 0.048021 | 0.99147 | [
"s915946910",
"s126442915"
] |
u066413086 | p02913 | python | s179101971 | s509434669 | 1,642 | 42 | 4,852 | 3,800 | Accepted | Accepted | 97.44 | from collections import defaultdict
class RollingHash(object):
def __init__(self, S: str, MOD: int = 10 ** 9 + 7, BASE: int = 10 ** 5 + 7):
self.S = S
self.N = N = len(S)
self.MOD = MOD
self.BASE = BASE
self.S_arr = [ord(x) for x in S]
self.POWER = [1] * (... | def solve():
N = int(eval(input()))
S = eval(input())
def rolling_hash(s, mod, base = 37):
l = len(s)
h = [0]*(l + 1)
v = 0
for i in range(l):
h[i+1] = v = (v * base + ord(s[i])) % mod
pw = [1]*(l + 1)
v = 1
for i in range(l):
... | 81 | 40 | 2,475 | 1,076 | from collections import defaultdict
class RollingHash(object):
def __init__(self, S: str, MOD: int = 10**9 + 7, BASE: int = 10**5 + 7):
self.S = S
self.N = N = len(S)
self.MOD = MOD
self.BASE = BASE
self.S_arr = [ord(x) for x in S]
self.POWER = [1] * (N + 1)
... | def solve():
N = int(eval(input()))
S = eval(input())
def rolling_hash(s, mod, base=37):
l = len(s)
h = [0] * (l + 1)
v = 0
for i in range(l):
h[i + 1] = v = (v * base + ord(s[i])) % mod
pw = [1] * (l + 1)
v = 1
for i in range(l):
... | false | 50.617284 | [
"-from collections import defaultdict",
"+def solve():",
"+ N = int(eval(input()))",
"+ S = eval(input())",
"+",
"+ def rolling_hash(s, mod, base=37):",
"+ l = len(s)",
"+ h = [0] * (l + 1)",
"+ v = 0",
"+ for i in range(l):",
"+ h[i + 1] = v = (v ... | false | 0.087703 | 0.035731 | 2.454522 | [
"s179101971",
"s509434669"
] |
u653883313 | p03478 | python | s004091038 | s906227284 | 38 | 30 | 3,060 | 2,940 | Accepted | Accepted | 21.05 | n, a, b= list(map(int, input().split()))
ALlsum = 0
for i in range(1, n+1):
sum = 0
i = str(i)
i_len = len(i)
for j in range(i_len):
sum += int(i[j])
if a<=sum and sum<=b :
ALlsum += int(i)
print(ALlsum) | n, a, b= list(map(int, input().split()))
Ssum = 0
for i in range(1, n+1):
tmp = i
sum = 0
while i>0 :
sum += i%10
i //= 10
if a<=sum and sum<=b:
Ssum += tmp
print(Ssum) | 14 | 13 | 249 | 216 | n, a, b = list(map(int, input().split()))
ALlsum = 0
for i in range(1, n + 1):
sum = 0
i = str(i)
i_len = len(i)
for j in range(i_len):
sum += int(i[j])
if a <= sum and sum <= b:
ALlsum += int(i)
print(ALlsum)
| n, a, b = list(map(int, input().split()))
Ssum = 0
for i in range(1, n + 1):
tmp = i
sum = 0
while i > 0:
sum += i % 10
i //= 10
if a <= sum and sum <= b:
Ssum += tmp
print(Ssum)
| false | 7.142857 | [
"-ALlsum = 0",
"+Ssum = 0",
"+ tmp = i",
"- i = str(i)",
"- i_len = len(i)",
"- for j in range(i_len):",
"- sum += int(i[j])",
"+ while i > 0:",
"+ sum += i % 10",
"+ i //= 10",
"- ALlsum += int(i)",
"-print(ALlsum)",
"+ Ssum += tmp",
"+pri... | false | 0.048313 | 0.039388 | 1.226601 | [
"s004091038",
"s906227284"
] |
u462329577 | p03029 | python | s205547266 | s899149410 | 164 | 17 | 38,256 | 2,940 | Accepted | Accepted | 89.63 | A,P = list(map(int,input().split()))
print(((A*3+P)//2)) | a, p = list(map(int, input().split()))
print(((a * 3 + p) // 2))
| 2 | 3 | 49 | 60 | A, P = list(map(int, input().split()))
print(((A * 3 + P) // 2))
| a, p = list(map(int, input().split()))
print(((a * 3 + p) // 2))
| false | 33.333333 | [
"-A, P = list(map(int, input().split()))",
"-print(((A * 3 + P) // 2))",
"+a, p = list(map(int, input().split()))",
"+print(((a * 3 + p) // 2))"
] | false | 0.042414 | 0.042433 | 0.999549 | [
"s205547266",
"s899149410"
] |
u837673618 | p02737 | python | s078794633 | s779278341 | 1,958 | 1,695 | 73,492 | 73,496 | Accepted | Accepted | 13.43 | from collections import defaultdict
M = 998244353
B = pow(10, 18, M)
N = int(eval(input()))
def ext_euc(a, b):
x1, y1, z1 = 1, 0, a
x2, y2, z2 = 0, 1, b
while z1 != 1:
d, m = divmod(z2,z1)
x1, x2 = x2-d*x1, x1
y1, y2 = y2-d*y1, y1
z1, z2 = m, z1
return x1, y1
def inv_mod(a, b,... | from collections import defaultdict
M = 998244353
B = pow(10, 18, M)
N = int(eval(input()))
def ext_euc(a, b):
x1, y1, z1 = 1, 0, a
x2, y2, z2 = 0, 1, b
while z1 != 1:
d, m = divmod(z2,z1)
x1, x2 = x2-d*x1, x1
y1, y2 = y2-d*y1, y1
z1, z2 = m, z1
return x1, y1
def inv_mod(a, b,... | 63 | 66 | 1,244 | 1,296 | from collections import defaultdict
M = 998244353
B = pow(10, 18, M)
N = int(eval(input()))
def ext_euc(a, b):
x1, y1, z1 = 1, 0, a
x2, y2, z2 = 0, 1, b
while z1 != 1:
d, m = divmod(z2, z1)
x1, x2 = x2 - d * x1, x1
y1, y2 = y2 - d * y1, y1
z1, z2 = m, z1
return x1, y1
... | from collections import defaultdict
M = 998244353
B = pow(10, 18, M)
N = int(eval(input()))
def ext_euc(a, b):
x1, y1, z1 = 1, 0, a
x2, y2, z2 = 0, 1, b
while z1 != 1:
d, m = divmod(z2, z1)
x1, x2 = x2 - d * x1, x1
y1, y2 = y2 - d * y1, y1
z1, z2 = m, z1
return x1, y1
... | false | 4.545455 | [
"- sum_g = defaultdict(int)",
"- sum_g[0] = inv_mod(B - 1, pow(B, N + 1, M) - B, M)",
"- x = pow(B, i, M)",
"- sum_g[m] += x",
"+ sum_g = defaultdict(int)",
"+ sum_g[0] = inv_mod(B - 1, pow(B, N + 1, M) - B, M)",
"+ x = 1",
"+ for i in range(1, N + 1):",
"+ ... | false | 0.056532 | 0.130122 | 0.43445 | [
"s078794633",
"s779278341"
] |
u411203878 | p03062 | python | s746921078 | s409379732 | 241 | 91 | 65,440 | 90,756 | Accepted | Accepted | 62.24 | n=int(eval(input()))
t = list(map(int,input().split()))
count = 0
for i in t:
if i < 0:
count += 1
memo = []
for i in t:
memo.append(abs(i))
memo.sort()
if count%2==0:
print((sum(memo)))
else:
print((sum(memo)-memo[0]*2)) | n=int(eval(input()))
a= list(map(int,input().split()))
plus = []
minas = []
for value in a:
if value < 0:
minas.append(abs(value))
else:
plus.append(value)
if len(minas)%2 == 0:
ans = sum(plus)+sum(minas)
else:
if len(plus) > 0:
mini = min(min(plus),min(min... | 20 | 25 | 260 | 446 | n = int(eval(input()))
t = list(map(int, input().split()))
count = 0
for i in t:
if i < 0:
count += 1
memo = []
for i in t:
memo.append(abs(i))
memo.sort()
if count % 2 == 0:
print((sum(memo)))
else:
print((sum(memo) - memo[0] * 2))
| n = int(eval(input()))
a = list(map(int, input().split()))
plus = []
minas = []
for value in a:
if value < 0:
minas.append(abs(value))
else:
plus.append(value)
if len(minas) % 2 == 0:
ans = sum(plus) + sum(minas)
else:
if len(plus) > 0:
mini = min(min(plus), min(minas))
a... | false | 20 | [
"-t = list(map(int, input().split()))",
"-count = 0",
"-for i in t:",
"- if i < 0:",
"- count += 1",
"-memo = []",
"-for i in t:",
"- memo.append(abs(i))",
"-memo.sort()",
"-if count % 2 == 0:",
"- print((sum(memo)))",
"+a = list(map(int, input().split()))",
"+plus = []",
"... | false | 0.044699 | 0.045001 | 0.993286 | [
"s746921078",
"s409379732"
] |
u945181840 | p03014 | python | s132205317 | s987362710 | 1,128 | 1,031 | 247,328 | 267,056 | Accepted | Accepted | 8.6 | import numpy as np
import sys
buf = sys.stdin.buffer
H, W = list(map(int, buf.readline().split()))
grid = np.zeros((H + 2, W + 2), np.int32)
grid[1:-1, 1:-1] = np.where(np.array(list(map(list, buf.read().decode('utf-8').split()))).reshape(H, W) == '.', 1, 0)
grid_v = grid.T
right = np.maximum.accumulate(np.w... | import numpy as np
import sys
line = sys.stdin.readline
H, W = list(map(int, line().split()))
grid = np.zeros((H + 2, W + 2), np.int32)
grid[1:-1, 1:-1] = (np.array([list(line().rstrip()) for _ in range(H)]).reshape(H, W) == '.') * 1
grid_v = grid.T
right = np.maximum.accumulate(np.where(grid < 1, np.arange(... | 15 | 15 | 724 | 699 | import numpy as np
import sys
buf = sys.stdin.buffer
H, W = list(map(int, buf.readline().split()))
grid = np.zeros((H + 2, W + 2), np.int32)
grid[1:-1, 1:-1] = np.where(
np.array(list(map(list, buf.read().decode("utf-8").split()))).reshape(H, W) == ".",
1,
0,
)
grid_v = grid.T
right = np.maximum.accumulate... | import numpy as np
import sys
line = sys.stdin.readline
H, W = list(map(int, line().split()))
grid = np.zeros((H + 2, W + 2), np.int32)
grid[1:-1, 1:-1] = (
np.array([list(line().rstrip()) for _ in range(H)]).reshape(H, W) == "."
) * 1
grid_v = grid.T
right = np.maximum.accumulate(np.where(grid < 1, np.arange(W + ... | false | 0 | [
"-buf = sys.stdin.buffer",
"-H, W = list(map(int, buf.readline().split()))",
"+line = sys.stdin.readline",
"+H, W = list(map(int, line().split()))",
"-grid[1:-1, 1:-1] = np.where(",
"- np.array(list(map(list, buf.read().decode(\"utf-8\").split()))).reshape(H, W) == \".\",",
"- 1,",
"- 0,",
... | false | 0.270777 | 0.792292 | 0.341765 | [
"s132205317",
"s987362710"
] |
u419877586 | p02778 | python | s795029846 | s834805344 | 169 | 17 | 38,256 | 2,940 | Accepted | Accepted | 89.94 | S=eval(input())
ans=["x" for _ in range(len(S))]
print(("".join(ans))) | S = eval(input())
print(("".join(["x" for _ in range(len(S))]))) | 3 | 2 | 64 | 57 | S = eval(input())
ans = ["x" for _ in range(len(S))]
print(("".join(ans)))
| S = eval(input())
print(("".join(["x" for _ in range(len(S))])))
| false | 33.333333 | [
"-ans = [\"x\" for _ in range(len(S))]",
"-print((\"\".join(ans)))",
"+print((\"\".join([\"x\" for _ in range(len(S))])))"
] | false | 0.041809 | 0.035644 | 1.172961 | [
"s795029846",
"s834805344"
] |
u150984829 | p00043 | python | s769014618 | s402814461 | 60 | 50 | 5,580 | 5,612 | Accepted | Accepted | 16.67 | import sys
def p(c,l,b):
for i in l:c[i]+=[-1,1][b]
def f(c):
if sum(c)in c:return 1
if 5 in c:return 0
if 4 in c:
k=c.index(4);c[k]-=3
if f(c):return 1
c[k]+=3
if 3 in c:
k=c.index(3);c[k]-=3
if f(c):return 1
c[k]+=3
for i in range(7):
if c[i]and c[i+1]and c[i+2]:
p(c,[i,i+1,i+2]... | import sys
def g(c,i):
a=[0]*9
for j in e+[i]:a[j-1]+=1
return a
def f(c):
if sum(c)in c:return 1
if 5 in c:return 0
if 4 in c:
k=c.index(4);c[k]-=3
if f(c):return 1
c[k]+=3
if 3 in c:
k=c.index(3);c[k]-=3
if f(c):return 1
c[k]+=3
for i in range(7):
if c[i]and c[i+1]and c[i+2]:
... | 25 | 26 | 503 | 527 | import sys
def p(c, l, b):
for i in l:
c[i] += [-1, 1][b]
def f(c):
if sum(c) in c:
return 1
if 5 in c:
return 0
if 4 in c:
k = c.index(4)
c[k] -= 3
if f(c):
return 1
c[k] += 3
if 3 in c:
k = c.index(3)
c[k] -= 3... | import sys
def g(c, i):
a = [0] * 9
for j in e + [i]:
a[j - 1] += 1
return a
def f(c):
if sum(c) in c:
return 1
if 5 in c:
return 0
if 4 in c:
k = c.index(4)
c[k] -= 3
if f(c):
return 1
c[k] += 3
if 3 in c:
k = c... | false | 3.846154 | [
"-def p(c, l, b):",
"- for i in l:",
"- c[i] += [-1, 1][b]",
"+def g(c, i):",
"+ a = [0] * 9",
"+ for j in e + [i]:",
"+ a[j - 1] += 1",
"+ return a",
"- p(c, [i, i + 1, i + 2], 0)",
"+ c[i] -= 1",
"+ c[i + 1] -= 1",
"+ c[i ... | false | 0.049835 | 0.05298 | 0.940639 | [
"s769014618",
"s402814461"
] |
u941407962 | p02901 | python | s323322163 | s901546203 | 288 | 247 | 47,576 | 42,732 | Accepted | Accepted | 14.24 | n, m = list(map(int, input().split()))
dp = [pow(10, 10) for _ in range(pow(2, n))]
dp[0] = 0
for _ in range(m):
a, b = list(map(int, input().split()))
cs = list(map(int, input().split()))
d = 0
for c in cs:
d += pow(2, (c-1))
for i in range(pow(2, n)):
dp[i|d] = min(dp[i... | import sys;input=sys.stdin.readline
N, M = list(map(int, input().split()))
inf = 10**18
dp = [inf]*(1<<N)
dp[0] = 0
for i in range(M):
a, b = list(map(int, input().split()))
Cs = list(map(int, input().split()))
bb = 0
for c in Cs:
bb += 2**(c-1)
for x in range((1<<N)-1, -1, -1):
... | 17 | 20 | 422 | 443 | n, m = list(map(int, input().split()))
dp = [pow(10, 10) for _ in range(pow(2, n))]
dp[0] = 0
for _ in range(m):
a, b = list(map(int, input().split()))
cs = list(map(int, input().split()))
d = 0
for c in cs:
d += pow(2, (c - 1))
for i in range(pow(2, n)):
dp[i | d] = min(dp[i | d], d... | import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))
inf = 10**18
dp = [inf] * (1 << N)
dp[0] = 0
for i in range(M):
a, b = list(map(int, input().split()))
Cs = list(map(int, input().split()))
bb = 0
for c in Cs:
bb += 2 ** (c - 1)
for x in range((1 << N) - 1, -1, -1... | false | 15 | [
"-n, m = list(map(int, input().split()))",
"-dp = [pow(10, 10) for _ in range(pow(2, n))]",
"+import sys",
"+",
"+input = sys.stdin.readline",
"+N, M = list(map(int, input().split()))",
"+inf = 10**18",
"+dp = [inf] * (1 << N)",
"-for _ in range(m):",
"+for i in range(M):",
"- cs = list(map(i... | false | 0.045219 | 0.039674 | 1.139743 | [
"s323322163",
"s901546203"
] |
u343128979 | p03030 | python | s805783993 | s598724153 | 169 | 148 | 38,256 | 12,496 | Accepted | Accepted | 12.43 | import math
def main():
N = int(eval(input()))
SP = [list(input().split()) + [i + 1] for i in range(N)]
SP.sort(key=lambda x: (x[0], -int(x[1])))
for i in [x[2] for x in SP]:
print(i)
if __name__ == '__main__':
main()
| import math
import numpy as np
def main():
N = int(eval(input()))
SP = [list(input().split()) + [i + 1] for i in range(N)]
SP.sort(key=lambda x: (x[0], -int(x[1])))
_SP = np.array(SP)
for i in _SP[:, 2]:
print(i)
if __name__ == '__main__':
main()
| 13 | 15 | 261 | 291 | import math
def main():
N = int(eval(input()))
SP = [list(input().split()) + [i + 1] for i in range(N)]
SP.sort(key=lambda x: (x[0], -int(x[1])))
for i in [x[2] for x in SP]:
print(i)
if __name__ == "__main__":
main()
| import math
import numpy as np
def main():
N = int(eval(input()))
SP = [list(input().split()) + [i + 1] for i in range(N)]
SP.sort(key=lambda x: (x[0], -int(x[1])))
_SP = np.array(SP)
for i in _SP[:, 2]:
print(i)
if __name__ == "__main__":
main()
| false | 13.333333 | [
"+import numpy as np",
"- for i in [x[2] for x in SP]:",
"+ _SP = np.array(SP)",
"+ for i in _SP[:, 2]:"
] | false | 0.037263 | 0.245566 | 0.151742 | [
"s805783993",
"s598724153"
] |
u844789719 | p03608 | python | s033528195 | s732245998 | 754 | 321 | 10,684 | 42,816 | Accepted | Accepted | 57.43 | import itertools
import heapq
V, E, R = [int(_) for _ in input().split()]
r = [int(_) - 1 for _ in input().split()] # 0-indexed
G = {}
for i in range(V):
G[i] = {}
G[i][i] = 0
for _ in range(E):
s, t, c = [int(_) for _ in input().split()]
s -= 1 # 0-indexed
t -= 1 # 0-indexed
... | import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
import itertools
I = [int(_) for _ in open(0).read().split()]
N, M, R = I[:3]
r = np.array(I[3:3 + R])
ABC = I[3 + R:]
F = floyd_warshall(csr_matrix((ABC[2::3], (ABC[::3], ABC[1::3])), (N + 1, N + 1)), 0).asty... | 52 | 13 | 1,099 | 473 | import itertools
import heapq
V, E, R = [int(_) for _ in input().split()]
r = [int(_) - 1 for _ in input().split()] # 0-indexed
G = {}
for i in range(V):
G[i] = {}
G[i][i] = 0
for _ in range(E):
s, t, c = [int(_) for _ in input().split()]
s -= 1 # 0-indexed
t -= 1 # 0-indexed
G[s][t] = c
... | import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
import itertools
I = [int(_) for _ in open(0).read().split()]
N, M, R = I[:3]
r = np.array(I[3 : 3 + R])
ABC = I[3 + R :]
F = floyd_warshall(
csr_matrix((ABC[2::3], (ABC[::3], ABC[1::3])), (N + 1, N + 1)), 0
).as... | false | 75 | [
"+import numpy as np",
"+from scipy.sparse import csr_matrix",
"+from scipy.sparse.csgraph import floyd_warshall",
"-import heapq",
"-V, E, R = [int(_) for _ in input().split()]",
"-r = [int(_) - 1 for _ in input().split()] # 0-indexed",
"-G = {}",
"-for i in range(V):",
"- G[i] = {}",
"- G... | false | 0.036054 | 0.744948 | 0.048399 | [
"s033528195",
"s732245998"
] |
u279605379 | p02265 | python | s140431809 | s883937870 | 4,570 | 1,990 | 71,992 | 214,356 | Accepted | Accepted | 56.46 | #ALDS1_3-C Elementary data structures - Doubly Linked List
import collections
q = collections.deque()
cmds={"insert":lambda cmd: q.appendleft(cmd[1]),
"delete":lambda cmd: q.remove(cmd[1]) if (q.count(cmd[1]) > 0) else "none",
"deleteFirst":lambda cmd: q.popleft(),
"deleteLast": lambda cmd: q.po... | #ALDS1_3-C Elementary data structures - Doubly Linked List
import collections
import sys
q = collections.deque()
n=int(eval(input()))
_input = sys.stdin.readlines()
cmds={"insert":lambda cmd: q.appendleft(cmd[1]),
"delete":lambda cmd: q.remove(cmd[1]) if (q.count(cmd[1]) > 0) else "none",
"deleteFir... | 14 | 16 | 428 | 474 | # ALDS1_3-C Elementary data structures - Doubly Linked List
import collections
q = collections.deque()
cmds = {
"insert": lambda cmd: q.appendleft(cmd[1]),
"delete": lambda cmd: q.remove(cmd[1]) if (q.count(cmd[1]) > 0) else "none",
"deleteFirst": lambda cmd: q.popleft(),
"deleteLast": lambda cmd: q.po... | # ALDS1_3-C Elementary data structures - Doubly Linked List
import collections
import sys
q = collections.deque()
n = int(eval(input()))
_input = sys.stdin.readlines()
cmds = {
"insert": lambda cmd: q.appendleft(cmd[1]),
"delete": lambda cmd: q.remove(cmd[1]) if (q.count(cmd[1]) > 0) else "none",
"deleteFi... | false | 12.5 | [
"+import sys",
"+n = int(eval(input()))",
"+_input = sys.stdin.readlines()",
"-n = int(eval(input()))",
"- cmd = input().split()",
"+ cmd = _input[i].split()"
] | false | 0.036284 | 0.035096 | 1.033847 | [
"s140431809",
"s883937870"
] |
u227082700 | p02883 | python | s836903746 | s877331663 | 1,285 | 790 | 132,236 | 127,200 | Accepted | Accepted | 38.52 | n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort()
ok=a[-1]*f[-1]
ng=0
if sum(a)<=k:print((0));exit()
ma=ok
while ng+1!=ok:
mid=(ok+ng)//2
b=[mid//i for i in f]
b.sort()
h=0
for i in range(n):h+=max(0,a[i]-b[i])
if h<=k:ok=mi... | n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort(reverse=1)
su=ok=ng=0
for i in range(n):
ok=max(ok,a[i]*f[i])
su+=a[i]
if su<=k:print((0));exit()
while ng+1!=ok:
mid=(ok+ng)//2
b=[mid//i for i in f]
b.sort()
h=0
for i in r... | 18 | 19 | 339 | 383 | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort()
ok = a[-1] * f[-1]
ng = 0
if sum(a) <= k:
print((0))
exit()
ma = ok
while ng + 1 != ok:
mid = (ok + ng) // 2
b = [mid // i for i in f]
b.sort()
h = 0
for i in rang... | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=1)
su = ok = ng = 0
for i in range(n):
ok = max(ok, a[i] * f[i])
su += a[i]
if su <= k:
print((0))
exit()
while ng + 1 != ok:
mid = (ok + ng) // 2
b = [mid // i ... | false | 5.263158 | [
"-f.sort()",
"-ok = a[-1] * f[-1]",
"-ng = 0",
"-if sum(a) <= k:",
"+f.sort(reverse=1)",
"+su = ok = ng = 0",
"+for i in range(n):",
"+ ok = max(ok, a[i] * f[i])",
"+ su += a[i]",
"+if su <= k:",
"-ma = ok"
] | false | 0.114095 | 0.046556 | 2.450717 | [
"s836903746",
"s877331663"
] |
u644516473 | p03379 | python | s199056896 | s643062004 | 303 | 235 | 25,228 | 25,620 | Accepted | Accepted | 22.44 | N = int(eval(input()))
X = list(map(int, input().split()))
mid = sorted(X)[N//2-1:N//2+1]
for xi in X:
if xi > mid[0]:
print((mid[0]))
else:
print((mid[1]))
| N = int(input())
X = list(map(int, input().split()))
mid1, mid2 = sorted(X)[N//2-1:N//2+1]
print(*[mid1 if xi>mid1 else mid2 for xi in X], sep="\n")
| 9 | 5 | 180 | 154 | N = int(eval(input()))
X = list(map(int, input().split()))
mid = sorted(X)[N // 2 - 1 : N // 2 + 1]
for xi in X:
if xi > mid[0]:
print((mid[0]))
else:
print((mid[1]))
| N = int(input())
X = list(map(int, input().split()))
mid1, mid2 = sorted(X)[N // 2 - 1 : N // 2 + 1]
print(*[mid1 if xi > mid1 else mid2 for xi in X], sep="\n")
| false | 44.444444 | [
"-N = int(eval(input()))",
"+N = int(input())",
"-mid = sorted(X)[N // 2 - 1 : N // 2 + 1]",
"-for xi in X:",
"- if xi > mid[0]:",
"- print((mid[0]))",
"- else:",
"- print((mid[1]))",
"+mid1, mid2 = sorted(X)[N // 2 - 1 : N // 2 + 1]",
"+print(*[mid1 if xi > mid1 else mid2 for ... | false | 0.047743 | 0.045457 | 1.050304 | [
"s199056896",
"s643062004"
] |
u127499732 | p02732 | python | s903065350 | s415285960 | 273 | 218 | 44,448 | 44,276 | Accepted | Accepted | 20.15 | def main():
from collections import defaultdict
from collections import Counter
import sys
n = int(eval(input()))
a = list(map(int, sys.stdin.readline().split()))
d = Counter(a)
e = defaultdict(int)
base = sum(v * (v - 1) // 2 for v in list(d.values()))
for k, v in l... | def main():
from collections import defaultdict
from collections import Counter
import sys
n = int(eval(input()))
a = list(map(int, sys.stdin.readline().split()))
d = Counter(a)
e = defaultdict(int)
base = sum(v * (v - 1) // 2 for v in list(d.values()))
e = {k: base - ... | 26 | 21 | 536 | 469 | def main():
from collections import defaultdict
from collections import Counter
import sys
n = int(eval(input()))
a = list(map(int, sys.stdin.readline().split()))
d = Counter(a)
e = defaultdict(int)
base = sum(v * (v - 1) // 2 for v in list(d.values()))
for k, v in list(d.items()):
... | def main():
from collections import defaultdict
from collections import Counter
import sys
n = int(eval(input()))
a = list(map(int, sys.stdin.readline().split()))
d = Counter(a)
e = defaultdict(int)
base = sum(v * (v - 1) // 2 for v in list(d.values()))
e = {k: base - (v >= 2) * (v ... | false | 19.230769 | [
"- for k, v in list(d.items()):",
"- if v <= 1:",
"- e[k] = base - 0",
"- else:",
"- e[k] = base - (v - 1)",
"+ e = {k: base - (v >= 2) * (v - 1) for k, v in list(d.items())}"
] | false | 0.041832 | 0.10552 | 0.396438 | [
"s903065350",
"s415285960"
] |
u813098295 | p03828 | python | s180732489 | s873696074 | 23 | 20 | 3,064 | 3,064 | Accepted | Accepted | 13.04 | n = int(eval(input()))
exps = [0] * 1003
for i in range(2, n+1):
t = i
div = 2
while div*div <= i:
if t % div == 0:
exps[div] += 1
t //= div
else:
div += 1
if t != 1:
exps[t] += 1
ans = 1
mod = int(1e9) + 7
for i in range(2... | def prime_factorize(n):
res = []
p = 2
while p*p <= n:
if n % p != 0:
p += 1
continue
num = 0
while n % p == 0:
num += 1
n //= p
res.append( [p, num] )
p += 1
if n != 1: res.append( [n, 1] )
ret... | 23 | 36 | 377 | 687 | n = int(eval(input()))
exps = [0] * 1003
for i in range(2, n + 1):
t = i
div = 2
while div * div <= i:
if t % div == 0:
exps[div] += 1
t //= div
else:
div += 1
if t != 1:
exps[t] += 1
ans = 1
mod = int(1e9) + 7
for i in range(2, n + 1):
ans... | def prime_factorize(n):
res = []
p = 2
while p * p <= n:
if n % p != 0:
p += 1
continue
num = 0
while n % p == 0:
num += 1
n //= p
res.append([p, num])
p += 1
if n != 1:
res.append([n, 1])
return res
# ... | false | 36.111111 | [
"+def prime_factorize(n):",
"+ res = []",
"+ p = 2",
"+ while p * p <= n:",
"+ if n % p != 0:",
"+ p += 1",
"+ continue",
"+ num = 0",
"+ while n % p == 0:",
"+ num += 1",
"+ n //= p",
"+ res.append([p, num])",
... | false | 0.036733 | 0.04324 | 0.849519 | [
"s180732489",
"s873696074"
] |
u616217092 | p02912 | python | s066000343 | s962986113 | 199 | 160 | 14,180 | 14,180 | Accepted | Accepted | 19.6 | from sys import stdin
import heapq
def main():
N, M = [int(x) for x in stdin.readline().rstrip().split()]
As = []
for i in [int(x) for x in stdin.readline().rstrip().split()]:
heapq.heappush(As, -i)
for _ in range(M):
x = heapq.heappop(As)
heapq.heappush(As, x / 2)
... | from sys import stdin
import heapq
def main():
N, M = [int(x) for x in stdin.readline().rstrip().split()]
As = []
for i in [int(x) for x in stdin.readline().rstrip().split()]:
heapq.heappush(As, -i)
for _ in range(M):
x = heapq.heappop(As)
heapq.heappush(As, -(-x // ... | 17 | 17 | 406 | 406 | from sys import stdin
import heapq
def main():
N, M = [int(x) for x in stdin.readline().rstrip().split()]
As = []
for i in [int(x) for x in stdin.readline().rstrip().split()]:
heapq.heappush(As, -i)
for _ in range(M):
x = heapq.heappop(As)
heapq.heappush(As, x / 2)
print((s... | from sys import stdin
import heapq
def main():
N, M = [int(x) for x in stdin.readline().rstrip().split()]
As = []
for i in [int(x) for x in stdin.readline().rstrip().split()]:
heapq.heappush(As, -i)
for _ in range(M):
x = heapq.heappop(As)
heapq.heappush(As, -(-x // 2))
pri... | false | 0 | [
"- heapq.heappush(As, x / 2)",
"- print((sum([-1 * int(x) for x in As])))",
"+ heapq.heappush(As, -(-x // 2))",
"+ print((sum([-1 * x for x in As])))"
] | false | 0.137455 | 0.037986 | 3.618577 | [
"s066000343",
"s962986113"
] |
u600402037 | p02832 | python | s964962011 | s033671318 | 139 | 100 | 27,180 | 26,140 | Accepted | Accepted | 28.06 | import sys
from fractions import gcd
stdin = sys.stdin
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to only numbers
rs = lambda: stdin.readline().rstrip() # ignores trailing space
N = ri()
A = rl()
answer = 0
cur = 1
for i in range(N):
if A[i] == cur:
... | import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
A = lr()
cur = 0
for a in A:
if a == cur + 1:
cur += 1
print((N-cur if cur > 0 else -1))
# 54 | 18 | 15 | 397 | 248 | import sys
from fractions import gcd
stdin = sys.stdin
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to only numbers
rs = lambda: stdin.readline().rstrip() # ignores trailing space
N = ri()
A = rl()
answer = 0
cur = 1
for i in range(N):
if A[i] == cur:
answer += 1... | import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
A = lr()
cur = 0
for a in A:
if a == cur + 1:
cur += 1
print((N - cur if cur > 0 else -1))
# 54
| false | 16.666667 | [
"-from fractions import gcd",
"-stdin = sys.stdin",
"-ri = lambda: int(rs())",
"-rl = lambda: list(map(int, stdin.readline().split())) # applies to only numbers",
"-rs = lambda: stdin.readline().rstrip() # ignores trailing space",
"-N = ri()",
"-A = rl()",
"-answer = 0",
"-cur = 1",
"-for i in r... | false | 0.038886 | 0.03738 | 1.040304 | [
"s964962011",
"s033671318"
] |
u352394527 | p02368 | python | s210691353 | s604660009 | 930 | 830 | 19,196 | 19,236 | Accepted | Accepted | 10.75 | """
強連結成分分解
"""
import sys
sys.setrecursionlimit(1000000)
def dfs(v, visited, edges, order):
visited[v] = True
for to in edges[v]:
if not visited[to]:
dfs(to, visited, edges, order)
order.append(v)
def search_strongly_connection(v, visited, reverse_edges, parent, num):
visited[v] =... | """
強連結成分分解
"""
import sys
sys.setrecursionlimit(1000000)
def dfs(v, visited, edges, order):
visited[v] = True
for to in edges[v]:
if not visited[to]:
dfs(to, visited, edges, order)
order.append(v)
def search_strongly_connection(v, visited, reverse_edges, parent, num):
visited[v] =... | 53 | 52 | 1,199 | 1,241 | """
強連結成分分解
"""
import sys
sys.setrecursionlimit(1000000)
def dfs(v, visited, edges, order):
visited[v] = True
for to in edges[v]:
if not visited[to]:
dfs(to, visited, edges, order)
order.append(v)
def search_strongly_connection(v, visited, reverse_edges, parent, num):
visited[v... | """
強連結成分分解
"""
import sys
sys.setrecursionlimit(1000000)
def dfs(v, visited, edges, order):
visited[v] = True
for to in edges[v]:
if not visited[to]:
dfs(to, visited, edges, order)
order.append(v)
def search_strongly_connection(v, visited, reverse_edges, parent, num):
visited[v... | false | 1.886792 | [
"-v_num, e_num = list(map(int, input().split()))",
"-edges = [[] for _ in range(v_num)]",
"-reverse_edges = [[] for _ in range(v_num)]",
"-for _ in range(e_num):",
"- s, t = list(map(int, input().split()))",
"- edges[s].append(t)",
"- reverse_edges[t].append(s)",
"-order = []",
"-visited = ... | false | 0.037679 | 0.035782 | 1.053001 | [
"s210691353",
"s604660009"
] |
u549161102 | p03610 | python | s107154690 | s778752079 | 43 | 21 | 3,956 | 3,572 | Accepted | Accepted | 51.16 | s = list(eval(input()))
l = len(s)
a = ''
if l%2 != 0:
for i in range(l//2+1):
a = a + "".join(s[2*i])
else:
for i in range(l//2):
a = a + "".join(s[2*i])
print(a) | S = eval(input())
l = [S[i] for i in range(0,len(S),2)]
a = "".join(l)
print(a) | 10 | 4 | 190 | 76 | s = list(eval(input()))
l = len(s)
a = ""
if l % 2 != 0:
for i in range(l // 2 + 1):
a = a + "".join(s[2 * i])
else:
for i in range(l // 2):
a = a + "".join(s[2 * i])
print(a)
| S = eval(input())
l = [S[i] for i in range(0, len(S), 2)]
a = "".join(l)
print(a)
| false | 60 | [
"-s = list(eval(input()))",
"-l = len(s)",
"-a = \"\"",
"-if l % 2 != 0:",
"- for i in range(l // 2 + 1):",
"- a = a + \"\".join(s[2 * i])",
"-else:",
"- for i in range(l // 2):",
"- a = a + \"\".join(s[2 * i])",
"+S = eval(input())",
"+l = [S[i] for i in range(0, len(S), 2)]... | false | 0.053162 | 0.040896 | 1.299925 | [
"s107154690",
"s778752079"
] |
u445624660 | p02971 | python | s790032924 | s422467546 | 681 | 355 | 40,964 | 9,188 | Accepted | Accepted | 47.87 | # 最大値と二番目に大きいやつをとっておく。最大値のときだけ二番目に大きいやつ採用
n = int(eval(input()))
arr = []
for i in range(n):
t = int(eval(input()))
arr.append([i, t])
sorted_arr = list(sorted(arr, key = lambda x : x[1]))
biggest = sorted_arr[-1]
second_biggest = sorted_arr[-2]
for i in range(n):
if i != biggest[0]:
print((bi... | n = int(eval(input()))
max_n = -1
semi_max_n = -1
max_idx = -1
for i in range(n):
x = int(eval(input()))
if x > max_n:
max_n = x
max_idx = i
elif x >= semi_max_n:
semi_max_n = x
for i in range(n):
if i == max_idx:
print(semi_max_n)
else:
print(m... | 16 | 16 | 356 | 313 | # 最大値と二番目に大きいやつをとっておく。最大値のときだけ二番目に大きいやつ採用
n = int(eval(input()))
arr = []
for i in range(n):
t = int(eval(input()))
arr.append([i, t])
sorted_arr = list(sorted(arr, key=lambda x: x[1]))
biggest = sorted_arr[-1]
second_biggest = sorted_arr[-2]
for i in range(n):
if i != biggest[0]:
print((biggest[1])... | n = int(eval(input()))
max_n = -1
semi_max_n = -1
max_idx = -1
for i in range(n):
x = int(eval(input()))
if x > max_n:
max_n = x
max_idx = i
elif x >= semi_max_n:
semi_max_n = x
for i in range(n):
if i == max_idx:
print(semi_max_n)
else:
print(max_n)
| false | 0 | [
"-# 最大値と二番目に大きいやつをとっておく。最大値のときだけ二番目に大きいやつ採用",
"-arr = []",
"+max_n = -1",
"+semi_max_n = -1",
"+max_idx = -1",
"- t = int(eval(input()))",
"- arr.append([i, t])",
"-sorted_arr = list(sorted(arr, key=lambda x: x[1]))",
"-biggest = sorted_arr[-1]",
"-second_biggest = sorted_arr[-2]",
"+ x... | false | 0.040888 | 0.04101 | 0.997016 | [
"s790032924",
"s422467546"
] |
u347600233 | p02984 | python | s961885918 | s738164297 | 203 | 127 | 14,024 | 14,092 | Accepted | Accepted | 37.44 | n = int(input())
a = [int(i) for i in input().split()]
x = [0] * n
not_x0 = 0
for i in range(1, n, 2):
not_x0 += 2*a[i]
x[0] = sum(a) - not_x0
for i in range(1, n):
x[i] = 2*a[i - 1] - x[i - 1]
for i in range(n):
print(x[i], end=' ')
| n = int(eval(input()))
a = [int(i) for i in input().split()]
x = [0] * n
x[0] = sum(a) - 2*sum(a[1::2])
for i in range(1, n):
x[i] = 2*a[i - 1] - x[i - 1]
print((*x)) | 14 | 8 | 261 | 170 | n = int(input())
a = [int(i) for i in input().split()]
x = [0] * n
not_x0 = 0
for i in range(1, n, 2):
not_x0 += 2 * a[i]
x[0] = sum(a) - not_x0
for i in range(1, n):
x[i] = 2 * a[i - 1] - x[i - 1]
for i in range(n):
print(x[i], end=" ")
| n = int(eval(input()))
a = [int(i) for i in input().split()]
x = [0] * n
x[0] = sum(a) - 2 * sum(a[1::2])
for i in range(1, n):
x[i] = 2 * a[i - 1] - x[i - 1]
print((*x))
| false | 42.857143 | [
"-n = int(input())",
"+n = int(eval(input()))",
"-not_x0 = 0",
"-for i in range(1, n, 2):",
"- not_x0 += 2 * a[i]",
"-x[0] = sum(a) - not_x0",
"+x[0] = sum(a) - 2 * sum(a[1::2])",
"-for i in range(n):",
"- print(x[i], end=\" \")",
"+print((*x))"
] | false | 0.035842 | 0.03632 | 0.98684 | [
"s961885918",
"s738164297"
] |
u701644092 | p03212 | python | s485613261 | s132611635 | 75 | 63 | 9,420 | 9,092 | Accepted | Accepted | 16 | N = int(eval(input()))
T = ("3","5","7")
from collections import deque
que = deque(list(T))
ans = 0
while que:
num = que.pop()
if int(num) > N:
continue
if len(set(num)) == 3:
ans += 1
for t in T:
que.append(num + t)
print(ans) | N = int(eval(input()))
T = ("3","5","7")
def dfs(x):
if x != "" and int(x) > N:
return 0
res = 0
if len(set(x)) == 3:
res = 1
for t in T:
res += dfs(x + t)
return res
print((dfs(""))) | 17 | 14 | 260 | 214 | N = int(eval(input()))
T = ("3", "5", "7")
from collections import deque
que = deque(list(T))
ans = 0
while que:
num = que.pop()
if int(num) > N:
continue
if len(set(num)) == 3:
ans += 1
for t in T:
que.append(num + t)
print(ans)
| N = int(eval(input()))
T = ("3", "5", "7")
def dfs(x):
if x != "" and int(x) > N:
return 0
res = 0
if len(set(x)) == 3:
res = 1
for t in T:
res += dfs(x + t)
return res
print((dfs("")))
| false | 17.647059 | [
"-from collections import deque",
"-que = deque(list(T))",
"-ans = 0",
"-while que:",
"- num = que.pop()",
"- if int(num) > N:",
"- continue",
"- if len(set(num)) == 3:",
"- ans += 1",
"+",
"+def dfs(x):",
"+ if x != \"\" and int(x) > N:",
"+ return 0",
"+ ... | false | 0.044482 | 0.046466 | 0.957293 | [
"s485613261",
"s132611635"
] |
u670180528 | p04035 | python | s409301628 | s935557547 | 77 | 71 | 19,660 | 19,660 | Accepted | Accepted | 7.79 | n,l,*a=list(map(int,open(0).read().split()))
for i,(x,y) in enumerate(zip(a,a[1:])):
if x+y>=l:
print("Possible")
r=list(range(n))
print(("\n".join(map(str,r[1:i+1]+r[n:i:-1]))))
exit()
print("Impossible") | def s():
n, l, *a = list(map(int, open(0).read().split()))
for i, (x, y) in enumerate(zip(a, a[1:])):
if x + y >= l:
print("Possible")
r = list(range(n))
print(("\n".join(map(str, r[1:i + 1] + r[n:i:-1]))))
break
else:
print("Impossible")
if __name__=="__main__":
s() | 8 | 12 | 213 | 290 | n, l, *a = list(map(int, open(0).read().split()))
for i, (x, y) in enumerate(zip(a, a[1:])):
if x + y >= l:
print("Possible")
r = list(range(n))
print(("\n".join(map(str, r[1 : i + 1] + r[n:i:-1]))))
exit()
print("Impossible")
| def s():
n, l, *a = list(map(int, open(0).read().split()))
for i, (x, y) in enumerate(zip(a, a[1:])):
if x + y >= l:
print("Possible")
r = list(range(n))
print(("\n".join(map(str, r[1 : i + 1] + r[n:i:-1]))))
break
else:
print("Impossible")
i... | false | 33.333333 | [
"-n, l, *a = list(map(int, open(0).read().split()))",
"-for i, (x, y) in enumerate(zip(a, a[1:])):",
"- if x + y >= l:",
"- print(\"Possible\")",
"- r = list(range(n))",
"- print((\"\\n\".join(map(str, r[1 : i + 1] + r[n:i:-1]))))",
"- exit()",
"-print(\"Impossible\")",
... | false | 0.044032 | 0.077228 | 0.570157 | [
"s409301628",
"s935557547"
] |
u904995051 | p03631 | python | s521285357 | s279524684 | 31 | 23 | 9,088 | 9,028 | Accepted | Accepted | 25.81 | #ABC070A
a = eval(input())
print(("Yes" if (a[-1] == a[0]) else "No")) | #ABC070
#文字列の逆順
n = eval(input())
print(("Yes" if n==n[::-1] else "No")) | 3 | 4 | 64 | 67 | # ABC070A
a = eval(input())
print(("Yes" if (a[-1] == a[0]) else "No"))
| # ABC070
# 文字列の逆順
n = eval(input())
print(("Yes" if n == n[::-1] else "No"))
| false | 25 | [
"-# ABC070A",
"-a = eval(input())",
"-print((\"Yes\" if (a[-1] == a[0]) else \"No\"))",
"+# ABC070",
"+# 文字列の逆順",
"+n = eval(input())",
"+print((\"Yes\" if n == n[::-1] else \"No\"))"
] | false | 0.032053 | 0.036439 | 0.879653 | [
"s521285357",
"s279524684"
] |
u718949306 | p02630 | python | s659482811 | s334996590 | 390 | 349 | 26,968 | 21,828 | Accepted | Accepted | 10.51 | N = int(eval(input()))
A = list(map(int, input().split()))
B = [0]*(N+1)
for n in range(N):
B[n+1] = B[n] + A[n]
C = B.pop()
Z = {}
for n in range(N):
Z[A[n]] = 0
for n in range(N):
Z[A[n]] += 1
D = []
Q = int(eval(input()))
for q in range(Q):
x, y = list(map(int, input().split()))
... | N = int(eval(input()))
A = list(map(int, input().split()))
C = sum(A)
Z = {}
for n in range(N):
Z[A[n]] = 0
for n in range(N):
Z[A[n]] += 1
D = []
Q = int(eval(input()))
for q in range(Q):
x, y = list(map(int, input().split()))
if x in Z:
C = C - x*Z[x]
C = C + y*Z[x]
... | 32 | 27 | 590 | 525 | N = int(eval(input()))
A = list(map(int, input().split()))
B = [0] * (N + 1)
for n in range(N):
B[n + 1] = B[n] + A[n]
C = B.pop()
Z = {}
for n in range(N):
Z[A[n]] = 0
for n in range(N):
Z[A[n]] += 1
D = []
Q = int(eval(input()))
for q in range(Q):
x, y = list(map(int, input().split()))
if x in Z:
... | N = int(eval(input()))
A = list(map(int, input().split()))
C = sum(A)
Z = {}
for n in range(N):
Z[A[n]] = 0
for n in range(N):
Z[A[n]] += 1
D = []
Q = int(eval(input()))
for q in range(Q):
x, y = list(map(int, input().split()))
if x in Z:
C = C - x * Z[x]
C = C + y * Z[x]
D.appen... | false | 15.625 | [
"-B = [0] * (N + 1)",
"-for n in range(N):",
"- B[n + 1] = B[n] + A[n]",
"-C = B.pop()",
"+C = sum(A)"
] | false | 0.071838 | 0.051405 | 1.397479 | [
"s659482811",
"s334996590"
] |
u254871849 | p03476 | python | s658738492 | s286174118 | 212 | 159 | 22,552 | 26,388 | Accepted | Accepted | 25 | import sys
# import collections
# import math
# import bisect
# import re
# import itertools
def primeNums(n):
from math import floor, sqrt
sieve = set(range(2, n + 1))
if 2 in sieve:
not_prime = set(range(2 * 2, n + 1, 2))
sieve -= not_prime
for i in range(3, floor(sqrt(... | import sys
from math import floor, sqrt
def prime_nums(n):
sieve = set(range(2, n + 1))
non_prime = set(range(2 * 2, n + 1, 2))
sieve -= non_prime
for i in range(3, floor(sqrt(n)) + 1, 2):
if i in sieve:
non_prime = set(range(i * 2, n + 1, i))
sieve -= non_prim... | 46 | 34 | 1,082 | 809 | import sys
# import collections
# import math
# import bisect
# import re
# import itertools
def primeNums(n):
from math import floor, sqrt
sieve = set(range(2, n + 1))
if 2 in sieve:
not_prime = set(range(2 * 2, n + 1, 2))
sieve -= not_prime
for i in range(3, floor(sqrt(n)) + 1, 2):
... | import sys
from math import floor, sqrt
def prime_nums(n):
sieve = set(range(2, n + 1))
non_prime = set(range(2 * 2, n + 1, 2))
sieve -= non_prime
for i in range(3, floor(sqrt(n)) + 1, 2):
if i in sieve:
non_prime = set(range(i * 2, n + 1, i))
sieve -= non_prime
ret... | false | 26.086957 | [
"+from math import floor, sqrt",
"-# import collections",
"-# import math",
"-# import bisect",
"-# import re",
"-# import itertools",
"-def primeNums(n):",
"- from math import floor, sqrt",
"+def prime_nums(n):",
"- if 2 in sieve:",
"- not_prime = set(range(2 * 2, n + 1, 2))",
"-... | false | 0.359262 | 0.344154 | 1.043898 | [
"s658738492",
"s286174118"
] |
u608007704 | p02621 | python | s417089982 | s269971013 | 29 | 25 | 9,148 | 9,084 | Accepted | Accepted | 13.79 | x=int(eval(input()))
print((x+x*x+x*x*x)) | a=int(eval(input()))
print((a+a**2+a**3)) | 2 | 2 | 34 | 34 | x = int(eval(input()))
print((x + x * x + x * x * x))
| a = int(eval(input()))
print((a + a**2 + a**3))
| false | 0 | [
"-x = int(eval(input()))",
"-print((x + x * x + x * x * x))",
"+a = int(eval(input()))",
"+print((a + a**2 + a**3))"
] | false | 0.042494 | 0.036421 | 1.166765 | [
"s417089982",
"s269971013"
] |
u556589653 | p02789 | python | s356423825 | s177884917 | 178 | 28 | 38,384 | 9,152 | Accepted | Accepted | 84.27 | N,M = list(map(int,input().split()))
if N==M:
print("Yes")
else:
print("No") | a,b = list(map(int,input().split()))
if a == b:
print("Yes")
else:
print("No") | 5 | 5 | 78 | 80 | N, M = list(map(int, input().split()))
if N == M:
print("Yes")
else:
print("No")
| a, b = list(map(int, input().split()))
if a == b:
print("Yes")
else:
print("No")
| false | 0 | [
"-N, M = list(map(int, input().split()))",
"-if N == M:",
"+a, b = list(map(int, input().split()))",
"+if a == b:"
] | false | 0.040437 | 0.037934 | 1.06597 | [
"s356423825",
"s177884917"
] |
u227082700 | p02880 | python | s804693956 | s988176778 | 20 | 18 | 2,940 | 2,940 | Accepted | Accepted | 10 | n=int(eval(input()))
for i in range(1,10):
if n%i==0 and n//i<10:print("Yes");exit()
print("No") | n=int(eval(input()))
for i in range(1,10):
for j in range(1,10):
if n==i*j:print("Yes");exit()
print("No") | 4 | 5 | 95 | 110 | n = int(eval(input()))
for i in range(1, 10):
if n % i == 0 and n // i < 10:
print("Yes")
exit()
print("No")
| n = int(eval(input()))
for i in range(1, 10):
for j in range(1, 10):
if n == i * j:
print("Yes")
exit()
print("No")
| false | 20 | [
"- if n % i == 0 and n // i < 10:",
"- print(\"Yes\")",
"- exit()",
"+ for j in range(1, 10):",
"+ if n == i * j:",
"+ print(\"Yes\")",
"+ exit()"
] | false | 0.038155 | 0.038889 | 0.981131 | [
"s804693956",
"s988176778"
] |
u635391238 | p01132 | python | s227653885 | s228552547 | 120 | 110 | 7,708 | 7,776 | Accepted | Accepted | 8.33 |
def back_oturigation(fee, coin_values, coin_nums):
"""
1. ????????????????????????????????£??????????????????
2. 1????????????????????????????????????????????????????????????
???????????§?????????????????????-> ?°????????????????????¶???????????????????
3. 2????????????????????°???????????... | def back_oturigation(fee, coin_values, coin_nums):
"""
1. ?????????????????????????????????£??????????????????
2. 1????????????????????????????????????????????????????????????
????????????§?????????????????????-> ??°?????????????????????¶???????????????????
3. 2?????????????????????°????????... | 43 | 42 | 1,527 | 1,534 | def back_oturigation(fee, coin_values, coin_nums):
"""
1. ????????????????????????????????£??????????????????
2. 1????????????????????????????????????????????????????????????
???????????§?????????????????????-> ?°????????????????????¶???????????????????
3. 2????????????????????°??????????????????... | def back_oturigation(fee, coin_values, coin_nums):
"""
1. ?????????????????????????????????£??????????????????
2. 1????????????????????????????????????????????????????????????
????????????§?????????????????????-> ??°?????????????????????¶???????????????????
3. 2?????????????????????°?????????????... | false | 2.325581 | [
"- 1. ????????????????????????????????£??????????????????",
"+ 1. ?????????????????????????????????£??????????????????",
"- ???????????§?????????????????????-> ?°????????????????????¶???????????????????",
"- 3. 2????????????????????°?????????????????????????????????????????????",
"+ ???... | false | 0.042841 | 0.049036 | 0.873677 | [
"s227653885",
"s228552547"
] |
u970308980 | p02882 | python | s611271999 | s685930994 | 170 | 19 | 38,356 | 3,188 | Accepted | Accepted | 88.82 | import math
a, b, x = list(map(int, input().split()))
p = ((x*2)/(a**2)) - b
if p == 0:
print((45))
exit()
if p > 0:
radian = math.atan2(a, b-p)
print((90-math.degrees(radian)))
else:
p = 2*x/(a*b)
radian = math.atan2(b, p)
print((math.degrees(radian)))
| import math
a, b, x = list(map(int, input().split()))
s = x / a
if s >= a * b / 2:
h = (a * b - s) * 2 / a
radian = math.atan2(h, a)
else:
w = s * 2 / b
radian = math.atan2(b, w)
ans = math.degrees(radian)
print(ans)
| 17 | 14 | 290 | 243 | import math
a, b, x = list(map(int, input().split()))
p = ((x * 2) / (a**2)) - b
if p == 0:
print((45))
exit()
if p > 0:
radian = math.atan2(a, b - p)
print((90 - math.degrees(radian)))
else:
p = 2 * x / (a * b)
radian = math.atan2(b, p)
print((math.degrees(radian)))
| import math
a, b, x = list(map(int, input().split()))
s = x / a
if s >= a * b / 2:
h = (a * b - s) * 2 / a
radian = math.atan2(h, a)
else:
w = s * 2 / b
radian = math.atan2(b, w)
ans = math.degrees(radian)
print(ans)
| false | 17.647059 | [
"-p = ((x * 2) / (a**2)) - b",
"-if p == 0:",
"- print((45))",
"- exit()",
"-if p > 0:",
"- radian = math.atan2(a, b - p)",
"- print((90 - math.degrees(radian)))",
"+s = x / a",
"+if s >= a * b / 2:",
"+ h = (a * b - s) * 2 / a",
"+ radian = math.atan2(h, a)",
"- p = 2 * x... | false | 0.053024 | 0.035654 | 1.487194 | [
"s611271999",
"s685930994"
] |
u762420987 | p03108 | python | s216471971 | s785761568 | 796 | 601 | 33,364 | 24,508 | Accepted | Accepted | 24.5 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
... | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
... | 58 | 60 | 1,423 | 1,481 | class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = se... | class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = se... | false | 3.333333 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"-ABlist = [list(map(int, input().split())) for _ in range(M)]",
"-ans = [0] * M",
"-for i in reversed(list(range(M))):",
"- A, B = ABlist[i]",
"- if not uf.same(A - 1, B - 1):",
"- ans[i] = uf.size(A - 1) * uf.size(B - 1)",
"- ... | false | 0.046965 | 0.116524 | 0.40305 | [
"s216471971",
"s785761568"
] |
u172569352 | p03945 | python | s669898818 | s372932856 | 48 | 44 | 3,188 | 3,188 | Accepted | Accepted | 8.33 | S = eval(input())
count = 0
for s in range(1, len(S)):
if S[s-1] != S[s]:
count += 1
print(count) | S = eval(input())
count = 0
for i in range(1, len(S)):
if S[i-1] != S[i]:
count += 1
print(count) | 7 | 7 | 110 | 110 | S = eval(input())
count = 0
for s in range(1, len(S)):
if S[s - 1] != S[s]:
count += 1
print(count)
| S = eval(input())
count = 0
for i in range(1, len(S)):
if S[i - 1] != S[i]:
count += 1
print(count)
| false | 0 | [
"-for s in range(1, len(S)):",
"- if S[s - 1] != S[s]:",
"+for i in range(1, len(S)):",
"+ if S[i - 1] != S[i]:"
] | false | 0.11974 | 0.043436 | 2.756689 | [
"s669898818",
"s372932856"
] |
u197300773 | p03504 | python | s216546441 | s133469315 | 584 | 403 | 28,360 | 28,360 | Accepted | Accepted | 30.99 | import sys
import math
from itertools import accumulate as acc
N,C=list(map(int,input().split()))
a=[[0 for i in range(10**5+1)] for i in range(C+1)]
rec=[0 for i in range(10**5+1)]
for i in range(N):
s,t,c=list(map(int,input().split()))
recs,rect=a[c][s],a[c][t]
if recs==0 and rect==0:
... | import sys
import math
from itertools import accumulate as acc
input=sys.stdin.readline
N,C=list(map(int,input().split()))
a=[[0 for i in range(10**5+1)] for i in range(C+1)]
rec=[0 for i in range(10**5+1)]
for i in range(N):
s,t,c=list(map(int,input().split()))
recs,rect=a[c][s],a[c][t]
... | 35 | 37 | 677 | 705 | import sys
import math
from itertools import accumulate as acc
N, C = list(map(int, input().split()))
a = [[0 for i in range(10**5 + 1)] for i in range(C + 1)]
rec = [0 for i in range(10**5 + 1)]
for i in range(N):
s, t, c = list(map(int, input().split()))
recs, rect = a[c][s], a[c][t]
if recs == 0 and rec... | import sys
import math
from itertools import accumulate as acc
input = sys.stdin.readline
N, C = list(map(int, input().split()))
a = [[0 for i in range(10**5 + 1)] for i in range(C + 1)]
rec = [0 for i in range(10**5 + 1)]
for i in range(N):
s, t, c = list(map(int, input().split()))
recs, rect = a[c][s], a[c][... | false | 5.405405 | [
"+input = sys.stdin.readline"
] | false | 0.12581 | 0.007655 | 16.435538 | [
"s216546441",
"s133469315"
] |
u562935282 | p03164 | python | s786038037 | s064826133 | 991 | 878 | 311,048 | 307,264 | Accepted | Accepted | 11.4 | inf = float('inf')
n, w = list(map(int, input().split()))
wv = tuple(tuple(map(int, input().split())) for _ in range(n))
dp = tuple([inf] * (pow(10, 3) * n + 1) for _ in range(n + 1))
dp[0][0] = 0
for ind, (wi, vi) in enumerate(wv, 1):
for v in range(pow(10, 3) * n + 1):
if vi <= v:
... | inf = float('inf')
n, w = list(map(int, input().split()))
e = tuple(list(map(int, input().split())) for _ in range(n))
wt, vt = list(zip(*e))
sv = sum(vt)
dp = tuple([inf] * (sv + 1) for _ in range(n + 1))
dp[0][0] = 0
for i in range(n):
dp[i + 1][:vt[i]] = dp[i][:vt[i]]
for j in range(vt[i], sv ... | 19 | 21 | 530 | 480 | inf = float("inf")
n, w = list(map(int, input().split()))
wv = tuple(tuple(map(int, input().split())) for _ in range(n))
dp = tuple([inf] * (pow(10, 3) * n + 1) for _ in range(n + 1))
dp[0][0] = 0
for ind, (wi, vi) in enumerate(wv, 1):
for v in range(pow(10, 3) * n + 1):
if vi <= v:
dp[ind][v] =... | inf = float("inf")
n, w = list(map(int, input().split()))
e = tuple(list(map(int, input().split())) for _ in range(n))
wt, vt = list(zip(*e))
sv = sum(vt)
dp = tuple([inf] * (sv + 1) for _ in range(n + 1))
dp[0][0] = 0
for i in range(n):
dp[i + 1][: vt[i]] = dp[i][: vt[i]]
for j in range(vt[i], sv + 1):
... | false | 9.52381 | [
"-wv = tuple(tuple(map(int, input().split())) for _ in range(n))",
"-dp = tuple([inf] * (pow(10, 3) * n + 1) for _ in range(n + 1))",
"+e = tuple(list(map(int, input().split())) for _ in range(n))",
"+wt, vt = list(zip(*e))",
"+sv = sum(vt)",
"+dp = tuple([inf] * (sv + 1) for _ in range(n + 1))",
"-for ... | false | 0.053636 | 0.040437 | 1.326428 | [
"s786038037",
"s064826133"
] |
u260980560 | p02295 | python | s851237997 | s980207192 | 30 | 20 | 6,464 | 7,780 | Accepted | Accepted | 33.33 | for t in range(eval(input())):
x0, y0, x1, y1, x2, y2, x3, y3 = list(map(int, input().split()))
dx0 = x1 - x0
dy0 = y1 - y0
dx1 = x3 - x2
dy1 = y3 - y2
s = (y0-y2)*dx1 - (x0-x2)*dy1
sm = dx0*dy1 - dy0*dx1
if s < 0:
s = -s
sm = -sm
t = (y2-y0)*dx0 - (x2-x0... | def intersection_ll(S0, S1, T0, T1):
x0, y0 = S0; x1, y1 = S1
X0, X1 = T0; X1, Y1 = T1
p = (x1-x0)*(y0-Y0) - (y1-y0)*(x0-X0) # -cross(S0, S1, T0)
q = (x1-x0)*(Y1-Y0) - (y1-y0)*(X1-X0) # cross(0, S1-S0, T1-T0)
return (X0 + p*(X1-X0)/float(q), Y0 + p*(Y1-Y0)/float(q))# T0 + p/q*(T1-T0)
n = int... | 24 | 11 | 556 | 497 | for t in range(eval(input())):
x0, y0, x1, y1, x2, y2, x3, y3 = list(map(int, input().split()))
dx0 = x1 - x0
dy0 = y1 - y0
dx1 = x3 - x2
dy1 = y3 - y2
s = (y0 - y2) * dx1 - (x0 - x2) * dy1
sm = dx0 * dy1 - dy0 * dx1
if s < 0:
s = -s
sm = -sm
t = (y2 - y0) * dx0 - (x2... | def intersection_ll(S0, S1, T0, T1):
x0, y0 = S0
x1, y1 = S1
X0, X1 = T0
X1, Y1 = T1
p = (x1 - x0) * (y0 - Y0) - (y1 - y0) * (x0 - X0) # -cross(S0, S1, T0)
q = (x1 - x0) * (Y1 - Y0) - (y1 - y0) * (X1 - X0) # cross(0, S1-S0, T1-T0)
return (
X0 + p * (X1 - X0) / float(q),
Y0 ... | false | 54.166667 | [
"-for t in range(eval(input())):",
"- x0, y0, x1, y1, x2, y2, x3, y3 = list(map(int, input().split()))",
"- dx0 = x1 - x0",
"- dy0 = y1 - y0",
"- dx1 = x3 - x2",
"- dy1 = y3 - y2",
"- s = (y0 - y2) * dx1 - (x0 - x2) * dy1",
"- sm = dx0 * dy1 - dy0 * dx1",
"- if s < 0:",
"- ... | false | 0.042935 | 0.053092 | 0.808687 | [
"s851237997",
"s980207192"
] |
u704001626 | p02803 | python | s798540138 | s454015639 | 1,705 | 393 | 3,724 | 3,540 | Accepted | Accepted | 76.95 | # -*- coding: utf-8 -*-
h,w = list(map(int,input().split()))
maze = [list(eval(input())) for i in range(h)]
for i in maze:
i.insert(0,"#")
i.append("#")
maze.insert(0,["#"]*(w+2))
maze.append(["#"]*(w+2))
import copy
def clear_maze(maze,target=0):
con = False
for r,v1 in enumerate(maze)... | # -*- coding: utf-8 -*-
h,w = list(map(int,input().split()))
inf=float("inf")
s = [[-1]*(w+2)] + [[-1] + [inf if i=="." else -1 for i in eval(input())] + [-1] for _ in range(h)] + [[-1]*(w+2)]
from copy import deepcopy
from collections import deque
ret = 0
for i in range(1,h+1):
for j in range(1,w+1):
... | 39 | 39 | 1,030 | 1,285 | # -*- coding: utf-8 -*-
h, w = list(map(int, input().split()))
maze = [list(eval(input())) for i in range(h)]
for i in maze:
i.insert(0, "#")
i.append("#")
maze.insert(0, ["#"] * (w + 2))
maze.append(["#"] * (w + 2))
import copy
def clear_maze(maze, target=0):
con = False
for r, v1 in enumerate(maze):... | # -*- coding: utf-8 -*-
h, w = list(map(int, input().split()))
inf = float("inf")
s = (
[[-1] * (w + 2)]
+ [[-1] + [inf if i == "." else -1 for i in eval(input())] + [-1] for _ in range(h)]
+ [[-1] * (w + 2)]
)
from copy import deepcopy
from collections import deque
ret = 0
for i in range(1, h + 1):
fo... | false | 0 | [
"-maze = [list(eval(input())) for i in range(h)]",
"-for i in maze:",
"- i.insert(0, \"#\")",
"- i.append(\"#\")",
"-maze.insert(0, [\"#\"] * (w + 2))",
"-maze.append([\"#\"] * (w + 2))",
"-import copy",
"-",
"-",
"-def clear_maze(maze, target=0):",
"- con = False",
"- for r, v1 in... | false | 0.071623 | 0.044351 | 1.614907 | [
"s798540138",
"s454015639"
] |
u285443936 | p03805 | python | s549794516 | s656768106 | 66 | 25 | 3,064 | 3,188 | Accepted | Accepted | 62.12 | N, M = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(M)]
visited = {i:False for i in range(N)}
visited[0] = True
ans = 0
def DFS(x):
# print(visited)
global ans
nextx = []
if False not in list(visited.values()):
ans += 1
return
for i in range(M):
... | N, M = list(map(int,input().split()))
C = [[] for i in range(N)]
for i in range(M):
a,b = list(map(int, input().split()))
a -= 1
b -= 1
C[a].append(b)
C[b].append(a)
visited = [0]*N
ans = 0
def dfs(x):
global ans
visited[x] = 1
if all(visited):
ans += 1
return
for i in C[x]:
... | 29 | 23 | 588 | 398 | N, M = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(M)]
visited = {i: False for i in range(N)}
visited[0] = True
ans = 0
def DFS(x):
# print(visited)
global ans
nextx = []
if False not in list(visited.values()):
ans += 1
return
for i in rang... | N, M = list(map(int, input().split()))
C = [[] for i in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
C[a].append(b)
C[b].append(a)
visited = [0] * N
ans = 0
def dfs(x):
global ans
visited[x] = 1
if all(visited):
ans += 1
return
f... | false | 20.689655 | [
"-ab = [list(map(int, input().split())) for i in range(M)]",
"-visited = {i: False for i in range(N)}",
"-visited[0] = True",
"+C = [[] for i in range(N)]",
"+for i in range(M):",
"+ a, b = list(map(int, input().split()))",
"+ a -= 1",
"+ b -= 1",
"+ C[a].append(b)",
"+ C[b].append(... | false | 0.047165 | 0.037753 | 1.249306 | [
"s549794516",
"s656768106"
] |
u357751375 | p02786 | python | s300360921 | s868162857 | 28 | 25 | 9,104 | 9,136 | Accepted | Accepted | 10.71 | h = int(eval(input()))
ans = 1
i = 1
while h > 1:
h = h // 2
ans += 2 ** i
i += 1
print(ans) | h = int(eval(input()))
ans = 0
i = 0
while h > 0:
h = h // 2
ans += 2 ** i
i += 1
print(ans) | 8 | 8 | 105 | 105 | h = int(eval(input()))
ans = 1
i = 1
while h > 1:
h = h // 2
ans += 2**i
i += 1
print(ans)
| h = int(eval(input()))
ans = 0
i = 0
while h > 0:
h = h // 2
ans += 2**i
i += 1
print(ans)
| false | 0 | [
"-ans = 1",
"-i = 1",
"-while h > 1:",
"+ans = 0",
"+i = 0",
"+while h > 0:"
] | false | 0.104513 | 0.115578 | 0.904264 | [
"s300360921",
"s868162857"
] |
u021019433 | p02837 | python | s682399720 | s453305802 | 60 | 55 | 3,064 | 3,188 | Accepted | Accepted | 8.33 | from itertools import combinations, count
n = int(eval(input()))
r = list(range(n))
a = [(set(), set()) for _ in r]
for i in r:
for _ in range(int(eval(input()))):
x, y = list(map(int, input().split()))
a[i][y].add(x - 1)
ans = next(i for i in count(n, - 1) for x in combinations(r, i)
if... | from itertools import combinations, count
n = int(eval(input()))
r = list(range(n))
a = [(set(), set()) for _ in r]
for i in r:
for _ in range(int(eval(input()))):
x, y = list(map(int, input().split()))
a[i][y].add(x - 1)
ans = next(i for i in count(n, - 1) for x in map(set, combinations(r, i))
... | 12 | 12 | 372 | 374 | from itertools import combinations, count
n = int(eval(input()))
r = list(range(n))
a = [(set(), set()) for _ in r]
for i in r:
for _ in range(int(eval(input()))):
x, y = list(map(int, input().split()))
a[i][y].add(x - 1)
ans = next(
i
for i in count(n, -1)
for x in combinations(r, i)
... | from itertools import combinations, count
n = int(eval(input()))
r = list(range(n))
a = [(set(), set()) for _ in r]
for i in r:
for _ in range(int(eval(input()))):
x, y = list(map(int, input().split()))
a[i][y].add(x - 1)
ans = next(
i
for i in count(n, -1)
for x in map(set, combination... | false | 0 | [
"- for x in combinations(r, i)",
"- if all(a[j][0].isdisjoint(x) and a[j][1].issubset(x) for j in x)",
"+ for x in map(set, combinations(r, i))",
"+ if all(a[j][0].isdisjoint(x) and a[j][1] < x for j in x)"
] | false | 0.03482 | 0.058231 | 0.597969 | [
"s682399720",
"s453305802"
] |
u168578024 | p03449 | python | s997469384 | s399024682 | 189 | 164 | 39,828 | 38,384 | Accepted | Accepted | 13.23 | N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
for i in range(N):
cur = 0
for j in range(N):
if j < i:
cur += A[j]
elif j == i:
cur += A[j] + B[j]
else:
cur += B[j]
ans = max(ans ... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
N = int(readline())
A = list(map(int,readline().split()))
B = list(map(int,readline().split()))
def rui(a):
ret = [0] * (len(a) + 1)
for i in range(len(a)):
ret[i + 1] = ret[i] + a[i]
return ret
ra = rui(A)... | 16 | 21 | 332 | 424 | N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
cur = 0
for j in range(N):
if j < i:
cur += A[j]
elif j == i:
cur += A[j] + B[j]
else:
cur += B[j]
ans = max(ans, cur)
print(a... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
N = int(readline())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
def rui(a):
ret = [0] * (len(a) + 1)
for i in range(len(a)):
ret[i + 1] = ret[i] + a[i]
return ret
ra = rui(A)
rb = rui(... | false | 23.809524 | [
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-B = list(map(int, input().split()))",
"+import sys",
"+",
"+read = sys.stdin.buffer.read",
"+readline = sys.stdin.buffer.readline",
"+N = int(readline())",
"+A = list(map(int, readline().split()))",
"+B = list(map(int, readline()... | false | 0.046877 | 0.047039 | 0.996541 | [
"s997469384",
"s399024682"
] |
u062484507 | p02683 | python | s105947641 | s567980734 | 78 | 61 | 9,276 | 9,540 | Accepted | Accepted | 21.79 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, m, x = list(map(int, readline().split()))
c = [list(map(int, readline().split())) for _ in range(n)]
ans = float('inf')
# bit全探索
for i in range(2 ** n):
bag = [0]*(m+1)
for j in r... | import itertools
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, m, x = list(map(int, readline().split()))
c = [list(map(int, readline().split())) for _ in range(n)]
ans = 10 ** 9 + 7
for l in list(itertools.product([0, 1], repeat=n)):
... | 19 | 19 | 538 | 586 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, m, x = list(map(int, readline().split()))
c = [list(map(int, readline().split())) for _ in range(n)]
ans = float("inf")
# bit全探索
for i in range(2**n):
bag = [0] * (m + 1)
for j in range(n):
... | import itertools
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, m, x = list(map(int, readline().split()))
c = [list(map(int, readline().split())) for _ in range(n)]
ans = 10**9 + 7
for l in list(itertools.product([0, 1], repeat=n)):
cart = [0]... | false | 0 | [
"+import itertools",
"-ans = float(\"inf\")",
"-# bit全探索",
"-for i in range(2**n):",
"- bag = [0] * (m + 1)",
"- for j in range(n):",
"- if (i >> j) & 1:",
"- bag = [x + y for (x, y) in zip(bag, c[j])]",
"- if min(bag[1::]) >= x:",
"- ans = min(ans, bag[0]... | false | 0.068565 | 0.049828 | 1.376034 | [
"s105947641",
"s567980734"
] |
u945181840 | p02960 | python | s358451705 | s620296378 | 1,111 | 825 | 63,160 | 3,188 | Accepted | Accepted | 25.74 | def main():
S = [int(i) if i != '?' else -1 for i in eval(input())]
s = len(S)
mod = 10 ** 9 + 7
dp = [[0] * 13 for _ in range(s)]
table = [[0] * 10 for _ in range(13)]
for i in range(13):
for j in range(10):
table[i][j] = (i * 10 + j) % 13
table2 = [[] for _... | def main():
S = str(eval(input()))
ans = [0] * 13
ans[0] = 1
MOD = 10**9 + 7
for i in S:
dp = [0] * 13
for j in range(13):
dp[(j * 10) % 13] = ans[j] % MOD
dp += dp
if i == '?':
for j in range(13):
ans[j] = sum(dp[j+4:j+14])
els... | 41 | 23 | 1,058 | 458 | def main():
S = [int(i) if i != "?" else -1 for i in eval(input())]
s = len(S)
mod = 10**9 + 7
dp = [[0] * 13 for _ in range(s)]
table = [[0] * 10 for _ in range(13)]
for i in range(13):
for j in range(10):
table[i][j] = (i * 10 + j) % 13
table2 = [[] for _ in range(13)]
... | def main():
S = str(eval(input()))
ans = [0] * 13
ans[0] = 1
MOD = 10**9 + 7
for i in S:
dp = [0] * 13
for j in range(13):
dp[(j * 10) % 13] = ans[j] % MOD
dp += dp
if i == "?":
for j in range(13):
ans[j] = sum(dp[j + 4 : j + 14... | false | 43.902439 | [
"- S = [int(i) if i != \"?\" else -1 for i in eval(input())]",
"- s = len(S)",
"- mod = 10**9 + 7",
"- dp = [[0] * 13 for _ in range(s)]",
"- table = [[0] * 10 for _ in range(13)]",
"- for i in range(13):",
"- for j in range(10):",
"- table[i][j] = (i * 10 + j) % 13... | false | 0.040732 | 0.039159 | 1.040161 | [
"s358451705",
"s620296378"
] |
u806976856 | p02687 | python | s873673229 | s542018897 | 23 | 21 | 9,092 | 9,032 | Accepted | Accepted | 8.7 | S=eval(input())
if S=="ABC":
print("ARC")
if S=="ARC":
print("ABC") | A=eval(input())
if A=="ABC":
print("ARC")
if A=="ARC":
print("ABC") | 5 | 5 | 73 | 73 | S = eval(input())
if S == "ABC":
print("ARC")
if S == "ARC":
print("ABC")
| A = eval(input())
if A == "ABC":
print("ARC")
if A == "ARC":
print("ABC")
| false | 0 | [
"-S = eval(input())",
"-if S == \"ABC\":",
"+A = eval(input())",
"+if A == \"ABC\":",
"-if S == \"ARC\":",
"+if A == \"ARC\":"
] | false | 0.043818 | 0.044426 | 0.986318 | [
"s873673229",
"s542018897"
] |
u606045429 | p03945 | python | s859536667 | s404078054 | 42 | 18 | 3,188 | 3,188 | Accepted | Accepted | 57.14 | S = eval(input())
count = 0
for i in range(len(S) - 1):
if S[i] != S[i + 1]:
count += 1
print(count) | S = eval(input())
print((S.count("WB") + S.count("BW"))) | 8 | 2 | 115 | 49 | S = eval(input())
count = 0
for i in range(len(S) - 1):
if S[i] != S[i + 1]:
count += 1
print(count)
| S = eval(input())
print((S.count("WB") + S.count("BW")))
| false | 75 | [
"-count = 0",
"-for i in range(len(S) - 1):",
"- if S[i] != S[i + 1]:",
"- count += 1",
"-print(count)",
"+print((S.count(\"WB\") + S.count(\"BW\")))"
] | false | 0.09887 | 0.079519 | 1.243351 | [
"s859536667",
"s404078054"
] |
u378691508 | p02787 | python | s021302130 | s599903389 | 471 | 342 | 217,288 | 217,768 | Accepted | Accepted | 27.39 | H, N = list(map(int, input().split()))
A=[]
B=[]
for i in range(N):
a,b = list(map(int, input().split()))
A.append(a)
B.append(b)
#dp[i+1][h] := i番目の魔法まで見て、ライフをh以上削った時の最小魔力コスト
dp=[[float("inf")]*(H+1) for _ in range(N+1)]
for i in range(N):
for h in range(H+1):
if A[i]>=h:
dp[i+1][h] = min(dp[i][... | H, N = list(map(int, input().split()))
A=[]
B=[]
for _ in range(N):
a, b = list(map(int, input().split()))
A.append(a)
B.append(b)
dp=[[float("inf")]*(H+1) for _ in range(N+1)]
dp[0][0]=0
for i in range(N):
a, b = A[i], B[i]
for j in range(H+1):
if a>=j:
dp[i+1][j] = min(dp[i][j], b)
else:... | 17 | 19 | 418 | 375 | H, N = list(map(int, input().split()))
A = []
B = []
for i in range(N):
a, b = list(map(int, input().split()))
A.append(a)
B.append(b)
# dp[i+1][h] := i番目の魔法まで見て、ライフをh以上削った時の最小魔力コスト
dp = [[float("inf")] * (H + 1) for _ in range(N + 1)]
for i in range(N):
for h in range(H + 1):
if A[i] >= h:
... | H, N = list(map(int, input().split()))
A = []
B = []
for _ in range(N):
a, b = list(map(int, input().split()))
A.append(a)
B.append(b)
dp = [[float("inf")] * (H + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
a, b = A[i], B[i]
for j in range(H + 1):
if a >= j:
dp[i + ... | false | 10.526316 | [
"-for i in range(N):",
"+for _ in range(N):",
"-# dp[i+1][h] := i番目の魔法まで見て、ライフをh以上削った時の最小魔力コスト",
"+dp[0][0] = 0",
"- for h in range(H + 1):",
"- if A[i] >= h:",
"- dp[i + 1][h] = min(dp[i][h], B[i])",
"+ a, b = A[i], B[i]",
"+ for j in range(H + 1):",
"+ if a >= j... | false | 0.113874 | 0.187852 | 0.606191 | [
"s021302130",
"s599903389"
] |
u798260206 | p02844 | python | s689120015 | s802897405 | 1,683 | 29 | 4,456 | 9,276 | Accepted | Accepted | 98.28 | n=int(eval(input()))
s=list(eval(input()))
cnt=0
for i in range (10):
i=str(i)
for j in range (10):
j=str(j)
for k in range (10):
k=str(k)
if s.count(i)!=0:
a=s.index(i)
x=s[(a+1):]
if x.count(j)!=0:
b=x.index(j)
y=x[(b+1):]
if... | n = int(eval(input()))
s = eval(input())
cnt = 0
for N in range(1000):
tgt = str(N).zfill(3)
if tgt[0] in s:
i = s.index(tgt[0])
if tgt[1] in s[i+1:]:
j = s[i+1:].index(tgt[1]) + i
if tgt[2] in s[j+2:]:
cnt += 1
print(cnt)
| 19 | 13 | 363 | 288 | n = int(eval(input()))
s = list(eval(input()))
cnt = 0
for i in range(10):
i = str(i)
for j in range(10):
j = str(j)
for k in range(10):
k = str(k)
if s.count(i) != 0:
a = s.index(i)
x = s[(a + 1) :]
if x.count(j) != 0:
... | n = int(eval(input()))
s = eval(input())
cnt = 0
for N in range(1000):
tgt = str(N).zfill(3)
if tgt[0] in s:
i = s.index(tgt[0])
if tgt[1] in s[i + 1 :]:
j = s[i + 1 :].index(tgt[1]) + i
if tgt[2] in s[j + 2 :]:
cnt += 1
print(cnt)
| false | 31.578947 | [
"-s = list(eval(input()))",
"+s = eval(input())",
"-for i in range(10):",
"- i = str(i)",
"- for j in range(10):",
"- j = str(j)",
"- for k in range(10):",
"- k = str(k)",
"- if s.count(i) != 0:",
"- a = s.index(i)",
"- x = ... | false | 0.041951 | 0.040212 | 1.043245 | [
"s689120015",
"s802897405"
] |
u855775311 | p02363 | python | s354976244 | s301955362 | 570 | 520 | 8,676 | 8,760 | Accepted | Accepted | 8.77 | def main():
nvertices, nedges = list(map(int, input().split()))
INF = float('inf')
D1 = [[INF for i in range(nvertices)] for i in range(nvertices)]
for i in range(nedges):
s, t, d = list(map(int, input().split()))
D1[s][t] = d
for i in range(nvertices):
D1[i][i] = 0... | import math
def main():
nvertices, nedges = list(map(int, input().split()))
INF = float('inf')
D1 = [[0 if i == j else INF for i in range(nvertices)]
for j in range(nvertices)]
for i in range(nedges):
u, v, w = list(map(int, input().split()))
D1[u][v] = w
for... | 28 | 29 | 798 | 773 | def main():
nvertices, nedges = list(map(int, input().split()))
INF = float("inf")
D1 = [[INF for i in range(nvertices)] for i in range(nvertices)]
for i in range(nedges):
s, t, d = list(map(int, input().split()))
D1[s][t] = d
for i in range(nvertices):
D1[i][i] = 0
for k... | import math
def main():
nvertices, nedges = list(map(int, input().split()))
INF = float("inf")
D1 = [[0 if i == j else INF for i in range(nvertices)] for j in range(nvertices)]
for i in range(nedges):
u, v, w = list(map(int, input().split()))
D1[u][v] = w
for k in range(nvertices):... | false | 3.448276 | [
"+import math",
"+",
"+",
"- D1 = [[INF for i in range(nvertices)] for i in range(nvertices)]",
"+ D1 = [[0 if i == j else INF for i in range(nvertices)] for j in range(nvertices)]",
"- s, t, d = list(map(int, input().split()))",
"- D1[s][t] = d",
"- for i in range(nvertices):",... | false | 0.045219 | 0.044598 | 1.013918 | [
"s354976244",
"s301955362"
] |
u463655976 | p03828 | python | s030278542 | s269549370 | 247 | 220 | 50,908 | 49,756 | Accepted | Accepted | 10.93 | from functools import reduce
N = int(eval(input()))
g = 10 ** 9 + 7
def add(a, b):
return (a + b) % g
def mul(a, b):
return (a * b) % g
def adda(a, p1, p2):
for x in range(len(a)):
a[x] = add(p1[x], p2[x])
d = []
DP = [[0 for _ in range(N+1)] for _ in range(N+1)]
ans = [0 for _ in rang... | from functools import reduce
N = int(eval(input()))
g = 10 ** 9 + 7
def mul(a, b):
return (a * b) % g
def adda(a, p1, p2):
for x in range(len(a)):
a[x] = p1[x] + p2[x]
d = []
DP = [[0 for _ in range(N+1)] for _ in range(N+1)]
ans = [0 for _ in range(N+1)]
for i in range(2, N+1):
for ... | 27 | 26 | 578 | 538 | from functools import reduce
N = int(eval(input()))
g = 10**9 + 7
def add(a, b):
return (a + b) % g
def mul(a, b):
return (a * b) % g
def adda(a, p1, p2):
for x in range(len(a)):
a[x] = add(p1[x], p2[x])
d = []
DP = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
ans = [0 for _ in range(N... | from functools import reduce
N = int(eval(input()))
g = 10**9 + 7
def mul(a, b):
return (a * b) % g
def adda(a, p1, p2):
for x in range(len(a)):
a[x] = p1[x] + p2[x]
d = []
DP = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
ans = [0 for _ in range(N + 1)]
for i in range(2, N + 1):
for j i... | false | 3.703704 | [
"-",
"-",
"-def add(a, b):",
"- return (a + b) % g",
"- a[x] = add(p1[x], p2[x])",
"+ a[x] = p1[x] + p2[x]"
] | false | 0.294382 | 0.074633 | 3.944403 | [
"s030278542",
"s269549370"
] |
u969850098 | p02947 | python | s617611267 | s260310897 | 633 | 225 | 19,844 | 19,728 | Accepted | Accepted | 64.45 | import sys
from collections import Counter
from math import factorial
def combinations_count(n, r):
return factorial(n) // (factorial(n - r) * factorial(r))
def main():
input = sys.stdin.readline
N = int(eval(input()))
texts = [''.join(sorted(list(input().rstrip()))) for _ in range(N)]
c = Coun... | import sys
from collections import Counter
def main():
input = sys.stdin.readline
N = int(eval(input()))
texts = [''.join(sorted(list(input().rstrip()))) for _ in range(N)]
c = Counter(texts)
cnt = 0
for t in list(c.values()):
if t > 1:
cnt += (t * (t-1)) // 2
print(cnt)
if __n... | 20 | 16 | 469 | 339 | import sys
from collections import Counter
from math import factorial
def combinations_count(n, r):
return factorial(n) // (factorial(n - r) * factorial(r))
def main():
input = sys.stdin.readline
N = int(eval(input()))
texts = ["".join(sorted(list(input().rstrip()))) for _ in range(N)]
c = Count... | import sys
from collections import Counter
def main():
input = sys.stdin.readline
N = int(eval(input()))
texts = ["".join(sorted(list(input().rstrip()))) for _ in range(N)]
c = Counter(texts)
cnt = 0
for t in list(c.values()):
if t > 1:
cnt += (t * (t - 1)) // 2
print(c... | false | 20 | [
"-from math import factorial",
"-",
"-",
"-def combinations_count(n, r):",
"- return factorial(n) // (factorial(n - r) * factorial(r))",
"- cnt += combinations_count(t, 2)",
"+ cnt += (t * (t - 1)) // 2"
] | false | 0.044868 | 0.038191 | 1.174848 | [
"s617611267",
"s260310897"
] |
u667978773 | p02994 | python | s430341236 | s669858462 | 198 | 17 | 38,384 | 2,940 | Accepted | Accepted | 91.41 | n,l = list(map(int,input().split()))
taste = [l+i-1 for i in range(1,n+1)]
ideal = sum(taste)
bited = [ideal-taste[i] for i in range(n)]
dif = [abs(ideal-bited[i]) for i in range(n)]
print((bited[dif.index(min(dif))]))
| n,l=(list(map(int,input().split())))
if l>0:
print((sum(range(l+1,l+n))))
elif l+n-1<0:
print((sum(range(l,l+n-1))))
else:
print((sum(range(l,l+n))))
| 6 | 7 | 217 | 150 | n, l = list(map(int, input().split()))
taste = [l + i - 1 for i in range(1, n + 1)]
ideal = sum(taste)
bited = [ideal - taste[i] for i in range(n)]
dif = [abs(ideal - bited[i]) for i in range(n)]
print((bited[dif.index(min(dif))]))
| n, l = list(map(int, input().split()))
if l > 0:
print((sum(range(l + 1, l + n))))
elif l + n - 1 < 0:
print((sum(range(l, l + n - 1))))
else:
print((sum(range(l, l + n))))
| false | 14.285714 | [
"-taste = [l + i - 1 for i in range(1, n + 1)]",
"-ideal = sum(taste)",
"-bited = [ideal - taste[i] for i in range(n)]",
"-dif = [abs(ideal - bited[i]) for i in range(n)]",
"-print((bited[dif.index(min(dif))]))",
"+if l > 0:",
"+ print((sum(range(l + 1, l + n))))",
"+elif l + n - 1 < 0:",
"+ p... | false | 0.073432 | 0.035477 | 2.069852 | [
"s430341236",
"s669858462"
] |
u232852711 | p03695 | python | s441465309 | s281938884 | 22 | 19 | 3,444 | 3,188 | Accepted | Accepted | 13.64 | import copy
n = int(eval(input()))
a = list(map(int, input().split()))
color = [0]*9
for i in range(n):
rate = min(a[i]//400, 8)
color[rate] += 1
ans_min = 0
color_min = copy.deepcopy(color)
for c in color_min[:-1]:
if c > 0:
ans_min += 1
ans_min = max(1, ans_min)
ans_max = 0
col... | n = int(eval(input()))
a = list(map(int, input().split()))
rates = [0]*9
for i in range(n):
r = min(a[i]//400, 8)
rates[r] += 1
n_min, n_max = 0, 0
if max(rates[:-1]) > 0:
for i in range(8):
n_min += 1 if rates[i] > 0 else 0
n_max = n_min+rates[-1]
else:
n_min = 1
n_max = rates[-1]
p... | 24 | 18 | 459 | 332 | import copy
n = int(eval(input()))
a = list(map(int, input().split()))
color = [0] * 9
for i in range(n):
rate = min(a[i] // 400, 8)
color[rate] += 1
ans_min = 0
color_min = copy.deepcopy(color)
for c in color_min[:-1]:
if c > 0:
ans_min += 1
ans_min = max(1, ans_min)
ans_max = 0
color_max = copy.d... | n = int(eval(input()))
a = list(map(int, input().split()))
rates = [0] * 9
for i in range(n):
r = min(a[i] // 400, 8)
rates[r] += 1
n_min, n_max = 0, 0
if max(rates[:-1]) > 0:
for i in range(8):
n_min += 1 if rates[i] > 0 else 0
n_max = n_min + rates[-1]
else:
n_min = 1
n_max = rates[-1]... | false | 25 | [
"-import copy",
"-",
"-color = [0] * 9",
"+rates = [0] * 9",
"- rate = min(a[i] // 400, 8)",
"- color[rate] += 1",
"-ans_min = 0",
"-color_min = copy.deepcopy(color)",
"-for c in color_min[:-1]:",
"- if c > 0:",
"- ans_min += 1",
"-ans_min = max(1, ans_min)",
"-ans_max = 0",
... | false | 0.038763 | 0.075329 | 0.514585 | [
"s441465309",
"s281938884"
] |
u726285999 | p02644 | python | s461537568 | s197986507 | 1,923 | 1,727 | 43,340 | 53,000 | Accepted | Accepted | 10.19 | #!/usr/bin python3
# -*- coding: utf-8 -*-
H, W, K = list(map(int,input().split()))
sth, stw, glh, glw = list(map(int,input().split()))
sth, stw = sth-1, stw-1
glh, glw = glh-1, glw-1
INF = -1
Gmap = [list(eval(input())) for _ in range(H)]
Seen = [[INF]*W for _ in range(H)]
direc = {(1,0), (-1,0), (0,1),... | from collections import deque
import sys
N_MAX = 200000 + 5
H, W, K = list(map(int, input().split()))
sth, stw, glh, glw = list(map(int, input().split()))
INF = 10**6 * K
dp = [[INF for _ in range(W+2)] for _ in range(H+2)]
dp[0] = [-1]*(W+2)
dp[H+1] = [-1]*(W+2)
for h in range(1, H+1):
s = sys.... | 45 | 57 | 1,192 | 1,311 | #!/usr/bin python3
# -*- coding: utf-8 -*-
H, W, K = list(map(int, input().split()))
sth, stw, glh, glw = list(map(int, input().split()))
sth, stw = sth - 1, stw - 1
glh, glw = glh - 1, glw - 1
INF = -1
Gmap = [list(eval(input())) for _ in range(H)]
Seen = [[INF] * W for _ in range(H)]
direc = {(1, 0), (-1, 0), (0, 1),... | from collections import deque
import sys
N_MAX = 200000 + 5
H, W, K = list(map(int, input().split()))
sth, stw, glh, glw = list(map(int, input().split()))
INF = 10**6 * K
dp = [[INF for _ in range(W + 2)] for _ in range(H + 2)]
dp[0] = [-1] * (W + 2)
dp[H + 1] = [-1] * (W + 2)
for h in range(1, H + 1):
s = sys.std... | false | 21.052632 | [
"-#!/usr/bin python3",
"-# -*- coding: utf-8 -*-",
"+from collections import deque",
"+import sys",
"+",
"+N_MAX = 200000 + 5",
"-sth, stw = sth - 1, stw - 1",
"-glh, glw = glh - 1, glw - 1",
"-INF = -1",
"-Gmap = [list(eval(input())) for _ in range(H)]",
"-Seen = [[INF] * W for _ in range(H)]",... | false | 0.035446 | 0.043674 | 0.811598 | [
"s461537568",
"s197986507"
] |
u813098295 | p02687 | python | s897760309 | s741119391 | 23 | 21 | 9,020 | 8,956 | Accepted | Accepted | 8.7 | S = eval(input())
print(("ABC" if S == "ARC" else "ARC"))
| print(("ABC" if eval(input()) == "ARC" else "ARC")) | 2 | 1 | 51 | 43 | S = eval(input())
print(("ABC" if S == "ARC" else "ARC"))
| print(("ABC" if eval(input()) == "ARC" else "ARC"))
| false | 50 | [
"-S = eval(input())",
"-print((\"ABC\" if S == \"ARC\" else \"ARC\"))",
"+print((\"ABC\" if eval(input()) == \"ARC\" else \"ARC\"))"
] | false | 0.077913 | 0.145226 | 0.536497 | [
"s897760309",
"s741119391"
] |
u089032001 | p02813 | python | s516220080 | s746772711 | 38 | 28 | 8,052 | 3,188 | Accepted | Accepted | 26.32 | from itertools import permutations as perm
def inpl():
return list(map(int, input().split()))
N = int(eval(input()))
P = tuple(inpl())
Q = tuple(inpl())
A = list(perm([i for i in range(1, N + 1)]))
A.sort()
for i, a in enumerate(A):
# print(a)
if a == P:
p = i
if a == Q:
... | from itertools import permutations as perm
def inpl():
return tuple(map(int, input().split()))
N = int(eval(input()))
P = inpl()
Q = inpl()
for i, p in enumerate(perm([j+1 for j in range(N)])):
if p == P:
pi = i
if p == Q:
qi = i
print((abs(pi-qi)))
| 22 | 17 | 350 | 291 | from itertools import permutations as perm
def inpl():
return list(map(int, input().split()))
N = int(eval(input()))
P = tuple(inpl())
Q = tuple(inpl())
A = list(perm([i for i in range(1, N + 1)]))
A.sort()
for i, a in enumerate(A):
# print(a)
if a == P:
p = i
if a == Q:
q = i
print(... | from itertools import permutations as perm
def inpl():
return tuple(map(int, input().split()))
N = int(eval(input()))
P = inpl()
Q = inpl()
for i, p in enumerate(perm([j + 1 for j in range(N)])):
if p == P:
pi = i
if p == Q:
qi = i
print((abs(pi - qi)))
| false | 22.727273 | [
"- return list(map(int, input().split()))",
"+ return tuple(map(int, input().split()))",
"-P = tuple(inpl())",
"-Q = tuple(inpl())",
"-A = list(perm([i for i in range(1, N + 1)]))",
"-A.sort()",
"-for i, a in enumerate(A):",
"- # print(a)",
"- if a == P:",
"- p = i",
"- if ... | false | 0.041854 | 0.040691 | 1.028566 | [
"s516220080",
"s746772711"
] |
u864197622 | p04022 | python | s486536776 | s118192190 | 3,615 | 2,847 | 123,228 | 123,352 | Accepted | Accepted | 21.24 | import sys
input = sys.stdin.readline
def primeFactor(N):
i = 2
ret = {}
n = N
mrFlg = 0
while i*i <= n:
k = 0
while n % i == 0:
n //= i
k += 1
if k: ret[i] = k
i += 1 + i%2
if i == 101 and n >= 2**20:
def f... | import sys
input = sys.stdin.readline
def gcd(a, b):
while b: a, b = b, a % b
return a
def isPrimeMR(n):
d = n - 1
d = d // (d & -d)
L = [2, 7, 61] if n < 1<<32 else [2, 3, 5, 7, 11, 13, 17] if n < 1<<48 else [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
for a in L:
t = d
y =... | 87 | 91 | 2,398 | 2,352 | import sys
input = sys.stdin.readline
def primeFactor(N):
i = 2
ret = {}
n = N
mrFlg = 0
while i * i <= n:
k = 0
while n % i == 0:
n //= i
k += 1
if k:
ret[i] = k
i += 1 + i % 2
if i == 101 and n >= 2**20:
de... | import sys
input = sys.stdin.readline
def gcd(a, b):
while b:
a, b = b, a % b
return a
def isPrimeMR(n):
d = n - 1
d = d // (d & -d)
L = (
[2, 7, 61]
if n < 1 << 32
else [2, 3, 5, 7, 11, 13, 17]
if n < 1 << 48
else [2, 3, 5, 7, 11, 13, 17, 19, 23,... | false | 4.395604 | [
"+",
"+",
"+def gcd(a, b):",
"+ while b:",
"+ a, b = b, a % b",
"+ return a",
"+",
"+",
"+def isPrimeMR(n):",
"+ d = n - 1",
"+ d = d // (d & -d)",
"+ L = (",
"+ [2, 7, 61]",
"+ if n < 1 << 32",
"+ else [2, 3, 5, 7, 11, 13, 17]",
"+ if ... | false | 0.05962 | 0.059811 | 0.996805 | [
"s486536776",
"s118192190"
] |
u197457087 | p02720 | python | s450352309 | s100636749 | 99 | 88 | 11,028 | 76,096 | Accepted | Accepted | 11.11 | k = int(eval(input()))
a = [1,2,3,4,5,6,7,8,9] #一桁目を入れる。
kosu = [0,1,1,1,1,1,1,1,1,1]
total = sum(kosu)
i = 0 #これが1桁に相当.
tempk = k*1
while k > total:
b = a.copy() #aのコピーを作ってbを参照して新しいaを作る。
tempk = k - total
i += 1
a = [] #ここでaをリセット
kosub = kosu.copy() #各々の数で終わる個数を記録
kosu = []
for i in range(10... | N = int(eval(input()))
if N <= 9:
print(N)
exit()
A = [[] for _ in range(11)]
A[0] = [1,2,3,4,5,6,7,8,9]
now = 9
keta = 1
while True:
for x in A[keta-1]:
x = str(x)
last = int(x[-1])
if last - 1 >= 0:
temp = x+str(last-1)
A[keta].append(int(temp))
now += 1
if no... | 37 | 34 | 906 | 649 | k = int(eval(input()))
a = [1, 2, 3, 4, 5, 6, 7, 8, 9] # 一桁目を入れる。
kosu = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]
total = sum(kosu)
i = 0 # これが1桁に相当.
tempk = k * 1
while k > total:
b = a.copy() # aのコピーを作ってbを参照して新しいaを作る。
tempk = k - total
i += 1
a = [] # ここでaをリセット
kosub = kosu.copy() # 各々の数で終わる個数を記録
k... | N = int(eval(input()))
if N <= 9:
print(N)
exit()
A = [[] for _ in range(11)]
A[0] = [1, 2, 3, 4, 5, 6, 7, 8, 9]
now = 9
keta = 1
while True:
for x in A[keta - 1]:
x = str(x)
last = int(x[-1])
if last - 1 >= 0:
temp = x + str(last - 1)
A[keta].append(int(temp)... | false | 8.108108 | [
"-k = int(eval(input()))",
"-a = [1, 2, 3, 4, 5, 6, 7, 8, 9] # 一桁目を入れる。",
"-kosu = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]",
"-total = sum(kosu)",
"-i = 0 # これが1桁に相当.",
"-tempk = k * 1",
"-while k > total:",
"- b = a.copy() # aのコピーを作ってbを参照して新しいaを作る。",
"- tempk = k - total",
"- i += 1",
"- ... | false | 0.007856 | 0.047857 | 0.164145 | [
"s450352309",
"s100636749"
] |
u761529120 | p02792 | python | s684898603 | s201735528 | 240 | 86 | 42,076 | 67,828 | Accepted | Accepted | 64.17 | def main():
N = int(eval(input()))
cnt = [[0] * 10 for _ in range(10)]
for i in range(1,N+1):
tmp = str(i)
top = int(tmp[0])
end = int(tmp[-1])
cnt[top][end] += 1
ans = 0
for a in range(10):
for b in range(10):
for c in range(10):
... | def main():
N = int(eval(input()))
dp = [[0] * 10 for _ in range(10)]
for i in range(1,N+1):
tmp = str(i)
left = int(tmp[0])
right = int(tmp[-1])
if left == 0 or right == 0:
continue
dp[left][right] += 1
ans = 0
for i in range(10):
... | 22 | 21 | 505 | 441 | def main():
N = int(eval(input()))
cnt = [[0] * 10 for _ in range(10)]
for i in range(1, N + 1):
tmp = str(i)
top = int(tmp[0])
end = int(tmp[-1])
cnt[top][end] += 1
ans = 0
for a in range(10):
for b in range(10):
for c in range(10):
... | def main():
N = int(eval(input()))
dp = [[0] * 10 for _ in range(10)]
for i in range(1, N + 1):
tmp = str(i)
left = int(tmp[0])
right = int(tmp[-1])
if left == 0 or right == 0:
continue
dp[left][right] += 1
ans = 0
for i in range(10):
for j... | false | 4.545455 | [
"- cnt = [[0] * 10 for _ in range(10)]",
"+ dp = [[0] * 10 for _ in range(10)]",
"- top = int(tmp[0])",
"- end = int(tmp[-1])",
"- cnt[top][end] += 1",
"+ left = int(tmp[0])",
"+ right = int(tmp[-1])",
"+ if left == 0 or right == 0:",
"+ con... | false | 0.067458 | 0.066709 | 1.011229 | [
"s684898603",
"s201735528"
] |
u062147869 | p03210 | python | s494724927 | s289454765 | 175 | 18 | 38,256 | 3,064 | Accepted | Accepted | 89.71 | X=int(eval(input()))
if X==7 or X==5 or X==3:
print('YES')
else:
print('NO') | N=int(eval(input()))
if N==3 or N==5 or N==7:
print('YES')
else:
print('NO') | 5 | 5 | 82 | 78 | X = int(eval(input()))
if X == 7 or X == 5 or X == 3:
print("YES")
else:
print("NO")
| N = int(eval(input()))
if N == 3 or N == 5 or N == 7:
print("YES")
else:
print("NO")
| false | 0 | [
"-X = int(eval(input()))",
"-if X == 7 or X == 5 or X == 3:",
"+N = int(eval(input()))",
"+if N == 3 or N == 5 or N == 7:"
] | false | 0.042802 | 0.033119 | 1.292346 | [
"s494724927",
"s289454765"
] |
u796942881 | p03659 | python | s071632097 | s247744039 | 126 | 112 | 24,320 | 24,320 | Accepted | Accepted | 11.11 | from itertools import accumulate
def main():
N, *a = list(map(int, open(0).read().split()))
a = list(accumulate(a))
total = a[-1]
print((min(abs(total - 2 * a[i]) for i in range(N - 1))))
return
main()
| from itertools import accumulate
def main():
N, *a = list(map(int, open(0).read().split()))
a = list(accumulate(a))
total = a[-1]
print((min(abs(total - 2 * i) for i in a[:-1])))
return
main()
| 12 | 12 | 229 | 220 | from itertools import accumulate
def main():
N, *a = list(map(int, open(0).read().split()))
a = list(accumulate(a))
total = a[-1]
print((min(abs(total - 2 * a[i]) for i in range(N - 1))))
return
main()
| from itertools import accumulate
def main():
N, *a = list(map(int, open(0).read().split()))
a = list(accumulate(a))
total = a[-1]
print((min(abs(total - 2 * i) for i in a[:-1])))
return
main()
| false | 0 | [
"- print((min(abs(total - 2 * a[i]) for i in range(N - 1))))",
"+ print((min(abs(total - 2 * i) for i in a[:-1])))"
] | false | 0.039784 | 0.040286 | 0.987554 | [
"s071632097",
"s247744039"
] |
u668503853 | p03031 | python | s019599356 | s729210192 | 42 | 38 | 3,064 | 3,064 | Accepted | Accepted | 9.52 | N,M=list(map(int,input().split()))
L=[list(map(int,input().split()))[1:] for _ in range(M)]
P=list(map(int,input().split()))
ans=0
for i in range(2**N):
lit=[0]*M
for j,switch in enumerate(L):
cnt=0
for s in switch:
if i>>(s-1)&1:
cnt+=1
if cnt%2==P[j]:
lit[j]=1
else... | N,M=list(map(int,input().split()))
L=[list(map(int,input().split()))[1:] for _ in range(M)]
P=list(map(int,input().split()))
ans=0
for i in range(2**N):
lit=[0]*M
for j,switches in enumerate(L):
cnt=0
for s in switches:
if i>>(s-1)&1:cnt+=1
if cnt%2==P[j]:lit[j]=1
if all(lit):ans+=1
... | 17 | 13 | 367 | 325 | N, M = list(map(int, input().split()))
L = [list(map(int, input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for i in range(2**N):
lit = [0] * M
for j, switch in enumerate(L):
cnt = 0
for s in switch:
if i >> (s - 1) & 1:
cnt += 1
... | N, M = list(map(int, input().split()))
L = [list(map(int, input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for i in range(2**N):
lit = [0] * M
for j, switches in enumerate(L):
cnt = 0
for s in switches:
if i >> (s - 1) & 1:
cnt += 1... | false | 23.529412 | [
"- for j, switch in enumerate(L):",
"+ for j, switches in enumerate(L):",
"- for s in switch:",
"+ for s in switches:",
"- else:",
"- lit[j] = 0"
] | false | 0.049622 | 0.049701 | 0.998411 | [
"s019599356",
"s729210192"
] |
u290563917 | p03163 | python | s194585932 | s857388142 | 738 | 500 | 144,744 | 120,812 | Accepted | Accepted | 32.25 | n, w = list(map(int, input().split(' ')))
items = [[]] * n
for i in range(n):
weight, val = list(map(int, input().split(' ')))
items[i] = [weight, val]
# print(n, w)
# print(items)
dp = []
for i in range(n+1):
dp.append([])
for j in range(w+1):
dp[i].append(0)
# print(len(dp), len(dp[0]), d... | n, w = list(map(int, input().split()))
wl = [0] * n
vl = [0] * n
for i in range(n):
wl[i], vl[i] = list(map(int, input().split()))
dp = [[]] * (n+1)
for i in range(n+1):
dp[i] = [0] * (w+1)
for i in range(n):
for j in range(w+1):
if j >= wl[i]:
dp[i+1][j] = max(dp[i][j], dp[i][j-wl[i]]+vl... | 26 | 19 | 611 | 415 | n, w = list(map(int, input().split(" ")))
items = [[]] * n
for i in range(n):
weight, val = list(map(int, input().split(" ")))
items[i] = [weight, val]
# print(n, w)
# print(items)
dp = []
for i in range(n + 1):
dp.append([])
for j in range(w + 1):
dp[i].append(0)
# print(len(dp), len(dp[0]), dp... | n, w = list(map(int, input().split()))
wl = [0] * n
vl = [0] * n
for i in range(n):
wl[i], vl[i] = list(map(int, input().split()))
dp = [[]] * (n + 1)
for i in range(n + 1):
dp[i] = [0] * (w + 1)
for i in range(n):
for j in range(w + 1):
if j >= wl[i]:
dp[i + 1][j] = max(dp[i][j], dp[i][... | false | 26.923077 | [
"-n, w = list(map(int, input().split(\" \")))",
"-items = [[]] * n",
"+n, w = list(map(int, input().split()))",
"+wl = [0] * n",
"+vl = [0] * n",
"- weight, val = list(map(int, input().split(\" \")))",
"- items[i] = [weight, val]",
"-# print(n, w)",
"-# print(items)",
"-dp = []",
"+ wl[... | false | 0.105547 | 0.078981 | 1.336364 | [
"s194585932",
"s857388142"
] |
u769640830 | p03171 | python | s709533285 | s089739370 | 1,932 | 462 | 164,488 | 115,292 | Accepted | Accepted | 76.09 | import sys
def f(l,beg,end):
if beg==end:
dp[beg][end]=l[beg]
return l[beg]
if beg+1==end:
dp[beg][end] = max(l[beg],l[end])
return max(l[beg],l[end])
if dp[beg][end]!=-1:
return dp[beg][end]
ans1=l[beg]+min(f(l,beg+2,end),f(l,beg+1,end-1))
ans2=... | n = int(eval(input()))
l = list(map(int, input().split()))
tl = sum(l)
dp=[]
for _ in range(n):
dp.append([0]*n)
for i in range(n):
dp[i][i]=l[i]
for i in range(n-1):
dp[i][i+1]=max(l[i],l[i+1])
for i in range(n-1,-1,-1):
for j in range(i+2,n):
ans1=l[i]+min(dp[i+2][j],dp[i+1][j-1])
... | 25 | 18 | 581 | 432 | import sys
def f(l, beg, end):
if beg == end:
dp[beg][end] = l[beg]
return l[beg]
if beg + 1 == end:
dp[beg][end] = max(l[beg], l[end])
return max(l[beg], l[end])
if dp[beg][end] != -1:
return dp[beg][end]
ans1 = l[beg] + min(f(l, beg + 2, end), f(l, beg + 1, en... | n = int(eval(input()))
l = list(map(int, input().split()))
tl = sum(l)
dp = []
for _ in range(n):
dp.append([0] * n)
for i in range(n):
dp[i][i] = l[i]
for i in range(n - 1):
dp[i][i + 1] = max(l[i], l[i + 1])
for i in range(n - 1, -1, -1):
for j in range(i + 2, n):
ans1 = l[i] + min(dp[i + 2][j... | false | 28 | [
"-import sys",
"-",
"-",
"-def f(l, beg, end):",
"- if beg == end:",
"- dp[beg][end] = l[beg]",
"- return l[beg]",
"- if beg + 1 == end:",
"- dp[beg][end] = max(l[beg], l[end])",
"- return max(l[beg], l[end])",
"- if dp[beg][end] != -1:",
"- return d... | false | 0.037351 | 0.042041 | 0.88844 | [
"s709533285",
"s089739370"
] |
u489959379 | p03240 | python | s363668762 | s974436067 | 566 | 231 | 3,064 | 9,164 | Accepted | Accepted | 59.19 | n = int(eval(input()))
query = []
query0 = []
for i in range(n):
x, y, h = list(map(int, input().split()))
if h > 0:
query.append([x, y, h])
else:
query0.append([x, y, h])
for cx in range(101):
for cy in range(101):
res = []
for i in range(len(query)):
... | import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n = int(eval(input()))
XYH = [list(map(int, input().split())) for _ in range(n)]
info = []
for x, y, h in XYH:
if h == 0:
continue
in... | 29 | 37 | 756 | 811 | n = int(eval(input()))
query = []
query0 = []
for i in range(n):
x, y, h = list(map(int, input().split()))
if h > 0:
query.append([x, y, h])
else:
query0.append([x, y, h])
for cx in range(101):
for cy in range(101):
res = []
for i in range(len(query)):
x, y, h... | import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
n = int(eval(input()))
XYH = [list(map(int, input().split())) for _ in range(n)]
info = []
for x, y, h in XYH:
if h == 0:
continue
info.append([x, y, h])
... | false | 21.621622 | [
"-n = int(eval(input()))",
"-query = []",
"-query0 = []",
"-for i in range(n):",
"- x, y, h = list(map(int, input().split()))",
"- if h > 0:",
"- query.append([x, y, h])",
"- else:",
"- query0.append([x, y, h])",
"-for cx in range(101):",
"- for cy in range(101):",
"-... | false | 0.11014 | 0.057266 | 1.923315 | [
"s363668762",
"s974436067"
] |
u691018832 | p02676 | python | s866439460 | s692601109 | 64 | 23 | 61,616 | 9,240 | Accepted | Accepted | 64.06 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
k = int(readline())
s = readline().rstrip().decode()
if len(s) <= k:
print(s)
else:
print((s[:k] + '...'))
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
k = int(readline())
s = read().rstrip().decode()
if len(s) <= k:
print(s)
else:
print((s[:k] + '...'))
| 12 | 12 | 272 | 268 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
k = int(readline())
s = readline().rstrip().decode()
if len(s) <= k:
print(s)
else:
print((s[:k] + "..."))
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
k = int(readline())
s = read().rstrip().decode()
if len(s) <= k:
print(s)
else:
print((s[:k] + "..."))
| false | 0 | [
"-s = readline().rstrip().decode()",
"+s = read().rstrip().decode()"
] | false | 0.038602 | 0.034922 | 1.105372 | [
"s866439460",
"s692601109"
] |
u753803401 | p02912 | python | s444141015 | s156858195 | 614 | 413 | 88,576 | 69,160 | Accepted | Accepted | 32.74 | def slove():
import sys
import heapq
input = sys.stdin.readline
n, m = list(map(int, input().rstrip('\n').split()))
a = list(map(int, input().rstrip('\n').split()))
for i in range(len(a)):
a[i] = a[i] * - 1
heapq.heapify(a)
for i in range(m):
p = heapq.heappop(a... | def slove():
import sys
import heapq
input = sys.stdin.readline
n, m = list(map(int, input().rstrip('\n').split()))
a = [- i for i in list(map(int, input().rstrip('\n').split()))]
heapq.heapify(a)
for i in range(m):
heapq.heappush(a, -(-heapq.heappop(a) // 2))
print((-su... | 21 | 14 | 492 | 370 | def slove():
import sys
import heapq
input = sys.stdin.readline
n, m = list(map(int, input().rstrip("\n").split()))
a = list(map(int, input().rstrip("\n").split()))
for i in range(len(a)):
a[i] = a[i] * -1
heapq.heapify(a)
for i in range(m):
p = heapq.heappop(a)
... | def slove():
import sys
import heapq
input = sys.stdin.readline
n, m = list(map(int, input().rstrip("\n").split()))
a = [-i for i in list(map(int, input().rstrip("\n").split()))]
heapq.heapify(a)
for i in range(m):
heapq.heappush(a, -(-heapq.heappop(a) // 2))
print((-sum(a)))
... | false | 33.333333 | [
"- a = list(map(int, input().rstrip(\"\\n\").split()))",
"- for i in range(len(a)):",
"- a[i] = a[i] * -1",
"+ a = [-i for i in list(map(int, input().rstrip(\"\\n\").split()))]",
"- p = heapq.heappop(a)",
"- p /= 2",
"- heapq.heappush(a, p)",
"- t = 0",
"- ... | false | 0.046349 | 0.106512 | 0.435151 | [
"s444141015",
"s156858195"
] |
u634046173 | p03612 | python | s760818582 | s369783582 | 284 | 85 | 83,836 | 83,968 | Accepted | Accepted | 70.07 | N = int(eval(input()))
P = list(map(int, input().split()))
c = 0
for i in range(N):
if P[i] == i+1:
if i != N - 1:
t = P[i]
P[i] = P[i+1]
P[i+1] = t
c += 1
else:
t = P[i]
P[i] = P[i-1]
P[i-1] = t
... | N = int(eval(input()))
P = list(map(int, input().split()))
c = 0
for i in range(N):
f = 1
if P[i] == i+1:
if i != N - 1:
if P[i+1] != i+1:
t = P[i]
P[i] = P[i+1]
P[i+1] = t
c += 1
else:
if P[i-1]... | 16 | 19 | 336 | 442 | N = int(eval(input()))
P = list(map(int, input().split()))
c = 0
for i in range(N):
if P[i] == i + 1:
if i != N - 1:
t = P[i]
P[i] = P[i + 1]
P[i + 1] = t
c += 1
else:
t = P[i]
P[i] = P[i - 1]
P[i - 1] = t
... | N = int(eval(input()))
P = list(map(int, input().split()))
c = 0
for i in range(N):
f = 1
if P[i] == i + 1:
if i != N - 1:
if P[i + 1] != i + 1:
t = P[i]
P[i] = P[i + 1]
P[i + 1] = t
c += 1
else:
if P[i - 1] ... | false | 15.789474 | [
"+ f = 1",
"- t = P[i]",
"- P[i] = P[i + 1]",
"- P[i + 1] = t",
"- c += 1",
"+ if P[i + 1] != i + 1:",
"+ t = P[i]",
"+ P[i] = P[i + 1]",
"+ P[i + 1] = t",
"+ c += 1",
"- ... | false | 0.089217 | 0.046281 | 1.927723 | [
"s760818582",
"s369783582"
] |
u200887663 | p02861 | python | s353150737 | s560219867 | 412 | 265 | 7,972 | 9,160 | Accepted | Accepted | 35.68 | n=int(eval(input()))
distance=[list(map(int,input().split())) for i in range(n)]
import itertools
import math
temp=[i for i in range(n)]
perm=list(itertools.permutations(temp))
sm=0
count=0
for route in perm:
count+=1
temp_dis=0
route_list=list(route)
for i in range(1,n):
j=rout... | import math
import itertools
n = int(eval(input()))
#n, m = map(int, input().split())
#hl = list(map(int, input().split()))
l = [list(map(int, input().split())) for i in range(n)]
total = 0
townnum = [i for i in range(n)]
for v in itertools.permutations(townnum):
for j in range(1, n):
cur = l[v[j]... | 21 | 15 | 512 | 467 | n = int(eval(input()))
distance = [list(map(int, input().split())) for i in range(n)]
import itertools
import math
temp = [i for i in range(n)]
perm = list(itertools.permutations(temp))
sm = 0
count = 0
for route in perm:
count += 1
temp_dis = 0
route_list = list(route)
for i in range(1, n):
j ... | import math
import itertools
n = int(eval(input()))
# n, m = map(int, input().split())
# hl = list(map(int, input().split()))
l = [list(map(int, input().split())) for i in range(n)]
total = 0
townnum = [i for i in range(n)]
for v in itertools.permutations(townnum):
for j in range(1, n):
cur = l[v[j]]
... | false | 28.571429 | [
"+import math",
"+import itertools",
"+",
"-distance = [list(map(int, input().split())) for i in range(n)]",
"-import itertools",
"-import math",
"-",
"-temp = [i for i in range(n)]",
"-perm = list(itertools.permutations(temp))",
"-sm = 0",
"-count = 0",
"-for route in perm:",
"- count +=... | false | 0.044662 | 0.042984 | 1.03902 | [
"s353150737",
"s560219867"
] |
u254871849 | p02972 | python | s517431164 | s582107751 | 304 | 224 | 8,336 | 13,220 | Accepted | Accepted | 26.32 | # 2019-11-15 14:12:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# from scipy.misc import c... | import sys
n, *a = map(int, sys.stdin.read().split())
a = [None] + a
def main():
res = [0] * (n + 1)
chosen = []
for i in range(n, 0, -1):
tmp = sum(res[i*2:n+1:i]) & 1
if tmp ^ a[i]:
res[i] = 1
chosen.append(i)
if chosen:
m = len(chosen)... | 30 | 24 | 778 | 482 | # 2019-11-15 14:12:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# from scipy.misc import comb # flo... | import sys
n, *a = map(int, sys.stdin.read().split())
a = [None] + a
def main():
res = [0] * (n + 1)
chosen = []
for i in range(n, 0, -1):
tmp = sum(res[i * 2 : n + 1 : i]) & 1
if tmp ^ a[i]:
res[i] = 1
chosen.append(i)
if chosen:
m = len(chosen)
... | false | 20 | [
"-# 2019-11-15 14:12:24(JST)",
"-# import collections",
"-# import math",
"-# from string import ascii_lowercase, ascii_uppercase, digits",
"-# from bisect import bisect_left as bi_l, bisect_right as bi_r",
"-# import itertools",
"-# from functools import reduce",
"-# import operator as op",
"-# imp... | false | 0.036631 | 0.218906 | 0.167337 | [
"s517431164",
"s582107751"
] |
u276204978 | p03821 | python | s951428501 | s085578192 | 926 | 773 | 14,072 | 14,168 | Accepted | Accepted | 16.52 | import numpy as np
N = int(eval(input()))
A = np.zeros(N).astype(int)
B = np.zeros(N).astype(int)
for i in range(N):
A[i], B[i] = list(map(int, input().split()))
ans = 0
for i in reversed(list(range(N))):
A[i] = A[i] + ans
if A[i] % B[i] == 0:
continue
elif B[i] - A[i] > 0:
... | import numpy as np
N = int(eval(input()))
A = np.zeros(N).astype(int)
B = np.zeros(N).astype(int)
for i in range(N):
A[i], B[i] = list(map(int, input().split()))
ans = 0
for i in reversed(list(range(N))):
A[i] = A[i] + ans
if A[i] % B[i] == 0:
continue
else:
ans += B[i]... | 20 | 18 | 391 | 336 | import numpy as np
N = int(eval(input()))
A = np.zeros(N).astype(int)
B = np.zeros(N).astype(int)
for i in range(N):
A[i], B[i] = list(map(int, input().split()))
ans = 0
for i in reversed(list(range(N))):
A[i] = A[i] + ans
if A[i] % B[i] == 0:
continue
elif B[i] - A[i] > 0:
ans += B[i] ... | import numpy as np
N = int(eval(input()))
A = np.zeros(N).astype(int)
B = np.zeros(N).astype(int)
for i in range(N):
A[i], B[i] = list(map(int, input().split()))
ans = 0
for i in reversed(list(range(N))):
A[i] = A[i] + ans
if A[i] % B[i] == 0:
continue
else:
ans += B[i] - (A[i] % B[i])
... | false | 10 | [
"- elif B[i] - A[i] > 0:",
"- ans += B[i] - A[i]"
] | false | 0.57466 | 0.272453 | 2.10921 | [
"s951428501",
"s085578192"
] |
u163783894 | p02621 | python | s202437641 | s827114826 | 1,104 | 698 | 12,692 | 9,044 | Accepted | Accepted | 36.78 | N = 10**7
M = 10**5
arr = list(range(M))
for i in range(N):
t = arr[i % M]
# 答え
a = int(eval(input()))
print((a + a**2 + a**3))
| N = 10**7
arr = [0]
for i in range(N):
t = arr[0]
# 答え
a = int(eval(input()))
print((a + a**2 + a**3))
| 10 | 9 | 135 | 109 | N = 10**7
M = 10**5
arr = list(range(M))
for i in range(N):
t = arr[i % M]
# 答え
a = int(eval(input()))
print((a + a**2 + a**3))
| N = 10**7
arr = [0]
for i in range(N):
t = arr[0]
# 答え
a = int(eval(input()))
print((a + a**2 + a**3))
| false | 10 | [
"-M = 10**5",
"-arr = list(range(M))",
"+arr = [0]",
"- t = arr[i % M]",
"+ t = arr[0]"
] | false | 1.651937 | 1.480967 | 1.115445 | [
"s202437641",
"s827114826"
] |
u622045059 | p03545 | python | s869188142 | s729608277 | 171 | 38 | 38,384 | 5,300 | Accepted | Accepted | 77.78 | ABCD = eval(input())
ops = ['+', '-']
for i in range(2**3):
ans = int(ABCD[0])
op = []
for j in range(3):
if ops[i % 2] == '+':
ans += int(ABCD[j+1])
else:
ans -= int(ABCD[j+1])
op.append(ops[i%2])
i //= 2
if ans == 7:
... | import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def... | 22 | 48 | 422 | 1,690 | ABCD = eval(input())
ops = ["+", "-"]
for i in range(2**3):
ans = int(ABCD[0])
op = []
for j in range(3):
if ops[i % 2] == "+":
ans += int(ABCD[j + 1])
else:
ans -= int(ABCD[j + 1])
op.append(ops[i % 2])
i //= 2
if ans == 7:
print((ABCD[0] ... | import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7
def gcd(a, b):
return fractions.gcd(a, b) # 最大公約数
def lcm(a, b):
return (a * b) // fractions.gcd(a, b)... | false | 54.166667 | [
"+import math",
"+import fractions",
"+import bisect",
"+import collections",
"+import itertools",
"+import heapq",
"+import string",
"+import sys",
"+import copy",
"+from collections import deque",
"+",
"+sys.setrecursionlimit(10**7)",
"+MOD = 10**9 + 7",
"+",
"+",
"+def gcd(a, b):",
... | false | 0.059017 | 0.053359 | 1.106032 | [
"s869188142",
"s729608277"
] |
u530383736 | p03814 | python | s380980947 | s268013678 | 60 | 38 | 3,516 | 3,516 | Accepted | Accepted | 36.67 | # -*- coding: utf-8 -*-
s = input().strip()
#----------
loc_A=len(s)+1
loc_Z=-1
for i in range(len(s)):
if s[i] == "Z" and loc_Z < i:
loc_Z = i
elif s[i] == "A" and i < loc_A:
loc_A = i
print(( loc_Z - (loc_A - 1) ))
| # -*- coding: utf-8 -*-
s=input().strip()
for i,word in enumerate(s):
if word == "A":
start = i
break
for i,word in enumerate( reversed(s) ):
if word == "Z":
end = len(s)-1-i
break
print(( end-start+1 ))
| 14 | 15 | 255 | 260 | # -*- coding: utf-8 -*-
s = input().strip()
# ----------
loc_A = len(s) + 1
loc_Z = -1
for i in range(len(s)):
if s[i] == "Z" and loc_Z < i:
loc_Z = i
elif s[i] == "A" and i < loc_A:
loc_A = i
print((loc_Z - (loc_A - 1)))
| # -*- coding: utf-8 -*-
s = input().strip()
for i, word in enumerate(s):
if word == "A":
start = i
break
for i, word in enumerate(reversed(s)):
if word == "Z":
end = len(s) - 1 - i
break
print((end - start + 1))
| false | 6.666667 | [
"-loc_A = len(s) + 1",
"-loc_Z = -1",
"-for i in range(len(s)):",
"- if s[i] == \"Z\" and loc_Z < i:",
"- loc_Z = i",
"- elif s[i] == \"A\" and i < loc_A:",
"- loc_A = i",
"-print((loc_Z - (loc_A - 1)))",
"+for i, word in enumerate(s):",
"+ if word == \"A\":",
"+ st... | false | 0.111706 | 0.04547 | 2.456689 | [
"s380980947",
"s268013678"
] |
u723345499 | p02641 | python | s669488487 | s470970201 | 22 | 20 | 9,060 | 9,200 | Accepted | Accepted | 9.09 | x, n = list(map(int, input().split()))
p = list(map(int, input().split()))
for i in range(200):
if x - i not in p:
print((x - i))
break
if x + i not in p:
print((x + i))
break | x, n = list(map(int, input().split()))
p = list(map(int, input().split()))
for i in range(101):
if x - i not in p:
print((x - i))
break
if x + i not in p:
print((x + i))
break | 11 | 11 | 217 | 217 | x, n = list(map(int, input().split()))
p = list(map(int, input().split()))
for i in range(200):
if x - i not in p:
print((x - i))
break
if x + i not in p:
print((x + i))
break
| x, n = list(map(int, input().split()))
p = list(map(int, input().split()))
for i in range(101):
if x - i not in p:
print((x - i))
break
if x + i not in p:
print((x + i))
break
| false | 0 | [
"-for i in range(200):",
"+for i in range(101):"
] | false | 0.032701 | 0.041583 | 0.786399 | [
"s669488487",
"s470970201"
] |
u673361376 | p03401 | python | s845595727 | s746641011 | 226 | 188 | 14,048 | 13,920 | Accepted | Accepted | 16.81 | n = int(eval(input()))
alist = [0] + list(map(int, input().split()))
total = 0
for i in range(n):total += abs(alist[i]-alist[i+1])
total += abs(alist[-1])
for i in range(1,n):
print((total-abs(alist[i]-alist[i-1])-abs(alist[i+1]-alist[i])+ abs(alist[i+1]-alist[i-1])))
print((total-abs(alist[-1]-alist[-2])-ab... | N = int(eval(input()))
A = [0] + list(map(int, input().split())) + [0]
costs = [0] + [abs(A[i] - A[i+1]) for i in range(N+1)]
sum_costs = sum(costs)
for i in range(1, N+1):
print((sum_costs - costs[i] - costs[i+1] + abs(A[i-1] - A[i+1])))
| 9 | 7 | 357 | 242 | n = int(eval(input()))
alist = [0] + list(map(int, input().split()))
total = 0
for i in range(n):
total += abs(alist[i] - alist[i + 1])
total += abs(alist[-1])
for i in range(1, n):
print(
(
total
- abs(alist[i] - alist[i - 1])
- abs(alist[i + 1] - alist[i])
... | N = int(eval(input()))
A = [0] + list(map(int, input().split())) + [0]
costs = [0] + [abs(A[i] - A[i + 1]) for i in range(N + 1)]
sum_costs = sum(costs)
for i in range(1, N + 1):
print((sum_costs - costs[i] - costs[i + 1] + abs(A[i - 1] - A[i + 1])))
| false | 22.222222 | [
"-n = int(eval(input()))",
"-alist = [0] + list(map(int, input().split()))",
"-total = 0",
"-for i in range(n):",
"- total += abs(alist[i] - alist[i + 1])",
"-total += abs(alist[-1])",
"-for i in range(1, n):",
"- print(",
"- (",
"- total",
"- - abs(alist[i] - ... | false | 0.04012 | 0.060159 | 0.666887 | [
"s845595727",
"s746641011"
] |
u965346773 | p03262 | python | s233643613 | s205516169 | 344 | 120 | 14,444 | 16,280 | Accepted | Accepted | 65.12 | N, X = list(map(int,input().split()))
x = list([abs(int(y)-X) for y in input().split()])
m = min(x)
def prim(y):
p=[]
while y>1:
for i in range(2,y+1):
if y%i==0:
y//=i
p.append(i)
break
return p
ans=1
for i in prim(m)... | import fractions
N, X = list(map(int,input().split()))
x = list([abs(int(y)-X) for y in input().split()])
m = min(x)
ans = x[0]
for i in range(1,N):
ans = fractions.gcd(ans,x[i])
print(ans) | 27 | 10 | 557 | 206 | N, X = list(map(int, input().split()))
x = list([abs(int(y) - X) for y in input().split()])
m = min(x)
def prim(y):
p = []
while y > 1:
for i in range(2, y + 1):
if y % i == 0:
y //= i
p.append(i)
break
return p
ans = 1
for i in prim(m)... | import fractions
N, X = list(map(int, input().split()))
x = list([abs(int(y) - X) for y in input().split()])
m = min(x)
ans = x[0]
for i in range(1, N):
ans = fractions.gcd(ans, x[i])
print(ans)
| false | 62.962963 | [
"+import fractions",
"+",
"-",
"-",
"-def prim(y):",
"- p = []",
"- while y > 1:",
"- for i in range(2, y + 1):",
"- if y % i == 0:",
"- y //= i",
"- p.append(i)",
"- break",
"- return p",
"-",
"-",
"-ans = 1",
"... | false | 0.057479 | 0.046246 | 1.242909 | [
"s233643613",
"s205516169"
] |
u145035045 | p03312 | python | s839146608 | s037020713 | 1,724 | 1,437 | 26,996 | 26,996 | Accepted | Accepted | 16.65 | from bisect import bisect_left as bl
from itertools import accumulate
INF = 10 ** 20
def get_score(acc, head, end):
sec_head = acc[head - 1]
sec_end = acc[end]
sec_sum = sec_end - sec_head
cut = bl(acc, sec_head + sec_sum // 2) - 1
score = INF
reta, retb = None, None
for i in range(cut - 2, cu... | from bisect import bisect_left as bl
from itertools import accumulate
INF = 10 ** 20
def get_score(acc, head, end):
sec_head = acc[head - 1]
sec_end = acc[end]
sec_sum = sec_end - sec_head
cut = bl(acc, sec_head + sec_sum // 2) - 1
score = INF
reta, retb = None, None
for i in range(cut - 1, cu... | 31 | 31 | 800 | 800 | from bisect import bisect_left as bl
from itertools import accumulate
INF = 10**20
def get_score(acc, head, end):
sec_head = acc[head - 1]
sec_end = acc[end]
sec_sum = sec_end - sec_head
cut = bl(acc, sec_head + sec_sum // 2) - 1
score = INF
reta, retb = None, None
for i in range(cut - 2,... | from bisect import bisect_left as bl
from itertools import accumulate
INF = 10**20
def get_score(acc, head, end):
sec_head = acc[head - 1]
sec_end = acc[end]
sec_sum = sec_end - sec_head
cut = bl(acc, sec_head + sec_sum // 2) - 1
score = INF
reta, retb = None, None
for i in range(cut - 1,... | false | 0 | [
"- for i in range(cut - 2, cut + 3):",
"+ for i in range(cut - 1, cut + 2):"
] | false | 0.037546 | 0.037309 | 1.006344 | [
"s839146608",
"s037020713"
] |
u562935282 | p03053 | python | s893379096 | s462829813 | 687 | 590 | 135,900 | 89,180 | Accepted | Accepted | 14.12 | from collections import deque
H, W = list(map(int, input().split()))
a = [eval(input()) for _ in range(H)]
bl = [[False] * W for _ in range(H)]
dq = deque()
for r in range(H):
for c in range(W):
if a[r][c] == '#':
bl[r][c] = True
dq.append((r, c, 0))
def in_range(... | import sys
input = sys.stdin.readline
from collections import deque
H, W = list(map(int, input().split()))
a = [eval(input()) for _ in range(H)]
dist = [[-1] * W for _ in range(H)]
dq = deque()
for r in range(H):
for c in range(W):
if a[r][c] == '#':
dist[r][c] = 0
... | 33 | 39 | 671 | 738 | from collections import deque
H, W = list(map(int, input().split()))
a = [eval(input()) for _ in range(H)]
bl = [[False] * W for _ in range(H)]
dq = deque()
for r in range(H):
for c in range(W):
if a[r][c] == "#":
bl[r][c] = True
dq.append((r, c, 0))
def in_range(r, c):
return... | import sys
input = sys.stdin.readline
from collections import deque
H, W = list(map(int, input().split()))
a = [eval(input()) for _ in range(H)]
dist = [[-1] * W for _ in range(H)]
dq = deque()
for r in range(H):
for c in range(W):
if a[r][c] == "#":
dist[r][c] = 0
dq.append((r, c)... | false | 15.384615 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"-bl = [[False] * W for _ in range(H)]",
"+dist = [[-1] * W for _ in range(H)]",
"- bl[r][c] = True",
"- dq.append((r, c, 0))",
"+ dist[r][c] = 0",
"+ dq.append((r, c))",
"+d = 0",
"- r, c, d = dq.p... | false | 0.040956 | 0.041853 | 0.978574 | [
"s893379096",
"s462829813"
] |
u155687575 | p03565 | python | s984184428 | s309633922 | 168 | 17 | 38,768 | 3,064 | Accepted | Accepted | 89.88 | s_ = eval(input())
t = eval(input())
exit_flag = True
for i in range(len(s_) - len(t) + 1):
flag = True
for j in range(len(t)):
if (s_[i+j] != '?') and (s_[i+j] != t[j]):
flag = False
if flag:
h = ''
for index in range(len(s_)):
if (i <= ind... | # C
sd = eval(input())
scnt = len(sd)
t = eval(input())
tcnt = len(t)
point = 0
unrestorable = True
while point <= scnt - tcnt:
oneroopcorres = True
for i in range(tcnt):
anyone = sd[point+i] == '?'
correspond = sd[point+i] == t[i]
if not (anyone or correspond):
... | 25 | 33 | 536 | 641 | s_ = eval(input())
t = eval(input())
exit_flag = True
for i in range(len(s_) - len(t) + 1):
flag = True
for j in range(len(t)):
if (s_[i + j] != "?") and (s_[i + j] != t[j]):
flag = False
if flag:
h = ""
for index in range(len(s_)):
if i <= index <= i + len(t)... | # C
sd = eval(input())
scnt = len(sd)
t = eval(input())
tcnt = len(t)
point = 0
unrestorable = True
while point <= scnt - tcnt:
oneroopcorres = True
for i in range(tcnt):
anyone = sd[point + i] == "?"
correspond = sd[point + i] == t[i]
if not (anyone or correspond):
oneroopco... | false | 24.242424 | [
"-s_ = eval(input())",
"+# C",
"+sd = eval(input())",
"+scnt = len(sd)",
"-exit_flag = True",
"-for i in range(len(s_) - len(t) + 1):",
"- flag = True",
"- for j in range(len(t)):",
"- if (s_[i + j] != \"?\") and (s_[i + j] != t[j]):",
"- flag = False",
"- if flag:",
... | false | 0.043612 | 0.039105 | 1.115253 | [
"s984184428",
"s309633922"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.