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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u112364985 | p02831 | python | s719112744 | s594839515 | 268 | 26 | 64,108 | 9,160 | Accepted | Accepted | 90.3 | import fractions
a,b = list(map(int,input().split()))
def lcm(x, y):
return (x * y) // fractions.gcd(x, y)
print((lcm(a, b))) | import math
a,b = list(map(int,input().split()))
def lcm(x, y):
return (x * y) // math.gcd(x, y)
print((lcm(a, b))) | 6 | 6 | 127 | 118 | import fractions
a, b = list(map(int, input().split()))
def lcm(x, y):
return (x * y) // fractions.gcd(x, y)
print((lcm(a, b)))
| import math
a, b = list(map(int, input().split()))
def lcm(x, y):
return (x * y) // math.gcd(x, y)
print((lcm(a, b)))
| false | 0 | [
"-import fractions",
"+import math",
"- return (x * y) // fractions.gcd(x, y)",
"+ return (x * y) // math.gcd(x, y)"
] | false | 0.061847 | 0.106112 | 0.582849 | [
"s719112744",
"s594839515"
] |
u991567869 | p02598 | python | s212447617 | s685529261 | 1,420 | 1,145 | 30,700 | 31,036 | Accepted | Accepted | 19.37 | n, k = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))[::-1]
l = 0
r = a[0] + 1
ref = 0
ans = a[0]
while r - l > 1:
now = (l + r)//2
for i in a:
ref += 0 - -i//now - 1
if ref > k:
ref = 0
l = now
break
else:
... | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
l = 0
r = 10**9 + 1
ref = 0
ans = 10**9
while r - l > 1:
now = (l + r)//2
for i in a:
ref += 0 - -i//now - 1
if ref > k:
ref = 0
l = now
break
else:
ans =... | 21 | 21 | 386 | 364 | n, k = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))[::-1]
l = 0
r = a[0] + 1
ref = 0
ans = a[0]
while r - l > 1:
now = (l + r) // 2
for i in a:
ref += 0 - -i // now - 1
if ref > k:
ref = 0
l = now
break
else:
ans = mi... | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
l = 0
r = 10**9 + 1
ref = 0
ans = 10**9
while r - l > 1:
now = (l + r) // 2
for i in a:
ref += 0 - -i // now - 1
if ref > k:
ref = 0
l = now
break
else:
ans = now
re... | false | 0 | [
"-a = sorted(list(map(int, input().split())))[::-1]",
"+a = list(map(int, input().split()))",
"-r = a[0] + 1",
"+r = 10**9 + 1",
"-ans = a[0]",
"+ans = 10**9",
"- ans = min(ans, now)",
"+ ans = now"
] | false | 0.037118 | 0.042107 | 0.881498 | [
"s212447617",
"s685529261"
] |
u340781749 | p02890 | python | s494549272 | s648252609 | 1,894 | 359 | 39,256 | 39,248 | Accepted | Accepted | 81.05 | from collections import Counter
from itertools import groupby
def bin_search(k, greater_count, smaller_sum):
l = 0
r = n + 1
while l < r - 1:
m = (l + r) // 2
gc = greater_count[m]
ss = smaller_sum[m]
if gc + ss // m >= k:
l = m
else:
... | from collections import Counter
from itertools import groupby, accumulate
n = int(eval(input()))
aaa = list(map(int, input().split()))
cnt = sorted(Counter(aaa).values())
remain = len(cnt)
total = 0
kkk = [0] * (n + 1)
p = 1
for c, itr in groupby(cnt):
l = len(list(itr))
for i in range(p, c + 1... | 49 | 28 | 1,136 | 560 | from collections import Counter
from itertools import groupby
def bin_search(k, greater_count, smaller_sum):
l = 0
r = n + 1
while l < r - 1:
m = (l + r) // 2
gc = greater_count[m]
ss = smaller_sum[m]
if gc + ss // m >= k:
l = m
else:
r = m
... | from collections import Counter
from itertools import groupby, accumulate
n = int(eval(input()))
aaa = list(map(int, input().split()))
cnt = sorted(Counter(aaa).values())
remain = len(cnt)
total = 0
kkk = [0] * (n + 1)
p = 1
for c, itr in groupby(cnt):
l = len(list(itr))
for i in range(p, c + 1):
kkk[r... | false | 42.857143 | [
"-from itertools import groupby",
"-",
"-",
"-def bin_search(k, greater_count, smaller_sum):",
"- l = 0",
"- r = n + 1",
"- while l < r - 1:",
"- m = (l + r) // 2",
"- gc = greater_count[m]",
"- ss = smaller_sum[m]",
"- if gc + ss // m >= k:",
"- ... | false | 0.047495 | 0.038961 | 1.219048 | [
"s494549272",
"s648252609"
] |
u587482466 | p03078 | python | s266398102 | s769623001 | 1,761 | 701 | 113,504 | 98,496 | Accepted | Accepted | 60.19 | # -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache
# 1整数
# n = int(input())
# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools... | # -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache
# 1整数
# n = int(input())
# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools... | 53 | 55 | 1,005 | 972 | # -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache
# 1整数
# n = int(input())
# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools import lru_cache... | # -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache
# 1整数
# n = int(input())
# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools import lru_cache... | false | 3.636364 | [
"-x, y, z, kk = list(map(int, input().split()))",
"+x, y, z, k = list(map(int, input().split()))",
"-a.sort(reverse=True)",
"-b.sort(reverse=True)",
"+ll = [0] * 1000001",
"+count = 0",
"+for i in a:",
"+ for j in b:",
"+ ll[count] = i + j",
"+ count += 1",
"+ll.sort(reverse=Tru... | false | 0.0416 | 0.239888 | 0.173416 | [
"s266398102",
"s769623001"
] |
u609061751 | p02852 | python | s848548268 | s185804902 | 223 | 134 | 50,928 | 6,408 | Accepted | Accepted | 39.91 | import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().split()]
s = input().rstrip()
s_rev = s[::-1]
place = 0
ans = []
while place < n:
flag = 1
for i in range(min(m, n - place), 0, -1):
if s_rev[place + i] == "0":
ans.append(i)
place += i
... | import sys
input = lambda: sys.stdin.readline().rstrip()
n, m = list(map(int, input().split()))
s = eval(input())
ans = []
s = s[::-1]
now = 0
while True:
for i in range(m, -1, -1):
if i == 0:
print((-1))
sys.exit()
if now + i <= n and s[now + i] == "0":
... | 24 | 23 | 431 | 496 | import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().split()]
s = input().rstrip()
s_rev = s[::-1]
place = 0
ans = []
while place < n:
flag = 1
for i in range(min(m, n - place), 0, -1):
if s_rev[place + i] == "0":
ans.append(i)
place += i
flag = 0
... | import sys
input = lambda: sys.stdin.readline().rstrip()
n, m = list(map(int, input().split()))
s = eval(input())
ans = []
s = s[::-1]
now = 0
while True:
for i in range(m, -1, -1):
if i == 0:
print((-1))
sys.exit()
if now + i <= n and s[now + i] == "0":
now += i... | false | 4.166667 | [
"-input = sys.stdin.readline",
"-n, m = [int(x) for x in input().split()]",
"-s = input().rstrip()",
"-s_rev = s[::-1]",
"-place = 0",
"+input = lambda: sys.stdin.readline().rstrip()",
"+n, m = list(map(int, input().split()))",
"+s = eval(input())",
"-while place < n:",
"- flag = 1",
"- fo... | false | 0.033372 | 0.035531 | 0.939221 | [
"s848548268",
"s185804902"
] |
u294721290 | p03814 | python | s990911150 | s395175515 | 100 | 18 | 3,500 | 3,500 | Accepted | Accepted | 82 | S = eval(input())
a = len(S)
z = 0
for i in range(len(S)):
if S[i] == 'A':
a = min(a,i)
if S[i] == 'Z':
z = max(z,i)
print((z-a+1)) | s = eval(input())
print((s.rfind('Z')-s.find('A')+1)) | 9 | 2 | 155 | 46 | S = eval(input())
a = len(S)
z = 0
for i in range(len(S)):
if S[i] == "A":
a = min(a, i)
if S[i] == "Z":
z = max(z, i)
print((z - a + 1))
| s = eval(input())
print((s.rfind("Z") - s.find("A") + 1))
| false | 77.777778 | [
"-S = eval(input())",
"-a = len(S)",
"-z = 0",
"-for i in range(len(S)):",
"- if S[i] == \"A\":",
"- a = min(a, i)",
"- if S[i] == \"Z\":",
"- z = max(z, i)",
"-print((z - a + 1))",
"+s = eval(input())",
"+print((s.rfind(\"Z\") - s.find(\"A\") + 1))"
] | false | 0.072187 | 0.046724 | 1.54498 | [
"s990911150",
"s395175515"
] |
u701531204 | p02813 | python | s645894816 | s801019786 | 43 | 28 | 8,052 | 8,052 | Accepted | Accepted | 34.88 | #!/usr/bin/env python3
import sys
import itertools
import bisect
def solve(N: int, P: "List[int]", Q: "List[int]"):
nums = [i for i in range(1, N + 1)]
perm = list(itertools.permutations(nums, N))
perm.sort()
p_at = 0
for i, pr in enumerate(perm):
if pr == tuple(P):
... | #!/usr/bin/env python3
import sys
import itertools
import bisect
def solve(N: int, P: "List[int]", Q: "List[int]"):
nums = [i for i in range(1, N + 1)]
perm = list(itertools.permutations(nums, N))
print((abs(perm.index(tuple(P)) - perm.index(tuple(Q)))))
return
# Generated by 1.1.7.1 ... | 38 | 30 | 1,019 | 875 | #!/usr/bin/env python3
import sys
import itertools
import bisect
def solve(N: int, P: "List[int]", Q: "List[int]"):
nums = [i for i in range(1, N + 1)]
perm = list(itertools.permutations(nums, N))
perm.sort()
p_at = 0
for i, pr in enumerate(perm):
if pr == tuple(P):
p_at = i + ... | #!/usr/bin/env python3
import sys
import itertools
import bisect
def solve(N: int, P: "List[int]", Q: "List[int]"):
nums = [i for i in range(1, N + 1)]
perm = list(itertools.permutations(nums, N))
print((abs(perm.index(tuple(P)) - perm.index(tuple(Q)))))
return
# Generated by 1.1.7.1 https://github.... | false | 21.052632 | [
"- perm.sort()",
"- p_at = 0",
"- for i, pr in enumerate(perm):",
"- if pr == tuple(P):",
"- p_at = i + 1",
"- if pr == tuple(Q):",
"- q_at = i + 1",
"- print((abs(p_at - q_at)))",
"+ print((abs(perm.index(tuple(P)) - perm.index(tuple(Q)))))"
] | false | 0.044882 | 0.045327 | 0.990166 | [
"s645894816",
"s801019786"
] |
u726769307 | p03086 | python | s907106510 | s061411769 | 21 | 17 | 3,316 | 3,060 | Accepted | Accepted | 19.05 | import re
s=re.split("[^ACGT]", eval(input()))
a=[]
for i in range(len(s)):
a.append(len(s[i]))
print((max(a))) | s = eval(input())
count = 0
temp = 0
for i in range(len(s)):
if s[i] in "ACGT":
temp += 1
elif temp:
if count < temp:
count = temp
temp = 0
if count < temp:
count = temp
print(count) | 6 | 13 | 112 | 212 | import re
s = re.split("[^ACGT]", eval(input()))
a = []
for i in range(len(s)):
a.append(len(s[i]))
print((max(a)))
| s = eval(input())
count = 0
temp = 0
for i in range(len(s)):
if s[i] in "ACGT":
temp += 1
elif temp:
if count < temp:
count = temp
temp = 0
if count < temp:
count = temp
print(count)
| false | 53.846154 | [
"-import re",
"-",
"-s = re.split(\"[^ACGT]\", eval(input()))",
"-a = []",
"+s = eval(input())",
"+count = 0",
"+temp = 0",
"- a.append(len(s[i]))",
"-print((max(a)))",
"+ if s[i] in \"ACGT\":",
"+ temp += 1",
"+ elif temp:",
"+ if count < temp:",
"+ count... | false | 0.055596 | 0.048564 | 1.144802 | [
"s907106510",
"s061411769"
] |
u652569315 | p02802 | python | s945547507 | s481330536 | 315 | 194 | 4,596 | 10,100 | Accepted | Accepted | 38.41 | n,m=list(map(int,input().split()))
ac,wa,k,l=0,0,[0]*n,[0]*n
for _ in range(m):
p,s=input().split()
if k[int(p)-1]==0:
if s=='AC':
ac+=1
k[int(p)-1]=1
wa+= l[int(p)-1]
else:
l[int(p)-1]+=1
print((ac,wa)) | def main():
import sys
input = sys.stdin.readline
n,m=list(map(int,input().split()))
ac,wa,l=0,0,[0]*n
for _ in [0]*m:
p,s=input().split()
if type(l[int(p)-1])==int:
if s=='AC':
ac+=1
wa+= l[int(p)-1]
l[int(p)-1]=str(l[int(p)-1])
else:
l[int(p)-... | 12 | 18 | 242 | 379 | n, m = list(map(int, input().split()))
ac, wa, k, l = 0, 0, [0] * n, [0] * n
for _ in range(m):
p, s = input().split()
if k[int(p) - 1] == 0:
if s == "AC":
ac += 1
k[int(p) - 1] = 1
wa += l[int(p) - 1]
else:
l[int(p) - 1] += 1
print((ac, wa))
| def main():
import sys
input = sys.stdin.readline
n, m = list(map(int, input().split()))
ac, wa, l = 0, 0, [0] * n
for _ in [0] * m:
p, s = input().split()
if type(l[int(p) - 1]) == int:
if s == "AC":
ac += 1
wa += l[int(p) - 1]
... | false | 33.333333 | [
"-n, m = list(map(int, input().split()))",
"-ac, wa, k, l = 0, 0, [0] * n, [0] * n",
"-for _ in range(m):",
"- p, s = input().split()",
"- if k[int(p) - 1] == 0:",
"- if s == \"AC\":",
"- ac += 1",
"- k[int(p) - 1] = 1",
"- wa += l[int(p) - 1]",
"- ... | false | 0.038232 | 0.007571 | 5.049813 | [
"s945547507",
"s481330536"
] |
u263830634 | p03221 | python | s519817516 | s331144380 | 1,008 | 569 | 38,520 | 33,308 | Accepted | Accepted | 43.55 | N, M = map(int, input().split())
PY = [list(map(int, input().split())) + [i] for i in range(M)]
PY.sort(key = lambda x: x[1])
PY.sort(key = lambda x: x[0])
ans_lst = []
x = 1
tmp_p = None
for p, y, i in PY:
if p == tmp_p: #属している県が同じ時
ans_lst.append([p, x, i])
x += 1
else:
a... | import sys
input = sys.stdin.readline
N, M = map(int, input().split())
lst = [list(map(int, input().split())) + [i] for i in range(M)]
# print (lst)
lst.sort(key = lambda x: x[1]) #x番目が小さい順に並べる
lst.sort(key = lambda x: x[0])
ans = [0] * M
count = 0
tmp = 0 #1つ前の県の番号
for p, y, i in lst:
if tmp... | 27 | 29 | 627 | 503 | N, M = map(int, input().split())
PY = [list(map(int, input().split())) + [i] for i in range(M)]
PY.sort(key=lambda x: x[1])
PY.sort(key=lambda x: x[0])
ans_lst = []
x = 1
tmp_p = None
for p, y, i in PY:
if p == tmp_p: # 属している県が同じ時
ans_lst.append([p, x, i])
x += 1
else:
ans_lst.append([p... | import sys
input = sys.stdin.readline
N, M = map(int, input().split())
lst = [list(map(int, input().split())) + [i] for i in range(M)]
# print (lst)
lst.sort(key=lambda x: x[1]) # x番目が小さい順に並べる
lst.sort(key=lambda x: x[0])
ans = [0] * M
count = 0
tmp = 0 # 1つ前の県の番号
for p, y, i in lst:
if tmp == p:
count +... | false | 6.896552 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"-PY = [list(map(int, input().split())) + [i] for i in range(M)]",
"-PY.sort(key=lambda x: x[1])",
"-PY.sort(key=lambda x: x[0])",
"-ans_lst = []",
"-x = 1",
"-tmp_p = None",
"-for p, y, i in PY:",
"- if p == tmp_p: # 属している県が同じ時",
"- ... | false | 0.080658 | 0.085496 | 0.94341 | [
"s519817516",
"s331144380"
] |
u183284051 | p03039 | python | s463833617 | s648315177 | 1,331 | 1,035 | 124,036 | 122,120 | Accepted | Accepted | 22.24 | def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
g1.append( ( g1[-1] * i ) % mod )
inverse.ap... | def main():
def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
... | 22 | 25 | 573 | 722 | def cmb(n, r, mod):
if r < 0 or r > n:
return 0
r = min(r, n - r)
return g1[n] * g2[r] * g2[n - r] % mod
mod = 10**9 + 7 # 出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inverse = [0, 1] # 逆元テーブル計算用テーブル
for i in range(2, N + 1):
g1.append((g1[-1] * i) % mod)
inverse.append((-... | def main():
def cmb(n, r, mod):
if r < 0 or r > n:
return 0
r = min(r, n - r)
return g1[n] * g2[r] * g2[n - r] % mod
mod = 10**9 + 7 # 出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inverse = [0, 1] # 逆元テーブル計算用テーブル
for i in range(2, N + 1):
... | false | 12 | [
"-def cmb(n, r, mod):",
"- if r < 0 or r > n:",
"- return 0",
"- r = min(r, n - r)",
"- return g1[n] * g2[r] * g2[n - r] % mod",
"+def main():",
"+ def cmb(n, r, mod):",
"+ if r < 0 or r > n:",
"+ return 0",
"+ r = min(r, n - r)",
"+ return g1[n... | false | 1.567489 | 1.700059 | 0.92202 | [
"s463833617",
"s648315177"
] |
u966695411 | p04045 | python | s195578349 | s978230473 | 94 | 74 | 2,940 | 3,060 | Accepted | Accepted | 21.28 | def main():
N, L = list(map(int, input().split()))
D = input().split()
ans = N
while 1:
s = str(ans)
if not [1 for i in D if i in s] : break
ans += 1
print(ans)
if __name__ == '__main__':
main() | def main():
N, L = list(map(int, input().split()))
D = input().split()
ans = N
while 1:
s = str(ans)
f = 1
for i in D:
if i in s : f = 0
if f : break
ans += 1
print(ans)
if __name__ == '__main__':
main() | 11 | 14 | 246 | 286 | def main():
N, L = list(map(int, input().split()))
D = input().split()
ans = N
while 1:
s = str(ans)
if not [1 for i in D if i in s]:
break
ans += 1
print(ans)
if __name__ == "__main__":
main()
| def main():
N, L = list(map(int, input().split()))
D = input().split()
ans = N
while 1:
s = str(ans)
f = 1
for i in D:
if i in s:
f = 0
if f:
break
ans += 1
print(ans)
if __name__ == "__main__":
main()
| false | 21.428571 | [
"- if not [1 for i in D if i in s]:",
"+ f = 1",
"+ for i in D:",
"+ if i in s:",
"+ f = 0",
"+ if f:"
] | false | 0.119821 | 0.079711 | 1.503184 | [
"s195578349",
"s978230473"
] |
u485319545 | p02881 | python | s957760545 | s318989320 | 183 | 120 | 40,612 | 3,292 | Accepted | Accepted | 34.43 | N=int(eval(input()))
from itertools import combinations
import math
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
return divisors
d=make_divisors(N... | N=int(eval(input()))
from itertools import combinations
import math
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
return divisors
d=make_divisors(N... | 27 | 27 | 495 | 493 | N = int(eval(input()))
from itertools import combinations
import math
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
return divisors
d = make_divisors(N)
if ... | N = int(eval(input()))
from itertools import combinations
import math
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
return divisors
d = make_divisors(N)
if ... | false | 0 | [
"-if math.sqrt(N) ** 2 == N:",
"+if math.sqrt(N) in d:"
] | false | 0.044121 | 0.084396 | 0.522787 | [
"s957760545",
"s318989320"
] |
u131464432 | p02732 | python | s902770486 | s747005882 | 985 | 269 | 34,144 | 34,096 | Accepted | Accepted | 72.69 | import collections
import math
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(eval(input()))
A = list(map(int,input().split()))
B = collections.Counter(A)
num = 0
for i in set(A):
if B[i] > 1:
num += combinations_count(B[i], 2)
fo... | import collections
N = int(eval(input()))
A = list(map(int,input().split()))
B = collections.Counter(A)
num = 0
for i in set(A):
if B[i] > 1:
num += B[i]*(B[i] - 1)//2
for i in A:
print((num-B[i]+1)) | 13 | 10 | 346 | 216 | import collections
import math
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(eval(input()))
A = list(map(int, input().split()))
B = collections.Counter(A)
num = 0
for i in set(A):
if B[i] > 1:
num += combinations_count(B[i], 2)
for i in... | import collections
N = int(eval(input()))
A = list(map(int, input().split()))
B = collections.Counter(A)
num = 0
for i in set(A):
if B[i] > 1:
num += B[i] * (B[i] - 1) // 2
for i in A:
print((num - B[i] + 1))
| false | 23.076923 | [
"-import math",
"-",
"-",
"-def combinations_count(n, r):",
"- return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))",
"-",
"- num += combinations_count(B[i], 2)",
"+ num += B[i] * (B[i] - 1) // 2"
] | false | 0.037132 | 0.037308 | 0.995282 | [
"s902770486",
"s747005882"
] |
u961595602 | p03232 | python | s078148085 | s666426956 | 1,837 | 506 | 14,252 | 14,044 | Accepted | Accepted | 72.46 | # -*- coding: utf-8 -*-
from sys import stdin
from itertools import accumulate
s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()
MOD = 10**9 + 7
N = d_in()
A_list = ds_in()
def fa... | # -*- coding: utf-8 -*-
from sys import stdin
from itertools import accumulate
s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()
MOD = 10**9 + 7
N = d_in()
A_list = ds_in()
def fa... | 69 | 35 | 1,597 | 797 | # -*- coding: utf-8 -*-
from sys import stdin
from itertools import accumulate
s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()
MOD = 10**9 + 7
N = d_in()
A_list = ds_in()
def factorial(N):... | # -*- coding: utf-8 -*-
from sys import stdin
from itertools import accumulate
s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()
MOD = 10**9 + 7
N = d_in()
A_list = ds_in()
def factorial(N):... | false | 49.275362 | [
"-def recursive_square(n, m, p):",
"- \"\"\"n**p (mod m)\"\"\"",
"- if p == 0:",
"- return 1 % m",
"- if p % 2 == 0:",
"- root = recursive_square(n, m, p // 2) % m",
"- return (root**2) % m",
"- else:",
"- return ((n % m) * recursive_square(n, m, p - 1)) % m",... | false | 0.03668 | 0.067693 | 0.541854 | [
"s078148085",
"s666426956"
] |
u645250356 | p02793 | python | s846710990 | s189357936 | 1,894 | 969 | 6,176 | 6,184 | Accepted | Accepted | 48.84 | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.rea... | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
... | 21 | 22 | 545 | 565 | from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, pprint, fractions
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
mod2 = 998244353
INF = float("inf")
def inp():
return int(sys.stdin.readline())
def inpl():
return list(map(in... | from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, pprint, fractions
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")
def inp():
return int(sys.stdin.readline())
def inpl():
return list(map(int, sys.stdin.read... | false | 4.545455 | [
"-mod2 = 998244353",
"-a = inpl()",
"+aa = inpl()",
"+for a in aa:",
"+ g = a * g // fractions.gcd(a, g)",
"+g %= mod",
"-for i in a:",
"- g = i * g // fractions.gcd(i, g)",
"-for i in a:",
"- res += g // i",
"-print((res % mod))",
"+for a in aa:",
"+ res += g * pow(a, mod - 2, m... | false | 0.158583 | 0.049637 | 3.194862 | [
"s846710990",
"s189357936"
] |
u620868411 | p03715 | python | s694095816 | s184831838 | 483 | 206 | 3,064 | 9,168 | Accepted | Accepted | 57.35 | # -*- coding: utf-8 -*-
H,W = list(map(int, input().split()))
ret = 10**9
for h in range(1,H):
w = W//2
s1 = h*W
s2 = (H-h)*w
s3 = (H-h)*(W-w)
ret = min(ret, max(s1,s2,s3)-min(s1,s2,s3))
hh = (H-h)//2
s1 = h*W
s2 = hh*W
s3 = (H-h-hh)*W
ret = min(ret, max(s1,s2,s3... | h,w = list(map(int, input().split()))
if h%3==0 or w%3==0:
print((0))
exit()
res = min(h,w)
for hi in range(1,h):
b1 = hi*w
b2 = (h-hi)*(w//2)
b3 = (h-hi)*(w//2+w%2)
res = min(res, max(b1,b2,b3)-min(b1,b2,b3))
for wi in range(1,w):
b1 = wi*h
b2 = (w-wi)*(h//2)
b3 = (... | 31 | 19 | 606 | 394 | # -*- coding: utf-8 -*-
H, W = list(map(int, input().split()))
ret = 10**9
for h in range(1, H):
w = W // 2
s1 = h * W
s2 = (H - h) * w
s3 = (H - h) * (W - w)
ret = min(ret, max(s1, s2, s3) - min(s1, s2, s3))
hh = (H - h) // 2
s1 = h * W
s2 = hh * W
s3 = (H - h - hh) * W
ret = mi... | h, w = list(map(int, input().split()))
if h % 3 == 0 or w % 3 == 0:
print((0))
exit()
res = min(h, w)
for hi in range(1, h):
b1 = hi * w
b2 = (h - hi) * (w // 2)
b3 = (h - hi) * (w // 2 + w % 2)
res = min(res, max(b1, b2, b3) - min(b1, b2, b3))
for wi in range(1, w):
b1 = wi * h
b2 = (w ... | false | 38.709677 | [
"-# -*- coding: utf-8 -*-",
"-H, W = list(map(int, input().split()))",
"-ret = 10**9",
"-for h in range(1, H):",
"- w = W // 2",
"- s1 = h * W",
"- s2 = (H - h) * w",
"- s3 = (H - h) * (W - w)",
"- ret = min(ret, max(s1, s2, s3) - min(s1, s2, s3))",
"- hh = (H - h) // 2",
"- ... | false | 0.040416 | 0.132473 | 0.305089 | [
"s694095816",
"s184831838"
] |
u562935282 | p03127 | python | s217102389 | s561295950 | 122 | 85 | 14,252 | 14,252 | Accepted | Accepted | 30.33 | def gcd(x,y):
if y==0:
return x
else:
return gcd(y,x%y)
n=int(eval(input()))
a=list(map(int,input().split()))
a=list(sorted(a))
g=a[0]
for aa in a:
g=gcd(g,aa)
print(g)
| def gcd(x, y):
if y == 0: return x
return gcd(y, x % y)
N = int(eval(input()))
a = list(map(int, input().split()))
g = a[0]
for aa in a:
g = gcd(g, aa)
print(g)
| 14 | 12 | 192 | 181 | def gcd(x, y):
if y == 0:
return x
else:
return gcd(y, x % y)
n = int(eval(input()))
a = list(map(int, input().split()))
a = list(sorted(a))
g = a[0]
for aa in a:
g = gcd(g, aa)
print(g)
| def gcd(x, y):
if y == 0:
return x
return gcd(y, x % y)
N = int(eval(input()))
a = list(map(int, input().split()))
g = a[0]
for aa in a:
g = gcd(g, aa)
print(g)
| false | 14.285714 | [
"- else:",
"- return gcd(y, x % y)",
"+ return gcd(y, x % y)",
"-n = int(eval(input()))",
"+N = int(eval(input()))",
"-a = list(sorted(a))"
] | false | 0.03474 | 0.03655 | 0.950478 | [
"s217102389",
"s561295950"
] |
u077291787 | p03805 | python | s390192253 | s553440775 | 29 | 26 | 3,064 | 3,064 | Accepted | Accepted | 10.34 | # ABC054C - One-stroke Path
# graph theory
# an undirected unweighted graph is given
# -> count up paths which visit all the vertices exactly once
import sys
input = sys.stdin.readline
from itertools import permutations as perm
def main():
N, M = tuple(map(int, input().split()))
A = set(tuple(map... | # ABC054C - One-stroke Path
# an undirected unweighted graph is given
# -> count up paths which visit all the vertices exactly once
# exhaustive search
from itertools import permutations as perm
def main():
N, M = tuple(map(int, input().split()))
E = set(tuple(map(int, input().split())) for _ in rang... | 23 | 21 | 645 | 677 | # ABC054C - One-stroke Path
# graph theory
# an undirected unweighted graph is given
# -> count up paths which visit all the vertices exactly once
import sys
input = sys.stdin.readline
from itertools import permutations as perm
def main():
N, M = tuple(map(int, input().split()))
A = set(tuple(map(int, input(... | # ABC054C - One-stroke Path
# an undirected unweighted graph is given
# -> count up paths which visit all the vertices exactly once
# exhaustive search
from itertools import permutations as perm
def main():
N, M = tuple(map(int, input().split()))
E = set(tuple(map(int, input().split())) for _ in range(M)) # ... | false | 8.695652 | [
"-# graph theory",
"-import sys",
"-",
"-input = sys.stdin.readline",
"+# exhaustive search",
"- A = set(tuple(map(int, input().split())) for _ in range(M))",
"+ E = set(tuple(map(int, input().split())) for _ in range(M)) # edges",
"+ E |= {(j, i) for i, j in E} # undirected graph -> add re... | false | 0.052277 | 0.050916 | 1.026736 | [
"s390192253",
"s553440775"
] |
u334712262 | p02579 | python | s382974667 | s964990313 | 1,165 | 984 | 216,040 | 254,908 | Accepted | Accepted | 15.54 | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutati... | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutati... | 98 | 98 | 2,135 | 2,095 | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from... | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from... | false | 0 | [
"- for nx, ny in [(x, y - 1), (x, y + 1), (x - 1, y), (x + 1, y)]:",
"- if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == \".\":",
"- q.appendleft((c, (nx, ny)))",
"- q.append((c + 1, (nx, ny)))",
"+ if abs(nx - x) + abs(ny - y) == 1:",
... | false | 0.035369 | 0.03768 | 0.938674 | [
"s382974667",
"s964990313"
] |
u631914718 | p03160 | python | s226923360 | s575938502 | 148 | 119 | 19,064 | 17,736 | Accepted | Accepted | 19.59 | def LI(): return list(map(int, input().split()))
n = int(eval(input()))
h = LI()
h1 = [abs(h[i+1] - h[i]) for i in range(n-1)]
h2 = [abs(h[i+2] - h[i]) for i in range(n-2)]
dp = [0] * n
dp[0], dp[1] = 0, abs(h[1] - h[0])
for i in range(n-2):
dp[i+2] = min(
dp[i+1] + h1[i+1],
dp[i] + h2... | #!/usr/bin/env python3
import sys
def solve(N: int, h: "List[int]"):
dp = [0] * N
dp[0], dp[1] = 0, abs(h[1] - h[0])
for i in range(2, N):
dp[i] = min(
dp[i-1] + abs(h[i] - h[i-1]),
dp[i-2] + abs(h[i] - h[i-2])
)
print((dp[-1]))
# Generated by 1... | 16 | 28 | 343 | 807 | def LI():
return list(map(int, input().split()))
n = int(eval(input()))
h = LI()
h1 = [abs(h[i + 1] - h[i]) for i in range(n - 1)]
h2 = [abs(h[i + 2] - h[i]) for i in range(n - 2)]
dp = [0] * n
dp[0], dp[1] = 0, abs(h[1] - h[0])
for i in range(n - 2):
dp[i + 2] = min(
dp[i + 1] + h1[i + 1],
dp... | #!/usr/bin/env python3
import sys
def solve(N: int, h: "List[int]"):
dp = [0] * N
dp[0], dp[1] = 0, abs(h[1] - h[0])
for i in range(2, N):
dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[-1]))
# Generated by 1.1.4 https://github.com/kyuridenamida/atc... | false | 42.857143 | [
"-def LI():",
"- return list(map(int, input().split()))",
"+#!/usr/bin/env python3",
"+import sys",
"-n = int(eval(input()))",
"-h = LI()",
"-h1 = [abs(h[i + 1] - h[i]) for i in range(n - 1)]",
"-h2 = [abs(h[i + 2] - h[i]) for i in range(n - 2)]",
"-dp = [0] * n",
"-dp[0], dp[1] = 0, abs(h[1] -... | false | 0.035712 | 0.035821 | 0.996958 | [
"s226923360",
"s575938502"
] |
u361826811 | p03160 | python | s890213660 | s797537462 | 164 | 131 | 12,232 | 12,308 | Accepted | Accepted | 20.12 | """
author : halo2halo
date : 4, Feb, 2020
"""
import sys
# import itertools
# import math
# import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, *H = list(map(int, read().split()))
dp = [0] * N
dp[1] = abs(H[1] - H[0])
... | """
author : halo2halo
date : 4, Feb, 2020
"""
import sys
# import itertools
# import math
# import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, *H = list(map(int, read().split()))
dp = [0] * N
for i in range(1, N):
... | 25 | 29 | 431 | 495 | """
author : halo2halo
date : 4, Feb, 2020
"""
import sys
# import itertools
# import math
# import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, *H = list(map(int, read().split()))
dp = [0] * N
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
... | """
author : halo2halo
date : 4, Feb, 2020
"""
import sys
# import itertools
# import math
# import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, *H = list(map(int, read().split()))
dp = [0] * N
for i in range(1, N):
x = dp[i - 1] + abs(H[i]... | false | 13.793103 | [
"-dp[1] = abs(H[1] - H[0])",
"-for i in range(2, N):",
"- dp[i] = min(dp[i - k] + abs(H[i] - H[i - k]) for k in [1, 2])",
"+for i in range(1, N):",
"+ x = dp[i - 1] + abs(H[i] - H[i - 1])",
"+ if i > 1:",
"+ y = dp[i - 2] + abs(H[i] - H[i - 2])",
"+ if x > y:",
"+ x... | false | 0.078879 | 0.087042 | 0.906223 | [
"s890213660",
"s797537462"
] |
u952708174 | p03674 | python | s053927284 | s234625584 | 311 | 275 | 21,668 | 18,976 | Accepted | Accepted | 11.58 | def D_11(x):
n = x[0] # 整数の数
a = x[1:] # 数列
M = 10**9 + 7 # 求めた解の剰余をこれで取る
s = set()
result = [x for x in a if x in s or s.add(x)]
# for x in a:
# if x in s:
# result.append(x)
# s.add(x) と同じ書き方
index = [i for i, x in enumerate(a) if x == result[0]]
l = ind... | def d_11(N, A): # N:整数の種類, A:数列
M = 10**9 + 7 # 求めた解の剰余をこれで取る
# 重複した数のインデックスを求める
from collections import Counter
c = Counter(A).most_common(n=1)[0][0] # 重複した整数の値を取得
index = [i for i, x in enumerate(A) if x == c] # 重複した整数のインデックス
l = index[0] + 1
r = index[1] + 1
# フェルマーの小定... | 40 | 35 | 1,136 | 1,084 | def D_11(x):
n = x[0] # 整数の数
a = x[1:] # 数列
M = 10**9 + 7 # 求めた解の剰余をこれで取る
s = set()
result = [x for x in a if x in s or s.add(x)]
# for x in a:
# if x in s:
# result.append(x)
# s.add(x) と同じ書き方
index = [i for i, x in enumerate(a) if x == result[0]]
l = index[0] + 1
... | def d_11(N, A): # N:整数の種類, A:数列
M = 10**9 + 7 # 求めた解の剰余をこれで取る
# 重複した数のインデックスを求める
from collections import Counter
c = Counter(A).most_common(n=1)[0][0] # 重複した整数の値を取得
index = [i for i, x in enumerate(A) if x == c] # 重複した整数のインデックス
l = index[0] + 1
r = index[1] + 1
# フェルマーの小定理を用いてコンビネーシ... | false | 12.5 | [
"-def D_11(x):",
"- n = x[0] # 整数の数",
"- a = x[1:] # 数列",
"+def d_11(N, A): # N:整数の種類, A:数列",
"- s = set()",
"- result = [x for x in a if x in s or s.add(x)]",
"- # for x in a:",
"- # if x in s:",
"- # result.append(x)",
"- # s.add(x) と同じ書き方",
"- index = [i for ... | false | 0.063134 | 0.124321 | 0.507829 | [
"s053927284",
"s234625584"
] |
u810356688 | p02819 | python | s614030896 | s881042648 | 57 | 17 | 17,184 | 3,064 | Accepted | Accepted | 70.18 | import sys
def input(): return sys.stdin.readline().rstrip()
def prime_list(n):
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
primes-=set(range(i*2, n+1, i))
return list(primes)
def main():
x=int(eval(input()))
primes = prime_list(100010)
for p in primes:
... | import sys
def input(): return sys.stdin.readline().rstrip()
import math
def is_prime(n):
if n==1:return False
for k in range(2,int(math.sqrt(n))+1):
if n%k==0:
return False
return True
def main():
x=int(eval(input()))
while True:
if is_prime(x)==True:
... | 16 | 18 | 406 | 399 | import sys
def input():
return sys.stdin.readline().rstrip()
def prime_list(n):
primes = set(range(2, n + 1))
for i in range(2, int(n**0.5 + 1)):
primes -= set(range(i * 2, n + 1, i))
return list(primes)
def main():
x = int(eval(input()))
primes = prime_list(100010)
for p in pr... | import sys
def input():
return sys.stdin.readline().rstrip()
import math
def is_prime(n):
if n == 1:
return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
return True
def main():
x = int(eval(input()))
while True:
if is_pri... | false | 11.111111 | [
"-def prime_list(n):",
"- primes = set(range(2, n + 1))",
"- for i in range(2, int(n**0.5 + 1)):",
"- primes -= set(range(i * 2, n + 1, i))",
"- return list(primes)",
"+import math",
"+",
"+",
"+def is_prime(n):",
"+ if n == 1:",
"+ return False",
"+ for k in range... | false | 0.146249 | 0.045552 | 3.210596 | [
"s614030896",
"s881042648"
] |
u537782349 | p02983 | python | s770058682 | s136440775 | 1,454 | 97 | 2,940 | 2,940 | Accepted | Accepted | 93.33 | a, b = list(map(int, input().split()))
c = 2019
if b - a >= 2019:
print((0))
else:
for i in range(a, b):
for j in range(a + 1 , b + 1):
c = min(c, i * j % 2019)
print(c)
| a, b = list(map(int, input().split()))
c = 2019
for i in range(a, b):
for j in range(a + 1 , b + 1):
c = min(c, i * j % 2019)
if c == 0:
print(c)
exit()
print(c)
| 10 | 9 | 204 | 208 | a, b = list(map(int, input().split()))
c = 2019
if b - a >= 2019:
print((0))
else:
for i in range(a, b):
for j in range(a + 1, b + 1):
c = min(c, i * j % 2019)
print(c)
| a, b = list(map(int, input().split()))
c = 2019
for i in range(a, b):
for j in range(a + 1, b + 1):
c = min(c, i * j % 2019)
if c == 0:
print(c)
exit()
print(c)
| false | 10 | [
"-if b - a >= 2019:",
"- print((0))",
"-else:",
"- for i in range(a, b):",
"- for j in range(a + 1, b + 1):",
"- c = min(c, i * j % 2019)",
"- print(c)",
"+for i in range(a, b):",
"+ for j in range(a + 1, b + 1):",
"+ c = min(c, i * j % 2019)",
"+ if c... | false | 0.04501 | 0.034933 | 1.288466 | [
"s770058682",
"s136440775"
] |
u692746605 | p02762 | python | s602860781 | s413576738 | 1,014 | 665 | 14,888 | 14,880 | Accepted | Accepted | 34.42 |
N,M,K=list(map(int,input().split()))
p=[i for i in range(N)]
r=[0]*N
def find(x):
if p[x]==x:
return x
else:
p[x]=find(p[x])
return p[x]
def unite(x,y):
x=find(x)
y=find(y)
if x==y:
return
if r[x]<r[y]:
p[x]=y
else:
p[y]=x
if r[x]==r[y]:
r[x]+=1... | import sys
input=sys.stdin.readline
N,M,K=list(map(int,input().split()))
p=list(range(N))
r=[0]*N
def find(x):
if p[x]==x:
return x
else:
p[x]=find(p[x])
return p[x]
def unite(x,y):
x=find(x)
y=find(y)
if x==y:
return
if r[x]<r[y]:
p[x]=y
else:
p[y]=x
... | 44 | 46 | 637 | 668 | N, M, K = list(map(int, input().split()))
p = [i for i in range(N)]
r = [0] * N
def find(x):
if p[x] == x:
return x
else:
p[x] = find(p[x])
return p[x]
def unite(x, y):
x = find(x)
y = find(y)
if x == y:
return
if r[x] < r[y]:
p[x] = y
else:
... | import sys
input = sys.stdin.readline
N, M, K = list(map(int, input().split()))
p = list(range(N))
r = [0] * N
def find(x):
if p[x] == x:
return x
else:
p[x] = find(p[x])
return p[x]
def unite(x, y):
x = find(x)
y = find(y)
if x == y:
return
if r[x] < r[y]:
... | false | 4.347826 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"-p = [i for i in range(N)]",
"+p = list(range(N))"
] | false | 0.043037 | 0.043105 | 0.998433 | [
"s602860781",
"s413576738"
] |
u904995051 | p03636 | python | s052559472 | s209021003 | 28 | 25 | 9,000 | 9,020 | Accepted | Accepted | 10.71 | #ABC069
s = eval(input())
print((s[0]+str(len(s)-2)+s[-1])) | a,*b,c = input()
print(a,len(b),c,sep="")
| 3 | 2 | 53 | 43 | # ABC069
s = eval(input())
print((s[0] + str(len(s) - 2) + s[-1]))
| a, *b, c = input()
print(a, len(b), c, sep="")
| false | 33.333333 | [
"-# ABC069",
"-s = eval(input())",
"-print((s[0] + str(len(s) - 2) + s[-1]))",
"+a, *b, c = input()",
"+print(a, len(b), c, sep=\"\")"
] | false | 0.043746 | 0.0401 | 1.090928 | [
"s052559472",
"s209021003"
] |
u078349616 | p03665 | python | s108000743 | s914618201 | 182 | 18 | 13,836 | 3,064 | Accepted | Accepted | 90.11 | from scipy.misc import comb
from math import factorial
N, P = list(map(int, input().split()))
A = list(map(int,input().split()))
e = len([a for a in A if a % 2 == 0])
o = N - e
ans = 0
if P == 0:
for i in range(0, o+1, 2):
ans += comb(o, i, exact=True)
print((ans * pow(2, e)))
else:
for i in... | from math import factorial
def combi(n, k):
return factorial(n) // factorial(n-k) // factorial(k)
N, P = list(map(int, input().split()))
A = list(map(int,input().split()))
e = len([a for a in A if a % 2 == 0])
o = N - e
ans = 0
for i in range(P, o+1, 2):
ans += combi(o, i)
print((ans * pow(2, e))) | 18 | 15 | 391 | 312 | from scipy.misc import comb
from math import factorial
N, P = list(map(int, input().split()))
A = list(map(int, input().split()))
e = len([a for a in A if a % 2 == 0])
o = N - e
ans = 0
if P == 0:
for i in range(0, o + 1, 2):
ans += comb(o, i, exact=True)
print((ans * pow(2, e)))
else:
for i in ran... | from math import factorial
def combi(n, k):
return factorial(n) // factorial(n - k) // factorial(k)
N, P = list(map(int, input().split()))
A = list(map(int, input().split()))
e = len([a for a in A if a % 2 == 0])
o = N - e
ans = 0
for i in range(P, o + 1, 2):
ans += combi(o, i)
print((ans * pow(2, e)))
| false | 16.666667 | [
"-from scipy.misc import comb",
"+",
"+",
"+def combi(n, k):",
"+ return factorial(n) // factorial(n - k) // factorial(k)",
"+",
"-if P == 0:",
"- for i in range(0, o + 1, 2):",
"- ans += comb(o, i, exact=True)",
"- print((ans * pow(2, e)))",
"-else:",
"- for i in range(1, o... | false | 0.431089 | 0.043282 | 9.960104 | [
"s108000743",
"s914618201"
] |
u088552457 | p03403 | python | s439641559 | s899628863 | 253 | 178 | 14,944 | 91,308 | Accepted | Accepted | 29.64 | n = int(eval(input()))
dp = [0]*(n+1)
spots = [0]
spots = spots + list(map(int, input().split())) + spots
sum_cost = 0
for i in range(n+2):
if i+1 > n+1:
break
sum_cost += abs(spots[i+1] - spots[i])
for i in range(1,n+1):
d = sum_cost - abs(spots[i]-spots[i+1]) - abs(spots[i-1]-spots[i]) + abs(spo... | from functools import reduce
from decimal import *
from operator import mul
def main():
n = int(eval(input()))
a = input_list()
a.insert(0, 0)
a.append(0)
total = 0
for i in range(1, n+2):
total += abs(a[i] - a[i-1])
for i in range(1, n+1):
tobashi = abs(a[i+1] ... | 14 | 45 | 352 | 939 | n = int(eval(input()))
dp = [0] * (n + 1)
spots = [0]
spots = spots + list(map(int, input().split())) + spots
sum_cost = 0
for i in range(n + 2):
if i + 1 > n + 1:
break
sum_cost += abs(spots[i + 1] - spots[i])
for i in range(1, n + 1):
d = (
sum_cost
- abs(spots[i] - spots[i + 1])
... | from functools import reduce
from decimal import *
from operator import mul
def main():
n = int(eval(input()))
a = input_list()
a.insert(0, 0)
a.append(0)
total = 0
for i in range(1, n + 2):
total += abs(a[i] - a[i - 1])
for i in range(1, n + 1):
tobashi = abs(a[i + 1] - a[... | false | 68.888889 | [
"-n = int(eval(input()))",
"-dp = [0] * (n + 1)",
"-spots = [0]",
"-spots = spots + list(map(int, input().split())) + spots",
"-sum_cost = 0",
"-for i in range(n + 2):",
"- if i + 1 > n + 1:",
"- break",
"- sum_cost += abs(spots[i + 1] - spots[i])",
"-for i in range(1, n + 1):",
"- ... | false | 0.044335 | 0.035999 | 1.231558 | [
"s439641559",
"s899628863"
] |
u780475861 | p02971 | python | s938590178 | s261401237 | 230 | 171 | 25,036 | 25,148 | Accepted | Accepted | 25.65 | import sys
def main():
n, *lst = map(int, sys.stdin.read().split())
copy = sorted(lst)
max1, max2 = copy[-1], copy[-2]
if max2 < max1:
print(*[max1 if j != max1 else max2 for j in lst], sep='\n')
else:
print(*[max1]*n, sep='\n')
if __name__ == '__main__':
main()
| import sys
def main():
n, *lst = map(int, sys.stdin.read().split())
max1 = max(lst)
idx = lst.index(max1)
max2 = max(lst[:idx] + lst[idx+1:])
if max2 < max1:
print(*[max1 if j != max1 else max2 for j in lst], sep='\n')
else:
print(*[max1]*n, sep='\n')
if __name__ == '__main__':... | 15 | 16 | 304 | 331 | import sys
def main():
n, *lst = map(int, sys.stdin.read().split())
copy = sorted(lst)
max1, max2 = copy[-1], copy[-2]
if max2 < max1:
print(*[max1 if j != max1 else max2 for j in lst], sep="\n")
else:
print(*[max1] * n, sep="\n")
if __name__ == "__main__":
main()
| import sys
def main():
n, *lst = map(int, sys.stdin.read().split())
max1 = max(lst)
idx = lst.index(max1)
max2 = max(lst[:idx] + lst[idx + 1 :])
if max2 < max1:
print(*[max1 if j != max1 else max2 for j in lst], sep="\n")
else:
print(*[max1] * n, sep="\n")
if __name__ == "__m... | false | 6.25 | [
"- copy = sorted(lst)",
"- max1, max2 = copy[-1], copy[-2]",
"+ max1 = max(lst)",
"+ idx = lst.index(max1)",
"+ max2 = max(lst[:idx] + lst[idx + 1 :])"
] | false | 0.046977 | 0.070115 | 0.669999 | [
"s938590178",
"s261401237"
] |
u229518917 | p02678 | python | s800092009 | s748764803 | 1,437 | 1,327 | 40,188 | 40,064 | Accepted | Accepted | 7.65 | import queue
N,M=list(map(int,input().split()))
adj=[[] for i in range(N+1)]
parent=[-1] * (N+1)
for m in range(M):
a,b=list(map(int,input().split()))
adj[a].append(b)
adj[b].append(a)
q=queue.Queue()
q.put((1,0))
while(not q.empty()):
x,p=q.get()
if parent[x]!=-1:
continue
... | import queue
N,M = list(map(int,input().split()))
adj = [[]for i in range(N+1)] #どこの部屋とどこの部屋が繋がっているかを表す、N+1の理由は、部屋番号とインデックスが一個ずれてるから
parent = [-1] * (N+1) #-1なら未訪問、N+1な理由は同様である
for m in range(M):
a,b = list(map(int,input().split()))
adj[a].append(b) #お互いの場所を書く、繋がっているかを記録する
adj[b].append(a) #こっちにもお互いの... | 21 | 21 | 454 | 868 | import queue
N, M = list(map(int, input().split()))
adj = [[] for i in range(N + 1)]
parent = [-1] * (N + 1)
for m in range(M):
a, b = list(map(int, input().split()))
adj[a].append(b)
adj[b].append(a)
q = queue.Queue()
q.put((1, 0))
while not q.empty():
x, p = q.get()
if parent[x] != -1:
co... | import queue
N, M = list(map(int, input().split()))
adj = [[] for i in range(N + 1)] # どこの部屋とどこの部屋が繋がっているかを表す、N+1の理由は、部屋番号とインデックスが一個ずれてるから
parent = [-1] * (N + 1) # -1なら未訪問、N+1な理由は同様である
for m in range(M):
a, b = list(map(int, input().split()))
adj[a].append(b) # お互いの場所を書く、繋がっているかを記録する
adj[b].append(a) ... | false | 0 | [
"-adj = [[] for i in range(N + 1)]",
"-parent = [-1] * (N + 1)",
"+adj = [[] for i in range(N + 1)] # どこの部屋とどこの部屋が繋がっているかを表す、N+1の理由は、部屋番号とインデックスが一個ずれてるから",
"+parent = [-1] * (N + 1) # -1なら未訪問、N+1な理由は同様である",
"- adj[a].append(b)",
"- adj[b].append(a)",
"-q = queue.Queue()",
"-q.put((1, 0))",
"... | false | 0.037012 | 0.037818 | 0.978702 | [
"s800092009",
"s748764803"
] |
u021759654 | p04045 | python | s344246961 | s309893103 | 537 | 133 | 3,060 | 2,940 | Accepted | Accepted | 75.23 | total, k = list(map(int, input().split()))
ds = list(input().split())
ans = total
while True:
flag = False
for d in ds:
if d in list(str(ans)):
flag = True
if flag:
ans += 1
else:
print(ans)
exit(0) | total, k = list(map(int, input().split()))
ds = list(input().split())
for i in range(total,total*10+2):
for d in ds:
if d in list(str(i)):
break
else:
print(i)
exit(0)
| 14 | 10 | 236 | 194 | total, k = list(map(int, input().split()))
ds = list(input().split())
ans = total
while True:
flag = False
for d in ds:
if d in list(str(ans)):
flag = True
if flag:
ans += 1
else:
print(ans)
exit(0)
| total, k = list(map(int, input().split()))
ds = list(input().split())
for i in range(total, total * 10 + 2):
for d in ds:
if d in list(str(i)):
break
else:
print(i)
exit(0)
| false | 28.571429 | [
"-ans = total",
"-while True:",
"- flag = False",
"+for i in range(total, total * 10 + 2):",
"- if d in list(str(ans)):",
"- flag = True",
"- if flag:",
"- ans += 1",
"+ if d in list(str(i)):",
"+ break",
"- print(ans)",
"+ print(i... | false | 0.056334 | 0.04183 | 1.346745 | [
"s344246961",
"s309893103"
] |
u736479342 | p03597 | python | s654519173 | s693218273 | 31 | 26 | 8,860 | 9,092 | Accepted | Accepted | 16.13 | n = int(eval(input()))
a = int(eval(input()))
print((n**2-a)) | n = int(eval(input()))
a = int(eval(input()))
print(((n**2)-a)) | 3 | 3 | 49 | 51 | n = int(eval(input()))
a = int(eval(input()))
print((n**2 - a))
| n = int(eval(input()))
a = int(eval(input()))
print(((n**2) - a))
| false | 0 | [
"-print((n**2 - a))",
"+print(((n**2) - a))"
] | false | 0.112787 | 0.047486 | 2.375177 | [
"s654519173",
"s693218273"
] |
u699994820 | p03556 | python | s652285512 | s097422232 | 29 | 17 | 3,064 | 2,940 | Accepted | Accepted | 41.38 | #2
n = int(eval(input()))
cnts = 0
while(cnts**2 <= n):
cnts += 1
print(((cnts-1)**2)) | #2
n = int(eval(input()))
num = 1
a = int(n**(0.5))
print((a**2)) | 7 | 8 | 89 | 75 | # 2
n = int(eval(input()))
cnts = 0
while cnts**2 <= n:
cnts += 1
print(((cnts - 1) ** 2))
| # 2
n = int(eval(input()))
num = 1
a = int(n ** (0.5))
print((a**2))
| false | 12.5 | [
"-cnts = 0",
"-while cnts**2 <= n:",
"- cnts += 1",
"-print(((cnts - 1) ** 2))",
"+num = 1",
"+a = int(n ** (0.5))",
"+print((a**2))"
] | false | 0.048381 | 0.044026 | 1.098912 | [
"s652285512",
"s097422232"
] |
u094155508 | p02713 | python | s109140063 | s236522128 | 1,282 | 683 | 9,016 | 9,188 | Accepted | Accepted | 46.72 | import math
def main():
k = int(eval(input()))
ans = 0
gcd = math.gcd
for i in range(1, k+1):
for j in range(1, k+1):
for l in range(1, k+1):
ans += gcd(gcd(i,j), l)
print(ans)
main() | import math
def main():
k = int(eval(input()))
ans = 0
gcd = math.gcd
for i in range(1, k+1):
for j in range(1, k+1):
ij = gcd(i,j)
for l in range(1, k+1):
ans += gcd(ij, l)
print(ans)
main()
| 15 | 16 | 251 | 273 | import math
def main():
k = int(eval(input()))
ans = 0
gcd = math.gcd
for i in range(1, k + 1):
for j in range(1, k + 1):
for l in range(1, k + 1):
ans += gcd(gcd(i, j), l)
print(ans)
main()
| import math
def main():
k = int(eval(input()))
ans = 0
gcd = math.gcd
for i in range(1, k + 1):
for j in range(1, k + 1):
ij = gcd(i, j)
for l in range(1, k + 1):
ans += gcd(ij, l)
print(ans)
main()
| false | 6.25 | [
"+ ij = gcd(i, j)",
"- ans += gcd(gcd(i, j), l)",
"+ ans += gcd(ij, l)"
] | false | 0.150915 | 0.140983 | 1.070449 | [
"s109140063",
"s236522128"
] |
u325956328 | p02695 | python | s360957905 | s192012878 | 1,182 | 673 | 22,236 | 9,216 | Accepted | Accepted | 43.06 | import itertools
N, M, Q = list(map(int, input().split()))
A = list(itertools.combinations_with_replacement(list(range(1, M + 1)), N))
B = []
# print(len(list(A)))
for a in A:
for j in range(N - 1):
flag = True
if a[j] > a[j + 1]:
flag = False
break
if flag:
... | N, M, Q = list(map(int, input().split()))
a = []
b = []
c = []
d = []
ans = 0
def dfs(A):
global ans
if len(A) == N:
now = 0
for i in range(Q):
if A[b[i]] - A[a[i]] == c[i]:
now += d[i]
ans = max(now, ans)
return
if not A: ... | 37 | 40 | 686 | 622 | import itertools
N, M, Q = list(map(int, input().split()))
A = list(itertools.combinations_with_replacement(list(range(1, M + 1)), N))
B = []
# print(len(list(A)))
for a in A:
for j in range(N - 1):
flag = True
if a[j] > a[j + 1]:
flag = False
break
if flag:
B.ap... | N, M, Q = list(map(int, input().split()))
a = []
b = []
c = []
d = []
ans = 0
def dfs(A):
global ans
if len(A) == N:
now = 0
for i in range(Q):
if A[b[i]] - A[a[i]] == c[i]:
now += d[i]
ans = max(now, ans)
return
if not A: # Aが空リストのとき
tm... | false | 7.5 | [
"-import itertools",
"-",
"-A = list(itertools.combinations_with_replacement(list(range(1, M + 1)), N))",
"-B = []",
"-# print(len(list(A)))",
"-for a in A:",
"- for j in range(N - 1):",
"- flag = True",
"- if a[j] > a[j + 1]:",
"- flag = False",
"- break",... | false | 0.275917 | 0.103625 | 2.662655 | [
"s360957905",
"s192012878"
] |
u506858457 | p02936 | python | s230659938 | s708414019 | 1,489 | 1,285 | 282,864 | 56,816 | Accepted | Accepted | 13.7 | import sys
sys.setrecursionlimit(10**6)
def MI(): return list(map(int, input().split()))
N,Q=MI()
graph=[[] for i in range(N)]
for i in range(1,N):
a,b=MI()
graph[a-1].append(b-1)
graph[b-1].append(a-1)
point=[0]*N
for i in range(Q):
p,x=MI()
point[p-1]+=x
def dfs(now,pre=-1):
for next in... | def MI(): return list(map(int, input().split()))
N,Q=MI()
graph=[[] for i in range(N)]
for i in range(1,N):
a,b=MI()
graph[a-1].append(b-1)
graph[b-1].append(a-1)
point=[0]*N
for i in range(Q):
p,x=MI()
point[p-1]+=x
import collections
q=collections.deque()
q.append(0)
check=[0]*N
check[0]=1... | 21 | 25 | 432 | 473 | import sys
sys.setrecursionlimit(10**6)
def MI():
return list(map(int, input().split()))
N, Q = MI()
graph = [[] for i in range(N)]
for i in range(1, N):
a, b = MI()
graph[a - 1].append(b - 1)
graph[b - 1].append(a - 1)
point = [0] * N
for i in range(Q):
p, x = MI()
point[p - 1] += x
def ... | def MI():
return list(map(int, input().split()))
N, Q = MI()
graph = [[] for i in range(N)]
for i in range(1, N):
a, b = MI()
graph[a - 1].append(b - 1)
graph[b - 1].append(a - 1)
point = [0] * N
for i in range(Q):
p, x = MI()
point[p - 1] += x
import collections
q = collections.deque()
q.app... | false | 16 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**6)",
"-",
"-",
"+import collections",
"-",
"-def dfs(now, pre=-1):",
"- for next in graph[now]:",
"- if next == pre:",
"+q = collections.deque()",
"+q.append(0)",
"+check = [0] * N",
"+check[0] = 1",
"+while len(q) > 0:",
"+ ... | false | 0.165722 | 0.047037 | 3.523202 | [
"s230659938",
"s708414019"
] |
u038408819 | p02984 | python | s554188539 | s888187516 | 139 | 128 | 14,092 | 14,092 | Accepted | Accepted | 7.91 | N = int(eval(input()))
a = list(map(int, input().split()))
x = [0] * N
x[0] = sum([a[i] for i in range(N) if i % 2 == 0]) - sum([a[i] for i in range(N) if i % 2 != 0])
for i in range(N - 1):
x[i + 1] = 2 * a[i] - x[i]
print((*x)) | N = int(eval(input()))
a = list(map(int, input().split()))
x1 = sum(a) - 2 * sum([a[i] for i in range(N) if i % 2 == 1])
ans = [0] * N
ans[0] = x1
for i in range(N - 1):
ans[i + 1] = 2 * a[i] - ans[i]
print((*ans)) | 7 | 8 | 231 | 217 | N = int(eval(input()))
a = list(map(int, input().split()))
x = [0] * N
x[0] = sum([a[i] for i in range(N) if i % 2 == 0]) - sum(
[a[i] for i in range(N) if i % 2 != 0]
)
for i in range(N - 1):
x[i + 1] = 2 * a[i] - x[i]
print((*x))
| N = int(eval(input()))
a = list(map(int, input().split()))
x1 = sum(a) - 2 * sum([a[i] for i in range(N) if i % 2 == 1])
ans = [0] * N
ans[0] = x1
for i in range(N - 1):
ans[i + 1] = 2 * a[i] - ans[i]
print((*ans))
| false | 12.5 | [
"-x = [0] * N",
"-x[0] = sum([a[i] for i in range(N) if i % 2 == 0]) - sum(",
"- [a[i] for i in range(N) if i % 2 != 0]",
"-)",
"+x1 = sum(a) - 2 * sum([a[i] for i in range(N) if i % 2 == 1])",
"+ans = [0] * N",
"+ans[0] = x1",
"- x[i + 1] = 2 * a[i] - x[i]",
"-print((*x))",
"+ ans[i + 1]... | false | 0.03839 | 0.038211 | 1.004683 | [
"s554188539",
"s888187516"
] |
u806976856 | p02678 | python | s502409700 | s001167152 | 591 | 435 | 119,436 | 113,404 | Accepted | Accepted | 26.4 | from collections import deque
n,m=list(map(int,input().split()))
r=[[] for i in range(n+1)]
R=[[] for i in range(n+1)]
for i in range(m):
a,b=list(map(int,input().split()))
r[a].append(b)
r[b].append(a)
R[a].append(b)
R[b].append(a)
dep=[-1]*(n+1)
dep[0]=0
dep[1]=0
data=deque([1])
d=0
... | from collections import deque
import sys
input = sys.stdin.readline
n,m=list(map(int,input().split()))
r=[[] for i in range(n+1)]
R=[[] for i in range(n+1)]
for i in range(m):
a,b=list(map(int,input().split()))
r[a].append(b)
r[b].append(a)
R[a].append(b)
R[b].append(a)
dep=[-1]*(n+1)
d... | 31 | 34 | 685 | 727 | from collections import deque
n, m = list(map(int, input().split()))
r = [[] for i in range(n + 1)]
R = [[] for i in range(n + 1)]
for i in range(m):
a, b = list(map(int, input().split()))
r[a].append(b)
r[b].append(a)
R[a].append(b)
R[b].append(a)
dep = [-1] * (n + 1)
dep[0] = 0
dep[1] = 0
data = ... | from collections import deque
import sys
input = sys.stdin.readline
n, m = list(map(int, input().split()))
r = [[] for i in range(n + 1)]
R = [[] for i in range(n + 1)]
for i in range(m):
a, b = list(map(int, input().split()))
r[a].append(b)
r[b].append(a)
R[a].append(b)
R[b].append(a)
dep = [-1] *... | false | 8.823529 | [
"+import sys",
"+input = sys.stdin.readline"
] | false | 0.034258 | 0.044765 | 0.76528 | [
"s502409700",
"s001167152"
] |
u092047183 | p02264 | python | s001606228 | s510271067 | 400 | 230 | 23,072 | 23,156 | Accepted | Accepted | 42.5 | # coding: utf-8
import sys
from collections import deque
n, q = list(map(int, input().split()))
total_time = 0
tasks = deque([x.split() for x in sys.stdin.readlines()])
try:
while True:
t = tasks.popleft()
if int(t[1]) - q <= 0:
total_time += int(t[1])
print(... | # coding: utf-8
import sys
from collections import deque
n, q = list(map(int, input().split()))
total_time = 0
tasks = deque([x.split() for x in sys.stdin.readlines()])
for task in tasks:
task[1] = int(task[1])
try:
while True:
t = tasks.popleft()
if t[1] <= q:
to... | 21 | 24 | 477 | 497 | # coding: utf-8
import sys
from collections import deque
n, q = list(map(int, input().split()))
total_time = 0
tasks = deque([x.split() for x in sys.stdin.readlines()])
try:
while True:
t = tasks.popleft()
if int(t[1]) - q <= 0:
total_time += int(t[1])
print((t[0], total_tim... | # coding: utf-8
import sys
from collections import deque
n, q = list(map(int, input().split()))
total_time = 0
tasks = deque([x.split() for x in sys.stdin.readlines()])
for task in tasks:
task[1] = int(task[1])
try:
while True:
t = tasks.popleft()
if t[1] <= q:
total_time += t[1]
... | false | 12.5 | [
"+for task in tasks:",
"+ task[1] = int(task[1])",
"- if int(t[1]) - q <= 0:",
"- total_time += int(t[1])",
"+ if t[1] <= q:",
"+ total_time += t[1]",
"- t[1] = str(int(t[1]) - q)",
"+ t[1] -= q"
] | false | 0.1174 | 0.044068 | 2.664096 | [
"s001606228",
"s510271067"
] |
u537976628 | p03636 | python | s004870409 | s333369481 | 29 | 25 | 9,092 | 9,100 | Accepted | Accepted | 13.79 | s = eval(input())
print((s[0] + str(len(s) - 2) + s[-1])) | s = eval(input())
print((s[0] + str(len(s[1:len(s) - 1])) + s[-1])) | 2 | 2 | 50 | 60 | s = eval(input())
print((s[0] + str(len(s) - 2) + s[-1]))
| s = eval(input())
print((s[0] + str(len(s[1 : len(s) - 1])) + s[-1]))
| false | 0 | [
"-print((s[0] + str(len(s) - 2) + s[-1]))",
"+print((s[0] + str(len(s[1 : len(s) - 1])) + s[-1]))"
] | false | 0.046153 | 0.04144 | 1.113741 | [
"s004870409",
"s333369481"
] |
u254871849 | p03721 | python | s657429880 | s557465674 | 334 | 167 | 5,848 | 5,744 | Accepted | Accepted | 50 | import sys
sys.stdin.readline
N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
a, b = [int(x) for x in input().split()]
arr[a] += b
remain = K
for i in range(1, 10**5+1):
if arr[i] != 0:
remain -= arr[i]
if remain <= 0:
print(i)
e... | from sys import stdin
input = stdin.readline
N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
a, b = [int(x) for x in input().split()]
arr[a] += b
remain = K
for i in range(1, 10**5+1):
if arr[i] != 0:
remain -= arr[i]
if remain <= 0:
prin... | 16 | 16 | 325 | 340 | import sys
sys.stdin.readline
N, K = [int(x) for x in input().split()]
arr = [0] * (10**5 + 1)
for _ in range(N):
a, b = [int(x) for x in input().split()]
arr[a] += b
remain = K
for i in range(1, 10**5 + 1):
if arr[i] != 0:
remain -= arr[i]
if remain <= 0:
print(i)
exit()
| from sys import stdin
input = stdin.readline
N, K = [int(x) for x in input().split()]
arr = [0] * (10**5 + 1)
for _ in range(N):
a, b = [int(x) for x in input().split()]
arr[a] += b
remain = K
for i in range(1, 10**5 + 1):
if arr[i] != 0:
remain -= arr[i]
if remain <= 0:
print(i)
... | false | 0 | [
"-import sys",
"+from sys import stdin",
"-sys.stdin.readline",
"+input = stdin.readline"
] | false | 0.110455 | 0.04729 | 2.33569 | [
"s657429880",
"s557465674"
] |
u017810624 | p02936 | python | s897018655 | s721553433 | 1,620 | 1,150 | 141,220 | 129,832 | Accepted | Accepted | 29.01 | import sys
input=sys.stdin.readline
n,q=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(n-1)]
l2=[list(map(int,input().split())) for i in range(q)]
connection=[[] for i in range(n)]
for i in range(n-1):
connection[l[i][0]-1].append(l[i][1]-1)
L4=[0 for i in range(n)]
for i in ... | import sys
input=sys.stdin.readline
n,q=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(n-1)]
l2=[list(map(int,input().split())) for i in range(q)]
connection=[[] for i in range(n)]
for i in range(n-1):
connection[l[i][0]-1].append(l[i][1]-1)
connection[l[i][1]-1].append(l[i]... | 27 | 30 | 735 | 830 | import sys
input = sys.stdin.readline
n, q = list(map(int, input().split()))
l = [list(map(int, input().split())) for i in range(n - 1)]
l2 = [list(map(int, input().split())) for i in range(q)]
connection = [[] for i in range(n)]
for i in range(n - 1):
connection[l[i][0] - 1].append(l[i][1] - 1)
L4 = [0 for i in r... | import sys
input = sys.stdin.readline
n, q = list(map(int, input().split()))
l = [list(map(int, input().split())) for i in range(n - 1)]
l2 = [list(map(int, input().split())) for i in range(q)]
connection = [[] for i in range(n)]
for i in range(n - 1):
connection[l[i][0] - 1].append(l[i][1] - 1)
connection[l[i... | false | 10 | [
"+ connection[l[i][1] - 1].append(l[i][0] - 1)",
"+L22 = [-1] * n",
"+ L22[L[j]] = 1",
"- distance[connection[L[j]][k]] = distance[L[j]] + L4[connection[L[j]][k]]",
"- L3.append(connection[L[j]][k])",
"- L2.append(L[j])",
"+ if L22[connection[L[j]][k]] =... | false | 0.0379 | 0.035524 | 1.066879 | [
"s897018655",
"s721553433"
] |
u688488162 | p02396 | python | s429262764 | s279634534 | 120 | 80 | 6,756 | 7,676 | Accepted | Accepted | 33.33 | array = []
while True:
x= eval(input())
if x == 0:
break
array.append(x)
for i in range(len(array)):
print(('Case {0}: {1}'.format(i+1,array[i]))) | import sys
a = sys.stdin
i = 1
for line in a:
if(int(line) == 0):
break
print('Case {0}: {1}'.format(i,line),end="")
i += 1
| 9 | 8 | 165 | 150 | array = []
while True:
x = eval(input())
if x == 0:
break
array.append(x)
for i in range(len(array)):
print(("Case {0}: {1}".format(i + 1, array[i])))
| import sys
a = sys.stdin
i = 1
for line in a:
if int(line) == 0:
break
print("Case {0}: {1}".format(i, line), end="")
i += 1
| false | 11.111111 | [
"-array = []",
"-while True:",
"- x = eval(input())",
"- if x == 0:",
"+import sys",
"+",
"+a = sys.stdin",
"+i = 1",
"+for line in a:",
"+ if int(line) == 0:",
"- array.append(x)",
"-for i in range(len(array)):",
"- print((\"Case {0}: {1}\".format(i + 1, array[i])))",
"+ ... | false | 0.043997 | 0.041165 | 1.068812 | [
"s429262764",
"s279634534"
] |
u145950990 | p02585 | python | s581451192 | s717013629 | 256 | 197 | 74,776 | 68,988 | Accepted | Accepted | 23.05 | n,k = list(map(int,input().split()))
p = list(map(int,input().split()))
for i in range(n):
p[i] -= 1
c = list(map(int,input().split()))
reach = [False]*n
x = []
for i in range(n):
if reach[i]:continue
buf = []
cur = i
while not reach[cur]:
buf.append(c[cur])
reach[cur]... | n,k = list(map(int,input().split()))
p = list(map(int,input().split()))
for i in range(n):
p[i] -= 1
c = list(map(int,input().split()))
reach = [False]*n
x = []
for i in range(n):
if reach[i]:continue
buf = []
cur = i
while not reach[cur]:
buf.append(c[cur])
reach[cur]... | 37 | 36 | 811 | 765 | n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
for i in range(n):
p[i] -= 1
c = list(map(int, input().split()))
reach = [False] * n
x = []
for i in range(n):
if reach[i]:
continue
buf = []
cur = i
while not reach[cur]:
buf.append(c[cur])
reach[cur]... | n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
for i in range(n):
p[i] -= 1
c = list(map(int, input().split()))
reach = [False] * n
x = []
for i in range(n):
if reach[i]:
continue
buf = []
cur = i
while not reach[cur]:
buf.append(c[cur])
reach[cur]... | false | 2.702703 | [
"- if z < ind + 1:",
"- ans = max(ans, a + s)",
"- else:",
"- ans = max(ans, s)",
"+ ans = max(ans, a + s)"
] | false | 0.03802 | 0.036084 | 1.053644 | [
"s581451192",
"s717013629"
] |
u498487134 | p02781 | python | s361788557 | s817218702 | 180 | 63 | 38,768 | 62,548 | Accepted | Accepted | 65 | #再帰ver
N=int(eval(input()))
K=int(eval(input()))
from collections import defaultdict
dd = defaultdict(int)
#NN以下,KKが非zero要素を残り使っても良い回数
def rep(NN,KK):
if KK<0:
return 0
ha=NN*10+KK
if dd[ha]!=0:
return dd[ha]
if NN<0:
return 0
if NN==0:... |
def I(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))
def main():
mod=10**9+7
S=eval(input())
N=len(S)
K=I()
dpl=[[0]*(K+1)for _ in range(N+1)]
dpt=[[0]*(K+1)for _ in range(N+1)]
#dp[i][j... | 42 | 58 | 631 | 1,327 | # 再帰ver
N = int(eval(input()))
K = int(eval(input()))
from collections import defaultdict
dd = defaultdict(int)
# NN以下,KKが非zero要素を残り使っても良い回数
def rep(NN, KK):
if KK < 0:
return 0
ha = NN * 10 + KK
if dd[ha] != 0:
return dd[ha]
if NN < 0:
return 0
if NN == 0:
if KK == ... | def I():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def LI():
return list(map(int, input().split()))
def main():
mod = 10**9 + 7
S = eval(input())
N = len(S)
K = I()
dpl = [[0] * (K + 1) for _ in range(N + 1)]
dpt = [[0] * (K + 1) for _ in range(... | false | 27.586207 | [
"-# 再帰ver",
"-N = int(eval(input()))",
"-K = int(eval(input()))",
"-from collections import defaultdict",
"-",
"-dd = defaultdict(int)",
"-# NN以下,KKが非zero要素を残り使っても良い回数",
"-def rep(NN, KK):",
"- if KK < 0:",
"- return 0",
"- ha = NN * 10 + KK",
"- if dd[ha] != 0:",
"- r... | false | 0.097316 | 0.091132 | 1.067854 | [
"s361788557",
"s817218702"
] |
u488636998 | p03835 | python | s760024096 | s123825432 | 1,982 | 1,662 | 2,940 | 3,060 | Accepted | Accepted | 16.15 | l=list(map(int, input().split()))
K, S = l[0], l[1]
count=0
for X in range(0, K+1):
for Y in range(0, K+1):
if S-(X+Y)>=0 and S-(X+Y)<=K:
count += 1
print(count)
| K, S=list(map(int, input().split()))
count=0
for x in range(0, K+1):
for y in range(0, K+1):
z = S-(x+y)
if 0<= z and z<=K:
count += 1
print(count)
| 9 | 9 | 195 | 189 | l = list(map(int, input().split()))
K, S = l[0], l[1]
count = 0
for X in range(0, K + 1):
for Y in range(0, K + 1):
if S - (X + Y) >= 0 and S - (X + Y) <= K:
count += 1
print(count)
| K, S = list(map(int, input().split()))
count = 0
for x in range(0, K + 1):
for y in range(0, K + 1):
z = S - (x + y)
if 0 <= z and z <= K:
count += 1
print(count)
| false | 0 | [
"-l = list(map(int, input().split()))",
"-K, S = l[0], l[1]",
"+K, S = list(map(int, input().split()))",
"-for X in range(0, K + 1):",
"- for Y in range(0, K + 1):",
"- if S - (X + Y) >= 0 and S - (X + Y) <= K:",
"+for x in range(0, K + 1):",
"+ for y in range(0, K + 1):",
"+ z =... | false | 0.04495 | 0.049005 | 0.917253 | [
"s760024096",
"s123825432"
] |
u753803401 | p03014 | python | s872363711 | s403692874 | 1,318 | 1,143 | 308,232 | 310,408 | Accepted | Accepted | 13.28 | def slove():
import sys
input = sys.stdin.readline
h, w = list(map(int, input().rstrip('\n').split()))
s = [list(str(input().rstrip('\n'))) for _ in range(h)]
R = [[0] * w for _ in range(h)]
L = [[0] * w for _ in range(h)]
U = [[0] * w for _ in range(h)]
D = [[0] * w for _ in ran... | def slove():
import sys
input = sys.stdin.readline
h, w = list(map(int, input().rstrip('\n').split()))
s = [list(str(input().rstrip('\n'))) for _ in range(h)]
U = [[0] * w for _ in range(h)]
D = [[0] * w for _ in range(h)]
R = [[0] * w for _ in range(h)]
L = [[0] * w for _ in r... | 32 | 34 | 1,164 | 1,165 | def slove():
import sys
input = sys.stdin.readline
h, w = list(map(int, input().rstrip("\n").split()))
s = [list(str(input().rstrip("\n"))) for _ in range(h)]
R = [[0] * w for _ in range(h)]
L = [[0] * w for _ in range(h)]
U = [[0] * w for _ in range(h)]
D = [[0] * w for _ in range(h)]
... | def slove():
import sys
input = sys.stdin.readline
h, w = list(map(int, input().rstrip("\n").split()))
s = [list(str(input().rstrip("\n"))) for _ in range(h)]
U = [[0] * w for _ in range(h)]
D = [[0] * w for _ in range(h)]
R = [[0] * w for _ in range(h)]
L = [[0] * w for _ in range(h)]
... | false | 5.882353 | [
"+ U = [[0] * w for _ in range(h)]",
"+ D = [[0] * w for _ in range(h)]",
"- U = [[0] * w for _ in range(h)]",
"- D = [[0] * w for _ in range(h)]",
"+ b = True",
"- if i == 0:",
"- U[i][j] = 1 if s[i][j] == \".\" else 0",
"- D[-i - 1][j] = 1 if s... | false | 0.036076 | 0.035775 | 1.008426 | [
"s872363711",
"s403692874"
] |
u075012704 | p03879 | python | s976530524 | s234690364 | 21 | 18 | 3,188 | 3,188 | Accepted | Accepted | 14.29 | x1, y1 = list(map(int, input().split()))
x2, y2 = list(map(int, input().split()))
x3, y3 = list(map(int, input().split()))
# 3辺の長さとその最大値
a = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
b = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
c = ((x3 - x1) ** 2 + (y3 - y1) ** 2) ** 0.5
L = max(a, b, c)
# ヘロンの公式
s = (a + ... | x1, y1 = list(map(int, input().split()))
x2, y2 = list(map(int, input().split()))
x3, y3 = list(map(int, input().split()))
d1 = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
d2 = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
d3 = ((x3 - x1) ** 2 + (y3 - y1) ** 2) ** 0.5
D = max(d1, d2, d3)
s = (d1 + d2 + d3) / 2
... | 19 | 27 | 441 | 559 | x1, y1 = list(map(int, input().split()))
x2, y2 = list(map(int, input().split()))
x3, y3 = list(map(int, input().split()))
# 3辺の長さとその最大値
a = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
b = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
c = ((x3 - x1) ** 2 + (y3 - y1) ** 2) ** 0.5
L = max(a, b, c)
# ヘロンの公式
s = (a + b + c) / 2
S ... | x1, y1 = list(map(int, input().split()))
x2, y2 = list(map(int, input().split()))
x3, y3 = list(map(int, input().split()))
d1 = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
d2 = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
d3 = ((x3 - x1) ** 2 + (y3 - y1) ** 2) ** 0.5
D = max(d1, d2, d3)
s = (d1 + d2 + d3) / 2
S = (s * (s - d1... | false | 29.62963 | [
"-# 3辺の長さとその最大値",
"-a = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5",
"-b = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5",
"-c = ((x3 - x1) ** 2 + (y3 - y1) ** 2) ** 0.5",
"-L = max(a, b, c)",
"-# ヘロンの公式",
"-s = (a + b + c) / 2",
"-S = (s * (s - a) * (s - b) * (s - c)) ** 0.5",
"-# 内接円の半径",
"-r = (2 * S)... | false | 0.033906 | 0.035106 | 0.965825 | [
"s976530524",
"s234690364"
] |
u970197315 | p03293 | python | s424872305 | s715223059 | 20 | 18 | 3,064 | 2,940 | Accepted | Accepted | 10 | # ABC103 B-StringRotation
S = [s for s in eval(input())]
T = eval(input())
S_ = []
S_Jugde = ""
for i in range(len(S)):
S_ = S[:]
for j in range(len(S)-1):
if j == 0:
S[0] = S_[len(S)-1]
S[j+1] = S_[j]
if j == len(S)-2:
S_Jugde = "".join(S)
... | s=eval(input())
t=eval(input())
n=len(s)
for i in range(n):
s+=s[i]
# print(s[i+1:])
if s[i+1:]==t:
print('Yes')
exit()
print('No') | 19 | 10 | 397 | 156 | # ABC103 B-StringRotation
S = [s for s in eval(input())]
T = eval(input())
S_ = []
S_Jugde = ""
for i in range(len(S)):
S_ = S[:]
for j in range(len(S) - 1):
if j == 0:
S[0] = S_[len(S) - 1]
S[j + 1] = S_[j]
if j == len(S) - 2:
S_Jugde = "".join(S)
if ... | s = eval(input())
t = eval(input())
n = len(s)
for i in range(n):
s += s[i]
# print(s[i+1:])
if s[i + 1 :] == t:
print("Yes")
exit()
print("No")
| false | 47.368421 | [
"-# ABC103 B-StringRotation",
"-S = [s for s in eval(input())]",
"-T = eval(input())",
"-S_ = []",
"-S_Jugde = \"\"",
"-for i in range(len(S)):",
"- S_ = S[:]",
"- for j in range(len(S) - 1):",
"- if j == 0:",
"- S[0] = S_[len(S) - 1]",
"- S[j + 1] = S_[j]",
"- ... | false | 0.03731 | 0.03921 | 0.951541 | [
"s424872305",
"s715223059"
] |
u867848444 | p03294 | python | s808605145 | s976194589 | 37 | 18 | 5,176 | 3,316 | Accepted | Accepted | 51.35 | n=int(eval(input()))
a=list(map(int,input().split()))
import fractions
def lcm(a,b):
lcm=fractions.gcd(a,b)
return lcm
m=1
for i in range(n):
m=lcm(m,a[i])
print((sum(a)-n)) | import math
n=int(eval(input()))
a=list(map(int,input().split()))
ans=sum(a)-n
print(ans) | 11 | 6 | 192 | 89 | n = int(eval(input()))
a = list(map(int, input().split()))
import fractions
def lcm(a, b):
lcm = fractions.gcd(a, b)
return lcm
m = 1
for i in range(n):
m = lcm(m, a[i])
print((sum(a) - n))
| import math
n = int(eval(input()))
a = list(map(int, input().split()))
ans = sum(a) - n
print(ans)
| false | 45.454545 | [
"+import math",
"+",
"-import fractions",
"-",
"-",
"-def lcm(a, b):",
"- lcm = fractions.gcd(a, b)",
"- return lcm",
"-",
"-",
"-m = 1",
"-for i in range(n):",
"- m = lcm(m, a[i])",
"-print((sum(a) - n))",
"+ans = sum(a) - n",
"+print(ans)"
] | false | 0.16736 | 0.080054 | 2.090597 | [
"s808605145",
"s976194589"
] |
u657913472 | p04002 | python | s291612323 | s653419182 | 2,217 | 1,938 | 166,480 | 166,532 | Accepted | Accepted | 12.58 | f=lambda:list(map(int,input().split()))
h,w,n=f()
c=[0]*10
c[0]=(h-2)*(w-2)
d={}
while n:
n-=1;x,y=f()
for i in range(9):
a=(x+i%3,y+i//3)
if h>=a[0]>2<a[1]<=w:d[a]=d.get(a,0)+1;c[d[a]-1]-=1;c[d[a]]+=1
print((*c)) | f=lambda:list(map(int,input().split()))
h,w,n=f()
d={}
while n:
n-=1;x,y=f()
for i in range(9):
a=(x+i%3,y+i//3)
if h>=a[0]>2<a[1]<=w:d[a]=d.get(a,0)+1
c=[0]*10
for i in d:c[d[i]]+=1
c[0]=(h-2)*(w-2)-sum(c)
print((*c)) | 11 | 12 | 221 | 227 | f = lambda: list(map(int, input().split()))
h, w, n = f()
c = [0] * 10
c[0] = (h - 2) * (w - 2)
d = {}
while n:
n -= 1
x, y = f()
for i in range(9):
a = (x + i % 3, y + i // 3)
if h >= a[0] > 2 < a[1] <= w:
d[a] = d.get(a, 0) + 1
c[d[a] - 1] -= 1
c[d[a]] +... | f = lambda: list(map(int, input().split()))
h, w, n = f()
d = {}
while n:
n -= 1
x, y = f()
for i in range(9):
a = (x + i % 3, y + i // 3)
if h >= a[0] > 2 < a[1] <= w:
d[a] = d.get(a, 0) + 1
c = [0] * 10
for i in d:
c[d[i]] += 1
c[0] = (h - 2) * (w - 2) - sum(c)
print((*c))
| false | 8.333333 | [
"-c = [0] * 10",
"-c[0] = (h - 2) * (w - 2)",
"- c[d[a] - 1] -= 1",
"- c[d[a]] += 1",
"+c = [0] * 10",
"+for i in d:",
"+ c[d[i]] += 1",
"+c[0] = (h - 2) * (w - 2) - sum(c)"
] | false | 0.121734 | 0.039052 | 3.117233 | [
"s291612323",
"s653419182"
] |
u194894739 | p03031 | python | s351681703 | s535819597 | 215 | 41 | 42,092 | 3,064 | Accepted | Accepted | 80.93 | N, M = list(map(int, input().split()))
K = []; S = []
for _ in range(M):
k, *s = list(map(int, input().split()))
K.append(k); S.append(s)
P = list(map(int,input().split()))
ans = 0
for i in range(2**N):
flag = 0
stat = str(bin(i)[2:])
stat = stat.rjust(N, "0")
for j in range(M):
... | N, M = list(map(int, input().split()))
lightList = []
for _ in range(M):
lightList.append(list(map(int, input().split())))
P = list(map(int, input().split()))
ans = 0
for i in range(2**N):
flag = True
for a in range(M):
cnt = 0
for b in lightList[a][1:]:
if not (i & ... | 22 | 19 | 477 | 450 | N, M = list(map(int, input().split()))
K = []
S = []
for _ in range(M):
k, *s = list(map(int, input().split()))
K.append(k)
S.append(s)
P = list(map(int, input().split()))
ans = 0
for i in range(2**N):
flag = 0
stat = str(bin(i)[2:])
stat = stat.rjust(N, "0")
for j in range(M):
p = 0... | N, M = list(map(int, input().split()))
lightList = []
for _ in range(M):
lightList.append(list(map(int, input().split())))
P = list(map(int, input().split()))
ans = 0
for i in range(2**N):
flag = True
for a in range(M):
cnt = 0
for b in lightList[a][1:]:
if not (i & (1 << b - 1))... | false | 13.636364 | [
"-K = []",
"-S = []",
"+lightList = []",
"- k, *s = list(map(int, input().split()))",
"- K.append(k)",
"- S.append(s)",
"+ lightList.append(list(map(int, input().split())))",
"- flag = 0",
"- stat = str(bin(i)[2:])",
"- stat = stat.rjust(N, \"0\")",
"- for j in range(M):"... | false | 0.050918 | 0.033409 | 1.524072 | [
"s351681703",
"s535819597"
] |
u885634168 | p03061 | python | s221975538 | s491895746 | 259 | 229 | 64,996 | 103,268 | Accepted | Accepted | 11.58 | N = int(eval(input()))
A = list(map(int,input().split()))
def gcd_(a, b):
if a < b: a, b = b, a
if b == 0: return a
return gcd_(b, a % b)
left = [0 for _ in range(N + 1)]
right = [0 for _ in range(N + 1)]
for i in range(1, N + 1):
left[i] = gcd_(left[i - 1], A[i - 1])
for i in reve... | def gcd_(a, b):
if a < b: a, b = b, a
if b == 0: return a
return gcd_(b, a % b)
def gcd_bl(A):
left = [0 for _ in range(N + 1)]
right = [0 for _ in range(N + 1)]
ans = [0 for _ in range(N)]
left[1] = A[0]
for i in range(1, N):
left[i + 1] = gcd_(left[i], A[i])
... | 20 | 32 | 463 | 708 | N = int(eval(input()))
A = list(map(int, input().split()))
def gcd_(a, b):
if a < b:
a, b = b, a
if b == 0:
return a
return gcd_(b, a % b)
left = [0 for _ in range(N + 1)]
right = [0 for _ in range(N + 1)]
for i in range(1, N + 1):
left[i] = gcd_(left[i - 1], A[i - 1])
for i in rever... | def gcd_(a, b):
if a < b:
a, b = b, a
if b == 0:
return a
return gcd_(b, a % b)
def gcd_bl(A):
left = [0 for _ in range(N + 1)]
right = [0 for _ in range(N + 1)]
ans = [0 for _ in range(N)]
left[1] = A[0]
for i in range(1, N):
left[i + 1] = gcd_(left[i], A[i])
... | false | 37.5 | [
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-",
"-",
"-left = [0 for _ in range(N + 1)]",
"-right = [0 for _ in range(N + 1)]",
"-for i in range(1, N + 1):",
"- left[i] = gcd_(left[i - 1], A[i - 1])",
"-for i in reversed(list(range(N))):",
"- right[i] = gcd_(right[i +... | false | 0.067419 | 0.03685 | 1.829568 | [
"s221975538",
"s491895746"
] |
u297574184 | p02793 | python | s695259946 | s953916183 | 1,009 | 843 | 44,072 | 59,752 | Accepted | Accepted | 16.45 | from collections import Counter
def solve():
MOD = 10**9 + 7
maxA = 10**6
def getPrimeFactors(x):
anss = []
while x%2 == 0:
anss.append(2)
x //= 2
for d in range(3, int(x**0.5)+1, 2):
while x%d == 0:
anss.append(d)
... | from collections import Counter
def solve():
MOD = 10**9 + 7
maxA = 10**6
N = int(eval(input()))
As = list(map(int, input().split()))
def getMinPFs(n):
isPrimes = [False]*2 + [True]*(n-1)
minPFs = [1] + list(range(1, n+1))
for d in range(2, int(n**0.5)+1):
... | 49 | 57 | 1,065 | 1,360 | from collections import Counter
def solve():
MOD = 10**9 + 7
maxA = 10**6
def getPrimeFactors(x):
anss = []
while x % 2 == 0:
anss.append(2)
x //= 2
for d in range(3, int(x**0.5) + 1, 2):
while x % d == 0:
anss.append(d)
... | from collections import Counter
def solve():
MOD = 10**9 + 7
maxA = 10**6
N = int(eval(input()))
As = list(map(int, input().split()))
def getMinPFs(n):
isPrimes = [False] * 2 + [True] * (n - 1)
minPFs = [1] + list(range(1, n + 1))
for d in range(2, int(n**0.5) + 1):
... | false | 14.035088 | [
"+ N = int(eval(input()))",
"+ As = list(map(int, input().split()))",
"- def getPrimeFactors(x):",
"+ def getMinPFs(n):",
"+ isPrimes = [False] * 2 + [True] * (n - 1)",
"+ minPFs = [1] + list(range(1, n + 1))",
"+ for d in range(2, int(n**0.5) + 1):",
"+ if ... | false | 1.34716 | 3.141586 | 0.428815 | [
"s695259946",
"s953916183"
] |
u397496203 | p02847 | python | s031053519 | s101437015 | 179 | 67 | 61,600 | 61,728 | Accepted | Accepted | 62.57 | s = eval(input())
x = 7
if s == "SUN":
pass
elif s == "SAT":
x = x - 6
elif s == "FRI":
x = x - 5
elif s == "THU":
x = x - 4
elif s == "WED":
x = x - 3
elif s == "TUE":
x = x - 2
elif s == "MON":
x = x - 1
print(x)
| s = eval(input())
d = {
"SUN": 7,
"MON": 6,
"TUE": 5,
"WED": 4,
"THU": 3,
"FRI": 2,
"SAT": 1
}
print((d[s])) | 19 | 13 | 257 | 142 | s = eval(input())
x = 7
if s == "SUN":
pass
elif s == "SAT":
x = x - 6
elif s == "FRI":
x = x - 5
elif s == "THU":
x = x - 4
elif s == "WED":
x = x - 3
elif s == "TUE":
x = x - 2
elif s == "MON":
x = x - 1
print(x)
| s = eval(input())
d = {"SUN": 7, "MON": 6, "TUE": 5, "WED": 4, "THU": 3, "FRI": 2, "SAT": 1}
print((d[s]))
| false | 31.578947 | [
"-x = 7",
"-if s == \"SUN\":",
"- pass",
"-elif s == \"SAT\":",
"- x = x - 6",
"-elif s == \"FRI\":",
"- x = x - 5",
"-elif s == \"THU\":",
"- x = x - 4",
"-elif s == \"WED\":",
"- x = x - 3",
"-elif s == \"TUE\":",
"- x = x - 2",
"-elif s == \"MON\":",
"- x = x - 1"... | false | 0.044896 | 0.007167 | 6.26432 | [
"s031053519",
"s101437015"
] |
u912237403 | p00150 | python | s456468150 | s303061355 | 260 | 100 | 4,628 | 4,592 | Accepted | Accepted | 61.54 | def prime(m):
N = list(range(1,m+2, 2))
r = int(m**.5)
h = len(N)
N[0] = 0
for i in range(h):
x = N[i]
if x>r: break
if x and i+x<h: N[i+x:h:x]=[0] * ((h-1-i-x)/x+1)
N[0] = 2
return [_f for _f in N if _f]
P = prime(10000)
x = [a for a,b in zip(P[1:],P[:-2]) if a-b==2]
while 1:
... | import bisect as bs
def prime(m):
N = list(range(1,m+1, 2))
N[0] = 2
for i in range(1, int(m**.5)+1):
x = N[i]
if x: N[i+x::x] = [0] * len(N[i+x::x])
return [_f for _f in N if _f]
P = prime(10000)
x = [P[i] for i in range(1,len(P)) if P[i] - P[i-1]==2]
while 1:
n = eval(input())
if n==... | 21 | 16 | 398 | 359 | def prime(m):
N = list(range(1, m + 2, 2))
r = int(m**0.5)
h = len(N)
N[0] = 0
for i in range(h):
x = N[i]
if x > r:
break
if x and i + x < h:
N[i + x : h : x] = [0] * ((h - 1 - i - x) / x + 1)
N[0] = 2
return [_f for _f in N if _f]
P = prime... | import bisect as bs
def prime(m):
N = list(range(1, m + 1, 2))
N[0] = 2
for i in range(1, int(m**0.5) + 1):
x = N[i]
if x:
N[i + x :: x] = [0] * len(N[i + x :: x])
return [_f for _f in N if _f]
P = prime(10000)
x = [P[i] for i in range(1, len(P)) if P[i] - P[i - 1] == 2]
... | false | 23.809524 | [
"+import bisect as bs",
"+",
"+",
"- N = list(range(1, m + 2, 2))",
"- r = int(m**0.5)",
"- h = len(N)",
"- N[0] = 0",
"- for i in range(h):",
"+ N = list(range(1, m + 1, 2))",
"+ N[0] = 2",
"+ for i in range(1, int(m**0.5) + 1):",
"- if x > r:",
"- ... | false | 0.047636 | 0.045693 | 1.042531 | [
"s456468150",
"s303061355"
] |
u668503853 | p02982 | python | s566023105 | s413336659 | 31 | 19 | 3,060 | 3,064 | Accepted | Accepted | 38.71 | n, d = list(map(int, input().split()))
X = []
for _ in range(n):
X.append([int(x) for x in input().split()])
ans = 0
for i in range(n - 1):
for j in range(i + 1, n):
s = sum((X[i][d] - X[j][d])**2 for d in range(d))
if any(k**2 == s for k in range(1000)):
ans += 1
print(ans... | n, d = list(map(int, input().split()))
X = []
for _ in range(n):
X.append([int(x) for x in input().split()])
ans = 0
for i in range(n - 1):
for j in range(i + 1, n):
s = sum((X[i][d] - X[j][d])**2 for d in range(d))
if (s ** .5).is_integer():
ans += 1
print(ans) | 11 | 11 | 316 | 288 | n, d = list(map(int, input().split()))
X = []
for _ in range(n):
X.append([int(x) for x in input().split()])
ans = 0
for i in range(n - 1):
for j in range(i + 1, n):
s = sum((X[i][d] - X[j][d]) ** 2 for d in range(d))
if any(k**2 == s for k in range(1000)):
ans += 1
print(ans)
| n, d = list(map(int, input().split()))
X = []
for _ in range(n):
X.append([int(x) for x in input().split()])
ans = 0
for i in range(n - 1):
for j in range(i + 1, n):
s = sum((X[i][d] - X[j][d]) ** 2 for d in range(d))
if (s**0.5).is_integer():
ans += 1
print(ans)
| false | 0 | [
"- if any(k**2 == s for k in range(1000)):",
"+ if (s**0.5).is_integer():"
] | false | 0.069629 | 0.046328 | 1.502947 | [
"s566023105",
"s413336659"
] |
u473221511 | p00001 | python | s796589255 | s386569993 | 20 | 10 | 7,628 | 6,360 | Accepted | Accepted | 50 | l = []
for i in range(10):
l.append(int(eval(input())))
l.sort()
for i in range(3):
print((l[-1 * (i+1)])) | mountains = []
for x in range(10):
mountains.append(int(input()))
mountains.sort()
print((mountains[-1]))
print((mountains[-2]))
print((mountains[-3])) | 9 | 7 | 117 | 159 | l = []
for i in range(10):
l.append(int(eval(input())))
l.sort()
for i in range(3):
print((l[-1 * (i + 1)]))
| mountains = []
for x in range(10):
mountains.append(int(input()))
mountains.sort()
print((mountains[-1]))
print((mountains[-2]))
print((mountains[-3]))
| false | 22.222222 | [
"-l = []",
"-for i in range(10):",
"- l.append(int(eval(input())))",
"-l.sort()",
"-for i in range(3):",
"- print((l[-1 * (i + 1)]))",
"+mountains = []",
"+for x in range(10):",
"+ mountains.append(int(input()))",
"+mountains.sort()",
"+print((mountains[-1]))",
"+print((mountains[-2])... | false | 0.068699 | 0.034663 | 1.981881 | [
"s796589255",
"s386569993"
] |
u190405389 | p03805 | python | s898682339 | s776507856 | 44 | 31 | 3,064 | 3,064 | Accepted | Accepted | 29.55 | n,m = list(map(int, input().split()))
line = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
a,b = list(map(int, input().split()))
line[a-1][b-1] = 1
line[b-1][a-1] = 1
stack = [0]
visited = [[0]]
ans = 0
while stack:
p = stack.pop()
v = visited.pop()
for i in ... | import itertools
n,m = list(map(int, input().split()))
line = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
a,b = list(map(int, input().split()))
line[a-1][b-1] = 1
line[b-1][a-1] = 1
ans = 0
p = [i for i in range(1, n)]
for x in itertools.permutations(p):
x = list(x... | 29 | 25 | 623 | 467 | n, m = list(map(int, input().split()))
line = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
a, b = list(map(int, input().split()))
line[a - 1][b - 1] = 1
line[b - 1][a - 1] = 1
stack = [0]
visited = [[0]]
ans = 0
while stack:
p = stack.pop()
v = visited.pop()
for i in range(n):
... | import itertools
n, m = list(map(int, input().split()))
line = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
a, b = list(map(int, input().split()))
line[a - 1][b - 1] = 1
line[b - 1][a - 1] = 1
ans = 0
p = [i for i in range(1, n)]
for x in itertools.permutations(p):
x = list(x)
x.ins... | false | 13.793103 | [
"+import itertools",
"+",
"-stack = [0]",
"-visited = [[0]]",
"-while stack:",
"- p = stack.pop()",
"- v = visited.pop()",
"- for i in range(n):",
"- if line[p][i]:",
"- if i not in v:",
"- if len(v) == n - 1:",
"- ans += 1",
"- ... | false | 0.042104 | 0.091854 | 0.458385 | [
"s898682339",
"s776507856"
] |
u392319141 | p03800 | python | s064579092 | s760598289 | 170 | 75 | 8,356 | 5,604 | Accepted | Accepted | 55.88 | N = int(input())
S = [1 if s == 'o' else -1 for s in input()]
for first in [1, -1]:
for second in [1, -1]:
ans = [first, second]
prev = first
now = second
for s in S[1:] + [S[0]]:
if s == 1:
if now == 1:
prev, now = now, pre... | N = int(eval(input()))
S = eval(input())
def isOk(first, second):
prev, now = first, second
ret = [prev]
for s in S[1:] + S[0]:
ret.append(now)
isSame = (s == 'o')
if isSame == now:
prev, now = now, prev
else:
prev, now = now, not prev... | 25 | 26 | 733 | 591 | N = int(input())
S = [1 if s == "o" else -1 for s in input()]
for first in [1, -1]:
for second in [1, -1]:
ans = [first, second]
prev = first
now = second
for s in S[1:] + [S[0]]:
if s == 1:
if now == 1:
prev, now = now, prev
... | N = int(eval(input()))
S = eval(input())
def isOk(first, second):
prev, now = first, second
ret = [prev]
for s in S[1:] + S[0]:
ret.append(now)
isSame = s == "o"
if isSame == now:
prev, now = now, prev
else:
prev, now = now, not prev
return ret i... | false | 3.846154 | [
"-N = int(input())",
"-S = [1 if s == \"o\" else -1 for s in input()]",
"-for first in [1, -1]:",
"- for second in [1, -1]:",
"- ans = [first, second]",
"- prev = first",
"- now = second",
"- for s in S[1:] + [S[0]]:",
"- if s == 1:",
"- if ... | false | 0.061342 | 0.047358 | 1.295281 | [
"s064579092",
"s760598289"
] |
u374802266 | p03147 | python | s264261896 | s320203366 | 30 | 27 | 9,140 | 9,136 | Accepted | Accepted | 10 | n=eval(input())
def garden(a,h):
if len(a)==0:
return 0
if len(a)==1:
return a[0]-h
m=min(a)
i=a.index(m)
return m-h+garden(a[:i],m)+garden(a[i+1:],m)
print((garden(list(map(int,input().split())),0))) | def garden(a,h):
if len(a)==0:
return 0
m=min(a)
i=a.index(m)
return m-h+garden(a[:i],m)+garden(a[i+1:],m)
n=eval(input())
print((garden(list(map(int,input().split())),0))) | 10 | 8 | 237 | 195 | n = eval(input())
def garden(a, h):
if len(a) == 0:
return 0
if len(a) == 1:
return a[0] - h
m = min(a)
i = a.index(m)
return m - h + garden(a[:i], m) + garden(a[i + 1 :], m)
print((garden(list(map(int, input().split())), 0)))
| def garden(a, h):
if len(a) == 0:
return 0
m = min(a)
i = a.index(m)
return m - h + garden(a[:i], m) + garden(a[i + 1 :], m)
n = eval(input())
print((garden(list(map(int, input().split())), 0)))
| false | 20 | [
"-n = eval(input())",
"-",
"-",
"- if len(a) == 1:",
"- return a[0] - h",
"+n = eval(input())"
] | false | 0.032872 | 0.034548 | 0.95148 | [
"s264261896",
"s320203366"
] |
u471684875 | p02953 | python | s938222189 | s556806532 | 131 | 70 | 15,020 | 14,396 | Accepted | Accepted | 46.56 | import sys
input = sys.stdin.readline
n=int(eval(input()))
h=list(map(int,input().split()))
l=h
s=[]
t=max(h)
for i in range(n-1):
if l[i]-1==l[i+1]:
l[i]=l[i]-1
s.append(l[i])
elif l[i]==l[i+1] and l[i]==t:
l[i]=l[i]-1
s.a... | n=int(eval(input()))
h=list(map(int,input().split()))
if n==1:
print('Yes')
else:
c=0
for i in range(n):
if c<h[i]:
h[i]-=1
c=h[i]
elif c==h[i]:
c=h[i]
else:
print('No')
break
else:
print('Yes... | 34 | 20 | 636 | 319 | import sys
input = sys.stdin.readline
n = int(eval(input()))
h = list(map(int, input().split()))
l = h
s = []
t = max(h)
for i in range(n - 1):
if l[i] - 1 == l[i + 1]:
l[i] = l[i] - 1
s.append(l[i])
elif l[i] == l[i + 1] and l[i] == t:
l[i] = l[i] - 1
s.append(l[i])
elif l[... | n = int(eval(input()))
h = list(map(int, input().split()))
if n == 1:
print("Yes")
else:
c = 0
for i in range(n):
if c < h[i]:
h[i] -= 1
c = h[i]
elif c == h[i]:
c = h[i]
else:
print("No")
break
else:
print("Yes"... | false | 41.176471 | [
"-import sys",
"-",
"-input = sys.stdin.readline",
"-l = h",
"-s = []",
"-t = max(h)",
"-for i in range(n - 1):",
"- if l[i] - 1 == l[i + 1]:",
"- l[i] = l[i] - 1",
"- s.append(l[i])",
"- elif l[i] == l[i + 1] and l[i] == t:",
"- l[i] = l[i] - 1",
"- s.appen... | false | 0.086555 | 0.125305 | 0.690752 | [
"s938222189",
"s556806532"
] |
u706414019 | p02608 | python | s257517051 | s686010599 | 229 | 106 | 9,480 | 74,668 | Accepted | Accepted | 53.71 | #AIsing2020 c
import sys,math,collections,itertools
input = sys.stdin.readline
N = int(eval(input()))
ans = [0]*N
for x in range(1,101):
for y in range(x+1,101):
for z in range(y+1,101):
n = x**2+y**2+z**2+x*y+y*z+z*x
if n <= N:
ans[n-1] +=6
... | #AIsing2020 c
import sys,math,collections,itertools
input = sys.stdin.readline
N = int(eval(input()))
ans = [0]*N
for x in range(1,101):
for y in range(1,101):
for z in range(1,101):
n = x**2+y**2+z**2+x*y+y*z+z*x
if n <= N:
ans[n-1] +=1
... | 35 | 19 | 721 | 369 | # AIsing2020 c
import sys, math, collections, itertools
input = sys.stdin.readline
N = int(eval(input()))
ans = [0] * N
for x in range(1, 101):
for y in range(x + 1, 101):
for z in range(y + 1, 101):
n = x**2 + y**2 + z**2 + x * y + y * z + z * x
if n <= N:
ans[n - 1... | # AIsing2020 c
import sys, math, collections, itertools
input = sys.stdin.readline
N = int(eval(input()))
ans = [0] * N
for x in range(1, 101):
for y in range(1, 101):
for z in range(1, 101):
n = x**2 + y**2 + z**2 + x * y + y * z + z * x
if n <= N:
ans[n - 1] += 1
f... | false | 45.714286 | [
"- for y in range(x + 1, 101):",
"- for z in range(y + 1, 101):",
"+ for y in range(1, 101):",
"+ for z in range(1, 101):",
"- ans[n - 1] += 6",
"-for x in range(1, 101):",
"- y = x",
"- for z in range(1, 101):",
"- if z == x:",
"- continu... | false | 0.258988 | 1.169789 | 0.221397 | [
"s257517051",
"s686010599"
] |
u936985471 | p02684 | python | s809265094 | s762657113 | 1,824 | 1,661 | 32,304 | 31,352 | Accepted | Accepted | 8.94 | N,K=list(map(int,input().split()))
A=[0]+list(map(int,input().split()))
c=1
while K:
if K&1:
c=A[c]
A=[A[A[i]] for i in range(N+1)]
K>>=1
print(c) | import sys
readline = sys.stdin.readline
N,K = list(map(int,readline().split()))
A = [0] + list(map(int,readline().split()))
now = 1
while K > 0:
if K & 1:
now = A[now]
A = [A[A[i]] for i in range(len(A))]
K >>= 1
print(now) | 9 | 14 | 158 | 244 | N, K = list(map(int, input().split()))
A = [0] + list(map(int, input().split()))
c = 1
while K:
if K & 1:
c = A[c]
A = [A[A[i]] for i in range(N + 1)]
K >>= 1
print(c)
| import sys
readline = sys.stdin.readline
N, K = list(map(int, readline().split()))
A = [0] + list(map(int, readline().split()))
now = 1
while K > 0:
if K & 1:
now = A[now]
A = [A[A[i]] for i in range(len(A))]
K >>= 1
print(now)
| false | 35.714286 | [
"-N, K = list(map(int, input().split()))",
"-A = [0] + list(map(int, input().split()))",
"-c = 1",
"-while K:",
"+import sys",
"+",
"+readline = sys.stdin.readline",
"+N, K = list(map(int, readline().split()))",
"+A = [0] + list(map(int, readline().split()))",
"+now = 1",
"+while K > 0:",
"- ... | false | 0.037543 | 0.041786 | 0.898467 | [
"s809265094",
"s762657113"
] |
u764600134 | p03994 | python | s065210605 | s785942123 | 75 | 54 | 4,764 | 4,764 | Accepted | Accepted | 28 | # -*- coding: utf-8 -*-
"""
C - 次のアルファベット / Next Letter
https://atcoder.jp/contests/code-festival-2016-quala/tasks/codefestival_2016_qualA_c
"""
import sys
from string import ascii_lowercase
def solve(s, K):
ans = []
for ch in s:
distance = ascii_lowercase[::-1].index(ch) + 1
if... | # -*- coding: utf-8 -*-
"""
C - 次のアルファベット / Next Letter
https://atcoder.jp/contests/code-festival-2016-quala/tasks/codefestival_2016_qualA_c
"""
import sys
from string import ascii_lowercase
def solve(s, K):
ans = []
lut = 'a' + ascii_lowercase[::-1]
for ch in s:
distance = lut.inde... | 32 | 33 | 696 | 699 | # -*- coding: utf-8 -*-
"""
C - 次のアルファベット / Next Letter
https://atcoder.jp/contests/code-festival-2016-quala/tasks/codefestival_2016_qualA_c
"""
import sys
from string import ascii_lowercase
def solve(s, K):
ans = []
for ch in s:
distance = ascii_lowercase[::-1].index(ch) + 1
if distance <= K ... | # -*- coding: utf-8 -*-
"""
C - 次のアルファベット / Next Letter
https://atcoder.jp/contests/code-festival-2016-quala/tasks/codefestival_2016_qualA_c
"""
import sys
from string import ascii_lowercase
def solve(s, K):
ans = []
lut = "a" + ascii_lowercase[::-1]
for ch in s:
distance = lut.index(ch)
i... | false | 3.030303 | [
"+ lut = \"a\" + ascii_lowercase[::-1]",
"- distance = ascii_lowercase[::-1].index(ch) + 1",
"- if distance <= K and ch != \"a\":",
"+ distance = lut.index(ch)",
"+ if distance <= K:"
] | false | 0.06178 | 0.093726 | 0.659157 | [
"s065210605",
"s785942123"
] |
u667024514 | p03387 | python | s177903551 | s803139546 | 21 | 17 | 3,064 | 3,060 | Accepted | Accepted | 19.05 | lis = list(map(int,input().split()))
cou = 0
lis.sort()
while lis[2] - lis[0] > 1:
lis[0] +=2
cou += 1
lis.sort()
if lis[0] == lis[1] and lis[1] == lis[2]:
print(cou)
elif lis[1] == lis[2]:
print((cou + 2))
else:
print((cou + 1)) | import math
lis = list(map(int,input().split()))
lis.sort()
ans = 0
while True:
if lis[0] == lis[2]:
print(ans)
exit()
if lis[0] == lis[1]:
lis[0] += 1
lis[1] += 1
else:
lis[0] += 2
ans += 1
lis.sort() | 13 | 15 | 261 | 275 | lis = list(map(int, input().split()))
cou = 0
lis.sort()
while lis[2] - lis[0] > 1:
lis[0] += 2
cou += 1
lis.sort()
if lis[0] == lis[1] and lis[1] == lis[2]:
print(cou)
elif lis[1] == lis[2]:
print((cou + 2))
else:
print((cou + 1))
| import math
lis = list(map(int, input().split()))
lis.sort()
ans = 0
while True:
if lis[0] == lis[2]:
print(ans)
exit()
if lis[0] == lis[1]:
lis[0] += 1
lis[1] += 1
else:
lis[0] += 2
ans += 1
lis.sort()
| false | 13.333333 | [
"+import math",
"+",
"-cou = 0",
"-while lis[2] - lis[0] > 1:",
"- lis[0] += 2",
"- cou += 1",
"+ans = 0",
"+while True:",
"+ if lis[0] == lis[2]:",
"+ print(ans)",
"+ exit()",
"+ if lis[0] == lis[1]:",
"+ lis[0] += 1",
"+ lis[1] += 1",
"+ else:... | false | 0.046181 | 0.084373 | 0.547352 | [
"s177903551",
"s803139546"
] |
u708255304 | p03060 | python | s176545081 | s914032494 | 40 | 17 | 3,064 | 2,940 | Accepted | Accepted | 57.5 | N = int(eval(input()))
V = list(map(int, input().split()))
C = list(map(int, input().split()))
difer = [v - c for v, c in zip(V, C)]
ans = 0
for i in range(len(difer)):
if difer[i] >= 0:
ans += difer[i]
print(ans)
| N = int(eval(input()))
V = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
for v, c in zip(V, C):
if v-c >= 0:
ans += (v-c)
print(ans)
| 12 | 10 | 234 | 180 | N = int(eval(input()))
V = list(map(int, input().split()))
C = list(map(int, input().split()))
difer = [v - c for v, c in zip(V, C)]
ans = 0
for i in range(len(difer)):
if difer[i] >= 0:
ans += difer[i]
print(ans)
| N = int(eval(input()))
V = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
for v, c in zip(V, C):
if v - c >= 0:
ans += v - c
print(ans)
| false | 16.666667 | [
"-difer = [v - c for v, c in zip(V, C)]",
"-for i in range(len(difer)):",
"- if difer[i] >= 0:",
"- ans += difer[i]",
"+for v, c in zip(V, C):",
"+ if v - c >= 0:",
"+ ans += v - c"
] | false | 0.042961 | 0.036418 | 1.179661 | [
"s176545081",
"s914032494"
] |
u891635666 | p03148 | python | s675387989 | s552263258 | 503 | 462 | 40,288 | 41,720 | Accepted | Accepted | 8.15 | import collections
import heapq
import operator
import sys
input = sys.stdin.readline
ri = lambda: int(eval(input()))
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in r... | import collections
import heapq
import operator
import sys
input = sys.stdin.readline
ri = lambda: int(eval(input()))
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in r... | 60 | 48 | 1,325 | 1,155 | import collections
import heapq
import operator
import sys
input = sys.stdin.readline
ri = lambda: int(eval(input()))
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils... | import collections
import heapq
import operator
import sys
input = sys.stdin.readline
ri = lambda: int(eval(input()))
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils... | false | 20 | [
"-counter = collections.Counter()",
"+counter0 = collections.Counter()",
"+counter1 = collections.Counter()",
"- heapq.heappush(ls0, (d, t))",
"- counter[t] += 1",
"+ if counter0[t] > 0:",
"+ heapq.heappush(ls0, (d, t))",
"+ counter0[t] += 1",
"- if t no... | false | 0.047263 | 0.043231 | 1.093275 | [
"s675387989",
"s552263258"
] |
u809819902 | p02723 | python | s036393170 | s461306414 | 85 | 28 | 61,592 | 8,916 | Accepted | Accepted | 67.06 | s=eval(input())
res="No"
if len(s)==6 and s[2]==s[3] and s[4]==s[5]:res="Yes"
print(res) | s=eval(input())
print(("Yes" if s[2]==s[3] and s[4]==s[5] else "No")) | 4 | 2 | 85 | 62 | s = eval(input())
res = "No"
if len(s) == 6 and s[2] == s[3] and s[4] == s[5]:
res = "Yes"
print(res)
| s = eval(input())
print(("Yes" if s[2] == s[3] and s[4] == s[5] else "No"))
| false | 50 | [
"-res = \"No\"",
"-if len(s) == 6 and s[2] == s[3] and s[4] == s[5]:",
"- res = \"Yes\"",
"-print(res)",
"+print((\"Yes\" if s[2] == s[3] and s[4] == s[5] else \"No\"))"
] | false | 0.043474 | 0.042079 | 1.033156 | [
"s036393170",
"s461306414"
] |
u983918956 | p03426 | python | s520756048 | s903682384 | 710 | 514 | 48,680 | 30,944 | Accepted | Accepted | 27.61 | from itertools import accumulate
H, W, D = list(map(int,input().split()))
A = [[int(e)-1 for e in input().split()] for _ in range(H)]
Q = int(eval(input()))
query = [[int(e)-1 for e in input().split()] for _ in range(Q)]
pos = [-1]*(H*W)
for i, line in enumerate(A):
for j, a in enumerate(line):
... | H, W, D = list(map(int,input().split()))
A = [[int(e)-1 for e in input().split()] for _ in range(H)]
Q = int(eval(input()))
query = [[int(e)-1 for e in input().split()] for _ in range(Q)]
mp = [0]*(H*W)
x = [-1]*(H*W)
y = [-1]*(H*W)
for i, line in enumerate(A):
for j, a in enumerate(line):
x[a]... | 37 | 19 | 899 | 461 | from itertools import accumulate
H, W, D = list(map(int, input().split()))
A = [[int(e) - 1 for e in input().split()] for _ in range(H)]
Q = int(eval(input()))
query = [[int(e) - 1 for e in input().split()] for _ in range(Q)]
pos = [-1] * (H * W)
for i, line in enumerate(A):
for j, a in enumerate(line):
po... | H, W, D = list(map(int, input().split()))
A = [[int(e) - 1 for e in input().split()] for _ in range(H)]
Q = int(eval(input()))
query = [[int(e) - 1 for e in input().split()] for _ in range(Q)]
mp = [0] * (H * W)
x = [-1] * (H * W)
y = [-1] * (H * W)
for i, line in enumerate(A):
for j, a in enumerate(line):
... | false | 48.648649 | [
"-from itertools import accumulate",
"-",
"-pos = [-1] * (H * W)",
"+mp = [0] * (H * W)",
"+x = [-1] * (H * W)",
"+y = [-1] * (H * W)",
"- pos[a] = (i, j)",
"-mp_list = [[0] for _ in range(D)]",
"-for r in range(D):",
"- res = []",
"- for k in range(H * W):",
"- if r + k * ... | false | 0.042255 | 0.104634 | 0.403832 | [
"s520756048",
"s903682384"
] |
u464205401 | p03612 | python | s104265560 | s861432019 | 86 | 79 | 20,344 | 20,676 | Accepted | Accepted | 8.14 | n = int(eval(input()))
p = list(map(int,input().split()))
cnt = 0
tmp = [-1,-1]
for i in range(n):
if p[i] == i+1:
if i+1 == tmp[0]+1 and p[i]==tmp[1]+1:
cnt+=0
tmp = [-1, -1]
else:
cnt+=1
tmp = [i+1,p[i]]
# print(p[i],tmp,cnt)
print(cnt) | n = int(eval(input()))
p = list(map(int,input().split()))
cnt = 0
tmp = -1
for i in range(n):
if p[i] == i+1:
if i+1 == tmp+1:
cnt+=0
tmp = -1
else:
cnt+=1
tmp = i+1
print(cnt) | 15 | 14 | 290 | 223 | n = int(eval(input()))
p = list(map(int, input().split()))
cnt = 0
tmp = [-1, -1]
for i in range(n):
if p[i] == i + 1:
if i + 1 == tmp[0] + 1 and p[i] == tmp[1] + 1:
cnt += 0
tmp = [-1, -1]
else:
cnt += 1
tmp = [i + 1, p[i]]
# print(p[i],tmp,cnt)
pr... | n = int(eval(input()))
p = list(map(int, input().split()))
cnt = 0
tmp = -1
for i in range(n):
if p[i] == i + 1:
if i + 1 == tmp + 1:
cnt += 0
tmp = -1
else:
cnt += 1
tmp = i + 1
print(cnt)
| false | 6.666667 | [
"-tmp = [-1, -1]",
"+tmp = -1",
"- if i + 1 == tmp[0] + 1 and p[i] == tmp[1] + 1:",
"+ if i + 1 == tmp + 1:",
"- tmp = [-1, -1]",
"+ tmp = -1",
"- tmp = [i + 1, p[i]]",
"-# print(p[i],tmp,cnt)",
"+ tmp = i + 1"
] | false | 0.043678 | 0.047654 | 0.916559 | [
"s104265560",
"s861432019"
] |
u350997995 | p03147 | python | s412836418 | s023515339 | 44 | 17 | 3,064 | 2,940 | Accepted | Accepted | 61.36 | N = int(eval(input()))
h = list(map(int,input().split()))
count = 0
while(h.count(0)!=N):
for k in range(N):
if h[k]!=0:
break
for j in range(k,N):
if h[j]==0:
j-=1
break
for i in range(k,j+1):
h[i]-=1
count+=1
print(count) | N = int(eval(input()))
h = list(map(int,input().split()))
count = h[0]
x = h[0]
for i in range(N):
if x<h[i]:
count+=h[i]-x
x = h[i]
print(count)
| 15 | 9 | 307 | 156 | N = int(eval(input()))
h = list(map(int, input().split()))
count = 0
while h.count(0) != N:
for k in range(N):
if h[k] != 0:
break
for j in range(k, N):
if h[j] == 0:
j -= 1
break
for i in range(k, j + 1):
h[i] -= 1
count += 1
print(count)
| N = int(eval(input()))
h = list(map(int, input().split()))
count = h[0]
x = h[0]
for i in range(N):
if x < h[i]:
count += h[i] - x
x = h[i]
print(count)
| false | 40 | [
"-count = 0",
"-while h.count(0) != N:",
"- for k in range(N):",
"- if h[k] != 0:",
"- break",
"- for j in range(k, N):",
"- if h[j] == 0:",
"- j -= 1",
"- break",
"- for i in range(k, j + 1):",
"- h[i] -= 1",
"- count += 1",
... | false | 0.044825 | 0.033331 | 1.344837 | [
"s412836418",
"s023515339"
] |
u641406334 | p03137 | python | s772336793 | s472479762 | 138 | 119 | 13,960 | 13,968 | Accepted | Accepted | 13.77 | n, m = list(map(int, input().split()))
k = list(map(int, input().split()))
d = [0]*(m-1)
k.sort()
for i in range(m-1):
d[i] = abs(k[i]-k[i+1])
d = sorted(d, reverse=True)
res = 0
for i in range(n-1):
if i==m-1:
break
res += d[i]
print((sum(d)-res))
| n, m = list(map(int, input().split()))
k = list(map(int, input().split()))
d = [0]*(m-1)
k.sort()
for i in range(m-1):
d[i] = abs(k[i]-k[i+1])
d = sorted(d, reverse=True)
print((sum(d)-sum(d[:n-1])))
| 13 | 8 | 273 | 203 | n, m = list(map(int, input().split()))
k = list(map(int, input().split()))
d = [0] * (m - 1)
k.sort()
for i in range(m - 1):
d[i] = abs(k[i] - k[i + 1])
d = sorted(d, reverse=True)
res = 0
for i in range(n - 1):
if i == m - 1:
break
res += d[i]
print((sum(d) - res))
| n, m = list(map(int, input().split()))
k = list(map(int, input().split()))
d = [0] * (m - 1)
k.sort()
for i in range(m - 1):
d[i] = abs(k[i] - k[i + 1])
d = sorted(d, reverse=True)
print((sum(d) - sum(d[: n - 1])))
| false | 38.461538 | [
"-res = 0",
"-for i in range(n - 1):",
"- if i == m - 1:",
"- break",
"- res += d[i]",
"-print((sum(d) - res))",
"+print((sum(d) - sum(d[: n - 1])))"
] | false | 0.007081 | 0.041694 | 0.169835 | [
"s772336793",
"s472479762"
] |
u051684204 | p02911 | python | s009723273 | s802520571 | 553 | 251 | 56,664 | 9,376 | Accepted | Accepted | 54.61 | N,K,Q=list(map(int,input().split()))
a = [int(eval(input())) for i in range(Q)]
point=[0 for i in range(N)]
for i in range(Q):
point[a[i]-1]=point[a[i]-1]+1
for j in range(N):
if point[j]>=Q-K+1:
print("Yes")
else:
print("No") | from collections import deque
N,K,Q=list(map(int,input().split()))
ls=[int(eval(input()))-1 for i in range(Q)]
que=deque(ls)
co=[0 for i in range(N)]
for j in range(Q):
co[que.popleft()]+=1
for i in co:
if i>Q-K:
print("Yes")
else:
print("No") | 10 | 12 | 237 | 256 | N, K, Q = list(map(int, input().split()))
a = [int(eval(input())) for i in range(Q)]
point = [0 for i in range(N)]
for i in range(Q):
point[a[i] - 1] = point[a[i] - 1] + 1
for j in range(N):
if point[j] >= Q - K + 1:
print("Yes")
else:
print("No")
| from collections import deque
N, K, Q = list(map(int, input().split()))
ls = [int(eval(input())) - 1 for i in range(Q)]
que = deque(ls)
co = [0 for i in range(N)]
for j in range(Q):
co[que.popleft()] += 1
for i in co:
if i > Q - K:
print("Yes")
else:
print("No")
| false | 16.666667 | [
"+from collections import deque",
"+",
"-a = [int(eval(input())) for i in range(Q)]",
"-point = [0 for i in range(N)]",
"-for i in range(Q):",
"- point[a[i] - 1] = point[a[i] - 1] + 1",
"-for j in range(N):",
"- if point[j] >= Q - K + 1:",
"+ls = [int(eval(input())) - 1 for i in range(Q)]",
... | false | 0.040579 | 0.039515 | 1.026913 | [
"s009723273",
"s802520571"
] |
u687159441 | p02779 | python | s235327367 | s844514630 | 111 | 76 | 33,996 | 31,156 | Accepted | Accepted | 31.53 | import collections
n = int(eval(input()))
a = list(map(int, input().split()))
# リストaの要素の出現回数を計算
s = collections.Counter(a)
# 出現回数の最大値を取得
max_s = max(s.values())
if max_s == 1:
print('YES')
else:
print('NO') | n = int(eval(input()))
# 被りの要素が削除される
a = set(input().split())
print(('YES' if len(a) == n else 'NO')) | 15 | 5 | 226 | 98 | import collections
n = int(eval(input()))
a = list(map(int, input().split()))
# リストaの要素の出現回数を計算
s = collections.Counter(a)
# 出現回数の最大値を取得
max_s = max(s.values())
if max_s == 1:
print("YES")
else:
print("NO")
| n = int(eval(input()))
# 被りの要素が削除される
a = set(input().split())
print(("YES" if len(a) == n else "NO"))
| false | 66.666667 | [
"-import collections",
"-",
"-a = list(map(int, input().split()))",
"-# リストaの要素の出現回数を計算",
"-s = collections.Counter(a)",
"-# 出現回数の最大値を取得",
"-max_s = max(s.values())",
"-if max_s == 1:",
"- print(\"YES\")",
"-else:",
"- print(\"NO\")",
"+# 被りの要素が削除される",
"+a = set(input().split())",
"+... | false | 0.098492 | 0.037779 | 2.607076 | [
"s235327367",
"s844514630"
] |
u683987726 | p02685 | python | s306627945 | s279811663 | 1,178 | 632 | 24,636 | 24,644 | Accepted | Accepted | 46.35 | MOD = 998244353
MAX = int(2e5 + 5)
fact = [0] * MAX
invFact = [0] * MAX
def bigmod(a, b):
if b == 0:
return 1
ret = bigmod(a, b // 2)
ret = (ret * ret) % MOD
if b % 2 == 1:
ret = (ret * a) % MOD
return ret
def mod_inverse(a):
return bigmod(a, MOD - 2)
def pre():
global fact, invF... | MOD = 998244353
MAX = int(2e5 + 5)
fact = [0] * MAX
invFact = [0] * MAX
def mod_inverse(a):
return pow(a, MOD - 2, MOD)
def pre():
global fact, invFact
fact[0] = 1
for i in range(1, MAX):
fact[i] = (fact[i - 1] * i) % MOD
invFact[MAX - 1] = mod_inverse(fact[MAX - 1])
for i in range(MAX - 2... | 47 | 37 | 829 | 678 | MOD = 998244353
MAX = int(2e5 + 5)
fact = [0] * MAX
invFact = [0] * MAX
def bigmod(a, b):
if b == 0:
return 1
ret = bigmod(a, b // 2)
ret = (ret * ret) % MOD
if b % 2 == 1:
ret = (ret * a) % MOD
return ret
def mod_inverse(a):
return bigmod(a, MOD - 2)
def pre():
global ... | MOD = 998244353
MAX = int(2e5 + 5)
fact = [0] * MAX
invFact = [0] * MAX
def mod_inverse(a):
return pow(a, MOD - 2, MOD)
def pre():
global fact, invFact
fact[0] = 1
for i in range(1, MAX):
fact[i] = (fact[i - 1] * i) % MOD
invFact[MAX - 1] = mod_inverse(fact[MAX - 1])
for i in range(M... | false | 21.276596 | [
"-def bigmod(a, b):",
"- if b == 0:",
"- return 1",
"- ret = bigmod(a, b // 2)",
"- ret = (ret * ret) % MOD",
"- if b % 2 == 1:",
"- ret = (ret * a) % MOD",
"- return ret",
"-",
"-",
"- return bigmod(a, MOD - 2)",
"+ return pow(a, MOD - 2, MOD)",
"- ans ... | false | 0.752493 | 0.263503 | 2.855724 | [
"s306627945",
"s279811663"
] |
u440566786 | p02925 | python | s771761620 | s734365362 | 1,848 | 639 | 169,088 | 65,500 | Accepted | Accepted | 65.42 | import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
n=int(eval(input()))
# id table
N=0
id=[[None]*n for _ in range(n)]
from itertools import product
for i,j in product(list(range(n)),repeat=2):
... | import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
n=int(eval(input()))
M=[None]*n
for i in range(n):
M[i]=list([int(x)-1 for x in input().split()])[::-1]
# i が誰かしらと対戦できるか
def check(i):
if(... | 45 | 51 | 1,094 | 1,258 | import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().rstrip()
def resolve():
n = int(eval(input()))
# id table
N = 0
id = [[None] * n for _ in range(n)]
from itertools import product
for i, j in product(list(range(n)), repeat=2)... | import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().rstrip()
def resolve():
n = int(eval(input()))
M = [None] * n
for i in range(n):
M[i] = list([int(x) - 1 for x in input().split()])[::-1]
# i が誰かしらと対戦できるか
def check(i):
... | false | 11.764706 | [
"- # id table",
"- N = 0",
"- id = [[None] * n for _ in range(n)]",
"- from itertools import product",
"+ M = [None] * n",
"+ for i in range(n):",
"+ M[i] = list([int(x) - 1 for x in input().split()])[::-1]",
"+ # i が誰かしらと対戦できるか",
"+ def check(i):",
"+ if not ... | false | 0.039936 | 0.040014 | 0.998043 | [
"s771761620",
"s734365362"
] |
u126227204 | p02888 | python | s092158051 | s625247416 | 1,284 | 991 | 3,188 | 89,536 | Accepted | Accepted | 22.82 | N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
count = 0
for i in range(N):
a = L[i]
k = i+2
for j in range(i+1,N):
b = L[j]
while k < N and a+b > L[k]:
k += 1
count += k - 1 - j
print(count)
| #coding:utf-8
import sys
import bisect
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
input = lambda : given().rstrip()
LMIIS = lambda : list(map(int,input().split()))
II = lambda... | 17 | 27 | 275 | 665 | N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
count = 0
for i in range(N):
a = L[i]
k = i + 2
for j in range(i + 1, N):
b = L[j]
while k < N and a + b > L[k]:
k += 1
count += k - 1 - j
print(count)
| # coding:utf-8
import sys
import bisect
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something: print(*something) if DEBUG else 0
DEBUG = False
def main(given=sys.stdin.readline):
input = lambda: given().rstrip()
LMIIS = lambda: list(map(int, input().split()))
II = lambda: int(inpu... | false | 37.037037 | [
"-N = int(eval(input()))",
"-L = list(map(int, input().split()))",
"-L.sort()",
"-count = 0",
"-for i in range(N):",
"- a = L[i]",
"- k = i + 2",
"- for j in range(i + 1, N):",
"- b = L[j]",
"- while k < N and a + b > L[k]:",
"- k += 1",
"- count += k -... | false | 0.039041 | 0.086124 | 0.453313 | [
"s092158051",
"s625247416"
] |
u368796742 | p02670 | python | s651690962 | s994834088 | 1,977 | 1,653 | 185,620 | 196,216 | Accepted | Accepted | 16.39 | def main():
import sys
input = sys.stdin.readline
n = int(eval(input()))
l = list(map(int,input().split()))
check = [[True]*n for i in range(n)]
d = [[min(i, n-i-1, j, n-j-1) for j in range(n)] for i in range(n)]
ans = 0
for t in l:
t -=1
x = t//n
y ... | def main():
import sys
input = sys.stdin.readline
n = int(eval(input()))
l = list(map(int,input().split()))
check = [[1 for j in range(n)] for i in range(n)]
d = [[min(i, n-i-1, j, n-j-1) for j in range(n)] for i in range(n)]
ans = 0
for t in l:
t -=1
x = t//... | 39 | 39 | 1,165 | 1,175 | def main():
import sys
input = sys.stdin.readline
n = int(eval(input()))
l = list(map(int, input().split()))
check = [[True] * n for i in range(n)]
d = [[min(i, n - i - 1, j, n - j - 1) for j in range(n)] for i in range(n)]
ans = 0
for t in l:
t -= 1
x = t // n
y... | def main():
import sys
input = sys.stdin.readline
n = int(eval(input()))
l = list(map(int, input().split()))
check = [[1 for j in range(n)] for i in range(n)]
d = [[min(i, n - i - 1, j, n - j - 1) for j in range(n)] for i in range(n)]
ans = 0
for t in l:
t -= 1
x = t // ... | false | 0 | [
"- check = [[True] * n for i in range(n)]",
"+ check = [[1 for j in range(n)] for i in range(n)]",
"- check[x][y] = False",
"+ check[x][y] = 0",
"- q.append([x, y, d[x][y]])",
"+ q.append((x, y, d[x][y]))",
"- q.append([bx - 1, by, z + check[bx - 1][b... | false | 0.104565 | 0.042222 | 2.47657 | [
"s651690962",
"s994834088"
] |
u210827208 | p02972 | python | s764669551 | s429267417 | 360 | 255 | 68,188 | 7,148 | Accepted | Accepted | 29.17 | n=int(eval(input()))
A=[0]+list(map(int,input().split()))
for i in reversed(list(range(1,n+1))):
if sum(A[::i])%2!=A[i]:
A[i]^=1
print((sum(A)))
if sum(A)!=0:
for i,a in enumerate(A):
if a==1:
print(i) | n=int(eval(input()))
A=[0]+list(map(int,input().split()))
for i in reversed(list(range(1,n+1))):
if sum(A[::i])%2!=A[i]:
if A[i]==0:
A[i]=1
else:
A[i]=0
print((sum(A)))
if sum(A)!=0:
for i,a in enumerate(A):
if a==1:
print(i) | 13 | 16 | 246 | 305 | n = int(eval(input()))
A = [0] + list(map(int, input().split()))
for i in reversed(list(range(1, n + 1))):
if sum(A[::i]) % 2 != A[i]:
A[i] ^= 1
print((sum(A)))
if sum(A) != 0:
for i, a in enumerate(A):
if a == 1:
print(i)
| n = int(eval(input()))
A = [0] + list(map(int, input().split()))
for i in reversed(list(range(1, n + 1))):
if sum(A[::i]) % 2 != A[i]:
if A[i] == 0:
A[i] = 1
else:
A[i] = 0
print((sum(A)))
if sum(A) != 0:
for i, a in enumerate(A):
if a == 1:
print(i)
| false | 18.75 | [
"- A[i] ^= 1",
"+ if A[i] == 0:",
"+ A[i] = 1",
"+ else:",
"+ A[i] = 0"
] | false | 0.077661 | 0.041273 | 1.881645 | [
"s764669551",
"s429267417"
] |
u945181840 | p03018 | python | s553488751 | s592952901 | 65 | 55 | 5,664 | 5,668 | Accepted | Accepted | 15.38 | import re
s = input().replace('BC', 'X')
S = re.split('[BC]', s)
answer = 0
for i in S:
tmp = 0
for j in i:
if j == 'A':
tmp += 1
elif j == 'X':
answer += tmp
print(answer) | import re
def main():
s = input().replace('BC', 'X')
S = re.split('[BC]', s)
answer = 0
for i in S:
tmp = 0
for j in i:
if j == 'A':
tmp += 1
else:
answer += tmp
print(answer)
if __name__ == '__main__':
... | 16 | 21 | 239 | 331 | import re
s = input().replace("BC", "X")
S = re.split("[BC]", s)
answer = 0
for i in S:
tmp = 0
for j in i:
if j == "A":
tmp += 1
elif j == "X":
answer += tmp
print(answer)
| import re
def main():
s = input().replace("BC", "X")
S = re.split("[BC]", s)
answer = 0
for i in S:
tmp = 0
for j in i:
if j == "A":
tmp += 1
else:
answer += tmp
print(answer)
if __name__ == "__main__":
main()
| false | 23.809524 | [
"-s = input().replace(\"BC\", \"X\")",
"-S = re.split(\"[BC]\", s)",
"-answer = 0",
"-for i in S:",
"- tmp = 0",
"- for j in i:",
"- if j == \"A\":",
"- tmp += 1",
"- elif j == \"X\":",
"- answer += tmp",
"-print(answer)",
"+",
"+def main():",
"+ ... | false | 0.044766 | 0.040116 | 1.115918 | [
"s553488751",
"s592952901"
] |
u690536347 | p04013 | python | s314761103 | s800736985 | 479 | 418 | 95,964 | 92,784 | Accepted | Accepted | 12.73 | n,a=list(map(int,input().split()))
l=list(map(int,input().split()))
x=max(l)
x=max(x,a)
dp=[[[0 for _ in range(n*x+1)] for _ in range(n+1)] for _ in range(n+1)]
for j in range(n+1):
for k in range(n+1):
for s in range(n*x+1):
if j==0 and k==0 and s==0:
dp[j][k][s]=1
elif j>=1 and s... | n,a=list(map(int,input().split()))
*x,=list(map(int,input().split()))
dp=[[[0]*(n*50+1) for i in range(n+1)] for _ in range(n+1)]
for i in range(n+1):
for j in range(n+1):
for k in range(n*50+1):
if i==0 and j==0 and k==0:
dp[i][j][k]=1
elif i and k<x[i-1]:
... | 23 | 17 | 555 | 558 | n, a = list(map(int, input().split()))
l = list(map(int, input().split()))
x = max(l)
x = max(x, a)
dp = [[[0 for _ in range(n * x + 1)] for _ in range(n + 1)] for _ in range(n + 1)]
for j in range(n + 1):
for k in range(n + 1):
for s in range(n * x + 1):
if j == 0 and k == 0 and s == 0:
... | n, a = list(map(int, input().split()))
(*x,) = list(map(int, input().split()))
dp = [[[0] * (n * 50 + 1) for i in range(n + 1)] for _ in range(n + 1)]
for i in range(n + 1):
for j in range(n + 1):
for k in range(n * 50 + 1):
if i == 0 and j == 0 and k == 0:
dp[i][j][k] = 1
... | false | 26.086957 | [
"-l = list(map(int, input().split()))",
"-x = max(l)",
"-x = max(x, a)",
"-dp = [[[0 for _ in range(n * x + 1)] for _ in range(n + 1)] for _ in range(n + 1)]",
"-for j in range(n + 1):",
"- for k in range(n + 1):",
"- for s in range(n * x + 1):",
"- if j == 0 and k == 0 and s == 0... | false | 0.047815 | 0.049559 | 0.964815 | [
"s314761103",
"s800736985"
] |
u784022244 | p02820 | python | s424801849 | s997196120 | 108 | 79 | 12,712 | 4,788 | Accepted | Accepted | 26.85 | N, K=list(map(int, input().split()))
R, S, P=list(map(int, input().split()))
T=list(eval(input()))
row=[]
for i in range(K):
row.append(T[i::K])
score=0
for r in row:
pre="n"
for i, hand in enumerate(r):
if hand==pre:
pre=0
else:
if hand=="r":
score+=P
pre=... | N,K=list(map(int, input().split()))
R,S,P=list(map(int, input().split()))
T=list(eval(input()))
D={"r":P, "s":R, "p":S}
result=["none"]*N
ans=0
for i in range(N):
if i<K:
ans+=D[T[i]]
result[i]=T[i]
else:
if T[i]!=result[i-K]:
ans+=D[T[i]]
result[i]=T... | 26 | 15 | 435 | 317 | N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = list(eval(input()))
row = []
for i in range(K):
row.append(T[i::K])
score = 0
for r in row:
pre = "n"
for i, hand in enumerate(r):
if hand == pre:
pre = 0
else:
if hand == "r":
... | N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = list(eval(input()))
D = {"r": P, "s": R, "p": S}
result = ["none"] * N
ans = 0
for i in range(N):
if i < K:
ans += D[T[i]]
result[i] = T[i]
else:
if T[i] != result[i - K]:
ans += D[T[i]]
... | false | 42.307692 | [
"-row = []",
"-for i in range(K):",
"- row.append(T[i::K])",
"-score = 0",
"-for r in row:",
"- pre = \"n\"",
"- for i, hand in enumerate(r):",
"- if hand == pre:",
"- pre = 0",
"- else:",
"- if hand == \"r\":",
"- score += P",
"- ... | false | 0.09881 | 0.037085 | 2.664424 | [
"s424801849",
"s997196120"
] |
u617384447 | p02615 | python | s779619178 | s397090148 | 155 | 136 | 31,376 | 105,040 | Accepted | Accepted | 12.26 | conf = 0
num_char = int(eval(input()))
char = list(map(int, input().split()))
char.sort(reverse=True)
count = 0
conf_int = 0
for i in range(num_char):
if count == 0:
count = 1
elif count == 1:
count = 2
conf = char[conf_int]
count_int = 0
conf_int = 1
else:
if count_int == 0... | N = int(eval(input()))
As = sorted(map(int, input().split()), reverse=True)
score = As[0]
counter = 0
index = 1
for i in range(2, N):
score += As[index]
if counter == 0:
counter += 1
else:
counter -= 1
index += 1
print(score)
| 23 | 22 | 463 | 292 | conf = 0
num_char = int(eval(input()))
char = list(map(int, input().split()))
char.sort(reverse=True)
count = 0
conf_int = 0
for i in range(num_char):
if count == 0:
count = 1
elif count == 1:
count = 2
conf = char[conf_int]
count_int = 0
conf_int = 1
else:
if... | N = int(eval(input()))
As = sorted(map(int, input().split()), reverse=True)
score = As[0]
counter = 0
index = 1
for i in range(2, N):
score += As[index]
if counter == 0:
counter += 1
else:
counter -= 1
index += 1
print(score)
| false | 4.347826 | [
"-conf = 0",
"-num_char = int(eval(input()))",
"-char = list(map(int, input().split()))",
"-char.sort(reverse=True)",
"-count = 0",
"-conf_int = 0",
"-for i in range(num_char):",
"- if count == 0:",
"- count = 1",
"- elif count == 1:",
"- count = 2",
"- conf = char[c... | false | 0.045717 | 0.045638 | 1.00172 | [
"s779619178",
"s397090148"
] |
u754022296 | p03163 | python | s319732584 | s780842719 | 1,570 | 172 | 17,000 | 14,596 | Accepted | Accepted | 89.04 | import sys
input = sys.stdin.readline
import numpy as np
def main():
n, W = list(map(int, input().split()))
dp = np.zeros(W+1, dtype=np.int64)
for _ in range(n):
w, v = list(map(int, input().split()))
dp[w:W+1] = np.array((dp[:W-w+1]+v, dp[w:W+1])).max(axis=0)
print((dp[W]))
if __name_... | import sys
input = sys.stdin.readline
import numpy as np
def main():
n, W = list(map(int, input().split()))
dp = np.zeros(W+1, dtype=np.int64)
for _ in range(n):
w, v = list(map(int, input().split()))
np.maximum(dp[:W-w+1]+v, dp[w:W+1], out=dp[w:W+1])
print((dp[W]))
if __name__ == "__m... | 15 | 15 | 332 | 323 | import sys
input = sys.stdin.readline
import numpy as np
def main():
n, W = list(map(int, input().split()))
dp = np.zeros(W + 1, dtype=np.int64)
for _ in range(n):
w, v = list(map(int, input().split()))
dp[w : W + 1] = np.array((dp[: W - w + 1] + v, dp[w : W + 1])).max(axis=0)
print((... | import sys
input = sys.stdin.readline
import numpy as np
def main():
n, W = list(map(int, input().split()))
dp = np.zeros(W + 1, dtype=np.int64)
for _ in range(n):
w, v = list(map(int, input().split()))
np.maximum(dp[: W - w + 1] + v, dp[w : W + 1], out=dp[w : W + 1])
print((dp[W]))
... | false | 0 | [
"- dp[w : W + 1] = np.array((dp[: W - w + 1] + v, dp[w : W + 1])).max(axis=0)",
"+ np.maximum(dp[: W - w + 1] + v, dp[w : W + 1], out=dp[w : W + 1])"
] | false | 0.280536 | 0.172724 | 1.62419 | [
"s319732584",
"s780842719"
] |
u816428863 | p03339 | python | s696645202 | s937716989 | 275 | 179 | 31,692 | 5,924 | Accepted | Accepted | 34.91 | n=int(eval(input()))
s=list(eval(input()))
count_east=[0]*n
count_west=[0]*n
counts=[0]*n
for i in range(n-2,-1,-1):
if s[i+1]=='E':
count_east[i]=count_east[i+1]+1
else:
count_east[i]=count_east[i+1]
for i in range(1,n):
if s[i-1]=='W':
count_west[i]=count_west[i-1]+1
... | n = int(eval(input()))
s = list(eval(input()))
num_E = s.count("E")
num_W = 0
ans = float("inf")
for i in range(n):
if s[i] == "W":
ans=min(ans , num_E + num_W)
num_W += 1
else:
num_E -= 1
ans=min(ans , num_E + num_W)
print(ans) | 20 | 16 | 442 | 278 | n = int(eval(input()))
s = list(eval(input()))
count_east = [0] * n
count_west = [0] * n
counts = [0] * n
for i in range(n - 2, -1, -1):
if s[i + 1] == "E":
count_east[i] = count_east[i + 1] + 1
else:
count_east[i] = count_east[i + 1]
for i in range(1, n):
if s[i - 1] == "W":
count_w... | n = int(eval(input()))
s = list(eval(input()))
num_E = s.count("E")
num_W = 0
ans = float("inf")
for i in range(n):
if s[i] == "W":
ans = min(ans, num_E + num_W)
num_W += 1
else:
num_E -= 1
ans = min(ans, num_E + num_W)
print(ans)
| false | 20 | [
"-count_east = [0] * n",
"-count_west = [0] * n",
"-counts = [0] * n",
"-for i in range(n - 2, -1, -1):",
"- if s[i + 1] == \"E\":",
"- count_east[i] = count_east[i + 1] + 1",
"+num_E = s.count(\"E\")",
"+num_W = 0",
"+ans = float(\"inf\")",
"+for i in range(n):",
"+ if s[i] == \"W\... | false | 0.040531 | 0.039655 | 1.022082 | [
"s696645202",
"s937716989"
] |
u631277801 | p03504 | python | s593654263 | s350177968 | 1,627 | 1,059 | 51,884 | 46,880 | Accepted | Accepted | 34.91 | import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.rea... | import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.re... | 39 | 45 | 955 | 1,061 | import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li():
return list(map(int, stdin.readline().split()))
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return list(map(float, stdin.readline().split()))
def ls():
return stdin.readline().split()
def ns():
... | import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li():
return list(map(int, stdin.readline().split()))
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return list(map(float, stdin.readline().split()))
def ls():
return stdin.readline().split()
def ns():
... | false | 13.333333 | [
"-N, C = li()",
"-MAX = 10**5",
"+n, ch = li()",
"+MAX_T = 10**5 + 1",
"+program = [[0] * MAX_T for _ in range(ch)]",
"+endset = [set() for _ in range(ch)]",
"-for _ in range(N):",
"- stc.append(list(li()))",
"-rec = [[0 for _ in range(MAX + 1)] for _ in range(C)]",
"+for _ in range(n):",
"+ ... | false | 0.268118 | 0.067792 | 3.955 | [
"s593654263",
"s350177968"
] |
u285022453 | p02678 | python | s868339306 | s821380728 | 673 | 485 | 37,696 | 37,796 | Accepted | Accepted | 27.93 | #!/usr/bin/env python3
from collections import deque
# import sys
# input = sys.std.readline
n, m = list(map(int, input().split()))
edges = [[] for _ in range(n)]
for _ in range(m):
a, b = list(map(int, input().split()))
edges[a - 1].append(b - 1)
edges[b - 1].append(a - 1)
que = deque()
dist... | #!/usr/bin/env python3
from collections import deque
import sys
input = sys.stdin.readline
n, m = list(map(int, input().split()))
edges = [[] for _ in range(n)]
for _ in range(m):
a, b = list(map(int, input().split()))
edges[a - 1].append(b - 1)
edges[b - 1].append(a - 1)
que = deque()
dist =... | 30 | 30 | 648 | 646 | #!/usr/bin/env python3
from collections import deque
# import sys
# input = sys.std.readline
n, m = list(map(int, input().split()))
edges = [[] for _ in range(n)]
for _ in range(m):
a, b = list(map(int, input().split()))
edges[a - 1].append(b - 1)
edges[b - 1].append(a - 1)
que = deque()
dist = [float("inf... | #!/usr/bin/env python3
from collections import deque
import sys
input = sys.stdin.readline
n, m = list(map(int, input().split()))
edges = [[] for _ in range(n)]
for _ in range(m):
a, b = list(map(int, input().split()))
edges[a - 1].append(b - 1)
edges[b - 1].append(a - 1)
que = deque()
dist = [float("inf")... | false | 0 | [
"+import sys",
"-# import sys",
"-# input = sys.std.readline",
"+input = sys.stdin.readline"
] | false | 0.033979 | 0.036863 | 0.921767 | [
"s868339306",
"s821380728"
] |
u919730120 | p03161 | python | s540714346 | s540063706 | 1,995 | 1,513 | 13,928 | 22,920 | Accepted | Accepted | 24.16 | n,k=list(map(int,input().split()))
h=list(map(int,input().split()))
c=[0]*n
for i in range(1,n):
c[i]=min([cj+abs(h[i]-hj) for cj,hj in zip(c[max(0,i-k):i],h[max(0,i-k):i])])
print((c[-1])) | import numpy as np
n,k=list(map(int,input().split()))
h=np.array(list(map(int,input().split()))+[0]*k)
dp = np.full(n+k, 10 ** 10, dtype=np.int64)
dp[0] = 0
for i in range(1,n):
dp[i:i+k]=np.minimum(dp[i:i+k],np.abs(h[i:i+k]-h[i-1])+dp[i-1])
print((dp[n-1])) | 6 | 8 | 190 | 261 | n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
c = [0] * n
for i in range(1, n):
c[i] = min(
[
cj + abs(h[i] - hj)
for cj, hj in zip(c[max(0, i - k) : i], h[max(0, i - k) : i])
]
)
print((c[-1]))
| import numpy as np
n, k = list(map(int, input().split()))
h = np.array(list(map(int, input().split())) + [0] * k)
dp = np.full(n + k, 10**10, dtype=np.int64)
dp[0] = 0
for i in range(1, n):
dp[i : i + k] = np.minimum(
dp[i : i + k], np.abs(h[i : i + k] - h[i - 1]) + dp[i - 1]
)
print((dp[n - 1]))
| false | 25 | [
"+import numpy as np",
"+",
"-h = list(map(int, input().split()))",
"-c = [0] * n",
"+h = np.array(list(map(int, input().split())) + [0] * k)",
"+dp = np.full(n + k, 10**10, dtype=np.int64)",
"+dp[0] = 0",
"- c[i] = min(",
"- [",
"- cj + abs(h[i] - hj)",
"- for cj... | false | 0.035469 | 0.195411 | 0.181508 | [
"s540714346",
"s540063706"
] |
u784022244 | p02834 | python | s302921182 | s696224850 | 903 | 352 | 102,420 | 91,216 | Accepted | Accepted | 61.02 | N,u,v=list(map(int, input().split()))
import sys
sys.setrecursionlimit(10**6)
T=[[] for _ in range(N)]
for i in range(N-1):
a,b=list(map(int, input().split()))
T[a-1].append(b-1)
T[b-1].append(a-1)
def dfs(start):
tolist=T[start]
nowd=done[start]
for next_n in tolist:
if ... | N,u,v=list(map(int, input().split()))
G=[[] for _ in range(N)]
for i in range(N-1):
a,b=list(map(int, input().split()))
G[a-1].append(b-1)
G[b-1].append(a-1)
from collections import deque
q=deque([])
q.append((v-1,0))
done1=[-1]*N
while q:
now, dist = q.popleft()
done1[now]=d... | 33 | 45 | 603 | 798 | N, u, v = list(map(int, input().split()))
import sys
sys.setrecursionlimit(10**6)
T = [[] for _ in range(N)]
for i in range(N - 1):
a, b = list(map(int, input().split()))
T[a - 1].append(b - 1)
T[b - 1].append(a - 1)
def dfs(start):
tolist = T[start]
nowd = done[start]
for next_n in tolist:
... | N, u, v = list(map(int, input().split()))
G = [[] for _ in range(N)]
for i in range(N - 1):
a, b = list(map(int, input().split()))
G[a - 1].append(b - 1)
G[b - 1].append(a - 1)
from collections import deque
q = deque([])
q.append((v - 1, 0))
done1 = [-1] * N
while q:
now, dist = q.popleft()
done1[n... | false | 26.666667 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**6)",
"-T = [[] for _ in range(N)]",
"+G = [[] for _ in range(N)]",
"- T[a - 1].append(b - 1)",
"- T[b - 1].append(a - 1)",
"+ G[a - 1].append(b - 1)",
"+ G[b - 1].append(a - 1)",
"+from collections import deque",
"-",
"-def dfs(start)... | false | 0.037198 | 0.035245 | 1.055418 | [
"s302921182",
"s696224850"
] |
u644907318 | p03475 | python | s254960731 | s325982327 | 207 | 104 | 40,688 | 74,252 | Accepted | Accepted | 49.76 | N = int(eval(input()))
A = [list(map(int,input().split())) for _ in range(N-1)]
A.insert(0,0)
B = [0 for _ in range(N+1)]
for i in range(1,N):
C1,S1,F1 = A[i]
T = S1
for j in range(i+1,N):
C2,S2,F2 = A[j]
if T+C1>=S2:
dt = (T+C1)%F2
if dt>0:
... | import math
N = int(eval(input()))
A = [list(map(int,input().split())) for _ in range(N-1)]
A.insert(0,0)
for i in range(1,N):
C,S,F = A[i]
T = S+C
j = i+1
while j<N:
C,S,F = A[j]
T = max(S,math.ceil(T/F)*F)
T += C
j += 1
print(T)
print((0)) | 24 | 15 | 527 | 299 | N = int(eval(input()))
A = [list(map(int, input().split())) for _ in range(N - 1)]
A.insert(0, 0)
B = [0 for _ in range(N + 1)]
for i in range(1, N):
C1, S1, F1 = A[i]
T = S1
for j in range(i + 1, N):
C2, S2, F2 = A[j]
if T + C1 >= S2:
dt = (T + C1) % F2
if dt > 0:
... | import math
N = int(eval(input()))
A = [list(map(int, input().split())) for _ in range(N - 1)]
A.insert(0, 0)
for i in range(1, N):
C, S, F = A[i]
T = S + C
j = i + 1
while j < N:
C, S, F = A[j]
T = max(S, math.ceil(T / F) * F)
T += C
j += 1
print(T)
print((0))
| false | 37.5 | [
"+import math",
"+",
"-B = [0 for _ in range(N + 1)]",
"- C1, S1, F1 = A[i]",
"- T = S1",
"- for j in range(i + 1, N):",
"- C2, S2, F2 = A[j]",
"- if T + C1 >= S2:",
"- dt = (T + C1) % F2",
"- if dt > 0:",
"- T += F2 - dt + C1",
"- ... | false | 0.03994 | 0.100317 | 0.398139 | [
"s254960731",
"s325982327"
] |
u089032001 | p03436 | python | s651728023 | s194103626 | 30 | 27 | 3,700 | 3,316 | Accepted | Accepted | 10 | def AppendQue(now, depth, que, past_visit, maze):
Next = ((now[0] - 1, now[1]), (now[0], now[1] - 1),
(now[0] + 1, now[1]), (now[0], now[1] + 1))
for h, w in Next:
if h < 0 or w < 0 or h >= H or w >= W:
continue
elif (h, w) in past_visit:
continue
... | import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)
def inpl():
return list(map(int, input().split()))
H, W = inpl()
S = ["#" + input().strip() + "#" for _ in range(H)]
S = ["#" * (W + 2)] + S + ["#" * (W + 2)]
sharp = sum(len(list([x for x in s if x... | 46 | 35 | 1,075 | 854 | def AppendQue(now, depth, que, past_visit, maze):
Next = (
(now[0] - 1, now[1]),
(now[0], now[1] - 1),
(now[0] + 1, now[1]),
(now[0], now[1] + 1),
)
for h, w in Next:
if h < 0 or w < 0 or h >= H or w >= W:
continue
elif (h, w) in past_visit:
... | import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)
def inpl():
return list(map(int, input().split()))
H, W = inpl()
S = ["#" + input().strip() + "#" for _ in range(H)]
S = ["#" * (W + 2)] + S + ["#" * (W + 2)]
sharp = sum(len(list([x for x in s if x == "#"])) f... | false | 23.913043 | [
"-def AppendQue(now, depth, que, past_visit, maze):",
"- Next = (",
"- (now[0] - 1, now[1]),",
"- (now[0], now[1] - 1),",
"- (now[0] + 1, now[1]),",
"- (now[0], now[1] + 1),",
"- )",
"- for h, w in Next:",
"- if h < 0 or w < 0 or h >= H or w >= W:",
"- ... | false | 0.044925 | 0.045452 | 0.988395 | [
"s651728023",
"s194103626"
] |
u994988729 | p03262 | python | s306577509 | s504646613 | 164 | 91 | 14,252 | 14,100 | Accepted | Accepted | 44.51 | N, X=list(map(int, input().split()))
x=[abs(int(i)-X) for i in input().split()]
def gcd(x, y):
x, y=max(x,y), min(x,y)
if y==0:
return x
else:
return gcd(y, x%y)
ans=1
for i in range(N):
if i==0:
ans=x[i]
else:
ans=gcd(ans, x[i])
print(ans) | from itertools import accumulate
def gcd(x, y):
if y == 0:
return x
return gcd(y, x % y)
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = [abs(a-K) for a in A]
ans = list(accumulate(B, func=gcd))[-1]
print(ans) | 17 | 15 | 304 | 269 | N, X = list(map(int, input().split()))
x = [abs(int(i) - X) for i in input().split()]
def gcd(x, y):
x, y = max(x, y), min(x, y)
if y == 0:
return x
else:
return gcd(y, x % y)
ans = 1
for i in range(N):
if i == 0:
ans = x[i]
else:
ans = gcd(ans, x[i])
print(ans)
| from itertools import accumulate
def gcd(x, y):
if y == 0:
return x
return gcd(y, x % y)
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = [abs(a - K) for a in A]
ans = list(accumulate(B, func=gcd))[-1]
print(ans)
| false | 11.764706 | [
"-N, X = list(map(int, input().split()))",
"-x = [abs(int(i) - X) for i in input().split()]",
"+from itertools import accumulate",
"- x, y = max(x, y), min(x, y)",
"- else:",
"- return gcd(y, x % y)",
"+ return gcd(y, x % y)",
"-ans = 1",
"-for i in range(N):",
"- if i == 0:",
... | false | 0.040726 | 0.040167 | 1.01391 | [
"s306577509",
"s504646613"
] |
u144913062 | p03576 | python | s689929775 | s403578471 | 1,376 | 297 | 50,780 | 43,372 | Accepted | Accepted | 78.42 | N, K = list(map(int, input().split()))
x = [0] * N
y = [0] * N
for i in range(N):
x[i], y[i] = list(map(int, input().split()))
ans = float('inf')
for x1 in x:
for x2 in x:
if x1 > x2:
continue
for y1 in y:
for y2 in y:
if y1 > y2:
... | from itertools import accumulate, combinations
N, K = list(map(int, input().split()))
X = [0] * N
Y = [0] * N
for i in range(N):
X[i], Y[i] = list(map(int, input().split()))
cx_to_x = sorted(list(set(X)))
x_to_cx = {k : i for i, k in enumerate(cx_to_x)}
cy_to_y = sorted(list(set(Y)))
y_to_cy = {k : i for... | 24 | 28 | 666 | 971 | N, K = list(map(int, input().split()))
x = [0] * N
y = [0] * N
for i in range(N):
x[i], y[i] = list(map(int, input().split()))
ans = float("inf")
for x1 in x:
for x2 in x:
if x1 > x2:
continue
for y1 in y:
for y2 in y:
if y1 > y2:
conti... | from itertools import accumulate, combinations
N, K = list(map(int, input().split()))
X = [0] * N
Y = [0] * N
for i in range(N):
X[i], Y[i] = list(map(int, input().split()))
cx_to_x = sorted(list(set(X)))
x_to_cx = {k: i for i, k in enumerate(cx_to_x)}
cy_to_y = sorted(list(set(Y)))
y_to_cy = {k: i for i, k in enu... | false | 14.285714 | [
"+from itertools import accumulate, combinations",
"+",
"-x = [0] * N",
"-y = [0] * N",
"+X = [0] * N",
"+Y = [0] * N",
"- x[i], y[i] = list(map(int, input().split()))",
"+ X[i], Y[i] = list(map(int, input().split()))",
"+cx_to_x = sorted(list(set(X)))",
"+x_to_cx = {k: i for i, k in enumera... | false | 0.040683 | 0.037148 | 1.095155 | [
"s689929775",
"s403578471"
] |
u606878291 | p03164 | python | s196002419 | s769245642 | 387 | 241 | 170,440 | 93,108 | Accepted | Accepted | 37.73 | import numpy as np
def main(n, w, items):
MAX_VALUE = 100100
dp = np.ones((n + 1, MAX_VALUE), dtype=int)
dp = dp * (1 << 30)
dp[0][0] = 0
for i in range(0, n):
weight, value = items[i]
dp[i + 1][:value] = np.minimum(dp[i][:value], dp[i + 1][:value])
dp[i + 1][val... | import numpy as np
MAX_VALUE = 100100
INF_WEIGHT = 1 << 30
def main(n, w, items):
dp = np.full(
shape=(n + 1, MAX_VALUE),
fill_value=INF_WEIGHT,
dtype=int,
)
dp[0][0] = 0
for i in range(0, n):
weight, value = items[i]
dp[i + 1][:value] = np.minim... | 26 | 27 | 694 | 676 | import numpy as np
def main(n, w, items):
MAX_VALUE = 100100
dp = np.ones((n + 1, MAX_VALUE), dtype=int)
dp = dp * (1 << 30)
dp[0][0] = 0
for i in range(0, n):
weight, value = items[i]
dp[i + 1][:value] = np.minimum(dp[i][:value], dp[i + 1][:value])
dp[i + 1][value:] = np.m... | import numpy as np
MAX_VALUE = 100100
INF_WEIGHT = 1 << 30
def main(n, w, items):
dp = np.full(
shape=(n + 1, MAX_VALUE),
fill_value=INF_WEIGHT,
dtype=int,
)
dp[0][0] = 0
for i in range(0, n):
weight, value = items[i]
dp[i + 1][:value] = np.minimum(dp[i][:value... | false | 3.703704 | [
"+",
"+MAX_VALUE = 100100",
"+INF_WEIGHT = 1 << 30",
"- MAX_VALUE = 100100",
"- dp = np.ones((n + 1, MAX_VALUE), dtype=int)",
"- dp = dp * (1 << 30)",
"+ dp = np.full(",
"+ shape=(n + 1, MAX_VALUE),",
"+ fill_value=INF_WEIGHT,",
"+ dtype=int,",
"+ )",
"- ... | false | 0.268261 | 0.209624 | 1.279728 | [
"s196002419",
"s769245642"
] |
u411203878 | p03578 | python | s289129227 | s048597235 | 462 | 325 | 126,164 | 137,576 | Accepted | Accepted | 29.65 | from collections import Counter
N = int(eval(input()))
D = list(input().split())
M = int(eval(input()))
T = list(input().split())
D_count = Counter(D)
T_count = Counter(T)
for k, v in list(T_count.items()):
if D_count[k] < v:
print('NO')
exit()
print('YES')
| N = int(eval(input()))
D = list(map(int,input().split()))
M = int(eval(input()))
T = list(map(int,input().split()))
memo = {}
for d in D:
if d in memo:
memo[d] += 1
else:
memo[d] = 1
for t in T:
if t in memo and 0 < memo[t]:
memo[t] -= 1
else:
... | 18 | 21 | 297 | 352 | from collections import Counter
N = int(eval(input()))
D = list(input().split())
M = int(eval(input()))
T = list(input().split())
D_count = Counter(D)
T_count = Counter(T)
for k, v in list(T_count.items()):
if D_count[k] < v:
print("NO")
exit()
print("YES")
| N = int(eval(input()))
D = list(map(int, input().split()))
M = int(eval(input()))
T = list(map(int, input().split()))
memo = {}
for d in D:
if d in memo:
memo[d] += 1
else:
memo[d] = 1
for t in T:
if t in memo and 0 < memo[t]:
memo[t] -= 1
else:
print("NO")
exit()... | false | 14.285714 | [
"-from collections import Counter",
"-",
"-D = list(input().split())",
"+D = list(map(int, input().split()))",
"-T = list(input().split())",
"-D_count = Counter(D)",
"-T_count = Counter(T)",
"-for k, v in list(T_count.items()):",
"- if D_count[k] < v:",
"+T = list(map(int, input().split()))",
... | false | 0.035853 | 0.072021 | 0.497813 | [
"s289129227",
"s048597235"
] |
u077291787 | p03675 | python | s474793810 | s320126846 | 222 | 195 | 25,412 | 25,536 | Accepted | Accepted | 12.16 | #ARC077C - pushpush (ABC066C)
from collections import deque
n = int(eval(input()))
lst = list(map(int, input().rstrip().split()))
b = deque()
parity = n % 2
for i, j in enumerate(lst, start=1):
if i % 2 == parity:
b.appendleft(j)
else:
b.append(j)
print((*b)) | # ARC077C - pushpush (ABC066C)
from collections import deque
def main():
n = int(eval(input()))
lst = list(map(int, input().rstrip().split()))
b = deque()
parity = n % 2
for i, j in enumerate(lst, start=1):
if i % 2 == parity:
b.appendleft(j)
else:
... | 13 | 19 | 288 | 388 | # ARC077C - pushpush (ABC066C)
from collections import deque
n = int(eval(input()))
lst = list(map(int, input().rstrip().split()))
b = deque()
parity = n % 2
for i, j in enumerate(lst, start=1):
if i % 2 == parity:
b.appendleft(j)
else:
b.append(j)
print((*b))
| # ARC077C - pushpush (ABC066C)
from collections import deque
def main():
n = int(eval(input()))
lst = list(map(int, input().rstrip().split()))
b = deque()
parity = n % 2
for i, j in enumerate(lst, start=1):
if i % 2 == parity:
b.appendleft(j)
else:
b.append(... | false | 31.578947 | [
"-n = int(eval(input()))",
"-lst = list(map(int, input().rstrip().split()))",
"-b = deque()",
"-parity = n % 2",
"-for i, j in enumerate(lst, start=1):",
"- if i % 2 == parity:",
"- b.appendleft(j)",
"- else:",
"- b.append(j)",
"-print((*b))",
"+",
"+def main():",
"+ n... | false | 0.037163 | 0.058323 | 0.637185 | [
"s474793810",
"s320126846"
] |
u903005414 | p02899 | python | s838458100 | s303475584 | 841 | 663 | 23,388 | 23,384 | Accepted | Accepted | 21.17 | import numpy as np
n = int(input())
a = list(map(int, input().split()))
a = np.argsort(np.array(a)) + 1
for i in range(len(a)):
print(a[i], end='')
if i != len(a) - 1:
print(' ', end='')
| import numpy as np
n = int(input())
a = list(map(int, input().split()))
a = np.argsort(np.array(a)) + 1
for i in range(len(a)):
print(a[i], end=' ')
| 8 | 6 | 210 | 158 | import numpy as np
n = int(input())
a = list(map(int, input().split()))
a = np.argsort(np.array(a)) + 1
for i in range(len(a)):
print(a[i], end="")
if i != len(a) - 1:
print(" ", end="")
| import numpy as np
n = int(input())
a = list(map(int, input().split()))
a = np.argsort(np.array(a)) + 1
for i in range(len(a)):
print(a[i], end=" ")
| false | 25 | [
"- print(a[i], end=\"\")",
"- if i != len(a) - 1:",
"- print(\" \", end=\"\")",
"+ print(a[i], end=\" \")"
] | false | 0.234634 | 0.229295 | 1.023283 | [
"s838458100",
"s303475584"
] |
u401452016 | p03162 | python | s158731761 | s286321982 | 448 | 404 | 47,384 | 47,280 | Accepted | Accepted | 9.82 | import sys
n = int(sys.stdin.readline())
L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
dp = [[0 for i in range(3)] for j in range(n)]
for col in range(3):
dp[0][col] = L[0][col]
#print(dp)
for i in range(1, n):
dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + L[i][0]
dp[i][1] = m... | #DP C
import sys
N = int(sys.stdin.readline())
L = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
#print(L)
dp = [[0,0,0] for _ in range(N)]
dp[0] = L[0].copy()
for i in range(1, N):
dp[i][0] = L[i][0] + max(dp[i-1][1], dp[i-1][2])
dp[i][1] = L[i][1] + max(dp[i-1][0], dp[i-1][2])
... | 15 | 14 | 432 | 407 | import sys
n = int(sys.stdin.readline())
L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
dp = [[0 for i in range(3)] for j in range(n)]
for col in range(3):
dp[0][col] = L[0][col]
# print(dp)
for i in range(1, n):
dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + L[i][0]
dp[i][1] = max(dp[i... | # DP C
import sys
N = int(sys.stdin.readline())
L = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
# print(L)
dp = [[0, 0, 0] for _ in range(N)]
dp[0] = L[0].copy()
for i in range(1, N):
dp[i][0] = L[i][0] + max(dp[i - 1][1], dp[i - 1][2])
dp[i][1] = L[i][1] + max(dp[i - 1][0], dp[i - 1][2])
... | false | 6.666667 | [
"+# DP C",
"-n = int(sys.stdin.readline())",
"-L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]",
"-dp = [[0 for i in range(3)] for j in range(n)]",
"-for col in range(3):",
"- dp[0][col] = L[0][col]",
"-# print(dp)",
"-for i in range(1, n):",
"- dp[i][0] = max(dp[i - 1][1]... | false | 0.038566 | 0.038644 | 0.997974 | [
"s158731761",
"s286321982"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.