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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u063052907 | p03150 | python | s374837802 | s543299909 | 21 | 19 | 3,060 | 3,060 | Accepted | Accepted | 9.52 | S = eval(input())
ans = "NO"
for i in range(len(S)):
for j in range(1, len(S)):
t = S[:i] + S[j:]
if t == "keyence":
ans = "YES"
break
print(ans) | S = eval(input())
ans = "NO"
for i in range(len(S)):
for j in range(i, len(S)):
t = S[:i] + S[j:]
if t == "keyence":
ans = "YES"
break
print(ans) | 10 | 10 | 193 | 193 | S = eval(input())
ans = "NO"
for i in range(len(S)):
for j in range(1, len(S)):
t = S[:i] + S[j:]
if t == "keyence":
ans = "YES"
break
print(ans)
| S = eval(input())
ans = "NO"
for i in range(len(S)):
for j in range(i, len(S)):
t = S[:i] + S[j:]
if t == "keyence":
ans = "YES"
break
print(ans)
| false | 0 | [
"- for j in range(1, len(S)):",
"+ for j in range(i, len(S)):"
] | false | 0.036786 | 0.037052 | 0.992807 | [
"s374837802",
"s543299909"
] |
u518987899 | p03013 | python | s657831945 | s711999232 | 648 | 595 | 462,708 | 462,708 | Accepted | Accepted | 8.18 | import sys
N,M = list(map(int, input().strip().split(' ')))
broken = set(int(line.strip()) for line in sys.stdin)
p = [0]*(N+2)
p[0] = 1
for i in range(N):
# 今i段目にいる
if i in broken:
continue
p[i+1] += p[i]
p[i+2] += p[i]
print((p[N]%1000000007))
| import sys
N,M = list(map(int, input().strip().split(' ')))
if M > 0:
broken = set(int(line.strip()) for line in sys.stdin)
else:
broken = set()
p = [0]*(N+2)
p[0] = 1
for i in range(N):
# 今i段目にいる
if i in broken:
continue
p[i+1] += p[i]
p[i+2] += p[i]
print((p[N]%1000000007))
| 12 | 15 | 261 | 299 | import sys
N, M = list(map(int, input().strip().split(" ")))
broken = set(int(line.strip()) for line in sys.stdin)
p = [0] * (N + 2)
p[0] = 1
for i in range(N):
# 今i段目にいる
if i in broken:
continue
p[i + 1] += p[i]
p[i + 2] += p[i]
print((p[N] % 1000000007))
| import sys
N, M = list(map(int, input().strip().split(" ")))
if M > 0:
broken = set(int(line.strip()) for line in sys.stdin)
else:
broken = set()
p = [0] * (N + 2)
p[0] = 1
for i in range(N):
# 今i段目にいる
if i in broken:
continue
p[i + 1] += p[i]
p[i + 2] += p[i]
print((p[N] % 1000000007))
| false | 20 | [
"-broken = set(int(line.strip()) for line in sys.stdin)",
"+if M > 0:",
"+ broken = set(int(line.strip()) for line in sys.stdin)",
"+else:",
"+ broken = set()"
] | false | 0.043813 | 0.145818 | 0.300462 | [
"s657831945",
"s711999232"
] |
u291303494 | p03013 | python | s920821910 | s266856278 | 1,510 | 638 | 535,480 | 469,684 | Accepted | Accepted | 57.75 | import sys
sys.setrecursionlimit(1000000)
def steps(n):
if memo[n] != -1:
return memo[n]
one = memo[n-1] if memo[n-1] != -1 else steps(n-1)
two = memo[n-2] if memo[n-2] != -1 else steps(n-2)
memo[n] = one + two
return memo[n]
n, m = list(map(int, input().split()))
broken = [int(eval(input())) for i in range(m)]
memo = [-1 for i in range(n+1)]
memo[0] = 1
memo[1] = 1
for b in broken:
memo[b] = 0
print((steps(n) % (10**9+7))) | n, m = list(map(int, input().split()))
broken = [int(eval(input())) for i in range(m)]
dp = [-1 for i in range(n+1)]
dp[0] = 1
dp[1] = 1
for b in broken:
dp[b] = 0
for i in range(2, n+1):
if dp[i] == -1:
dp[i] = dp[i-1] + dp[i-2]
print((dp[n] % (10**9+7))) | 23 | 11 | 481 | 266 | import sys
sys.setrecursionlimit(1000000)
def steps(n):
if memo[n] != -1:
return memo[n]
one = memo[n - 1] if memo[n - 1] != -1 else steps(n - 1)
two = memo[n - 2] if memo[n - 2] != -1 else steps(n - 2)
memo[n] = one + two
return memo[n]
n, m = list(map(int, input().split()))
broken = [int(eval(input())) for i in range(m)]
memo = [-1 for i in range(n + 1)]
memo[0] = 1
memo[1] = 1
for b in broken:
memo[b] = 0
print((steps(n) % (10**9 + 7)))
| n, m = list(map(int, input().split()))
broken = [int(eval(input())) for i in range(m)]
dp = [-1 for i in range(n + 1)]
dp[0] = 1
dp[1] = 1
for b in broken:
dp[b] = 0
for i in range(2, n + 1):
if dp[i] == -1:
dp[i] = dp[i - 1] + dp[i - 2]
print((dp[n] % (10**9 + 7)))
| false | 52.173913 | [
"-import sys",
"-",
"-sys.setrecursionlimit(1000000)",
"-",
"-",
"-def steps(n):",
"- if memo[n] != -1:",
"- return memo[n]",
"- one = memo[n - 1] if memo[n - 1] != -1 else steps(n - 1)",
"- two = memo[n - 2] if memo[n - 2] != -1 else steps(n - 2)",
"- memo[n] = one + two",
... | false | 0.049014 | 0.046526 | 1.053475 | [
"s920821910",
"s266856278"
] |
u562935282 | p02929 | python | s087360509 | s642032765 | 231 | 153 | 85,504 | 6,964 | Accepted | Accepted | 33.77 | import sys
sys.setrecursionlimit(10 ** 7)
def fact(x):
if x == 0:
return 1
else:
return x * fact(x - 1) % mod
mod = 10 ** 9 + 7
n = int(eval(input()))
s = eval(input())
t = list([1 if x == 'B' else 0 for x in s])
t = tuple((tt - df) % 2 for tt, df in zip(t, reversed(list(range(n * 2)))))
# print(t)
zeros = 0
ans = 1
ones = 0
for tt in t:
if tt == 0:
zeros += 1
else:
if zeros == 0:
print((0))
exit()
ans *= zeros
ans %= mod
zeros -= 1
ones += 1
if zeros > 0:
ans = 0
ans *= fact(ones)
ans %= mod
print(ans)
| mod = 10 ** 9 + 7
n = int(eval(input()))
s = eval(input())
t = list([1 if x == 'B' else 0 for x in s])
t = tuple((tt - df) % 2 for tt, df in zip(t, reversed(list(range(n * 2)))))
# print(t)
ans = 1
zeros = 0
ones = 0
for tt in t:
if tt == 0:
zeros += 1
else:
if zeros == 0:
print((0))
exit()
ans *= zeros
ans %= mod
zeros -= 1
ones += 1
if zeros > 0:
print((0))
exit()
for i in range(1, n + 1):
ans *= i
ans %= mod
print(ans)
| 41 | 32 | 651 | 541 | import sys
sys.setrecursionlimit(10**7)
def fact(x):
if x == 0:
return 1
else:
return x * fact(x - 1) % mod
mod = 10**9 + 7
n = int(eval(input()))
s = eval(input())
t = list([1 if x == "B" else 0 for x in s])
t = tuple((tt - df) % 2 for tt, df in zip(t, reversed(list(range(n * 2)))))
# print(t)
zeros = 0
ans = 1
ones = 0
for tt in t:
if tt == 0:
zeros += 1
else:
if zeros == 0:
print((0))
exit()
ans *= zeros
ans %= mod
zeros -= 1
ones += 1
if zeros > 0:
ans = 0
ans *= fact(ones)
ans %= mod
print(ans)
| mod = 10**9 + 7
n = int(eval(input()))
s = eval(input())
t = list([1 if x == "B" else 0 for x in s])
t = tuple((tt - df) % 2 for tt, df in zip(t, reversed(list(range(n * 2)))))
# print(t)
ans = 1
zeros = 0
ones = 0
for tt in t:
if tt == 0:
zeros += 1
else:
if zeros == 0:
print((0))
exit()
ans *= zeros
ans %= mod
zeros -= 1
ones += 1
if zeros > 0:
print((0))
exit()
for i in range(1, n + 1):
ans *= i
ans %= mod
print(ans)
| false | 21.95122 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**7)",
"-",
"-",
"-def fact(x):",
"- if x == 0:",
"- return 1",
"- else:",
"- return x * fact(x - 1) % mod",
"-",
"-",
"+ans = 1",
"-ans = 1",
"- ans = 0",
"-ans *= fact(ones)",
"-ans %= mod",
"+ print((0))",
... | false | 0.038245 | 0.037576 | 1.017809 | [
"s087360509",
"s642032765"
] |
u077291787 | p03014 | python | s737752432 | s206133084 | 1,463 | 682 | 176,904 | 177,160 | Accepted | Accepted | 53.38 | # ABC129D - Lamp
import sys
input = sys.stdin.readline
def main():
H, W = tuple(map(int, input().split()))
S = tuple(input().rstrip() for _ in range(H))
L, R = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
U, D = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
for x1 in range(H):
for y1 in range(W):
if S[x1][y1] == ".": # left and upper sides of S[i][j]
U[x1][y1] = U[x1 - 1][y1] + 1
L[x1][y1] = L[x1][y1 - 1] + 1
x2, y2 = -x1 - 1, -y1 - 1
if S[x2][y2] == ".": # right and under sides
D[x2][y2] = D[x2 + 1][y2] + 1
R[x2][y2] = R[x2][y2 + 1] + 1
ans = max(
L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3 for i in range(H) for j in range(W)
)
print(ans)
if __name__ == "__main__":
main() | def slove():
import sys
input = sys.stdin.readline
H, W = tuple(map(int, input().split()))
s = tuple(input().rstrip() for _ in range(H))
L, R = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
U, D = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
for i in range(H):
for j in range(W):
if s[i][j] == "#":
L[i][j] = 0
else:
if i == 0:
L[i][j] = 1
else:
L[i][j] = L[i - 1][j] + 1
if s[-i-1][j] == "#":
R[-i-1][j] = 0
else:
if i == 0:
R[-i-1][j] = 1
else:
R[-i-1][j] = R[-i][j] + 1
if s[i][j] == "#":
U[i][j] = 0
else:
if j == 0:
U[i][j] = 1
else:
U[i][j] = U[i][j-1] + 1
if s[i][-j-1] == "#":
D[i][-j-1] = 0
else:
if j == 0:
D[i][-j-1] = 1
else:
D[i][-j-1] = D[i][-j] + 1
mn = 0
for i in range(H):
for j in range(W):
mn = max(mn, U[i][j] + D[i][j] + L[i][j] + R[i][j] - 3)
print(mn)
if __name__ == '__main__':
slove() | 26 | 46 | 884 | 1,399 | # ABC129D - Lamp
import sys
input = sys.stdin.readline
def main():
H, W = tuple(map(int, input().split()))
S = tuple(input().rstrip() for _ in range(H))
L, R = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
U, D = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
for x1 in range(H):
for y1 in range(W):
if S[x1][y1] == ".": # left and upper sides of S[i][j]
U[x1][y1] = U[x1 - 1][y1] + 1
L[x1][y1] = L[x1][y1 - 1] + 1
x2, y2 = -x1 - 1, -y1 - 1
if S[x2][y2] == ".": # right and under sides
D[x2][y2] = D[x2 + 1][y2] + 1
R[x2][y2] = R[x2][y2 + 1] + 1
ans = max(
L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3 for i in range(H) for j in range(W)
)
print(ans)
if __name__ == "__main__":
main()
| def slove():
import sys
input = sys.stdin.readline
H, W = tuple(map(int, input().split()))
s = tuple(input().rstrip() for _ in range(H))
L, R = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
U, D = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
for i in range(H):
for j in range(W):
if s[i][j] == "#":
L[i][j] = 0
else:
if i == 0:
L[i][j] = 1
else:
L[i][j] = L[i - 1][j] + 1
if s[-i - 1][j] == "#":
R[-i - 1][j] = 0
else:
if i == 0:
R[-i - 1][j] = 1
else:
R[-i - 1][j] = R[-i][j] + 1
if s[i][j] == "#":
U[i][j] = 0
else:
if j == 0:
U[i][j] = 1
else:
U[i][j] = U[i][j - 1] + 1
if s[i][-j - 1] == "#":
D[i][-j - 1] = 0
else:
if j == 0:
D[i][-j - 1] = 1
else:
D[i][-j - 1] = D[i][-j] + 1
mn = 0
for i in range(H):
for j in range(W):
mn = max(mn, U[i][j] + D[i][j] + L[i][j] + R[i][j] - 3)
print(mn)
if __name__ == "__main__":
slove()
| false | 43.478261 | [
"-# ABC129D - Lamp",
"-import sys",
"+def slove():",
"+ import sys",
"-input = sys.stdin.readline",
"-",
"-",
"-def main():",
"+ input = sys.stdin.readline",
"- S = tuple(input().rstrip() for _ in range(H))",
"+ s = tuple(input().rstrip() for _ in range(H))",
"- for x1 in range(... | false | 0.111841 | 0.204326 | 0.547366 | [
"s737752432",
"s206133084"
] |
u197955752 | p02582 | python | s450696595 | s849952551 | 33 | 27 | 9,096 | 9,108 | Accepted | Accepted | 18.18 | W = eval(input())
if W == 'RRR':
print((3))
elif W == 'SSS':
print((0))
elif any([W == 'RRS', W == 'SRR']):
print((2))
else:
print((1)) | W = eval(input())
cnt = 0
max_cnt = 0
for i in range(3):
if W[i] == 'S':
cnt = 0
else:
cnt += 1
max_cnt = max(max_cnt, cnt)
print(max_cnt) | 9 | 11 | 146 | 175 | W = eval(input())
if W == "RRR":
print((3))
elif W == "SSS":
print((0))
elif any([W == "RRS", W == "SRR"]):
print((2))
else:
print((1))
| W = eval(input())
cnt = 0
max_cnt = 0
for i in range(3):
if W[i] == "S":
cnt = 0
else:
cnt += 1
max_cnt = max(max_cnt, cnt)
print(max_cnt)
| false | 18.181818 | [
"-if W == \"RRR\":",
"- print((3))",
"-elif W == \"SSS\":",
"- print((0))",
"-elif any([W == \"RRS\", W == \"SRR\"]):",
"- print((2))",
"-else:",
"- print((1))",
"+cnt = 0",
"+max_cnt = 0",
"+for i in range(3):",
"+ if W[i] == \"S\":",
"+ cnt = 0",
"+ else:",
"+ ... | false | 0.044917 | 0.045215 | 0.993409 | [
"s450696595",
"s849952551"
] |
u813098295 | p03253 | python | s978606739 | s276477544 | 22 | 19 | 3,188 | 3,064 | Accepted | Accepted | 13.64 | import math
def prime_factorize(n):
ret = []
# 小さい素数から順に試し割りしていく
for i in range(2, int(math.sqrt(n))+1):
if n % i != 0:
continue
e = 0
while n % i == 0:
e += 1
n //= i
ret += [(i, e)]
if n != 1:
ret += [(n, 1)]
return ret
def extgcd(a, b):
x,y, u,v = 0,1, 1,0
while a != 0:
q, r = b//a, b%a
m, n = x-u*q, y-v*q
b,a, x,y, u,v = a,r, u,v, m,n
g = b
return x, y, g
def modinv(a, m):
x, y, g = extgcd(a, m)
if g != 1:
print ("[+]Inverse does not exist.")
else:
return ((m + x) % m) % m
def mod_comb(n, r, mod):
ans_mul, ans_div = 1, 1
for i in range(r):
ans_mul *= (n-i)
ans_div *= (i+1)
ans_mul %= mod
ans_div %= mod
return ans_mul * modinv(ans_div, mod) % mod
def main():
N, M = list(map(int, input().split()))
v = prime_factorize(M)
MOD = int(10**9+7)
ans = 1
for i in v:
ans *= mod_comb(N+i[1]-1, i[1], MOD)
ans %= MOD
print (ans)
main()
| def prime_factor(n):
ret, p = {}, 2
while p*p <= n:
while n % p == 0:
ret[p] = ret.get(p, 0) + 1
n //= p
p += 1
if n != 1: ret[n] = 1
return ret
def mod_inverse(x, mod):
return pow(x, mod-2, mod)
def mod_comb(n, k, mod):
numer, denom = 1, 1
for i in range(k):
numer = numer * ((n-i) % mod) % mod
denom = denom * ((i+1) % mod) % mod
return numer * mod_inverse(denom, mod) % mod
def main():
n, m = list(map(int, input().split()))
prime = prime_factor(m)
mod = 1000000007
ans = 1
for (p, e) in list(prime.items()):
ans = ans * mod_comb(n+e-1, e, mod) % mod
print(ans)
main() | 62 | 35 | 1,160 | 722 | import math
def prime_factorize(n):
ret = []
# 小さい素数から順に試し割りしていく
for i in range(2, int(math.sqrt(n)) + 1):
if n % i != 0:
continue
e = 0
while n % i == 0:
e += 1
n //= i
ret += [(i, e)]
if n != 1:
ret += [(n, 1)]
return ret
def extgcd(a, b):
x, y, u, v = 0, 1, 1, 0
while a != 0:
q, r = b // a, b % a
m, n = x - u * q, y - v * q
b, a, x, y, u, v = a, r, u, v, m, n
g = b
return x, y, g
def modinv(a, m):
x, y, g = extgcd(a, m)
if g != 1:
print("[+]Inverse does not exist.")
else:
return ((m + x) % m) % m
def mod_comb(n, r, mod):
ans_mul, ans_div = 1, 1
for i in range(r):
ans_mul *= n - i
ans_div *= i + 1
ans_mul %= mod
ans_div %= mod
return ans_mul * modinv(ans_div, mod) % mod
def main():
N, M = list(map(int, input().split()))
v = prime_factorize(M)
MOD = int(10**9 + 7)
ans = 1
for i in v:
ans *= mod_comb(N + i[1] - 1, i[1], MOD)
ans %= MOD
print(ans)
main()
| def prime_factor(n):
ret, p = {}, 2
while p * p <= n:
while n % p == 0:
ret[p] = ret.get(p, 0) + 1
n //= p
p += 1
if n != 1:
ret[n] = 1
return ret
def mod_inverse(x, mod):
return pow(x, mod - 2, mod)
def mod_comb(n, k, mod):
numer, denom = 1, 1
for i in range(k):
numer = numer * ((n - i) % mod) % mod
denom = denom * ((i + 1) % mod) % mod
return numer * mod_inverse(denom, mod) % mod
def main():
n, m = list(map(int, input().split()))
prime = prime_factor(m)
mod = 1000000007
ans = 1
for (p, e) in list(prime.items()):
ans = ans * mod_comb(n + e - 1, e, mod) % mod
print(ans)
main()
| false | 43.548387 | [
"-import math",
"-",
"-",
"-def prime_factorize(n):",
"- ret = []",
"- # 小さい素数から順に試し割りしていく",
"- for i in range(2, int(math.sqrt(n)) + 1):",
"- if n % i != 0:",
"- continue",
"- e = 0",
"- while n % i == 0:",
"- e += 1",
"- n //= ... | false | 0.008249 | 0.041852 | 0.197102 | [
"s978606739",
"s276477544"
] |
u933341648 | p03262 | python | s127019960 | s456139786 | 101 | 84 | 16,280 | 14,224 | Accepted | Accepted | 16.83 | from fractions import gcd
n, x = list(map(int, input().split()))
town = list(map(int, input().split()))
res = abs(town[0] - x)
for t in town[1:]:
d = abs(t - x)
res = gcd(res, d)
print(res) | def gcd(a, b):
while a > 0:
if a < b:
a, b = b, a
a = a % b
return b
n, x = list(map(int, input().split()))
town = list(map(int, input().split()))
res = abs(town[0] - x)
for t in town[1:]:
d = abs(t - x)
res = gcd(res, d)
print(res) | 11 | 16 | 204 | 288 | from fractions import gcd
n, x = list(map(int, input().split()))
town = list(map(int, input().split()))
res = abs(town[0] - x)
for t in town[1:]:
d = abs(t - x)
res = gcd(res, d)
print(res)
| def gcd(a, b):
while a > 0:
if a < b:
a, b = b, a
a = a % b
return b
n, x = list(map(int, input().split()))
town = list(map(int, input().split()))
res = abs(town[0] - x)
for t in town[1:]:
d = abs(t - x)
res = gcd(res, d)
print(res)
| false | 31.25 | [
"-from fractions import gcd",
"+def gcd(a, b):",
"+ while a > 0:",
"+ if a < b:",
"+ a, b = b, a",
"+ a = a % b",
"+ return b",
"+"
] | false | 0.16929 | 0.128812 | 1.314245 | [
"s127019960",
"s456139786"
] |
u836939578 | p02743 | python | s334549929 | s785553844 | 253 | 181 | 59,700 | 38,384 | Accepted | Accepted | 28.46 | import sys
input = lambda: sys.stdin.readline().rstrip()
from decimal import *
a,b,c = list(map(int, input().split()))
a = Decimal(a).sqrt()
b = Decimal(b).sqrt()
c = Decimal(c).sqrt()
if a + b < c:
print("Yes")
else:
print("No") | import sys
input = lambda: sys.stdin.readline().rstrip()
a,b,c = list(map(int, input().split()))
if c - a - b < 0:
print("No")
elif 4 * a * b < (c - a - b) ** 2:
print('Yes')
else:
print('No') | 15 | 11 | 253 | 210 | import sys
input = lambda: sys.stdin.readline().rstrip()
from decimal import *
a, b, c = list(map(int, input().split()))
a = Decimal(a).sqrt()
b = Decimal(b).sqrt()
c = Decimal(c).sqrt()
if a + b < c:
print("Yes")
else:
print("No")
| import sys
input = lambda: sys.stdin.readline().rstrip()
a, b, c = list(map(int, input().split()))
if c - a - b < 0:
print("No")
elif 4 * a * b < (c - a - b) ** 2:
print("Yes")
else:
print("No")
| false | 26.666667 | [
"-from decimal import *",
"-",
"-a = Decimal(a).sqrt()",
"-b = Decimal(b).sqrt()",
"-c = Decimal(c).sqrt()",
"-if a + b < c:",
"+if c - a - b < 0:",
"+ print(\"No\")",
"+elif 4 * a * b < (c - a - b) ** 2:"
] | false | 0.046435 | 0.043642 | 1.063991 | [
"s334549929",
"s785553844"
] |
u883048396 | p03253 | python | s710210159 | s273038355 | 805 | 92 | 40,692 | 10,996 | Accepted | Accepted | 88.57 | iN,iM = [int(x) for x in input().split()]
iD = 10**9 +7 #法
def fPrimeCounter(iM):
i = 2
iS = int(iM ** 0.5) + 1
aRet = []
while i < iS or iM != 1:
iCounter = 0
while iM % i == 0:
iM = iM // i
iCounter += 1
if 0 < iCounter : aRet.append(iCounter)
i += 1
return aRet
#二分累乗法 iDを法として
def fBiPow(iX,iN,iD):
iY = 1
while iN > 0:
if iN % 2 == 0:
iX = iX * iX % iD
iN = iN // 2
else:
iY = iX * iY % iD
iN = iN - 1
return iY
aP = fPrimeCounter(iM)
if aP == [] :
print((1))
else:
iMax = max(aP) + iN - 1
aM = [1] * (iMax + 1)
#階乗 iD を法とした
for i in range(1,iMax + 1):
aM[i] = aM[i-1] * i % iD
aInvM = [1]* (iMax + 1)
aInvM[iMax] = fBiPow(aM[iMax],iD-2,iD)
#階乗の逆元 iD を法とした
for i in range(iMax,0,-1):
aInvM[i-1] = aInvM[i]*i % iD
iRet = 1
for i in aP:
# i + iN -1 C iN -1
iRet *= aM[i+iN-1] * aInvM[iN-1] * aInvM[i] % iD
iRet %= iD
print(iRet)
|
iN,iM = [int(x) for x in input().split()]
iD = 10**9 +7 #法
def fPrimeCounter(iM):
iS = int(iM ** 0.5) + 1
aRet = []
for i in range(2,iS + 1):
iCounter = 0
while iM % i == 0:
iM = iM / i
iCounter += 1
if 0 < iCounter : aRet.append(iCounter)
if iM == 1 : break
if 1 < iM : aRet.append(1)
return aRet
#二分累乗法 iDを法として
def fBiPow(iX,iN,iD):
iY = 1
while iN > 0:
if iN % 2 == 0:
iX = iX * iX % iD
iN = iN // 2
else:
iY = iX * iY % iD
iN = iN - 1
return iY
aP = fPrimeCounter(iM)
if len(aP) == 0:
print((1))
exit()
iMax = max(aP) + iN - 1
aM = [1] * (iMax + 1)
#階乗 iD を法とした
for i in range(1,iMax + 1):
aM[i] = aM[i-1] * i % iD
aInvM = [1]* (iMax + 1)
aInvM[iMax] = fBiPow(aM[iMax],iD-2,iD)
#階乗の逆元 iD を法とした
for i in range(iMax,0,-1):
aInvM[i-1] = aInvM[i]*i % iD
iRet = 1
for i in aP:
# i + iN -1 C iN -1
iRet *= aM[i+iN-1] * aInvM[iN-1] * aInvM[i] % iD
iRet %= iD
print(iRet)
| 50 | 50 | 1,123 | 1,100 | iN, iM = [int(x) for x in input().split()]
iD = 10**9 + 7 # 法
def fPrimeCounter(iM):
i = 2
iS = int(iM**0.5) + 1
aRet = []
while i < iS or iM != 1:
iCounter = 0
while iM % i == 0:
iM = iM // i
iCounter += 1
if 0 < iCounter:
aRet.append(iCounter)
i += 1
return aRet
# 二分累乗法 iDを法として
def fBiPow(iX, iN, iD):
iY = 1
while iN > 0:
if iN % 2 == 0:
iX = iX * iX % iD
iN = iN // 2
else:
iY = iX * iY % iD
iN = iN - 1
return iY
aP = fPrimeCounter(iM)
if aP == []:
print((1))
else:
iMax = max(aP) + iN - 1
aM = [1] * (iMax + 1)
# 階乗 iD を法とした
for i in range(1, iMax + 1):
aM[i] = aM[i - 1] * i % iD
aInvM = [1] * (iMax + 1)
aInvM[iMax] = fBiPow(aM[iMax], iD - 2, iD)
# 階乗の逆元 iD を法とした
for i in range(iMax, 0, -1):
aInvM[i - 1] = aInvM[i] * i % iD
iRet = 1
for i in aP:
# i + iN -1 C iN -1
iRet *= aM[i + iN - 1] * aInvM[iN - 1] * aInvM[i] % iD
iRet %= iD
print(iRet)
| iN, iM = [int(x) for x in input().split()]
iD = 10**9 + 7 # 法
def fPrimeCounter(iM):
iS = int(iM**0.5) + 1
aRet = []
for i in range(2, iS + 1):
iCounter = 0
while iM % i == 0:
iM = iM / i
iCounter += 1
if 0 < iCounter:
aRet.append(iCounter)
if iM == 1:
break
if 1 < iM:
aRet.append(1)
return aRet
# 二分累乗法 iDを法として
def fBiPow(iX, iN, iD):
iY = 1
while iN > 0:
if iN % 2 == 0:
iX = iX * iX % iD
iN = iN // 2
else:
iY = iX * iY % iD
iN = iN - 1
return iY
aP = fPrimeCounter(iM)
if len(aP) == 0:
print((1))
exit()
iMax = max(aP) + iN - 1
aM = [1] * (iMax + 1)
# 階乗 iD を法とした
for i in range(1, iMax + 1):
aM[i] = aM[i - 1] * i % iD
aInvM = [1] * (iMax + 1)
aInvM[iMax] = fBiPow(aM[iMax], iD - 2, iD)
# 階乗の逆元 iD を法とした
for i in range(iMax, 0, -1):
aInvM[i - 1] = aInvM[i] * i % iD
iRet = 1
for i in aP:
# i + iN -1 C iN -1
iRet *= aM[i + iN - 1] * aInvM[iN - 1] * aInvM[i] % iD
iRet %= iD
print(iRet)
| false | 0 | [
"- i = 2",
"- while i < iS or iM != 1:",
"+ for i in range(2, iS + 1):",
"- iM = iM // i",
"+ iM = iM / i",
"- i += 1",
"+ if iM == 1:",
"+ break",
"+ if 1 < iM:",
"+ aRet.append(1)",
"-if aP == []:",
"+if len(aP) == 0:",
"-el... | false | 0.064784 | 0.183583 | 0.352884 | [
"s710210159",
"s273038355"
] |
u995062424 | p03031 | python | s165100636 | s194667064 | 288 | 49 | 3,064 | 3,064 | Accepted | Accepted | 82.99 | N, M = list(map(int, input().split()))
s = []
for i in range(M):
s.append(list(map(int, input().split())))
p = list(map(int, input().split()))
ans = 0
for i in range(2**N):
Flg = True
for j in range(M):
cnt = 0
for m in range(1, len(s[j])):
for k in range(N):
if((i>>k)&1 and s[j][m]-1 == k):
cnt += 1
if(cnt%2 != p[j]):
Flg = False
if(Flg):
ans += 1
print(ans) | N, M = list(map(int, input().split()))
s = []
for i in range(M):
s.append(list(map(int, input().split())))
p = list(map(int, input().split()))
ans = 0
for i in range(2**N):
Flg = True
for j in range(M):
cnt = 0
for k in range(1, s[j][0]+1):
if((i>>(s[j][k]-1))&1):
cnt += 1
if(cnt%2 != p[j]):
Flg = False
if(Flg):
ans += 1
print(ans) | 20 | 19 | 494 | 445 | N, M = list(map(int, input().split()))
s = []
for i in range(M):
s.append(list(map(int, input().split())))
p = list(map(int, input().split()))
ans = 0
for i in range(2**N):
Flg = True
for j in range(M):
cnt = 0
for m in range(1, len(s[j])):
for k in range(N):
if (i >> k) & 1 and s[j][m] - 1 == k:
cnt += 1
if cnt % 2 != p[j]:
Flg = False
if Flg:
ans += 1
print(ans)
| N, M = list(map(int, input().split()))
s = []
for i in range(M):
s.append(list(map(int, input().split())))
p = list(map(int, input().split()))
ans = 0
for i in range(2**N):
Flg = True
for j in range(M):
cnt = 0
for k in range(1, s[j][0] + 1):
if (i >> (s[j][k] - 1)) & 1:
cnt += 1
if cnt % 2 != p[j]:
Flg = False
if Flg:
ans += 1
print(ans)
| false | 5 | [
"- for m in range(1, len(s[j])):",
"- for k in range(N):",
"- if (i >> k) & 1 and s[j][m] - 1 == k:",
"- cnt += 1",
"+ for k in range(1, s[j][0] + 1):",
"+ if (i >> (s[j][k] - 1)) & 1:",
"+ cnt += 1"
] | false | 0.065311 | 0.046624 | 1.400805 | [
"s165100636",
"s194667064"
] |
u467041847 | p03448 | python | s055492562 | s925336899 | 64 | 22 | 3,064 | 3,064 | Accepted | Accepted | 65.62 | a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
x = int(eval(input()))
l = 0
def pattern(a, b, c, x):
if x == 0:
return 1
else:
if (x >= 500) and (a >= 1):
return pattern(a - 1, b, c, x - 500) + pattern(0, b, c, x)
elif (x >= 100) and (b >= 1):
return pattern(a, b - 1, c, x - 100) + pattern(a, 0, c, x)
elif (x >= 50) and (c >= 1):
return pattern(a, b, c - 1, x - 50) + pattern(a, b, 0, x)
else:
return 0
ans = pattern(a, b, c, x)
print(ans) | a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
x = int(eval(input()))
l = 0
def pattern(a, b, c, x):
if x == 0:
return 1
else:
if (500 * a + 100 * b + 50 * c < x):
return 0
elif (x >= 500) and (a >= 1):
return pattern(a - 1, b, c, x - 500) + pattern(0, b, c, x)
elif (x >= 100) and (b >= 1):
return pattern(a, b - 1, c, x - 100) + pattern(a, 0, c, x)
elif (x >= 50) and (c >= 1):
return pattern(a, b, c - 1, x - 50) + pattern(a, b, 0, x)
else:
return 0
ans = pattern(a, b, c, x)
print(ans) | 23 | 25 | 489 | 544 | a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
x = int(eval(input()))
l = 0
def pattern(a, b, c, x):
if x == 0:
return 1
else:
if (x >= 500) and (a >= 1):
return pattern(a - 1, b, c, x - 500) + pattern(0, b, c, x)
elif (x >= 100) and (b >= 1):
return pattern(a, b - 1, c, x - 100) + pattern(a, 0, c, x)
elif (x >= 50) and (c >= 1):
return pattern(a, b, c - 1, x - 50) + pattern(a, b, 0, x)
else:
return 0
ans = pattern(a, b, c, x)
print(ans)
| a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
x = int(eval(input()))
l = 0
def pattern(a, b, c, x):
if x == 0:
return 1
else:
if 500 * a + 100 * b + 50 * c < x:
return 0
elif (x >= 500) and (a >= 1):
return pattern(a - 1, b, c, x - 500) + pattern(0, b, c, x)
elif (x >= 100) and (b >= 1):
return pattern(a, b - 1, c, x - 100) + pattern(a, 0, c, x)
elif (x >= 50) and (c >= 1):
return pattern(a, b, c - 1, x - 50) + pattern(a, b, 0, x)
else:
return 0
ans = pattern(a, b, c, x)
print(ans)
| false | 8 | [
"- if (x >= 500) and (a >= 1):",
"+ if 500 * a + 100 * b + 50 * c < x:",
"+ return 0",
"+ elif (x >= 500) and (a >= 1):"
] | false | 0.064503 | 0.038239 | 1.686844 | [
"s055492562",
"s925336899"
] |
u191829404 | p02928 | python | s790493135 | s130331676 | 513 | 269 | 43,028 | 41,196 | Accepted | Accepted | 47.56 | import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき,A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right
from heapq import heappush, heappop
import re
# import numpy as np
# from scipy.misc import comb
# 再帰がやばいとき
import sys
sys.setrecursionlimit(10**9)
def inside(y, x, H, W):
return 0 <= y < H and 0 <= x < W
# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def i_inpl(): return int(eval(input()))
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]
INF = int(1e30)
MOD = int(1e9)+7 # 10^9 + 7
# field[H][W]
def create_grid(H, W, value = 0):
return [[ value for _ in range(W)] for _ in range(H)]
########
def count_inversion(sequence):
count = 0
for i in range(1,len(sequence),1):
for j in range(i,len(sequence),1):
if sequence[i-1] > sequence[j]:
count += 1
return count
def power_func(a,n,p):
bi=str(format(n,"b"))#2進表現に
res=1
for i in range(len(bi)):
res=(res*res) %p
if bi[i]=="1":
res=(res*a) %p
return res
def main():
N, K = l_inpl()
A = l_inpl()
a1 = count_inversion(A)
b1 = (count_inversion(A*2) - count_inversion(A))
b2 = (count_inversion(A*3) - count_inversion(A*2))
c1 = b2 - b1
print(((a1*K+c1*(K%MOD)*((K-1)%MOD)//2)%MOD))
if __name__ == "__main__":
main()
| import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき,A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right
from heapq import heappush, heappop
import re
# import numpy as np
# from scipy.misc import comb
# 再帰がやばいとき
import sys
sys.setrecursionlimit(10**9)
def inside(y, x, H, W):
return 0 <= y < H and 0 <= x < W
# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def i_inpl(): return int(eval(input()))
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]
INF = int(1e30)
MOD = int(1e9)+7 # 10^9 + 7
# field[H][W]
def create_grid(H, W, value = 0):
return [[ value for _ in range(W)] for _ in range(H)]
########
def c(seq):
ans = 0
for i in range(0, len(seq)):
for j in range(i, len(seq)):
if seq[i] > seq[j]:
ans += 1
return ans
def main():
N, K = l_inpl()
A = l_inpl()
a = c(A)
b = c(A*2)
print(((a*K+(b-2*a)*K*(K-1)//2)%MOD))
if __name__ == "__main__":
main()
| 74 | 63 | 1,883 | 1,526 | import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき,A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right
from heapq import heappush, heappop
import re
# import numpy as np
# from scipy.misc import comb
# 再帰がやばいとき
import sys
sys.setrecursionlimit(10**9)
def inside(y, x, H, W):
return 0 <= y < H and 0 <= x < W
# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def i_inpl():
return int(eval(input()))
def l_inpl():
return list(map(int, input().split()))
def line_inpl(x):
return [i_inpl() for _ in range(x)]
INF = int(1e30)
MOD = int(1e9) + 7 # 10^9 + 7
# field[H][W]
def create_grid(H, W, value=0):
return [[value for _ in range(W)] for _ in range(H)]
########
def count_inversion(sequence):
count = 0
for i in range(1, len(sequence), 1):
for j in range(i, len(sequence), 1):
if sequence[i - 1] > sequence[j]:
count += 1
return count
def power_func(a, n, p):
bi = str(format(n, "b")) # 2進表現に
res = 1
for i in range(len(bi)):
res = (res * res) % p
if bi[i] == "1":
res = (res * a) % p
return res
def main():
N, K = l_inpl()
A = l_inpl()
a1 = count_inversion(A)
b1 = count_inversion(A * 2) - count_inversion(A)
b2 = count_inversion(A * 3) - count_inversion(A * 2)
c1 = b2 - b1
print(((a1 * K + c1 * (K % MOD) * ((K - 1) % MOD) // 2) % MOD))
if __name__ == "__main__":
main()
| import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき,A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right
from heapq import heappush, heappop
import re
# import numpy as np
# from scipy.misc import comb
# 再帰がやばいとき
import sys
sys.setrecursionlimit(10**9)
def inside(y, x, H, W):
return 0 <= y < H and 0 <= x < W
# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def i_inpl():
return int(eval(input()))
def l_inpl():
return list(map(int, input().split()))
def line_inpl(x):
return [i_inpl() for _ in range(x)]
INF = int(1e30)
MOD = int(1e9) + 7 # 10^9 + 7
# field[H][W]
def create_grid(H, W, value=0):
return [[value for _ in range(W)] for _ in range(H)]
########
def c(seq):
ans = 0
for i in range(0, len(seq)):
for j in range(i, len(seq)):
if seq[i] > seq[j]:
ans += 1
return ans
def main():
N, K = l_inpl()
A = l_inpl()
a = c(A)
b = c(A * 2)
print(((a * K + (b - 2 * a) * K * (K - 1) // 2) % MOD))
if __name__ == "__main__":
main()
| false | 14.864865 | [
"-def count_inversion(sequence):",
"- count = 0",
"- for i in range(1, len(sequence), 1):",
"- for j in range(i, len(sequence), 1):",
"- if sequence[i - 1] > sequence[j]:",
"- count += 1",
"- return count",
"-",
"-",
"-def power_func(a, n, p):",
"- bi... | false | 0.042527 | 0.045505 | 0.934554 | [
"s790493135",
"s130331676"
] |
u963468276 | p04030 | python | s924871954 | s144041110 | 184 | 162 | 38,384 | 38,384 | Accepted | Accepted | 11.96 | def typing(s, ans):
for i in range(len(s)):
if s[i] == '0':
ans += '0'
if s[i] == '1':
ans += '1'
if s[i] == 'B' and ans != '':
ans = ans[:len(ans)-1]
print(ans)
S = str(eval(input()))
ANS = ''
typing(S, ANS) | def typing(s, ans):
for i in range(len(s)):
if s[i] == '0':
ans.append('0')
elif s[i] == '1':
ans.append('1')
elif s[i] == 'B' and len(ans) != 0:
ans.pop()
else:
continue
print((''.join(ans)))
S = str(eval(input()))
ANS = []
typing(S, ANS) | 14 | 16 | 285 | 336 | def typing(s, ans):
for i in range(len(s)):
if s[i] == "0":
ans += "0"
if s[i] == "1":
ans += "1"
if s[i] == "B" and ans != "":
ans = ans[: len(ans) - 1]
print(ans)
S = str(eval(input()))
ANS = ""
typing(S, ANS)
| def typing(s, ans):
for i in range(len(s)):
if s[i] == "0":
ans.append("0")
elif s[i] == "1":
ans.append("1")
elif s[i] == "B" and len(ans) != 0:
ans.pop()
else:
continue
print(("".join(ans)))
S = str(eval(input()))
ANS = []
typing(S, ANS)
| false | 12.5 | [
"- ans += \"0\"",
"- if s[i] == \"1\":",
"- ans += \"1\"",
"- if s[i] == \"B\" and ans != \"\":",
"- ans = ans[: len(ans) - 1]",
"- print(ans)",
"+ ans.append(\"0\")",
"+ elif s[i] == \"1\":",
"+ ans.append(\"1\")",
"+ ... | false | 0.108773 | 0.04425 | 2.45812 | [
"s924871954",
"s144041110"
] |
u424209323 | p02273 | python | s391341518 | s517611556 | 20 | 10 | 6,652 | 6,716 | Accepted | Accepted | 50 | import math
def kock(n, x1, y1, x2, y2):
if n == 0:
return
angle = math.radians(60)
sx = (2*x1 + x2)/3
sy = (2*y1 + y2)/3
tx = (2*x2 + x1)/3
ty = (2*y2 + y1)/3
ux = (tx - sx)*math.cos(angle) - (ty - sy)*math.sin(angle) + sx
uy = (tx - sx)*math.sin(angle) + (ty - sy)*math.cos(angle) + sy
kock(n-1, x1, y1, sx, sy)
print(sx, sy)
kock(n-1, sx, sy, ux, uy)
print(ux, uy)
kock(n-1, ux, uy, tx, ty)
print(tx, ty)
kock(n-1, tx, ty, x2, y2)
n = eval(input())
p1x = float(0.)
p1y = float(0.)
p2x = float(100.)
p2y = float(0.)
print(p1x, p1y)
kock(n, p1x, p1y, p2x, p2y)
print(p2x, p2y) | import math
def kock(n, x1, y1, x2, y2):
if n == 0:
return
angle = math.radians(60)
sx = (2*x1 + x2)/3
sy = (2*y1 + y2)/3
tx = (2*x2 + x1)/3
ty = (2*y2 + y1)/3
ux = (tx - sx)*math.cos(angle) - (ty - sy)*math.sin(angle) + sx
uy = (tx - sx)*math.sin(angle) + (ty - sy)*math.cos(angle) + sy
kock(n-1, x1, y1, sx, sy)
print(sx, sy)
kock(n-1, sx, sy, ux, uy)
print(ux, uy)
kock(n-1, ux, uy, tx, ty)
print(tx, ty)
kock(n-1, tx, ty, x2, y2)
n = eval(input())
p1x = 0.
p1y = 0.
p2x = 100.
p2y = 0.
print(p1x, p1y)
kock(n, p1x, p1y, p2x, p2y)
print(p2x, p2y) | 33 | 33 | 673 | 645 | import math
def kock(n, x1, y1, x2, y2):
if n == 0:
return
angle = math.radians(60)
sx = (2 * x1 + x2) / 3
sy = (2 * y1 + y2) / 3
tx = (2 * x2 + x1) / 3
ty = (2 * y2 + y1) / 3
ux = (tx - sx) * math.cos(angle) - (ty - sy) * math.sin(angle) + sx
uy = (tx - sx) * math.sin(angle) + (ty - sy) * math.cos(angle) + sy
kock(n - 1, x1, y1, sx, sy)
print(sx, sy)
kock(n - 1, sx, sy, ux, uy)
print(ux, uy)
kock(n - 1, ux, uy, tx, ty)
print(tx, ty)
kock(n - 1, tx, ty, x2, y2)
n = eval(input())
p1x = float(0.0)
p1y = float(0.0)
p2x = float(100.0)
p2y = float(0.0)
print(p1x, p1y)
kock(n, p1x, p1y, p2x, p2y)
print(p2x, p2y)
| import math
def kock(n, x1, y1, x2, y2):
if n == 0:
return
angle = math.radians(60)
sx = (2 * x1 + x2) / 3
sy = (2 * y1 + y2) / 3
tx = (2 * x2 + x1) / 3
ty = (2 * y2 + y1) / 3
ux = (tx - sx) * math.cos(angle) - (ty - sy) * math.sin(angle) + sx
uy = (tx - sx) * math.sin(angle) + (ty - sy) * math.cos(angle) + sy
kock(n - 1, x1, y1, sx, sy)
print(sx, sy)
kock(n - 1, sx, sy, ux, uy)
print(ux, uy)
kock(n - 1, ux, uy, tx, ty)
print(tx, ty)
kock(n - 1, tx, ty, x2, y2)
n = eval(input())
p1x = 0.0
p1y = 0.0
p2x = 100.0
p2y = 0.0
print(p1x, p1y)
kock(n, p1x, p1y, p2x, p2y)
print(p2x, p2y)
| false | 0 | [
"-p1x = float(0.0)",
"-p1y = float(0.0)",
"-p2x = float(100.0)",
"-p2y = float(0.0)",
"+p1x = 0.0",
"+p1y = 0.0",
"+p2x = 100.0",
"+p2y = 0.0"
] | false | 0.038339 | 0.109246 | 0.350944 | [
"s391341518",
"s517611556"
] |
u814663076 | p03317 | python | s257906630 | s698757439 | 26 | 17 | 10,420 | 2,940 | Accepted | Accepted | 34.62 | # AtCoder Beginner Contest 101
# C - Minimization
N, K = [int(i) for i in input().split()]
A = input().split()
print((-(-(N-1) // (K-1)))) | # AtCoder Beginner Contest 101
# C - Minimization
N, K = [int(i) for i in input().split()]
# A = input().split()
print((-(-(N-1) // (K-1)))) | 6 | 6 | 142 | 144 | # AtCoder Beginner Contest 101
# C - Minimization
N, K = [int(i) for i in input().split()]
A = input().split()
print((-(-(N - 1) // (K - 1))))
| # AtCoder Beginner Contest 101
# C - Minimization
N, K = [int(i) for i in input().split()]
# A = input().split()
print((-(-(N - 1) // (K - 1))))
| false | 0 | [
"-A = input().split()",
"+# A = input().split()"
] | false | 0.04354 | 0.085426 | 0.509687 | [
"s257906630",
"s698757439"
] |
u353797797 | p03963 | python | s189051937 | s814799090 | 21 | 17 | 3,316 | 3,064 | Accepted | Accepted | 19.05 | from itertools import permutations
import sys
sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]
def main():
n,k=MI()
ans=k*pow(k-1,n-1)
print(ans)
main()
| import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]
def main():
n,k=MI()
print(pow(k-1,n-1)*k)
main()
| 25 | 16 | 737 | 449 | from itertools import permutations
import sys
sys.setrecursionlimit(10**6)
from bisect import *
from collections import *
from heapq import *
def II():
return int(sys.stdin.readline())
def MI():
return map(int, sys.stdin.readline().split())
def LI():
return list(map(int, sys.stdin.readline().split()))
def SI():
return sys.stdin.readline()[:-1]
def LLI(rows_number):
return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1():
return map(int1, sys.stdin.readline().split())
def LI1():
return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]
def main():
n, k = MI()
ans = k * pow(k - 1, n - 1)
print(ans)
main()
| import sys
sys.setrecursionlimit(10**6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II():
return int(sys.stdin.readline())
def MI():
return map(int, sys.stdin.readline().split())
def LI():
return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number):
return [LI() for _ in range(rows_number)]
def SI():
return sys.stdin.readline()[:-1]
def main():
n, k = MI()
print(pow(k - 1, n - 1) * k)
main()
| false | 36 | [
"-from itertools import permutations",
"-from bisect import *",
"-from collections import *",
"-from heapq import *",
"+int1 = lambda x: int(x) - 1",
"+p2D = lambda x: print(*x, sep=\"\\n\")",
"+def LLI(rows_number):",
"+ return [LI() for _ in range(rows_number)]",
"+",
"+",
"-def LLI(rows_nu... | false | 0.045679 | 0.047031 | 0.971241 | [
"s189051937",
"s814799090"
] |
u567380442 | p00253 | python | s094706330 | s228981305 | 50 | 40 | 6,740 | 6,736 | Accepted | Accepted | 20 | from itertools import count
def get_weed(h):
d10 = h[1] - h[0]
d21 = h[2] - h[1]
d32 = h[3] - h[2]
if d10 == d21 == d32:
for hi, expect in zip(h, count(h[0], d10)):
if hi != expect:
return hi
d43 = h[4] - h[3]
if d21 == d32 == d43:
return h[0]
elif h[2] - h[0] == d32 == d43:
return h[1]
elif d10 == h[3] - h[1] == d43:
return h[2]
elif d10 == d21 == h[4] - h[2]:
return h[3]
import sys
f = sys.stdin
while True:
n = int(f.readline())
if n == 0:
break
h = list(map(int, f.readline().split()))
print((get_weed(h))) | from itertools import count
def get_weed(h):
d = [h[i + 1] - h[i] for i in range(3)]
if d[0] == d[1] == d[2]:
for hi, expect in zip(h, count(h[0], d[0])):
if hi != expect:
return hi
for i in range(4):
hh = h[:i] + h[i + 1:]
d = [hh[i + 1] - hh[i] for i in range(3)]
if d[0] == d[1] == d[2]:
return h[i]
import sys
f = sys.stdin
while True:
n = int(f.readline())
if n == 0:
break
h = list(map(int, f.readline().split()))
print((get_weed(h))) | 30 | 23 | 672 | 571 | from itertools import count
def get_weed(h):
d10 = h[1] - h[0]
d21 = h[2] - h[1]
d32 = h[3] - h[2]
if d10 == d21 == d32:
for hi, expect in zip(h, count(h[0], d10)):
if hi != expect:
return hi
d43 = h[4] - h[3]
if d21 == d32 == d43:
return h[0]
elif h[2] - h[0] == d32 == d43:
return h[1]
elif d10 == h[3] - h[1] == d43:
return h[2]
elif d10 == d21 == h[4] - h[2]:
return h[3]
import sys
f = sys.stdin
while True:
n = int(f.readline())
if n == 0:
break
h = list(map(int, f.readline().split()))
print((get_weed(h)))
| from itertools import count
def get_weed(h):
d = [h[i + 1] - h[i] for i in range(3)]
if d[0] == d[1] == d[2]:
for hi, expect in zip(h, count(h[0], d[0])):
if hi != expect:
return hi
for i in range(4):
hh = h[:i] + h[i + 1 :]
d = [hh[i + 1] - hh[i] for i in range(3)]
if d[0] == d[1] == d[2]:
return h[i]
import sys
f = sys.stdin
while True:
n = int(f.readline())
if n == 0:
break
h = list(map(int, f.readline().split()))
print((get_weed(h)))
| false | 23.333333 | [
"- d10 = h[1] - h[0]",
"- d21 = h[2] - h[1]",
"- d32 = h[3] - h[2]",
"- if d10 == d21 == d32:",
"- for hi, expect in zip(h, count(h[0], d10)):",
"+ d = [h[i + 1] - h[i] for i in range(3)]",
"+ if d[0] == d[1] == d[2]:",
"+ for hi, expect in zip(h, count(h[0], d[0])):",
... | false | 0.056252 | 0.038153 | 1.474365 | [
"s094706330",
"s228981305"
] |
u562935282 | p03038 | python | s099372082 | s653342727 | 836 | 535 | 93,464 | 31,964 | Accepted | Accepted | 36 | from heapq import heapify, heappush, heappop
N, M = list(map(int, input().split()))
a = list(map(int, input().split()))
hq = list([(-x, 1) for x in a])
heapify(hq)
for _ in range(M):
b, c = list(map(int, input().split()))
heappush(hq, (-c, b))
rest = N
ans = 0
while rest > 0 and hq:
mv, b = heappop(hq)
mv *= -1
use = min(rest, b)
ans += mv * use
rest -= use
print(ans)
| from heapq import heappop, heappush
n, m = list(map(int, input().split()))
a = tuple(map(int, input().split()))
hq = []
for aa in a:
heappush(hq, (-aa, 1))
for _ in range(m):
b, c = list(map(int, input().split()))
heappush(hq, (-c, b))
rest = n
ans = 0
while rest > 0:
num, cnt = heappop(hq)
num *= (-1)
use = min(rest, cnt)
ans += use * num
rest -= use
print(ans)
| 21 | 24 | 410 | 414 | from heapq import heapify, heappush, heappop
N, M = list(map(int, input().split()))
a = list(map(int, input().split()))
hq = list([(-x, 1) for x in a])
heapify(hq)
for _ in range(M):
b, c = list(map(int, input().split()))
heappush(hq, (-c, b))
rest = N
ans = 0
while rest > 0 and hq:
mv, b = heappop(hq)
mv *= -1
use = min(rest, b)
ans += mv * use
rest -= use
print(ans)
| from heapq import heappop, heappush
n, m = list(map(int, input().split()))
a = tuple(map(int, input().split()))
hq = []
for aa in a:
heappush(hq, (-aa, 1))
for _ in range(m):
b, c = list(map(int, input().split()))
heappush(hq, (-c, b))
rest = n
ans = 0
while rest > 0:
num, cnt = heappop(hq)
num *= -1
use = min(rest, cnt)
ans += use * num
rest -= use
print(ans)
| false | 12.5 | [
"-from heapq import heapify, heappush, heappop",
"+from heapq import heappop, heappush",
"-N, M = list(map(int, input().split()))",
"-a = list(map(int, input().split()))",
"-hq = list([(-x, 1) for x in a])",
"-heapify(hq)",
"-for _ in range(M):",
"+n, m = list(map(int, input().split()))",
"+a = tupl... | false | 0.03918 | 0.039162 | 1.000454 | [
"s099372082",
"s653342727"
] |
u729133443 | p02988 | python | s246443761 | s886235899 | 165 | 17 | 38,384 | 2,940 | Accepted | Accepted | 89.7 | _,p=open(0);*p,=list(map(int,p.split()));print((sum(sorted(a)[1]==a[1]for a in zip(p,p[1:],p[2:])))) | _,p=open(0);p=p.split();print((sum(sorted(a,key=int)[1]==a[1]for a in zip(p,p[1:],p[2:])))) | 1 | 1 | 92 | 89 | _, p = open(0)
(*p,) = list(map(int, p.split()))
print((sum(sorted(a)[1] == a[1] for a in zip(p, p[1:], p[2:]))))
| _, p = open(0)
p = p.split()
print((sum(sorted(a, key=int)[1] == a[1] for a in zip(p, p[1:], p[2:]))))
| false | 0 | [
"-(*p,) = list(map(int, p.split()))",
"-print((sum(sorted(a)[1] == a[1] for a in zip(p, p[1:], p[2:]))))",
"+p = p.split()",
"+print((sum(sorted(a, key=int)[1] == a[1] for a in zip(p, p[1:], p[2:]))))"
] | false | 0.039911 | 0.040186 | 0.993164 | [
"s246443761",
"s886235899"
] |
u528470578 | p03545 | python | s460867959 | s686548569 | 179 | 18 | 38,384 | 3,064 | Accepted | Accepted | 89.94 | import sys
S = eval(input())
op_cnt = len(S) - 1
for i in range(2 ** op_cnt):
op = ["-"] * op_cnt
for j in range(op_cnt):
if ((i >> j) & 1):
op[op_cnt - j - 1] = "+"
formula = ""
for p_n, p_o in zip(S, op + [""]):
formula += (p_n + p_o)
if eval(formula) == 7:
print((formula + "=7"))
sys.exit() | s = eval(input())
A, B, C, D = s[0], s[1], s[2], s[3]
ans = 7
siki = [[] for _ in range(2**3)]
for i in range(2 ** 3):
for j in range(3):
if (i >> j) & 1:
siki[i].append("+")
else:
siki[i].append("-")
for o1, o2, o3 in siki:
temp = A + o1 + B + o2 + C + o3 + D
if eval(temp) == ans:
print((temp + "=7"))
break | 16 | 16 | 367 | 385 | import sys
S = eval(input())
op_cnt = len(S) - 1
for i in range(2**op_cnt):
op = ["-"] * op_cnt
for j in range(op_cnt):
if (i >> j) & 1:
op[op_cnt - j - 1] = "+"
formula = ""
for p_n, p_o in zip(S, op + [""]):
formula += p_n + p_o
if eval(formula) == 7:
print((formula + "=7"))
sys.exit()
| s = eval(input())
A, B, C, D = s[0], s[1], s[2], s[3]
ans = 7
siki = [[] for _ in range(2**3)]
for i in range(2**3):
for j in range(3):
if (i >> j) & 1:
siki[i].append("+")
else:
siki[i].append("-")
for o1, o2, o3 in siki:
temp = A + o1 + B + o2 + C + o3 + D
if eval(temp) == ans:
print((temp + "=7"))
break
| false | 0 | [
"-import sys",
"-",
"-S = eval(input())",
"-op_cnt = len(S) - 1",
"-for i in range(2**op_cnt):",
"- op = [\"-\"] * op_cnt",
"- for j in range(op_cnt):",
"+s = eval(input())",
"+A, B, C, D = s[0], s[1], s[2], s[3]",
"+ans = 7",
"+siki = [[] for _ in range(2**3)]",
"+for i in range(2**3):"... | false | 0.039629 | 0.033192 | 1.193926 | [
"s460867959",
"s686548569"
] |
u130900604 | p02883 | python | s666335211 | s604863183 | 383 | 335 | 117,376 | 113,648 | Accepted | Accepted | 12.53 | n,k=list(map(int,input().split()))
abilities=sorted(list(map(int,input().split())))
foods=sorted(list(map(int,input().split())),reverse=True)
if sum(abilities)<=k:
print((0))
exit()
def check(score):
ret=0
for a,f in zip(abilities,foods):
ret+=max(0,(a*f-score+f-1)//f)
return ret<=k
ok=10**12+1
ng=0
for _ in range(50):
mid=(ok+ng)//2
if check(mid):
ok=mid
else:
ng=mid
print(ok)
| n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort(reverse=True)
def check(s):
ret=0
for i,j in zip(a,f):
ret+=max(0,i-s//j)
return ret<=k
ok=10**12+1
ng=-1
while ok-ng>1:
mid=(ok+ng)//2
if check(mid):
ok=mid
else:
ng=mid
print(ok) | 25 | 21 | 441 | 337 | n, k = list(map(int, input().split()))
abilities = sorted(list(map(int, input().split())))
foods = sorted(list(map(int, input().split())), reverse=True)
if sum(abilities) <= k:
print((0))
exit()
def check(score):
ret = 0
for a, f in zip(abilities, foods):
ret += max(0, (a * f - score + f - 1) // f)
return ret <= k
ok = 10**12 + 1
ng = 0
for _ in range(50):
mid = (ok + ng) // 2
if check(mid):
ok = mid
else:
ng = mid
print(ok)
| n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)
def check(s):
ret = 0
for i, j in zip(a, f):
ret += max(0, i - s // j)
return ret <= k
ok = 10**12 + 1
ng = -1
while ok - ng > 1:
mid = (ok + ng) // 2
if check(mid):
ok = mid
else:
ng = mid
print(ok)
| false | 16 | [
"-abilities = sorted(list(map(int, input().split())))",
"-foods = sorted(list(map(int, input().split())), reverse=True)",
"-if sum(abilities) <= k:",
"- print((0))",
"- exit()",
"+a = list(map(int, input().split()))",
"+f = list(map(int, input().split()))",
"+a.sort()",
"+f.sort(reverse=True)"... | false | 0.040884 | 0.047615 | 0.858634 | [
"s666335211",
"s604863183"
] |
u777283665 | p02936 | python | s439069360 | s315625483 | 1,328 | 856 | 65,324 | 96,460 | Accepted | Accepted | 35.54 | from collections import deque
import sys
input = sys.stdin.readline
n, q = (int(i) for i in input().split())
tree = [[] for _ in range(n)]
for _ in range(n-1):
a, b = (int(i) for i in input().split())
tree[a-1].append(b-1)
tree[b-1].append(a-1)
ans = [0] * n
for _ in range(q):
p, x = (int(i) for i in input().split())
ans[p-1] += x
query = deque([(0, -1)])
while query:
current_node, parent_node = query.popleft()
current_value = ans[current_node]
for node in tree[current_node]:
if node == parent_node:
continue
else:
ans[node] += current_value
query.append([node, current_node])
print((*ans)) | from collections import deque
import sys
input = sys.stdin.readline
n, q = list(map(int, input().split()))
tree = [[] for _ in range(n)]
for _ in range(n-1):
a, b = list(map(int, input().split()))
tree[a-1].append(b-1)
tree[b-1].append(a-1)
counter = [0] * n
for _ in range(q):
p, x = list(map(int, input().split()))
counter[p-1] += x
query = deque([(0, -1)]) # current, parent
while query:
current, parent = query.popleft()
value = counter[current]
for node in tree[current]:
if node == parent:
continue
else:
counter[node] += value
query.append((node, current))
print((*counter)) | 30 | 31 | 712 | 682 | from collections import deque
import sys
input = sys.stdin.readline
n, q = (int(i) for i in input().split())
tree = [[] for _ in range(n)]
for _ in range(n - 1):
a, b = (int(i) for i in input().split())
tree[a - 1].append(b - 1)
tree[b - 1].append(a - 1)
ans = [0] * n
for _ in range(q):
p, x = (int(i) for i in input().split())
ans[p - 1] += x
query = deque([(0, -1)])
while query:
current_node, parent_node = query.popleft()
current_value = ans[current_node]
for node in tree[current_node]:
if node == parent_node:
continue
else:
ans[node] += current_value
query.append([node, current_node])
print((*ans))
| from collections import deque
import sys
input = sys.stdin.readline
n, q = list(map(int, input().split()))
tree = [[] for _ in range(n)]
for _ in range(n - 1):
a, b = list(map(int, input().split()))
tree[a - 1].append(b - 1)
tree[b - 1].append(a - 1)
counter = [0] * n
for _ in range(q):
p, x = list(map(int, input().split()))
counter[p - 1] += x
query = deque([(0, -1)]) # current, parent
while query:
current, parent = query.popleft()
value = counter[current]
for node in tree[current]:
if node == parent:
continue
else:
counter[node] += value
query.append((node, current))
print((*counter))
| false | 3.225806 | [
"-n, q = (int(i) for i in input().split())",
"+n, q = list(map(int, input().split()))",
"- a, b = (int(i) for i in input().split())",
"+ a, b = list(map(int, input().split()))",
"-ans = [0] * n",
"+counter = [0] * n",
"- p, x = (int(i) for i in input().split())",
"- ans[p - 1] += x",
"-q... | false | 0.049402 | 0.033528 | 1.473452 | [
"s439069360",
"s315625483"
] |
u353797797 | p03177 | python | s376321305 | s326390793 | 1,889 | 857 | 72,796 | 13,296 | Accepted | Accepted | 54.63 | import sys
input = sys.stdin.readline
def dot(a, b):
c = [[0] * n for _ in range(n)]
for i, ai in enumerate(a):
for j, bj in enumerate(zip(*b)):
c[i][j] = sum(ak * bk for ak, bk in zip(ai, bj)) % md
return c
def pwr(a, k):
c = None
while c == None:
if k & 1:
c = a
a = dot(a, a)
k >>= 1
while k:
if k & 1:
c = dot(a, c)
a = dot(a, a)
k >>= 1
return c
md = 10 ** 9 + 7
n, k = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
print((sum([sum(pk) % md for pk in pwr(a, k)]) % md))
| import numpy as np
import sys
input = sys.stdin.readline
md = 10 ** 9 + 7
n, k = list(map(int, input().split()))
a = np.array([list(map(int, input().split())) for _ in range(n)], dtype="O")
c = np.eye(n, dtype="O")
while k:
if k & 1:
c = np.dot(a, c) % md
a = np.dot(a, a) % md
k >>= 1
print((np.sum(c) % md))
| 33 | 16 | 669 | 340 | import sys
input = sys.stdin.readline
def dot(a, b):
c = [[0] * n for _ in range(n)]
for i, ai in enumerate(a):
for j, bj in enumerate(zip(*b)):
c[i][j] = sum(ak * bk for ak, bk in zip(ai, bj)) % md
return c
def pwr(a, k):
c = None
while c == None:
if k & 1:
c = a
a = dot(a, a)
k >>= 1
while k:
if k & 1:
c = dot(a, c)
a = dot(a, a)
k >>= 1
return c
md = 10**9 + 7
n, k = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
print((sum([sum(pk) % md for pk in pwr(a, k)]) % md))
| import numpy as np
import sys
input = sys.stdin.readline
md = 10**9 + 7
n, k = list(map(int, input().split()))
a = np.array([list(map(int, input().split())) for _ in range(n)], dtype="O")
c = np.eye(n, dtype="O")
while k:
if k & 1:
c = np.dot(a, c) % md
a = np.dot(a, a) % md
k >>= 1
print((np.sum(c) % md))
| false | 51.515152 | [
"+import numpy as np",
"-",
"-",
"-def dot(a, b):",
"- c = [[0] * n for _ in range(n)]",
"- for i, ai in enumerate(a):",
"- for j, bj in enumerate(zip(*b)):",
"- c[i][j] = sum(ak * bk for ak, bk in zip(ai, bj)) % md",
"- return c",
"-",
"-",
"-def pwr(a, k):",
"- ... | false | 0.047976 | 0.215581 | 0.222544 | [
"s376321305",
"s326390793"
] |
u058240079 | p03610 | python | s282798066 | s608865430 | 25 | 22 | 3,424 | 3,140 | Accepted | Accepted | 12 | print("".join(map(str, [c for i,c in enumerate(input()) if i % 2 == 0])))
| print("".join([c for i,c in enumerate(input()) if i % 2 == 0]))
| 1 | 1 | 77 | 67 | print("".join(map(str, [c for i, c in enumerate(input()) if i % 2 == 0])))
| print("".join([c for i, c in enumerate(input()) if i % 2 == 0]))
| false | 0 | [
"-print(\"\".join(map(str, [c for i, c in enumerate(input()) if i % 2 == 0])))",
"+print(\"\".join([c for i, c in enumerate(input()) if i % 2 == 0]))"
] | false | 0.038251 | 0.037995 | 1.006753 | [
"s282798066",
"s608865430"
] |
u958506960 | p02861 | python | s780908372 | s164157681 | 319 | 26 | 13,928 | 9,276 | Accepted | Accepted | 91.85 | from itertools import permutations
import math
n = int(eval(input()))
l = [list(map(int, input().split())) for _ in range(n)]
m = math.factorial(n)
p = list(permutations(l))
d = 0
for i in range(m):
for j in range(n-1):
x = p[i][j][0] - p[i][j-1][0]
y = p[i][j][1] - p[i][j-1][1]
d += math.sqrt(x**2 + y**2)
print((d/m)) | n = int(eval(input()))
l = [list(map(int, input().split())) for _ in range(n)]
d = 0
for x, y in l:
for z, w in l:
d += ((x-z)**2+(y-w)**2)**0.5
print((d/n)) | 16 | 8 | 358 | 169 | from itertools import permutations
import math
n = int(eval(input()))
l = [list(map(int, input().split())) for _ in range(n)]
m = math.factorial(n)
p = list(permutations(l))
d = 0
for i in range(m):
for j in range(n - 1):
x = p[i][j][0] - p[i][j - 1][0]
y = p[i][j][1] - p[i][j - 1][1]
d += math.sqrt(x**2 + y**2)
print((d / m))
| n = int(eval(input()))
l = [list(map(int, input().split())) for _ in range(n)]
d = 0
for x, y in l:
for z, w in l:
d += ((x - z) ** 2 + (y - w) ** 2) ** 0.5
print((d / n))
| false | 50 | [
"-from itertools import permutations",
"-import math",
"-",
"-m = math.factorial(n)",
"-p = list(permutations(l))",
"-for i in range(m):",
"- for j in range(n - 1):",
"- x = p[i][j][0] - p[i][j - 1][0]",
"- y = p[i][j][1] - p[i][j - 1][1]",
"- d += math.sqrt(x**2 + y**2)",
... | false | 0.044141 | 0.040818 | 1.081404 | [
"s780908372",
"s164157681"
] |
u548303713 | p02873 | python | s697002951 | s820339549 | 344 | 311 | 104,524 | 120,948 | Accepted | Accepted | 9.59 | s=list(eval(input()))
n=len(s)
#print(s)
num=[]
def search(now,kigo): #自分より右に何回同じ記号が続くか
global s,n
count=0
while s[now]==kigo:
now+=1
count+=1
if now==n:
break
return count
where=0
left=0
if s[0]=="<":
a=search(0,"<")
nn=0
for i in range(a):
num.append(nn)
if i==a-1:
break
nn+=1
left=nn
else:
a=search(0,">")
nn=a
for i in range(a):
num.append(nn)
nn-=1
left=1
where=a #次調べる場所
while where<=n-1:
if s[where]=="<":
a=search(where,"<")
nn=0
for i in range(a):
num.append(nn)
if i==a-1:
break
nn+=1
left=nn
else:
a=search(where,">")
if left<a:
nn=a
else:
nn=left+1
num.append(nn)
nnn=a-1
for i in range(a-1):
num.append(nnn)
nnn-=1
left=1
where+=a
#print(a)
if s[-1]=="<":
num.append(left+1)
else:
num.append(left-1)
#print(num)
print((sum(num))) | s=list(eval(input()))
n=len(s)
l=[0] #自分より左にある<の数
r=[0] #自分より右にある>の数
l_num=0
r_num=0
for i in range(n):
if s[i]=="<":
l_num+=1
else:
l_num=0
if s[-(i+1)]==">":
r_num+=1
else:
r_num=0
l.append(l_num)
r.append(r_num)
ans=0
for i in range(n+1):
ans+=max(l[i],r[-(i+1)])
print(ans) | 62 | 21 | 1,144 | 351 | s = list(eval(input()))
n = len(s)
# print(s)
num = []
def search(now, kigo): # 自分より右に何回同じ記号が続くか
global s, n
count = 0
while s[now] == kigo:
now += 1
count += 1
if now == n:
break
return count
where = 0
left = 0
if s[0] == "<":
a = search(0, "<")
nn = 0
for i in range(a):
num.append(nn)
if i == a - 1:
break
nn += 1
left = nn
else:
a = search(0, ">")
nn = a
for i in range(a):
num.append(nn)
nn -= 1
left = 1
where = a # 次調べる場所
while where <= n - 1:
if s[where] == "<":
a = search(where, "<")
nn = 0
for i in range(a):
num.append(nn)
if i == a - 1:
break
nn += 1
left = nn
else:
a = search(where, ">")
if left < a:
nn = a
else:
nn = left + 1
num.append(nn)
nnn = a - 1
for i in range(a - 1):
num.append(nnn)
nnn -= 1
left = 1
where += a
# print(a)
if s[-1] == "<":
num.append(left + 1)
else:
num.append(left - 1)
# print(num)
print((sum(num)))
| s = list(eval(input()))
n = len(s)
l = [0] # 自分より左にある<の数
r = [0] # 自分より右にある>の数
l_num = 0
r_num = 0
for i in range(n):
if s[i] == "<":
l_num += 1
else:
l_num = 0
if s[-(i + 1)] == ">":
r_num += 1
else:
r_num = 0
l.append(l_num)
r.append(r_num)
ans = 0
for i in range(n + 1):
ans += max(l[i], r[-(i + 1)])
print(ans)
| false | 66.129032 | [
"-# print(s)",
"-num = []",
"-",
"-",
"-def search(now, kigo): # 自分より右に何回同じ記号が続くか",
"- global s, n",
"- count = 0",
"- while s[now] == kigo:",
"- now += 1",
"- count += 1",
"- if now == n:",
"- break",
"- return count",
"-",
"-",
"-where = 0... | false | 0.096244 | 0.048342 | 1.990874 | [
"s697002951",
"s820339549"
] |
u403301154 | p03805 | python | s714099442 | s376786195 | 32 | 26 | 3,064 | 3,316 | Accepted | Accepted | 18.75 | n, m = list(map(int, input().split()))
e = [[False]*n for _ in range(n)]
for m in range(m):
a, b = list(map(int, input().split()))
e[a-1][b-1] = True
e[b-1][a-1] = True
visited = [False for _ in range(n)]
ans = 0
def dfs(v):
global ans
if all(visited):
ans += 1
return
for i in range(n):
if e[v][i] == False:
continue
if visited[i] == True:
continue
visited[i] = True
dfs(i)
visited[i] = False
visited[0] = True
dfs(0)
print(ans) | from collections import defaultdict
n, m = list(map(int, input().split()))
edge = defaultdict(list)
for i in range(m):
a, b = list(map(int, input().split()))
edge[a-1].append(b-1)
edge[b-1].append(a-1)
visited = [0 for i in range(n)]
ans = 0
def dfs(x, t):
if t==n:
return 1
visited[x] = 1
cur = 0
for nx in edge[x]:
if not visited[nx]:
cur += dfs(nx, t+1)
visited[x] = 0
return cur
print((dfs(0, 1))) | 30 | 23 | 506 | 456 | n, m = list(map(int, input().split()))
e = [[False] * n for _ in range(n)]
for m in range(m):
a, b = list(map(int, input().split()))
e[a - 1][b - 1] = True
e[b - 1][a - 1] = True
visited = [False for _ in range(n)]
ans = 0
def dfs(v):
global ans
if all(visited):
ans += 1
return
for i in range(n):
if e[v][i] == False:
continue
if visited[i] == True:
continue
visited[i] = True
dfs(i)
visited[i] = False
visited[0] = True
dfs(0)
print(ans)
| from collections import defaultdict
n, m = list(map(int, input().split()))
edge = defaultdict(list)
for i in range(m):
a, b = list(map(int, input().split()))
edge[a - 1].append(b - 1)
edge[b - 1].append(a - 1)
visited = [0 for i in range(n)]
ans = 0
def dfs(x, t):
if t == n:
return 1
visited[x] = 1
cur = 0
for nx in edge[x]:
if not visited[nx]:
cur += dfs(nx, t + 1)
visited[x] = 0
return cur
print((dfs(0, 1)))
| false | 23.333333 | [
"+from collections import defaultdict",
"+",
"-e = [[False] * n for _ in range(n)]",
"-for m in range(m):",
"+edge = defaultdict(list)",
"+for i in range(m):",
"- e[a - 1][b - 1] = True",
"- e[b - 1][a - 1] = True",
"-visited = [False for _ in range(n)]",
"+ edge[a - 1].append(b - 1)",
... | false | 0.105305 | 0.03651 | 2.884276 | [
"s714099442",
"s376786195"
] |
u075012704 | p03946 | python | s791152180 | s516085755 | 95 | 87 | 15,020 | 14,244 | Accepted | Accepted | 8.42 | N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
B = A[::-1]
C = []
maxv = 0
for i in range(N):
if maxv > B[i]:
C.append(maxv)
else:
maxv = B[i]
C.append(maxv)
C = C[::-1]
ans = 0
maxv = 0
for i in range(N-1):
z = C[i] - A[i]
if maxv > z:
continue
elif maxv < z:
maxv = z
ans = 1
else:
ans += 1
print(ans)
| N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
maxp = 0
minv = float('inf')
ans = 0
for a in A:
p = a - minv
if p > maxp:
maxp = p
ans = 1
elif p == maxp:
ans += 1
minv = min(minv, a)
print(ans) | 29 | 17 | 439 | 275 | N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
B = A[::-1]
C = []
maxv = 0
for i in range(N):
if maxv > B[i]:
C.append(maxv)
else:
maxv = B[i]
C.append(maxv)
C = C[::-1]
ans = 0
maxv = 0
for i in range(N - 1):
z = C[i] - A[i]
if maxv > z:
continue
elif maxv < z:
maxv = z
ans = 1
else:
ans += 1
print(ans)
| N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
maxp = 0
minv = float("inf")
ans = 0
for a in A:
p = a - minv
if p > maxp:
maxp = p
ans = 1
elif p == maxp:
ans += 1
minv = min(minv, a)
print(ans)
| false | 41.37931 | [
"-B = A[::-1]",
"-C = []",
"-maxv = 0",
"-for i in range(N):",
"- if maxv > B[i]:",
"- C.append(maxv)",
"- else:",
"- maxv = B[i]",
"- C.append(maxv)",
"-C = C[::-1]",
"+maxp = 0",
"+minv = float(\"inf\")",
"-maxv = 0",
"-for i in range(N - 1):",
"- z = C[i]... | false | 0.05027 | 0.042721 | 1.176699 | [
"s791152180",
"s516085755"
] |
u753803401 | p03386 | python | s085089154 | s489366399 | 23 | 21 | 3,064 | 3,316 | Accepted | Accepted | 8.7 | a, b, k = list(map(int, input().split()))
l = []
for i in range(a, min(a + k, b + 1)):
if i not in l:
l.append(i)
for i in range(b, max(b - k, a - 1), -1):
if i not in l:
l.append(i)
l.sort()
for i in l:
print(i)
| import collections
a, b, k = list(map(int, input().split()))
ans = [a, b]
for i in range(a, min(a + k, b )):
if i not in ans:
ans.append(i)
for i in range(b, max(b - k, a), - 1):
if i not in ans:
ans.append(i)
ans = collections.Counter(ans).most_common()
ans.sort()
for i in ans:
print((i[0]))
| 11 | 13 | 245 | 326 | a, b, k = list(map(int, input().split()))
l = []
for i in range(a, min(a + k, b + 1)):
if i not in l:
l.append(i)
for i in range(b, max(b - k, a - 1), -1):
if i not in l:
l.append(i)
l.sort()
for i in l:
print(i)
| import collections
a, b, k = list(map(int, input().split()))
ans = [a, b]
for i in range(a, min(a + k, b)):
if i not in ans:
ans.append(i)
for i in range(b, max(b - k, a), -1):
if i not in ans:
ans.append(i)
ans = collections.Counter(ans).most_common()
ans.sort()
for i in ans:
print((i[0]))
| false | 15.384615 | [
"+import collections",
"+",
"-l = []",
"-for i in range(a, min(a + k, b + 1)):",
"- if i not in l:",
"- l.append(i)",
"-for i in range(b, max(b - k, a - 1), -1):",
"- if i not in l:",
"- l.append(i)",
"-l.sort()",
"-for i in l:",
"- print(i)",
"+ans = [a, b]",
"+for ... | false | 0.041489 | 0.037442 | 1.1081 | [
"s085089154",
"s489366399"
] |
u038021590 | p03164 | python | s226930505 | s606770676 | 1,006 | 833 | 309,712 | 229,832 | Accepted | Accepted | 17.2 | N, W = list(map(int, input().split()))
Weight = [0]
Value = [0]
ans = 0
for i in range(N):
w, v = list(map(int, input().split()))
Weight.append(w)
Value.append(v)
VS = sum(Value)
DP = [[float('inf')] * (VS + 1) for i in range(N + 1)]
for n in range(N + 1):
for val in range(VS + 1):
if val == 0:
DP[n][val] = 0
elif Value[n] > val:
DP[n][val] = DP[n - 1][val]
else:
DP[n][val] = min(DP[n - 1][val], DP[n - 1][val - Value[n]] + Weight[n])
if (n == N) and (DP[n][val] <= W):
ans = max(ans, val)
print(ans) | N, W = list(map(int, input().split()))
Items = [tuple(map(int, input().split())) for _ in range(N)]
DP = [float('inf')] * 10 ** 6
DP[0] = 0
for w, v in Items:
D = DP[:]
for i, d in enumerate(DP):
if w + d > W:
continue
D[i + v] = min(DP[i + v], w + d)
DP = D
ans = 0
for i, d in enumerate(DP):
if d == float('inf'):
continue
ans = i
print(ans) | 23 | 17 | 619 | 409 | N, W = list(map(int, input().split()))
Weight = [0]
Value = [0]
ans = 0
for i in range(N):
w, v = list(map(int, input().split()))
Weight.append(w)
Value.append(v)
VS = sum(Value)
DP = [[float("inf")] * (VS + 1) for i in range(N + 1)]
for n in range(N + 1):
for val in range(VS + 1):
if val == 0:
DP[n][val] = 0
elif Value[n] > val:
DP[n][val] = DP[n - 1][val]
else:
DP[n][val] = min(DP[n - 1][val], DP[n - 1][val - Value[n]] + Weight[n])
if (n == N) and (DP[n][val] <= W):
ans = max(ans, val)
print(ans)
| N, W = list(map(int, input().split()))
Items = [tuple(map(int, input().split())) for _ in range(N)]
DP = [float("inf")] * 10**6
DP[0] = 0
for w, v in Items:
D = DP[:]
for i, d in enumerate(DP):
if w + d > W:
continue
D[i + v] = min(DP[i + v], w + d)
DP = D
ans = 0
for i, d in enumerate(DP):
if d == float("inf"):
continue
ans = i
print(ans)
| false | 26.086957 | [
"-Weight = [0]",
"-Value = [0]",
"+Items = [tuple(map(int, input().split())) for _ in range(N)]",
"+DP = [float(\"inf\")] * 10**6",
"+DP[0] = 0",
"+for w, v in Items:",
"+ D = DP[:]",
"+ for i, d in enumerate(DP):",
"+ if w + d > W:",
"+ continue",
"+ D[i + v] = mi... | false | 0.098652 | 2.220302 | 0.044432 | [
"s226930505",
"s606770676"
] |
u416758623 | p03061 | python | s609728664 | s303640918 | 192 | 45 | 16,148 | 14,584 | Accepted | Accepted | 76.56 | import fractions
n = int(eval(input()))
a = list(map(int, input().split()))
l = [0]
r = [0]
for i in range(n):
l.append(fractions.gcd(l[i], a[i]))
r.append(fractions.gcd(r[i], a[-(i+1)]))
m = [fractions.gcd(l[i], r[-(i+2)]) for i in range(n)]
print((max(m))) | n = int(eval(input()))
ls = list(map(int, input().split()))
p = 50
ans = 0
if p>n:p=n
def gcd(a,b):
if a < b:
a,b = b,a
while b:
a, b =b, a % b
return a
def cul(n, x):
l = len(x)
b = [x[i] for i in range(l)]
b.pop(n)
tmp = b[0]
for i in range(1, l-1):
tmp = gcd(tmp, b[i])
return tmp
for i in range(p):
s = cul(i,ls[:p])
if s > ans:
ans = s
print(ans)
| 13 | 27 | 277 | 455 | import fractions
n = int(eval(input()))
a = list(map(int, input().split()))
l = [0]
r = [0]
for i in range(n):
l.append(fractions.gcd(l[i], a[i]))
r.append(fractions.gcd(r[i], a[-(i + 1)]))
m = [fractions.gcd(l[i], r[-(i + 2)]) for i in range(n)]
print((max(m)))
| n = int(eval(input()))
ls = list(map(int, input().split()))
p = 50
ans = 0
if p > n:
p = n
def gcd(a, b):
if a < b:
a, b = b, a
while b:
a, b = b, a % b
return a
def cul(n, x):
l = len(x)
b = [x[i] for i in range(l)]
b.pop(n)
tmp = b[0]
for i in range(1, l - 1):
tmp = gcd(tmp, b[i])
return tmp
for i in range(p):
s = cul(i, ls[:p])
if s > ans:
ans = s
print(ans)
| false | 51.851852 | [
"-import fractions",
"+n = int(eval(input()))",
"+ls = list(map(int, input().split()))",
"+p = 50",
"+ans = 0",
"+if p > n:",
"+ p = n",
"-n = int(eval(input()))",
"-a = list(map(int, input().split()))",
"-l = [0]",
"-r = [0]",
"-for i in range(n):",
"- l.append(fractions.gcd(l[i], a[i... | false | 0.045443 | 0.034748 | 1.30779 | [
"s609728664",
"s303640918"
] |
u938486382 | p03209 | python | s551985688 | s948004141 | 20 | 17 | 3,188 | 3,064 | Accepted | Accepted | 15 | n, k = list(map(int, input().split(' ')))
lens = {}
lens[0] = 1
for i in range(1, 51):
lens[i] = lens[i-1] * 2 + 3
memo = {}
def sumP(level, index):
key = (level, index)
if key in memo:
return memo[key]
if level == 0:
if index == 1:
memo[key] = 1
else:
memo[key] = 0
elif index < lens[level] // 2 + 1: # レベル一つ下の奴の一部分のみ
memo[key] = sumP(level-1, index-1)
elif index == lens[level] // 2 + 1: # ど真ん中のPを入れて一つ下全部(index-1は左端のB)
memo[key] = 1 + sumP(level-1, lens[level-1])
else: # レベル一つ下の奴の丸々1つ + P + レベル一つ下の奴の一部分もしくは全部, minは最後のBを捨てるため
memo[key] = sumP(level-1, lens[level-1]) + 1 + sumP(level-1, min(lens[level-1], index-lens[level-1]-2))
return memo[key]
print((sumP(n, k)))
| n, k = list(map(int, input().split(' ')))
lens = {0: 1}
for i in range(1, 51):
lens[i] = lens[i-1] * 2 + 3
memo = {}
def sumP(level, index):
key = (level, index)
if key in memo:
return memo[key]
if level == 0:
if index == 1:
memo[key] = 1
else:
memo[key] = 0
elif index < lens[level] // 2 + 1: # レベル一つ下の奴の一部分のみ
memo[key] = sumP(level-1, index-1)
elif index == lens[level] // 2 + 1: # ど真ん中のPを入れて一つ下全部(index-1は左端のB)
memo[key] = 1 + sumP(level-1, lens[level-1])
else: # レベル一つ下の奴の丸々1つ + P + レベル一つ下の奴の一部分もしくは全部, minは最後のBを捨てるため
memo[key] = sumP(level-1, lens[level-1]) + 1 + sumP(level-1, min(lens[level-1], index-lens[level-1]-2))
return memo[key]
print((sumP(n, k))) | 26 | 23 | 752 | 738 | n, k = list(map(int, input().split(" ")))
lens = {}
lens[0] = 1
for i in range(1, 51):
lens[i] = lens[i - 1] * 2 + 3
memo = {}
def sumP(level, index):
key = (level, index)
if key in memo:
return memo[key]
if level == 0:
if index == 1:
memo[key] = 1
else:
memo[key] = 0
elif index < lens[level] // 2 + 1: # レベル一つ下の奴の一部分のみ
memo[key] = sumP(level - 1, index - 1)
elif index == lens[level] // 2 + 1: # ど真ん中のPを入れて一つ下全部(index-1は左端のB)
memo[key] = 1 + sumP(level - 1, lens[level - 1])
else: # レベル一つ下の奴の丸々1つ + P + レベル一つ下の奴の一部分もしくは全部, minは最後のBを捨てるため
memo[key] = (
sumP(level - 1, lens[level - 1])
+ 1
+ sumP(level - 1, min(lens[level - 1], index - lens[level - 1] - 2))
)
return memo[key]
print((sumP(n, k)))
| n, k = list(map(int, input().split(" ")))
lens = {0: 1}
for i in range(1, 51):
lens[i] = lens[i - 1] * 2 + 3
memo = {}
def sumP(level, index):
key = (level, index)
if key in memo:
return memo[key]
if level == 0:
if index == 1:
memo[key] = 1
else:
memo[key] = 0
elif index < lens[level] // 2 + 1: # レベル一つ下の奴の一部分のみ
memo[key] = sumP(level - 1, index - 1)
elif index == lens[level] // 2 + 1: # ど真ん中のPを入れて一つ下全部(index-1は左端のB)
memo[key] = 1 + sumP(level - 1, lens[level - 1])
else: # レベル一つ下の奴の丸々1つ + P + レベル一つ下の奴の一部分もしくは全部, minは最後のBを捨てるため
memo[key] = (
sumP(level - 1, lens[level - 1])
+ 1
+ sumP(level - 1, min(lens[level - 1], index - lens[level - 1] - 2))
)
return memo[key]
print((sumP(n, k)))
| false | 11.538462 | [
"-lens = {}",
"-lens[0] = 1",
"+lens = {0: 1}"
] | false | 0.048719 | 0.05046 | 0.965501 | [
"s551985688",
"s948004141"
] |
u796942881 | p02983 | python | s468974575 | s476780338 | 43 | 37 | 6,804 | 3,316 | Accepted | Accepted | 13.95 | def main():
L, R = list(map(int, input().split()))
# 60 の相異なる素因数は 3, 673 の 2つ
if L + 672 <= R:
print((0))
return
lst = []
for i in range(L, R + 1):
for j in range(i + 1, R + 1):
m = i * j % 2019
lst.append(m)
if m == 0:
break
if m == 0:
break
print((min(lst)))
return
main()
| def main():
L, R = list(map(int, input().split()))
# 60 の相異なる素因数は 3, 673 の 2つ
if L + 672 <= R:
print((0))
return
print((min(i * j % 2019 for i in range(L, R + 1)
for j in range(i + 1, R + 1))))
return
main()
| 20 | 12 | 410 | 261 | def main():
L, R = list(map(int, input().split()))
# 60 の相異なる素因数は 3, 673 の 2つ
if L + 672 <= R:
print((0))
return
lst = []
for i in range(L, R + 1):
for j in range(i + 1, R + 1):
m = i * j % 2019
lst.append(m)
if m == 0:
break
if m == 0:
break
print((min(lst)))
return
main()
| def main():
L, R = list(map(int, input().split()))
# 60 の相異なる素因数は 3, 673 の 2つ
if L + 672 <= R:
print((0))
return
print((min(i * j % 2019 for i in range(L, R + 1) for j in range(i + 1, R + 1))))
return
main()
| false | 40 | [
"- lst = []",
"- for i in range(L, R + 1):",
"- for j in range(i + 1, R + 1):",
"- m = i * j % 2019",
"- lst.append(m)",
"- if m == 0:",
"- break",
"- if m == 0:",
"- break",
"- print((min(lst)))",
"+ print((min... | false | 0.046056 | 0.039009 | 1.180655 | [
"s468974575",
"s476780338"
] |
u046187684 | p02584 | python | s298062826 | s640455919 | 31 | 26 | 9,196 | 9,004 | Accepted | Accepted | 16.13 | def solve(string):
x, k, d = list(map(int, string.split()))
x = abs(x)
if k % 2:
x = min(x - d, x + d, key=abs)
k -= 1
k, d = k // 2, d * 2
if x < k * d:
return str(min(x % d, abs((x % d) - d)))
else:
return str(x - k * d)
if __name__ == '__main__':
import sys
print((solve(sys.stdin.read().strip())))
| def solve(string):
x, k, d = list(map(int, string.split()))
x = abs(x)
if k % 2:
x = min(x - d, x + d, key=abs)
k -= 1
k, d = k // 2, d * 2
return str(min(x % d, abs((x % d) - d))) if x < k * d else str(x - k * d)
if __name__ == '__main__':
import sys
print((solve(sys.stdin.read().strip())))
| 16 | 13 | 375 | 343 | def solve(string):
x, k, d = list(map(int, string.split()))
x = abs(x)
if k % 2:
x = min(x - d, x + d, key=abs)
k -= 1
k, d = k // 2, d * 2
if x < k * d:
return str(min(x % d, abs((x % d) - d)))
else:
return str(x - k * d)
if __name__ == "__main__":
import sys
print((solve(sys.stdin.read().strip())))
| def solve(string):
x, k, d = list(map(int, string.split()))
x = abs(x)
if k % 2:
x = min(x - d, x + d, key=abs)
k -= 1
k, d = k // 2, d * 2
return str(min(x % d, abs((x % d) - d))) if x < k * d else str(x - k * d)
if __name__ == "__main__":
import sys
print((solve(sys.stdin.read().strip())))
| false | 18.75 | [
"- if x < k * d:",
"- return str(min(x % d, abs((x % d) - d)))",
"- else:",
"- return str(x - k * d)",
"+ return str(min(x % d, abs((x % d) - d))) if x < k * d else str(x - k * d)"
] | false | 0.038086 | 0.037587 | 1.013264 | [
"s298062826",
"s640455919"
] |
u054825571 | p02882 | python | s693349763 | s979505101 | 179 | 164 | 38,384 | 38,256 | Accepted | Accepted | 8.38 | import math
a,b,x=list(map(int,input().split()))
v=a*a*b
if v <= 2*x:
b1=(v-x)/a*2/a
c=math.sqrt(a**2+b1**2)
print((math.degrees(math.acos(a/c))))
else:
a1=((x/a)*2)/b
c=math.sqrt(a1**2+b**2)
print((math.degrees(math.asin(b/c))))
| import math
a,b,x=list(map(int,input().split()))
if a*a*b <= 2*x:
b1=(a*a*b-x)/a*2/a
print((math.degrees(math.atan(b1/a))))
else:
a1=((x/a)*2)/b
print((math.degrees(math.atan(b/a1)))) | 11 | 8 | 254 | 196 | import math
a, b, x = list(map(int, input().split()))
v = a * a * b
if v <= 2 * x:
b1 = (v - x) / a * 2 / a
c = math.sqrt(a**2 + b1**2)
print((math.degrees(math.acos(a / c))))
else:
a1 = ((x / a) * 2) / b
c = math.sqrt(a1**2 + b**2)
print((math.degrees(math.asin(b / c))))
| import math
a, b, x = list(map(int, input().split()))
if a * a * b <= 2 * x:
b1 = (a * a * b - x) / a * 2 / a
print((math.degrees(math.atan(b1 / a))))
else:
a1 = ((x / a) * 2) / b
print((math.degrees(math.atan(b / a1))))
| false | 27.272727 | [
"-v = a * a * b",
"-if v <= 2 * x:",
"- b1 = (v - x) / a * 2 / a",
"- c = math.sqrt(a**2 + b1**2)",
"- print((math.degrees(math.acos(a / c))))",
"+if a * a * b <= 2 * x:",
"+ b1 = (a * a * b - x) / a * 2 / a",
"+ print((math.degrees(math.atan(b1 / a))))",
"- c = math.sqrt(a1**2 + b... | false | 0.1649 | 0.044476 | 3.707584 | [
"s693349763",
"s979505101"
] |
u089230684 | p02753 | python | s981350243 | s091279314 | 164 | 17 | 38,384 | 2,940 | Accepted | Accepted | 89.63 | l = eval(input())
n = len(l)
stat = "No"
for i in range(n-1):
if l[i] != l[i+1]:
stat = "Yes"
break
print(stat) | a = eval(input())
a1 = list(set(a))
if len(a1) == 2:
print("Yes")
else:
print("No") | 9 | 6 | 134 | 90 | l = eval(input())
n = len(l)
stat = "No"
for i in range(n - 1):
if l[i] != l[i + 1]:
stat = "Yes"
break
print(stat)
| a = eval(input())
a1 = list(set(a))
if len(a1) == 2:
print("Yes")
else:
print("No")
| false | 33.333333 | [
"-l = eval(input())",
"-n = len(l)",
"-stat = \"No\"",
"-for i in range(n - 1):",
"- if l[i] != l[i + 1]:",
"- stat = \"Yes\"",
"- break",
"-print(stat)",
"+a = eval(input())",
"+a1 = list(set(a))",
"+if len(a1) == 2:",
"+ print(\"Yes\")",
"+else:",
"+ print(\"No\")"... | false | 0.147394 | 0.039171 | 3.762808 | [
"s981350243",
"s091279314"
] |
u873482706 | p00209 | python | s710602474 | s730062968 | 1,190 | 1,050 | 4,528 | 4,532 | Accepted | Accepted | 11.76 | def main(piece, c):
for h in range(n-m+1):
for w in range(n-m+1):
if f(piece, h, w):
break
if c != 4:
move(piece, c)
else:
if ans:
print(ans[0], ans[1])
else:
print('NA')
def f(piece, h, w):
global ans
coordinate = None
for _h in range(m):
for _w in range(m):
if piece[_h][_w] != '-1':
if piece[_h][_w] == picture[h+_h][w+_w]:
if coordinate is None:
coordinate = (int(w+_w+1), int(h+_h+1))
if ans:
if coordinate[1] > ans[1]:
return
elif coordinate[1] == ans[1]:
if coordinate[0] > ans[0]:
return
else:
return
else:
ans = coordinate
return True
def move(piece, c):
_piece = []
for w in range(m):
lis = []
for h in range(m):
lis.append(piece[h][w])
else:
lis.reverse()
_piece.append(lis)
else:
main(_piece, c+1)
while True:
n, m = list(map(int, input().split()))
if n == m == 0: break
picture = [input().split() for i in range(n)]
piece = [input().split() for i in range(m)]
ans = None
main(piece, 1) | def main(piece, c):
for h in range(n-m+1):
for w in range(n-m+1):
if f(piece, h, w):
break
if c != 4:
move(piece, c)
else:
if ans:
print(ans[0], ans[1])
else:
print('NA')
def f(piece, h, w):
global ans
coordinate = None
for _h in range(m):
for _w in range(m):
if piece[_h][_w] != '-1':
if piece[_h][_w] == picture[h+_h][w+_w]:
if coordinate is None:
coordinate = (int(w+_w+1), int(h+_h+1))
else:
return
else:
if ans is None:
ans = coordinate
elif coordinate[1] < ans[1]:
ans = coordinate
elif coordinate[1] == ans[1]:
if coordinate[0] < ans[0]:
ans = coordinate
return True
def move(piece, c):
_piece = []
for w in range(m):
lis = []
for h in range(m):
lis.append(piece[h][w])
else:
lis.reverse()
_piece.append(lis)
else:
main(_piece, c+1)
while True:
n, m = list(map(int, input().split()))
if n == m == 0: break
picture = [input().split() for i in range(n)]
piece = [input().split() for i in range(m)]
ans = None
main(piece, 1) | 53 | 53 | 1,489 | 1,407 | def main(piece, c):
for h in range(n - m + 1):
for w in range(n - m + 1):
if f(piece, h, w):
break
if c != 4:
move(piece, c)
else:
if ans:
print(ans[0], ans[1])
else:
print("NA")
def f(piece, h, w):
global ans
coordinate = None
for _h in range(m):
for _w in range(m):
if piece[_h][_w] != "-1":
if piece[_h][_w] == picture[h + _h][w + _w]:
if coordinate is None:
coordinate = (int(w + _w + 1), int(h + _h + 1))
if ans:
if coordinate[1] > ans[1]:
return
elif coordinate[1] == ans[1]:
if coordinate[0] > ans[0]:
return
else:
return
else:
ans = coordinate
return True
def move(piece, c):
_piece = []
for w in range(m):
lis = []
for h in range(m):
lis.append(piece[h][w])
else:
lis.reverse()
_piece.append(lis)
else:
main(_piece, c + 1)
while True:
n, m = list(map(int, input().split()))
if n == m == 0:
break
picture = [input().split() for i in range(n)]
piece = [input().split() for i in range(m)]
ans = None
main(piece, 1)
| def main(piece, c):
for h in range(n - m + 1):
for w in range(n - m + 1):
if f(piece, h, w):
break
if c != 4:
move(piece, c)
else:
if ans:
print(ans[0], ans[1])
else:
print("NA")
def f(piece, h, w):
global ans
coordinate = None
for _h in range(m):
for _w in range(m):
if piece[_h][_w] != "-1":
if piece[_h][_w] == picture[h + _h][w + _w]:
if coordinate is None:
coordinate = (int(w + _w + 1), int(h + _h + 1))
else:
return
else:
if ans is None:
ans = coordinate
elif coordinate[1] < ans[1]:
ans = coordinate
elif coordinate[1] == ans[1]:
if coordinate[0] < ans[0]:
ans = coordinate
return True
def move(piece, c):
_piece = []
for w in range(m):
lis = []
for h in range(m):
lis.append(piece[h][w])
else:
lis.reverse()
_piece.append(lis)
else:
main(_piece, c + 1)
while True:
n, m = list(map(int, input().split()))
if n == m == 0:
break
picture = [input().split() for i in range(n)]
piece = [input().split() for i in range(m)]
ans = None
main(piece, 1)
| false | 0 | [
"- if ans:",
"- if coordinate[1] > ans[1]:",
"- return",
"- elif coordinate[1] == ans[1]:",
"- if coordinate[0] > ans[0]:",
"- retur... | false | 0.118031 | 0.042415 | 2.782738 | [
"s710602474",
"s730062968"
] |
u528181687 | p02536 | python | s010042709 | s275157064 | 288 | 266 | 19,208 | 12,908 | Accepted | Accepted | 7.64 | def main():
n, m = list(map(int, input().split()))
# マイナスの場合は leader であり、同時にサイズ(*-1)を保持する
uf = [-1] * (n+1)
def uf_leader(a):
if uf[a]<0:
return a
uf[a] = uf_leader(uf[a])
return uf[a]
def uf_unite(a, b):
ua, ub = uf_leader(a), uf_leader(b)
if ua==ub:
return False
if uf[ua] > uf[ub]:
ua, ub = ub, ua
uf[ua] += uf[ub]
uf[ub] = ua
return True
def uf_leaders():
return set([uf_leader(v) for v in range(1,n+1)])
# print(uf[1:])
for _ in range(m):
a, b = list(map(int, input().split()))
uf_unite(a, b)
# print(uf[1:])
# print(uf_leaders())
ans = len(uf_leaders())-1
print(ans)
main() | def main():
n, m = list(map(int, input().split()))
# マイナスの場合は leader であり、同時にサイズ(*-1)を保持する
uf = [-1] * (n+1)
def uf_leader(a):
if uf[a]<0:
return a
uf[a] = uf_leader(uf[a])
return uf[a]
def uf_unite(a, b):
ua, ub = uf_leader(a), uf_leader(b)
if ua==ub:
return False
if uf[ua] > uf[ub]:
ua, ub = ub, ua
uf[ua] += uf[ub]
uf[ub] = ua
return True
def uf_leaders():
return [v for v in range(1,n+1) if uf[v]<0]
# print(uf[1:])
for _ in range(m):
a, b = list(map(int, input().split()))
uf_unite(a, b)
# print(uf[1:])
# print(uf_leaders())
ans = len(uf_leaders())-1
print(ans)
main()
| 34 | 34 | 793 | 789 | def main():
n, m = list(map(int, input().split()))
# マイナスの場合は leader であり、同時にサイズ(*-1)を保持する
uf = [-1] * (n + 1)
def uf_leader(a):
if uf[a] < 0:
return a
uf[a] = uf_leader(uf[a])
return uf[a]
def uf_unite(a, b):
ua, ub = uf_leader(a), uf_leader(b)
if ua == ub:
return False
if uf[ua] > uf[ub]:
ua, ub = ub, ua
uf[ua] += uf[ub]
uf[ub] = ua
return True
def uf_leaders():
return set([uf_leader(v) for v in range(1, n + 1)])
# print(uf[1:])
for _ in range(m):
a, b = list(map(int, input().split()))
uf_unite(a, b)
# print(uf[1:])
# print(uf_leaders())
ans = len(uf_leaders()) - 1
print(ans)
main()
| def main():
n, m = list(map(int, input().split()))
# マイナスの場合は leader であり、同時にサイズ(*-1)を保持する
uf = [-1] * (n + 1)
def uf_leader(a):
if uf[a] < 0:
return a
uf[a] = uf_leader(uf[a])
return uf[a]
def uf_unite(a, b):
ua, ub = uf_leader(a), uf_leader(b)
if ua == ub:
return False
if uf[ua] > uf[ub]:
ua, ub = ub, ua
uf[ua] += uf[ub]
uf[ub] = ua
return True
def uf_leaders():
return [v for v in range(1, n + 1) if uf[v] < 0]
# print(uf[1:])
for _ in range(m):
a, b = list(map(int, input().split()))
uf_unite(a, b)
# print(uf[1:])
# print(uf_leaders())
ans = len(uf_leaders()) - 1
print(ans)
main()
| false | 0 | [
"- return set([uf_leader(v) for v in range(1, n + 1)])",
"+ return [v for v in range(1, n + 1) if uf[v] < 0]"
] | false | 0.113976 | 0.048231 | 2.363144 | [
"s010042709",
"s275157064"
] |
u032032867 | p02901 | python | s802976483 | s795981453 | 149 | 121 | 34,024 | 35,176 | Accepted | Accepted | 18.79 | # -*- coding: utf-8 -*-
# if x < y:
# z = x
# elif True:
# z = y
# else:
# z = 100
import sys,os,math
from collections import Counter, defaultdict
import bisect
from sys import stdin, stdout
from itertools import repeat
# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())
def main():
n, m = list(map(int, input().split()))
bf, af = [10000000 for i in range(1<<n)], [10000000 for i in range(1<<n)]
bf[0] = 0
for i in range(m):
a, b = list(map(int, input().split()))
ad = 0
for st in map(int, input().split()):
ad |= 1<<(st-1)
for st in range(1<<n):
af[st|ad] = min(bf[st|ad], bf[st]+a, af[st|ad])
af[st] = min(af[st], bf[st])
bf, af = af, bf
if bf[(1<<n)-1] == 10000000:
print(-1)
else:
print(bf[(1<<n)-1])
main()
| # -*- coding: utf-8 -*-
# if x < y:
# z = x
# elif True:
# z = y
# else:
# z = 100
import sys,os,math
from collections import Counter, defaultdict
import bisect
from sys import stdin, stdout
from itertools import repeat
# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())
def main():
n, m = list(map(int, input().split()))
bf, af = [10000000 for i in range(1<<n)], [10000000 for i in range(1<<n)]
bf[0] = 0
for i in range(m):
a, b = list(map(int, input().split()))
ad = 0
for st in map(int, input().split()):
ad |= 1<<(st-1)
for st in range(1<<n):
af[st|ad] = min(bf[st]+a, af[st|ad])
af[st] = min(af[st], bf[st])
bf, af = af, bf
if bf[(1<<n)-1] == 10000000:
print(-1)
else:
print(bf[(1<<n)-1])
main()
| 39 | 38 | 944 | 931 | # -*- coding: utf-8 -*-
# if x < y:
# z = x
# elif True:
# z = y
# else:
# z = 100
import sys, os, math
from collections import Counter, defaultdict
import bisect
from sys import stdin, stdout
from itertools import repeat
# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())
def main():
n, m = list(map(int, input().split()))
bf, af = [10000000 for i in range(1 << n)], [10000000 for i in range(1 << n)]
bf[0] = 0
for i in range(m):
a, b = list(map(int, input().split()))
ad = 0
for st in map(int, input().split()):
ad |= 1 << (st - 1)
for st in range(1 << n):
af[st | ad] = min(bf[st | ad], bf[st] + a, af[st | ad])
af[st] = min(af[st], bf[st])
bf, af = af, bf
if bf[(1 << n) - 1] == 10000000:
print(-1)
else:
print(bf[(1 << n) - 1])
main()
| # -*- coding: utf-8 -*-
# if x < y:
# z = x
# elif True:
# z = y
# else:
# z = 100
import sys, os, math
from collections import Counter, defaultdict
import bisect
from sys import stdin, stdout
from itertools import repeat
# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())
def main():
n, m = list(map(int, input().split()))
bf, af = [10000000 for i in range(1 << n)], [10000000 for i in range(1 << n)]
bf[0] = 0
for i in range(m):
a, b = list(map(int, input().split()))
ad = 0
for st in map(int, input().split()):
ad |= 1 << (st - 1)
for st in range(1 << n):
af[st | ad] = min(bf[st] + a, af[st | ad])
af[st] = min(af[st], bf[st])
bf, af = af, bf
if bf[(1 << n) - 1] == 10000000:
print(-1)
else:
print(bf[(1 << n) - 1])
main()
| false | 2.564103 | [
"- af[st | ad] = min(bf[st | ad], bf[st] + a, af[st | ad])",
"+ af[st | ad] = min(bf[st] + a, af[st | ad])"
] | false | 0.045011 | 0.007594 | 5.927313 | [
"s802976483",
"s795981453"
] |
u576432509 | p03111 | python | s988717405 | s500209429 | 594 | 275 | 3,192 | 3,064 | Accepted | Accepted | 53.7 | l=[]
n,a,b,c=list(map(int,input().split()))
for i in range(n):
li=int(eval(input()))
l.append(li)
d=[a,b,c]
d.sort()
mpmin=sum(l)*4+len(l)*10+sum(d)
for i in range(4**n):
k=[]
kj=i%4
k.append(kj)
b=int((i-kj)/4)
l0=[]
l1=[]
l2=[]
l3=[]
if kj==0:
l0.append(l[0])
elif kj==1:
l1.append(l[0])
elif kj==2:
l2.append(l[0])
elif kj==3:
l3.append(l[0])
for j in range(n-1):
kj=b%4
k.append(kj)
b=int((b-kj)/4)
if kj==0:
l0.append(l[j+1])
elif kj==1:
l1.append(l[j+1])
elif kj==2:
l2.append(l[j+1])
elif kj==3:
l3.append(l[j+1])
mp=0
if len(l0)>=1:
mp=mp+(len(l0)-1)*10
if len(l1)>=1:
mp=mp+(len(l1)-1)*10
if len(l2)>=1:
mp=mp+(len(l2)-1)*10
ls=[]
ls=[sum(l0),sum(l1),sum(l2)]
ls.sort()
mp=mp+abs(d[0]-ls[0])+abs(d[1]-ls[1])+abs(d[2]-ls[2])
if mpmin>mp and len(l0)>=1 and len(l1)>=1 and len(l2)>=1:
mpmin=mp
print(mpmin)
|
n,a,b,c=list(map(int,input().split()))
l=[0]*n
for i in range(n):
l[i]=int(eval(input()))
import itertools
mpmin=a+b+c+1
for i in itertools.product([0,1,2,3], repeat=n):
aa=0
bb=0
cc=0
mpa=0
mpb=0
mpc=0
ia=0
ib=0
ic=0
for ii in range(n):
if i[ii]==1:
ia=1
if aa>0:
mpa+=10
aa+=l[ii]
elif i[ii]==2:
ib=1
if bb>0:
mpb+=10
bb+=l[ii]
elif i[ii]==3:
ic=1
if cc>0:
mpc+=10
cc+=l[ii]
if ia==1 and ib==1 and ic==1:
mp=mpa+abs(a-aa)+mpb+abs(b-bb)+mpc+abs(c-cc)
# if mp<mpmin:
# print(mp,mpa,mpb,mpc,i)
mpmin=min(mp,mpmin)
print(mpmin)
| 55 | 42 | 1,151 | 830 | l = []
n, a, b, c = list(map(int, input().split()))
for i in range(n):
li = int(eval(input()))
l.append(li)
d = [a, b, c]
d.sort()
mpmin = sum(l) * 4 + len(l) * 10 + sum(d)
for i in range(4**n):
k = []
kj = i % 4
k.append(kj)
b = int((i - kj) / 4)
l0 = []
l1 = []
l2 = []
l3 = []
if kj == 0:
l0.append(l[0])
elif kj == 1:
l1.append(l[0])
elif kj == 2:
l2.append(l[0])
elif kj == 3:
l3.append(l[0])
for j in range(n - 1):
kj = b % 4
k.append(kj)
b = int((b - kj) / 4)
if kj == 0:
l0.append(l[j + 1])
elif kj == 1:
l1.append(l[j + 1])
elif kj == 2:
l2.append(l[j + 1])
elif kj == 3:
l3.append(l[j + 1])
mp = 0
if len(l0) >= 1:
mp = mp + (len(l0) - 1) * 10
if len(l1) >= 1:
mp = mp + (len(l1) - 1) * 10
if len(l2) >= 1:
mp = mp + (len(l2) - 1) * 10
ls = []
ls = [sum(l0), sum(l1), sum(l2)]
ls.sort()
mp = mp + abs(d[0] - ls[0]) + abs(d[1] - ls[1]) + abs(d[2] - ls[2])
if mpmin > mp and len(l0) >= 1 and len(l1) >= 1 and len(l2) >= 1:
mpmin = mp
print(mpmin)
| n, a, b, c = list(map(int, input().split()))
l = [0] * n
for i in range(n):
l[i] = int(eval(input()))
import itertools
mpmin = a + b + c + 1
for i in itertools.product([0, 1, 2, 3], repeat=n):
aa = 0
bb = 0
cc = 0
mpa = 0
mpb = 0
mpc = 0
ia = 0
ib = 0
ic = 0
for ii in range(n):
if i[ii] == 1:
ia = 1
if aa > 0:
mpa += 10
aa += l[ii]
elif i[ii] == 2:
ib = 1
if bb > 0:
mpb += 10
bb += l[ii]
elif i[ii] == 3:
ic = 1
if cc > 0:
mpc += 10
cc += l[ii]
if ia == 1 and ib == 1 and ic == 1:
mp = mpa + abs(a - aa) + mpb + abs(b - bb) + mpc + abs(c - cc)
# if mp<mpmin:
# print(mp,mpa,mpb,mpc,i)
mpmin = min(mp, mpmin)
print(mpmin)
| false | 23.636364 | [
"-l = []",
"+l = [0] * n",
"- li = int(eval(input()))",
"- l.append(li)",
"-d = [a, b, c]",
"-d.sort()",
"-mpmin = sum(l) * 4 + len(l) * 10 + sum(d)",
"-for i in range(4**n):",
"- k = []",
"- kj = i % 4",
"- k.append(kj)",
"- b = int((i - kj) / 4)",
"- l0 = []",
"- ... | false | 0.557142 | 0.367199 | 1.517274 | [
"s988717405",
"s500209429"
] |
u597455618 | p03855 | python | s931506507 | s379290698 | 790 | 714 | 44,084 | 47,836 | Accepted | Accepted | 9.62 | from collections import Counter
class UnionFind:
def __init__(self, n):
self.table = [-1] * n
def _root(self, x):
stack = []
tbl = self.table
while tbl[x] >= 0:
stack.append(x)
x = tbl[x]
for y in stack:
tbl[y] = x
return x
def find(self, x, y):
return self._root(x) == self._root(y)
def union(self, x, y):
r1 = self._root(x)
r2 = self._root(y)
if r1 == r2:
return
d1 = self.table[r1]
d2 = self.table[r2]
if d1 <= d2:
self.table[r2] = r1
self.table[r1] += d2
else:
self.table[r1] = r2
self.table[r2] += d1
def main():
n, k, l = list(map(int, input().split()))
a = UnionFind(n)
b = UnionFind(n)
for _ in range(k):
p, q = list(map(int, input().split()))
a.union(p-1, q-1)
for _ in range(l):
r, s = list(map(int, input().split()))
b.union(r-1, s-1)
d = Counter((a._root(i), b._root(i)) for i in range(n))
print((*(d[(a._root(i), b._root(i))] for i in range(n))))
if __name__ == '__main__':
main()
| from collections import Counter
from typing import AnyStr
class UnionFind:
def __init__(self, n):
self.table = [-1] * n
def _root(self, x):
stack = []
tbl = self.table
while tbl[x] >= 0:
stack.append(x)
x = tbl[x]
for y in stack:
tbl[y] = x
return x
def find(self, x, y):
return self._root(x) == self._root(y)
def union(self, x, y):
r1 = self._root(x)
r2 = self._root(y)
if r1 == r2:
return
d1 = self.table[r1]
d2 = self.table[r2]
if d1 <= d2:
self.table[r2] = r1
self.table[r1] += d2
else:
self.table[r1] = r2
self.table[r2] += d1
def main():
n, k, l = list(map(int, input().split()))
a = UnionFind(n)
b = UnionFind(n)
for _ in range(k):
p, q = list(map(int, input().split()))
a.union(p-1, q-1)
for _ in range(l):
r, s = list(map(int, input().split()))
b.union(r-1, s-1)
pairs = []
for i in range(n):
pairs.append((a._root(i), b._root(i)))
d = Counter(pairs)
ans = [d[x] for x in pairs]
print((*ans))
if __name__ == '__main__':
main()
| 51 | 57 | 1,221 | 1,290 | from collections import Counter
class UnionFind:
def __init__(self, n):
self.table = [-1] * n
def _root(self, x):
stack = []
tbl = self.table
while tbl[x] >= 0:
stack.append(x)
x = tbl[x]
for y in stack:
tbl[y] = x
return x
def find(self, x, y):
return self._root(x) == self._root(y)
def union(self, x, y):
r1 = self._root(x)
r2 = self._root(y)
if r1 == r2:
return
d1 = self.table[r1]
d2 = self.table[r2]
if d1 <= d2:
self.table[r2] = r1
self.table[r1] += d2
else:
self.table[r1] = r2
self.table[r2] += d1
def main():
n, k, l = list(map(int, input().split()))
a = UnionFind(n)
b = UnionFind(n)
for _ in range(k):
p, q = list(map(int, input().split()))
a.union(p - 1, q - 1)
for _ in range(l):
r, s = list(map(int, input().split()))
b.union(r - 1, s - 1)
d = Counter((a._root(i), b._root(i)) for i in range(n))
print((*(d[(a._root(i), b._root(i))] for i in range(n))))
if __name__ == "__main__":
main()
| from collections import Counter
from typing import AnyStr
class UnionFind:
def __init__(self, n):
self.table = [-1] * n
def _root(self, x):
stack = []
tbl = self.table
while tbl[x] >= 0:
stack.append(x)
x = tbl[x]
for y in stack:
tbl[y] = x
return x
def find(self, x, y):
return self._root(x) == self._root(y)
def union(self, x, y):
r1 = self._root(x)
r2 = self._root(y)
if r1 == r2:
return
d1 = self.table[r1]
d2 = self.table[r2]
if d1 <= d2:
self.table[r2] = r1
self.table[r1] += d2
else:
self.table[r1] = r2
self.table[r2] += d1
def main():
n, k, l = list(map(int, input().split()))
a = UnionFind(n)
b = UnionFind(n)
for _ in range(k):
p, q = list(map(int, input().split()))
a.union(p - 1, q - 1)
for _ in range(l):
r, s = list(map(int, input().split()))
b.union(r - 1, s - 1)
pairs = []
for i in range(n):
pairs.append((a._root(i), b._root(i)))
d = Counter(pairs)
ans = [d[x] for x in pairs]
print((*ans))
if __name__ == "__main__":
main()
| false | 10.526316 | [
"+from typing import AnyStr",
"- d = Counter((a._root(i), b._root(i)) for i in range(n))",
"- print((*(d[(a._root(i), b._root(i))] for i in range(n))))",
"+ pairs = []",
"+ for i in range(n):",
"+ pairs.append((a._root(i), b._root(i)))",
"+ d = Counter(pairs)",
"+ ans = [d[x] ... | false | 0.08247 | 0.075635 | 1.090366 | [
"s931506507",
"s379290698"
] |
u966207392 | p02712 | python | s321732105 | s234193408 | 204 | 171 | 29,964 | 29,956 | Accepted | Accepted | 16.18 | N = int(eval(input()))
A = []
for i in range(N+1):
if i % 15 == 0:
pass
elif i % 3 == 0:
pass
elif i % 5 == 0:
pass
else:
A.append(i)
print((sum(A))) | N = int(eval(input()))
A = []
for i in range(N+1):
if i % 3 == 0:
pass
elif i % 5 == 0:
pass
else:
A.append(i)
print((sum(A))) | 12 | 10 | 200 | 163 | N = int(eval(input()))
A = []
for i in range(N + 1):
if i % 15 == 0:
pass
elif i % 3 == 0:
pass
elif i % 5 == 0:
pass
else:
A.append(i)
print((sum(A)))
| N = int(eval(input()))
A = []
for i in range(N + 1):
if i % 3 == 0:
pass
elif i % 5 == 0:
pass
else:
A.append(i)
print((sum(A)))
| false | 16.666667 | [
"- if i % 15 == 0:",
"- pass",
"- elif i % 3 == 0:",
"+ if i % 3 == 0:"
] | false | 0.152979 | 0.43173 | 0.35434 | [
"s321732105",
"s234193408"
] |
u292735000 | p03478 | python | s735571495 | s477612474 | 40 | 35 | 3,060 | 3,060 | Accepted | Accepted | 12.5 | n, a, b = list(map(int, input().split()))
sum_all = 0
for i in range(1, n + 1):
m = str(i)
sum_m = 0
for j in range(len(m)):
sum_m += int(m[j])
if a <= sum_m <= b:
sum_all += i
print(sum_all) | import math
n, a, b = list(map(int, input().split()))
sum_all = 0
for i in range(1, n + 1):
sum_n = 0
m = i
while(m > 0):
sum_n += m % 10
m = int(m / 10)
if a <= sum_n <= b:
sum_all += i
print(sum_all) | 10 | 15 | 226 | 252 | n, a, b = list(map(int, input().split()))
sum_all = 0
for i in range(1, n + 1):
m = str(i)
sum_m = 0
for j in range(len(m)):
sum_m += int(m[j])
if a <= sum_m <= b:
sum_all += i
print(sum_all)
| import math
n, a, b = list(map(int, input().split()))
sum_all = 0
for i in range(1, n + 1):
sum_n = 0
m = i
while m > 0:
sum_n += m % 10
m = int(m / 10)
if a <= sum_n <= b:
sum_all += i
print(sum_all)
| false | 33.333333 | [
"+import math",
"+",
"- m = str(i)",
"- sum_m = 0",
"- for j in range(len(m)):",
"- sum_m += int(m[j])",
"- if a <= sum_m <= b:",
"+ sum_n = 0",
"+ m = i",
"+ while m > 0:",
"+ sum_n += m % 10",
"+ m = int(m / 10)",
"+ if a <= sum_n <= b:"
] | false | 0.038106 | 0.044062 | 0.864839 | [
"s735571495",
"s477612474"
] |
u114648678 | p03013 | python | s462771231 | s645777145 | 659 | 197 | 460,020 | 13,192 | Accepted | Accepted | 70.11 | n,m=list(map(int,input().split()))
a=[]
for i in range(m):
a.append(int(eval(input())))
a=set(a)
dp=[0]*(n+1)
dp[0]=1
if 1 in a:
dp[1]=0
else:
dp[1]=1
for i in range(2,n+1):
if i in a:
dp[i]=0
else:
dp[i]=dp[i-1]+dp[i-2]
print((dp[n]%1000000007))
| n,m=list(map(int,input().split()))
a=[]
for i in range(m):
a.append(int(eval(input())))
a=set(a)
dp=[0]*(n+1)
dp[0]=1
if 1 in a:
dp[1]=0
else:
dp[1]=1
for i in range(2,n+1):
if i in a:
dp[i]=0
else:
dp[i]=(dp[i-1]+dp[i-2])%1000000007
print((dp[n]%1000000007))
| 17 | 17 | 267 | 280 | n, m = list(map(int, input().split()))
a = []
for i in range(m):
a.append(int(eval(input())))
a = set(a)
dp = [0] * (n + 1)
dp[0] = 1
if 1 in a:
dp[1] = 0
else:
dp[1] = 1
for i in range(2, n + 1):
if i in a:
dp[i] = 0
else:
dp[i] = dp[i - 1] + dp[i - 2]
print((dp[n] % 1000000007))
| n, m = list(map(int, input().split()))
a = []
for i in range(m):
a.append(int(eval(input())))
a = set(a)
dp = [0] * (n + 1)
dp[0] = 1
if 1 in a:
dp[1] = 0
else:
dp[1] = 1
for i in range(2, n + 1):
if i in a:
dp[i] = 0
else:
dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007
print((dp[n] % 1000000007))
| false | 0 | [
"- dp[i] = dp[i - 1] + dp[i - 2]",
"+ dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007"
] | false | 0.047296 | 0.137673 | 0.343542 | [
"s462771231",
"s645777145"
] |
u761320129 | p03222 | python | s211048892 | s274485749 | 40 | 36 | 3,064 | 3,064 | Accepted | Accepted | 10 | H,W,K = list(map(int,input().split()))
MOD = 10**9+7
dp = [0] * W
dp[0] = 1
for i in range(H):
dp2 = [0] * W
for b in range(2**(W-1)):
if '11' in bin(b): continue
b *= 2
for j in range(W):
if b&(1<<j):
dp2[j] += dp[j-1]
elif b&(1<<(j+1)):
dp2[j] += dp[j+1]
else:
dp2[j] += dp[j]
dp2[j] %= MOD
dp = dp2
print((dp[K-1])) | H,W,K = list(map(int,input().split()))
MOD = 10**9+7
dp = [[0]*W for _ in range(H+1)]
dp[0][0] = 1
for i in range(H):
for b in range(1<<(W-1)):
if '11' in bin(b): continue
for k in range(W):
if k and b&(1<<(k-1)):
dp[i+1][k-1] += dp[i][k]
elif b&(1<<k):
dp[i+1][k+1] += dp[i][k]
else:
dp[i+1][k] += dp[i][k]
print((dp[-1][K-1] % MOD))
| 21 | 17 | 464 | 449 | H, W, K = list(map(int, input().split()))
MOD = 10**9 + 7
dp = [0] * W
dp[0] = 1
for i in range(H):
dp2 = [0] * W
for b in range(2 ** (W - 1)):
if "11" in bin(b):
continue
b *= 2
for j in range(W):
if b & (1 << j):
dp2[j] += dp[j - 1]
elif b & (1 << (j + 1)):
dp2[j] += dp[j + 1]
else:
dp2[j] += dp[j]
dp2[j] %= MOD
dp = dp2
print((dp[K - 1]))
| H, W, K = list(map(int, input().split()))
MOD = 10**9 + 7
dp = [[0] * W for _ in range(H + 1)]
dp[0][0] = 1
for i in range(H):
for b in range(1 << (W - 1)):
if "11" in bin(b):
continue
for k in range(W):
if k and b & (1 << (k - 1)):
dp[i + 1][k - 1] += dp[i][k]
elif b & (1 << k):
dp[i + 1][k + 1] += dp[i][k]
else:
dp[i + 1][k] += dp[i][k]
print((dp[-1][K - 1] % MOD))
| false | 19.047619 | [
"-dp = [0] * W",
"-dp[0] = 1",
"+dp = [[0] * W for _ in range(H + 1)]",
"+dp[0][0] = 1",
"- dp2 = [0] * W",
"- for b in range(2 ** (W - 1)):",
"+ for b in range(1 << (W - 1)):",
"- b *= 2",
"- for j in range(W):",
"- if b & (1 << j):",
"- dp2[j] +... | false | 0.046119 | 0.04672 | 0.987149 | [
"s211048892",
"s274485749"
] |
u881378225 | p03086 | python | s419226689 | s291114115 | 20 | 17 | 3,188 | 2,940 | Accepted | Accepted | 15 | s=eval(input())
acgt=["A","C","G","T"]
s=[s[i] in acgt for i in range(len(s))]
max_len=0
flag=False
for n in range(len(s),0,-1):
for i in range(len(s)-n+1):
if all(s[i:i+n]):
max_len=n
flag=True
break
if flag:
break
print(max_len) | s=eval(input())
count,max_count=0,0
for t in s:
if t in ["A","C","G","T"]:
count+=1
if max_count<count:
max_count=count
else:
count=0
print(max_count) | 14 | 10 | 267 | 197 | s = eval(input())
acgt = ["A", "C", "G", "T"]
s = [s[i] in acgt for i in range(len(s))]
max_len = 0
flag = False
for n in range(len(s), 0, -1):
for i in range(len(s) - n + 1):
if all(s[i : i + n]):
max_len = n
flag = True
break
if flag:
break
print(max_len)
| s = eval(input())
count, max_count = 0, 0
for t in s:
if t in ["A", "C", "G", "T"]:
count += 1
if max_count < count:
max_count = count
else:
count = 0
print(max_count)
| false | 28.571429 | [
"-acgt = [\"A\", \"C\", \"G\", \"T\"]",
"-s = [s[i] in acgt for i in range(len(s))]",
"-max_len = 0",
"-flag = False",
"-for n in range(len(s), 0, -1):",
"- for i in range(len(s) - n + 1):",
"- if all(s[i : i + n]):",
"- max_len = n",
"- flag = True",
"- ... | false | 0.038905 | 0.039738 | 0.979031 | [
"s419226689",
"s291114115"
] |
u057109575 | p02757 | python | s369867288 | s411863262 | 203 | 145 | 41,180 | 74,824 | Accepted | Accepted | 28.57 | N, P = list(map(int, input().split()))
S = eval(input())
res = 0
if P == 2 or P == 5:
# Corner case
for i in range(N):
if int(S[N - i - 1]) % P == 0:
res += N - i
else:
val = [0] * P
tenfactor = 1
cur = 0
val[cur] += 1
for i in range(N):
cur = (cur + int(S[N - i - 1]) * tenfactor) % P
tenfactor = (tenfactor * 10) % P
val[cur] += 1
# Combination
for p in range(P):
res += val[p] * (val[p] - 1) // 2
print(res)
|
from collections import defaultdict
N, P = list(map(int, input().split()))
S = eval(input())
if P == 2 or P == 5:
ans = 0
for i in range(N):
if int(S[i]) % P == 0:
ans += i + 1
print(ans)
else:
ctr = defaultdict(int)
ctr[0] = 1
cur = 0
for i in reversed(list(range(N))):
cur = (cur + int(S[i]) * pow(10, N - i - 1, P)) % P
ctr[cur] += 1
ans = 0
for v in list(ctr.values()):
ans += v * (v - 1) // 2
print(ans)
| 26 | 24 | 529 | 496 | N, P = list(map(int, input().split()))
S = eval(input())
res = 0
if P == 2 or P == 5:
# Corner case
for i in range(N):
if int(S[N - i - 1]) % P == 0:
res += N - i
else:
val = [0] * P
tenfactor = 1
cur = 0
val[cur] += 1
for i in range(N):
cur = (cur + int(S[N - i - 1]) * tenfactor) % P
tenfactor = (tenfactor * 10) % P
val[cur] += 1
# Combination
for p in range(P):
res += val[p] * (val[p] - 1) // 2
print(res)
| from collections import defaultdict
N, P = list(map(int, input().split()))
S = eval(input())
if P == 2 or P == 5:
ans = 0
for i in range(N):
if int(S[i]) % P == 0:
ans += i + 1
print(ans)
else:
ctr = defaultdict(int)
ctr[0] = 1
cur = 0
for i in reversed(list(range(N))):
cur = (cur + int(S[i]) * pow(10, N - i - 1, P)) % P
ctr[cur] += 1
ans = 0
for v in list(ctr.values()):
ans += v * (v - 1) // 2
print(ans)
| false | 7.692308 | [
"+from collections import defaultdict",
"+",
"-res = 0",
"- # Corner case",
"+ ans = 0",
"- if int(S[N - i - 1]) % P == 0:",
"- res += N - i",
"+ if int(S[i]) % P == 0:",
"+ ans += i + 1",
"+ print(ans)",
"- val = [0] * P",
"- tenfactor = 1",
... | false | 0.086964 | 0.081653 | 1.065045 | [
"s369867288",
"s411863262"
] |
u155687575 | p02888 | python | s943948056 | s421461711 | 1,372 | 916 | 3,188 | 3,316 | Accepted | Accepted | 33.24 | ### a<=b<=cととることとし、a,bを固定すると
### cは c<a+b
from bisect import bisect_left
N = int(eval(input()))
lst = list(map(int, input().split()))
sor = sorted(lst)
res = 0
for i in range(N):
for j in range(i+1, N):##ここでa<=bを満たしている
ab = sor[i] + sor[j]
highbound = bisect_left(sor, ab)
res += highbound - j - 1
print(res)
### ライブラリを使おう!!! | ### a<=b<=cととることとし、a,bを固定すると
### cは c<a+b
from bisect import bisect_left
def main():
N = int(eval(input()))
lst = list(map(int, input().split()))
sor = sorted(lst)
res = 0
for i in range(N):
for j in range(i+1, N):##ここでa<=bを満たしている
ab = sor[i] + sor[j]
highbound = bisect_left(sor, ab)
res += highbound - j - 1
print(res)
main()
### ライブラリを使おう!!! | 14 | 16 | 360 | 421 | ### a<=b<=cととることとし、a,bを固定すると
### cは c<a+b
from bisect import bisect_left
N = int(eval(input()))
lst = list(map(int, input().split()))
sor = sorted(lst)
res = 0
for i in range(N):
for j in range(i + 1, N): ##ここでa<=bを満たしている
ab = sor[i] + sor[j]
highbound = bisect_left(sor, ab)
res += highbound - j - 1
print(res)
### ライブラリを使おう!!!
| ### a<=b<=cととることとし、a,bを固定すると
### cは c<a+b
from bisect import bisect_left
def main():
N = int(eval(input()))
lst = list(map(int, input().split()))
sor = sorted(lst)
res = 0
for i in range(N):
for j in range(i + 1, N): ##ここでa<=bを満たしている
ab = sor[i] + sor[j]
highbound = bisect_left(sor, ab)
res += highbound - j - 1
print(res)
main()
### ライブラリを使おう!!!
| false | 12.5 | [
"-N = int(eval(input()))",
"-lst = list(map(int, input().split()))",
"-sor = sorted(lst)",
"-res = 0",
"-for i in range(N):",
"- for j in range(i + 1, N): ##ここでa<=bを満たしている",
"- ab = sor[i] + sor[j]",
"- highbound = bisect_left(sor, ab)",
"- res += highbound - j - 1",
"-pri... | false | 0.047064 | 0.049376 | 0.953173 | [
"s943948056",
"s421461711"
] |
u855199458 | p02243 | python | s029372474 | s629356848 | 500 | 340 | 69,716 | 40,248 | Accepted | Accepted | 32 | # -*- coding: utf-8 -*-
from heapq import heappush, heappop
N = int(eval(input()))
INF = float("inf")
adj = []
for _ in range(N):
inp = tuple(map(int, input().split()))
adj.append(tuple(zip(inp[2::2], inp[3::2])))
checked = [False for _ in range(N)]
d = [float("inf") for _ in range(N)]
d[0] = 0
heap = [[0, 0]] # cost, vec
while heap:
c, u = heappop(heap)
if d[u] < c or checked[u]:
continue
for nu, nc in adj[u]:
new_d = d[u] + nc
if new_d < d[nu]:
d[nu] = new_d
heappush(heap, [d[nu], nu])
checked[u] = True
for n in range(N):
print(("{} {}".format(n, d[n]))) | # -*- coding: utf-8 -*-
from heapq import heappop, heappush
def inpl(): return list(map(int, input().split()))
INF = float("inf")
N = int(eval(input()))
G = []
for _ in range(N):
I = inpl()
G.append(list(zip(*[I[3::2], I[2::2]])))
def dijkstra(G):
C = [INF]*(N)
C[0] = 0
visited = [False] * (N)
Q = [[0, 0]]
while Q:
c, u = heappop(Q)
if C[u] < c:
continue
visited[u] = True
for d, v in G[u]:
if visited[v]:
continue
e = c + d
if e < C[v]:
C[v] = e
heappush(Q, [e, v])
return C
for i, c in enumerate(dijkstra(G)):
print((i, c))
| 29 | 32 | 663 | 712 | # -*- coding: utf-8 -*-
from heapq import heappush, heappop
N = int(eval(input()))
INF = float("inf")
adj = []
for _ in range(N):
inp = tuple(map(int, input().split()))
adj.append(tuple(zip(inp[2::2], inp[3::2])))
checked = [False for _ in range(N)]
d = [float("inf") for _ in range(N)]
d[0] = 0
heap = [[0, 0]] # cost, vec
while heap:
c, u = heappop(heap)
if d[u] < c or checked[u]:
continue
for nu, nc in adj[u]:
new_d = d[u] + nc
if new_d < d[nu]:
d[nu] = new_d
heappush(heap, [d[nu], nu])
checked[u] = True
for n in range(N):
print(("{} {}".format(n, d[n])))
| # -*- coding: utf-8 -*-
from heapq import heappop, heappush
def inpl():
return list(map(int, input().split()))
INF = float("inf")
N = int(eval(input()))
G = []
for _ in range(N):
I = inpl()
G.append(list(zip(*[I[3::2], I[2::2]])))
def dijkstra(G):
C = [INF] * (N)
C[0] = 0
visited = [False] * (N)
Q = [[0, 0]]
while Q:
c, u = heappop(Q)
if C[u] < c:
continue
visited[u] = True
for d, v in G[u]:
if visited[v]:
continue
e = c + d
if e < C[v]:
C[v] = e
heappush(Q, [e, v])
return C
for i, c in enumerate(dijkstra(G)):
print((i, c))
| false | 9.375 | [
"-from heapq import heappush, heappop",
"+from heapq import heappop, heappush",
"+",
"+def inpl():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+INF = float(\"inf\")",
"-INF = float(\"inf\")",
"-adj = []",
"+G = []",
"- inp = tuple(map(int, input().split()))",
"- adj.app... | false | 0.035885 | 0.040448 | 0.887188 | [
"s029372474",
"s629356848"
] |
u609061751 | p02657 | python | s056877835 | s647892911 | 61 | 55 | 61,580 | 61,580 | Accepted | Accepted | 9.84 | import sys
input = sys.stdin.readline
a, b = [int(x) for x in input().split()]
print((a*b)) | import sys
input = lambda: sys.stdin.readline().rstrip()
a, b = list(map(int, input().split()))
print((a*b))
| 5 | 7 | 94 | 110 | import sys
input = sys.stdin.readline
a, b = [int(x) for x in input().split()]
print((a * b))
| import sys
input = lambda: sys.stdin.readline().rstrip()
a, b = list(map(int, input().split()))
print((a * b))
| false | 28.571429 | [
"-input = sys.stdin.readline",
"-a, b = [int(x) for x in input().split()]",
"+input = lambda: sys.stdin.readline().rstrip()",
"+a, b = list(map(int, input().split()))"
] | false | 0.057935 | 0.092457 | 0.626611 | [
"s056877835",
"s647892911"
] |
u790922244 | p03017 | python | s022321977 | s588769291 | 89 | 70 | 3,572 | 3,572 | Accepted | Accepted | 21.35 | N,A,B,C,D=list(map(int, input().split()))
S=eval(input())
result = ""
for i in range(A,max(C,D)-1):
if S[i:i+2]=="##":
result ="No"
break
if result == "":
if C < D:
result ="Yes"
else: # D < C
if S[B-2] == "." and S[B] == ".":
result = "Yes"
else:
for i in range(B-2,D-1):
if S[i:i+3] == "...":
result = "Yes"
#if S[B-2:D+1].count('...')>0:
# result = 'Yes'
if result == "":
result = "No"
print(result)
| N,A,B,C,D=list(map(int, input().split()))
S=eval(input())
result = ""
for i in range(A,max(C,D)):
if S[i:i+2]=="##":
result = "No"
break
if result == "":
if C < D:
result ="Yes"
else: # D < C
if S[B-2] == "." and S[B] == ".":
result = "Yes"
else:
for i in range(B-2,D-2):
if S[i:i+4] == "#...":
result = "Yes"
if result == "":
result = "No"
print(result)
| 26 | 24 | 569 | 486 | N, A, B, C, D = list(map(int, input().split()))
S = eval(input())
result = ""
for i in range(A, max(C, D) - 1):
if S[i : i + 2] == "##":
result = "No"
break
if result == "":
if C < D:
result = "Yes"
else: # D < C
if S[B - 2] == "." and S[B] == ".":
result = "Yes"
else:
for i in range(B - 2, D - 1):
if S[i : i + 3] == "...":
result = "Yes"
# if S[B-2:D+1].count('...')>0:
# result = 'Yes'
if result == "":
result = "No"
print(result)
| N, A, B, C, D = list(map(int, input().split()))
S = eval(input())
result = ""
for i in range(A, max(C, D)):
if S[i : i + 2] == "##":
result = "No"
break
if result == "":
if C < D:
result = "Yes"
else: # D < C
if S[B - 2] == "." and S[B] == ".":
result = "Yes"
else:
for i in range(B - 2, D - 2):
if S[i : i + 4] == "#...":
result = "Yes"
if result == "":
result = "No"
print(result)
| false | 7.692308 | [
"-for i in range(A, max(C, D) - 1):",
"+for i in range(A, max(C, D)):",
"- for i in range(B - 2, D - 1):",
"- if S[i : i + 3] == \"...\":",
"+ for i in range(B - 2, D - 2):",
"+ if S[i : i + 4] == \"#...\":",
"- # if S[B-2:D+1].count('...')>... | false | 0.03527 | 0.041521 | 0.849444 | [
"s022321977",
"s588769291"
] |
u029000441 | p03103 | python | s825264595 | s585410306 | 314 | 279 | 88,512 | 27,680 | Accepted | Accepted | 11.15 | #float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))
def LI2(): return [int(eval(input())) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print(('\n'.join(x)))
def printni(x): print(('\n'.join(list(map(str,x)))))
inf = 10**17
mod = 10**9 + 7
n,m=MI()
lis=[LI() for i in range(n)]
lis.sort()
#print(lis)
price=0
i=0
while m>0:
price+=lis[i][0]*min(m,lis[i][1])
m-=min(m,lis[i][1])
#print(price)
i+=1
print(price)
| #float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))
def LI2(): return [int(eval(input())) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print(('\n'.join(x)))
def printni(x): print(('\n'.join(list(map(str,x)))))
inf = 10**17
mod = 10**9 + 7
n,m=MI()
lis=[LI() for i in range(n)]
lis.sort()
pay=0
i=0
while m>0:
pay+=lis[i][0]*min(m,lis[i][1])
m-=min(m,lis[i][1])
i+=1
print(pay)
| 60 | 39 | 1,143 | 992 | # float型を許すな
# numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left, bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil, pi, factorial
from operator import itemgetter
def I():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def LI():
return list(map(int, input().split()))
def LI2():
return [int(eval(input())) for i in range(n)]
def MXI():
return [[LI()] for i in range(n)]
def SI():
return input().rstrip()
def printns(x):
print(("\n".join(x)))
def printni(x):
print(("\n".join(list(map(str, x)))))
inf = 10**17
mod = 10**9 + 7
n, m = MI()
lis = [LI() for i in range(n)]
lis.sort()
# print(lis)
price = 0
i = 0
while m > 0:
price += lis[i][0] * min(m, lis[i][1])
m -= min(m, lis[i][1])
# print(price)
i += 1
print(price)
| # float型を許すな
# numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left, bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil, pi, factorial
from operator import itemgetter
def I():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def LI():
return list(map(int, input().split()))
def LI2():
return [int(eval(input())) for i in range(n)]
def MXI():
return [[LI()] for i in range(n)]
def SI():
return input().rstrip()
def printns(x):
print(("\n".join(x)))
def printni(x):
print(("\n".join(list(map(str, x)))))
inf = 10**17
mod = 10**9 + 7
n, m = MI()
lis = [LI() for i in range(n)]
lis.sort()
pay = 0
i = 0
while m > 0:
pay += lis[i][0] * min(m, lis[i][1])
m -= min(m, lis[i][1])
i += 1
print(pay)
| false | 35 | [
"-# print(lis)",
"-price = 0",
"+pay = 0",
"- price += lis[i][0] * min(m, lis[i][1])",
"+ pay += lis[i][0] * min(m, lis[i][1])",
"- # print(price)",
"-print(price)",
"+print(pay)"
] | false | 0.03873 | 0.036139 | 1.071677 | [
"s825264595",
"s585410306"
] |
u140480594 | p02847 | python | s479667983 | s576013165 | 20 | 17 | 2,940 | 2,940 | Accepted | Accepted | 15 | S = str(eval(input()))
week = ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"]
if S == "SUN" :
print((7))
else :
print((7 - week.index(S) - 1)) | S = str(eval(input()))
week = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
print((7 - week.index(S))) | 6 | 3 | 141 | 100 | S = str(eval(input()))
week = ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"]
if S == "SUN":
print((7))
else:
print((7 - week.index(S) - 1))
| S = str(eval(input()))
week = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
print((7 - week.index(S)))
| false | 50 | [
"-week = [\"MON\", \"TUE\", \"WED\", \"THU\", \"FRI\", \"SAT\", \"SUN\"]",
"-if S == \"SUN\":",
"- print((7))",
"-else:",
"- print((7 - week.index(S) - 1))",
"+week = [\"SUN\", \"MON\", \"TUE\", \"WED\", \"THU\", \"FRI\", \"SAT\"]",
"+print((7 - week.index(S)))"
] | false | 0.051095 | 0.085625 | 0.596735 | [
"s479667983",
"s576013165"
] |
u863442865 | p02694 | python | s402675133 | s342846340 | 152 | 24 | 68,044 | 9,408 | Accepted | Accepted | 84.21 | #MLE注意!0や1のケースに注意
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
import math
from math import gcd
#inf = 10**17
#mod = 10**9 + 7
x = int(eval(input()))
n = 100
res = 0
while n < x:
res += 1
n = int(n*1.01)
print(res)
if __name__ == '__main__':
main() | #MLE注意!0や1のケースに注意
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
import math
from math import gcd
#inf = 10**17
#mod = 10**9 + 7
x = int(eval(input()))
n = 100
res = 0
while n < x:
res += 1
n = n*101//100
print(res)
if __name__ == '__main__':
main()
| 27 | 27 | 638 | 638 | # MLE注意!0や1のケースに注意
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
# from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left, bisect_right
from heapq import heapify, heappop, heappush
import math
from math import gcd
# inf = 10**17
# mod = 10**9 + 7
x = int(eval(input()))
n = 100
res = 0
while n < x:
res += 1
n = int(n * 1.01)
print(res)
if __name__ == "__main__":
main()
| # MLE注意!0や1のケースに注意
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
# from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left, bisect_right
from heapq import heapify, heappop, heappush
import math
from math import gcd
# inf = 10**17
# mod = 10**9 + 7
x = int(eval(input()))
n = 100
res = 0
while n < x:
res += 1
n = n * 101 // 100
print(res)
if __name__ == "__main__":
main()
| false | 0 | [
"- n = int(n * 1.01)",
"+ n = n * 101 // 100"
] | false | 0.041024 | 0.035554 | 1.153856 | [
"s402675133",
"s342846340"
] |
u296518383 | p03141 | python | s277923756 | s980680376 | 641 | 383 | 74,456 | 33,040 | Accepted | Accepted | 40.25 | N = int(eval(input()))
AB = [list(map(int, input().split())) for _ in range(N)]
A = []
C = []
for a, b in AB:
A.append(a)
C.append(a + b)
#print("C:", C)
C.sort()
C = C[::-1]
print((sum(A) - sum(C[1::2]))) | N = int(eval(input()))
AB = [list(map(int, input().split())) for _ in range(N)]
A = [a for a, b in AB]
C = [a + b for a, b in AB]
C.sort()
C = C[::-1]
print((sum(A) - sum(C[1::2]))) | 14 | 8 | 217 | 181 | N = int(eval(input()))
AB = [list(map(int, input().split())) for _ in range(N)]
A = []
C = []
for a, b in AB:
A.append(a)
C.append(a + b)
# print("C:", C)
C.sort()
C = C[::-1]
print((sum(A) - sum(C[1::2])))
| N = int(eval(input()))
AB = [list(map(int, input().split())) for _ in range(N)]
A = [a for a, b in AB]
C = [a + b for a, b in AB]
C.sort()
C = C[::-1]
print((sum(A) - sum(C[1::2])))
| false | 42.857143 | [
"-A = []",
"-C = []",
"-for a, b in AB:",
"- A.append(a)",
"- C.append(a + b)",
"-# print(\"C:\", C)",
"+A = [a for a, b in AB]",
"+C = [a + b for a, b in AB]"
] | false | 0.065723 | 0.039472 | 1.665034 | [
"s277923756",
"s980680376"
] |
u970308980 | p03212 | python | s008407719 | s285809091 | 264 | 243 | 49,624 | 6,348 | Accepted | Accepted | 7.95 | # 753数の列挙
# DFS
def make_753number(n):
s = str(n)
if '7' in s and '5' in s and '3' in s:
n753.add(n)
if n <= 10**9:
make_753number(10 * n + 7)
make_753number(10 * n + 5)
make_753number(10 * n + 3)
n753 = set()
make_753number(0)
N = int(eval(input()))
print((len([1 for n in n753 if n <= N])))
| N = int(input())
N753 = set()
def dfs(depth, s):
if depth == 9:
n = int(s)
if '0' not in str(n) \
and '3' in str(n) \
and '5' in str(n) \
and '7' in str(n):
N753.add(n)
return
dfs(depth+1, s+'0')
dfs(depth+1, s+'3')
dfs(depth+1, s+'5')
dfs(depth+1, s+'7')
dfs(0, '')
ans = len([n for n in N753 if n <= N])
print(ans)
| 16 | 23 | 346 | 436 | # 753数の列挙
# DFS
def make_753number(n):
s = str(n)
if "7" in s and "5" in s and "3" in s:
n753.add(n)
if n <= 10**9:
make_753number(10 * n + 7)
make_753number(10 * n + 5)
make_753number(10 * n + 3)
n753 = set()
make_753number(0)
N = int(eval(input()))
print((len([1 for n in n753 if n <= N])))
| N = int(input())
N753 = set()
def dfs(depth, s):
if depth == 9:
n = int(s)
if "0" not in str(n) and "3" in str(n) and "5" in str(n) and "7" in str(n):
N753.add(n)
return
dfs(depth + 1, s + "0")
dfs(depth + 1, s + "3")
dfs(depth + 1, s + "5")
dfs(depth + 1, s + "7")
dfs(0, "")
ans = len([n for n in N753 if n <= N])
print(ans)
| false | 30.434783 | [
"-# 753数の列挙",
"-# DFS",
"-def make_753number(n):",
"- s = str(n)",
"- if \"7\" in s and \"5\" in s and \"3\" in s:",
"- n753.add(n)",
"- if n <= 10**9:",
"- make_753number(10 * n + 7)",
"- make_753number(10 * n + 5)",
"- make_753number(10 * n + 3)",
"+N = int... | false | 0.175344 | 0.045398 | 3.862407 | [
"s008407719",
"s285809091"
] |
u573754721 | p03043 | python | s321513989 | s037917672 | 48 | 43 | 2,940 | 2,940 | Accepted | Accepted | 10.42 | n,m=list(map(int,input().split()))
ans=0
for i in range(1,n+1):
c=0
j=i
while j<m:
j=j*2
c+=1
ans+=(1/n)*(1/2)**c
print(ans)
| n,k=list(map(int,input().split()))
s=0
for i in range(1,n+1):
c=0
while k>i:
i=i*2
c+=1
s+=(1/n)*((1/2)**c)
print(s)
| 12 | 10 | 168 | 163 | n, m = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
c = 0
j = i
while j < m:
j = j * 2
c += 1
ans += (1 / n) * (1 / 2) ** c
print(ans)
| n, k = list(map(int, input().split()))
s = 0
for i in range(1, n + 1):
c = 0
while k > i:
i = i * 2
c += 1
s += (1 / n) * ((1 / 2) ** c)
print(s)
| false | 16.666667 | [
"-n, m = list(map(int, input().split()))",
"-ans = 0",
"+n, k = list(map(int, input().split()))",
"+s = 0",
"- j = i",
"- while j < m:",
"- j = j * 2",
"+ while k > i:",
"+ i = i * 2",
"- ans += (1 / n) * (1 / 2) ** c",
"-print(ans)",
"+ s += (1 / n) * ((1 / 2) ** ... | false | 0.11618 | 0.113359 | 1.024885 | [
"s321513989",
"s037917672"
] |
u315485238 | p04000 | python | s047388290 | s748327080 | 2,997 | 1,808 | 174,556 | 191,248 | Accepted | Accepted | 39.67 | H, W, N = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N)]
from itertools import product
S = [set() for _ in range(10)]
# S[i]: set(黒いマスをi個こ含む3*3マスの中心セル)
for a,b in AB:
for x,y in product([-1,0,1], repeat=2):
X = a+x-1
Y = b+y-1
if X<=0 or H-1<=X or Y<=0 or W-1<=Y:
continue
for i in range(10):
if (X, Y) in S[i]:
S[i].remove((X, Y))
S[i+1].add((X, Y))
break
else:
S[1].add((X, Y))
L = [len(s) for s in S[1:]]
print(((H-2)*(W-2) - sum(L)))
for l in L:
print(l) | H, W, N = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N)]
from itertools import product
S = [set() for _ in range(10)]
# S[i]: set(黒いマスをi個こ含む3*3マスの中心セル)
memo = {}
for a,b in AB:
for x,y in product([-1,0,1], repeat=2):
X = a+x-1
Y = b+y-1
if X<=0 or H-1<=X or Y<=0 or W-1<=Y:
continue
memo[(X,Y)] = memo.get((X,Y),0) + 1
#print(memo)
from collections import Counter
c = Counter(list(memo.values()))
L = [c.get(i,0) for i in range(1,10)]
print(((H-2)*(W-2) - sum(L)))
for l in L:
print(l) | 27 | 27 | 595 | 578 | H, W, N = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N)]
from itertools import product
S = [set() for _ in range(10)]
# S[i]: set(黒いマスをi個こ含む3*3マスの中心セル)
for a, b in AB:
for x, y in product([-1, 0, 1], repeat=2):
X = a + x - 1
Y = b + y - 1
if X <= 0 or H - 1 <= X or Y <= 0 or W - 1 <= Y:
continue
for i in range(10):
if (X, Y) in S[i]:
S[i].remove((X, Y))
S[i + 1].add((X, Y))
break
else:
S[1].add((X, Y))
L = [len(s) for s in S[1:]]
print(((H - 2) * (W - 2) - sum(L)))
for l in L:
print(l)
| H, W, N = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N)]
from itertools import product
S = [set() for _ in range(10)]
# S[i]: set(黒いマスをi個こ含む3*3マスの中心セル)
memo = {}
for a, b in AB:
for x, y in product([-1, 0, 1], repeat=2):
X = a + x - 1
Y = b + y - 1
if X <= 0 or H - 1 <= X or Y <= 0 or W - 1 <= Y:
continue
memo[(X, Y)] = memo.get((X, Y), 0) + 1
# print(memo)
from collections import Counter
c = Counter(list(memo.values()))
L = [c.get(i, 0) for i in range(1, 10)]
print(((H - 2) * (W - 2) - sum(L)))
for l in L:
print(l)
| false | 0 | [
"+memo = {}",
"- for i in range(10):",
"- if (X, Y) in S[i]:",
"- S[i].remove((X, Y))",
"- S[i + 1].add((X, Y))",
"- break",
"- else:",
"- S[1].add((X, Y))",
"-L = [len(s) for s in S[1:]]",
"+ memo[(X, Y)] = me... | false | 0.039818 | 0.040753 | 0.97704 | [
"s047388290",
"s748327080"
] |
u790012205 | p03611 | python | s409052426 | s207746367 | 173 | 81 | 30,172 | 20,788 | Accepted | Accepted | 53.18 | import collections
N = int(eval(input()))
a = (list(map(int, input().split())))
for i in range(N):
a.append(a[i] - 1)
a.append(a[i] + 1)
c = collections.Counter(a)
print((c.most_common()[0][1]))
| N = int(eval(input()))
a = list(map(int, input().split()))
A = [0] * (10 ** 5 + 5)
for ai in a:
A[ai - 1] += 1
A[ai] += 1
A[ai + 1] += 1
print((max(A))) | 8 | 8 | 202 | 163 | import collections
N = int(eval(input()))
a = list(map(int, input().split()))
for i in range(N):
a.append(a[i] - 1)
a.append(a[i] + 1)
c = collections.Counter(a)
print((c.most_common()[0][1]))
| N = int(eval(input()))
a = list(map(int, input().split()))
A = [0] * (10**5 + 5)
for ai in a:
A[ai - 1] += 1
A[ai] += 1
A[ai + 1] += 1
print((max(A)))
| false | 0 | [
"-import collections",
"-",
"-for i in range(N):",
"- a.append(a[i] - 1)",
"- a.append(a[i] + 1)",
"-c = collections.Counter(a)",
"-print((c.most_common()[0][1]))",
"+A = [0] * (10**5 + 5)",
"+for ai in a:",
"+ A[ai - 1] += 1",
"+ A[ai] += 1",
"+ A[ai + 1] += 1",
"+print((max(... | false | 0.056681 | 0.046719 | 1.213236 | [
"s409052426",
"s207746367"
] |
u600195339 | p03044 | python | s612626023 | s055163307 | 1,372 | 1,247 | 101,120 | 96,116 | Accepted | Accepted | 9.11 | import sys
sys.setrecursionlimit(10**5)
class Node:
# def __init__(self, val):
def __init__(self):
self.val = None
self.color = None
self.a = []
n = int(eval(input()))
nodes = []
for i in range(n):
nodes.append(Node())
# nodes.append(Node(i+1))
for i in range(n-1):
u, v, w = list(map(int, input().split()))
node1 = nodes[u-1]
node2 = nodes[v-1]
node1.val = u
node2.val = v
node1.a.append([node2, w])
node2.a.append([node1, w])
# for i in range(n):
# node = nodes[i]
# for pair in node.a:
# print(pair[0])
# print(pair[1])
root = nodes[0]
root.color = True
nodeSet = set()
def traverse(node, distance):
if node in nodeSet:
return
else:
nodeSet.add(node)
# print('# traverse: ' + str(node.val))
for pair in node.a:
adjNode = pair[0]
dis = pair[1]
if (distance + dis) % 2 == 0:
adjNode.color = root.color
else:
adjNode.color = not root.color
traverse(adjNode, distance + dis)
traverse(root, 0)
for i in range(n):
node = nodes[i]
if node.color:
print((1))
else:
print((0))
| import sys
sys.setrecursionlimit(10**5)
class Node:
def __init__(self):
self.val = None
self.a = []
n = int(eval(input()))
nodes = []
for i in range(n):
nodes.append(Node())
for i in range(n-1):
u, v, w = list(map(int, input().split()))
node1 = nodes[u-1]
node2 = nodes[v-1]
node1.a.append([node2, w])
node2.a.append([node1, w])
root = nodes[0]
root.val = True
nodeSet = set()
def traverse(node):
if node in nodeSet:
return
else:
nodeSet.add(node)
for pair in node.a:
adjNode = pair[0]
dis = pair[1]
if dis % 2 == 0:
adjNode.val = node.val
else:
adjNode.val = not node.val
traverse(adjNode)
traverse(root)
for i in range(n):
node = nodes[i]
if node.val:
print((1))
else:
print((0))
| 59 | 50 | 1,237 | 890 | import sys
sys.setrecursionlimit(10**5)
class Node:
# def __init__(self, val):
def __init__(self):
self.val = None
self.color = None
self.a = []
n = int(eval(input()))
nodes = []
for i in range(n):
nodes.append(Node())
# nodes.append(Node(i+1))
for i in range(n - 1):
u, v, w = list(map(int, input().split()))
node1 = nodes[u - 1]
node2 = nodes[v - 1]
node1.val = u
node2.val = v
node1.a.append([node2, w])
node2.a.append([node1, w])
# for i in range(n):
# node = nodes[i]
# for pair in node.a:
# print(pair[0])
# print(pair[1])
root = nodes[0]
root.color = True
nodeSet = set()
def traverse(node, distance):
if node in nodeSet:
return
else:
nodeSet.add(node)
# print('# traverse: ' + str(node.val))
for pair in node.a:
adjNode = pair[0]
dis = pair[1]
if (distance + dis) % 2 == 0:
adjNode.color = root.color
else:
adjNode.color = not root.color
traverse(adjNode, distance + dis)
traverse(root, 0)
for i in range(n):
node = nodes[i]
if node.color:
print((1))
else:
print((0))
| import sys
sys.setrecursionlimit(10**5)
class Node:
def __init__(self):
self.val = None
self.a = []
n = int(eval(input()))
nodes = []
for i in range(n):
nodes.append(Node())
for i in range(n - 1):
u, v, w = list(map(int, input().split()))
node1 = nodes[u - 1]
node2 = nodes[v - 1]
node1.a.append([node2, w])
node2.a.append([node1, w])
root = nodes[0]
root.val = True
nodeSet = set()
def traverse(node):
if node in nodeSet:
return
else:
nodeSet.add(node)
for pair in node.a:
adjNode = pair[0]
dis = pair[1]
if dis % 2 == 0:
adjNode.val = node.val
else:
adjNode.val = not node.val
traverse(adjNode)
traverse(root)
for i in range(n):
node = nodes[i]
if node.val:
print((1))
else:
print((0))
| false | 15.254237 | [
"- # def __init__(self, val):",
"- self.color = None",
"- # nodes.append(Node(i+1))",
"- node1.val = u",
"- node2.val = v",
"-# for i in range(n):",
"-# node = nodes[i]",
"-# for pair in node.a:",
"-# print(pair[0])",
"-# print(pair[1])",
"-root.color =... | false | 0.037728 | 0.044412 | 0.849488 | [
"s612626023",
"s055163307"
] |
u680851063 | p02642 | python | s872870078 | s223081553 | 545 | 476 | 42,368 | 32,064 | Accepted | Accepted | 12.66 | n = int(eval(input()))
l = list(map(int,input().split()))
num = max(l)+1
rcd = [0 for _ in range(num)] # indexを数列Aと読み替え可能な配列として初期化
for v in l: # 重複する配列を区別するため各要素数をカウントして...
rcd[v] += 1
unq = []
for w in range(num): # 1個の場合は重複がない要素として'unq'に集約
if rcd[w] == 1:
unq.append(w)
#print(unq)
rcd = [0 for _ in range(num)] # 再度初期化
#l = set(l)
for x in l: # 自身以外の約数の有無を確認 ※ここでは重複を考慮しない
for y in range(2*x, num, x): # ※自身を約数としてカウントしない工夫!
rcd[y] = 1 # 自身以外の約数がある場合は'1'が代入される
#print(rcd)
ans = 0
for z in unq: # 'unq'の中で...
if rcd[z] == 0: # 自身以外に約数を持たない要素のみを...
ans += 1 # カウント
print(ans)
| n = int(eval(input()))
l = list(map(int,input().split()))
num = max(l)+1
rcd = [0 for _ in range(num)]
for x in l:
for y in range(x, num, x):
rcd[y] += 1
ans = 0
for k in l:
if rcd[k] == 1:
ans += 1
print(ans)
| 27 | 16 | 642 | 251 | n = int(eval(input()))
l = list(map(int, input().split()))
num = max(l) + 1
rcd = [0 for _ in range(num)] # indexを数列Aと読み替え可能な配列として初期化
for v in l: # 重複する配列を区別するため各要素数をカウントして...
rcd[v] += 1
unq = []
for w in range(num): # 1個の場合は重複がない要素として'unq'に集約
if rcd[w] == 1:
unq.append(w)
# print(unq)
rcd = [0 for _ in range(num)] # 再度初期化
# l = set(l)
for x in l: # 自身以外の約数の有無を確認 ※ここでは重複を考慮しない
for y in range(2 * x, num, x): # ※自身を約数としてカウントしない工夫!
rcd[y] = 1 # 自身以外の約数がある場合は'1'が代入される
# print(rcd)
ans = 0
for z in unq: # 'unq'の中で...
if rcd[z] == 0: # 自身以外に約数を持たない要素のみを...
ans += 1 # カウント
print(ans)
| n = int(eval(input()))
l = list(map(int, input().split()))
num = max(l) + 1
rcd = [0 for _ in range(num)]
for x in l:
for y in range(x, num, x):
rcd[y] += 1
ans = 0
for k in l:
if rcd[k] == 1:
ans += 1
print(ans)
| false | 40.740741 | [
"-rcd = [0 for _ in range(num)] # indexを数列Aと読み替え可能な配列として初期化",
"-for v in l: # 重複する配列を区別するため各要素数をカウントして...",
"- rcd[v] += 1",
"-unq = []",
"-for w in range(num): # 1個の場合は重複がない要素として'unq'に集約",
"- if rcd[w] == 1:",
"- unq.append(w)",
"-# print(unq)",
"-rcd = [0 for _ in range(num)] # 再度... | false | 0.035076 | 0.036864 | 0.951498 | [
"s872870078",
"s223081553"
] |
u564589929 | p03241 | python | s239453746 | s917461532 | 24 | 20 | 3,444 | 3,064 | Accepted | Accepted | 16.67 | import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline ####
def int1(x): return int(x) - 1
def II(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return input().split()
def printlist(lst, k='\n'): print((k.join(list(map(str, lst)))))
INF = float('inf')
from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush
def solve():
N, M = MI()
ans = 1
for i in range(1, int(pow(M, 0.5))+1):
if M % i: continue
j = M // i
if i * N <= M: ans = max(ans, i)
if j * N <= M: ans = max(ans, j)
print(ans)
if __name__ == '__main__':
solve()
| import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline ####
def int1(x): return int(x) - 1
def II(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SMI(): return input().split()
def SLI(): return list(eval(input()))
def printlist(lst, k=' '): print((k.join(list(map(str, lst)))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum # accumulate
def solve():
N, M = MI()
ans = 1
for i in range(1, int(pow(M, 0.5))+1):
if M % i: continue
if N * i <= M: ans = max(ans, i)
if N * (M // i) <= M: ans = max(ans, M//i)
print(ans)
if __name__ == '__main__':
solve()
| 41 | 33 | 1,041 | 1,130 | import sys
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline ####
def int1(x):
return int(x) - 1
def II():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def MI1():
return list(map(int1, input().split()))
def LI():
return list(map(int, input().split()))
def LI1():
return list(map(int1, input().split()))
def LLI(rows_number):
return [LI() for _ in range(rows_number)]
def SI():
return input().split()
def printlist(lst, k="\n"):
print((k.join(list(map(str, lst)))))
INF = float("inf")
from math import ceil, floor, log2
from collections import deque
from itertools import (
combinations as comb,
combinations_with_replacement as comb_w,
accumulate,
product,
)
from heapq import heapify, heappop, heappush
def solve():
N, M = MI()
ans = 1
for i in range(1, int(pow(M, 0.5)) + 1):
if M % i:
continue
j = M // i
if i * N <= M:
ans = max(ans, i)
if j * N <= M:
ans = max(ans, j)
print(ans)
if __name__ == "__main__":
solve()
| import sys
sys.setrecursionlimit(10**9)
# input = sys.stdin.readline ####
def int1(x):
return int(x) - 1
def II():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def MI1():
return list(map(int1, input().split()))
def LI():
return list(map(int, input().split()))
def LI1():
return list(map(int1, input().split()))
def LLI(rows_number):
return [LI() for _ in range(rows_number)]
def SMI():
return input().split()
def SLI():
return list(eval(input()))
def printlist(lst, k=" "):
print((k.join(list(map(str, lst)))))
INF = float("inf")
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum # accumulate
def solve():
N, M = MI()
ans = 1
for i in range(1, int(pow(M, 0.5)) + 1):
if M % i:
continue
if N * i <= M:
ans = max(ans, i)
if N * (M // i) <= M:
ans = max(ans, M // i)
print(ans)
if __name__ == "__main__":
solve()
| false | 19.512195 | [
"-sys.setrecursionlimit(10**6)",
"+sys.setrecursionlimit(10**9)",
"-def SI():",
"+def SMI():",
"-def printlist(lst, k=\"\\n\"):",
"+def SLI():",
"+ return list(eval(input()))",
"+",
"+",
"+def printlist(lst, k=\" \"):",
"-from math import ceil, floor, log2",
"-from collections import deque"... | false | 0.094898 | 0.106184 | 0.893711 | [
"s239453746",
"s917461532"
] |
u443569380 | p03385 | python | s862845412 | s701687892 | 25 | 17 | 3,188 | 3,060 | Accepted | Accepted | 32 | # coding: utf-8
import re
S = eval(input())
find_a = re.findall("a",S)
find_b = re.findall("b",S)
find_c = re.findall("c",S)
if find_a and find_b and find_c:
print("Yes")
else:
print("No") | S = eval(input())
ans = 0
for i in S:
if i == "a":
ans += 1
elif i == "b":
ans += 2
elif i == "c":
ans += 3
if ans == 6:
print("Yes")
else:
print("No") | 10 | 13 | 199 | 201 | # coding: utf-8
import re
S = eval(input())
find_a = re.findall("a", S)
find_b = re.findall("b", S)
find_c = re.findall("c", S)
if find_a and find_b and find_c:
print("Yes")
else:
print("No")
| S = eval(input())
ans = 0
for i in S:
if i == "a":
ans += 1
elif i == "b":
ans += 2
elif i == "c":
ans += 3
if ans == 6:
print("Yes")
else:
print("No")
| false | 23.076923 | [
"-# coding: utf-8",
"-import re",
"-",
"-find_a = re.findall(\"a\", S)",
"-find_b = re.findall(\"b\", S)",
"-find_c = re.findall(\"c\", S)",
"-if find_a and find_b and find_c:",
"+ans = 0",
"+for i in S:",
"+ if i == \"a\":",
"+ ans += 1",
"+ elif i == \"b\":",
"+ ans += ... | false | 0.038875 | 0.037623 | 1.033262 | [
"s862845412",
"s701687892"
] |
u981122970 | p03012 | python | s832405045 | s216196824 | 174 | 17 | 38,384 | 3,060 | Accepted | Accepted | 90.23 | n = int(eval(input()))
a = [int(i) for i in input().split()]
ret = 1000
for i in range(1, n):
s = abs(sum(a[:i]) - sum(a[i:]))
if s < ret:
ret = s
print(ret) | from sys import stdin
n = int(eval(input()))
a = [int(i) for i in stdin.readline().rstrip().split()]
ret = 1000
for i in range(1, n):
s = abs(sum(a[:i]) - sum(a[i:]))
if s < ret:
ret = s
print(ret)
| 9 | 10 | 176 | 218 | n = int(eval(input()))
a = [int(i) for i in input().split()]
ret = 1000
for i in range(1, n):
s = abs(sum(a[:i]) - sum(a[i:]))
if s < ret:
ret = s
print(ret)
| from sys import stdin
n = int(eval(input()))
a = [int(i) for i in stdin.readline().rstrip().split()]
ret = 1000
for i in range(1, n):
s = abs(sum(a[:i]) - sum(a[i:]))
if s < ret:
ret = s
print(ret)
| false | 10 | [
"+from sys import stdin",
"+",
"-a = [int(i) for i in input().split()]",
"+a = [int(i) for i in stdin.readline().rstrip().split()]"
] | false | 0.115975 | 0.044211 | 2.623236 | [
"s832405045",
"s216196824"
] |
u230717961 | p03262 | python | s836322911 | s242688503 | 106 | 73 | 20,824 | 20,456 | Accepted | Accepted | 31.13 | import functools
import math
N, X = [int(i) for i in input().split()]
x_list = [int(i) for i in input().split()]
x_list.append(X)
num_list = sorted(x_list)
tmp = [abs(x[0] - x[1]) for x in zip(num_list[:-1],num_list[1:])]
D = functools.reduce(lambda acc, x: math.gcd(acc, x), tmp, 0)
print(D)
| import functools
import math
N, X = [int(i) for i in input().split()]
x_list = [abs(int(i) - X) for i in input().split()]
D = functools.reduce(lambda acc, x: math.gcd(acc, x), x_list, 0)
print(D) | 15 | 9 | 328 | 206 | import functools
import math
N, X = [int(i) for i in input().split()]
x_list = [int(i) for i in input().split()]
x_list.append(X)
num_list = sorted(x_list)
tmp = [abs(x[0] - x[1]) for x in zip(num_list[:-1], num_list[1:])]
D = functools.reduce(lambda acc, x: math.gcd(acc, x), tmp, 0)
print(D)
| import functools
import math
N, X = [int(i) for i in input().split()]
x_list = [abs(int(i) - X) for i in input().split()]
D = functools.reduce(lambda acc, x: math.gcd(acc, x), x_list, 0)
print(D)
| false | 40 | [
"-x_list = [int(i) for i in input().split()]",
"-x_list.append(X)",
"-num_list = sorted(x_list)",
"-tmp = [abs(x[0] - x[1]) for x in zip(num_list[:-1], num_list[1:])]",
"-D = functools.reduce(lambda acc, x: math.gcd(acc, x), tmp, 0)",
"+x_list = [abs(int(i) - X) for i in input().split()]",
"+D = functoo... | false | 0.071853 | 0.044076 | 1.630189 | [
"s836322911",
"s242688503"
] |
u597374218 | p03486 | python | s673568925 | s434333065 | 28 | 25 | 9,076 | 9,060 | Accepted | Accepted | 10.71 | s=sorted(eval(input()))
t=sorted(eval(input()))[::-1]
print(("Yes" if s<t else "No")) | s=eval(input())
t=eval(input())
print(("Yes" if sorted(s)<sorted(t)[::-1] else "No")) | 3 | 3 | 73 | 73 | s = sorted(eval(input()))
t = sorted(eval(input()))[::-1]
print(("Yes" if s < t else "No"))
| s = eval(input())
t = eval(input())
print(("Yes" if sorted(s) < sorted(t)[::-1] else "No"))
| false | 0 | [
"-s = sorted(eval(input()))",
"-t = sorted(eval(input()))[::-1]",
"-print((\"Yes\" if s < t else \"No\"))",
"+s = eval(input())",
"+t = eval(input())",
"+print((\"Yes\" if sorted(s) < sorted(t)[::-1] else \"No\"))"
] | false | 0.045299 | 0.085334 | 0.530837 | [
"s673568925",
"s434333065"
] |
u945181840 | p02824 | python | s054764697 | s251058405 | 548 | 190 | 18,404 | 23,112 | Accepted | Accepted | 65.33 | import sys
read = sys.stdin.read
N, M, V, P, *A = list(map(int, read().split()))
A += [10 ** 10]
A.sort(reverse=True)
left = P
right = N + 1
# i番目の問題が採用される可能性があるか否や
e = tuple(enumerate(A))
while right - left > 1:
mid = (right + left) // 2
score = A[mid] + M
if score < A[P]:
right = mid
continue
s = M * (V - P)
for idx, i in e[P:]:
if mid == idx:
continue
if i + M <= score:
s -= M
else:
s -= score - i
if s <= 0:
left = mid
else:
right = mid
print(left)
| import sys
import numpy as np
read = sys.stdin.read
N, M, V, P, *A = list(map(int, read().split()))
A = np.array(A + [10 ** 10], np.int64)
A.sort()
A = A[::-1]
left = P
right = N + 1
# i番目の問題が採用される可能性があるか否や
while right - left > 1:
mid = (right + left) // 2
score = A[mid] + M
if score < A[P]:
right = mid
continue
s = np.minimum(score - A[P:], M)
if np.sum(s) >= M * (V - (P - 1)):
left = mid
else:
right = mid
print(left)
| 32 | 26 | 605 | 502 | import sys
read = sys.stdin.read
N, M, V, P, *A = list(map(int, read().split()))
A += [10**10]
A.sort(reverse=True)
left = P
right = N + 1
# i番目の問題が採用される可能性があるか否や
e = tuple(enumerate(A))
while right - left > 1:
mid = (right + left) // 2
score = A[mid] + M
if score < A[P]:
right = mid
continue
s = M * (V - P)
for idx, i in e[P:]:
if mid == idx:
continue
if i + M <= score:
s -= M
else:
s -= score - i
if s <= 0:
left = mid
else:
right = mid
print(left)
| import sys
import numpy as np
read = sys.stdin.read
N, M, V, P, *A = list(map(int, read().split()))
A = np.array(A + [10**10], np.int64)
A.sort()
A = A[::-1]
left = P
right = N + 1
# i番目の問題が採用される可能性があるか否や
while right - left > 1:
mid = (right + left) // 2
score = A[mid] + M
if score < A[P]:
right = mid
continue
s = np.minimum(score - A[P:], M)
if np.sum(s) >= M * (V - (P - 1)):
left = mid
else:
right = mid
print(left)
| false | 18.75 | [
"+import numpy as np",
"-A += [10**10]",
"-A.sort(reverse=True)",
"+A = np.array(A + [10**10], np.int64)",
"+A.sort()",
"+A = A[::-1]",
"-e = tuple(enumerate(A))",
"- s = M * (V - P)",
"- for idx, i in e[P:]:",
"- if mid == idx:",
"- continue",
"- if i + M <= sco... | false | 0.041768 | 0.213376 | 0.19575 | [
"s054764697",
"s251058405"
] |
u997641430 | p03450 | python | s458429134 | s744490953 | 1,569 | 1,167 | 67,604 | 66,300 | Accepted | Accepted | 25.62 | n, m = list(map(int, input().split()))
inf = 10**10
G = [{} for i in range(n)]
for i in range(m):
l, r, d = list(map(int, input().split()))
G[l-1][r-1] = d
G[r-1][l-1] = -d
V = [False for i in range(n)]
D = [inf for i in range(n)]
for i in range(n):
if V[i]:
continue
Q = [i]
D[i] = 0
while Q:
j = Q.pop()
V[j] = True
for k in list(G[j].keys()):
if not V[k]:
Q.append(k)
if D[k] == inf:
D[k] = D[j]+G[j][k]
elif D[k] != D[j]+G[j][k]:
print('No')
exit()
print('Yes')
| n, m = list(map(int, input().split()))
inf = 10**10
# G[i][j] = iからjへの距離
G = [{} for i in range(n)]
for i in range(m):
l, r, d = list(map(int, input().split()))
G[l-1][r-1] = d
G[r-1][l-1] = -d
# D[j] = jの属する連結成分のトップからjへの距離
D = [inf for i in range(n)]
# まだ探索していないiをトップとして探索する
for i in range(n):
if D[i] != inf:
continue
Q = [i]
D[i] = 0
while Q:
j = Q.pop()
for k in list(G[j].keys()):
if D[k] == inf:
Q.append(k)
if D[k] == inf:
D[k] = D[j]+G[j][k]
elif D[k] != D[j]+G[j][k]:
print('No')
exit()
print('Yes')
| 26 | 27 | 633 | 669 | n, m = list(map(int, input().split()))
inf = 10**10
G = [{} for i in range(n)]
for i in range(m):
l, r, d = list(map(int, input().split()))
G[l - 1][r - 1] = d
G[r - 1][l - 1] = -d
V = [False for i in range(n)]
D = [inf for i in range(n)]
for i in range(n):
if V[i]:
continue
Q = [i]
D[i] = 0
while Q:
j = Q.pop()
V[j] = True
for k in list(G[j].keys()):
if not V[k]:
Q.append(k)
if D[k] == inf:
D[k] = D[j] + G[j][k]
elif D[k] != D[j] + G[j][k]:
print("No")
exit()
print("Yes")
| n, m = list(map(int, input().split()))
inf = 10**10
# G[i][j] = iからjへの距離
G = [{} for i in range(n)]
for i in range(m):
l, r, d = list(map(int, input().split()))
G[l - 1][r - 1] = d
G[r - 1][l - 1] = -d
# D[j] = jの属する連結成分のトップからjへの距離
D = [inf for i in range(n)]
# まだ探索していないiをトップとして探索する
for i in range(n):
if D[i] != inf:
continue
Q = [i]
D[i] = 0
while Q:
j = Q.pop()
for k in list(G[j].keys()):
if D[k] == inf:
Q.append(k)
if D[k] == inf:
D[k] = D[j] + G[j][k]
elif D[k] != D[j] + G[j][k]:
print("No")
exit()
print("Yes")
| false | 3.703704 | [
"+# G[i][j] = iからjへの距離",
"-V = [False for i in range(n)]",
"+# D[j] = jの属する連結成分のトップからjへの距離",
"+# まだ探索していないiをトップとして探索する",
"- if V[i]:",
"+ if D[i] != inf:",
"- V[j] = True",
"- if not V[k]:",
"+ if D[k] == inf:"
] | false | 0.062472 | 0.039568 | 1.578864 | [
"s458429134",
"s744490953"
] |
u775681539 | p03013 | python | s487572375 | s448181814 | 175 | 56 | 8,616 | 14,164 | Accepted | Accepted | 68 | #python3
MOD = int(1e9+7)
def main():
n, m = list(map(int, input().split()))
a = [int(eval(input())) for _ in range(m)]
broken = [0]*(n+1)
for i in a:
broken[i] = 1;
dp = [0]*(n+2)
dp[n] = 1
for i in reversed(list(range(n))):
if broken[i]:
dp[i] = 0;
continue;
dp[i] = (dp[i+1] + dp[i+2]) % MOD
print((dp[0]))
main() | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
N, M, *a = list(map(int, read().split()))
A = set()
P = (10**9)+7
for i in a:
A.add(i)
dp = [0 for _ in range(N+1)]
dp[0] = 1
if not (1 in A):
dp[1] = 1
for i in range(2, N+1):
if i in A:
continue
else:
dp[i] = (dp[i-1] + dp[i-2])%P
print((dp[N]))
if __name__ == '__main__':
main()
| 21 | 27 | 402 | 538 | # python3
MOD = int(1e9 + 7)
def main():
n, m = list(map(int, input().split()))
a = [int(eval(input())) for _ in range(m)]
broken = [0] * (n + 1)
for i in a:
broken[i] = 1
dp = [0] * (n + 2)
dp[n] = 1
for i in reversed(list(range(n))):
if broken[i]:
dp[i] = 0
continue
dp[i] = (dp[i + 1] + dp[i + 2]) % MOD
print((dp[0]))
main()
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
N, M, *a = list(map(int, read().split()))
A = set()
P = (10**9) + 7
for i in a:
A.add(i)
dp = [0 for _ in range(N + 1)]
dp[0] = 1
if not (1 in A):
dp[1] = 1
for i in range(2, N + 1):
if i in A:
continue
else:
dp[i] = (dp[i - 1] + dp[i - 2]) % P
print((dp[N]))
if __name__ == "__main__":
main()
| false | 22.222222 | [
"-# python3",
"-MOD = int(1e9 + 7)",
"+import sys",
"+",
"+read = sys.stdin.buffer.read",
"+readline = sys.stdin.buffer.readline",
"+readlines = sys.stdin.buffer.readlines",
"- n, m = list(map(int, input().split()))",
"- a = [int(eval(input())) for _ in range(m)]",
"- broken = [0] * (n + ... | false | 0.063979 | 0.036434 | 1.756048 | [
"s487572375",
"s448181814"
] |
u901447859 | p03448 | python | s959924638 | s840537835 | 49 | 18 | 3,060 | 2,940 | Accepted | Accepted | 63.27 | a,b,c,x=list(map(int,open(0).read().split()))
total=0
for a_ in range(0,a+1):
for b_ in range(0,b+1):
for c_ in range(0,c+1):
if 500*a_+b_*100+c_*50 == x:
total+=1
break
print(total) | a,b,c,x=list(map(int,open(0).read().split()))
total=0
for a_ in range(0,a+1):
for b_ in range(0,b+1):
y=x-a_*500-b_*100
if y%50==0 and 0<=y//50<=c:
total+=1
print(total) | 10 | 9 | 214 | 188 | a, b, c, x = list(map(int, open(0).read().split()))
total = 0
for a_ in range(0, a + 1):
for b_ in range(0, b + 1):
for c_ in range(0, c + 1):
if 500 * a_ + b_ * 100 + c_ * 50 == x:
total += 1
break
print(total)
| a, b, c, x = list(map(int, open(0).read().split()))
total = 0
for a_ in range(0, a + 1):
for b_ in range(0, b + 1):
y = x - a_ * 500 - b_ * 100
if y % 50 == 0 and 0 <= y // 50 <= c:
total += 1
print(total)
| false | 10 | [
"- for c_ in range(0, c + 1):",
"- if 500 * a_ + b_ * 100 + c_ * 50 == x:",
"- total += 1",
"- break",
"+ y = x - a_ * 500 - b_ * 100",
"+ if y % 50 == 0 and 0 <= y // 50 <= c:",
"+ total += 1"
] | false | 0.063266 | 0.037221 | 1.699746 | [
"s959924638",
"s840537835"
] |
u298297089 | p03043 | python | s350465332 | s848647977 | 39 | 23 | 3,188 | 3,064 | Accepted | Accepted | 41.03 |
def bisect(bi, x, target, left, right):
if left + 1 == right:
return right
half = (right + left) // 2
if bi[half] * x < target:
half = bisect(bi, x, target, half, right)
else:
half = bisect(bi, x, target, left, half)
return half
N,K = list(map(int, input().split()))
bi = []
i = 1
while i <= 10**5:
bi.append(i)
i *= 2
bi.append(i)
ans = 0
for i in range(1,N+1):
if i >= K:
ans += 1
else:
j = bisect(bi, i, K, 0, len(bi))
ans += 0.5**j
print(('{:.10f}'.format(ans / N))) | N,K = list(map(int, input().split()))
bi = []
i = 1
j = 0
while i < K:
bi.append(i)
i *= 2
j += 1
bi.append(i)
ans = max(0,N-K+1)
ite = min(N+1,K)
for i in range(1,ite):
# print(i,j, bi[j-1] * i)
if j > 0 and bi[j-1] * i >= K:
j -= 1
#print(i, j, i*bi[j])
ans += 0.5**j
print(('{:.10f}'.format(ans / N))) | 26 | 19 | 573 | 351 | def bisect(bi, x, target, left, right):
if left + 1 == right:
return right
half = (right + left) // 2
if bi[half] * x < target:
half = bisect(bi, x, target, half, right)
else:
half = bisect(bi, x, target, left, half)
return half
N, K = list(map(int, input().split()))
bi = []
i = 1
while i <= 10**5:
bi.append(i)
i *= 2
bi.append(i)
ans = 0
for i in range(1, N + 1):
if i >= K:
ans += 1
else:
j = bisect(bi, i, K, 0, len(bi))
ans += 0.5**j
print(("{:.10f}".format(ans / N)))
| N, K = list(map(int, input().split()))
bi = []
i = 1
j = 0
while i < K:
bi.append(i)
i *= 2
j += 1
bi.append(i)
ans = max(0, N - K + 1)
ite = min(N + 1, K)
for i in range(1, ite):
# print(i,j, bi[j-1] * i)
if j > 0 and bi[j - 1] * i >= K:
j -= 1
# print(i, j, i*bi[j])
ans += 0.5**j
print(("{:.10f}".format(ans / N)))
| false | 26.923077 | [
"-def bisect(bi, x, target, left, right):",
"- if left + 1 == right:",
"- return right",
"- half = (right + left) // 2",
"- if bi[half] * x < target:",
"- half = bisect(bi, x, target, half, right)",
"- else:",
"- half = bisect(bi, x, target, left, half)",
"- retur... | false | 0.162639 | 0.036193 | 4.493609 | [
"s350465332",
"s848647977"
] |
u200887663 | p02755 | python | s686800031 | s244568178 | 26 | 18 | 3,060 | 2,940 | Accepted | Accepted | 30.77 | #n=int(input())
a,b=list(map(int,input().split()))
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
import math
flag=False
ans=-1
for i in range(1,10001):
a2=i*0.08
a1=int(i*0.08)
b1=int(i*0.1)
if a1==a and b1==b:
ans=i
break
print(ans)
| #k=int(input())
a,b=list(map(int,input().split()))
#hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
flag=False
import math
for price in range(1,1001):
if math.floor(price*0.08)==a and math.floor(price*0.1)==b:
flag=True
break
if flag:
print(price)
else:
print((-1))
| 20 | 16 | 326 | 343 | # n=int(input())
a, b = list(map(int, input().split()))
# l=list(map(int,input().split()))
# l=[list(map(int,input().split())) for i in range(n)]
import math
flag = False
ans = -1
for i in range(1, 10001):
a2 = i * 0.08
a1 = int(i * 0.08)
b1 = int(i * 0.1)
if a1 == a and b1 == b:
ans = i
break
print(ans)
| # k=int(input())
a, b = list(map(int, input().split()))
# hl=list(map(int,input().split()))
# l=[list(map(int,input().split())) for i in range(n)]
flag = False
import math
for price in range(1, 1001):
if math.floor(price * 0.08) == a and math.floor(price * 0.1) == b:
flag = True
break
if flag:
print(price)
else:
print((-1))
| false | 20 | [
"-# n=int(input())",
"+# k=int(input())",
"-# l=list(map(int,input().split()))",
"+# hl=list(map(int,input().split()))",
"+flag = False",
"-flag = False",
"-ans = -1",
"-for i in range(1, 10001):",
"- a2 = i * 0.08",
"- a1 = int(i * 0.08)",
"- b1 = int(i * 0.1)",
"- if a1 == a and ... | false | 0.038713 | 0.161345 | 0.239942 | [
"s686800031",
"s244568178"
] |
u803617136 | p02897 | python | s773623755 | s716980107 | 170 | 17 | 38,496 | 2,940 | Accepted | Accepted | 90 | N = int(eval(input()))
odds = N // 2
if N % 2 == 1:
odds += 1
print((odds / N)) | n = int(eval(input()))
ans = (n - n // 2) / n
print(ans) | 5 | 3 | 79 | 52 | N = int(eval(input()))
odds = N // 2
if N % 2 == 1:
odds += 1
print((odds / N))
| n = int(eval(input()))
ans = (n - n // 2) / n
print(ans)
| false | 40 | [
"-N = int(eval(input()))",
"-odds = N // 2",
"-if N % 2 == 1:",
"- odds += 1",
"-print((odds / N))",
"+n = int(eval(input()))",
"+ans = (n - n // 2) / n",
"+print(ans)"
] | false | 0.043555 | 0.0415 | 1.049521 | [
"s773623755",
"s716980107"
] |
u481250941 | p02837 | python | s165639642 | s451641057 | 219 | 114 | 16,352 | 16,168 | Accepted | Accepted | 47.95 | #
# abc147 c
#
import sys
from io import StringIO
import unittest
class TestClass(unittest.TestCase):
def assertIO(self, input, output):
stdout, stdin = sys.stdout, sys.stdin
sys.stdout, sys.stdin = StringIO(), StringIO(input)
resolve()
sys.stdout.seek(0)
out = sys.stdout.read()[:-1]
sys.stdout, sys.stdin = stdout, stdin
self.assertEqual(out, output)
def test_入力例_1(self):
input = """3
1
2 1
1
1 1
1
2 0"""
output = """2"""
self.assertIO(input, output)
def test_入力例_2(self):
input = """3
2
2 1
3 0
2
3 1
1 0
2
1 1
2 0"""
output = """0"""
self.assertIO(input, output)
def test_入力例_3(self):
input = """2
1
2 0
1
1 0"""
output = """1"""
self.assertIO(input, output)
def resolve():
N = int(eval(input()))
C = []
for i in range(N):
a = int(eval(input()))
C.append([list(map(int, input().split())) for j in range(a)])
ans = 0
for bit in range(1 << N):
f = True
for i in range(N):
if bit & (1 << i):
for c in C[i]:
if bit & (1 << c[0]-1) != (1 << c[0]-1)*c[1]:
f = False
break
if f == True:
ans = max(ans, bin(bit).count("1"))
print(ans)
if __name__ == "__main__":
# unittest.main()
resolve()
| #
# abc147 c
#
import sys
from io import StringIO
import unittest
from collections import deque
class TestClass(unittest.TestCase):
def assertIO(self, input, output):
stdout, stdin = sys.stdout, sys.stdin
sys.stdout, sys.stdin = StringIO(), StringIO(input)
resolve()
sys.stdout.seek(0)
out = sys.stdout.read()[:-1]
sys.stdout, sys.stdin = stdout, stdin
self.assertEqual(out, output)
def test_入力例_1(self):
input = """3
1
2 1
1
1 1
1
2 0"""
output = """2"""
self.assertIO(input, output)
def test_入力例_2(self):
input = """3
2
2 1
3 0
2
3 1
1 0
2
1 1
2 0"""
output = """0"""
self.assertIO(input, output)
def test_入力例_3(self):
input = """2
1
2 0
1
1 0"""
output = """1"""
self.assertIO(input, output)
def resolve_bit():
N = int(eval(input()))
C = []
for i in range(N):
a = int(eval(input()))
C.append([list(map(int, input().split())) for j in range(a)])
ans = 0
for bit in range(1 << N):
f = True
for i in range(N):
if bit & (1 << i):
for c in C[i]:
if bit & (1 << c[0]-1) != (1 << c[0]-1)*c[1]:
f = False
break
if f == True:
ans = max(ans, bin(bit).count("1"))
print(ans)
def resolve():
global N, C
N = int(eval(input()))
C = []
for i in range(N):
a = int(eval(input()))
C.append([list(map(int, input().split())) for j in range(a)])
V = deque()
print((dfs(0, V)))
def dfs(n, V):
if n == N:
count = 0
for v in V:
if count == -1:
break
for c in C[v-1]:
if (c[0] in V and c[1] == 0) or (c[0] not in V and c[1] == 1):
count = -1
break
else:
count += 1
if count == -1:
return 0
else:
return count
ans = 0
V.append(n+1)
ans = max(ans, dfs(n+1, V))
V.pop()
ans = max(ans, dfs(n+1, V))
return ans
if __name__ == "__main__":
# unittest.main()
resolve()
| 77 | 116 | 1,486 | 2,317 | #
# abc147 c
#
import sys
from io import StringIO
import unittest
class TestClass(unittest.TestCase):
def assertIO(self, input, output):
stdout, stdin = sys.stdout, sys.stdin
sys.stdout, sys.stdin = StringIO(), StringIO(input)
resolve()
sys.stdout.seek(0)
out = sys.stdout.read()[:-1]
sys.stdout, sys.stdin = stdout, stdin
self.assertEqual(out, output)
def test_入力例_1(self):
input = """3
1
2 1
1
1 1
1
2 0"""
output = """2"""
self.assertIO(input, output)
def test_入力例_2(self):
input = """3
2
2 1
3 0
2
3 1
1 0
2
1 1
2 0"""
output = """0"""
self.assertIO(input, output)
def test_入力例_3(self):
input = """2
1
2 0
1
1 0"""
output = """1"""
self.assertIO(input, output)
def resolve():
N = int(eval(input()))
C = []
for i in range(N):
a = int(eval(input()))
C.append([list(map(int, input().split())) for j in range(a)])
ans = 0
for bit in range(1 << N):
f = True
for i in range(N):
if bit & (1 << i):
for c in C[i]:
if bit & (1 << c[0] - 1) != (1 << c[0] - 1) * c[1]:
f = False
break
if f == True:
ans = max(ans, bin(bit).count("1"))
print(ans)
if __name__ == "__main__":
# unittest.main()
resolve()
| #
# abc147 c
#
import sys
from io import StringIO
import unittest
from collections import deque
class TestClass(unittest.TestCase):
def assertIO(self, input, output):
stdout, stdin = sys.stdout, sys.stdin
sys.stdout, sys.stdin = StringIO(), StringIO(input)
resolve()
sys.stdout.seek(0)
out = sys.stdout.read()[:-1]
sys.stdout, sys.stdin = stdout, stdin
self.assertEqual(out, output)
def test_入力例_1(self):
input = """3
1
2 1
1
1 1
1
2 0"""
output = """2"""
self.assertIO(input, output)
def test_入力例_2(self):
input = """3
2
2 1
3 0
2
3 1
1 0
2
1 1
2 0"""
output = """0"""
self.assertIO(input, output)
def test_入力例_3(self):
input = """2
1
2 0
1
1 0"""
output = """1"""
self.assertIO(input, output)
def resolve_bit():
N = int(eval(input()))
C = []
for i in range(N):
a = int(eval(input()))
C.append([list(map(int, input().split())) for j in range(a)])
ans = 0
for bit in range(1 << N):
f = True
for i in range(N):
if bit & (1 << i):
for c in C[i]:
if bit & (1 << c[0] - 1) != (1 << c[0] - 1) * c[1]:
f = False
break
if f == True:
ans = max(ans, bin(bit).count("1"))
print(ans)
def resolve():
global N, C
N = int(eval(input()))
C = []
for i in range(N):
a = int(eval(input()))
C.append([list(map(int, input().split())) for j in range(a)])
V = deque()
print((dfs(0, V)))
def dfs(n, V):
if n == N:
count = 0
for v in V:
if count == -1:
break
for c in C[v - 1]:
if (c[0] in V and c[1] == 0) or (c[0] not in V and c[1] == 1):
count = -1
break
else:
count += 1
if count == -1:
return 0
else:
return count
ans = 0
V.append(n + 1)
ans = max(ans, dfs(n + 1, V))
V.pop()
ans = max(ans, dfs(n + 1, V))
return ans
if __name__ == "__main__":
# unittest.main()
resolve()
| false | 33.62069 | [
"+from collections import deque",
"-def resolve():",
"+def resolve_bit():",
"+def resolve():",
"+ global N, C",
"+ N = int(eval(input()))",
"+ C = []",
"+ for i in range(N):",
"+ a = int(eval(input()))",
"+ C.append([list(map(int, input().split())) for j in range(a)])",
... | false | 0.189556 | 0.097592 | 1.942323 | [
"s165639642",
"s451641057"
] |
u764215612 | p02690 | python | s104865214 | s485414197 | 41 | 34 | 9,164 | 9,312 | Accepted | Accepted | 17.07 | def main():
x = int(eval(input()))
r = list(range(-120,120))
for i in r:
for j in r:
if i**5 - j**5 == x:
print((str(i) + ' ' + str(j)))
return
main() | import math
def main():
x = int(eval(input()))
for i in range(-120,120):
for j in range(-120,120):
if math.pow(i, 5) - math.pow(j, 5) == x:
print((str(i) + ' ' + str(j)))
return
main() | 9 | 9 | 176 | 214 | def main():
x = int(eval(input()))
r = list(range(-120, 120))
for i in r:
for j in r:
if i**5 - j**5 == x:
print((str(i) + " " + str(j)))
return
main()
| import math
def main():
x = int(eval(input()))
for i in range(-120, 120):
for j in range(-120, 120):
if math.pow(i, 5) - math.pow(j, 5) == x:
print((str(i) + " " + str(j)))
return
main()
| false | 0 | [
"+import math",
"+",
"+",
"- r = list(range(-120, 120))",
"- for i in r:",
"- for j in r:",
"- if i**5 - j**5 == x:",
"+ for i in range(-120, 120):",
"+ for j in range(-120, 120):",
"+ if math.pow(i, 5) - math.pow(j, 5) == x:"
] | false | 0.062126 | 0.049708 | 1.249804 | [
"s104865214",
"s485414197"
] |
u827202523 | p03151 | python | s660343712 | s113266498 | 146 | 129 | 18,652 | 100,204 | Accepted | Accepted | 11.64 | def getN():
return int(eval(input()))
def getMN():
a = input().split()
b = [int(i) for i in a]
return b[0],b[1]
def getlist():
a = input().split()
b = [int(i) for i in a]
return b
import bisect
n = getN()
pres = getlist()
needs = getlist()
mores = []
for i in range(len(pres)):
mores.append(pres[i] - needs[i])
ans = 0
mores.sort(reverse=False)
div = bisect.bisect_left(mores, 0)
ans += div
husoku = -(sum(mores[:div]))
amari = mores[div:]#.sort(reverse=True)
if type(amari) == int:
amari = [amari]
amari.sort(reverse=True)
if sum(amari) < husoku:
ans = -1
else:
if husoku > 0:
for a in amari:
ans += 1
if a >= husoku:
break
else:
husoku -= a
print(ans)
| import sys
from collections import defaultdict, deque, Counter
import math
# import copy
from bisect import bisect_left, bisect_right
import heapq
# sys.setrecursionlimit(1000000)
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(eval(input()))
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)
def nck(n, k, kaijyo):
return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD
def npk(n, k, kaijyo):
if k == 0 or k == n:
return n % MOD
return (kaijyo[n] * divide(kaijyo[n-k])) % MOD
def kaijyo(n):
ret = [1]
for i in range(1, n + 1):
ret.append((ret[-1] * i)% MOD)
return ret
def solve():
n = getN()
anums = getList()
bnums = getList()
if sum(anums) < sum(bnums):
print((-1))
return
husoku = 0
ans = 0
tari = []
for a, b in zip(anums, bnums):
if b > a:
husoku += b - a
ans += 1
else:
tari.append(a - b)
tari.sort(reverse=True)
if husoku == 0:
print((0))
return
# ans = 0
for t in tari:
ans += 1
husoku -= t
if husoku <= 0:
print(ans)
return
def main():
n = getN()
for _ in range(n):
solve()
if __name__ == "__main__":
# main()
solve() | 48 | 77 | 826 | 1,523 | def getN():
return int(eval(input()))
def getMN():
a = input().split()
b = [int(i) for i in a]
return b[0], b[1]
def getlist():
a = input().split()
b = [int(i) for i in a]
return b
import bisect
n = getN()
pres = getlist()
needs = getlist()
mores = []
for i in range(len(pres)):
mores.append(pres[i] - needs[i])
ans = 0
mores.sort(reverse=False)
div = bisect.bisect_left(mores, 0)
ans += div
husoku = -(sum(mores[:div]))
amari = mores[div:] # .sort(reverse=True)
if type(amari) == int:
amari = [amari]
amari.sort(reverse=True)
if sum(amari) < husoku:
ans = -1
else:
if husoku > 0:
for a in amari:
ans += 1
if a >= husoku:
break
else:
husoku -= a
print(ans)
| import sys
from collections import defaultdict, deque, Counter
import math
# import copy
from bisect import bisect_left, bisect_right
import heapq
# sys.setrecursionlimit(1000000)
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(eval(input()))
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
INF = 10**20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD - 2, MOD)
def nck(n, k, kaijyo):
return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD
def npk(n, k, kaijyo):
if k == 0 or k == n:
return n % MOD
return (kaijyo[n] * divide(kaijyo[n - k])) % MOD
def kaijyo(n):
ret = [1]
for i in range(1, n + 1):
ret.append((ret[-1] * i) % MOD)
return ret
def solve():
n = getN()
anums = getList()
bnums = getList()
if sum(anums) < sum(bnums):
print((-1))
return
husoku = 0
ans = 0
tari = []
for a, b in zip(anums, bnums):
if b > a:
husoku += b - a
ans += 1
else:
tari.append(a - b)
tari.sort(reverse=True)
if husoku == 0:
print((0))
return
# ans = 0
for t in tari:
ans += 1
husoku -= t
if husoku <= 0:
print(ans)
return
def main():
n = getN()
for _ in range(n):
solve()
if __name__ == "__main__":
# main()
solve()
| false | 37.662338 | [
"-def getN():",
"- return int(eval(input()))",
"+import sys",
"+from collections import defaultdict, deque, Counter",
"+import math",
"+",
"+# import copy",
"+from bisect import bisect_left, bisect_right",
"+import heapq",
"+",
"+# sys.setrecursionlimit(1000000)",
"+# input aliases",
"+in... | false | 0.047888 | 0.048064 | 0.996341 | [
"s660343712",
"s113266498"
] |
u597455618 | p02559 | python | s503619695 | s476191067 | 4,243 | 2,693 | 74,548 | 160,856 | Accepted | Accepted | 36.53 | import sys
import numpy as np
class Bit:
def __init__(self, n, arr):
self.size = n
self.tree = np.array([0] + arr)
for i in range(1, n+1):
if i + (i & -i) < n + 1:
self.tree[i + (i & -i)] += self.tree[i]
def sum(self, i):
s = 0
while i > 0:
s += self.tree[i]
i -= i & -i
return s
def add(self, i, x):
while i <= self.size:
self.tree[i] += x
i += i & -i
def range_sum(self, l, r):
return self.sum(r) - self.sum(l)
def main():
n, q = list(map(int, sys.stdin.buffer.readline().split()))
bit = Bit(n, list(map(int, sys.stdin.buffer.readline().split())))
for x in sys.stdin.buffer.readlines():
q, p, x = list(map(int, x.split()))
if q:
print((bit.range_sum(p, x)))
else:
bit.add(p+1, x)
if __name__ == "__main__":
main()
| import numpy as np
import sys
from numba import njit, i8, jitclass
spec = [
("size", i8),
("tree", i8[:])
]
@jitclass(spec)
class Bit:
def __init__(self, n, arr):
self.size = n
self.tree = np.array([0] + arr, np.int64)
for i in range(1, n+1):
if i + (i & -i) < n + 1:
self.tree[i + (i & -i)] += self.tree[i]
def sum(self, i):
s = 0
while i > 0:
s += self.tree[i]
i -= i & -i
return s
def add(self, i, x):
while i <= self.size:
self.tree[i] += x
i += i & -i
def range_sum(self, l, r):
return self.sum(r) - self.sum(l)
def main():
n, q = list(map(int, sys.stdin.buffer.readline().split()))
bit = Bit(n, list(map(int, sys.stdin.buffer.readline().split())))
for x in sys.stdin.buffer.readlines():
q, p, x = list(map(int, x.split()))
if q:
print((bit.range_sum(p, x)))
else:
bit.add(p+1, x)
if __name__ == "__main__":
main()
| 41 | 48 | 971 | 1,091 | import sys
import numpy as np
class Bit:
def __init__(self, n, arr):
self.size = n
self.tree = np.array([0] + arr)
for i in range(1, n + 1):
if i + (i & -i) < n + 1:
self.tree[i + (i & -i)] += self.tree[i]
def sum(self, i):
s = 0
while i > 0:
s += self.tree[i]
i -= i & -i
return s
def add(self, i, x):
while i <= self.size:
self.tree[i] += x
i += i & -i
def range_sum(self, l, r):
return self.sum(r) - self.sum(l)
def main():
n, q = list(map(int, sys.stdin.buffer.readline().split()))
bit = Bit(n, list(map(int, sys.stdin.buffer.readline().split())))
for x in sys.stdin.buffer.readlines():
q, p, x = list(map(int, x.split()))
if q:
print((bit.range_sum(p, x)))
else:
bit.add(p + 1, x)
if __name__ == "__main__":
main()
| import numpy as np
import sys
from numba import njit, i8, jitclass
spec = [("size", i8), ("tree", i8[:])]
@jitclass(spec)
class Bit:
def __init__(self, n, arr):
self.size = n
self.tree = np.array([0] + arr, np.int64)
for i in range(1, n + 1):
if i + (i & -i) < n + 1:
self.tree[i + (i & -i)] += self.tree[i]
def sum(self, i):
s = 0
while i > 0:
s += self.tree[i]
i -= i & -i
return s
def add(self, i, x):
while i <= self.size:
self.tree[i] += x
i += i & -i
def range_sum(self, l, r):
return self.sum(r) - self.sum(l)
def main():
n, q = list(map(int, sys.stdin.buffer.readline().split()))
bit = Bit(n, list(map(int, sys.stdin.buffer.readline().split())))
for x in sys.stdin.buffer.readlines():
q, p, x = list(map(int, x.split()))
if q:
print((bit.range_sum(p, x)))
else:
bit.add(p + 1, x)
if __name__ == "__main__":
main()
| false | 14.583333 | [
"+import numpy as np",
"-import numpy as np",
"+from numba import njit, i8, jitclass",
"+",
"+spec = [(\"size\", i8), (\"tree\", i8[:])]",
"+@jitclass(spec)",
"- self.tree = np.array([0] + arr)",
"+ self.tree = np.array([0] + arr, np.int64)"
] | false | 0.268901 | 0.331547 | 0.81105 | [
"s503619695",
"s476191067"
] |
u923662841 | p02861 | python | s361199930 | s472169221 | 116 | 28 | 27,280 | 9,308 | Accepted | Accepted | 75.86 | import numpy as np
import statistics
N = int(eval(input()))
XY = np.array([tuple(map(int, input().split())) for i in range(N)])
ans = 0
for i in range(N):
av = statistics.mean([np.linalg.norm(XY[i]-XY[j]) for j in range(N)])
ans += av
print(ans) | N=int(eval(input()))
xy=[list(map(int,input().split())) for i in range(N)]
print((sum(((xi-xj)**2+(yi-yj)**2)**.5 for xi,yi in xy for xj,yj in xy)/N)) | 9 | 3 | 255 | 144 | import numpy as np
import statistics
N = int(eval(input()))
XY = np.array([tuple(map(int, input().split())) for i in range(N)])
ans = 0
for i in range(N):
av = statistics.mean([np.linalg.norm(XY[i] - XY[j]) for j in range(N)])
ans += av
print(ans)
| N = int(eval(input()))
xy = [list(map(int, input().split())) for i in range(N)]
print(
(
sum(((xi - xj) ** 2 + (yi - yj) ** 2) ** 0.5 for xi, yi in xy for xj, yj in xy)
/ N
)
)
| false | 66.666667 | [
"-import numpy as np",
"-import statistics",
"-",
"-XY = np.array([tuple(map(int, input().split())) for i in range(N)])",
"-ans = 0",
"-for i in range(N):",
"- av = statistics.mean([np.linalg.norm(XY[i] - XY[j]) for j in range(N)])",
"- ans += av",
"-print(ans)",
"+xy = [list(map(int, input(... | false | 0.339243 | 0.059687 | 5.683703 | [
"s361199930",
"s472169221"
] |
u394731058 | p02780 | python | s183765636 | s105794615 | 212 | 170 | 25,064 | 24,812 | Accepted | Accepted | 19.81 | n,k = list(map(int, input().split()))
l = list(map(int, input().split()))
l2 = [0 for _ in range(n+1)]
for i in range(n):
l[i] = 1+l[i]
for i in range(n):
l2[i + 1] = l2[i]+l[i]
l3 = []
for i in range(n-k+1):
l3.append(l2[i+k]-l2[i])
print(("{:.8}".format(max(l3)/2))) | n,k = list(map(int, input().split()))
l = list(map(int, input().split()))
el = []
sl = [0]*(n-k+1)
for i in l:
el.append((1+i)/2)
sl[0] = sum(el[:k])
for i in range(n-k):
sl[i+1] = sl[i]-el[i]+el[i+k]
print(("{:.20}".format(max(sl)))) | 11 | 10 | 276 | 239 | n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
l2 = [0 for _ in range(n + 1)]
for i in range(n):
l[i] = 1 + l[i]
for i in range(n):
l2[i + 1] = l2[i] + l[i]
l3 = []
for i in range(n - k + 1):
l3.append(l2[i + k] - l2[i])
print(("{:.8}".format(max(l3) / 2)))
| n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
el = []
sl = [0] * (n - k + 1)
for i in l:
el.append((1 + i) / 2)
sl[0] = sum(el[:k])
for i in range(n - k):
sl[i + 1] = sl[i] - el[i] + el[i + k]
print(("{:.20}".format(max(sl))))
| false | 9.090909 | [
"-l2 = [0 for _ in range(n + 1)]",
"-for i in range(n):",
"- l[i] = 1 + l[i]",
"-for i in range(n):",
"- l2[i + 1] = l2[i] + l[i]",
"-l3 = []",
"-for i in range(n - k + 1):",
"- l3.append(l2[i + k] - l2[i])",
"-print((\"{:.8}\".format(max(l3) / 2)))",
"+el = []",
"+sl = [0] * (n - k + 1... | false | 0.062087 | 0.04921 | 1.261666 | [
"s183765636",
"s105794615"
] |
u489959379 | p03488 | python | s856695932 | s807070900 | 903 | 569 | 3,816 | 9,720 | Accepted | Accepted | 36.99 | # https://atcoder.jp/contests/abc082/submissions/13655878
# D - FT Robot
import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
s = eval(input())
gx, gy = list(map(int, input().split()))
spl = list(map(len, s.split("T")))
init_x = spl[0]
is_x = 0
to_x, to_y = [], []
for i in range(1, len(spl)):
if spl[i]:
to_x.append(spl[i]) if is_x else to_y.append(spl[i])
is_x ^= 1
now_x = [init_x]
for move in to_x:
nx = set()
for x in now_x:
nx.add(x + move)
nx.add(x - move)
now_x = nx
now_y = [0]
for move in to_y:
ny = set()
for y in now_y:
ny.add(y + move)
ny.add(y - move)
now_y = ny
print(("Yes" if gx in now_x and gy in now_y else "No"))
if __name__ == '__main__':
resolve()
| import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
S = eval(input())
X, Y = list(map(int, input().split()))
S = list(map(len, S.split("T")))
init_x = S[0]
is_x = 0
to_x, to_y = [], []
for i in range(1, len(S)):
if S[i]:
to_x.append(S[i]) if is_x else to_y.append(S[i])
is_x ^= 1
now_x = {init_x}
for x in to_x:
tmp = set()
for now in now_x:
tmp.add(now - x)
tmp.add(now + x)
now_x = tmp
now_y = {0}
for y in to_y:
tmp = set()
for now in now_y:
tmp.add(now - y)
tmp.add(now + y)
now_y = tmp
print(("Yes" if X in now_x and Y in now_y else "No"))
if __name__ == '__main__':
resolve()
| 43 | 41 | 926 | 837 | # https://atcoder.jp/contests/abc082/submissions/13655878
# D - FT Robot
import sys
sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
s = eval(input())
gx, gy = list(map(int, input().split()))
spl = list(map(len, s.split("T")))
init_x = spl[0]
is_x = 0
to_x, to_y = [], []
for i in range(1, len(spl)):
if spl[i]:
to_x.append(spl[i]) if is_x else to_y.append(spl[i])
is_x ^= 1
now_x = [init_x]
for move in to_x:
nx = set()
for x in now_x:
nx.add(x + move)
nx.add(x - move)
now_x = nx
now_y = [0]
for move in to_y:
ny = set()
for y in now_y:
ny.add(y + move)
ny.add(y - move)
now_y = ny
print(("Yes" if gx in now_x and gy in now_y else "No"))
if __name__ == "__main__":
resolve()
| import sys
sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
S = eval(input())
X, Y = list(map(int, input().split()))
S = list(map(len, S.split("T")))
init_x = S[0]
is_x = 0
to_x, to_y = [], []
for i in range(1, len(S)):
if S[i]:
to_x.append(S[i]) if is_x else to_y.append(S[i])
is_x ^= 1
now_x = {init_x}
for x in to_x:
tmp = set()
for now in now_x:
tmp.add(now - x)
tmp.add(now + x)
now_x = tmp
now_y = {0}
for y in to_y:
tmp = set()
for now in now_y:
tmp.add(now - y)
tmp.add(now + y)
now_y = tmp
print(("Yes" if X in now_x and Y in now_y else "No"))
if __name__ == "__main__":
resolve()
| false | 4.651163 | [
"-# https://atcoder.jp/contests/abc082/submissions/13655878",
"-# D - FT Robot",
"- s = eval(input())",
"- gx, gy = list(map(int, input().split()))",
"- spl = list(map(len, s.split(\"T\")))",
"- init_x = spl[0]",
"+ S = eval(input())",
"+ X, Y = list(map(int, input().split()))",
"+... | false | 0.123418 | 0.038906 | 3.172187 | [
"s856695932",
"s807070900"
] |
u948911484 | p02862 | python | s347971954 | s207220805 | 1,371 | 693 | 124,064 | 82,440 | Accepted | Accepted | 49.45 | x,y = list(map(int,input().split()))
if x > y*2 or y > x*2 or (x+y)%3 != 0:
print((0))
exit()
n = (x+y)//3
r = min(x-n,2*n-x)
def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, N + 1 ):
g1.append( ( g1[-1] * i ) % mod )
inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
g2.append( (g2[-1] * inverse[-1]) % mod )
print((cmb(n,r,mod))) | x,y = list(map(int,input().split()))
if (x+y)%3 != 0:
print((0))
quit()
elif x < (x+y)//3 or y < (x+y)//3:
print((0))
quit()
else:
n = (x+y)//3
r = x-n
mod = 10**9+7
def cmb(n,r,mod):
r = min(r, n-r)
return (fact[n] * factinv[r] * factinv[n-r]) % mod
def makefact(n,mod):
fact = [1,1]
factinv = [1,1]
inv = [0,1]
for i in range(2,n+1):
fact.append((fact[-1]*i) % mod)
inv.append(-inv[mod%i]*(mod//i)%mod)
factinv.append((factinv[-1]*inv[-1])%mod)
return fact,factinv
fact,factinv = makefact(n,mod)
print((cmb(n,r,mod))) | 25 | 27 | 528 | 611 | x, y = list(map(int, input().split()))
if x > y * 2 or y > x * 2 or (x + y) % 3 != 0:
print((0))
exit()
n = (x + y) // 3
r = min(x - n, 2 * n - x)
def cmb(n, r, mod):
if r < 0 or r > n:
return 0
r = min(r, n - r)
return g1[n] * g2[r] * g2[n - r] % mod
mod = 10**9 + 7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range(2, N + 1):
g1.append((g1[-1] * i) % mod)
inverse.append((-inverse[mod % i] * (mod // i)) % mod)
g2.append((g2[-1] * inverse[-1]) % mod)
print((cmb(n, r, mod)))
| x, y = list(map(int, input().split()))
if (x + y) % 3 != 0:
print((0))
quit()
elif x < (x + y) // 3 or y < (x + y) // 3:
print((0))
quit()
else:
n = (x + y) // 3
r = x - n
mod = 10**9 + 7
def cmb(n, r, mod):
r = min(r, n - r)
return (fact[n] * factinv[r] * factinv[n - r]) % mod
def makefact(n, mod):
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, n + 1):
fact.append((fact[-1] * i) % mod)
inv.append(-inv[mod % i] * (mod // i) % mod)
factinv.append((factinv[-1] * inv[-1]) % mod)
return fact, factinv
fact, factinv = makefact(n, mod)
print((cmb(n, r, mod)))
| false | 7.407407 | [
"-if x > y * 2 or y > x * 2 or (x + y) % 3 != 0:",
"+if (x + y) % 3 != 0:",
"- exit()",
"-n = (x + y) // 3",
"-r = min(x - n, 2 * n - x)",
"+ quit()",
"+elif x < (x + y) // 3 or y < (x + y) // 3:",
"+ print((0))",
"+ quit()",
"+else:",
"+ n = (x + y) // 3",
"+ r = x - n",
"... | false | 1.616006 | 0.204783 | 7.891319 | [
"s347971954",
"s207220805"
] |
u836737505 | p02959 | python | s563369816 | s980881819 | 248 | 213 | 19,156 | 18,624 | Accepted | Accepted | 14.11 | n = int(eval(input()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
for i in range(n):
ans += min(a[i],b[i]) + min(a[i+1],max(b[i]-a[i],0))
a[i+1] = max(a[i+1]-max(b[i]-a[i],0),0)
print(ans) | n = int(eval(input()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
for i in range(n):
c = min(a[i],b[i])
ans += c
if a[i] < b[i]:
ans += min(a[i+1],b[i]-a[i])
a[i+1] = max(a[i+1] - (b[i]-a[i]),0)
print(ans) | 8 | 12 | 232 | 282 | n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(n):
ans += min(a[i], b[i]) + min(a[i + 1], max(b[i] - a[i], 0))
a[i + 1] = max(a[i + 1] - max(b[i] - a[i], 0), 0)
print(ans)
| n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(n):
c = min(a[i], b[i])
ans += c
if a[i] < b[i]:
ans += min(a[i + 1], b[i] - a[i])
a[i + 1] = max(a[i + 1] - (b[i] - a[i]), 0)
print(ans)
| false | 33.333333 | [
"- ans += min(a[i], b[i]) + min(a[i + 1], max(b[i] - a[i], 0))",
"- a[i + 1] = max(a[i + 1] - max(b[i] - a[i], 0), 0)",
"+ c = min(a[i], b[i])",
"+ ans += c",
"+ if a[i] < b[i]:",
"+ ans += min(a[i + 1], b[i] - a[i])",
"+ a[i + 1] = max(a[i + 1] - (b[i] - a[i]), 0)"
] | false | 0.048309 | 0.047606 | 1.014761 | [
"s563369816",
"s980881819"
] |
u644907318 | p02659 | python | s080636033 | s383246632 | 74 | 65 | 61,860 | 61,796 | Accepted | Accepted | 12.16 | A,B = input().split()
A = int(A)
x = ""
for i in range(len(B)):
if B[i]!=".":
x += B[i]
B = int(x)
C = A*B
C = C//100
print(C) | A,B = input().split()
A = int(A)
B = "".join(list(B.split(".")))
B = int(B)
print(((A*B)//100)) | 10 | 5 | 147 | 97 | A, B = input().split()
A = int(A)
x = ""
for i in range(len(B)):
if B[i] != ".":
x += B[i]
B = int(x)
C = A * B
C = C // 100
print(C)
| A, B = input().split()
A = int(A)
B = "".join(list(B.split(".")))
B = int(B)
print(((A * B) // 100))
| false | 50 | [
"-x = \"\"",
"-for i in range(len(B)):",
"- if B[i] != \".\":",
"- x += B[i]",
"-B = int(x)",
"-C = A * B",
"-C = C // 100",
"-print(C)",
"+B = \"\".join(list(B.split(\".\")))",
"+B = int(B)",
"+print(((A * B) // 100))"
] | false | 0.043062 | 0.03728 | 1.155114 | [
"s080636033",
"s383246632"
] |
u493520238 | p02972 | python | s427066543 | s262313592 | 877 | 614 | 69,864 | 99,696 | Accepted | Accepted | 29.99 | def divs(n):
res = []
i = 1
while i**2 <= n:
if n%i == 0:
res.append(i)
if i**2 != n:
res.append(n//i)
i+=1
return res
def main():
n = int(eval(input()))
al_0 = list(map(int, input().split()))
if sum(al_0) == 0:
print((0))
return
al = [0] + al_0
divs_cnts = [0]*(n+1)
ans = []
for i in range(n,0,-1):
if divs_cnts[i]%2 != al[i]%2:
ans.append(i)
div_l = divs(i)
for d in div_l:
divs_cnts[d] += 1
print((len(ans)))
print((*ans))
if __name__ == "__main__":
main() | N = int(eval(input()))
al = list(map(int, input().split()))
al = [0] + al # 1-index
multi_cnts = [0]*(N+1)
ans = []
for n in range(N,0,-1):
if multi_cnts[n] != al[n]:
ans.append(n)
for i in range(1, int(n**0.5)+1):
if n%i == 0:
multi_cnts[i]+=1
multi_cnts[i]%=2
if i*i != n:
multi_cnts[n//i]+=1
multi_cnts[n//i]%=2
print((len(ans)))
if ans: print((*ans)) | 35 | 20 | 678 | 486 | def divs(n):
res = []
i = 1
while i**2 <= n:
if n % i == 0:
res.append(i)
if i**2 != n:
res.append(n // i)
i += 1
return res
def main():
n = int(eval(input()))
al_0 = list(map(int, input().split()))
if sum(al_0) == 0:
print((0))
return
al = [0] + al_0
divs_cnts = [0] * (n + 1)
ans = []
for i in range(n, 0, -1):
if divs_cnts[i] % 2 != al[i] % 2:
ans.append(i)
div_l = divs(i)
for d in div_l:
divs_cnts[d] += 1
print((len(ans)))
print((*ans))
if __name__ == "__main__":
main()
| N = int(eval(input()))
al = list(map(int, input().split()))
al = [0] + al # 1-index
multi_cnts = [0] * (N + 1)
ans = []
for n in range(N, 0, -1):
if multi_cnts[n] != al[n]:
ans.append(n)
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
multi_cnts[i] += 1
multi_cnts[i] %= 2
if i * i != n:
multi_cnts[n // i] += 1
multi_cnts[n // i] %= 2
print((len(ans)))
if ans:
print((*ans))
| false | 42.857143 | [
"-def divs(n):",
"- res = []",
"- i = 1",
"- while i**2 <= n:",
"- if n % i == 0:",
"- res.append(i)",
"- if i**2 != n:",
"- res.append(n // i)",
"- i += 1",
"- return res",
"-",
"-",
"-def main():",
"- n = int(eval(input())... | false | 0.067007 | 0.038413 | 1.744401 | [
"s427066543",
"s262313592"
] |
u894114233 | p00507 | python | s192132736 | s237110117 | 70 | 60 | 7,884 | 8,144 | Accepted | Accepted | 14.29 | n=int(input())
a=[int(input()) for _ in range(n)]
a.sort()
ans=[]
for i in range(3):
for j in range(i+1,n):
ans.append(int(str(a[i])+str(a[j])))
ans.append(int(str(a[j])+str(a[i])))
ans.sort()
print((ans[2])) | n=int(input())
a=[int(input()) for _ in range(n)]
a.sort()
ans=[]
for i in range(3):
for j in range(i+1,n):
ans.append(int(str(a[i])+str(a[j])))
ans.append(int(str(a[j])+str(a[i])))
ans.sort()
print((ans[2])) | 10 | 10 | 250 | 246 | n = int(input())
a = [int(input()) for _ in range(n)]
a.sort()
ans = []
for i in range(3):
for j in range(i + 1, n):
ans.append(int(str(a[i]) + str(a[j])))
ans.append(int(str(a[j]) + str(a[i])))
ans.sort()
print((ans[2]))
| n = int(input())
a = [int(input()) for _ in range(n)]
a.sort()
ans = []
for i in range(3):
for j in range(i + 1, n):
ans.append(int(str(a[i]) + str(a[j])))
ans.append(int(str(a[j]) + str(a[i])))
ans.sort()
print((ans[2]))
| false | 0 | [
"- ans.sort()",
"+ans.sort()"
] | false | 0.165972 | 0.118519 | 1.400385 | [
"s192132736",
"s237110117"
] |
u046187684 | p03111 | python | s450068713 | s269517274 | 1,440 | 404 | 58,460 | 54,488 | Accepted | Accepted | 71.94 | from itertools import permutations, combinations
def solve(string):
n, a, b, c, *l = list(map(int, string.split()))
ans = 3000
for _l in permutations(l):
for i, j, k in combinations(list(range(1, len(l) + 1)), 3):
tmp = 10 * (i - 1) + abs(a - sum(_l[:i]))
if tmp > ans:
continue
tmp += 10 * (j - i - 1) + abs(b - sum(_l[i:j]))
if tmp > ans:
continue
tmp += 10 * (k - j - 1) + abs(c - sum(_l[j:k]))
if tmp < ans:
ans = tmp
return str(ans)
if __name__ == '__main__':
n, a, b, c = list(map(int, input().split()))
print((solve('{} {} {} {}\n'.format(n, a, b, c) + '\n'.join([eval(input()) for _ in range(n)]))))
| from itertools import product
def solve(string):
n, a, b, c, *l = list(map(int, string.split()))
ans = 3000
for p in product(list(range(4)), repeat=n):
if not ({0, 1, 2} <= set(p)):
continue
sums = [0, 0, 0, 0]
for _p, _l in zip(p, l):
sums[_p] += _l
mp12 = sum(abs(_s - _abc) for _s, _abc in zip(sums[:3], [a, b, c]))
mp3 = sum(1 for _p in p if _p < 3) - 3
ans = min(ans, mp12 + mp3 * 10)
return str(ans)
if __name__ == '__main__':
n, a, b, c = list(map(int, input().split()))
print((solve('{} {} {} {}\n'.format(n, a, b, c) + '\n'.join([eval(input()) for _ in range(n)]))))
| 23 | 21 | 760 | 670 | from itertools import permutations, combinations
def solve(string):
n, a, b, c, *l = list(map(int, string.split()))
ans = 3000
for _l in permutations(l):
for i, j, k in combinations(list(range(1, len(l) + 1)), 3):
tmp = 10 * (i - 1) + abs(a - sum(_l[:i]))
if tmp > ans:
continue
tmp += 10 * (j - i - 1) + abs(b - sum(_l[i:j]))
if tmp > ans:
continue
tmp += 10 * (k - j - 1) + abs(c - sum(_l[j:k]))
if tmp < ans:
ans = tmp
return str(ans)
if __name__ == "__main__":
n, a, b, c = list(map(int, input().split()))
print(
(
solve(
"{} {} {} {}\n".format(n, a, b, c)
+ "\n".join([eval(input()) for _ in range(n)])
)
)
)
| from itertools import product
def solve(string):
n, a, b, c, *l = list(map(int, string.split()))
ans = 3000
for p in product(list(range(4)), repeat=n):
if not ({0, 1, 2} <= set(p)):
continue
sums = [0, 0, 0, 0]
for _p, _l in zip(p, l):
sums[_p] += _l
mp12 = sum(abs(_s - _abc) for _s, _abc in zip(sums[:3], [a, b, c]))
mp3 = sum(1 for _p in p if _p < 3) - 3
ans = min(ans, mp12 + mp3 * 10)
return str(ans)
if __name__ == "__main__":
n, a, b, c = list(map(int, input().split()))
print(
(
solve(
"{} {} {} {}\n".format(n, a, b, c)
+ "\n".join([eval(input()) for _ in range(n)])
)
)
)
| false | 8.695652 | [
"-from itertools import permutations, combinations",
"+from itertools import product",
"- for _l in permutations(l):",
"- for i, j, k in combinations(list(range(1, len(l) + 1)), 3):",
"- tmp = 10 * (i - 1) + abs(a - sum(_l[:i]))",
"- if tmp > ans:",
"- cont... | false | 0.076821 | 0.041078 | 1.870111 | [
"s450068713",
"s269517274"
] |
u788068140 | p02642 | python | s761380462 | s130710563 | 772 | 397 | 36,436 | 32,384 | Accepted | Accepted | 48.58 | N = 5
ARR = [24, 11, 8, 3, 16]
N = 4
ARR = [5, 5, 5, 5]
N = 10
ARR = [33, 18, 45, 28, 8, 19, 89, 86, 2, 4]
N = int(eval(input()))
ARR = list(map(int,input().split()))
def calculate(n, arr):
prr = [0 for i in range(2000005)]
for i in range(n):
start = arr[i]
#
if prr[start] > 0:
prr[start] = 2
continue
for j in range(start, 2000005, start):
prr[j] = prr[j] + 1
result = 0
for i in range(n):
start = arr[i]
if prr[start] == 1:
result += 1
print(result)
calculate(N, ARR)
| N = 5
ARR = [24, 11, 8, 3, 16]
N = 4
ARR = [5, 5, 5, 5]
N = 10
ARR = [33, 18, 45, 28, 8, 19, 89, 86, 2, 4]
N = int(eval(input()))
ARR = list(map(int,input().split()))
def calculate(n, arr):
krr = [0 for i in range(1, 1000007)]
for i in range(n):
start = arr[i]
if krr[start] > 0:
krr[start] = 2
continue
for j in range(start, 1000006, start):
krr[j] += 1
result = 0
for i in range(n):
if krr[arr[i]] == 1:
result += 1
print(result)
calculate(N, ARR)
| 39 | 34 | 633 | 588 | N = 5
ARR = [24, 11, 8, 3, 16]
N = 4
ARR = [5, 5, 5, 5]
N = 10
ARR = [33, 18, 45, 28, 8, 19, 89, 86, 2, 4]
N = int(eval(input()))
ARR = list(map(int, input().split()))
def calculate(n, arr):
prr = [0 for i in range(2000005)]
for i in range(n):
start = arr[i]
#
if prr[start] > 0:
prr[start] = 2
continue
for j in range(start, 2000005, start):
prr[j] = prr[j] + 1
result = 0
for i in range(n):
start = arr[i]
if prr[start] == 1:
result += 1
print(result)
calculate(N, ARR)
| N = 5
ARR = [24, 11, 8, 3, 16]
N = 4
ARR = [5, 5, 5, 5]
N = 10
ARR = [33, 18, 45, 28, 8, 19, 89, 86, 2, 4]
N = int(eval(input()))
ARR = list(map(int, input().split()))
def calculate(n, arr):
krr = [0 for i in range(1, 1000007)]
for i in range(n):
start = arr[i]
if krr[start] > 0:
krr[start] = 2
continue
for j in range(start, 1000006, start):
krr[j] += 1
result = 0
for i in range(n):
if krr[arr[i]] == 1:
result += 1
print(result)
calculate(N, ARR)
| false | 12.820513 | [
"- prr = [0 for i in range(2000005)]",
"+ krr = [0 for i in range(1, 1000007)]",
"- #",
"- if prr[start] > 0:",
"- prr[start] = 2",
"+ if krr[start] > 0:",
"+ krr[start] = 2",
"- for j in range(start, 2000005, start):",
"- prr[j] = p... | false | 0.358608 | 0.341821 | 1.049112 | [
"s761380462",
"s130710563"
] |
u935984175 | p02844 | python | s241008969 | s620342077 | 116 | 73 | 3,572 | 3,188 | Accepted | Accepted | 37.07 | def solve():
N = int(eval(input()))
S = list(eval(input()))
ans = 0
i_tmp = []
j_tmp = []
for i in range(N-2):
if S[i] in i_tmp:
continue
else:
i_tmp.append(S[i])
j_tmp.clear()
for j in range(i+1, N-1):
if S[j] in j_tmp:
continue
else:
j_tmp.append(S[j])
ans += len(set(S[j+1:]))
print(ans)
if __name__ == '__main__':
solve() | def solve():
N = int(eval(input()))
S = eval(input())
ans = 0
for i in range(10):
s1 = S.find(str(i), 0, -2)
if s1 == -1:
continue
for j in range(10):
s2 = S.find(str(j), s1+1, -1)
if s2 == -1:
continue
ans += len(set(S[s2+1:]))
print(ans)
if __name__ == '__main__':
solve() | 24 | 19 | 503 | 395 | def solve():
N = int(eval(input()))
S = list(eval(input()))
ans = 0
i_tmp = []
j_tmp = []
for i in range(N - 2):
if S[i] in i_tmp:
continue
else:
i_tmp.append(S[i])
j_tmp.clear()
for j in range(i + 1, N - 1):
if S[j] in j_tmp:
continue
else:
j_tmp.append(S[j])
ans += len(set(S[j + 1 :]))
print(ans)
if __name__ == "__main__":
solve()
| def solve():
N = int(eval(input()))
S = eval(input())
ans = 0
for i in range(10):
s1 = S.find(str(i), 0, -2)
if s1 == -1:
continue
for j in range(10):
s2 = S.find(str(j), s1 + 1, -1)
if s2 == -1:
continue
ans += len(set(S[s2 + 1 :]))
print(ans)
if __name__ == "__main__":
solve()
| false | 20.833333 | [
"- S = list(eval(input()))",
"+ S = eval(input())",
"- i_tmp = []",
"- j_tmp = []",
"- for i in range(N - 2):",
"- if S[i] in i_tmp:",
"+ for i in range(10):",
"+ s1 = S.find(str(i), 0, -2)",
"+ if s1 == -1:",
"- else:",
"- i_tmp.append(S[... | false | 0.038448 | 0.038782 | 0.991372 | [
"s241008969",
"s620342077"
] |
u652656291 | p03805 | python | s057740404 | s917484606 | 125 | 66 | 3,064 | 8,052 | Accepted | Accepted | 47.2 | n,m=[int(i) for i in input().split()]
es=set()
for _ in range(m):
u,v=list(map(int,input().split()))
u,v=u-1,v-1
es|={(u,v),(v,u)}
p=[[0]]
x=0
while p:
p1=p.pop()
if len(p1)==n:
x+=1
else:
for l0,l1 in es:
if l0==p1[len(p1)-1] and l1 not in p1:
p.append(p1+[l1])
print(x) | import itertools
N,M=list(map(int,input().split()))
ab=list(list(map(int,input().split())) for _ in range(M))
l=list(l for l in range(1,N+1))
numlist=list(itertools.permutations(l))
ans=0
for I in numlist:
if I[0]==1 and all(sorted([I[j],I[j+1]]) in ab for j in range(N-1)):
ans+=1
print(ans)
| 19 | 10 | 329 | 308 | n, m = [int(i) for i in input().split()]
es = set()
for _ in range(m):
u, v = list(map(int, input().split()))
u, v = u - 1, v - 1
es |= {(u, v), (v, u)}
p = [[0]]
x = 0
while p:
p1 = p.pop()
if len(p1) == n:
x += 1
else:
for l0, l1 in es:
if l0 == p1[len(p1) - 1] and l1 not in p1:
p.append(p1 + [l1])
print(x)
| import itertools
N, M = list(map(int, input().split()))
ab = list(list(map(int, input().split())) for _ in range(M))
l = list(l for l in range(1, N + 1))
numlist = list(itertools.permutations(l))
ans = 0
for I in numlist:
if I[0] == 1 and all(sorted([I[j], I[j + 1]]) in ab for j in range(N - 1)):
ans += 1
print(ans)
| false | 47.368421 | [
"-n, m = [int(i) for i in input().split()]",
"-es = set()",
"-for _ in range(m):",
"- u, v = list(map(int, input().split()))",
"- u, v = u - 1, v - 1",
"- es |= {(u, v), (v, u)}",
"-p = [[0]]",
"-x = 0",
"-while p:",
"- p1 = p.pop()",
"- if len(p1) == n:",
"- x += 1",
"... | false | 0.062742 | 0.108374 | 0.57894 | [
"s057740404",
"s917484606"
] |
u094999522 | p03472 | python | s136096945 | s740090601 | 121 | 108 | 110,392 | 31,784 | Accepted | Accepted | 10.74 | #!/usr/bin/env python3
n, h, *A = list(map(int, open(0).read().split()))
a = max(A[::2])
b = sorted(A[1::2])[::-1]
for i in range(n):
if h <= 0:
print(i)
exit()
if b[i] < a:
print((i - (-h // a)))
exit()
h -= b[i]
print((n - (-h // a)))
| n, h, *A = list(map(int, open(0).read().split()))
a = max(A[::2])
b = sorted(A[1::2])[::-1]
for i in range(n):
if h <= 0:
n = i
h = 0
break
if b[i] < a:
n = i
break
h -= b[i]
print((n - (-h // a)))
| 13 | 13 | 283 | 254 | #!/usr/bin/env python3
n, h, *A = list(map(int, open(0).read().split()))
a = max(A[::2])
b = sorted(A[1::2])[::-1]
for i in range(n):
if h <= 0:
print(i)
exit()
if b[i] < a:
print((i - (-h // a)))
exit()
h -= b[i]
print((n - (-h // a)))
| n, h, *A = list(map(int, open(0).read().split()))
a = max(A[::2])
b = sorted(A[1::2])[::-1]
for i in range(n):
if h <= 0:
n = i
h = 0
break
if b[i] < a:
n = i
break
h -= b[i]
print((n - (-h // a)))
| false | 0 | [
"-#!/usr/bin/env python3",
"- print(i)",
"- exit()",
"+ n = i",
"+ h = 0",
"+ break",
"- print((i - (-h // a)))",
"- exit()",
"+ n = i",
"+ break"
] | false | 0.03767 | 0.036803 | 1.023572 | [
"s136096945",
"s740090601"
] |
u936985471 | p02911 | python | s809036062 | s217484486 | 272 | 92 | 6,584 | 9,892 | Accepted | Accepted | 66.18 | N,K,Q=list(map(int,input().split()))
res=[K-Q]*N
for i in range(Q):
ans=int(eval(input()))-1
res[ans]=res[ans]+1
for j in range(N):
print((("No","Yes")[res[j]>0]))
| import sys
readline = sys.stdin.readline
# (Q - 正解数)点減る
N,K,Q = list(map(int,readline().split()))
P = [0] * N
for i in range(Q):
P[int(readline()) - 1] += 1
for p in P:
if K - (Q - p) > 0:
print("Yes")
else:
print("No") | 8 | 15 | 164 | 244 | N, K, Q = list(map(int, input().split()))
res = [K - Q] * N
for i in range(Q):
ans = int(eval(input())) - 1
res[ans] = res[ans] + 1
for j in range(N):
print((("No", "Yes")[res[j] > 0]))
| import sys
readline = sys.stdin.readline
# (Q - 正解数)点減る
N, K, Q = list(map(int, readline().split()))
P = [0] * N
for i in range(Q):
P[int(readline()) - 1] += 1
for p in P:
if K - (Q - p) > 0:
print("Yes")
else:
print("No")
| false | 46.666667 | [
"-N, K, Q = list(map(int, input().split()))",
"-res = [K - Q] * N",
"+import sys",
"+",
"+readline = sys.stdin.readline",
"+# (Q - 正解数)点減る",
"+N, K, Q = list(map(int, readline().split()))",
"+P = [0] * N",
"- ans = int(eval(input())) - 1",
"- res[ans] = res[ans] + 1",
"-for j in range(N):"... | false | 0.043074 | 0.042776 | 1.006948 | [
"s809036062",
"s217484486"
] |
u390901183 | p02713 | python | s495038954 | s695228088 | 1,535 | 592 | 11,240 | 10,556 | Accepted | Accepted | 61.43 | from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
# import numpy as np
from fractions import gcd
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10 ** -7
def inp(): return int(sys.stdin.readline())
def inp_list(): return list(map(int, sys.stdin.readline().split()))
def lcm(x, y): return (x * y) // gcd(x, y)
def gcd_3(x, y, z):
return gcd(gcd(x, y), z)
K = inp()
dic = {} # key: (i, j, k), el: gcd(i, j, k)
ans = 0
for i in range(1, K + 1):
for j in range(i, K + 1):
tmp = gcd(i, j)
for k in range(j, K + 1):
a = gcd(tmp, k)
if i == j == k:
ans += a
elif i == j or j == k:
ans += a * 3
else:
ans += a * 3 * 2
print(ans)
| from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
# import numpy as np
from math import gcd
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10 ** -7
def inp(): return int(sys.stdin.readline())
def inp_list(): return list(map(int, sys.stdin.readline().split()))
def lcm(x, y): return (x * y) // gcd(x, y)
K = inp()
dic = {} # key: (i, j, k), el: gcd(i, j, k)
ans = 0
for i in range(1, K + 1):
for j in range(i, K + 1):
# tmp = gcd(i, j)
for k in range(j, K + 1):
# a = gcd(tmp, k)
a = gcd(gcd(i, j), k)
if i == j == k:
ans += a
elif i == j or j == k:
ans += a * 3
else:
ans += a * 3 * 2
print(ans)
| 44 | 42 | 924 | 905 | from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
# import numpy as np
from fractions import gcd
sys.setrecursionlimit(10**8)
INF = float("inf")
mod = 10**9 + 7
eps = 10**-7
def inp():
return int(sys.stdin.readline())
def inp_list():
return list(map(int, sys.stdin.readline().split()))
def lcm(x, y):
return (x * y) // gcd(x, y)
def gcd_3(x, y, z):
return gcd(gcd(x, y), z)
K = inp()
dic = {} # key: (i, j, k), el: gcd(i, j, k)
ans = 0
for i in range(1, K + 1):
for j in range(i, K + 1):
tmp = gcd(i, j)
for k in range(j, K + 1):
a = gcd(tmp, k)
if i == j == k:
ans += a
elif i == j or j == k:
ans += a * 3
else:
ans += a * 3 * 2
print(ans)
| from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
# import numpy as np
from math import gcd
sys.setrecursionlimit(10**8)
INF = float("inf")
mod = 10**9 + 7
eps = 10**-7
def inp():
return int(sys.stdin.readline())
def inp_list():
return list(map(int, sys.stdin.readline().split()))
def lcm(x, y):
return (x * y) // gcd(x, y)
K = inp()
dic = {} # key: (i, j, k), el: gcd(i, j, k)
ans = 0
for i in range(1, K + 1):
for j in range(i, K + 1):
# tmp = gcd(i, j)
for k in range(j, K + 1):
# a = gcd(tmp, k)
a = gcd(gcd(i, j), k)
if i == j == k:
ans += a
elif i == j or j == k:
ans += a * 3
else:
ans += a * 3 * 2
print(ans)
| false | 4.545455 | [
"-from fractions import gcd",
"+from math import gcd",
"-def gcd_3(x, y, z):",
"- return gcd(gcd(x, y), z)",
"-",
"-",
"- tmp = gcd(i, j)",
"+ # tmp = gcd(i, j)",
"- a = gcd(tmp, k)",
"+ # a = gcd(tmp, k)",
"+ a = gcd(gcd(i, j), k)"
] | false | 0.209856 | 0.102775 | 2.041907 | [
"s495038954",
"s695228088"
] |
u057109575 | p02780 | python | s176056189 | s681292907 | 282 | 118 | 78,876 | 106,000 | Accepted | Accepted | 58.16 | N, K, *P = list(map(int, open(0).read().split()))
A = [0]
for i in range(1, 1001):
A.append(A[-1] + i)
B = [0] + [A[i] / i for i in range(1, 1001)]
Q = [B[p] for p in P]
ans = [sum(Q[:K])]
for i in range(N - K):
ans.append(ans[-1] - Q[i] + Q[i + K])
print((max(ans)))
| N, K, *X = list(map(int, open(0).read().split()))
y = [float(x * (x + 1) / 2 / x) for x in X]
ans = sum(y[:K])
res = ans
for i in range(K, N):
res = res - y[i - K] + y[i]
ans = max(ans, res)
print(ans)
| 13 | 9 | 287 | 213 | N, K, *P = list(map(int, open(0).read().split()))
A = [0]
for i in range(1, 1001):
A.append(A[-1] + i)
B = [0] + [A[i] / i for i in range(1, 1001)]
Q = [B[p] for p in P]
ans = [sum(Q[:K])]
for i in range(N - K):
ans.append(ans[-1] - Q[i] + Q[i + K])
print((max(ans)))
| N, K, *X = list(map(int, open(0).read().split()))
y = [float(x * (x + 1) / 2 / x) for x in X]
ans = sum(y[:K])
res = ans
for i in range(K, N):
res = res - y[i - K] + y[i]
ans = max(ans, res)
print(ans)
| false | 30.769231 | [
"-N, K, *P = list(map(int, open(0).read().split()))",
"-A = [0]",
"-for i in range(1, 1001):",
"- A.append(A[-1] + i)",
"-B = [0] + [A[i] / i for i in range(1, 1001)]",
"-Q = [B[p] for p in P]",
"-ans = [sum(Q[:K])]",
"-for i in range(N - K):",
"- ans.append(ans[-1] - Q[i] + Q[i + K])",
"-pr... | false | 0.036914 | 0.036418 | 1.013632 | [
"s176056189",
"s681292907"
] |
u912237403 | p00079 | python | s925721295 | s129129796 | 20 | 10 | 4,236 | 4,244 | Accepted | Accepted | 50 | import sys
c=[list(map(float,s[:-1].split(","))) for s in sys.stdin]
x0,y0=c[0]
x1,y1=c[1][0]-x0,c[1][1]-y0
s=0
for ex,ey in c[2:]:
x2,y2=ex-x0,ey-y0
s+=abs(x1*y2-x2*y1)
x1,y1=x2,y2
print(s/2) | import sys
x0,y0=list(map(float,input()[:-1].split(",")))
x1,y1=list(map(float,input()[:-1].split(",")))
x1,y1=x1-x0,y1-y0
s=0
for e in sys.stdin:
ex,ey=list(map(float,e[:-1].split(",")))
x2,y2=ex-x0,ey-y0
s+=abs(x1*y2-x2*y1)
x1,y1=x2,y2
print(s/2) | 10 | 11 | 206 | 263 | import sys
c = [list(map(float, s[:-1].split(","))) for s in sys.stdin]
x0, y0 = c[0]
x1, y1 = c[1][0] - x0, c[1][1] - y0
s = 0
for ex, ey in c[2:]:
x2, y2 = ex - x0, ey - y0
s += abs(x1 * y2 - x2 * y1)
x1, y1 = x2, y2
print(s / 2)
| import sys
x0, y0 = list(map(float, input()[:-1].split(",")))
x1, y1 = list(map(float, input()[:-1].split(",")))
x1, y1 = x1 - x0, y1 - y0
s = 0
for e in sys.stdin:
ex, ey = list(map(float, e[:-1].split(",")))
x2, y2 = ex - x0, ey - y0
s += abs(x1 * y2 - x2 * y1)
x1, y1 = x2, y2
print(s / 2)
| false | 9.090909 | [
"-c = [list(map(float, s[:-1].split(\",\"))) for s in sys.stdin]",
"-x0, y0 = c[0]",
"-x1, y1 = c[1][0] - x0, c[1][1] - y0",
"+x0, y0 = list(map(float, input()[:-1].split(\",\")))",
"+x1, y1 = list(map(float, input()[:-1].split(\",\")))",
"+x1, y1 = x1 - x0, y1 - y0",
"-for ex, ey in c[2:]:",
"+for e ... | false | 0.046533 | 0.035933 | 1.295005 | [
"s925721295",
"s129129796"
] |
u814781830 | p02861 | python | s362103947 | s792981122 | 413 | 194 | 8,052 | 40,684 | Accepted | Accepted | 53.03 | import math
import itertools
N = int(eval(input()))
xy = [list(map(int, input().split())) for _ in range(N)]
all_root = list(itertools.permutations(xy))
ret = 0
for root in all_root:
for i in range(len(root)-1):
x = (root[i][0] - root[i+1][0]) ** 2
y = (root[i][1] - root[i+1][1]) ** 2
ret += math.sqrt(x+y)
print((ret/len(all_root))) | import math
from itertools import permutations
N = int(eval(input()))
xy = [list(map(int, input().split())) for _ in range(N)]
ret = 0
cnt = 0
for i in permutations(xy):
for j in range(N-1):
x = (i[j][0] - i[j+1][0]) ** 2
y = (i[j][1] - i[j+1][1]) ** 2
ret += math.sqrt(x+y)
cnt += 1
print((ret/cnt))
| 15 | 16 | 371 | 343 | import math
import itertools
N = int(eval(input()))
xy = [list(map(int, input().split())) for _ in range(N)]
all_root = list(itertools.permutations(xy))
ret = 0
for root in all_root:
for i in range(len(root) - 1):
x = (root[i][0] - root[i + 1][0]) ** 2
y = (root[i][1] - root[i + 1][1]) ** 2
ret += math.sqrt(x + y)
print((ret / len(all_root)))
| import math
from itertools import permutations
N = int(eval(input()))
xy = [list(map(int, input().split())) for _ in range(N)]
ret = 0
cnt = 0
for i in permutations(xy):
for j in range(N - 1):
x = (i[j][0] - i[j + 1][0]) ** 2
y = (i[j][1] - i[j + 1][1]) ** 2
ret += math.sqrt(x + y)
cnt += 1
print((ret / cnt))
| false | 6.25 | [
"-import itertools",
"+from itertools import permutations",
"-all_root = list(itertools.permutations(xy))",
"-for root in all_root:",
"- for i in range(len(root) - 1):",
"- x = (root[i][0] - root[i + 1][0]) ** 2",
"- y = (root[i][1] - root[i + 1][1]) ** 2",
"+cnt = 0",
"+for i in pe... | false | 0.044369 | 0.048559 | 0.913706 | [
"s362103947",
"s792981122"
] |
u277104886 | p03273 | python | s700271900 | s361053433 | 40 | 32 | 9,160 | 9,140 | Accepted | Accepted | 20 | h, w = list(map(int, input().split()))
l = []
r = []
for i in range(h):
ls = list(eval(input()))
if "#" in ls:
l.append(ls)
for j in range(w):
if ls[j] == "." and j not in r:
r.append(j)
s = [i for i in range(w)]
for i in r:
count = 0
for j in range(len(l)):
if l[j][i] == ".":
count += 1
if count == len(l):
s.remove(i)
ans = []
for i in range(len(l)):
a = []
for j in s:
a.append(l[i][j])
ans.append(a)
for i in range(len(l)):
b = "".join(ans[i])
print(b)
| h, w = list(map(int, input().split()))
l = []
r = []
for i in range(h):
ls = list(eval(input()))
if "#" in ls:
l.append(ls)
s = [0]*w
for i in range(len(l)):
for j in range(w):
if l[i][j] == "#":
s[j] = 1
for i in range(len(l)):
ans = ""
for j in range(w):
ans += l[i][j]*s[j]
print(ans)
| 35 | 23 | 579 | 352 | h, w = list(map(int, input().split()))
l = []
r = []
for i in range(h):
ls = list(eval(input()))
if "#" in ls:
l.append(ls)
for j in range(w):
if ls[j] == "." and j not in r:
r.append(j)
s = [i for i in range(w)]
for i in r:
count = 0
for j in range(len(l)):
if l[j][i] == ".":
count += 1
if count == len(l):
s.remove(i)
ans = []
for i in range(len(l)):
a = []
for j in s:
a.append(l[i][j])
ans.append(a)
for i in range(len(l)):
b = "".join(ans[i])
print(b)
| h, w = list(map(int, input().split()))
l = []
r = []
for i in range(h):
ls = list(eval(input()))
if "#" in ls:
l.append(ls)
s = [0] * w
for i in range(len(l)):
for j in range(w):
if l[i][j] == "#":
s[j] = 1
for i in range(len(l)):
ans = ""
for j in range(w):
ans += l[i][j] * s[j]
print(ans)
| false | 34.285714 | [
"- for j in range(w):",
"- if ls[j] == \".\" and j not in r:",
"- r.append(j)",
"-s = [i for i in range(w)]",
"-for i in r:",
"- count = 0",
"- for j in range(len(l)):",
"- if l[j][i] == \".\":",
"- count += 1",
"- if count == len(l):",
... | false | 0.036547 | 0.035279 | 1.035951 | [
"s700271900",
"s361053433"
] |
u072717685 | p02785 | python | s789112914 | s553053778 | 158 | 104 | 26,764 | 31,408 | Accepted | Accepted | 34.18 | n, k = list(map(int, input().split()))
h = [int(i) for i in input().split()]
h.sort()
nokori = max(0, n - k)
h = h[:nokori]
print((sum(h)))
| def main():
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
if n <= k:
print((0))
else:
h.sort(reverse=True)
print((sum(h[k:])))
if __name__ == '__main__':
main() | 6 | 12 | 137 | 236 | n, k = list(map(int, input().split()))
h = [int(i) for i in input().split()]
h.sort()
nokori = max(0, n - k)
h = h[:nokori]
print((sum(h)))
| def main():
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
if n <= k:
print((0))
else:
h.sort(reverse=True)
print((sum(h[k:])))
if __name__ == "__main__":
main()
| false | 50 | [
"-n, k = list(map(int, input().split()))",
"-h = [int(i) for i in input().split()]",
"-h.sort()",
"-nokori = max(0, n - k)",
"-h = h[:nokori]",
"-print((sum(h)))",
"+def main():",
"+ n, k = list(map(int, input().split()))",
"+ h = list(map(int, input().split()))",
"+ if n <= k:",
"+ ... | false | 0.037427 | 0.038427 | 0.973975 | [
"s789112914",
"s553053778"
] |
u297574184 | p02984 | python | s080176799 | s716464794 | 129 | 87 | 19,484 | 19,148 | Accepted | Accepted | 32.56 | N = int(eval(input()))
As = list(map(int, input().split()))
sumA = sum(As)
ys = [0]*N
for i in range(1, N):
ys[i] = As[i-1]-ys[i-1]
sumY = sum(ys)
z = sumA-sumY
#print(z)
#print(ys)
x = z - sumY
for i in range(N):
ys[i] *= 2
if i%2:
ys[i] -= x
else:
ys[i] += x
print((' '.join(map(str, ys))))
| N = int(eval(input()))
As = list(map(int, input().split()))
sumA = sum(As)
sumOdd = sum(As[::2])
B = 2*sumOdd - sumA
Bs = [B]
for A in As[:-1]:
B = 2*A - B
Bs.append(B)
print((' '.join(map(str, Bs))))
| 24 | 13 | 346 | 216 | N = int(eval(input()))
As = list(map(int, input().split()))
sumA = sum(As)
ys = [0] * N
for i in range(1, N):
ys[i] = As[i - 1] - ys[i - 1]
sumY = sum(ys)
z = sumA - sumY
# print(z)
# print(ys)
x = z - sumY
for i in range(N):
ys[i] *= 2
if i % 2:
ys[i] -= x
else:
ys[i] += x
print((" ".join(map(str, ys))))
| N = int(eval(input()))
As = list(map(int, input().split()))
sumA = sum(As)
sumOdd = sum(As[::2])
B = 2 * sumOdd - sumA
Bs = [B]
for A in As[:-1]:
B = 2 * A - B
Bs.append(B)
print((" ".join(map(str, Bs))))
| false | 45.833333 | [
"-ys = [0] * N",
"-for i in range(1, N):",
"- ys[i] = As[i - 1] - ys[i - 1]",
"-sumY = sum(ys)",
"-z = sumA - sumY",
"-# print(z)",
"-# print(ys)",
"-x = z - sumY",
"-for i in range(N):",
"- ys[i] *= 2",
"- if i % 2:",
"- ys[i] -= x",
"- else:",
"- ys[i] += x",
... | false | 0.04065 | 0.04079 | 0.99657 | [
"s080176799",
"s716464794"
] |
u303739137 | p02756 | python | s104783315 | s163373321 | 1,507 | 464 | 4,512 | 4,468 | Accepted | Accepted | 69.21 | s = str(eval(input()))
q = int(eval(input()))
inv = False
head = ''
tail = ''
for i in range(q):
a = eval(input())
if a == '1':
inv = not inv
continue
a = a.split()
if (a[1] == '1')^inv:
head = a[2] + head
else:
tail += a[2]
s = head + s + tail
if inv:
print((s[::-1]))
else:
print(s) | s = str(eval(input()))
q = int(eval(input()))
inv = False
head = ''
tail = ''
for i in range(q):
a = eval(input())
if a == '1':
inv = not inv
continue
a = a.split()
if (a[1] == '1')^inv:
head += a[2]
else:
tail += a[2]
#s = head + s + tail
if inv:
print((tail[::-1]+s[::-1] + head))
else:
print((head[::-1]+s+tail)) | 21 | 21 | 345 | 375 | s = str(eval(input()))
q = int(eval(input()))
inv = False
head = ""
tail = ""
for i in range(q):
a = eval(input())
if a == "1":
inv = not inv
continue
a = a.split()
if (a[1] == "1") ^ inv:
head = a[2] + head
else:
tail += a[2]
s = head + s + tail
if inv:
print((s[::-1]))
else:
print(s)
| s = str(eval(input()))
q = int(eval(input()))
inv = False
head = ""
tail = ""
for i in range(q):
a = eval(input())
if a == "1":
inv = not inv
continue
a = a.split()
if (a[1] == "1") ^ inv:
head += a[2]
else:
tail += a[2]
# s = head + s + tail
if inv:
print((tail[::-1] + s[::-1] + head))
else:
print((head[::-1] + s + tail))
| false | 0 | [
"- head = a[2] + head",
"+ head += a[2]",
"-s = head + s + tail",
"+# s = head + s + tail",
"- print((s[::-1]))",
"+ print((tail[::-1] + s[::-1] + head))",
"- print(s)",
"+ print((head[::-1] + s + tail))"
] | false | 0.038596 | 0.036652 | 1.053042 | [
"s104783315",
"s163373321"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.