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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u020604402 | p03474 | python | s241471184 | s336085798 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | A, B = list(map(int,input().split()))
S = eval(input())
v = 0
if len(S) != A + B + 1:
v = 1
for i in range(len(S)):
if i!= A and S[i] not in [str(j) for j in range(10)]:
v = 1
if i == A and S[i] != '-':
v = 1
if v == 1:
print("No")
else:
print("Yes")
| A, B = list(map(int,input().split()))
S = eval(input())
if len(S) == A + B + 1:
cnt = 0
for x in S:
if x == '-':
cnt += 1
if cnt == 1 and S[A] == '-':
print("Yes")
quit()
print("No")
| 17 | 11 | 306 | 230 | A, B = list(map(int, input().split()))
S = eval(input())
v = 0
if len(S) != A + B + 1:
v = 1
for i in range(len(S)):
if i != A and S[i] not in [str(j) for j in range(10)]:
v = 1
if i == A and S[i] != "-":
v = 1
if v == 1:
print("No")
else:
print("Yes")
| A, B = list(map(int, input().split()))
S = eval(input())
if len(S) == A + B + 1:
cnt = 0
for x in S:
if x == "-":
cnt += 1
if cnt == 1 and S[A] == "-":
print("Yes")
quit()
print("No")
| false | 35.294118 | [
"-v = 0",
"-if len(S) != A + B + 1:",
"- v = 1",
"-for i in range(len(S)):",
"- if i != A and S[i] not in [str(j) for j in range(10)]:",
"- v = 1",
"- if i == A and S[i] != \"-\":",
"- v = 1",
"-if v == 1:",
"- print(\"No\")",
"-else:",
"- print(\"Yes\")",
"+if l... | false | 0.045194 | 0.076593 | 0.590051 | [
"s241471184",
"s336085798"
] |
u263830634 | p03172 | python | s815617567 | s873439004 | 622 | 360 | 119,276 | 92,904 | Accepted | Accepted | 42.12 | MOD = 10 ** 9 + 7
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
if K == 0:
print((1))
exit()
dp = [[0] * (K + 1) for _ in range(N + 1)]
for j in range(K + 1):
dp[N][j] = 1
# dp[N][0] = 1
# print (dp[N])
for i in range(N - 1, -1, -1):
for j in range(K + 1):
if j <= A[i]:
dp[i][j] = dp[i + 1][j]
else:
dp[i][j] = dp[i + 1][j] - dp[i + 1][j - A[i] - 1]
# print (i)
# print (dp[i])
for j in range(K):
dp[i][j + 1] += dp[i][j]
dp[i][j + 1] %= MOD
# print (dp[i])
print(((dp[0][K] - dp[0][K - 1]) % MOD)) | MOD = 10 ** 9 + 7
import numpy as np
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
if K == 0:
print((1))
exit()
dp = np.zeros((N + 1, K + 1), dtype = np.int64)
dp[N: N + 1,:] = 1
# print (dp[N]):
for i in range(N - 1, -1, -1):
dp[i:i + 1, :A[i] + 1] = dp[i + 1:i + 2, :A[i] + 1]
dp[i:i + 1, A[i] + 1:] = dp[i + 1:i + 2, A[i] + 1:] - dp[i + 1:i + 2, :K - A[i]]
# print (dp[i])
dp[i] = np.cumsum(dp[i]) % MOD
# print (dp[i])
print(((dp[0, K] - dp[0, K - 1]) % MOD)) | 28 | 22 | 643 | 538 | MOD = 10**9 + 7
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
if K == 0:
print((1))
exit()
dp = [[0] * (K + 1) for _ in range(N + 1)]
for j in range(K + 1):
dp[N][j] = 1
# dp[N][0] = 1
# print (dp[N])
for i in range(N - 1, -1, -1):
for j in range(K + 1):
if j <= A[i]:
dp[i][j] = dp[i + 1][j]
else:
dp[i][j] = dp[i + 1][j] - dp[i + 1][j - A[i] - 1]
# print (i)
# print (dp[i])
for j in range(K):
dp[i][j + 1] += dp[i][j]
dp[i][j + 1] %= MOD
# print (dp[i])
print(((dp[0][K] - dp[0][K - 1]) % MOD))
| MOD = 10**9 + 7
import numpy as np
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
if K == 0:
print((1))
exit()
dp = np.zeros((N + 1, K + 1), dtype=np.int64)
dp[N : N + 1, :] = 1
# print (dp[N]):
for i in range(N - 1, -1, -1):
dp[i : i + 1, : A[i] + 1] = dp[i + 1 : i + 2, : A[i] + 1]
dp[i : i + 1, A[i] + 1 :] = (
dp[i + 1 : i + 2, A[i] + 1 :] - dp[i + 1 : i + 2, : K - A[i]]
)
# print (dp[i])
dp[i] = np.cumsum(dp[i]) % MOD
# print (dp[i])
print(((dp[0, K] - dp[0, K - 1]) % MOD))
| false | 21.428571 | [
"+import numpy as np",
"+",
"-dp = [[0] * (K + 1) for _ in range(N + 1)]",
"-for j in range(K + 1):",
"- dp[N][j] = 1",
"-# dp[N][0] = 1",
"-# print (dp[N])",
"+dp = np.zeros((N + 1, K + 1), dtype=np.int64)",
"+dp[N : N + 1, :] = 1",
"+# print (dp[N]):",
"- for j in range(K + 1):",
"- ... | false | 0.484621 | 0.319146 | 1.518496 | [
"s815617567",
"s873439004"
] |
u645250356 | p02936 | python | s934299313 | s474014525 | 959 | 534 | 122,000 | 127,912 | Accepted | Accepted | 44.32 | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
n,q = inpl()
g = [[] for _ in range(n)]
for i in range(n-1):
a,b = inpl()
a -= 1; b -= 1
g[a].append(b)
g[b].append(a)
c = [0] * n
for i in range(q):
a,b = inpl()
c[a-1] += b
q = deque()
q.append(0)
fin = [False] * n
fin[0] = True
while q:
v = q.popleft()
for nv in g[v]:
if fin[nv]:continue
c[nv] += c[v]
fin[nv] = True
q.append(nv)
print((*c)) | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
n,q = inpl()
g = [[] for _ in range(n)]
c = [0] * n
for _ in range(n-1):
a,b = inpl()
a,b = a-1,b-1
g[a].append(b)
g[b].append(a)
for _ in range(q):
x,y = inpl()
c[x-1] += y
seen = [False] * n
seen[0] = True
q = deque()
q.append(0)
while q:
now = q.popleft()
for v in g[now]:
if seen[v]: continue
c[v] += c[now]
seen[v] = True
q.append(v)
print((*c)) | 32 | 32 | 752 | 757 | from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, fractions, pprint
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")
def inp():
return int(sys.stdin.readline())
def inpl():
return list(map(int, sys.stdin.readline().split()))
n, q = inpl()
g = [[] for _ in range(n)]
for i in range(n - 1):
a, b = inpl()
a -= 1
b -= 1
g[a].append(b)
g[b].append(a)
c = [0] * n
for i in range(q):
a, b = inpl()
c[a - 1] += b
q = deque()
q.append(0)
fin = [False] * n
fin[0] = True
while q:
v = q.popleft()
for nv in g[v]:
if fin[nv]:
continue
c[nv] += c[v]
fin[nv] = True
q.append(nv)
print((*c))
| from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, fractions, pprint
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")
def inp():
return int(sys.stdin.readline())
def inpl():
return list(map(int, sys.stdin.readline().split()))
n, q = inpl()
g = [[] for _ in range(n)]
c = [0] * n
for _ in range(n - 1):
a, b = inpl()
a, b = a - 1, b - 1
g[a].append(b)
g[b].append(a)
for _ in range(q):
x, y = inpl()
c[x - 1] += y
seen = [False] * n
seen[0] = True
q = deque()
q.append(0)
while q:
now = q.popleft()
for v in g[now]:
if seen[v]:
continue
c[v] += c[now]
seen[v] = True
q.append(v)
print((*c))
| false | 0 | [
"-for i in range(n - 1):",
"+c = [0] * n",
"+for _ in range(n - 1):",
"- a -= 1",
"- b -= 1",
"+ a, b = a - 1, b - 1",
"-c = [0] * n",
"-for i in range(q):",
"- a, b = inpl()",
"- c[a - 1] += b",
"+for _ in range(q):",
"+ x, y = inpl()",
"+ c[x - 1] += y",
"+seen = [Fa... | false | 0.036835 | 0.041351 | 0.890787 | [
"s934299313",
"s474014525"
] |
u003475507 | p02972 | python | s020150289 | s578352819 | 309 | 222 | 14,744 | 14,744 | Accepted | Accepted | 28.16 | import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline
n = int(eval(input()))
a = list(map(int, input().split()))
b=[0]*n
for i in range(n-1,-1,-1):
if sum(b[i:n:i+1]) %2 and a[i] == 0:
b[i] = 1
elif not sum(b[i:n:i+1]) %2 and a[i] == 1:
b[i] = 1
print((sum(b)))
print((" ".join([str(k+1) for k,v in enumerate(b) if v== 1]))) | import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline
n = int(eval(input()))
a = list(map(int, input().split()))
b=[0]*n
for i in range(n-1,-1,-1):
if sum(b[i:n:i+1]) %2 ^ a[i]:
b[i] = 1
print((sum(b)))
print((" ".join([str(k+1) for k,v in enumerate(b) if v== 1]))) | 18 | 16 | 378 | 304 | import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int, input().split()))
b = [0] * n
for i in range(n - 1, -1, -1):
if sum(b[i : n : i + 1]) % 2 and a[i] == 0:
b[i] = 1
elif not sum(b[i : n : i + 1]) % 2 and a[i] == 1:
b[i] = 1
print((sum(b)))
print((" ".join([str(k + 1) for k, v in enumerate(b) if v == 1])))
| import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int, input().split()))
b = [0] * n
for i in range(n - 1, -1, -1):
if sum(b[i : n : i + 1]) % 2 ^ a[i]:
b[i] = 1
print((sum(b)))
print((" ".join([str(k + 1) for k, v in enumerate(b) if v == 1])))
| false | 11.111111 | [
"- if sum(b[i : n : i + 1]) % 2 and a[i] == 0:",
"- b[i] = 1",
"- elif not sum(b[i : n : i + 1]) % 2 and a[i] == 1:",
"+ if sum(b[i : n : i + 1]) % 2 ^ a[i]:"
] | false | 0.042867 | 0.099275 | 0.431803 | [
"s020150289",
"s578352819"
] |
u609061751 | p02676 | python | s446352615 | s525788220 | 59 | 24 | 61,616 | 9,160 | Accepted | Accepted | 59.32 | import sys
input = sys.stdin.readline
k = int(eval(input()))
s = list(input().rstrip())
n = len(s)
if n <= k:
print(("".join(s)))
else:
ans = "".join(s[:k]) + "..."
print(ans) | import sys
input = sys.stdin.readline
k = int(eval(input()))
s = input().rstrip()
ans = s if len(s) <= k else s[:k] + "..."
print(ans) | 11 | 7 | 190 | 135 | import sys
input = sys.stdin.readline
k = int(eval(input()))
s = list(input().rstrip())
n = len(s)
if n <= k:
print(("".join(s)))
else:
ans = "".join(s[:k]) + "..."
print(ans)
| import sys
input = sys.stdin.readline
k = int(eval(input()))
s = input().rstrip()
ans = s if len(s) <= k else s[:k] + "..."
print(ans)
| false | 36.363636 | [
"-s = list(input().rstrip())",
"-n = len(s)",
"-if n <= k:",
"- print((\"\".join(s)))",
"-else:",
"- ans = \"\".join(s[:k]) + \"...\"",
"- print(ans)",
"+s = input().rstrip()",
"+ans = s if len(s) <= k else s[:k] + \"...\"",
"+print(ans)"
] | false | 0.045174 | 0.043999 | 1.026716 | [
"s446352615",
"s525788220"
] |
u127499732 | p03775 | python | s548841183 | s676220567 | 31 | 28 | 9,420 | 9,356 | Accepted | Accepted | 9.68 | def main():
n = int(eval(input()))
m = 1
k = int(n ** 0.5)
ans = len(str(n))
for i in range(k + 1, 0, -1):
if n % i == 0:
n = n // i
m *= i
tmp = max(len(str(m)), len(str(n)))
ans = min(ans, tmp)
print(ans)
if __name__ == '__main__':
main()
| def main():
n = int(eval(input()))
m = 1
k = int(n ** 0.5)
ans = len(str(n))
for i in range(k + 1, 0, -1):
if n % i == 0:
n = n // i
m *= i
tmp = max(len(str(m)), len(str(n)))
ans = min(ans, tmp)
break
print(ans)
if __name__ == '__main__':
main()
| 18 | 19 | 340 | 359 | def main():
n = int(eval(input()))
m = 1
k = int(n**0.5)
ans = len(str(n))
for i in range(k + 1, 0, -1):
if n % i == 0:
n = n // i
m *= i
tmp = max(len(str(m)), len(str(n)))
ans = min(ans, tmp)
print(ans)
if __name__ == "__main__":
main()
| def main():
n = int(eval(input()))
m = 1
k = int(n**0.5)
ans = len(str(n))
for i in range(k + 1, 0, -1):
if n % i == 0:
n = n // i
m *= i
tmp = max(len(str(m)), len(str(n)))
ans = min(ans, tmp)
break
print(ans)
if __name__ == "__main__":
main()
| false | 5.263158 | [
"+ break"
] | false | 0.055806 | 0.052809 | 1.056763 | [
"s548841183",
"s676220567"
] |
u895641117 | p03074 | python | s934230660 | s015454922 | 258 | 164 | 8,656 | 8,616 | Accepted | Accepted | 36.43 | n, k = list(map(int, input().split()))
s = eval(input())
s = list(map(int, s))
v = []
cnt = 1
for i in range(n - 1):
if s[i] == s[i + 1]:
cnt = cnt + 1
else:
v.append(cnt)
cnt = 1
v.append(cnt)
m = len(v)
sum = [0] * (m + 1)
for i in range(1, m + 1):
sum[i] = sum[i - 1] + v[i - 1]
ans = 0
for i in range(m + 1):
if s[0] == 0:
if i % 2 == 0:
ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
else:
ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
else:
if i % 2 == 0:
ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
else:
ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
k = k - 1
for i in range(m + 1):
if s[0] == 0:
if i % 2 == 1:
ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
else:
ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
else:
if i % 2 == 1:
ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
else:
ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
print(ans) | n, k = list(map(int, input().split()))
s = eval(input())
s = list(map(int, s))
v = []
cnt = 1
for i in range(n - 1):
if s[i] == s[i + 1]:
cnt = cnt + 1
else:
v.append(cnt)
cnt = 1
v.append(cnt)
m = len(v)
sum = [0] * (m + 1)
for i in range(1, m + 1):
sum[i] = sum[i - 1] + v[i - 1]
ans = 0
for i in range(m + 1):
if s[0] == 0:
if i % 2 == 0:
ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
else:
ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
else:
if i % 2 == 0:
ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
else:
ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
print(ans)
| 46 | 33 | 971 | 641 | n, k = list(map(int, input().split()))
s = eval(input())
s = list(map(int, s))
v = []
cnt = 1
for i in range(n - 1):
if s[i] == s[i + 1]:
cnt = cnt + 1
else:
v.append(cnt)
cnt = 1
v.append(cnt)
m = len(v)
sum = [0] * (m + 1)
for i in range(1, m + 1):
sum[i] = sum[i - 1] + v[i - 1]
ans = 0
for i in range(m + 1):
if s[0] == 0:
if i % 2 == 0:
ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
else:
ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
else:
if i % 2 == 0:
ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
else:
ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
k = k - 1
for i in range(m + 1):
if s[0] == 0:
if i % 2 == 1:
ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
else:
ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
else:
if i % 2 == 1:
ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
else:
ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
print(ans)
| n, k = list(map(int, input().split()))
s = eval(input())
s = list(map(int, s))
v = []
cnt = 1
for i in range(n - 1):
if s[i] == s[i + 1]:
cnt = cnt + 1
else:
v.append(cnt)
cnt = 1
v.append(cnt)
m = len(v)
sum = [0] * (m + 1)
for i in range(1, m + 1):
sum[i] = sum[i - 1] + v[i - 1]
ans = 0
for i in range(m + 1):
if s[0] == 0:
if i % 2 == 0:
ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
else:
ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
else:
if i % 2 == 0:
ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])
else:
ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])
print(ans)
| false | 28.26087 | [
"-k = k - 1",
"-for i in range(m + 1):",
"- if s[0] == 0:",
"- if i % 2 == 1:",
"- ans = max(ans, sum[i] - sum[max(i - k * 2 - 1, 0)])",
"- else:",
"- ans = max(ans, sum[i] - sum[max(i - k * 2, 0)])",
"- else:",
"- if i % 2 == 1:",
"- ans... | false | 0.037518 | 0.069106 | 0.542911 | [
"s934230660",
"s015454922"
] |
u497952650 | p03681 | python | s479922538 | s934801051 | 442 | 40 | 4,096 | 3,060 | Accepted | Accepted | 90.95 | import math
def fact(n):
mod = int(1e9)+7
return math.factorial(n)%mod
N,M = list(map(int,input().split()))
if abs(N-M) >= 2:
print((0))
exit()
mod = int(1e9)+7
if N == M:
print((2*fact(N)*fact(M)%mod))
else:
print((fact(N)*fact(M)%mod)) | def fact(n):
mod = int(1e9)+7
res = 1
for i in range(1,n+1):
res = (res*i)%mod
return res
N,M = list(map(int,input().split()))
if abs(N-M) >= 2:
print((0))
exit()
mod = int(1e9)+7
if N == M:
print((2*fact(N)*fact(M)%mod))
else:
print((fact(N)*fact(M)%mod)) | 17 | 19 | 269 | 306 | import math
def fact(n):
mod = int(1e9) + 7
return math.factorial(n) % mod
N, M = list(map(int, input().split()))
if abs(N - M) >= 2:
print((0))
exit()
mod = int(1e9) + 7
if N == M:
print((2 * fact(N) * fact(M) % mod))
else:
print((fact(N) * fact(M) % mod))
| def fact(n):
mod = int(1e9) + 7
res = 1
for i in range(1, n + 1):
res = (res * i) % mod
return res
N, M = list(map(int, input().split()))
if abs(N - M) >= 2:
print((0))
exit()
mod = int(1e9) + 7
if N == M:
print((2 * fact(N) * fact(M) % mod))
else:
print((fact(N) * fact(M) % mod))
| false | 10.526316 | [
"-import math",
"-",
"-",
"- return math.factorial(n) % mod",
"+ res = 1",
"+ for i in range(1, n + 1):",
"+ res = (res * i) % mod",
"+ return res"
] | false | 0.040617 | 0.030467 | 1.333144 | [
"s479922538",
"s934801051"
] |
u197956883 | p02768 | python | s781289820 | s296996308 | 177 | 132 | 38,640 | 9,172 | Accepted | Accepted | 25.42 | mod = 1000000007
# 繰り返し二乗法
def mod_pow(a, n, p):
if n == 1:
return a % p
if n % 2 == 1:
return (a* mod_pow(a, n - 1, p)) % p
tmp = mod_pow(a, n / 2, p)
return ( tmp * tmp ) % p
# 組み合わせ
def mod_cmb(n, k, p):
if n < 0 or k < 0 or n < k: return 0
if n == 0 or k == 0: return 1
if (k > n - k):
return mod_cmb(n, n - k, p)
c = d = 1
for i in range(k):
c *= (n - i)
d *= (k - i)
c %= p
d %= p
return c * mod_pow(d, p - 2, p) % p
def main():
n, a, b = list(map(int, input().split()))
ans = mod_pow(2, n, mod) - 1
tmp_a = mod_cmb(n , a, mod)
tmp_b = mod_cmb(n , b, mod)
print(((ans-tmp_a-tmp_b)%mod))
if __name__ == '__main__':
main() | mod = 1000000007
def mod_cmb(n: int, k: int, p: int) -> int:
if n < 0 or k < 0 or n < k: return 0
if n == 0 or k == 0: return 1
if (k > n - k):
return mod_cmb(n, n - k, p)
c = d = 1
for i in range(k):
c *= (n - i)
d *= (k - i)
c %= p
d %= p
return c * pow(d, -1, p) % p
def main():
n, a, b = list(map(int, input().split()))
ans = pow(2, n, mod) - 1
tmp_a = mod_cmb(n , a, mod)
tmp_b = mod_cmb(n , b, mod)
print(((ans-tmp_a-tmp_b)%mod))
if __name__ == '__main__':
main()
| 37 | 27 | 783 | 582 | mod = 1000000007
# 繰り返し二乗法
def mod_pow(a, n, p):
if n == 1:
return a % p
if n % 2 == 1:
return (a * mod_pow(a, n - 1, p)) % p
tmp = mod_pow(a, n / 2, p)
return (tmp * tmp) % p
# 組み合わせ
def mod_cmb(n, k, p):
if n < 0 or k < 0 or n < k:
return 0
if n == 0 or k == 0:
return 1
if k > n - k:
return mod_cmb(n, n - k, p)
c = d = 1
for i in range(k):
c *= n - i
d *= k - i
c %= p
d %= p
return c * mod_pow(d, p - 2, p) % p
def main():
n, a, b = list(map(int, input().split()))
ans = mod_pow(2, n, mod) - 1
tmp_a = mod_cmb(n, a, mod)
tmp_b = mod_cmb(n, b, mod)
print(((ans - tmp_a - tmp_b) % mod))
if __name__ == "__main__":
main()
| mod = 1000000007
def mod_cmb(n: int, k: int, p: int) -> int:
if n < 0 or k < 0 or n < k:
return 0
if n == 0 or k == 0:
return 1
if k > n - k:
return mod_cmb(n, n - k, p)
c = d = 1
for i in range(k):
c *= n - i
d *= k - i
c %= p
d %= p
return c * pow(d, -1, p) % p
def main():
n, a, b = list(map(int, input().split()))
ans = pow(2, n, mod) - 1
tmp_a = mod_cmb(n, a, mod)
tmp_b = mod_cmb(n, b, mod)
print(((ans - tmp_a - tmp_b) % mod))
if __name__ == "__main__":
main()
| false | 27.027027 | [
"-# 繰り返し二乗法",
"-def mod_pow(a, n, p):",
"- if n == 1:",
"- return a % p",
"- if n % 2 == 1:",
"- return (a * mod_pow(a, n - 1, p)) % p",
"- tmp = mod_pow(a, n / 2, p)",
"- return (tmp * tmp) % p",
"-# 組み合わせ",
"-def mod_cmb(n, k, p):",
"+def mod_cmb(n: int, k: int, p: in... | false | 0.082926 | 0.080827 | 1.025972 | [
"s781289820",
"s296996308"
] |
u936985471 | p03472 | python | s405534864 | s932403732 | 388 | 214 | 12,532 | 9,044 | Accepted | Accepted | 44.85 | n,h=list(map(int,input().split()))
a=[0]*n
b=[0]*n
maxa=0
minb=10**9+1
for i in range(n):
a[i],b[i]=list(map(int,input().split()))
maxa=max(maxa,a[i])
for i in range(len(b)):
if b[i]<maxa:
b[i]=0
b=sorted(b)[::-1]
ans=0
for i in range(len(b)):
if b[i]==0:
break
h-=b[i]
ans+=1
if h<=0:
print(ans)
exit(0)
print((ans+h//maxa+(h%maxa!=0))) | import sys
readline = sys.stdin.readline
N,H = list(map(int,readline().split()))
maxA = 0
B = [0] * N
for i in range(N):
a,b = list(map(int,readline().split()))
B[i] = b
if maxA < a:
maxA = a
usefulB = []
for i in range(N):
if B[i] > maxA:
usefulB += [B[i]]
usefulB = sorted(usefulB,reverse = True)
cnt = 0
for b in usefulB:
H -= b
cnt += 1
if H <= 0:
print(cnt)
break
else:
cnt += (H + maxA - 1) // maxA
print(cnt) | 22 | 29 | 374 | 469 | n, h = list(map(int, input().split()))
a = [0] * n
b = [0] * n
maxa = 0
minb = 10**9 + 1
for i in range(n):
a[i], b[i] = list(map(int, input().split()))
maxa = max(maxa, a[i])
for i in range(len(b)):
if b[i] < maxa:
b[i] = 0
b = sorted(b)[::-1]
ans = 0
for i in range(len(b)):
if b[i] == 0:
break
h -= b[i]
ans += 1
if h <= 0:
print(ans)
exit(0)
print((ans + h // maxa + (h % maxa != 0)))
| import sys
readline = sys.stdin.readline
N, H = list(map(int, readline().split()))
maxA = 0
B = [0] * N
for i in range(N):
a, b = list(map(int, readline().split()))
B[i] = b
if maxA < a:
maxA = a
usefulB = []
for i in range(N):
if B[i] > maxA:
usefulB += [B[i]]
usefulB = sorted(usefulB, reverse=True)
cnt = 0
for b in usefulB:
H -= b
cnt += 1
if H <= 0:
print(cnt)
break
else:
cnt += (H + maxA - 1) // maxA
print(cnt)
| false | 24.137931 | [
"-n, h = list(map(int, input().split()))",
"-a = [0] * n",
"-b = [0] * n",
"-maxa = 0",
"-minb = 10**9 + 1",
"-for i in range(n):",
"- a[i], b[i] = list(map(int, input().split()))",
"- maxa = max(maxa, a[i])",
"-for i in range(len(b)):",
"- if b[i] < maxa:",
"- b[i] = 0",
"-b =... | false | 0.04282 | 0.044243 | 0.967835 | [
"s405534864",
"s932403732"
] |
u763249708 | p02725 | python | s000913112 | s734561484 | 218 | 146 | 26,444 | 32,368 | Accepted | Accepted | 33.03 | k, n = list(map(int, input().split()))
a = list(map(int, input().split()))
diff = 0
total = 0
for i in range(n-1):
diff = max(abs(a[i] - a[i+1]), diff)
total += abs(a[i] - a[i+1])
diff_tmp = abs(a[n-1] - k) + a[0]
diff = max(diff_tmp, diff)
total += abs(a[n-1] - k) + a[0] - diff
print(total) | k, n = list(map(int, input().split()))
a = list(map(int, input().split()))
bef = a[0]
max_diff = 0
for i in range(1,n):
diff = abs(bef - a[i])
max_diff = max(diff, max_diff)
bef = a[i]
print((k - max(max_diff, k - abs(a[n-1] - a[0])))) | 14 | 11 | 314 | 251 | k, n = list(map(int, input().split()))
a = list(map(int, input().split()))
diff = 0
total = 0
for i in range(n - 1):
diff = max(abs(a[i] - a[i + 1]), diff)
total += abs(a[i] - a[i + 1])
diff_tmp = abs(a[n - 1] - k) + a[0]
diff = max(diff_tmp, diff)
total += abs(a[n - 1] - k) + a[0] - diff
print(total)
| k, n = list(map(int, input().split()))
a = list(map(int, input().split()))
bef = a[0]
max_diff = 0
for i in range(1, n):
diff = abs(bef - a[i])
max_diff = max(diff, max_diff)
bef = a[i]
print((k - max(max_diff, k - abs(a[n - 1] - a[0]))))
| false | 21.428571 | [
"-diff = 0",
"-total = 0",
"-for i in range(n - 1):",
"- diff = max(abs(a[i] - a[i + 1]), diff)",
"- total += abs(a[i] - a[i + 1])",
"-diff_tmp = abs(a[n - 1] - k) + a[0]",
"-diff = max(diff_tmp, diff)",
"-total += abs(a[n - 1] - k) + a[0] - diff",
"-print(total)",
"+bef = a[0]",
"+max_dif... | false | 0.079223 | 0.085757 | 0.923807 | [
"s000913112",
"s734561484"
] |
u790710233 | p03347 | python | s165698981 | s941173964 | 329 | 301 | 32,804 | 9,116 | Accepted | Accepted | 8.51 | n = int(eval(input()))
A = [int(eval(input()))for _ in range(n)]
if A[0] != 0:
print((-1))
exit()
ans = A[-1]
for a, prev_a in reversed(tuple(zip(A, A[1:]))):
if a == prev_a-1:
continue
if a < prev_a-1:
print((-1))
break
ans += a
else:
print(ans)
| n = int(eval(input()))
ans = -1
prev = -1
for _ in range(n):
a = int(eval(input()))
if prev+1 == a:
prev = a
ans += 1
continue
if prev+1 < a:
print((-1))
break
ans += a
prev = a
else:
print(ans)
| 16 | 16 | 295 | 260 | n = int(eval(input()))
A = [int(eval(input())) for _ in range(n)]
if A[0] != 0:
print((-1))
exit()
ans = A[-1]
for a, prev_a in reversed(tuple(zip(A, A[1:]))):
if a == prev_a - 1:
continue
if a < prev_a - 1:
print((-1))
break
ans += a
else:
print(ans)
| n = int(eval(input()))
ans = -1
prev = -1
for _ in range(n):
a = int(eval(input()))
if prev + 1 == a:
prev = a
ans += 1
continue
if prev + 1 < a:
print((-1))
break
ans += a
prev = a
else:
print(ans)
| false | 0 | [
"-A = [int(eval(input())) for _ in range(n)]",
"-if A[0] != 0:",
"- print((-1))",
"- exit()",
"-ans = A[-1]",
"-for a, prev_a in reversed(tuple(zip(A, A[1:]))):",
"- if a == prev_a - 1:",
"+ans = -1",
"+prev = -1",
"+for _ in range(n):",
"+ a = int(eval(input()))",
"+ if prev + ... | false | 0.074955 | 0.050112 | 1.495736 | [
"s165698981",
"s941173964"
] |
u827141374 | p03378 | python | s637965199 | s589783428 | 20 | 17 | 3,064 | 3,064 | Accepted | Accepted | 15 | N, M, X = (int(x) for x in input().split())
A = [int(x) for x in input().split()]
Z = [0] * N
for a in A:
Z[a] = 1
lower = 0
for i in range(0, X+1):
lower += Z[i]
higher = 0
for i in range(X, N):
higher += Z[i]
print((min(lower,higher))) | N, M, X = (int(x) for x in input().split())
A = [int(x) for x in input().split()]
Z = [0] * N
for a in A:
Z[a] = 1
lower = 0
higher = 0
for i in range(0, N):
lower += Z[i] if i < X else 0
higher += Z[i] if i > X else 0
print((min(lower, higher))) | 12 | 12 | 258 | 268 | N, M, X = (int(x) for x in input().split())
A = [int(x) for x in input().split()]
Z = [0] * N
for a in A:
Z[a] = 1
lower = 0
for i in range(0, X + 1):
lower += Z[i]
higher = 0
for i in range(X, N):
higher += Z[i]
print((min(lower, higher)))
| N, M, X = (int(x) for x in input().split())
A = [int(x) for x in input().split()]
Z = [0] * N
for a in A:
Z[a] = 1
lower = 0
higher = 0
for i in range(0, N):
lower += Z[i] if i < X else 0
higher += Z[i] if i > X else 0
print((min(lower, higher)))
| false | 0 | [
"-for i in range(0, X + 1):",
"- lower += Z[i]",
"-for i in range(X, N):",
"- higher += Z[i]",
"+for i in range(0, N):",
"+ lower += Z[i] if i < X else 0",
"+ higher += Z[i] if i > X else 0"
] | false | 0.082878 | 0.05051 | 1.640835 | [
"s637965199",
"s589783428"
] |
u498677593 | p02573 | python | s265233976 | s804737505 | 1,781 | 555 | 160,784 | 83,332 | Accepted | Accepted | 68.84 | N,M=list(map(int,input().split()))
f=[set() for i in range(N)]
v=[False]*N
g=[]
for i in range(0,M):
a,b=list(map(int,input().split()))
a-=1
b-=1
f[a].add(b)
f[b].add(a)
for i in range(0,N):
if v[i]:
continue
s=set()
q=[i]
while len(q)>0:
p=q.pop()
v[p]=True
s.add(p)
for x in f[p]:
if v[x]:
continue
q.append(x)
g.append(s)
z=0
for x in g:
z=max(z,len(x))
print(z) | class UnionFind():
def __init__(self, n):
self.parent = [i for i in range(0, n)]
self.rank= [0] * n
def root(self, x):
if self.parent[x] != x:
self.parent[x] = self.root(self.parent[x])
return self.parent[x]
def union(self, x, y):
x = self.root(x)
y = self.root(y)
if self.rank[x] < self.rank[y]:
self.parent[x] = y
else:
self.parent[y] = x
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
def same(self, x, y):
return self.find(x) == self.find(y)
def rootRank(self, x):
return self.rank[self.root(x)]
N,M=list(map(int,input().split()))
uf = UnionFind(N)
for i in range(M):
a,b=list(map(int,input().split()))
a-=1
b-=1
uf.union(a,b)
z=0
c=[0]*N
for i in range(N):
p=uf.root(i)
c[p]+=1
if z<c[p]:
z=c[p]
print(z)
| 32 | 46 | 512 | 957 | N, M = list(map(int, input().split()))
f = [set() for i in range(N)]
v = [False] * N
g = []
for i in range(0, M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
f[a].add(b)
f[b].add(a)
for i in range(0, N):
if v[i]:
continue
s = set()
q = [i]
while len(q) > 0:
p = q.pop()
v[p] = True
s.add(p)
for x in f[p]:
if v[x]:
continue
q.append(x)
g.append(s)
z = 0
for x in g:
z = max(z, len(x))
print(z)
| class UnionFind:
def __init__(self, n):
self.parent = [i for i in range(0, n)]
self.rank = [0] * n
def root(self, x):
if self.parent[x] != x:
self.parent[x] = self.root(self.parent[x])
return self.parent[x]
def union(self, x, y):
x = self.root(x)
y = self.root(y)
if self.rank[x] < self.rank[y]:
self.parent[x] = y
else:
self.parent[y] = x
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
def same(self, x, y):
return self.find(x) == self.find(y)
def rootRank(self, x):
return self.rank[self.root(x)]
N, M = list(map(int, input().split()))
uf = UnionFind(N)
for i in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
uf.union(a, b)
z = 0
c = [0] * N
for i in range(N):
p = uf.root(i)
c[p] += 1
if z < c[p]:
z = c[p]
print(z)
| false | 30.434783 | [
"+class UnionFind:",
"+ def __init__(self, n):",
"+ self.parent = [i for i in range(0, n)]",
"+ self.rank = [0] * n",
"+",
"+ def root(self, x):",
"+ if self.parent[x] != x:",
"+ self.parent[x] = self.root(self.parent[x])",
"+ return self.parent[x]",
"+... | false | 0.038498 | 0.048008 | 0.801913 | [
"s265233976",
"s804737505"
] |
u631277801 | p03472 | python | s920741975 | s477655142 | 526 | 350 | 28,328 | 17,400 | Accepted | Accepted | 33.46 | from itertools import accumulate
from bisect import bisect_left
from math import ceil
N,H = list(map(int, input().split()))
AB = []
for _ in range(N):
AB.append(tuple(map(int, input().split())))
# A昇順、B降順にソート
AB.sort(key=lambda x: (x[0], -x[1]))
# 最後の刀を装備する
equip = AB.pop()
# a_max < b なる刀を集める
b_list = []
for a,b in AB:
if b > equip[0]:
b_list.append(b)
# bを攻撃力の高い順に並べ替える
b_list.sort(reverse=True)
b_list_cum = list(accumulate(b_list))
b_list_cum = [0] + b_list_cum
ans = 0
# hpがb_list_cum[-1]以下なら、刀投げで終わる
if H <= b_list_cum[-1]:
ans = bisect_left(b_list_cum,H)
print(ans)
# 違えば、まずはb>=a_maxなる刀を全部投げ、equipでhp<=bになるまで攻撃し、
# 最後の1手で刀を投げる
else:
ans = len(b_list_cum)-1
res = H - b_list_cum[-1]
a_attack = max(0, int(ceil((res-equip[1]) / equip[0])))
# aで攻撃した分と、最後の1手の刀投げの分を足す
ans += (a_attack + 1)
print(ans) | from itertools import accumulate
from bisect import bisect_left
from math import ceil
N,H = list(map(int, input().split()))
A = []
B = []
for _ in range(N):
a, b = list(map(int, input().split()))
A.append(a)
B.append(b)
# 最も強いaを探す
a_max = max(A)
# それ以上のbを探す
b_strong = []
for b in B:
if b >= a_max:
b_strong.append(b)
# bをソートしてcum作る
b_strong.sort(reverse=True)
b_cum = list(accumulate(b_strong))
b_cum = [0] + b_cum
# もしHPがb_cum[-1]なら投げてるうちに倒せる
if H <= b_cum[-1]:
ans = bisect_left(b_cum, H)
else:
ans = len(b_cum) - 1
ans += ceil((H - b_cum[-1]) / a_max)
print(ans) | 42 | 35 | 901 | 655 | from itertools import accumulate
from bisect import bisect_left
from math import ceil
N, H = list(map(int, input().split()))
AB = []
for _ in range(N):
AB.append(tuple(map(int, input().split())))
# A昇順、B降順にソート
AB.sort(key=lambda x: (x[0], -x[1]))
# 最後の刀を装備する
equip = AB.pop()
# a_max < b なる刀を集める
b_list = []
for a, b in AB:
if b > equip[0]:
b_list.append(b)
# bを攻撃力の高い順に並べ替える
b_list.sort(reverse=True)
b_list_cum = list(accumulate(b_list))
b_list_cum = [0] + b_list_cum
ans = 0
# hpがb_list_cum[-1]以下なら、刀投げで終わる
if H <= b_list_cum[-1]:
ans = bisect_left(b_list_cum, H)
print(ans)
# 違えば、まずはb>=a_maxなる刀を全部投げ、equipでhp<=bになるまで攻撃し、
# 最後の1手で刀を投げる
else:
ans = len(b_list_cum) - 1
res = H - b_list_cum[-1]
a_attack = max(0, int(ceil((res - equip[1]) / equip[0])))
# aで攻撃した分と、最後の1手の刀投げの分を足す
ans += a_attack + 1
print(ans)
| from itertools import accumulate
from bisect import bisect_left
from math import ceil
N, H = list(map(int, input().split()))
A = []
B = []
for _ in range(N):
a, b = list(map(int, input().split()))
A.append(a)
B.append(b)
# 最も強いaを探す
a_max = max(A)
# それ以上のbを探す
b_strong = []
for b in B:
if b >= a_max:
b_strong.append(b)
# bをソートしてcum作る
b_strong.sort(reverse=True)
b_cum = list(accumulate(b_strong))
b_cum = [0] + b_cum
# もしHPがb_cum[-1]なら投げてるうちに倒せる
if H <= b_cum[-1]:
ans = bisect_left(b_cum, H)
else:
ans = len(b_cum) - 1
ans += ceil((H - b_cum[-1]) / a_max)
print(ans)
| false | 16.666667 | [
"-AB = []",
"+A = []",
"+B = []",
"- AB.append(tuple(map(int, input().split())))",
"-# A昇順、B降順にソート",
"-AB.sort(key=lambda x: (x[0], -x[1]))",
"-# 最後の刀を装備する",
"-equip = AB.pop()",
"-# a_max < b なる刀を集める",
"-b_list = []",
"-for a, b in AB:",
"- if b > equip[0]:",
"- b_list.append(b... | false | 0.040408 | 0.039656 | 1.018973 | [
"s920741975",
"s477655142"
] |
u254871849 | p02972 | python | s977933843 | s517431164 | 435 | 304 | 7,056 | 8,336 | Accepted | Accepted | 30.11 | # 2019-11-15 14:12:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# from scipy.misc import comb # float
# import numpy as np
def main():
n, *a = [int(x) for x in sys.stdin.read().split()]
a = [None] + a
in_or_not = [0 for _ in range(n+1)]
for i in range(n, 0, -1):
count = 0
for j in range(2 * i, n+1, i):
count += in_or_not[j]
in_or_not[i] = a[i] ^ count % 2
print(in_or_not.count(1))
for i in range(1, n+1):
if in_or_not[i] == 1:
print(i, end=' ')
if __name__ == "__main__":
main()
| # 2019-11-15 14:12:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# from scipy.misc import comb # float
# import numpy as np
def main():
n, *a = [int(x) for x in sys.stdin.read().split()]
a = [None] + a
in_or_not = [0 for _ in range(n+1)]
for i in range(n, 0, -1):
count = sum(in_or_not[2*i:n+1:i])
in_or_not[i] = a[i] ^ count % 2
print(in_or_not.count(1))
for i in range(1, n+1):
if in_or_not[i] == 1:
print(i, end=' ')
if __name__ == "__main__":
main()
| 36 | 30 | 843 | 778 | # 2019-11-15 14:12:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# from scipy.misc import comb # float
# import numpy as np
def main():
n, *a = [int(x) for x in sys.stdin.read().split()]
a = [None] + a
in_or_not = [0 for _ in range(n + 1)]
for i in range(n, 0, -1):
count = 0
for j in range(2 * i, n + 1, i):
count += in_or_not[j]
in_or_not[i] = a[i] ^ count % 2
print(in_or_not.count(1))
for i in range(1, n + 1):
if in_or_not[i] == 1:
print(i, end=" ")
if __name__ == "__main__":
main()
| # 2019-11-15 14:12:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# from scipy.misc import comb # float
# import numpy as np
def main():
n, *a = [int(x) for x in sys.stdin.read().split()]
a = [None] + a
in_or_not = [0 for _ in range(n + 1)]
for i in range(n, 0, -1):
count = sum(in_or_not[2 * i : n + 1 : i])
in_or_not[i] = a[i] ^ count % 2
print(in_or_not.count(1))
for i in range(1, n + 1):
if in_or_not[i] == 1:
print(i, end=" ")
if __name__ == "__main__":
main()
| false | 16.666667 | [
"- count = 0",
"- for j in range(2 * i, n + 1, i):",
"- count += in_or_not[j]",
"+ count = sum(in_or_not[2 * i : n + 1 : i])"
] | false | 0.037238 | 0.036631 | 1.016558 | [
"s977933843",
"s517431164"
] |
u729133443 | p03147 | python | s632828649 | s164525983 | 170 | 19 | 39,280 | 3,188 | Accepted | Accepted | 88.82 | def solve(l):
if len(l)<2:
return max(0,l[0])
m=10**18
a=0
for i in range(len(l)):
if l[i]<1:
if i+1<len(l):
a+=solve(l[i+1:])
else:
l=l[:i]
break
m=min(m,l[i])
l=l[:i+1]
for i in range(len(l)):
l[i]-=m
return solve(l)+a+m*(m!=10**18)
n=int(eval(input()))
*h,=list(map(int,input().split()))
print((solve(h))) | def solve(h):
if len(h)<2:
return h[0]
s=[i for i in range(len(h))if h[i]<1]
s=[-1]+s+[len(h)]
a=0
for l in[h[i+1:j]for i,j in zip(s,s[1:])]:
if not l:continue
v=min(l)
l=[t-v for t in l]
a+=v+solve(l)
return a
eval(input())
print((solve(list(map(int,input().split()))))) | 21 | 14 | 443 | 340 | def solve(l):
if len(l) < 2:
return max(0, l[0])
m = 10**18
a = 0
for i in range(len(l)):
if l[i] < 1:
if i + 1 < len(l):
a += solve(l[i + 1 :])
else:
l = l[:i]
break
m = min(m, l[i])
l = l[: i + 1]
for i in range(len(l)):
l[i] -= m
return solve(l) + a + m * (m != 10**18)
n = int(eval(input()))
(*h,) = list(map(int, input().split()))
print((solve(h)))
| def solve(h):
if len(h) < 2:
return h[0]
s = [i for i in range(len(h)) if h[i] < 1]
s = [-1] + s + [len(h)]
a = 0
for l in [h[i + 1 : j] for i, j in zip(s, s[1:])]:
if not l:
continue
v = min(l)
l = [t - v for t in l]
a += v + solve(l)
return a
eval(input())
print((solve(list(map(int, input().split())))))
| false | 33.333333 | [
"-def solve(l):",
"- if len(l) < 2:",
"- return max(0, l[0])",
"- m = 10**18",
"+def solve(h):",
"+ if len(h) < 2:",
"+ return h[0]",
"+ s = [i for i in range(len(h)) if h[i] < 1]",
"+ s = [-1] + s + [len(h)]",
"- for i in range(len(l)):",
"- if l[i] < 1:",... | false | 0.059811 | 0.037598 | 1.590807 | [
"s632828649",
"s164525983"
] |
u374802266 | p03635 | python | s816164970 | s281440036 | 176 | 17 | 38,384 | 2,940 | Accepted | Accepted | 90.34 | a=list(map(int,input().split()))
print(((a[0]-1)*(a[1]-1))) | a,b=list(map(int,input().split()))
print((a*b-a-b+1)) | 2 | 2 | 58 | 46 | a = list(map(int, input().split()))
print(((a[0] - 1) * (a[1] - 1)))
| a, b = list(map(int, input().split()))
print((a * b - a - b + 1))
| false | 0 | [
"-a = list(map(int, input().split()))",
"-print(((a[0] - 1) * (a[1] - 1)))",
"+a, b = list(map(int, input().split()))",
"+print((a * b - a - b + 1))"
] | false | 0.123061 | 0.039892 | 3.084876 | [
"s816164970",
"s281440036"
] |
u525065967 | p02990 | python | s258310879 | s731175617 | 879 | 19 | 14,248 | 3,316 | Accepted | Accepted | 97.84 | from scipy.misc import comb
# from scipy.special import comb
MOD = 10**9+7
N, K = list(map(int, input().split()))
red, blue = N-K, K
for i in range(1,blue+1):
print(((comb(red+1, i, exact=True) * comb(blue-1, i-1, exact=True)) % MOD))
| MOD = 10**9+7
N,K = list(map(int, input().split()))
red, blue = N-K, K
ai = red+1
print(ai)
for i in range(2,blue+1):
ai = ai * (red-i+2) * (blue-i+1) // (i*(i-1))
print((ai%MOD)) | 7 | 8 | 235 | 186 | from scipy.misc import comb
# from scipy.special import comb
MOD = 10**9 + 7
N, K = list(map(int, input().split()))
red, blue = N - K, K
for i in range(1, blue + 1):
print(((comb(red + 1, i, exact=True) * comb(blue - 1, i - 1, exact=True)) % MOD))
| MOD = 10**9 + 7
N, K = list(map(int, input().split()))
red, blue = N - K, K
ai = red + 1
print(ai)
for i in range(2, blue + 1):
ai = ai * (red - i + 2) * (blue - i + 1) // (i * (i - 1))
print((ai % MOD))
| false | 12.5 | [
"-from scipy.misc import comb",
"-",
"-# from scipy.special import comb",
"-for i in range(1, blue + 1):",
"- print(((comb(red + 1, i, exact=True) * comb(blue - 1, i - 1, exact=True)) % MOD))",
"+ai = red + 1",
"+print(ai)",
"+for i in range(2, blue + 1):",
"+ ai = ai * (red - i + 2) * (blue -... | false | 0.421915 | 0.036968 | 11.412846 | [
"s258310879",
"s731175617"
] |
u796942881 | p02947 | python | s457733984 | s581123074 | 233 | 214 | 29,056 | 26,752 | Accepted | Accepted | 8.15 | from collections import defaultdict
def main():
s = [tuple(sorted(i)) for i in open(0).read().split()[1:]]
d = defaultdict(lambda: 0)
ans = 0
for i in s:
ans += d[i]
d[i] += 1
print(ans)
return
main()
| from collections import defaultdict
def main():
s = ("".join(sorted(i)) for i in open(0).read().split()[1:])
d = defaultdict(lambda: 0)
ans = 0
for i in s:
ans += d[i]
d[i] += 1
print(ans)
return
main()
| 15 | 15 | 259 | 261 | from collections import defaultdict
def main():
s = [tuple(sorted(i)) for i in open(0).read().split()[1:]]
d = defaultdict(lambda: 0)
ans = 0
for i in s:
ans += d[i]
d[i] += 1
print(ans)
return
main()
| from collections import defaultdict
def main():
s = ("".join(sorted(i)) for i in open(0).read().split()[1:])
d = defaultdict(lambda: 0)
ans = 0
for i in s:
ans += d[i]
d[i] += 1
print(ans)
return
main()
| false | 0 | [
"- s = [tuple(sorted(i)) for i in open(0).read().split()[1:]]",
"+ s = (\"\".join(sorted(i)) for i in open(0).read().split()[1:])"
] | false | 0.120031 | 0.070807 | 1.69518 | [
"s457733984",
"s581123074"
] |
u426534722 | p02394 | python | s693492767 | s225212776 | 30 | 20 | 7,736 | 5,592 | Accepted | Accepted | 33.33 | W, H, x, y, r = [int(i) for i in input().split()]
ans = "Yes"
if x - r < 0 or W < x + r: ans = "No"
if y - r < 0 or H < y + r: ans = "No"
print(ans) | W, H, x, y, r = list(map(int, input().split()))
print(("Yes" if 0 <= x - r and x + r <= W and 0 <= y - r and y + r <= H else "No"))
| 5 | 2 | 152 | 125 | W, H, x, y, r = [int(i) for i in input().split()]
ans = "Yes"
if x - r < 0 or W < x + r:
ans = "No"
if y - r < 0 or H < y + r:
ans = "No"
print(ans)
| W, H, x, y, r = list(map(int, input().split()))
print(("Yes" if 0 <= x - r and x + r <= W and 0 <= y - r and y + r <= H else "No"))
| false | 60 | [
"-W, H, x, y, r = [int(i) for i in input().split()]",
"-ans = \"Yes\"",
"-if x - r < 0 or W < x + r:",
"- ans = \"No\"",
"-if y - r < 0 or H < y + r:",
"- ans = \"No\"",
"-print(ans)",
"+W, H, x, y, r = list(map(int, input().split()))",
"+print((\"Yes\" if 0 <= x - r and x + r <= W and 0 <= y ... | false | 0.037833 | 0.03951 | 0.957559 | [
"s693492767",
"s225212776"
] |
u163320134 | p02716 | python | s471805801 | s136981222 | 1,182 | 463 | 86,972 | 45,220 | Accepted | Accepted | 60.83 | n=int(eval(input()))
arr=list(map(int,input().split()))
if n%2==0:
ans=-10**18
dp=[[0]*2 for _ in range(n+10)]
for i in range(n):
dp[i+1][0]=dp[i-1][0]+arr[i]
dp[i+1][1]=max(dp[i-1][1]+arr[i],dp[i-2][0]+arr[i])
ans=max(ans,dp[n-1][0],dp[n][1])
dp=[[0]*2 for _ in range(n+10)]
for i in range(1,n):
dp[i+1][0]=dp[i-1][0]+arr[i]
dp[i+1][1]=max(dp[i-1][1]+arr[i],dp[i-2][0]+arr[i])
ans=max(ans,dp[n][0])
print(ans)
else:
ans=-10**18
dp=[[0]*3 for _ in range(n+10)]
for i in range(n):
dp[i+1][0]=dp[i-1][0]+arr[i]
dp[i+1][1]=max(dp[i-1][1]+arr[i],dp[i-2][0]+arr[i])
dp[i+1][2]=max(dp[i-1][2]+arr[i],dp[i-2][1]+arr[i],dp[i-3][0]+arr[i])
ans=max(ans,dp[n-2][0],dp[n-1][1],dp[n][2])
dp=[[0]*3 for _ in range(n+10)]
for i in range(1,n):
dp[i+1][0]=dp[i-1][0]+arr[i]
dp[i+1][1]=max(dp[i-1][1]+arr[i],dp[i-2][0]+arr[i])
dp[i+1][2]=max(dp[i-1][2]+arr[i],dp[i-2][1]+arr[i],dp[i-3][0]+arr[i])
ans=max(ans,dp[n-1][0],dp[n][1])
dp=[[0]*3 for _ in range(n+10)]
for i in range(2,n):
dp[i+1][0]=dp[i-1][0]+arr[i]
dp[i+1][1]=max(dp[i-1][1]+arr[i],dp[i-2][0]+arr[i])
dp[i+1][2]=max(dp[i-1][2]+arr[i],dp[i-2][1]+arr[i],dp[i-3][0]+arr[i])
ans=max(ans,dp[n][0])
print(ans) | n=int(eval(input()))
arr=list(map(int,input().split()))
acum1=[0]
acum2=[0]
for i in range(n):
if i%2==0:
acum1.append(acum1[-1]+arr[i])
acum2.append(acum2[-1]+0)
else:
acum1.append(acum1[-1]+0)
acum2.append(acum2[-1]+arr[i])
if n%2==0:
ans=max(acum1[n-1]-acum1[0],acum2[n]-acum2[1])
for i in range(1,n+1,2):
if i+3>n:
continue
tmp=(acum1[i]-acum1[0])+(acum2[n]-acum2[i+2])
ans=max(ans,tmp)
else:
ans=max(acum1[n-2]-acum1[0],acum2[n-1]-acum2[1],acum1[n]-acum1[2])
for i in range(1,n+1,2):
if i+3>n-1:
continue
tmp=(acum1[i]-acum1[0])+(acum2[n-1]-acum2[i+2])
ans=max(ans,tmp)
for i in range(2,n+1,2):
if i+3>n:
continue
tmp=(acum2[i]-acum2[1])+(acum1[n]-acum1[i+2])
ans=max(ans,tmp)
for i in range(1,n+1,2):
if i+4>n:
continue
tmp=(acum1[i]-acum1[0])+(acum1[n]-acum1[i+3])
ans=max(ans,tmp)
acummax=[-10**18]
for i in range(1,n+1):
if i+2>n:
acummax.append(-10**18)
else:
if i%2==0:
acummax.append(acum2[i]+acum1[n]-acum1[i+2])
else:
acummax.append(-10**18)
for i in range(n-1,-1,-1):
acummax[i]=max(acummax[i],acummax[i+1])
for i in range(1,n+1,2):
if i+6>n:
continue
tmp=(acum1[i]-acum1[0]-acum2[i+2])+acummax[i+3]
ans=max(ans,tmp)
print(ans) | 36 | 52 | 1,267 | 1,363 | n = int(eval(input()))
arr = list(map(int, input().split()))
if n % 2 == 0:
ans = -(10**18)
dp = [[0] * 2 for _ in range(n + 10)]
for i in range(n):
dp[i + 1][0] = dp[i - 1][0] + arr[i]
dp[i + 1][1] = max(dp[i - 1][1] + arr[i], dp[i - 2][0] + arr[i])
ans = max(ans, dp[n - 1][0], dp[n][1])
dp = [[0] * 2 for _ in range(n + 10)]
for i in range(1, n):
dp[i + 1][0] = dp[i - 1][0] + arr[i]
dp[i + 1][1] = max(dp[i - 1][1] + arr[i], dp[i - 2][0] + arr[i])
ans = max(ans, dp[n][0])
print(ans)
else:
ans = -(10**18)
dp = [[0] * 3 for _ in range(n + 10)]
for i in range(n):
dp[i + 1][0] = dp[i - 1][0] + arr[i]
dp[i + 1][1] = max(dp[i - 1][1] + arr[i], dp[i - 2][0] + arr[i])
dp[i + 1][2] = max(
dp[i - 1][2] + arr[i], dp[i - 2][1] + arr[i], dp[i - 3][0] + arr[i]
)
ans = max(ans, dp[n - 2][0], dp[n - 1][1], dp[n][2])
dp = [[0] * 3 for _ in range(n + 10)]
for i in range(1, n):
dp[i + 1][0] = dp[i - 1][0] + arr[i]
dp[i + 1][1] = max(dp[i - 1][1] + arr[i], dp[i - 2][0] + arr[i])
dp[i + 1][2] = max(
dp[i - 1][2] + arr[i], dp[i - 2][1] + arr[i], dp[i - 3][0] + arr[i]
)
ans = max(ans, dp[n - 1][0], dp[n][1])
dp = [[0] * 3 for _ in range(n + 10)]
for i in range(2, n):
dp[i + 1][0] = dp[i - 1][0] + arr[i]
dp[i + 1][1] = max(dp[i - 1][1] + arr[i], dp[i - 2][0] + arr[i])
dp[i + 1][2] = max(
dp[i - 1][2] + arr[i], dp[i - 2][1] + arr[i], dp[i - 3][0] + arr[i]
)
ans = max(ans, dp[n][0])
print(ans)
| n = int(eval(input()))
arr = list(map(int, input().split()))
acum1 = [0]
acum2 = [0]
for i in range(n):
if i % 2 == 0:
acum1.append(acum1[-1] + arr[i])
acum2.append(acum2[-1] + 0)
else:
acum1.append(acum1[-1] + 0)
acum2.append(acum2[-1] + arr[i])
if n % 2 == 0:
ans = max(acum1[n - 1] - acum1[0], acum2[n] - acum2[1])
for i in range(1, n + 1, 2):
if i + 3 > n:
continue
tmp = (acum1[i] - acum1[0]) + (acum2[n] - acum2[i + 2])
ans = max(ans, tmp)
else:
ans = max(acum1[n - 2] - acum1[0], acum2[n - 1] - acum2[1], acum1[n] - acum1[2])
for i in range(1, n + 1, 2):
if i + 3 > n - 1:
continue
tmp = (acum1[i] - acum1[0]) + (acum2[n - 1] - acum2[i + 2])
ans = max(ans, tmp)
for i in range(2, n + 1, 2):
if i + 3 > n:
continue
tmp = (acum2[i] - acum2[1]) + (acum1[n] - acum1[i + 2])
ans = max(ans, tmp)
for i in range(1, n + 1, 2):
if i + 4 > n:
continue
tmp = (acum1[i] - acum1[0]) + (acum1[n] - acum1[i + 3])
ans = max(ans, tmp)
acummax = [-(10**18)]
for i in range(1, n + 1):
if i + 2 > n:
acummax.append(-(10**18))
else:
if i % 2 == 0:
acummax.append(acum2[i] + acum1[n] - acum1[i + 2])
else:
acummax.append(-(10**18))
for i in range(n - 1, -1, -1):
acummax[i] = max(acummax[i], acummax[i + 1])
for i in range(1, n + 1, 2):
if i + 6 > n:
continue
tmp = (acum1[i] - acum1[0] - acum2[i + 2]) + acummax[i + 3]
ans = max(ans, tmp)
print(ans)
| false | 30.769231 | [
"+acum1 = [0]",
"+acum2 = [0]",
"+for i in range(n):",
"+ if i % 2 == 0:",
"+ acum1.append(acum1[-1] + arr[i])",
"+ acum2.append(acum2[-1] + 0)",
"+ else:",
"+ acum1.append(acum1[-1] + 0)",
"+ acum2.append(acum2[-1] + arr[i])",
"- ans = -(10**18)",
"- dp =... | false | 0.036495 | 0.074719 | 0.488437 | [
"s471805801",
"s136981222"
] |
u977389981 | p03194 | python | s314037362 | s677891201 | 296 | 98 | 2,940 | 3,064 | Accepted | Accepted | 66.89 | n, p = list(map(int, input().split()))
p2 = round(p ** (1 / n))
for i in range(p2, 0, -1):
if p % (i ** n) == 0:
print(i)
break | n, p = list(map(int, input().split()))
def prf(m):
pf = {}
for i in range(2, int(m**0.5)+1):
while m % i == 0:
pf[i] = pf.get(i, 0)+1
m //= i
if m > 1:
pf[m] = 1
return pf
pf = prf(p)
ans = 1
for i in pf:
while pf[i] >= n:
ans *= i
pf[i] -= n
print(ans) | 8 | 21 | 150 | 355 | n, p = list(map(int, input().split()))
p2 = round(p ** (1 / n))
for i in range(p2, 0, -1):
if p % (i**n) == 0:
print(i)
break
| n, p = list(map(int, input().split()))
def prf(m):
pf = {}
for i in range(2, int(m**0.5) + 1):
while m % i == 0:
pf[i] = pf.get(i, 0) + 1
m //= i
if m > 1:
pf[m] = 1
return pf
pf = prf(p)
ans = 1
for i in pf:
while pf[i] >= n:
ans *= i
pf[i] -= n
print(ans)
| false | 61.904762 | [
"-p2 = round(p ** (1 / n))",
"-for i in range(p2, 0, -1):",
"- if p % (i**n) == 0:",
"- print(i)",
"- break",
"+",
"+",
"+def prf(m):",
"+ pf = {}",
"+ for i in range(2, int(m**0.5) + 1):",
"+ while m % i == 0:",
"+ pf[i] = pf.get(i, 0) + 1",
"+ ... | false | 0.042784 | 0.049167 | 0.870167 | [
"s314037362",
"s677891201"
] |
u328510800 | p02831 | python | s239975346 | s209211390 | 51 | 28 | 5,688 | 9,064 | Accepted | Accepted | 45.1 | import fractions
def lcm(x, y):
return (x * y) // fractions.gcd(x, y)
a, b = list(map(int, input().split()))
print((lcm(a, b))) | import math
def lcm(x, y):
return (x * y) // math.gcd(x, y)
a, b = list(map(int, input().split()))
print((lcm(a, b))) | 6 | 8 | 127 | 125 | import fractions
def lcm(x, y):
return (x * y) // fractions.gcd(x, y)
a, b = list(map(int, input().split()))
print((lcm(a, b)))
| import math
def lcm(x, y):
return (x * y) // math.gcd(x, y)
a, b = list(map(int, input().split()))
print((lcm(a, b)))
| false | 25 | [
"-import fractions",
"+import math",
"- return (x * y) // fractions.gcd(x, y)",
"+ return (x * y) // math.gcd(x, y)"
] | false | 0.044627 | 0.034591 | 1.290134 | [
"s239975346",
"s209211390"
] |
u260036763 | p03610 | python | s359953851 | s961359425 | 83 | 37 | 4,596 | 3,188 | Accepted | Accepted | 55.42 | s = input()
for i in range(len(s)):
if i%2 == 0:
print(s[i], end = '')
| s = eval(input())
ans = ''
for i in range(len(s)):
if i % 2 == 0:
ans += s[i]
print(ans) | 4 | 6 | 79 | 93 | s = input()
for i in range(len(s)):
if i % 2 == 0:
print(s[i], end="")
| s = eval(input())
ans = ""
for i in range(len(s)):
if i % 2 == 0:
ans += s[i]
print(ans)
| false | 33.333333 | [
"-s = input()",
"+s = eval(input())",
"+ans = \"\"",
"- print(s[i], end=\"\")",
"+ ans += s[i]",
"+print(ans)"
] | false | 0.08314 | 0.11902 | 0.698538 | [
"s359953851",
"s961359425"
] |
u802963389 | p03045 | python | s286498004 | s485582390 | 536 | 354 | 32,184 | 31,832 | Accepted | Accepted | 33.96 | N, M = list(map(int, input().split()))
XYZ = [list(map(int, input().split())) for _ in range(M)]
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 = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
def size(self, x):
return -self.parents[self.find(x)]
def same(self, x, y):
return self.find(x) == self.find(y)
def members(self, x):
root = self.find(x)
return [i for i in range(self.n) if self.find(i) == root]
def roots(self):
return [i for i, x in enumerate(self.parents) if x < 0]
def group_count(self):
return len(self.roots())
def all_group_members(self):
return {r: self.members(r) for r in self.roots()}
def __str__(self):
return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
uf = UnionFind(N)
for xyz in XYZ:
x, y, z = xyz
uf.union(x - 1, y - 1)
print((uf.group_count()))
| 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 = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
def size(self, x):
return -self.parents[self.find(x)]
def same(self, x, y):
return self.find(x) == self.find(y)
def members(self, x):
root = self.find(x)
return [i for i in range(self.n) if self.find(i) == root]
def roots(self):
return [i for i, x in enumerate(self.parents) if x < 0]
def group_count(self):
return len(self.roots())
def all_group_members(self):
return {r: self.members(r) for r in self.roots()}
def __str__(self):
return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n, m = list(map(int, input().split()))
XYZ = [list(map(int, input().split())) for _ in range(m)]
uf = uf = UnionFind(n)
for x, y, z in XYZ:
x -= 1
y -= 1
uf.union(x, y)
print((uf.group_count())) | 55 | 58 | 1,342 | 1,401 | N, M = list(map(int, input().split()))
XYZ = [list(map(int, input().split())) for _ in range(M)]
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 = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
def size(self, x):
return -self.parents[self.find(x)]
def same(self, x, y):
return self.find(x) == self.find(y)
def members(self, x):
root = self.find(x)
return [i for i in range(self.n) if self.find(i) == root]
def roots(self):
return [i for i, x in enumerate(self.parents) if x < 0]
def group_count(self):
return len(self.roots())
def all_group_members(self):
return {r: self.members(r) for r in self.roots()}
def __str__(self):
return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots())
uf = UnionFind(N)
for xyz in XYZ:
x, y, z = xyz
uf.union(x - 1, y - 1)
print((uf.group_count()))
| 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 = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
def size(self, x):
return -self.parents[self.find(x)]
def same(self, x, y):
return self.find(x) == self.find(y)
def members(self, x):
root = self.find(x)
return [i for i in range(self.n) if self.find(i) == root]
def roots(self):
return [i for i, x in enumerate(self.parents) if x < 0]
def group_count(self):
return len(self.roots())
def all_group_members(self):
return {r: self.members(r) for r in self.roots()}
def __str__(self):
return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots())
n, m = list(map(int, input().split()))
XYZ = [list(map(int, input().split())) for _ in range(m)]
uf = uf = UnionFind(n)
for x, y, z in XYZ:
x -= 1
y -= 1
uf.union(x, y)
print((uf.group_count()))
| false | 5.172414 | [
"-N, M = list(map(int, input().split()))",
"-XYZ = [list(map(int, input().split())) for _ in range(M)]",
"-",
"-",
"-uf = UnionFind(N)",
"-for xyz in XYZ:",
"- x, y, z = xyz",
"- uf.union(x - 1, y - 1)",
"+n, m = list(map(int, input().split()))",
"+XYZ = [list(map(int, input().split())) for ... | false | 0.050413 | 0.108714 | 0.463721 | [
"s286498004",
"s485582390"
] |
u945181840 | p03599 | python | s593708902 | s315148513 | 320 | 66 | 3,064 | 5,316 | Accepted | Accepted | 79.38 | A, B, C, D, E, F = list(map(int, input().split()))
ans = [100 * A, 0]
c = 0
for i in range(1, F // (100 * A) + 1):
for j in range((F - 100 * A * i) // (100 * B) + 1):
a = 100 * A * i + 100 * B * j
for k in range((F - a) // C + 1):
for l in range((F - a - C * k) // D + 1):
b = k * C + l * D
concentration = 100 * b / (a + b)
if (A * i + B * j) * E >= b:
if concentration > c:
c = concentration
ans = [a + b, b]
else:
break
print((' '.join(map(str, ans)))) | A, B, C, D, E, F = list(map(int, input().split()))
water = set([])
for i in range(1, F // (100 * A) + 1):
water1 = i * 100 * A
for j in range((F - water1) // (100 * B) + 1):
water2 = j * 100 * B
water.add(water1 + water2)
ans = [100 * A, 0]
c = 0
for i in water:
max_sugar = min(i // 100 * E, F - i)
sugar = [0]
for j in range(max_sugar // C + 1):
for k in range((max_sugar - j * C) // D + 1):
sugar.append(j * C + k * D)
max_sugar = max(sugar)
concentration = max_sugar / (i + max_sugar)
if c < concentration:
c = concentration
ans = [i + max_sugar, max_sugar]
print((' '.join(map(str, ans)))) | 19 | 25 | 651 | 698 | A, B, C, D, E, F = list(map(int, input().split()))
ans = [100 * A, 0]
c = 0
for i in range(1, F // (100 * A) + 1):
for j in range((F - 100 * A * i) // (100 * B) + 1):
a = 100 * A * i + 100 * B * j
for k in range((F - a) // C + 1):
for l in range((F - a - C * k) // D + 1):
b = k * C + l * D
concentration = 100 * b / (a + b)
if (A * i + B * j) * E >= b:
if concentration > c:
c = concentration
ans = [a + b, b]
else:
break
print((" ".join(map(str, ans))))
| A, B, C, D, E, F = list(map(int, input().split()))
water = set([])
for i in range(1, F // (100 * A) + 1):
water1 = i * 100 * A
for j in range((F - water1) // (100 * B) + 1):
water2 = j * 100 * B
water.add(water1 + water2)
ans = [100 * A, 0]
c = 0
for i in water:
max_sugar = min(i // 100 * E, F - i)
sugar = [0]
for j in range(max_sugar // C + 1):
for k in range((max_sugar - j * C) // D + 1):
sugar.append(j * C + k * D)
max_sugar = max(sugar)
concentration = max_sugar / (i + max_sugar)
if c < concentration:
c = concentration
ans = [i + max_sugar, max_sugar]
print((" ".join(map(str, ans))))
| false | 24 | [
"+water = set([])",
"+for i in range(1, F // (100 * A) + 1):",
"+ water1 = i * 100 * A",
"+ for j in range((F - water1) // (100 * B) + 1):",
"+ water2 = j * 100 * B",
"+ water.add(water1 + water2)",
"-for i in range(1, F // (100 * A) + 1):",
"- for j in range((F - 100 * A * i) /... | false | 0.078213 | 0.055989 | 1.396938 | [
"s593708902",
"s315148513"
] |
u139112865 | p03986 | python | s808597830 | s162731953 | 109 | 78 | 3,500 | 5,088 | Accepted | Accepted | 28.44 | s = input()[::-1]
n = len(s)
tmp = 0
ans = 0
for i in range(n):
if s[i] == 'S':
tmp += 1
else:
tmp -= 1
ans = max(ans, tmp)
print((ans * 2)) | from collections import deque
s = eval(input())
n = len(s)
que = deque()
for i in range(n):
if s[i] == 'S':
que.append(s[i])
else:
if len(que) == 0:
que.append(s[i])
elif que[-1] == 'T':
que.append(s[i])
else:
que.pop()
print((len(que))) | 12 | 17 | 178 | 327 | s = input()[::-1]
n = len(s)
tmp = 0
ans = 0
for i in range(n):
if s[i] == "S":
tmp += 1
else:
tmp -= 1
ans = max(ans, tmp)
print((ans * 2))
| from collections import deque
s = eval(input())
n = len(s)
que = deque()
for i in range(n):
if s[i] == "S":
que.append(s[i])
else:
if len(que) == 0:
que.append(s[i])
elif que[-1] == "T":
que.append(s[i])
else:
que.pop()
print((len(que)))
| false | 29.411765 | [
"-s = input()[::-1]",
"+from collections import deque",
"+",
"+s = eval(input())",
"-tmp = 0",
"-ans = 0",
"+que = deque()",
"- tmp += 1",
"+ que.append(s[i])",
"- tmp -= 1",
"- ans = max(ans, tmp)",
"-print((ans * 2))",
"+ if len(que) == 0:",
"+ q... | false | 0.035697 | 0.036452 | 0.979289 | [
"s808597830",
"s162731953"
] |
u595905528 | p02762 | python | s143782782 | s926299908 | 1,598 | 1,121 | 62,528 | 48,100 | Accepted | Accepted | 29.85 | def main():
import sys
sys.setrecursionlimit(10**5+10)
N, M, K = list(map(int,input().split()))
class UnionFind:
def __init__(self, N):
self.par = [-1 for i in range(N+1)]
self.rank = [1]*(N+1)
def find(self, x):
if self.par[x] < 0:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
def same_check(self, x, y):
return self.find(x) == self.find(y)
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if self.rank[x] > self.rank[y]:
self.par[x] += self.par[y]
self.par[y] = x
else:
self.par[y] += self.par[x]
self.par[x] = y
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
UF = UnionFind(N)
friendlist = [[] for _ in range(N+1)]
for n in range(M):
A, B = list(map(int,input().split()))
friendlist[A].append(B)
friendlist[B].append(A)
if not UF.same_check(A,B):
UF.union(A, B)
blocklist = [[] for _ in range(N+1)]
for n in range(K):
C, D = list(map(int, input().split()))
blocklist[C].append(D)
blocklist[D].append(C)
for person in range(1,N+1):
root = UF.find(person)
ans = -UF.par[root]-1
ans -= len(friendlist[person])
for l in blocklist[person]:
if UF.same_check(person,l):
ans -= 1
print(ans)
if __name__ == '__main__':
main()
| from collections import deque
N, M, K = list(map(int,input().split()))
friendlist = [[] for _ in range(N+1)]
for n in range(M):
A, B = list(map(int,input().split()))
friendlist[A].append(B)
friendlist[B].append(A)
blocklist = [[] for _ in range(N+1)]
for n in range(K):
C, D = list(map(int, input().split()))
blocklist[C].append(D)
blocklist[D].append(C)
whatgroup = [-1 for _ in range(N+1)]
visited = [-1] * (N+1)
d = deque()
leaderdic = {}
for person in range(1,N+1):
d.append(person)
leader = person
cnt = 0
while len(d)>0:
nowwho = d.popleft()
if whatgroup[nowwho] != -1:
continue
d.extend(friendlist[nowwho])
whatgroup[nowwho] = leader
cnt += 1
if cnt != 0:
leaderdic[leader] = cnt
for person in range(1,N+1):
ans = leaderdic[whatgroup[person]]
ans -= 1
ans -= len(friendlist[person])
for block in blocklist[person]:
if whatgroup[person]==whatgroup[block]:
ans -= 1
print(ans) | 57 | 39 | 1,575 | 1,047 | def main():
import sys
sys.setrecursionlimit(10**5 + 10)
N, M, K = list(map(int, input().split()))
class UnionFind:
def __init__(self, N):
self.par = [-1 for i in range(N + 1)]
self.rank = [1] * (N + 1)
def find(self, x):
if self.par[x] < 0:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
def same_check(self, x, y):
return self.find(x) == self.find(y)
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if self.rank[x] > self.rank[y]:
self.par[x] += self.par[y]
self.par[y] = x
else:
self.par[y] += self.par[x]
self.par[x] = y
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
UF = UnionFind(N)
friendlist = [[] for _ in range(N + 1)]
for n in range(M):
A, B = list(map(int, input().split()))
friendlist[A].append(B)
friendlist[B].append(A)
if not UF.same_check(A, B):
UF.union(A, B)
blocklist = [[] for _ in range(N + 1)]
for n in range(K):
C, D = list(map(int, input().split()))
blocklist[C].append(D)
blocklist[D].append(C)
for person in range(1, N + 1):
root = UF.find(person)
ans = -UF.par[root] - 1
ans -= len(friendlist[person])
for l in blocklist[person]:
if UF.same_check(person, l):
ans -= 1
print(ans)
if __name__ == "__main__":
main()
| from collections import deque
N, M, K = list(map(int, input().split()))
friendlist = [[] for _ in range(N + 1)]
for n in range(M):
A, B = list(map(int, input().split()))
friendlist[A].append(B)
friendlist[B].append(A)
blocklist = [[] for _ in range(N + 1)]
for n in range(K):
C, D = list(map(int, input().split()))
blocklist[C].append(D)
blocklist[D].append(C)
whatgroup = [-1 for _ in range(N + 1)]
visited = [-1] * (N + 1)
d = deque()
leaderdic = {}
for person in range(1, N + 1):
d.append(person)
leader = person
cnt = 0
while len(d) > 0:
nowwho = d.popleft()
if whatgroup[nowwho] != -1:
continue
d.extend(friendlist[nowwho])
whatgroup[nowwho] = leader
cnt += 1
if cnt != 0:
leaderdic[leader] = cnt
for person in range(1, N + 1):
ans = leaderdic[whatgroup[person]]
ans -= 1
ans -= len(friendlist[person])
for block in blocklist[person]:
if whatgroup[person] == whatgroup[block]:
ans -= 1
print(ans)
| false | 31.578947 | [
"-def main():",
"- import sys",
"+from collections import deque",
"- sys.setrecursionlimit(10**5 + 10)",
"- N, M, K = list(map(int, input().split()))",
"-",
"- class UnionFind:",
"- def __init__(self, N):",
"- self.par = [-1 for i in range(N + 1)]",
"- self... | false | 0.047651 | 0.046813 | 1.017903 | [
"s143782782",
"s926299908"
] |
u707498674 | p03107 | python | s039718497 | s537443612 | 185 | 72 | 6,680 | 4,212 | Accepted | Accepted | 61.08 | from collections import deque
import copy
S = deque(eval(input()))
S2 = deque([])
counter = 0
while True:
flag = True
while True:
if len(S) == 0:
break
s = S.popleft()
if len(S2) == 0:
S2.append(s)
flag = False
continue
elif s!=S2[-1]:
S2.pop()
flag = False
counter +=2
else:
S2.append(s)
if flag:
break
else:
S = copy.deepcopy(S2)
print(counter) | from collections import deque
S = deque(eval(input()))
S2 = deque([])
counter = 0
flag = True
while True:
if len(S) == 0:
break
s = S.popleft()
if len(S2) == 0:
S2.append(s)
flag = False
continue
elif s!=S2[-1]:
S2.pop()
flag = False
counter +=2
else:
S2.append(s)
if flag:
break
print(counter) | 28 | 23 | 549 | 435 | from collections import deque
import copy
S = deque(eval(input()))
S2 = deque([])
counter = 0
while True:
flag = True
while True:
if len(S) == 0:
break
s = S.popleft()
if len(S2) == 0:
S2.append(s)
flag = False
continue
elif s != S2[-1]:
S2.pop()
flag = False
counter += 2
else:
S2.append(s)
if flag:
break
else:
S = copy.deepcopy(S2)
print(counter)
| from collections import deque
S = deque(eval(input()))
S2 = deque([])
counter = 0
flag = True
while True:
if len(S) == 0:
break
s = S.popleft()
if len(S2) == 0:
S2.append(s)
flag = False
continue
elif s != S2[-1]:
S2.pop()
flag = False
counter += 2
else:
S2.append(s)
if flag:
break
print(counter)
| false | 17.857143 | [
"-import copy",
"+flag = True",
"- flag = True",
"- while True:",
"- if len(S) == 0:",
"- break",
"- s = S.popleft()",
"- if len(S2) == 0:",
"- S2.append(s)",
"- flag = False",
"- continue",
"- elif s != S2[-1]:",
... | false | 0.045546 | 0.061835 | 0.736575 | [
"s039718497",
"s537443612"
] |
u125545880 | p04045 | python | s541923154 | s501707777 | 86 | 26 | 9,144 | 9,252 | Accepted | Accepted | 69.77 | def main():
N, K = list(map(int, input().split()))
D = set(map(int, input().split()))
numset = set(range(0,10))
d = numset.difference(D)
for n in range(N, pow(10, 6) + 10):
check = set(list(str(n)))
ngflag = False
for i in check:
if int(i) in D:
ngflag = True
break
if not ngflag:
break
print(n)
if __name__ == "__main__":
main()
| def minN(N:int, usable:list, restrict=True):
usable.sort()
keta = False
if restrict:
for i in usable:
if i >= N:
return str(i)
# 桁が増える
return '1'+str(usable[0])
else:
return str(usable[0])
def rote(N:list, D:set, d:set):
ans = []
flag = True
lenNstr = len(N)
for i, n in enumerate(N):
n = int(n)
keta = 10**(len(N) - i - 1)
if flag:
if n in D:
ans.append(int(minN(n, d)) * keta)
flag = False
else:
ans.append(keta * n)
else:
ans.append(keta * min(d))
return sum(ans)
def main():
N, K = list(map(int, input().split()))
D = set(map(int, input().split()))
numset = set(range(0,10))
d = list(numset.difference(D))
d.sort()
for _ in range(10):
Nstr = list(str(N))
ans = rote(Nstr, D, d)
N = ans
print(ans)
if __name__ == "__main__":
main()
| 19 | 43 | 460 | 1,046 | def main():
N, K = list(map(int, input().split()))
D = set(map(int, input().split()))
numset = set(range(0, 10))
d = numset.difference(D)
for n in range(N, pow(10, 6) + 10):
check = set(list(str(n)))
ngflag = False
for i in check:
if int(i) in D:
ngflag = True
break
if not ngflag:
break
print(n)
if __name__ == "__main__":
main()
| def minN(N: int, usable: list, restrict=True):
usable.sort()
keta = False
if restrict:
for i in usable:
if i >= N:
return str(i)
# 桁が増える
return "1" + str(usable[0])
else:
return str(usable[0])
def rote(N: list, D: set, d: set):
ans = []
flag = True
lenNstr = len(N)
for i, n in enumerate(N):
n = int(n)
keta = 10 ** (len(N) - i - 1)
if flag:
if n in D:
ans.append(int(minN(n, d)) * keta)
flag = False
else:
ans.append(keta * n)
else:
ans.append(keta * min(d))
return sum(ans)
def main():
N, K = list(map(int, input().split()))
D = set(map(int, input().split()))
numset = set(range(0, 10))
d = list(numset.difference(D))
d.sort()
for _ in range(10):
Nstr = list(str(N))
ans = rote(Nstr, D, d)
N = ans
print(ans)
if __name__ == "__main__":
main()
| false | 55.813953 | [
"+def minN(N: int, usable: list, restrict=True):",
"+ usable.sort()",
"+ keta = False",
"+ if restrict:",
"+ for i in usable:",
"+ if i >= N:",
"+ return str(i)",
"+ # 桁が増える",
"+ return \"1\" + str(usable[0])",
"+ else:",
"+ retur... | false | 0.084523 | 0.043664 | 1.935732 | [
"s541923154",
"s501707777"
] |
u315078622 | p02915 | python | s933071871 | s634641551 | 171 | 25 | 38,256 | 9,080 | Accepted | Accepted | 85.38 | N = int(eval(input()))
print((N**3))
| def main() -> None:
print((int(eval(input())) ** 3))
if __name__ == '__main__':
main()
| 2 | 6 | 30 | 94 | N = int(eval(input()))
print((N**3))
| def main() -> None:
print((int(eval(input())) ** 3))
if __name__ == "__main__":
main()
| false | 66.666667 | [
"-N = int(eval(input()))",
"-print((N**3))",
"+def main() -> None:",
"+ print((int(eval(input())) ** 3))",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.035687 | 0.041721 | 0.855356 | [
"s933071871",
"s634641551"
] |
u832039789 | p02916 | python | s675350988 | s105577520 | 51 | 18 | 5,712 | 3,060 | Accepted | Accepted | 64.71 | import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
if f:
print('Yes')
else:
print('No')
def Y(f):
if f:
print('YES')
else:
print('NO')
n = int(eval(input()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
res = 0
for i in a:
res += b[i - 1]
for i, j in zip(a, a[1:]):
if j == i + 1:
res += c[i - 1]
print(res) | n = int(eval(input()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
res = sum(b)
for i in range(n - 1):
if a[i] + 1 == a[i + 1]:
res += c[a[i] - 1]
print(res)
| 30 | 10 | 681 | 235 | import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
if f:
print("Yes")
else:
print("No")
def Y(f):
if f:
print("YES")
else:
print("NO")
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
res = 0
for i in a:
res += b[i - 1]
for i, j in zip(a, a[1:]):
if j == i + 1:
res += c[i - 1]
print(res)
| n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
res = sum(b)
for i in range(n - 1):
if a[i] + 1 == a[i + 1]:
res += c[a[i] - 1]
print(res)
| false | 66.666667 | [
"-import sys",
"-from fractions import gcd",
"-from itertools import groupby as gb",
"-from itertools import permutations as perm",
"-from itertools import combinations as comb",
"-from collections import Counter as C",
"-from collections import defaultdict as dd",
"-",
"-sys.setrecursionlimit(10**5... | false | 0.036101 | 0.035731 | 1.010341 | [
"s675350988",
"s105577520"
] |
u057109575 | p02661 | python | s950842158 | s300085390 | 445 | 375 | 116,524 | 104,864 | Accepted | Accepted | 15.73 | N = int(eval(input()))
X = [list(map(int, input().split())) for _ in range(N)]
lb = sorted(v for v, _ in X)
ub = sorted(v for _, v in X)
if N % 2 == 0:
l = lb[N // 2 - 1] + lb[N // 2]
u = ub[N // 2 - 1] + ub[N // 2]
print((u - l + 1))
else:
l = lb[N // 2]
u = ub[N // 2]
print((u - l + 1)) |
N = int(eval(input()))
A = []
B = []
for _ in range(N):
a, b = list(map(int, input().split()))
A.append(a)
B.append(b)
A.sort()
B.sort()
if N % 2 == 0:
l = A[N // 2 - 1] + A[N // 2]
u = B[N // 2 - 1] + B[N // 2]
print((u - l + 1))
else:
l = A[N // 2]
u = B[N // 2]
print((u - l + 1))
| 14 | 20 | 318 | 326 | N = int(eval(input()))
X = [list(map(int, input().split())) for _ in range(N)]
lb = sorted(v for v, _ in X)
ub = sorted(v for _, v in X)
if N % 2 == 0:
l = lb[N // 2 - 1] + lb[N // 2]
u = ub[N // 2 - 1] + ub[N // 2]
print((u - l + 1))
else:
l = lb[N // 2]
u = ub[N // 2]
print((u - l + 1))
| N = int(eval(input()))
A = []
B = []
for _ in range(N):
a, b = list(map(int, input().split()))
A.append(a)
B.append(b)
A.sort()
B.sort()
if N % 2 == 0:
l = A[N // 2 - 1] + A[N // 2]
u = B[N // 2 - 1] + B[N // 2]
print((u - l + 1))
else:
l = A[N // 2]
u = B[N // 2]
print((u - l + 1))
| false | 30 | [
"-X = [list(map(int, input().split())) for _ in range(N)]",
"-lb = sorted(v for v, _ in X)",
"-ub = sorted(v for _, v in X)",
"+A = []",
"+B = []",
"+for _ in range(N):",
"+ a, b = list(map(int, input().split()))",
"+ A.append(a)",
"+ B.append(b)",
"+A.sort()",
"+B.sort()",
"- l = ... | false | 0.04029 | 0.106734 | 0.377481 | [
"s950842158",
"s300085390"
] |
u312025627 | p03599 | python | s619961686 | s617751055 | 393 | 27 | 3,064 | 3,188 | Accepted | Accepted | 93.13 | def main():
A, B, C, D, E, F = (int(i) for i in input().split())
water = set()
for a in range(0,F+1,100*A):
for b in range(0,F+1,100*B):
if a + b != 0 and a+b <= F:
water.add(a+b)
max_consist = 0
ans = (0,0)
for w in water:
ab = w //100
sugar_max = E * ab
x = sugar_max // C
y = sugar_max // D
s = max(C*i + D*j for i in range(x+1) for j in range(y+1) if C*i + D*j <= sugar_max and w + C*i + D*j <= F)
if w + s <= F:
cur_consist = (100*s)/(w+s)
if max_consist <= cur_consist:
max_consist = cur_consist
ans = (w + s,s)
print((*ans))
if __name__ == '__main__':
main() | #提出 #6036238 参考
def main():
A, B, C, D, E, F = (int(i) for i in input().split())
WF = F//100
water = [False] * (WF + 1)
water[0] = True
#30
for n in range(WF + 1):
if water[n]:
if n+A <= WF: water[n+A] = True
if n+B <= WF: water[n+B] = True
sugar = [False] * (F + 1)
sugar[0] = True
#3000
for n in range(F + 1):
if sugar[n]:
if n+C <= F: sugar[n+C] = True
if n+D <= F: sugar[n+D] = True
water = set(100*x for x in range(1,1+WF) if water[x]) #0除算を避け、かつ水の量0はありえないのでrange(1,1+WF)
sugar = set(x for x in range(1+F) if sugar[x]) #砂糖0gでも、濃度0%の砂糖水
max_consist = -1
ans = (0,0)
#at most 30*3000
for w in water:
for s in sugar:
if s <= w//100 * E and w + s <= F: #sがwに溶け残らない、かつwとsがビーカーに入り切る
cur_consist = (100*s)/(w+s)
if max_consist < cur_consist:
max_consist = cur_consist
ans = (w + s,s)
print((*ans))
if __name__ == '__main__':
main() | 26 | 38 | 763 | 1,098 | def main():
A, B, C, D, E, F = (int(i) for i in input().split())
water = set()
for a in range(0, F + 1, 100 * A):
for b in range(0, F + 1, 100 * B):
if a + b != 0 and a + b <= F:
water.add(a + b)
max_consist = 0
ans = (0, 0)
for w in water:
ab = w // 100
sugar_max = E * ab
x = sugar_max // C
y = sugar_max // D
s = max(
C * i + D * j
for i in range(x + 1)
for j in range(y + 1)
if C * i + D * j <= sugar_max and w + C * i + D * j <= F
)
if w + s <= F:
cur_consist = (100 * s) / (w + s)
if max_consist <= cur_consist:
max_consist = cur_consist
ans = (w + s, s)
print((*ans))
if __name__ == "__main__":
main()
| # 提出 #6036238 参考
def main():
A, B, C, D, E, F = (int(i) for i in input().split())
WF = F // 100
water = [False] * (WF + 1)
water[0] = True
# 30
for n in range(WF + 1):
if water[n]:
if n + A <= WF:
water[n + A] = True
if n + B <= WF:
water[n + B] = True
sugar = [False] * (F + 1)
sugar[0] = True
# 3000
for n in range(F + 1):
if sugar[n]:
if n + C <= F:
sugar[n + C] = True
if n + D <= F:
sugar[n + D] = True
water = set(
100 * x for x in range(1, 1 + WF) if water[x]
) # 0除算を避け、かつ水の量0はありえないのでrange(1,1+WF)
sugar = set(x for x in range(1 + F) if sugar[x]) # 砂糖0gでも、濃度0%の砂糖水
max_consist = -1
ans = (0, 0)
# at most 30*3000
for w in water:
for s in sugar:
if s <= w // 100 * E and w + s <= F: # sがwに溶け残らない、かつwとsがビーカーに入り切る
cur_consist = (100 * s) / (w + s)
if max_consist < cur_consist:
max_consist = cur_consist
ans = (w + s, s)
print((*ans))
if __name__ == "__main__":
main()
| false | 31.578947 | [
"+# 提出 #6036238 参考",
"- water = set()",
"- for a in range(0, F + 1, 100 * A):",
"- for b in range(0, F + 1, 100 * B):",
"- if a + b != 0 and a + b <= F:",
"- water.add(a + b)",
"- max_consist = 0",
"+ WF = F // 100",
"+ water = [False] * (WF + 1)",
"... | false | 0.139406 | 0.038658 | 3.606158 | [
"s619961686",
"s617751055"
] |
u633255271 | p02614 | python | s305297546 | s186744124 | 174 | 84 | 74,752 | 74,096 | Accepted | Accepted | 51.72 | from itertools import product
from copy import deepcopy
H, W, K = list(map(int, input().split()))
board = [list(eval(input())) for _ in range(H)]
ans = 0
for row in product(['.', '%'], repeat=H):
if row == tuple(['%']*H):
continue
tmp1 = deepcopy(board)
for h in range(H):
if row[h] == '%':
tmp1[h] = ['%']*W
for col in product(['.', '%'], repeat=W):
if col == tuple(['%']*W):
continue
tmp2 = deepcopy(tmp1)
for w in range(W):
if col[w] == '%':
for h in range(H):
tmp2[h][w] = '%'
if sum(tmp2, []).count('#') == K:
ans += 1
print(ans)
| from itertools import product
H, W, K = list(map(int, input().split()))
# 黒なら1
board = [[1 if x == '#' else 0 for x in list(eval(input()))] for _ in range(H)]
ans = 0
# 塗らないなら1
for row in product([0, 1], repeat=H):
for col in product([0, 1], repeat=W):
# 元が黒でタテヨコ塗らないマスを数える
blacks = sum([board[h][w] * row[h] * col[w] for h in range(H) for w in range(W)])
if blacks == K:
ans += 1
print(ans)
| 25 | 15 | 703 | 442 | from itertools import product
from copy import deepcopy
H, W, K = list(map(int, input().split()))
board = [list(eval(input())) for _ in range(H)]
ans = 0
for row in product([".", "%"], repeat=H):
if row == tuple(["%"] * H):
continue
tmp1 = deepcopy(board)
for h in range(H):
if row[h] == "%":
tmp1[h] = ["%"] * W
for col in product([".", "%"], repeat=W):
if col == tuple(["%"] * W):
continue
tmp2 = deepcopy(tmp1)
for w in range(W):
if col[w] == "%":
for h in range(H):
tmp2[h][w] = "%"
if sum(tmp2, []).count("#") == K:
ans += 1
print(ans)
| from itertools import product
H, W, K = list(map(int, input().split()))
# 黒なら1
board = [[1 if x == "#" else 0 for x in list(eval(input()))] for _ in range(H)]
ans = 0
# 塗らないなら1
for row in product([0, 1], repeat=H):
for col in product([0, 1], repeat=W):
# 元が黒でタテヨコ塗らないマスを数える
blacks = sum(
[board[h][w] * row[h] * col[w] for h in range(H) for w in range(W)]
)
if blacks == K:
ans += 1
print(ans)
| false | 40 | [
"-from copy import deepcopy",
"-board = [list(eval(input())) for _ in range(H)]",
"+# 黒なら1",
"+board = [[1 if x == \"#\" else 0 for x in list(eval(input()))] for _ in range(H)]",
"-for row in product([\".\", \"%\"], repeat=H):",
"- if row == tuple([\"%\"] * H):",
"- continue",
"- tmp1 = d... | false | 0.048357 | 0.046667 | 1.036223 | [
"s305297546",
"s186744124"
] |
u377989038 | p02615 | python | s764739085 | s258451060 | 143 | 113 | 31,392 | 31,620 | Accepted | Accepted | 20.98 | n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
cnt = a.pop()
tmp = a.pop()
l = 0
for i in range(n - 2):
if l == 2:
l = 0
tmp = a.pop()
cnt += tmp
l += 1
print(cnt) | n = int(eval(input()))
a = sorted(list(map(int, input().split())))[::-1]
print((a[0] + sum(a[1:n // 2]) * 2 + sum(a[n // 2:n // 2 + n % 2]))) | 14 | 3 | 220 | 135 | n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
cnt = a.pop()
tmp = a.pop()
l = 0
for i in range(n - 2):
if l == 2:
l = 0
tmp = a.pop()
cnt += tmp
l += 1
print(cnt)
| n = int(eval(input()))
a = sorted(list(map(int, input().split())))[::-1]
print((a[0] + sum(a[1 : n // 2]) * 2 + sum(a[n // 2 : n // 2 + n % 2])))
| false | 78.571429 | [
"-a = list(map(int, input().split()))",
"-a.sort()",
"-cnt = a.pop()",
"-tmp = a.pop()",
"-l = 0",
"-for i in range(n - 2):",
"- if l == 2:",
"- l = 0",
"- tmp = a.pop()",
"- cnt += tmp",
"- l += 1",
"-print(cnt)",
"+a = sorted(list(map(int, input().split())))[::-1]",
... | false | 0.041199 | 0.041483 | 0.993159 | [
"s764739085",
"s258451060"
] |
u071680334 | p02775 | python | s027205564 | s122472167 | 948 | 612 | 5,492 | 11,076 | Accepted | Accepted | 35.44 | def main():
s = input().rstrip()
s = "0" + s
dp = [0, float("inf")]
for c in s:
x = int(c)
dp = [min(dp[0] + x, dp[1] + (10-x)), min(dp[0] + x+1, dp[1] + (10-x) - 1)]
print((dp[0]))
if __name__ == "__main__":
main()
| def main():
s = eval(input())
dp = [0, 1]
for c in s:
x = int(c)
a = dp[0] + x
if a > dp[1] + 10 - x:
a = dp[1] + 10 - x
b = dp[0] + x + 1
if b > dp[1] + 10 - x - 1:
b = dp[1] + 10 - x - 1
dp[0] = a
dp[1] = b
dp[1] += 1
print((min(dp)))
if __name__ == "__main__":
main()
| 11 | 18 | 265 | 385 | def main():
s = input().rstrip()
s = "0" + s
dp = [0, float("inf")]
for c in s:
x = int(c)
dp = [
min(dp[0] + x, dp[1] + (10 - x)),
min(dp[0] + x + 1, dp[1] + (10 - x) - 1),
]
print((dp[0]))
if __name__ == "__main__":
main()
| def main():
s = eval(input())
dp = [0, 1]
for c in s:
x = int(c)
a = dp[0] + x
if a > dp[1] + 10 - x:
a = dp[1] + 10 - x
b = dp[0] + x + 1
if b > dp[1] + 10 - x - 1:
b = dp[1] + 10 - x - 1
dp[0] = a
dp[1] = b
dp[1] += 1
print((min(dp)))
if __name__ == "__main__":
main()
| false | 38.888889 | [
"- s = input().rstrip()",
"- s = \"0\" + s",
"- dp = [0, float(\"inf\")]",
"+ s = eval(input())",
"+ dp = [0, 1]",
"- dp = [",
"- min(dp[0] + x, dp[1] + (10 - x)),",
"- min(dp[0] + x + 1, dp[1] + (10 - x) - 1),",
"- ]",
"- print((dp[0]))",
"+... | false | 0.035404 | 0.035819 | 0.988435 | [
"s027205564",
"s122472167"
] |
u054556734 | p02678 | python | s469848356 | s332796144 | 923 | 726 | 76,536 | 64,248 | Accepted | Accepted | 21.34 | import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return list(map(int, sinput().split()))
def fmap(): return list(map(float, sinput().split()))
def iarr(): return list(map())
def farr(): return list(fmap())
def sarr(): return sinput().split()
#標準入力
n,m = map()
ab = np.array([iarr() for i in range(m)])
a,b = ab.T[0]-1, ab.T[1]-1
#隣接行列はnumpy使うな
g = [[] for i in range(n)]
for aa,bb in zip(a,b):
g[aa].append(bb)
g[bb].append(aa)
anss = [0]*n
know = [0]*n; know[0] = 1
q = col.deque([0])
while q:
now = q.popleft()
for next in g[now]:
if know[next]: continue
else: know[next] = 1; anss[next] = now; q.append(next)
print('Yes')
for ans in anss[1:]: print((ans+1))
| import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return list(map(int, sinput().split()))
def fmap(): return list(map(float, sinput().split()))
def iarr(n=0):
if n: return [0 for _ in range(n)]
else: return list(map())
def farr(): return list(fmap())
def sarr(n=0):
if n: return ["" for _ in range(n)]
else: return sinput().split()
def barr(n): return [False for _ in range(n)]
n,m = map()
g = [[] for i in range(n+1)]
for i in range(m):
a,b = map()
g[a].append(b)
g[b].append(a)
q = col.deque([1])
know = barr(n+1); know[1] = True
anss = iarr(n+1)
while q:
now = q.popleft()
for next in g[now]:
if know[next]: continue
else: know[next] = True; q.append(next); anss[next] = now
print("Yes")
for ans in anss[2:]: print(ans)
| 44 | 42 | 990 | 1,068 | import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput():
return sys.stdin.readline()
def iinput():
return int(sinput())
def imap():
return list(map(int, sinput().split()))
def fmap():
return list(map(float, sinput().split()))
def iarr():
return list(map())
def farr():
return list(fmap())
def sarr():
return sinput().split()
# 標準入力
n, m = map()
ab = np.array([iarr() for i in range(m)])
a, b = ab.T[0] - 1, ab.T[1] - 1
# 隣接行列はnumpy使うな
g = [[] for i in range(n)]
for aa, bb in zip(a, b):
g[aa].append(bb)
g[bb].append(aa)
anss = [0] * n
know = [0] * n
know[0] = 1
q = col.deque([0])
while q:
now = q.popleft()
for next in g[now]:
if know[next]:
continue
else:
know[next] = 1
anss[next] = now
q.append(next)
print("Yes")
for ans in anss[1:]:
print((ans + 1))
| import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput():
return sys.stdin.readline()
def iinput():
return int(sinput())
def imap():
return list(map(int, sinput().split()))
def fmap():
return list(map(float, sinput().split()))
def iarr(n=0):
if n:
return [0 for _ in range(n)]
else:
return list(map())
def farr():
return list(fmap())
def sarr(n=0):
if n:
return ["" for _ in range(n)]
else:
return sinput().split()
def barr(n):
return [False for _ in range(n)]
n, m = map()
g = [[] for i in range(n + 1)]
for i in range(m):
a, b = map()
g[a].append(b)
g[b].append(a)
q = col.deque([1])
know = barr(n + 1)
know[1] = True
anss = iarr(n + 1)
while q:
now = q.popleft()
for next in g[now]:
if know[next]:
continue
else:
know[next] = True
q.append(next)
anss[next] = now
print("Yes")
for ans in anss[2:]:
print(ans)
| false | 4.545455 | [
"-def iarr():",
"- return list(map())",
"+def iarr(n=0):",
"+ if n:",
"+ return [0 for _ in range(n)]",
"+ else:",
"+ return list(map())",
"-def sarr():",
"- return sinput().split()",
"+def sarr(n=0):",
"+ if n:",
"+ return [\"\" for _ in range(n)]",
"+ ... | false | 0.316024 | 0.073589 | 4.294448 | [
"s469848356",
"s332796144"
] |
u614181788 | p03227 | python | s690210406 | s315694103 | 26 | 24 | 8,916 | 8,816 | Accepted | Accepted | 7.69 | s = eval(input())
if len(s) == 2:
print(s)
else:
print((s[::-1])) | s = list(eval(input()))
if len(s) == 2:
print(("".join(s)))
else:
print(("".join(s[::-1]))) | 5 | 5 | 69 | 93 | s = eval(input())
if len(s) == 2:
print(s)
else:
print((s[::-1]))
| s = list(eval(input()))
if len(s) == 2:
print(("".join(s)))
else:
print(("".join(s[::-1])))
| false | 0 | [
"-s = eval(input())",
"+s = list(eval(input()))",
"- print(s)",
"+ print((\"\".join(s)))",
"- print((s[::-1]))",
"+ print((\"\".join(s[::-1])))"
] | false | 0.046442 | 0.105177 | 0.441565 | [
"s690210406",
"s315694103"
] |
u314050667 | p03290 | python | s119126291 | s722726858 | 65 | 22 | 3,188 | 3,188 | Accepted | Accepted | 66.15 | D, G = list(map(int, input().split()))
def Base_10_to_n(X, n):
X_dumy = X
out = ''
while X_dumy>0:
out = str(X_dumy%n)+out
X_dumy = int(X_dumy/n)
return out
p = []
c = []
for _ in range(D):
p_tmp, c_tmp = list(map(int,input().split()))
p.append(p_tmp)
c.append(c_tmp)
t = [(i+1)*100*p[i] + c[i] for i in range(D)]
ans = float("inf")
for i in range(2**D):
flg = list(map(int, Base_10_to_n(i,2).rjust(D,"0")))
tmp_score = sum([t[j] for j in range(D) if flg[j] == 1])
cnt = sum([p[j] for j in range(D) if flg[j] == 1])
if tmp_score < G:
rst_max_q = max([j for j in range(D) if flg[j] == 0])
rst_q_num = 0
while rst_q_num < p[rst_max_q]:
tmp_score += 100*(rst_max_q+1)
rst_q_num += 1
cnt += 1
if tmp_score >= G:
break
if tmp_score < G:
continue
ans = min(ans, cnt)
print(ans) | import itertools
D,G = list(map(int, input().split()))
PC = [list(map(int, input().split())) for _ in range(D)]
P_list = list(range(D))
cnt = float('inf')
for i in range(D):
for bonus in itertools.combinations(P_list, i):
tmp_cnt = 0
score = 0
for j in bonus:
score += PC[j][0] * 100 * (j+1) + PC[j][1]
tmp_cnt += PC[j][0]
res_max_p = max([k for k in range(D) if k not in bonus])
res_score = G - score
if res_score > 0:
t = (-res_score//((res_max_p+1)*100)) * (-1)
if t < PC[res_max_p][0]:
tmp_cnt += t
else:
continue
cnt = min(cnt, tmp_cnt)
if cnt == float('inf'):
cnt = sum([PC[j][0] for j in range(D)])
print(cnt)
| 44 | 35 | 880 | 696 | D, G = list(map(int, input().split()))
def Base_10_to_n(X, n):
X_dumy = X
out = ""
while X_dumy > 0:
out = str(X_dumy % n) + out
X_dumy = int(X_dumy / n)
return out
p = []
c = []
for _ in range(D):
p_tmp, c_tmp = list(map(int, input().split()))
p.append(p_tmp)
c.append(c_tmp)
t = [(i + 1) * 100 * p[i] + c[i] for i in range(D)]
ans = float("inf")
for i in range(2**D):
flg = list(map(int, Base_10_to_n(i, 2).rjust(D, "0")))
tmp_score = sum([t[j] for j in range(D) if flg[j] == 1])
cnt = sum([p[j] for j in range(D) if flg[j] == 1])
if tmp_score < G:
rst_max_q = max([j for j in range(D) if flg[j] == 0])
rst_q_num = 0
while rst_q_num < p[rst_max_q]:
tmp_score += 100 * (rst_max_q + 1)
rst_q_num += 1
cnt += 1
if tmp_score >= G:
break
if tmp_score < G:
continue
ans = min(ans, cnt)
print(ans)
| import itertools
D, G = list(map(int, input().split()))
PC = [list(map(int, input().split())) for _ in range(D)]
P_list = list(range(D))
cnt = float("inf")
for i in range(D):
for bonus in itertools.combinations(P_list, i):
tmp_cnt = 0
score = 0
for j in bonus:
score += PC[j][0] * 100 * (j + 1) + PC[j][1]
tmp_cnt += PC[j][0]
res_max_p = max([k for k in range(D) if k not in bonus])
res_score = G - score
if res_score > 0:
t = (-res_score // ((res_max_p + 1) * 100)) * (-1)
if t < PC[res_max_p][0]:
tmp_cnt += t
else:
continue
cnt = min(cnt, tmp_cnt)
if cnt == float("inf"):
cnt = sum([PC[j][0] for j in range(D)])
print(cnt)
| false | 20.454545 | [
"+import itertools",
"+",
"-",
"-",
"-def Base_10_to_n(X, n):",
"- X_dumy = X",
"- out = \"\"",
"- while X_dumy > 0:",
"- out = str(X_dumy % n) + out",
"- X_dumy = int(X_dumy / n)",
"- return out",
"-",
"-",
"-p = []",
"-c = []",
"-for _ in range(D):",
"- ... | false | 0.081312 | 0.077899 | 1.043815 | [
"s119126291",
"s722726858"
] |
u796942881 | p03262 | python | s153130531 | s955319151 | 68 | 53 | 14,052 | 14,052 | Accepted | Accepted | 22.06 | def gcd(a, b):
while b:
a, b = b, a % b
return a
def main():
N, X, *xn = list(map(int, open(0).read().split()))
ans = None
for x in xn:
if ans is not None:
ans = gcd(ans, abs(X - x))
else:
ans = abs(X - xn[0])
print(ans)
return
main()
| def gcd(a, b):
while b:
a, b = b, a % b
return a
def main():
N, X, *xn = list(map(int, open(0).read().split()))
ans = None
for x in xn:
if ans is not None:
if abs(X - x) % ans:
ans = gcd(ans, abs(X - x))
else:
ans = abs(X - xn[0])
print(ans)
return
main()
| 19 | 20 | 327 | 365 | def gcd(a, b):
while b:
a, b = b, a % b
return a
def main():
N, X, *xn = list(map(int, open(0).read().split()))
ans = None
for x in xn:
if ans is not None:
ans = gcd(ans, abs(X - x))
else:
ans = abs(X - xn[0])
print(ans)
return
main()
| def gcd(a, b):
while b:
a, b = b, a % b
return a
def main():
N, X, *xn = list(map(int, open(0).read().split()))
ans = None
for x in xn:
if ans is not None:
if abs(X - x) % ans:
ans = gcd(ans, abs(X - x))
else:
ans = abs(X - xn[0])
print(ans)
return
main()
| false | 5 | [
"- ans = gcd(ans, abs(X - x))",
"+ if abs(X - x) % ans:",
"+ ans = gcd(ans, abs(X - x))"
] | false | 0.046786 | 0.043142 | 1.084477 | [
"s153130531",
"s955319151"
] |
u699547221 | p02731 | python | s721548995 | s369162060 | 20 | 17 | 3,316 | 3,060 | Accepted | Accepted | 15 | L = int(eval(input()))
import random
print((L**3/27)) | l = int(eval(input()))
print(((l/3)**3)) | 5 | 2 | 51 | 33 | L = int(eval(input()))
import random
print((L**3 / 27))
| l = int(eval(input()))
print(((l / 3) ** 3))
| false | 60 | [
"-L = int(eval(input()))",
"-import random",
"-",
"-print((L**3 / 27))",
"+l = int(eval(input()))",
"+print(((l / 3) ** 3))"
] | false | 0.042035 | 0.067354 | 0.624091 | [
"s721548995",
"s369162060"
] |
u695811449 | p03309 | python | s661194214 | s383155483 | 477 | 275 | 92,372 | 34,784 | Accepted | Accepted | 42.35 | N=int(eval(input()))
A=list(map(int,input().split()))
B=[None]*N
for i in range(N):
B[i]=A[i]-i-1
B.sort()
Left=0
Right=sum(B)-B[0]*N
ANS=Left+Right
#print(B)
#print(Left,Right)
for i in range(1,N):
Left=Left+(B[i]-B[i-1])*i
Right=Right-(B[i]-B[i-1])*(N-i)
#print(Left,Right)
if ANS>Left+Right:
ANS=Left+Right
print(ANS)
| N=int(eval(input()))
A=list(map(int,input().split()))
B=[A[i]-(i+1) for i in range(N)]
B.sort()
B1=[abs(B[i]-B[N//2]) for i in range(N)]
B2=[abs(B[i]-B[N//2-1]) for i in range(N)]
print((min(sum(B1),sum(B2)))) | 25 | 10 | 374 | 213 | N = int(eval(input()))
A = list(map(int, input().split()))
B = [None] * N
for i in range(N):
B[i] = A[i] - i - 1
B.sort()
Left = 0
Right = sum(B) - B[0] * N
ANS = Left + Right
# print(B)
# print(Left,Right)
for i in range(1, N):
Left = Left + (B[i] - B[i - 1]) * i
Right = Right - (B[i] - B[i - 1]) * (N - i)
# print(Left,Right)
if ANS > Left + Right:
ANS = Left + Right
print(ANS)
| N = int(eval(input()))
A = list(map(int, input().split()))
B = [A[i] - (i + 1) for i in range(N)]
B.sort()
B1 = [abs(B[i] - B[N // 2]) for i in range(N)]
B2 = [abs(B[i] - B[N // 2 - 1]) for i in range(N)]
print((min(sum(B1), sum(B2))))
| false | 60 | [
"-B = [None] * N",
"-for i in range(N):",
"- B[i] = A[i] - i - 1",
"+B = [A[i] - (i + 1) for i in range(N)]",
"-Left = 0",
"-Right = sum(B) - B[0] * N",
"-ANS = Left + Right",
"-# print(B)",
"-# print(Left,Right)",
"-for i in range(1, N):",
"- Left = Left + (B[i] - B[i - 1]) * i",
"- ... | false | 0.08448 | 0.081627 | 1.034943 | [
"s661194214",
"s383155483"
] |
u894114233 | p02242 | python | s847015383 | s428637848 | 30 | 10 | 6,488 | 6,780 | Accepted | Accepted | 66.67 | def dijkstra(s):
global d
color=[0]*n
d=[float('inf')]*n
d[s]=0
while True:
mincost=float('inf')
for i in range(n):
if color[i]!=2 and d[i]<mincost:
mincost=d[i]
u=i
if mincost==float('inf'):
break
color[u]=2
for v in range(n):
if color[v]!=2 and m[u][v]!=0:
if d[u]+m[u][v]<d[v]:
d[v]=d[u]+m[u][v]
color[v]=1
if __name__=='__main__':
n=eval(input())
m=[[0]*n for i in range(n)]
for i in range(n):
en=list(map(int,input().split()))
for j in range(2*en[1]):
if j%2==0:
enid=en[2+j]
else:
m[en[0]][enid]=en[2+j]
dijkstra(0)
for i in range(n):
print(i,d[i]) | import heapq
def dijkstra(s,g,c):
d=[float('inf')]*n
d[s]=0
heapq.heappush(pq,[0,s])
while len(pq)!=0:
t,u=heapq.heappop(pq)
if d[u]<t:
continue
for v in g[u]:
if d[u]+c[u][v]<d[v]:
d[v]=d[u]+c[u][v]
heapq.heappush(pq,[d[v],v])
return d
n=int(input())
g=[[] for _ in range(n)]
cost=[[10**9+5]*n for i in range(n)]
for i in range(n):
en=list(map(int,input().split()))
u=en[0];k=en[1];v=en[2:-1:2];c=en[3::2]
for j in range(k):
g[u].append(v[j])
cost[u][v[j]]=c[j]
pq=[]
dist=dijkstra(0,g,cost)
for i in range(n):
print(i,dist[i]) | 33 | 32 | 868 | 702 | def dijkstra(s):
global d
color = [0] * n
d = [float("inf")] * n
d[s] = 0
while True:
mincost = float("inf")
for i in range(n):
if color[i] != 2 and d[i] < mincost:
mincost = d[i]
u = i
if mincost == float("inf"):
break
color[u] = 2
for v in range(n):
if color[v] != 2 and m[u][v] != 0:
if d[u] + m[u][v] < d[v]:
d[v] = d[u] + m[u][v]
color[v] = 1
if __name__ == "__main__":
n = eval(input())
m = [[0] * n for i in range(n)]
for i in range(n):
en = list(map(int, input().split()))
for j in range(2 * en[1]):
if j % 2 == 0:
enid = en[2 + j]
else:
m[en[0]][enid] = en[2 + j]
dijkstra(0)
for i in range(n):
print(i, d[i])
| import heapq
def dijkstra(s, g, c):
d = [float("inf")] * n
d[s] = 0
heapq.heappush(pq, [0, s])
while len(pq) != 0:
t, u = heapq.heappop(pq)
if d[u] < t:
continue
for v in g[u]:
if d[u] + c[u][v] < d[v]:
d[v] = d[u] + c[u][v]
heapq.heappush(pq, [d[v], v])
return d
n = int(input())
g = [[] for _ in range(n)]
cost = [[10**9 + 5] * n for i in range(n)]
for i in range(n):
en = list(map(int, input().split()))
u = en[0]
k = en[1]
v = en[2:-1:2]
c = en[3::2]
for j in range(k):
g[u].append(v[j])
cost[u][v[j]] = c[j]
pq = []
dist = dijkstra(0, g, cost)
for i in range(n):
print(i, dist[i])
| false | 3.030303 | [
"-def dijkstra(s):",
"- global d",
"- color = [0] * n",
"+import heapq",
"+",
"+",
"+def dijkstra(s, g, c):",
"- while True:",
"- mincost = float(\"inf\")",
"- for i in range(n):",
"- if color[i] != 2 and d[i] < mincost:",
"- mincost = d[i]",
... | false | 0.044419 | 0.044312 | 1.002429 | [
"s847015383",
"s428637848"
] |
u932465688 | p03201 | python | s818442133 | s929220288 | 1,057 | 418 | 33,296 | 110,292 | Accepted | Accepted | 60.45 | import bisect
from collections import Counter
n = int(eval(input()))
A = list(map(int,input().split()))
A.sort()
C = Counter(A)
ans = 0
for i in range(n-1,-1,-1):
temp = A[i]
beki = 1
while beki <= temp:
beki *= 2
counterpart = beki-temp
if C[counterpart] > 0 and C[temp] > 0 and counterpart != temp:
C[counterpart] -= 1
C[temp] -= 1
ans += 1
elif counterpart == temp and C[counterpart] > 1:
C[counterpart] -= 2
ans += 1
print(ans)
| from collections import Counter
n = int(eval(input()))
A = list(map(int,input().split()))
A.sort()
C = Counter(A)
ans = 0
for i in range(n-1,-1,-1):
temp = A[i]
beki = 1
if C[temp] == 0:
continue
while beki <= temp:
beki *= 2
counterpart = beki-temp
if C[counterpart] > 0 and C[temp] > 0 and counterpart != temp:
C[counterpart] -= 1
C[temp] -= 1
ans += 1
elif counterpart == temp and C[counterpart] > 1:
C[counterpart] -= 2
ans += 1
print(ans)
| 21 | 22 | 518 | 543 | import bisect
from collections import Counter
n = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
C = Counter(A)
ans = 0
for i in range(n - 1, -1, -1):
temp = A[i]
beki = 1
while beki <= temp:
beki *= 2
counterpart = beki - temp
if C[counterpart] > 0 and C[temp] > 0 and counterpart != temp:
C[counterpart] -= 1
C[temp] -= 1
ans += 1
elif counterpart == temp and C[counterpart] > 1:
C[counterpart] -= 2
ans += 1
print(ans)
| from collections import Counter
n = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
C = Counter(A)
ans = 0
for i in range(n - 1, -1, -1):
temp = A[i]
beki = 1
if C[temp] == 0:
continue
while beki <= temp:
beki *= 2
counterpart = beki - temp
if C[counterpart] > 0 and C[temp] > 0 and counterpart != temp:
C[counterpart] -= 1
C[temp] -= 1
ans += 1
elif counterpart == temp and C[counterpart] > 1:
C[counterpart] -= 2
ans += 1
print(ans)
| false | 4.545455 | [
"-import bisect",
"+ if C[temp] == 0:",
"+ continue"
] | false | 0.080056 | 0.138442 | 0.578263 | [
"s818442133",
"s929220288"
] |
u478719560 | p02624 | python | s187137148 | s703102142 | 1,653 | 1,347 | 9,176 | 9,052 | Accepted | Accepted | 18.51 | import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18
def su(N):
return N*(N+1) / 2
def solve():
n = int(stdin.readline().rstrip())
#A, B, C = map(int, stdin.readline().rstrip().split())
#l = list(map(int, stdin.readline().rstrip().split()))
#numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
#word = [stdin.readline().rstrip() for _ in range(n)]
#number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
#zeros = [[0] * w for i in range(h)]
ans = 0
for i in range(1,n+1):
ans += i * su(n//i)
print((int(ans)))
if __name__ == '__main__':
solve()
| import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18
def solve():
n = int(stdin.readline().rstrip())
#A, B, C = map(int, stdin.readline().rstrip().split())
#l = list(map(int, stdin.readline().rstrip().split()))
#numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
#word = [stdin.readline().rstrip() for _ in range(n)]
#number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
#zeros = [[0] * w for i in range(h)]
ans = 0
for i in range(1,n+1):
ans += i * (n//i)*((n//i)+1) / 2
print((int(ans)))
if __name__ == '__main__':
solve()
| 40 | 37 | 1,093 | 1,068 | import sys
# import string
# from collections import defaultdict, deque, Counter
# import bisect
# import heapq
# import math
# from itertools import accumulate
# from itertools import permutations as perm
# from itertools import combinations as comb
# from itertools import combinations_with_replacement as combr
# from fractions import gcd
# import numpy as np
stdin = sys.stdin
sys.setrecursionlimit(10**7)
MIN = -(10**9)
MOD = 10**9 + 7
INF = float("inf")
IINF = 10**18
def su(N):
return N * (N + 1) / 2
def solve():
n = int(stdin.readline().rstrip())
# A, B, C = map(int, stdin.readline().rstrip().split())
# l = list(map(int, stdin.readline().rstrip().split()))
# numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
# word = [stdin.readline().rstrip() for _ in range(n)]
# number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
# zeros = [[0] * w for i in range(h)]
ans = 0
for i in range(1, n + 1):
ans += i * su(n // i)
print((int(ans)))
if __name__ == "__main__":
solve()
| import sys
# import string
# from collections import defaultdict, deque, Counter
# import bisect
# import heapq
# import math
# from itertools import accumulate
# from itertools import permutations as perm
# from itertools import combinations as comb
# from itertools import combinations_with_replacement as combr
# from fractions import gcd
# import numpy as np
stdin = sys.stdin
sys.setrecursionlimit(10**7)
MIN = -(10**9)
MOD = 10**9 + 7
INF = float("inf")
IINF = 10**18
def solve():
n = int(stdin.readline().rstrip())
# A, B, C = map(int, stdin.readline().rstrip().split())
# l = list(map(int, stdin.readline().rstrip().split()))
# numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
# word = [stdin.readline().rstrip() for _ in range(n)]
# number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
# zeros = [[0] * w for i in range(h)]
ans = 0
for i in range(1, n + 1):
ans += i * (n // i) * ((n // i) + 1) / 2
print((int(ans)))
if __name__ == "__main__":
solve()
| false | 7.5 | [
"-def su(N):",
"- return N * (N + 1) / 2",
"-",
"-",
"- ans += i * su(n // i)",
"+ ans += i * (n // i) * ((n // i) + 1) / 2"
] | false | 0.66224 | 0.645855 | 1.02537 | [
"s187137148",
"s703102142"
] |
u744034042 | p03835 | python | s050058129 | s327591974 | 1,287 | 1,101 | 2,940 | 2,940 | Accepted | Accepted | 14.45 | k, s = list(map(int, input().split()))
n = k + 1
count = 0
for i in range(n):
for j in range(n):
if ( 0 <= s - i - j <= k):
count += 1
print(count) | k,s = list(map(int,input().split()))
print((sum(0<=s-i-j<=k for i in range(k+1) for j in range(k+1)))) | 8 | 2 | 170 | 95 | k, s = list(map(int, input().split()))
n = k + 1
count = 0
for i in range(n):
for j in range(n):
if 0 <= s - i - j <= k:
count += 1
print(count)
| k, s = list(map(int, input().split()))
print((sum(0 <= s - i - j <= k for i in range(k + 1) for j in range(k + 1))))
| false | 75 | [
"-n = k + 1",
"-count = 0",
"-for i in range(n):",
"- for j in range(n):",
"- if 0 <= s - i - j <= k:",
"- count += 1",
"-print(count)",
"+print((sum(0 <= s - i - j <= k for i in range(k + 1) for j in range(k + 1))))"
] | false | 0.11833 | 0.115454 | 1.024904 | [
"s050058129",
"s327591974"
] |
u225388820 | p03013 | python | s275826319 | s933011967 | 357 | 191 | 460,788 | 7,668 | Accepted | Accepted | 46.5 | def dp(n):
d=[0]*(n+1)
if n==1:
return 1
else:
d[0]=1
if a[1]==0:
d[1]=1
else:
d[1]=0
for i in range(2,n+1):
if a[i]==0:
d[i]=d[i-1]+d[i-2]
else:
d[i]=0
return d[n]
n,m=list(map(int, input().split()))
a=[0]*(n+1)
for i in range(0,m):
k=int(eval(input()))
a[k]=1
print((dp(n)%1000000007)) | def dp(n):
d=[0]*(n+1)
if n==1:
return 1
else:
d[0]=1
if a[1]==0:
d[1]=1
else:
d[1]=0
for i in range(2,n+1):
if a[i]==0:
d[i]=(d[i-1]+d[i-2])%1000000007
else:
d[i]=0
return d[n]
n,m=list(map(int, input().split()))
a=[0]*(n+1)
for i in range(0,m):
k=int(eval(input()))
a[k]=1
print((dp(n))) | 23 | 23 | 449 | 451 | def dp(n):
d = [0] * (n + 1)
if n == 1:
return 1
else:
d[0] = 1
if a[1] == 0:
d[1] = 1
else:
d[1] = 0
for i in range(2, n + 1):
if a[i] == 0:
d[i] = d[i - 1] + d[i - 2]
else:
d[i] = 0
return d[n]
n, m = list(map(int, input().split()))
a = [0] * (n + 1)
for i in range(0, m):
k = int(eval(input()))
a[k] = 1
print((dp(n) % 1000000007))
| def dp(n):
d = [0] * (n + 1)
if n == 1:
return 1
else:
d[0] = 1
if a[1] == 0:
d[1] = 1
else:
d[1] = 0
for i in range(2, n + 1):
if a[i] == 0:
d[i] = (d[i - 1] + d[i - 2]) % 1000000007
else:
d[i] = 0
return d[n]
n, m = list(map(int, input().split()))
a = [0] * (n + 1)
for i in range(0, m):
k = int(eval(input()))
a[k] = 1
print((dp(n)))
| false | 0 | [
"- d[i] = d[i - 1] + d[i - 2]",
"+ d[i] = (d[i - 1] + d[i - 2]) % 1000000007",
"-print((dp(n) % 1000000007))",
"+print((dp(n)))"
] | false | 0.050163 | 0.036288 | 1.382349 | [
"s275826319",
"s933011967"
] |
u080364835 | p02756 | python | s598077700 | s880487471 | 533 | 340 | 14,052 | 10,048 | Accepted | Accepted | 36.21 | s = list(input())
n = int(input())
head = []
tail = []
cnt = 0
for _ in range(n):
li = list(input().split())
if li[0] == '1':
head, tail = tail, head
cnt += 1
else:
if li[1] == '1':
head.append(li[2])
else:
tail.append(li[2])
if cnt % 2 != 0:
s = s[::-1]
ans = head[::-1] + s + tail
print(*ans , sep='')
| s = eval(input())
q = int(eval(input()))
head = ''
tail = ''
rev = 0
for _ in range(q):
T = list(input().split())
if T[0] == '1':
head, tail = tail, head
rev += 1
else:
if T[1] == '1':
head += T[2]
else:
tail += T[2]
if rev%2 == 0:
print((head[::-1]+s+tail))
else:
print((head[::-1]+s[::-1]+tail))
| 22 | 21 | 399 | 380 | s = list(input())
n = int(input())
head = []
tail = []
cnt = 0
for _ in range(n):
li = list(input().split())
if li[0] == "1":
head, tail = tail, head
cnt += 1
else:
if li[1] == "1":
head.append(li[2])
else:
tail.append(li[2])
if cnt % 2 != 0:
s = s[::-1]
ans = head[::-1] + s + tail
print(*ans, sep="")
| s = eval(input())
q = int(eval(input()))
head = ""
tail = ""
rev = 0
for _ in range(q):
T = list(input().split())
if T[0] == "1":
head, tail = tail, head
rev += 1
else:
if T[1] == "1":
head += T[2]
else:
tail += T[2]
if rev % 2 == 0:
print((head[::-1] + s + tail))
else:
print((head[::-1] + s[::-1] + tail))
| false | 4.545455 | [
"-s = list(input())",
"-n = int(input())",
"-head = []",
"-tail = []",
"-cnt = 0",
"-for _ in range(n):",
"- li = list(input().split())",
"- if li[0] == \"1\":",
"+s = eval(input())",
"+q = int(eval(input()))",
"+head = \"\"",
"+tail = \"\"",
"+rev = 0",
"+for _ in range(q):",
"+ ... | false | 0.046685 | 0.042968 | 1.086512 | [
"s598077700",
"s880487471"
] |
u581187895 | p02900 | python | s528595830 | s143332643 | 244 | 196 | 7,492 | 5,048 | Accepted | Accepted | 19.67 | import fractions, math
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
# divisors.sort()
return divisors
def is_prime(q):
q = abs(q)
if q == 2: return True
if q < 2 or q&1 == 0: return False
return pow(2, q-1, q) == 1
import random
def is_prime3(q,k=50):
q = abs(q)
#計算するまでもなく判定できるものははじく
if q == 2: return True
if q < 2 or q&1 == 0: return False
#n-1=2^s*dとし(但しaは整数、dは奇数)、dを求める
d = (q-1)>>1
while d&1 == 0:
d >>= 1
#判定をk回繰り返す
for i in range(k):
a = random.randint(1,q-1)
t = d
y = pow(a,t,q)
#[0,s-1]の範囲すべてをチェック
while t != q-1 and y != 1 and y != q-1:
y = pow(y,2,q)
t <<= 1
if y != q-1 and t&1 == 0:
return False
return True
A, B = list(map(int, input().split()))
ans = set(make_divisors(A)) & set(make_divisors(B))
print((sum([is_prime3(i) for i in ans])+1))
| from fractions import gcd
def prime_decomposition(n): #素因数分解
i = 2
table = []
while i*i <= n:
while n%i == 0:
n /= i
table.append(i)
i += 1
if n > 1:
table.append(int(n))
# 重複なし
return set(table)
A, B = list(map(int, input().split()))
n_gcd = gcd(A, B)
n_div = prime_decomposition(n_gcd)
print((len(n_div)+1)) | 48 | 19 | 1,125 | 357 | import fractions, math
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
# divisors.sort()
return divisors
def is_prime(q):
q = abs(q)
if q == 2:
return True
if q < 2 or q & 1 == 0:
return False
return pow(2, q - 1, q) == 1
import random
def is_prime3(q, k=50):
q = abs(q)
# 計算するまでもなく判定できるものははじく
if q == 2:
return True
if q < 2 or q & 1 == 0:
return False
# n-1=2^s*dとし(但しaは整数、dは奇数)、dを求める
d = (q - 1) >> 1
while d & 1 == 0:
d >>= 1
# 判定をk回繰り返す
for i in range(k):
a = random.randint(1, q - 1)
t = d
y = pow(a, t, q)
# [0,s-1]の範囲すべてをチェック
while t != q - 1 and y != 1 and y != q - 1:
y = pow(y, 2, q)
t <<= 1
if y != q - 1 and t & 1 == 0:
return False
return True
A, B = list(map(int, input().split()))
ans = set(make_divisors(A)) & set(make_divisors(B))
print((sum([is_prime3(i) for i in ans]) + 1))
| from fractions import gcd
def prime_decomposition(n): # 素因数分解
i = 2
table = []
while i * i <= n:
while n % i == 0:
n /= i
table.append(i)
i += 1
if n > 1:
table.append(int(n))
# 重複なし
return set(table)
A, B = list(map(int, input().split()))
n_gcd = gcd(A, B)
n_div = prime_decomposition(n_gcd)
print((len(n_div) + 1))
| false | 60.416667 | [
"-import fractions, math",
"+from fractions import gcd",
"-def make_divisors(n):",
"- divisors = []",
"- for i in range(1, int(n**0.5) + 1):",
"- if n % i == 0:",
"- divisors.append(i)",
"- if i != n // i:",
"- divisors.append(n // i)",
"- # div... | false | 0.094191 | 0.144997 | 0.649605 | [
"s528595830",
"s143332643"
] |
u143492911 | p02958 | python | s827392978 | s451075912 | 22 | 17 | 3,444 | 2,940 | Accepted | Accepted | 22.73 | #a,b=map(int,input().split())
n=int(input())
p=list(map(int,input().split()))
import copy
P=copy.deepcopy(p)
P.sort()
cnt=0
for i,j in zip(p,P):
if i!=j:
cnt+=1
print("YES") if cnt<=2 else print("NO")
| n=int(input())
p=list(map(int,input().split()))
#b=list(map(int,input().split()))
cnt=0
for i in range(n):
if p[i]!=i+1:
cnt+=1
print("YES") if cnt<=2 else print("NO")
| 11 | 8 | 235 | 186 | # a,b=map(int,input().split())
n = int(input())
p = list(map(int, input().split()))
import copy
P = copy.deepcopy(p)
P.sort()
cnt = 0
for i, j in zip(p, P):
if i != j:
cnt += 1
print("YES") if cnt <= 2 else print("NO")
| n = int(input())
p = list(map(int, input().split()))
# b=list(map(int,input().split()))
cnt = 0
for i in range(n):
if p[i] != i + 1:
cnt += 1
print("YES") if cnt <= 2 else print("NO")
| false | 27.272727 | [
"-# a,b=map(int,input().split())",
"-import copy",
"-",
"-P = copy.deepcopy(p)",
"-P.sort()",
"+# b=list(map(int,input().split()))",
"-for i, j in zip(p, P):",
"- if i != j:",
"+for i in range(n):",
"+ if p[i] != i + 1:"
] | false | 0.036488 | 0.045431 | 0.803149 | [
"s827392978",
"s451075912"
] |
u659712937 | p02813 | python | s327581176 | s247243917 | 36 | 28 | 13,844 | 9,156 | Accepted | Accepted | 22.22 | n=int(eval(input()))
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
import itertools
l=list(itertools.permutations(list(range(1,n+1))))
#print(l)
print((abs(l.index(p)-l.index(q)))) | #c
import math
n=int(eval(input()))
p=list(map(int,input().split()))
q=list(map(int,input().split()))
orderp=0
orderq=0
for i in range(n):
orderp+=(p[i]-1)*math.factorial(n-i-1)
orderq+=(q[i]-1)*math.factorial(n-i-1)
for j in range(i+1,n):
if p[j]>p[i]:
p[j]-=1
if q[j]>q[i]:
q[j]-=1
#print(orderp,orderq)
#print(p,q)
print((abs(orderp-orderq))) | 9 | 22 | 198 | 392 | n = int(eval(input()))
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
import itertools
l = list(itertools.permutations(list(range(1, n + 1))))
# print(l)
print((abs(l.index(p) - l.index(q))))
| # c
import math
n = int(eval(input()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
orderp = 0
orderq = 0
for i in range(n):
orderp += (p[i] - 1) * math.factorial(n - i - 1)
orderq += (q[i] - 1) * math.factorial(n - i - 1)
for j in range(i + 1, n):
if p[j] > p[i]:
p[j] -= 1
if q[j] > q[i]:
q[j] -= 1
# print(orderp,orderq)
# print(p,q)
print((abs(orderp - orderq)))
| false | 59.090909 | [
"+# c",
"+import math",
"+",
"-p = tuple(map(int, input().split()))",
"-q = tuple(map(int, input().split()))",
"-import itertools",
"-",
"-l = list(itertools.permutations(list(range(1, n + 1))))",
"-# print(l)",
"-print((abs(l.index(p) - l.index(q))))",
"+p = list(map(int, input().split()))",
... | false | 0.03997 | 0.039445 | 1.013305 | [
"s327581176",
"s247243917"
] |
u761320129 | p03504 | python | s755004416 | s391457486 | 684 | 507 | 64,796 | 27,512 | Accepted | Accepted | 25.88 | N,C = list(map(int,input().split()))
src = [list(map(int,input().split())) for i in range(N)]
MAX = 10**5
bucket = [[] for i in range(MAX+2)]
bucket2 = [set() for i in range(MAX+2)]
for s,t,c in src:
bucket[s].append((t,c))
bucket2[s].add(c)
imos = [0]*(MAX+2)
for s in range(MAX):
for t,c in bucket[s]:
imos[s-1] += 1
if c in bucket2[t]:
imos[t-1] -= 1
else:
imos[t] -= 1
ans = tmp = 0
for im in imos:
tmp += im
ans = max(ans, tmp)
print(ans) | N,C = list(map(int,input().split()))
STC = [tuple(map(int,input().split())) for i in range(N)]
cs = [[] for _ in range(30)]
for s,t,c in STC:
cs[c-1].append((s,t))
imos = [0]*(100005)
for c in cs:
c.sort(key=lambda x:x[0])
pt = -1
for s,t in c:
if s==pt:
imos[s] += 1
else:
imos[s-1] += 1
imos[t] -= 1
pt = t
for i in range(len(imos)-1):
imos[i+1] += imos[i]
print((max(imos))) | 24 | 21 | 531 | 467 | N, C = list(map(int, input().split()))
src = [list(map(int, input().split())) for i in range(N)]
MAX = 10**5
bucket = [[] for i in range(MAX + 2)]
bucket2 = [set() for i in range(MAX + 2)]
for s, t, c in src:
bucket[s].append((t, c))
bucket2[s].add(c)
imos = [0] * (MAX + 2)
for s in range(MAX):
for t, c in bucket[s]:
imos[s - 1] += 1
if c in bucket2[t]:
imos[t - 1] -= 1
else:
imos[t] -= 1
ans = tmp = 0
for im in imos:
tmp += im
ans = max(ans, tmp)
print(ans)
| N, C = list(map(int, input().split()))
STC = [tuple(map(int, input().split())) for i in range(N)]
cs = [[] for _ in range(30)]
for s, t, c in STC:
cs[c - 1].append((s, t))
imos = [0] * (100005)
for c in cs:
c.sort(key=lambda x: x[0])
pt = -1
for s, t in c:
if s == pt:
imos[s] += 1
else:
imos[s - 1] += 1
imos[t] -= 1
pt = t
for i in range(len(imos) - 1):
imos[i + 1] += imos[i]
print((max(imos)))
| false | 12.5 | [
"-src = [list(map(int, input().split())) for i in range(N)]",
"-MAX = 10**5",
"-bucket = [[] for i in range(MAX + 2)]",
"-bucket2 = [set() for i in range(MAX + 2)]",
"-for s, t, c in src:",
"- bucket[s].append((t, c))",
"- bucket2[s].add(c)",
"-imos = [0] * (MAX + 2)",
"-for s in range(MAX):",... | false | 0.264306 | 0.069775 | 3.788 | [
"s755004416",
"s391457486"
] |
u141786930 | p03557 | python | s899519943 | s644850281 | 940 | 396 | 23,328 | 23,360 | Accepted | Accepted | 57.87 | # C - Snuke Festival
N = int(eval(input()))
A = list(int(x) for x in input().split())
B = list(int(x) for x in input().split())
C = list(int(x) for x in input().split())
A.sort()
C.sort()
def binarySearchLeft(a, b):
l = -1
r = N
while l+1<r:
m = (l+r)//2
if a[m]<b:
l = m
else:
r = m
return r
def binarySearchRight(a, b):
l = -1
r = N
while l+1<r:
m = (l+r)//2
if a[m]<=b:
l = m
else:
r = m
return r
ans = 0
for j in range(N):
ans += binarySearchLeft(A, B[j]) * (N - binarySearchRight(C, B[j]))
print(ans) | # C - Snuke Festival
import bisect
N = int(eval(input()))
A = list(int(x) for x in input().split())
B = list(int(x) for x in input().split())
C = list(int(x) for x in input().split())
A.sort()
C.sort()
ans = 0
for j in range(N):
ans += bisect.bisect_left(A, B[j]) * (N - bisect.bisect_right(C, B[j]))
print(ans) | 37 | 17 | 673 | 330 | # C - Snuke Festival
N = int(eval(input()))
A = list(int(x) for x in input().split())
B = list(int(x) for x in input().split())
C = list(int(x) for x in input().split())
A.sort()
C.sort()
def binarySearchLeft(a, b):
l = -1
r = N
while l + 1 < r:
m = (l + r) // 2
if a[m] < b:
l = m
else:
r = m
return r
def binarySearchRight(a, b):
l = -1
r = N
while l + 1 < r:
m = (l + r) // 2
if a[m] <= b:
l = m
else:
r = m
return r
ans = 0
for j in range(N):
ans += binarySearchLeft(A, B[j]) * (N - binarySearchRight(C, B[j]))
print(ans)
| # C - Snuke Festival
import bisect
N = int(eval(input()))
A = list(int(x) for x in input().split())
B = list(int(x) for x in input().split())
C = list(int(x) for x in input().split())
A.sort()
C.sort()
ans = 0
for j in range(N):
ans += bisect.bisect_left(A, B[j]) * (N - bisect.bisect_right(C, B[j]))
print(ans)
| false | 54.054054 | [
"+import bisect",
"+",
"-",
"-",
"-def binarySearchLeft(a, b):",
"- l = -1",
"- r = N",
"- while l + 1 < r:",
"- m = (l + r) // 2",
"- if a[m] < b:",
"- l = m",
"- else:",
"- r = m",
"- return r",
"-",
"-",
"-def binarySearchRigh... | false | 0.052328 | 0.088377 | 0.592096 | [
"s899519943",
"s644850281"
] |
u792834675 | p02402 | python | s863378830 | s188725575 | 30 | 20 | 5,056 | 4,964 | Accepted | Accepted | 33.33 | from functools import reduce
n = eval(input())
l = sorted(map(int,input().split()))
print(l[0], l[n-1], reduce(lambda x,y: x+y, l)) | n = eval(input())
l = list(map(int,input().split()))
print(min(l), max(l), sum(l)) | 3 | 3 | 101 | 75 | from functools import reduce
n = eval(input())
l = sorted(map(int, input().split()))
print(l[0], l[n - 1], reduce(lambda x, y: x + y, l))
| n = eval(input())
l = list(map(int, input().split()))
print(min(l), max(l), sum(l))
| false | 0 | [
"-from functools import reduce",
"-",
"-l = sorted(map(int, input().split()))",
"-print(l[0], l[n - 1], reduce(lambda x, y: x + y, l))",
"+l = list(map(int, input().split()))",
"+print(min(l), max(l), sum(l))"
] | false | 0.040831 | 0.042075 | 0.970441 | [
"s863378830",
"s188725575"
] |
u811733736 | p00092 | python | s891147002 | s712517510 | 4,170 | 3,340 | 35,084 | 35,088 | Accepted | Accepted | 19.9 | import sys
def find_square(data):
max_size = 0
lmap = [] # dp??¨???2?¬??????????
# '.'????????????0??????'*'????????????1????????????
for row in data:
temp = []
for c in row:
if c == '.':
temp.append(1)
else:
temp.append(0)
lmap.append(temp)
# ????±?????????????????????????????????£????????????????????£?????¢????¢??????§??????????????§????????????
for y in range(1, len(lmap)):
for x in range(1, len(lmap[0])):
if lmap[y][x] == 1:
lmap[y][x] = min(lmap[y-1][x-1], min(lmap[y-1][x], lmap[y][x-1])) + 1
if lmap[y][x] > max_size:
max_size = lmap[y][x]
return max_size
def main(args):
while True:
n = int(eval(input()))
if n == 0:
break
data = [eval(input()) for _ in range(n)]
result = find_square(data)
print(result)
if __name__ == '__main__':
main(sys.argv[1:]) | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0092
"""
import sys
def find_square(data):
max_size = 0
lmap = []
for row in data:
temp = []
for c in row:
if c == '.':
temp.append(1)
else:
temp.append(0)
lmap.append(temp)
prev_row = lmap[0]
for curr_row in lmap[1:]:
for x in range(1, len(lmap[0])):
if curr_row[x] == 1:
if prev_row[x-1] != 0 and prev_row[x] != 0 and curr_row[x-1] != 0:
curr_row[x] = min(prev_row[x-1], min(prev_row[x], curr_row[x-1])) + 1
if curr_row[x] > max_size:
max_size = curr_row[x]
prev_row = curr_row
return max_size
def find_square2(data):
max_size = 0
lmap = []
for row in data:
temp = []
for c in row:
if c == '.':
temp.append(1)
else:
temp.append(0)
lmap.append(temp)
prev_row = lmap[0]
for curr_row in lmap[1:]:
for x, t in enumerate(curr_row[1:], start=1):
if t == 1:
curr_row[x] = min(prev_row[x-1], min(prev_row[x], curr_row[x-1])) + 1
if curr_row[x] > max_size:
max_size = curr_row[x]
prev_row = curr_row
return max_size
def main(args):
while True:
n = int(eval(input()))
if n == 0:
break
data = [eval(input()) for _ in range(n)]
result = find_square2(data)
print(result)
if __name__ == '__main__':
main(sys.argv[1:]) | 38 | 67 | 1,034 | 1,711 | import sys
def find_square(data):
max_size = 0
lmap = [] # dp??¨???2?¬??????????
# '.'????????????0??????'*'????????????1????????????
for row in data:
temp = []
for c in row:
if c == ".":
temp.append(1)
else:
temp.append(0)
lmap.append(temp)
# ????±?????????????????????????????????£????????????????????£?????¢????¢??????§??????????????§????????????
for y in range(1, len(lmap)):
for x in range(1, len(lmap[0])):
if lmap[y][x] == 1:
lmap[y][x] = (
min(lmap[y - 1][x - 1], min(lmap[y - 1][x], lmap[y][x - 1])) + 1
)
if lmap[y][x] > max_size:
max_size = lmap[y][x]
return max_size
def main(args):
while True:
n = int(eval(input()))
if n == 0:
break
data = [eval(input()) for _ in range(n)]
result = find_square(data)
print(result)
if __name__ == "__main__":
main(sys.argv[1:])
| # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0092
"""
import sys
def find_square(data):
max_size = 0
lmap = []
for row in data:
temp = []
for c in row:
if c == ".":
temp.append(1)
else:
temp.append(0)
lmap.append(temp)
prev_row = lmap[0]
for curr_row in lmap[1:]:
for x in range(1, len(lmap[0])):
if curr_row[x] == 1:
if prev_row[x - 1] != 0 and prev_row[x] != 0 and curr_row[x - 1] != 0:
curr_row[x] = (
min(prev_row[x - 1], min(prev_row[x], curr_row[x - 1])) + 1
)
if curr_row[x] > max_size:
max_size = curr_row[x]
prev_row = curr_row
return max_size
def find_square2(data):
max_size = 0
lmap = []
for row in data:
temp = []
for c in row:
if c == ".":
temp.append(1)
else:
temp.append(0)
lmap.append(temp)
prev_row = lmap[0]
for curr_row in lmap[1:]:
for x, t in enumerate(curr_row[1:], start=1):
if t == 1:
curr_row[x] = (
min(prev_row[x - 1], min(prev_row[x], curr_row[x - 1])) + 1
)
if curr_row[x] > max_size:
max_size = curr_row[x]
prev_row = curr_row
return max_size
def main(args):
while True:
n = int(eval(input()))
if n == 0:
break
data = [eval(input()) for _ in range(n)]
result = find_square2(data)
print(result)
if __name__ == "__main__":
main(sys.argv[1:])
| false | 43.283582 | [
"+# -*- coding: utf-8 -*-",
"+\"\"\"",
"+http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0092",
"+\"\"\"",
"- lmap = [] # dp??¨???2?¬??????????",
"- # '.'????????????0??????'*'????????????1????????????",
"+ lmap = []",
"- # ????±?????????????????????????????????£?????????????????... | false | 0.051786 | 0.053296 | 0.971664 | [
"s891147002",
"s712517510"
] |
u219417113 | p02579 | python | s674505064 | s105329382 | 856 | 692 | 138,496 | 208,532 | Accepted | Accepted | 19.16 | H, W = list(map(int, input().split()))
ch, cw = list(map(int, input().split()))
ch -= 1
cw -= 1
dh, dw = list(map(int, input().split()))
dh -= 1
dw -= 1
S = [list(eval(input())) for _ in range(H)]
dist = [[float("inf")] * W for _ in range(H)]
# x = []
# for i in range(5):
# for j in range(5):
# if i == 3 and j == 3:
# continue
# x.append((i-2, j-2))
# x = set(x)
y = {(0, 1), (1, 0), (-1, 0), (0, -1)}
# x = x - y
from collections import deque
q = deque()
q.append((ch, cw))
dist[ch][cw] = 0
while q:
h, w = q.popleft()
for hh, ww in y:
if 0 <= h+hh < H and 0 <= w+ww < W and S[h+hh][w+ww] == "." and dist[h+hh][w+ww] > dist[h][w]:
dist[h+hh][w+ww] = dist[h][w]
q.appendleft((h+hh, w+ww))
for hh in range(-2, 3):
for ww in range(-2, 3):
if 0 <= h+hh < H and 0 <= w+ww < W and S[h+hh][w+ww] == "." and dist[h+hh][w+ww] > dist[h][w] + 1:
dist[h+hh][w+ww] = dist[h][w] + 1
q.append((h+hh, w+ww))
if dist[dh][dw] == float("inf"):
print((-1))
else:
print((dist[dh][dw]))
| from collections import deque
H, W = list(map(int, input().split()))
ch, cw = [int(x)-1 for x in input().split()]
dh, dw = [int(x)-1 for x in input().split()]
S = [list(eval(input())) for _ in range(H)]
dist = [[-1] * W for _ in range(H)]
move = []
for i in range(-2, 3):
for j in range(-2, 3):
if i == 0 and j == 0:
continue
move.append((i, j))
q = deque()
q.append((0, ch, cw))
while q:
c, h, w = q.popleft()
if dist[h][w] >= 0:
continue
dist[h][w] = c
for hh, ww in move:
if 0 <= h+hh < H and 0 <= w+ww < W and S[h+hh][w+ww] == "." and dist[h+hh][w+ww] < 0:
if (hh, ww) in ((0,1), (1,0), (-1,0), (0,-1)):
q.appendleft((c, h+hh, w+ww)) # 徒歩は前に追加
else:
q.append((c+1, h+hh, w+ww)) # ワープは後ろに追加
print((dist[dh][dw])) | 40 | 29 | 1,118 | 862 | H, W = list(map(int, input().split()))
ch, cw = list(map(int, input().split()))
ch -= 1
cw -= 1
dh, dw = list(map(int, input().split()))
dh -= 1
dw -= 1
S = [list(eval(input())) for _ in range(H)]
dist = [[float("inf")] * W for _ in range(H)]
# x = []
# for i in range(5):
# for j in range(5):
# if i == 3 and j == 3:
# continue
# x.append((i-2, j-2))
# x = set(x)
y = {(0, 1), (1, 0), (-1, 0), (0, -1)}
# x = x - y
from collections import deque
q = deque()
q.append((ch, cw))
dist[ch][cw] = 0
while q:
h, w = q.popleft()
for hh, ww in y:
if (
0 <= h + hh < H
and 0 <= w + ww < W
and S[h + hh][w + ww] == "."
and dist[h + hh][w + ww] > dist[h][w]
):
dist[h + hh][w + ww] = dist[h][w]
q.appendleft((h + hh, w + ww))
for hh in range(-2, 3):
for ww in range(-2, 3):
if (
0 <= h + hh < H
and 0 <= w + ww < W
and S[h + hh][w + ww] == "."
and dist[h + hh][w + ww] > dist[h][w] + 1
):
dist[h + hh][w + ww] = dist[h][w] + 1
q.append((h + hh, w + ww))
if dist[dh][dw] == float("inf"):
print((-1))
else:
print((dist[dh][dw]))
| from collections import deque
H, W = list(map(int, input().split()))
ch, cw = [int(x) - 1 for x in input().split()]
dh, dw = [int(x) - 1 for x in input().split()]
S = [list(eval(input())) for _ in range(H)]
dist = [[-1] * W for _ in range(H)]
move = []
for i in range(-2, 3):
for j in range(-2, 3):
if i == 0 and j == 0:
continue
move.append((i, j))
q = deque()
q.append((0, ch, cw))
while q:
c, h, w = q.popleft()
if dist[h][w] >= 0:
continue
dist[h][w] = c
for hh, ww in move:
if (
0 <= h + hh < H
and 0 <= w + ww < W
and S[h + hh][w + ww] == "."
and dist[h + hh][w + ww] < 0
):
if (hh, ww) in ((0, 1), (1, 0), (-1, 0), (0, -1)):
q.appendleft((c, h + hh, w + ww)) # 徒歩は前に追加
else:
q.append((c + 1, h + hh, w + ww)) # ワープは後ろに追加
print((dist[dh][dw]))
| false | 27.5 | [
"-H, W = list(map(int, input().split()))",
"-ch, cw = list(map(int, input().split()))",
"-ch -= 1",
"-cw -= 1",
"-dh, dw = list(map(int, input().split()))",
"-dh -= 1",
"-dw -= 1",
"-S = [list(eval(input())) for _ in range(H)]",
"-dist = [[float(\"inf\")] * W for _ in range(H)]",
"-# x = []",
"-... | false | 0.038763 | 0.070675 | 0.548468 | [
"s674505064",
"s105329382"
] |
u926412290 | p03436 | python | s488857507 | s451387583 | 99 | 75 | 74,024 | 73,872 | Accepted | Accepted | 24.24 | from collections import deque
dh = [-1, 0, 1, 0]
dw = [0, 1, 0, -1]
H, W = list(map(int, input().split()))
G = [eval(input()) for _ in range(H)]
# 色を変える前のマップ上の黒色マスを数える
def count_black():
res = 0
for i in range(H):
for j in range(W):
if G[i][j] == '#':
res += 1
return res
# 色を変えずにスタートからゴールまでの最短歩数を数える
def minimum_step():
dist = [[0] * W for _ in range(H)]
dist[0][0] = 1
que = deque([[0, 0]])
# BFS
while que:
h, w = que.popleft()
for i in range(4):
nh = h + dh[i]
nw = w + dw[i]
if nh < 0 or nw < 0 or nh >= H or nw >= W:
continue
if G[nh][nw] == '#':
continue
if dist[nh][nw]:
continue
dist[nh][nw] = dist[h][w] + 1
que.append([nh, nw])
return dist[H - 1][W - 1]
def main():
step = minimum_step()
print((H * W - step - count_black() if step else -1))
if __name__ == "__main__":
main() | from collections import deque
dh = [-1, 0, 1, 0]
dw = [0, 1, 0, -1]
H, W = list(map(int, input().split()))
G = [eval(input()) for _ in range(H)]
# 色を変える前のマップ上の白色マスを数える
def count_white():
res = 0
for i in range(H):
for j in range(W):
if G[i][j] == '.':
res += 1
return res
# 色を変えずにスタートからゴールまでの最短歩数を数える
def minimum_step():
dist = [[0] * W for _ in range(H)]
dist[0][0] = 1
que = deque([[0, 0]])
# BFS
while que:
h, w = que.popleft()
for i in range(4):
nh = h + dh[i]
nw = w + dw[i]
if nh < 0 or nw < 0 or nh >= H or nw >= W:
continue
if G[nh][nw] == '#':
continue
if dist[nh][nw]:
continue
dist[nh][nw] = dist[h][w] + 1
que.append([nh, nw])
return dist[H - 1][W - 1]
def main():
step = minimum_step()
print((count_white() - step if step else -1))
if __name__ == "__main__":
main() | 50 | 50 | 1,065 | 1,057 | from collections import deque
dh = [-1, 0, 1, 0]
dw = [0, 1, 0, -1]
H, W = list(map(int, input().split()))
G = [eval(input()) for _ in range(H)]
# 色を変える前のマップ上の黒色マスを数える
def count_black():
res = 0
for i in range(H):
for j in range(W):
if G[i][j] == "#":
res += 1
return res
# 色を変えずにスタートからゴールまでの最短歩数を数える
def minimum_step():
dist = [[0] * W for _ in range(H)]
dist[0][0] = 1
que = deque([[0, 0]])
# BFS
while que:
h, w = que.popleft()
for i in range(4):
nh = h + dh[i]
nw = w + dw[i]
if nh < 0 or nw < 0 or nh >= H or nw >= W:
continue
if G[nh][nw] == "#":
continue
if dist[nh][nw]:
continue
dist[nh][nw] = dist[h][w] + 1
que.append([nh, nw])
return dist[H - 1][W - 1]
def main():
step = minimum_step()
print((H * W - step - count_black() if step else -1))
if __name__ == "__main__":
main()
| from collections import deque
dh = [-1, 0, 1, 0]
dw = [0, 1, 0, -1]
H, W = list(map(int, input().split()))
G = [eval(input()) for _ in range(H)]
# 色を変える前のマップ上の白色マスを数える
def count_white():
res = 0
for i in range(H):
for j in range(W):
if G[i][j] == ".":
res += 1
return res
# 色を変えずにスタートからゴールまでの最短歩数を数える
def minimum_step():
dist = [[0] * W for _ in range(H)]
dist[0][0] = 1
que = deque([[0, 0]])
# BFS
while que:
h, w = que.popleft()
for i in range(4):
nh = h + dh[i]
nw = w + dw[i]
if nh < 0 or nw < 0 or nh >= H or nw >= W:
continue
if G[nh][nw] == "#":
continue
if dist[nh][nw]:
continue
dist[nh][nw] = dist[h][w] + 1
que.append([nh, nw])
return dist[H - 1][W - 1]
def main():
step = minimum_step()
print((count_white() - step if step else -1))
if __name__ == "__main__":
main()
| false | 0 | [
"-# 色を変える前のマップ上の黒色マスを数える",
"-def count_black():",
"+# 色を変える前のマップ上の白色マスを数える",
"+def count_white():",
"- if G[i][j] == \"#\":",
"+ if G[i][j] == \".\":",
"- print((H * W - step - count_black() if step else -1))",
"+ print((count_white() - step if step else -1))"
] | false | 0.0364 | 0.041472 | 0.877707 | [
"s488857507",
"s451387583"
] |
u796942881 | p03339 | python | s319274333 | s375106618 | 208 | 48 | 15,340 | 3,572 | Accepted | Accepted | 76.92 | from sys import stdin
input = stdin.readline
MAX_N = 300001
N = int(eval(input()))
S = eval(input())
def main():
# 東を向いている人の累積和
E = [0] * N
if S[0] == 'E':
E[0] += 1
for i in range(1, N):
E[i] = E[i - 1]
if S[i] == 'E':
E[i] += 1
ans = MAX_N
for i in range(N):
# 東を向いている人 西に向ける
num = E[-1] - E[i]
if (0 < i):
# 西を向いている人 東に向ける
num += i - E[i - 1]
ans = min(ans, num)
print(ans)
return
main()
| def main():
N, S = open(0).read().split()
pre = S.count("E")
ans = pre
for Si in S:
if pre < ans:
ans = pre
if Si == "E":
pre -= 1
else:
pre += 1
print((pre if pre < ans else ans))
return
main()
| 40 | 16 | 557 | 294 | from sys import stdin
input = stdin.readline
MAX_N = 300001
N = int(eval(input()))
S = eval(input())
def main():
# 東を向いている人の累積和
E = [0] * N
if S[0] == "E":
E[0] += 1
for i in range(1, N):
E[i] = E[i - 1]
if S[i] == "E":
E[i] += 1
ans = MAX_N
for i in range(N):
# 東を向いている人 西に向ける
num = E[-1] - E[i]
if 0 < i:
# 西を向いている人 東に向ける
num += i - E[i - 1]
ans = min(ans, num)
print(ans)
return
main()
| def main():
N, S = open(0).read().split()
pre = S.count("E")
ans = pre
for Si in S:
if pre < ans:
ans = pre
if Si == "E":
pre -= 1
else:
pre += 1
print((pre if pre < ans else ans))
return
main()
| false | 60 | [
"-from sys import stdin",
"-",
"-input = stdin.readline",
"-MAX_N = 300001",
"-N = int(eval(input()))",
"-S = eval(input())",
"-",
"-",
"- # 東を向いている人の累積和",
"- E = [0] * N",
"- if S[0] == \"E\":",
"- E[0] += 1",
"- for i in range(1, N):",
"- E[i] = E[i - 1]",
"- ... | false | 0.089276 | 0.046303 | 1.928072 | [
"s319274333",
"s375106618"
] |
u463775490 | p03262 | python | s608139533 | s013713246 | 135 | 114 | 14,600 | 16,372 | Accepted | Accepted | 15.56 | #import math
#import fractions
from functools import reduce
'''
def gcdList(ls):
return reduce(math.gcd, ls)
# return reduce(fractions.gcd, ls)
'''
def gcd(a,b):
while b:
a, b = b, a % b
return a
def gcdList(ls):
return reduce(gcd,ls)
n,y = list(map(int,input().split()))
x = sorted([int(i) for i in input().split()])
x_ = [0 for _ in range(n)]
for i in range(n):
x_[i] = abs(y-x[i])
print((gcdList(x_))) | from fractions import gcd
n, X = list(map(int, input().split()))
x = list(map(int, input().split()))
a = []
for i in range(n):
a.append(abs(X-x[i]))
if n > 1:
b = gcd(a[0],a[1])
else:
b = a[0]
for i in range(n):
b = gcd(b,a[i])
print(b) | 23 | 13 | 452 | 258 | # import math
# import fractions
from functools import reduce
"""
def gcdList(ls):
return reduce(math.gcd, ls)
# return reduce(fractions.gcd, ls)
"""
def gcd(a, b):
while b:
a, b = b, a % b
return a
def gcdList(ls):
return reduce(gcd, ls)
n, y = list(map(int, input().split()))
x = sorted([int(i) for i in input().split()])
x_ = [0 for _ in range(n)]
for i in range(n):
x_[i] = abs(y - x[i])
print((gcdList(x_)))
| from fractions import gcd
n, X = list(map(int, input().split()))
x = list(map(int, input().split()))
a = []
for i in range(n):
a.append(abs(X - x[i]))
if n > 1:
b = gcd(a[0], a[1])
else:
b = a[0]
for i in range(n):
b = gcd(b, a[i])
print(b)
| false | 43.478261 | [
"-# import math",
"-# import fractions",
"-from functools import reduce",
"+from fractions import gcd",
"-\"\"\"",
"-def gcdList(ls):",
"- return reduce(math.gcd, ls)",
"-# return reduce(fractions.gcd, ls)",
"-\"\"\"",
"-",
"-",
"-def gcd(a, b):",
"- while b:",
"- a, b = b,... | false | 0.03534 | 0.042606 | 0.829468 | [
"s608139533",
"s013713246"
] |
u314050667 | p03557 | python | s675708343 | s636251791 | 517 | 280 | 33,688 | 24,948 | Accepted | Accepted | 45.84 | import numpy as np
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
A = np.array(A)
B = list(map(int, input().split()))
B.sort()
B = np.array(B)
C = list(map(int, input().split()))
C.sort()
C = np.array(C)
cnt_A = np.searchsorted(A,B,side='left')
cnt_C = np.searchsorted(C,B,side='right')
ans = (cnt_A * (N-cnt_C)).sum()
print(ans) | import numpy as np
N = int(eval(input()))
A = np.array(list(map(int, input().split())))
B = np.array(list(map(int, input().split())))
C = np.array(list(map(int, input().split())))
A.sort()
B.sort()
C.sort()
cnt_A = np.searchsorted(A,B)
cnt_C = N - np.searchsorted(C,B,side='right')
ans = (cnt_A*cnt_C).sum()
print(ans)
| 18 | 15 | 364 | 330 | import numpy as np
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
A = np.array(A)
B = list(map(int, input().split()))
B.sort()
B = np.array(B)
C = list(map(int, input().split()))
C.sort()
C = np.array(C)
cnt_A = np.searchsorted(A, B, side="left")
cnt_C = np.searchsorted(C, B, side="right")
ans = (cnt_A * (N - cnt_C)).sum()
print(ans)
| import numpy as np
N = int(eval(input()))
A = np.array(list(map(int, input().split())))
B = np.array(list(map(int, input().split())))
C = np.array(list(map(int, input().split())))
A.sort()
B.sort()
C.sort()
cnt_A = np.searchsorted(A, B)
cnt_C = N - np.searchsorted(C, B, side="right")
ans = (cnt_A * cnt_C).sum()
print(ans)
| false | 16.666667 | [
"-A = list(map(int, input().split()))",
"+A = np.array(list(map(int, input().split())))",
"+B = np.array(list(map(int, input().split())))",
"+C = np.array(list(map(int, input().split())))",
"-A = np.array(A)",
"-B = list(map(int, input().split()))",
"-B = np.array(B)",
"-C = list(map(int, input().spli... | false | 0.446554 | 0.444596 | 1.004404 | [
"s675708343",
"s636251791"
] |
u588341295 | p02798 | python | s555365864 | s040844185 | 1,257 | 811 | 104,368 | 48,348 | Accepted | Accepted | 35.48 | # -*- coding: utf-8 -*-
import sys
from itertools import accumulate
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def pop_count(i):
i = i - ((i >> 1) & 0x55555555)
i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
i = (i + (i >> 4)) & 0x0f0f0f0f
i = i + (i >> 8)
i = i + (i >> 16)
return i & 0x3f
N = INT()
cards = [[]] * 2
cards[0] = LIST()
cards[1] = LIST()
# dp[S][i] := 既に使用したカードの集合がSで、最後に使った(現在の右端の)カードがiの時の最小合計転倒数
dp = list2d(1<<N, N, INF)
for i in range(N):
# 一番左は何が来ても転倒数0
dp[1<<i][i] = 0
for S in range(1, 1<<N):
popcnt = pop_count(S)
# 各位置より元indexが右側にある出現済要素の個数(転倒数)を前計算しておく
acc = [0] * N
for i in range(N):
if S & 1<<i:
acc[i] = 1
# 後ろから累積和
acc = list(accumulate(acc[::-1]))[::-1]
for i in range(N):
if dp[S][i] == INF or not S & 1<<i:
continue
# 遷移元の右端カードの表裏を確定
cur = cards[(i&1)^(1-(popcnt&1))][i]
for j in range(N):
if S & 1<<j:
continue
# 遷移先の右端カードの表裏を確定
nxt = cards[(j&1)^(popcnt&1)][j]
# 昇順が崩れないなら遷移させてOK
if cur <= nxt:
# 転倒数を追加して遷移
dp[S|1<<j][j] = min(dp[S|1<<j][j], dp[S][i] + acc[j])
ans = INF
for i in range(N):
ans = min(ans, dp[(1<<N)-1][i])
if ans == INF:
print((-1))
else:
print(ans)
| # -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def pop_count(i):
i = i - ((i >> 1) & 0x55555555)
i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
i = (i + (i >> 4)) & 0x0f0f0f0f
i = i + (i >> 8)
i = i + (i >> 16)
return i & 0x3f
N = INT()
cards = [[]] * 2
cards[0] = LIST()
cards[1] = LIST()
ans = INF
for S in range(1<<N):
# 無理なケース(奇数枚裏返す)を除外
if pop_count(S) % 2 != 0:
continue
# 奇数位置と偶数位置で分けて保持する
A1 = [[] for i in range(2)]
for i in range(N):
# カードiを青くする
if S & 1<<i:
A1[(i&1)^1].append((cards[1][i], i))
# 赤のまま
else:
A1[i&1].append((cards[0][i], i))
# 無理なケース(置きたい偶奇位置の数がおかしい)を除外
if len(A1[0]) != ceil(N, 2) or len(A1[1]) != N // 2:
continue
# 偶奇が同じ位置同士は自由に動けるのでソートする
A1[0].sort(reverse=1)
A1[1].sort(reverse=1)
cnt = 0
A2 = [0] * N
idxs = [0] * N
for i in range(N):
# 偶奇位置を交互に取り出す
A2[i], idxs[i] = A1[i&1].pop()
# ソート済と一致すればOK
if A2 == sorted(A2):
# 移動距離を転倒数数え上げで求める(Nが小さいのでN^2かけて大丈夫)
cnt = 0
for i, idx1 in enumerate(idxs):
for j, idx2 in enumerate(idxs[i+1:], i+1):
if idx1 > idx2:
cnt += 1
ans = min(ans, cnt)
if ans == INF:
print((-1))
else:
print(ans)
| 69 | 72 | 2,014 | 2,024 | # -*- coding: utf-8 -*-
import sys
from itertools import accumulate
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1):
return int(-(-x // y))
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST(N=None):
return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes():
print("Yes")
def No():
print("No")
def YES():
print("YES")
def NO():
print("NO")
sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7
def pop_count(i):
i = i - ((i >> 1) & 0x55555555)
i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
i = (i + (i >> 4)) & 0x0F0F0F0F
i = i + (i >> 8)
i = i + (i >> 16)
return i & 0x3F
N = INT()
cards = [[]] * 2
cards[0] = LIST()
cards[1] = LIST()
# dp[S][i] := 既に使用したカードの集合がSで、最後に使った(現在の右端の)カードがiの時の最小合計転倒数
dp = list2d(1 << N, N, INF)
for i in range(N):
# 一番左は何が来ても転倒数0
dp[1 << i][i] = 0
for S in range(1, 1 << N):
popcnt = pop_count(S)
# 各位置より元indexが右側にある出現済要素の個数(転倒数)を前計算しておく
acc = [0] * N
for i in range(N):
if S & 1 << i:
acc[i] = 1
# 後ろから累積和
acc = list(accumulate(acc[::-1]))[::-1]
for i in range(N):
if dp[S][i] == INF or not S & 1 << i:
continue
# 遷移元の右端カードの表裏を確定
cur = cards[(i & 1) ^ (1 - (popcnt & 1))][i]
for j in range(N):
if S & 1 << j:
continue
# 遷移先の右端カードの表裏を確定
nxt = cards[(j & 1) ^ (popcnt & 1)][j]
# 昇順が崩れないなら遷移させてOK
if cur <= nxt:
# 転倒数を追加して遷移
dp[S | 1 << j][j] = min(dp[S | 1 << j][j], dp[S][i] + acc[j])
ans = INF
for i in range(N):
ans = min(ans, dp[(1 << N) - 1][i])
if ans == INF:
print((-1))
else:
print(ans)
| # -*- coding: utf-8 -*-
import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1):
return int(-(-x // y))
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST(N=None):
return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes():
print("Yes")
def No():
print("No")
def YES():
print("YES")
def NO():
print("NO")
sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7
def pop_count(i):
i = i - ((i >> 1) & 0x55555555)
i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
i = (i + (i >> 4)) & 0x0F0F0F0F
i = i + (i >> 8)
i = i + (i >> 16)
return i & 0x3F
N = INT()
cards = [[]] * 2
cards[0] = LIST()
cards[1] = LIST()
ans = INF
for S in range(1 << N):
# 無理なケース(奇数枚裏返す)を除外
if pop_count(S) % 2 != 0:
continue
# 奇数位置と偶数位置で分けて保持する
A1 = [[] for i in range(2)]
for i in range(N):
# カードiを青くする
if S & 1 << i:
A1[(i & 1) ^ 1].append((cards[1][i], i))
# 赤のまま
else:
A1[i & 1].append((cards[0][i], i))
# 無理なケース(置きたい偶奇位置の数がおかしい)を除外
if len(A1[0]) != ceil(N, 2) or len(A1[1]) != N // 2:
continue
# 偶奇が同じ位置同士は自由に動けるのでソートする
A1[0].sort(reverse=1)
A1[1].sort(reverse=1)
cnt = 0
A2 = [0] * N
idxs = [0] * N
for i in range(N):
# 偶奇位置を交互に取り出す
A2[i], idxs[i] = A1[i & 1].pop()
# ソート済と一致すればOK
if A2 == sorted(A2):
# 移動距離を転倒数数え上げで求める(Nが小さいのでN^2かけて大丈夫)
cnt = 0
for i, idx1 in enumerate(idxs):
for j, idx2 in enumerate(idxs[i + 1 :], i + 1):
if idx1 > idx2:
cnt += 1
ans = min(ans, cnt)
if ans == INF:
print((-1))
else:
print(ans)
| false | 4.166667 | [
"-from itertools import accumulate",
"-# dp[S][i] := 既に使用したカードの集合がSで、最後に使った(現在の右端の)カードがiの時の最小合計転倒数",
"-dp = list2d(1 << N, N, INF)",
"-for i in range(N):",
"- # 一番左は何が来ても転倒数0",
"- dp[1 << i][i] = 0",
"-for S in range(1, 1 << N):",
"- popcnt = pop_count(S)",
"- # 各位置より元indexが右側にある出現済要素の個数... | false | 0.042191 | 0.116405 | 0.362448 | [
"s555365864",
"s040844185"
] |
u562935282 | p02863 | python | s138518626 | s918013614 | 565 | 344 | 46,960 | 43,248 | Accepted | Accepted | 39.12 | def solve():
from collections import namedtuple
import sys
input = sys.stdin.readline
Dish = namedtuple('Dish', 'idx cost pt')
n, t = list(map(int, input().split()))
dishes = []
for idx in range(1, n + 1):
cost, pt = list(map(int, input().split()))
dishes.append(Dish(idx=idx, cost=cost, pt=pt))
dp = [[0] * 2 for _ in range(t)]
# dp[完食にかかる総時間][最後の皿を選んだか]:= 美味しさの最大値
for dish in dishes:
for cost_ in range(t - 1, -1, -1):
dp[cost_][True] = max(dp[cost_][True], dp[cost_][False] + dish.pt)
if cost_ >= dish.cost:
dp[cost_][False] = max(dp[cost_][False], dp[cost_ - dish.cost][False] + dish.pt)
dp[cost_][True] = max(dp[cost_][True], dp[cost_ - dish.cost][True] + dish.pt)
return max(dp[cost_][True] for cost_ in range(t))
print((solve()))
# 最後の皿を選んだかフラグを設ける
# https://sen-comp.hatenablog.com/entry/2019/11/17/003150
| def solve():
from collections import namedtuple
from operator import attrgetter
import sys
input = sys.stdin.readline
Dish = namedtuple('Dish', 'idx cost pt')
n, t = list(map(int, input().split()))
dishes = []
for idx in range(1, n + 1):
cost, pt = list(map(int, input().split()))
dishes.append(Dish(idx=idx, cost=cost, pt=pt))
dishes.sort(key=attrgetter('cost'))
dp = [0] * t
# dp[完食にかかる総時間]:= 美味しさの最大値
ret = 0
for dish in dishes:
for cost_ in range(t - 1, -1, -1):
ret = max(ret, dp[cost_] + dish.pt)
if cost_ >= dish.cost:
dp[cost_] = max(dp[cost_], dp[cost_ - dish.cost] + dish.pt)
return ret
print((solve()))
# コスト昇順ソートした皿で、DPする
# 各皿は最後の皿(コスト0で、ポイントだけ加算し、以降は皿を取れない)にすることができる
# 最後の皿を選んだ時点でのポイントのmax
# https://sen-comp.hatenablog.com/entry/2019/11/17/003150
| 30 | 35 | 962 | 910 | def solve():
from collections import namedtuple
import sys
input = sys.stdin.readline
Dish = namedtuple("Dish", "idx cost pt")
n, t = list(map(int, input().split()))
dishes = []
for idx in range(1, n + 1):
cost, pt = list(map(int, input().split()))
dishes.append(Dish(idx=idx, cost=cost, pt=pt))
dp = [[0] * 2 for _ in range(t)]
# dp[完食にかかる総時間][最後の皿を選んだか]:= 美味しさの最大値
for dish in dishes:
for cost_ in range(t - 1, -1, -1):
dp[cost_][True] = max(dp[cost_][True], dp[cost_][False] + dish.pt)
if cost_ >= dish.cost:
dp[cost_][False] = max(
dp[cost_][False], dp[cost_ - dish.cost][False] + dish.pt
)
dp[cost_][True] = max(
dp[cost_][True], dp[cost_ - dish.cost][True] + dish.pt
)
return max(dp[cost_][True] for cost_ in range(t))
print((solve()))
# 最後の皿を選んだかフラグを設ける
# https://sen-comp.hatenablog.com/entry/2019/11/17/003150
| def solve():
from collections import namedtuple
from operator import attrgetter
import sys
input = sys.stdin.readline
Dish = namedtuple("Dish", "idx cost pt")
n, t = list(map(int, input().split()))
dishes = []
for idx in range(1, n + 1):
cost, pt = list(map(int, input().split()))
dishes.append(Dish(idx=idx, cost=cost, pt=pt))
dishes.sort(key=attrgetter("cost"))
dp = [0] * t
# dp[完食にかかる総時間]:= 美味しさの最大値
ret = 0
for dish in dishes:
for cost_ in range(t - 1, -1, -1):
ret = max(ret, dp[cost_] + dish.pt)
if cost_ >= dish.cost:
dp[cost_] = max(dp[cost_], dp[cost_ - dish.cost] + dish.pt)
return ret
print((solve()))
# コスト昇順ソートした皿で、DPする
# 各皿は最後の皿(コスト0で、ポイントだけ加算し、以降は皿を取れない)にすることができる
# 最後の皿を選んだ時点でのポイントのmax
# https://sen-comp.hatenablog.com/entry/2019/11/17/003150
| false | 14.285714 | [
"+ from operator import attrgetter",
"- dp = [[0] * 2 for _ in range(t)]",
"- # dp[完食にかかる総時間][最後の皿を選んだか]:= 美味しさの最大値",
"+ dishes.sort(key=attrgetter(\"cost\"))",
"+ dp = [0] * t",
"+ # dp[完食にかかる総時間]:= 美味しさの最大値",
"+ ret = 0",
"- dp[cost_][True] = max(dp[cost_][True], dp[c... | false | 0.038842 | 0.058658 | 0.662187 | [
"s138518626",
"s918013614"
] |
u329937934 | p02706 | python | s700789115 | s362277617 | 106 | 69 | 27,644 | 67,996 | Accepted | Accepted | 34.91 | import numpy as np
N,M = list(map(int,input().split()))
A = np.array(list(map(int,input().split())))
if (output := N - np.sum(A)) >= 0:
print(output)
else:
print((-1))
| N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
output = N - sum(A)
if output >= 0:
print(output)
else:
print((-1)) | 7 | 7 | 174 | 145 | import numpy as np
N, M = list(map(int, input().split()))
A = np.array(list(map(int, input().split())))
if (output := N - np.sum(A)) >= 0:
print(output)
else:
print((-1))
| N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
output = N - sum(A)
if output >= 0:
print(output)
else:
print((-1))
| false | 0 | [
"-import numpy as np",
"-",
"-A = np.array(list(map(int, input().split())))",
"-if (output := N - np.sum(A)) >= 0:",
"+A = list(map(int, input().split()))",
"+output = N - sum(A)",
"+if output >= 0:"
] | false | 0.354334 | 0.08889 | 3.986217 | [
"s700789115",
"s362277617"
] |
u127499732 | p02837 | python | s957196510 | s243980839 | 298 | 266 | 10,800 | 6,892 | Accepted | Accepted | 10.74 | import itertools
n=int(eval(input()))
H,L=[[] for _ in range(n)],[[] for _ in range(n)]
for i in range(n):
m=int(eval(input()))
for j in range(m):
x,y=list(map(int,input().split()))
if y==1:
H[i].append(x-1)
else:
L[i].append(x-1)
N=set(range(n))
ans=0
pat=set()
for num in range(1,n+1):
pat=pat|set(itertools.combinations(list(range(n)),num))
for h in pat:
h=set(h)
num=len(h)
nh=N-h
t=sum([H[i] for i in h],[])
l=sum([L[i] for i in h],[])
if set(t)<=h and set(l)<=nh:
ans=max(ans,num)
print(ans) | import itertools
n=int(eval(input()))
H,L=[[] for _ in range(n)],[[] for _ in range(n)]
for i in range(n):
m=int(eval(input()))
for j in range(m):
x,y=list(map(int,input().split()))
if y==1:
H[i].append(x-1)
else:
L[i].append(x-1)
N=set(range(n))
ans=0
for num in range(1,n+1):
pat=set(itertools.combinations(list(range(n)),num))
for h in pat:
h=set(h)
num=len(h)
nh=N-h
t=sum([H[i] for i in h],[])
l=sum([L[i] for i in h],[])
if set(t)<=h and set(l)<=nh:
ans=max(ans,num)
print(ans) | 28 | 27 | 571 | 572 | import itertools
n = int(eval(input()))
H, L = [[] for _ in range(n)], [[] for _ in range(n)]
for i in range(n):
m = int(eval(input()))
for j in range(m):
x, y = list(map(int, input().split()))
if y == 1:
H[i].append(x - 1)
else:
L[i].append(x - 1)
N = set(range(n))
ans = 0
pat = set()
for num in range(1, n + 1):
pat = pat | set(itertools.combinations(list(range(n)), num))
for h in pat:
h = set(h)
num = len(h)
nh = N - h
t = sum([H[i] for i in h], [])
l = sum([L[i] for i in h], [])
if set(t) <= h and set(l) <= nh:
ans = max(ans, num)
print(ans)
| import itertools
n = int(eval(input()))
H, L = [[] for _ in range(n)], [[] for _ in range(n)]
for i in range(n):
m = int(eval(input()))
for j in range(m):
x, y = list(map(int, input().split()))
if y == 1:
H[i].append(x - 1)
else:
L[i].append(x - 1)
N = set(range(n))
ans = 0
for num in range(1, n + 1):
pat = set(itertools.combinations(list(range(n)), num))
for h in pat:
h = set(h)
num = len(h)
nh = N - h
t = sum([H[i] for i in h], [])
l = sum([L[i] for i in h], [])
if set(t) <= h and set(l) <= nh:
ans = max(ans, num)
print(ans)
| false | 3.571429 | [
"-pat = set()",
"- pat = pat | set(itertools.combinations(list(range(n)), num))",
"-for h in pat:",
"- h = set(h)",
"- num = len(h)",
"- nh = N - h",
"- t = sum([H[i] for i in h], [])",
"- l = sum([L[i] for i in h], [])",
"- if set(t) <= h and set(l) <= nh:",
"- ans = m... | false | 0.038577 | 0.036103 | 1.068519 | [
"s957196510",
"s243980839"
] |
u038676814 | p02689 | python | s759597032 | s360231399 | 539 | 274 | 34,672 | 19,972 | Accepted | Accepted | 49.17 | N,M = list(map(int, input().split()))
HList = input().split(" ")
ABHash = {}
for i in range(M) :
A,B = list(map(int, input().split()))
A = A-1
B = B-1
if A not in ABHash :
ABHash[A] = []
ABHash[A].append(B)
if B not in ABHash :
ABHash[B] = []
ABHash[B].append(A)
count = 0
for i in range(N) :
if i not in ABHash :
count += 1
continue
BList = ABHash[i]
AHeight = int(HList[i])
isGood = True
for j in range(len(BList)) :
if AHeight <= int(HList[BList[j]]) :
isGood = False
if(isGood) :
count += 1
print(count) | N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
A = [True for i in range(N)]
for i in range(M) :
a,b = list(map(int, input().split()))
a -= 1
b -= 1
if(H[a] <= H[b]) :
A[a] = False
if(H[b] <= H[a]) :
A[b] = False
ans = 0
for i in range(N) :
if(A[i]) :
ans += 1
print(ans) | 31 | 17 | 646 | 351 | N, M = list(map(int, input().split()))
HList = input().split(" ")
ABHash = {}
for i in range(M):
A, B = list(map(int, input().split()))
A = A - 1
B = B - 1
if A not in ABHash:
ABHash[A] = []
ABHash[A].append(B)
if B not in ABHash:
ABHash[B] = []
ABHash[B].append(A)
count = 0
for i in range(N):
if i not in ABHash:
count += 1
continue
BList = ABHash[i]
AHeight = int(HList[i])
isGood = True
for j in range(len(BList)):
if AHeight <= int(HList[BList[j]]):
isGood = False
if isGood:
count += 1
print(count)
| N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
A = [True for i in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
if H[a] <= H[b]:
A[a] = False
if H[b] <= H[a]:
A[b] = False
ans = 0
for i in range(N):
if A[i]:
ans += 1
print(ans)
| false | 45.16129 | [
"-HList = input().split(\" \")",
"-ABHash = {}",
"+H = list(map(int, input().split()))",
"+A = [True for i in range(N)]",
"- A, B = list(map(int, input().split()))",
"- A = A - 1",
"- B = B - 1",
"- if A not in ABHash:",
"- ABHash[A] = []",
"- ABHash[A].append(B)",
"- if... | false | 0.035359 | 0.0349 | 1.013141 | [
"s759597032",
"s360231399"
] |
u150984829 | p00040 | python | s478990897 | s955061624 | 140 | 110 | 5,600 | 5,604 | Accepted | Accepted | 21.43 | z='abcdefghijklmnopqrstuvwxyz'
for _ in[0]*int(eval(input())):
e=eval(input())
for i in range(1,26,2):
for j in range(26):
a=''.join(z[(z.index(c)*i+j)%26]if c in z else c for c in e)
if'that'in a or'this'in a:print(a);break
| z='abcdefghijklmnopqrstuvwxyz'
def f(x):
for i in range(1,26,2):
for j in range(26):
a=''.join(z[(z.index(c)*i+j)%26]if c in z else c for c in x)
if'that'in a or'this'in a:return a
for _ in[0]*int(eval(input())):print((f(eval(input()))))
| 7 | 7 | 229 | 239 | z = "abcdefghijklmnopqrstuvwxyz"
for _ in [0] * int(eval(input())):
e = eval(input())
for i in range(1, 26, 2):
for j in range(26):
a = "".join(z[(z.index(c) * i + j) % 26] if c in z else c for c in e)
if "that" in a or "this" in a:
print(a)
break
| z = "abcdefghijklmnopqrstuvwxyz"
def f(x):
for i in range(1, 26, 2):
for j in range(26):
a = "".join(z[(z.index(c) * i + j) % 26] if c in z else c for c in x)
if "that" in a or "this" in a:
return a
for _ in [0] * int(eval(input())):
print((f(eval(input()))))
| false | 0 | [
"-for _ in [0] * int(eval(input())):",
"- e = eval(input())",
"+",
"+",
"+def f(x):",
"- a = \"\".join(z[(z.index(c) * i + j) % 26] if c in z else c for c in e)",
"+ a = \"\".join(z[(z.index(c) * i + j) % 26] if c in z else c for c in x)",
"- print(a)",
"- ... | false | 0.039934 | 0.039783 | 1.003794 | [
"s478990897",
"s955061624"
] |
u945839160 | p03455 | python | s898163270 | s193339350 | 161 | 17 | 38,256 | 2,940 | Accepted | Accepted | 89.44 | a, b = list(map(int, input().split()))
if a % 2 == 1 and b % 2 == 1:
print("Odd")
else:
print("Even") | def resolve():
a, b = list(map(int, input().split()))
if a % 2 == 1 and b % 2 == 1:
print("Odd")
else:
print("Even")
resolve() | 6 | 9 | 109 | 164 | a, b = list(map(int, input().split()))
if a % 2 == 1 and b % 2 == 1:
print("Odd")
else:
print("Even")
| def resolve():
a, b = list(map(int, input().split()))
if a % 2 == 1 and b % 2 == 1:
print("Odd")
else:
print("Even")
resolve()
| false | 33.333333 | [
"-a, b = list(map(int, input().split()))",
"-if a % 2 == 1 and b % 2 == 1:",
"- print(\"Odd\")",
"-else:",
"- print(\"Even\")",
"+def resolve():",
"+ a, b = list(map(int, input().split()))",
"+ if a % 2 == 1 and b % 2 == 1:",
"+ print(\"Odd\")",
"+ else:",
"+ print(\... | false | 0.098871 | 0.033727 | 2.931507 | [
"s898163270",
"s193339350"
] |
u852690916 | p02850 | python | s968619182 | s524138962 | 718 | 646 | 44,616 | 45,416 | Accepted | Accepted | 10.03 | N = int(eval(input()))
E=[[] for _ in range(N)]
for i in range(N-1):
a,b=list(map(int,input().split()))
E[a-1].append((b-1,i))
E[b-1].append((a-1,i))
C = [0] * (N-1)
stack=[0]
max_c=0
while stack:
n=stack.pop()
u=set()
for to,i in E[n]:
if C[i]!=0:
u.add(C[i])
c=1
for to,i in E[n]:
if C[i]!=0:
continue
while c in u:
c+=1
C[i]=c
max_c=max(max_c,c)
c+=1
stack.append(to)
print(max_c)
print(('\n'.join(map(str,C)))) | N = int(eval(input()))
E=[[] for _ in range(N)]
for i in range(N-1):
a,b=list(map(int,input().split()))
E[a-1].append((b-1,i))
E[b-1].append((a-1,i))
C = [0] * (N-1)
stack=[0]
parent_e=[0]*N
max_c=0
while stack:
n=stack.pop()
c=1
for to,i in E[n]:
if n!=0 and parent_e[n]==i:
continue
c+=1 if n!=0 and C[parent_e[n]]==c else 0
C[i]=c
max_c=max(max_c,c)
c+=1
stack.append(to)
parent_e[to]=i
print(max_c)
print(('\n'.join(map(str,C)))) | 29 | 26 | 554 | 538 | N = int(eval(input()))
E = [[] for _ in range(N)]
for i in range(N - 1):
a, b = list(map(int, input().split()))
E[a - 1].append((b - 1, i))
E[b - 1].append((a - 1, i))
C = [0] * (N - 1)
stack = [0]
max_c = 0
while stack:
n = stack.pop()
u = set()
for to, i in E[n]:
if C[i] != 0:
u.add(C[i])
c = 1
for to, i in E[n]:
if C[i] != 0:
continue
while c in u:
c += 1
C[i] = c
max_c = max(max_c, c)
c += 1
stack.append(to)
print(max_c)
print(("\n".join(map(str, C))))
| N = int(eval(input()))
E = [[] for _ in range(N)]
for i in range(N - 1):
a, b = list(map(int, input().split()))
E[a - 1].append((b - 1, i))
E[b - 1].append((a - 1, i))
C = [0] * (N - 1)
stack = [0]
parent_e = [0] * N
max_c = 0
while stack:
n = stack.pop()
c = 1
for to, i in E[n]:
if n != 0 and parent_e[n] == i:
continue
c += 1 if n != 0 and C[parent_e[n]] == c else 0
C[i] = c
max_c = max(max_c, c)
c += 1
stack.append(to)
parent_e[to] = i
print(max_c)
print(("\n".join(map(str, C))))
| false | 10.344828 | [
"+parent_e = [0] * N",
"- u = set()",
"- for to, i in E[n]:",
"- if C[i] != 0:",
"- u.add(C[i])",
"- if C[i] != 0:",
"+ if n != 0 and parent_e[n] == i:",
"- while c in u:",
"- c += 1",
"+ c += 1 if n != 0 and C[parent_e[n]] == c else 0... | false | 0.041674 | 0.068366 | 0.609581 | [
"s968619182",
"s524138962"
] |
u426649993 | p02768 | python | s429698071 | s077627241 | 1,555 | 127 | 5,400 | 3,064 | Accepted | Accepted | 91.83 | from math import factorial
def modpow(a, n, p):
if n == 0:
return 1
elif n == 1:
return a % p
if n % 2 == 1:
return (a * modpow(a, n-1, p)) % p
tmp = modpow(a, n//2, p)
return (tmp * tmp) % p
def main():
mod = 10 ** 9 + 7
n, a, b = list(map(int, input().split()))
# まずは繰り返し2乗法によって全部の組み合わせを求める
# すべての組み合わせは、花を選ぶ/選ばないで組み合わせを決めれる
ans = (modpow(2, n, mod) - 1) % mod
# a本選んだときの数を引く
c_a = 1
for i in range(n, n-a, -1):
c_a *= i
c_a %= mod
c_a *= modpow(factorial(a), mod-2, mod)
ans -= c_a
ans %= mod
# b本選んだときの数を引く
c_b = 1
for i in range(n, n-b, -1):
c_b *= i
c_b %= mod
c_b *= modpow(factorial(b), mod-2, mod)
ans -= c_b
ans %= mod
print(ans)
if __name__ == "__main__":
main()
| def modpow(a, n, p):
if n == 0:
return 1
elif n == 1:
return a % p
if n % 2 == 1:
return (a * modpow(a, n-1, p)) % p
tmp = modpow(a, n//2, p)
return (tmp * tmp) % p
def modfactrial(a, p):
ret = 1
for i in range(a, 1, -1):
ret = ret * i % p
return ret
def main():
mod = 10 ** 9 + 7
n, a, b = list(map(int, input().split()))
# まずは繰り返し2乗法によって全部の組み合わせを求める
# すべての組み合わせは、花を選ぶ/選ばないで組み合わせを決めれる
ans = (modpow(2, n, mod) - 1) % mod
# a本選んだときの数を引く
c_a = 1
for i in range(n, n-a, -1):
c_a *= i
c_a %= mod
c_a *= modpow(modfactrial(a, mod), mod-2, mod)
ans -= c_a
ans %= mod
# b本選んだときの数を引く
c_b = 1
for i in range(n, n-b, -1):
c_b *= i
c_b %= mod
c_b *= modpow(modfactrial(b, mod), mod-2, mod)
ans -= c_b
ans %= mod
print(ans)
if __name__ == "__main__":
main()
| 46 | 50 | 876 | 973 | from math import factorial
def modpow(a, n, p):
if n == 0:
return 1
elif n == 1:
return a % p
if n % 2 == 1:
return (a * modpow(a, n - 1, p)) % p
tmp = modpow(a, n // 2, p)
return (tmp * tmp) % p
def main():
mod = 10**9 + 7
n, a, b = list(map(int, input().split()))
# まずは繰り返し2乗法によって全部の組み合わせを求める
# すべての組み合わせは、花を選ぶ/選ばないで組み合わせを決めれる
ans = (modpow(2, n, mod) - 1) % mod
# a本選んだときの数を引く
c_a = 1
for i in range(n, n - a, -1):
c_a *= i
c_a %= mod
c_a *= modpow(factorial(a), mod - 2, mod)
ans -= c_a
ans %= mod
# b本選んだときの数を引く
c_b = 1
for i in range(n, n - b, -1):
c_b *= i
c_b %= mod
c_b *= modpow(factorial(b), mod - 2, mod)
ans -= c_b
ans %= mod
print(ans)
if __name__ == "__main__":
main()
| def modpow(a, n, p):
if n == 0:
return 1
elif n == 1:
return a % p
if n % 2 == 1:
return (a * modpow(a, n - 1, p)) % p
tmp = modpow(a, n // 2, p)
return (tmp * tmp) % p
def modfactrial(a, p):
ret = 1
for i in range(a, 1, -1):
ret = ret * i % p
return ret
def main():
mod = 10**9 + 7
n, a, b = list(map(int, input().split()))
# まずは繰り返し2乗法によって全部の組み合わせを求める
# すべての組み合わせは、花を選ぶ/選ばないで組み合わせを決めれる
ans = (modpow(2, n, mod) - 1) % mod
# a本選んだときの数を引く
c_a = 1
for i in range(n, n - a, -1):
c_a *= i
c_a %= mod
c_a *= modpow(modfactrial(a, mod), mod - 2, mod)
ans -= c_a
ans %= mod
# b本選んだときの数を引く
c_b = 1
for i in range(n, n - b, -1):
c_b *= i
c_b %= mod
c_b *= modpow(modfactrial(b, mod), mod - 2, mod)
ans -= c_b
ans %= mod
print(ans)
if __name__ == "__main__":
main()
| false | 8 | [
"-from math import factorial",
"-",
"-",
"+",
"+",
"+def modfactrial(a, p):",
"+ ret = 1",
"+ for i in range(a, 1, -1):",
"+ ret = ret * i % p",
"+ return ret",
"- c_a *= modpow(factorial(a), mod - 2, mod)",
"+ c_a *= modpow(modfactrial(a, mod), mod - 2, mod)",
"- c_... | false | 1.005465 | 0.07311 | 13.752687 | [
"s429698071",
"s077627241"
] |
u863370423 | p03264 | python | s962355886 | s308355249 | 17 | 10 | 2,940 | 2,568 | Accepted | Accepted | 41.18 | K = int(eval(input()))
x = 0
for i in range (0,K,1):
if i % 2 == 0:
x +=1
sum = x * (K-x)
print(sum) | a=int(eval(input()))
w=int((a/2)*(a/2))
z=int(a/2)*int((a/2)+1)
if a%2==0:
print(w)
else:
print(z) | 7 | 7 | 112 | 106 | K = int(eval(input()))
x = 0
for i in range(0, K, 1):
if i % 2 == 0:
x += 1
sum = x * (K - x)
print(sum)
| a = int(eval(input()))
w = int((a / 2) * (a / 2))
z = int(a / 2) * int((a / 2) + 1)
if a % 2 == 0:
print(w)
else:
print(z)
| false | 0 | [
"-K = int(eval(input()))",
"-x = 0",
"-for i in range(0, K, 1):",
"- if i % 2 == 0:",
"- x += 1",
"-sum = x * (K - x)",
"-print(sum)",
"+a = int(eval(input()))",
"+w = int((a / 2) * (a / 2))",
"+z = int(a / 2) * int((a / 2) + 1)",
"+if a % 2 == 0:",
"+ print(w)",
"+else:",
"+ ... | false | 0.0357 | 0.04413 | 0.808959 | [
"s962355886",
"s308355249"
] |
u811841526 | p02393 | python | s089875779 | s255319029 | 30 | 20 | 7,656 | 5,584 | Accepted | Accepted | 33.33 | xs=list(map(int,input().split()))
print((' '.join(map(str, sorted(xs))))) | input_list = list(map(int, input().split()))
print((' '.join(map(str, sorted(input_list)))))
| 2 | 2 | 66 | 86 | xs = list(map(int, input().split()))
print((" ".join(map(str, sorted(xs)))))
| input_list = list(map(int, input().split()))
print((" ".join(map(str, sorted(input_list)))))
| false | 0 | [
"-xs = list(map(int, input().split()))",
"-print((\" \".join(map(str, sorted(xs)))))",
"+input_list = list(map(int, input().split()))",
"+print((\" \".join(map(str, sorted(input_list)))))"
] | false | 0.039247 | 0.041764 | 0.939727 | [
"s089875779",
"s255319029"
] |
u021019433 | p02803 | python | s121988960 | s987304504 | 611 | 552 | 3,316 | 3,316 | Accepted | Accepted | 9.66 | from collections import deque
h, w = list(map(int, input().split()))
a = ['#' * (w + 2)] * 2
a[1: 1] = ['#' + eval(input()) + '#' for _ in range(h)]
r = 0
for i in range(1, h + 1):
for j in range(1, w + 1):
if a[i][j] == '.':
b = list(map(list, a))
q = deque()
b[i][j] = 0
q.append((i, j))
while(q):
i, j = q.popleft()
r = max(r, b[i][j])
d = 0
for i1 in range(i - 1, i + 2):
for j1 in range(j - d, j + 2, 2):
if b[i1][j1] == '.':
b[i1][j1] = b[i][j] + 1
q.append((i1, j1))
d ^= 1
print(r) | from collections import deque
h, w = list(map(int, input().split()))
a = ['#' + eval(input()) + '#' for _ in range(h)]
b = ['#' * (w + 1)] * 2
r = 0
for i in range(1, h + 1):
for j in range(1, w + 1):
if a[i - 1][j] == '.':
b[1: -1] = list(map(list, a))
q = deque()
b[i][j] = 0
q.append((i, j))
while(q):
i, j = q.popleft()
r = max(r, b[i][j])
d = 0
for i1 in range(i - 1, i + 2):
for j1 in range(j - d, j + 2, 2):
if b[i1][j1] == '.':
b[i1][j1] = b[i][j] + 1
q.append((i1, j1))
d ^= 1
print(r) | 24 | 24 | 647 | 646 | from collections import deque
h, w = list(map(int, input().split()))
a = ["#" * (w + 2)] * 2
a[1:1] = ["#" + eval(input()) + "#" for _ in range(h)]
r = 0
for i in range(1, h + 1):
for j in range(1, w + 1):
if a[i][j] == ".":
b = list(map(list, a))
q = deque()
b[i][j] = 0
q.append((i, j))
while q:
i, j = q.popleft()
r = max(r, b[i][j])
d = 0
for i1 in range(i - 1, i + 2):
for j1 in range(j - d, j + 2, 2):
if b[i1][j1] == ".":
b[i1][j1] = b[i][j] + 1
q.append((i1, j1))
d ^= 1
print(r)
| from collections import deque
h, w = list(map(int, input().split()))
a = ["#" + eval(input()) + "#" for _ in range(h)]
b = ["#" * (w + 1)] * 2
r = 0
for i in range(1, h + 1):
for j in range(1, w + 1):
if a[i - 1][j] == ".":
b[1:-1] = list(map(list, a))
q = deque()
b[i][j] = 0
q.append((i, j))
while q:
i, j = q.popleft()
r = max(r, b[i][j])
d = 0
for i1 in range(i - 1, i + 2):
for j1 in range(j - d, j + 2, 2):
if b[i1][j1] == ".":
b[i1][j1] = b[i][j] + 1
q.append((i1, j1))
d ^= 1
print(r)
| false | 0 | [
"-a = [\"#\" * (w + 2)] * 2",
"-a[1:1] = [\"#\" + eval(input()) + \"#\" for _ in range(h)]",
"+a = [\"#\" + eval(input()) + \"#\" for _ in range(h)]",
"+b = [\"#\" * (w + 1)] * 2",
"- if a[i][j] == \".\":",
"- b = list(map(list, a))",
"+ if a[i - 1][j] == \".\":",
"+ ... | false | 0.163656 | 0.113862 | 1.437315 | [
"s121988960",
"s987304504"
] |
u767797498 | p03160 | python | s093228946 | s816620492 | 156 | 123 | 20,596 | 20,576 | Accepted | Accepted | 21.15 | n=int(eval(input()))
a=list(map(int,input().split()))
# dp には 足場(i)へ至る最小コストが入る。
dp=[float("inf")]*(n)
dp[0]=0
for i in range(n-1):
dp[i+1]=min(dp[i+1],dp[i]+abs(a[i]-a[i+1]))
if i+2 < n:
dp[i+2]=min(dp[i+2],dp[i]+abs(a[i]-a[i+2]))
print((dp[-1]))
| # 参考:
# https://qiita.com/drken/items/dc53c683d6de8aeacf5a
# ver 2,振り返る DP
n=int(eval(input()))
a=list(map(int,input().split()))
# dp には 足場(i)へ至る最小コストが入る。
dp=[float("inf")]*(n)
# 振り返り起点(i==2)までのdp値は埋めておく。
dp[0]=0
dp[1]=abs(a[1]-a[0])
for i in range(2,n):
dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]))
print((dp[-1]))
| 14 | 17 | 272 | 347 | n = int(eval(input()))
a = list(map(int, input().split()))
# dp には 足場(i)へ至る最小コストが入る。
dp = [float("inf")] * (n)
dp[0] = 0
for i in range(n - 1):
dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i] - a[i + 1]))
if i + 2 < n:
dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i] - a[i + 2]))
print((dp[-1]))
| # 参考:
# https://qiita.com/drken/items/dc53c683d6de8aeacf5a
# ver 2,振り返る DP
n = int(eval(input()))
a = list(map(int, input().split()))
# dp には 足場(i)へ至る最小コストが入る。
dp = [float("inf")] * (n)
# 振り返り起点(i==2)までのdp値は埋めておく。
dp[0] = 0
dp[1] = abs(a[1] - a[0])
for i in range(2, n):
dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]))
print((dp[-1]))
| false | 17.647059 | [
"+# 参考:",
"+# https://qiita.com/drken/items/dc53c683d6de8aeacf5a",
"+# ver 2,振り返る DP",
"+# 振り返り起点(i==2)までのdp値は埋めておく。",
"-for i in range(n - 1):",
"- dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i] - a[i + 1]))",
"- if i + 2 < n:",
"- dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i] - a[i + 2]))",
... | false | 0.044191 | 0.104325 | 0.42359 | [
"s093228946",
"s816620492"
] |
u767797498 | p03161 | python | s037660311 | s189955015 | 876 | 166 | 143,824 | 38,140 | Accepted | Accepted | 81.05 | import numpy as np
from numba import njit
@njit
def main():
# Worst Case
#n,k=100000,100
#a=[p for p in range(100000)]
kl=[p for p in range(1,k+1)]
dp=[10**9]*(n)
dp[0]=0
for i in range(n):
for j in kl:
ij=i+j
if ij < n:
m=dp[i]+abs(a[i]-a[ij])
if m < dp[ij]:
dp[ij]=m
return dp[n-1]
n,k=list(map(int,input().split()))
a=np.array(list(map(int,input().split())))
print((main()))
| import numpy as np
def main(n,k,a):
# Worst Case
#n,k=100000,100
#a=[p for p in range(100000)]
kl=[p for p in range(1,k+1)]
dp=[10**9]*(n)
dp[0]=0
for i in range(n):
for j in kl:
ij=i+j
if ij < n:
m=dp[i]+abs(a[i]-a[ij])
if m < dp[ij]:
dp[ij]=m
print((dp[n-1]))
def cc_export():
from numba.pycc import CC
cc = CC('my_module')
cc.export('main','(i4,i4,i4[:])')(main)
cc.compile()
if __name__ == '__main__':
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
cc_export()
from my_module import main
n,k=list(map(int,input().split()))
a=np.array(input().split(),np.int32)
main(n,k,a)
| 24 | 33 | 456 | 709 | import numpy as np
from numba import njit
@njit
def main():
# Worst Case
# n,k=100000,100
# a=[p for p in range(100000)]
kl = [p for p in range(1, k + 1)]
dp = [10**9] * (n)
dp[0] = 0
for i in range(n):
for j in kl:
ij = i + j
if ij < n:
m = dp[i] + abs(a[i] - a[ij])
if m < dp[ij]:
dp[ij] = m
return dp[n - 1]
n, k = list(map(int, input().split()))
a = np.array(list(map(int, input().split())))
print((main()))
| import numpy as np
def main(n, k, a):
# Worst Case
# n,k=100000,100
# a=[p for p in range(100000)]
kl = [p for p in range(1, k + 1)]
dp = [10**9] * (n)
dp[0] = 0
for i in range(n):
for j in kl:
ij = i + j
if ij < n:
m = dp[i] + abs(a[i] - a[ij])
if m < dp[ij]:
dp[ij] = m
print((dp[n - 1]))
def cc_export():
from numba.pycc import CC
cc = CC("my_module")
cc.export("main", "(i4,i4,i4[:])")(main)
cc.compile()
if __name__ == "__main__":
import sys
if sys.argv[-1] == "ONLINE_JUDGE":
cc_export()
from my_module import main
n, k = list(map(int, input().split()))
a = np.array(input().split(), np.int32)
main(n, k, a)
| false | 27.272727 | [
"-from numba import njit",
"-@njit",
"-def main():",
"+def main(n, k, a):",
"- return dp[n - 1]",
"+ print((dp[n - 1]))",
"-n, k = list(map(int, input().split()))",
"-a = np.array(list(map(int, input().split())))",
"-print((main()))",
"+def cc_export():",
"+ from numba.pycc import CC",
... | false | 0.317418 | 0.295884 | 1.072777 | [
"s037660311",
"s189955015"
] |
u941753895 | p03170 | python | s625067831 | s549085257 | 1,523 | 579 | 5,932 | 5,932 | Accepted | Accepted | 61.98 | import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return eval(input())
def main():
n,k=LI()
dp=[0]*100100
l=LI()
for i in range(k):
for x in l:
if i+x<=k:
if dp[i+x]==0 and dp[i]==0:
dp[i+x]=1
# print(dp[:k+1])
return 'First' if dp[k] else 'Second'
# main()
print((main()))
| import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return eval(input())
def main():
n,k=LI()
l=LI()
dp=[0]*100100
for i in range(k):
for x in l:
y=dp[i]
if y==0 and i+x<100100:
dp[i+x]=1
if dp[k]==1:
return 'First'
return 'Second'
# main()
print((main()))
| 31 | 34 | 778 | 764 | import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LF():
return [float(x) for x in sys.stdin.readline().split()]
def I():
return int(sys.stdin.readline())
def F():
return float(sys.stdin.readline())
def LS():
return sys.stdin.readline().split()
def S():
return eval(input())
def main():
n, k = LI()
dp = [0] * 100100
l = LI()
for i in range(k):
for x in l:
if i + x <= k:
if dp[i + x] == 0 and dp[i] == 0:
dp[i + x] = 1
# print(dp[:k+1])
return "First" if dp[k] else "Second"
# main()
print((main()))
| import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LF():
return [float(x) for x in sys.stdin.readline().split()]
def I():
return int(sys.stdin.readline())
def F():
return float(sys.stdin.readline())
def LS():
return sys.stdin.readline().split()
def S():
return eval(input())
def main():
n, k = LI()
l = LI()
dp = [0] * 100100
for i in range(k):
for x in l:
y = dp[i]
if y == 0 and i + x < 100100:
dp[i + x] = 1
if dp[k] == 1:
return "First"
return "Second"
# main()
print((main()))
| false | 8.823529 | [
"+ l = LI()",
"- l = LI()",
"- if i + x <= k:",
"- if dp[i + x] == 0 and dp[i] == 0:",
"- dp[i + x] = 1",
"- # print(dp[:k+1])",
"- return \"First\" if dp[k] else \"Second\"",
"+ y = dp[i]",
"+ if y == 0 and i + x < 10010... | false | 0.040887 | 0.038633 | 1.058363 | [
"s625067831",
"s549085257"
] |
u657329920 | p02988 | python | s294313716 | s380030956 | 19 | 17 | 3,060 | 3,060 | Accepted | Accepted | 10.53 | n = int(eval(input()))
p = input().split()
p = [int(num) for num in p]
t = 0
for i in range(1,n-1):
if ((p[i-1] < p[i] and p[i] < p[i+1])
or (p[i+1] < p[i] and p[i] < p[i-1])):
t += 1
print(t) | n = int(eval(input()))
p = input().split()
p = [int(num) for num in p]
t = 0
for i in range(1,n-1):
if ((p[i-1] < p[i] < p[i+1])
or (p[i+1] < p[i] < p[i-1])):
t += 1
print(t) | 9 | 9 | 206 | 188 | n = int(eval(input()))
p = input().split()
p = [int(num) for num in p]
t = 0
for i in range(1, n - 1):
if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i + 1] < p[i] and p[i] < p[i - 1]):
t += 1
print(t)
| n = int(eval(input()))
p = input().split()
p = [int(num) for num in p]
t = 0
for i in range(1, n - 1):
if (p[i - 1] < p[i] < p[i + 1]) or (p[i + 1] < p[i] < p[i - 1]):
t += 1
print(t)
| false | 0 | [
"- if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i + 1] < p[i] and p[i] < p[i - 1]):",
"+ if (p[i - 1] < p[i] < p[i + 1]) or (p[i + 1] < p[i] < p[i - 1]):"
] | false | 0.042877 | 0.040279 | 1.064479 | [
"s294313716",
"s380030956"
] |
u506705885 | p02409 | python | s931297156 | s799726549 | 50 | 20 | 7,788 | 5,632 | Accepted | Accepted | 60 | import sys
write=sys.stdout.write
buildings=[[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]]]
for i in range(0,4):
for j in range(0,3):
for k in range(0,10):
buildings[i][j].append(0)
informations=int(eval(input()))
for i in range(0,informations):
information=[]
information=input().split()
information[0]=int(information[0])
information[1]=int(information[1])
information[2]=int(information[2])
information[3]=int(information[3])
buildings[information[0]-1][information[1]-1][information[2]-1]+=information[3]
for i in range(0,4):
for j in range(0,3):
for k in range(0,10):
write(' ')
write(str(buildings[i][j][k]))
print()
if i !=3:
for j in range(0,20):
write('#')
print() | buildings=[[[0 for i in range(10)]for m in range(3)]for k in range(4)]
x=int(input())
for i in range(x):
a,b,c,d=map(int,input().split())
buildings[a-1][b-1][c-1]+=d
for i in range(4):
for j in range(3):
for k in range(10):
print("",buildings[i][j][k],end="")
print()
if i!=3:
print("#"*20)
| 30 | 12 | 826 | 353 | import sys
write = sys.stdout.write
buildings = [[[], [], []], [[], [], []], [[], [], []], [[], [], []]]
for i in range(0, 4):
for j in range(0, 3):
for k in range(0, 10):
buildings[i][j].append(0)
informations = int(eval(input()))
for i in range(0, informations):
information = []
information = input().split()
information[0] = int(information[0])
information[1] = int(information[1])
information[2] = int(information[2])
information[3] = int(information[3])
buildings[information[0] - 1][information[1] - 1][
information[2] - 1
] += information[3]
for i in range(0, 4):
for j in range(0, 3):
for k in range(0, 10):
write(" ")
write(str(buildings[i][j][k]))
print()
if i != 3:
for j in range(0, 20):
write("#")
print()
| buildings = [[[0 for i in range(10)] for m in range(3)] for k in range(4)]
x = int(input())
for i in range(x):
a, b, c, d = map(int, input().split())
buildings[a - 1][b - 1][c - 1] += d
for i in range(4):
for j in range(3):
for k in range(10):
print("", buildings[i][j][k], end="")
print()
if i != 3:
print("#" * 20)
| false | 60 | [
"-import sys",
"-",
"-write = sys.stdout.write",
"-buildings = [[[], [], []], [[], [], []], [[], [], []], [[], [], []]]",
"-for i in range(0, 4):",
"- for j in range(0, 3):",
"- for k in range(0, 10):",
"- buildings[i][j].append(0)",
"-informations = int(eval(input()))",
"-for... | false | 0.037177 | 0.108662 | 0.342136 | [
"s931297156",
"s799726549"
] |
u730769327 | p03167 | python | s988207480 | s880430888 | 1,822 | 316 | 281,472 | 108,640 | Accepted | Accepted | 82.66 | import queue
INF=10**8
R=10**9+7
h,w=list(map(int,input().split()))
maze=[eval(input()) for _ in range(h)]
d=[[0 for i in range(h)] for _ in range(w)]
sx=0
sy=0
gx=w-1
gy=h-1
q=queue.Queue()
dx=[1,0]
dy=[0,1]
q.put((sx,sy))
d[sy][sx]=1
while not q.empty():
x,y=q.get()
if (x,y)==(gx,gy):break
for i in range(2):
nx=x+dx[i]
ny=y+dy[i]
if nx<w and ny<h:
if maze[ny][nx]=='.':
if d[nx][ny]==0:
q.put((nx,ny))
d[nx][ny]=d[x][y]
else:d[nx][ny]+=d[x][y]
print((d[gx][gy]%R)) | from collections import*
mod=10**9+7
h,w=list(map(int,input().split()))
a=[eval(input()) for _ in range(h)]
dx=[0,1]
dy=[1,0]
d=[[0]*w for _ in range(h)]
v=[[0]*w for _ in range(h)]
d[0][0]=1
q=deque([(0,0)])
while q:
x,y=q.popleft()
if v[x][y]:continue
v[x][y]=1
for i,j in zip(dx,dy):
nx=x+i
ny=y+j
if 0<=nx<h and 0<=ny<w and a[nx][ny]==".":
d[nx][ny]+=d[x][y]
d[nx][ny]%=mod
q.append((nx,ny))
print((d[-1][-1])) | 28 | 22 | 541 | 459 | import queue
INF = 10**8
R = 10**9 + 7
h, w = list(map(int, input().split()))
maze = [eval(input()) for _ in range(h)]
d = [[0 for i in range(h)] for _ in range(w)]
sx = 0
sy = 0
gx = w - 1
gy = h - 1
q = queue.Queue()
dx = [1, 0]
dy = [0, 1]
q.put((sx, sy))
d[sy][sx] = 1
while not q.empty():
x, y = q.get()
if (x, y) == (gx, gy):
break
for i in range(2):
nx = x + dx[i]
ny = y + dy[i]
if nx < w and ny < h:
if maze[ny][nx] == ".":
if d[nx][ny] == 0:
q.put((nx, ny))
d[nx][ny] = d[x][y]
else:
d[nx][ny] += d[x][y]
print((d[gx][gy] % R))
| from collections import *
mod = 10**9 + 7
h, w = list(map(int, input().split()))
a = [eval(input()) for _ in range(h)]
dx = [0, 1]
dy = [1, 0]
d = [[0] * w for _ in range(h)]
v = [[0] * w for _ in range(h)]
d[0][0] = 1
q = deque([(0, 0)])
while q:
x, y = q.popleft()
if v[x][y]:
continue
v[x][y] = 1
for i, j in zip(dx, dy):
nx = x + i
ny = y + j
if 0 <= nx < h and 0 <= ny < w and a[nx][ny] == ".":
d[nx][ny] += d[x][y]
d[nx][ny] %= mod
q.append((nx, ny))
print((d[-1][-1]))
| false | 21.428571 | [
"-import queue",
"+from collections import *",
"-INF = 10**8",
"-R = 10**9 + 7",
"+mod = 10**9 + 7",
"-maze = [eval(input()) for _ in range(h)]",
"-d = [[0 for i in range(h)] for _ in range(w)]",
"-sx = 0",
"-sy = 0",
"-gx = w - 1",
"-gy = h - 1",
"-q = queue.Queue()",
"-dx = [1, 0]",
"-dy... | false | 0.049334 | 0.04679 | 1.054366 | [
"s988207480",
"s880430888"
] |
u729133443 | p03576 | python | s143235634 | s261174898 | 1,938 | 1,524 | 62,172 | 62,556 | Accepted | Accepted | 21.36 | n,k=list(map(int,input().split()))
z=[list(map(int,input().split()))for _ in range(n)]
x=[]
y=[]
for i,j in z:
x.append(i)
y.append(j)
x.sort()
y.sort()
a=10**20
for i,l in enumerate(x):
for r in x[i+1:]:
for v,d in enumerate(y):
for u in y[v+1:]:
if sum([1for i,j in z if l<=i<=r and d<=j<=u])>=k:
a=min(a,(r-l)*(u-d))
print(a) | n,k=list(map(int,input().split()))
z=[tuple(map(int,input().split()))for _ in range(n)]
x=[i for i,_ in z]
y=[j for _,j in z]
x.sort()
y.sort()
a=10**20
for i,l in enumerate(x):
for r in x[i+1:]:
for v,d in enumerate(y):
for u in y[v+1:]:
if sum([1for i,j in z if l<=i<=r and d<=j<=u])>=k:
a=min(a,(r-l)*(u-d))
print(a) | 17 | 14 | 406 | 386 | n, k = list(map(int, input().split()))
z = [list(map(int, input().split())) for _ in range(n)]
x = []
y = []
for i, j in z:
x.append(i)
y.append(j)
x.sort()
y.sort()
a = 10**20
for i, l in enumerate(x):
for r in x[i + 1 :]:
for v, d in enumerate(y):
for u in y[v + 1 :]:
if sum([1 for i, j in z if l <= i <= r and d <= j <= u]) >= k:
a = min(a, (r - l) * (u - d))
print(a)
| n, k = list(map(int, input().split()))
z = [tuple(map(int, input().split())) for _ in range(n)]
x = [i for i, _ in z]
y = [j for _, j in z]
x.sort()
y.sort()
a = 10**20
for i, l in enumerate(x):
for r in x[i + 1 :]:
for v, d in enumerate(y):
for u in y[v + 1 :]:
if sum([1 for i, j in z if l <= i <= r and d <= j <= u]) >= k:
a = min(a, (r - l) * (u - d))
print(a)
| false | 17.647059 | [
"-z = [list(map(int, input().split())) for _ in range(n)]",
"-x = []",
"-y = []",
"-for i, j in z:",
"- x.append(i)",
"- y.append(j)",
"+z = [tuple(map(int, input().split())) for _ in range(n)]",
"+x = [i for i, _ in z]",
"+y = [j for _, j in z]"
] | false | 0.04951 | 0.049378 | 1.002673 | [
"s143235634",
"s261174898"
] |
u955251526 | p03835 | python | s238998839 | s951222554 | 1,615 | 20 | 2,940 | 2,940 | Accepted | Accepted | 98.76 | k, s = list(map(int, input().split()))
ret = 0
for i in range(k+1):
for j in range(k+1):
if i + j <= s <= i + j + k:
ret += 1
print(ret) | k, s = list(map(int, input().split()))
ret = 0
for i in range(k+1):
ret += max(0,min(s-i, 2*k-s+i)+1)
print(ret) | 7 | 5 | 160 | 114 | k, s = list(map(int, input().split()))
ret = 0
for i in range(k + 1):
for j in range(k + 1):
if i + j <= s <= i + j + k:
ret += 1
print(ret)
| k, s = list(map(int, input().split()))
ret = 0
for i in range(k + 1):
ret += max(0, min(s - i, 2 * k - s + i) + 1)
print(ret)
| false | 28.571429 | [
"- for j in range(k + 1):",
"- if i + j <= s <= i + j + k:",
"- ret += 1",
"+ ret += max(0, min(s - i, 2 * k - s + i) + 1)"
] | false | 0.069097 | 0.048471 | 1.425529 | [
"s238998839",
"s951222554"
] |
u325227960 | p02659 | python | s374694316 | s636623679 | 89 | 61 | 71,316 | 61,836 | Accepted | Accepted | 31.46 | from decimal import *
a, b = input().split()
A = int(a)
B = Decimal(b)
print((int(A * B))) | a, b= input().split()
a = int(a)
b = int(b[0]) * 100 + int(b[2:4])
print(((a * b)//100))
| 7 | 7 | 96 | 96 | from decimal import *
a, b = input().split()
A = int(a)
B = Decimal(b)
print((int(A * B)))
| a, b = input().split()
a = int(a)
b = int(b[0]) * 100 + int(b[2:4])
print(((a * b) // 100))
| false | 0 | [
"-from decimal import *",
"-",
"-A = int(a)",
"-B = Decimal(b)",
"-print((int(A * B)))",
"+a = int(a)",
"+b = int(b[0]) * 100 + int(b[2:4])",
"+print(((a * b) // 100))"
] | false | 0.038577 | 0.045711 | 0.843926 | [
"s374694316",
"s636623679"
] |
u698919163 | p02693 | python | s073253738 | s354852398 | 23 | 20 | 9,168 | 9,084 | Accepted | Accepted | 13.04 | K = int(eval(input()))
A,B = list(map(int,input().split()))
import sys
for i in range(A,B+1):
if i % K == 0:
print('OK')
sys.exit()
print('NG') | K = int(eval(input()))
A,B = list(map(int,input().split()))
tmp = B//K * K
if A <= tmp:
print('OK')
else:
print('NG') | 12 | 9 | 174 | 123 | K = int(eval(input()))
A, B = list(map(int, input().split()))
import sys
for i in range(A, B + 1):
if i % K == 0:
print("OK")
sys.exit()
print("NG")
| K = int(eval(input()))
A, B = list(map(int, input().split()))
tmp = B // K * K
if A <= tmp:
print("OK")
else:
print("NG")
| false | 25 | [
"-import sys",
"-",
"-for i in range(A, B + 1):",
"- if i % K == 0:",
"- print(\"OK\")",
"- sys.exit()",
"-print(\"NG\")",
"+tmp = B // K * K",
"+if A <= tmp:",
"+ print(\"OK\")",
"+else:",
"+ print(\"NG\")"
] | false | 0.035896 | 0.03629 | 0.989141 | [
"s073253738",
"s354852398"
] |
u995062424 | p03425 | python | s903027173 | s913953394 | 207 | 179 | 3,064 | 3,064 | Accepted | Accepted | 13.53 | import itertools
s = set()
N = int(eval(input()))
dict = {i:0 for i in "MARCH"}
sum_v = 0
ans = 0
for i in range(N):
S = eval(input())
if(S[0] in "MARCH"):
dict[S[0]] += 1
s.add(S[0])
sum_v += 1
c = itertools.combinations(s, 3)
for i in c:
ans += dict[i[0]] * dict[i[1]] * dict[i[2]]
print(ans) | import itertools
N = int(eval(input()))
march = list(itertools.combinations("MARCH", 3))
dict = {i:0 for i in "MARCH"}
for _ in range(N):
S = eval(input())
if(S[0] in "MARCH"):
dict[S[0]] += 1
ans = 0
for i in range(10):
ans += dict[march[i][0]]*dict[march[i][1]]*dict[march[i][2]]
print(ans) | 20 | 13 | 353 | 315 | import itertools
s = set()
N = int(eval(input()))
dict = {i: 0 for i in "MARCH"}
sum_v = 0
ans = 0
for i in range(N):
S = eval(input())
if S[0] in "MARCH":
dict[S[0]] += 1
s.add(S[0])
sum_v += 1
c = itertools.combinations(s, 3)
for i in c:
ans += dict[i[0]] * dict[i[1]] * dict[i[2]]
print(ans)
| import itertools
N = int(eval(input()))
march = list(itertools.combinations("MARCH", 3))
dict = {i: 0 for i in "MARCH"}
for _ in range(N):
S = eval(input())
if S[0] in "MARCH":
dict[S[0]] += 1
ans = 0
for i in range(10):
ans += dict[march[i][0]] * dict[march[i][1]] * dict[march[i][2]]
print(ans)
| false | 35 | [
"-s = set()",
"+march = list(itertools.combinations(\"MARCH\", 3))",
"-sum_v = 0",
"-ans = 0",
"-for i in range(N):",
"+for _ in range(N):",
"- s.add(S[0])",
"- sum_v += 1",
"-c = itertools.combinations(s, 3)",
"-for i in c:",
"- ans += dict[i[0]] * dict[i[1]] * dict[i[2]]",
"... | false | 0.038323 | 0.037463 | 1.022939 | [
"s903027173",
"s913953394"
] |
u639343026 | p02881 | python | s277107844 | s923320577 | 161 | 114 | 3,572 | 3,268 | Accepted | Accepted | 29.19 | a=int(eval(input()))
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
res=[]
if n % i == 0:
res.append(i)
if i != n // i:
res.append(n//i)
if res!=[]:
divisors.append(res)
return divisors
res=make_divisors(a)
my_min=0
for i in range(len(res)):
if i==0:
if len(res[i])==2:
my_min=res[i][0]+res[i][1]
else:
my_min=(res[i][0]*2)
else:
if len(res[i])==2:
my_min=min(my_min,res[i][0]+res[i][1])
else:
my_min=min(my_min,res[i][0]*2)
print((my_min-2)) | n=int(eval(input()))
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
# divisors.sort()
return divisors
a=make_divisors(n)
#print(a)
if a[-1]**2==n:
print((a[-1]*2-2))
else:
print((a[-1]+a[-2]-2)) | 29 | 17 | 667 | 368 | a = int(eval(input()))
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5) + 1):
res = []
if n % i == 0:
res.append(i)
if i != n // i:
res.append(n // i)
if res != []:
divisors.append(res)
return divisors
res = make_divisors(a)
my_min = 0
for i in range(len(res)):
if i == 0:
if len(res[i]) == 2:
my_min = res[i][0] + res[i][1]
else:
my_min = res[i][0] * 2
else:
if len(res[i]) == 2:
my_min = min(my_min, res[i][0] + res[i][1])
else:
my_min = min(my_min, res[i][0] * 2)
print((my_min - 2))
| n = int(eval(input()))
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
# divisors.sort()
return divisors
a = make_divisors(n)
# print(a)
if a[-1] ** 2 == n:
print((a[-1] * 2 - 2))
else:
print((a[-1] + a[-2] - 2))
| false | 41.37931 | [
"-a = int(eval(input()))",
"+n = int(eval(input()))",
"- res = []",
"- res.append(i)",
"+ divisors.append(i)",
"- res.append(n // i)",
"- if res != []:",
"- divisors.append(res)",
"+ divisors.append(n // i)",
"+ # divi... | false | 0.059013 | 0.044099 | 1.338201 | [
"s277107844",
"s923320577"
] |
u285891772 | p02773 | python | s664463898 | s281182116 | 756 | 660 | 51,796 | 51,760 | Accepted | Accepted | 12.7 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
N = INT()
S = [eval(input()) for _ in range(N)]
cnt_s = Counter(S)
tmp = cnt_s.most_common()[0][1]
for key, val in sorted(cnt_s.most_common(), key=lambda x:x[0]):
if val == tmp:
print(key) | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
N = INT()
S = [eval(input()) for _ in range(N)]
cnt_s = Counter(S)
tmp = cnt_s.most_common()[0][1]
for key, val in sorted(cnt_s.most_common(), key=itemgetter(0)):
if val == tmp:
print(key) | 27 | 27 | 923 | 925 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input():
return sys.stdin.readline().strip()
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST():
return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
N = INT()
S = [eval(input()) for _ in range(N)]
cnt_s = Counter(S)
tmp = cnt_s.most_common()[0][1]
for key, val in sorted(cnt_s.most_common(), key=lambda x: x[0]):
if val == tmp:
print(key)
| import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input():
return sys.stdin.readline().strip()
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST():
return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
N = INT()
S = [eval(input()) for _ in range(N)]
cnt_s = Counter(S)
tmp = cnt_s.most_common()[0][1]
for key, val in sorted(cnt_s.most_common(), key=itemgetter(0)):
if val == tmp:
print(key)
| false | 0 | [
"-for key, val in sorted(cnt_s.most_common(), key=lambda x: x[0]):",
"+for key, val in sorted(cnt_s.most_common(), key=itemgetter(0)):"
] | false | 0.040746 | 0.038592 | 1.055799 | [
"s664463898",
"s281182116"
] |
u891635666 | p02913 | python | s430301027 | s816962069 | 204 | 75 | 5,864 | 6,388 | Accepted | Accepted | 63.24 | import collections
class RollingHashSingle:
def __init__(self, s, base, mod):
self.base = base
self.mod = mod
self.hash = [0]
self.power = [1]
for c in s:
self.hash.append((self.hash[-1] * base + ord(c)) % mod)
self.power.append(self.power[-1] * base % mod)
def get(self, left, right):
h = self.hash[right] - self.hash[left] * self.power[right - left]
return (h + self.mod) % self.mod
class RollingHash:
def __init__(self,
s,
base=(10**4 + 7, 10**4 + 9),
mod=(10**9 + 7, 10**9 + 9)):
if isinstance(base, int):
assert isinstance(mod, int)
self.base = (base, )
self.mod = (mod, )
elif isinstance(base, tuple):
assert isinstance(mod, tuple)
assert len(base) == len(mod)
self.base = base
self.mod = mod
else:
raise ValueError()
self._rh = [
RollingHashSingle(s, base, mod)
for base, mod in zip(self.base, self.mod)
]
def get(self, left, right):
return tuple(rh.get(left, right) for rh in self._rh)
n = int(eval(input()))
s = input().rstrip()
rh = RollingHash(s)
def check(diff):
d = collections.defaultdict(list)
for i in range(n - diff + 1):
h = rh.get(i, i + diff)
d[h].append(i)
for l in list(d.values()):
if max(l) - min(l) >= diff:
return True
return False
lo = 0
hi = n // 2 + 1
while lo + 1 < hi:
mid = (lo + hi) // 2
if check(mid):
lo = mid
else:
hi = mid
print(lo) | n = int(eval(input()))
s = input().rstrip()
def check(length):
d = set()
for i in range(n - 2 * length + 1):
d.add(s[i:i + length])
if s[i + length:i + 2 * length] in d:
return True
return False
lo = 0
hi = n // 2 + 1
while lo + 1 < hi:
mid = (lo + hi) // 2
if check(mid):
lo = mid
else:
hi = mid
print(lo) | 70 | 22 | 1,735 | 393 | import collections
class RollingHashSingle:
def __init__(self, s, base, mod):
self.base = base
self.mod = mod
self.hash = [0]
self.power = [1]
for c in s:
self.hash.append((self.hash[-1] * base + ord(c)) % mod)
self.power.append(self.power[-1] * base % mod)
def get(self, left, right):
h = self.hash[right] - self.hash[left] * self.power[right - left]
return (h + self.mod) % self.mod
class RollingHash:
def __init__(
self, s, base=(10**4 + 7, 10**4 + 9), mod=(10**9 + 7, 10**9 + 9)
):
if isinstance(base, int):
assert isinstance(mod, int)
self.base = (base,)
self.mod = (mod,)
elif isinstance(base, tuple):
assert isinstance(mod, tuple)
assert len(base) == len(mod)
self.base = base
self.mod = mod
else:
raise ValueError()
self._rh = [
RollingHashSingle(s, base, mod) for base, mod in zip(self.base, self.mod)
]
def get(self, left, right):
return tuple(rh.get(left, right) for rh in self._rh)
n = int(eval(input()))
s = input().rstrip()
rh = RollingHash(s)
def check(diff):
d = collections.defaultdict(list)
for i in range(n - diff + 1):
h = rh.get(i, i + diff)
d[h].append(i)
for l in list(d.values()):
if max(l) - min(l) >= diff:
return True
return False
lo = 0
hi = n // 2 + 1
while lo + 1 < hi:
mid = (lo + hi) // 2
if check(mid):
lo = mid
else:
hi = mid
print(lo)
| n = int(eval(input()))
s = input().rstrip()
def check(length):
d = set()
for i in range(n - 2 * length + 1):
d.add(s[i : i + length])
if s[i + length : i + 2 * length] in d:
return True
return False
lo = 0
hi = n // 2 + 1
while lo + 1 < hi:
mid = (lo + hi) // 2
if check(mid):
lo = mid
else:
hi = mid
print(lo)
| false | 68.571429 | [
"-import collections",
"+n = int(eval(input()))",
"+s = input().rstrip()",
"-class RollingHashSingle:",
"- def __init__(self, s, base, mod):",
"- self.base = base",
"- self.mod = mod",
"- self.hash = [0]",
"- self.power = [1]",
"- for c in s:",
"- ... | false | 0.042798 | 0.071879 | 0.595417 | [
"s430301027",
"s816962069"
] |
u425177436 | p03495 | python | s538812181 | s506019341 | 142 | 92 | 44,984 | 35,616 | Accepted | Accepted | 35.21 | N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = {i:0 for i in set(A)}
for a in A:
B[a] += 1
print((sum(sorted(B.values())[:-K]))) | N, K = list(map(int, input().split()))
B = {}
for i in input().split():
if i in B:
B[i] += 1
else:
B[i] = 1
print((sum(sorted(B.values())[:-K]))) | 6 | 8 | 161 | 168 | N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = {i: 0 for i in set(A)}
for a in A:
B[a] += 1
print((sum(sorted(B.values())[:-K])))
| N, K = list(map(int, input().split()))
B = {}
for i in input().split():
if i in B:
B[i] += 1
else:
B[i] = 1
print((sum(sorted(B.values())[:-K])))
| false | 25 | [
"-A = list(map(int, input().split()))",
"-B = {i: 0 for i in set(A)}",
"-for a in A:",
"- B[a] += 1",
"+B = {}",
"+for i in input().split():",
"+ if i in B:",
"+ B[i] += 1",
"+ else:",
"+ B[i] = 1"
] | false | 0.052569 | 0.049965 | 1.052119 | [
"s538812181",
"s506019341"
] |
u297801580 | p03171 | python | s289147290 | s894507920 | 305 | 280 | 111,708 | 110,192 | Accepted | Accepted | 8.2 | def main():
n = int(eval(input()))
a = list(map(int, input().split()))
dp = [[0] * n for _ in range(n)]
for i in range(n):
dp[i][i] = a[i]
for i in range(n - 2, -1, -1):
for j in range(i + 1, n):
dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])
print((dp[0][n - 1]))
main() | def main():
n = int(eval(input()))
a = list(map(int, input().split()))
dp = [0] * (n*n)
for i in range(n):
dp[i+i*n] = a[i]
for i in range(n - 2, -1, -1):
for j in range(i + 1, n):
dp[i+j*n] = max(a[i] - dp[i + 1+j*n], a[j] - dp[i+(j - 1)*n])
print((dp[(n - 1)*n]))
main() | 12 | 11 | 338 | 326 | def main():
n = int(eval(input()))
a = list(map(int, input().split()))
dp = [[0] * n for _ in range(n)]
for i in range(n):
dp[i][i] = a[i]
for i in range(n - 2, -1, -1):
for j in range(i + 1, n):
dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])
print((dp[0][n - 1]))
main()
| def main():
n = int(eval(input()))
a = list(map(int, input().split()))
dp = [0] * (n * n)
for i in range(n):
dp[i + i * n] = a[i]
for i in range(n - 2, -1, -1):
for j in range(i + 1, n):
dp[i + j * n] = max(a[i] - dp[i + 1 + j * n], a[j] - dp[i + (j - 1) * n])
print((dp[(n - 1) * n]))
main()
| false | 8.333333 | [
"- dp = [[0] * n for _ in range(n)]",
"+ dp = [0] * (n * n)",
"- dp[i][i] = a[i]",
"+ dp[i + i * n] = a[i]",
"- dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])",
"- print((dp[0][n - 1]))",
"+ dp[i + j * n] = max(a[i] - dp[i + 1 + j * n], a[j] - dp[i ... | false | 0.035861 | 0.035637 | 1.006268 | [
"s289147290",
"s894507920"
] |
u747602774 | p02928 | python | s924279084 | s495288497 | 1,642 | 1,382 | 3,188 | 3,188 | Accepted | Accepted | 15.83 | N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
P = 10**9+7
ans = 0
for i in range(N):
for j in range(N):
if i == j:
continue
if A[i] > A[j]:
if i < j:
ans += K*(K+1)//2
ans %= P
else:
ans += K*(K-1)//2
ans %= P
print(ans)
| N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
P = 10**9+7
ans1 = 0
ans2 = 0
for i in range(N):
for j in range(N):
if i == j:
continue
if A[i] > A[j]:
if i < j:
ans1 += 1
else:
ans2 += 1
K1 = (K*(K+1)//2)%P
K2 = (K*(K-1)//2)%P
ans = (ans1*K1+ans2*K2)%P
print(ans)
| 18 | 23 | 380 | 398 | N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
P = 10**9 + 7
ans = 0
for i in range(N):
for j in range(N):
if i == j:
continue
if A[i] > A[j]:
if i < j:
ans += K * (K + 1) // 2
ans %= P
else:
ans += K * (K - 1) // 2
ans %= P
print(ans)
| N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
P = 10**9 + 7
ans1 = 0
ans2 = 0
for i in range(N):
for j in range(N):
if i == j:
continue
if A[i] > A[j]:
if i < j:
ans1 += 1
else:
ans2 += 1
K1 = (K * (K + 1) // 2) % P
K2 = (K * (K - 1) // 2) % P
ans = (ans1 * K1 + ans2 * K2) % P
print(ans)
| false | 21.73913 | [
"-ans = 0",
"+ans1 = 0",
"+ans2 = 0",
"- ans += K * (K + 1) // 2",
"- ans %= P",
"+ ans1 += 1",
"- ans += K * (K - 1) // 2",
"- ans %= P",
"+ ans2 += 1",
"+K1 = (K * (K + 1) // 2) % P",
"+K2 = (K * (K - 1) ... | false | 0.114011 | 0.035103 | 3.247887 | [
"s924279084",
"s495288497"
] |
u272457181 | p02627 | python | s591575348 | s535664610 | 29 | 26 | 8,984 | 8,892 | Accepted | Accepted | 10.34 | x = eval(input())
if x.isupper():
print('A')
else:
print('a') | a = eval(input())
if a.isupper():
print('A')
else:
print('a') | 5 | 5 | 63 | 63 | x = eval(input())
if x.isupper():
print("A")
else:
print("a")
| a = eval(input())
if a.isupper():
print("A")
else:
print("a")
| false | 0 | [
"-x = eval(input())",
"-if x.isupper():",
"+a = eval(input())",
"+if a.isupper():"
] | false | 0.117937 | 0.048425 | 2.43543 | [
"s591575348",
"s535664610"
] |
u561231954 | p02720 | python | s283386883 | s331601354 | 296 | 189 | 12,296 | 19,356 | Accepted | Accepted | 36.15 | MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)
K = int(eval(input()))
lunlun = []
def dfs(i,before):
if i == 11:
return
lunlun.append(before)
back = before%10
for j in range(-1,2):
t = back + j
if 0 <= t < 10:
dfs(i + 1,before*10 + t)
for i in range(1,10):
dfs(1,i)
lunlun.sort()
print((lunlun[K - 1]))
| import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
Lunlun = []
K = int(eval(input()))
def dfs(i,before):
if i == 10:
return
Lunlun.append(before)
x = before%10
for d in (-1,0,1):
y = x + d
if y < 0 or y >= 10:
continue
dfs(i + 1,before*10 + y)
for i in range(1,10):
dfs(0,i)
Lunlun.sort()
ans = Lunlun[K - 1]
print(ans) | 22 | 24 | 405 | 428 | MOD = 10**9 + 7
INF = 10**11
import sys
sys.setrecursionlimit(100000000)
K = int(eval(input()))
lunlun = []
def dfs(i, before):
if i == 11:
return
lunlun.append(before)
back = before % 10
for j in range(-1, 2):
t = back + j
if 0 <= t < 10:
dfs(i + 1, before * 10 + t)
for i in range(1, 10):
dfs(1, i)
lunlun.sort()
print((lunlun[K - 1]))
| import sys
sys.setrecursionlimit(10000000)
MOD = 10**9 + 7
INF = 10**15
Lunlun = []
K = int(eval(input()))
def dfs(i, before):
if i == 10:
return
Lunlun.append(before)
x = before % 10
for d in (-1, 0, 1):
y = x + d
if y < 0 or y >= 10:
continue
dfs(i + 1, before * 10 + y)
for i in range(1, 10):
dfs(0, i)
Lunlun.sort()
ans = Lunlun[K - 1]
print(ans)
| false | 8.333333 | [
"-MOD = 10**9 + 7",
"-INF = 10**11",
"-sys.setrecursionlimit(100000000)",
"+sys.setrecursionlimit(10000000)",
"+MOD = 10**9 + 7",
"+INF = 10**15",
"+Lunlun = []",
"-lunlun = []",
"- if i == 11:",
"+ if i == 10:",
"- lunlun.append(before)",
"- back = before % 10",
"- for j in r... | false | 0.353694 | 0.29781 | 1.187647 | [
"s283386883",
"s331601354"
] |
u715329136 | p02602 | python | s874057696 | s883861198 | 150 | 127 | 93,192 | 31,672 | Accepted | Accepted | 15.33 | NK = list(map(int, input().split(' ')))
N = NK[0]
K = NK[1]
A = list(map(int, input().split(' ')))
for i in range(K, N):
if (A[i-K] < A[i]):
print('Yes')
else:
print('No')
| def resolve():
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(k, n):
if (A[i-k] < A[i]):
print('Yes')
else:
print('No')
if __name__ == "__main__":
resolve() | 10 | 12 | 206 | 262 | NK = list(map(int, input().split(" ")))
N = NK[0]
K = NK[1]
A = list(map(int, input().split(" ")))
for i in range(K, N):
if A[i - K] < A[i]:
print("Yes")
else:
print("No")
| def resolve():
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(k, n):
if A[i - k] < A[i]:
print("Yes")
else:
print("No")
if __name__ == "__main__":
resolve()
| false | 16.666667 | [
"-NK = list(map(int, input().split(\" \")))",
"-N = NK[0]",
"-K = NK[1]",
"-A = list(map(int, input().split(\" \")))",
"-for i in range(K, N):",
"- if A[i - K] < A[i]:",
"- print(\"Yes\")",
"- else:",
"- print(\"No\")",
"+def resolve():",
"+ n, k = list(map(int, input().sp... | false | 0.084821 | 0.122857 | 0.6904 | [
"s874057696",
"s883861198"
] |
u912237403 | p00161 | python | s165064368 | s606142038 | 80 | 70 | 4,988 | 4,984 | Accepted | Accepted | 12.5 | while 1:
n = eval(input())
if n==0: break
d = [0]*n
for i in range(n):
x = list(map(int, input().split()))
d[i]=[sum(x[1::2])*60+sum(x[2::2]),x[0]]
d = sorted(d)
print(d[0][1])
print(d[1][1])
print(d[-2][1]) | while 1:
n = eval(input())
if n==0: break
D = [0]*n
for j in range(n):
a,b,c,d,e,f,g,h,i = list(map(int, input().split()))
D[j] = [(b+d+f+h)*60 + c+e+g+i, a]
D = sorted(D)
print(D[0][1])
print(D[1][1])
print(D[-2][1]) | 11 | 11 | 230 | 240 | while 1:
n = eval(input())
if n == 0:
break
d = [0] * n
for i in range(n):
x = list(map(int, input().split()))
d[i] = [sum(x[1::2]) * 60 + sum(x[2::2]), x[0]]
d = sorted(d)
print(d[0][1])
print(d[1][1])
print(d[-2][1])
| while 1:
n = eval(input())
if n == 0:
break
D = [0] * n
for j in range(n):
a, b, c, d, e, f, g, h, i = list(map(int, input().split()))
D[j] = [(b + d + f + h) * 60 + c + e + g + i, a]
D = sorted(D)
print(D[0][1])
print(D[1][1])
print(D[-2][1])
| false | 0 | [
"- d = [0] * n",
"- for i in range(n):",
"- x = list(map(int, input().split()))",
"- d[i] = [sum(x[1::2]) * 60 + sum(x[2::2]), x[0]]",
"- d = sorted(d)",
"- print(d[0][1])",
"- print(d[1][1])",
"- print(d[-2][1])",
"+ D = [0] * n",
"+ for j in range(n):",
"+... | false | 0.045347 | 0.042766 | 1.060336 | [
"s165064368",
"s606142038"
] |
u704001626 | p03013 | python | s869817263 | s872345220 | 479 | 203 | 460,312 | 8,864 | Accepted | Accepted | 57.62 | # -*- coding: utf-8 -*-
n,m = list(map(int,input().split()))
a = [int(eval(input())) for i in range(m)]
inf=float("inf")
fib_memo = [-inf for i in range(n+1)]
fib_memo[0] = 1
if 1 in a:
fib_memo[1]=0
else:
fib_memo[1]=1
for i in a:
fib_memo[i]=0
if 1 in [a[i] - a[i-1] for i in range(1,m)]:
print((0))
import sys
sys.exit()
else:
cur_fib_i = 2
while cur_fib_i <= n:
if fib_memo[cur_fib_i]==0:
pass
else:
fib_memo[cur_fib_i] = fib_memo[cur_fib_i-1] + fib_memo[cur_fib_i-2]
cur_fib_i += 1
print((fib_memo[n]%1000000007))
#print(fib_memo)
| # -*- coding: utf-8 -*-
n,m = list(map(int,input().split()))
a = [int(eval(input())) for i in range(m)]
from collections import deque
stack_deque = deque(a)
def pl():
try:
return stack_deque.popleft()
except:
return -1
MOD = 10**9+7
#i段目への移動方法
dp = [0] * (n+1)
dp[0]=1
min_a = pl()
if min_a!=1:
dp[1]=1
else:
min_a = pl()
for i in range(2,n+1):
if i == min_a:
dp[i]=0
min_a = pl()
else:
dp[i]=(dp[i-1]%MOD+dp[i-2]%MOD) % MOD
print((dp[-1])) | 29 | 29 | 637 | 527 | # -*- coding: utf-8 -*-
n, m = list(map(int, input().split()))
a = [int(eval(input())) for i in range(m)]
inf = float("inf")
fib_memo = [-inf for i in range(n + 1)]
fib_memo[0] = 1
if 1 in a:
fib_memo[1] = 0
else:
fib_memo[1] = 1
for i in a:
fib_memo[i] = 0
if 1 in [a[i] - a[i - 1] for i in range(1, m)]:
print((0))
import sys
sys.exit()
else:
cur_fib_i = 2
while cur_fib_i <= n:
if fib_memo[cur_fib_i] == 0:
pass
else:
fib_memo[cur_fib_i] = fib_memo[cur_fib_i - 1] + fib_memo[cur_fib_i - 2]
cur_fib_i += 1
print((fib_memo[n] % 1000000007))
# print(fib_memo)
| # -*- coding: utf-8 -*-
n, m = list(map(int, input().split()))
a = [int(eval(input())) for i in range(m)]
from collections import deque
stack_deque = deque(a)
def pl():
try:
return stack_deque.popleft()
except:
return -1
MOD = 10**9 + 7
# i段目への移動方法
dp = [0] * (n + 1)
dp[0] = 1
min_a = pl()
if min_a != 1:
dp[1] = 1
else:
min_a = pl()
for i in range(2, n + 1):
if i == min_a:
dp[i] = 0
min_a = pl()
else:
dp[i] = (dp[i - 1] % MOD + dp[i - 2] % MOD) % MOD
print((dp[-1]))
| false | 0 | [
"-inf = float(\"inf\")",
"-fib_memo = [-inf for i in range(n + 1)]",
"-fib_memo[0] = 1",
"-if 1 in a:",
"- fib_memo[1] = 0",
"+from collections import deque",
"+",
"+stack_deque = deque(a)",
"+",
"+",
"+def pl():",
"+ try:",
"+ return stack_deque.popleft()",
"+ except:",
... | false | 0.047206 | 0.112935 | 0.417993 | [
"s869817263",
"s872345220"
] |
u186838327 | p03107 | python | s244313561 | s585368499 | 171 | 74 | 39,408 | 64,476 | Accepted | Accepted | 56.73 | s =str(eval(input()))
a = 0
b = 0
for i in range(len(s)):
if s[i] == '0':
a += 1
else:
b += 1
print((min(a, b)*2))
| s = str(eval(input()))
a = 0
b = 0
for i in range(len(s)):
if s[i] == '0':
a += 1
else:
b += 1
print((2*min(a, b)))
| 9 | 9 | 139 | 140 | s = str(eval(input()))
a = 0
b = 0
for i in range(len(s)):
if s[i] == "0":
a += 1
else:
b += 1
print((min(a, b) * 2))
| s = str(eval(input()))
a = 0
b = 0
for i in range(len(s)):
if s[i] == "0":
a += 1
else:
b += 1
print((2 * min(a, b)))
| false | 0 | [
"-print((min(a, b) * 2))",
"+print((2 * min(a, b)))"
] | false | 0.036741 | 0.035923 | 1.022768 | [
"s244313561",
"s585368499"
] |
u280667879 | p03714 | python | s098983714 | s168174278 | 552 | 506 | 127,576 | 127,576 | Accepted | Accepted | 8.33 | import sys,heapq
n,*a=list(map(int,sys.stdin.read().split()))
def f(l,m,n,d):
s=0
q=[]
for i in range(l,m,d):
s+=a[i]
heapq.heappush(q,a[i]*d)
r=[s]
for i in range(m,n,d):
s+=a[i]
heapq.heappush(q,a[i]*d)
s-=heapq.heappop(q)*d
r.append(s)
return r
ra=f(0,n,2*n,1)
rb=reversed(f(3*n-1,2*n-1,n-1,-1))
print((max(x-y for x,y in zip(ra,rb)))) | def f(l,m,n,d):
s=0;q=[]
for i in range(l,m,d):s+=a[i];heappush(q,a[i]*d)
r=[s]
for i in range(m,n,d):s+=a[i];heappush(q,a[i]*d);s-=heappop(q)*d;r+=[s]
return r
import sys;from heapq import*;n,*a=list(map(int,sys.stdin.read().split()));print((max(x-y for x,y in zip(f(0,n,2*n,1),reversed(f(3*n-1,2*n-1,n-1,-1)))))) | 18 | 7 | 371 | 323 | import sys, heapq
n, *a = list(map(int, sys.stdin.read().split()))
def f(l, m, n, d):
s = 0
q = []
for i in range(l, m, d):
s += a[i]
heapq.heappush(q, a[i] * d)
r = [s]
for i in range(m, n, d):
s += a[i]
heapq.heappush(q, a[i] * d)
s -= heapq.heappop(q) * d
r.append(s)
return r
ra = f(0, n, 2 * n, 1)
rb = reversed(f(3 * n - 1, 2 * n - 1, n - 1, -1))
print((max(x - y for x, y in zip(ra, rb))))
| def f(l, m, n, d):
s = 0
q = []
for i in range(l, m, d):
s += a[i]
heappush(q, a[i] * d)
r = [s]
for i in range(m, n, d):
s += a[i]
heappush(q, a[i] * d)
s -= heappop(q) * d
r += [s]
return r
import sys
from heapq import *
n, *a = list(map(int, sys.stdin.read().split()))
print(
(
max(
x - y
for x, y in zip(
f(0, n, 2 * n, 1), reversed(f(3 * n - 1, 2 * n - 1, n - 1, -1))
)
)
)
)
| false | 61.111111 | [
"-import sys, heapq",
"-",
"-n, *a = list(map(int, sys.stdin.read().split()))",
"-",
"-",
"- heapq.heappush(q, a[i] * d)",
"+ heappush(q, a[i] * d)",
"- heapq.heappush(q, a[i] * d)",
"- s -= heapq.heappop(q) * d",
"- r.append(s)",
"+ heappush(q, a[i] * d... | false | 0.032634 | 0.043747 | 0.745965 | [
"s098983714",
"s168174278"
] |
u844646164 | p03546 | python | s766678971 | s610868517 | 221 | 91 | 40,668 | 73,772 | Accepted | Accepted | 58.82 | h, w = list(map(int, input().split()))
d = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(h)]
def warshall_floyd(d):
#d[i][j]: iからjへの最短距離
for k in range(10):
for i in range(10):
for j in range(10):
d[i][j] = min(d[i][j],d[i][k] + d[k][j])
return d
d = warshall_floyd(d)
ans = 0
for i in range(h):
for j in range(w):
if A[i][j] != 1 and A[i][j] != -1:
ans += d[A[i][j]][1]
print(ans) | H, W = list(map(int, input().split()))
c = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]
def warshall_floyd(d):
#d[i][j]: iからjへの最短距離
for k in range(10):
for i in range(10):
for j in range(10):
d[i][j] = min(d[i][j],d[i][k] + d[k][j])
return d
d = warshall_floyd(c)
ans = 0
for i in range(H):
for j in range(W):
if A[i][j] != -1 and A[i][j] != 1:
ans += d[A[i][j]][1]
print(ans) | 19 | 19 | 528 | 526 | h, w = list(map(int, input().split()))
d = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(h)]
def warshall_floyd(d):
# d[i][j]: iからjへの最短距離
for k in range(10):
for i in range(10):
for j in range(10):
d[i][j] = min(d[i][j], d[i][k] + d[k][j])
return d
d = warshall_floyd(d)
ans = 0
for i in range(h):
for j in range(w):
if A[i][j] != 1 and A[i][j] != -1:
ans += d[A[i][j]][1]
print(ans)
| H, W = list(map(int, input().split()))
c = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]
def warshall_floyd(d):
# d[i][j]: iからjへの最短距離
for k in range(10):
for i in range(10):
for j in range(10):
d[i][j] = min(d[i][j], d[i][k] + d[k][j])
return d
d = warshall_floyd(c)
ans = 0
for i in range(H):
for j in range(W):
if A[i][j] != -1 and A[i][j] != 1:
ans += d[A[i][j]][1]
print(ans)
| false | 0 | [
"-h, w = list(map(int, input().split()))",
"-d = [list(map(int, input().split())) for _ in range(10)]",
"-A = [list(map(int, input().split())) for _ in range(h)]",
"+H, W = list(map(int, input().split()))",
"+c = [list(map(int, input().split())) for _ in range(10)]",
"+A = [list(map(int, input().split()))... | false | 0.03515 | 0.034827 | 1.00926 | [
"s766678971",
"s610868517"
] |
u353895424 | p04045 | python | s392137580 | s399351609 | 201 | 76 | 40,924 | 73,576 | Accepted | Accepted | 62.19 | n, k = list(map(int, input().split()))
d = list(map(int, input().split()))
use = [i for i in range(10)]
for _d in d:
use.remove(_d)
while True:
ok = True
s = str(n)
for i in range(len(s)):
if int(s[i]) not in use:
ok = False
break
if ok:
print(n)
exit()
else:
n += 1
| n, k = list(map(int, input().split()))
D = list(map(str, input().split()))
money = n
ok = True
while True:
for d in D:
if d in str(money):
ok = False
break
if ok:
print(money)
break
money += 1
ok = True | 23 | 14 | 369 | 273 | n, k = list(map(int, input().split()))
d = list(map(int, input().split()))
use = [i for i in range(10)]
for _d in d:
use.remove(_d)
while True:
ok = True
s = str(n)
for i in range(len(s)):
if int(s[i]) not in use:
ok = False
break
if ok:
print(n)
exit()
else:
n += 1
| n, k = list(map(int, input().split()))
D = list(map(str, input().split()))
money = n
ok = True
while True:
for d in D:
if d in str(money):
ok = False
break
if ok:
print(money)
break
money += 1
ok = True
| false | 39.130435 | [
"-d = list(map(int, input().split()))",
"-use = [i for i in range(10)]",
"-for _d in d:",
"- use.remove(_d)",
"+D = list(map(str, input().split()))",
"+money = n",
"+ok = True",
"- ok = True",
"- s = str(n)",
"- for i in range(len(s)):",
"- if int(s[i]) not in use:",
"+ f... | false | 0.044762 | 0.075824 | 0.59034 | [
"s392137580",
"s399351609"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.