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
sequence | 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
sequence |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u729133443 | p03657 | python | s252569931 | s579542506 | 107 | 27 | 61,008 | 9,028 | Accepted | Accepted | 74.77 | print(((eval(input().replace(*' *'))%3%2*'Imp'or'P')+'ossible')) | print(f"{eval(input().replace(*' *'))%3%2*'Imp'or'P'}ossible") | 1 | 1 | 62 | 62 | print(((eval(input().replace(*" *")) % 3 % 2 * "Imp" or "P") + "ossible"))
| print(f"{eval(input().replace(*' *'))%3%2*'Imp'or'P'}ossible")
| false | 0 | [
"-print(((eval(input().replace(*\" *\")) % 3 % 2 * \"Imp\" or \"P\") + \"ossible\"))",
"+print(f\"{eval(input().replace(*' *'))%3%2*'Imp'or'P'}ossible\")"
] | false | 0.046969 | 0.150594 | 0.31189 | [
"s252569931",
"s579542506"
] |
u078349616 | p02837 | python | s425424388 | s635043712 | 280 | 257 | 3,064 | 3,064 | Accepted | Accepted | 8.21 | from itertools import product
N = int(eval(input()))
A = []
XY = [[] for _ in range(N)]
for i in range(N):
A.append(int(eval(input())))
for j in range(A[i]):
XY[i].append(list(map(int, input().split())))
ans = 0
for pattern in product(list(range(2)), repeat=N): # 0:不正直 1:正直
flag = True
for i in range(N):
if pattern[i]: # iさんが正直と仮定
# 発言と一致するか?
for a in range(A[i]):
if pattern[XY[i][a][0]-1] != XY[i][a][1]:
flag = False
break
if flag:
ans = max(ans, sum(pattern))
print(ans) | N = int(eval(input()))
XY = []
for i in range(N):
A = int(eval(input()))
XY.append([list(map(int, input().split())) for _ in range(A)])
ans = 0
for bit in range(1 << N):
honest_cnt = 0
flag = True
for i in range(N):
if (bit >> i) & 1 == 0:
continue
honest_cnt += 1
for x, y in XY[i]:
if (bit >> (x-1)) & 1 != y:
flag = False
break
if flag:
ans = max(ans, honest_cnt)
print(ans) | 24 | 22 | 547 | 448 | from itertools import product
N = int(eval(input()))
A = []
XY = [[] for _ in range(N)]
for i in range(N):
A.append(int(eval(input())))
for j in range(A[i]):
XY[i].append(list(map(int, input().split())))
ans = 0
for pattern in product(list(range(2)), repeat=N): # 0:不正直 1:正直
flag = True
for i in range(N):
if pattern[i]: # iさんが正直と仮定
# 発言と一致するか?
for a in range(A[i]):
if pattern[XY[i][a][0] - 1] != XY[i][a][1]:
flag = False
break
if flag:
ans = max(ans, sum(pattern))
print(ans)
| N = int(eval(input()))
XY = []
for i in range(N):
A = int(eval(input()))
XY.append([list(map(int, input().split())) for _ in range(A)])
ans = 0
for bit in range(1 << N):
honest_cnt = 0
flag = True
for i in range(N):
if (bit >> i) & 1 == 0:
continue
honest_cnt += 1
for x, y in XY[i]:
if (bit >> (x - 1)) & 1 != y:
flag = False
break
if flag:
ans = max(ans, honest_cnt)
print(ans)
| false | 8.333333 | [
"-from itertools import product",
"-",
"-A = []",
"-XY = [[] for _ in range(N)]",
"+XY = []",
"- A.append(int(eval(input())))",
"- for j in range(A[i]):",
"- XY[i].append(list(map(int, input().split())))",
"+ A = int(eval(input()))",
"+ XY.append([list(map(int, input().split())) for _ in range(A)])",
"-for pattern in product(list(range(2)), repeat=N): # 0:不正直 1:正直",
"+for bit in range(1 << N):",
"+ honest_cnt = 0",
"- if pattern[i]: # iさんが正直と仮定",
"- # 発言と一致するか?",
"- for a in range(A[i]):",
"- if pattern[XY[i][a][0] - 1] != XY[i][a][1]:",
"- flag = False",
"- break",
"+ if (bit >> i) & 1 == 0:",
"+ continue",
"+ honest_cnt += 1",
"+ for x, y in XY[i]:",
"+ if (bit >> (x - 1)) & 1 != y:",
"+ flag = False",
"+ break",
"- ans = max(ans, sum(pattern))",
"+ ans = max(ans, honest_cnt)"
] | false | 0.09691 | 0.109525 | 0.884821 | [
"s425424388",
"s635043712"
] |
u993435350 | p03167 | python | s152996730 | s537488890 | 781 | 211 | 60,504 | 14,408 | Accepted | Accepted | 72.98 | import sys
import numpy as np
from functools import lru_cache
from collections import deque
#input = sys.stdin.readline
#sys.setrecursionlimit(10 ** 5)
H,W = list(map(int,input().split()))
grid = [list(eval(input())) for i in range(H)]
dp = [[0] * (W + 1) for i in range(H + 1)]
dp[0][0] = 1
mod = (10 ** 9) + 7
for i in range(H):
for j in range(W):
if i > 0 or j > 0:
if grid[i][j] == "#":
dp[i][j] = 0
else:
dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod
print((dp[H - 1][W - 1]))
#print(dp) | import sys
buf = sys.stdin.buffer
import numpy as np
MOD = 10 ** 9 + 7
H,W = list(map(int,buf.readline().split()))
grid = np.frombuffer(buf.read(),dtype='S1').reshape(H,-1)[:,:W]
#print(grid)
MOD = 10 ** 9 + 7
dp = np.zeros(W, dtype = np.int64)
dp[0] = 1
for row in grid:
#print(row == b"#")
wall = (row == b'#')
# 上から落としてくる
dp[wall] = 0
# 左から右に
np.cumsum(dp, out = dp)
# 壁の補正
sub = np.maximum.accumulate(dp * wall)
dp -= sub
dp %= MOD
answer = dp[-1]
print(answer) | 24 | 30 | 540 | 515 | import sys
import numpy as np
from functools import lru_cache
from collections import deque
# input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 5)
H, W = list(map(int, input().split()))
grid = [list(eval(input())) for i in range(H)]
dp = [[0] * (W + 1) for i in range(H + 1)]
dp[0][0] = 1
mod = (10**9) + 7
for i in range(H):
for j in range(W):
if i > 0 or j > 0:
if grid[i][j] == "#":
dp[i][j] = 0
else:
dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod
print((dp[H - 1][W - 1]))
# print(dp)
| import sys
buf = sys.stdin.buffer
import numpy as np
MOD = 10**9 + 7
H, W = list(map(int, buf.readline().split()))
grid = np.frombuffer(buf.read(), dtype="S1").reshape(H, -1)[:, :W]
# print(grid)
MOD = 10**9 + 7
dp = np.zeros(W, dtype=np.int64)
dp[0] = 1
for row in grid:
# print(row == b"#")
wall = row == b"#"
# 上から落としてくる
dp[wall] = 0
# 左から右に
np.cumsum(dp, out=dp)
# 壁の補正
sub = np.maximum.accumulate(dp * wall)
dp -= sub
dp %= MOD
answer = dp[-1]
print(answer)
| false | 20 | [
"+",
"+buf = sys.stdin.buffer",
"-from functools import lru_cache",
"-from collections import deque",
"-# input = sys.stdin.readline",
"-# sys.setrecursionlimit(10 ** 5)",
"-H, W = list(map(int, input().split()))",
"-grid = [list(eval(input())) for i in range(H)]",
"-dp = [[0] * (W + 1) for i in range(H + 1)]",
"-dp[0][0] = 1",
"-mod = (10**9) + 7",
"-for i in range(H):",
"- for j in range(W):",
"- if i > 0 or j > 0:",
"- if grid[i][j] == \"#\":",
"- dp[i][j] = 0",
"- else:",
"- dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod",
"-print((dp[H - 1][W - 1]))",
"-# print(dp)",
"+MOD = 10**9 + 7",
"+H, W = list(map(int, buf.readline().split()))",
"+grid = np.frombuffer(buf.read(), dtype=\"S1\").reshape(H, -1)[:, :W]",
"+# print(grid)",
"+MOD = 10**9 + 7",
"+dp = np.zeros(W, dtype=np.int64)",
"+dp[0] = 1",
"+for row in grid:",
"+ # print(row == b\"#\")",
"+ wall = row == b\"#\"",
"+ # 上から落としてくる",
"+ dp[wall] = 0",
"+ # 左から右に",
"+ np.cumsum(dp, out=dp)",
"+ # 壁の補正",
"+ sub = np.maximum.accumulate(dp * wall)",
"+ dp -= sub",
"+ dp %= MOD",
"+answer = dp[-1]",
"+print(answer)"
] | false | 0.044151 | 0.25937 | 0.170226 | [
"s152996730",
"s537488890"
] |
u392029857 | p03556 | python | s273873551 | s903554806 | 65 | 17 | 3,188 | 3,060 | Accepted | Accepted | 73.85 | n = int(eval(input()))
for i in range(n,0,-1):
if i**0.5 == int(i**0.5):
ans = i
break
print(ans) | n = int(eval(input()))
print((int(n**0.5)**2)) | 6 | 2 | 116 | 39 | n = int(eval(input()))
for i in range(n, 0, -1):
if i**0.5 == int(i**0.5):
ans = i
break
print(ans)
| n = int(eval(input()))
print((int(n**0.5) ** 2))
| false | 66.666667 | [
"-for i in range(n, 0, -1):",
"- if i**0.5 == int(i**0.5):",
"- ans = i",
"- break",
"-print(ans)",
"+print((int(n**0.5) ** 2))"
] | false | 0.048732 | 0.038416 | 1.268549 | [
"s273873551",
"s903554806"
] |
u677096240 | p02408 | python | s826737558 | s865280692 | 30 | 20 | 5,604 | 5,600 | Accepted | Accepted | 33.33 | n = int(input())
cards, suits = [], ["S", "H", "C", "D"]
for suit in suits:
for x in range(1, 14):
cards.append('{} {}'.format(suit, x))
for _ in range(n):
target = ' '.join(input().split())
if target in cards:
cards.remove(target)
[print(c) for c in cards]
| # 2次元配列バージョン
# かつ、内包表記バージョン
n = int(input())
suits = ["S", "H", "C", "D"]
cards = [[s, n] for s in suits for n in range(1, 14)]
for i in range(n):
target = list(map(
lambda a: int(a) if a.isnumeric() else a, input().split()
))
if target in cards:
cards.remove(target)
[print("{} {}".format(c[0], c[1])) for c in cards]
| 12 | 13 | 299 | 360 | n = int(input())
cards, suits = [], ["S", "H", "C", "D"]
for suit in suits:
for x in range(1, 14):
cards.append("{} {}".format(suit, x))
for _ in range(n):
target = " ".join(input().split())
if target in cards:
cards.remove(target)
[print(c) for c in cards]
| # 2次元配列バージョン
# かつ、内包表記バージョン
n = int(input())
suits = ["S", "H", "C", "D"]
cards = [[s, n] for s in suits for n in range(1, 14)]
for i in range(n):
target = list(map(lambda a: int(a) if a.isnumeric() else a, input().split()))
if target in cards:
cards.remove(target)
[print("{} {}".format(c[0], c[1])) for c in cards]
| false | 7.692308 | [
"+# 2次元配列バージョン",
"+# かつ、内包表記バージョン",
"-cards, suits = [], [\"S\", \"H\", \"C\", \"D\"]",
"-for suit in suits:",
"- for x in range(1, 14):",
"- cards.append(\"{} {}\".format(suit, x))",
"-for _ in range(n):",
"- target = \" \".join(input().split())",
"+suits = [\"S\", \"H\", \"C\", \"D\"]",
"+cards = [[s, n] for s in suits for n in range(1, 14)]",
"+for i in range(n):",
"+ target = list(map(lambda a: int(a) if a.isnumeric() else a, input().split()))",
"-[print(c) for c in cards]",
"+[print(\"{} {}\".format(c[0], c[1])) for c in cards]"
] | false | 0.044207 | 0.061583 | 0.717848 | [
"s826737558",
"s865280692"
] |
u150984829 | p02315 | python | s966994156 | s012228070 | 360 | 330 | 5,924 | 5,928 | Accepted | Accepted | 8.33 | N,W=list(map(int,input().split()))
I=[[*list(map(int,input().split()))]for _ in[0]*N]
C=[0]*-~W
for i in range(1,N+1):
v,w=I[~-i]
for j in range(W,w-1,-1):
t=v+C[j-w]
if t>C[j]:C[j]=t
print((C[W]))
| import sys
W=int(input().split()[1])
C=[0]*-~W
for e in sys.stdin:
v,w=list(map(int,e.split()))
for i in range(W,w-1,-1):
t=v+C[i-w]
if t>C[i]:C[i]=t
print((C[W]))
| 9 | 9 | 198 | 170 | N, W = list(map(int, input().split()))
I = [[*list(map(int, input().split()))] for _ in [0] * N]
C = [0] * -~W
for i in range(1, N + 1):
v, w = I[~-i]
for j in range(W, w - 1, -1):
t = v + C[j - w]
if t > C[j]:
C[j] = t
print((C[W]))
| import sys
W = int(input().split()[1])
C = [0] * -~W
for e in sys.stdin:
v, w = list(map(int, e.split()))
for i in range(W, w - 1, -1):
t = v + C[i - w]
if t > C[i]:
C[i] = t
print((C[W]))
| false | 0 | [
"-N, W = list(map(int, input().split()))",
"-I = [[*list(map(int, input().split()))] for _ in [0] * N]",
"+import sys",
"+",
"+W = int(input().split()[1])",
"-for i in range(1, N + 1):",
"- v, w = I[~-i]",
"- for j in range(W, w - 1, -1):",
"- t = v + C[j - w]",
"- if t > C[j]:",
"- C[j] = t",
"+for e in sys.stdin:",
"+ v, w = list(map(int, e.split()))",
"+ for i in range(W, w - 1, -1):",
"+ t = v + C[i - w]",
"+ if t > C[i]:",
"+ C[i] = t"
] | false | 0.0417 | 0.067333 | 0.619305 | [
"s966994156",
"s012228070"
] |
u624475441 | p03290 | python | s468722663 | s706260018 | 515 | 23 | 3,188 | 3,064 | Accepted | Accepted | 95.53 | D,G = list(map(int,input().split()))
P = []
num_p = 0
for i in range(1,D+1):
p,c = list(map(int,input().split()))
num_p += p
for j in range(1,p+1):
P += [(j,i*100*j+c*(j==p))]
dp = [0]*(num_p+1)
for k,pt in P:
if k==1:
t_dp = dp[:]
for cur in range(1,num_p+1):
if cur>=k:
dp[cur] = max(dp[cur], t_dp[cur-k]+pt)
for i in range(num_p+1):
if dp[i]>=G:
print(i)
break | d,g = list(map(int,input().split()))
pc = [list(map(int,input().split()))for _ in[0]*d]
ans = []
for mask in range(1 << d):
s = 0
num = 0
rest_max = -1
for i in range(d):
p,c = pc[i]
if mask >> i & 1:
s += p * 100 * (i + 1) + c
num += p
else:
rest_max = i
if s < g:
s1 = 100 * (rest_max + 1)
need = (g - s + s1 - 1) // s1
if need >= pc[rest_max][0]:
continue
num += need
ans.append(num)
print((min(ans))) | 19 | 22 | 445 | 545 | D, G = list(map(int, input().split()))
P = []
num_p = 0
for i in range(1, D + 1):
p, c = list(map(int, input().split()))
num_p += p
for j in range(1, p + 1):
P += [(j, i * 100 * j + c * (j == p))]
dp = [0] * (num_p + 1)
for k, pt in P:
if k == 1:
t_dp = dp[:]
for cur in range(1, num_p + 1):
if cur >= k:
dp[cur] = max(dp[cur], t_dp[cur - k] + pt)
for i in range(num_p + 1):
if dp[i] >= G:
print(i)
break
| d, g = list(map(int, input().split()))
pc = [list(map(int, input().split())) for _ in [0] * d]
ans = []
for mask in range(1 << d):
s = 0
num = 0
rest_max = -1
for i in range(d):
p, c = pc[i]
if mask >> i & 1:
s += p * 100 * (i + 1) + c
num += p
else:
rest_max = i
if s < g:
s1 = 100 * (rest_max + 1)
need = (g - s + s1 - 1) // s1
if need >= pc[rest_max][0]:
continue
num += need
ans.append(num)
print((min(ans)))
| false | 13.636364 | [
"-D, G = list(map(int, input().split()))",
"-P = []",
"-num_p = 0",
"-for i in range(1, D + 1):",
"- p, c = list(map(int, input().split()))",
"- num_p += p",
"- for j in range(1, p + 1):",
"- P += [(j, i * 100 * j + c * (j == p))]",
"-dp = [0] * (num_p + 1)",
"-for k, pt in P:",
"- if k == 1:",
"- t_dp = dp[:]",
"- for cur in range(1, num_p + 1):",
"- if cur >= k:",
"- dp[cur] = max(dp[cur], t_dp[cur - k] + pt)",
"-for i in range(num_p + 1):",
"- if dp[i] >= G:",
"- print(i)",
"- break",
"+d, g = list(map(int, input().split()))",
"+pc = [list(map(int, input().split())) for _ in [0] * d]",
"+ans = []",
"+for mask in range(1 << d):",
"+ s = 0",
"+ num = 0",
"+ rest_max = -1",
"+ for i in range(d):",
"+ p, c = pc[i]",
"+ if mask >> i & 1:",
"+ s += p * 100 * (i + 1) + c",
"+ num += p",
"+ else:",
"+ rest_max = i",
"+ if s < g:",
"+ s1 = 100 * (rest_max + 1)",
"+ need = (g - s + s1 - 1) // s1",
"+ if need >= pc[rest_max][0]:",
"+ continue",
"+ num += need",
"+ ans.append(num)",
"+print((min(ans)))"
] | false | 0.045702 | 0.036726 | 1.244398 | [
"s468722663",
"s706260018"
] |
u759412327 | p03043 | python | s846763596 | s781343602 | 60 | 47 | 2,940 | 9,124 | Accepted | Accepted | 21.67 | n,k = list(map(int, input().split()))
a = 0
for i in range(n):
s=i+1
c=0
while s<=k-1:
c+=1
s*=2
a+=1/n*(1/2**c)
print(a) | N,K = list(map(int, input().split()))
a = 0
for n in range(1,N+1):
c = 0
while n<K:
c+=1
n*=2
a+=(1/2**c)/N
print(a) | 12 | 11 | 144 | 136 | n, k = list(map(int, input().split()))
a = 0
for i in range(n):
s = i + 1
c = 0
while s <= k - 1:
c += 1
s *= 2
a += 1 / n * (1 / 2**c)
print(a)
| N, K = list(map(int, input().split()))
a = 0
for n in range(1, N + 1):
c = 0
while n < K:
c += 1
n *= 2
a += (1 / 2**c) / N
print(a)
| false | 8.333333 | [
"-n, k = list(map(int, input().split()))",
"+N, K = list(map(int, input().split()))",
"-for i in range(n):",
"- s = i + 1",
"+for n in range(1, N + 1):",
"- while s <= k - 1:",
"+ while n < K:",
"- s *= 2",
"- a += 1 / n * (1 / 2**c)",
"+ n *= 2",
"+ a += (1 / 2**c) / N"
] | false | 0.054192 | 0.050734 | 1.068173 | [
"s846763596",
"s781343602"
] |
u857547702 | p02713 | python | s207436570 | s453701423 | 1,386 | 1,011 | 188,952 | 69,836 | Accepted | Accepted | 27.06 | import math
from functools import reduce
def gcd(*numbers):
return reduce(math.gcd, numbers)
K=int(eval(input()))
ans=[]
for i in range(1,K+1):
for j in range(1,K+1):
for k in range(1,K+1):
ans.append(gcd(i,j,k))
print((sum(ans))) | import math
from functools import reduce
def gcd(*numbers):
return reduce(math.gcd, numbers)
K=int(eval(input()))
ans=0
for i in range(1,K+1):
for j in range(1,K+1):
for k in range(1,K+1):
ans+=gcd(i,j,k)
print(ans) | 12 | 12 | 265 | 249 | import math
from functools import reduce
def gcd(*numbers):
return reduce(math.gcd, numbers)
K = int(eval(input()))
ans = []
for i in range(1, K + 1):
for j in range(1, K + 1):
for k in range(1, K + 1):
ans.append(gcd(i, j, k))
print((sum(ans)))
| import math
from functools import reduce
def gcd(*numbers):
return reduce(math.gcd, numbers)
K = int(eval(input()))
ans = 0
for i in range(1, K + 1):
for j in range(1, K + 1):
for k in range(1, K + 1):
ans += gcd(i, j, k)
print(ans)
| false | 0 | [
"-ans = []",
"+ans = 0",
"- ans.append(gcd(i, j, k))",
"-print((sum(ans)))",
"+ ans += gcd(i, j, k)",
"+print(ans)"
] | false | 0.037301 | 0.044312 | 0.84178 | [
"s207436570",
"s453701423"
] |
u923668099 | p02402 | python | s263054226 | s318169008 | 30 | 20 | 8,600 | 8,684 | Accepted | Accepted | 33.33 | # coding: utf-8
# Here your code !
n = int(eval(input()))
a = list(map(int, input().split()))
print((min(a),max(a),sum(a))) | eval(input())
a = [int(i) for i in input().split()]
print((min(a),max(a),sum(a))) | 6 | 4 | 121 | 77 | # coding: utf-8
# Here your code !
n = int(eval(input()))
a = list(map(int, input().split()))
print((min(a), max(a), sum(a)))
| eval(input())
a = [int(i) for i in input().split()]
print((min(a), max(a), sum(a)))
| false | 33.333333 | [
"-# coding: utf-8",
"-# Here your code !",
"-n = int(eval(input()))",
"-a = list(map(int, input().split()))",
"+eval(input())",
"+a = [int(i) for i in input().split()]"
] | false | 0.048757 | 0.049488 | 0.985234 | [
"s263054226",
"s318169008"
] |
u414980766 | p02913 | python | s003301092 | s576043624 | 1,640 | 1,141 | 3,060 | 3,064 | Accepted | Accepted | 30.43 | N = int(eval(input()))
S = eval(input())
r = 0
ans = 0
for i in range(N):
while True:
if S.rfind(S[i : r + 1]) >= r + 1:
r += 1
ans = max(ans, r - i)
else:
break
print(ans) | N = int(eval(input()))
S = eval(input())
l = 0
k = 1
for i in range(N - 1):
while True:
if S[i : i + k] in S[i + k :]:
k += 1
else:
break
l = max(l, k - 1)
print(l) | 12 | 12 | 227 | 211 | N = int(eval(input()))
S = eval(input())
r = 0
ans = 0
for i in range(N):
while True:
if S.rfind(S[i : r + 1]) >= r + 1:
r += 1
ans = max(ans, r - i)
else:
break
print(ans)
| N = int(eval(input()))
S = eval(input())
l = 0
k = 1
for i in range(N - 1):
while True:
if S[i : i + k] in S[i + k :]:
k += 1
else:
break
l = max(l, k - 1)
print(l)
| false | 0 | [
"-r = 0",
"-ans = 0",
"-for i in range(N):",
"+l = 0",
"+k = 1",
"+for i in range(N - 1):",
"- if S.rfind(S[i : r + 1]) >= r + 1:",
"- r += 1",
"- ans = max(ans, r - i)",
"+ if S[i : i + k] in S[i + k :]:",
"+ k += 1",
"-print(ans)",
"+ l = max(l, k - 1)",
"+print(l)"
] | false | 0.007836 | 0.040879 | 0.191679 | [
"s003301092",
"s576043624"
] |
u644907318 | p02571 | python | s681007106 | s135795605 | 81 | 67 | 67,456 | 72,760 | Accepted | Accepted | 17.28 | S = input().strip()
T = input().strip()
k = len(T)
dmin = len(S)
for i in range(len(S)-k+1):
cnt = 0
for j in range(k):
if S[i+j]!=T[j]:
cnt += 1
dmin = min(dmin,cnt)
print(dmin) | S = input().strip()
N = len(S)
T = input().strip()
k = len(T)
cmin = N
for i in range(N-k+1):
cnt = 0
for j in range(k):
if S[i+j]!=T[j]:
cnt += 1
cmin = min(cmin,cnt)
print(cmin) | 11 | 12 | 220 | 222 | S = input().strip()
T = input().strip()
k = len(T)
dmin = len(S)
for i in range(len(S) - k + 1):
cnt = 0
for j in range(k):
if S[i + j] != T[j]:
cnt += 1
dmin = min(dmin, cnt)
print(dmin)
| S = input().strip()
N = len(S)
T = input().strip()
k = len(T)
cmin = N
for i in range(N - k + 1):
cnt = 0
for j in range(k):
if S[i + j] != T[j]:
cnt += 1
cmin = min(cmin, cnt)
print(cmin)
| false | 8.333333 | [
"+N = len(S)",
"-dmin = len(S)",
"-for i in range(len(S) - k + 1):",
"+cmin = N",
"+for i in range(N - k + 1):",
"- dmin = min(dmin, cnt)",
"-print(dmin)",
"+ cmin = min(cmin, cnt)",
"+print(cmin)"
] | false | 0.045515 | 0.044636 | 1.019685 | [
"s681007106",
"s135795605"
] |
u994988729 | p03971 | python | s282933097 | s312054717 | 111 | 88 | 4,016 | 6,344 | Accepted | Accepted | 20.72 | n, a, b = list(map(int, input().split()))
s = eval(input())
A = 0
B = 0
for i in s:
if A + B < a + b:
if i == "a":
A += 1
print("Yes")
elif i == "b" and B < b:
B += 1
print("Yes")
else:
print("No")
else:
print("No")
| N, A, B = map(int, input().split())
S = input()
total = 0
tot_b = 0
ans = []
for s in S:
if s == "a" and total < A + B:
ans.append("Yes")
total += 1
elif s == "b" and total < A + B and tot_b < B:
ans.append("Yes")
tot_b += 1
total += 1
else:
ans.append("No")
print(*ans, sep="\n")
| 17 | 20 | 321 | 364 | n, a, b = list(map(int, input().split()))
s = eval(input())
A = 0
B = 0
for i in s:
if A + B < a + b:
if i == "a":
A += 1
print("Yes")
elif i == "b" and B < b:
B += 1
print("Yes")
else:
print("No")
else:
print("No")
| N, A, B = map(int, input().split())
S = input()
total = 0
tot_b = 0
ans = []
for s in S:
if s == "a" and total < A + B:
ans.append("Yes")
total += 1
elif s == "b" and total < A + B and tot_b < B:
ans.append("Yes")
tot_b += 1
total += 1
else:
ans.append("No")
print(*ans, sep="\n")
| false | 15 | [
"-n, a, b = list(map(int, input().split()))",
"-s = eval(input())",
"-A = 0",
"-B = 0",
"-for i in s:",
"- if A + B < a + b:",
"- if i == \"a\":",
"- A += 1",
"- print(\"Yes\")",
"- elif i == \"b\" and B < b:",
"- B += 1",
"- print(\"Yes\")",
"- else:",
"- print(\"No\")",
"+N, A, B = map(int, input().split())",
"+S = input()",
"+total = 0",
"+tot_b = 0",
"+ans = []",
"+for s in S:",
"+ if s == \"a\" and total < A + B:",
"+ ans.append(\"Yes\")",
"+ total += 1",
"+ elif s == \"b\" and total < A + B and tot_b < B:",
"+ ans.append(\"Yes\")",
"+ tot_b += 1",
"+ total += 1",
"- print(\"No\")",
"+ ans.append(\"No\")",
"+print(*ans, sep=\"\\n\")"
] | false | 0.044473 | 0.00843 | 5.275863 | [
"s282933097",
"s312054717"
] |
u245641078 | p03860 | python | s530712296 | s267935931 | 27 | 23 | 8,908 | 8,924 | Accepted | Accepted | 14.81 | print(("A%sC"%input()[8])) | print(("A"+input()[8]+"C")) | 1 | 1 | 24 | 25 | print(("A%sC" % input()[8]))
| print(("A" + input()[8] + "C"))
| false | 0 | [
"-print((\"A%sC\" % input()[8]))",
"+print((\"A\" + input()[8] + \"C\"))"
] | false | 0.03998 | 0.036637 | 1.091238 | [
"s530712296",
"s267935931"
] |
u745561510 | p03161 | python | s361970047 | s247419321 | 474 | 415 | 55,392 | 55,264 | Accepted | Accepted | 12.45 | N, K = list(map(int,input().split()))
h = list(map(int,input().split()))
dp = [float("inf")] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2,N):
for j in range(1,K+1):
dp[i] = min(dp[i],dp[i-j] + abs(h[i] - h[i-j]))
print((dp[-1])) | N, K = list(map(int, input().split()))
h = list(map(int, input().split()))
ans = [float("inf")] * N
ans[0] = 0
for i in range(N-1):
for j in range(1, K+1):
if i + j > N - 1:
continue
ans[i+j] = min(ans[i+j], ans[i] + abs(h[i] - h[i+j]))
print((ans[-1])) | 12 | 11 | 257 | 290 | N, K = list(map(int, input().split()))
h = list(map(int, input().split()))
dp = [float("inf")] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, N):
for j in range(1, K + 1):
dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))
print((dp[-1]))
| N, K = list(map(int, input().split()))
h = list(map(int, input().split()))
ans = [float("inf")] * N
ans[0] = 0
for i in range(N - 1):
for j in range(1, K + 1):
if i + j > N - 1:
continue
ans[i + j] = min(ans[i + j], ans[i] + abs(h[i] - h[i + j]))
print((ans[-1]))
| false | 8.333333 | [
"-dp = [float(\"inf\")] * N",
"-dp[0] = 0",
"-dp[1] = abs(h[1] - h[0])",
"-for i in range(2, N):",
"+ans = [float(\"inf\")] * N",
"+ans[0] = 0",
"+for i in range(N - 1):",
"- dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))",
"-print((dp[-1]))",
"+ if i + j > N - 1:",
"+ continue",
"+ ans[i + j] = min(ans[i + j], ans[i] + abs(h[i] - h[i + j]))",
"+print((ans[-1]))"
] | false | 0.038095 | 0.092808 | 0.410475 | [
"s361970047",
"s247419321"
] |
u761320129 | p02984 | python | s727144591 | s802968429 | 132 | 118 | 14,100 | 14,092 | Accepted | Accepted | 10.61 | N = list(map(int,input().split()))
A = list(map(int,input().split()))
x = 0
for a in A:
x = (a - x//2) * 2
x //= 2
ans = []
for a in A:
ans.append(x)
x = (a - x//2) * 2
print((*ans)) | N = int(eval(input()))
A = list(map(int,input().split()))
e = sum(A[::2])
o = sum(A[1::2])
ans = [e-o]
for a in A:
ans.append(2*(a-ans[-1]//2))
ans.pop()
print((*ans)) | 13 | 9 | 200 | 171 | N = list(map(int, input().split()))
A = list(map(int, input().split()))
x = 0
for a in A:
x = (a - x // 2) * 2
x //= 2
ans = []
for a in A:
ans.append(x)
x = (a - x // 2) * 2
print((*ans))
| N = int(eval(input()))
A = list(map(int, input().split()))
e = sum(A[::2])
o = sum(A[1::2])
ans = [e - o]
for a in A:
ans.append(2 * (a - ans[-1] // 2))
ans.pop()
print((*ans))
| false | 30.769231 | [
"-N = list(map(int, input().split()))",
"+N = int(eval(input()))",
"-x = 0",
"+e = sum(A[::2])",
"+o = sum(A[1::2])",
"+ans = [e - o]",
"- x = (a - x // 2) * 2",
"-x //= 2",
"-ans = []",
"-for a in A:",
"- ans.append(x)",
"- x = (a - x // 2) * 2",
"+ ans.append(2 * (a - ans[-1] // 2))",
"+ans.pop()"
] | false | 0.036201 | 0.063443 | 0.570608 | [
"s727144591",
"s802968429"
] |
u607074939 | p03644 | python | s681260188 | s520394499 | 20 | 17 | 3,060 | 3,060 | Accepted | Accepted | 15 | N=int(eval(input()))
n=1
while(2*n<=N):
n*=2
print(n) | n = int(eval(input()))
count = 0
max = 0
for i in range(1, n+1):
while(i%2 ==0):
i = i/2
count +=1
if(max < count):
max = count
count = 0
print((2**max)) | 7 | 11 | 59 | 191 | N = int(eval(input()))
n = 1
while 2 * n <= N:
n *= 2
print(n)
| n = int(eval(input()))
count = 0
max = 0
for i in range(1, n + 1):
while i % 2 == 0:
i = i / 2
count += 1
if max < count:
max = count
count = 0
print((2**max))
| false | 36.363636 | [
"-N = int(eval(input()))",
"-n = 1",
"-while 2 * n <= N:",
"- n *= 2",
"-print(n)",
"+n = int(eval(input()))",
"+count = 0",
"+max = 0",
"+for i in range(1, n + 1):",
"+ while i % 2 == 0:",
"+ i = i / 2",
"+ count += 1",
"+ if max < count:",
"+ max = count",
"+ count = 0",
"+print((2**max))"
] | false | 0.068574 | 0.073285 | 0.935717 | [
"s681260188",
"s520394499"
] |
u151785909 | p02862 | python | s622050824 | s337065330 | 762 | 122 | 115,180 | 3,064 | Accepted | Accepted | 83.99 | MOD=10**9+7
x , y = list(map(int, input().split()))
a=(2*x-y)//3
b=(2*y-x)//3
if 2*a+b!=x:
print((0))
exit()
factorial = [1]
inverse = [1]
n=a+b
r=a
for i in range(1, n+2):
factorial.append(factorial[-1] * i % MOD)
inverse.append(pow(factorial[-1], MOD - 2, MOD))
def combi(n, r):
if n < r or r < 0:
return 0
elif r == 0:
return 1
return factorial[n] * inverse[r] * inverse[n - r] % MOD
ans = combi(n,r)
print(ans)
| N=10**9+7
x , y = list(map(int, input().split()))
a=(2*x-y)//3
b=(2*y-x)//3
if 2*a+b!=x:
print((0))
exit()
n=a+b
r=a
def fac(n,r,N):
ans=1
for i in range(r):
ans=ans*(n-i)%N
return ans
def combi(n,r,N):
if n<r or n<0 or r<0:
ans = 0
return ans
r= min(r, n-r)
ans = fac(n,r,N)*pow(fac(r,r,N),N-2,N)%N
return ans
ans = combi(n,r,N)
print(ans)
| 27 | 28 | 482 | 425 | MOD = 10**9 + 7
x, y = list(map(int, input().split()))
a = (2 * x - y) // 3
b = (2 * y - x) // 3
if 2 * a + b != x:
print((0))
exit()
factorial = [1]
inverse = [1]
n = a + b
r = a
for i in range(1, n + 2):
factorial.append(factorial[-1] * i % MOD)
inverse.append(pow(factorial[-1], MOD - 2, MOD))
def combi(n, r):
if n < r or r < 0:
return 0
elif r == 0:
return 1
return factorial[n] * inverse[r] * inverse[n - r] % MOD
ans = combi(n, r)
print(ans)
| N = 10**9 + 7
x, y = list(map(int, input().split()))
a = (2 * x - y) // 3
b = (2 * y - x) // 3
if 2 * a + b != x:
print((0))
exit()
n = a + b
r = a
def fac(n, r, N):
ans = 1
for i in range(r):
ans = ans * (n - i) % N
return ans
def combi(n, r, N):
if n < r or n < 0 or r < 0:
ans = 0
return ans
r = min(r, n - r)
ans = fac(n, r, N) * pow(fac(r, r, N), N - 2, N) % N
return ans
ans = combi(n, r, N)
print(ans)
| false | 3.571429 | [
"-MOD = 10**9 + 7",
"+N = 10**9 + 7",
"-factorial = [1]",
"-inverse = [1]",
"-for i in range(1, n + 2):",
"- factorial.append(factorial[-1] * i % MOD)",
"- inverse.append(pow(factorial[-1], MOD - 2, MOD))",
"-def combi(n, r):",
"- if n < r or r < 0:",
"- return 0",
"- elif r == 0:",
"- return 1",
"- return factorial[n] * inverse[r] * inverse[n - r] % MOD",
"+def fac(n, r, N):",
"+ ans = 1",
"+ for i in range(r):",
"+ ans = ans * (n - i) % N",
"+ return ans",
"-ans = combi(n, r)",
"+def combi(n, r, N):",
"+ if n < r or n < 0 or r < 0:",
"+ ans = 0",
"+ return ans",
"+ r = min(r, n - r)",
"+ ans = fac(n, r, N) * pow(fac(r, r, N), N - 2, N) % N",
"+ return ans",
"+",
"+",
"+ans = combi(n, r, N)"
] | false | 0.005851 | 0.052494 | 0.111461 | [
"s622050824",
"s337065330"
] |
u861141787 | p02690 | python | s545932060 | s243235030 | 47 | 39 | 9,172 | 9,052 | Accepted | Accepted | 17.02 | x = int(eval(input()))
for a in range(-118, 120):
for b in range(-118, 120):
if x == a ** 5 - b ** 5:
print((a, b))
exit() | x = int(eval(input()))
for a in range(-118, 120):
for b in range(-119, 118):
if x == a ** 5 - b ** 5:
print((a, b))
exit() | 7 | 7 | 157 | 157 | x = int(eval(input()))
for a in range(-118, 120):
for b in range(-118, 120):
if x == a**5 - b**5:
print((a, b))
exit()
| x = int(eval(input()))
for a in range(-118, 120):
for b in range(-119, 118):
if x == a**5 - b**5:
print((a, b))
exit()
| false | 0 | [
"- for b in range(-118, 120):",
"+ for b in range(-119, 118):"
] | false | 0.050589 | 0.055219 | 0.916157 | [
"s545932060",
"s243235030"
] |
u730769327 | p03775 | python | s593773936 | s337812258 | 174 | 63 | 38,512 | 64,192 | Accepted | Accepted | 63.79 | n=int(eval(input()))
for i in range(int((n**0.5+1)//1),0,-1):
if n/i%1==0:
f=max(len(str(i)),len(str(n//i)))
break
print(f)
| n=int(eval(input()))
s=10**11
for i in range(1,int(n**0.5)+1):
if n%i==0:
s=min(s,max(i,n//i))
print((len(str(s)))) | 7 | 6 | 140 | 118 | n = int(eval(input()))
for i in range(int((n**0.5 + 1) // 1), 0, -1):
if n / i % 1 == 0:
f = max(len(str(i)), len(str(n // i)))
break
print(f)
| n = int(eval(input()))
s = 10**11
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
s = min(s, max(i, n // i))
print((len(str(s))))
| false | 14.285714 | [
"-for i in range(int((n**0.5 + 1) // 1), 0, -1):",
"- if n / i % 1 == 0:",
"- f = max(len(str(i)), len(str(n // i)))",
"- break",
"-print(f)",
"+s = 10**11",
"+for i in range(1, int(n**0.5) + 1):",
"+ if n % i == 0:",
"+ s = min(s, max(i, n // i))",
"+print((len(str(s))))"
] | false | 0.041683 | 0.086175 | 0.483702 | [
"s593773936",
"s337812258"
] |
u770698847 | p02412 | python | s397821258 | s405618432 | 1,870 | 10 | 4,716 | 4,656 | Accepted | Accepted | 99.47 | while(1):
comb = []
count =0
inp = input().split(" ")
if inp[0] == "0" and inp[1] == "0":
break
for i in range(1,int(inp[0])+1):
for j in range(1,int(inp[0])+1):
if i == j:
break
sum = i + j
if sum > int(inp[1]):
j = int(inp[0])
break
for k in range(1,int(inp[0])+1):
if i == j or i == k or j == k:
break
sum = i + j + k
if sum > int(inp[1]):
k = int(inp[0])
break
if sum == int(inp[1]):
if not ([i,j,k] in comb or [i,k,j] in comb or [j,k,i] in comb or [j,i,k] in comb or [k,i,j] in comb or [k,j,i] in comb):
comb.append([i,j,k])
count += 1
print(count)
| # coding: UTF-8
def find_comb(n,x):
count = 0
#探索
for i in range(1,n-1):
for j in range(i+1,n):
k = x - i - j #←がi < j < k <= nを満たせばその時点で総和がxとなる
if j < k <= n:
count += 1
print(count)
while(1):
n,x = list(map(int, input().split(" ")))
if(n == 0 and x == 0):
break
find_comb(n,x)
| 26 | 15 | 911 | 375 | while 1:
comb = []
count = 0
inp = input().split(" ")
if inp[0] == "0" and inp[1] == "0":
break
for i in range(1, int(inp[0]) + 1):
for j in range(1, int(inp[0]) + 1):
if i == j:
break
sum = i + j
if sum > int(inp[1]):
j = int(inp[0])
break
for k in range(1, int(inp[0]) + 1):
if i == j or i == k or j == k:
break
sum = i + j + k
if sum > int(inp[1]):
k = int(inp[0])
break
if sum == int(inp[1]):
if not (
[i, j, k] in comb
or [i, k, j] in comb
or [j, k, i] in comb
or [j, i, k] in comb
or [k, i, j] in comb
or [k, j, i] in comb
):
comb.append([i, j, k])
count += 1
print(count)
| # coding: UTF-8
def find_comb(n, x):
count = 0
# 探索
for i in range(1, n - 1):
for j in range(i + 1, n):
k = x - i - j # ←がi < j < k <= nを満たせばその時点で総和がxとなる
if j < k <= n:
count += 1
print(count)
while 1:
n, x = list(map(int, input().split(" ")))
if n == 0 and x == 0:
break
find_comb(n, x)
| false | 42.307692 | [
"+# coding: UTF-8",
"+def find_comb(n, x):",
"+ count = 0",
"+ # 探索",
"+ for i in range(1, n - 1):",
"+ for j in range(i + 1, n):",
"+ k = x - i - j # ←がi < j < k <= nを満たせばその時点で総和がxとなる",
"+ if j < k <= n:",
"+ count += 1",
"+ print(count)",
"+",
"+",
"- comb = []",
"- count = 0",
"- inp = input().split(\" \")",
"- if inp[0] == \"0\" and inp[1] == \"0\":",
"+ n, x = list(map(int, input().split(\" \")))",
"+ if n == 0 and x == 0:",
"- for i in range(1, int(inp[0]) + 1):",
"- for j in range(1, int(inp[0]) + 1):",
"- if i == j:",
"- break",
"- sum = i + j",
"- if sum > int(inp[1]):",
"- j = int(inp[0])",
"- break",
"- for k in range(1, int(inp[0]) + 1):",
"- if i == j or i == k or j == k:",
"- break",
"- sum = i + j + k",
"- if sum > int(inp[1]):",
"- k = int(inp[0])",
"- break",
"- if sum == int(inp[1]):",
"- if not (",
"- [i, j, k] in comb",
"- or [i, k, j] in comb",
"- or [j, k, i] in comb",
"- or [j, i, k] in comb",
"- or [k, i, j] in comb",
"- or [k, j, i] in comb",
"- ):",
"- comb.append([i, j, k])",
"- count += 1",
"- print(count)",
"+ find_comb(n, x)"
] | false | 0.04929 | 0.051021 | 0.966069 | [
"s397821258",
"s405618432"
] |
u296518383 | p03127 | python | s700386684 | s893829381 | 88 | 69 | 14,252 | 15,020 | Accepted | Accepted | 21.59 | def gcd(a,b):
if b==0:
return a
else:
return gcd(b,a%b)
N=int(eval(input()))
A=list(map(int,input().split()))
g=A[0]
for i in range(1,N):
g=gcd(g,A[i])
print(g) | N = int(eval(input()))
A = list(map(int, input().split()))
def gcd(x, y):
while y:
x, y = y, x % y
return x
answer = A[0]
for i in range(1, N):
answer = gcd(A[i], answer)
print(answer) | 14 | 13 | 184 | 205 | def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
N = int(eval(input()))
A = list(map(int, input().split()))
g = A[0]
for i in range(1, N):
g = gcd(g, A[i])
print(g)
| N = int(eval(input()))
A = list(map(int, input().split()))
def gcd(x, y):
while y:
x, y = y, x % y
return x
answer = A[0]
for i in range(1, N):
answer = gcd(A[i], answer)
print(answer)
| false | 7.142857 | [
"-def gcd(a, b):",
"- if b == 0:",
"- return a",
"- else:",
"- return gcd(b, a % b)",
"+N = int(eval(input()))",
"+A = list(map(int, input().split()))",
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-g = A[0]",
"+def gcd(x, y):",
"+ while y:",
"+ x, y = y, x % y",
"+ return x",
"+",
"+",
"+answer = A[0]",
"- g = gcd(g, A[i])",
"-print(g)",
"+ answer = gcd(A[i], answer)",
"+print(answer)"
] | false | 0.035974 | 0.041412 | 0.86867 | [
"s700386684",
"s893829381"
] |
u747602774 | p03329 | python | s181731143 | s465995424 | 245 | 208 | 3,064 | 45,040 | Accepted | Accepted | 15.1 | def nbasesum(value,n):
nbasevalue = 0
while value > 0:
nbasevalue += value%n
value //= n
return nbasevalue
N = int(eval(input()))
ans = nbasesum(N,9)
for i in range(N+1):
c6 = i
c9 = N-i
ans = min(ans, nbasesum(c9,9)+nbasesum(c6,6))
print(ans)
| n = int(eval(input()))
m = [1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049]
dp = [10**6 for i in range(100001)]
for mi in m:
dp[mi] = 1
for i in range(1,100001):
for mi in m:
if i+mi <= 100000:
dp[i+mi] = min(dp[i+mi],dp[i]+1)
else:
break
print((dp[n]))
| 16 | 12 | 296 | 316 | def nbasesum(value, n):
nbasevalue = 0
while value > 0:
nbasevalue += value % n
value //= n
return nbasevalue
N = int(eval(input()))
ans = nbasesum(N, 9)
for i in range(N + 1):
c6 = i
c9 = N - i
ans = min(ans, nbasesum(c9, 9) + nbasesum(c6, 6))
print(ans)
| n = int(eval(input()))
m = [1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049]
dp = [10**6 for i in range(100001)]
for mi in m:
dp[mi] = 1
for i in range(1, 100001):
for mi in m:
if i + mi <= 100000:
dp[i + mi] = min(dp[i + mi], dp[i] + 1)
else:
break
print((dp[n]))
| false | 25 | [
"-def nbasesum(value, n):",
"- nbasevalue = 0",
"- while value > 0:",
"- nbasevalue += value % n",
"- value //= n",
"- return nbasevalue",
"-",
"-",
"-N = int(eval(input()))",
"-ans = nbasesum(N, 9)",
"-for i in range(N + 1):",
"- c6 = i",
"- c9 = N - i",
"- ans = min(ans, nbasesum(c9, 9) + nbasesum(c6, 6))",
"-print(ans)",
"+n = int(eval(input()))",
"+m = [1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049]",
"+dp = [10**6 for i in range(100001)]",
"+for mi in m:",
"+ dp[mi] = 1",
"+for i in range(1, 100001):",
"+ for mi in m:",
"+ if i + mi <= 100000:",
"+ dp[i + mi] = min(dp[i + mi], dp[i] + 1)",
"+ else:",
"+ break",
"+print((dp[n]))"
] | false | 0.212186 | 0.007447 | 28.494011 | [
"s181731143",
"s465995424"
] |
u094191970 | p02866 | python | s967116681 | s133184286 | 155 | 105 | 21,980 | 24,316 | Accepted | Accepted | 32.26 | from collections import Counter
n=int(eval(input()))
d=list(map(int,input().split()))
if d[0]!=0:
print((0))
exit()
c=Counter(d)
c=sorted(list(c.items()),key=lambda x:x[0])
if c[0]!=(0,1):
print((0))
exit()
ans=1
check=1
for i in range(1,len(c)):
if c[i][0]!=check:
print((0))
exit()
check+=1
ans*=c[i-1][1]**c[i][1]
ans%=998244353
print((ans%998244353)) | from sys import stdin
nii=lambda:list(map(int,stdin.readline().split()))
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import Counter
n=int(eval(input()))
d=lnii()
mod=998244353
c=Counter(d)
max_key=max(d)
if d[0]!=0 or c[0]!=1:
print((0))
exit()
ans=1
patterns=1
for i in range(max_key+1):
p_num=c[i]
ans*=patterns**p_num
ans%=mod
patterns=p_num
print(ans) | 22 | 26 | 404 | 409 | from collections import Counter
n = int(eval(input()))
d = list(map(int, input().split()))
if d[0] != 0:
print((0))
exit()
c = Counter(d)
c = sorted(list(c.items()), key=lambda x: x[0])
if c[0] != (0, 1):
print((0))
exit()
ans = 1
check = 1
for i in range(1, len(c)):
if c[i][0] != check:
print((0))
exit()
check += 1
ans *= c[i - 1][1] ** c[i][1]
ans %= 998244353
print((ans % 998244353))
| from sys import stdin
nii = lambda: list(map(int, stdin.readline().split()))
lnii = lambda: list(map(int, stdin.readline().split()))
from collections import Counter
n = int(eval(input()))
d = lnii()
mod = 998244353
c = Counter(d)
max_key = max(d)
if d[0] != 0 or c[0] != 1:
print((0))
exit()
ans = 1
patterns = 1
for i in range(max_key + 1):
p_num = c[i]
ans *= patterns**p_num
ans %= mod
patterns = p_num
print(ans)
| false | 15.384615 | [
"+from sys import stdin",
"+",
"+nii = lambda: list(map(int, stdin.readline().split()))",
"+lnii = lambda: list(map(int, stdin.readline().split()))",
"-d = list(map(int, input().split()))",
"-if d[0] != 0:",
"- print((0))",
"- exit()",
"+d = lnii()",
"+mod = 998244353",
"-c = sorted(list(c.items()), key=lambda x: x[0])",
"-if c[0] != (0, 1):",
"+max_key = max(d)",
"+if d[0] != 0 or c[0] != 1:",
"-check = 1",
"-for i in range(1, len(c)):",
"- if c[i][0] != check:",
"- print((0))",
"- exit()",
"- check += 1",
"- ans *= c[i - 1][1] ** c[i][1]",
"- ans %= 998244353",
"-print((ans % 998244353))",
"+patterns = 1",
"+for i in range(max_key + 1):",
"+ p_num = c[i]",
"+ ans *= patterns**p_num",
"+ ans %= mod",
"+ patterns = p_num",
"+print(ans)"
] | false | 0.040877 | 0.04086 | 1.000413 | [
"s967116681",
"s133184286"
] |
u312025627 | p03145 | python | s630490101 | s071084121 | 184 | 169 | 38,384 | 38,384 | Accepted | Accepted | 8.15 | ab,bc,ca = (int(i) for i in input().split())
print((ab*bc//2)) | def main():
a, b, c = (int(i) for i in input().split())
from math import sqrt
s = (a + b + c) / 2
print((int(sqrt(s*(s-a)*(s-b)*(s-c)))))
if __name__ == '__main__':
main()
| 2 | 9 | 61 | 200 | ab, bc, ca = (int(i) for i in input().split())
print((ab * bc // 2))
| def main():
a, b, c = (int(i) for i in input().split())
from math import sqrt
s = (a + b + c) / 2
print((int(sqrt(s * (s - a) * (s - b) * (s - c)))))
if __name__ == "__main__":
main()
| false | 77.777778 | [
"-ab, bc, ca = (int(i) for i in input().split())",
"-print((ab * bc // 2))",
"+def main():",
"+ a, b, c = (int(i) for i in input().split())",
"+ from math import sqrt",
"+",
"+ s = (a + b + c) / 2",
"+ print((int(sqrt(s * (s - a) * (s - b) * (s - c)))))",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.046442 | 0.128216 | 0.362215 | [
"s630490101",
"s071084121"
] |
u887207211 | p03779 | python | s908696745 | s632335997 | 31 | 27 | 3,060 | 3,060 | Accepted | Accepted | 12.9 | X = int(eval(input()))
for i in range(1,X+1):
if((i*(i+1))/2 >= X):
print(i)
break | import sys
stdin = sys.stdin
ns = lambda : stdin.readline().rstrip()
na = lambda : list(map(int, stdin.readline().split()))
ni = lambda : int(ns())
def main():
n = ni()
f = lambda x: (x * (x+1)) // 2
for i in range(1, n+1):
if (f(i) >= n):
print(i)
return
main() | 6 | 15 | 92 | 294 | X = int(eval(input()))
for i in range(1, X + 1):
if (i * (i + 1)) / 2 >= X:
print(i)
break
| import sys
stdin = sys.stdin
ns = lambda: stdin.readline().rstrip()
na = lambda: list(map(int, stdin.readline().split()))
ni = lambda: int(ns())
def main():
n = ni()
f = lambda x: (x * (x + 1)) // 2
for i in range(1, n + 1):
if f(i) >= n:
print(i)
return
main()
| false | 60 | [
"-X = int(eval(input()))",
"-for i in range(1, X + 1):",
"- if (i * (i + 1)) / 2 >= X:",
"- print(i)",
"- break",
"+import sys",
"+",
"+stdin = sys.stdin",
"+ns = lambda: stdin.readline().rstrip()",
"+na = lambda: list(map(int, stdin.readline().split()))",
"+ni = lambda: int(ns())",
"+",
"+",
"+def main():",
"+ n = ni()",
"+ f = lambda x: (x * (x + 1)) // 2",
"+ for i in range(1, n + 1):",
"+ if f(i) >= n:",
"+ print(i)",
"+ return",
"+",
"+",
"+main()"
] | false | 0.03902 | 0.180077 | 0.216686 | [
"s908696745",
"s632335997"
] |
u546285759 | p02116 | python | s599370316 | s937955572 | 70 | 20 | 7,696 | 7,696 | Accepted | Accepted | 71.43 | n = int(eval(input()))
print(((n+1) &- (n+1))) | n = int(eval(input())) + 1
print((n &- n)) | 2 | 2 | 39 | 35 | n = int(eval(input()))
print(((n + 1) & -(n + 1)))
| n = int(eval(input())) + 1
print((n & -n))
| false | 0 | [
"-n = int(eval(input()))",
"-print(((n + 1) & -(n + 1)))",
"+n = int(eval(input())) + 1",
"+print((n & -n))"
] | false | 0.043134 | 0.036368 | 1.186041 | [
"s599370316",
"s937955572"
] |
u254871849 | p03329 | python | s160845961 | s751283959 | 1,113 | 105 | 20,244 | 3,064 | Accepted | Accepted | 90.57 | import sys
from math import log, floor
n = int(sys.stdin.readline().rstrip())
def main():
cand = set()
for i in range(floor(log(n, 6)) + 1):
if 6 ** i <= n:
cand.add(6 ** i)
if 9 ** i <= n:
cand.add(9 ** i)
cand = sorted(cand)
res = set([0])
cnt = 0
while True:
nex = set()
for val in res:
for c in cand:
if val + c <= n:
nex.add(val + c)
else:
break
cnt += 1
if n in nex:
return cnt
res = nex
if __name__ == '__main__':
ans = main()
print(ans) | import sys
n = int(sys.stdin.readline().rstrip())
def main():
bit6 = [0] * 8
bit9 = [0] * 7
b = n
for i in range(5, -1, -1):
q, r = divmod(b, 9 ** i)
bit9[i] = q
b = r
res = sum(bit6) + sum(bit9)
for _ in range(n):
i = 0
while True:
bit6[i] += 1
if bit6[i] == 6:
bit6[i] = 0
i += 1
else:
break
i = 0
while True:
bit9[i] -= 1
if bit9[i] == -1:
bit9[i] = 8
i += 1
else:
break
res = min(res, sum(bit6) + sum(bit9))
return res
if __name__ == '__main__':
ans = main()
print(ans) | 32 | 41 | 691 | 797 | import sys
from math import log, floor
n = int(sys.stdin.readline().rstrip())
def main():
cand = set()
for i in range(floor(log(n, 6)) + 1):
if 6**i <= n:
cand.add(6**i)
if 9**i <= n:
cand.add(9**i)
cand = sorted(cand)
res = set([0])
cnt = 0
while True:
nex = set()
for val in res:
for c in cand:
if val + c <= n:
nex.add(val + c)
else:
break
cnt += 1
if n in nex:
return cnt
res = nex
if __name__ == "__main__":
ans = main()
print(ans)
| import sys
n = int(sys.stdin.readline().rstrip())
def main():
bit6 = [0] * 8
bit9 = [0] * 7
b = n
for i in range(5, -1, -1):
q, r = divmod(b, 9**i)
bit9[i] = q
b = r
res = sum(bit6) + sum(bit9)
for _ in range(n):
i = 0
while True:
bit6[i] += 1
if bit6[i] == 6:
bit6[i] = 0
i += 1
else:
break
i = 0
while True:
bit9[i] -= 1
if bit9[i] == -1:
bit9[i] = 8
i += 1
else:
break
res = min(res, sum(bit6) + sum(bit9))
return res
if __name__ == "__main__":
ans = main()
print(ans)
| false | 21.95122 | [
"-from math import log, floor",
"- cand = set()",
"- for i in range(floor(log(n, 6)) + 1):",
"- if 6**i <= n:",
"- cand.add(6**i)",
"- if 9**i <= n:",
"- cand.add(9**i)",
"- cand = sorted(cand)",
"- res = set([0])",
"- cnt = 0",
"- while True:",
"- nex = set()",
"- for val in res:",
"- for c in cand:",
"- if val + c <= n:",
"- nex.add(val + c)",
"- else:",
"- break",
"- cnt += 1",
"- if n in nex:",
"- return cnt",
"- res = nex",
"+ bit6 = [0] * 8",
"+ bit9 = [0] * 7",
"+ b = n",
"+ for i in range(5, -1, -1):",
"+ q, r = divmod(b, 9**i)",
"+ bit9[i] = q",
"+ b = r",
"+ res = sum(bit6) + sum(bit9)",
"+ for _ in range(n):",
"+ i = 0",
"+ while True:",
"+ bit6[i] += 1",
"+ if bit6[i] == 6:",
"+ bit6[i] = 0",
"+ i += 1",
"+ else:",
"+ break",
"+ i = 0",
"+ while True:",
"+ bit9[i] -= 1",
"+ if bit9[i] == -1:",
"+ bit9[i] = 8",
"+ i += 1",
"+ else:",
"+ break",
"+ res = min(res, sum(bit6) + sum(bit9))",
"+ return res"
] | false | 0.116117 | 0.039578 | 2.933913 | [
"s160845961",
"s751283959"
] |
u564902833 | p03103 | python | s698284681 | s513274217 | 722 | 564 | 35,796 | 58,824 | Accepted | Accepted | 21.88 | from functools import reduce
N, M = list(map(int, input().split()))
A, B = list(zip(*sorted((list(map(int, input().split())) for _ in range(N)))))
ans = reduce(lambda acc, t: (acc[0] + t[0] * min(max(0, M - acc[1]), t[1]), acc[1] + t[1]), list(zip(A, B)), (0, 0))[0]
print(ans)
| from functools import reduce
# 入力
N, M = list(map(int, input().split()))
A, B = list(zip(*(list(map(int, input().split())) for _ in range(N))))
# 1本あたりの値段が安い店から順に購入
ans = reduce(
lambda acc, t: (
acc[0] + t[0] * min(t[1], M - acc[1]),
acc[1] + t[1]
) if acc[1] < M else
acc,
sorted(zip(A, B)),
(0, 0)
)[0]
# 出力
print(ans)
| 5 | 18 | 264 | 359 | from functools import reduce
N, M = list(map(int, input().split()))
A, B = list(zip(*sorted((list(map(int, input().split())) for _ in range(N)))))
ans = reduce(
lambda acc, t: (acc[0] + t[0] * min(max(0, M - acc[1]), t[1]), acc[1] + t[1]),
list(zip(A, B)),
(0, 0),
)[0]
print(ans)
| from functools import reduce
# 入力
N, M = list(map(int, input().split()))
A, B = list(zip(*(list(map(int, input().split())) for _ in range(N))))
# 1本あたりの値段が安い店から順に購入
ans = reduce(
lambda acc, t: (acc[0] + t[0] * min(t[1], M - acc[1]), acc[1] + t[1])
if acc[1] < M
else acc,
sorted(zip(A, B)),
(0, 0),
)[0]
# 出力
print(ans)
| false | 72.222222 | [
"+# 入力",
"-A, B = list(zip(*sorted((list(map(int, input().split())) for _ in range(N)))))",
"+A, B = list(zip(*(list(map(int, input().split())) for _ in range(N))))",
"+# 1本あたりの値段が安い店から順に購入",
"- lambda acc, t: (acc[0] + t[0] * min(max(0, M - acc[1]), t[1]), acc[1] + t[1]),",
"- list(zip(A, B)),",
"+ lambda acc, t: (acc[0] + t[0] * min(t[1], M - acc[1]), acc[1] + t[1])",
"+ if acc[1] < M",
"+ else acc,",
"+ sorted(zip(A, B)),",
"+# 出力"
] | false | 0.041473 | 0.114701 | 0.361574 | [
"s698284681",
"s513274217"
] |
u970197315 | p03352 | python | s134519030 | s912468210 | 33 | 17 | 3,060 | 2,940 | Accepted | Accepted | 48.48 | x=int(eval(input()))
a=set()
for i in range(1,1001):
for j in range(2,34):
t=i**j
if t<=x:
a.add(i**j)
a=list(a)
a.sort()
print((a[-1])) | x=int(eval(input()))
ans=0
for i in range(1,35):
for j in range(2,10):
t=i**j
if t<=x:
ans=max(ans,t)
print(ans)
| 10 | 11 | 153 | 136 | x = int(eval(input()))
a = set()
for i in range(1, 1001):
for j in range(2, 34):
t = i**j
if t <= x:
a.add(i**j)
a = list(a)
a.sort()
print((a[-1]))
| x = int(eval(input()))
ans = 0
for i in range(1, 35):
for j in range(2, 10):
t = i**j
if t <= x:
ans = max(ans, t)
print(ans)
| false | 9.090909 | [
"-a = set()",
"-for i in range(1, 1001):",
"- for j in range(2, 34):",
"+ans = 0",
"+for i in range(1, 35):",
"+ for j in range(2, 10):",
"- a.add(i**j)",
"-a = list(a)",
"-a.sort()",
"-print((a[-1]))",
"+ ans = max(ans, t)",
"+print(ans)"
] | false | 0.082466 | 0.037705 | 2.187147 | [
"s134519030",
"s912468210"
] |
u077291787 | p03608 | python | s601519361 | s522278264 | 348 | 210 | 9,828 | 9,836 | Accepted | Accepted | 39.66 | # ABC073D - joisino's travel (218ms)
from heapq import heapify, heappop, heappush
from itertools import permutations
def dijkstra(G: "Array[Array[int]]", size: int, start: int) -> list:
dist = [float("inf")] * size
queue = [(0, start)]
heapify(queue)
while queue:
cost, v = heappop(queue)
if cost > dist[v]:
continue
dist[v] = cost
for next_cost, u in G[v]:
if cost + next_cost < dist[u]:
heappush(queue, (cost + next_cost, u))
return dist
def main():
global G, N
N, M, R, *RABC = list(map(int, open(0).read().split()))
visit, ABC = RABC[:R], RABC[R:]
G = [[] for _ in range(N + 1)]
for v, u, cost in zip(*[iter(ABC)] * 3):
G[v].append((cost, u)), G[u].append((cost, v))
dist = {v: dijkstra(G, N + 1, v) for v in visit}
ans = float("inf")
for perm in permutations(visit):
cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))
ans = min(ans, cur)
print(ans)
if __name__ == "__main__":
main() | # ABC073D - joisino's travel (218ms)
from heapq import heapify, heappop, heappush
from itertools import permutations
def dijkstra(G: "Array[Array[int]]", size: int, start: int) -> list:
dist = [float("inf")] * size
unchecked = size - 1 # vertex_0 won't appear in 1-idx graph
queue = [(0, start)]
heapify(queue)
while queue:
cost, v = heappop(queue)
if cost > dist[v]:
continue
dist[v] = cost
for next_cost, u in G[v]:
if cost + next_cost < dist[u]:
heappush(queue, (cost + next_cost, u))
unchecked -= 1
if not unchecked:
return dist
def main():
global G, N
N, M, R, *RABC = list(map(int, open(0).read().split()))
visit, ABC = RABC[:R], RABC[R:]
G = [[] for _ in range(N + 1)]
for v, u, cost in zip(*[iter(ABC)] * 3):
G[v].append((cost, u)), G[u].append((cost, v))
dist = {v: dijkstra(G, N + 1, v) for v in visit}
ans = float("inf")
for perm in permutations(visit):
cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))
ans = min(ans, cur)
print(ans)
if __name__ == "__main__":
main() | 37 | 40 | 1,082 | 1,207 | # ABC073D - joisino's travel (218ms)
from heapq import heapify, heappop, heappush
from itertools import permutations
def dijkstra(G: "Array[Array[int]]", size: int, start: int) -> list:
dist = [float("inf")] * size
queue = [(0, start)]
heapify(queue)
while queue:
cost, v = heappop(queue)
if cost > dist[v]:
continue
dist[v] = cost
for next_cost, u in G[v]:
if cost + next_cost < dist[u]:
heappush(queue, (cost + next_cost, u))
return dist
def main():
global G, N
N, M, R, *RABC = list(map(int, open(0).read().split()))
visit, ABC = RABC[:R], RABC[R:]
G = [[] for _ in range(N + 1)]
for v, u, cost in zip(*[iter(ABC)] * 3):
G[v].append((cost, u)), G[u].append((cost, v))
dist = {v: dijkstra(G, N + 1, v) for v in visit}
ans = float("inf")
for perm in permutations(visit):
cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))
ans = min(ans, cur)
print(ans)
if __name__ == "__main__":
main()
| # ABC073D - joisino's travel (218ms)
from heapq import heapify, heappop, heappush
from itertools import permutations
def dijkstra(G: "Array[Array[int]]", size: int, start: int) -> list:
dist = [float("inf")] * size
unchecked = size - 1 # vertex_0 won't appear in 1-idx graph
queue = [(0, start)]
heapify(queue)
while queue:
cost, v = heappop(queue)
if cost > dist[v]:
continue
dist[v] = cost
for next_cost, u in G[v]:
if cost + next_cost < dist[u]:
heappush(queue, (cost + next_cost, u))
unchecked -= 1
if not unchecked:
return dist
def main():
global G, N
N, M, R, *RABC = list(map(int, open(0).read().split()))
visit, ABC = RABC[:R], RABC[R:]
G = [[] for _ in range(N + 1)]
for v, u, cost in zip(*[iter(ABC)] * 3):
G[v].append((cost, u)), G[u].append((cost, v))
dist = {v: dijkstra(G, N + 1, v) for v in visit}
ans = float("inf")
for perm in permutations(visit):
cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))
ans = min(ans, cur)
print(ans)
if __name__ == "__main__":
main()
| false | 7.5 | [
"+ unchecked = size - 1 # vertex_0 won't appear in 1-idx graph",
"- return dist",
"+ unchecked -= 1",
"+ if not unchecked:",
"+ return dist"
] | false | 0.045432 | 0.041117 | 1.104953 | [
"s601519361",
"s522278264"
] |
u620084012 | p03241 | python | s278192434 | s794318011 | 181 | 21 | 38,640 | 3,064 | Accepted | Accepted | 88.4 | import math
N, M = list(map(int,input().split()))
P = []
for k in range(1,math.floor(math.sqrt(M))+1):
if M % k == 0:
P.append(k)
P.append(M//k)
ans = 1
for e in P:
if e*N <= M:
ans = max(ans,e)
print(ans)
| import math
N, M = list(map(int,input().split()))
b = 0
P = [1]
for k in range(2,math.floor(math.sqrt(M))+1):
if M % k == 0:
P.append(k)
P.append(M//k)
P = sorted(P)
for e in P:
if e >= N:
print((M//e))
exit(0)
print((1))
| 13 | 16 | 245 | 269 | import math
N, M = list(map(int, input().split()))
P = []
for k in range(1, math.floor(math.sqrt(M)) + 1):
if M % k == 0:
P.append(k)
P.append(M // k)
ans = 1
for e in P:
if e * N <= M:
ans = max(ans, e)
print(ans)
| import math
N, M = list(map(int, input().split()))
b = 0
P = [1]
for k in range(2, math.floor(math.sqrt(M)) + 1):
if M % k == 0:
P.append(k)
P.append(M // k)
P = sorted(P)
for e in P:
if e >= N:
print((M // e))
exit(0)
print((1))
| false | 18.75 | [
"-P = []",
"-for k in range(1, math.floor(math.sqrt(M)) + 1):",
"+b = 0",
"+P = [1]",
"+for k in range(2, math.floor(math.sqrt(M)) + 1):",
"-ans = 1",
"+P = sorted(P)",
"- if e * N <= M:",
"- ans = max(ans, e)",
"-print(ans)",
"+ if e >= N:",
"+ print((M // e))",
"+ exit(0)",
"+print((1))"
] | false | 0.03574 | 0.083917 | 0.425905 | [
"s278192434",
"s794318011"
] |
u047393579 | p03745 | python | s283415855 | s154902661 | 79 | 69 | 14,252 | 14,252 | Accepted | Accepted | 12.66 | N = int(eval(input()))
sub = 0
count = 1
A = [int(i) for i in input().split()]
if N > 1:
pre_num = A[1]
pre_sub = A[1] - A[0]
for num in A[2:]:
if not pre_num == num:
if pre_sub * (num - pre_num) < 0:
count += 1
pre_sub = 0
else:
pre_sub = num - pre_num
pre_num = num
print(count) | _ = int(eval(input()))
A = [int(a) for a in input().split()]
selector = 0
count = 1
pre_a = A[0]
for a in A[1:]:
if selector == 0:
selector = a - pre_a
elif selector * (a - pre_a) < 0:
count += 1
selector = 0
pre_a = a
print(count) | 16 | 13 | 354 | 273 | N = int(eval(input()))
sub = 0
count = 1
A = [int(i) for i in input().split()]
if N > 1:
pre_num = A[1]
pre_sub = A[1] - A[0]
for num in A[2:]:
if not pre_num == num:
if pre_sub * (num - pre_num) < 0:
count += 1
pre_sub = 0
else:
pre_sub = num - pre_num
pre_num = num
print(count)
| _ = int(eval(input()))
A = [int(a) for a in input().split()]
selector = 0
count = 1
pre_a = A[0]
for a in A[1:]:
if selector == 0:
selector = a - pre_a
elif selector * (a - pre_a) < 0:
count += 1
selector = 0
pre_a = a
print(count)
| false | 18.75 | [
"-N = int(eval(input()))",
"-sub = 0",
"+_ = int(eval(input()))",
"+A = [int(a) for a in input().split()]",
"+selector = 0",
"-A = [int(i) for i in input().split()]",
"-if N > 1:",
"- pre_num = A[1]",
"- pre_sub = A[1] - A[0]",
"-for num in A[2:]:",
"- if not pre_num == num:",
"- if pre_sub * (num - pre_num) < 0:",
"- count += 1",
"- pre_sub = 0",
"- else:",
"- pre_sub = num - pre_num",
"- pre_num = num",
"+pre_a = A[0]",
"+for a in A[1:]:",
"+ if selector == 0:",
"+ selector = a - pre_a",
"+ elif selector * (a - pre_a) < 0:",
"+ count += 1",
"+ selector = 0",
"+ pre_a = a"
] | false | 0.095121 | 0.060808 | 1.564294 | [
"s283415855",
"s154902661"
] |
u761320129 | p03767 | python | s351112470 | s308176848 | 249 | 207 | 28,776 | 37,084 | Accepted | Accepted | 16.87 | N = eval(input())
arr = list(map(int, input().split()))
arr.sort()
sum = 0
for i in range(3*N-2, N-1, -2):
sum += arr[i]
print(sum) | N = int(eval(input()))
src = list(map(int,input().split()))
src.sort(reverse=True)
print((sum(src[1:2*N+1:2])))
| 7 | 4 | 130 | 107 | N = eval(input())
arr = list(map(int, input().split()))
arr.sort()
sum = 0
for i in range(3 * N - 2, N - 1, -2):
sum += arr[i]
print(sum)
| N = int(eval(input()))
src = list(map(int, input().split()))
src.sort(reverse=True)
print((sum(src[1 : 2 * N + 1 : 2])))
| false | 42.857143 | [
"-N = eval(input())",
"-arr = list(map(int, input().split()))",
"-arr.sort()",
"-sum = 0",
"-for i in range(3 * N - 2, N - 1, -2):",
"- sum += arr[i]",
"-print(sum)",
"+N = int(eval(input()))",
"+src = list(map(int, input().split()))",
"+src.sort(reverse=True)",
"+print((sum(src[1 : 2 * N + 1 : 2])))"
] | false | 0.041651 | 0.037393 | 1.113874 | [
"s351112470",
"s308176848"
] |
u312025627 | p03371 | python | s211564242 | s456686847 | 187 | 66 | 38,256 | 61,904 | Accepted | Accepted | 64.71 | def main():
a, b, c, x, y = (int(i) for i in input().split())
ans = a*x + b*y
ans = min(ans, 2*c*max(x, y))
if x < y:
d = y - x
d *= b
else:
d = x - y
d *= a
ans = min(ans, 2*c*min(x, y)+d)
print(ans)
if __name__ == '__main__':
main()
| def main():
a, b, c, x, y = (int(i) for i in input().split())
v1 = 2*c*max(x, y)
v2 = 2*c*min(x, y) + (y-x if x < y else x-y)*(b if x < y else a)
v3 = a*x + b*y
print((min(v1, v2, v3)))
if __name__ == '__main__':
main()
| 16 | 10 | 316 | 253 | def main():
a, b, c, x, y = (int(i) for i in input().split())
ans = a * x + b * y
ans = min(ans, 2 * c * max(x, y))
if x < y:
d = y - x
d *= b
else:
d = x - y
d *= a
ans = min(ans, 2 * c * min(x, y) + d)
print(ans)
if __name__ == "__main__":
main()
| def main():
a, b, c, x, y = (int(i) for i in input().split())
v1 = 2 * c * max(x, y)
v2 = 2 * c * min(x, y) + (y - x if x < y else x - y) * (b if x < y else a)
v3 = a * x + b * y
print((min(v1, v2, v3)))
if __name__ == "__main__":
main()
| false | 37.5 | [
"- ans = a * x + b * y",
"- ans = min(ans, 2 * c * max(x, y))",
"- if x < y:",
"- d = y - x",
"- d *= b",
"- else:",
"- d = x - y",
"- d *= a",
"- ans = min(ans, 2 * c * min(x, y) + d)",
"- print(ans)",
"+ v1 = 2 * c * max(x, y)",
"+ v2 = 2 * c * min(x, y) + (y - x if x < y else x - y) * (b if x < y else a)",
"+ v3 = a * x + b * y",
"+ print((min(v1, v2, v3)))"
] | false | 0.007527 | 0.034986 | 0.215155 | [
"s211564242",
"s456686847"
] |
u168578024 | p03061 | python | s797001049 | s291758013 | 953 | 504 | 111,648 | 56,256 | Accepted | Accepted | 47.11 | from fractions import gcd
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
import copy
class SegmentTree:
def __init__(self, N, func, I):
self.sz = 2**(N-1).bit_length()
self.func = func
self.I = copy.deepcopy(I)
self.seg = [copy.deepcopy(I) for i in range(self.sz * 2)]
def assign(self, k, x):
self.seg[k + self.sz] = copy.deepcopy(x)
def build(self):
for i in range(self.sz - 1, 0, -1):
self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
def update(self, k, x):
k += self.sz
self.seg[k] = copy.deepcopy(x)
while k > 1:
k >>= 1
self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])
def query(self, a, b):
L = copy.deepcopy(self.I)
R = copy.deepcopy(self.I)
a += self.sz
b += self.sz
while a < b:
if a & 1:
L = self.func(L, self.seg[a])
a += 1
if b & 1:
b -= 1
R = self.func(self.seg[b], R)
a >>= 1
b >>= 1
return self.func(L, R)
def main():
N = int(readline())
m = list(map(int, read().split()))
seg = SegmentTree(N, gcd, 0)
for i in range(N):
seg.assign(i, next(m))
seg.build()
ans = 1
for i in range(N):
ans = max(ans, gcd(seg.query(0, i), seg.query(i+1, N)))
print(ans)
main()
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
class SegmentTree:
def __init__(self, N, func, I):
self.func = func
self.I = I
self.sz = 2**(N-1).bit_length()
self.seg = [I] * (self.sz * 2)
def assign(self, k, x):
self.seg[k + self.sz] = x
def build(self):
for i in range(self.sz - 1, 0, -1):
self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
def update(self, k, x):
k += self.sz
self.seg[k] = x
while k > 1:
k >>= 1
self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])
def query(self, a, b):
L = self.I
R = self.I
a += self.sz
b += self.sz
while a < b:
if a & 1:
L = self.func(L, self.seg[a])
a += 1
if b & 1:
b -= 1
R = self.func(self.seg[b], R)
a >>= 1
b >>= 1
return self.func(L, R)
def gcd(a, b):
while b:
a, b = b, a % b
return a
def main():
N = int(readline())
m = list(map(int,read().split()))
seg = SegmentTree(N , gcd , 0)
for i in range(N):
seg.assign(i , next(m))
seg.build()
ans = 1
for i in range(N):
ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
print(ans)
main()
| 56 | 59 | 1,520 | 1,452 | from fractions import gcd
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
import copy
class SegmentTree:
def __init__(self, N, func, I):
self.sz = 2 ** (N - 1).bit_length()
self.func = func
self.I = copy.deepcopy(I)
self.seg = [copy.deepcopy(I) for i in range(self.sz * 2)]
def assign(self, k, x):
self.seg[k + self.sz] = copy.deepcopy(x)
def build(self):
for i in range(self.sz - 1, 0, -1):
self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
def update(self, k, x):
k += self.sz
self.seg[k] = copy.deepcopy(x)
while k > 1:
k >>= 1
self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])
def query(self, a, b):
L = copy.deepcopy(self.I)
R = copy.deepcopy(self.I)
a += self.sz
b += self.sz
while a < b:
if a & 1:
L = self.func(L, self.seg[a])
a += 1
if b & 1:
b -= 1
R = self.func(self.seg[b], R)
a >>= 1
b >>= 1
return self.func(L, R)
def main():
N = int(readline())
m = list(map(int, read().split()))
seg = SegmentTree(N, gcd, 0)
for i in range(N):
seg.assign(i, next(m))
seg.build()
ans = 1
for i in range(N):
ans = max(ans, gcd(seg.query(0, i), seg.query(i + 1, N)))
print(ans)
main()
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
class SegmentTree:
def __init__(self, N, func, I):
self.func = func
self.I = I
self.sz = 2 ** (N - 1).bit_length()
self.seg = [I] * (self.sz * 2)
def assign(self, k, x):
self.seg[k + self.sz] = x
def build(self):
for i in range(self.sz - 1, 0, -1):
self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
def update(self, k, x):
k += self.sz
self.seg[k] = x
while k > 1:
k >>= 1
self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])
def query(self, a, b):
L = self.I
R = self.I
a += self.sz
b += self.sz
while a < b:
if a & 1:
L = self.func(L, self.seg[a])
a += 1
if b & 1:
b -= 1
R = self.func(self.seg[b], R)
a >>= 1
b >>= 1
return self.func(L, R)
def gcd(a, b):
while b:
a, b = b, a % b
return a
def main():
N = int(readline())
m = list(map(int, read().split()))
seg = SegmentTree(N, gcd, 0)
for i in range(N):
seg.assign(i, next(m))
seg.build()
ans = 1
for i in range(N):
ans = max(ans, gcd(seg.query(0, i), seg.query(i + 1, N)))
print(ans)
main()
| false | 5.084746 | [
"-from fractions import gcd",
"-import copy",
"+ self.func = func",
"+ self.I = I",
"- self.func = func",
"- self.I = copy.deepcopy(I)",
"- self.seg = [copy.deepcopy(I) for i in range(self.sz * 2)]",
"+ self.seg = [I] * (self.sz * 2)",
"- self.seg[k + self.sz] = copy.deepcopy(x)",
"+ self.seg[k + self.sz] = x",
"- self.seg[k] = copy.deepcopy(x)",
"+ self.seg[k] = x",
"- L = copy.deepcopy(self.I)",
"- R = copy.deepcopy(self.I)",
"+ L = self.I",
"+ R = self.I",
"+",
"+",
"+def gcd(a, b):",
"+ while b:",
"+ a, b = b, a % b",
"+ return a"
] | false | 0.131856 | 0.073117 | 1.803358 | [
"s797001049",
"s291758013"
] |
u216392490 | p02596 | python | s043772087 | s404933136 | 246 | 183 | 9,180 | 9,180 | Accepted | Accepted | 25.61 | import sys
import math
import time
sys.setrecursionlimit(int(1e6))
if False:
dprint = print
else:
def dprint(*args):
pass
k = list(map(int, input().split()))[0]
am = 7 % k
i = 1
for i in range(k):
if am==0:
print(i+1)
exit()
else:
i+=1
am=(am*10+7)%k
print('-1')
| import sys
import math
import time
sys.setrecursionlimit(int(1e6))
if False:
dprint = print
else:
def dprint(*args):
pass
k = list(map(int, input().split()))[0]
modk = 7 % k
i = 1
for i in range(k):
if modk == 0:
print(i+1)
exit()
modk = (modk * 10 + 7) % k
else:
print(-1)
| 24 | 22 | 347 | 342 | import sys
import math
import time
sys.setrecursionlimit(int(1e6))
if False:
dprint = print
else:
def dprint(*args):
pass
k = list(map(int, input().split()))[0]
am = 7 % k
i = 1
for i in range(k):
if am == 0:
print(i + 1)
exit()
else:
i += 1
am = (am * 10 + 7) % k
print("-1")
| import sys
import math
import time
sys.setrecursionlimit(int(1e6))
if False:
dprint = print
else:
def dprint(*args):
pass
k = list(map(int, input().split()))[0]
modk = 7 % k
i = 1
for i in range(k):
if modk == 0:
print(i + 1)
exit()
modk = (modk * 10 + 7) % k
else:
print(-1)
| false | 8.333333 | [
"-am = 7 % k",
"+modk = 7 % k",
"- if am == 0:",
"+ if modk == 0:",
"- else:",
"- i += 1",
"- am = (am * 10 + 7) % k",
"-print(\"-1\")",
"+ modk = (modk * 10 + 7) % k",
"+else:",
"+ print(-1)"
] | false | 0.226557 | 0.336837 | 0.672602 | [
"s043772087",
"s404933136"
] |
u203843959 | p03401 | python | s592448494 | s547658036 | 256 | 229 | 14,048 | 14,048 | Accepted | Accepted | 10.55 | N=int(eval(input()))
alist=list(map(int,input().split()))
a2list=[0]+alist+[0]
#print(a2list)
alldist=0
for i in range(1,N+2):
alldist+=abs(a2list[i]-a2list[i-1])
#print(alldist)
for i in range(N):
if a2list[i+1]-a2list[i]>=0 and a2list[i+2]-a2list[i+1]>=0:
print(alldist)
elif a2list[i+1]-a2list[i]<=0 and a2list[i+2]-a2list[i+1]<=0:
print(alldist)
else:
dist=alldist-abs(a2list[i+1]-a2list[i])-abs(a2list[i+2]-a2list[i+1])+abs(a2list[i+2]-a2list[i])
print(dist) | N=int(eval(input()))
alist=list(map(int,input().split()))
a2list=[0]+alist+[0]
#print(a2list)
alldist=0
for i in range(1,N+2):
alldist+=abs(a2list[i]-a2list[i-1])
#print(alldist)
for i in range(N):
dist=alldist-abs(a2list[i+1]-a2list[i])-abs(a2list[i+2]-a2list[i+1])+abs(a2list[i+2]-a2list[i])
print(dist) | 18 | 13 | 500 | 319 | N = int(eval(input()))
alist = list(map(int, input().split()))
a2list = [0] + alist + [0]
# print(a2list)
alldist = 0
for i in range(1, N + 2):
alldist += abs(a2list[i] - a2list[i - 1])
# print(alldist)
for i in range(N):
if a2list[i + 1] - a2list[i] >= 0 and a2list[i + 2] - a2list[i + 1] >= 0:
print(alldist)
elif a2list[i + 1] - a2list[i] <= 0 and a2list[i + 2] - a2list[i + 1] <= 0:
print(alldist)
else:
dist = (
alldist
- abs(a2list[i + 1] - a2list[i])
- abs(a2list[i + 2] - a2list[i + 1])
+ abs(a2list[i + 2] - a2list[i])
)
print(dist)
| N = int(eval(input()))
alist = list(map(int, input().split()))
a2list = [0] + alist + [0]
# print(a2list)
alldist = 0
for i in range(1, N + 2):
alldist += abs(a2list[i] - a2list[i - 1])
# print(alldist)
for i in range(N):
dist = (
alldist
- abs(a2list[i + 1] - a2list[i])
- abs(a2list[i + 2] - a2list[i + 1])
+ abs(a2list[i + 2] - a2list[i])
)
print(dist)
| false | 27.777778 | [
"- if a2list[i + 1] - a2list[i] >= 0 and a2list[i + 2] - a2list[i + 1] >= 0:",
"- print(alldist)",
"- elif a2list[i + 1] - a2list[i] <= 0 and a2list[i + 2] - a2list[i + 1] <= 0:",
"- print(alldist)",
"- else:",
"- dist = (",
"- alldist",
"- - abs(a2list[i + 1] - a2list[i])",
"- - abs(a2list[i + 2] - a2list[i + 1])",
"- + abs(a2list[i + 2] - a2list[i])",
"- )",
"- print(dist)",
"+ dist = (",
"+ alldist",
"+ - abs(a2list[i + 1] - a2list[i])",
"+ - abs(a2list[i + 2] - a2list[i + 1])",
"+ + abs(a2list[i + 2] - a2list[i])",
"+ )",
"+ print(dist)"
] | false | 0.049827 | 0.038745 | 1.286015 | [
"s592448494",
"s547658036"
] |
u823458368 | p03846 | python | s273294834 | s625398847 | 93 | 76 | 14,008 | 20,560 | Accepted | Accepted | 18.28 | n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
if n%2==1:
dummy = [0]
for i in range(1, 1+(len(a)-1)//2):
dummy.append(2*i)
dummy.append(2*i)
if sorted(a) == dummy:
ans = 2**((len(a)-1)//2)
else:
dummy = []
for i in range(1, 1+(len(a))//2):
dummy.append(2*i - 1)
dummy.append(2*i - 1)
if sorted(a) == dummy:
ans = 2**((len(a))//2)
print((ans%(10**9 + 7))) | n = int(eval(input()))
a = sorted(list(map(int, input().split())))
if len(a)%2==1:
tmp = [0]
for i in range((len(a)-1)//2):
tmp.append((i+1)*2)
tmp.append((i+1)*2)
if a == tmp:
ans = (2**((len(a)-1)//2))%(10**9+7)
else:
ans = 0
else:
tmp = []
for i in range(len(a)//2):
tmp.append(2*i+1)
tmp.append(2*i+1)
if a == tmp:
ans = (2**(len(a)//2))%(10**9+7)
else:
ans = 0
print(ans) | 18 | 22 | 457 | 488 | n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
if n % 2 == 1:
dummy = [0]
for i in range(1, 1 + (len(a) - 1) // 2):
dummy.append(2 * i)
dummy.append(2 * i)
if sorted(a) == dummy:
ans = 2 ** ((len(a) - 1) // 2)
else:
dummy = []
for i in range(1, 1 + (len(a)) // 2):
dummy.append(2 * i - 1)
dummy.append(2 * i - 1)
if sorted(a) == dummy:
ans = 2 ** ((len(a)) // 2)
print((ans % (10**9 + 7)))
| n = int(eval(input()))
a = sorted(list(map(int, input().split())))
if len(a) % 2 == 1:
tmp = [0]
for i in range((len(a) - 1) // 2):
tmp.append((i + 1) * 2)
tmp.append((i + 1) * 2)
if a == tmp:
ans = (2 ** ((len(a) - 1) // 2)) % (10**9 + 7)
else:
ans = 0
else:
tmp = []
for i in range(len(a) // 2):
tmp.append(2 * i + 1)
tmp.append(2 * i + 1)
if a == tmp:
ans = (2 ** (len(a) // 2)) % (10**9 + 7)
else:
ans = 0
print(ans)
| false | 18.181818 | [
"-a = list(map(int, input().split()))",
"-ans = 0",
"-if n % 2 == 1:",
"- dummy = [0]",
"- for i in range(1, 1 + (len(a) - 1) // 2):",
"- dummy.append(2 * i)",
"- dummy.append(2 * i)",
"- if sorted(a) == dummy:",
"- ans = 2 ** ((len(a) - 1) // 2)",
"+a = sorted(list(map(int, input().split())))",
"+if len(a) % 2 == 1:",
"+ tmp = [0]",
"+ for i in range((len(a) - 1) // 2):",
"+ tmp.append((i + 1) * 2)",
"+ tmp.append((i + 1) * 2)",
"+ if a == tmp:",
"+ ans = (2 ** ((len(a) - 1) // 2)) % (10**9 + 7)",
"+ else:",
"+ ans = 0",
"- dummy = []",
"- for i in range(1, 1 + (len(a)) // 2):",
"- dummy.append(2 * i - 1)",
"- dummy.append(2 * i - 1)",
"- if sorted(a) == dummy:",
"- ans = 2 ** ((len(a)) // 2)",
"-print((ans % (10**9 + 7)))",
"+ tmp = []",
"+ for i in range(len(a) // 2):",
"+ tmp.append(2 * i + 1)",
"+ tmp.append(2 * i + 1)",
"+ if a == tmp:",
"+ ans = (2 ** (len(a) // 2)) % (10**9 + 7)",
"+ else:",
"+ ans = 0",
"+print(ans)"
] | false | 0.046927 | 0.047126 | 0.995797 | [
"s273294834",
"s625398847"
] |
u638456847 | p03108 | python | s970055270 | s723356248 | 831 | 490 | 17,704 | 32,856 | Accepted | Accepted | 41.03 | class UnionFind_size:
def __init__(self, n):
self.par = [i for i in range(n+1)]
self.size = [1] * (n+1)
# 根を検索する関数
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.find(self.par[x])
# 結合(unite)する関数
def unite(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.size[x] < self.size[y]:
self.par[x] = y
self.size[y] += self.size[x]
else:
self.par[y] = x
self.size[x] += self.size[y]
# 同じグループに属するかを判定する関数
def same_check(self, x, y):
return self.find(x) == self.find(y)
# 要素が属する木のサイズを返す関数
def get_size(self, x):
return self.size[self.find(x)]
# グループ数を返す関数
def group_sum(self):
c = 0
for i in range(len(self.par)):
if self.find(i) == i:
c += 1
return c
if __name__ == "__main__":
N,M = list(map(int, input().split()))
uf = UnionFind_size(N)
A, B = [0] * M, [0] * M
for i in range(M):
A[i], B[i] = [int(j) for j in input().split()]
total = int(N * (N-1) / 2)
ans = [total]
for i in range(M-1):
if uf.same_check(A[-(i+1)], B[-(i+1)]):
ans.append(ans[i])
else:
ans.append(ans[i] - uf.get_size(A[-(i+1)]) * uf.get_size(B[-(i+1)]))
uf.unite(A[-(i+1)], B[-(i+1)])
for i in (reversed(ans)):
print(i) | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
class UnionFind:
def __init__(self, n):
# 初期状態は全要素が根なので、親は自分自身
self.par = [i for i in range(n+1)]
# 集団の要素数(size)を格納する(初期は全て1)
self.size = [1] * (n+1)
# 根を検索する関数
def find(self, x):
# 根までたどったらその番号を返す
if self.par[x] == x:
return x
# 根でないなら親の要素で再検索
else:
# 検索過程で親を書き換える(圧縮経路)
self.par[x] = self.find(self.par[x])
return self.find(self.par[x])
# 結合(unite)する関数
def unite(self, x, y):
# 根を探す
x = self.find(x)
y = self.find(y)
if x == y:
return
# サイズを比較し、小さい方を大きい方に繋げる
if self.size[x] < self.size[y]:
self.par[x] = y
self.size[y] += self.size[x]
else:
self.par[y] = x
self.size[x] += self.size[y]
# 同じグループに属するかを判定する関数
def is_same(self, x, y):
return self.find(x) == self.find(y)
# 要素が属する木のサイズを返す関数
def get_size(self, x):
return self.size[self.find(x)]
# グループ数を返す関数
def group_sum(self):
c = 0
for i in range(len(self.par)):
if self.find(i) == i:
c += 1
return c
def main():
N,M,*ab = list(map(int, read().split()))
E = [(a, b) for a, b in zip(*[iter(ab)]*2)]
pair = N * (N - 1) // 2
ans = []
uf = UnionFind(N)
con = 0
for a, b in reversed(E):
ans.append(pair)
if not uf.is_same(a, b):
n_a = uf.get_size(a)
n_b = uf.get_size(b)
pair -= n_a * n_b
uf.unite(a, b)
print(("\n".join(map(str, ans[::-1]))))
if __name__ == "__main__":
main()
| 62 | 79 | 1,632 | 1,874 | class UnionFind_size:
def __init__(self, n):
self.par = [i for i in range(n + 1)]
self.size = [1] * (n + 1)
# 根を検索する関数
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.find(self.par[x])
# 結合(unite)する関数
def unite(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.size[x] < self.size[y]:
self.par[x] = y
self.size[y] += self.size[x]
else:
self.par[y] = x
self.size[x] += self.size[y]
# 同じグループに属するかを判定する関数
def same_check(self, x, y):
return self.find(x) == self.find(y)
# 要素が属する木のサイズを返す関数
def get_size(self, x):
return self.size[self.find(x)]
# グループ数を返す関数
def group_sum(self):
c = 0
for i in range(len(self.par)):
if self.find(i) == i:
c += 1
return c
if __name__ == "__main__":
N, M = list(map(int, input().split()))
uf = UnionFind_size(N)
A, B = [0] * M, [0] * M
for i in range(M):
A[i], B[i] = [int(j) for j in input().split()]
total = int(N * (N - 1) / 2)
ans = [total]
for i in range(M - 1):
if uf.same_check(A[-(i + 1)], B[-(i + 1)]):
ans.append(ans[i])
else:
ans.append(ans[i] - uf.get_size(A[-(i + 1)]) * uf.get_size(B[-(i + 1)]))
uf.unite(A[-(i + 1)], B[-(i + 1)])
for i in reversed(ans):
print(i)
| import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
class UnionFind:
def __init__(self, n):
# 初期状態は全要素が根なので、親は自分自身
self.par = [i for i in range(n + 1)]
# 集団の要素数(size)を格納する(初期は全て1)
self.size = [1] * (n + 1)
# 根を検索する関数
def find(self, x):
# 根までたどったらその番号を返す
if self.par[x] == x:
return x
# 根でないなら親の要素で再検索
else:
# 検索過程で親を書き換える(圧縮経路)
self.par[x] = self.find(self.par[x])
return self.find(self.par[x])
# 結合(unite)する関数
def unite(self, x, y):
# 根を探す
x = self.find(x)
y = self.find(y)
if x == y:
return
# サイズを比較し、小さい方を大きい方に繋げる
if self.size[x] < self.size[y]:
self.par[x] = y
self.size[y] += self.size[x]
else:
self.par[y] = x
self.size[x] += self.size[y]
# 同じグループに属するかを判定する関数
def is_same(self, x, y):
return self.find(x) == self.find(y)
# 要素が属する木のサイズを返す関数
def get_size(self, x):
return self.size[self.find(x)]
# グループ数を返す関数
def group_sum(self):
c = 0
for i in range(len(self.par)):
if self.find(i) == i:
c += 1
return c
def main():
N, M, *ab = list(map(int, read().split()))
E = [(a, b) for a, b in zip(*[iter(ab)] * 2)]
pair = N * (N - 1) // 2
ans = []
uf = UnionFind(N)
con = 0
for a, b in reversed(E):
ans.append(pair)
if not uf.is_same(a, b):
n_a = uf.get_size(a)
n_b = uf.get_size(b)
pair -= n_a * n_b
uf.unite(a, b)
print(("\n".join(map(str, ans[::-1]))))
if __name__ == "__main__":
main()
| false | 21.518987 | [
"-class UnionFind_size:",
"+import sys",
"+",
"+read = sys.stdin.read",
"+readline = sys.stdin.readline",
"+readlines = sys.stdin.readlines",
"+",
"+",
"+class UnionFind:",
"+ # 初期状態は全要素が根なので、親は自分自身",
"+ # 集団の要素数(size)を格納する(初期は全て1)",
"+ # 根までたどったらその番号を返す",
"+ # 根でないなら親の要素で再検索",
"+ # 検索過程で親を書き換える(圧縮経路)",
"+ # 根を探す",
"+ # サイズを比較し、小さい方を大きい方に繋げる",
"- def same_check(self, x, y):",
"+ def is_same(self, x, y):",
"+def main():",
"+ N, M, *ab = list(map(int, read().split()))",
"+ E = [(a, b) for a, b in zip(*[iter(ab)] * 2)]",
"+ pair = N * (N - 1) // 2",
"+ ans = []",
"+ uf = UnionFind(N)",
"+ con = 0",
"+ for a, b in reversed(E):",
"+ ans.append(pair)",
"+ if not uf.is_same(a, b):",
"+ n_a = uf.get_size(a)",
"+ n_b = uf.get_size(b)",
"+ pair -= n_a * n_b",
"+ uf.unite(a, b)",
"+ print((\"\\n\".join(map(str, ans[::-1]))))",
"+",
"+",
"- N, M = list(map(int, input().split()))",
"- uf = UnionFind_size(N)",
"- A, B = [0] * M, [0] * M",
"- for i in range(M):",
"- A[i], B[i] = [int(j) for j in input().split()]",
"- total = int(N * (N - 1) / 2)",
"- ans = [total]",
"- for i in range(M - 1):",
"- if uf.same_check(A[-(i + 1)], B[-(i + 1)]):",
"- ans.append(ans[i])",
"- else:",
"- ans.append(ans[i] - uf.get_size(A[-(i + 1)]) * uf.get_size(B[-(i + 1)]))",
"- uf.unite(A[-(i + 1)], B[-(i + 1)])",
"- for i in reversed(ans):",
"- print(i)",
"+ main()"
] | false | 0.047748 | 0.047919 | 0.996427 | [
"s970055270",
"s723356248"
] |
u985929170 | p03044 | python | s370965097 | s930312024 | 759 | 461 | 101,192 | 43,272 | Accepted | Accepted | 39.26 | import sys
sys.setrecursionlimit(500*500)
n = int(eval(input()))
l = [list(map(int,input().split())) for _ in range(n-1)]
g = [[] for _ in range(n)]
for i in l:
v = i[0]-1
y = i[1]-1
w = i[2]
g[v].append([y,w])
g[y].append([v,w])
seen = [0] + [-1] * (n-1)
def dfs(s):
for k in g[s]:
v,w = k[0],k[1]
if seen[v]!=-1:continue
seen[v] = seen[s]^(w%2)
dfs(v)
dfs(0)
for i in seen:
print(i) | n = int(eval(input()))
g = [[] for _ in range(n)]
for _ in range(n-1):
u,v,w = list(map(int,input().split()))
g[u-1].append((v-1,w))
g[v-1].append((u-1,w))
from collections import deque
que = deque()
seen = [0] + [-1]*(n-1)
que.append(0)
while que:
s = que.popleft()
for v,w in g[s]:
if seen[v] != -1:continue
seen[v] = seen[s]^(w%2)
que.append(v)
for i in seen:
print(i) | 26 | 22 | 476 | 432 | import sys
sys.setrecursionlimit(500 * 500)
n = int(eval(input()))
l = [list(map(int, input().split())) for _ in range(n - 1)]
g = [[] for _ in range(n)]
for i in l:
v = i[0] - 1
y = i[1] - 1
w = i[2]
g[v].append([y, w])
g[y].append([v, w])
seen = [0] + [-1] * (n - 1)
def dfs(s):
for k in g[s]:
v, w = k[0], k[1]
if seen[v] != -1:
continue
seen[v] = seen[s] ^ (w % 2)
dfs(v)
dfs(0)
for i in seen:
print(i)
| n = int(eval(input()))
g = [[] for _ in range(n)]
for _ in range(n - 1):
u, v, w = list(map(int, input().split()))
g[u - 1].append((v - 1, w))
g[v - 1].append((u - 1, w))
from collections import deque
que = deque()
seen = [0] + [-1] * (n - 1)
que.append(0)
while que:
s = que.popleft()
for v, w in g[s]:
if seen[v] != -1:
continue
seen[v] = seen[s] ^ (w % 2)
que.append(v)
for i in seen:
print(i)
| false | 15.384615 | [
"-import sys",
"+n = int(eval(input()))",
"+g = [[] for _ in range(n)]",
"+for _ in range(n - 1):",
"+ u, v, w = list(map(int, input().split()))",
"+ g[u - 1].append((v - 1, w))",
"+ g[v - 1].append((u - 1, w))",
"+from collections import deque",
"-sys.setrecursionlimit(500 * 500)",
"-n = int(eval(input()))",
"-l = [list(map(int, input().split())) for _ in range(n - 1)]",
"-g = [[] for _ in range(n)]",
"-for i in l:",
"- v = i[0] - 1",
"- y = i[1] - 1",
"- w = i[2]",
"- g[v].append([y, w])",
"- g[y].append([v, w])",
"+que = deque()",
"-",
"-",
"-def dfs(s):",
"- for k in g[s]:",
"- v, w = k[0], k[1]",
"+que.append(0)",
"+while que:",
"+ s = que.popleft()",
"+ for v, w in g[s]:",
"- dfs(v)",
"-",
"-",
"-dfs(0)",
"+ que.append(v)"
] | false | 0.10131 | 0.130145 | 0.778439 | [
"s370965097",
"s930312024"
] |
u287500079 | p03425 | python | s519826505 | s486368078 | 309 | 148 | 10,212 | 5,332 | Accepted | Accepted | 52.1 | from itertools import combinations
n = int(eval(input()))
s = [eval(input()) for _ in range(n)]
s.sort()
march = [0, 0, 0, 0, 0]
st = ['M', 'A', 'R', 'C', 'H']
for i in range(n):
for j in range(5):
if s[i][0] == st[j]:
march[j] += 1
#print(march)
if sum(march) == 0:
print((0))
exit()
ans = 0
a = list(combinations(list(range(5)), 3))
for i in range(len(a)):
tmp = 1
for j in a[i]:
tmp *= march[j]
ans += tmp
print(ans) | import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return eval(input())
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def S_MAP(): return list(map(str, input().split()))
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
n = INT()
num = [0 for _ in range(5)]
arr = ['M', 'A', 'R', 'C', 'H']
for _ in range(n):
s = STR()
if s[0] in arr:
num[arr.index(s[0])] += 1
ans = 0
arr2 = list(combinations(list(range(5)), 3))
for i in range(len(arr2)):
tmp = 1
for j in arr2[i]:
tmp *= num[j]
ans += tmp
print(ans)
| 26 | 34 | 480 | 1,091 | from itertools import combinations
n = int(eval(input()))
s = [eval(input()) for _ in range(n)]
s.sort()
march = [0, 0, 0, 0, 0]
st = ["M", "A", "R", "C", "H"]
for i in range(n):
for j in range(5):
if s[i][0] == st[j]:
march[j] += 1
# print(march)
if sum(march) == 0:
print((0))
exit()
ans = 0
a = list(combinations(list(range(5)), 3))
for i in range(len(a)):
tmp = 1
for j in a[i]:
tmp *= march[j]
ans += tmp
print(ans)
| import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input():
return sys.stdin.readline().strip()
def STR():
return eval(input())
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def S_MAP():
return list(map(str, input().split()))
def LIST():
return list(map(int, input().split()))
def S_LIST():
return list(map(str, input().split()))
sys.setrecursionlimit(10**9)
inf = sys.maxsize
mod = 10**9 + 7
n = INT()
num = [0 for _ in range(5)]
arr = ["M", "A", "R", "C", "H"]
for _ in range(n):
s = STR()
if s[0] in arr:
num[arr.index(s[0])] += 1
ans = 0
arr2 = list(combinations(list(range(5)), 3))
for i in range(len(arr2)):
tmp = 1
for j in arr2[i]:
tmp *= num[j]
ans += tmp
print(ans)
| false | 23.529412 | [
"-from itertools import combinations",
"+import sys, re, os",
"+from collections import deque, defaultdict, Counter",
"+from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin",
"+from itertools import permutations, combinations, product, accumulate",
"+from operator import itemgetter, mul",
"+from copy import deepcopy",
"+from string import ascii_lowercase, ascii_uppercase, digits",
"+from fractions import gcd",
"-n = int(eval(input()))",
"-s = [eval(input()) for _ in range(n)]",
"-s.sort()",
"-march = [0, 0, 0, 0, 0]",
"-st = [\"M\", \"A\", \"R\", \"C\", \"H\"]",
"-for i in range(n):",
"- for j in range(5):",
"- if s[i][0] == st[j]:",
"- march[j] += 1",
"-# print(march)",
"-if sum(march) == 0:",
"- print((0))",
"- exit()",
"+",
"+def input():",
"+ return sys.stdin.readline().strip()",
"+",
"+",
"+def STR():",
"+ return eval(input())",
"+",
"+",
"+def INT():",
"+ return int(eval(input()))",
"+",
"+",
"+def MAP():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def S_MAP():",
"+ return list(map(str, input().split()))",
"+",
"+",
"+def LIST():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def S_LIST():",
"+ return list(map(str, input().split()))",
"+",
"+",
"+sys.setrecursionlimit(10**9)",
"+inf = sys.maxsize",
"+mod = 10**9 + 7",
"+n = INT()",
"+num = [0 for _ in range(5)]",
"+arr = [\"M\", \"A\", \"R\", \"C\", \"H\"]",
"+for _ in range(n):",
"+ s = STR()",
"+ if s[0] in arr:",
"+ num[arr.index(s[0])] += 1",
"-a = list(combinations(list(range(5)), 3))",
"-for i in range(len(a)):",
"+arr2 = list(combinations(list(range(5)), 3))",
"+for i in range(len(arr2)):",
"- for j in a[i]:",
"- tmp *= march[j]",
"+ for j in arr2[i]:",
"+ tmp *= num[j]"
] | false | 0.06011 | 0.067933 | 0.884836 | [
"s519826505",
"s486368078"
] |
u380524497 | p02708 | python | s064861991 | s467270504 | 176 | 89 | 9,188 | 9,168 | Accepted | Accepted | 49.43 | n, k = list(map(int, input().split()))
mod = 10 ** 9 + 7
ans = 0
for t in range(k, n+2):
mini = t * (t-1) // 2 % mod
residue = n - t + 1
maxim = mini + t * residue
maxim %= mod
count = maxim - mini + 1
count %= mod
ans += count
ans %= mod
print(ans)
| n, k = list(map(int, input().split()))
mod = 10 ** 9 + 7
ans = 0
for t in range(k, n+2):
pattern = t * (n+1-t) + 1 % mod
ans = (ans + pattern) % mod
print(ans)
| 15 | 9 | 292 | 172 | n, k = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
for t in range(k, n + 2):
mini = t * (t - 1) // 2 % mod
residue = n - t + 1
maxim = mini + t * residue
maxim %= mod
count = maxim - mini + 1
count %= mod
ans += count
ans %= mod
print(ans)
| n, k = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
for t in range(k, n + 2):
pattern = t * (n + 1 - t) + 1 % mod
ans = (ans + pattern) % mod
print(ans)
| false | 40 | [
"- mini = t * (t - 1) // 2 % mod",
"- residue = n - t + 1",
"- maxim = mini + t * residue",
"- maxim %= mod",
"- count = maxim - mini + 1",
"- count %= mod",
"- ans += count",
"- ans %= mod",
"+ pattern = t * (n + 1 - t) + 1 % mod",
"+ ans = (ans + pattern) % mod"
] | false | 0.073322 | 0.049552 | 1.4797 | [
"s064861991",
"s467270504"
] |
u970197315 | p03014 | python | s958072957 | s891294080 | 1,035 | 824 | 181,252 | 179,588 | Accepted | Accepted | 20.39 | # D -Lamp
h,w=list(map(int,input().split()))
g=[eval(input()) for i in range(h)]
l=[[0]*w for i in range(h)]
r=[[0]*w for i in range(h)]
u=[[0]*w for i in range(h)]
o=[[0]*w for i in range(h)]
for i in range(h):
if g[i][0]=='.':
l[i][0]=1
for i in range(h):
for j in range(w-1):
if g[i][j+1]=='.':
l[i][j+1]=l[i][j]+1
elif g[i][j+1]=='#':
l[i][j+1]=0
for i in range(h):
if g[i][w-1]=='.':
r[i][w-1]=1
for i in range(h):
for j in range(w-1,0,-1):
if g[i][j-1]=='.':
r[i][j-1]=r[i][j]+1
elif g[i][j-1]=='#':
r[i][j-1]=0
for i in range(w):
if g[0][i]=='.':
u[0][i]=1
for i in range(w):
for j in range(h-1):
if g[j+1][i]=='.':
u[j+1][i]=u[j][i]+1
elif g[j+1][i]=='#':
u[j+1][i]=0
for i in range(w):
if g[h-1][i]=='.':
o[h-1][i]=1
for i in range(w):
for j in range(h-1,0,-1):
if g[j-1][i]=='.':
o[j-1][i]=o[j][i]+1
elif g[j-1][i]=='#':
o[j-1][i]=0
ans=0
for i in range(h):
for j in range(w):
ans=max(ans,l[i][j]+r[i][j]+u[i][j]+o[i][j]-3)
print(ans)
| h,w=list(map(int,input().split()))
s=[]
s.append("#"*(w+2))
for i in range(h):
s.append("#"+eval(input())+"#")
s.append("#"*(w+2))
r=[[0]*(w+2) for i in range(h+2)]
l=[[0]*(w+2) for i in range(h+2)]
d=[[0]*(w+2) for i in range(h+2)]
u=[[0]*(w+2) for i in range(h+2)]
for i in range(1,h+1):
for j in range(w+1,0,-1):
if s[i][j]=="#":
r[i][j]=0
else:
r[i][j]+=r[i][j+1]+1
# print(r)
for i in range(1,h+1):
for j in range(1,w+1):
if s[i][j]=="#":
l[i][j]=0
else:
l[i][j]+=l[i][j-1]+1
# print(l)
for i in range(1,h+1):
for j in range(1,w+1):
if s[i][j]=="#":
u[i][j]=0
else:
u[i][j]+=u[i-1][j]+1
# print(u)
for i in range(h+1,0,-1):
for j in range(1,w+1):
if s[i][j]=="#":
d[i][j]=0
else:
d[i][j]+=d[i+1][j]+1
# print(d)
ans=0
for i in range(1,h+1):
for j in range(1,w+1):
ans=max(r[i][j]+l[i][j]+u[i][j]+d[i][j]-3,ans)
print(ans) | 58 | 44 | 1,237 | 954 | # D -Lamp
h, w = list(map(int, input().split()))
g = [eval(input()) for i in range(h)]
l = [[0] * w for i in range(h)]
r = [[0] * w for i in range(h)]
u = [[0] * w for i in range(h)]
o = [[0] * w for i in range(h)]
for i in range(h):
if g[i][0] == ".":
l[i][0] = 1
for i in range(h):
for j in range(w - 1):
if g[i][j + 1] == ".":
l[i][j + 1] = l[i][j] + 1
elif g[i][j + 1] == "#":
l[i][j + 1] = 0
for i in range(h):
if g[i][w - 1] == ".":
r[i][w - 1] = 1
for i in range(h):
for j in range(w - 1, 0, -1):
if g[i][j - 1] == ".":
r[i][j - 1] = r[i][j] + 1
elif g[i][j - 1] == "#":
r[i][j - 1] = 0
for i in range(w):
if g[0][i] == ".":
u[0][i] = 1
for i in range(w):
for j in range(h - 1):
if g[j + 1][i] == ".":
u[j + 1][i] = u[j][i] + 1
elif g[j + 1][i] == "#":
u[j + 1][i] = 0
for i in range(w):
if g[h - 1][i] == ".":
o[h - 1][i] = 1
for i in range(w):
for j in range(h - 1, 0, -1):
if g[j - 1][i] == ".":
o[j - 1][i] = o[j][i] + 1
elif g[j - 1][i] == "#":
o[j - 1][i] = 0
ans = 0
for i in range(h):
for j in range(w):
ans = max(ans, l[i][j] + r[i][j] + u[i][j] + o[i][j] - 3)
print(ans)
| h, w = list(map(int, input().split()))
s = []
s.append("#" * (w + 2))
for i in range(h):
s.append("#" + eval(input()) + "#")
s.append("#" * (w + 2))
r = [[0] * (w + 2) for i in range(h + 2)]
l = [[0] * (w + 2) for i in range(h + 2)]
d = [[0] * (w + 2) for i in range(h + 2)]
u = [[0] * (w + 2) for i in range(h + 2)]
for i in range(1, h + 1):
for j in range(w + 1, 0, -1):
if s[i][j] == "#":
r[i][j] = 0
else:
r[i][j] += r[i][j + 1] + 1
# print(r)
for i in range(1, h + 1):
for j in range(1, w + 1):
if s[i][j] == "#":
l[i][j] = 0
else:
l[i][j] += l[i][j - 1] + 1
# print(l)
for i in range(1, h + 1):
for j in range(1, w + 1):
if s[i][j] == "#":
u[i][j] = 0
else:
u[i][j] += u[i - 1][j] + 1
# print(u)
for i in range(h + 1, 0, -1):
for j in range(1, w + 1):
if s[i][j] == "#":
d[i][j] = 0
else:
d[i][j] += d[i + 1][j] + 1
# print(d)
ans = 0
for i in range(1, h + 1):
for j in range(1, w + 1):
ans = max(r[i][j] + l[i][j] + u[i][j] + d[i][j] - 3, ans)
print(ans)
| false | 24.137931 | [
"-# D -Lamp",
"-g = [eval(input()) for i in range(h)]",
"-l = [[0] * w for i in range(h)]",
"-r = [[0] * w for i in range(h)]",
"-u = [[0] * w for i in range(h)]",
"-o = [[0] * w for i in range(h)]",
"+s = []",
"+s.append(\"#\" * (w + 2))",
"- if g[i][0] == \".\":",
"- l[i][0] = 1",
"-for i in range(h):",
"- for j in range(w - 1):",
"- if g[i][j + 1] == \".\":",
"- l[i][j + 1] = l[i][j] + 1",
"- elif g[i][j + 1] == \"#\":",
"- l[i][j + 1] = 0",
"-for i in range(h):",
"- if g[i][w - 1] == \".\":",
"- r[i][w - 1] = 1",
"-for i in range(h):",
"- for j in range(w - 1, 0, -1):",
"- if g[i][j - 1] == \".\":",
"- r[i][j - 1] = r[i][j] + 1",
"- elif g[i][j - 1] == \"#\":",
"- r[i][j - 1] = 0",
"-for i in range(w):",
"- if g[0][i] == \".\":",
"- u[0][i] = 1",
"-for i in range(w):",
"- for j in range(h - 1):",
"- if g[j + 1][i] == \".\":",
"- u[j + 1][i] = u[j][i] + 1",
"- elif g[j + 1][i] == \"#\":",
"- u[j + 1][i] = 0",
"-for i in range(w):",
"- if g[h - 1][i] == \".\":",
"- o[h - 1][i] = 1",
"-for i in range(w):",
"- for j in range(h - 1, 0, -1):",
"- if g[j - 1][i] == \".\":",
"- o[j - 1][i] = o[j][i] + 1",
"- elif g[j - 1][i] == \"#\":",
"- o[j - 1][i] = 0",
"+ s.append(\"#\" + eval(input()) + \"#\")",
"+s.append(\"#\" * (w + 2))",
"+r = [[0] * (w + 2) for i in range(h + 2)]",
"+l = [[0] * (w + 2) for i in range(h + 2)]",
"+d = [[0] * (w + 2) for i in range(h + 2)]",
"+u = [[0] * (w + 2) for i in range(h + 2)]",
"+for i in range(1, h + 1):",
"+ for j in range(w + 1, 0, -1):",
"+ if s[i][j] == \"#\":",
"+ r[i][j] = 0",
"+ else:",
"+ r[i][j] += r[i][j + 1] + 1",
"+# print(r)",
"+for i in range(1, h + 1):",
"+ for j in range(1, w + 1):",
"+ if s[i][j] == \"#\":",
"+ l[i][j] = 0",
"+ else:",
"+ l[i][j] += l[i][j - 1] + 1",
"+# print(l)",
"+for i in range(1, h + 1):",
"+ for j in range(1, w + 1):",
"+ if s[i][j] == \"#\":",
"+ u[i][j] = 0",
"+ else:",
"+ u[i][j] += u[i - 1][j] + 1",
"+# print(u)",
"+for i in range(h + 1, 0, -1):",
"+ for j in range(1, w + 1):",
"+ if s[i][j] == \"#\":",
"+ d[i][j] = 0",
"+ else:",
"+ d[i][j] += d[i + 1][j] + 1",
"+# print(d)",
"-for i in range(h):",
"- for j in range(w):",
"- ans = max(ans, l[i][j] + r[i][j] + u[i][j] + o[i][j] - 3)",
"+for i in range(1, h + 1):",
"+ for j in range(1, w + 1):",
"+ ans = max(r[i][j] + l[i][j] + u[i][j] + d[i][j] - 3, ans)"
] | false | 0.043372 | 0.034119 | 1.271187 | [
"s958072957",
"s891294080"
] |
u844646164 | p03401 | python | s044278206 | s559880212 | 226 | 171 | 13,920 | 90,468 | Accepted | Accepted | 24.34 | N = int(eval(input()))
A = list(map(int, input().split()))
A.insert(0, 0)
A.append(0)
a = 0
cost = 0
for i in A:
b = i
cost += abs(a-b)
a = b
cost += abs(A[-1])
ori = cost
for i in range(1, len(A)-1):
cost += abs(A[i-1]-A[i+1])
cost -= abs(A[i-1]-A[i])+abs(A[i+1]-A[i])
print(cost)
cost = ori | N = int(eval(input()))
A = list(map(int, input().split()))
ans = abs(A[0])
ans += sum([abs(A[i]-A[i-1]) for i in range(1, N)])
ans += abs(A[-1])
for i in range(N):
if i == 0:
if (0 <= A[i] <= A[i+1]) or (A[i+1] <= A[i] <= 0):
tmp = ans
else:
tmp = ans - abs(A[0]) - abs(A[0]-A[1]) + abs(A[1])
print(tmp)
elif i == N-1:
if (0 <= A[i] <= A[i-1]) or (A[i-1] <= A[i] <= 0):
tmp = ans
else:
tmp = ans - abs(A[i]-A[i-1]) - abs(A[i]) + abs(A[i-1])
print(tmp)
else:
if (A[i-1] <= A[i] <= A[i+1]) or (A[i-1] >= A[i] >= A[i+1]):
print(ans)
else:
tmp = ans - abs(A[i]-A[i-1]) - abs(A[i]-A[i+1]) + abs(A[i+1]-A[i-1])
print(tmp) | 18 | 25 | 333 | 795 | N = int(eval(input()))
A = list(map(int, input().split()))
A.insert(0, 0)
A.append(0)
a = 0
cost = 0
for i in A:
b = i
cost += abs(a - b)
a = b
cost += abs(A[-1])
ori = cost
for i in range(1, len(A) - 1):
cost += abs(A[i - 1] - A[i + 1])
cost -= abs(A[i - 1] - A[i]) + abs(A[i + 1] - A[i])
print(cost)
cost = ori
| N = int(eval(input()))
A = list(map(int, input().split()))
ans = abs(A[0])
ans += sum([abs(A[i] - A[i - 1]) for i in range(1, N)])
ans += abs(A[-1])
for i in range(N):
if i == 0:
if (0 <= A[i] <= A[i + 1]) or (A[i + 1] <= A[i] <= 0):
tmp = ans
else:
tmp = ans - abs(A[0]) - abs(A[0] - A[1]) + abs(A[1])
print(tmp)
elif i == N - 1:
if (0 <= A[i] <= A[i - 1]) or (A[i - 1] <= A[i] <= 0):
tmp = ans
else:
tmp = ans - abs(A[i] - A[i - 1]) - abs(A[i]) + abs(A[i - 1])
print(tmp)
else:
if (A[i - 1] <= A[i] <= A[i + 1]) or (A[i - 1] >= A[i] >= A[i + 1]):
print(ans)
else:
tmp = (
ans
- abs(A[i] - A[i - 1])
- abs(A[i] - A[i + 1])
+ abs(A[i + 1] - A[i - 1])
)
print(tmp)
| false | 28 | [
"-A.insert(0, 0)",
"-A.append(0)",
"-a = 0",
"-cost = 0",
"-for i in A:",
"- b = i",
"- cost += abs(a - b)",
"- a = b",
"-cost += abs(A[-1])",
"-ori = cost",
"-for i in range(1, len(A) - 1):",
"- cost += abs(A[i - 1] - A[i + 1])",
"- cost -= abs(A[i - 1] - A[i]) + abs(A[i + 1] - A[i])",
"- print(cost)",
"- cost = ori",
"+ans = abs(A[0])",
"+ans += sum([abs(A[i] - A[i - 1]) for i in range(1, N)])",
"+ans += abs(A[-1])",
"+for i in range(N):",
"+ if i == 0:",
"+ if (0 <= A[i] <= A[i + 1]) or (A[i + 1] <= A[i] <= 0):",
"+ tmp = ans",
"+ else:",
"+ tmp = ans - abs(A[0]) - abs(A[0] - A[1]) + abs(A[1])",
"+ print(tmp)",
"+ elif i == N - 1:",
"+ if (0 <= A[i] <= A[i - 1]) or (A[i - 1] <= A[i] <= 0):",
"+ tmp = ans",
"+ else:",
"+ tmp = ans - abs(A[i] - A[i - 1]) - abs(A[i]) + abs(A[i - 1])",
"+ print(tmp)",
"+ else:",
"+ if (A[i - 1] <= A[i] <= A[i + 1]) or (A[i - 1] >= A[i] >= A[i + 1]):",
"+ print(ans)",
"+ else:",
"+ tmp = (",
"+ ans",
"+ - abs(A[i] - A[i - 1])",
"+ - abs(A[i] - A[i + 1])",
"+ + abs(A[i + 1] - A[i - 1])",
"+ )",
"+ print(tmp)"
] | false | 0.039303 | 0.074872 | 0.524933 | [
"s044278206",
"s559880212"
] |
u698868214 | p03294 | python | s915496348 | s616062616 | 29 | 25 | 9,304 | 9,400 | Accepted | Accepted | 13.79 | N = int(eval(input()))
A = list(map(int,input().split()))
ans = 0
for i in range(N):
ans += A[i] - 1
print(ans) | import math
N = int(eval(input()))
A = list(map(int,input().split()))
A = list([int(math.copysign(x-1, x)) for x in A])
print((sum(A))) | 8 | 7 | 118 | 140 | N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for i in range(N):
ans += A[i] - 1
print(ans)
| import math
N = int(eval(input()))
A = list(map(int, input().split()))
A = list([int(math.copysign(x - 1, x)) for x in A])
print((sum(A)))
| false | 12.5 | [
"+import math",
"+",
"-ans = 0",
"-for i in range(N):",
"- ans += A[i] - 1",
"-print(ans)",
"+A = list([int(math.copysign(x - 1, x)) for x in A])",
"+print((sum(A)))"
] | false | 0.036611 | 0.043889 | 0.834153 | [
"s915496348",
"s616062616"
] |
u392319141 | p03283 | python | s098810067 | s854364802 | 2,989 | 1,161 | 45,828 | 77,680 | Accepted | Accepted | 61.16 | import numpy as np
N, M, K = map(int, input().split())
LR = np.zeros(shape=(N + 1, N + 1), dtype=np.int32)
for _ in range(M):
L, R = map(int, input().split())
LR[L, R] += 1
np.cumsum(LR, axis=0, out=LR)
np.cumsum(LR, axis=1, out=LR)
P, Q = np.array([input().split() for _ in range(K)], dtype=np.int32).T
P -= 1
ans = LR[Q, Q] - LR[P, Q] - LR[Q, P] + LR[P, P]
print(*ans, sep='\n')
| import numpy as np
N, M, K = map(int, input().split())
LR = np.zeros(shape=(N + 1, N + 1), dtype=np.int32)
L, R = np.array([input().split() for _ in range(M)], dtype=np.int32).T
np.add.at(LR, (L, R), 1)
np.cumsum(LR, axis=0, out=LR)
np.cumsum(LR, axis=1, out=LR)
P, Q = np.array([input().split() for _ in range(K)], dtype=np.int32).T
P -= 1
ans = LR[Q, Q] - LR[P, Q] - LR[Q, P] + LR[P, P]
print(*ans, sep='\n')
| 17 | 16 | 410 | 431 | import numpy as np
N, M, K = map(int, input().split())
LR = np.zeros(shape=(N + 1, N + 1), dtype=np.int32)
for _ in range(M):
L, R = map(int, input().split())
LR[L, R] += 1
np.cumsum(LR, axis=0, out=LR)
np.cumsum(LR, axis=1, out=LR)
P, Q = np.array([input().split() for _ in range(K)], dtype=np.int32).T
P -= 1
ans = LR[Q, Q] - LR[P, Q] - LR[Q, P] + LR[P, P]
print(*ans, sep="\n")
| import numpy as np
N, M, K = map(int, input().split())
LR = np.zeros(shape=(N + 1, N + 1), dtype=np.int32)
L, R = np.array([input().split() for _ in range(M)], dtype=np.int32).T
np.add.at(LR, (L, R), 1)
np.cumsum(LR, axis=0, out=LR)
np.cumsum(LR, axis=1, out=LR)
P, Q = np.array([input().split() for _ in range(K)], dtype=np.int32).T
P -= 1
ans = LR[Q, Q] - LR[P, Q] - LR[Q, P] + LR[P, P]
print(*ans, sep="\n")
| false | 5.882353 | [
"-for _ in range(M):",
"- L, R = map(int, input().split())",
"- LR[L, R] += 1",
"+L, R = np.array([input().split() for _ in range(M)], dtype=np.int32).T",
"+np.add.at(LR, (L, R), 1)"
] | false | 0.198277 | 0.314233 | 0.630987 | [
"s098810067",
"s854364802"
] |
u461573913 | p03381 | python | s157571916 | s096569083 | 1,053 | 444 | 34,148 | 34,196 | Accepted | Accepted | 57.83 | import numpy as np
N = int(eval(input()))
X = np.array(list(map(int, input().split())))
sort_X = np.sort(X)
l = sort_X[int(N/2 - 1)]
r = sort_X[int(N/2)]
for i in range(N):
if (X[i] <= l):
print(r)
else:
print(l)
| import numpy as np
N = int(eval(input()))
X = list(map(int, input().split()))
sort_X = sorted(X)
l = sort_X[int(N/2 - 1)]
r = sort_X[int(N/2)]
for i in range(N):
if (X[i] <= l):
print(r)
else:
print(l)
| 14 | 14 | 247 | 236 | import numpy as np
N = int(eval(input()))
X = np.array(list(map(int, input().split())))
sort_X = np.sort(X)
l = sort_X[int(N / 2 - 1)]
r = sort_X[int(N / 2)]
for i in range(N):
if X[i] <= l:
print(r)
else:
print(l)
| import numpy as np
N = int(eval(input()))
X = list(map(int, input().split()))
sort_X = sorted(X)
l = sort_X[int(N / 2 - 1)]
r = sort_X[int(N / 2)]
for i in range(N):
if X[i] <= l:
print(r)
else:
print(l)
| false | 0 | [
"-X = np.array(list(map(int, input().split())))",
"-sort_X = np.sort(X)",
"+X = list(map(int, input().split()))",
"+sort_X = sorted(X)"
] | false | 0.261991 | 0.034813 | 7.525618 | [
"s157571916",
"s096569083"
] |
u254871849 | p03210 | python | s149924074 | s476541617 | 20 | 17 | 3,060 | 2,940 | Accepted | Accepted | 15 | import sys
cand = [7, 5, 3]
x = int(sys.stdin.readline().rstrip())
def main():
return 'YES' if x in cand else 'NO'
if __name__ == '__main__':
ans = main()
print(ans) | import sys
u = set('753')
x = sys.stdin.readline().rstrip()
def main():
ans = 'YES' if x in u else 'NO'
print(ans)
if __name__ == '__main__':
main() | 12 | 11 | 192 | 174 | import sys
cand = [7, 5, 3]
x = int(sys.stdin.readline().rstrip())
def main():
return "YES" if x in cand else "NO"
if __name__ == "__main__":
ans = main()
print(ans)
| import sys
u = set("753")
x = sys.stdin.readline().rstrip()
def main():
ans = "YES" if x in u else "NO"
print(ans)
if __name__ == "__main__":
main()
| false | 8.333333 | [
"-cand = [7, 5, 3]",
"-x = int(sys.stdin.readline().rstrip())",
"+u = set(\"753\")",
"+x = sys.stdin.readline().rstrip()",
"- return \"YES\" if x in cand else \"NO\"",
"+ ans = \"YES\" if x in u else \"NO\"",
"+ print(ans)",
"- ans = main()",
"- print(ans)",
"+ main()"
] | false | 0.043156 | 0.043189 | 0.999248 | [
"s149924074",
"s476541617"
] |
u077291787 | p03608 | python | s998511767 | s655951673 | 208 | 143 | 9,836 | 8,252 | Accepted | Accepted | 31.25 | # ABC073D - joisino's travel (210ms)
from heapq import heapify, heappop, heappush
from itertools import permutations
def dijkstra(source: int) -> list:
dist = [float("inf")] * (N + 1)
undetermined = N # vertex_0 won't appear in 1-idx graph
queue = [(0, source)]
heapify(queue)
while queue:
cost, v = heappop(queue)
if cost > dist[v]:
continue
dist[v] = cost
for next_cost, u in G[v]:
if cost + next_cost < dist[u]:
heappush(queue, (cost + next_cost, u))
undetermined -= 1
if not undetermined:
return dist
def main():
global G, N
N, M, R, *RABC = list(map(int, open(0).read().split()))
visit, ABC = RABC[:R], RABC[R:]
G = [[] for _ in range(N + 1)]
for v, u, cost in zip(*[iter(ABC)] * 3):
G[v].append((cost, u)), G[u].append((cost, v))
dist = {v: dijkstra(v) for v in visit}
ans = float("inf")
for perm in permutations(visit):
cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))
ans = min(ans, cur)
print(ans)
if __name__ == "__main__":
main() | # ABC073D - joisino's travel
from heapq import heappop, heappush
from itertools import permutations
def dijkstra(source: int) -> "Array[int]":
# compute the distance of the shortest path from V_source to each vertex
size = len(G)
dist = [float("inf")] * size
dist[source] = 0
undetermined = size - 2 # V_0 and V_source are determined in 1-idx graph
queue = [(0, source)]
while queue:
cost, v = heappop(queue)
if cost > dist[v]:
continue
for next_cost, u in G[v]:
if cost + next_cost < dist[u]:
dist[u] = cost + next_cost
heappush(queue, (dist[u], u))
undetermined -= 1
if not undetermined:
return dist
return dist
def main():
global G
N, M, R, *RABC = list(map(int, open(0).read().split()))
visit, ABC = RABC[:R], RABC[R:]
G = [[] for _ in range(N + 1)]
for v, u, cost in zip(*[iter(ABC)] * 3):
G[v].append((cost, u)), G[u].append((cost, v))
dist = {v: dijkstra(v) for v in visit}
ans = float("inf")
for perm in permutations(visit):
cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))
ans = min(ans, cur)
print(ans)
if __name__ == "__main__":
main() | 40 | 43 | 1,169 | 1,298 | # ABC073D - joisino's travel (210ms)
from heapq import heapify, heappop, heappush
from itertools import permutations
def dijkstra(source: int) -> list:
dist = [float("inf")] * (N + 1)
undetermined = N # vertex_0 won't appear in 1-idx graph
queue = [(0, source)]
heapify(queue)
while queue:
cost, v = heappop(queue)
if cost > dist[v]:
continue
dist[v] = cost
for next_cost, u in G[v]:
if cost + next_cost < dist[u]:
heappush(queue, (cost + next_cost, u))
undetermined -= 1
if not undetermined:
return dist
def main():
global G, N
N, M, R, *RABC = list(map(int, open(0).read().split()))
visit, ABC = RABC[:R], RABC[R:]
G = [[] for _ in range(N + 1)]
for v, u, cost in zip(*[iter(ABC)] * 3):
G[v].append((cost, u)), G[u].append((cost, v))
dist = {v: dijkstra(v) for v in visit}
ans = float("inf")
for perm in permutations(visit):
cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))
ans = min(ans, cur)
print(ans)
if __name__ == "__main__":
main()
| # ABC073D - joisino's travel
from heapq import heappop, heappush
from itertools import permutations
def dijkstra(source: int) -> "Array[int]":
# compute the distance of the shortest path from V_source to each vertex
size = len(G)
dist = [float("inf")] * size
dist[source] = 0
undetermined = size - 2 # V_0 and V_source are determined in 1-idx graph
queue = [(0, source)]
while queue:
cost, v = heappop(queue)
if cost > dist[v]:
continue
for next_cost, u in G[v]:
if cost + next_cost < dist[u]:
dist[u] = cost + next_cost
heappush(queue, (dist[u], u))
undetermined -= 1
if not undetermined:
return dist
return dist
def main():
global G
N, M, R, *RABC = list(map(int, open(0).read().split()))
visit, ABC = RABC[:R], RABC[R:]
G = [[] for _ in range(N + 1)]
for v, u, cost in zip(*[iter(ABC)] * 3):
G[v].append((cost, u)), G[u].append((cost, v))
dist = {v: dijkstra(v) for v in visit}
ans = float("inf")
for perm in permutations(visit):
cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))
ans = min(ans, cur)
print(ans)
if __name__ == "__main__":
main()
| false | 6.976744 | [
"-# ABC073D - joisino's travel (210ms)",
"-from heapq import heapify, heappop, heappush",
"+# ABC073D - joisino's travel",
"+from heapq import heappop, heappush",
"-def dijkstra(source: int) -> list:",
"- dist = [float(\"inf\")] * (N + 1)",
"- undetermined = N # vertex_0 won't appear in 1-idx graph",
"+def dijkstra(source: int) -> \"Array[int]\":",
"+ # compute the distance of the shortest path from V_source to each vertex",
"+ size = len(G)",
"+ dist = [float(\"inf\")] * size",
"+ dist[source] = 0",
"+ undetermined = size - 2 # V_0 and V_source are determined in 1-idx graph",
"- heapify(queue)",
"- dist[v] = cost",
"- heappush(queue, (cost + next_cost, u))",
"+ dist[u] = cost + next_cost",
"+ heappush(queue, (dist[u], u))",
"+ return dist",
"- global G, N",
"+ global G"
] | false | 0.035762 | 0.041096 | 0.870214 | [
"s998511767",
"s655951673"
] |
u285443936 | p03073 | python | s338750021 | s068466044 | 71 | 35 | 3,188 | 3,188 | Accepted | Accepted | 50.7 | S = eval(input())
#偶数を0,奇数を1にする場合
count01 = 0
for i in range(len(S)):
if i%2 == 0:#偶数番目のとき
if S[i] != "0":
count01 += 1
else:
if S[i] != "1":
count01 += 1
#偶数を1,奇数を0にする場合
count10 = 0
for i in range(len(S)):
if i%2 == 0:#偶数番目のとき
if S[i] != "1":
count10 += 1
else:
if S[i] != "0":
count10 += 1
print((min(count01,count10))) | S = eval(input())
a, b = 0, 0
for i in range(0,len(S),2):
if S[i] == "0":
a += 1
else:
b += 1
for i in range(1,len(S),2):
if S[i] == "1":
a += 1
else:
b += 1
print((min(a, b))) | 23 | 14 | 392 | 206 | S = eval(input())
# 偶数を0,奇数を1にする場合
count01 = 0
for i in range(len(S)):
if i % 2 == 0: # 偶数番目のとき
if S[i] != "0":
count01 += 1
else:
if S[i] != "1":
count01 += 1
# 偶数を1,奇数を0にする場合
count10 = 0
for i in range(len(S)):
if i % 2 == 0: # 偶数番目のとき
if S[i] != "1":
count10 += 1
else:
if S[i] != "0":
count10 += 1
print((min(count01, count10)))
| S = eval(input())
a, b = 0, 0
for i in range(0, len(S), 2):
if S[i] == "0":
a += 1
else:
b += 1
for i in range(1, len(S), 2):
if S[i] == "1":
a += 1
else:
b += 1
print((min(a, b)))
| false | 39.130435 | [
"-# 偶数を0,奇数を1にする場合",
"-count01 = 0",
"-for i in range(len(S)):",
"- if i % 2 == 0: # 偶数番目のとき",
"- if S[i] != \"0\":",
"- count01 += 1",
"+a, b = 0, 0",
"+for i in range(0, len(S), 2):",
"+ if S[i] == \"0\":",
"+ a += 1",
"- if S[i] != \"1\":",
"- count01 += 1",
"-# 偶数を1,奇数を0にする場合",
"-count10 = 0",
"-for i in range(len(S)):",
"- if i % 2 == 0: # 偶数番目のとき",
"- if S[i] != \"1\":",
"- count10 += 1",
"+ b += 1",
"+for i in range(1, len(S), 2):",
"+ if S[i] == \"1\":",
"+ a += 1",
"- if S[i] != \"0\":",
"- count10 += 1",
"-print((min(count01, count10)))",
"+ b += 1",
"+print((min(a, b)))"
] | false | 0.041191 | 0.042819 | 0.961997 | [
"s338750021",
"s068466044"
] |
u193264896 | p02783 | python | s771407826 | s200714914 | 36 | 17 | 5,076 | 3,060 | Accepted | Accepted | 52.78 | from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
def main():
h, a = list(map(int, readline().split()))
print((ceil(h/a)))
if __name__ == '__main__':
main() | import sys
import math
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
def main():
H, A = list(map(int, readline().split()))
print((math.ceil(H/A)))
if __name__ == '__main__':
main() | 26 | 13 | 851 | 257 | from collections import deque
from collections import Counter
from itertools import product, permutations, combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
# pypyではscipy, numpyは使えない
# from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
# from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
# import numpy as np
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float("inf")
def main():
h, a = list(map(int, readline().split()))
print((ceil(h / a)))
if __name__ == "__main__":
main()
| import sys
import math
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**8)
INF = float("inf")
MOD = 10**9 + 7
def main():
H, A = list(map(int, readline().split()))
print((math.ceil(H / A)))
if __name__ == "__main__":
main()
| false | 50 | [
"-from collections import deque",
"-from collections import Counter",
"-from itertools import product, permutations, combinations",
"-from operator import itemgetter",
"-from heapq import heappop, heappush",
"-from bisect import bisect_left, bisect_right, bisect",
"+import sys",
"+import math",
"-# pypyではscipy, numpyは使えない",
"-# from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree",
"-# from scipy.sparse import csr_matrix, coo_matrix, lil_matrix",
"-# import numpy as np",
"-from fractions import gcd",
"-from math import ceil, floor, sqrt, cos, sin, pi, factorial",
"-import sys",
"-",
"-read = sys.stdin.buffer.read",
"-readlines = sys.stdin.buffer.readlines",
"+MOD = 10**9 + 7",
"- h, a = list(map(int, readline().split()))",
"- print((ceil(h / a)))",
"+ H, A = list(map(int, readline().split()))",
"+ print((math.ceil(H / A)))"
] | false | 0.046301 | 0.038366 | 1.206803 | [
"s771407826",
"s200714914"
] |
u302789073 | p03494 | python | s147046463 | s951367904 | 30 | 26 | 9,236 | 9,180 | Accepted | Accepted | 13.33 | n=int(eval(input()))
list=[int(i) for i in input().split()]
c_list=[]
for i in list:
count=0
while True:
if i%2==0:
i=i/2
count+=1
else:
break
c_list.append(count)
print((min(c_list)))
| # Your code here!
n=int(eval(input()))
a_list=[int(i) for i in input().split()]
count_list=[]
for i in range(n):
num=a_list[i]
count=0
while True:
if num%2==0:
num//=2
count+=1
else:
break
count_list.append(count)
#print(count_list)
print((min(count_list))) | 18 | 19 | 282 | 341 | n = int(eval(input()))
list = [int(i) for i in input().split()]
c_list = []
for i in list:
count = 0
while True:
if i % 2 == 0:
i = i / 2
count += 1
else:
break
c_list.append(count)
print((min(c_list)))
| # Your code here!
n = int(eval(input()))
a_list = [int(i) for i in input().split()]
count_list = []
for i in range(n):
num = a_list[i]
count = 0
while True:
if num % 2 == 0:
num //= 2
count += 1
else:
break
count_list.append(count)
# print(count_list)
print((min(count_list)))
| false | 5.263158 | [
"+# Your code here!",
"-list = [int(i) for i in input().split()]",
"-c_list = []",
"-for i in list:",
"+a_list = [int(i) for i in input().split()]",
"+count_list = []",
"+for i in range(n):",
"+ num = a_list[i]",
"- if i % 2 == 0:",
"- i = i / 2",
"+ if num % 2 == 0:",
"+ num //= 2",
"- c_list.append(count)",
"-print((min(c_list)))",
"+ count_list.append(count)",
"+# print(count_list)",
"+print((min(count_list)))"
] | false | 0.04649 | 0.043878 | 1.059518 | [
"s147046463",
"s951367904"
] |
u017810624 | p03077 | python | s929265055 | s656183320 | 21 | 17 | 2,940 | 2,940 | Accepted | Accepted | 19.05 | n=int(eval(input()))
l=[int(eval(input()))for i in range(5)]
print(((n+min(l)-1)//min(l)+4)) | n=int(eval(input()))
x=min([int(eval(input()))for i in range(5)])
print(((n+x-1)//x+4)) | 3 | 3 | 80 | 75 | n = int(eval(input()))
l = [int(eval(input())) for i in range(5)]
print(((n + min(l) - 1) // min(l) + 4))
| n = int(eval(input()))
x = min([int(eval(input())) for i in range(5)])
print(((n + x - 1) // x + 4))
| false | 0 | [
"-l = [int(eval(input())) for i in range(5)]",
"-print(((n + min(l) - 1) // min(l) + 4))",
"+x = min([int(eval(input())) for i in range(5)])",
"+print(((n + x - 1) // x + 4))"
] | false | 0.044022 | 0.042779 | 1.029043 | [
"s929265055",
"s656183320"
] |
u043236471 | p02996 | python | s840660391 | s288057873 | 1,178 | 909 | 38,104 | 42,832 | Accepted | Accepted | 22.84 | N = int(eval(input()))
li = []
for _ in range(N):
a, b = list(map(int,input().split()))
li.append([b,a,b])
flag = True
now = 0
li = sorted(li)
for a, b, c in li:
now += b
if now > c:
print("No")
flag = False
break
if flag:
print("Yes") | N = int(eval(input()))
ab_list = []
for _ in range(N):
ab_list.append([int(x) for x in input().split()])
ab_list = sorted(ab_list, key=lambda x: x[-1])
sum_work = 0
res = 'Yes'
for a, b in ab_list:
sum_work += a
if sum_work > b:
res = 'No'
break
print(res) | 19 | 15 | 302 | 298 | N = int(eval(input()))
li = []
for _ in range(N):
a, b = list(map(int, input().split()))
li.append([b, a, b])
flag = True
now = 0
li = sorted(li)
for a, b, c in li:
now += b
if now > c:
print("No")
flag = False
break
if flag:
print("Yes")
| N = int(eval(input()))
ab_list = []
for _ in range(N):
ab_list.append([int(x) for x in input().split()])
ab_list = sorted(ab_list, key=lambda x: x[-1])
sum_work = 0
res = "Yes"
for a, b in ab_list:
sum_work += a
if sum_work > b:
res = "No"
break
print(res)
| false | 21.052632 | [
"-li = []",
"+ab_list = []",
"- a, b = list(map(int, input().split()))",
"- li.append([b, a, b])",
"-flag = True",
"-now = 0",
"-li = sorted(li)",
"-for a, b, c in li:",
"- now += b",
"- if now > c:",
"- print(\"No\")",
"- flag = False",
"+ ab_list.append([int(x) for x in input().split()])",
"+ab_list = sorted(ab_list, key=lambda x: x[-1])",
"+sum_work = 0",
"+res = \"Yes\"",
"+for a, b in ab_list:",
"+ sum_work += a",
"+ if sum_work > b:",
"+ res = \"No\"",
"-if flag:",
"- print(\"Yes\")",
"+print(res)"
] | false | 0.074495 | 0.047939 | 1.553952 | [
"s840660391",
"s288057873"
] |
u503228842 | p03293 | python | s194759069 | s580565948 | 20 | 17 | 2,940 | 2,940 | Accepted | Accepted | 15 | s = eval(input())
t = eval(input())
for _ in range(len(s)):
s = s[-1]+s[:-1]
#print(s)
if s == t:
print("Yes")
exit()
print("No") | s = eval(input())
t = eval(input())
for i in range(len(s)):
s = s[-1] + s[:-1]
#print(s)
if s == t:
print('Yes')
exit()
print('No') | 9 | 10 | 153 | 157 | s = eval(input())
t = eval(input())
for _ in range(len(s)):
s = s[-1] + s[:-1]
# print(s)
if s == t:
print("Yes")
exit()
print("No")
| s = eval(input())
t = eval(input())
for i in range(len(s)):
s = s[-1] + s[:-1]
# print(s)
if s == t:
print("Yes")
exit()
print("No")
| false | 10 | [
"-for _ in range(len(s)):",
"+for i in range(len(s)):"
] | false | 0.101149 | 0.040883 | 2.47411 | [
"s194759069",
"s580565948"
] |
u169350228 | p02552 | python | s725829576 | s626863139 | 65 | 58 | 61,580 | 62,204 | Accepted | Accepted | 10.77 | print((1-int(eval(input())))) | import math
print((1-math.ceil(math.sin(int(eval(input())))))) | 1 | 2 | 21 | 55 | print((1 - int(eval(input()))))
| import math
print((1 - math.ceil(math.sin(int(eval(input()))))))
| false | 50 | [
"-print((1 - int(eval(input()))))",
"+import math",
"+",
"+print((1 - math.ceil(math.sin(int(eval(input()))))))"
] | false | 0.089206 | 0.095597 | 0.933153 | [
"s725829576",
"s626863139"
] |
u116038906 | p02660 | python | s777757811 | s792331764 | 200 | 113 | 9,460 | 9,380 | Accepted | Accepted | 43.5 | #約数
def make_divisors(n): #約数をリストで返す
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
# divisors.sort()
return divisors
#素因数分解
def soinsu_bunkai(m):
pf={}
for i in range(2,int(m**0.5)+1):
while m%i==0:
pf[i]=pf.get(i,0)+1
m//=i
if m>1:
pf[m]=1
return pf
#初期入力
N = int(eval(input()))
div =make_divisors(N) #Nの約数
div.sort()
div_1_except=div[1:]
count =0
for i in div_1_except:
q,mod= divmod(N,i)
if mod ==0:
ii =soinsu_bunkai(i) #Nの約数を素因数分解
if len(ii) ==1 :
count +=1
N =q
print(count) | #約数は使わず、素因数分解のみ
#素因数分解
def soinsu_bunkai(m):
pf={}
for i in range(2,int(m**0.5)+1):
while m%i==0:
pf[i]=pf.get(i,0)+1
m//=i
if m>1:
pf[m]=1
return pf
#初期入力
N = int(eval(input()))
xx =[]
prime_factorization =soinsu_bunkai(N)
count =0
for i in list(prime_factorization.keys()):
x=1
while x <= prime_factorization[i]:
if N % i**x ==0:
xx.append(i**x)
count +=1
N //= i**x
x +=1
print(count) | 39 | 28 | 762 | 521 | # 約数
def make_divisors(n): # 約数をリストで返す
divisors = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
# divisors.sort()
return divisors
# 素因数分解
def soinsu_bunkai(m):
pf = {}
for i in range(2, int(m**0.5) + 1):
while m % i == 0:
pf[i] = pf.get(i, 0) + 1
m //= i
if m > 1:
pf[m] = 1
return pf
# 初期入力
N = int(eval(input()))
div = make_divisors(N) # Nの約数
div.sort()
div_1_except = div[1:]
count = 0
for i in div_1_except:
q, mod = divmod(N, i)
if mod == 0:
ii = soinsu_bunkai(i) # Nの約数を素因数分解
if len(ii) == 1:
count += 1
N = q
print(count)
| # 約数は使わず、素因数分解のみ
# 素因数分解
def soinsu_bunkai(m):
pf = {}
for i in range(2, int(m**0.5) + 1):
while m % i == 0:
pf[i] = pf.get(i, 0) + 1
m //= i
if m > 1:
pf[m] = 1
return pf
# 初期入力
N = int(eval(input()))
xx = []
prime_factorization = soinsu_bunkai(N)
count = 0
for i in list(prime_factorization.keys()):
x = 1
while x <= prime_factorization[i]:
if N % i**x == 0:
xx.append(i**x)
count += 1
N //= i**x
x += 1
print(count)
| false | 28.205128 | [
"-# 約数",
"-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",
"-",
"-",
"+# 約数は使わず、素因数分解のみ",
"-div = make_divisors(N) # Nの約数",
"-div.sort()",
"-div_1_except = div[1:]",
"+xx = []",
"+prime_factorization = soinsu_bunkai(N)",
"-for i in div_1_except:",
"- q, mod = divmod(N, i)",
"- if mod == 0:",
"- ii = soinsu_bunkai(i) # Nの約数を素因数分解",
"- if len(ii) == 1:",
"+for i in list(prime_factorization.keys()):",
"+ x = 1",
"+ while x <= prime_factorization[i]:",
"+ if N % i**x == 0:",
"+ xx.append(i**x)",
"- N = q",
"+ N //= i**x",
"+ x += 1"
] | false | 0.139989 | 0.044985 | 3.11189 | [
"s777757811",
"s792331764"
] |
u177756077 | p03796 | python | s346057285 | s245903361 | 34 | 24 | 5,764 | 5,764 | Accepted | Accepted | 29.41 | N = eval(input())
ans = 1
for i in range(1, N + 1):
ans = (ans * i) % (1e9 + 7)
print(int(ans)) | #!/usr/bin/env python
n=int(input().strip())
power=1
for i in range(1,n+1):
power=power*i%(10**9+7)
print(power) | 5 | 9 | 93 | 130 | N = eval(input())
ans = 1
for i in range(1, N + 1):
ans = (ans * i) % (1e9 + 7)
print(int(ans))
| #!/usr/bin/env python
n = int(input().strip())
power = 1
for i in range(1, n + 1):
power = power * i % (10**9 + 7)
print(power)
| false | 44.444444 | [
"-N = eval(input())",
"-ans = 1",
"-for i in range(1, N + 1):",
"- ans = (ans * i) % (1e9 + 7)",
"-print(int(ans))",
"+#!/usr/bin/env python",
"+n = int(input().strip())",
"+power = 1",
"+for i in range(1, n + 1):",
"+ power = power * i % (10**9 + 7)",
"+print(power)"
] | false | 0.043831 | 0.041495 | 1.056314 | [
"s346057285",
"s245903361"
] |
u790710233 | p03126 | python | s080113155 | s401951758 | 21 | 17 | 3,316 | 3,060 | Accepted | Accepted | 19.05 | from collections import defaultdict
n, m = list(map(int, input().split()))
s = []
for _ in range(n):
k, *a = list(map(int, input().split()))
s.append(a)
dd = defaultdict(int)
for l in s:
for k in l:
dd[k] += 1
print((sum(1 if v == n else 0 for k, v in list(dd.items()))))
| n, m = list(map(int, input().split()))
s = set(range(1, m+1))
for _ in range(n):
k, *a = list(map(int, input().split()))
s &= set(a)
print((len(s))) | 12 | 6 | 284 | 147 | from collections import defaultdict
n, m = list(map(int, input().split()))
s = []
for _ in range(n):
k, *a = list(map(int, input().split()))
s.append(a)
dd = defaultdict(int)
for l in s:
for k in l:
dd[k] += 1
print((sum(1 if v == n else 0 for k, v in list(dd.items()))))
| n, m = list(map(int, input().split()))
s = set(range(1, m + 1))
for _ in range(n):
k, *a = list(map(int, input().split()))
s &= set(a)
print((len(s)))
| false | 50 | [
"-from collections import defaultdict",
"-",
"-s = []",
"+s = set(range(1, m + 1))",
"- s.append(a)",
"-dd = defaultdict(int)",
"-for l in s:",
"- for k in l:",
"- dd[k] += 1",
"-print((sum(1 if v == n else 0 for k, v in list(dd.items()))))",
"+ s &= set(a)",
"+print((len(s)))"
] | false | 0.041324 | 0.043037 | 0.960195 | [
"s080113155",
"s401951758"
] |
u347640436 | p03379 | python | s066617070 | s300492470 | 320 | 276 | 26,016 | 25,052 | Accepted | Accepted | 13.75 | n = int(eval(input()))
x = list(map(int, input().split()))
y = list(sorted(x))
a = y[n // 2 - 1]
b = y[n // 2]
for i in range(n):
if x[i] >= b:
print(a)
else:
print(b)
| import sys
n, *x = list(map(int, sys.stdin.read().split()))
y = list(sorted(x))
a = y[n // 2 - 1]
b = y[n // 2]
print((*[a if x[i] >= b else b for i in range(n)]))
| 10 | 6 | 183 | 167 | n = int(eval(input()))
x = list(map(int, input().split()))
y = list(sorted(x))
a = y[n // 2 - 1]
b = y[n // 2]
for i in range(n):
if x[i] >= b:
print(a)
else:
print(b)
| import sys
n, *x = list(map(int, sys.stdin.read().split()))
y = list(sorted(x))
a = y[n // 2 - 1]
b = y[n // 2]
print((*[a if x[i] >= b else b for i in range(n)]))
| false | 40 | [
"-n = int(eval(input()))",
"-x = list(map(int, input().split()))",
"+import sys",
"+",
"+n, *x = list(map(int, sys.stdin.read().split()))",
"-for i in range(n):",
"- if x[i] >= b:",
"- print(a)",
"- else:",
"- print(b)",
"+print((*[a if x[i] >= b else b for i in range(n)]))"
] | false | 0.045912 | 0.073384 | 0.625645 | [
"s066617070",
"s300492470"
] |
u994307795 | p02784 | python | s935418622 | s861279192 | 59 | 38 | 13,788 | 10,528 | Accepted | Accepted | 35.59 | h, n = list(map(int, input().split()))
a = [int(i) for i in input().split()]
sum = 0
for i in range(n):
sum += a[i]
print(("Yes" if h <= sum else "No")) | h, n = list(map(int, input().split()))
a = list(map(int, input().split()))
print(('Yes' if sum(a) >= h else 'No')) | 8 | 4 | 154 | 104 | h, n = list(map(int, input().split()))
a = [int(i) for i in input().split()]
sum = 0
for i in range(n):
sum += a[i]
print(("Yes" if h <= sum else "No"))
| h, n = list(map(int, input().split()))
a = list(map(int, input().split()))
print(("Yes" if sum(a) >= h else "No"))
| false | 50 | [
"-a = [int(i) for i in input().split()]",
"-sum = 0",
"-for i in range(n):",
"- sum += a[i]",
"-print((\"Yes\" if h <= sum else \"No\"))",
"+a = list(map(int, input().split()))",
"+print((\"Yes\" if sum(a) >= h else \"No\"))"
] | false | 0.089437 | 0.069661 | 1.283891 | [
"s935418622",
"s861279192"
] |
u047102107 | p02781 | python | s228709820 | s565989233 | 73 | 67 | 62,068 | 67,896 | Accepted | Accepted | 8.22 | # https://atcoder.jp/contests/abc154/tasks/abc154_e
# 桁DPっぽいよなぁ => O
"""
memo
dp0[i][j]
上からi桁目まで決めて,0でない桁がj個あり
Nより小さいことが確定している (less)
dp1[i][j]
上からi桁目まで決めて,0でない桁がj個あり
Nより小さいことが確定していない (i桁目まで同じ)
通常の再帰
rec
"""
S = eval(input())
K = int(eval(input()))
N = len(S)
def com(N, R):
if R < 0 or R > N:
return 0
if R == 1:
return N
elif R == 2:
return N * (N - 1) // 2
elif R == 3:
return N * (N - 1) * (N - 2) // 6
else:
raise NotImplementedError("NIE")
# 再帰呼出し
def rec(i, k, smaller):
if i == N:
return 1 if k == 0 else 0
if k == 0:
return 1
if smaller:
# 残っている桁数からk個を選び,それぞれ9^kのパターンがある
return com(N - i, k) * pow(9, k)
else:
if S[i] == '0':
return rec(i + 1, k , False)
else:
zero = rec(i + 1, k, True)
aida = rec(i + 1, k - 1, True) * (int(S[i]) - 1)
ichi = rec(i + 1, k - 1, False)
return zero + aida + ichi
ans = rec(0, K, False)
print(ans) | # https://atcoder.jp/contests/abc154/tasks/abc154_e
# 桁DPっぽいよなぁ => O
"""
memo
dp0[i][j]
上からi桁目まで決めて,0でない桁がj個あり
Nより小さいことが確定している (less)
dp1[i][j]
上からi桁目まで決めて,0でない桁がj個あり
Nより小さいことが確定していない (i桁目まで同じ)
通常の再帰
rec
"""
S = eval(input())
K = int(eval(input()))
N = len(S)
dp0 = [[0] * (K + 2) for _ in range(N + 1)]
dp1 = [[0] * (K + 2) for _ in range(N + 1)]
dp0[0][0] = 1
# i桁目まで
for i in range(N):
dig = int(S[i])
# 0でない桁の個数がj個
for j in range(K + 1):
# 選ぶ数字がk=0..9
for k in range(10):
nj = j if k == 0 else j + 1
if k < dig:
dp1[i + 1][nj] += dp0[i][j] + dp1[i][j]
elif k == dig:
dp1[i + 1][nj] += dp1[i][j]
dp0[i + 1][nj] += dp0[i][j]
else:
dp1[i + 1][nj] += dp1[i][j]
ans = dp0[N][K] + dp1[N][K]
print(ans) | 53 | 44 | 1,076 | 887 | # https://atcoder.jp/contests/abc154/tasks/abc154_e
# 桁DPっぽいよなぁ => O
"""
memo
dp0[i][j]
上からi桁目まで決めて,0でない桁がj個あり
Nより小さいことが確定している (less)
dp1[i][j]
上からi桁目まで決めて,0でない桁がj個あり
Nより小さいことが確定していない (i桁目まで同じ)
通常の再帰
rec
"""
S = eval(input())
K = int(eval(input()))
N = len(S)
def com(N, R):
if R < 0 or R > N:
return 0
if R == 1:
return N
elif R == 2:
return N * (N - 1) // 2
elif R == 3:
return N * (N - 1) * (N - 2) // 6
else:
raise NotImplementedError("NIE")
# 再帰呼出し
def rec(i, k, smaller):
if i == N:
return 1 if k == 0 else 0
if k == 0:
return 1
if smaller:
# 残っている桁数からk個を選び,それぞれ9^kのパターンがある
return com(N - i, k) * pow(9, k)
else:
if S[i] == "0":
return rec(i + 1, k, False)
else:
zero = rec(i + 1, k, True)
aida = rec(i + 1, k - 1, True) * (int(S[i]) - 1)
ichi = rec(i + 1, k - 1, False)
return zero + aida + ichi
ans = rec(0, K, False)
print(ans)
| # https://atcoder.jp/contests/abc154/tasks/abc154_e
# 桁DPっぽいよなぁ => O
"""
memo
dp0[i][j]
上からi桁目まで決めて,0でない桁がj個あり
Nより小さいことが確定している (less)
dp1[i][j]
上からi桁目まで決めて,0でない桁がj個あり
Nより小さいことが確定していない (i桁目まで同じ)
通常の再帰
rec
"""
S = eval(input())
K = int(eval(input()))
N = len(S)
dp0 = [[0] * (K + 2) for _ in range(N + 1)]
dp1 = [[0] * (K + 2) for _ in range(N + 1)]
dp0[0][0] = 1
# i桁目まで
for i in range(N):
dig = int(S[i])
# 0でない桁の個数がj個
for j in range(K + 1):
# 選ぶ数字がk=0..9
for k in range(10):
nj = j if k == 0 else j + 1
if k < dig:
dp1[i + 1][nj] += dp0[i][j] + dp1[i][j]
elif k == dig:
dp1[i + 1][nj] += dp1[i][j]
dp0[i + 1][nj] += dp0[i][j]
else:
dp1[i + 1][nj] += dp1[i][j]
ans = dp0[N][K] + dp1[N][K]
print(ans)
| false | 16.981132 | [
"-",
"-",
"-def com(N, R):",
"- if R < 0 or R > N:",
"- return 0",
"- if R == 1:",
"- return N",
"- elif R == 2:",
"- return N * (N - 1) // 2",
"- elif R == 3:",
"- return N * (N - 1) * (N - 2) // 6",
"- else:",
"- raise NotImplementedError(\"NIE\")",
"-",
"-",
"-# 再帰呼出し",
"-def rec(i, k, smaller):",
"- if i == N:",
"- return 1 if k == 0 else 0",
"- if k == 0:",
"- return 1",
"- if smaller:",
"- # 残っている桁数からk個を選び,それぞれ9^kのパターンがある",
"- return com(N - i, k) * pow(9, k)",
"- else:",
"- if S[i] == \"0\":",
"- return rec(i + 1, k, False)",
"- else:",
"- zero = rec(i + 1, k, True)",
"- aida = rec(i + 1, k - 1, True) * (int(S[i]) - 1)",
"- ichi = rec(i + 1, k - 1, False)",
"- return zero + aida + ichi",
"-",
"-",
"-ans = rec(0, K, False)",
"+dp0 = [[0] * (K + 2) for _ in range(N + 1)]",
"+dp1 = [[0] * (K + 2) for _ in range(N + 1)]",
"+dp0[0][0] = 1",
"+# i桁目まで",
"+for i in range(N):",
"+ dig = int(S[i])",
"+ # 0でない桁の個数がj個",
"+ for j in range(K + 1):",
"+ # 選ぶ数字がk=0..9",
"+ for k in range(10):",
"+ nj = j if k == 0 else j + 1",
"+ if k < dig:",
"+ dp1[i + 1][nj] += dp0[i][j] + dp1[i][j]",
"+ elif k == dig:",
"+ dp1[i + 1][nj] += dp1[i][j]",
"+ dp0[i + 1][nj] += dp0[i][j]",
"+ else:",
"+ dp1[i + 1][nj] += dp1[i][j]",
"+ans = dp0[N][K] + dp1[N][K]"
] | false | 0.049815 | 0.11276 | 0.441784 | [
"s228709820",
"s565989233"
] |
u175111751 | p02414 | python | s601912576 | s086044862 | 400 | 180 | 8,640 | 8,696 | Accepted | Accepted | 55 | n, m, l = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(n)]
B = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
r = []
for j in range(l):
c = 0
for k in range(m):
c += A[i][k] * B[k][j]
r.append(c)
print((*r)) | n, m, l = list(map(int, input().split()))
A = [tuple(map(int, input().split())) for _ in range(n)]
B = [tuple(map(int, input().split())) for _ in range(m)]
B_T = [tuple(r) for r in zip(*B)]
for L in ((sum((a*b for a, b in zip(ai, bj))) for bj in B_T) for ai in A):
print((*L)) | 11 | 6 | 321 | 277 | n, m, l = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(n)]
B = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
r = []
for j in range(l):
c = 0
for k in range(m):
c += A[i][k] * B[k][j]
r.append(c)
print((*r))
| n, m, l = list(map(int, input().split()))
A = [tuple(map(int, input().split())) for _ in range(n)]
B = [tuple(map(int, input().split())) for _ in range(m)]
B_T = [tuple(r) for r in zip(*B)]
for L in ((sum((a * b for a, b in zip(ai, bj))) for bj in B_T) for ai in A):
print((*L))
| false | 45.454545 | [
"-A = [list(map(int, input().split())) for _ in range(n)]",
"-B = [list(map(int, input().split())) for _ in range(m)]",
"-for i in range(n):",
"- r = []",
"- for j in range(l):",
"- c = 0",
"- for k in range(m):",
"- c += A[i][k] * B[k][j]",
"- r.append(c)",
"- print((*r))",
"+A = [tuple(map(int, input().split())) for _ in range(n)]",
"+B = [tuple(map(int, input().split())) for _ in range(m)]",
"+B_T = [tuple(r) for r in zip(*B)]",
"+for L in ((sum((a * b for a, b in zip(ai, bj))) for bj in B_T) for ai in A):",
"+ print((*L))"
] | false | 0.039752 | 0.048402 | 0.821288 | [
"s601912576",
"s086044862"
] |
u197457087 | p03221 | python | s089206703 | s723030110 | 578 | 374 | 110,716 | 93,788 | Accepted | Accepted | 35.29 | from collections import defaultdict
dic = defaultdict(int)
N,M = list(map(int,input().split()))
A = []
for i in range(M):
a,b = list(map(int,input().split()))
A.append((a,b,i))
A.sort()
#print(A)
ans = [-1 for _ in range(M)]
for i in range(M):
dic[A[i][0]] += 1
#print(dic[A[i][0]])
temp = "0"*(6-len(str(A[i][0])))+str(A[i][0])+"0"*(6-len(str(dic[A[i][0]])))+str(dic[A[i][0]])
ans[A[i][2]] = temp
#print(i,temp)
for t in ans:
print(t)
| import bisect
N,M = list(map(int,input().split()))
A = [[] for _ in range(N)] #重複がある場合にはsetにする?
original = []
for i in range(M):
a,b = list(map(int,input().split()))
a-=1 #県を0indexに直す
A[a].append(b)
original.append((a,b))
for X in A:
X.sort()
#print(A)
for i in range(M):
ken,now = original[i]
ID = bisect.bisect_left(A[ken],now)
ken += 1; ID+=1
ans = "0"*(6-len(str(ken)))+str(ken)+"0"*(6-len(str(ID)))+str(ID)
print(ans)
| 19 | 18 | 460 | 448 | from collections import defaultdict
dic = defaultdict(int)
N, M = list(map(int, input().split()))
A = []
for i in range(M):
a, b = list(map(int, input().split()))
A.append((a, b, i))
A.sort()
# print(A)
ans = [-1 for _ in range(M)]
for i in range(M):
dic[A[i][0]] += 1
# print(dic[A[i][0]])
temp = (
"0" * (6 - len(str(A[i][0])))
+ str(A[i][0])
+ "0" * (6 - len(str(dic[A[i][0]])))
+ str(dic[A[i][0]])
)
ans[A[i][2]] = temp
# print(i,temp)
for t in ans:
print(t)
| import bisect
N, M = list(map(int, input().split()))
A = [[] for _ in range(N)] # 重複がある場合にはsetにする?
original = []
for i in range(M):
a, b = list(map(int, input().split()))
a -= 1 # 県を0indexに直す
A[a].append(b)
original.append((a, b))
for X in A:
X.sort()
# print(A)
for i in range(M):
ken, now = original[i]
ID = bisect.bisect_left(A[ken], now)
ken += 1
ID += 1
ans = "0" * (6 - len(str(ken))) + str(ken) + "0" * (6 - len(str(ID))) + str(ID)
print(ans)
| false | 5.263158 | [
"-from collections import defaultdict",
"+import bisect",
"-dic = defaultdict(int)",
"-A = []",
"+A = [[] for _ in range(N)] # 重複がある場合にはsetにする?",
"+original = []",
"- A.append((a, b, i))",
"-A.sort()",
"+ a -= 1 # 県を0indexに直す",
"+ A[a].append(b)",
"+ original.append((a, b))",
"+for X in A:",
"+ X.sort()",
"-ans = [-1 for _ in range(M)]",
"- dic[A[i][0]] += 1",
"- # print(dic[A[i][0]])",
"- temp = (",
"- \"0\" * (6 - len(str(A[i][0])))",
"- + str(A[i][0])",
"- + \"0\" * (6 - len(str(dic[A[i][0]])))",
"- + str(dic[A[i][0]])",
"- )",
"- ans[A[i][2]] = temp",
"- # print(i,temp)",
"-for t in ans:",
"- print(t)",
"+ ken, now = original[i]",
"+ ID = bisect.bisect_left(A[ken], now)",
"+ ken += 1",
"+ ID += 1",
"+ ans = \"0\" * (6 - len(str(ken))) + str(ken) + \"0\" * (6 - len(str(ID))) + str(ID)",
"+ print(ans)"
] | false | 0.007004 | 0.06482 | 0.108047 | [
"s089206703",
"s723030110"
] |
u729133443 | p02735 | python | s164489548 | s036993432 | 22 | 20 | 3,060 | 3,188 | Accepted | Accepted | 9.09 | def main():
_,*s=open(0)
b,q='.'*101,list(range(101))
for i,s in enumerate(s):
a=[]
for x,y,z,c in zip(b,'.'+s,s,q):
c+=x=='.'>z
i+=y=='.'>z
if i>c:i=c
a+=i,
b,q=s,a
print((a[-2]))
main() | def main():
import sys
input=sys.stdin.buffer.readline
h,w=list(map(int,input().split()))
b,q=b'.'*w,list(range(w))
for i in range(h):
s=eval(input())
a=[]
for x,y,z,c in zip(b,b'.'+s,s,q):
c+=x==46>z
i+=y==46>z
if i>c:i=c
a+=i,
b,q=s,a
print(i)
main() | 13 | 16 | 235 | 301 | def main():
_, *s = open(0)
b, q = "." * 101, list(range(101))
for i, s in enumerate(s):
a = []
for x, y, z, c in zip(b, "." + s, s, q):
c += x == "." > z
i += y == "." > z
if i > c:
i = c
a += (i,)
b, q = s, a
print((a[-2]))
main()
| def main():
import sys
input = sys.stdin.buffer.readline
h, w = list(map(int, input().split()))
b, q = b"." * w, list(range(w))
for i in range(h):
s = eval(input())
a = []
for x, y, z, c in zip(b, b"." + s, s, q):
c += x == 46 > z
i += y == 46 > z
if i > c:
i = c
a += (i,)
b, q = s, a
print(i)
main()
| false | 18.75 | [
"- _, *s = open(0)",
"- b, q = \".\" * 101, list(range(101))",
"- for i, s in enumerate(s):",
"+ import sys",
"+",
"+ input = sys.stdin.buffer.readline",
"+ h, w = list(map(int, input().split()))",
"+ b, q = b\".\" * w, list(range(w))",
"+ for i in range(h):",
"+ s = eval(input())",
"- for x, y, z, c in zip(b, \".\" + s, s, q):",
"- c += x == \".\" > z",
"- i += y == \".\" > z",
"+ for x, y, z, c in zip(b, b\".\" + s, s, q):",
"+ c += x == 46 > z",
"+ i += y == 46 > z",
"- print((a[-2]))",
"+ print(i)"
] | false | 0.035999 | 0.036119 | 0.996686 | [
"s164489548",
"s036993432"
] |
End of preview. Expand
in Dataset Viewer.
- Downloads last month
- 73