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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u977389981 | p04045 | python | s538721266 | s515355254 | 74 | 54 | 2,940 | 2,940 | Accepted | Accepted | 27.03 | n, k = list(map(int, input().split()))
A = list(input().split())
for i in range(10 * n):
for a in A:
if a in str(n + i):
break
else:
ans = n + i
break
print(ans) | n, k = list(map(int, input().split()))
A = list(input().split())
for i in range(n * 10):
for j in str(n + i):
if j in A:
break
else:
print((n + i))
break | 10 | 10 | 212 | 199 | n, k = list(map(int, input().split()))
A = list(input().split())
for i in range(10 * n):
for a in A:
if a in str(n + i):
break
else:
ans = n + i
break
print(ans)
| n, k = list(map(int, input().split()))
A = list(input().split())
for i in range(n * 10):
for j in str(n + i):
if j in A:
break
else:
print((n + i))
break
| false | 0 | [
"-for i in range(10 * n):",
"- for a in A:",
"- if a in str(n + i):",
"+for i in range(n * 10):",
"+ for j in str(n + i):",
"+ if j in A:",
"- ans = n + i",
"+ print((n + i))",
"-print(ans)"
] | false | 0.03287 | 0.039276 | 0.836891 | [
"s538721266",
"s515355254"
] |
u753803401 | p03470 | python | s566877171 | s367686476 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | n = int(eval(input()))
d = [int(eval(input()))for _ in range(n)]
d = sorted(d, reverse=True)
cnt = 1
for i in range(1, n):
if d[i] < d[i-1]:
cnt += 1
print(cnt)
| n = int(eval(input()))
d = [int(eval(input())) for _ in range(n)]
d = sorted(d, reverse=True)
cnt = 0
last = 10 ** 9
for i in d:
if i < last:
last = i
cnt += 1
print(cnt)
| 8 | 10 | 168 | 188 | n = int(eval(input()))
d = [int(eval(input())) for _ in range(n)]
d = sorted(d, reverse=True)
cnt = 1
for i in range(1, n):
if d[i] < d[i - 1]:
cnt += 1
print(cnt)
| n = int(eval(input()))
d = [int(eval(input())) for _ in range(n)]
d = sorted(d, reverse=True)
cnt = 0
last = 10**9
for i in d:
if i < last:
last = i
cnt += 1
print(cnt)
| false | 20 | [
"-cnt = 1",
"-for i in range(1, n):",
"- if d[i] < d[i - 1]:",
"+cnt = 0",
"+last = 10**9",
"+for i in d:",
"+ if i < last:",
"+ last = i"
] | false | 0.042629 | 0.131228 | 0.324845 | [
"s566877171",
"s367686476"
] |
u072717685 | p02713 | python | s926357683 | s273421285 | 1,429 | 304 | 9,160 | 89,564 | Accepted | Accepted | 78.73 | import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import gcd
def main():
k = int(eval(input()))
r = 0
for i1 in range(1, k + 1):
for i2 in range(1, k + 1):
for i3 in range(1, k + 1):
t1 = gcd(i1, i2)
r += gcd(t1, i3)
... | import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np
def main():
k = int(eval(input()))
k2 = np.arange(1, k+1)
k2gcd = np.gcd.outer(k2, np.gcd.outer(k2, k2))
print((k2gcd.sum()))
if __name__ == '__main__':
main() | 16 | 13 | 366 | 269 | import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import gcd
def main():
k = int(eval(input()))
r = 0
for i1 in range(1, k + 1):
for i2 in range(1, k + 1):
for i3 in range(1, k + 1):
t1 = gcd(i1, i2)
r += gcd(t1, i3)
print(r... | import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np
def main():
k = int(eval(input()))
k2 = np.arange(1, k + 1)
k2gcd = np.gcd.outer(k2, np.gcd.outer(k2, k2))
print((k2gcd.sum()))
if __name__ == "__main__":
main()
| false | 18.75 | [
"-from math import gcd",
"+import numpy as np",
"- r = 0",
"- for i1 in range(1, k + 1):",
"- for i2 in range(1, k + 1):",
"- for i3 in range(1, k + 1):",
"- t1 = gcd(i1, i2)",
"- r += gcd(t1, i3)",
"- print(r)",
"+ k2 = np.arange(1, k + ... | false | 0.080565 | 0.215459 | 0.373923 | [
"s926357683",
"s273421285"
] |
u958506960 | p03814 | python | s291508770 | s568754064 | 74 | 18 | 11,152 | 3,500 | Accepted | Accepted | 75.68 | S = eval(input())
a = []
z = []
for i, s in enumerate(S):
if s == 'A':
a.append(i + 1)
elif s == 'Z':
z.append(i + 1)
print((max(z) - min(a) + 1)) | s = eval(input())
a = s.index('A')
z = s.rindex('Z')
print((z - a + 1)) | 10 | 4 | 172 | 66 | S = eval(input())
a = []
z = []
for i, s in enumerate(S):
if s == "A":
a.append(i + 1)
elif s == "Z":
z.append(i + 1)
print((max(z) - min(a) + 1))
| s = eval(input())
a = s.index("A")
z = s.rindex("Z")
print((z - a + 1))
| false | 60 | [
"-S = eval(input())",
"-a = []",
"-z = []",
"-for i, s in enumerate(S):",
"- if s == \"A\":",
"- a.append(i + 1)",
"- elif s == \"Z\":",
"- z.append(i + 1)",
"-print((max(z) - min(a) + 1))",
"+s = eval(input())",
"+a = s.index(\"A\")",
"+z = s.rindex(\"Z\")",
"+print((z -... | false | 0.039032 | 0.034259 | 1.139337 | [
"s291508770",
"s568754064"
] |
u868701750 | p03160 | python | s898304529 | s689620964 | 147 | 117 | 13,928 | 13,980 | Accepted | Accepted | 20.41 | if __name__ == '__main__':
N = int(eval(input()))
h = list(map(int, input().split()))
DP = [0]
for i in range(1, N):
if i == 1:
DP += [abs(h[i]-h[i-1])]
continue
DP += [min(DP[i-1]+abs(h[i]-h[i-1]), DP[i-2]+abs(h[i]-h[i-2]))]
print((DP[-1]... | def dp():
N = int(eval(input()))
h = list(map(int, input().split()))
DP = [0]
for i in range(1, N):
if i == 1:
DP += [abs(h[i]-h[i-1])]
continue
DP += [min(DP[i-1]+abs(h[i]-h[i-1]), DP[i-2]+abs(h[i]-h[i-2]))]
print((DP[-1]))
dp()
| 12 | 13 | 315 | 296 | if __name__ == "__main__":
N = int(eval(input()))
h = list(map(int, input().split()))
DP = [0]
for i in range(1, N):
if i == 1:
DP += [abs(h[i] - h[i - 1])]
continue
DP += [min(DP[i - 1] + abs(h[i] - h[i - 1]), DP[i - 2] + abs(h[i] - h[i - 2]))]
print((DP[-1])... | def dp():
N = int(eval(input()))
h = list(map(int, input().split()))
DP = [0]
for i in range(1, N):
if i == 1:
DP += [abs(h[i] - h[i - 1])]
continue
DP += [min(DP[i - 1] + abs(h[i] - h[i - 1]), DP[i - 2] + abs(h[i] - h[i - 2]))]
print((DP[-1]))
dp()
| false | 7.692308 | [
"-if __name__ == \"__main__\":",
"+def dp():",
"+",
"+",
"+dp()"
] | false | 0.039276 | 0.044581 | 0.881009 | [
"s898304529",
"s689620964"
] |
u476604182 | p03354 | python | s590836350 | s111624103 | 1,047 | 436 | 101,740 | 36,952 | Accepted | Accepted | 58.36 | from collections import defaultdict
class UnionFind:
def __init__(self, n):
self.par = [i for i in range(n)]
self.rank = [0]*n
def find(self, x):
if self.par[x]==x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
def unite(self, x, y)... | class UnionFind:
def __init__(self, n):
self.par = [i for i in range(n)]
self.rank = [0]*n
def find(self, x):
if self.par[x]==x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
def unit(self, x, y):
x = self.find(x)
y = self.find(y)
... | 59 | 37 | 1,217 | 860 | from collections import defaultdict
class UnionFind:
def __init__(self, n):
self.par = [i for i in range(n)]
self.rank = [0] * n
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
... | class UnionFind:
def __init__(self, n):
self.par = [i for i in range(n)]
self.rank = [0] * n
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
def unit(self, x, y):
x = ... | false | 37.288136 | [
"-from collections import defaultdict",
"-",
"-",
"- def unite(self, x, y):",
"+ def unit(self, x, y):",
"- if self.rank[x] < self.rank[y]:",
"+ elif self.rank[x] < self.rank[y]:",
"+ return",
"+ elif self.rank[y] < self.rank[x]:",
"+ self.par[y] = ... | false | 0.039788 | 0.046089 | 0.863273 | [
"s590836350",
"s111624103"
] |
u287132915 | p02720 | python | s111517664 | s986006648 | 69 | 61 | 6,096 | 79,072 | Accepted | Accepted | 11.59 | from collections import deque
k = int(eval(input()))
if 1 <= k and k <= 9:
print(k)
exit()
d = deque([i for i in range(1, 10)])
k -= 9
while k > 0:
num = d.popleft()
if num % 10 != 0:
new = 10*num + (num%10) - 1
d.append(new)
k -= 1
if k == 0: break
... | k = int(eval(input()))
if k <= 9:
print(k)
k -= 9
lst = list(range(1, 10))
while k > 0:
new = []
for num in lst:
amari = num % 10
if amari == 0:
new.append(num*10)
new.append(num*10+1)
elif amari == 9:
new.append(num*10+8)
... | 28 | 27 | 531 | 593 | from collections import deque
k = int(eval(input()))
if 1 <= k and k <= 9:
print(k)
exit()
d = deque([i for i in range(1, 10)])
k -= 9
while k > 0:
num = d.popleft()
if num % 10 != 0:
new = 10 * num + (num % 10) - 1
d.append(new)
k -= 1
if k == 0:
break
n... | k = int(eval(input()))
if k <= 9:
print(k)
k -= 9
lst = list(range(1, 10))
while k > 0:
new = []
for num in lst:
amari = num % 10
if amari == 0:
new.append(num * 10)
new.append(num * 10 + 1)
elif amari == 9:
new.append(num * 10 + 8)
new... | false | 3.571429 | [
"-from collections import deque",
"-",
"-if 1 <= k and k <= 9:",
"+if k <= 9:",
"- exit()",
"-d = deque([i for i in range(1, 10)])",
"+lst = list(range(1, 10))",
"- num = d.popleft()",
"- if num % 10 != 0:",
"- new = 10 * num + (num % 10) - 1",
"- d.append(new)",
"- ... | false | 0.037997 | 0.040993 | 0.926901 | [
"s111517664",
"s986006648"
] |
u332906195 | p03573 | python | s137810318 | s702234441 | 167 | 17 | 38,256 | 2,940 | Accepted | Accepted | 89.82 | A, B, C = list(map(int, input().split()))
if A == B:
print(C)
elif B == C:
print(A)
else:
print(B)
| A, B, C = list(map(int, input().split()))
print((C if A == B else A if B == C else B))
| 7 | 2 | 111 | 80 | A, B, C = list(map(int, input().split()))
if A == B:
print(C)
elif B == C:
print(A)
else:
print(B)
| A, B, C = list(map(int, input().split()))
print((C if A == B else A if B == C else B))
| false | 71.428571 | [
"-if A == B:",
"- print(C)",
"-elif B == C:",
"- print(A)",
"-else:",
"- print(B)",
"+print((C if A == B else A if B == C else B))"
] | false | 0.038373 | 0.037542 | 1.022126 | [
"s137810318",
"s702234441"
] |
u347640436 | p02887 | python | s578563207 | s487137815 | 42 | 34 | 3,316 | 3,316 | Accepted | Accepted | 19.05 | N = int(eval(input()))
S = eval(input())
p = ''
result = 0
for i in range(N):
if p != S[i]:
result += 1
p = S[i]
print(result)
| N = int(eval(input()))
S = eval(input())
print((sum(1 for i in range(N - 1) if S[i] != S[i + 1]) + 1))
| 10 | 4 | 135 | 93 | N = int(eval(input()))
S = eval(input())
p = ""
result = 0
for i in range(N):
if p != S[i]:
result += 1
p = S[i]
print(result)
| N = int(eval(input()))
S = eval(input())
print((sum(1 for i in range(N - 1) if S[i] != S[i + 1]) + 1))
| false | 60 | [
"-p = \"\"",
"-result = 0",
"-for i in range(N):",
"- if p != S[i]:",
"- result += 1",
"- p = S[i]",
"-print(result)",
"+print((sum(1 for i in range(N - 1) if S[i] != S[i + 1]) + 1))"
] | false | 0.039085 | 0.081995 | 0.476676 | [
"s578563207",
"s487137815"
] |
u436149658 | p03469 | python | s535078942 | s612487501 | 26 | 24 | 9,096 | 8,916 | Accepted | Accepted | 7.69 | s = eval(input())
print((str(int(s[:4]) + 1) + s[4:])) | print(("2018/01/" + input()[-2:])) | 2 | 1 | 48 | 32 | s = eval(input())
print((str(int(s[:4]) + 1) + s[4:]))
| print(("2018/01/" + input()[-2:]))
| false | 50 | [
"-s = eval(input())",
"-print((str(int(s[:4]) + 1) + s[4:]))",
"+print((\"2018/01/\" + input()[-2:]))"
] | false | 0.074553 | 0.073196 | 1.018536 | [
"s535078942",
"s612487501"
] |
u761989513 | p03848 | python | s687519811 | s064808401 | 78 | 59 | 14,820 | 14,820 | Accepted | Accepted | 24.36 | import collections
n = int(eval(input()))
a = list(map(int, input().split()))
ac = collections.Counter(a)
if n % 2:
if ac[0] != 1:
print((0))
exit()
for i in ac:
if i == 0:
continue
if ac[i] != 2:
print((0))
exit()
else:
if... | import collections
n = int(eval(input()))
mod = 10 ** 9 + 7
a = list(map(int, input().split()))
ac = collections.Counter(a)
if n % 2:
for i in list(ac.items()):
if i[0] == 0:
if i[1] != 1:
print((0))
exit()
else:
if i[1] != 2:
... | 27 | 23 | 531 | 512 | import collections
n = int(eval(input()))
a = list(map(int, input().split()))
ac = collections.Counter(a)
if n % 2:
if ac[0] != 1:
print((0))
exit()
for i in ac:
if i == 0:
continue
if ac[i] != 2:
print((0))
exit()
else:
if ac[1] != 2:
... | import collections
n = int(eval(input()))
mod = 10**9 + 7
a = list(map(int, input().split()))
ac = collections.Counter(a)
if n % 2:
for i in list(ac.items()):
if i[0] == 0:
if i[1] != 1:
print((0))
exit()
else:
if i[1] != 2:
pr... | false | 14.814815 | [
"+mod = 10**9 + 7",
"- if ac[0] != 1:",
"- print((0))",
"- exit()",
"- for i in ac:",
"- if i == 0:",
"- continue",
"- if ac[i] != 2:",
"+ for i in list(ac.items()):",
"+ if i[0] == 0:",
"+ if i[1] != 1:",
"+ prin... | false | 0.115927 | 0.113444 | 1.021887 | [
"s687519811",
"s064808401"
] |
u423665486 | p02683 | python | s291864470 | s128665884 | 84 | 61 | 68,564 | 9,216 | Accepted | Accepted | 27.38 | def resolve():
n, m, x = list(map(int, input().split()))
books = [list(map(int, input().split())) for _ in range(n)]
pay = float('inf')
for i in range(1 << n):
selected = []
for j in range(n):
if i >> j & 1:
selected.append(j)
rem = [0] * m
tmp_pay = 0
for j in selected:
tmp_pay +=... | def resolve():
n, m, x = list(map(int, input().split()))
c_seq = []
a_seq = []
ans = float('inf')
for i in range(n):
c, *a = list(map(int, input().split()))
c_seq.append(c)
a_seq.append(a)
for i in range(1 << n):
pay = 0
skill = [0]*m
for j in range(n):
if i >> j & 1:
pay += c_seq... | 27 | 25 | 569 | 515 | def resolve():
n, m, x = list(map(int, input().split()))
books = [list(map(int, input().split())) for _ in range(n)]
pay = float("inf")
for i in range(1 << n):
selected = []
for j in range(n):
if i >> j & 1:
selected.append(j)
rem = [0] * m
tmp... | def resolve():
n, m, x = list(map(int, input().split()))
c_seq = []
a_seq = []
ans = float("inf")
for i in range(n):
c, *a = list(map(int, input().split()))
c_seq.append(c)
a_seq.append(a)
for i in range(1 << n):
pay = 0
skill = [0] * m
for j in ra... | false | 7.407407 | [
"- books = [list(map(int, input().split())) for _ in range(n)]",
"- pay = float(\"inf\")",
"+ c_seq = []",
"+ a_seq = []",
"+ ans = float(\"inf\")",
"+ for i in range(n):",
"+ c, *a = list(map(int, input().split()))",
"+ c_seq.append(c)",
"+ a_seq.append(a)",
... | false | 0.03335 | 0.037645 | 0.885905 | [
"s291864470",
"s128665884"
] |
u118642796 | p03476 | python | s788219473 | s860281631 | 1,092 | 401 | 52,640 | 54,488 | Accepted | Accepted | 63.28 | prime = [True]*((10**5)+1)
prime[0]=False
prime[1]=False
for i in range(2,10**3):
if i*i>10**5:
break
if prime[i]:
for j in range(i,10**5):
if i*j>10**5:
break
prime[i*j]=False
prime2017 = [x for x in prime]
prime2017[2] = False
for i in range(3,(10**5)+1):
if prime[i]:... | import sys
import heapq
import bisect
mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))
def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])
def GCD(a,b):
while b... | 30 | 59 | 580 | 1,148 | prime = [True] * ((10**5) + 1)
prime[0] = False
prime[1] = False
for i in range(2, 10**3):
if i * i > 10**5:
break
if prime[i]:
for j in range(i, 10**5):
if i * j > 10**5:
break
prime[i * j] = False
prime2017 = [x for x in prime]
prime2017[2] = False
for i... | import sys
import heapq
import bisect
mod = 10**9 + 7
dd = ((-1, 0), (1, 0), (0, -1), (0, 1))
def I():
return int(sys.stdin.readline())
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def S():
return sys.stdin.readline()[:-1]
def IR(n):
return [I() for _ in range(n)]
def GCD(a... | false | 49.152542 | [
"-prime = [True] * ((10**5) + 1)",
"-prime[0] = False",
"-prime[1] = False",
"-for i in range(2, 10**3):",
"- if i * i > 10**5:",
"- break",
"- if prime[i]:",
"- for j in range(i, 10**5):",
"- if i * j > 10**5:",
"- break",
"- prime[i * j]... | false | 0.126981 | 0.123754 | 1.026081 | [
"s788219473",
"s860281631"
] |
u175034939 | p03167 | python | s352568912 | s793825862 | 1,443 | 272 | 43,712 | 53,488 | Accepted | Accepted | 81.15 | h, w = list(map(int, input().split()))
a = [eval(input()) for _ in range(h)]
MOD = 10**9+7
dp = [[0]*(w+1) for _ in range(h+1)]
dp[0][0] = 1
for i in range(h):
for j in range(w):
if i+1 < h and a[i+1][j] == '.':
dp[i+1][j] += dp[i][j]
if dp[i+1][j] >= MOD:
... | h, w = list(map(int, input().split()))
a = [eval(input()) for _ in range(h)]
MOD = 10**9+7
dp = [[0]*(w) for _ in range(h)]
dp[0][0] = 1
for i in range(h):
for j in range(w):
if i+1 < h and a[i+1][j] == '.':
dp[i+1][j] += dp[i][j]
if dp[i+1][j] >= MOD:
dp[... | 17 | 17 | 495 | 491 | h, w = list(map(int, input().split()))
a = [eval(input()) for _ in range(h)]
MOD = 10**9 + 7
dp = [[0] * (w + 1) for _ in range(h + 1)]
dp[0][0] = 1
for i in range(h):
for j in range(w):
if i + 1 < h and a[i + 1][j] == ".":
dp[i + 1][j] += dp[i][j]
if dp[i + 1][j] >= MOD:
... | h, w = list(map(int, input().split()))
a = [eval(input()) for _ in range(h)]
MOD = 10**9 + 7
dp = [[0] * (w) for _ in range(h)]
dp[0][0] = 1
for i in range(h):
for j in range(w):
if i + 1 < h and a[i + 1][j] == ".":
dp[i + 1][j] += dp[i][j]
if dp[i + 1][j] >= MOD:
dp[... | false | 0 | [
"-dp = [[0] * (w + 1) for _ in range(h + 1)]",
"+dp = [[0] * (w) for _ in range(h)]"
] | false | 0.038403 | 0.046501 | 0.825852 | [
"s352568912",
"s793825862"
] |
u197300773 | p03310 | python | s546325889 | s034917612 | 1,067 | 914 | 24,180 | 25,972 | Accepted | Accepted | 14.34 | from itertools import accumulate as acc
from bisect import bisect_left as bl
def ans(n):
tmp=0
for i in range(N):
tmp+=abs(a[i]-a[n-1])
return tmp
N=int(eval(input()))
a=list(map(int,input().split()))
a=list(acc(a))
ans=10**18
p=0
q=2
for j in range(1,N-2):
q=max(q,j+1)
... | from itertools import accumulate as acc
from bisect import bisect_left as bl
def ans(n):
tmp=0
for i in range(N):
tmp+=abs(a[i]-a[n-1])
return tmp
N=int(eval(input()))
a=list(acc(list(map(int,input().split()))))
ans=a[-1]
p=0
q=2
for j in range(1,N-2):
q=max(q,j+1)
whil... | 28 | 27 | 582 | 556 | from itertools import accumulate as acc
from bisect import bisect_left as bl
def ans(n):
tmp = 0
for i in range(N):
tmp += abs(a[i] - a[n - 1])
return tmp
N = int(eval(input()))
a = list(map(int, input().split()))
a = list(acc(a))
ans = 10**18
p = 0
q = 2
for j in range(1, N - 2):
q = max(q,... | from itertools import accumulate as acc
from bisect import bisect_left as bl
def ans(n):
tmp = 0
for i in range(N):
tmp += abs(a[i] - a[n - 1])
return tmp
N = int(eval(input()))
a = list(acc(list(map(int, input().split()))))
ans = a[-1]
p = 0
q = 2
for j in range(1, N - 2):
q = max(q, j + 1)... | false | 3.571429 | [
"-a = list(map(int, input().split()))",
"-a = list(acc(a))",
"-ans = 10**18",
"+a = list(acc(list(map(int, input().split()))))",
"+ans = a[-1]",
"- P, Q, R, S = a[p], a[j] - a[p], a[q] - a[j], a[N - 1] - a[q]",
"- ans = min(ans, max(P, Q, R, S) - min(P, Q, R, S))",
"+ x = [a[p], a[j] - a[p], ... | false | 0.049251 | 0.119084 | 0.413585 | [
"s546325889",
"s034917612"
] |
u623231048 | p02678 | python | s063564295 | s039185096 | 495 | 322 | 94,968 | 92,244 | Accepted | Accepted | 34.95 | from collections import deque
def main():
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)
q = deque([0])
ans = [-1]*n
ans[0] = 0
... | from collections import deque
import sys
input = sys.stdin.readline
def main():
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)
q = deque([0... | 37 | 39 | 718 | 758 | from collections import deque
def main():
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)
q = deque([0])
ans = [-1] * n
ans[0] = 0
c... | from collections import deque
import sys
input = sys.stdin.readline
def main():
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)
q = deque([0])
... | false | 5.128205 | [
"+import sys",
"+",
"+input = sys.stdin.readline"
] | false | 0.038088 | 0.036437 | 1.045305 | [
"s063564295",
"s039185096"
] |
u729133443 | p03298 | python | s489141011 | s816817998 | 2,974 | 1,382 | 125,760 | 174,460 | Accepted | Accepted | 53.53 | n=int(eval(input()))
s=list(eval(input()))
l=s[:n]
r=s[n:][::-1]
d={}
e={}
for i in range(1<<n):
s=t=u=v=''
for j in range(n):
if (i>>j)&1:
s+=l[j]
t+=r[j]
else:
u+=l[j]
v+=r[j]
d[(s,u)]=d.get((s,u),0)+1
e[(t,v)]=e.get((t,v),0)+1
a=0
for i in list(d.keys()):
... | n=int(eval(input()));s=eval(input());l=s[:n];r=s[n:][::-1];d={};e={}
for i in range(1<<n):
s=t=u=v=''
for j in range(n):
if i>>j&1:s+=l[j];t+=r[j]
else:u+=l[j];v+=r[j]
d[s,u]=d.get((s,u),0)+1
e[t,v]=e.get((t,v),0)+1
print((sum(d[i]*e.get(i,0)for i in list(d.keys())))) | 21 | 9 | 330 | 264 | n = int(eval(input()))
s = list(eval(input()))
l = s[:n]
r = s[n:][::-1]
d = {}
e = {}
for i in range(1 << n):
s = t = u = v = ""
for j in range(n):
if (i >> j) & 1:
s += l[j]
t += r[j]
else:
u += l[j]
v += r[j]
d[(s, u)] = d.get((s, u), 0) + 1... | n = int(eval(input()))
s = eval(input())
l = s[:n]
r = s[n:][::-1]
d = {}
e = {}
for i in range(1 << n):
s = t = u = v = ""
for j in range(n):
if i >> j & 1:
s += l[j]
t += r[j]
else:
u += l[j]
v += r[j]
d[s, u] = d.get((s, u), 0) + 1
e[t, ... | false | 57.142857 | [
"-s = list(eval(input()))",
"+s = eval(input())",
"- if (i >> j) & 1:",
"+ if i >> j & 1:",
"- d[(s, u)] = d.get((s, u), 0) + 1",
"- e[(t, v)] = e.get((t, v), 0) + 1",
"-a = 0",
"-for i in list(d.keys()):",
"- a += d[i] * e.get(i, 0)",
"-print(a)",
"+ d[s, u] = d.get((s... | false | 0.037287 | 0.035641 | 1.046177 | [
"s489141011",
"s816817998"
] |
u337626942 | p03037 | python | s742099959 | s895552121 | 360 | 239 | 27,328 | 22,552 | Accepted | Accepted | 33.61 | N, M=list(map(int, input().split()))
w=[list(map(int, input().split())) for i in range(M)]
R_min=10**6
L_max=0
cnt=0
for i in range(M):
if w[i][1]<=R_min:
R_min=w[i][1]
for i in range(M):
if w[i][0]>=L_max:
L_max=w[i][0]
for num in range(1, N+1):
if L_max<= num <= R_min:
... | n, m=list(map(int, input().split()))
gate=[]
for i in range(m):
L, R=list(map(int, input().split()))
gate.append((L, R))
L_max=0
R_min=10**6
for i in range(m):
if gate[i][0]>L_max:
L_max=gate[i][0]
for i in range(m):
if gate[i][1]<R_min:
R_min=gate[i][1]
ans=0
f... | 18 | 25 | 339 | 385 | N, M = list(map(int, input().split()))
w = [list(map(int, input().split())) for i in range(M)]
R_min = 10**6
L_max = 0
cnt = 0
for i in range(M):
if w[i][1] <= R_min:
R_min = w[i][1]
for i in range(M):
if w[i][0] >= L_max:
L_max = w[i][0]
for num in range(1, N + 1):
if L_max <= num <= R_min:... | n, m = list(map(int, input().split()))
gate = []
for i in range(m):
L, R = list(map(int, input().split()))
gate.append((L, R))
L_max = 0
R_min = 10**6
for i in range(m):
if gate[i][0] > L_max:
L_max = gate[i][0]
for i in range(m):
if gate[i][1] < R_min:
R_min = gate[i][1]
ans = 0
for i i... | false | 28 | [
"-N, M = list(map(int, input().split()))",
"-w = [list(map(int, input().split())) for i in range(M)]",
"+n, m = list(map(int, input().split()))",
"+gate = []",
"+for i in range(m):",
"+ L, R = list(map(int, input().split()))",
"+ gate.append((L, R))",
"+L_max = 0",
"-L_max = 0",
"-cnt = 0",
... | false | 0.042612 | 0.049236 | 0.865458 | [
"s742099959",
"s895552121"
] |
u098012509 | p03645 | python | s522681703 | s473461411 | 686 | 450 | 60,508 | 45,116 | Accepted | Accepted | 34.4 | import sys
import collections
input = sys.stdin.readline
def main():
N, M = [int(x) for x in input().split()]
ab = [[] for j in range(N + 1)]
distance = [0] * (N + 1)
for _ in range(M):
a, b = [int(x) for x in input().split()]
ab[a].append(b)
ab[b].append(a)
... | N, M = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(M)]
x = set()
for a, b in AB:
if a == 1:
x.add(b)
if b == 1:
x.add(a)
f = False
for a, b in AB:
if (a in x and b == N) or (b in x and a == N):
f = True
if f:
pri... | 46 | 21 | 810 | 367 | import sys
import collections
input = sys.stdin.readline
def main():
N, M = [int(x) for x in input().split()]
ab = [[] for j in range(N + 1)]
distance = [0] * (N + 1)
for _ in range(M):
a, b = [int(x) for x in input().split()]
ab[a].append(b)
ab[b].append(a)
q = collection... | N, M = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(M)]
x = set()
for a, b in AB:
if a == 1:
x.add(b)
if b == 1:
x.add(a)
f = False
for a, b in AB:
if (a in x and b == N) or (b in x and a == N):
f = True
if f:
print("POSSIBLE")
else:
... | false | 54.347826 | [
"-import sys",
"-import collections",
"-",
"-input = sys.stdin.readline",
"-",
"-",
"-def main():",
"- N, M = [int(x) for x in input().split()]",
"- ab = [[] for j in range(N + 1)]",
"- distance = [0] * (N + 1)",
"- for _ in range(M):",
"- a, b = [int(x) for x in input().spl... | false | 0.048613 | 0.047148 | 1.031079 | [
"s522681703",
"s473461411"
] |
u312025627 | p02572 | python | s108268129 | s276293204 | 135 | 120 | 103,700 | 105,192 | Accepted | Accepted | 11.11 | MOD = 10**9 + 7
def main():
N = int(eval(input()))
A = [int(i) for i in input().split()]
from itertools import accumulate
S = list(accumulate([0] + A))
ans = 0
for i in range(N-1):
ans += A[i] * (S[N] - S[i+1])
ans %= MOD
print(ans)
if __name__ == '__main__... | MOD = 10**9 + 7
def main():
_ = int(eval(input()))
A = [int(i) for i in input().split()]
ans = (sum(A)**2) % MOD - (sum(pow(a, 2, MOD) for a in A)) % MOD
ans *= pow(2, MOD-2, MOD)
ans %= MOD
print(ans)
if __name__ == '__main__':
main()
| 17 | 15 | 329 | 277 | MOD = 10**9 + 7
def main():
N = int(eval(input()))
A = [int(i) for i in input().split()]
from itertools import accumulate
S = list(accumulate([0] + A))
ans = 0
for i in range(N - 1):
ans += A[i] * (S[N] - S[i + 1])
ans %= MOD
print(ans)
if __name__ == "__main__":
mai... | MOD = 10**9 + 7
def main():
_ = int(eval(input()))
A = [int(i) for i in input().split()]
ans = (sum(A) ** 2) % MOD - (sum(pow(a, 2, MOD) for a in A)) % MOD
ans *= pow(2, MOD - 2, MOD)
ans %= MOD
print(ans)
if __name__ == "__main__":
main()
| false | 11.764706 | [
"- N = int(eval(input()))",
"+ _ = int(eval(input()))",
"- from itertools import accumulate",
"-",
"- S = list(accumulate([0] + A))",
"- ans = 0",
"- for i in range(N - 1):",
"- ans += A[i] * (S[N] - S[i + 1])",
"- ans %= MOD",
"+ ans = (sum(A) ** 2) % MOD - (sum... | false | 0.008074 | 0.037093 | 0.217683 | [
"s108268129",
"s276293204"
] |
u179169725 | p03720 | python | s813265236 | s549636757 | 31 | 26 | 10,124 | 10,180 | Accepted | Accepted | 16.13 | mycode = r'''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。
ctypedef long l... |
import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE': # コンパイル時
mycode = r'''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionError... | 42 | 43 | 983 | 989 | mycode = r"""
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。
ctypedef long long LL
... | import sys
import os
if sys.argv[-1] == "ONLINE_JUDGE": # コンパイル時
mycode = r"""
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処... | false | 2.325581 | [
"-mycode = r\"\"\"",
"+import sys",
"+import os",
"+",
"+if sys.argv[-1] == \"ONLINE_JUDGE\": # コンパイル時",
"+ mycode = r\"\"\"",
"-import sys",
"-import os",
"-",
"-if sys.argv[-1] == \"ONLINE_JUDGE\": # コンパイル時"
] | false | 0.041285 | 0.042342 | 0.975054 | [
"s813265236",
"s549636757"
] |
u581187895 | p02821 | python | s582262950 | s380847390 | 992 | 835 | 21,288 | 21,036 | Accepted | Accepted | 15.83 |
from bisect import bisect_left, bisect_right
from itertools import accumulate
def resolve():
def shake_cnt(x):
cnt = 0
pos = 0
for i in range(N):
pos = bisect_left(A, x - A[i])
cnt += N - pos
return cnt < M # X以上の和がM個未満かどうか
N, M = list(map(in... |
from bisect import bisect_left
from itertools import accumulate
def resolve():
def getCount(x):
count = 0
for Ai in A:
idx = bisect_left(A, x - Ai)
count += N - idx
return count >= M
N, M = list(map(int, input().split()))
A = sorted(map(int, in... | 39 | 38 | 886 | 819 | from bisect import bisect_left, bisect_right
from itertools import accumulate
def resolve():
def shake_cnt(x):
cnt = 0
pos = 0
for i in range(N):
pos = bisect_left(A, x - A[i])
cnt += N - pos
return cnt < M # X以上の和がM個未満かどうか
N, M = list(map(int, input()... | from bisect import bisect_left
from itertools import accumulate
def resolve():
def getCount(x):
count = 0
for Ai in A:
idx = bisect_left(A, x - Ai)
count += N - idx
return count >= M
N, M = list(map(int, input().split()))
A = sorted(map(int, input().split()... | false | 2.564103 | [
"-from bisect import bisect_left, bisect_right",
"+from bisect import bisect_left",
"- def shake_cnt(x):",
"- cnt = 0",
"- pos = 0",
"- for i in range(N):",
"- pos = bisect_left(A, x - A[i])",
"- cnt += N - pos",
"- return cnt < M # X以上の和がM個未満かどう... | false | 0.109652 | 0.079008 | 1.387857 | [
"s582262950",
"s380847390"
] |
u350064373 | p02269 | python | s156177010 | s479148148 | 4,200 | 3,070 | 37,372 | 323,088 | Accepted | Accepted | 26.9 | dic = {}
for s in range(int(eval(input()))):
i = input().split()
if i[0] == "insert":
dic[i[1]] = None
else:
print(("yes" if i[1] in dic else "no")) | dic = {}
line = []
for i in range(int(eval(input()))):
line.append(input().split())
for i in line:
if i[0][0] == "i":
dic[i[1]] = None
else:
print(("yes" if i[1] in dic else "no")) | 7 | 9 | 174 | 208 | dic = {}
for s in range(int(eval(input()))):
i = input().split()
if i[0] == "insert":
dic[i[1]] = None
else:
print(("yes" if i[1] in dic else "no"))
| dic = {}
line = []
for i in range(int(eval(input()))):
line.append(input().split())
for i in line:
if i[0][0] == "i":
dic[i[1]] = None
else:
print(("yes" if i[1] in dic else "no"))
| false | 22.222222 | [
"-for s in range(int(eval(input()))):",
"- i = input().split()",
"- if i[0] == \"insert\":",
"+line = []",
"+for i in range(int(eval(input()))):",
"+ line.append(input().split())",
"+for i in line:",
"+ if i[0][0] == \"i\":"
] | false | 0.036932 | 0.036796 | 1.00369 | [
"s156177010",
"s479148148"
] |
u962718741 | p03681 | python | s242953080 | s879048683 | 263 | 37 | 10,696 | 9,204 | Accepted | Accepted | 85.93 | import math
def main():
N, M = list(map(int, input().split()))
mod = 10 ** 9 + 7
if abs(N - M) > 1:
ans = 0
elif N - M == 1:
ans = (math.factorial(M)**2 * N) % mod
elif N - M == -1:
ans = (math.factorial(N)**2 * M) % mod
else:
ans = (math.factorial(... | def factorial(n, mod=10**9 + 7):
a = 1
for i in range(1, n + 1):
a = a * i % mod
return a
def main():
N, M = list(map(int, input().split()))
mod = 10 ** 9 + 7
if abs(N - M) > 1:
ans = 0
elif abs(N - M) == 1:
ans = (factorial(min(N, M))**2 * max(N, M)) %... | 20 | 22 | 393 | 435 | import math
def main():
N, M = list(map(int, input().split()))
mod = 10**9 + 7
if abs(N - M) > 1:
ans = 0
elif N - M == 1:
ans = (math.factorial(M) ** 2 * N) % mod
elif N - M == -1:
ans = (math.factorial(N) ** 2 * M) % mod
else:
ans = (math.factorial(N) ** 2 * 2... | def factorial(n, mod=10**9 + 7):
a = 1
for i in range(1, n + 1):
a = a * i % mod
return a
def main():
N, M = list(map(int, input().split()))
mod = 10**9 + 7
if abs(N - M) > 1:
ans = 0
elif abs(N - M) == 1:
ans = (factorial(min(N, M)) ** 2 * max(N, M)) % mod
else... | false | 9.090909 | [
"-import math",
"+def factorial(n, mod=10**9 + 7):",
"+ a = 1",
"+ for i in range(1, n + 1):",
"+ a = a * i % mod",
"+ return a",
"- elif N - M == 1:",
"- ans = (math.factorial(M) ** 2 * N) % mod",
"- elif N - M == -1:",
"- ans = (math.factorial(N) ** 2 * M) % m... | false | 0.040105 | 0.075921 | 0.528246 | [
"s242953080",
"s879048683"
] |
u389910364 | p03372 | python | s393729114 | s036403559 | 1,588 | 1,072 | 45,156 | 45,152 | Accepted | Accepted | 32.49 | from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
sys.setrecursionlimit(10000)
INF = float('inf')
def cummax(li, first=-float(... | from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
sys.setrecursionlimit(10000)
INF = float('inf')
def cummax(li, first=-float(... | 69 | 57 | 1,460 | 1,218 | from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
def cummax(li, first=-float("inf")):
"""... | from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
def cummax(li, first=-float("inf")):
"""... | false | 17.391304 | [
"-ans = max(cm1.max(), cm2.max())",
"-# 時計回りに X[L] まで行って、折り返して反時計回りに X[r] まで行く",
"-r = 0",
"-for L in range(len(X)):",
"- while r < len(X) and X[r] < X[L] * 2:",
"- r += 1",
"- if r < len(X):",
"- ans = max(ans, cm1[L] + cm2[r] - X[L])",
"- else:",
"- break",
"-# 反時... | false | 0.735663 | 0.185156 | 3.973201 | [
"s393729114",
"s036403559"
] |
u225388820 | p02646 | python | s964322370 | s416770998 | 63 | 20 | 61,704 | 9,160 | Accepted | Accepted | 68.25 | a,v=list(map(int,input().split()))
b,w=list(map(int,input().split()))
t=int(eval(input()))
k=abs(a-b)
if w-v>0:
print("NO")
elif w==v:
if k==0:
print("YES")
else:
print("NO")
else:
if k<=(v-w)*t:
print("YES")
else:
print("NO") | a,v=list(map(int,input().split()))
b,w=list(map(int,input().split()))
t=int(eval(input()))
k=abs(a-b)
if 0<=k<=(v-w)*t and v!=w:
print("YES")
else:
print("NO") | 16 | 8 | 275 | 156 | a, v = list(map(int, input().split()))
b, w = list(map(int, input().split()))
t = int(eval(input()))
k = abs(a - b)
if w - v > 0:
print("NO")
elif w == v:
if k == 0:
print("YES")
else:
print("NO")
else:
if k <= (v - w) * t:
print("YES")
else:
print("NO")
| a, v = list(map(int, input().split()))
b, w = list(map(int, input().split()))
t = int(eval(input()))
k = abs(a - b)
if 0 <= k <= (v - w) * t and v != w:
print("YES")
else:
print("NO")
| false | 50 | [
"-if w - v > 0:",
"+if 0 <= k <= (v - w) * t and v != w:",
"+ print(\"YES\")",
"+else:",
"-elif w == v:",
"- if k == 0:",
"- print(\"YES\")",
"- else:",
"- print(\"NO\")",
"-else:",
"- if k <= (v - w) * t:",
"- print(\"YES\")",
"- else:",
"- print... | false | 0.036197 | 0.05303 | 0.682571 | [
"s964322370",
"s416770998"
] |
u480472958 | p03564 | python | s798955099 | s121983105 | 22 | 17 | 3,444 | 2,940 | Accepted | Accepted | 22.73 | n, k, ans = int(eval(input())), int(eval(input())), 1
for _ in range(n):
ans += min(ans, k)
print(ans) | n = int(eval(input()))
k = int(eval(input()))
ans = 1
for _ in range(n):
ans += min(ans, k)
print(ans) | 4 | 6 | 97 | 99 | n, k, ans = int(eval(input())), int(eval(input())), 1
for _ in range(n):
ans += min(ans, k)
print(ans)
| n = int(eval(input()))
k = int(eval(input()))
ans = 1
for _ in range(n):
ans += min(ans, k)
print(ans)
| false | 33.333333 | [
"-n, k, ans = int(eval(input())), int(eval(input())), 1",
"+n = int(eval(input()))",
"+k = int(eval(input()))",
"+ans = 1"
] | false | 0.044351 | 0.084525 | 0.52471 | [
"s798955099",
"s121983105"
] |
u753803401 | p03311 | python | s775398191 | s493626832 | 298 | 267 | 79,952 | 75,248 | Accepted | Accepted | 10.4 | import sys
def solve():
input = sys.stdin.readline
mod = 10 ** 9 + 7
n = int(input().rstrip('\n'))
a = list(map(int, input().rstrip('\n').split()))
for i in range(n):
a[i] -= i + 1
a.sort()
t = a[n // 2]
mt = 0
for v in a:
mt += abs(t - v)
print(m... | import sys
def solve():
readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
for i in range(n):
a[i] -= i + 1
a.sort()
t = 0
for v in a:
t += abs(a[n // 2] - v)
print(t)
if __name__ == '... | 20 | 19 | 368 | 344 | import sys
def solve():
input = sys.stdin.readline
mod = 10**9 + 7
n = int(input().rstrip("\n"))
a = list(map(int, input().rstrip("\n").split()))
for i in range(n):
a[i] -= i + 1
a.sort()
t = a[n // 2]
mt = 0
for v in a:
mt += abs(t - v)
print(mt)
if __name__ ... | import sys
def solve():
readline = sys.stdin.buffer.readline
mod = 10**9 + 7
n = int(readline())
a = list(map(int, readline().split()))
for i in range(n):
a[i] -= i + 1
a.sort()
t = 0
for v in a:
t += abs(a[n // 2] - v)
print(t)
if __name__ == "__main__":
solv... | false | 5 | [
"- input = sys.stdin.readline",
"+ readline = sys.stdin.buffer.readline",
"- n = int(input().rstrip(\"\\n\"))",
"- a = list(map(int, input().rstrip(\"\\n\").split()))",
"+ n = int(readline())",
"+ a = list(map(int, readline().split()))",
"- t = a[n // 2]",
"- mt = 0",
"+ t... | false | 0.044931 | 0.043878 | 1.023982 | [
"s775398191",
"s493626832"
] |
u075012704 | p02781 | python | s083649713 | s282740790 | 1,384 | 18 | 42,092 | 3,064 | Accepted | Accepted | 98.7 | N = int(eval(input()))
N_digit = len(str(N))
K = int(eval(input()))
ans = 0
factorial = [1, 1]
for i in range(2, 101):
factorial.append(factorial[-1] * i)
def nCr(n, r):
if n - r < 0:
return 0
return factorial[n] // (factorial[r] * factorial[n - r])
if K == 1:
ans += 9 * (nCr... | N = eval(input())
N_digit = len(N)
K = int(eval(input()))
# dp[i][k] := i番目みて、0でない数がk個出現しているときの通り数
# dp0 := N以下であることが未確定, dp1 := N以下であることが確定
dp0 = [[0] * (K + 1) for i in range(N_digit + 1)]
dp1 = [[0] * (K + 1) for i in range(N_digit + 1)]
dp0[0][0] = 1
for i, n in enumerate(N):
for k in range(K + 1):... | 49 | 28 | 1,645 | 805 | N = int(eval(input()))
N_digit = len(str(N))
K = int(eval(input()))
ans = 0
factorial = [1, 1]
for i in range(2, 101):
factorial.append(factorial[-1] * i)
def nCr(n, r):
if n - r < 0:
return 0
return factorial[n] // (factorial[r] * factorial[n - r])
if K == 1:
ans += 9 * (nCr(N_digit - 1, 1)... | N = eval(input())
N_digit = len(N)
K = int(eval(input()))
# dp[i][k] := i番目みて、0でない数がk個出現しているときの通り数
# dp0 := N以下であることが未確定, dp1 := N以下であることが確定
dp0 = [[0] * (K + 1) for i in range(N_digit + 1)]
dp1 = [[0] * (K + 1) for i in range(N_digit + 1)]
dp0[0][0] = 1
for i, n in enumerate(N):
for k in range(K + 1):
if n... | false | 42.857143 | [
"-N = int(eval(input()))",
"-N_digit = len(str(N))",
"+N = eval(input())",
"+N_digit = len(N)",
"-ans = 0",
"-factorial = [1, 1]",
"-for i in range(2, 101):",
"- factorial.append(factorial[-1] * i)",
"-",
"-",
"-def nCr(n, r):",
"- if n - r < 0:",
"- return 0",
"- return fa... | false | 0.349851 | 0.042551 | 8.221902 | [
"s083649713",
"s282740790"
] |
u970197315 | p03634 | python | s383681504 | s301134566 | 1,573 | 1,305 | 51,276 | 74,256 | Accepted | Accepted | 17.04 | n=int(eval(input()))
G=[[] for i in range(n)]
for i in range(n-1):
u,v,w=list(map(int,input().split()))
G[u-1].append([v-1,w])
G[v-1].append([u-1,w])
dist=[-1]*n
from collections import deque
Q,k=list(map(int,input().split()))
q=deque()
q.append(k-1)
dist[k-1]=0
while q:
cur=q.popleft()
for nx,n... | from heapq import heappop,heappush
def dijkstra(s,n,edge):
"""
始点sから各頂点への最短距離を返す
Parameters
----------
s : int
視点とする頂点(0-indexed)
n : int
グラフの要素数
eage:list
グラグ
Returns
-------
dist :list
始点sから各頂点への最短距離
"""
dist=[float("inf")]*n
dist[s]=0
used=[-1]*n... | 23 | 48 | 484 | 918 | n = int(eval(input()))
G = [[] for i in range(n)]
for i in range(n - 1):
u, v, w = list(map(int, input().split()))
G[u - 1].append([v - 1, w])
G[v - 1].append([u - 1, w])
dist = [-1] * n
from collections import deque
Q, k = list(map(int, input().split()))
q = deque()
q.append(k - 1)
dist[k - 1] = 0
while q... | from heapq import heappop, heappush
def dijkstra(s, n, edge):
"""
始点sから各頂点への最短距離を返す
Parameters
----------
s : int
視点とする頂点(0-indexed)
n : int
グラフの要素数
eage:list
グラグ
Returns
-------
dist :list
始点sから各頂点への最短距離
"""
dist = [float("inf")] * n
dis... | false | 52.083333 | [
"+from heapq import heappop, heappush",
"+",
"+",
"+def dijkstra(s, n, edge):",
"+ \"\"\"",
"+ 始点sから各頂点への最短距離を返す",
"+ Parameters",
"+ s : int",
"+ 視点とする頂点(0-indexed)",
"+ n : int",
"+ グラフの要素数",
"+ eage:list",
"+ グラグ",
"+ Returns",
"+ dist :lis... | false | 0.034421 | 0.037191 | 0.925544 | [
"s383681504",
"s301134566"
] |
u877415670 | p02744 | python | s394113606 | s838440817 | 587 | 155 | 44,556 | 4,412 | Accepted | Accepted | 73.59 | n=int(eval(input()))
char=[chr(i) for i in range(97, 97+26)]
ans=["a"]
before=0
for i in range(2,n+1):
for c in range(len(ans)):
From=char.index(sorted(list(ans[c]))[-1])
for m in range(From+2):
ans.append(ans[c]+char[m])
#print(ans)
b=[]
for g in range(len(ans... | import sys
sys.setrecursionlimit(10**9)
N = int(eval(input()))
def bfs(s, cnt, m):
if cnt == N:
print(s)
return
for i in range(97,ord(m)+2):
if chr(i) > m:
bfs(s+chr(i), cnt+1, chr(i))
else:
bfs(s+chr(i), cnt+1, m)
bfs('a',1,'a') | 23 | 17 | 423 | 259 | n = int(eval(input()))
char = [chr(i) for i in range(97, 97 + 26)]
ans = ["a"]
before = 0
for i in range(2, n + 1):
for c in range(len(ans)):
From = char.index(sorted(list(ans[c]))[-1])
for m in range(From + 2):
ans.append(ans[c] + char[m])
# print(ans)
b = []
for g in range(len(ans)... | import sys
sys.setrecursionlimit(10**9)
N = int(eval(input()))
def bfs(s, cnt, m):
if cnt == N:
print(s)
return
for i in range(97, ord(m) + 2):
if chr(i) > m:
bfs(s + chr(i), cnt + 1, chr(i))
else:
bfs(s + chr(i), cnt + 1, m)
bfs("a", 1, "a")
| false | 26.086957 | [
"-n = int(eval(input()))",
"-char = [chr(i) for i in range(97, 97 + 26)]",
"-ans = [\"a\"]",
"-before = 0",
"-for i in range(2, n + 1):",
"- for c in range(len(ans)):",
"- From = char.index(sorted(list(ans[c]))[-1])",
"- for m in range(From + 2):",
"- ans.append(ans[c] + ... | false | 0.080312 | 0.060792 | 1.321094 | [
"s394113606",
"s838440817"
] |
u088552457 | p03147 | python | s804264796 | s147574557 | 281 | 135 | 64,876 | 77,492 | Accepted | Accepted | 51.96 | import fractions
import sys
from functools import reduce
import math
input = sys.stdin.readline
def main():
n = int(eval(input()))
h = input_list()
count = 0
while list(set(h)) != [0]:
count += 1
flag = False
for i, v in enumerate(h):
if v != 0:
... | # import sys
# input = sys.stdin.readline
# import re
import collections
import bisect
import math
import fractions
import collections
import itertools
from functools import reduce
def main():
n = int(eval(input()))
h = list(input_list())
count = 0
while True:
if list(set(h)) ==... | 70 | 48 | 1,310 | 914 | import fractions
import sys
from functools import reduce
import math
input = sys.stdin.readline
def main():
n = int(eval(input()))
h = input_list()
count = 0
while list(set(h)) != [0]:
count += 1
flag = False
for i, v in enumerate(h):
if v != 0:
fla... | # import sys
# input = sys.stdin.readline
# import re
import collections
import bisect
import math
import fractions
import collections
import itertools
from functools import reduce
def main():
n = int(eval(input()))
h = list(input_list())
count = 0
while True:
if list(set(h)) == [0]:
... | false | 31.428571 | [
"+# import sys",
"+# input = sys.stdin.readline",
"+# import re",
"+import collections",
"+import bisect",
"+import math",
"-import sys",
"+import collections",
"+import itertools",
"-import math",
"-",
"-input = sys.stdin.readline",
"- h = input_list()",
"+ h = list(input_list())",
... | false | 0.11715 | 0.047145 | 2.484874 | [
"s804264796",
"s147574557"
] |
u562935282 | p03765 | python | s401766186 | s198672505 | 510 | 466 | 15,772 | 15,772 | Accepted | Accepted | 8.63 | # https://atcoder.jp/contests/arc071/submissions/6325840
from itertools import accumulate
S = tuple(map(lambda x: 1 if x == 'A' else 2, input()))
T = tuple(map(lambda x: 1 if x == 'A' else 2, input()))
# A=1,B=2
acc_s = (0,) + tuple(accumulate(S))
acc_t = (0,) + tuple(accumulate(T))
ans = []
Q = int(i... | # https://atcoder.jp/contests/arc071/submissions/6325840
from itertools import accumulate
convert = {'A': 1, 'B': 2}
S = tuple(convert[x] for x in input())
T = tuple(convert[x] for x in input())
# maspyさんのやり方
acc_s = (0,) + tuple(accumulate(S))
acc_t = (0,) + tuple(accumulate(T))
ans = []
Q = int(input... | 23 | 23 | 603 | 599 | # https://atcoder.jp/contests/arc071/submissions/6325840
from itertools import accumulate
S = tuple(map(lambda x: 1 if x == "A" else 2, input()))
T = tuple(map(lambda x: 1 if x == "A" else 2, input()))
# A=1,B=2
acc_s = (0,) + tuple(accumulate(S))
acc_t = (0,) + tuple(accumulate(T))
ans = []
Q = int(input())
for _ in ... | # https://atcoder.jp/contests/arc071/submissions/6325840
from itertools import accumulate
convert = {"A": 1, "B": 2}
S = tuple(convert[x] for x in input())
T = tuple(convert[x] for x in input())
# maspyさんのやり方
acc_s = (0,) + tuple(accumulate(S))
acc_t = (0,) + tuple(accumulate(T))
ans = []
Q = int(input())
for _ in ran... | false | 0 | [
"-S = tuple(map(lambda x: 1 if x == \"A\" else 2, input()))",
"-T = tuple(map(lambda x: 1 if x == \"A\" else 2, input()))",
"-# A=1,B=2",
"+convert = {\"A\": 1, \"B\": 2}",
"+S = tuple(convert[x] for x in input())",
"+T = tuple(convert[x] for x in input())",
"+# maspyさんのやり方"
] | false | 0.126084 | 0.099 | 1.273576 | [
"s401766186",
"s198672505"
] |
u163320134 | p02972 | python | s327969892 | s210636911 | 679 | 493 | 14,096 | 14,000 | Accepted | Accepted | 27.39 | n=int(eval(input()))
arr=list(map(int,input().split()))
flag=[-1]*n
ans=[]
for i in range(n-1,-1,-1):
cnt=0
for j in range(i,n,i+1):
if j==i:
continue
else:
if flag[j]==1:
cnt+=1
if (arr[i]+cnt)%2==0:
flag[i]=0
else:
flag[i]=1
ans.append(i+1)
num=len(ans)... | n=int(eval(input()))
arr=list(map(int,input().split()))
flag=[-1]*n
ans=[]
for i in range(n-1,-1,-1):
cnt=0
for j in range(2*i+1,n,i+1):
if flag[j]==1:
cnt+=1
if (arr[i]+cnt)%2==0:
flag[i]=0
else:
flag[i]=1
ans.append(i+1)
num=len(ans)
if num==0:
print((0))
else:
prin... | 23 | 20 | 374 | 333 | n = int(eval(input()))
arr = list(map(int, input().split()))
flag = [-1] * n
ans = []
for i in range(n - 1, -1, -1):
cnt = 0
for j in range(i, n, i + 1):
if j == i:
continue
else:
if flag[j] == 1:
cnt += 1
if (arr[i] + cnt) % 2 == 0:
flag[i] = ... | n = int(eval(input()))
arr = list(map(int, input().split()))
flag = [-1] * n
ans = []
for i in range(n - 1, -1, -1):
cnt = 0
for j in range(2 * i + 1, n, i + 1):
if flag[j] == 1:
cnt += 1
if (arr[i] + cnt) % 2 == 0:
flag[i] = 0
else:
flag[i] = 1
ans.append(i +... | false | 13.043478 | [
"- for j in range(i, n, i + 1):",
"- if j == i:",
"- continue",
"- else:",
"- if flag[j] == 1:",
"- cnt += 1",
"+ for j in range(2 * i + 1, n, i + 1):",
"+ if flag[j] == 1:",
"+ cnt += 1"
] | false | 0.037436 | 0.037523 | 0.997674 | [
"s327969892",
"s210636911"
] |
u347267726 | p03250 | python | s106015088 | s477174657 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | a,b,c=list(map(int,input().split()))
if(a>=b):
if(a>=c):
print(((a*10)+b+c))
else:
print(((c*10)+a+b))
elif (b>=c):
print((b * 10 + a + c)) | a,b,c=sorted(map(int,input().split()))
print((c*10+a+b)) | 8 | 2 | 162 | 55 | a, b, c = list(map(int, input().split()))
if a >= b:
if a >= c:
print(((a * 10) + b + c))
else:
print(((c * 10) + a + b))
elif b >= c:
print((b * 10 + a + c))
| a, b, c = sorted(map(int, input().split()))
print((c * 10 + a + b))
| false | 75 | [
"-a, b, c = list(map(int, input().split()))",
"-if a >= b:",
"- if a >= c:",
"- print(((a * 10) + b + c))",
"- else:",
"- print(((c * 10) + a + b))",
"-elif b >= c:",
"- print((b * 10 + a + c))",
"+a, b, c = sorted(map(int, input().split()))",
"+print((c * 10 + a + b))"
] | false | 0.045345 | 0.043166 | 1.050468 | [
"s106015088",
"s477174657"
] |
u844646164 | p02768 | python | s270357406 | s781971633 | 175 | 144 | 38,640 | 3,064 | Accepted | Accepted | 17.71 | def ncr(n, r, p):
num = den = 1
for i in range(r):
num = (num * (n - i)) % p
den = (den * (i + 1)) % p
return (num * pow(den, p - 2, p)) % p
p=10**9+7
n,a,b = list(map(int,(input().split())))
bb = ncr(n,a,p)+ncr(n,b,p)+1
print(((pow(2,n,p)-(bb%p))%p)) | n, a, b = list(map(int, input().split()))
fac = [1, 1]
finv = [1, 1]
inv = [0, 1]
Mod = 10**9+7
def COMinit():
#N_C_kのN
for i in range(2, n+10):
fac.append(fac[-1]*i%Mod)
inv.append((-inv[Mod%i] * (Mod//i)) % Mod)
finv.append(finv[-1] * inv[-1] % Mod)
def COM(n, k):
if n < 0 or k < 0... | 10 | 35 | 275 | 673 | def ncr(n, r, p):
num = den = 1
for i in range(r):
num = (num * (n - i)) % p
den = (den * (i + 1)) % p
return (num * pow(den, p - 2, p)) % p
p = 10**9 + 7
n, a, b = list(map(int, (input().split())))
bb = ncr(n, a, p) + ncr(n, b, p) + 1
print(((pow(2, n, p) - (bb % p)) % p))
| n, a, b = list(map(int, input().split()))
fac = [1, 1]
finv = [1, 1]
inv = [0, 1]
Mod = 10**9 + 7
def COMinit():
# N_C_kのN
for i in range(2, n + 10):
fac.append(fac[-1] * i % Mod)
inv.append((-inv[Mod % i] * (Mod // i)) % Mod)
finv.append(finv[-1] * inv[-1] % Mod)
def COM(n, k):
... | false | 71.428571 | [
"+n, a, b = list(map(int, input().split()))",
"+fac = [1, 1]",
"+finv = [1, 1]",
"+inv = [0, 1]",
"+Mod = 10**9 + 7",
"+",
"+",
"+def COMinit():",
"+ # N_C_kのN",
"+ for i in range(2, n + 10):",
"+ fac.append(fac[-1] * i % Mod)",
"+ inv.append((-inv[Mod % i] * (Mod // i)) % ... | false | 0.117248 | 0.181521 | 0.645918 | [
"s270357406",
"s781971633"
] |
u941407962 | p03968 | python | s278280086 | s728372760 | 2,981 | 2,755 | 49,240 | 62,680 | Accepted | Accepted | 7.58 | from collections import defaultdict
N, = list(map(int, input().split()))
dd = defaultdict(int)
cc = dict()
norm = dict()
ss = []
for _ in range(N):
xs = list(map(int, input().split()))
cnd = [tuple(xs[j:] + xs[:j]) for j in range(1, 5)]
x = min(cnd)
for item in cnd:
norm[item] = x
... | from collections import defaultdict
N, = list(map(int, input().split()))
dd = defaultdict(int)
cc = dict()
nrm = dict()
ss = []
for _ in range(N):
xs = list(map(int, input().split()))
cnd = [tuple(xs[j:]+xs[:j])for j in range(4)]
x = min(cnd)
for item in cnd:
nrm[item] = x
dd[x] += 1
cc[x] ... | 46 | 41 | 1,061 | 909 | from collections import defaultdict
(N,) = list(map(int, input().split()))
dd = defaultdict(int)
cc = dict()
norm = dict()
ss = []
for _ in range(N):
xs = list(map(int, input().split()))
cnd = [tuple(xs[j:] + xs[:j]) for j in range(1, 5)]
x = min(cnd)
for item in cnd:
norm[item] = x
dd[x] +... | from collections import defaultdict
(N,) = list(map(int, input().split()))
dd = defaultdict(int)
cc = dict()
nrm = dict()
ss = []
for _ in range(N):
xs = list(map(int, input().split()))
cnd = [tuple(xs[j:] + xs[:j]) for j in range(4)]
x = min(cnd)
for item in cnd:
nrm[item] = x
dd[x] += 1
... | false | 10.869565 | [
"-norm = dict()",
"+nrm = dict()",
"- cnd = [tuple(xs[j:] + xs[:j]) for j in range(1, 5)]",
"+ cnd = [tuple(xs[j:] + xs[:j]) for j in range(4)]",
"- norm[item] = x",
"+ nrm[item] = x",
"- for i in range(4):",
"- if tl[i] not in norm:",
"+ q = defaultdict(int)",
"+ ... | false | 0.067829 | 0.085532 | 0.793029 | [
"s278280086",
"s728372760"
] |
u088552457 | p03147 | python | s147574557 | s079316265 | 135 | 73 | 77,492 | 67,980 | Accepted | Accepted | 45.93 | # import sys
# input = sys.stdin.readline
# import re
import collections
import bisect
import math
import fractions
import collections
import itertools
from functools import reduce
def main():
n = int(eval(input()))
h = list(input_list())
count = 0
while True:
if list(set(h)) ==... | # import sys
# input = sys.stdin.readline
import collections
def main():
n = int(eval(input()))
h = input_list()
count = 0
while True:
if list(set(h)) == [0]:
break
count += 1
f = False
for i, v in enumerate(h):
if v == 0:
... | 48 | 33 | 914 | 630 | # import sys
# input = sys.stdin.readline
# import re
import collections
import bisect
import math
import fractions
import collections
import itertools
from functools import reduce
def main():
n = int(eval(input()))
h = list(input_list())
count = 0
while True:
if list(set(h)) == [0]:
... | # import sys
# input = sys.stdin.readline
import collections
def main():
n = int(eval(input()))
h = input_list()
count = 0
while True:
if list(set(h)) == [0]:
break
count += 1
f = False
for i, v in enumerate(h):
if v == 0:
if f:
... | false | 31.25 | [
"-# import re",
"-import bisect",
"-import math",
"-import fractions",
"-import collections",
"-import itertools",
"-from functools import reduce",
"- h = list(input_list())",
"+ h = input_list()",
"- flag = False",
"+ f = False",
"- if v != 0:",
"- ... | false | 0.047145 | 0.035083 | 1.343829 | [
"s147574557",
"s079316265"
] |
u423665486 | p03944 | python | s600738205 | s159838566 | 202 | 46 | 41,712 | 3,064 | Accepted | Accepted | 77.23 | def resolve():
w, h, n = list(map(int, input().split()))
r = [[True]*w for _ in range(h)]
for _ in range(n):
ix, iy, a = list(map(int, input().split()))
if a == 1:
for i in range(h):
for j in range(ix):
r[i][j] = False
elif a == 2:
for i in range(h):
for j in range(ix, w):
r... | def resolve():
w, h, n = list(map(int, input().split()))
r = [[True]*w for _ in range(h)]
for i in range(n):
x, y, a = list(map(int, input().split()))
if a == 1:
for j in range(h):
for k in range(x):
r[j][k] = False
if a == 2:
for j in range(h):
for k in range(x, w):
r[j][k]... | 29 | 28 | 583 | 582 | def resolve():
w, h, n = list(map(int, input().split()))
r = [[True] * w for _ in range(h)]
for _ in range(n):
ix, iy, a = list(map(int, input().split()))
if a == 1:
for i in range(h):
for j in range(ix):
r[i][j] = False
elif a == 2:
... | def resolve():
w, h, n = list(map(int, input().split()))
r = [[True] * w for _ in range(h)]
for i in range(n):
x, y, a = list(map(int, input().split()))
if a == 1:
for j in range(h):
for k in range(x):
r[j][k] = False
if a == 2:
... | false | 3.448276 | [
"- for _ in range(n):",
"- ix, iy, a = list(map(int, input().split()))",
"+ for i in range(n):",
"+ x, y, a = list(map(int, input().split()))",
"- for i in range(h):",
"- for j in range(ix):",
"- r[i][j] = False",
"- elif a == 2:"... | false | 0.058008 | 0.057982 | 1.000447 | [
"s600738205",
"s159838566"
] |
u539367121 | p02773 | python | s378751125 | s381799670 | 735 | 391 | 67,208 | 35,320 | Accepted | Accepted | 46.8 | N=int(eval(input()))
S={}
for n in range(N):
s=eval(input())
S[s]=S.get(s,0)+1
maxS=max(S.values())
S={k:v for k, v in list(S.items()) if v==maxS}
S=sorted(list(S.items()), key=lambda x:(-x[1],x[0]))
for k,cnt in S:
print(k)
| N=int(eval(input()))
S={}
for n in range(N):
s=eval(input())
S[s]=S.get(s,0)+1
maxS=max(S.values())
S=[k for k,v in list(S.items()) if v==maxS]
print(('\n'.join(sorted(S))))
| 11 | 9 | 218 | 167 | N = int(eval(input()))
S = {}
for n in range(N):
s = eval(input())
S[s] = S.get(s, 0) + 1
maxS = max(S.values())
S = {k: v for k, v in list(S.items()) if v == maxS}
S = sorted(list(S.items()), key=lambda x: (-x[1], x[0]))
for k, cnt in S:
print(k)
| N = int(eval(input()))
S = {}
for n in range(N):
s = eval(input())
S[s] = S.get(s, 0) + 1
maxS = max(S.values())
S = [k for k, v in list(S.items()) if v == maxS]
print(("\n".join(sorted(S))))
| false | 18.181818 | [
"-S = {k: v for k, v in list(S.items()) if v == maxS}",
"-S = sorted(list(S.items()), key=lambda x: (-x[1], x[0]))",
"-for k, cnt in S:",
"- print(k)",
"+S = [k for k, v in list(S.items()) if v == maxS]",
"+print((\"\\n\".join(sorted(S))))"
] | false | 0.06767 | 0.036807 | 1.838506 | [
"s378751125",
"s381799670"
] |
u648901783 | p03805 | python | s384971430 | s265211768 | 37 | 28 | 3,064 | 3,316 | Accepted | Accepted | 24.32 | n,m= list(map(int,input().split()))
a = [input().rstrip().split() for j in range(m)]
cnt = 0#現在の経路
# a
visited=[False]*n#もう訪問したか
graph = [[False for i in range(n)] for j in range(n)]#どこが連結されているか
# graph
for i in range(0,m):
x = int(a[i][0])-1
y = int(a[i][1])-1
graph[x][y]=graph[y][x]=True
# grap... | N,M = list(map(int,input().split()))
ab = [list(map(int,input().split())) for i in range(M)]
from collections import defaultdict
memo = defaultdict(list)
for ele in ab:
memo[ele[0]-1].append(ele[1]-1)
memo[ele[1]-1].append(ele[0]-1)
que = []
visited = defaultdict(int)
ans = [0]
def dfs(visit... | 37 | 34 | 818 | 684 | n, m = list(map(int, input().split()))
a = [input().rstrip().split() for j in range(m)]
cnt = 0 # 現在の経路
# a
visited = [False] * n # もう訪問したか
graph = [[False for i in range(n)] for j in range(n)] # どこが連結されているか
# graph
for i in range(0, m):
x = int(a[i][0]) - 1
y = int(a[i][1]) - 1
graph[x][y] = graph[y][x]... | N, M = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(M)]
from collections import defaultdict
memo = defaultdict(list)
for ele in ab:
memo[ele[0] - 1].append(ele[1] - 1)
memo[ele[1] - 1].append(ele[0] - 1)
que = []
visited = defaultdict(int)
ans = [0]
def dfs(visited, no... | false | 8.108108 | [
"-n, m = list(map(int, input().split()))",
"-a = [input().rstrip().split() for j in range(m)]",
"-cnt = 0 # 現在の経路",
"-# a",
"-visited = [False] * n # もう訪問したか",
"-graph = [[False for i in range(n)] for j in range(n)] # どこが連結されているか",
"-# graph",
"-for i in range(0, m):",
"- x = int(a[i][0]) - 1"... | false | 0.047172 | 0.045936 | 1.026919 | [
"s384971430",
"s265211768"
] |
u647766105 | p00114 | python | s046397552 | s963812514 | 360 | 230 | 5,900 | 5,900 | Accepted | Accepted | 36.11 | from fractions import gcd
from functools import reduce
def lcm(a,b):
return a*b/gcd(a,b)
while True:
tmp = list(map(int, input().split(" ")))
if all(t==0 for t in tmp):
break
b = []
for a,m in zip(tmp[::2], tmp[1::2]):
i, c = 1, a%m
while c!=1:
c = (a*c... | from fractions import gcd
from functools import reduce
def lcm(a,b):
return a*b/gcd(a,b)
def ge(a,m):
for aa,mm in zip(a, m):
i, b = 1, aa%mm
while b!=1:
b = (aa*b)%mm
i += 1
yield i
while True:
tmp = list(map(int, input().split(" ")))
if all(... | 15 | 15 | 358 | 369 | from fractions import gcd
from functools import reduce
def lcm(a, b):
return a * b / gcd(a, b)
while True:
tmp = list(map(int, input().split(" ")))
if all(t == 0 for t in tmp):
break
b = []
for a, m in zip(tmp[::2], tmp[1::2]):
i, c = 1, a % m
while c != 1:
c ... | from fractions import gcd
from functools import reduce
def lcm(a, b):
return a * b / gcd(a, b)
def ge(a, m):
for aa, mm in zip(a, m):
i, b = 1, aa % mm
while b != 1:
b = (aa * b) % mm
i += 1
yield i
while True:
tmp = list(map(int, input().split(" ")))
... | false | 0 | [
"+def ge(a, m):",
"+ for aa, mm in zip(a, m):",
"+ i, b = 1, aa % mm",
"+ while b != 1:",
"+ b = (aa * b) % mm",
"+ i += 1",
"+ yield i",
"+",
"+",
"- b = []",
"- for a, m in zip(tmp[::2], tmp[1::2]):",
"- i, c = 1, a % m",
"- ... | false | 0.051283 | 0.052724 | 0.972667 | [
"s046397552",
"s963812514"
] |
u962909487 | p02397 | python | s084955841 | s923753607 | 60 | 50 | 5,612 | 5,612 | Accepted | Accepted | 16.67 | while True:
x,y = list(map(int,input().split()))
if (x,y) ==(0,0): break
if x < y:
print((x,y))
else:
print((y,x))
| while True:
a,b = list(map(int,input().split()))
if a == 0 and b==0:
break
if a > b:
print((b,a))
else:
print((a,b))
| 7 | 8 | 143 | 155 | while True:
x, y = list(map(int, input().split()))
if (x, y) == (0, 0):
break
if x < y:
print((x, y))
else:
print((y, x))
| while True:
a, b = list(map(int, input().split()))
if a == 0 and b == 0:
break
if a > b:
print((b, a))
else:
print((a, b))
| false | 12.5 | [
"- x, y = list(map(int, input().split()))",
"- if (x, y) == (0, 0):",
"+ a, b = list(map(int, input().split()))",
"+ if a == 0 and b == 0:",
"- if x < y:",
"- print((x, y))",
"+ if a > b:",
"+ print((b, a))",
"- print((y, x))",
"+ print((a, b))"
] | false | 0.079286 | 0.080821 | 0.981016 | [
"s084955841",
"s923753607"
] |
u426764965 | p02947 | python | s729550285 | s673409840 | 845 | 456 | 12,224 | 19,732 | Accepted | Accepted | 46.04 | N = int(eval(input()))
words = []
for i in range(N):
s = str(eval(input()))
s_sort = ''.join(sorted([ch for ch in s]))
words.append(s_sort)
words_sort = sorted(words)
counter = 0
target_word = ''
counts = []
for word in words_sort:
if word == target_word:
counter += 1
else:
counts.ap... | N = int(eval(input()))
words = []
for i in range(N):
s_in = str(eval(input()))
s_sort = ''.join(sorted([ch for ch in s_in]))
words.append(s_sort)
#print(words)
# Counterクラス: key=要素, val=出現回数
from collections import Counter
cntr = Counter(words)
#print(cntr)
# 出現回数2個以上は組み合わせ数を足す
ans = 0
for cnt in... | 30 | 20 | 530 | 385 | N = int(eval(input()))
words = []
for i in range(N):
s = str(eval(input()))
s_sort = "".join(sorted([ch for ch in s]))
words.append(s_sort)
words_sort = sorted(words)
counter = 0
target_word = ""
counts = []
for word in words_sort:
if word == target_word:
counter += 1
else:
counts.ap... | N = int(eval(input()))
words = []
for i in range(N):
s_in = str(eval(input()))
s_sort = "".join(sorted([ch for ch in s_in]))
words.append(s_sort)
# print(words)
# Counterクラス: key=要素, val=出現回数
from collections import Counter
cntr = Counter(words)
# print(cntr)
# 出現回数2個以上は組み合わせ数を足す
ans = 0
for cnt in list(cn... | false | 33.333333 | [
"- s = str(eval(input()))",
"- s_sort = \"\".join(sorted([ch for ch in s]))",
"+ s_in = str(eval(input()))",
"+ s_sort = \"\".join(sorted([ch for ch in s_in]))",
"-words_sort = sorted(words)",
"-counter = 0",
"-target_word = \"\"",
"-counts = []",
"-for word in words_sort:",
"- if w... | false | 0.034974 | 0.037601 | 0.930135 | [
"s729550285",
"s673409840"
] |
u054556734 | p03575 | python | s087268869 | s917311295 | 242 | 166 | 17,568 | 13,240 | Accepted | Accepted | 31.4 | import numpy as np
class unionfind: #ノード数nを読み込む
def __init__(self,n): #コンストラクタ
self.parent = list(range(n))
def find(self,a): #根を探す、そのつど根を更新
if self.parent[a] == a: return a #自分が根だったら終了
else:
self.parent[a] = self.find(self.parent[a]) #経路圧縮
return self.p... | import numpy as np
def find(x):
if x == root[x]: return x
else: root[x] = find(root[x]); return root[x]
def unite(x,y):
px,py = find(x),find(y)
if px == py : return
else: root[px] = py
def same(x,y): return find(x)==find(y)
n,m = list(map(int,input().split()))
ab = np.array([list(map... | 42 | 27 | 1,226 | 662 | import numpy as np
class unionfind: # ノード数nを読み込む
def __init__(self, n): # コンストラクタ
self.parent = list(range(n))
def find(self, a): # 根を探す、そのつど根を更新
if self.parent[a] == a:
return a # 自分が根だったら終了
else:
self.parent[a] = self.find(self.parent[a]) # 経路圧縮
... | import numpy as np
def find(x):
if x == root[x]:
return x
else:
root[x] = find(root[x])
return root[x]
def unite(x, y):
px, py = find(x), find(y)
if px == py:
return
else:
root[px] = py
def same(x, y):
return find(x) == find(y)
n, m = list(map(int,... | false | 35.714286 | [
"-class unionfind: # ノード数nを読み込む",
"- def __init__(self, n): # コンストラクタ",
"- self.parent = list(range(n))",
"-",
"- def find(self, a): # 根を探す、そのつど根を更新",
"- if self.parent[a] == a:",
"- return a # 自分が根だったら終了",
"- else:",
"- self.parent[a] = self.find... | false | 0.36359 | 0.211057 | 1.722708 | [
"s087268869",
"s917311295"
] |
u981122970 | p03013 | python | s760395888 | s129860592 | 514 | 441 | 463,984 | 464,008 | Accepted | Accepted | 14.2 | n, m = [int(i) for i in input().split()]
a = [-1] + [int(eval(input())) for _ in range(m)] + [n+1]
fib_l = [-1] * (n+3)
def make_fib(n):
fib_l[0] = fib_l[1] = 1
for i in range(2, n):
fib_l[i] = fib_l[i-1] + fib_l[i-2]
make_fib(n+3)
ret = 1
for i in range(m+1):
t = a[i+1] - a[i] - 2
... | from sys import stdin
n, m = [int(i) for i in stdin.readline().rstrip().split()]
a = [-1] + [int(stdin.readline()) for _ in range(m)] + [n+1]
fib_l = [-1] * (n+3)
def make_fib(n):
fib_l[0] = fib_l[1] = 1
for i in range(2, n):
fib_l[i] = fib_l[i-1] + fib_l[i-2]
make_fib(n+3)
ret = 1
for... | 19 | 21 | 405 | 457 | n, m = [int(i) for i in input().split()]
a = [-1] + [int(eval(input())) for _ in range(m)] + [n + 1]
fib_l = [-1] * (n + 3)
def make_fib(n):
fib_l[0] = fib_l[1] = 1
for i in range(2, n):
fib_l[i] = fib_l[i - 1] + fib_l[i - 2]
make_fib(n + 3)
ret = 1
for i in range(m + 1):
t = a[i + 1] - a[i] - 2... | from sys import stdin
n, m = [int(i) for i in stdin.readline().rstrip().split()]
a = [-1] + [int(stdin.readline()) for _ in range(m)] + [n + 1]
fib_l = [-1] * (n + 3)
def make_fib(n):
fib_l[0] = fib_l[1] = 1
for i in range(2, n):
fib_l[i] = fib_l[i - 1] + fib_l[i - 2]
make_fib(n + 3)
ret = 1
for i ... | false | 9.52381 | [
"-n, m = [int(i) for i in input().split()]",
"-a = [-1] + [int(eval(input())) for _ in range(m)] + [n + 1]",
"+from sys import stdin",
"+",
"+n, m = [int(i) for i in stdin.readline().rstrip().split()]",
"+a = [-1] + [int(stdin.readline()) for _ in range(m)] + [n + 1]"
] | false | 0.086412 | 0.042954 | 2.011747 | [
"s760395888",
"s129860592"
] |
u863442865 | p02936 | python | s106886610 | s880017161 | 1,877 | 1,182 | 80,516 | 80,544 | Accepted | Accepted | 37.03 | import sys
sys.setrecursionlimit(500000)
N, Q = list(map(int, input().split()))
G = [set() for _ in range(N)]
cnt = [0]*N
visited = [0]*N
def dfs(start_node):
for i in G[start_node]:
if visited[i]==0:
visited[i]=1
cnt[i] += cnt[start_node]
dfs(i)
for _ i... | import sys
sys.setrecursionlimit(500000)
input = sys.stdin.readline
N, Q = list(map(int, input().split()))
G = [set() for _ in range(N)]
cnt = [0]*N
visited = [0]*N
for _ in range(N-1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
G[a].add(b)
G[b].add(a)
for i in range(Q):... | 39 | 33 | 730 | 596 | import sys
sys.setrecursionlimit(500000)
N, Q = list(map(int, input().split()))
G = [set() for _ in range(N)]
cnt = [0] * N
visited = [0] * N
def dfs(start_node):
for i in G[start_node]:
if visited[i] == 0:
visited[i] = 1
cnt[i] += cnt[start_node]
dfs(i)
for _ in ran... | import sys
sys.setrecursionlimit(500000)
input = sys.stdin.readline
N, Q = list(map(int, input().split()))
G = [set() for _ in range(N)]
cnt = [0] * N
visited = [0] * N
for _ in range(N - 1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
G[a].add(b)
G[b].add(a)
for i in range(Q):
node, x... | false | 15.384615 | [
"+input = sys.stdin.readline",
"-",
"-",
"-def dfs(start_node):",
"- for i in G[start_node]:",
"- if visited[i] == 0:",
"- visited[i] = 1",
"- cnt[i] += cnt[start_node]",
"- dfs(i)",
"-",
"-",
"-# dfs(0)"
] | false | 0.008288 | 0.066206 | 0.125188 | [
"s106886610",
"s880017161"
] |
u855775311 | p02376 | python | s196109310 | s813184390 | 50 | 40 | 7,888 | 7,856 | Accepted | Accepted | 20 | def main():
nvertices, nedges = list(map(int, input().split()))
adj = [[0] * nvertices for i in range(nvertices)]
for i in range(nedges):
u, v, c = list(map(int, input().split()))
adj[u][v] = c
ans = 0
while True:
parents = bfs(0, nvertices - 1, adj)
if par... | def main():
nvertices, nedges = list(map(int, input().split()))
adj = [[0] * nvertices for j in range(nvertices)]
for i in range(nedges):
u, v, c = list(map(int, input().split()))
adj[u][v] = c
INF = float('inf')
ans = 0
while True:
parents = bfs(0, nvertices -... | 49 | 52 | 1,184 | 1,185 | def main():
nvertices, nedges = list(map(int, input().split()))
adj = [[0] * nvertices for i in range(nvertices)]
for i in range(nedges):
u, v, c = list(map(int, input().split()))
adj[u][v] = c
ans = 0
while True:
parents = bfs(0, nvertices - 1, adj)
if parents is Non... | def main():
nvertices, nedges = list(map(int, input().split()))
adj = [[0] * nvertices for j in range(nvertices)]
for i in range(nedges):
u, v, c = list(map(int, input().split()))
adj[u][v] = c
INF = float("inf")
ans = 0
while True:
parents = bfs(0, nvertices - 1, adj)
... | false | 5.769231 | [
"- adj = [[0] * nvertices for i in range(nvertices)]",
"+ adj = [[0] * nvertices for j in range(nvertices)]",
"+ INF = float(\"inf\")",
"- flow = float(\"inf\")",
"+ f = INF",
"- flow = min(flow, adj[u][v])",
"+ f = min(f, adj[u][v])",
"- ans += flow... | false | 0.037972 | 0.007936 | 4.784715 | [
"s196109310",
"s813184390"
] |
u504836877 | p03682 | python | s335391229 | s639211207 | 1,734 | 1,279 | 55,384 | 43,972 | Accepted | Accepted | 26.24 | from operator import itemgetter
import heapq
N = int(eval(input()))
X = [[int(p) for p in input().split()] for _ in range(N)]
X.sort()
for i in range(N):
X[i].append(i)
Y = sorted(X, key=itemgetter(1))
h = []
for i in range(N-1):
heapq.heappush(h, (X[i+1][0]-X[i][0], i+1, i))
heapq.he... | from operator import itemgetter
import heapq
N = int(eval(input()))
pos = [[int(p) for p in input().split()] for _ in range(N)]
pos.sort()
for i in range(N):
pos[i].append(i)
Y = sorted(pos, key=itemgetter(1))
Y_idx = [0]*N
for i in range(N):
Y_idx[Y[i][2]] = i
ans = 0
used = [0]*N... | 62 | 47 | 1,495 | 1,169 | from operator import itemgetter
import heapq
N = int(eval(input()))
X = [[int(p) for p in input().split()] for _ in range(N)]
X.sort()
for i in range(N):
X[i].append(i)
Y = sorted(X, key=itemgetter(1))
h = []
for i in range(N - 1):
heapq.heappush(h, (X[i + 1][0] - X[i][0], i + 1, i))
heapq.heappush(h, (Y[i... | from operator import itemgetter
import heapq
N = int(eval(input()))
pos = [[int(p) for p in input().split()] for _ in range(N)]
pos.sort()
for i in range(N):
pos[i].append(i)
Y = sorted(pos, key=itemgetter(1))
Y_idx = [0] * N
for i in range(N):
Y_idx[Y[i][2]] = i
ans = 0
used = [0] * N
used[0] = 1
h = []
c = 1... | false | 24.193548 | [
"-X = [[int(p) for p in input().split()] for _ in range(N)]",
"-X.sort()",
"+pos = [[int(p) for p in input().split()] for _ in range(N)]",
"+pos.sort()",
"- X[i].append(i)",
"-Y = sorted(X, key=itemgetter(1))",
"+ pos[i].append(i)",
"+Y = sorted(pos, key=itemgetter(1))",
"+Y_idx = [0] * N",
... | false | 0.040824 | 0.039179 | 1.041977 | [
"s335391229",
"s639211207"
] |
u038404105 | p02678 | python | s966236436 | s782640272 | 1,364 | 698 | 34,652 | 34,228 | Accepted | Accepted | 48.83 | N, M = list(map(int, input().split()))
to = [[] for i in range(N+1)]
dist = [100001 for i in range(N+1)]
flug = [1 for i in range(N+1)]
to[0].append(1)
dist[0] = 0
flug[0] = 0
for i in range(M):
a, b = list(map(int, input().split()))
to[a].append(b)
to[b].append(a)
q = []
q.append(0)
... | from collections import deque
N, M = list(map(int, input().split()))
to = [[] for i in range(N+1)]
#dist = [100001 for i in range(N+1)]
flug = [0 for i in range(N+1)]
to[0].append(1)
#dist[0] = 0
for i in range(M):
a, b = list(map(int, input().split()))
to[a].append(b)
to[b].append(a)
q =... | 29 | 27 | 542 | 555 | N, M = list(map(int, input().split()))
to = [[] for i in range(N + 1)]
dist = [100001 for i in range(N + 1)]
flug = [1 for i in range(N + 1)]
to[0].append(1)
dist[0] = 0
flug[0] = 0
for i in range(M):
a, b = list(map(int, input().split()))
to[a].append(b)
to[b].append(a)
q = []
q.append(0)
while len(q) != 0... | from collections import deque
N, M = list(map(int, input().split()))
to = [[] for i in range(N + 1)]
# dist = [100001 for i in range(N+1)]
flug = [0 for i in range(N + 1)]
to[0].append(1)
# dist[0] = 0
for i in range(M):
a, b = list(map(int, input().split()))
to[a].append(b)
to[b].append(a)
q = deque([0])
... | false | 6.896552 | [
"+from collections import deque",
"+",
"-dist = [100001 for i in range(N + 1)]",
"-flug = [1 for i in range(N + 1)]",
"+# dist = [100001 for i in range(N+1)]",
"+flug = [0 for i in range(N + 1)]",
"-dist[0] = 0",
"-flug[0] = 0",
"+# dist[0] = 0",
"-q = []",
"-q.append(0)",
"+q = deque([0])",
... | false | 0.088036 | 0.088957 | 0.989652 | [
"s966236436",
"s782640272"
] |
u207241407 | p03680 | python | s186094374 | s747948738 | 81 | 55 | 7,852 | 7,068 | Accepted | Accepted | 32.1 | import sys
n = int(eval(input()))
a = [0] + [int(sys.stdin.readline()) for _ in range(n)]
button = 1
for i in range(n):
if button == 2:
print(i)
break
button = a[button]
else:
print((-1)) | import sys
n = list(map(int, sys.stdin))
button = 1
for i in range(n[0]):
if button == 2:
print(i)
break
button = n[button]
else:
print((-1)) | 14 | 13 | 223 | 182 | import sys
n = int(eval(input()))
a = [0] + [int(sys.stdin.readline()) for _ in range(n)]
button = 1
for i in range(n):
if button == 2:
print(i)
break
button = a[button]
else:
print((-1))
| import sys
n = list(map(int, sys.stdin))
button = 1
for i in range(n[0]):
if button == 2:
print(i)
break
button = n[button]
else:
print((-1))
| false | 7.142857 | [
"-n = int(eval(input()))",
"-a = [0] + [int(sys.stdin.readline()) for _ in range(n)]",
"+n = list(map(int, sys.stdin))",
"-for i in range(n):",
"+for i in range(n[0]):",
"- button = a[button]",
"+ button = n[button]"
] | false | 0.076782 | 0.035869 | 2.140645 | [
"s186094374",
"s747948738"
] |
u995004106 | p02679 | python | s175353956 | s088653356 | 971 | 840 | 228,404 | 236,244 | Accepted | Accepted | 13.49 | def modpow(a,n,p):
if n==0:
return 1
x=modpow(a,n//2,p)
x=(x*x)%p
if (n%2)==1:
x=(x*a)%p
return x%p
def modinv(a,p):
return modpow(a,p-2,p)
def ggcd(a,b):
if(b==0):
return a
return ggcd(b,a%b)
import math
import fractions
import collections
import... | def modpow(a,n,p):
if n==0:
return 1
x=modpow(a,n//2,p)
x=(x*x)%p
if (n%2)==1:
x=(x*a)%p
return x%p
def modinv(a,p):
return modpow(a,p-2,p)
def ggcd(a,b):
if(b==0):
return a
return ggcd(b,a%b)
import math
import fractions
import collections
import... | 83 | 75 | 1,964 | 1,498 | def modpow(a, n, p):
if n == 0:
return 1
x = modpow(a, n // 2, p)
x = (x * x) % p
if (n % 2) == 1:
x = (x * a) % p
return x % p
def modinv(a, p):
return modpow(a, p - 2, p)
def ggcd(a, b):
if b == 0:
return a
return ggcd(b, a % b)
import math
import fraction... | def modpow(a, n, p):
if n == 0:
return 1
x = modpow(a, n // 2, p)
x = (x * x) % p
if (n % 2) == 1:
x = (x * a) % p
return x % p
def modinv(a, p):
return modpow(a, p - 2, p)
def ggcd(a, b):
if b == 0:
return a
return ggcd(b, a % b)
import math
import fraction... | false | 9.638554 | [
"- # イメージ的にはa/bを格納していく感じ",
"- # ai/bi==-bj/ajならダメ",
"- g = ggcd(abs(a), abs(b))",
"- if g != 0: # ggcdの定義よりa=b=0なら0になりそう(a=0,b!=0ならb,逆もしかり)",
"+ g = ggcd(a, b)",
"+ if g != 0:",
"- # ここらへんで、a,bをそのgcdで割ることによる正規化が完了しているはず",
"- # b<0の時に強制的にbを正の値に変換しても影響はない(これを噛ませると後々嬉しい)",
"-fi... | false | 0.146095 | 0.038217 | 3.822778 | [
"s175353956",
"s088653356"
] |
u578441226 | p03999 | python | s633732299 | s272872555 | 29 | 26 | 9,096 | 9,096 | Accepted | Accepted | 10.34 | def dfs(i,sum1):
global ss
#print(i,sum1)
if i == len(s):
return sum(list(map(int,sum1.split("+"))))
return dfs(i + 1, sum1 + s[i]) + dfs(i + 1, sum1 + "+" +s[i])
s = eval(input())
ss = 0
print((dfs(1,s[0]))) | def dfs(i,sum1):
if i == len(s):
return sum(list(map(int,sum1.split("+"))))
return dfs(i+1,sum1 + "+" + s[i])+dfs(i+1,sum1 + s[i])
s = eval(input())#一以上9以下
print((dfs(1,s[0]))) | 11 | 6 | 236 | 189 | def dfs(i, sum1):
global ss
# print(i,sum1)
if i == len(s):
return sum(list(map(int, sum1.split("+"))))
return dfs(i + 1, sum1 + s[i]) + dfs(i + 1, sum1 + "+" + s[i])
s = eval(input())
ss = 0
print((dfs(1, s[0])))
| def dfs(i, sum1):
if i == len(s):
return sum(list(map(int, sum1.split("+"))))
return dfs(i + 1, sum1 + "+" + s[i]) + dfs(i + 1, sum1 + s[i])
s = eval(input()) # 一以上9以下
print((dfs(1, s[0])))
| false | 45.454545 | [
"- global ss",
"- # print(i,sum1)",
"- return dfs(i + 1, sum1 + s[i]) + dfs(i + 1, sum1 + \"+\" + s[i])",
"+ return dfs(i + 1, sum1 + \"+\" + s[i]) + dfs(i + 1, sum1 + s[i])",
"-s = eval(input())",
"-ss = 0",
"+s = eval(input()) # 一以上9以下"
] | false | 0.046672 | 0.045086 | 1.035178 | [
"s633732299",
"s272872555"
] |
u171366497 | p03305 | python | s400036633 | s577431987 | 1,625 | 1,435 | 115,616 | 104,212 | Accepted | Accepted | 11.69 | import sys
input=sys.stdin.readline
from collections import defaultdict
from heapq import heappush,heappop
from itertools import accumulate
N,m,s,t=list(map(int,input().split()))
en=defaultdict(set)
sneek=defaultdict(set)
for i in range(m):
u,v,a,b=list(map(int,input().split()))
en[u]|={(a,v)}
en... | import sys
input=sys.stdin.readline
from collections import defaultdict
from heapq import heappush,heappop
from itertools import accumulate
N,m,s,t=map(int,input().split())
en=[set() for i in range(N+1)]
sneek=[set() for i in range(N+1)]
for i in range(m):
u,v,a,b=map(int,input().split())
en[u]|={(a,v... | 35 | 34 | 1,016 | 1,034 | import sys
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappush, heappop
from itertools import accumulate
N, m, s, t = list(map(int, input().split()))
en = defaultdict(set)
sneek = defaultdict(set)
for i in range(m):
u, v, a, b = list(map(int, input().split()))
en[u] |= {(... | import sys
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappush, heappop
from itertools import accumulate
N, m, s, t = map(int, input().split())
en = [set() for i in range(N + 1)]
sneek = [set() for i in range(N + 1)]
for i in range(m):
u, v, a, b = map(int, input().split())
... | false | 2.857143 | [
"-N, m, s, t = list(map(int, input().split()))",
"-en = defaultdict(set)",
"-sneek = defaultdict(set)",
"+N, m, s, t = map(int, input().split())",
"+en = [set() for i in range(N + 1)]",
"+sneek = [set() for i in range(N + 1)]",
"- u, v, a, b = list(map(int, input().split()))",
"+ u, v, a, b = ma... | false | 0.033442 | 0.032943 | 1.015132 | [
"s400036633",
"s577431987"
] |
u891635666 | p02918 | python | s457580115 | s322798416 | 78 | 37 | 10,408 | 3,316 | Accepted | Accepted | 52.56 | 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 = lambda n: [ril() for _ in range(n)... | 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 = lambda n: [ril() for _ in range(n)... | 27 | 23 | 596 | 523 | 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 = lambda n: [ril() for _ in range(n)]
rsls = la... | 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 = lambda n: [ril() for _ in range(n)]
rsls = la... | false | 14.814815 | [
"-",
"-",
"-def rle(s):",
"- import itertools",
"-",
"- return list([(x[0], len(list(x[1]))) for x in itertools.groupby(s)])",
"-",
"-",
"-s = rle(s)",
"-m = len(s)",
"+m = 1",
"+for c0, c1 in zip(s, s[1:]):",
"+ if c0 != c1:",
"+ m += 1"
] | false | 0.064356 | 0.084386 | 0.762644 | [
"s457580115",
"s322798416"
] |
u102461423 | p02715 | python | s749908955 | s126983750 | 295 | 28 | 29,640 | 9,408 | Accepted | Accepted | 90.51 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
MOD = 10**9 + 7
N, K = list(map(int, read().split()))
is_prime = np.zeros(K + 10, np.bool)
is_prime[2] = 1
is_prime[3::2] = 1
for p in range(3, K + 10, 2):
if p * p >... | N, K = list(map(int, input().split()))
MOD = 10**9 + 7
M = int(K ** .5)
f_l = [0] * (M+1) # f(k)
f_h = [0] * (M+1) # f(K//d)
def f(k):
return f_l[k] if k <= M else f_h[K//k]
def compute_f(k):
x = pow(k, N, MOD)
sq = int(k ** .5)
for d in range(2, k+1):
n = k // d
if n <= sq:
b... | 30 | 45 | 662 | 830 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
MOD = 10**9 + 7
N, K = list(map(int, read().split()))
is_prime = np.zeros(K + 10, np.bool)
is_prime[2] = 1
is_prime[3::2] = 1
for p in range(3, K + 10, 2):
if p * p > K:
b... | N, K = list(map(int, input().split()))
MOD = 10**9 + 7
M = int(K**0.5)
f_l = [0] * (M + 1) # f(k)
f_h = [0] * (M + 1) # f(K//d)
def f(k):
return f_l[k] if k <= M else f_h[K // k]
def compute_f(k):
x = pow(k, N, MOD)
sq = int(k**0.5)
for d in range(2, k + 1):
n = k // d
if n <= sq:
... | false | 33.333333 | [
"-import sys",
"+N, K = list(map(int, input().split()))",
"+MOD = 10**9 + 7",
"+M = int(K**0.5)",
"+f_l = [0] * (M + 1) # f(k)",
"+f_h = [0] * (M + 1) # f(K//d)",
"-read = sys.stdin.buffer.read",
"-readline = sys.stdin.buffer.readline",
"-readlines = sys.stdin.buffer.readlines",
"-import numpy a... | false | 0.538511 | 0.048238 | 11.163626 | [
"s749908955",
"s126983750"
] |
u072717685 | p02570 | python | s708893182 | s249630596 | 111 | 70 | 64,676 | 61,808 | Accepted | Accepted | 36.94 | import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import Counter
def main():
d, t, s = list(map(int, input().split()))
dis = s * t
if d > dis:
print('No')
else:
print('Yes')
if __name__ == '__main__':
main() | import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
d, t, s = list(map(int, input().split()))
if t * s >= d:
print('Yes')
else:
print('No')
if __name__ == '__main__':
main()
| 14 | 13 | 283 | 239 | import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import Counter
def main():
d, t, s = list(map(int, input().split()))
dis = s * t
if d > dis:
print("No")
else:
print("Yes")
if __name__ == "__main__":
main()
| import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
d, t, s = list(map(int, input().split()))
if t * s >= d:
print("Yes")
else:
print("No")
if __name__ == "__main__":
main()
| false | 7.142857 | [
"-from collections import Counter",
"- dis = s * t",
"- if d > dis:",
"+ if t * s >= d:",
"+ print(\"Yes\")",
"+ else:",
"- else:",
"- print(\"Yes\")"
] | false | 0.038621 | 0.035746 | 1.080433 | [
"s708893182",
"s249630596"
] |
u550061714 | p03163 | python | s691791224 | s040997019 | 584 | 187 | 120,172 | 14,800 | Accepted | Accepted | 67.98 | N, W = list(map(int, input().split()))
goods = []
for _ in range(N):
goods.append(tuple(map(int, input().split())))
table = [[0] * (W + 1) for _ in range(N + 1)]
for n in range(N):
for w in range(W + 1):
addn = table[n][w - goods[n][0]] + goods[n][1] if w - goods[n][0] >= 0 else 0
tabl... | import numpy as np
N, W = list(map(int, input().split()))
goods = [tuple(map(int, input().split())) for _ in range(N)]
dp = np.zeros(W + 1, dtype=np.int64)
for n in range(N):
tmp = np.zeros_like(dp, dtype=np.int64)
tmp[goods[n][0]:] = dp[:W + 1 - goods[n][0]] + goods[n][1]
dp = np.maximum(dp, tmp... | 11 | 11 | 371 | 330 | N, W = list(map(int, input().split()))
goods = []
for _ in range(N):
goods.append(tuple(map(int, input().split())))
table = [[0] * (W + 1) for _ in range(N + 1)]
for n in range(N):
for w in range(W + 1):
addn = table[n][w - goods[n][0]] + goods[n][1] if w - goods[n][0] >= 0 else 0
table[n + 1][w... | import numpy as np
N, W = list(map(int, input().split()))
goods = [tuple(map(int, input().split())) for _ in range(N)]
dp = np.zeros(W + 1, dtype=np.int64)
for n in range(N):
tmp = np.zeros_like(dp, dtype=np.int64)
tmp[goods[n][0] :] = dp[: W + 1 - goods[n][0]] + goods[n][1]
dp = np.maximum(dp, tmp)
print(... | false | 0 | [
"+import numpy as np",
"+",
"-goods = []",
"-for _ in range(N):",
"- goods.append(tuple(map(int, input().split())))",
"-table = [[0] * (W + 1) for _ in range(N + 1)]",
"+goods = [tuple(map(int, input().split())) for _ in range(N)]",
"+dp = np.zeros(W + 1, dtype=np.int64)",
"- for w in range(W ... | false | 0.075263 | 0.410375 | 0.183402 | [
"s691791224",
"s040997019"
] |
u757030836 | p03805 | python | s011598278 | s532403582 | 43 | 33 | 3,060 | 3,064 | Accepted | Accepted | 23.26 | import itertools
N,M=list(map(int,input().split()))
edges={tuple(sorted(map(int,input().split()))) for i in range(M)}
ans=0
for i in itertools.permutations(list(range(2,N+1)),N-1):
l=[1]+list(i)
ans+=sum(1 for edge in zip(l,l[1:]) if tuple(sorted(edge)) in edges)==N-1
print(ans) | import itertools
N,M=list(map(int,input().split()))
edges=set()
for _ in range(M):
a,b =list(map(int,input().split()))
edges.add((a,b))
edges.add((b,a))
answer=0
for p in itertools.permutations(list(range(1,N+1))):
if p[0] !=1:
continue
bl=True
for i in range(N-1):
if(p[i],p... | 8 | 25 | 282 | 405 | import itertools
N, M = list(map(int, input().split()))
edges = {tuple(sorted(map(int, input().split()))) for i in range(M)}
ans = 0
for i in itertools.permutations(list(range(2, N + 1)), N - 1):
l = [1] + list(i)
ans += sum(1 for edge in zip(l, l[1:]) if tuple(sorted(edge)) in edges) == N - 1
print(ans)
| import itertools
N, M = list(map(int, input().split()))
edges = set()
for _ in range(M):
a, b = list(map(int, input().split()))
edges.add((a, b))
edges.add((b, a))
answer = 0
for p in itertools.permutations(list(range(1, N + 1))):
if p[0] != 1:
continue
bl = True
for i in range(N - 1):
... | false | 68 | [
"-edges = {tuple(sorted(map(int, input().split()))) for i in range(M)}",
"-ans = 0",
"-for i in itertools.permutations(list(range(2, N + 1)), N - 1):",
"- l = [1] + list(i)",
"- ans += sum(1 for edge in zip(l, l[1:]) if tuple(sorted(edge)) in edges) == N - 1",
"-print(ans)",
"+edges = set()",
"+... | false | 0.081532 | 0.057677 | 1.413603 | [
"s011598278",
"s532403582"
] |
u869790980 | p03425 | python | s230795202 | s064069802 | 376 | 104 | 98,876 | 82,792 | Accepted | Accepted | 72.34 | import collections
cc = collections.Counter()
for _ in range(int(input())):
cc[input()[0]] +=1
def dfs(i, total ,cumul, cc, k, s):
if i == len(s) or k == 0:
if k == 0: total[0] += cumul
return
if k:
dfs(i+1, total, cumul * cc[s[i]], cc,k - 1, s)
dfs(i+1, total, cumul, cc, k, s)
total = [0]... | import collections
cc = collections.Counter([input()[0] for _ in range(int(input()))])
def dfs(i, total ,cumul, cc, k, s):
if i == len(s) or k == 0:
if k == 0: total[0] += cumul
return
dfs(i+1, total, cumul * cc[s[i]], cc,k - 1, s)
dfs(i+1, total, cumul, cc, k, s)
total = [0]
dfs(0, total, 1 ,... | 17 | 15 | 379 | 360 | import collections
cc = collections.Counter()
for _ in range(int(input())):
cc[input()[0]] += 1
def dfs(i, total, cumul, cc, k, s):
if i == len(s) or k == 0:
if k == 0:
total[0] += cumul
return
if k:
dfs(i + 1, total, cumul * cc[s[i]], cc, k - 1, s)
dfs(i + 1, tota... | import collections
cc = collections.Counter([input()[0] for _ in range(int(input()))])
def dfs(i, total, cumul, cc, k, s):
if i == len(s) or k == 0:
if k == 0:
total[0] += cumul
return
dfs(i + 1, total, cumul * cc[s[i]], cc, k - 1, s)
dfs(i + 1, total, cumul, cc, k, s)
total... | false | 11.764706 | [
"-cc = collections.Counter()",
"-for _ in range(int(input())):",
"- cc[input()[0]] += 1",
"+cc = collections.Counter([input()[0] for _ in range(int(input()))])",
"- if k:",
"- dfs(i + 1, total, cumul * cc[s[i]], cc, k - 1, s)",
"+ dfs(i + 1, total, cumul * cc[s[i]], cc, k - 1, s)"
] | false | 0.007648 | 0.039494 | 0.193655 | [
"s230795202",
"s064069802"
] |
u089142196 | p02984 | python | s406573871 | s598776718 | 161 | 132 | 14,624 | 14,028 | Accepted | Accepted | 18.01 | N=int(eval(input()))
A=list(map(int, input().split()))
M=[0]*N
maxi=sum(A)
M[0]=maxi//4
tmp=10**9
while M[0]/2 != tmp:
for i in range(1,N):
M[i]= 2*(A[i-1]-M[i-1]//2)
tmp = A[-1] - M[N-1]//2
#print(M,tmp)
if M[0] != tmp*2:
M[0] = (M[0]+tmp*2)//2
if M[0]%2!=0:
M[0] +=1
else:
... | N=int(eval(input()))
A=list(map(int, input().split()))
M=[0]*N
maxi=sum(A)
M[0]= maxi-2*sum(A[1::2])
for i in range(1,N):
M[i]= 2*(A[i-1]-M[i-1]//2)
print((*M)) | 19 | 9 | 326 | 163 | N = int(eval(input()))
A = list(map(int, input().split()))
M = [0] * N
maxi = sum(A)
M[0] = maxi // 4
tmp = 10**9
while M[0] / 2 != tmp:
for i in range(1, N):
M[i] = 2 * (A[i - 1] - M[i - 1] // 2)
tmp = A[-1] - M[N - 1] // 2
# print(M,tmp)
if M[0] != tmp * 2:
M[0] = (M[0] + tmp * 2) // 2... | N = int(eval(input()))
A = list(map(int, input().split()))
M = [0] * N
maxi = sum(A)
M[0] = maxi - 2 * sum(A[1::2])
for i in range(1, N):
M[i] = 2 * (A[i - 1] - M[i - 1] // 2)
print((*M))
| false | 52.631579 | [
"-M[0] = maxi // 4",
"-tmp = 10**9",
"-while M[0] / 2 != tmp:",
"- for i in range(1, N):",
"- M[i] = 2 * (A[i - 1] - M[i - 1] // 2)",
"- tmp = A[-1] - M[N - 1] // 2",
"- # print(M,tmp)",
"- if M[0] != tmp * 2:",
"- M[0] = (M[0] + tmp * 2) // 2",
"- if M[0] % 2 != 0... | false | 0.047182 | 0.110774 | 0.425926 | [
"s406573871",
"s598776718"
] |
u389910364 | p03344 | python | s921645248 | s204865829 | 1,274 | 1,177 | 69,908 | 127,928 | Accepted | Accepted | 7.61 | import os
import sys
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353
class UnionFind:
def __init__(self, size=None, nodes=None):
"""
size か nodes どっちか指定。
... | import os
import sys
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353
class UnionFind:
def __init__(self, size=None, nodes=None):
"""
size か nodes どっちか指定。
... | 130 | 125 | 3,260 | 3,118 | import os
import sys
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(10**9)
INF = float("inf")
IINF = 10**18
MOD = 10**9 + 7
# MOD = 998244353
class UnionFind:
def __init__(self, size=None, nodes=None):
"""
size か nodes どっちか指定。
nodes は set、size は list を使う。
... | import os
import sys
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(10**9)
INF = float("inf")
IINF = 10**18
MOD = 10**9 + 7
# MOD = 998244353
class UnionFind:
def __init__(self, size=None, nodes=None):
"""
size か nodes どっちか指定。
nodes は set、size は list を使う。
... | false | 3.846154 | [
"-# 解説",
"-# C[v] = A[v] - B[v]",
"-# C の小さい順にグラフを構築して、部分グラフごとに答えを持つ",
"-reqs = [max(0, a - b) for a, b in zip(A, B)]",
"+reqs = [max(a, b) for a, b in zip(A, B)]",
"-idx = argsort(reqs)",
"+idx = argsort([a - b for a, b in zip(A, B)])",
"- # v: 今までに見た中で C が最大の頂点",
"- # v を最初にする場合",
"- re... | false | 0.045204 | 0.035937 | 1.257889 | [
"s921645248",
"s204865829"
] |
u346812984 | p03229 | python | s863736929 | s960418183 | 243 | 136 | 7,512 | 7,524 | Accepted | Accepted | 44.03 | N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
A.sort()
if N % 2 == 0:
ans = 0
for i in range(N // 2):
ans -= 2 * A[i]
for i in range(N // 2, N):
ans += 2 * A[i]
ans += A[N // 2 - 1]
ans -= A[N // 2]
print(ans)
else:
ans1 = 0
for i in ra... | import sys
sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7
def input():
return sys.stdin.readline().strip()
def main():
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
A.sort()
if N % 2 == 0:
ans = A[N // 2] - A[N // 2 - 1]
... | 30 | 42 | 670 | 899 | N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
A.sort()
if N % 2 == 0:
ans = 0
for i in range(N // 2):
ans -= 2 * A[i]
for i in range(N // 2, N):
ans += 2 * A[i]
ans += A[N // 2 - 1]
ans -= A[N // 2]
print(ans)
else:
ans1 = 0
for i in range(N // 2):
... | import sys
sys.setrecursionlimit(10**6)
INF = float("inf")
MOD = 10**9 + 7
def input():
return sys.stdin.readline().strip()
def main():
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
A.sort()
if N % 2 == 0:
ans = A[N // 2] - A[N // 2 - 1]
for i in range(N // 2... | false | 28.571429 | [
"-N = int(eval(input()))",
"-A = [int(eval(input())) for _ in range(N)]",
"-A.sort()",
"-if N % 2 == 0:",
"- ans = 0",
"- for i in range(N // 2):",
"- ans -= 2 * A[i]",
"- for i in range(N // 2, N):",
"- ans += 2 * A[i]",
"- ans += A[N // 2 - 1]",
"- ans -= A[N // 2]... | false | 0.037448 | 0.081704 | 0.458338 | [
"s863736929",
"s960418183"
] |
u611853667 | p00109 | python | s069393053 | s712607780 | 20 | 10 | 4,384 | 4,368 | Accepted | Accepted | 50 | def divide(x, y):
s = 1
if(x < 0):s *= -1
if(y < 0):s *= -1
return abs(x) / abs(y) * s
operator = {"+":(lambda x,y: x+y),
"-":(lambda x,y: x-y),
"*":(lambda x,y: x*y),
"/":divide
}
def ind(src, x):
if x not in src:return 1<<30
... | def divide(x, y):
s = 1
if(x < 0):s *= -1
if(y < 0):s *= -1
return abs(x) / abs(y) * s
operator = {"+":(lambda x,y: x+y),
"-":(lambda x,y: x-y),
"*":(lambda x,y: x*y),
"/":divide
}
def ind(src, x):
if x not in src:return 1<<30
... | 64 | 59 | 1,618 | 1,408 | def divide(x, y):
s = 1
if x < 0:
s *= -1
if y < 0:
s *= -1
return abs(x) / abs(y) * s
operator = {
"+": (lambda x, y: x + y),
"-": (lambda x, y: x - y),
"*": (lambda x, y: x * y),
"/": divide,
}
def ind(src, x):
if x not in src:
return 1 << 30
return ... | def divide(x, y):
s = 1
if x < 0:
s *= -1
if y < 0:
s *= -1
return abs(x) / abs(y) * s
operator = {
"+": (lambda x, y: x + y),
"-": (lambda x, y: x - y),
"*": (lambda x, y: x * y),
"/": divide,
}
def ind(src, x):
if x not in src:
return 1 << 30
return ... | false | 7.8125 | [
"- if \"*\" in src or \"/\" in src:",
"- pos = min(ind(src, \"*\"), ind(src, \"/\"))",
"- op = src[pos]",
"- l, r = src[pos - 1], src[pos + 1]",
"- mid = operator[op](l, r)",
"- return evaluate(src[: pos - 1] + [mid] + src[pos + 2 :])",
"- else:",
"+ pos = m... | false | 0.074621 | 0.047253 | 1.579162 | [
"s069393053",
"s712607780"
] |
u268554510 | p02793 | python | s136622512 | s779543342 | 967 | 313 | 5,616 | 53,228 | Accepted | Accepted | 67.63 | N = int(eval(input()))
A = list(map(int,input().split()))
from fractions import gcd
mod = 10**9+7
g = A[0]
for a in A[1::]:
g = g*a//gcd(g,a)
ans = 0
b = g%mod
for a in A:
ans += b*pow(a,mod-2,mod)
ans %= mod
print((ans%mod)) | N = int(eval(input()))
A = list(map(int,input().split()))
mod = 10**9+7
l = [0]*(max(A)+1)
l[1]=1
for a in A:
if a==1:
continue
x=0
while a%2==0:
a//=2
x+=1
l[2]=max(l[2],x)
f = 3
while f**2<=a:
x = 0
while a%f==0:
a//=f
x+=1
l[f]=max(l[f],x)
... | 15 | 38 | 241 | 518 | N = int(eval(input()))
A = list(map(int, input().split()))
from fractions import gcd
mod = 10**9 + 7
g = A[0]
for a in A[1::]:
g = g * a // gcd(g, a)
ans = 0
b = g % mod
for a in A:
ans += b * pow(a, mod - 2, mod)
ans %= mod
print((ans % mod))
| N = int(eval(input()))
A = list(map(int, input().split()))
mod = 10**9 + 7
l = [0] * (max(A) + 1)
l[1] = 1
for a in A:
if a == 1:
continue
x = 0
while a % 2 == 0:
a //= 2
x += 1
l[2] = max(l[2], x)
f = 3
while f**2 <= a:
x = 0
while a % f == 0:
... | false | 60.526316 | [
"-from fractions import gcd",
"-",
"-g = A[0]",
"-for a in A[1::]:",
"- g = g * a // gcd(g, a)",
"+l = [0] * (max(A) + 1)",
"+l[1] = 1",
"+for a in A:",
"+ if a == 1:",
"+ continue",
"+ x = 0",
"+ while a % 2 == 0:",
"+ a //= 2",
"+ x += 1",
"+ l[2] = ... | false | 0.046649 | 0.357424 | 0.130514 | [
"s136622512",
"s779543342"
] |
u936985471 | p02948 | python | s110358843 | s816149375 | 317 | 230 | 27,832 | 31,960 | Accepted | Accepted | 27.44 | import sys
readline = sys.stdin.readline
# 逆順に見ていく
# A_iの値が小さい順にheapqに追加していく
N,M = list(map(int,readline().split()))
from collections import defaultdict
tasks = defaultdict(list)
for i in range(N):
a,b = list(map(int,readline().split()))
tasks[a].append(b)
import heapq
q = []
heapq.heapify(q)
a... | import sys
readline = sys.stdin.readline
N,M = list(map(int,readline().split()))
from collections import defaultdict
tasks = defaultdict(list)
for i in range(N):
a,b = list(map(int,readline().split()))
tasks[a].append(b)
import heapq as hq
q = []
ans = 0
for i in range(1, M + 1):
newtask = tasks... | 25 | 21 | 460 | 405 | import sys
readline = sys.stdin.readline
# 逆順に見ていく
# A_iの値が小さい順にheapqに追加していく
N, M = list(map(int, readline().split()))
from collections import defaultdict
tasks = defaultdict(list)
for i in range(N):
a, b = list(map(int, readline().split()))
tasks[a].append(b)
import heapq
q = []
heapq.heapify(q)
ans = 0
for... | import sys
readline = sys.stdin.readline
N, M = list(map(int, readline().split()))
from collections import defaultdict
tasks = defaultdict(list)
for i in range(N):
a, b = list(map(int, readline().split()))
tasks[a].append(b)
import heapq as hq
q = []
ans = 0
for i in range(1, M + 1):
newtask = tasks[i]
... | false | 16 | [
"-# 逆順に見ていく",
"-# A_iの値が小さい順にheapqに追加していく",
"-import heapq",
"+import heapq as hq",
"-heapq.heapify(q)",
"- for task in tasks[i]:",
"- heapq.heappush(q, -task)",
"+ newtask = tasks[i]",
"+ for t in newtask:",
"+ hq.heappush(q, -t)",
"- t = heapq.heappop(q)",
"- ... | false | 0.037978 | 0.036635 | 1.036665 | [
"s110358843",
"s816149375"
] |
u814986259 | p03103 | python | s428218658 | s728001799 | 454 | 412 | 29,020 | 16,984 | Accepted | Accepted | 9.25 | N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort(key=lambda x: x[0])
ans = 0
for i in range(N):
if M >= AB[i][1]:
ans += AB[i][0] * AB[i][1]
M -= AB[i][1]
else:
ans += AB[i][0] * M
M = 0
if M == 0:
b... | N, M = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for i in range(N)]
AB.sort()
ans = 0
for a, b in AB:
if M > b:
M -= b
ans += a*b
else:
ans += a*M
break
print(ans)
| 15 | 14 | 331 | 242 | N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort(key=lambda x: x[0])
ans = 0
for i in range(N):
if M >= AB[i][1]:
ans += AB[i][0] * AB[i][1]
M -= AB[i][1]
else:
ans += AB[i][0] * M
M = 0
if M == 0:
break
print(ans... | N, M = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for i in range(N)]
AB.sort()
ans = 0
for a, b in AB:
if M > b:
M -= b
ans += a * b
else:
ans += a * M
break
print(ans)
| false | 6.666667 | [
"-AB = [list(map(int, input().split())) for i in range(N)]",
"-AB.sort(key=lambda x: x[0])",
"+AB = [tuple(map(int, input().split())) for i in range(N)]",
"+AB.sort()",
"-for i in range(N):",
"- if M >= AB[i][1]:",
"- ans += AB[i][0] * AB[i][1]",
"- M -= AB[i][1]",
"+for a, b in AB:... | false | 0.105173 | 0.042486 | 2.475457 | [
"s428218658",
"s728001799"
] |
u735891571 | p02762 | python | s878352038 | s454864914 | 1,503 | 1,390 | 64,532 | 64,560 | Accepted | Accepted | 7.52 |
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y)... |
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y)... | 60 | 59 | 1,345 | 1,329 | class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = se... | class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = se... | false | 1.666667 | [
"- uf.find(A)"
] | false | 0.035969 | 0.103656 | 0.347 | [
"s878352038",
"s454864914"
] |
u416011173 | p02578 | python | s343479984 | s333489646 | 176 | 131 | 32,224 | 31,008 | Accepted | Accepted | 25.57 | # -*- coding: utf-8 -*-
# 標準入力を取得
N = int(eval(input()))
A = list(map(int, input().split()))
# 求解処理
ans = 0
highest = 0
for n in range(N):
highest = max(highest, A[n])
ans += max(highest - A[n], 0)
# 結果出力
print(ans)
| # -*- coding: utf-8 -*-
def get_input() -> tuple:
"""
標準入力を取得する.
Returns:\n
tuple: 標準入力
"""
N = int(eval(input()))
A = list(map(int, input().split()))
return N, A
def main(A: list) -> None:
"""
メイン処理.
Args:\n
A (list): 身長(1 <= A_i <= 10**... | 14 | 39 | 233 | 591 | # -*- coding: utf-8 -*-
# 標準入力を取得
N = int(eval(input()))
A = list(map(int, input().split()))
# 求解処理
ans = 0
highest = 0
for n in range(N):
highest = max(highest, A[n])
ans += max(highest - A[n], 0)
# 結果出力
print(ans)
| # -*- coding: utf-8 -*-
def get_input() -> tuple:
"""
標準入力を取得する.
Returns:\n
tuple: 標準入力
"""
N = int(eval(input()))
A = list(map(int, input().split()))
return N, A
def main(A: list) -> None:
"""
メイン処理.
Args:\n
A (list): 身長(1 <= A_i <= 10**9)
"""
# 求解処理
... | false | 64.102564 | [
"-# 標準入力を取得",
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-# 求解処理",
"-ans = 0",
"-highest = 0",
"-for n in range(N):",
"- highest = max(highest, A[n])",
"- ans += max(highest - A[n], 0)",
"-# 結果出力",
"-print(ans)",
"+def get_input() -> tuple:",
"+ \"\"\"",
"... | false | 0.076719 | 0.048593 | 1.578808 | [
"s343479984",
"s333489646"
] |
u638282348 | p03607 | python | s034001540 | s116267816 | 232 | 75 | 15,032 | 18,400 | Accepted | Accepted | 67.67 | N = int(eval(input()))
d = dict()
for _ in range(N):
a = int(eval(input()))
d[a] = d.get(a, 0) ^ 1
print((sum(d.values()))) | N, *A = list(map(int, open(0).read().split()))
d = dict()
for a in A:
d[a] = d.get(a, 0) ^ 1
print((sum(d.values()))) | 6 | 5 | 122 | 117 | N = int(eval(input()))
d = dict()
for _ in range(N):
a = int(eval(input()))
d[a] = d.get(a, 0) ^ 1
print((sum(d.values())))
| N, *A = list(map(int, open(0).read().split()))
d = dict()
for a in A:
d[a] = d.get(a, 0) ^ 1
print((sum(d.values())))
| false | 16.666667 | [
"-N = int(eval(input()))",
"+N, *A = list(map(int, open(0).read().split()))",
"-for _ in range(N):",
"- a = int(eval(input()))",
"+for a in A:"
] | false | 0.063092 | 0.035631 | 1.770682 | [
"s034001540",
"s116267816"
] |
u227020436 | p02702 | python | s792171514 | s021788802 | 643 | 200 | 71,952 | 16,500 | Accepted | Accepted | 68.9 | # D - Multiple of 2019
s = eval(input())
# pow[k] = 10 ** k % 2019
pow = [1]
while len(pow) <= 1 or pow[-1] > 1:
pow.append(pow[-1] * 10 % 2019)
n = len(pow) - 1 # 10 ** n == 1 mod 2019
# memo[i % n][m] = (int(s[:i+1]) % 2019 == mであるiの個数)
memo = [[0] * 2019 for i in range(n)]
memo[n - 1][0] = 1 # m... | # D - Multiple of 2019
from collections import Counter
s = eval(input())
count = 0
counter = Counter([0])
suffix = [0] * (len(s) + 1)
pow = 1
for i in range(len(s) - 1, -1, -1):
suffix[i] = (int(s[i]) * pow + suffix[i + 1]) % 2019
pow = pow * 10 % 2019
count += counter[suffix[i]]
coun... | 24 | 18 | 676 | 350 | # D - Multiple of 2019
s = eval(input())
# pow[k] = 10 ** k % 2019
pow = [1]
while len(pow) <= 1 or pow[-1] > 1:
pow.append(pow[-1] * 10 % 2019)
n = len(pow) - 1 # 10 ** n == 1 mod 2019
# memo[i % n][m] = (int(s[:i+1]) % 2019 == mであるiの個数)
memo = [[0] * 2019 for i in range(n)]
memo[n - 1][0] = 1 # memo[-1][0] = 1
... | # D - Multiple of 2019
from collections import Counter
s = eval(input())
count = 0
counter = Counter([0])
suffix = [0] * (len(s) + 1)
pow = 1
for i in range(len(s) - 1, -1, -1):
suffix[i] = (int(s[i]) * pow + suffix[i + 1]) % 2019
pow = pow * 10 % 2019
count += counter[suffix[i]]
counter[suffix[i]] += ... | false | 25 | [
"+from collections import Counter",
"+",
"-# pow[k] = 10 ** k % 2019",
"-pow = [1]",
"-while len(pow) <= 1 or pow[-1] > 1:",
"- pow.append(pow[-1] * 10 % 2019)",
"-n = len(pow) - 1 # 10 ** n == 1 mod 2019",
"-# memo[i % n][m] = (int(s[:i+1]) % 2019 == mであるiの個数)",
"-memo = [[0] * 2019 for i in ra... | false | 0.156318 | 0.038495 | 4.060773 | [
"s792171514",
"s021788802"
] |
u677121387 | p02947 | python | s915211427 | s126379856 | 380 | 317 | 17,852 | 24,976 | Accepted | Accepted | 16.58 | n = int(eval(input()))
d = {}
ans = 0
for i in range(n):
s = "".join(sorted(eval(input())))
if s not in d:
d[s] = 1
else:
ans += d[s]
d[s] += 1
print(ans) | n = int(eval(input()))
S = [eval(input()) for _ in range(n)]
d = {}
ans = 0
for s in S:
x = "".join(sorted(s))
if x in d: ans += d[x]
d[x] = d.get(x,0) + 1
print(ans) | 13 | 9 | 196 | 174 | n = int(eval(input()))
d = {}
ans = 0
for i in range(n):
s = "".join(sorted(eval(input())))
if s not in d:
d[s] = 1
else:
ans += d[s]
d[s] += 1
print(ans)
| n = int(eval(input()))
S = [eval(input()) for _ in range(n)]
d = {}
ans = 0
for s in S:
x = "".join(sorted(s))
if x in d:
ans += d[x]
d[x] = d.get(x, 0) + 1
print(ans)
| false | 30.769231 | [
"+S = [eval(input()) for _ in range(n)]",
"-for i in range(n):",
"- s = \"\".join(sorted(eval(input())))",
"- if s not in d:",
"- d[s] = 1",
"- else:",
"- ans += d[s]",
"- d[s] += 1",
"+for s in S:",
"+ x = \"\".join(sorted(s))",
"+ if x in d:",
"+ an... | false | 0.048032 | 0.04874 | 0.98546 | [
"s915211427",
"s126379856"
] |
u832039789 | p03449 | python | s399106178 | s504540640 | 22 | 18 | 3,060 | 3,060 | Accepted | Accepted | 18.18 | res = 0
n = int(eval(input()))
a = [list(map(int,input().split())) for _ in range(2)]
# したにいくます
for i in range(n):
t = 0
tmp = 0
for j in range(n):
tmp += a[t][j]
if i==j:
t += 1
tmp += a[t][j]
res = max(res,tmp)
print(res)
| n = int(eval(input()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
res = 0
for i in range(n):
tmp = 0
for j in range(i + 1):
tmp += a[j]
for j in range(i, n):
tmp += b[j]
res = max(res, tmp)
print(res)
| 14 | 13 | 287 | 267 | res = 0
n = int(eval(input()))
a = [list(map(int, input().split())) for _ in range(2)]
# したにいくます
for i in range(n):
t = 0
tmp = 0
for j in range(n):
tmp += a[t][j]
if i == j:
t += 1
tmp += a[t][j]
res = max(res, tmp)
print(res)
| n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = 0
for i in range(n):
tmp = 0
for j in range(i + 1):
tmp += a[j]
for j in range(i, n):
tmp += b[j]
res = max(res, tmp)
print(res)
| false | 7.142857 | [
"+n = int(eval(input()))",
"+a = list(map(int, input().split()))",
"+b = list(map(int, input().split()))",
"-n = int(eval(input()))",
"-a = [list(map(int, input().split())) for _ in range(2)]",
"-# したにいくます",
"- t = 0",
"- for j in range(n):",
"- tmp += a[t][j]",
"- if i == j:",... | false | 0.036587 | 0.035615 | 1.027296 | [
"s399106178",
"s504540640"
] |
u761320129 | p03600 | python | s254276972 | s850101837 | 736 | 454 | 44,124 | 74,908 | Accepted | Accepted | 38.32 | N = int(eval(input()))
src = [list(map(int,input().split())) for i in range(N)]
ans = 0
for k in range(N):
for i in range(N):
for j in range(N):
if src[i][j] > src[i][k] + src[k][j]:
print((-1))
exit()
for i in range(N-1):
for j in range(i+1,N):
... | N = int(eval(input()))
A = [list(map(int,input().split())) for i in range(N)]
for k in range(N):
for i in range(N):
for j in range(N):
if A[i][j] > A[i][k] + A[k][j]:
print((-1))
exit()
ans = 0
for i in range(N-1):
for j in range(i+1,N):
... | 20 | 20 | 510 | 494 | N = int(eval(input()))
src = [list(map(int, input().split())) for i in range(N)]
ans = 0
for k in range(N):
for i in range(N):
for j in range(N):
if src[i][j] > src[i][k] + src[k][j]:
print((-1))
exit()
for i in range(N - 1):
for j in range(i + 1, N):
... | N = int(eval(input()))
A = [list(map(int, input().split())) for i in range(N)]
for k in range(N):
for i in range(N):
for j in range(N):
if A[i][j] > A[i][k] + A[k][j]:
print((-1))
exit()
ans = 0
for i in range(N - 1):
for j in range(i + 1, N):
for k in... | false | 0 | [
"-src = [list(map(int, input().split())) for i in range(N)]",
"-ans = 0",
"+A = [list(map(int, input().split())) for i in range(N)]",
"- if src[i][j] > src[i][k] + src[k][j]:",
"+ if A[i][j] > A[i][k] + A[k][j]:",
"+ans = 0",
"- if src[i][j] == src[i][k] + src[k][j]:",
... | false | 0.037616 | 0.037758 | 0.996242 | [
"s254276972",
"s850101837"
] |
u631277801 | p03290 | python | s702976132 | s636409177 | 27 | 22 | 3,064 | 3,064 | Accepted | Accepted | 18.52 |
D,G = list(map(int, input().split()))
#prob_num = [3,5]
#comp = [500,800]
prob_num = []
comp = []
for i in range(D):
p,c = list(map(int, input().split()))
prob_num.append(p)
comp.append(c)
comp_point = []
for i in range(D):
comp_point.append((100*(i+1)*prob_num[i]+comp[i]))
a... | D,G = list(map(int, input().split()))
prob_num = []
bonus = []
comp_pt = []
for i in range(D):
p,b = list(map(int, input().split()))
prob_num.append(p)
bonus.append(b)
comp_pt.append(100*(i+1)*p+b)
def dfs(hascomp:str, target:int, prob:int, depth:int) -> int:
if target <= 0:
#pr... | 64 | 40 | 1,374 | 1,201 | D, G = list(map(int, input().split()))
# prob_num = [3,5]
# comp = [500,800]
prob_num = []
comp = []
for i in range(D):
p, c = list(map(int, input().split()))
prob_num.append(p)
comp.append(c)
comp_point = []
for i in range(D):
comp_point.append((100 * (i + 1) * prob_num[i] + comp[i]))
ans = 1000000
for... | D, G = list(map(int, input().split()))
prob_num = []
bonus = []
comp_pt = []
for i in range(D):
p, b = list(map(int, input().split()))
prob_num.append(p)
bonus.append(b)
comp_pt.append(100 * (i + 1) * p + b)
def dfs(hascomp: str, target: int, prob: int, depth: int) -> int:
if target <= 0:
... | false | 37.5 | [
"-# prob_num = [3,5]",
"-# comp = [500,800]",
"-comp = []",
"+bonus = []",
"+comp_pt = []",
"- p, c = list(map(int, input().split()))",
"+ p, b = list(map(int, input().split()))",
"- comp.append(c)",
"-comp_point = []",
"-for i in range(D):",
"- comp_point.append((100 * (i + 1) * pro... | false | 0.03495 | 0.042326 | 0.825734 | [
"s702976132",
"s636409177"
] |
u112364985 | p02608 | python | s298096203 | s368866572 | 1,219 | 520 | 9,428 | 9,780 | Accepted | Accepted | 57.34 | import itertools
n=int(eval(input()))
mylist=[0]*n
a=1
while(6*(a**2)<n):
a+=1
l=list(range(1,3*a-1))
for c in itertools.product(l,repeat=3):
sum_num=sum(c)**2-(c[0]*c[1]+c[1]*c[2]+c[2]*c[0])
if sum_num<=n:
mylist[sum_num-1]+=1
for i in mylist:
print(i) | n=int(eval(input()))
l=[0]*(10**5)
for x in range(1,101):
for y in range(1,101):
for z in range(1,101):
l[(x*x+y*y+z*z+x*y+y*z+z*x)-1]+=1
for i in range(n):
print((l[i])) | 13 | 8 | 283 | 197 | import itertools
n = int(eval(input()))
mylist = [0] * n
a = 1
while 6 * (a**2) < n:
a += 1
l = list(range(1, 3 * a - 1))
for c in itertools.product(l, repeat=3):
sum_num = sum(c) ** 2 - (c[0] * c[1] + c[1] * c[2] + c[2] * c[0])
if sum_num <= n:
mylist[sum_num - 1] += 1
for i in mylist:
print(i... | n = int(eval(input()))
l = [0] * (10**5)
for x in range(1, 101):
for y in range(1, 101):
for z in range(1, 101):
l[(x * x + y * y + z * z + x * y + y * z + z * x) - 1] += 1
for i in range(n):
print((l[i]))
| false | 38.461538 | [
"-import itertools",
"-",
"-mylist = [0] * n",
"-a = 1",
"-while 6 * (a**2) < n:",
"- a += 1",
"-l = list(range(1, 3 * a - 1))",
"-for c in itertools.product(l, repeat=3):",
"- sum_num = sum(c) ** 2 - (c[0] * c[1] + c[1] * c[2] + c[2] * c[0])",
"- if sum_num <= n:",
"- mylist[sum... | false | 0.066689 | 0.687157 | 0.097051 | [
"s298096203",
"s368866572"
] |
u777299405 | p00022 | python | s340896758 | s830464009 | 2,360 | 40 | 7,932 | 7,728 | Accepted | Accepted | 98.31 | import itertools
while True:
n = int(eval(input()))
if n == 0:
break
else:
a = [int(eval(input())) for i in range(n)]
a = list(itertools.accumulate(a))
a.insert(0, 0)
ans = -100000
for j in range(n):
for k in range(j + 1, n + 1):
... | while True:
n = int(eval(input()))
if n == 0:
break
else:
a = [int(eval(input())) for i in range(n)]
for i in range(1, n):
a[i] = max(a[i - 1] + a[i], a[i])
print((max(a))) | 15 | 9 | 367 | 222 | import itertools
while True:
n = int(eval(input()))
if n == 0:
break
else:
a = [int(eval(input())) for i in range(n)]
a = list(itertools.accumulate(a))
a.insert(0, 0)
ans = -100000
for j in range(n):
for k in range(j + 1, n + 1):
a... | while True:
n = int(eval(input()))
if n == 0:
break
else:
a = [int(eval(input())) for i in range(n)]
for i in range(1, n):
a[i] = max(a[i - 1] + a[i], a[i])
print((max(a)))
| false | 40 | [
"-import itertools",
"-",
"- a = list(itertools.accumulate(a))",
"- a.insert(0, 0)",
"- ans = -100000",
"- for j in range(n):",
"- for k in range(j + 1, n + 1):",
"- ans = max(ans, a[k] - a[j])",
"- print(ans)",
"+ for i in range(... | false | 0.036895 | 0.037776 | 0.976677 | [
"s340896758",
"s830464009"
] |
u086503932 | p03472 | python | s558218201 | s244416863 | 338 | 296 | 17,508 | 20,988 | Accepted | Accepted | 12.43 | #!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right,bisect_left
from itertools import accumulate
def main():
N, H = list(map(int, input().split()))
a = [None] * N
b = [None] * N
for i in range(N):
a[i], b[i... | from heapq import heappop, heappush
N, H = list(map(int, input().split()))
a = [None] * N
b = [None] * N
for i in range(N):
a[i], b[i] = list(map(int, input().split()))
a.sort()
b.sort()
q = []
for i in range(N):
if b[i] > a[-1]:
heappush(q, -b[i])
ans = 0
while q:
H += heappop(q... | 26 | 24 | 654 | 410 | #!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right, bisect_left
from itertools import accumulate
def main():
N, H = list(map(int, input().split()))
a = [None] * N
b = [None] * N
for i in range(N):
a[i], b[i] = list(... | from heapq import heappop, heappush
N, H = list(map(int, input().split()))
a = [None] * N
b = [None] * N
for i in range(N):
a[i], b[i] = list(map(int, input().split()))
a.sort()
b.sort()
q = []
for i in range(N):
if b[i] > a[-1]:
heappush(q, -b[i])
ans = 0
while q:
H += heappop(q)
ans += 1
... | false | 7.692308 | [
"-#!/usr/bin/env python3",
"-from collections import deque, Counter",
"-from bisect import bisect_right, bisect_left",
"-from itertools import accumulate",
"-",
"-def main():",
"- N, H = list(map(int, input().split()))",
"- a = [None] * N",
"- b = [None] * N",
"- for i in range(N):",
... | false | 0.050509 | 0.049049 | 1.029771 | [
"s558218201",
"s244416863"
] |
u788337030 | p02726 | python | s204643506 | s534695462 | 1,418 | 1,311 | 3,444 | 3,444 | Accepted | Accepted | 7.55 | n, x, y = list(map(int, input().split()))
ans = [0 for i in range(n-1)]
for i in range(n-1):
k = i + 1
b_1 = k - x
if b_1 < 0:
b_1 = - b_1
for j in range(i+1, n):
l = j + 1
a = l - k
b_2 = l - y
if b_2 < 0:
b_2 = - b_2
b = b_1 + b_2 + 1
if b < a:
a = b
... | n, x, y = list(map(int, input().split()))
ans = [0 for i in range(n-1)]
for i in range(n-1):
k = i + 1
b_1 = k - x
for j in range(i+1, n):
l = j + 1
a = l - k
b = abs(k - x) + abs(l - y) + 1
if b < a:
a = b
ans[a-1] += 1
for i in range(n-1):
print((ans[i])) | 19 | 14 | 369 | 296 | n, x, y = list(map(int, input().split()))
ans = [0 for i in range(n - 1)]
for i in range(n - 1):
k = i + 1
b_1 = k - x
if b_1 < 0:
b_1 = -b_1
for j in range(i + 1, n):
l = j + 1
a = l - k
b_2 = l - y
if b_2 < 0:
b_2 = -b_2
b = b_1 + b_2 + 1
... | n, x, y = list(map(int, input().split()))
ans = [0 for i in range(n - 1)]
for i in range(n - 1):
k = i + 1
b_1 = k - x
for j in range(i + 1, n):
l = j + 1
a = l - k
b = abs(k - x) + abs(l - y) + 1
if b < a:
a = b
ans[a - 1] += 1
for i in range(n - 1):
... | false | 26.315789 | [
"- if b_1 < 0:",
"- b_1 = -b_1",
"- b_2 = l - y",
"- if b_2 < 0:",
"- b_2 = -b_2",
"- b = b_1 + b_2 + 1",
"+ b = abs(k - x) + abs(l - y) + 1"
] | false | 0.03638 | 0.040409 | 0.9003 | [
"s204643506",
"s534695462"
] |
u312025627 | p03049 | python | s578141859 | s900354154 | 308 | 270 | 45,160 | 44,760 | Accepted | Accepted | 12.34 | def main():
N = int(eval(input()))
ab_cnt = 0
b_cnt = 0
a_cnt = 0
ans = 0
for _ in range(N):
S = eval(input())
ans += S.count("AB")
if S[0] == "B" and S[-1] == "A":
ab_cnt += 1
elif S[0] == "B":
b_cnt += 1
elif S[-1] ==... | def main():
N = int(eval(input()))
A = [eval(input()) for i in range(N)]
ans = 0
ba = 0
b = 0
a = 0
for s in A:
ans += s.count("AB")
if s[0] == "B" and s[-1] == "A":
ba += 1
elif s[0] == "B":
b += 1
elif s[-1] == "A":
... | 33 | 33 | 719 | 706 | def main():
N = int(eval(input()))
ab_cnt = 0
b_cnt = 0
a_cnt = 0
ans = 0
for _ in range(N):
S = eval(input())
ans += S.count("AB")
if S[0] == "B" and S[-1] == "A":
ab_cnt += 1
elif S[0] == "B":
b_cnt += 1
elif S[-1] == "A":
... | def main():
N = int(eval(input()))
A = [eval(input()) for i in range(N)]
ans = 0
ba = 0
b = 0
a = 0
for s in A:
ans += s.count("AB")
if s[0] == "B" and s[-1] == "A":
ba += 1
elif s[0] == "B":
b += 1
elif s[-1] == "A":
a += 1... | false | 0 | [
"- ab_cnt = 0",
"- b_cnt = 0",
"- a_cnt = 0",
"+ A = [eval(input()) for i in range(N)]",
"- for _ in range(N):",
"- S = eval(input())",
"- ans += S.count(\"AB\")",
"- if S[0] == \"B\" and S[-1] == \"A\":",
"- ab_cnt += 1",
"- elif S[0] == \"B\"... | false | 0.038703 | 0.038738 | 0.999081 | [
"s578141859",
"s900354154"
] |
u729133443 | p03240 | python | s861376616 | s085201417 | 49 | 43 | 3,700 | 3,700 | Accepted | Accepted | 12.24 | A=abs
_,*p=[list(map(int,t.split()))for t in open(0)]
x,y,h=[t for t in p if t[2]][0]
for I in range(10201):j,i=I//101,I%101;H=h+A(x-j)+A(y-i);print((*(j,i,H)*all(u==max(H-A(s-j)-A(t-i),0)for s,t,u in p))) | A=abs
_,*p=[list(map(int,t.split()))for t in open(0)]
for t in p:
if t[2]:x,y,h=t
for I in range(10201):j,i=I//101,I%101;H=h+A(x-j)+A(y-i);print((*(j,i,H)*all(u==max(H-A(s-j)-A(t-i),0)for s,t,u in p))) | 4 | 5 | 206 | 204 | A = abs
_, *p = [list(map(int, t.split())) for t in open(0)]
x, y, h = [t for t in p if t[2]][0]
for I in range(10201):
j, i = I // 101, I % 101
H = h + A(x - j) + A(y - i)
print((*(j, i, H) * all(u == max(H - A(s - j) - A(t - i), 0) for s, t, u in p)))
| A = abs
_, *p = [list(map(int, t.split())) for t in open(0)]
for t in p:
if t[2]:
x, y, h = t
for I in range(10201):
j, i = I // 101, I % 101
H = h + A(x - j) + A(y - i)
print((*(j, i, H) * all(u == max(H - A(s - j) - A(t - i), 0) for s, t, u in p)))
| false | 20 | [
"-x, y, h = [t for t in p if t[2]][0]",
"+for t in p:",
"+ if t[2]:",
"+ x, y, h = t"
] | false | 0.135172 | 0.127962 | 1.056349 | [
"s861376616",
"s085201417"
] |
u179169725 | p02698 | python | s060259270 | s966259526 | 1,464 | 947 | 554,452 | 232,364 | Accepted | Accepted | 35.31 | # 木によってLISを作り、dfsで抜けるときにLISをその前の状態まで復元する
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate
def mina1(x):
return int(x) - 1
def read_ints(mina=False):
if mina:
return list(map(mina1, read().split()))
else:
return list(map(int,... | # 木によってLISを作り、dfsで抜けるときにLISをその前の状態まで復元する
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate
def mina1(x):
return int(x) - 1
def read_ints(mina=False):
if mina:
return list(map(mina1, read().split()))
else:
return list(map(int,... | 80 | 66 | 1,528 | 1,241 | # 木によってLISを作り、dfsで抜けるときにLISをその前の状態まで復元する
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate
def mina1(x):
return int(x) - 1
def read_ints(mina=False):
if mina:
return list(map(mina1, read().split()))
else:
return list(map(int, read().split()))... | # 木によってLISを作り、dfsで抜けるときにLISをその前の状態まで復元する
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate
def mina1(x):
return int(x) - 1
def read_ints(mina=False):
if mina:
return list(map(mina1, read().split()))
else:
return list(map(int, read().split()))... | false | 17.5 | [
"-",
"-####################",
"-# dp = []",
"-# for a in A:",
"-# print(dp)",
"-# idx = bisect_left(dp, a) # 初めて真に大きい要素になるidx",
"-# if idx == len(dp):",
"-# dp.append(a)",
"-# else:",
"-# dp[idx] = a # aに更新",
"-# print(dp)",
"-# print(len(dp))",
"-##########... | false | 0.037705 | 0.03649 | 1.033294 | [
"s060259270",
"s966259526"
] |
u585482323 | p04044 | python | s061441411 | s902456394 | 232 | 199 | 43,496 | 38,512 | Accepted | Accepted | 14.22 | #!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))... | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS... | 107 | 39 | 1,626 | 943 | #!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI():
return list(map(int, sys.stdin.readline().split()))
def I():
return int(sys.stdin.readline())
def LS():
return list(map(list, sys.stdin.readline().... | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI():
return [int(x) for x in sys.stdin.buffer.readline().split()]
def I():
return int(sys.stdin.buffer.readline())
d... | false | 63.551402 | [
"-from collections import defaultdict",
"+from collections import defaultdict, deque",
"+from itertools import permutations, accumulate",
"-import random",
"- return list(map(int, sys.stdin.readline().split()))",
"+ return [int(x) for x in sys.stdin.buffer.readline().split()]",
"- return int(sy... | false | 0.081674 | 0.078164 | 1.044904 | [
"s061441411",
"s902456394"
] |
u797673668 | p02278 | python | s171047226 | s395642410 | 160 | 40 | 7,832 | 7,764 | Accepted | Accepted | 75 | def perfect_swap():
global n, a, b, cost
for i in range(1, n - 1):
for j in range(i + 1, n):
ai, aj = a[i], a[j]
if ai == b[j] and aj == b[i]:
a[i], a[j] = aj, ai
cost += ai + aj
def lowest_swap():
global n, a, b, cost
for i i... | n, a, cost = int(eval(input())), list(map(int, input().split())), 0
b = sorted(a)
b0 = b[0]
for i in range(n - 1):
bi, tmp_cost, count = b[i], 0, 0
si = a.index(bi)
while si != i:
bsi = b[si]
sj = a.index(bsi)
a[si], a[sj] = bsi, bi
tmp_cost += bi + bsi
cou... | 34 | 16 | 913 | 443 | def perfect_swap():
global n, a, b, cost
for i in range(1, n - 1):
for j in range(i + 1, n):
ai, aj = a[i], a[j]
if ai == b[j] and aj == b[i]:
a[i], a[j] = aj, ai
cost += ai + aj
def lowest_swap():
global n, a, b, cost
for i in range(n - ... | n, a, cost = int(eval(input())), list(map(int, input().split())), 0
b = sorted(a)
b0 = b[0]
for i in range(n - 1):
bi, tmp_cost, count = b[i], 0, 0
si = a.index(bi)
while si != i:
bsi = b[si]
sj = a.index(bsi)
a[si], a[sj] = bsi, bi
tmp_cost += bi + bsi
count += 1
... | false | 52.941176 | [
"-def perfect_swap():",
"- global n, a, b, cost",
"- for i in range(1, n - 1):",
"- for j in range(i + 1, n):",
"- ai, aj = a[i], a[j]",
"- if ai == b[j] and aj == b[i]:",
"- a[i], a[j] = aj, ai",
"- cost += ai + aj",
"-",
"-",
"-d... | false | 0.041139 | 0.036762 | 1.11908 | [
"s171047226",
"s395642410"
] |
u753803401 | p02947 | python | s131733043 | s963239827 | 395 | 356 | 72,540 | 64,092 | Accepted | Accepted | 9.87 | def slove():
import sys, collections
input = sys.stdin.readline
n = int(input().rstrip('\n'))
s = ["".join(sorted(list(str(input().rstrip('\n'))))) for _ in range(n)]
s = collections.Counter(s).most_common()
t = 0
for i, v in s:
for j in range(1, v):
t += j
... | def slove():
import sys
import collections
input = sys.stdin.readline
n = int(input().rstrip('\n'))
s = collections.Counter(["".join(sorted(str(input().rstrip('\n')))) for _ in range(n)])
t = 0
for k, v in list(s.items()):
for i in range(1, v):
t += i
print(... | 15 | 15 | 374 | 362 | def slove():
import sys, collections
input = sys.stdin.readline
n = int(input().rstrip("\n"))
s = ["".join(sorted(list(str(input().rstrip("\n"))))) for _ in range(n)]
s = collections.Counter(s).most_common()
t = 0
for i, v in s:
for j in range(1, v):
t += j
print(t)
... | def slove():
import sys
import collections
input = sys.stdin.readline
n = int(input().rstrip("\n"))
s = collections.Counter(
["".join(sorted(str(input().rstrip("\n")))) for _ in range(n)]
)
t = 0
for k, v in list(s.items()):
for i in range(1, v):
t += i
p... | false | 0 | [
"- import sys, collections",
"+ import sys",
"+ import collections",
"- s = [\"\".join(sorted(list(str(input().rstrip(\"\\n\"))))) for _ in range(n)]",
"- s = collections.Counter(s).most_common()",
"+ s = collections.Counter(",
"+ [\"\".join(sorted(str(input().rstrip(\"\\n\"))))... | false | 0.042298 | 0.121761 | 0.347388 | [
"s131733043",
"s963239827"
] |
u440566786 | p02868 | python | s573230673 | s036687968 | 1,546 | 624 | 124,524 | 78,624 | Accepted | Accepted | 59.64 | import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
class SegmentTree(object):
def __init__(self,A,dot,e):
n=2**((len(A)-1).bit_length())
self.__n=n
self.__dot=dot
self.__e=e
self.__node=[e]*(2*n)
... | import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
n,m=list(map(int,input().split()))
E=[[] for _ in range(n)]
for i in range(1,n):
E[i].append((i-1,0))
for _ in range(m):
l,r,c=list(map(int,inpu... | 59 | 31 | 1,480 | 771 | import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().rstrip()
class SegmentTree(object):
def __init__(self, A, dot, e):
n = 2 ** ((len(A) - 1).bit_length())
self.__n = n
self.__dot = dot
self.__e = e
self.__no... | import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().rstrip()
def resolve():
n, m = list(map(int, input().split()))
E = [[] for _ in range(n)]
for i in range(1, n):
E[i].append((i - 1, 0))
for _ in range(m):
l, r, c = lis... | false | 47.457627 | [
"-class SegmentTree(object):",
"- def __init__(self, A, dot, e):",
"- n = 2 ** ((len(A) - 1).bit_length())",
"- self.__n = n",
"- self.__dot = dot",
"- self.__e = e",
"- self.__node = [e] * (2 * n)",
"- for i in range(len(A)):",
"- self.__node[... | false | 0.04497 | 0.04376 | 1.027655 | [
"s573230673",
"s036687968"
] |
u919633157 | p03640 | python | s401583909 | s591660222 | 32 | 28 | 4,212 | 4,084 | Accepted | Accepted | 12.5 | # 2019/09/09
from collections import deque
h,w=list(map(int,input().split()))
n=int(eval(input()))
a=list(map(int,input().split()))
res=[]
for i in range(n):
res+=[i+1]*a[i]
res=deque(res)
for i in range(h):
tmp=[]
for j in range(w):
tmp.append(res.popleft())
if i%2:print(... | # https://atcoder.jp/contests/arc080/tasks/arc080_b
h,w = list(map(int,input().split()))
n = int(eval(input()))
a = list(map(int,input().split()))
hw=[]
for i in range(n):
hw+=([str(i+1)]*a[i])
flag = False
for i in range(h):
bgn=i*w
end=bgn+w
res = hw[bgn:end]
if flag:
re... | 20 | 21 | 341 | 390 | # 2019/09/09
from collections import deque
h, w = list(map(int, input().split()))
n = int(eval(input()))
a = list(map(int, input().split()))
res = []
for i in range(n):
res += [i + 1] * a[i]
res = deque(res)
for i in range(h):
tmp = []
for j in range(w):
tmp.append(res.popleft())
if i % 2:
... | # https://atcoder.jp/contests/arc080/tasks/arc080_b
h, w = list(map(int, input().split()))
n = int(eval(input()))
a = list(map(int, input().split()))
hw = []
for i in range(n):
hw += [str(i + 1)] * a[i]
flag = False
for i in range(h):
bgn = i * w
end = bgn + w
res = hw[bgn:end]
if flag:
res ... | false | 4.761905 | [
"-# 2019/09/09",
"-from collections import deque",
"-",
"+# https://atcoder.jp/contests/arc080/tasks/arc080_b",
"-res = []",
"+hw = []",
"- res += [i + 1] * a[i]",
"-res = deque(res)",
"+ hw += [str(i + 1)] * a[i]",
"+flag = False",
"- tmp = []",
"- for j in range(w):",
"- ... | false | 0.101276 | 0.042933 | 2.358957 | [
"s401583909",
"s591660222"
] |
u361826811 | p02831 | python | s275353552 | s121231106 | 147 | 17 | 12,416 | 3,060 | Accepted | Accepted | 88.44 | """
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
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
A, B... | """
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
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
A, B... | 25 | 23 | 373 | 373 | """
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
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
A, B = list(map(int, readline... | """
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
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
A, B = list(map(int, readl... | false | 8 | [
"-import itertools",
"+# import itertools",
"-import numpy as np",
"-",
"+# import numpy as np"
] | false | 0.037513 | 0.042758 | 0.877321 | [
"s275353552",
"s121231106"
] |
u634079249 | p02946 | python | s357620688 | s544725563 | 19 | 17 | 3,064 | 3,060 | Accepted | Accepted | 10.53 | import sys
import os
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
K, X = list(map(int, sys.stdin.readline().split()))
MAX = 1000000
MIN = -1000000
ret = [X]
for i in range(1, K):
if X + i <= MAX:
ret.append(X+i)
els... | import sys
import os
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
K, X = list(map(int, sys.stdin.readline().split()))
ret = []
for i in range(X-K+1, X+K):
ret.append(i)
print((*ret))
if __name__ == '__main__':
main()
| 28 | 18 | 531 | 303 | import sys
import os
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
K, X = list(map(int, sys.stdin.readline().split()))
MAX = 1000000
MIN = -1000000
ret = [X]
for i in range(1, K):
if X + i <= MAX:
ret.append(X + i)
else:
r... | import sys
import os
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
K, X = list(map(int, sys.stdin.readline().split()))
ret = []
for i in range(X - K + 1, X + K):
ret.append(i)
print((*ret))
if __name__ == "__main__":
main()
| false | 35.714286 | [
"- MAX = 1000000",
"- MIN = -1000000",
"- ret = [X]",
"- for i in range(1, K):",
"- if X + i <= MAX:",
"- ret.append(X + i)",
"- else:",
"- ret.append(X - K)",
"- if X - i >= MIN:",
"- ret.append(X - i)",
"- else:",
"- ... | false | 0.123149 | 0.047124 | 2.613275 | [
"s357620688",
"s544725563"
] |
u822353071 | p03862 | python | s728831851 | s323977437 | 190 | 114 | 14,152 | 14,548 | Accepted | Accepted | 40 | #003
N,x=input().split(" ")
s = input().split(" ")
list = []
for i in range(int(N)):
list.append(int(s[i]))
count = 0
if(list[0]>int(x)):
count+=list[0]-int(x)
list[0]-=list[0]-int(x)
for i in range(1,int(N)):
temp = list[i]+list[i-1]
if(temp>int(x)):
count+=temp-int(x)
... | #003
N,x= [int(i) for i in input().split(" ")]
list = [int(i) for i in input().split(" ")]
count = 0
for i in range(N):
if(i==0):
if list[i]>x:
temp = list[i]-x
count+=temp
list[i]-=temp
else:
temp = list[i]+list[i-1]-x
if(temp>0):
... | 18 | 16 | 368 | 382 | # 003
N, x = input().split(" ")
s = input().split(" ")
list = []
for i in range(int(N)):
list.append(int(s[i]))
count = 0
if list[0] > int(x):
count += list[0] - int(x)
list[0] -= list[0] - int(x)
for i in range(1, int(N)):
temp = list[i] + list[i - 1]
if temp > int(x):
count += temp - int(x... | # 003
N, x = [int(i) for i in input().split(" ")]
list = [int(i) for i in input().split(" ")]
count = 0
for i in range(N):
if i == 0:
if list[i] > x:
temp = list[i] - x
count += temp
list[i] -= temp
else:
temp = list[i] + list[i - 1] - x
if temp > 0:
... | false | 11.111111 | [
"-N, x = input().split(\" \")",
"-s = input().split(\" \")",
"-list = []",
"-for i in range(int(N)):",
"- list.append(int(s[i]))",
"+N, x = [int(i) for i in input().split(\" \")]",
"+list = [int(i) for i in input().split(\" \")]",
"-if list[0] > int(x):",
"- count += list[0] - int(x)",
"- ... | false | 0.039701 | 0.042854 | 0.926426 | [
"s728831851",
"s323977437"
] |
u241159583 | p02768 | python | s757249286 | s890269187 | 150 | 132 | 3,064 | 9,156 | Accepted | Accepted | 12 | n,a,b = list(map(int, input().split()))
MOD = 10**9+7
def cmb(n,r):
a,b = 1,1
for i in range(r):
a = a * (n-i) % MOD
b = b * (i+1) % MOD
return a * pow(b, MOD-2, MOD)%MOD
print(((pow(2,n,MOD) - cmb(n,a) - cmb(n,b) - 1)%MOD)) | n,a,b = list(map(int, input().split()))
mod = 10**9+7
def cmb(n,r):
a,b = 1,1
for i in range(r):
a = a * (n-i) % mod
b = b * (i+1) % mod
return a * pow(b, mod-2, mod) %mod
print(((pow(2, n, mod) - cmb(n,a) - cmb(n,b) - 1)%mod)) | 11 | 11 | 256 | 259 | n, a, b = list(map(int, input().split()))
MOD = 10**9 + 7
def cmb(n, r):
a, b = 1, 1
for i in range(r):
a = a * (n - i) % MOD
b = b * (i + 1) % MOD
return a * pow(b, MOD - 2, MOD) % MOD
print(((pow(2, n, MOD) - cmb(n, a) - cmb(n, b) - 1) % MOD))
| n, a, b = list(map(int, input().split()))
mod = 10**9 + 7
def cmb(n, r):
a, b = 1, 1
for i in range(r):
a = a * (n - i) % mod
b = b * (i + 1) % mod
return a * pow(b, mod - 2, mod) % mod
print(((pow(2, n, mod) - cmb(n, a) - cmb(n, b) - 1) % mod))
| false | 0 | [
"-MOD = 10**9 + 7",
"+mod = 10**9 + 7",
"- a = a * (n - i) % MOD",
"- b = b * (i + 1) % MOD",
"- return a * pow(b, MOD - 2, MOD) % MOD",
"+ a = a * (n - i) % mod",
"+ b = b * (i + 1) % mod",
"+ return a * pow(b, mod - 2, mod) % mod",
"-print(((pow(2, n, MOD) - cmb(n... | false | 0.239285 | 0.102972 | 2.323797 | [
"s757249286",
"s890269187"
] |
u797673668 | p02272 | python | s130410545 | s900825011 | 4,360 | 3,910 | 63,848 | 64,024 | Accepted | Accepted | 10.32 | def merge(a, l, m, r):
global cnt
ll = a[l:m] + [1e9 + 1]
rl = a[m:r] + [1e9 + 1]
i, j = 0, 0
for k in range(l, r):
if ll[i] < rl[j]:
a[k] = ll[i]
i += 1
else:
a[k] = rl[j]
j += 1
cnt += 1
def merge_sort(a, l, r... | from collections import deque
INFTY = 1e9 + 1
def merge(a, l, m, r):
global cnt
ll = deque(a[l:m])
rl = deque(a[m:r])
ll.append(INFTY)
rl.append(INFTY)
for k in range(l, r):
a[k] = (ll if ll[0] < rl[0] else rl).popleft()
cnt += r - l
def merge_sort(a, l, r):
... | 27 | 28 | 562 | 555 | def merge(a, l, m, r):
global cnt
ll = a[l:m] + [1e9 + 1]
rl = a[m:r] + [1e9 + 1]
i, j = 0, 0
for k in range(l, r):
if ll[i] < rl[j]:
a[k] = ll[i]
i += 1
else:
a[k] = rl[j]
j += 1
cnt += 1
def merge_sort(a, l, r):
if l + 1... | from collections import deque
INFTY = 1e9 + 1
def merge(a, l, m, r):
global cnt
ll = deque(a[l:m])
rl = deque(a[m:r])
ll.append(INFTY)
rl.append(INFTY)
for k in range(l, r):
a[k] = (ll if ll[0] < rl[0] else rl).popleft()
cnt += r - l
def merge_sort(a, l, r):
if l + 1 < r:
... | false | 3.571429 | [
"+from collections import deque",
"+",
"+INFTY = 1e9 + 1",
"+",
"+",
"- ll = a[l:m] + [1e9 + 1]",
"- rl = a[m:r] + [1e9 + 1]",
"- i, j = 0, 0",
"+ ll = deque(a[l:m])",
"+ rl = deque(a[m:r])",
"+ ll.append(INFTY)",
"+ rl.append(INFTY)",
"- if ll[i] < rl[j]:",
"- ... | false | 0.04929 | 0.048459 | 1.017157 | [
"s130410545",
"s900825011"
] |
u923668099 | p02396 | python | s957311474 | s067861760 | 140 | 70 | 7,488 | 7,764 | Accepted | Accepted | 50 | # coding: utf-8
# Here your code !
import sys
i = 1
while True:
n = int(eval(input()))
if n == 0:
break
print(("Case " + str(i) + ": " + str(n)))
i += 1 | from sys import stdin
for test_case in range(10**4 + 2):
x = int(stdin.readline())
if not x:
break
print(('Case {}: {}'.format(test_case + 1, x))) | 14 | 9 | 193 | 175 | # coding: utf-8
# Here your code !
import sys
i = 1
while True:
n = int(eval(input()))
if n == 0:
break
print(("Case " + str(i) + ": " + str(n)))
i += 1
| from sys import stdin
for test_case in range(10**4 + 2):
x = int(stdin.readline())
if not x:
break
print(("Case {}: {}".format(test_case + 1, x)))
| false | 35.714286 | [
"-# coding: utf-8",
"-# Here your code !",
"-import sys",
"+from sys import stdin",
"-i = 1",
"-while True:",
"- n = int(eval(input()))",
"- if n == 0:",
"+for test_case in range(10**4 + 2):",
"+ x = int(stdin.readline())",
"+ if not x:",
"- print((\"Case \" + str(i) + \": \" + ... | false | 0.034662 | 0.034937 | 0.992126 | [
"s957311474",
"s067861760"
] |
u933341648 | p03838 | python | s056008428 | s779898308 | 31 | 26 | 9,172 | 9,068 | Accepted | Accepted | 16.13 | x, y = list(map(int, input().split()))
d = abs(abs(y) - abs(x))
if (x > 0 and y <= 0) or (x >= 0 and y < 0) or (x < 0 and y > 0):
d += 1
elif x > y:
d += 2
print(d)
| x, y = list(map(int, input().split()))
d = abs(abs(y) - abs(x))
if (x > 0 and y < 0) or (x < 0 and y > 0):
d += 1
elif x > y:
if x == 0 or y == 0:
d += 1
else:
d += 2
print(d)
| 10 | 13 | 179 | 213 | x, y = list(map(int, input().split()))
d = abs(abs(y) - abs(x))
if (x > 0 and y <= 0) or (x >= 0 and y < 0) or (x < 0 and y > 0):
d += 1
elif x > y:
d += 2
print(d)
| x, y = list(map(int, input().split()))
d = abs(abs(y) - abs(x))
if (x > 0 and y < 0) or (x < 0 and y > 0):
d += 1
elif x > y:
if x == 0 or y == 0:
d += 1
else:
d += 2
print(d)
| false | 23.076923 | [
"-if (x > 0 and y <= 0) or (x >= 0 and y < 0) or (x < 0 and y > 0):",
"+if (x > 0 and y < 0) or (x < 0 and y > 0):",
"- d += 2",
"+ if x == 0 or y == 0:",
"+ d += 1",
"+ else:",
"+ d += 2"
] | false | 0.034746 | 0.03651 | 0.951691 | [
"s056008428",
"s779898308"
] |
u785220618 | p03557 | python | s153476907 | s305245047 | 984 | 311 | 23,328 | 23,244 | Accepted | Accepted | 68.39 | # -*- coding: utf-8 -*-
def higher_search(list, key):
l = -1
r = len(list)
while r - l > 1:
mid = l + (r - l) // 2
if list[mid] > key:
r = mid
else:
l = mid
if r == len(list):
return -1
else:
return r
def lower... | # -*- coding: utf-8 -*-
import bisect
n = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for b in B:
ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))
print(ans)
| 54 | 13 | 936 | 303 | # -*- coding: utf-8 -*-
def higher_search(list, key):
l = -1
r = len(list)
while r - l > 1:
mid = l + (r - l) // 2
if list[mid] > key:
r = mid
else:
l = mid
if r == len(list):
return -1
else:
return r
def lower_search(list, key):
... | # -*- coding: utf-8 -*-
import bisect
n = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for b in B:
ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))
print(ans)
| false | 75.925926 | [
"-def higher_search(list, key):",
"- l = -1",
"- r = len(list)",
"- while r - l > 1:",
"- mid = l + (r - l) // 2",
"- if list[mid] > key:",
"- r = mid",
"- else:",
"- l = mid",
"- if r == len(list):",
"- return -1",
"- else:",
... | false | 0.041468 | 0.079514 | 0.521511 | [
"s153476907",
"s305245047"
] |
u503228842 | p04013 | python | s814247739 | s124135769 | 426 | 296 | 92,636 | 92,124 | Accepted | Accepted | 30.52 | n, a = list(map(int, input().split()))
x = list(map(int, input().split()))
X = max(max(x), a)
#dp = [[[0]*(n*X+1) for _ in range(X+1)] for i in range(n+1)]
dp = [[[0]*(n*X+1) for _ in range(n+1)] for i 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... | # 配列を大きめにとって配った方がすっきりかけるのかも
n, a = list(map(int, input().split()))
x = list(map(int, input().split()))
X = max(max(x), a)
dp = [[[0]*(n*X+1) for _ in range(n+1)] for i in range(n+1)]
#if j == 0 and k == 0 and s == 0:
dp[0][0][0] = 1
for j in range(n):
for k in range(n):
for s in range(n*X):
... | 21 | 21 | 707 | 513 | n, a = list(map(int, input().split()))
x = list(map(int, input().split()))
X = max(max(x), a)
# dp = [[[0]*(n*X+1) for _ in range(X+1)] for i in range(n+1)]
dp = [[[0] * (n * X + 1) for _ in range(n + 1)] for i in range(n + 1)]
for j in range(n + 1):
for k in range(n + 1):
for s in range(n * X + 1):
... | # 配列を大きめにとって配った方がすっきりかけるのかも
n, a = list(map(int, input().split()))
x = list(map(int, input().split()))
X = max(max(x), a)
dp = [[[0] * (n * X + 1) for _ in range(n + 1)] for i in range(n + 1)]
# if j == 0 and k == 0 and s == 0:
dp[0][0][0] = 1
for j in range(n):
for k in range(n):
for s in range(n * X):
... | false | 0 | [
"+# 配列を大きめにとって配った方がすっきりかけるのかも",
"-# dp = [[[0]*(n*X+1) for _ in range(X+1)] for i 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 ... | false | 0.04078 | 0.045356 | 0.899112 | [
"s814247739",
"s124135769"
] |
u445032255 | p02267 | python | s854365423 | s661252309 | 30 | 20 | 6,336 | 6,340 | Accepted | Accepted | 33.33 | def main():
N = int(eval(input()))
S = [int(_) for _ in input().split()]
Q = int(eval(input()))
T = [int(_) for _ in input().split()]
ans = 0
for t in T:
for s in S:
if s == t:
ans += 1
break
print(ans)
main()
| import sys
# Set max recursion limit
sys.setrecursionlimit(1000000)
def li_input():
return [int(_) for _ in input().split()]
def main():
n = int(eval(input()))
S = li_input()
q = int(eval(input()))
T = li_input()
ans = 0
for t in T:
if t in S:
a... | 18 | 27 | 300 | 348 | def main():
N = int(eval(input()))
S = [int(_) for _ in input().split()]
Q = int(eval(input()))
T = [int(_) for _ in input().split()]
ans = 0
for t in T:
for s in S:
if s == t:
ans += 1
break
print(ans)
main()
| import sys
# Set max recursion limit
sys.setrecursionlimit(1000000)
def li_input():
return [int(_) for _ in input().split()]
def main():
n = int(eval(input()))
S = li_input()
q = int(eval(input()))
T = li_input()
ans = 0
for t in T:
if t in S:
ans += 1
print(ans)... | false | 33.333333 | [
"+import sys",
"+",
"+# Set max recursion limit",
"+sys.setrecursionlimit(1000000)",
"+",
"+",
"+def li_input():",
"+ return [int(_) for _ in input().split()]",
"+",
"+",
"- N = int(eval(input()))",
"- S = [int(_) for _ in input().split()]",
"- Q = int(eval(input()))",
"- T ... | false | 0.040276 | 0.083093 | 0.484702 | [
"s854365423",
"s661252309"
] |
u540761833 | p03408 | python | s837219109 | s700439954 | 21 | 18 | 3,316 | 3,060 | Accepted | Accepted | 14.29 | import collections
N = int(eval(input()))
blue = []
red = []
for i in range(N):
s = eval(input())
blue.append(s)
bc = sorted(list(collections.Counter(blue).items()), key = lambda x:x[1],reverse = True)
M = int(eval(input()))
for i in range(M):
t = eval(input())
red.append(t)
rc = collections... | N= int(eval(input()))
s = [eval(input()) for i in range(N)]
M = int(eval(input()))
t = [eval(input()) for i in range(M)]
ans = 0
for i in s:
ans = max(ans,s.count(i)-t.count(i))
print(ans) | 23 | 8 | 469 | 176 | import collections
N = int(eval(input()))
blue = []
red = []
for i in range(N):
s = eval(input())
blue.append(s)
bc = sorted(list(collections.Counter(blue).items()), key=lambda x: x[1], reverse=True)
M = int(eval(input()))
for i in range(M):
t = eval(input())
red.append(t)
rc = collections.Counter(red)... | N = int(eval(input()))
s = [eval(input()) for i in range(N)]
M = int(eval(input()))
t = [eval(input()) for i in range(M)]
ans = 0
for i in s:
ans = max(ans, s.count(i) - t.count(i))
print(ans)
| false | 65.217391 | [
"-import collections",
"-",
"-blue = []",
"-red = []",
"-for i in range(N):",
"- s = eval(input())",
"- blue.append(s)",
"-bc = sorted(list(collections.Counter(blue).items()), key=lambda x: x[1], reverse=True)",
"+s = [eval(input()) for i in range(N)]",
"-for i in range(M):",
"- t = eva... | false | 0.058822 | 0.041626 | 1.41312 | [
"s837219109",
"s700439954"
] |
u222668979 | p02844 | python | s219440036 | s879039476 | 959 | 304 | 3,188 | 41,324 | Accepted | Accepted | 68.3 | n, s = int(eval(input())), str(eval(input()))
num1, num2, num3 = set([]), set([]), set([])
for i in range(n):
if s[i] in num1:
continue
num1.add(s[i])
for j in range(i + 1, n):
tmp2 = s[i] + s[j]
if tmp2 in num2:
continue
num2.add(tmp2)
for k ... | n, s = int(eval(input())), str(eval(input()))
num1, num2, num3 = set([]), set([]), set([])
for i in range(n):
if s[i] in num1:
continue
num1.add(s[i])
for j in range(i + 1, n):
tmp2 = s[i] + s[j]
if tmp2 in num2:
continue
num2.add(tmp2)
for k ... | 18 | 15 | 461 | 381 | n, s = int(eval(input())), str(eval(input()))
num1, num2, num3 = set([]), set([]), set([])
for i in range(n):
if s[i] in num1:
continue
num1.add(s[i])
for j in range(i + 1, n):
tmp2 = s[i] + s[j]
if tmp2 in num2:
continue
num2.add(tmp2)
for k in range(j + ... | n, s = int(eval(input())), str(eval(input()))
num1, num2, num3 = set([]), set([]), set([])
for i in range(n):
if s[i] in num1:
continue
num1.add(s[i])
for j in range(i + 1, n):
tmp2 = s[i] + s[j]
if tmp2 in num2:
continue
num2.add(tmp2)
for k in range(j + ... | false | 16.666667 | [
"- tmp3 = tmp2 + s[k]",
"- if tmp3 in num3:",
"- continue",
"- num3.add(tmp3)",
"+ num3.add(tmp2 + s[k])"
] | false | 0.035736 | 0.045931 | 0.778036 | [
"s219440036",
"s879039476"
] |
u670180528 | p03240 | python | s751803086 | s568233245 | 35 | 32 | 3,064 | 3,064 | Accepted | Accepted | 8.57 | n = int(eval(input()));_h=0
li = []
for _ in range(n):
x,y,h = list(map(int,input().split()))
li.append((x,y,h))
if not _h:
_x,_y,_h = x,y,h
for i in range(101):
for j in range(101):
H = _h + abs(i-_x) + abs(j-_y)
if all(h==max(0,H-abs(i-x)-abs(j-y)) for (x,y,h) in li):
print((i,j,H))
exit()... | l=[];A=abs;r=list(range(101))
for _ in range(int(eval(input()))):
*t,=list(map(int,input().split()))
l+=[t]
if t[2]:a,b,c=t
for i in r:
for j in r:
H=c+A(i-a)+A(j-b)
if all(h==max(0,H-A(i-x)-A(j-y))for x,y,h in l):
print((i,j,H)) | 15 | 10 | 324 | 229 | n = int(eval(input()))
_h = 0
li = []
for _ in range(n):
x, y, h = list(map(int, input().split()))
li.append((x, y, h))
if not _h:
_x, _y, _h = x, y, h
for i in range(101):
for j in range(101):
H = _h + abs(i - _x) + abs(j - _y)
if all(h == max(0, H - abs(i - x) - abs(j - y)) for... | l = []
A = abs
r = list(range(101))
for _ in range(int(eval(input()))):
(*t,) = list(map(int, input().split()))
l += [t]
if t[2]:
a, b, c = t
for i in r:
for j in r:
H = c + A(i - a) + A(j - b)
if all(h == max(0, H - A(i - x) - A(j - y)) for x, y, h in l):
print((i, j... | false | 33.333333 | [
"-n = int(eval(input()))",
"-_h = 0",
"-li = []",
"-for _ in range(n):",
"- x, y, h = list(map(int, input().split()))",
"- li.append((x, y, h))",
"- if not _h:",
"- _x, _y, _h = x, y, h",
"-for i in range(101):",
"- for j in range(101):",
"- H = _h + abs(i - _x) + abs(j... | false | 0.051803 | 0.071305 | 0.726493 | [
"s751803086",
"s568233245"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.