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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u706929073 | p02780 | python | s035338058 | s236366707 | 237 | 161 | 25,060 | 25,060 | Accepted | Accepted | 32.07 | n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
def mean(value):
return 0.5 * (value + 1)
res = 0
for l in range(k):
res += mean(p[l])
cur = res
for l in range(k, n):
cur += mean(p[l]) - mean(p[l-k])
res = max(res, cur)
print(res)
| n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
max_mean = 0
for i in range(k):
max_mean += 0.5 * (p[i] + 1)
cur = max_mean
for l in range(k, n):
cur += 0.5 * (p[l] - p[l-k])
max_mean = max(max_mean, cur)
print(max_mean)
| 17 | 13 | 289 | 269 | n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
def mean(value):
return 0.5 * (value + 1)
res = 0
for l in range(k):
res += mean(p[l])
cur = res
for l in range(k, n):
cur += mean(p[l]) - mean(p[l - k])
res = max(res, cur)
print(res)
| n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
max_mean = 0
for i in range(k):
max_mean += 0.5 * (p[i] + 1)
cur = max_mean
for l in range(k, n):
cur += 0.5 * (p[l] - p[l - k])
max_mean = max(max_mean, cur)
print(max_mean)
| false | 23.529412 | [
"-",
"-",
"-def mean(value):",
"- return 0.5 * (value + 1)",
"-",
"-",
"-res = 0",
"-for l in range(k):",
"- res += mean(p[l])",
"-cur = res",
"+max_mean = 0",
"+for i in range(k):",
"+ max_mean += 0.5 * (p[i] + 1)",
"+cur = max_mean",
"- cur += mean(p[l]) - mean(p[l - k])",
... | false | 0.035085 | 0.133361 | 0.263084 | [
"s035338058",
"s236366707"
] |
u606878291 | p03162 | python | s725450847 | s820776023 | 967 | 639 | 41,812 | 49,128 | Accepted | Accepted | 33.92 | import numpy as np
N = int(eval(input()))
values = np.array([list(map(int, input().split(' '))) for _ in range(N)])
dp = np.zeros(shape=(N, 3), dtype=int)
dp[0] = values[0]
for i in range(1, N):
prev = dp[i - 1]
dp[i][0] = values[i][0] + max(prev[1], prev[2])
dp[i][1] = values[i][1] + max(pr... | import numpy as np
N = int(eval(input()))
values = [tuple(map(int, input().split(' '))) for _ in range(N)]
dp = [values[0]]
for _ in range(N - 1):
dp.append([0, 0, 0])
for i in range(1, N):
prev = dp[i - 1]
dp[i][0] = values[i][0] + max(prev[1], prev[2])
dp[i][1] = values[i][1] + max(prev... | 16 | 16 | 411 | 409 | import numpy as np
N = int(eval(input()))
values = np.array([list(map(int, input().split(" "))) for _ in range(N)])
dp = np.zeros(shape=(N, 3), dtype=int)
dp[0] = values[0]
for i in range(1, N):
prev = dp[i - 1]
dp[i][0] = values[i][0] + max(prev[1], prev[2])
dp[i][1] = values[i][1] + max(prev[0], prev[2])... | import numpy as np
N = int(eval(input()))
values = [tuple(map(int, input().split(" "))) for _ in range(N)]
dp = [values[0]]
for _ in range(N - 1):
dp.append([0, 0, 0])
for i in range(1, N):
prev = dp[i - 1]
dp[i][0] = values[i][0] + max(prev[1], prev[2])
dp[i][1] = values[i][1] + max(prev[0], prev[2])
... | false | 0 | [
"-values = np.array([list(map(int, input().split(\" \"))) for _ in range(N)])",
"-dp = np.zeros(shape=(N, 3), dtype=int)",
"-dp[0] = values[0]",
"+values = [tuple(map(int, input().split(\" \"))) for _ in range(N)]",
"+dp = [values[0]]",
"+for _ in range(N - 1):",
"+ dp.append([0, 0, 0])"
] | false | 0.394313 | 0.279933 | 1.408598 | [
"s725450847",
"s820776023"
] |
u581187895 | p03830 | python | s156171873 | s406985372 | 35 | 20 | 3,060 | 3,064 | Accepted | Accepted | 42.86 | import math
n = math.factorial(int(eval(input())))
i = 2
ans = 1
M = 10**9+7
while i*i <= n:
cnt = 1
while n%i == 0:
cnt += 1
n //= i
ans *= cnt
i += 1
if n != 1:
ans *= 2
print((int(ans%M)))
|
def resolve():
def dic_factorization(n):
dic = {} # 素数:指数
i = 2
while i * i <= n:
while n % i == 0:
n //= i
if i in dic:
dic[i] += 1
else:
dic[i] = 1
i += 1
... | 15 | 34 | 216 | 739 | import math
n = math.factorial(int(eval(input())))
i = 2
ans = 1
M = 10**9 + 7
while i * i <= n:
cnt = 1
while n % i == 0:
cnt += 1
n //= i
ans *= cnt
i += 1
if n != 1:
ans *= 2
print((int(ans % M)))
| def resolve():
def dic_factorization(n):
dic = {} # 素数:指数
i = 2
while i * i <= n:
while n % i == 0:
n //= i
if i in dic:
dic[i] += 1
else:
dic[i] = 1
i += 1
if n > 1:
... | false | 55.882353 | [
"-import math",
"+def resolve():",
"+ def dic_factorization(n):",
"+ dic = {} # 素数:指数",
"+ i = 2",
"+ while i * i <= n:",
"+ while n % i == 0:",
"+ n //= i",
"+ if i in dic:",
"+ dic[i] += 1",
"+ ... | false | 0.074989 | 0.041431 | 1.809994 | [
"s156171873",
"s406985372"
] |
u102461423 | p03295 | python | s382570013 | s460226307 | 402 | 147 | 22,812 | 26,808 | Accepted | Accepted | 63.43 | N,M = list(map(int,input().split()))
pairs = []
for _ in range(M):
pairs.append([int(x) for x in input().split()])
pairs.sort(key = lambda x: x[1])
right_most = 0 # 最後に破壊されている場所(右のindex)
cnt = 0
for a,b in pairs:
if a < right_most:
continue
cnt += 1
right_most = b
print(cnt) | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from operator import itemgetter
N,M = list(map(int,readline().split()))
m = list(map(int,read().split()))
AB = sorted(zip(m,m),key=itemgetter(1))
answer = 0
x = 0
for a,b in AB:
if a ... | 19 | 20 | 305 | 376 | N, M = list(map(int, input().split()))
pairs = []
for _ in range(M):
pairs.append([int(x) for x in input().split()])
pairs.sort(key=lambda x: x[1])
right_most = 0 # 最後に破壊されている場所(右のindex)
cnt = 0
for a, b in pairs:
if a < right_most:
continue
cnt += 1
right_most = b
print(cnt)
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from operator import itemgetter
N, M = list(map(int, readline().split()))
m = list(map(int, read().split()))
AB = sorted(zip(m, m), key=itemgetter(1))
answer = 0
x = 0
for a, b in AB:
if a <= x:
... | false | 5 | [
"-N, M = list(map(int, input().split()))",
"-pairs = []",
"-for _ in range(M):",
"- pairs.append([int(x) for x in input().split()])",
"-pairs.sort(key=lambda x: x[1])",
"-right_most = 0 # 最後に破壊されている場所(右のindex)",
"-cnt = 0",
"-for a, b in pairs:",
"- if a < right_most:",
"+import sys",
"+"... | false | 0.041112 | 0.056923 | 0.722231 | [
"s382570013",
"s460226307"
] |
u981931040 | p03665 | python | s399878557 | s800498120 | 22 | 17 | 3,064 | 3,064 | Accepted | Accepted | 22.73 | import math
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N , P = list(map(int,input().split()))
A = list(map(int,input().split()))
odd_num = 0
even_num = 0
for a in A:
if a % 2 == 1:
odd_num += 1
else:
even_num += 1
... | from math import factorial
N, P = list(map(int, input().split()))
A = list(map(int, input().split()))
A = list([x % 2 for x in A])
counter = {'0': 0, '1': 0}
for a in A:
c_a = str(a)
counter[c_a] += 1
#print(counter)
ans = 2 ** counter['0']
tmp = factorial(counter['1'])
tmp_ans = 0
for i in range(0 ... | 31 | 15 | 633 | 436 | import math
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N, P = list(map(int, input().split()))
A = list(map(int, input().split()))
odd_num = 0
even_num = 0
for a in A:
if a % 2 == 1:
odd_num += 1
else:
even_num += 1
ans = 0
if P =... | from math import factorial
N, P = list(map(int, input().split()))
A = list(map(int, input().split()))
A = list([x % 2 for x in A])
counter = {"0": 0, "1": 0}
for a in A:
c_a = str(a)
counter[c_a] += 1
# print(counter)
ans = 2 ** counter["0"]
tmp = factorial(counter["1"])
tmp_ans = 0
for i in range(0 + P, count... | false | 51.612903 | [
"-import math",
"-",
"-",
"-def combinations_count(n, r):",
"- return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))",
"-",
"+from math import factorial",
"-odd_num = 0",
"-even_num = 0",
"+A = list([x % 2 for x in A])",
"+counter = {\"0\": 0, \"1\": 0}",
"- if a % 2 ==... | false | 0.034274 | 0.042984 | 0.797356 | [
"s399878557",
"s800498120"
] |
u423585790 | p02688 | python | s986426187 | s567338905 | 561 | 77 | 77,520 | 68,128 | Accepted | Accepted | 86.27 | #!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(... | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS... | 41 | 41 | 1,162 | 972 | #!/usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI():
return list(map(int, input().split()))
def LF... | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI():
return [int(x) for x in sys.stdin.buffer.readline().split()]
def I():
return int(sys.stdin.buffer.readline())
d... | false | 0 | [
"-#!/usr/bin/env python3",
"+#!usr/bin/env python3",
"-from bisect import bisect_left, bisect_right",
"-import sys, random, itertools, math",
"-",
"-sys.setrecursionlimit(10**5)",
"-input = sys.stdin.readline",
"-sqrt = math.sqrt",
"+from itertools import permutations, accumulate",
"+import sys",
... | false | 0.041375 | 0.037413 | 1.105907 | [
"s986426187",
"s567338905"
] |
u379720557 | p02707 | python | s502499009 | s508912164 | 243 | 150 | 40,960 | 32,356 | Accepted | Accepted | 38.27 | N = int(eval(input()))
A = list(map(int, input().split()))
keys = [0]*N
for i in range(N):
keys[i] = i+1
num = {key:0 for key in keys}
for i in A:
num[i] += 1
for i in range(N):
print((num[i+1])) | N = int(eval(input()))
A = list(map(int, input().split()))
ans = [0]*N
for a in A:
ans[a-1] += 1
for i in ans:
print(i) | 14 | 9 | 216 | 131 | N = int(eval(input()))
A = list(map(int, input().split()))
keys = [0] * N
for i in range(N):
keys[i] = i + 1
num = {key: 0 for key in keys}
for i in A:
num[i] += 1
for i in range(N):
print((num[i + 1]))
| N = int(eval(input()))
A = list(map(int, input().split()))
ans = [0] * N
for a in A:
ans[a - 1] += 1
for i in ans:
print(i)
| false | 35.714286 | [
"-keys = [0] * N",
"-for i in range(N):",
"- keys[i] = i + 1",
"-num = {key: 0 for key in keys}",
"-for i in A:",
"- num[i] += 1",
"-for i in range(N):",
"- print((num[i + 1]))",
"+ans = [0] * N",
"+for a in A:",
"+ ans[a - 1] += 1",
"+for i in ans:",
"+ print(i)"
] | false | 0.007859 | 0.036788 | 0.213621 | [
"s502499009",
"s508912164"
] |
u189023301 | p03559 | python | s246634222 | s573881815 | 452 | 417 | 71,516 | 71,020 | Accepted | Accepted | 7.74 | import bisect
import sys
readline = sys.stdin.buffer.readline
def main():
n = int(readline())
a = list(map(int,readline().rsplit()))
b = list(map(int,readline().rsplit()))
c = list(map(int,readline().rsplit()))
a.sort()
c.sort()
ans = 0
for i in b:
d = bisect.bise... | import bisect
import sys
readline = sys.stdin.buffer.readline
def main():
n = int(readline())
a = list(map(int,readline().rsplit()))
b = list(map(int,readline().rsplit()))
c = list(map(int,readline().rsplit()))
a.sort()
c.sort()
ans = 0
for i in b:
d = bisect.bise... | 21 | 21 | 462 | 457 | import bisect
import sys
readline = sys.stdin.buffer.readline
def main():
n = int(readline())
a = list(map(int, readline().rsplit()))
b = list(map(int, readline().rsplit()))
c = list(map(int, readline().rsplit()))
a.sort()
c.sort()
ans = 0
for i in b:
d = bisect.bisect_left(a,... | import bisect
import sys
readline = sys.stdin.buffer.readline
def main():
n = int(readline())
a = list(map(int, readline().rsplit()))
b = list(map(int, readline().rsplit()))
c = list(map(int, readline().rsplit()))
a.sort()
c.sort()
ans = 0
for i in b:
d = bisect.bisect_left(a,... | false | 0 | [
"- e = len(c) - bisect.bisect_right(c, i)",
"+ e = n - bisect.bisect_right(c, i)"
] | false | 0.038649 | 0.048563 | 0.795863 | [
"s246634222",
"s573881815"
] |
u903005414 | p02550 | python | s254005001 | s380473336 | 67 | 55 | 13,324 | 13,764 | Accepted | Accepted | 17.91 | N, X, M = list(map(int, input().split()))
if N == 1:
print(X)
exit()
A = [-1] * (10**5 + 1)
A[1] = X
# %M は答えをMOD Mにしなさいといってくれているだけ
# M はたかだか10^5なので10^5繰り返すとどこかで循環する。循環するまで繰り返す。
S = set([X])
i = 2
while True:
A[i] = ((A[i - 1])**2) % M
if A[i] in S:
break
S.add(A[i])
... | N, X, M = list(map(int, input().split()))
I = [-1] * M
A = []
total = 0
while (I[X] == -1):
A.append(X)
I[X] = len(A)
total += X
X = (X * X) % M
# print(f'{A=}')
# print(f'{I[:20]=}')
# print(f'{total=}')
# print(f'{X=}, {I[X]=}')
c = len(A) - I[X] + 1
s = sum(A[I[X] - 1:])
# print(... | 60 | 29 | 1,165 | 510 | N, X, M = list(map(int, input().split()))
if N == 1:
print(X)
exit()
A = [-1] * (10**5 + 1)
A[1] = X
# %M は答えをMOD Mにしなさいといってくれているだけ
# M はたかだか10^5なので10^5繰り返すとどこかで循環する。循環するまで繰り返す。
S = set([X])
i = 2
while True:
A[i] = ((A[i - 1]) ** 2) % M
if A[i] in S:
break
S.add(A[i])
i += 1
# i -= 1
# ... | N, X, M = list(map(int, input().split()))
I = [-1] * M
A = []
total = 0
while I[X] == -1:
A.append(X)
I[X] = len(A)
total += X
X = (X * X) % M
# print(f'{A=}')
# print(f'{I[:20]=}')
# print(f'{total=}')
# print(f'{X=}, {I[X]=}')
c = len(A) - I[X] + 1
s = sum(A[I[X] - 1 :])
# print(f'{c=}, {s=}')
ans = 0... | false | 51.666667 | [
"-if N == 1:",
"- print(X)",
"- exit()",
"-A = [-1] * (10**5 + 1)",
"-A[1] = X",
"-# %M は答えをMOD Mにしなさいといってくれているだけ",
"-# M はたかだか10^5なので10^5繰り返すとどこかで循環する。循環するまで繰り返す。",
"-S = set([X])",
"-i = 2",
"-while True:",
"- A[i] = ((A[i - 1]) ** 2) % M",
"- if A[i] in S:",
"- break",
... | false | 0.09604 | 0.046557 | 2.062836 | [
"s254005001",
"s380473336"
] |
u023127434 | p03272 | python | s600631378 | s606494597 | 28 | 23 | 8,880 | 9,156 | Accepted | Accepted | 17.86 | n, i = list(map(int, input().split()))
if n == 1:
print((1))
else:
print((n - i + 1)) | n, i = list(map(int, input().split()))
print((n - i + 1)) | 5 | 2 | 87 | 50 | n, i = list(map(int, input().split()))
if n == 1:
print((1))
else:
print((n - i + 1))
| n, i = list(map(int, input().split()))
print((n - i + 1))
| false | 60 | [
"-if n == 1:",
"- print((1))",
"-else:",
"- print((n - i + 1))",
"+print((n - i + 1))"
] | false | 0.115664 | 0.035359 | 3.27114 | [
"s600631378",
"s606494597"
] |
u547492399 | p02381 | python | s747785431 | s254678554 | 30 | 20 | 7,804 | 7,740 | Accepted | Accepted | 33.33 | while True:
n = int(eval(input()))
if n == 0:
break
s = list(map(int, input().split()))
m = sum(s)/n
a2 = sum([(s[i] - m)**2 for i in range(n)])/n
a = a2**0.5
print(a) | while True:
n = int(eval(input()))
if n == 0:
break
s = list(map(int, input().split()))
m = sum(s)/n
a2 = 0.0
for i in range(n):
a2 += (s[i] - m)**2
a = (a2/n)**0.5
print(a) | 9 | 11 | 205 | 225 | while True:
n = int(eval(input()))
if n == 0:
break
s = list(map(int, input().split()))
m = sum(s) / n
a2 = sum([(s[i] - m) ** 2 for i in range(n)]) / n
a = a2**0.5
print(a)
| while True:
n = int(eval(input()))
if n == 0:
break
s = list(map(int, input().split()))
m = sum(s) / n
a2 = 0.0
for i in range(n):
a2 += (s[i] - m) ** 2
a = (a2 / n) ** 0.5
print(a)
| false | 18.181818 | [
"- a2 = sum([(s[i] - m) ** 2 for i in range(n)]) / n",
"- a = a2**0.5",
"+ a2 = 0.0",
"+ for i in range(n):",
"+ a2 += (s[i] - m) ** 2",
"+ a = (a2 / n) ** 0.5"
] | false | 0.037258 | 0.042977 | 0.866923 | [
"s747785431",
"s254678554"
] |
u968166680 | p02814 | python | s521389134 | s092287843 | 501 | 148 | 88,672 | 16,088 | Accepted | Accepted | 70.46 | N, M = list(map(int, input().split()))
a = list(map(int, input().split()))
from math import floor
from fractions import gcd
from functools import reduce
def lcm(x, y):
return x * y // gcd(x, y)
b = [n // 2 for n in a]
lcm_b = reduce(lcm, b)
for n in b:
if (lcm_b // n) % 2 == 0:
... | import sys
from fractions import gcd
from functools import reduce
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
def lcm(x, y):
return x * y // gcd(x, y)
def main():
N, M, *A = list(map(int, read().split()))
... | 24 | 32 | 389 | 622 | N, M = list(map(int, input().split()))
a = list(map(int, input().split()))
from math import floor
from fractions import gcd
from functools import reduce
def lcm(x, y):
return x * y // gcd(x, y)
b = [n // 2 for n in a]
lcm_b = reduce(lcm, b)
for n in b:
if (lcm_b // n) % 2 == 0:
print((0))
ex... | import sys
from fractions import gcd
from functools import reduce
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
def lcm(x, y):
return x * y // gcd(x, y)
def main():
N, M, *A = list(map(int, read().split()))
A = [a // 2 for... | false | 25 | [
"-N, M = list(map(int, input().split()))",
"-a = list(map(int, input().split()))",
"-from math import floor",
"+import sys",
"+",
"+read = sys.stdin.read",
"+readline = sys.stdin.readline",
"+readlines = sys.stdin.readlines",
"+sys.setrecursionlimit(10**9)",
"+INF = 1 << 60",
"-b = [n // 2 for n... | false | 0.22341 | 0.048801 | 4.577938 | [
"s521389134",
"s092287843"
] |
u970197315 | p03108 | python | s917909629 | s442851109 | 816 | 483 | 36,048 | 28,212 | Accepted | Accepted | 40.81 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self... | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
... | 62 | 62 | 1,449 | 1,539 | class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = se... | class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = se... | false | 0 | [
"-ab = [list(map(int, input().split())) for i in range(m)]",
"+ab = []",
"+uf = UnionFind(n + 1)",
"+for i in range(m):",
"+ a, b = list(map(int, input().split()))",
"+ ab.append((a, b))",
"-ans.append(n * (n - 1) // 2)",
"-uf = UnionFind(n)",
"+huben = n * (n - 1) // 2",
"- if not uf.sam... | false | 0.036933 | 0.052546 | 0.702874 | [
"s917909629",
"s442851109"
] |
u564902833 | p03001 | python | s188765182 | s970105675 | 189 | 17 | 38,256 | 2,940 | Accepted | Accepted | 91.01 | W, H, x, y = list(map(int, input().split()))
ans = '{} {}'.format(
W * H / 2,
1 if 2 * x == W and 2 * y == H else
0
)
print(ans)
| # 入力
W, H, x, y = list(map(int, input().split()))
# 面積は必ず二等分可能
# 面積を二等分する直線は長方形の中心を通る
ans = '{} {}'.format(
W * H / 2,
1 if x == W / 2 and y == H / 2 else
0
)
# 出力
print(ans)
| 9 | 13 | 145 | 195 | W, H, x, y = list(map(int, input().split()))
ans = "{} {}".format(W * H / 2, 1 if 2 * x == W and 2 * y == H else 0)
print(ans)
| # 入力
W, H, x, y = list(map(int, input().split()))
# 面積は必ず二等分可能
# 面積を二等分する直線は長方形の中心を通る
ans = "{} {}".format(W * H / 2, 1 if x == W / 2 and y == H / 2 else 0)
# 出力
print(ans)
| false | 30.769231 | [
"+# 入力",
"-ans = \"{} {}\".format(W * H / 2, 1 if 2 * x == W and 2 * y == H else 0)",
"+# 面積は必ず二等分可能",
"+# 面積を二等分する直線は長方形の中心を通る",
"+ans = \"{} {}\".format(W * H / 2, 1 if x == W / 2 and y == H / 2 else 0)",
"+# 出力"
] | false | 0.039943 | 0.035771 | 1.116633 | [
"s188765182",
"s970105675"
] |
u814986259 | p02850 | python | s110889501 | s028457227 | 1,399 | 783 | 145,432 | 84,440 | Accepted | Accepted | 44.03 | import collections
import sys
input = sys.stdin.readline
N = int(eval(input()))
ab = [list(map(int, input().split())) for i in range(N-1)]
eda = [set() for i in range(N)]
for a, b in ab:
eda[a-1].add(b)
eda[b-1].add(a)
max_e = 0
for i in range(N-1):
max_e = max(max_e, len(eda[i]))
id = 0
for i ... | import collections
N = int(input())
G = [set() for i in range(N)]
ab = [tuple(map(int, input().split())) for i in range(N-1)]
d = dict()
i = 0
for a, b in ab:
a -= 1
b -= 1
d[(a, b)] = i
d[(b, a)] = i
i += 1
G[a].add(b)
G[b].add(a)
q = collections.deque()
r = set()
r.ad... | 46 | 38 | 901 | 677 | import collections
import sys
input = sys.stdin.readline
N = int(eval(input()))
ab = [list(map(int, input().split())) for i in range(N - 1)]
eda = [set() for i in range(N)]
for a, b in ab:
eda[a - 1].add(b)
eda[b - 1].add(a)
max_e = 0
for i in range(N - 1):
max_e = max(max_e, len(eda[i]))
id = 0
for i in r... | import collections
N = int(input())
G = [set() for i in range(N)]
ab = [tuple(map(int, input().split())) for i in range(N - 1)]
d = dict()
i = 0
for a, b in ab:
a -= 1
b -= 1
d[(a, b)] = i
d[(b, a)] = i
i += 1
G[a].add(b)
G[b].add(a)
q = collections.deque()
r = set()
r.add(0)
q.append((0, 0... | false | 17.391304 | [
"-import sys",
"-input = sys.stdin.readline",
"-N = int(eval(input()))",
"-ab = [list(map(int, input().split())) for i in range(N - 1)]",
"-eda = [set() for i in range(N)]",
"+N = int(input())",
"+G = [set() for i in range(N)]",
"+ab = [tuple(map(int, input().split())) for i in range(N - 1)]",
"+d =... | false | 0.036203 | 0.037594 | 0.963019 | [
"s110889501",
"s028457227"
] |
u968404618 | p02862 | python | s200943151 | s124928931 | 740 | 474 | 82,164 | 55,796 | Accepted | Accepted | 35.95 | mod = 10**9+7
n = 10**6
def comb(n, r):
if 2 * r > n: return comb(n, n-r)
return fac[n] * inv[r] * inv[n-r] % mod
x, y = list(map(int, input().split()))
if (x+y) % 3 != 0:
print((0))
exit()
a = -(x-2*y)//3
b = (2*x-y)//3
if a<0 or b<0:
print((0))
exit()
fac = [1] * (n+2)
i... | mod = 10**9+7
def comb(n, r):
if 2 * r > n: return comb(n, n-r)
return fac[n] * inv[r] * inv[n-r] % mod
x, y = list(map(int, input().split()))
if (x+y) % 3 != 0:
print((0))
exit()
n = (x+y)//3
x -= n
y -= n
if x<0 or y<0:
print((0))
exit()
fac = [1] * (n+2)
inv = [1] * (n+2... | 27 | 27 | 521 | 506 | mod = 10**9 + 7
n = 10**6
def comb(n, r):
if 2 * r > n:
return comb(n, n - r)
return fac[n] * inv[r] * inv[n - r] % mod
x, y = list(map(int, input().split()))
if (x + y) % 3 != 0:
print((0))
exit()
a = -(x - 2 * y) // 3
b = (2 * x - y) // 3
if a < 0 or b < 0:
print((0))
exit()
fac = ... | mod = 10**9 + 7
def comb(n, r):
if 2 * r > n:
return comb(n, n - r)
return fac[n] * inv[r] * inv[n - r] % mod
x, y = list(map(int, input().split()))
if (x + y) % 3 != 0:
print((0))
exit()
n = (x + y) // 3
x -= n
y -= n
if x < 0 or y < 0:
print((0))
exit()
fac = [1] * (n + 2)
inv = [1... | false | 0 | [
"-n = 10**6",
"-a = -(x - 2 * y) // 3",
"-b = (2 * x - y) // 3",
"-if a < 0 or b < 0:",
"+n = (x + y) // 3",
"+x -= n",
"+y -= n",
"+if x < 0 or y < 0:",
"-print((comb(a + b, a) % mod))",
"+print((comb(x + y, x) % mod))"
] | false | 0.481623 | 0.130945 | 3.678044 | [
"s200943151",
"s124928931"
] |
u562935282 | p03325 | python | s348407682 | s017715481 | 129 | 79 | 4,148 | 4,148 | Accepted | Accepted | 38.76 | n = int(eval(input()))
a = list(map(int, input().split()))
cnt = 0
for x in a:
while x % 2 == 0:
cnt += 1
x /= 2
print(cnt)
| n = int(eval(input()))
a = list(map(int, input().split()))
cnt = 0
for x in a:
while x % 2 == 0:
x //= 2
cnt += 1
print(cnt) | 10 | 9 | 152 | 147 | n = int(eval(input()))
a = list(map(int, input().split()))
cnt = 0
for x in a:
while x % 2 == 0:
cnt += 1
x /= 2
print(cnt)
| n = int(eval(input()))
a = list(map(int, input().split()))
cnt = 0
for x in a:
while x % 2 == 0:
x //= 2
cnt += 1
print(cnt)
| false | 10 | [
"+ x //= 2",
"- x /= 2"
] | false | 0.043604 | 0.082068 | 0.531312 | [
"s348407682",
"s017715481"
] |
u285022453 | p03160 | python | s445646360 | s218875805 | 202 | 138 | 13,928 | 13,928 | Accepted | Accepted | 31.68 | # https://atcoder.jp/contests/dp/tasks/dp_a
n = int(eval(input()))
h = list(map(int, input().split()))
dp = [float('inf') for _ in range(n)]
dp[0] = 0
for i in range(0, n - 1):
dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
if i < n - 2:
dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i +... | n = int(eval(input()))
h = list(map(int, input().split()))
dp = [0] * n
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[n-1])) | 13 | 9 | 344 | 221 | # https://atcoder.jp/contests/dp/tasks/dp_a
n = int(eval(input()))
h = list(map(int, input().split()))
dp = [float("inf") for _ in range(n)]
dp[0] = 0
for i in range(0, n - 1):
dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
if i < n - 2:
dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))... | n = int(eval(input()))
h = list(map(int, input().split()))
dp = [0] * n
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[n - 1]))
| false | 30.769231 | [
"-# https://atcoder.jp/contests/dp/tasks/dp_a",
"-dp = [float(\"inf\") for _ in range(n)]",
"-dp[0] = 0",
"-for i in range(0, n - 1):",
"- dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))",
"- if i < n - 2:",
"- dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))",
"-print((d... | false | 0.036171 | 0.052874 | 0.684088 | [
"s445646360",
"s218875805"
] |
u045707160 | p02946 | python | s834001016 | s502720817 | 21 | 18 | 3,316 | 3,060 | Accepted | Accepted | 14.29 | K,X = map(int,input().split())
for i in range(X -K + 1,X + K):
print(i, end = " ")
| k,x = map(int,input().split())
ans = 0
for i in range(k*2-1):
ans = x-(k-1)+i
print(ans,' ',end='')
| 3 | 6 | 93 | 114 | K, X = map(int, input().split())
for i in range(X - K + 1, X + K):
print(i, end=" ")
| k, x = map(int, input().split())
ans = 0
for i in range(k * 2 - 1):
ans = x - (k - 1) + i
print(ans, " ", end="")
| false | 50 | [
"-K, X = map(int, input().split())",
"-for i in range(X - K + 1, X + K):",
"- print(i, end=\" \")",
"+k, x = map(int, input().split())",
"+ans = 0",
"+for i in range(k * 2 - 1):",
"+ ans = x - (k - 1) + i",
"+ print(ans, \" \", end=\"\")"
] | false | 0.10468 | 0.04428 | 2.364043 | [
"s834001016",
"s502720817"
] |
u905582793 | p03835 | python | s504162564 | s616948025 | 1,229 | 18 | 2,940 | 2,940 | Accepted | Accepted | 98.54 | k,s=list(map(int,input().split()))
ans = 0
for i in range(k+1):
for j in range(k+1):
if 0<=s-i-j<=k:
ans+=1
print(ans) | k,s=list(map(int,input().split()))
ans = 0
for i in range(k+1):
if k <=s-i<=2*k:
ans+= k*2-s+i+1
elif 0<=s-i<=k:
ans+= s-i+1
print(ans) | 7 | 8 | 130 | 148 | k, s = list(map(int, input().split()))
ans = 0
for i in range(k + 1):
for j in range(k + 1):
if 0 <= s - i - j <= k:
ans += 1
print(ans)
| k, s = list(map(int, input().split()))
ans = 0
for i in range(k + 1):
if k <= s - i <= 2 * k:
ans += k * 2 - s + i + 1
elif 0 <= s - i <= k:
ans += s - i + 1
print(ans)
| false | 12.5 | [
"- for j in range(k + 1):",
"- if 0 <= s - i - j <= k:",
"- ans += 1",
"+ if k <= s - i <= 2 * k:",
"+ ans += k * 2 - s + i + 1",
"+ elif 0 <= s - i <= k:",
"+ ans += s - i + 1"
] | false | 0.116972 | 0.047966 | 2.438646 | [
"s504162564",
"s616948025"
] |
u860002137 | p02861 | python | s172662438 | s018061995 | 440 | 292 | 8,052 | 13,832 | Accepted | Accepted | 33.64 | from itertools import permutations
N = int(eval(input()))
x = [0]*N
y = [0]*N
route = list(permutations(list(range(N))))
for i in range(N):
x[i], y[i] = list(map(int, input().split()))
ans = 0
for r in route:
for l in range(len(r)-1):
tmp = ((x[r[l]] - x[r[l+1]])**2 + (y[r[l]] - y[r[l+1]])... | from itertools import permutations
n = int(eval(input()))
xy = [list(map(int, input().split())) for _ in range(n)]
pattern = list(permutations(list(range(n))))
ans = 0
for p in pattern:
tmp = 0
for i in range(n - 1):
tmp += ((xy[p[i + 1]][0] - xy[p[i]][0])**2 +
(xy[p[i + 1... | 16 | 16 | 358 | 382 | from itertools import permutations
N = int(eval(input()))
x = [0] * N
y = [0] * N
route = list(permutations(list(range(N))))
for i in range(N):
x[i], y[i] = list(map(int, input().split()))
ans = 0
for r in route:
for l in range(len(r) - 1):
tmp = ((x[r[l]] - x[r[l + 1]]) ** 2 + (y[r[l]] - y[r[l + 1]]) ... | from itertools import permutations
n = int(eval(input()))
xy = [list(map(int, input().split())) for _ in range(n)]
pattern = list(permutations(list(range(n))))
ans = 0
for p in pattern:
tmp = 0
for i in range(n - 1):
tmp += (
(xy[p[i + 1]][0] - xy[p[i]][0]) ** 2 + (xy[p[i + 1]][1] - xy[p[i]... | false | 0 | [
"-N = int(eval(input()))",
"-x = [0] * N",
"-y = [0] * N",
"-route = list(permutations(list(range(N))))",
"-for i in range(N):",
"- x[i], y[i] = list(map(int, input().split()))",
"+n = int(eval(input()))",
"+xy = [list(map(int, input().split())) for _ in range(n)]",
"+pattern = list(permutations(... | false | 0.031481 | 0.038662 | 0.814258 | [
"s172662438",
"s018061995"
] |
u525065967 | p03354 | python | s571514396 | s776763690 | 764 | 667 | 54,848 | 54,880 | Accepted | Accepted | 12.7 | n,m = list(map(int, input().split()))
P = [0]+list(map(int, input().split()))
XY = list(list(map(int, input().split())) for _ in range(m))
G = [[] for _ in range(n+1)]
for x, y in XY:
G[x].append(y)
G[y].append(x)
# print(n,m)
# print(P)
# print(XY)
# print(G)
# for i in range(len(G)):#########
# ... | from collections import deque
n,m = list(map(int, input().split()))
P = [0]+list(map(int, input().split()))
XY = list(list(map(int, input().split())) for _ in range(m))
G = [[] for _ in range(n+1)]
for x, y in XY:
G[x].append(y)
G[y].append(x)
q = deque()
vis = [False]*(n+1)
ans = 0
for i in rang... | 43 | 27 | 1,055 | 643 | n, m = list(map(int, input().split()))
P = [0] + list(map(int, input().split()))
XY = list(list(map(int, input().split())) for _ in range(m))
G = [[] for _ in range(n + 1)]
for x, y in XY:
G[x].append(y)
G[y].append(x)
# print(n,m)
# print(P)
# print(XY)
# print(G)
# for i in range(len(G)):#########
# print... | from collections import deque
n, m = list(map(int, input().split()))
P = [0] + list(map(int, input().split()))
XY = list(list(map(int, input().split())) for _ in range(m))
G = [[] for _ in range(n + 1)]
for x, y in XY:
G[x].append(y)
G[y].append(x)
q = deque()
vis = [False] * (n + 1)
ans = 0
for i in range(1, ... | false | 37.209302 | [
"+from collections import deque",
"+",
"-# print(n,m)",
"-# print(P)",
"-# print(XY)",
"-# print(G)",
"-# for i in range(len(G)):#########",
"-# print(i, G[i])###############",
"-from collections import deque",
"-",
"- # print('i',i, 'G[i]',G[i])",
"- inc_x = set()",
"- inc_px =... | false | 0.046049 | 0.039226 | 1.173959 | [
"s571514396",
"s776763690"
] |
u984664611 | p03074 | python | s713762890 | s509993179 | 211 | 91 | 52,600 | 5,024 | Accepted | Accepted | 56.87 | import sys
n, k = list(map(int, input().split()))
s = [int(s) for s in list(eval(input()))]
count = 0
tmp = 1
c = []
ans = 0
for i in s:
if i == tmp:
count += 1
else:
c.append(count)
tmp = i
count = 1
c.append(count)
if s[-1] == 0:
c.append(0)
# kが十分大... | n, k = list(map(int, input().split()))
s = [int(s) for s in list(eval(input()))]
count = 0
tmp = 1
c = []
for i in s:
if i == tmp:
count += 1
else:
c.append(count)
tmp = i
count = 1
c.append(count)
if s[-1] == 0:
c.append(0)
if len(c) <= 2*k+1:
ans =... | 34 | 27 | 634 | 508 | import sys
n, k = list(map(int, input().split()))
s = [int(s) for s in list(eval(input()))]
count = 0
tmp = 1
c = []
ans = 0
for i in s:
if i == tmp:
count += 1
else:
c.append(count)
tmp = i
count = 1
c.append(count)
if s[-1] == 0:
c.append(0)
# kが十分大きいなら
if len(c) <= 2 * k ... | n, k = list(map(int, input().split()))
s = [int(s) for s in list(eval(input()))]
count = 0
tmp = 1
c = []
for i in s:
if i == tmp:
count += 1
else:
c.append(count)
tmp = i
count = 1
c.append(count)
if s[-1] == 0:
c.append(0)
if len(c) <= 2 * k + 1:
ans = sum(c)
else:
... | false | 20.588235 | [
"-import sys",
"-",
"-ans = 0",
"-# kが十分大きいなら",
"- print((sum(c)))",
"- sys.exit()",
"-# TLEしたから尺取りにしたい",
"-# for i in range(0, len(c)-2*k, 2):",
"-# ans = max(ans, sum(c[i:i+2*k+1]))",
"-ans = total = sum(c[: 2 * k + 1])",
"-for i in range(0, len(c) - 2 * k - 2, 2):",
"- total = ... | false | 0.036862 | 0.036178 | 1.018911 | [
"s713762890",
"s509993179"
] |
u747602774 | p02912 | python | s478941762 | s215426630 | 142 | 117 | 14,480 | 14,484 | Accepted | Accepted | 17.61 | import bisect
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
A.sort()
while M != 0:
x = bisect.bisect_left(A,A[-1]/2)
if N-x <= M:
M -= N-x
for i in range(x,N):
A[i] = A[i]/2
A.sort()
else:
for i in range(N-M,N):
... | #二分探索を使った解法
import bisect
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
A.sort()
while M != 0:
x = bisect.bisect_left(A,A[-1]//2)
if N-x <= M:
M -= N-x
for i in range(x,N):
A[i] = A[i]//2
A.sort()
else:
for i in range(N-M,N... | 19 | 20 | 388 | 394 | import bisect
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
while M != 0:
x = bisect.bisect_left(A, A[-1] / 2)
if N - x <= M:
M -= N - x
for i in range(x, N):
A[i] = A[i] / 2
A.sort()
else:
for i in range(N - M, N):
... | # 二分探索を使った解法
import bisect
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
while M != 0:
x = bisect.bisect_left(A, A[-1] // 2)
if N - x <= M:
M -= N - x
for i in range(x, N):
A[i] = A[i] // 2
A.sort()
else:
for i in range(N - M... | false | 5 | [
"+# 二分探索を使った解法",
"- x = bisect.bisect_left(A, A[-1] / 2)",
"+ x = bisect.bisect_left(A, A[-1] // 2)",
"- A[i] = A[i] / 2",
"+ A[i] = A[i] // 2",
"- A[i] = A[i] / 2",
"+ A[i] = A[i] // 2",
"-print((sum(map(int, A))))",
"+print((sum(A)))"
] | false | 0.052735 | 0.0524 | 1.006401 | [
"s478941762",
"s215426630"
] |
u433532588 | p03126 | python | s978068173 | s602393760 | 21 | 18 | 3,316 | 3,060 | Accepted | Accepted | 14.29 |
import collections
N, M = list(map(int, input().split()))
likes = []
for i in range(N):
x = list(map(int, input().split()))
_ = x.pop(0)
likes += x
col = collections.Counter(likes)
count = 0
for k, v in list(col.items()):
if v == N:
count += 1
print(count) |
n, m = list(map(int, input().split()))
likes = [0] * m
for i in range(n):
k, *a = list(map(int, input().split()))
for j in a:
likes[j-1] += 1
count = 0
for i in likes:
if i == n:
count += 1
print(count) | 17 | 15 | 294 | 237 | import collections
N, M = list(map(int, input().split()))
likes = []
for i in range(N):
x = list(map(int, input().split()))
_ = x.pop(0)
likes += x
col = collections.Counter(likes)
count = 0
for k, v in list(col.items()):
if v == N:
count += 1
print(count)
| n, m = list(map(int, input().split()))
likes = [0] * m
for i in range(n):
k, *a = list(map(int, input().split()))
for j in a:
likes[j - 1] += 1
count = 0
for i in likes:
if i == n:
count += 1
print(count)
| false | 11.764706 | [
"-import collections",
"-",
"-N, M = list(map(int, input().split()))",
"-likes = []",
"-for i in range(N):",
"- x = list(map(int, input().split()))",
"- _ = x.pop(0)",
"- likes += x",
"-col = collections.Counter(likes)",
"+n, m = list(map(int, input().split()))",
"+likes = [0] * m",
"... | false | 0.038312 | 0.038075 | 1.006231 | [
"s978068173",
"s602393760"
] |
u346812984 | p03546 | python | s858539277 | s754831814 | 38 | 31 | 3,444 | 3,444 | Accepted | Accepted | 18.42 | import heapq
H, W = list(map(int, input().split()))
C = []
for _ in range(10):
c = list(map(int, input().split()))
C.append(c)
A = []
for _ in range(H):
a = list(map(int, input().split()))
A.append(a)
def dijkstra(start, goal, n, edge):
d = [float("inf")] * n
d[start] = 0
... | import sys
sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7
def input():
return sys.stdin.readline().strip()
def main():
H, W = list(map(int, input().split()))
C = []
for _ in range(10):
c = list(map(int, input().split()))
C.append(c)
A = []... | 46 | 48 | 913 | 983 | import heapq
H, W = list(map(int, input().split()))
C = []
for _ in range(10):
c = list(map(int, input().split()))
C.append(c)
A = []
for _ in range(H):
a = list(map(int, input().split()))
A.append(a)
def dijkstra(start, goal, n, edge):
d = [float("inf")] * n
d[start] = 0
q = [(0, start)]... | import sys
sys.setrecursionlimit(10**6)
INF = float("inf")
MOD = 10**9 + 7
def input():
return sys.stdin.readline().strip()
def main():
H, W = list(map(int, input().split()))
C = []
for _ in range(10):
c = list(map(int, input().split()))
C.append(c)
A = []
for _ in range(H):... | false | 4.166667 | [
"-import heapq",
"+import sys",
"-H, W = list(map(int, input().split()))",
"-C = []",
"-for _ in range(10):",
"- c = list(map(int, input().split()))",
"- C.append(c)",
"-A = []",
"-for _ in range(H):",
"- a = list(map(int, input().split()))",
"- A.append(a)",
"+sys.setrecursionlimi... | false | 0.047653 | 0.042863 | 1.111748 | [
"s858539277",
"s754831814"
] |
u642012866 | p03162 | python | s900869537 | s366319779 | 491 | 416 | 80,732 | 70,492 | Accepted | Accepted | 15.27 | import sys
input = sys.stdin.readline
N = int(eval(input()))
ABC = [list(map(int,input().split())) for i in range(N)]
dp = [[0]*3 for i in range(N+1)]
for i in range(1,N+1):
dp[i] = [max([dp[i-1][k]+ABC[i-1][j] for k in range(3) if j != k]) for j in range(3)]
print((max(dp[N]))) | import sys
input = sys.stdin.readline
N = int(eval(input()))
ABC = [list(map(int,input().split())) for i in range(N)]
dp = [0]*(N+1)
dp[0] = [0,0,0]
for i in range(1,N+1):
dp[i] = [max([dp[i-1][k]+ABC[i-1][j] for k in range(3) if j != k]) for j in range(3)]
print((max(dp[N]))) | 11 | 12 | 288 | 287 | import sys
input = sys.stdin.readline
N = int(eval(input()))
ABC = [list(map(int, input().split())) for i in range(N)]
dp = [[0] * 3 for i in range(N + 1)]
for i in range(1, N + 1):
dp[i] = [
max([dp[i - 1][k] + ABC[i - 1][j] for k in range(3) if j != k])
for j in range(3)
]
print((max(dp[N])))... | import sys
input = sys.stdin.readline
N = int(eval(input()))
ABC = [list(map(int, input().split())) for i in range(N)]
dp = [0] * (N + 1)
dp[0] = [0, 0, 0]
for i in range(1, N + 1):
dp[i] = [
max([dp[i - 1][k] + ABC[i - 1][j] for k in range(3) if j != k])
for j in range(3)
]
print((max(dp[N])))... | false | 8.333333 | [
"-dp = [[0] * 3 for i in range(N + 1)]",
"+dp = [0] * (N + 1)",
"+dp[0] = [0, 0, 0]"
] | false | 0.03873 | 0.044985 | 0.860966 | [
"s900869537",
"s366319779"
] |
u867826040 | p02603 | python | s286464480 | s984583202 | 37 | 30 | 9,184 | 9,204 | Accepted | Accepted | 18.92 | n = int(eval(input()))
a = list(map(int,input().split()))
m = 1000
kabu = 0
for i in range(n-1):
if a[i] < a[i+1]:
kabu += m//a[i]
m -= (m//a[i])*a[i]
else:
m += a[i]*kabu
kabu = 0
print((m+kabu*a[-1])) | n = int(eval(input()))
a = list(map(int,input().split()))
m = 1000
kabu = 0
for i in range(n-1):
if a[i] < a[i+1]:
x = m//a[i]
kabu += x
m -= x*a[i]
else:
m += kabu*a[i]
kabu = 0
print((m+(kabu*a[-1]))) | 12 | 14 | 245 | 256 | n = int(eval(input()))
a = list(map(int, input().split()))
m = 1000
kabu = 0
for i in range(n - 1):
if a[i] < a[i + 1]:
kabu += m // a[i]
m -= (m // a[i]) * a[i]
else:
m += a[i] * kabu
kabu = 0
print((m + kabu * a[-1]))
| n = int(eval(input()))
a = list(map(int, input().split()))
m = 1000
kabu = 0
for i in range(n - 1):
if a[i] < a[i + 1]:
x = m // a[i]
kabu += x
m -= x * a[i]
else:
m += kabu * a[i]
kabu = 0
print((m + (kabu * a[-1])))
| false | 14.285714 | [
"- kabu += m // a[i]",
"- m -= (m // a[i]) * a[i]",
"+ x = m // a[i]",
"+ kabu += x",
"+ m -= x * a[i]",
"- m += a[i] * kabu",
"+ m += kabu * a[i]",
"-print((m + kabu * a[-1]))",
"+print((m + (kabu * a[-1])))"
] | false | 0.035776 | 0.036086 | 0.991414 | [
"s286464480",
"s984583202"
] |
u777283665 | p03293 | python | s970214465 | s500349994 | 20 | 17 | 3,064 | 3,064 | Accepted | Accepted | 15 | s = eval(input())
t = eval(input())
for i in range(len(s)):
if s[i:]+s[:i] == t:
print("Yes")
exit()
print("No") | s, t = eval(input()), eval(input())
cnt = 0
while cnt <= len(s):
s = s[-1] + s[:-1]
if s == t:
print("Yes")
exit()
cnt+=1
print("No") | 9 | 10 | 130 | 160 | s = eval(input())
t = eval(input())
for i in range(len(s)):
if s[i:] + s[:i] == t:
print("Yes")
exit()
print("No")
| s, t = eval(input()), eval(input())
cnt = 0
while cnt <= len(s):
s = s[-1] + s[:-1]
if s == t:
print("Yes")
exit()
cnt += 1
print("No")
| false | 10 | [
"-s = eval(input())",
"-t = eval(input())",
"-for i in range(len(s)):",
"- if s[i:] + s[:i] == t:",
"+s, t = eval(input()), eval(input())",
"+cnt = 0",
"+while cnt <= len(s):",
"+ s = s[-1] + s[:-1]",
"+ if s == t:",
"+ cnt += 1"
] | false | 0.04689 | 0.04737 | 0.989858 | [
"s970214465",
"s500349994"
] |
u488401358 | p02947 | python | s783721162 | s828042452 | 1,332 | 475 | 38,732 | 24,652 | Accepted | Accepted | 64.34 | def letternumber(S):
alphabet=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
s=[0 for i in range(0,26)]
for i in range(0,10):
s[alphabet.index(S[i])]+=1
return s
def main():
N=int(eval(input()))
r=[]
for i in range... |
def main():
N=int(eval(input()))
r=[]
for i in range(0,N):
r.append(sorted(eval(input())))
r.sort()
s=1
ans=0
for i in range(0,N-1):
if r[i]==r[i+1]:
s=s+1
else:
ans+=s*(s-1)//2
s=1
print((ans+s*(s-1)//2))
i... | 25 | 20 | 598 | 344 | def letternumber(S):
alphabet = [
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"... | def main():
N = int(eval(input()))
r = []
for i in range(0, N):
r.append(sorted(eval(input())))
r.sort()
s = 1
ans = 0
for i in range(0, N - 1):
if r[i] == r[i + 1]:
s = s + 1
else:
ans += s * (s - 1) // 2
s = 1
print((ans + s *... | false | 20 | [
"-def letternumber(S):",
"- alphabet = [",
"- \"a\",",
"- \"b\",",
"- \"c\",",
"- \"d\",",
"- \"e\",",
"- \"f\",",
"- \"g\",",
"- \"h\",",
"- \"i\",",
"- \"j\",",
"- \"k\",",
"- \"l\",",
"- \"m\... | false | 0.036926 | 0.037131 | 0.994484 | [
"s783721162",
"s828042452"
] |
u223646582 | p03215 | python | s731992812 | s178127786 | 1,407 | 145 | 28,848 | 112,708 | Accepted | Accepted | 89.69 | N, K = list(map(int, input().split()))
a = [int(i) for i in input().split()]
cand = []
for i in range(N):
sum = 0
for j in range(i, N):
sum += a[j]
cand.append(sum)
def countMask(a):
ret = 0
for x in cand:
if (x & a) == a:
ret += 1
return ret
... | import bisect
N, K = list(map(int, input().split()))
A = [int(i) for i in input().split()]
SA = [0]
for i in range(N):
SA.append(SA[-1]+A[i])
C = []
for i in range(N):
for j in range(i+1, N+1):
C.append(SA[j]-SA[i])
C.sort()
ans = 0
for i in range(41, -1, -1):
B = 1 << i
in... | 27 | 27 | 437 | 505 | N, K = list(map(int, input().split()))
a = [int(i) for i in input().split()]
cand = []
for i in range(N):
sum = 0
for j in range(i, N):
sum += a[j]
cand.append(sum)
def countMask(a):
ret = 0
for x in cand:
if (x & a) == a:
ret += 1
return ret
ans = 0
for i in ... | import bisect
N, K = list(map(int, input().split()))
A = [int(i) for i in input().split()]
SA = [0]
for i in range(N):
SA.append(SA[-1] + A[i])
C = []
for i in range(N):
for j in range(i + 1, N + 1):
C.append(SA[j] - SA[i])
C.sort()
ans = 0
for i in range(41, -1, -1):
B = 1 << i
ind = bisect.bi... | false | 0 | [
"+import bisect",
"+",
"-a = [int(i) for i in input().split()]",
"-cand = []",
"+A = [int(i) for i in input().split()]",
"+SA = [0]",
"- sum = 0",
"- for j in range(i, N):",
"- sum += a[j]",
"- cand.append(sum)",
"-",
"-",
"-def countMask(a):",
"- ret = 0",
"- f... | false | 0.042079 | 0.04392 | 0.958083 | [
"s731992812",
"s178127786"
] |
u316401642 | p02994 | python | s670399197 | s858606580 | 20 | 17 | 3,064 | 3,060 | Accepted | Accepted | 15 | N, L = list(map(int,input().split()))
a = L - 1
b = [a + i for i in range(1, N+1)]
s = sum(b)
if 0 in b:
print(s)
elif s > 0:
print((s - min(b)))
else:
print((s - max(b))) | N, L = list(map(int,input().split()))
b = [L -1 + i for i in range(1, N+1)]
s = sum(b)
if 0 in b:
print(s)
elif s > 0:
print((s - min(b)))
else:
print((s - max(b))) | 11 | 10 | 190 | 182 | N, L = list(map(int, input().split()))
a = L - 1
b = [a + i for i in range(1, N + 1)]
s = sum(b)
if 0 in b:
print(s)
elif s > 0:
print((s - min(b)))
else:
print((s - max(b)))
| N, L = list(map(int, input().split()))
b = [L - 1 + i for i in range(1, N + 1)]
s = sum(b)
if 0 in b:
print(s)
elif s > 0:
print((s - min(b)))
else:
print((s - max(b)))
| false | 9.090909 | [
"-a = L - 1",
"-b = [a + i for i in range(1, N + 1)]",
"+b = [L - 1 + i for i in range(1, N + 1)]"
] | false | 0.046051 | 0.046542 | 0.989452 | [
"s670399197",
"s858606580"
] |
u670567845 | p04005 | python | s200069922 | s214550524 | 71 | 29 | 61,832 | 9,044 | Accepted | Accepted | 59.15 | A, B, C = list(map(int, input().split()))
def diff(x,n, m):
if x%2 == 0:
return 0
if x%2 == 1:
return m*n
print((min([diff(A,B,C), diff(B,C,A), diff(C,A,B)]))) | A, B, C = list(map(int, input().split()))
ans = 0
if A%2 == 0 or B%2 == 0 or C%2 ==0:
ans = 0
else:
ans = min([A*B,B*C,C*A])
print(ans) | 7 | 7 | 169 | 139 | A, B, C = list(map(int, input().split()))
def diff(x, n, m):
if x % 2 == 0:
return 0
if x % 2 == 1:
return m * n
print((min([diff(A, B, C), diff(B, C, A), diff(C, A, B)])))
| A, B, C = list(map(int, input().split()))
ans = 0
if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
ans = 0
else:
ans = min([A * B, B * C, C * A])
print(ans)
| false | 0 | [
"-",
"-",
"-def diff(x, n, m):",
"- if x % 2 == 0:",
"- return 0",
"- if x % 2 == 1:",
"- return m * n",
"-",
"-",
"-print((min([diff(A, B, C), diff(B, C, A), diff(C, A, B)])))",
"+ans = 0",
"+if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:",
"+ ans = 0",
"+else:",
"+ ... | false | 0.052226 | 0.052815 | 0.988843 | [
"s200069922",
"s214550524"
] |
u532966492 | p03430 | python | s057741973 | s787595210 | 1,162 | 982 | 154,076 | 154,076 | Accepted | Accepted | 15.49 | def main():
s = eval(input())
n = len(s)
k = int(eval(input()))
# dp[使った回数][左端からの距離][左端]
dp = [[[1]*(n-i) for i in range(n)] for _ in range(k+1)]
for i in range(n-1):
if s[i] == s[i+1]:
dp[0][1][i] = 2
if k > 0:
for cnt in range(1, k+1):
f... | def main():
s = eval(input())
n = len(s)
k = int(eval(input()))
# dp[使った回数][左端からの距離][左端]
dp = [[[1]*(n-i) for i in range(n)] for _ in range(k+1)]
if n == 1:
print((1))
return
dp2 = dp[0][1]
for i in range(n-1):
if s[i] == s[i+1]:
dp2[i] =... | 35 | 44 | 1,135 | 1,259 | def main():
s = eval(input())
n = len(s)
k = int(eval(input()))
# dp[使った回数][左端からの距離][左端]
dp = [[[1] * (n - i) for i in range(n)] for _ in range(k + 1)]
for i in range(n - 1):
if s[i] == s[i + 1]:
dp[0][1][i] = 2
if k > 0:
for cnt in range(1, k + 1):
fo... | def main():
s = eval(input())
n = len(s)
k = int(eval(input()))
# dp[使った回数][左端からの距離][左端]
dp = [[[1] * (n - i) for i in range(n)] for _ in range(k + 1)]
if n == 1:
print((1))
return
dp2 = dp[0][1]
for i in range(n - 1):
if s[i] == s[i + 1]:
dp2[i] = 2
... | false | 20.454545 | [
"+ if n == 1:",
"+ print((1))",
"+ return",
"+ dp2 = dp[0][1]",
"- dp[0][1][i] = 2",
"+ dp2[i] = 2",
"+ dp2 = dp[cnt][1]",
"- dp[cnt][1][i] = 2",
"+ dp2[i] = 2",
"+ dp2 = dp[cnt]",
"+ dp3 = dp2[d... | false | 0.063665 | 0.036025 | 1.767238 | [
"s057741973",
"s787595210"
] |
u094191970 | p03006 | python | s644414309 | s739539322 | 187 | 109 | 9,224 | 9,148 | Accepted | Accepted | 41.71 | from sys import stdin
nii=lambda:list(map(int,stdin.readline().split()))
lnii=lambda:list(map(int,stdin.readline().split()))
n=int(eval(input()))
xy=[lnii() for i in range(n)]
xy.sort(key=lambda x:x[0])
ans=n
pq=[]
for i in range(n):
for j in range(n):
if i==j:
continue
t_p=xy[j][0]-xy... | from sys import stdin
nii=lambda:list(map(int,stdin.readline().split()))
lnii=lambda:list(map(int,stdin.readline().split()))
n=int(eval(input()))
xy=[lnii() for i in range(n)]
xy.sort(key=lambda x:x[0])
ans=n
pq=[]
for i in range(n-1):
for j in range(i+1,n):
t_p=xy[j][0]-xy[i][0]
t_q=xy[j][1]... | 27 | 25 | 489 | 465 | from sys import stdin
nii = lambda: list(map(int, stdin.readline().split()))
lnii = lambda: list(map(int, stdin.readline().split()))
n = int(eval(input()))
xy = [lnii() for i in range(n)]
xy.sort(key=lambda x: x[0])
ans = n
pq = []
for i in range(n):
for j in range(n):
if i == j:
continue
... | from sys import stdin
nii = lambda: list(map(int, stdin.readline().split()))
lnii = lambda: list(map(int, stdin.readline().split()))
n = int(eval(input()))
xy = [lnii() for i in range(n)]
xy.sort(key=lambda x: x[0])
ans = n
pq = []
for i in range(n - 1):
for j in range(i + 1, n):
t_p = xy[j][0] - xy[i][0]
... | false | 7.407407 | [
"-for i in range(n):",
"- for j in range(n):",
"- if i == j:",
"- continue",
"+for i in range(n - 1):",
"+ for j in range(i + 1, n):"
] | false | 0.036729 | 0.042188 | 0.870586 | [
"s644414309",
"s739539322"
] |
u562935282 | p02984 | python | s687926597 | s838406199 | 278 | 122 | 72,932 | 14,864 | Accepted | Accepted | 56.12 | N = int(eval(input()))
a = tuple(map(int, input().split()))
ans = []
t = 0
for i, aa in enumerate(a):
if i % 2 == 0:
t += aa
else:
t -= aa
ans.append(t)
s = t // 2
for i, aa in enumerate(a[:-1]):
# print(aa, '-', s)
s = aa - s
# print(s, end='')
ans.append(s * ... | def main():
from itertools import cycle
from operator import add, sub
N = int(eval(input()))
*A, = list(map(int, input().split()))
cycl_oper = cycle((add, sub))
M0 = 0 # 山0(0-ind)への降雨量
for op, x in zip(cycl_oper, A):
M0 = op(M0, x)
ans = [0] * N
ans[0] = M0... | 20 | 23 | 348 | 443 | N = int(eval(input()))
a = tuple(map(int, input().split()))
ans = []
t = 0
for i, aa in enumerate(a):
if i % 2 == 0:
t += aa
else:
t -= aa
ans.append(t)
s = t // 2
for i, aa in enumerate(a[:-1]):
# print(aa, '-', s)
s = aa - s
# print(s, end='')
ans.append(s * 2)
# print(ans)... | def main():
from itertools import cycle
from operator import add, sub
N = int(eval(input()))
(*A,) = list(map(int, input().split()))
cycl_oper = cycle((add, sub))
M0 = 0 # 山0(0-ind)への降雨量
for op, x in zip(cycl_oper, A):
M0 = op(M0, x)
ans = [0] * N
ans[0] = M0
for i in r... | false | 13.043478 | [
"-N = int(eval(input()))",
"-a = tuple(map(int, input().split()))",
"-ans = []",
"-t = 0",
"-for i, aa in enumerate(a):",
"- if i % 2 == 0:",
"- t += aa",
"- else:",
"- t -= aa",
"-ans.append(t)",
"-s = t // 2",
"-for i, aa in enumerate(a[:-1]):",
"- # print(aa, '-', s... | false | 0.045635 | 0.104034 | 0.438656 | [
"s687926597",
"s838406199"
] |
u623819879 | p02745 | python | s464263996 | s133126478 | 885 | 811 | 52,060 | 47,836 | Accepted | Accepted | 8.36 | def chk(a,b):
A,B=len(a),len(b)
rt=[0]*A
for i in range(A):
f=1
for j in range(min(A-i,B)):
if len(set([a[i+j],b[j],'?']))>2:f=0;break
rt[i]=f
return rt+[1]
def tri_chk(ix):
i1,i2,i3=ix
ab,bc,ac=M[i1][i2],M[i2][i3],M[i1][i3]
A,B,C=list(map(le... | def F(a,b):
A,B=len(a),len(b)
r=[0]*A
for i in range(A):
f=1
for j in range(min(A-i,B)):
if len(set([a[i+j],b[j],'?']))>2:f=0;break
r[i]=f
return r+[1]
def T(ix):
i1,i2,i3=ix;ab,bc,ac=M[i1][i2],M[i2][i3],M[i1][i3];A,B,C=list(map(len,[S[i]for i in ix]));q=A+B+C
for l in range(A+1):
if ab[l]!... | 31 | 19 | 784 | 605 | def chk(a, b):
A, B = len(a), len(b)
rt = [0] * A
for i in range(A):
f = 1
for j in range(min(A - i, B)):
if len(set([a[i + j], b[j], "?"])) > 2:
f = 0
break
rt[i] = f
return rt + [1]
def tri_chk(ix):
i1, i2, i3 = ix
ab, bc, a... | def F(a, b):
A, B = len(a), len(b)
r = [0] * A
for i in range(A):
f = 1
for j in range(min(A - i, B)):
if len(set([a[i + j], b[j], "?"])) > 2:
f = 0
break
r[i] = f
return r + [1]
def T(ix):
i1, i2, i3 = ix
ab, bc, ac = M[i1][i... | false | 38.709677 | [
"-def chk(a, b):",
"+def F(a, b):",
"- rt = [0] * A",
"+ r = [0] * A",
"- rt[i] = f",
"- return rt + [1]",
"+ r[i] = f",
"+ return r + [1]",
"-def tri_chk(ix):",
"+def T(ix):",
"- rt = A + B + C",
"+ q = A + B + C",
"- if ab[l] == 0:",
"- c... | false | 0.097725 | 0.086818 | 1.125635 | [
"s464263996",
"s133126478"
] |
u537976628 | p02712 | python | s102946949 | s783820960 | 283 | 158 | 178,964 | 9,076 | Accepted | Accepted | 44.17 | n = int(eval(input()))
us = set(i for i in range(1, n + 1))
m3 = set(i for i in range(3, n + 1, 3))
m5 = set(i for i in range(5, n + 1, 5))
print((sum(list(us - m3 - m5)))) | n = int(eval(input()))
sum = 0
for i in range(1, n + 1):
if i % 3 != 0 and i % 5 != 0:
sum += i
print(sum) | 5 | 6 | 168 | 117 | n = int(eval(input()))
us = set(i for i in range(1, n + 1))
m3 = set(i for i in range(3, n + 1, 3))
m5 = set(i for i in range(5, n + 1, 5))
print((sum(list(us - m3 - m5))))
| n = int(eval(input()))
sum = 0
for i in range(1, n + 1):
if i % 3 != 0 and i % 5 != 0:
sum += i
print(sum)
| false | 16.666667 | [
"-us = set(i for i in range(1, n + 1))",
"-m3 = set(i for i in range(3, n + 1, 3))",
"-m5 = set(i for i in range(5, n + 1, 5))",
"-print((sum(list(us - m3 - m5))))",
"+sum = 0",
"+for i in range(1, n + 1):",
"+ if i % 3 != 0 and i % 5 != 0:",
"+ sum += i",
"+print(sum)"
] | false | 0.164279 | 0.114221 | 1.438265 | [
"s102946949",
"s783820960"
] |
u489959379 | p03559 | python | s076878749 | s925719222 | 333 | 219 | 23,092 | 29,212 | Accepted | Accepted | 34.23 | import bisect
n = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
res = 0
for i in range(n):
index1 = bisect.bisect_left(a, b[i])
index2 = bisect.bisect_right(c, b[i])
res += index1 * (n - ind... | import sys
from bisect import bisect_left, bisect_right
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorte... | 14 | 25 | 333 | 548 | import bisect
n = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
res = 0
for i in range(n):
index1 = bisect.bisect_left(a, b[i])
index2 = bisect.bisect_right(c, b[i])
res += index1 * (n - index2)
print(r... | import sys
from bisect import bisect_left, bisect_right
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
n = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, i... | false | 44 | [
"-import bisect",
"+import sys",
"+from bisect import bisect_left, bisect_right",
"-n = int(eval(input()))",
"-a = sorted(list(map(int, input().split())))",
"-b = sorted(list(map(int, input().split())))",
"-c = sorted(list(map(int, input().split())))",
"-res = 0",
"-for i in range(n):",
"- inde... | false | 0.042046 | 0.047368 | 0.887649 | [
"s076878749",
"s925719222"
] |
u562935282 | p03162 | python | s829372326 | s586854799 | 642 | 339 | 59,628 | 53,996 | Accepted | Accepted | 47.2 | def main():
import sys
readline = sys.stdin.readline
n = int(readline())
dp = [[0] * 3 for _ in range(n + 1)]
for i in range(1, n + 1): # i日目の最大幸福度,1-indexed
a, b, c = list(map(int, input().split()))
dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a
dp[i][1] = max... | def main():
import sys
readline = sys.stdin.readline
n = int(readline())
dp = [[0] * 3 for _ in range(n + 1)]
for i in range(1, n + 1): # i日目の最大幸福度,1-indexed
a, b, c = list(map(int, readline().split()))
dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a
dp[i][1] = ... | 19 | 19 | 472 | 475 | def main():
import sys
readline = sys.stdin.readline
n = int(readline())
dp = [[0] * 3 for _ in range(n + 1)]
for i in range(1, n + 1): # i日目の最大幸福度,1-indexed
a, b, c = list(map(int, input().split()))
dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a
dp[i][1] = max(dp[i - 1][2]... | def main():
import sys
readline = sys.stdin.readline
n = int(readline())
dp = [[0] * 3 for _ in range(n + 1)]
for i in range(1, n + 1): # i日目の最大幸福度,1-indexed
a, b, c = list(map(int, readline().split()))
dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a
dp[i][1] = max(dp[i - 1]... | false | 0 | [
"- a, b, c = list(map(int, input().split()))",
"+ a, b, c = list(map(int, readline().split()))"
] | false | 0.069918 | 0.039415 | 1.773886 | [
"s829372326",
"s586854799"
] |
u620480037 | p03361 | python | s057740782 | s590983041 | 185 | 21 | 39,792 | 3,064 | Accepted | Accepted | 88.65 | H,W=list(map(int,input().split()))
L=[]
l=["." for i in range(W+2)]
L.append(l)
for i in range(H):
a=list(eval(input()))
a=["."]+a+["."]
L.append(a)
L.append(l)
#print(L)
X=[1,-1,0,0]
Y=[0,0,1,-1]
for i in range(1,H+1):
for j in range(1,W+1):
if L[i][j]=="#":
F=1... | H,W=list(map(int,input().split()))
L=[]
l=["." for i in range(W+2)]
L.append(l)
for i in range(H):
S=["."]+list(eval(input()))+["."]
L.append(S)
L.append(l)
#print(L)
X=[1,-1,0,0]
Y=[0,0,1,-1]
for h in range(1,H+1):
for w in range(1,W+1):
if L[h][w]=="#":
F=0
... | 27 | 23 | 517 | 485 | H, W = list(map(int, input().split()))
L = []
l = ["." for i in range(W + 2)]
L.append(l)
for i in range(H):
a = list(eval(input()))
a = ["."] + a + ["."]
L.append(a)
L.append(l)
# print(L)
X = [1, -1, 0, 0]
Y = [0, 0, 1, -1]
for i in range(1, H + 1):
for j in range(1, W + 1):
if L[i][j] == "#":... | H, W = list(map(int, input().split()))
L = []
l = ["." for i in range(W + 2)]
L.append(l)
for i in range(H):
S = ["."] + list(eval(input())) + ["."]
L.append(S)
L.append(l)
# print(L)
X = [1, -1, 0, 0]
Y = [0, 0, 1, -1]
for h in range(1, H + 1):
for w in range(1, W + 1):
if L[h][w] == "#":
... | false | 14.814815 | [
"- a = list(eval(input()))",
"- a = [\".\"] + a + [\".\"]",
"- L.append(a)",
"+ S = [\".\"] + list(eval(input())) + [\".\"]",
"+ L.append(S)",
"-for i in range(1, H + 1):",
"- for j in range(1, W + 1):",
"- if L[i][j] == \"#\":",
"- F = 1",
"- for k i... | false | 0.041691 | 0.033945 | 1.228183 | [
"s057740782",
"s590983041"
] |
u298224238 | p02267 | python | s956833463 | s712174206 | 50 | 20 | 6,552 | 6,552 | Accepted | Accepted | 60 | def linearSearch(key, list, N):
list[N] = key
i = 0
while list[i] != key:
i += 1
return int(i != N)
N1 = int(eval(input()))
arr1 = [int(n) for n in input().split()] + [0]
N2 = int(eval(input()))
arr2 = [int(n) for n in input().split()]
print((sum([linearSearch(key, arr1, N1) for ... | def linearSearch(key, list):
for e in list:
if key == e:
return 1
return 0
N1 = int(eval(input()))
arr1 = [int(n) for n in input().split()]
N2 = int(eval(input()))
arr2 = [int(n) for n in input().split()]
print((sum([linearSearch(key, arr1) for key in arr2])))
| 15 | 14 | 324 | 292 | def linearSearch(key, list, N):
list[N] = key
i = 0
while list[i] != key:
i += 1
return int(i != N)
N1 = int(eval(input()))
arr1 = [int(n) for n in input().split()] + [0]
N2 = int(eval(input()))
arr2 = [int(n) for n in input().split()]
print((sum([linearSearch(key, arr1, N1) for key in arr2]))... | def linearSearch(key, list):
for e in list:
if key == e:
return 1
return 0
N1 = int(eval(input()))
arr1 = [int(n) for n in input().split()]
N2 = int(eval(input()))
arr2 = [int(n) for n in input().split()]
print((sum([linearSearch(key, arr1) for key in arr2])))
| false | 6.666667 | [
"-def linearSearch(key, list, N):",
"- list[N] = key",
"- i = 0",
"- while list[i] != key:",
"- i += 1",
"- return int(i != N)",
"+def linearSearch(key, list):",
"+ for e in list:",
"+ if key == e:",
"+ return 1",
"+ return 0",
"-arr1 = [int(n) for n ... | false | 0.036825 | 0.036694 | 1.003576 | [
"s956833463",
"s712174206"
] |
u921518222 | p02972 | python | s401344352 | s220407721 | 843 | 366 | 75,240 | 77,916 | Accepted | Accepted | 56.58 | def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
divisors.sort()
return divisors
n = int(eval(input()))
a = list(map(int, input().split()))
box = ... | n = int(eval(input()))
*a, = list(map(int, input().split()))
ans = [0] * n
for i in range(n-1, -1, -1):
if not sum(ans[i::i+1]) % 2 == a[i]:
ans[i] = 1
print((sum(ans)))
print((*[i+1 for i in range(n) if ans[i] == 1]))
| 39 | 8 | 968 | 222 | def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
divisors.sort()
return divisors
n = int(eval(input()))
a = list(map(int, input().split()))
box = [0 for _ in... | n = int(eval(input()))
(*a,) = list(map(int, input().split()))
ans = [0] * n
for i in range(n - 1, -1, -1):
if not sum(ans[i :: i + 1]) % 2 == a[i]:
ans[i] = 1
print((sum(ans)))
print((*[i + 1 for i in range(n) if ans[i] == 1]))
| false | 79.487179 | [
"-def make_divisors(n):",
"- divisors = []",
"- for i in range(1, int(n**0.5) + 1):",
"- if n % i == 0:",
"- divisors.append(i)",
"- if i != n // i:",
"- divisors.append(n // i)",
"- divisors.sort()",
"- return divisors",
"-",
"-",
"-a = ... | false | 0.037496 | 0.060301 | 0.621808 | [
"s401344352",
"s220407721"
] |
u059940903 | p02714 | python | s046937328 | s454893798 | 552 | 128 | 68,400 | 73,644 | Accepted | Accepted | 76.81 | N = int(eval(input()))
S = eval(input())
bad_list = ['RGB', 'RBG', 'GRB', 'GBR', 'BRG', 'BGR']
res = S.count("R") * S.count("G") * S.count("B")
for (i, s) in enumerate(S):
for j in range(((i+1)//2)+1)[1:]:
if S[i::-j][:3] in bad_list:
res -= 1
print(res) | N = int(eval(input()))
S = eval(input())
res = S.count("R") * S.count("G") * S.count("B")
for i in range(N):
for j in range(N)[i:]:
k = 2*j-i
if N <= k:
break
if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
res -= 1
print(res) | 13 | 13 | 272 | 257 | N = int(eval(input()))
S = eval(input())
bad_list = ["RGB", "RBG", "GRB", "GBR", "BRG", "BGR"]
res = S.count("R") * S.count("G") * S.count("B")
for (i, s) in enumerate(S):
for j in range(((i + 1) // 2) + 1)[1:]:
if S[i::-j][:3] in bad_list:
res -= 1
print(res)
| N = int(eval(input()))
S = eval(input())
res = S.count("R") * S.count("G") * S.count("B")
for i in range(N):
for j in range(N)[i:]:
k = 2 * j - i
if N <= k:
break
if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
res -= 1
print(res)
| false | 0 | [
"-bad_list = [\"RGB\", \"RBG\", \"GRB\", \"GBR\", \"BRG\", \"BGR\"]",
"-for (i, s) in enumerate(S):",
"- for j in range(((i + 1) // 2) + 1)[1:]:",
"- if S[i::-j][:3] in bad_list:",
"+for i in range(N):",
"+ for j in range(N)[i:]:",
"+ k = 2 * j - i",
"+ if N <= k:",
"+ ... | false | 0.036821 | 0.035904 | 1.025534 | [
"s046937328",
"s454893798"
] |
u226108478 | p03804 | python | s674702518 | s273705570 | 32 | 18 | 3,064 | 3,060 | Accepted | Accepted | 43.75 | # -*- coding: utf-8 -*-
# AtCoder Beginner Contest
# Problem B
if __name__ == '__main__':
n, m = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(n)]
b = [list(eval(input())) for _ in range(m)]
for i in range(n - m + 1):
for j in range(n - m + 1):
... | # -*- coding: utf-8 -*-
# AtCoder Beginner Contest
# Problem B
if __name__ == '__main__':
n, m = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(n)]
b = [list(eval(input())) for _ in range(m)]
for i in range(n - m + 1):
for j in range(n - m + 1):
... | 26 | 27 | 630 | 673 | # -*- coding: utf-8 -*-
# AtCoder Beginner Contest
# Problem B
if __name__ == "__main__":
n, m = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(n)]
b = [list(eval(input())) for _ in range(m)]
for i in range(n - m + 1):
for j in range(n - m + 1):
is_exist = Tr... | # -*- coding: utf-8 -*-
# AtCoder Beginner Contest
# Problem B
if __name__ == "__main__":
n, m = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(n)]
b = [list(eval(input())) for _ in range(m)]
for i in range(n - m + 1):
for j in range(n - m + 1):
is_exist = Tr... | false | 3.703704 | [
"+ # See:",
"+ # https://beta.atcoder.jp/contests/abc054/submissions/1103264",
"- for dy in range(m):",
"- if a[i + dx][j + dy] != b[dx][dy]:",
"- is_exist = False",
"- break",
"+ if a[i ... | false | 0.039436 | 0.043876 | 0.898804 | [
"s674702518",
"s273705570"
] |
u398846051 | p03767 | python | s760348611 | s788224718 | 264 | 226 | 37,084 | 37,084 | Accepted | Accepted | 14.39 | N = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(N, len(a), 2):
ans += a[i]
print(ans) | N = int(eval(input()))
print((sum(sorted(map(int, input().split()))[N:3*N:2]))) | 7 | 2 | 132 | 72 | N = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(N, len(a), 2):
ans += a[i]
print(ans)
| N = int(eval(input()))
print((sum(sorted(map(int, input().split()))[N : 3 * N : 2])))
| false | 71.428571 | [
"-a = list(map(int, input().split()))",
"-a.sort()",
"-ans = 0",
"-for i in range(N, len(a), 2):",
"- ans += a[i]",
"-print(ans)",
"+print((sum(sorted(map(int, input().split()))[N : 3 * N : 2])))"
] | false | 0.037654 | 0.038053 | 0.989495 | [
"s760348611",
"s788224718"
] |
u197615397 | p02261 | python | s538161411 | s645229775 | 30 | 20 | 7,800 | 5,616 | Accepted | Accepted | 33.33 | N = int(eval(input()))
a = [(s[0], int(s[1])) for s in input().split()]
def bubble(a):
n = len(a)
for i in range(n):
for j in range(n-1, i, -1):
if a[j][1] < a[j-1][1]:
a[j], a[j-1] = a[j-1], a[j]
return a
def selection(a):
n = len(a)
for i in range... | def bubble_sort(a, n):
for i in range(n-1):
for j in range(n-1, i, -1):
if a[j-1][1] > a[j][1]:
a[j-1], a[j] = a[j], a[j-1]
return a
def selection_sort(a, n):
for i in range(n-1):
min_j = i
for j in range(i+1, n):
if a[min_j][1]... | 29 | 31 | 695 | 724 | N = int(eval(input()))
a = [(s[0], int(s[1])) for s in input().split()]
def bubble(a):
n = len(a)
for i in range(n):
for j in range(n - 1, i, -1):
if a[j][1] < a[j - 1][1]:
a[j], a[j - 1] = a[j - 1], a[j]
return a
def selection(a):
n = len(a)
for i in range(n)... | def bubble_sort(a, n):
for i in range(n - 1):
for j in range(n - 1, i, -1):
if a[j - 1][1] > a[j][1]:
a[j - 1], a[j] = a[j], a[j - 1]
return a
def selection_sort(a, n):
for i in range(n - 1):
min_j = i
for j in range(i + 1, n):
if a[min_j][1]... | false | 6.451613 | [
"-N = int(eval(input()))",
"-a = [(s[0], int(s[1])) for s in input().split()]",
"-",
"-",
"-def bubble(a):",
"- n = len(a)",
"- for i in range(n):",
"+def bubble_sort(a, n):",
"+ for i in range(n - 1):",
"- if a[j][1] < a[j - 1][1]:",
"- a[j], a[j - 1] = a[j - ... | false | 0.041415 | 0.041192 | 1.005414 | [
"s538161411",
"s645229775"
] |
u573754721 | p02936 | python | s006896277 | s585272496 | 1,926 | 1,776 | 105,236 | 105,236 | Accepted | Accepted | 7.79 | from collections import deque
n,q=list(map(int,input().split()))
L=[[]for _ in range(n)]
V=[False]*n
P=[0]*n
for i in range(n-1):
a,b=list(map(int,input().split()))
L[a-1].append(b-1)
L[b-1].append(a-1)
for i in range(q):
p,x=list(map(int,input().split()))
P[p-1]+=x
que=deque([0])
while que:... | from collections import deque
n,q=list(map(int,input().split()))
K=[[]for _ in range(n)]
P=[0]*n
V=[False]*n
for i in range(n-1):
a,b=list(map(int,input().split()))
K[a-1].append(b-1)
K[b-1].append(a-1)
for i in range(q):
p,x=list(map(int,input().split()))
P[p-1]+=x
que=deque([0])
while que:... | 21 | 21 | 443 | 438 | from collections import deque
n, q = list(map(int, input().split()))
L = [[] for _ in range(n)]
V = [False] * n
P = [0] * n
for i in range(n - 1):
a, b = list(map(int, input().split()))
L[a - 1].append(b - 1)
L[b - 1].append(a - 1)
for i in range(q):
p, x = list(map(int, input().split()))
P[p - 1] ... | from collections import deque
n, q = list(map(int, input().split()))
K = [[] for _ in range(n)]
P = [0] * n
V = [False] * n
for i in range(n - 1):
a, b = list(map(int, input().split()))
K[a - 1].append(b - 1)
K[b - 1].append(a - 1)
for i in range(q):
p, x = list(map(int, input().split()))
P[p - 1] ... | false | 0 | [
"-L = [[] for _ in range(n)]",
"+K = [[] for _ in range(n)]",
"+P = [0] * n",
"-P = [0] * n",
"- L[a - 1].append(b - 1)",
"- L[b - 1].append(a - 1)",
"+ K[a - 1].append(b - 1)",
"+ K[b - 1].append(a - 1)",
"- for ni in L[s]:",
"+ for ni in K[s]:"
] | false | 0.046392 | 0.043983 | 1.054776 | [
"s006896277",
"s585272496"
] |
u367701763 | p02955 | python | s702407409 | s062747770 | 266 | 64 | 27,240 | 66,124 | Accepted | Accepted | 75.94 | def max2(x,y):
return x if x > y else y
def divisors(n):
i = 1
table = set()
while i * i <= n:
if not n % i:
table.add(i)
table.add(n//i)
i += 1
table = list(table)
return table
import numpy as np
import sys
input = sys.stdin.readline
... | def divisors(n):
i = 1
table = set()
while i * i <= n:
if not n % i:
table.add(i)
table.add(n//i)
i += 1
table = list(table)
return table
def binary_search_int(ok, ng, test):
"""
:param ok: solve(x) = True を必ず満たす点
:param ng: solve(x)... | 32 | 45 | 586 | 936 | def max2(x, y):
return x if x > y else y
def divisors(n):
i = 1
table = set()
while i * i <= n:
if not n % i:
table.add(i)
table.add(n // i)
i += 1
table = list(table)
return table
import numpy as np
import sys
input = sys.stdin.readline
N, K = list(m... | def divisors(n):
i = 1
table = set()
while i * i <= n:
if not n % i:
table.add(i)
table.add(n // i)
i += 1
table = list(table)
return table
def binary_search_int(ok, ng, test):
"""
:param ok: solve(x) = True を必ず満たす点
:param ng: solve(x) = False を必... | false | 28.888889 | [
"-def max2(x, y):",
"- return x if x > y else y",
"-",
"-",
"-import numpy as np",
"+def binary_search_int(ok, ng, test):",
"+ \"\"\"",
"+ :param ok: solve(x) = True を必ず満たす点",
"+ :param ng: solve(x) = False を必ず満たす点",
"+ \"\"\"",
"+ while abs(ok - ng) > 1:",
"+ mid = (o... | false | 0.334852 | 0.041264 | 8.114914 | [
"s702407409",
"s062747770"
] |
u899975427 | p03592 | python | s523120265 | s168961164 | 313 | 17 | 2,940 | 3,060 | Accepted | Accepted | 94.57 | n,m,k = list(map(int,input().split()))
for i in range(m+1):
for j in range(n+1):
if n*i + m*j - 2*i*j == k:
print('Yes')
exit()
print('No') | n,m,k = list(map(int,input().split()))
for i in range(m+1):
a = k - i * n
b = m - 2 * i
if b != 0 and a % b == 0 and 0 <= a // b <= n:
print('Yes')
exit()
print('No') | 8 | 9 | 159 | 197 | n, m, k = list(map(int, input().split()))
for i in range(m + 1):
for j in range(n + 1):
if n * i + m * j - 2 * i * j == k:
print("Yes")
exit()
print("No")
| n, m, k = list(map(int, input().split()))
for i in range(m + 1):
a = k - i * n
b = m - 2 * i
if b != 0 and a % b == 0 and 0 <= a // b <= n:
print("Yes")
exit()
print("No")
| false | 11.111111 | [
"- for j in range(n + 1):",
"- if n * i + m * j - 2 * i * j == k:",
"- print(\"Yes\")",
"- exit()",
"+ a = k - i * n",
"+ b = m - 2 * i",
"+ if b != 0 and a % b == 0 and 0 <= a // b <= n:",
"+ print(\"Yes\")",
"+ exit()"
] | false | 0.072484 | 0.035407 | 2.047149 | [
"s523120265",
"s168961164"
] |
u806855121 | p03266 | python | s893132474 | s943206007 | 83 | 17 | 3,060 | 2,940 | Accepted | Accepted | 79.52 | N, K = list(map(int, input().split()))
if K % 2 == 0:
c1 = 0
c2 = 0
for i in range(1, N+1):
if i % K == K//2:
c2 += 1
if i % K == 0:
c1 += 1
print((c1**3+c2**3))
else:
c = 0
for i in range(1, N+1):
if i % K == 0:
c += 1
... | N, K = list(map(int, input().split()))
c1 = N // K
if K % 2 == 1:
print((c1**3))
else:
c2 = (N+K//2)//K
print((c1**3+c2**3)) | 18 | 7 | 334 | 132 | N, K = list(map(int, input().split()))
if K % 2 == 0:
c1 = 0
c2 = 0
for i in range(1, N + 1):
if i % K == K // 2:
c2 += 1
if i % K == 0:
c1 += 1
print((c1**3 + c2**3))
else:
c = 0
for i in range(1, N + 1):
if i % K == 0:
c += 1
prin... | N, K = list(map(int, input().split()))
c1 = N // K
if K % 2 == 1:
print((c1**3))
else:
c2 = (N + K // 2) // K
print((c1**3 + c2**3))
| false | 61.111111 | [
"-if K % 2 == 0:",
"- c1 = 0",
"- c2 = 0",
"- for i in range(1, N + 1):",
"- if i % K == K // 2:",
"- c2 += 1",
"- if i % K == 0:",
"- c1 += 1",
"+c1 = N // K",
"+if K % 2 == 1:",
"+ print((c1**3))",
"+else:",
"+ c2 = (N + K // 2) // K",
"... | false | 0.039707 | 0.079794 | 0.497616 | [
"s893132474",
"s943206007"
] |
u493520238 | p02887 | python | s765842467 | s514137551 | 170 | 71 | 69,396 | 69,568 | Accepted | Accepted | 58.24 | n = int(eval(input()))
s = eval(input())
ans = 0
prev = ''
for si in s:
if prev == si:
continue
else:
ans += 1
prev = si
print(ans) | n = int(eval(input()))
s = eval(input())
ans = 0
prev = ''
for si in s:
if prev == si:
continue
ans += 1
prev = si
print(ans) | 13 | 12 | 165 | 146 | n = int(eval(input()))
s = eval(input())
ans = 0
prev = ""
for si in s:
if prev == si:
continue
else:
ans += 1
prev = si
print(ans)
| n = int(eval(input()))
s = eval(input())
ans = 0
prev = ""
for si in s:
if prev == si:
continue
ans += 1
prev = si
print(ans)
| false | 7.692308 | [
"- else:",
"- ans += 1",
"- prev = si",
"+ ans += 1",
"+ prev = si"
] | false | 0.036678 | 0.035897 | 1.021736 | [
"s765842467",
"s514137551"
] |
u859987056 | p03545 | python | s728153106 | s390180574 | 34 | 29 | 9,108 | 8,840 | Accepted | Accepted | 14.71 | s = eval(input())
def dfs(i,tmp,sum):
if i == 3:
if sum == 7:
print((tmp + "=7"))
exit()
else:
dfs(i+1, tmp +"+"+ s[i+1], sum + int(s[i+1]))
dfs(i+1, tmp +"-"+ s[i+1], sum - int(s[i+1]))
print((dfs(0,s[0],int(s[0])))) | s = eval(input())
for bit in range(1 << 3):
ans = s[0]
value = int(s[0])
for i in range(3):
if bit & (1 << i):
ans += "+" + s[i+1]
value += int(s[i+1])
else:
ans += "-" + s[i+1]
value -= int(s[i+1])
if value == 7:
... | 13 | 16 | 278 | 349 | s = eval(input())
def dfs(i, tmp, sum):
if i == 3:
if sum == 7:
print((tmp + "=7"))
exit()
else:
dfs(i + 1, tmp + "+" + s[i + 1], sum + int(s[i + 1]))
dfs(i + 1, tmp + "-" + s[i + 1], sum - int(s[i + 1]))
print((dfs(0, s[0], int(s[0]))))
| s = eval(input())
for bit in range(1 << 3):
ans = s[0]
value = int(s[0])
for i in range(3):
if bit & (1 << i):
ans += "+" + s[i + 1]
value += int(s[i + 1])
else:
ans += "-" + s[i + 1]
value -= int(s[i + 1])
if value == 7:
print((ans... | false | 18.75 | [
"-",
"-",
"-def dfs(i, tmp, sum):",
"- if i == 3:",
"- if sum == 7:",
"- print((tmp + \"=7\"))",
"- exit()",
"- else:",
"- dfs(i + 1, tmp + \"+\" + s[i + 1], sum + int(s[i + 1]))",
"- dfs(i + 1, tmp + \"-\" + s[i + 1], sum - int(s[i + 1]))",
"-",
... | false | 0.09514 | 0.044845 | 2.121543 | [
"s728153106",
"s390180574"
] |
u836737505 | p03971 | python | s433237678 | s354554561 | 298 | 116 | 52,952 | 4,016 | Accepted | Accepted | 61.07 | n, a, b = list(map(int, input().split()))
t, o = 0, 0
s = eval(input())
for i in range(n):
if s[i]=="a":
t += 1
if t <= a+b:
print("Yes")
else:
print("No")
elif s[i]=="b":
o += 1
if o <= b and t < a+b:
t += 1
p... | n,a,b = list(map(int, input().split()))
s = eval(input())
c = 0
d = 1
for i in range(n):
if s[i] == "a" and c <(a+b):
print("Yes")
c += 1
elif s[i] == "b" and c < (a+b) and d <= b:
print("Yes")
c += 1
d += 1
else:
print("No") | 19 | 14 | 391 | 287 | n, a, b = list(map(int, input().split()))
t, o = 0, 0
s = eval(input())
for i in range(n):
if s[i] == "a":
t += 1
if t <= a + b:
print("Yes")
else:
print("No")
elif s[i] == "b":
o += 1
if o <= b and t < a + b:
t += 1
print("... | n, a, b = list(map(int, input().split()))
s = eval(input())
c = 0
d = 1
for i in range(n):
if s[i] == "a" and c < (a + b):
print("Yes")
c += 1
elif s[i] == "b" and c < (a + b) and d <= b:
print("Yes")
c += 1
d += 1
else:
print("No")
| false | 26.315789 | [
"-t, o = 0, 0",
"+c = 0",
"+d = 1",
"- if s[i] == \"a\":",
"- t += 1",
"- if t <= a + b:",
"- print(\"Yes\")",
"- else:",
"- print(\"No\")",
"- elif s[i] == \"b\":",
"- o += 1",
"- if o <= b and t < a + b:",
"- t += 1"... | false | 0.040233 | 0.040134 | 1.002457 | [
"s433237678",
"s354554561"
] |
u919633157 | p03645 | python | s024893754 | s273608608 | 844 | 510 | 38,296 | 38,320 | Accepted | Accepted | 39.57 | # 2019/08/05
n,m=list(map(int,input().split()))
edge=[[] for _ in range(n)]
for i in range(m):
a,b=list(map(int,input().split()))
a-=1;b-=1
edge[a].append(b)
edge[b].append(a)
for e in edge[-1]:
if 0 in edge[e]:
print('POSSIBLE')
exit()
print('IMPOSSIBLE') | # 2019/08/05
input=open(0).readline
n,m=list(map(int,input().split()))
edge=[[] for _ in range(n)]
for i in range(m):
a,b=list(map(int,input().split()))
a-=1;b-=1
edge[a].append(b)
edge[b].append(a)
for e in edge[-1]:
if 0 in edge[e]:
print('POSSIBLE')
exit()
p... | 17 | 19 | 300 | 326 | # 2019/08/05
n, m = list(map(int, input().split()))
edge = [[] for _ in range(n)]
for i in range(m):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
edge[a].append(b)
edge[b].append(a)
for e in edge[-1]:
if 0 in edge[e]:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
| # 2019/08/05
input = open(0).readline
n, m = list(map(int, input().split()))
edge = [[] for _ in range(n)]
for i in range(m):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
edge[a].append(b)
edge[b].append(a)
for e in edge[-1]:
if 0 in edge[e]:
print("POSSIBLE")
exit()
prin... | false | 10.526316 | [
"+input = open(0).readline"
] | false | 0.043854 | 0.045855 | 0.95636 | [
"s024893754",
"s273608608"
] |
u674052742 | p02848 | python | s123754505 | s042241422 | 44 | 23 | 3,444 | 3,060 | Accepted | Accepted | 47.73 | # -*- coding: utf-8 -*-
"""
Created on Tue Mar 10 21:49:13 2020
@author: Kanaru Sato
"""
N = int(eval(input()))
s = eval(input())
dict = {'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8, 'I': 9, 'J': 10, 'K': 11, 'L': 12, 'M': 13, 'N': 14, 'O': 15, 'P': 16, 'Q': 17, 'R': 18, 'S': 19, 'T': 20... | # -*- coding: utf-8 -*-
"""
Created on Wed Mar 11 14:41:22 2020
@author: Kanaru Sato
"""
N = int(eval(input()))
s = list(eval(input()))
loop = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ"*2)
for i in range(len(s)):
s[i] = loop[loop.index(s[i])+N]
print(("".join(s))) | 23 | 16 | 630 | 265 | # -*- coding: utf-8 -*-
"""
Created on Tue Mar 10 21:49:13 2020
@author: Kanaru Sato
"""
N = int(eval(input()))
s = eval(input())
dict = {
"A": 1,
"B": 2,
"C": 3,
"D": 4,
"E": 5,
"F": 6,
"G": 7,
"H": 8,
"I": 9,
"J": 10,
"K": 11,
"L": 12,
"M": 13,
"N": 14,
"O":... | # -*- coding: utf-8 -*-
"""
Created on Wed Mar 11 14:41:22 2020
@author: Kanaru Sato
"""
N = int(eval(input()))
s = list(eval(input()))
loop = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ" * 2)
for i in range(len(s)):
s[i] = loop[loop.index(s[i]) + N]
print(("".join(s)))
| false | 30.434783 | [
"-Created on Tue Mar 10 21:49:13 2020",
"+Created on Wed Mar 11 14:41:22 2020",
"-s = eval(input())",
"-dict = {",
"- \"A\": 1,",
"- \"B\": 2,",
"- \"C\": 3,",
"- \"D\": 4,",
"- \"E\": 5,",
"- \"F\": 6,",
"- \"G\": 7,",
"- \"H\": 8,",
"- \"I\": 9,",
"- \"J\": ... | false | 0.046087 | 0.085732 | 0.537575 | [
"s123754505",
"s042241422"
] |
u794173881 | p03132 | python | s971185934 | s152012111 | 1,103 | 906 | 67,816 | 84,688 | Accepted | Accepted | 17.86 | l = int(eval(input()))
a = []
for i in range(l):
a.append(int(eval(input())))
dp=[[0]*5 for i in range(l+1)]
for i in range(0,l):
if a[i]==0:
even=2
else:
even=a[i]%2
dp[i+1][0]=dp[i][0]+a[i]
dp[i+1][1]=min(dp[i][0],dp[i][1]) + even
dp[i+1][2]=min(dp[i][0],dp[i][1],dp[i][2]) + ... | n = int(eval(input()))
a = [int(eval(input())) for i in range(n)]
# 0区間、偶数区間(2以上)、奇数区間、偶数区間(2以上)、0区間
dp = [[0] * (5) for i in range(n + 1)]
for i in range(n):
dp[i + 1][0] = dp[i][0] + a[i]
dp[i + 1][1] = min(dp[i][0:2]) + (a[i] % 2)
if a[i] == 0:
dp[i + 1][1] += 2
dp[i +... | 21 | 21 | 478 | 525 | l = int(eval(input()))
a = []
for i in range(l):
a.append(int(eval(input())))
dp = [[0] * 5 for i in range(l + 1)]
for i in range(0, l):
if a[i] == 0:
even = 2
else:
even = a[i] % 2
dp[i + 1][0] = dp[i][0] + a[i]
dp[i + 1][1] = min(dp[i][0], dp[i][1]) + even
dp[i + 1][2] = min(dp... | n = int(eval(input()))
a = [int(eval(input())) for i in range(n)]
# 0区間、偶数区間(2以上)、奇数区間、偶数区間(2以上)、0区間
dp = [[0] * (5) for i in range(n + 1)]
for i in range(n):
dp[i + 1][0] = dp[i][0] + a[i]
dp[i + 1][1] = min(dp[i][0:2]) + (a[i] % 2)
if a[i] == 0:
dp[i + 1][1] += 2
dp[i + 1][2] = min(dp[i][0:3])... | false | 0 | [
"-l = int(eval(input()))",
"-a = []",
"-for i in range(l):",
"- a.append(int(eval(input())))",
"-dp = [[0] * 5 for i in range(l + 1)]",
"-for i in range(0, l):",
"+n = int(eval(input()))",
"+a = [int(eval(input())) for i in range(n)]",
"+# 0区間、偶数区間(2以上)、奇数区間、偶数区間(2以上)、0区間",
"+dp = [[0] * (5) fo... | false | 0.051971 | 0.052003 | 0.999377 | [
"s971185934",
"s152012111"
] |
u620480037 | p03472 | python | s300545053 | s522765276 | 393 | 348 | 11,348 | 7,388 | Accepted | Accepted | 11.45 | n,h=list(map(int,input().split()))
slash=[]
throw=[]
for i in range(n):
x,y=list(map(int,input().split()))
slash.append(x)
throw.append(y)
slash.sort(reverse=True)
throw.sort(reverse=True)
attack=0
for i in range(n):
if throw[i]>=slash[0]:
h-=throw[i]
attack+=1
i... | N,HP=list(map(int,input().split()))
K=0
listN=[]
for i in range(N):
k,n=list(map(int,input().split()))
if k>K:
K=k
listN.append(n)
listN.sort(reverse=True)
cnt=0
for i in range(N):
if listN[i]>=K:
HP-=listN[i]
cnt+=1
if HP<=0:
print(cnt)
... | 23 | 23 | 447 | 386 | n, h = list(map(int, input().split()))
slash = []
throw = []
for i in range(n):
x, y = list(map(int, input().split()))
slash.append(x)
throw.append(y)
slash.sort(reverse=True)
throw.sort(reverse=True)
attack = 0
for i in range(n):
if throw[i] >= slash[0]:
h -= throw[i]
attack += 1
... | N, HP = list(map(int, input().split()))
K = 0
listN = []
for i in range(N):
k, n = list(map(int, input().split()))
if k > K:
K = k
listN.append(n)
listN.sort(reverse=True)
cnt = 0
for i in range(N):
if listN[i] >= K:
HP -= listN[i]
cnt += 1
if HP <= 0:
print(c... | false | 0 | [
"-n, h = list(map(int, input().split()))",
"-slash = []",
"-throw = []",
"-for i in range(n):",
"- x, y = list(map(int, input().split()))",
"- slash.append(x)",
"- throw.append(y)",
"-slash.sort(reverse=True)",
"-throw.sort(reverse=True)",
"-attack = 0",
"-for i in range(n):",
"- i... | false | 0.04359 | 0.046122 | 0.9451 | [
"s300545053",
"s522765276"
] |
u223646582 | p02863 | python | s610566096 | s454165952 | 1,164 | 775 | 195,844 | 124,120 | Accepted | Accepted | 33.42 | # dp[i][t_sum]: i番目までの品物で時間がt_sumを超えないように選んだときの、満足度の総和の最大値
N, T = list(map(int, input().split()))
items = [tuple(map(int, input().split())) for i in range(N)]
dp1 = [[0 for t_sum in range(T+1)] for i in range(N+2)]
dp2 = [[0 for t_sum in range(T+1)] for i in range(N+2)]
for i in range(N):
for t_sum in ran... | # dp[i][t_sum]: i番目までの品物で時間がt_sumを超えないように選んだときの、満足度の総和の最大値
N, T = list(map(int, input().split()))
items = sorted([tuple(map(int, input().split()))
for i in range(N)], key=lambda x: x[0])
dp1 = [[0 for t_sum in range(T+1)] for i in range(N+2)]
for i in range(N):
for t_sum in range(T+1):
... | 26 | 19 | 965 | 651 | # dp[i][t_sum]: i番目までの品物で時間がt_sumを超えないように選んだときの、満足度の総和の最大値
N, T = list(map(int, input().split()))
items = [tuple(map(int, input().split())) for i in range(N)]
dp1 = [[0 for t_sum in range(T + 1)] for i in range(N + 2)]
dp2 = [[0 for t_sum in range(T + 1)] for i in range(N + 2)]
for i in range(N):
for t_sum in range... | # dp[i][t_sum]: i番目までの品物で時間がt_sumを超えないように選んだときの、満足度の総和の最大値
N, T = list(map(int, input().split()))
items = sorted([tuple(map(int, input().split())) for i in range(N)], key=lambda x: x[0])
dp1 = [[0 for t_sum in range(T + 1)] for i in range(N + 2)]
for i in range(N):
for t_sum in range(T + 1):
if t_sum - item... | false | 26.923077 | [
"-items = [tuple(map(int, input().split())) for i in range(N)]",
"+items = sorted([tuple(map(int, input().split())) for i in range(N)], key=lambda x: x[0])",
"-dp2 = [[0 for t_sum in range(T + 1)] for i in range(N + 2)]",
"- for t_sum in range(T + 1):",
"- if t_sum - items[N - 1 - i][0] >= 0:",
... | false | 0.048066 | 0.04689 | 1.02507 | [
"s610566096",
"s454165952"
] |
u411858517 | p03059 | python | s525472624 | s775494859 | 21 | 17 | 3,316 | 2,940 | Accepted | Accepted | 19.05 | A, B, T = list(map(int, input().split()))
tmp = (T+0.5) // A
print((int(B*tmp))) | A, B, T = list(map(int, input().split()))
res = B * (T // A)
print(res) | 5 | 4 | 78 | 69 | A, B, T = list(map(int, input().split()))
tmp = (T + 0.5) // A
print((int(B * tmp)))
| A, B, T = list(map(int, input().split()))
res = B * (T // A)
print(res)
| false | 20 | [
"-tmp = (T + 0.5) // A",
"-print((int(B * tmp)))",
"+res = B * (T // A)",
"+print(res)"
] | false | 0.056631 | 0.008392 | 6.748432 | [
"s525472624",
"s775494859"
] |
u761320129 | p03659 | python | s330469414 | s128565340 | 222 | 177 | 24,832 | 30,592 | Accepted | Accepted | 20.27 | N = int(eval(input()))
A = list(map(int,input().split()))
cums = [0]
for a in A:
cums.append(cums[-1] + a)
ans = 10**20
for i in range(1,N):
x = cums[i]
y = cums[-1] - cums[i]
ans = min(ans, abs(x-y))
print(ans) | N = int(eval(input()))
A = list(map(int,input().split()))
cums = [0]
for a in A:
cums.append(cums[-1] + a)
ans = float('inf')
for i in range(1,N):
c = cums[i]
ans = min(ans, abs(cums[-1]-c - c))
print(ans) | 12 | 10 | 233 | 220 | N = int(eval(input()))
A = list(map(int, input().split()))
cums = [0]
for a in A:
cums.append(cums[-1] + a)
ans = 10**20
for i in range(1, N):
x = cums[i]
y = cums[-1] - cums[i]
ans = min(ans, abs(x - y))
print(ans)
| N = int(eval(input()))
A = list(map(int, input().split()))
cums = [0]
for a in A:
cums.append(cums[-1] + a)
ans = float("inf")
for i in range(1, N):
c = cums[i]
ans = min(ans, abs(cums[-1] - c - c))
print(ans)
| false | 16.666667 | [
"-ans = 10**20",
"+ans = float(\"inf\")",
"- x = cums[i]",
"- y = cums[-1] - cums[i]",
"- ans = min(ans, abs(x - y))",
"+ c = cums[i]",
"+ ans = min(ans, abs(cums[-1] - c - c))"
] | false | 0.04201 | 0.042486 | 0.988795 | [
"s330469414",
"s128565340"
] |
u186838327 | p03403 | python | s203694486 | s466326053 | 317 | 170 | 58,732 | 86,752 | Accepted | Accepted | 46.37 | n = int(eval(input()))
A = list(map(int, input().split()))
ans = [-1]*n
A = [0]+A+[0]
s = 0
for i in range(1, n+2):
s += abs(A[i]-A[i-1])
#print(s)
for i in range(n):
temp = s
temp -= abs(A[i+1]-A[i])
temp -= abs(A[i+2]-A[i+1])
temp += abs(A[i+2]-A[i])
ans[i] = temp
for i in range(... | n = int(eval(input()))
A = list(map(int, input().split()))
A = [0]+A+[0]
s = 0
for i in range(1, n+2):
s += abs(A[i]-A[i-1])
for i in range(1, n+1):
ans = s
ans -= abs(A[i]-A[i-1])
ans -= abs(A[i+1]-A[i])
ans += abs(A[i+1]-A[i-1])
print(ans)
| 16 | 15 | 337 | 277 | n = int(eval(input()))
A = list(map(int, input().split()))
ans = [-1] * n
A = [0] + A + [0]
s = 0
for i in range(1, n + 2):
s += abs(A[i] - A[i - 1])
# print(s)
for i in range(n):
temp = s
temp -= abs(A[i + 1] - A[i])
temp -= abs(A[i + 2] - A[i + 1])
temp += abs(A[i + 2] - A[i])
ans[i] = temp
fo... | n = int(eval(input()))
A = list(map(int, input().split()))
A = [0] + A + [0]
s = 0
for i in range(1, n + 2):
s += abs(A[i] - A[i - 1])
for i in range(1, n + 1):
ans = s
ans -= abs(A[i] - A[i - 1])
ans -= abs(A[i + 1] - A[i])
ans += abs(A[i + 1] - A[i - 1])
print(ans)
| false | 6.25 | [
"-ans = [-1] * n",
"-# print(s)",
"-for i in range(n):",
"- temp = s",
"- temp -= abs(A[i + 1] - A[i])",
"- temp -= abs(A[i + 2] - A[i + 1])",
"- temp += abs(A[i + 2] - A[i])",
"- ans[i] = temp",
"-for i in range(n):",
"- print((ans[i]))",
"+for i in range(1, n + 1):",
"+ ... | false | 0.085256 | 0.044468 | 1.917254 | [
"s203694486",
"s466326053"
] |
u677523557 | p02819 | python | s047425273 | s657967056 | 143 | 110 | 5,424 | 11,244 | Accepted | Accepted | 23.08 | X = int(eval(input()))
import math
# Mまでの素数全列挙(エラトステネスの篩)
def primes(M):
is_prime = [-1 for _ in range(M+1)]
for m in range(2, M+1):
if is_prime[m] == -1:
is_prime[m] = 1
l = 2
while m*l <= M:
is_prime[m*l] = 0
l += 1
... | N = int(eval(input()))
import math
# Mまでの素数全列挙(エラトステネスの篩)
def primes(M):
is_prime = [-1 for _ in range(M+1)]
for m in range(2, M+1):
if is_prime[m] == -1:
is_prime[m] = 1
l = 2
while m*l <= M:
is_prime[m*l] = 0
l += 1
... | 26 | 28 | 524 | 539 | X = int(eval(input()))
import math
# Mまでの素数全列挙(エラトステネスの篩)
def primes(M):
is_prime = [-1 for _ in range(M + 1)]
for m in range(2, M + 1):
if is_prime[m] == -1:
is_prime[m] = 1
l = 2
while m * l <= M:
is_prime[m * l] = 0
l += 1
prime... | N = int(eval(input()))
import math
# Mまでの素数全列挙(エラトステネスの篩)
def primes(M):
is_prime = [-1 for _ in range(M + 1)]
for m in range(2, M + 1):
if is_prime[m] == -1:
is_prime[m] = 1
l = 2
while m * l <= M:
is_prime[m * l] = 0
l += 1
prime... | false | 7.142857 | [
"-X = int(eval(input()))",
"+N = int(eval(input()))",
"-ps = primes(2 * 10**5)",
"-for p in ps:",
"- if p >= X:",
"- print(p)",
"+P = primes(2 * N)",
"+ans = -1",
"+for p in P:",
"+ if p >= N:",
"+ ans = p",
"+print(ans)"
] | false | 0.199291 | 0.051848 | 3.843795 | [
"s047425273",
"s657967056"
] |
u349449706 | p03196 | python | s106665891 | s650922705 | 78 | 63 | 63,340 | 63,584 | Accepted | Accepted | 19.23 | import math
def factrization_prime(number):
factor = {}
div = 2
s = math.sqrt(number)
while div < s:
div_cnt = 0
while number % div == 0:
div_cnt += 1
number //= div
if div_cnt != 0:
factor[div] = div_cnt
div += 1
if nu... | N,P=list(map(int,input().split()))
i=round(P**(1/N))
while 1:
if P%(i**N)==0:print(i);exit()
i-=1
| 22 | 5 | 491 | 104 | import math
def factrization_prime(number):
factor = {}
div = 2
s = math.sqrt(number)
while div < s:
div_cnt = 0
while number % div == 0:
div_cnt += 1
number //= div
if div_cnt != 0:
factor[div] = div_cnt
div += 1
if number > 1:
... | N, P = list(map(int, input().split()))
i = round(P ** (1 / N))
while 1:
if P % (i**N) == 0:
print(i)
exit()
i -= 1
| false | 77.272727 | [
"-import math",
"-",
"-",
"-def factrization_prime(number):",
"- factor = {}",
"- div = 2",
"- s = math.sqrt(number)",
"- while div < s:",
"- div_cnt = 0",
"- while number % div == 0:",
"- div_cnt += 1",
"- number //= div",
"- if div_cnt... | false | 0.006102 | 0.132963 | 0.045892 | [
"s106665891",
"s650922705"
] |
u841621946 | p02819 | python | s793393207 | s809284652 | 46 | 18 | 5,260 | 2,940 | Accepted | Accepted | 60.87 | X = int(eval(input()))
def primes(n):
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(n**0.5) + 1):
if not is_prime[i]:
continue
for j in range(i * 2, n + 1, i):
is_prime[j] = False
return [i for i in range(n... | X = int(eval(input()))
def is_prime(x):
flag = True
for i in range(2,int(x**(0.5))+1):
if x % i == 0:
flag = False
return flag
for i in range(X,2*X+1):
if is_prime(i):
print(i)
break | 17 | 11 | 455 | 238 | X = int(eval(input()))
def primes(n):
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(n**0.5) + 1):
if not is_prime[i]:
continue
for j in range(i * 2, n + 1, i):
is_prime[j] = False
return [i for i in range(n + 1) if... | X = int(eval(input()))
def is_prime(x):
flag = True
for i in range(2, int(x ** (0.5)) + 1):
if x % i == 0:
flag = False
return flag
for i in range(X, 2 * X + 1):
if is_prime(i):
print(i)
break
| false | 35.294118 | [
"-def primes(n):",
"- is_prime = [True] * (n + 1)",
"- is_prime[0] = False",
"- is_prime[1] = False",
"- for i in range(2, int(n**0.5) + 1):",
"- if not is_prime[i]:",
"- continue",
"- for j in range(i * 2, n + 1, i):",
"- is_prime[j] = False",
"- ... | false | 0.04113 | 0.007886 | 5.215849 | [
"s793393207",
"s809284652"
] |
u821588465 | p03564 | python | s195002914 | s242912097 | 30 | 25 | 9,072 | 9,148 | Accepted | Accepted | 16.67 | n = int(eval(input()))
k = int(eval(input()))
cnt = 1
tmp = 0
for i in range(n):
cnt = min(cnt*2, cnt + k)
print(cnt) | N = int(eval(input()))
K = int(eval(input()))
display = 1
for i in range(N):
display = min(display*2, display + K)
print(display)
| 8 | 7 | 117 | 129 | n = int(eval(input()))
k = int(eval(input()))
cnt = 1
tmp = 0
for i in range(n):
cnt = min(cnt * 2, cnt + k)
print(cnt)
| N = int(eval(input()))
K = int(eval(input()))
display = 1
for i in range(N):
display = min(display * 2, display + K)
print(display)
| false | 12.5 | [
"-n = int(eval(input()))",
"-k = int(eval(input()))",
"-cnt = 1",
"-tmp = 0",
"-for i in range(n):",
"- cnt = min(cnt * 2, cnt + k)",
"-print(cnt)",
"+N = int(eval(input()))",
"+K = int(eval(input()))",
"+display = 1",
"+for i in range(N):",
"+ display = min(display * 2, display + K)",
... | false | 0.181383 | 0.046763 | 3.878785 | [
"s195002914",
"s242912097"
] |
u528470578 | p03160 | python | s086520263 | s782647500 | 242 | 127 | 52,208 | 13,928 | Accepted | Accepted | 47.52 | N = int(eval(input()))
h = list(map(int, input().split()))
INF = int(1e20)
dp = [INF] * (N)
dp[0] = 0
for i in range(N-1):
if i == N-2:
dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
else:
dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
dp[i+2] = min(dp[i+2], dp[i]... | N = int(eval(input()))
h = list(map(int, input().split()))
# DP
dp = [0] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, N):
dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
print((dp[N-1])) | 16 | 11 | 354 | 230 | N = int(eval(input()))
h = list(map(int, input().split()))
INF = int(1e20)
dp = [INF] * (N)
dp[0] = 0
for i in range(N - 1):
if i == N - 2:
dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
else:
dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
dp[i + 2] = min(dp[i + 2], d... | N = int(eval(input()))
h = list(map(int, input().split()))
# DP
dp = [0] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, N):
dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[N - 1]))
| false | 31.25 | [
"-INF = int(1e20)",
"-dp = [INF] * (N)",
"+# DP",
"+dp = [0] * N",
"-for i in range(N - 1):",
"- if i == N - 2:",
"- dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))",
"- else:",
"- dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))",
"- dp[i + 2] = min(dp[... | false | 0.041683 | 0.08374 | 0.497763 | [
"s086520263",
"s782647500"
] |
u747184036 | p03018 | python | s395264969 | s697330552 | 48 | 34 | 3,500 | 3,500 | Accepted | Accepted | 29.17 | S = input().replace("BC", "1")
ans = 0
a = 0
for s in S:
if s == "A":
a += 1
elif s == "1":
ans += a
else:
a = 0
print(ans)
|
def main():
S = input().replace("BC", "1")
ans = 0
a = 0
for s in S:
if s == "A":
a += 1
elif s == "1":
ans += a
else:
a = 0
print(ans)
main() | 11 | 15 | 170 | 216 | S = input().replace("BC", "1")
ans = 0
a = 0
for s in S:
if s == "A":
a += 1
elif s == "1":
ans += a
else:
a = 0
print(ans)
| def main():
S = input().replace("BC", "1")
ans = 0
a = 0
for s in S:
if s == "A":
a += 1
elif s == "1":
ans += a
else:
a = 0
print(ans)
main()
| false | 26.666667 | [
"-S = input().replace(\"BC\", \"1\")",
"-ans = 0",
"-a = 0",
"-for s in S:",
"- if s == \"A\":",
"- a += 1",
"- elif s == \"1\":",
"- ans += a",
"- else:",
"- a = 0",
"-print(ans)",
"+def main():",
"+ S = input().replace(\"BC\", \"1\")",
"+ ans = 0",
"... | false | 0.062215 | 0.061684 | 1.008615 | [
"s395264969",
"s697330552"
] |
u528470578 | p02725 | python | s675600197 | s784744412 | 164 | 129 | 25,836 | 105,692 | Accepted | Accepted | 21.34 | K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
dA = []
for i in range(1, N):
dA.append(A[i] - A[i-1])
if i == N - 1:
dA.append(A[0] - (A[i] - K))
dA = sorted(dA)
print((sum(dA[:N-1]))) | # C - Traveling Salesman around Lake
K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
dist = []
for i in range(N-1):
dist.append(abs(A[i] - A[i+1]))
dist.append(abs(K - A[-1] + A[0]))
dist = sorted(dist, reverse=True)
print((sum(dist[1:]))) | 11 | 10 | 232 | 272 | K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
dA = []
for i in range(1, N):
dA.append(A[i] - A[i - 1])
if i == N - 1:
dA.append(A[0] - (A[i] - K))
dA = sorted(dA)
print((sum(dA[: N - 1])))
| # C - Traveling Salesman around Lake
K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
dist = []
for i in range(N - 1):
dist.append(abs(A[i] - A[i + 1]))
dist.append(abs(K - A[-1] + A[0]))
dist = sorted(dist, reverse=True)
print((sum(dist[1:])))
| false | 9.090909 | [
"+# C - Traveling Salesman around Lake",
"-dA = []",
"-for i in range(1, N):",
"- dA.append(A[i] - A[i - 1])",
"- if i == N - 1:",
"- dA.append(A[0] - (A[i] - K))",
"-dA = sorted(dA)",
"-print((sum(dA[: N - 1])))",
"+dist = []",
"+for i in range(N - 1):",
"+ dist.append(abs(A[i] ... | false | 0.043174 | 0.102807 | 0.41995 | [
"s675600197",
"s784744412"
] |
u638456847 | p03221 | python | s753098218 | s127537392 | 429 | 371 | 35,260 | 36,952 | Accepted | Accepted | 13.52 | import sys
import bisect
input = sys.stdin.readline
def main():
N,M = list(map(int, input().split()))
PY_input = []
PY_dict = {}
for _ in range(M):
p, y = list(map(int, input().split()))
PY_input.append((p, y))
PY_dict.setdefault(p, []).append(y)
for i in list(... | import sys
import bisect
read = sys.stdin.read
readline = sys.stdin.readline
def main2():
N,M,*PY = list(map(int, read().split()))
PY_input = []
PY_dict = {}
for p, y in zip(*[iter(PY)]*2):
PY_input.append((p, y))
PY_dict.setdefault(p, []).append(y)
for i in list(PY_di... | 22 | 22 | 487 | 488 | import sys
import bisect
input = sys.stdin.readline
def main():
N, M = list(map(int, input().split()))
PY_input = []
PY_dict = {}
for _ in range(M):
p, y = list(map(int, input().split()))
PY_input.append((p, y))
PY_dict.setdefault(p, []).append(y)
for i in list(PY_dict.val... | import sys
import bisect
read = sys.stdin.read
readline = sys.stdin.readline
def main2():
N, M, *PY = list(map(int, read().split()))
PY_input = []
PY_dict = {}
for p, y in zip(*[iter(PY)] * 2):
PY_input.append((p, y))
PY_dict.setdefault(p, []).append(y)
for i in list(PY_dict.value... | false | 0 | [
"-input = sys.stdin.readline",
"+read = sys.stdin.read",
"+readline = sys.stdin.readline",
"-def main():",
"- N, M = list(map(int, input().split()))",
"+def main2():",
"+ N, M, *PY = list(map(int, read().split()))",
"- for _ in range(M):",
"- p, y = list(map(int, input().split()))",
... | false | 0.042466 | 0.042991 | 0.9878 | [
"s753098218",
"s127537392"
] |
u994307795 | p03814 | python | s982142545 | s697297988 | 20 | 18 | 3,644 | 3,500 | Accepted | Accepted | 10 | import re
s = eval(input())
m = re.search(r'A.*Z', s)
print((len(m.group()))) | s = eval(input())
print((s.rfind('Z') - s.find('A') + 1)) | 4 | 2 | 72 | 50 | import re
s = eval(input())
m = re.search(r"A.*Z", s)
print((len(m.group())))
| s = eval(input())
print((s.rfind("Z") - s.find("A") + 1))
| false | 50 | [
"-import re",
"-",
"-m = re.search(r\"A.*Z\", s)",
"-print((len(m.group())))",
"+print((s.rfind(\"Z\") - s.find(\"A\") + 1))"
] | false | 0.095648 | 0.037285 | 2.56535 | [
"s982142545",
"s697297988"
] |
u127499732 | p02936 | python | s582840160 | s208180879 | 1,380 | 970 | 294,848 | 95,620 | Accepted | Accepted | 29.71 | def main():
import sys
sys.setrecursionlimit(300000)
n, q, *abpx = list(map(int, sys.stdin.read().split()))
g = [[] for _ in range(n + 1)]
for u, v in zip(*[iter(abpx[:2 * (n - 1)])] * 2):
g[u].append(v)
g[v].append(u)
f = [0 for _ in range(n + 1)]
for p, x in ... | def main():
from collections import deque
n, q, *abpx = list(map(int, open(0).read().split()))
g = [[] for _ in range(n + 1)]
for u, v in zip(*[iter(abpx[:2 * (n - 1)])] * 2):
g[u].append(v)
g[v].append(u)
f = [0 for _ in range(n + 1)]
for p, x in zip(*[iter(abpx[... | 34 | 37 | 744 | 816 | def main():
import sys
sys.setrecursionlimit(300000)
n, q, *abpx = list(map(int, sys.stdin.read().split()))
g = [[] for _ in range(n + 1)]
for u, v in zip(*[iter(abpx[: 2 * (n - 1)])] * 2):
g[u].append(v)
g[v].append(u)
f = [0 for _ in range(n + 1)]
for p, x in zip(*[iter(ab... | def main():
from collections import deque
n, q, *abpx = list(map(int, open(0).read().split()))
g = [[] for _ in range(n + 1)]
for u, v in zip(*[iter(abpx[: 2 * (n - 1)])] * 2):
g[u].append(v)
g[v].append(u)
f = [0 for _ in range(n + 1)]
for p, x in zip(*[iter(abpx[2 * (n - 1) :]... | false | 8.108108 | [
"- import sys",
"+ from collections import deque",
"- sys.setrecursionlimit(300000)",
"- n, q, *abpx = list(map(int, sys.stdin.read().split()))",
"+ n, q, *abpx = list(map(int, open(0).read().split()))",
"-",
"- def c(i, p):",
"+ q = deque([])",
"+ q.append([1, 0])",
"+ ... | false | 0.039858 | 0.040642 | 0.980701 | [
"s582840160",
"s208180879"
] |
u435300817 | p02409 | python | s054517348 | s695954358 | 50 | 20 | 7,744 | 7,748 | Accepted | Accepted | 60 | #!/usr/bin/env python3
n = int(eval(input()))
matrix = []
while n > 0:
values = [int(x) for x in input().split()]
matrix.append(values)
n -= 1
official_house = [[[0 for z in range(10)] for y in range(3)] for x in range(4)]
Min = 0
Max = 9
for b, f, r, v in matrix:
num = official_house[b... | #!/usr/bin/env python3
n = int(eval(input()))
matrix = []
while n > 0:
values = [int(x) for x in input().split()]
matrix.append(values)
n -= 1
official_house = [[[0 for z in range(10)] for y in range(3)] for x in range(4)]
Min = 0
Max = 9
for b, f, r, v in matrix:
num = official_house[b... | 23 | 23 | 569 | 569 | #!/usr/bin/env python3
n = int(eval(input()))
matrix = []
while n > 0:
values = [int(x) for x in input().split()]
matrix.append(values)
n -= 1
official_house = [[[0 for z in range(10)] for y in range(3)] for x in range(4)]
Min = 0
Max = 9
for b, f, r, v in matrix:
num = official_house[b - 1][f - 1][r - ... | #!/usr/bin/env python3
n = int(eval(input()))
matrix = []
while n > 0:
values = [int(x) for x in input().split()]
matrix.append(values)
n -= 1
official_house = [[[0 for z in range(10)] for y in range(3)] for x in range(4)]
Min = 0
Max = 9
for b, f, r, v in matrix:
num = official_house[b - 1][f - 1][r - ... | false | 0 | [
"- if Min >= num or Max >= num:",
"+ if Min <= num or Max >= num:"
] | false | 0.037622 | 0.036755 | 1.023589 | [
"s054517348",
"s695954358"
] |
u272028993 | p03733 | python | s017754077 | s278168700 | 210 | 152 | 20,036 | 20,060 | Accepted | Accepted | 27.62 | n,T=list(map(int,input().split()))
t=list(map(int,input().split()))
i=1
now=T
ans=T
while i<n:
if t[i]+T<now:
while t[i]+T<now:
i+=1
if t[i]>=now:
now=t[i]+T
ans+=T
i+=1
elif t[i]+T>=now:
ans+=t[i]+T-now
now=t[i]+T
i+=1
pri... | n,T=list(map(int,input().split()))
t=list(map(int,input().split()))
ans=0
now=0
for i in range(n):
if t[i]<=now:
ans+=t[i]+T-now
now=t[i]+T
else:
ans+=T
now=t[i]+T
print(ans) | 18 | 12 | 323 | 221 | n, T = list(map(int, input().split()))
t = list(map(int, input().split()))
i = 1
now = T
ans = T
while i < n:
if t[i] + T < now:
while t[i] + T < now:
i += 1
if t[i] >= now:
now = t[i] + T
ans += T
i += 1
elif t[i] + T >= now:
ans += t[i] + T - now
... | n, T = list(map(int, input().split()))
t = list(map(int, input().split()))
ans = 0
now = 0
for i in range(n):
if t[i] <= now:
ans += t[i] + T - now
now = t[i] + T
else:
ans += T
now = t[i] + T
print(ans)
| false | 33.333333 | [
"-i = 1",
"-now = T",
"-ans = T",
"-while i < n:",
"- if t[i] + T < now:",
"- while t[i] + T < now:",
"- i += 1",
"- if t[i] >= now:",
"- now = t[i] + T",
"- ans += T",
"- i += 1",
"- elif t[i] + T >= now:",
"+ans = 0",
"+now = 0",
"+for i ... | false | 0.037562 | 0.041822 | 0.898147 | [
"s017754077",
"s278168700"
] |
u347640436 | p02707 | python | s899550454 | s501866281 | 297 | 108 | 52,720 | 33,064 | Accepted | Accepted | 63.64 | N = int(eval(input()))
A = list(map(int, input().split()))
d = {}
for i in range(N - 1):
if A[i] in d:
d[A[i]].append(i + 2)
else:
d[A[i]] = [i + 2]
for i in range(1, N + 1):
if i in d:
print((len(d[i])))
else:
print((0))
| N = int(eval(input()))
A = list(map(int, input().split()))
result = [0] * N
for a in A:
result[a - 1] += 1
print(('\n'.join(map(str, result))))
| 16 | 7 | 278 | 147 | N = int(eval(input()))
A = list(map(int, input().split()))
d = {}
for i in range(N - 1):
if A[i] in d:
d[A[i]].append(i + 2)
else:
d[A[i]] = [i + 2]
for i in range(1, N + 1):
if i in d:
print((len(d[i])))
else:
print((0))
| N = int(eval(input()))
A = list(map(int, input().split()))
result = [0] * N
for a in A:
result[a - 1] += 1
print(("\n".join(map(str, result))))
| false | 56.25 | [
"-d = {}",
"-for i in range(N - 1):",
"- if A[i] in d:",
"- d[A[i]].append(i + 2)",
"- else:",
"- d[A[i]] = [i + 2]",
"-for i in range(1, N + 1):",
"- if i in d:",
"- print((len(d[i])))",
"- else:",
"- print((0))",
"+result = [0] * N",
"+for a in A:",
... | false | 0.037061 | 0.037393 | 0.991112 | [
"s899550454",
"s501866281"
] |
u266874640 | p03030 | python | s371605159 | s474303495 | 21 | 18 | 3,316 | 3,060 | Accepted | Accepted | 14.29 | import collections
from operator import itemgetter
N = int(eval(input()))
SP = []
for i in range(N):
s,p = input().split()
SP.append([0,0])
SP[i][0] = s
SP[i][1] = int(p)
SP_new = sorted(SP)
t = 0
for i in range(N):
if t > 0:
t -= 1
continue
s = SP_new[i][0]
t... | N = int(eval(input()))
SP = []
for i in range(N):
s,p = input().split()
SP.append([0,0])
SP[i][0] = s
SP[i][1] = -int(p)
SP_new = sorted(SP)
for i in SP_new:
print((SP.index(i)+1))
| 27 | 10 | 609 | 202 | import collections
from operator import itemgetter
N = int(eval(input()))
SP = []
for i in range(N):
s, p = input().split()
SP.append([0, 0])
SP[i][0] = s
SP[i][1] = int(p)
SP_new = sorted(SP)
t = 0
for i in range(N):
if t > 0:
t -= 1
continue
s = SP_new[i][0]
t = 0
for ... | N = int(eval(input()))
SP = []
for i in range(N):
s, p = input().split()
SP.append([0, 0])
SP[i][0] = s
SP[i][1] = -int(p)
SP_new = sorted(SP)
for i in SP_new:
print((SP.index(i) + 1))
| false | 62.962963 | [
"-import collections",
"-from operator import itemgetter",
"-",
"- SP[i][1] = int(p)",
"+ SP[i][1] = -int(p)",
"-t = 0",
"-for i in range(N):",
"- if t > 0:",
"- t -= 1",
"- continue",
"- s = SP_new[i][0]",
"- t = 0",
"- for j in range(i + 1, N):",
"- ... | false | 0.040545 | 0.129392 | 0.31335 | [
"s371605159",
"s474303495"
] |
u546285759 | p00063 | python | s435707886 | s320970480 | 30 | 20 | 7,264 | 5,556 | Accepted | Accepted | 33.33 | import sys
s = []
for line in sys.stdin:
line = line.strip()
if line == line[::-1]:
s.append(line)
print((len(s))) | ans = 0
while True:
try:
string = eval(input())
except:
break
ans += [0, 1][string == string[::-1]]
print(ans)
| 8 | 9 | 136 | 142 | import sys
s = []
for line in sys.stdin:
line = line.strip()
if line == line[::-1]:
s.append(line)
print((len(s)))
| ans = 0
while True:
try:
string = eval(input())
except:
break
ans += [0, 1][string == string[::-1]]
print(ans)
| false | 11.111111 | [
"-import sys",
"-",
"-s = []",
"-for line in sys.stdin:",
"- line = line.strip()",
"- if line == line[::-1]:",
"- s.append(line)",
"-print((len(s)))",
"+ans = 0",
"+while True:",
"+ try:",
"+ string = eval(input())",
"+ except:",
"+ break",
"+ ans += [... | false | 0.03393 | 0.036411 | 0.931841 | [
"s435707886",
"s320970480"
] |
u855057563 | p02576 | python | s818117463 | s812225411 | 35 | 31 | 9,104 | 9,144 | Accepted | Accepted | 11.43 | N,X,T=list(map(int,input().split()))
if N%X==0:
s=N//X
print((s*T))
else:
s=N//X+1
print((s*T)) | n,x,t=list(map(int,input().split()))
if n%x==0:
print((n//x*t))
else:
print(((n//x+1)*t))
| 7 | 5 | 99 | 88 | N, X, T = list(map(int, input().split()))
if N % X == 0:
s = N // X
print((s * T))
else:
s = N // X + 1
print((s * T))
| n, x, t = list(map(int, input().split()))
if n % x == 0:
print((n // x * t))
else:
print(((n // x + 1) * t))
| false | 28.571429 | [
"-N, X, T = list(map(int, input().split()))",
"-if N % X == 0:",
"- s = N // X",
"- print((s * T))",
"+n, x, t = list(map(int, input().split()))",
"+if n % x == 0:",
"+ print((n // x * t))",
"- s = N // X + 1",
"- print((s * T))",
"+ print(((n // x + 1) * t))"
] | false | 0.034951 | 0.055048 | 0.634921 | [
"s818117463",
"s812225411"
] |
u952656646 | p03087 | python | s821667287 | s872510433 | 851 | 475 | 6,164 | 31,392 | Accepted | Accepted | 44.18 | N, Q = list(map(int, input().split()))
S = eval(input())
c = [0]*N
for i in range(1, N):
c[i] = c[i-1]
if S[i-1]=="A" and S[i]=="C":
c[i] = c[i-1] + 1
for _ in range(Q):
l, r = list(map(int, input().split()))
print((c[r-1]-c[l-1])) | import re
N, Q = list(map(int, input().split()))
S = eval(input())
query = [list(map(int, input().split())) for _ in range(Q)]
s = re.sub(r"AC", "0", S)
accum = [0 for _ in range(N)]
for i in range(1, N):
accum[i] = accum[i-1]
if S[i-1]=="A" and S[i]=="C":
accum[i] += + 1
for l,r in query:
... | 10 | 13 | 244 | 340 | N, Q = list(map(int, input().split()))
S = eval(input())
c = [0] * N
for i in range(1, N):
c[i] = c[i - 1]
if S[i - 1] == "A" and S[i] == "C":
c[i] = c[i - 1] + 1
for _ in range(Q):
l, r = list(map(int, input().split()))
print((c[r - 1] - c[l - 1]))
| import re
N, Q = list(map(int, input().split()))
S = eval(input())
query = [list(map(int, input().split())) for _ in range(Q)]
s = re.sub(r"AC", "0", S)
accum = [0 for _ in range(N)]
for i in range(1, N):
accum[i] = accum[i - 1]
if S[i - 1] == "A" and S[i] == "C":
accum[i] += +1
for l, r in query:
... | false | 23.076923 | [
"+import re",
"+",
"-c = [0] * N",
"+query = [list(map(int, input().split())) for _ in range(Q)]",
"+s = re.sub(r\"AC\", \"0\", S)",
"+accum = [0 for _ in range(N)]",
"- c[i] = c[i - 1]",
"+ accum[i] = accum[i - 1]",
"- c[i] = c[i - 1] + 1",
"-for _ in range(Q):",
"- l, r = list(... | false | 0.042608 | 0.118688 | 0.358995 | [
"s821667287",
"s872510433"
] |
u143492911 | p03557 | python | s453270635 | s883554527 | 365 | 333 | 23,204 | 22,720 | Accepted | Accepted | 8.77 | n=int(eval(input()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
import bisect
a.sort()
c.sort()
cl=len(c)
cnt=0
for i in b:
x=bisect.bisect_left(a,i)
y=bisect.bisect_right(c,i)
cnt+=x*(cl-y)
print(cnt)
| n=int(eval(input()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
import bisect
a.sort()
b.sort()
c.sort()
ans=0
for i in range(n):
ans+=bisect.bisect_left(a,b[i])*(n-bisect.bisect_right(c,b[i]))
print(ans)
| 15 | 12 | 283 | 270 | n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
import bisect
a.sort()
c.sort()
cl = len(c)
cnt = 0
for i in b:
x = bisect.bisect_left(a, i)
y = bisect.bisect_right(c, i)
cnt += x * (cl - y)
print(cnt)
| n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
import bisect
a.sort()
b.sort()
c.sort()
ans = 0
for i in range(n):
ans += bisect.bisect_left(a, b[i]) * (n - bisect.bisect_right(c, b[i]))
print(ans)
| false | 20 | [
"+b.sort()",
"-cl = len(c)",
"-cnt = 0",
"-for i in b:",
"- x = bisect.bisect_left(a, i)",
"- y = bisect.bisect_right(c, i)",
"- cnt += x * (cl - y)",
"-print(cnt)",
"+ans = 0",
"+for i in range(n):",
"+ ans += bisect.bisect_left(a, b[i]) * (n - bisect.bisect_right(c, b[i]))",
"+pr... | false | 0.039954 | 0.048915 | 0.816812 | [
"s453270635",
"s883554527"
] |
u576432509 | p03739 | python | s769542185 | s472810228 | 168 | 127 | 14,332 | 14,468 | Accepted | Accepted | 24.4 | n=int(eval(input()))
a=list(map(int,input().split()))
# 0 1 2 3 evn odd
# kevn + - + - + -
# kodd - + - + - +
a0=a[0]
if a0<0:
kevn=1-a0
sevn=1
elif a0==0:
kevn=1
sevn=1
elif a0>0:
kevn=0
sevn=a0
for i in range(1,n):
ai=a[i]
if i%2==0:
... | n=int(eval(input()))
a=list(map(int,input().split()))
# 0 1 2 3 evn odd
# kevn + - + - + -
# kodd - + - + - +
def kf(a,flag,n):
a0=a[0]*flag
if a0<=0:
kevn=1-a0
sevn=1
elif a0>0:
kevn=0
sevn=a0
for i in range(1,n):
ai=a[i... | 80 | 36 | 1,505 | 784 | n = int(eval(input()))
a = list(map(int, input().split()))
# 0 1 2 3 evn odd
# kevn + - + - + -
# kodd - + - + - +
a0 = a[0]
if a0 < 0:
kevn = 1 - a0
sevn = 1
elif a0 == 0:
kevn = 1
sevn = 1
elif a0 > 0:
kevn = 0
sevn = a0
for i in range(1, n):
ai = a[i]
if i % 2 =... | n = int(eval(input()))
a = list(map(int, input().split()))
# 0 1 2 3 evn odd
# kevn + - + - + -
# kodd - + - + - +
def kf(a, flag, n):
a0 = a[0] * flag
if a0 <= 0:
kevn = 1 - a0
sevn = 1
elif a0 > 0:
kevn = 0
sevn = a0
for i in range(1, n):
... | false | 55 | [
"-a0 = a[0]",
"-if a0 < 0:",
"- kevn = 1 - a0",
"- sevn = 1",
"-elif a0 == 0:",
"- kevn = 1",
"- sevn = 1",
"-elif a0 > 0:",
"- kevn = 0",
"- sevn = a0",
"-for i in range(1, n):",
"- ai = a[i]",
"- if i % 2 == 0:",
"- if sevn + ai < 0:",
"- kevn ... | false | 0.049048 | 0.04829 | 1.01571 | [
"s769542185",
"s472810228"
] |
u150984829 | p02257 | python | s997029834 | s955427877 | 60 | 50 | 5,620 | 5,624 | Accepted | Accepted | 16.67 | import sys
eval(input())
print((sum(1 for x in map(int,sys.stdin)if 2 in[x,pow(2,x,x)])))
| import sys
eval(input())
print((len([1 for x in map(int,sys.stdin)if 2 in[x,pow(2,x,x)]])))
| 3 | 3 | 84 | 86 | import sys
eval(input())
print((sum(1 for x in map(int, sys.stdin) if 2 in [x, pow(2, x, x)])))
| import sys
eval(input())
print((len([1 for x in map(int, sys.stdin) if 2 in [x, pow(2, x, x)]])))
| false | 0 | [
"-print((sum(1 for x in map(int, sys.stdin) if 2 in [x, pow(2, x, x)])))",
"+print((len([1 for x in map(int, sys.stdin) if 2 in [x, pow(2, x, x)]])))"
] | false | 0.127408 | 0.044466 | 2.86529 | [
"s997029834",
"s955427877"
] |
u935558307 | p03356 | python | s462484906 | s896720216 | 1,041 | 379 | 93,932 | 90,896 | Accepted | Accepted | 63.59 | #各pは、自分の今いるインデックスがindex p-1と繋がっていればそこに移動する
import sys
sys.setrecursionlimit(200000)
class UnionFind():
def __init__(self,n):
self.n=n
self.parents = [i for i in range(n+1)]
self.size = [1]*(n+1)
def find(self,x):
if self.parents[x]==x:
return x
el... | """
初期状態でpiにいる数が、pi番目にたどり着けるかを判定すればよい。
unionFind木が使える
"""
N,M = list(map(int,input().split()))
P = list(map(int,input().split()))
class UnionFind():
def __init__(self,n):
self.n=n
self.parents = [i for i in range(n+1)]
self.size = [1]*(n+1)
def find(self,x):
if self.p... | 39 | 41 | 1,062 | 1,113 | # 各pは、自分の今いるインデックスがindex p-1と繋がっていればそこに移動する
import sys
sys.setrecursionlimit(200000)
class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [i for i in range(n + 1)]
self.size = [1] * (n + 1)
def find(self, x):
if self.parents[x] == x:
return x
... | """
初期状態でpiにいる数が、pi番目にたどり着けるかを判定すればよい。
unionFind木が使える
"""
N, M = list(map(int, input().split()))
P = list(map(int, input().split()))
class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [i for i in range(n + 1)]
self.size = [1] * (n + 1)
def find(self, x):
if self... | false | 4.878049 | [
"-# 各pは、自分の今いるインデックスがindex p-1と繋がっていればそこに移動する",
"-import sys",
"-",
"-sys.setrecursionlimit(200000)",
"+\"\"\"",
"+初期状態でpiにいる数が、pi番目にたどり着けるかを判定すればよい。",
"+unionFind木が使える",
"+\"\"\"",
"+N, M = list(map(int, input().split()))",
"+P = list(map(int, input().split()))",
"+ self.size[xRoot] ... | false | 0.083408 | 0.04611 | 1.808871 | [
"s462484906",
"s896720216"
] |
u657361950 | p02271 | python | s752834762 | s044227982 | 1,350 | 1,160 | 5,944 | 5,976 | Accepted | Accepted | 14.07 | def subset_sum(n, s, a):
dp = [[0 for x in range(s+1)] for x in range(n+1)]
for i in range(n):
v = a[i]
for j in range(s+1):
if v==j or (v<j and dp[i][j-v]>0):
dp[i+1][j] = dp[i][j] + 1
else:
dp[i+1][j] = dp[i][j]
return dp[n][s] > 0
n = int(eval(input()))
a = list(map(int, input().spl... | def subset_sum(n, s, a):
dp = [[0 for x in range(s+1)] for x in range(n+1)]
dp[0][0]=1
for i in range(n):
v = a[i]
for j in range(s+1):
if v > j:
dp[i+1][j] = dp[i][j]
else:
dp[i+1][j] = dp[i][j]+dp[i][j-v]
return dp[n][s] > 0
n = int(eval(input()))
a = list(map(int, input().split())... | 21 | 22 | 474 | 470 | def subset_sum(n, s, a):
dp = [[0 for x in range(s + 1)] for x in range(n + 1)]
for i in range(n):
v = a[i]
for j in range(s + 1):
if v == j or (v < j and dp[i][j - v] > 0):
dp[i + 1][j] = dp[i][j] + 1
else:
dp[i + 1][j] = dp[i][j]
retu... | def subset_sum(n, s, a):
dp = [[0 for x in range(s + 1)] for x in range(n + 1)]
dp[0][0] = 1
for i in range(n):
v = a[i]
for j in range(s + 1):
if v > j:
dp[i + 1][j] = dp[i][j]
else:
dp[i + 1][j] = dp[i][j] + dp[i][j - v]
return dp... | false | 4.545455 | [
"+ dp[0][0] = 1",
"- if v == j or (v < j and dp[i][j - v] > 0):",
"- dp[i + 1][j] = dp[i][j] + 1",
"+ if v > j:",
"+ dp[i + 1][j] = dp[i][j]",
"- dp[i + 1][j] = dp[i][j]",
"+ dp[i + 1][j] = dp[i][j] + dp[i][j - v]"
] | false | 0.037897 | 0.039097 | 0.969303 | [
"s752834762",
"s044227982"
] |
u373047809 | p02888 | python | s797745272 | s106733358 | 1,876 | 914 | 3,188 | 9,232 | Accepted | Accepted | 51.28 | from bisect import*
n, *l = list(map(int, open(0).read().split()))
l.sort();c=0
for i in range(n):
for j in range(i+1, n):
d = bisect_left(l, l[i] + l[j])
c += max(0, d-j-1)
print(c) | from bisect import*
n, *l = list(map(int, open(0).read().split()))
l.sort()
print((sum(max(0, bisect_left(l, l[i] + l[j]) - j - 1) for i in range(n) for j in range(i+1, n)))) | 8 | 4 | 193 | 169 | from bisect import *
n, *l = list(map(int, open(0).read().split()))
l.sort()
c = 0
for i in range(n):
for j in range(i + 1, n):
d = bisect_left(l, l[i] + l[j])
c += max(0, d - j - 1)
print(c)
| from bisect import *
n, *l = list(map(int, open(0).read().split()))
l.sort()
print(
(
sum(
max(0, bisect_left(l, l[i] + l[j]) - j - 1)
for i in range(n)
for j in range(i + 1, n)
)
)
)
| false | 50 | [
"-c = 0",
"-for i in range(n):",
"- for j in range(i + 1, n):",
"- d = bisect_left(l, l[i] + l[j])",
"- c += max(0, d - j - 1)",
"-print(c)",
"+print(",
"+ (",
"+ sum(",
"+ max(0, bisect_left(l, l[i] + l[j]) - j - 1)",
"+ for i in range(n)",
"+ ... | false | 0.034866 | 0.066652 | 0.523112 | [
"s797745272",
"s106733358"
] |
u116002573 | p02972 | python | s101498799 | s885334946 | 238 | 213 | 20,788 | 20,792 | Accepted | Accepted | 10.5 | n = int(eval(input()))
A = list(map(int, input().split()))
filled = [0]*(n+1)
ans = []
for i in range(n-1, -1, -1):
if sum(filled[::i+1][1:]) % 2 != A[i]:
filled[i+1] = 1
ans.append(i+1)
print((len(ans)))
print((' '.join(map(str, ans)))) | def main():
n = int(eval(input()))
A = list(map(int, input().split()))
filled = [0]*(n+1)
ans = []
for i in range(n-1, -1, -1):
if sum(filled[::i+1][1:]) % 2 != A[i]:
filled[i+1] = 1
ans.append(i+1)
print((len(ans)))
print((' '.join(map(str, ans)))... | 11 | 16 | 248 | 355 | n = int(eval(input()))
A = list(map(int, input().split()))
filled = [0] * (n + 1)
ans = []
for i in range(n - 1, -1, -1):
if sum(filled[:: i + 1][1:]) % 2 != A[i]:
filled[i + 1] = 1
ans.append(i + 1)
print((len(ans)))
print((" ".join(map(str, ans))))
| def main():
n = int(eval(input()))
A = list(map(int, input().split()))
filled = [0] * (n + 1)
ans = []
for i in range(n - 1, -1, -1):
if sum(filled[:: i + 1][1:]) % 2 != A[i]:
filled[i + 1] = 1
ans.append(i + 1)
print((len(ans)))
print((" ".join(map(str, ans))... | false | 31.25 | [
"-n = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-filled = [0] * (n + 1)",
"-ans = []",
"-for i in range(n - 1, -1, -1):",
"- if sum(filled[:: i + 1][1:]) % 2 != A[i]:",
"- filled[i + 1] = 1",
"- ans.append(i + 1)",
"-print((len(ans)))",
"-print((\" \".join(map(... | false | 0.046008 | 0.045843 | 1.003599 | [
"s101498799",
"s885334946"
] |
u324314500 | p03006 | python | s255403547 | s847168747 | 186 | 172 | 39,152 | 39,280 | Accepted | Accepted | 7.53 | import sys
from collections import deque # 双方向キュー
from collections import defaultdict # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop # プライオリティキュー
from bisect import bisect_left, bisect_right # 二分探索
#import numpy as np # 1.8.2
#import scipy # 0.13.3
s2nn = lambda s: [int(c) for c in s... | import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss ... | 38 | 37 | 1,119 | 1,062 | import sys
from collections import deque # 双方向キュー
from collections import defaultdict # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop # プライオリティキュー
from bisect import bisect_left, bisect_right # 二分探索
# import numpy as np # 1.8.2
# import scipy # 0.13.3
s2nn = lambda s: [int(c) for c in s.split... | import sys
s2nn = lambda s: [int(c) for c in s.split(" ")]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambd... | false | 2.631579 | [
"-from collections import deque # 双方向キュー",
"-from collections import defaultdict # 初期化済み辞書",
"-from heapq import heapify, heappush, heappop, heappushpop # プライオリティキュー",
"-from bisect import bisect_left, bisect_right # 二分探索",
"-# import numpy as np # 1.8.2",
"-# import scipy # 0.13.3",
"+ii2sss = la... | false | 0.133371 | 0.044427 | 3.002038 | [
"s255403547",
"s847168747"
] |
u923662841 | p02911 | python | s147801842 | s822763178 | 293 | 270 | 29,200 | 29,416 | Accepted | Accepted | 7.85 | import numpy as np
N,K,Q = list(map(int, input().split()))
n = [0]*N
for _ in range(Q):
n[int(eval(input()))-1] +=1
nn = np.array(n)
ans = K - Q + nn
for an in ans:
if an > 0:
print('Yes')
else:
print("No") | import numpy as np
N,K,Q = list(map(int, input().split()))
n = [K-Q]*N
for _ in range(Q):
n[int(eval(input()))-1] +=1
for an in n:
if an > 0:
print('Yes')
else:
print("No") | 14 | 12 | 237 | 201 | import numpy as np
N, K, Q = list(map(int, input().split()))
n = [0] * N
for _ in range(Q):
n[int(eval(input())) - 1] += 1
nn = np.array(n)
ans = K - Q + nn
for an in ans:
if an > 0:
print("Yes")
else:
print("No")
| import numpy as np
N, K, Q = list(map(int, input().split()))
n = [K - Q] * N
for _ in range(Q):
n[int(eval(input())) - 1] += 1
for an in n:
if an > 0:
print("Yes")
else:
print("No")
| false | 14.285714 | [
"-n = [0] * N",
"+n = [K - Q] * N",
"-nn = np.array(n)",
"-ans = K - Q + nn",
"-for an in ans:",
"+for an in n:"
] | false | 0.288966 | 0.045074 | 6.410961 | [
"s147801842",
"s822763178"
] |
u680851063 | p02678 | python | s138532040 | s441784726 | 616 | 549 | 34,696 | 34,820 | Accepted | Accepted | 10.88 | # ノードの開始が'0'でなく'1'であることに注意!!※※※
# AtCoder Beginner Contest 168
# https://atcoder.jp/contests/abc168/tasks/abc168_d
import sys
input = sys.stdin.readline
n, m = list(map(int, input().split())) # nは頂点の数、mは辺の数
pic = [[] for _ in range(n)] # 隣接リスト_初期化
for _ in range(m): # 隣接リスト_取り込み
a, b = list(map(int, ... | # ダミーノード'0'を設定 ※※※
# AtCoder Beginner Contest 168
# https://atcoder.jp/contests/abc168/tasks/abc168_d
import sys
input = sys.stdin.readline
n, m = list(map(int, input().split())) # nは頂点の数、mは辺の数
pic = [[] for _ in range(n+1)] # 隣接リスト_初期化 ※※※
for _ in range(m): # 隣接リスト_取り込み
a, b = list(map(int, input()... | 36 | 36 | 1,031 | 1,044 | # ノードの開始が'0'でなく'1'であることに注意!!※※※
# AtCoder Beginner Contest 168
# https://atcoder.jp/contests/abc168/tasks/abc168_d
import sys
input = sys.stdin.readline
n, m = list(map(int, input().split())) # nは頂点の数、mは辺の数
pic = [[] for _ in range(n)] # 隣接リスト_初期化
for _ in range(m): # 隣接リスト_取り込み
a, b = list(map(int, input().spl... | # ダミーノード'0'を設定 ※※※
# AtCoder Beginner Contest 168
# https://atcoder.jp/contests/abc168/tasks/abc168_d
import sys
input = sys.stdin.readline
n, m = list(map(int, input().split())) # nは頂点の数、mは辺の数
pic = [[] for _ in range(n + 1)] # 隣接リスト_初期化 ※※※
for _ in range(m): # 隣接リスト_取り込み
a, b = list(map(int, input().split())... | false | 0 | [
"-# ノードの開始が'0'でなく'1'であることに注意!!※※※",
"+# ダミーノード'0'を設定 ※※※",
"-pic = [[] for _ in range(n)] # 隣接リスト_初期化",
"+pic = [[] for _ in range(n + 1)] # 隣接リスト_初期化 ※※※",
"- pic[a - 1].append(b - 1) # ※※※",
"- pic[b - 1].append(a - 1) # ※※※",
"+ pic[a].append(b) # ※※※",
"+ pic[b].append(a) # ※※※",... | false | 0.085254 | 0.038617 | 2.207689 | [
"s138532040",
"s441784726"
] |
u553987207 | p02725 | python | s966138681 | s186616123 | 150 | 133 | 26,436 | 33,216 | Accepted | Accepted | 11.33 | K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
maxd = (K - A[-1]) + A[0]
for i in range(1, N):
d = A[i] - A[i - 1]
maxd = max(maxd, d)
print((K - maxd)) | K, N = list(map(int, input().split()))
A = tuple(map(int, input().split()))
maxd = K - A[-1] + A[0]
for i in range(1, N):
d = A[i] - A[i-1]
maxd = max(maxd, d)
ans = K - maxd
print(ans) | 7 | 9 | 186 | 196 | K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
maxd = (K - A[-1]) + A[0]
for i in range(1, N):
d = A[i] - A[i - 1]
maxd = max(maxd, d)
print((K - maxd))
| K, N = list(map(int, input().split()))
A = tuple(map(int, input().split()))
maxd = K - A[-1] + A[0]
for i in range(1, N):
d = A[i] - A[i - 1]
maxd = max(maxd, d)
ans = K - maxd
print(ans)
| false | 22.222222 | [
"-A = list(map(int, input().split()))",
"-maxd = (K - A[-1]) + A[0]",
"+A = tuple(map(int, input().split()))",
"+maxd = K - A[-1] + A[0]",
"-print((K - maxd))",
"+ans = K - maxd",
"+print(ans)"
] | false | 0.036869 | 0.096085 | 0.383714 | [
"s966138681",
"s186616123"
] |
u840310460 | p03495 | python | s857906356 | s788488417 | 309 | 198 | 98,768 | 39,040 | Accepted | Accepted | 35.92 | N, K = [int(i) for i in input().split()]
B = sorted([int(i) for i in input().split()])
D ={}
bag = 0
for i in B:
if i in D:
D[i] += 1
else:
D[i] = 1
LLL = sorted(list(D.values()))
AA = len(D) - K
if len(D) <= K:
print((0))
else:
for i in range(AA):
bag += LLL[i... | N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
dic = {}
for i in A:
if i in dic:
dic[i] += 1
else:
dic[i] = 1
dic_sort = sorted(list(dic.items()), key=lambda x:x[1], reverse=True)
ans = []
for i in range(K, len(dic_sort)):
ans.append(dic_sort[... | 19 | 17 | 335 | 339 | N, K = [int(i) for i in input().split()]
B = sorted([int(i) for i in input().split()])
D = {}
bag = 0
for i in B:
if i in D:
D[i] += 1
else:
D[i] = 1
LLL = sorted(list(D.values()))
AA = len(D) - K
if len(D) <= K:
print((0))
else:
for i in range(AA):
bag += LLL[i]
print(bag)
| N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
dic = {}
for i in A:
if i in dic:
dic[i] += 1
else:
dic[i] = 1
dic_sort = sorted(list(dic.items()), key=lambda x: x[1], reverse=True)
ans = []
for i in range(K, len(dic_sort)):
ans.append(dic_sort[i][1])
print((su... | false | 10.526316 | [
"-B = sorted([int(i) for i in input().split()])",
"-D = {}",
"-bag = 0",
"-for i in B:",
"- if i in D:",
"- D[i] += 1",
"+A = [int(i) for i in input().split()]",
"+dic = {}",
"+for i in A:",
"+ if i in dic:",
"+ dic[i] += 1",
"- D[i] = 1",
"-LLL = sorted(list(D.val... | false | 0.039949 | 0.148855 | 0.268374 | [
"s857906356",
"s788488417"
] |
u476604182 | p02852 | python | s888061853 | s423590165 | 306 | 163 | 29,556 | 10,340 | Accepted | Accepted | 46.73 | from heapq import heappush, heappop
N, M = list(map(int, input().split()))
s = eval(input())
q = [(0,N)]
INF = 10**9
dic = {}
for i in range(N-1, -1, -1):
cnt, j = q[0]
while j-i>M:
heappop(q)
cnt, j = q[0]
heappush(q, (cnt,j))
cnt += 1 if s[i]!='1' else INF
heappush(q, (cnt,i))
dic[i]... | from bisect import bisect_left
N, M = list(map(int, input().split()))
s = eval(input())
safe = []
out = []
cnt = 0
for i, m in enumerate(s):
if m=='1':
out += [i]
cnt += 1
if cnt==M:
print((-1))
break
else:
safe += [i]
cnt = 0
else:
ps = N
ans = []
while ps!=... | 24 | 25 | 415 | 416 | from heapq import heappush, heappop
N, M = list(map(int, input().split()))
s = eval(input())
q = [(0, N)]
INF = 10**9
dic = {}
for i in range(N - 1, -1, -1):
cnt, j = q[0]
while j - i > M:
heappop(q)
cnt, j = q[0]
heappush(q, (cnt, j))
cnt += 1 if s[i] != "1" else INF
heappush(q, (c... | from bisect import bisect_left
N, M = list(map(int, input().split()))
s = eval(input())
safe = []
out = []
cnt = 0
for i, m in enumerate(s):
if m == "1":
out += [i]
cnt += 1
if cnt == M:
print((-1))
break
else:
safe += [i]
cnt = 0
else:
ps = N... | false | 4 | [
"-from heapq import heappush, heappop",
"+from bisect import bisect_left",
"-q = [(0, N)]",
"-INF = 10**9",
"-dic = {}",
"-for i in range(N - 1, -1, -1):",
"- cnt, j = q[0]",
"- while j - i > M:",
"- heappop(q)",
"- cnt, j = q[0]",
"- heappush(q, (cnt, j))",
"- cnt +=... | false | 0.038028 | 0.114508 | 0.332097 | [
"s888061853",
"s423590165"
] |
u572142121 | p03221 | python | s525061195 | s534428694 | 651 | 448 | 37,456 | 97,868 | Accepted | Accepted | 31.18 | N,M=map(int, input().split())
A=[[] for i in range(N)]
for i in range(M):
p,y=map(int, input().split())
A[p-1].append((y, i))
X=[0]*M
for i,d in enumerate(A):
d.sort()
for k,(y,j) in enumerate(d):
X[j]=str(i+1).zfill(6)+str(k+1).zfill(6)
print(*X,sep='\n')
| N,M=list(map(int,input().split()))
A=[[] for i in range(N)]
for i in range(M):
a,b=list(map(int,input().split()))
A[a-1].append((b,i))
ans=[0]*M
for i in range(N):
d=sorted(A[i])
n=len(d)
for j in range(n):
a,b=d[j]
D=str(i+1)
E=str(j+1)
r=D.zfill(6)+E.zfill(6)
ans[b]=r
for ... | 13 | 17 | 282 | 329 | N, M = map(int, input().split())
A = [[] for i in range(N)]
for i in range(M):
p, y = map(int, input().split())
A[p - 1].append((y, i))
X = [0] * M
for i, d in enumerate(A):
d.sort()
for k, (y, j) in enumerate(d):
X[j] = str(i + 1).zfill(6) + str(k + 1).zfill(6)
print(*X, sep="\n")
| N, M = list(map(int, input().split()))
A = [[] for i in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
A[a - 1].append((b, i))
ans = [0] * M
for i in range(N):
d = sorted(A[i])
n = len(d)
for j in range(n):
a, b = d[j]
D = str(i + 1)
E = str(j + 1)
... | false | 23.529412 | [
"-N, M = map(int, input().split())",
"+N, M = list(map(int, input().split()))",
"- p, y = map(int, input().split())",
"- A[p - 1].append((y, i))",
"-X = [0] * M",
"-for i, d in enumerate(A):",
"- d.sort()",
"- for k, (y, j) in enumerate(d):",
"- X[j] = str(i + 1).zfill(6) + str(k ... | false | 0.038032 | 0.038329 | 0.992241 | [
"s525061195",
"s534428694"
] |
u157379742 | p03078 | python | s706927325 | s974162512 | 1,947 | 1,732 | 161,780 | 161,892 | Accepted | Accepted | 11.04 | def int_raw():
return int(eval(input()))
def ss_raw():
return input().split()
def ints_raw():
return list(map(int,ss_raw()))
X,Y,Z,K = ints_raw()
A = list(map(int, input().split()))
B= list(map(int, input().split()))
C= list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=T... | def int_raw():
return int(eval(input()))
def ss_raw():
return input().split()
def ints_raw():
return list(map(int,ss_raw()))
X,Y,Z,K = ints_raw()
A = list(map(int, input().split()))
B= list(map(int, input().split()))
C= list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=T... | 33 | 27 | 632 | 552 | def int_raw():
return int(eval(input()))
def ss_raw():
return input().split()
def ints_raw():
return list(map(int, ss_raw()))
X, Y, Z, K = ints_raw()
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.... | def int_raw():
return int(eval(input()))
def ss_raw():
return input().split()
def ints_raw():
return list(map(int, ss_raw()))
X, Y, Z, K = ints_raw()
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.... | false | 18.181818 | [
"- D = []",
"- for a in A:",
"- for b in B:",
"- D.append(a + b)",
"+ D = [a + b for a in A for b in B]",
"- E = []",
"- for d in D:",
"- for c in C:",
"- E.append(d + c)",
"+ E = [d + c for d in D for c in C]"
] | false | 0.045001 | 0.159784 | 0.281639 | [
"s706927325",
"s974162512"
] |
u968166680 | p02822 | python | s265422435 | s492343357 | 1,228 | 1,081 | 58,132 | 59,080 | Accepted | Accepted | 11.97 | from sys import stdin, setrecursionlimit
from collections import deque
setrecursionlimit(10 ** 9)
INF = 1 << 60
def input():
return stdin.readline().strip()
MOD = 1000000007
N = int(eval(input()))
G = [[] for _ in range(N)]
for _ in range(N - 1):
a, b = list(map(int, input().split()))
G... | from sys import stdin, setrecursionlimit
from collections import deque
setrecursionlimit(10 ** 9)
INF = 1 << 60
def input():
return stdin.readline().strip()
MOD = 1000000007
N = int(stdin.buffer.readline())
m = list(map(int, stdin.buffer.read().split()))
AB = list(zip(m, m))
G = [[] for _ in ran... | 50 | 51 | 1,021 | 1,051 | from sys import stdin, setrecursionlimit
from collections import deque
setrecursionlimit(10**9)
INF = 1 << 60
def input():
return stdin.readline().strip()
MOD = 1000000007
N = int(eval(input()))
G = [[] for _ in range(N)]
for _ in range(N - 1):
a, b = list(map(int, input().split()))
G[a - 1].append(b -... | from sys import stdin, setrecursionlimit
from collections import deque
setrecursionlimit(10**9)
INF = 1 << 60
def input():
return stdin.readline().strip()
MOD = 1000000007
N = int(stdin.buffer.readline())
m = list(map(int, stdin.buffer.read().split()))
AB = list(zip(m, m))
G = [[] for _ in range(N)]
for a, b i... | false | 1.960784 | [
"-N = int(eval(input()))",
"+N = int(stdin.buffer.readline())",
"+m = list(map(int, stdin.buffer.read().split()))",
"+AB = list(zip(m, m))",
"-for _ in range(N - 1):",
"- a, b = list(map(int, input().split()))",
"+for a, b in AB:"
] | false | 0.039168 | 0.039457 | 0.99268 | [
"s265422435",
"s492343357"
] |
u698176039 | p02892 | python | s054702677 | s585100121 | 469 | 279 | 49,128 | 42,224 | Accepted | Accepted | 40.51 | import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
N = int(input())
S = [list(input()) for _ in range(N)]
edge = [[] for _ in range(N)]
for i in range(N):
for j in range(N):
if S[i][j]=='1':
edge[i].append(j)
ans = 0
import queue
for i in range(N):
q = queu... |
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
N = int(eval(input()))
S = [list(eval(input())) for _ in range(N)]
INF = 10**12
dist = [[INF]*N for _ in range(N)]
edge = [[] for _ in range(N)]
for i in range(N):
for j in range(N):
if i==j:
dist[i][j] = 0
... | 35 | 48 | 803 | 991 | import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
N = int(input())
S = [list(input()) for _ in range(N)]
edge = [[] for _ in range(N)]
for i in range(N):
for j in range(N):
if S[i][j] == "1":
edge[i].append(j)
ans = 0
import queue
for i in range(N):
q = queue.Queue()
q... | import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
N = int(eval(input()))
S = [list(eval(input())) for _ in range(N)]
INF = 10**12
dist = [[INF] * N for _ in range(N)]
edge = [[] for _ in range(N)]
for i in range(N):
for j in range(N):
if i == j:
dist[i][j] = 0
if S[i][j... | false | 27.083333 | [
"-N = int(input())",
"-S = [list(input()) for _ in range(N)]",
"+N = int(eval(input()))",
"+S = [list(eval(input())) for _ in range(N)]",
"+INF = 10**12",
"+dist = [[INF] * N for _ in range(N)]",
"+ if i == j:",
"+ dist[i][j] = 0",
"+ dist[i][j] = 1",
"+",
"+",
"+d... | false | 0.134984 | 0.178151 | 0.757695 | [
"s054702677",
"s585100121"
] |
u794173881 | p03215 | python | s908489509 | s821589558 | 1,051 | 233 | 56,504 | 65,916 | Accepted | Accepted | 77.83 | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
ruiseki = [0] * (n + 1)
for i in range(n):
ruiseki[i+1] = ruiseki[i] + a[i]
li = []
for i in range(n):
for j in range(i, n):
tmp = format(ruiseki[j + 1] - ruiseki[i], '040b')
li.append(tmp)
for i in range(... | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
li = []
for i in range(n):
num = 0
for j in range(i, n):
num += a[j]
li.append(num)
ans = 0
for i in range(40)[::-1]:
bit = 2 ** i
new_li = [num for num in li if num&bit != 0]
if len(new_li) ... | 27 | 19 | 587 | 376 | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
ruiseki = [0] * (n + 1)
for i in range(n):
ruiseki[i + 1] = ruiseki[i] + a[i]
li = []
for i in range(n):
for j in range(i, n):
tmp = format(ruiseki[j + 1] - ruiseki[i], "040b")
li.append(tmp)
for i in range(40):
cnt =... | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
li = []
for i in range(n):
num = 0
for j in range(i, n):
num += a[j]
li.append(num)
ans = 0
for i in range(40)[::-1]:
bit = 2**i
new_li = [num for num in li if num & bit != 0]
if len(new_li) >= k:
li =... | false | 29.62963 | [
"-ruiseki = [0] * (n + 1)",
"-for i in range(n):",
"- ruiseki[i + 1] = ruiseki[i] + a[i]",
"+ num = 0",
"- tmp = format(ruiseki[j + 1] - ruiseki[i], \"040b\")",
"- li.append(tmp)",
"-for i in range(40):",
"- cnt = 0",
"- new_li = []",
"- for j in range(len(li)):",
"-... | false | 0.048327 | 0.059249 | 0.815668 | [
"s908489509",
"s821589558"
] |
u046187684 | p03487 | python | s488976325 | s030962652 | 85 | 74 | 20,848 | 19,572 | Accepted | Accepted | 12.94 | #!/usr/bin/env python3
# coding=utf-8
import collections
import sys
n = sys.stdin.readline().strip()
a = sys.stdin.readline().strip().split(" ")
a_count = collections.Counter(a)
ans = 0
for k, v in list(a_count.items()):
if int(k) > v:
ans += v
else:
ans += v - int(k)
print(ans) | from collections import Counter
def solve(string):
n, *a = list(map(int, string.split()))
count = Counter(a)
return str(sum([v if int(k) > v else v - int(k) for k, v in list(count.items())]))
if __name__ == '__main__':
print((solve('\n'.join([eval(input()), eval(input())]))))
| 16 | 11 | 314 | 281 | #!/usr/bin/env python3
# coding=utf-8
import collections
import sys
n = sys.stdin.readline().strip()
a = sys.stdin.readline().strip().split(" ")
a_count = collections.Counter(a)
ans = 0
for k, v in list(a_count.items()):
if int(k) > v:
ans += v
else:
ans += v - int(k)
print(ans)
| from collections import Counter
def solve(string):
n, *a = list(map(int, string.split()))
count = Counter(a)
return str(sum([v if int(k) > v else v - int(k) for k, v in list(count.items())]))
if __name__ == "__main__":
print((solve("\n".join([eval(input()), eval(input())]))))
| false | 31.25 | [
"-#!/usr/bin/env python3",
"-# coding=utf-8",
"-import collections",
"-import sys",
"+from collections import Counter",
"-n = sys.stdin.readline().strip()",
"-a = sys.stdin.readline().strip().split(\" \")",
"-a_count = collections.Counter(a)",
"-ans = 0",
"-for k, v in list(a_count.items()):",
"... | false | 0.085474 | 0.112937 | 0.756832 | [
"s488976325",
"s030962652"
] |
u657818166 | p03846 | python | s130812203 | s593928943 | 96 | 47 | 14,436 | 13,812 | Accepted | Accepted | 51.04 | n=int(eval(input()))
l=list(map(int,input().split()))
nOdd=len(l)%2==1
if nOdd:
num=[x for x in range(n) if n%2==0]
else:
num=[x for x in range(n) if n%2!=0]
dic={}
for i in num:
dic[i]=0
for i in l:
dic.setdefault(i,0)
dic[i]+=1
for i,c in list(dic.items()):
if i==0 and nOdd:
... | import math
n=int(eval(input()))
arr=list(map(int,input().split()))
ans=True
if n%2!=0:
if arr.count(0)!=1:
ans=False
elif len(set(arr))!=int(n/2)+1:
ans=False
else:
if 0 in arr:
ans=False
elif len(set(arr))!=int(n/2):
ans=False
if ans:
print((2**math.... | 28 | 20 | 520 | 357 | n = int(eval(input()))
l = list(map(int, input().split()))
nOdd = len(l) % 2 == 1
if nOdd:
num = [x for x in range(n) if n % 2 == 0]
else:
num = [x for x in range(n) if n % 2 != 0]
dic = {}
for i in num:
dic[i] = 0
for i in l:
dic.setdefault(i, 0)
dic[i] += 1
for i, c in list(dic.items()):
if i ... | import math
n = int(eval(input()))
arr = list(map(int, input().split()))
ans = True
if n % 2 != 0:
if arr.count(0) != 1:
ans = False
elif len(set(arr)) != int(n / 2) + 1:
ans = False
else:
if 0 in arr:
ans = False
elif len(set(arr)) != int(n / 2):
ans = False
if ans:
... | false | 28.571429 | [
"+import math",
"+",
"-l = list(map(int, input().split()))",
"-nOdd = len(l) % 2 == 1",
"-if nOdd:",
"- num = [x for x in range(n) if n % 2 == 0]",
"+arr = list(map(int, input().split()))",
"+ans = True",
"+if n % 2 != 0:",
"+ if arr.count(0) != 1:",
"+ ans = False",
"+ elif le... | false | 0.054532 | 0.077617 | 0.702583 | [
"s130812203",
"s593928943"
] |
u740284863 | p03380 | python | s699189661 | s642913715 | 109 | 71 | 14,052 | 14,428 | Accepted | Accepted | 34.86 | n = int(eval(input()))
a = list(map(int,input().split()))
a.sort()
dis = [abs(a[-1]/2 - a[i]) for i in range(n-1)]
r = a[dis.index(min(dis))]
print((a[-1],r)) | n = int(eval(input()))
a = list(map(int,input().split()))
m = max(a)
del a[a.index(m)]
dis = [abs(m/2 - a[i]) for i in range(n-1)]
r = a[dis.index(min(dis))]
print((m,r)) | 6 | 7 | 155 | 168 | n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
dis = [abs(a[-1] / 2 - a[i]) for i in range(n - 1)]
r = a[dis.index(min(dis))]
print((a[-1], r))
| n = int(eval(input()))
a = list(map(int, input().split()))
m = max(a)
del a[a.index(m)]
dis = [abs(m / 2 - a[i]) for i in range(n - 1)]
r = a[dis.index(min(dis))]
print((m, r))
| false | 14.285714 | [
"-a.sort()",
"-dis = [abs(a[-1] / 2 - a[i]) for i in range(n - 1)]",
"+m = max(a)",
"+del a[a.index(m)]",
"+dis = [abs(m / 2 - a[i]) for i in range(n - 1)]",
"-print((a[-1], r))",
"+print((m, r))"
] | false | 0.079629 | 0.133619 | 0.59594 | [
"s699189661",
"s642913715"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.