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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u072053884 | p02266 | python | s787819541 | s416854074 | 100 | 90 | 8,388 | 8,392 | Accepted | Accepted | 10 | import collections
S1 = collections.deque()
S2 = collections.deque()
S3 = collections.deque()
for i, j in enumerate(eval(input())):
if j == '\\':
S1.append(i)
elif j == '/':
if S1:
left_edge = S1.pop()
new_puddle = i - left_edge
while True:
if S2:
if S2[-1] > left_edge:
S2.pop()
new_puddle += S3.pop()
else:
break
else:
break
S2.append(left_edge)
S3.append(new_puddle)
else:
pass
print((sum(S3)))
print((len(S3), *list(S3))) | import collections
S1 = collections.deque()
S2 = collections.deque()
S3 = collections.deque()
for i, j in enumerate(eval(input())):
if j == '\\':
S1.append(i)
elif j == '/':
if S1:
left_edge = S1.pop()
new_puddle = i - left_edge
while True:
if S2:
if S2[-1] > left_edge:
S2.pop()
new_puddle += S3.pop()
else:
break
else:
break
S2.append(left_edge)
S3.append(new_puddle)
else:
pass
print((sum(S3)))
print((len(S3), *S3)) | 31 | 31 | 718 | 712 | import collections
S1 = collections.deque()
S2 = collections.deque()
S3 = collections.deque()
for i, j in enumerate(eval(input())):
if j == "\\":
S1.append(i)
elif j == "/":
if S1:
left_edge = S1.pop()
new_puddle = i - left_edge
while True:
if S2:
if S2[-1] > left_edge:
S2.pop()
new_puddle += S3.pop()
else:
break
else:
break
S2.append(left_edge)
S3.append(new_puddle)
else:
pass
print((sum(S3)))
print((len(S3), *list(S3)))
| import collections
S1 = collections.deque()
S2 = collections.deque()
S3 = collections.deque()
for i, j in enumerate(eval(input())):
if j == "\\":
S1.append(i)
elif j == "/":
if S1:
left_edge = S1.pop()
new_puddle = i - left_edge
while True:
if S2:
if S2[-1] > left_edge:
S2.pop()
new_puddle += S3.pop()
else:
break
else:
break
S2.append(left_edge)
S3.append(new_puddle)
else:
pass
print((sum(S3)))
print((len(S3), *S3))
| false | 0 | [
"-print((len(S3), *list(S3)))",
"+print((len(S3), *S3))"
] | false | 0.047846 | 0.047062 | 1.016663 | [
"s787819541",
"s416854074"
] |
u309120194 | p03478 | python | s841910566 | s554327472 | 40 | 35 | 9,196 | 9,176 | Accepted | Accepted | 12.5 | N, A, B = list(map(int, input().split()))
ans = 0
for n in range(1, N+1):
s = sum(list(map(int, list(str(n)))))
if A <= s and s <= B: ans += n
print(ans) | N, A, B = list(map(int, input().split()))
# 別解:10で割った余りを足していく
ans = 0
for n in range(1, N+1):
s = 0
m = n
while m > 0:
s += m % 10
m = m // 10
if A <= s and s <= B: ans += n
print(ans) | 8 | 13 | 165 | 212 | N, A, B = list(map(int, input().split()))
ans = 0
for n in range(1, N + 1):
s = sum(list(map(int, list(str(n)))))
if A <= s and s <= B:
ans += n
print(ans)
| N, A, B = list(map(int, input().split()))
# 別解:10で割った余りを足していく
ans = 0
for n in range(1, N + 1):
s = 0
m = n
while m > 0:
s += m % 10
m = m // 10
if A <= s and s <= B:
ans += n
print(ans)
| false | 38.461538 | [
"+# 別解:10で割った余りを足していく",
"- s = sum(list(map(int, list(str(n)))))",
"+ s = 0",
"+ m = n",
"+ while m > 0:",
"+ s += m % 10",
"+ m = m // 10"
] | false | 0.033885 | 0.036705 | 0.923179 | [
"s841910566",
"s554327472"
] |
u297574184 | p02988 | python | s643908495 | s308660818 | 21 | 17 | 3,316 | 3,060 | Accepted | Accepted | 19.05 | N = int(eval(input()))
ps = list(map(int, input().split()))
ans = 0
for i in range(1, N-1):
if ps[i-1] < ps[i] < ps[i+1] or ps[i-1] > ps[i] > ps[i+1]:
ans += 1
print(ans)
| N = int(eval(input()))
Ps = list(map(int, input().split()))
ans = 0
for i in range(1, N-1):
if Ps[i-1]<Ps[i]<Ps[i+1] or Ps[i-1]>Ps[i]>Ps[i+1]:
ans += 1
print(ans)
| 9 | 9 | 187 | 179 | N = int(eval(input()))
ps = list(map(int, input().split()))
ans = 0
for i in range(1, N - 1):
if ps[i - 1] < ps[i] < ps[i + 1] or ps[i - 1] > ps[i] > ps[i + 1]:
ans += 1
print(ans)
| N = int(eval(input()))
Ps = list(map(int, input().split()))
ans = 0
for i in range(1, N - 1):
if Ps[i - 1] < Ps[i] < Ps[i + 1] or Ps[i - 1] > Ps[i] > Ps[i + 1]:
ans += 1
print(ans)
| false | 0 | [
"-ps = list(map(int, input().split()))",
"+Ps = list(map(int, input().split()))",
"- if ps[i - 1] < ps[i] < ps[i + 1] or ps[i - 1] > ps[i] > ps[i + 1]:",
"+ if Ps[i - 1] < Ps[i] < Ps[i + 1] or Ps[i - 1] > Ps[i] > Ps[i + 1]:"
] | false | 0.038066 | 0.042081 | 0.904574 | [
"s643908495",
"s308660818"
] |
u608088992 | p03158 | python | s677195614 | s885284133 | 1,296 | 293 | 20,136 | 30,832 | Accepted | Accepted | 77.39 | from math import ceil
N, Q = list(map(int, input().split()))
A = [int(a) for a in input().split()]
AltTake = [0 for a in range(N)]
GetAll = [0 for a in range(N)]
AltTake[0], AltTake[1] = A[0], A[1]
GetAll[-1] = A[-1]
BlockList = [0 for i in range(ceil(N/2))]
maxBlock = ceil(N/2)
for i in range(2, N):
AltTake[i] = A[i] + AltTake[i-2]
for i in reversed(list(range(N-1))):
GetAll[i] = GetAll[i+1] + A[i]
for i in range(ceil(N/2) - 1):
BlockList[-i-1] = (A[-i-2] + A[-2*i - 3]) // 2 + 1
def BSearch(x, L):
left, right = 0, len(L)
while right - left > 1:
mid = (right + left)//2
if L[mid] > x:
right = mid
else:
left = mid
return left
for _ in range(Q):
block = maxBlock - BSearch(int(eval(input())), BlockList)
if block == maxBlock: print((GetAll[-block]))
else: print((GetAll[-block] + AltTake[N - block * 2 -1])) | import sys
from bisect import bisect_left
def solve():
input = sys.stdin.readline
N, Q = map(int, input().split())
A = [int(a) for a in input().split()]
X = [int(input()) for _ in range(Q)]
cont = [0] * N
cont[N-1] = A[N-1]
for i in reversed(range(N-1)): cont[i] = cont[i+1] + A[i]
change = [0] * N
change[0] = A[0]
change[1] = A[1]
for i in range(2, N): change[i] = change[i-2] + A[i]
upperBound = [-1] * N
for i in range((N + 1)// 2): #上からi+1個連続でとれるxの最大値
target = A[N-i-1]
lower = A[(N-i-1) - i]
upperBound[N-i-1] = (target + lower) // 2
upperBound[N-1] = 10 ** 10
Ans = [0] * Q
for i, x in enumerate(X):
pos = bisect_left(upperBound, x)
Ans[i] += cont[pos] #連続で取れる数
if N - (N - pos) * 2 - 1 >= 0: Ans[i] += change[N - (N - pos) * 2 - 1]
print(*Ans, sep="\n")
return 0
if __name__ == "__main__":
solve()
| 31 | 32 | 911 | 963 | from math import ceil
N, Q = list(map(int, input().split()))
A = [int(a) for a in input().split()]
AltTake = [0 for a in range(N)]
GetAll = [0 for a in range(N)]
AltTake[0], AltTake[1] = A[0], A[1]
GetAll[-1] = A[-1]
BlockList = [0 for i in range(ceil(N / 2))]
maxBlock = ceil(N / 2)
for i in range(2, N):
AltTake[i] = A[i] + AltTake[i - 2]
for i in reversed(list(range(N - 1))):
GetAll[i] = GetAll[i + 1] + A[i]
for i in range(ceil(N / 2) - 1):
BlockList[-i - 1] = (A[-i - 2] + A[-2 * i - 3]) // 2 + 1
def BSearch(x, L):
left, right = 0, len(L)
while right - left > 1:
mid = (right + left) // 2
if L[mid] > x:
right = mid
else:
left = mid
return left
for _ in range(Q):
block = maxBlock - BSearch(int(eval(input())), BlockList)
if block == maxBlock:
print((GetAll[-block]))
else:
print((GetAll[-block] + AltTake[N - block * 2 - 1]))
| import sys
from bisect import bisect_left
def solve():
input = sys.stdin.readline
N, Q = map(int, input().split())
A = [int(a) for a in input().split()]
X = [int(input()) for _ in range(Q)]
cont = [0] * N
cont[N - 1] = A[N - 1]
for i in reversed(range(N - 1)):
cont[i] = cont[i + 1] + A[i]
change = [0] * N
change[0] = A[0]
change[1] = A[1]
for i in range(2, N):
change[i] = change[i - 2] + A[i]
upperBound = [-1] * N
for i in range((N + 1) // 2): # 上からi+1個連続でとれるxの最大値
target = A[N - i - 1]
lower = A[(N - i - 1) - i]
upperBound[N - i - 1] = (target + lower) // 2
upperBound[N - 1] = 10**10
Ans = [0] * Q
for i, x in enumerate(X):
pos = bisect_left(upperBound, x)
Ans[i] += cont[pos] # 連続で取れる数
if N - (N - pos) * 2 - 1 >= 0:
Ans[i] += change[N - (N - pos) * 2 - 1]
print(*Ans, sep="\n")
return 0
if __name__ == "__main__":
solve()
| false | 3.125 | [
"-from math import ceil",
"-",
"-N, Q = list(map(int, input().split()))",
"-A = [int(a) for a in input().split()]",
"-AltTake = [0 for a in range(N)]",
"-GetAll = [0 for a in range(N)]",
"-AltTake[0], AltTake[1] = A[0], A[1]",
"-GetAll[-1] = A[-1]",
"-BlockList = [0 for i in range(ceil(N / 2))]",
"-maxBlock = ceil(N / 2)",
"-for i in range(2, N):",
"- AltTake[i] = A[i] + AltTake[i - 2]",
"-for i in reversed(list(range(N - 1))):",
"- GetAll[i] = GetAll[i + 1] + A[i]",
"-for i in range(ceil(N / 2) - 1):",
"- BlockList[-i - 1] = (A[-i - 2] + A[-2 * i - 3]) // 2 + 1",
"+import sys",
"+from bisect import bisect_left",
"-def BSearch(x, L):",
"- left, right = 0, len(L)",
"- while right - left > 1:",
"- mid = (right + left) // 2",
"- if L[mid] > x:",
"- right = mid",
"- else:",
"- left = mid",
"- return left",
"+def solve():",
"+ input = sys.stdin.readline",
"+ N, Q = map(int, input().split())",
"+ A = [int(a) for a in input().split()]",
"+ X = [int(input()) for _ in range(Q)]",
"+ cont = [0] * N",
"+ cont[N - 1] = A[N - 1]",
"+ for i in reversed(range(N - 1)):",
"+ cont[i] = cont[i + 1] + A[i]",
"+ change = [0] * N",
"+ change[0] = A[0]",
"+ change[1] = A[1]",
"+ for i in range(2, N):",
"+ change[i] = change[i - 2] + A[i]",
"+ upperBound = [-1] * N",
"+ for i in range((N + 1) // 2): # 上からi+1個連続でとれるxの最大値",
"+ target = A[N - i - 1]",
"+ lower = A[(N - i - 1) - i]",
"+ upperBound[N - i - 1] = (target + lower) // 2",
"+ upperBound[N - 1] = 10**10",
"+ Ans = [0] * Q",
"+ for i, x in enumerate(X):",
"+ pos = bisect_left(upperBound, x)",
"+ Ans[i] += cont[pos] # 連続で取れる数",
"+ if N - (N - pos) * 2 - 1 >= 0:",
"+ Ans[i] += change[N - (N - pos) * 2 - 1]",
"+ print(*Ans, sep=\"\\n\")",
"+ return 0",
"-for _ in range(Q):",
"- block = maxBlock - BSearch(int(eval(input())), BlockList)",
"- if block == maxBlock:",
"- print((GetAll[-block]))",
"- else:",
"- print((GetAll[-block] + AltTake[N - block * 2 - 1]))",
"+if __name__ == \"__main__\":",
"+ solve()"
] | false | 0.039493 | 0.045496 | 0.868055 | [
"s677195614",
"s885284133"
] |
u075012704 | p02863 | python | s511267537 | s881828060 | 956 | 601 | 180,228 | 119,000 | Accepted | Accepted | 37.13 | N, W = list(map(int, input().split()))
items = [list(map(int, input().split())) for i in range(N)]
# dp1[i][j] := 商品0 ~ i が対象
# dp2[i][j] := 商品i ~ N が対象(順番はそのまま)
# out-of-index 対策に余分に取っておく
dp1 = [[0] * (W + 1) for i in range(N + 2)]
dp2 = [[0] * (W + 1) for i in range(N + 2)]
# dp1を埋める
for i in range(N):
wi, vi = items[i]
for j in range(W + 1):
if j + wi <= W:
dp1[i + 1][j + wi] = max(dp1[i + 1][j + wi], dp1[i][j] + vi)
dp1[i + 1][j] = max(dp1[i][j], dp1[i + 1][j])
# dp2を埋める
for i in range(N + 1, 1, -1):
wi, vi = items[i - 2]
for j in range(W + 1):
if j + wi <= W:
dp2[i - 1][j + wi] = max(dp2[i - 1][j + wi], dp2[i][j] + vi)
dp2[i - 1][j] = max(dp2[i][j], dp2[i - 1][j])
# 2つのdpテーブルを使って、最後に使う商品を全探索
ans = 0
# ここからは商品を1-indexedとする
for i, (wi, vi) in enumerate(items, start=1):
for j in range(W):
ans = max(ans, dp1[i - 1][j] + dp2[i + 1][W - j - 1] + vi)
print(ans)
| N, W = list(map(int, input().split()))
items = sorted([list(map(int, input().split())) for i in range(N)])
# dp1[i][j] := 商品0 ~ i が対象
dp = [[0] * (W + 1) for i in range(N + 1)]
# dpテーブルを埋める
for i in range(N):
wi, vi = items[i]
for j in range(W + 1):
if j + wi <= W:
dp[i + 1][j + wi] = max(dp[i + 1][j + wi], dp[i][j] + vi)
dp[i + 1][j] = max(dp[i][j], dp[i + 1][j])
ans = 0
for i, (wi, vi) in enumerate(items):
for j in range(W):
ans = max(ans, dp[i][j] + vi)
print(ans)
| 34 | 21 | 989 | 539 | N, W = list(map(int, input().split()))
items = [list(map(int, input().split())) for i in range(N)]
# dp1[i][j] := 商品0 ~ i が対象
# dp2[i][j] := 商品i ~ N が対象(順番はそのまま)
# out-of-index 対策に余分に取っておく
dp1 = [[0] * (W + 1) for i in range(N + 2)]
dp2 = [[0] * (W + 1) for i in range(N + 2)]
# dp1を埋める
for i in range(N):
wi, vi = items[i]
for j in range(W + 1):
if j + wi <= W:
dp1[i + 1][j + wi] = max(dp1[i + 1][j + wi], dp1[i][j] + vi)
dp1[i + 1][j] = max(dp1[i][j], dp1[i + 1][j])
# dp2を埋める
for i in range(N + 1, 1, -1):
wi, vi = items[i - 2]
for j in range(W + 1):
if j + wi <= W:
dp2[i - 1][j + wi] = max(dp2[i - 1][j + wi], dp2[i][j] + vi)
dp2[i - 1][j] = max(dp2[i][j], dp2[i - 1][j])
# 2つのdpテーブルを使って、最後に使う商品を全探索
ans = 0
# ここからは商品を1-indexedとする
for i, (wi, vi) in enumerate(items, start=1):
for j in range(W):
ans = max(ans, dp1[i - 1][j] + dp2[i + 1][W - j - 1] + vi)
print(ans)
| N, W = list(map(int, input().split()))
items = sorted([list(map(int, input().split())) for i in range(N)])
# dp1[i][j] := 商品0 ~ i が対象
dp = [[0] * (W + 1) for i in range(N + 1)]
# dpテーブルを埋める
for i in range(N):
wi, vi = items[i]
for j in range(W + 1):
if j + wi <= W:
dp[i + 1][j + wi] = max(dp[i + 1][j + wi], dp[i][j] + vi)
dp[i + 1][j] = max(dp[i][j], dp[i + 1][j])
ans = 0
for i, (wi, vi) in enumerate(items):
for j in range(W):
ans = max(ans, dp[i][j] + vi)
print(ans)
| false | 38.235294 | [
"-items = [list(map(int, input().split())) for i in range(N)]",
"+items = sorted([list(map(int, input().split())) for i in range(N)])",
"-# dp2[i][j] := 商品i ~ N が対象(順番はそのまま)",
"-# out-of-index 対策に余分に取っておく",
"-dp1 = [[0] * (W + 1) for i in range(N + 2)]",
"-dp2 = [[0] * (W + 1) for i in range(N + 2)]",
"-# dp1を埋める",
"+dp = [[0] * (W + 1) for i in range(N + 1)]",
"+# dpテーブルを埋める",
"- dp1[i + 1][j + wi] = max(dp1[i + 1][j + wi], dp1[i][j] + vi)",
"- dp1[i + 1][j] = max(dp1[i][j], dp1[i + 1][j])",
"-# dp2を埋める",
"-for i in range(N + 1, 1, -1):",
"- wi, vi = items[i - 2]",
"- for j in range(W + 1):",
"- if j + wi <= W:",
"- dp2[i - 1][j + wi] = max(dp2[i - 1][j + wi], dp2[i][j] + vi)",
"- dp2[i - 1][j] = max(dp2[i][j], dp2[i - 1][j])",
"-# 2つのdpテーブルを使って、最後に使う商品を全探索",
"+ dp[i + 1][j + wi] = max(dp[i + 1][j + wi], dp[i][j] + vi)",
"+ dp[i + 1][j] = max(dp[i][j], dp[i + 1][j])",
"-# ここからは商品を1-indexedとする",
"-for i, (wi, vi) in enumerate(items, start=1):",
"+for i, (wi, vi) in enumerate(items):",
"- ans = max(ans, dp1[i - 1][j] + dp2[i + 1][W - j - 1] + vi)",
"+ ans = max(ans, dp[i][j] + vi)"
] | false | 0.048766 | 0.046864 | 1.040567 | [
"s511267537",
"s881828060"
] |
u785989355 | p03482 | python | s687198668 | s181718601 | 58 | 44 | 3,188 | 3,188 | Accepted | Accepted | 24.14 |
S = eval(input())
l=len(S)
if l%2==0:
count=0
s=S[int(l/2)]
for i in range(int(l/2)):
if S[int(l/2)-1-i]!=s or S[int(l/2)+i]!=s:
break
count+=1
print((int(l/2)+count))
else:
s=S[int(l/2)]
count=0
for i in range(int(l/2)):
if S[int(l/2)-1-i]!=s or S[int(l/2)+1+i]!=s:
break
count+=1
print((int(l/2)+1+count)) | S=eval(input())
l=len(S)
if l%2==0:
count=l//2
a=S[l//2-1]
for i in range(l//2):
if S[l//2-1-i]==a and S[l//2+i]==a:
count+=1
else:
break
print(count)
else:
count=l//2+1
a=S[l//2]
for i in range(l//2):
if S[l//2-1-i]==a and S[l//2+1+i]==a:
count+=1
else:
break
print(count) | 19 | 23 | 404 | 404 | S = eval(input())
l = len(S)
if l % 2 == 0:
count = 0
s = S[int(l / 2)]
for i in range(int(l / 2)):
if S[int(l / 2) - 1 - i] != s or S[int(l / 2) + i] != s:
break
count += 1
print((int(l / 2) + count))
else:
s = S[int(l / 2)]
count = 0
for i in range(int(l / 2)):
if S[int(l / 2) - 1 - i] != s or S[int(l / 2) + 1 + i] != s:
break
count += 1
print((int(l / 2) + 1 + count))
| S = eval(input())
l = len(S)
if l % 2 == 0:
count = l // 2
a = S[l // 2 - 1]
for i in range(l // 2):
if S[l // 2 - 1 - i] == a and S[l // 2 + i] == a:
count += 1
else:
break
print(count)
else:
count = l // 2 + 1
a = S[l // 2]
for i in range(l // 2):
if S[l // 2 - 1 - i] == a and S[l // 2 + 1 + i] == a:
count += 1
else:
break
print(count)
| false | 17.391304 | [
"- count = 0",
"- s = S[int(l / 2)]",
"- for i in range(int(l / 2)):",
"- if S[int(l / 2) - 1 - i] != s or S[int(l / 2) + i] != s:",
"+ count = l // 2",
"+ a = S[l // 2 - 1]",
"+ for i in range(l // 2):",
"+ if S[l // 2 - 1 - i] == a and S[l // 2 + i] == a:",
"+ count += 1",
"+ else:",
"- count += 1",
"- print((int(l / 2) + count))",
"+ print(count)",
"- s = S[int(l / 2)]",
"- count = 0",
"- for i in range(int(l / 2)):",
"- if S[int(l / 2) - 1 - i] != s or S[int(l / 2) + 1 + i] != s:",
"+ count = l // 2 + 1",
"+ a = S[l // 2]",
"+ for i in range(l // 2):",
"+ if S[l // 2 - 1 - i] == a and S[l // 2 + 1 + i] == a:",
"+ count += 1",
"+ else:",
"- count += 1",
"- print((int(l / 2) + 1 + count))",
"+ print(count)"
] | false | 0.033632 | 0.034055 | 0.987559 | [
"s687198668",
"s181718601"
] |
u227082700 | p03252 | python | s147689754 | s410863216 | 389 | 137 | 43,852 | 3,632 | Accepted | Accepted | 64.78 | s,t=eval(input()),eval(input())
rs=[""for _ in range(26)]
rt=[""for _ in range(26)]
def a(n):return [chr(ord('a')+i)for i in range(26)].index(n)
for i in range(len(s)):
ss,tt=a(s[i]),a(t[i])
if rs[ss]=="":rs[ss]=t[i]
elif rs[ss]!=t[i]:print("No");exit()
if rt[tt]=="":rt[tt]=s[i]
elif rt[tt]!=s[i]:print("No");exit()
print("Yes")
| a="abcdefghijklmnopqrstuvwxyz"
s=input()
t=input()
ds={}
dt={}
for i in a:ds[i]=dt[i]=""
for i in range(len(s)):
if ds[s[i]]=="":ds[s[i]]=t[i]
elif ds[s[i]]!=t[i]:exit(print("No"))
if dt[t[i]]=="":dt[t[i]]=s[i]
elif dt[t[i]]!=s[i]:exit(print("No"))
print("Yes")
| 11 | 12 | 338 | 280 | s, t = eval(input()), eval(input())
rs = ["" for _ in range(26)]
rt = ["" for _ in range(26)]
def a(n):
return [chr(ord("a") + i) for i in range(26)].index(n)
for i in range(len(s)):
ss, tt = a(s[i]), a(t[i])
if rs[ss] == "":
rs[ss] = t[i]
elif rs[ss] != t[i]:
print("No")
exit()
if rt[tt] == "":
rt[tt] = s[i]
elif rt[tt] != s[i]:
print("No")
exit()
print("Yes")
| a = "abcdefghijklmnopqrstuvwxyz"
s = input()
t = input()
ds = {}
dt = {}
for i in a:
ds[i] = dt[i] = ""
for i in range(len(s)):
if ds[s[i]] == "":
ds[s[i]] = t[i]
elif ds[s[i]] != t[i]:
exit(print("No"))
if dt[t[i]] == "":
dt[t[i]] = s[i]
elif dt[t[i]] != s[i]:
exit(print("No"))
print("Yes")
| false | 8.333333 | [
"-s, t = eval(input()), eval(input())",
"-rs = [\"\" for _ in range(26)]",
"-rt = [\"\" for _ in range(26)]",
"-",
"-",
"-def a(n):",
"- return [chr(ord(\"a\") + i) for i in range(26)].index(n)",
"-",
"-",
"+a = \"abcdefghijklmnopqrstuvwxyz\"",
"+s = input()",
"+t = input()",
"+ds = {}",
"+dt = {}",
"+for i in a:",
"+ ds[i] = dt[i] = \"\"",
"- ss, tt = a(s[i]), a(t[i])",
"- if rs[ss] == \"\":",
"- rs[ss] = t[i]",
"- elif rs[ss] != t[i]:",
"- print(\"No\")",
"- exit()",
"- if rt[tt] == \"\":",
"- rt[tt] = s[i]",
"- elif rt[tt] != s[i]:",
"- print(\"No\")",
"- exit()",
"+ if ds[s[i]] == \"\":",
"+ ds[s[i]] = t[i]",
"+ elif ds[s[i]] != t[i]:",
"+ exit(print(\"No\"))",
"+ if dt[t[i]] == \"\":",
"+ dt[t[i]] = s[i]",
"+ elif dt[t[i]] != s[i]:",
"+ exit(print(\"No\"))"
] | false | 0.055123 | 0.035916 | 1.534756 | [
"s147689754",
"s410863216"
] |
u190616335 | p02700 | python | s600532324 | s632465381 | 22 | 20 | 9,024 | 9,096 | Accepted | Accepted | 9.09 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
a, b, c, d = list(map(int, input().split()))
if (c + b - 1) // b <= ( a + d - 1) // d:
print("Yes")
else:
print("No")
| #!/usr/bin/python3
# -*- coding: utf-8 -*-
import math
a, b, c, d = list(map(int, input().split()))
if math.ceil(c / b) <= math.ceil(a / d):
print("Yes")
else:
print("No")
| 8 | 9 | 174 | 186 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
a, b, c, d = list(map(int, input().split()))
if (c + b - 1) // b <= (a + d - 1) // d:
print("Yes")
else:
print("No")
| #!/usr/bin/python3
# -*- coding: utf-8 -*-
import math
a, b, c, d = list(map(int, input().split()))
if math.ceil(c / b) <= math.ceil(a / d):
print("Yes")
else:
print("No")
| false | 11.111111 | [
"+import math",
"+",
"-if (c + b - 1) // b <= (a + d - 1) // d:",
"+if math.ceil(c / b) <= math.ceil(a / d):"
] | false | 0.038313 | 0.038155 | 1.004159 | [
"s600532324",
"s632465381"
] |
u545368057 | p03037 | python | s588454988 | s963919999 | 573 | 339 | 55,896 | 8,636 | Accepted | Accepted | 40.84 | N, M = list(map(int,input().split()))
Ls,Rs = [],[]
for i in range(M):
L,R = list(map(int,input().split()))
Ls.append(L)
Rs.append(R)
print((max(0,min(Rs)-max(Ls)+1))) |
"""
imos
"""
N, M = list(map(int,input().split()))
from itertools import accumulate
imos = [0]*(N+2)
for i in range(M):
L,R = list(map(int,input().split()))
imos[L] += 1
imos[R+1] -= 1
acc = list(accumulate(imos))
print((sum([1 for a in acc if a == M]))) | 8 | 13 | 173 | 265 | N, M = list(map(int, input().split()))
Ls, Rs = [], []
for i in range(M):
L, R = list(map(int, input().split()))
Ls.append(L)
Rs.append(R)
print((max(0, min(Rs) - max(Ls) + 1)))
| """
imos
"""
N, M = list(map(int, input().split()))
from itertools import accumulate
imos = [0] * (N + 2)
for i in range(M):
L, R = list(map(int, input().split()))
imos[L] += 1
imos[R + 1] -= 1
acc = list(accumulate(imos))
print((sum([1 for a in acc if a == M])))
| false | 38.461538 | [
"+\"\"\"",
"+imos",
"+\"\"\"",
"-Ls, Rs = [], []",
"+from itertools import accumulate",
"+",
"+imos = [0] * (N + 2)",
"- Ls.append(L)",
"- Rs.append(R)",
"-print((max(0, min(Rs) - max(Ls) + 1)))",
"+ imos[L] += 1",
"+ imos[R + 1] -= 1",
"+acc = list(accumulate(imos))",
"+print((sum([1 for a in acc if a == M])))"
] | false | 0.105956 | 0.041133 | 2.575955 | [
"s588454988",
"s963919999"
] |
u054514819 | p03476 | python | s258366532 | s501316226 | 696 | 197 | 64,984 | 89,696 | Accepted | Accepted | 71.7 | Q = int(eval(input()))
MIN, MAX = 10**18, 0
LR = []
for q in range(Q):
l, r = list(map(int, input().split()))
MIN = min(MIN, l)
MAX = max(MAX, r)
LR.append((l, r))
from math import sqrt
from itertools import accumulate
lis = [0]*(MAX+1)
search = [2] + [i for i in range(2, MAX+1) if i%2!=0]
lim = sqrt(MAX)
prime = set()
while 1:
n = search[0]
if n>=lim:
break
prime.add(n)
if (n+1)//2 in prime:
lis[n] = 1
search = [i for i in search if i%n!=0]
for s in search:
prime.add(s)
if (s+1)//2 in prime:
lis[s] = 1
clis = list(accumulate(lis))
for l, r in LR:
print((clis[r]-clis[l-1]))
| import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
s = set()
for i in range(2, 10**5+5):
if i in s:
continue
cnt = 2
while i*cnt<=10**5+5:
s.add(i*cnt)
cnt += 1
from itertools import accumulate
lis = [0]*(10**5+5)
for i in range(3, 10**5+5, 2):
if not i in s and not (i+1)//2 in s:
lis[i] = 1
lis = list(accumulate(lis))
Q = int(eval(input()))
for _ in range(Q):
l, r = mapint()
print((lis[r]-lis[l-1])) | 30 | 26 | 669 | 565 | Q = int(eval(input()))
MIN, MAX = 10**18, 0
LR = []
for q in range(Q):
l, r = list(map(int, input().split()))
MIN = min(MIN, l)
MAX = max(MAX, r)
LR.append((l, r))
from math import sqrt
from itertools import accumulate
lis = [0] * (MAX + 1)
search = [2] + [i for i in range(2, MAX + 1) if i % 2 != 0]
lim = sqrt(MAX)
prime = set()
while 1:
n = search[0]
if n >= lim:
break
prime.add(n)
if (n + 1) // 2 in prime:
lis[n] = 1
search = [i for i in search if i % n != 0]
for s in search:
prime.add(s)
if (s + 1) // 2 in prime:
lis[s] = 1
clis = list(accumulate(lis))
for l, r in LR:
print((clis[r] - clis[l - 1]))
| import sys
def input():
return sys.stdin.readline().strip()
def mapint():
return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
s = set()
for i in range(2, 10**5 + 5):
if i in s:
continue
cnt = 2
while i * cnt <= 10**5 + 5:
s.add(i * cnt)
cnt += 1
from itertools import accumulate
lis = [0] * (10**5 + 5)
for i in range(3, 10**5 + 5, 2):
if not i in s and not (i + 1) // 2 in s:
lis[i] = 1
lis = list(accumulate(lis))
Q = int(eval(input()))
for _ in range(Q):
l, r = mapint()
print((lis[r] - lis[l - 1]))
| false | 13.333333 | [
"-Q = int(eval(input()))",
"-MIN, MAX = 10**18, 0",
"-LR = []",
"-for q in range(Q):",
"- l, r = list(map(int, input().split()))",
"- MIN = min(MIN, l)",
"- MAX = max(MAX, r)",
"- LR.append((l, r))",
"-from math import sqrt",
"+import sys",
"+",
"+",
"+def input():",
"+ return sys.stdin.readline().strip()",
"+",
"+",
"+def mapint():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+sys.setrecursionlimit(10**9)",
"+s = set()",
"+for i in range(2, 10**5 + 5):",
"+ if i in s:",
"+ continue",
"+ cnt = 2",
"+ while i * cnt <= 10**5 + 5:",
"+ s.add(i * cnt)",
"+ cnt += 1",
"-lis = [0] * (MAX + 1)",
"-search = [2] + [i for i in range(2, MAX + 1) if i % 2 != 0]",
"-lim = sqrt(MAX)",
"-prime = set()",
"-while 1:",
"- n = search[0]",
"- if n >= lim:",
"- break",
"- prime.add(n)",
"- if (n + 1) // 2 in prime:",
"- lis[n] = 1",
"- search = [i for i in search if i % n != 0]",
"-for s in search:",
"- prime.add(s)",
"- if (s + 1) // 2 in prime:",
"- lis[s] = 1",
"-clis = list(accumulate(lis))",
"-for l, r in LR:",
"- print((clis[r] - clis[l - 1]))",
"+lis = [0] * (10**5 + 5)",
"+for i in range(3, 10**5 + 5, 2):",
"+ if not i in s and not (i + 1) // 2 in s:",
"+ lis[i] = 1",
"+lis = list(accumulate(lis))",
"+Q = int(eval(input()))",
"+for _ in range(Q):",
"+ l, r = mapint()",
"+ print((lis[r] - lis[l - 1]))"
] | false | 0.133665 | 0.545363 | 0.245095 | [
"s258366532",
"s501316226"
] |
u761320129 | p03607 | python | s216385967 | s528034992 | 306 | 193 | 16,640 | 13,204 | Accepted | Accepted | 36.93 | from collections import Counter
N = int(eval(input()))
src = [int(eval(input())) for i in range(N)]
counter = Counter(src)
ans = 0
for v in list(counter.values()):
if v%2 == 1:
ans += 1
print(ans)
| N = int(eval(input()))
src = [int(eval(input())) for i in range(N)]
ss = set()
for a in src:
if a in ss:
ss.remove(a)
else:
ss.add(a)
print((len(ss)))
| 10 | 10 | 201 | 171 | from collections import Counter
N = int(eval(input()))
src = [int(eval(input())) for i in range(N)]
counter = Counter(src)
ans = 0
for v in list(counter.values()):
if v % 2 == 1:
ans += 1
print(ans)
| N = int(eval(input()))
src = [int(eval(input())) for i in range(N)]
ss = set()
for a in src:
if a in ss:
ss.remove(a)
else:
ss.add(a)
print((len(ss)))
| false | 0 | [
"-from collections import Counter",
"-",
"-counter = Counter(src)",
"-ans = 0",
"-for v in list(counter.values()):",
"- if v % 2 == 1:",
"- ans += 1",
"-print(ans)",
"+ss = set()",
"+for a in src:",
"+ if a in ss:",
"+ ss.remove(a)",
"+ else:",
"+ ss.add(a)",
"+print((len(ss)))"
] | false | 0.047336 | 0.040215 | 1.177056 | [
"s216385967",
"s528034992"
] |
u050641473 | p02712 | python | s114781102 | s006214479 | 189 | 152 | 9,172 | 9,020 | Accepted | Accepted | 19.58 | x = int(eval(input()))
ans = 0
for i in range(x+1):
if i % 15 == 0 :
pass
elif i % 3 == 0:
pass
elif i % 5 == 0:
pass
else:
ans += i
print(ans) | x = int(eval(input()))
ans = 0
for i in range(1, x+1):
if i % 3 != 0 and i % 5 != 0:
ans += i
print(ans) | 14 | 7 | 176 | 111 | x = int(eval(input()))
ans = 0
for i in range(x + 1):
if i % 15 == 0:
pass
elif i % 3 == 0:
pass
elif i % 5 == 0:
pass
else:
ans += i
print(ans)
| x = int(eval(input()))
ans = 0
for i in range(1, x + 1):
if i % 3 != 0 and i % 5 != 0:
ans += i
print(ans)
| false | 50 | [
"-for i in range(x + 1):",
"- if i % 15 == 0:",
"- pass",
"- elif i % 3 == 0:",
"- pass",
"- elif i % 5 == 0:",
"- pass",
"- else:",
"+for i in range(1, x + 1):",
"+ if i % 3 != 0 and i % 5 != 0:"
] | false | 0.349916 | 0.136007 | 2.572792 | [
"s114781102",
"s006214479"
] |
u752522099 | p02595 | python | s045618849 | s909891663 | 601 | 483 | 45,460 | 9,204 | Accepted | Accepted | 19.63 | import math
n, d = list(map(int, input().split()))
lis = []
for i in range(n):
p = list(map(int, input().split()))
lis.append(p)
count = 0
for r in lis:
distance = r[0] ** 2 + r[1] ** 2
distance = math.sqrt(distance)
if distance <= d:
count += 1
print(count) | n, d = list(map(int, input().split()))
d = d ** 2
count = 0
for i in range(n):
p = list(map(int, input().split()))
dis = p[0] ** 2 + p[1] ** 2
if dis <= d:
count += 1
print(count) | 16 | 9 | 302 | 201 | import math
n, d = list(map(int, input().split()))
lis = []
for i in range(n):
p = list(map(int, input().split()))
lis.append(p)
count = 0
for r in lis:
distance = r[0] ** 2 + r[1] ** 2
distance = math.sqrt(distance)
if distance <= d:
count += 1
print(count)
| n, d = list(map(int, input().split()))
d = d**2
count = 0
for i in range(n):
p = list(map(int, input().split()))
dis = p[0] ** 2 + p[1] ** 2
if dis <= d:
count += 1
print(count)
| false | 43.75 | [
"-import math",
"-",
"-lis = []",
"+d = d**2",
"+count = 0",
"- lis.append(p)",
"-count = 0",
"-for r in lis:",
"- distance = r[0] ** 2 + r[1] ** 2",
"- distance = math.sqrt(distance)",
"- if distance <= d:",
"+ dis = p[0] ** 2 + p[1] ** 2",
"+ if dis <= d:"
] | false | 0.096477 | 0.037817 | 2.55117 | [
"s045618849",
"s909891663"
] |
u403301154 | p03674 | python | s920624526 | s656399930 | 1,261 | 740 | 28,880 | 28,920 | Accepted | Accepted | 41.32 | MOD = 10**9+7
def mod_pow(x, n):
if x==0: return 1
res = 1
while n > 0:
if n&1:
res = (res*x)%MOD
x = (x*x)%MOD
n >>= 1
return res
fact, invfact = [0]*(10**5+2), [0]*(10**5+2)
fact[0], invfact[0] = 1, 1
for i in range(1, 10**5+2):
fact[i] = (fact[i-1]*i)%MOD
invfact[i] = mod_pow(fact[i], MOD-2)%MOD
def comb(n, r):
if n<r or n==0 or r==0: return 0
return (((fact[n]*invfact[r])%MOD)*invfact[n-r])%MOD
from collections import defaultdict
n = int(eval(input()))
a = list(map(int, input().split()))
d = defaultdict(int)
for i, ele in enumerate(a):
if d[ele] == 0:
d[ele]= i+1
else:
l = d[ele]
r = i+1
print(n)
for k in range(2, n+2):
print(((comb(n+1, k)-comb(l-1+n-r+1, k-1))%MOD)) | # Pythonの組み込み関数powを使ったバージョン
MOD = 10**9+7
fact, invfact = [0]*(10**5+2), [0]*(10**5+2)
fact[0], invfact[0] = 1, 1
for i in range(1, 10**5+2):
fact[i] = (fact[i-1]*i)%MOD
invfact[i] = pow(fact[i], MOD-2, MOD)
def mod_comb(n, r):
if n<r or n==0 or r==0: return 0
return (((fact[n]*invfact[r])%MOD)*invfact[n-r])%MOD
from collections import defaultdict
n = int(eval(input()))
a = list(map(int, input().split()))
d = defaultdict(int)
for i, ele in enumerate(a):
if d[ele] == 0:
d[ele]= i+1
else:
l = d[ele]
r = i+1
print(n)
for k in range(2, n+2):
print(((mod_comb(n+1, k)-mod_comb(l-1+n-r+1, k-1))%MOD)) | 36 | 28 | 764 | 650 | MOD = 10**9 + 7
def mod_pow(x, n):
if x == 0:
return 1
res = 1
while n > 0:
if n & 1:
res = (res * x) % MOD
x = (x * x) % MOD
n >>= 1
return res
fact, invfact = [0] * (10**5 + 2), [0] * (10**5 + 2)
fact[0], invfact[0] = 1, 1
for i in range(1, 10**5 + 2):
fact[i] = (fact[i - 1] * i) % MOD
invfact[i] = mod_pow(fact[i], MOD - 2) % MOD
def comb(n, r):
if n < r or n == 0 or r == 0:
return 0
return (((fact[n] * invfact[r]) % MOD) * invfact[n - r]) % MOD
from collections import defaultdict
n = int(eval(input()))
a = list(map(int, input().split()))
d = defaultdict(int)
for i, ele in enumerate(a):
if d[ele] == 0:
d[ele] = i + 1
else:
l = d[ele]
r = i + 1
print(n)
for k in range(2, n + 2):
print(((comb(n + 1, k) - comb(l - 1 + n - r + 1, k - 1)) % MOD))
| # Pythonの組み込み関数powを使ったバージョン
MOD = 10**9 + 7
fact, invfact = [0] * (10**5 + 2), [0] * (10**5 + 2)
fact[0], invfact[0] = 1, 1
for i in range(1, 10**5 + 2):
fact[i] = (fact[i - 1] * i) % MOD
invfact[i] = pow(fact[i], MOD - 2, MOD)
def mod_comb(n, r):
if n < r or n == 0 or r == 0:
return 0
return (((fact[n] * invfact[r]) % MOD) * invfact[n - r]) % MOD
from collections import defaultdict
n = int(eval(input()))
a = list(map(int, input().split()))
d = defaultdict(int)
for i, ele in enumerate(a):
if d[ele] == 0:
d[ele] = i + 1
else:
l = d[ele]
r = i + 1
print(n)
for k in range(2, n + 2):
print(((mod_comb(n + 1, k) - mod_comb(l - 1 + n - r + 1, k - 1)) % MOD))
| false | 22.222222 | [
"+# Pythonの組み込み関数powを使ったバージョン",
"-",
"-",
"-def mod_pow(x, n):",
"- if x == 0:",
"- return 1",
"- res = 1",
"- while n > 0:",
"- if n & 1:",
"- res = (res * x) % MOD",
"- x = (x * x) % MOD",
"- n >>= 1",
"- return res",
"-",
"-",
"- invfact[i] = mod_pow(fact[i], MOD - 2) % MOD",
"+ invfact[i] = pow(fact[i], MOD - 2, MOD)",
"-def comb(n, r):",
"+def mod_comb(n, r):",
"- print(((comb(n + 1, k) - comb(l - 1 + n - r + 1, k - 1)) % MOD))",
"+ print(((mod_comb(n + 1, k) - mod_comb(l - 1 + n - r + 1, k - 1)) % MOD))"
] | false | 1.812723 | 0.555105 | 3.265551 | [
"s920624526",
"s656399930"
] |
u952245863 | p02699 | python | s870855349 | s099237550 | 22 | 20 | 9,152 | 9,092 | Accepted | Accepted | 9.09 | def issafe(S,W):
if S > W:
return "safe"
return "unsafe"
S,W = list(map(int,input().split()))
print((issafe(S,W)))
| def main():
s,w = list(map(int,input().split()))
if s>w:
print("safe")
else:
print("unsafe")
main()
| 7 | 8 | 130 | 122 | def issafe(S, W):
if S > W:
return "safe"
return "unsafe"
S, W = list(map(int, input().split()))
print((issafe(S, W)))
| def main():
s, w = list(map(int, input().split()))
if s > w:
print("safe")
else:
print("unsafe")
main()
| false | 12.5 | [
"-def issafe(S, W):",
"- if S > W:",
"- return \"safe\"",
"- return \"unsafe\"",
"+def main():",
"+ s, w = list(map(int, input().split()))",
"+ if s > w:",
"+ print(\"safe\")",
"+ else:",
"+ print(\"unsafe\")",
"-S, W = list(map(int, input().split()))",
"-print((issafe(S, W)))",
"+main()"
] | false | 0.041891 | 0.040559 | 1.032835 | [
"s870855349",
"s099237550"
] |
u357751375 | p03150 | python | s977230611 | s747853794 | 35 | 29 | 9,040 | 9,052 | Accepted | Accepted | 17.14 | s = eval(input())
n = len(s)
k = 'keyence'
a = 0
b = 6
for i in range(n):
if k[a] == s[i]:
a += 1
else:
break
if a == 7:
break
for i in range(n)[::-1]:
if k[b] == s[i]:
b -= 1
else:
break
if b == -1:
break
b = 7 - b - 1
if a + b >= 7:
print('YES')
else:
print('NO') | s = list(eval(input()))
n = len(s)
for i in range(n):
for j in range(i,n):
t = s[:i] + s[j:]
if ''.join(t) == 'keyence':
print('YES')
exit(0)
print('NO') | 27 | 9 | 372 | 199 | s = eval(input())
n = len(s)
k = "keyence"
a = 0
b = 6
for i in range(n):
if k[a] == s[i]:
a += 1
else:
break
if a == 7:
break
for i in range(n)[::-1]:
if k[b] == s[i]:
b -= 1
else:
break
if b == -1:
break
b = 7 - b - 1
if a + b >= 7:
print("YES")
else:
print("NO")
| s = list(eval(input()))
n = len(s)
for i in range(n):
for j in range(i, n):
t = s[:i] + s[j:]
if "".join(t) == "keyence":
print("YES")
exit(0)
print("NO")
| false | 66.666667 | [
"-s = eval(input())",
"+s = list(eval(input()))",
"-k = \"keyence\"",
"-a = 0",
"-b = 6",
"- if k[a] == s[i]:",
"- a += 1",
"- else:",
"- break",
"- if a == 7:",
"- break",
"-for i in range(n)[::-1]:",
"- if k[b] == s[i]:",
"- b -= 1",
"- else:",
"- break",
"- if b == -1:",
"- break",
"-b = 7 - b - 1",
"-if a + b >= 7:",
"- print(\"YES\")",
"-else:",
"- print(\"NO\")",
"+ for j in range(i, n):",
"+ t = s[:i] + s[j:]",
"+ if \"\".join(t) == \"keyence\":",
"+ print(\"YES\")",
"+ exit(0)",
"+print(\"NO\")"
] | false | 0.084353 | 0.104507 | 0.807154 | [
"s977230611",
"s747853794"
] |
u426649993 | p03274 | python | s523939819 | s715212208 | 221 | 101 | 62,576 | 14,780 | Accepted | Accepted | 54.3 | if __name__ == "__main__":
N, K = list(map(int, input().split()))
x = list(map(int, input().split()))
ans = 10 ** 10
for i in range(N-K+1):
L = x[i]
R = x[i+K-1]
if L <= 0 and R <= 0:
tmp = abs(L)
elif L >= 0 and R >= 0:
tmp = R
else:
tmp = abs(L) + (R-L)
if tmp > 2 * R + abs(L):
tmp = 2 * R + abs(L)
if tmp < ans:
ans = tmp
print(ans)
| if __name__ == "__main__":
n, k = list(map(int, input().split()))
x = list(map(int, input().split()))
x.sort()
xmin = x[0]
xmax = x[k-1]
ans = 0
if xmin < 0 and xmax >= 0:
ans = min([abs(xmin), abs(xmax)]) * 2 + max([abs(xmin), abs(xmax)])
else:
ans = max([abs(xmin), abs(xmax)])
for i in range(n - k + 1):
xmin = x[i]
xmax = x[i + k - 1]
if xmin < 0 and xmax >= 0:
tmp = min([abs(xmin), abs(xmax)]) * 2 + max([abs(xmin), abs(xmax)])
else:
tmp = max([abs(xmin), abs(xmax)])
if tmp < ans:
ans = tmp
print(ans)
| 19 | 25 | 494 | 663 | if __name__ == "__main__":
N, K = list(map(int, input().split()))
x = list(map(int, input().split()))
ans = 10**10
for i in range(N - K + 1):
L = x[i]
R = x[i + K - 1]
if L <= 0 and R <= 0:
tmp = abs(L)
elif L >= 0 and R >= 0:
tmp = R
else:
tmp = abs(L) + (R - L)
if tmp > 2 * R + abs(L):
tmp = 2 * R + abs(L)
if tmp < ans:
ans = tmp
print(ans)
| if __name__ == "__main__":
n, k = list(map(int, input().split()))
x = list(map(int, input().split()))
x.sort()
xmin = x[0]
xmax = x[k - 1]
ans = 0
if xmin < 0 and xmax >= 0:
ans = min([abs(xmin), abs(xmax)]) * 2 + max([abs(xmin), abs(xmax)])
else:
ans = max([abs(xmin), abs(xmax)])
for i in range(n - k + 1):
xmin = x[i]
xmax = x[i + k - 1]
if xmin < 0 and xmax >= 0:
tmp = min([abs(xmin), abs(xmax)]) * 2 + max([abs(xmin), abs(xmax)])
else:
tmp = max([abs(xmin), abs(xmax)])
if tmp < ans:
ans = tmp
print(ans)
| false | 24 | [
"- N, K = list(map(int, input().split()))",
"+ n, k = list(map(int, input().split()))",
"- ans = 10**10",
"- for i in range(N - K + 1):",
"- L = x[i]",
"- R = x[i + K - 1]",
"- if L <= 0 and R <= 0:",
"- tmp = abs(L)",
"- elif L >= 0 and R >= 0:",
"- tmp = R",
"+ x.sort()",
"+ xmin = x[0]",
"+ xmax = x[k - 1]",
"+ ans = 0",
"+ if xmin < 0 and xmax >= 0:",
"+ ans = min([abs(xmin), abs(xmax)]) * 2 + max([abs(xmin), abs(xmax)])",
"+ else:",
"+ ans = max([abs(xmin), abs(xmax)])",
"+ for i in range(n - k + 1):",
"+ xmin = x[i]",
"+ xmax = x[i + k - 1]",
"+ if xmin < 0 and xmax >= 0:",
"+ tmp = min([abs(xmin), abs(xmax)]) * 2 + max([abs(xmin), abs(xmax)])",
"- tmp = abs(L) + (R - L)",
"- if tmp > 2 * R + abs(L):",
"- tmp = 2 * R + abs(L)",
"+ tmp = max([abs(xmin), abs(xmax)])"
] | false | 0.044512 | 0.037323 | 1.192596 | [
"s523939819",
"s715212208"
] |
u279955105 | p02398 | python | s796754184 | s166020592 | 40 | 20 | 7,592 | 5,596 | Accepted | Accepted | 50 | i = 0
a,b,c = list(map(int, input().split()))
for d in range(a,b+1):
e = c % d
if (e == 0):
i += 1
print(i) | a,b,c = list(map(int, input().split()))
Answer = 0
for i in range(a,b+1):
if c % i == 0:
Answer = Answer + 1
print(Answer)
| 7 | 6 | 117 | 134 | i = 0
a, b, c = list(map(int, input().split()))
for d in range(a, b + 1):
e = c % d
if e == 0:
i += 1
print(i)
| a, b, c = list(map(int, input().split()))
Answer = 0
for i in range(a, b + 1):
if c % i == 0:
Answer = Answer + 1
print(Answer)
| false | 14.285714 | [
"-i = 0",
"-for d in range(a, b + 1):",
"- e = c % d",
"- if e == 0:",
"- i += 1",
"-print(i)",
"+Answer = 0",
"+for i in range(a, b + 1):",
"+ if c % i == 0:",
"+ Answer = Answer + 1",
"+print(Answer)"
] | false | 0.035324 | 0.035048 | 1.007868 | [
"s796754184",
"s166020592"
] |
u022979415 | p03329 | python | s099349138 | s477449466 | 742 | 230 | 3,064 | 3,064 | Accepted | Accepted | 69 | # 貪欲的だが「6^i円で払う分」と「9^i円で払う分」にNを分割してN+1通り全探索.
def how_many_times_withdraw(withdraw, base, limit):
result = 0
while withdraw >= base:
result += withdraw // (base ** limit)
withdraw = withdraw % (base ** limit)
limit -= 1
return result + withdraw
def main():
N = int(eval(input()))
limit = []
answer = float("inf")
for yen in [6, 9]:
i = 1
while yen ** i <= N:
i += 1
limit.append(i - 1)
for i in range(N + 1):
answer = min(answer, how_many_times_withdraw(i, 6, limit[0]) + how_many_times_withdraw(N - i, 9, limit[1]))
print(answer)
if __name__ == '__main__':
main() | def make_list(a, n):
res = [1]
i = 1
while pow(a, i) <= n:
res.append(pow(a, i))
i += 1
return res[::-1]
def find_withdraw_times(n, w):
res = 0
for ww in w:
res += n // ww
n %= ww
return res
def main():
n = int(eval(input()))
answer = float("inf")
way_6 = make_list(6, n)
way_9 = make_list(9, n)
for i in range(n + 1):
answer = min(answer, find_withdraw_times(i, way_6) + find_withdraw_times(n - i, way_9))
print(answer)
if __name__ == '__main__':
main()
| 28 | 30 | 698 | 581 | # 貪欲的だが「6^i円で払う分」と「9^i円で払う分」にNを分割してN+1通り全探索.
def how_many_times_withdraw(withdraw, base, limit):
result = 0
while withdraw >= base:
result += withdraw // (base**limit)
withdraw = withdraw % (base**limit)
limit -= 1
return result + withdraw
def main():
N = int(eval(input()))
limit = []
answer = float("inf")
for yen in [6, 9]:
i = 1
while yen**i <= N:
i += 1
limit.append(i - 1)
for i in range(N + 1):
answer = min(
answer,
how_many_times_withdraw(i, 6, limit[0])
+ how_many_times_withdraw(N - i, 9, limit[1]),
)
print(answer)
if __name__ == "__main__":
main()
| def make_list(a, n):
res = [1]
i = 1
while pow(a, i) <= n:
res.append(pow(a, i))
i += 1
return res[::-1]
def find_withdraw_times(n, w):
res = 0
for ww in w:
res += n // ww
n %= ww
return res
def main():
n = int(eval(input()))
answer = float("inf")
way_6 = make_list(6, n)
way_9 = make_list(9, n)
for i in range(n + 1):
answer = min(
answer, find_withdraw_times(i, way_6) + find_withdraw_times(n - i, way_9)
)
print(answer)
if __name__ == "__main__":
main()
| false | 6.666667 | [
"-# 貪欲的だが「6^i円で払う分」と「9^i円で払う分」にNを分割してN+1通り全探索.",
"-def how_many_times_withdraw(withdraw, base, limit):",
"- result = 0",
"- while withdraw >= base:",
"- result += withdraw // (base**limit)",
"- withdraw = withdraw % (base**limit)",
"- limit -= 1",
"- return result + withdraw",
"+def make_list(a, n):",
"+ res = [1]",
"+ i = 1",
"+ while pow(a, i) <= n:",
"+ res.append(pow(a, i))",
"+ i += 1",
"+ return res[::-1]",
"+",
"+",
"+def find_withdraw_times(n, w):",
"+ res = 0",
"+ for ww in w:",
"+ res += n // ww",
"+ n %= ww",
"+ return res",
"- N = int(eval(input()))",
"- limit = []",
"+ n = int(eval(input()))",
"- for yen in [6, 9]:",
"- i = 1",
"- while yen**i <= N:",
"- i += 1",
"- limit.append(i - 1)",
"- for i in range(N + 1):",
"+ way_6 = make_list(6, n)",
"+ way_9 = make_list(9, n)",
"+ for i in range(n + 1):",
"- answer,",
"- how_many_times_withdraw(i, 6, limit[0])",
"- + how_many_times_withdraw(N - i, 9, limit[1]),",
"+ answer, find_withdraw_times(i, way_6) + find_withdraw_times(n - i, way_9)"
] | false | 0.143531 | 0.069808 | 2.056093 | [
"s099349138",
"s477449466"
] |
u987120132 | p02952 | python | s110242088 | s893741948 | 58 | 17 | 2,940 | 2,940 | Accepted | Accepted | 70.69 | N = int(eval(input()))
ans = 0
for i in range(1, N + 1):
if len(str(i)) % 2 == 1:
ans += 1
print(ans) | N = int(eval(input()))
if N < 10:
print(N)
elif 10 <= N < 100:
print((9))
elif 100 <= N < 1000:
print((N-90))
elif 1000 <= N < 10000:
print((909))
elif 10000 <= N <100000:
print((N-9090))
else:
print((90909)) | 8 | 14 | 116 | 230 | N = int(eval(input()))
ans = 0
for i in range(1, N + 1):
if len(str(i)) % 2 == 1:
ans += 1
print(ans)
| N = int(eval(input()))
if N < 10:
print(N)
elif 10 <= N < 100:
print((9))
elif 100 <= N < 1000:
print((N - 90))
elif 1000 <= N < 10000:
print((909))
elif 10000 <= N < 100000:
print((N - 9090))
else:
print((90909))
| false | 42.857143 | [
"-ans = 0",
"-for i in range(1, N + 1):",
"- if len(str(i)) % 2 == 1:",
"- ans += 1",
"-print(ans)",
"+if N < 10:",
"+ print(N)",
"+elif 10 <= N < 100:",
"+ print((9))",
"+elif 100 <= N < 1000:",
"+ print((N - 90))",
"+elif 1000 <= N < 10000:",
"+ print((909))",
"+elif 10000 <= N < 100000:",
"+ print((N - 9090))",
"+else:",
"+ print((90909))"
] | false | 0.047901 | 0.039834 | 1.202517 | [
"s110242088",
"s893741948"
] |
u753803401 | p03463 | python | s851455677 | s569730822 | 170 | 18 | 38,256 | 2,940 | Accepted | Accepted | 89.41 | import sys
def solve():
readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n, a, b = list(map(int, readline().split()))
print(("Alice" if abs(a - b) % 2 == 0 else "Borys"))
if __name__ == '__main__':
solve()
| import sys
def solve():
readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n, a, b = list(map(int, readline().split()))
if (abs(a - b) - 1) % 2 != 0:
print("Alice")
else:
print("Borys")
if __name__ == '__main__':
solve()
| 12 | 15 | 245 | 283 | import sys
def solve():
readline = sys.stdin.buffer.readline
mod = 10**9 + 7
n, a, b = list(map(int, readline().split()))
print(("Alice" if abs(a - b) % 2 == 0 else "Borys"))
if __name__ == "__main__":
solve()
| import sys
def solve():
readline = sys.stdin.buffer.readline
mod = 10**9 + 7
n, a, b = list(map(int, readline().split()))
if (abs(a - b) - 1) % 2 != 0:
print("Alice")
else:
print("Borys")
if __name__ == "__main__":
solve()
| false | 20 | [
"- print((\"Alice\" if abs(a - b) % 2 == 0 else \"Borys\"))",
"+ if (abs(a - b) - 1) % 2 != 0:",
"+ print(\"Alice\")",
"+ else:",
"+ print(\"Borys\")"
] | false | 0.036727 | 0.036925 | 0.994647 | [
"s851455677",
"s569730822"
] |
u631277801 | p03786 | python | s969668658 | s373090475 | 117 | 108 | 14,476 | 14,472 | Accepted | Accepted | 7.69 | import sys
stdin = sys.stdin
def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())
from itertools import accumulate
n = ni()
a = li()
a.sort()
a_cum = list(accumulate(a))[::-1]
a.sort(reverse=True)
ans = n
for i in range(n-1):
if a[i] <= 2*a_cum[i+1]:
continue
else:
ans = i+1
break
print(ans) | import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
from itertools import accumulate
n = ni()
a = list(li())
a.sort()
acc = list(accumulate(a))
ans = 0
for ai, acci in zip(a[-1:0:-1], acc[-2::-1]):
if 2*acci >= ai:
ans += 1
else:
break
print((ans+1)) | 31 | 32 | 670 | 704 | import sys
stdin = sys.stdin
def li():
return [int(x) for x in stdin.readline().split()]
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return [float(x) for x in stdin.readline().split()]
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()
def lc():
return list(ns())
def ni():
return int(ns())
def nf():
return float(ns())
from itertools import accumulate
n = ni()
a = li()
a.sort()
a_cum = list(accumulate(a))[::-1]
a.sort(reverse=True)
ans = n
for i in range(n - 1):
if a[i] <= 2 * a_cum[i + 1]:
continue
else:
ans = i + 1
break
print(ans)
| import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li():
return list(map(int, stdin.readline().split()))
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return list(map(float, stdin.readline().split()))
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()
def lc():
return list(ns())
def ni():
return int(stdin.readline())
def nf():
return float(stdin.readline())
from itertools import accumulate
n = ni()
a = list(li())
a.sort()
acc = list(accumulate(a))
ans = 0
for ai, acci in zip(a[-1:0:-1], acc[-2::-1]):
if 2 * acci >= ai:
ans += 1
else:
break
print((ans + 1))
| false | 3.125 | [
"+sys.setrecursionlimit(10**5)",
"- return [int(x) for x in stdin.readline().split()]",
"+ return list(map(int, stdin.readline().split()))",
"- return [float(x) for x in stdin.readline().split()]",
"+ return list(map(float, stdin.readline().split()))",
"- return int(ns())",
"+ return int(stdin.readline())",
"- return float(ns())",
"+ return float(stdin.readline())",
"-a = li()",
"+a = list(li())",
"-a_cum = list(accumulate(a))[::-1]",
"-a.sort(reverse=True)",
"-ans = n",
"-for i in range(n - 1):",
"- if a[i] <= 2 * a_cum[i + 1]:",
"- continue",
"+acc = list(accumulate(a))",
"+ans = 0",
"+for ai, acci in zip(a[-1:0:-1], acc[-2::-1]):",
"+ if 2 * acci >= ai:",
"+ ans += 1",
"- ans = i + 1",
"-print(ans)",
"+print((ans + 1))"
] | false | 0.120601 | 0.074724 | 1.613966 | [
"s969668658",
"s373090475"
] |
u896741788 | p03608 | python | s122455458 | s773572292 | 546 | 326 | 65,112 | 71,016 | Accepted | Accepted | 40.29 | t,r,g=list(map(int,input().split()))
d=[[float("INF") for ccc in range(t)] for i in range(t)]
for i in range(t):
d[i][i]=0
gl=list(map(int,input().split()))
for j in range(r):
x,y,c=list(map(int,input().split()))
d[x-1][y-1]=c
d[y-1][x-1]=c
for i in range(t):
for j in range(t):
for k in range(t):
d[k][j]=min(d[k][j],d[k][i]+d[i][j])
from itertools import permutations as pe
ans=float("INF")
for G in pe(gl):
p=0
for qw in range(g-1):
p+=d[G[qw]-1][G[qw+1]-1]
ans=min(ans,p)
print(ans) | class WarshallFloyd:
#O(V^3)で任意2頂点の最短距離
def __init__(self,n,_first_index=0):
self.v = n
self._first_idx=_first_index
self.d = [[float("INF")]*(n) for _ in range(n)]
for i in range(n):
self.d[i][i] = 0
def path(self,x,y,c):
if x == y:
return False
f=self._first_idx
self.d[x-f][y-f] = c
self.d[y-f][x-f] = c
return True
def build(self):
for k in range(self.v):
for i in range(self.v):
for j in range(self.v):
self.d[i][j] = min(self.d[i][j], self.d[i][k] + self.d[k][j])
return self.d
n,m,r=list(map(int,input().split()))
rs=[x-1 for x in map(int,input().split())]
w=WarshallFloyd(n,1)
for i in range(m):w.path(*list(map(int,input().split())))
v=w.build()
from itertools import permutations as pe
print((min(sum(v[f][t]for f,t in zip(i,i[1:]))for i in pe(rs))))
| 21 | 30 | 554 | 954 | t, r, g = list(map(int, input().split()))
d = [[float("INF") for ccc in range(t)] for i in range(t)]
for i in range(t):
d[i][i] = 0
gl = list(map(int, input().split()))
for j in range(r):
x, y, c = list(map(int, input().split()))
d[x - 1][y - 1] = c
d[y - 1][x - 1] = c
for i in range(t):
for j in range(t):
for k in range(t):
d[k][j] = min(d[k][j], d[k][i] + d[i][j])
from itertools import permutations as pe
ans = float("INF")
for G in pe(gl):
p = 0
for qw in range(g - 1):
p += d[G[qw] - 1][G[qw + 1] - 1]
ans = min(ans, p)
print(ans)
| class WarshallFloyd:
# O(V^3)で任意2頂点の最短距離
def __init__(self, n, _first_index=0):
self.v = n
self._first_idx = _first_index
self.d = [[float("INF")] * (n) for _ in range(n)]
for i in range(n):
self.d[i][i] = 0
def path(self, x, y, c):
if x == y:
return False
f = self._first_idx
self.d[x - f][y - f] = c
self.d[y - f][x - f] = c
return True
def build(self):
for k in range(self.v):
for i in range(self.v):
for j in range(self.v):
self.d[i][j] = min(self.d[i][j], self.d[i][k] + self.d[k][j])
return self.d
n, m, r = list(map(int, input().split()))
rs = [x - 1 for x in map(int, input().split())]
w = WarshallFloyd(n, 1)
for i in range(m):
w.path(*list(map(int, input().split())))
v = w.build()
from itertools import permutations as pe
print((min(sum(v[f][t] for f, t in zip(i, i[1:])) for i in pe(rs))))
| false | 30 | [
"-t, r, g = list(map(int, input().split()))",
"-d = [[float(\"INF\") for ccc in range(t)] for i in range(t)]",
"-for i in range(t):",
"- d[i][i] = 0",
"-gl = list(map(int, input().split()))",
"-for j in range(r):",
"- x, y, c = list(map(int, input().split()))",
"- d[x - 1][y - 1] = c",
"- d[y - 1][x - 1] = c",
"-for i in range(t):",
"- for j in range(t):",
"- for k in range(t):",
"- d[k][j] = min(d[k][j], d[k][i] + d[i][j])",
"+class WarshallFloyd:",
"+ # O(V^3)で任意2頂点の最短距離",
"+ def __init__(self, n, _first_index=0):",
"+ self.v = n",
"+ self._first_idx = _first_index",
"+ self.d = [[float(\"INF\")] * (n) for _ in range(n)]",
"+ for i in range(n):",
"+ self.d[i][i] = 0",
"+",
"+ def path(self, x, y, c):",
"+ if x == y:",
"+ return False",
"+ f = self._first_idx",
"+ self.d[x - f][y - f] = c",
"+ self.d[y - f][x - f] = c",
"+ return True",
"+",
"+ def build(self):",
"+ for k in range(self.v):",
"+ for i in range(self.v):",
"+ for j in range(self.v):",
"+ self.d[i][j] = min(self.d[i][j], self.d[i][k] + self.d[k][j])",
"+ return self.d",
"+",
"+",
"+n, m, r = list(map(int, input().split()))",
"+rs = [x - 1 for x in map(int, input().split())]",
"+w = WarshallFloyd(n, 1)",
"+for i in range(m):",
"+ w.path(*list(map(int, input().split())))",
"+v = w.build()",
"-ans = float(\"INF\")",
"-for G in pe(gl):",
"- p = 0",
"- for qw in range(g - 1):",
"- p += d[G[qw] - 1][G[qw + 1] - 1]",
"- ans = min(ans, p)",
"-print(ans)",
"+print((min(sum(v[f][t] for f, t in zip(i, i[1:])) for i in pe(rs))))"
] | false | 0.047641 | 0.047632 | 1.000188 | [
"s122455458",
"s773572292"
] |
u844945939 | p01538 | python | s321187022 | s131144317 | 60 | 50 | 6,836 | 6,816 | Accepted | Accepted | 16.67 | import sys
import math
Q = sys.stdin.readline()
for _ in range(int(Q)):
cnt = 0
N = int(sys.stdin.readline())
if N != 0:
digLeng = int(math.log10(N)) + 1
else:
digLeng = 1
while digLeng > 1:
Nmax = 0
for dig in range(digLeng):
lNum = N // int(math.pow(10,dig))
rNum = N % int(math.pow(10,dig))
Nmax = max(Nmax,lNum * rNum)
N = Nmax
cnt += 1
if N != 0:
digLeng = int(math.log10(N)) + 1
else:
digLeng = 1
print(cnt) | from math import log10
for i in range(int(eval(input()))):
n = int(eval(input()))
j = 0
while n >= 10:
n = max((n // (10**k)) * (n % (10**k)) for k in range(1, int(log10(n)) + 1))
j += 1
print(j) | 23 | 9 | 583 | 224 | import sys
import math
Q = sys.stdin.readline()
for _ in range(int(Q)):
cnt = 0
N = int(sys.stdin.readline())
if N != 0:
digLeng = int(math.log10(N)) + 1
else:
digLeng = 1
while digLeng > 1:
Nmax = 0
for dig in range(digLeng):
lNum = N // int(math.pow(10, dig))
rNum = N % int(math.pow(10, dig))
Nmax = max(Nmax, lNum * rNum)
N = Nmax
cnt += 1
if N != 0:
digLeng = int(math.log10(N)) + 1
else:
digLeng = 1
print(cnt)
| from math import log10
for i in range(int(eval(input()))):
n = int(eval(input()))
j = 0
while n >= 10:
n = max((n // (10**k)) * (n % (10**k)) for k in range(1, int(log10(n)) + 1))
j += 1
print(j)
| false | 60.869565 | [
"-import sys",
"-import math",
"+from math import log10",
"-Q = sys.stdin.readline()",
"-for _ in range(int(Q)):",
"- cnt = 0",
"- N = int(sys.stdin.readline())",
"- if N != 0:",
"- digLeng = int(math.log10(N)) + 1",
"- else:",
"- digLeng = 1",
"- while digLeng > 1:",
"- Nmax = 0",
"- for dig in range(digLeng):",
"- lNum = N // int(math.pow(10, dig))",
"- rNum = N % int(math.pow(10, dig))",
"- Nmax = max(Nmax, lNum * rNum)",
"- N = Nmax",
"- cnt += 1",
"- if N != 0:",
"- digLeng = int(math.log10(N)) + 1",
"- else:",
"- digLeng = 1",
"- print(cnt)",
"+for i in range(int(eval(input()))):",
"+ n = int(eval(input()))",
"+ j = 0",
"+ while n >= 10:",
"+ n = max((n // (10**k)) * (n % (10**k)) for k in range(1, int(log10(n)) + 1))",
"+ j += 1",
"+ print(j)"
] | false | 0.036185 | 0.036984 | 0.978397 | [
"s321187022",
"s131144317"
] |
u839188633 | p02720 | python | s072868915 | s664328113 | 154 | 105 | 12,508 | 11,880 | Accepted | Accepted | 31.82 | import numpy as np
K = int(eval(input()))
top = np.ones(10, dtype=int)
adj = np.eye(10, dtype=int)
adj[1:, :-1] += np.eye(9, dtype=int)
adj[:-1, 1:] += np.eye(9, dtype=int)
counts = [top]
tmp = top
for _ in range(10):
tmp = np.dot(tmp, adj)
counts.append(tmp)
for i in range(10):
for j in range(1, 10):
if K > counts[i][j]:
K -= counts[i][j]
else:
break
else:
continue
break
ans = [-1] * (i + 1)
ans[i] = j
for d in range(i, 0, -1):
for k in range(max(0, j - 1), min(9, j + 1) + 1):
if K > counts[d - 1][k]:
K -= counts[d - 1][k]
else:
ans[d - 1] = k
j = k
break
print(("".join(list(map(str, ans))[::-1])))
| from collections import deque
K = int(eval(input()))
q = deque(list(range(1, 10)))
for i in range(K):
x = q.popleft()
r = x % 10
y = 10 * x + r
if r != 0:
q.append(y - 1)
q.append(y)
if r != 9:
q.append(y + 1)
print(x)
| 39 | 17 | 781 | 267 | import numpy as np
K = int(eval(input()))
top = np.ones(10, dtype=int)
adj = np.eye(10, dtype=int)
adj[1:, :-1] += np.eye(9, dtype=int)
adj[:-1, 1:] += np.eye(9, dtype=int)
counts = [top]
tmp = top
for _ in range(10):
tmp = np.dot(tmp, adj)
counts.append(tmp)
for i in range(10):
for j in range(1, 10):
if K > counts[i][j]:
K -= counts[i][j]
else:
break
else:
continue
break
ans = [-1] * (i + 1)
ans[i] = j
for d in range(i, 0, -1):
for k in range(max(0, j - 1), min(9, j + 1) + 1):
if K > counts[d - 1][k]:
K -= counts[d - 1][k]
else:
ans[d - 1] = k
j = k
break
print(("".join(list(map(str, ans))[::-1])))
| from collections import deque
K = int(eval(input()))
q = deque(list(range(1, 10)))
for i in range(K):
x = q.popleft()
r = x % 10
y = 10 * x + r
if r != 0:
q.append(y - 1)
q.append(y)
if r != 9:
q.append(y + 1)
print(x)
| false | 56.410256 | [
"-import numpy as np",
"+from collections import deque",
"-top = np.ones(10, dtype=int)",
"-adj = np.eye(10, dtype=int)",
"-adj[1:, :-1] += np.eye(9, dtype=int)",
"-adj[:-1, 1:] += np.eye(9, dtype=int)",
"-counts = [top]",
"-tmp = top",
"-for _ in range(10):",
"- tmp = np.dot(tmp, adj)",
"- counts.append(tmp)",
"-for i in range(10):",
"- for j in range(1, 10):",
"- if K > counts[i][j]:",
"- K -= counts[i][j]",
"- else:",
"- break",
"- else:",
"- continue",
"- break",
"-ans = [-1] * (i + 1)",
"-ans[i] = j",
"-for d in range(i, 0, -1):",
"- for k in range(max(0, j - 1), min(9, j + 1) + 1):",
"- if K > counts[d - 1][k]:",
"- K -= counts[d - 1][k]",
"- else:",
"- ans[d - 1] = k",
"- j = k",
"- break",
"-print((\"\".join(list(map(str, ans))[::-1])))",
"+q = deque(list(range(1, 10)))",
"+for i in range(K):",
"+ x = q.popleft()",
"+ r = x % 10",
"+ y = 10 * x + r",
"+ if r != 0:",
"+ q.append(y - 1)",
"+ q.append(y)",
"+ if r != 9:",
"+ q.append(y + 1)",
"+print(x)"
] | false | 0.474632 | 0.097808 | 4.852711 | [
"s072868915",
"s664328113"
] |
u529722835 | p02832 | python | s415801717 | s952573133 | 92 | 80 | 18,332 | 26,268 | Accepted | Accepted | 13.04 | def main():
N = int(eval(input()))
a = input().split()
for i in range(N):
a[i] = int(a[i])
j = 1
for i in range(N):
if(j == a[i]):
j += 1
if j > 1:
print((N-j+1))
else:
print((-1))
if __name__ == '__main__':
main() | def main():
N = int(eval(input()))
a = list(map(int,input().split()))
j = 1
for i in range(N):
if(j == a[i]):
j += 1
print((N - j + 1 if j > 1 else -1))
if __name__ == '__main__':
main() | 16 | 12 | 304 | 243 | def main():
N = int(eval(input()))
a = input().split()
for i in range(N):
a[i] = int(a[i])
j = 1
for i in range(N):
if j == a[i]:
j += 1
if j > 1:
print((N - j + 1))
else:
print((-1))
if __name__ == "__main__":
main()
| def main():
N = int(eval(input()))
a = list(map(int, input().split()))
j = 1
for i in range(N):
if j == a[i]:
j += 1
print((N - j + 1 if j > 1 else -1))
if __name__ == "__main__":
main()
| false | 25 | [
"- a = input().split()",
"- for i in range(N):",
"- a[i] = int(a[i])",
"+ a = list(map(int, input().split()))",
"- if j > 1:",
"- print((N - j + 1))",
"- else:",
"- print((-1))",
"+ print((N - j + 1 if j > 1 else -1))"
] | false | 0.03608 | 0.036754 | 0.981653 | [
"s415801717",
"s952573133"
] |
u186838327 | p03634 | python | s673413573 | s716418716 | 951 | 729 | 55,932 | 83,616 | Accepted | Accepted | 23.34 | import heapq
def dijkstra_heap(s):
d = [float("inf")] * n
used = [True] * n
d[s] = 0
used[s] = False
edgelist = []
for e in edge[s]:
heapq.heappush(edgelist,e)
while len(edgelist):
minedge = heapq.heappop(edgelist)
if not used[minedge[1]]:
continue
v = minedge[1]
d[v] = minedge[0]
used[v] = False
for e in edge[v]:
if used[e[1]]:
heapq.heappush(edgelist,[e[0]+d[v],e[1]])
return d
import sys
input = sys.stdin.readline
n =int(eval(input()))
edge = [[] for i in range(n)]
#edge[i] : [weght,to]
for i in range(n-1):
a, b, c = list(map(int,input().split()))
a, b = a-1, b-1
edge[a].append([c,b])
edge[b].append([c,a])
q, k = list(map(int, input().split()))
k = k-1
d = dijkstra_heap(k)
for i in range(q):
x, y = list(map(int, input().split()))
x, y = x-1, y-1
print((d[x]+d[y])) | import heapq
def dijkstra_heap(s):
d = [float("inf")] * n
used = [True] * n #True: not used
d[s] = 0
used[s] = False
edgelist = []
for e in edge[s]:
heapq.heappush(edgelist,e)
while len(edgelist):
minedge = heapq.heappop(edgelist)
if not used[minedge[1]]:
continue
v = minedge[1]
d[v] = minedge[0]
used[v] = False
for e in edge[v]:
if used[e[1]]:
heapq.heappush(edgelist,(e[0]+d[v],e[1]))
return d
import sys
input = sys.stdin.readline
n =int(eval(input()))
edge = [[] for i in range(n)]
#edge[i] : [weght,to]
for i in range(n-1):
a, b, c = list(map(int,input().split()))
a, b = a-1, b-1
edge[a].append((c,b))
edge[b].append((c,a))
q, k = list(map(int, input().split()))
k = k-1
d = dijkstra_heap(k)
for i in range(q):
x, y = list(map(int, input().split()))
x, y = x-1, y-1
print((d[x]+d[y])) | 38 | 38 | 940 | 956 | import heapq
def dijkstra_heap(s):
d = [float("inf")] * n
used = [True] * n
d[s] = 0
used[s] = False
edgelist = []
for e in edge[s]:
heapq.heappush(edgelist, e)
while len(edgelist):
minedge = heapq.heappop(edgelist)
if not used[minedge[1]]:
continue
v = minedge[1]
d[v] = minedge[0]
used[v] = False
for e in edge[v]:
if used[e[1]]:
heapq.heappush(edgelist, [e[0] + d[v], e[1]])
return d
import sys
input = sys.stdin.readline
n = int(eval(input()))
edge = [[] for i in range(n)]
# edge[i] : [weght,to]
for i in range(n - 1):
a, b, c = list(map(int, input().split()))
a, b = a - 1, b - 1
edge[a].append([c, b])
edge[b].append([c, a])
q, k = list(map(int, input().split()))
k = k - 1
d = dijkstra_heap(k)
for i in range(q):
x, y = list(map(int, input().split()))
x, y = x - 1, y - 1
print((d[x] + d[y]))
| import heapq
def dijkstra_heap(s):
d = [float("inf")] * n
used = [True] * n # True: not used
d[s] = 0
used[s] = False
edgelist = []
for e in edge[s]:
heapq.heappush(edgelist, e)
while len(edgelist):
minedge = heapq.heappop(edgelist)
if not used[minedge[1]]:
continue
v = minedge[1]
d[v] = minedge[0]
used[v] = False
for e in edge[v]:
if used[e[1]]:
heapq.heappush(edgelist, (e[0] + d[v], e[1]))
return d
import sys
input = sys.stdin.readline
n = int(eval(input()))
edge = [[] for i in range(n)]
# edge[i] : [weght,to]
for i in range(n - 1):
a, b, c = list(map(int, input().split()))
a, b = a - 1, b - 1
edge[a].append((c, b))
edge[b].append((c, a))
q, k = list(map(int, input().split()))
k = k - 1
d = dijkstra_heap(k)
for i in range(q):
x, y = list(map(int, input().split()))
x, y = x - 1, y - 1
print((d[x] + d[y]))
| false | 0 | [
"- used = [True] * n",
"+ used = [True] * n # True: not used",
"- heapq.heappush(edgelist, [e[0] + d[v], e[1]])",
"+ heapq.heappush(edgelist, (e[0] + d[v], e[1]))",
"- edge[a].append([c, b])",
"- edge[b].append([c, a])",
"+ edge[a].append((c, b))",
"+ edge[b].append((c, a))"
] | false | 0.043469 | 0.039024 | 1.113928 | [
"s673413573",
"s716418716"
] |
u759412327 | p03836 | python | s431611922 | s962596034 | 19 | 17 | 3,060 | 3,060 | Accepted | Accepted | 10.53 | sx,sy,tx,ty = list(map(int,input().split()))
dx = tx-sx
dy = ty-sy
p1 = dx*"R"+dy*"U"
p2 = dx*"L"+dy*"D"
p3 = "D"+(1+dx)*"R"+(1+dy)*"U"+"L"
p4 = "U"+(1+dx)*"L"+(1+dy)*"D"+"R"
print((p1+p2+p3+p4)) | sx,sy,tx,ty = list(map(int,input().split()))
dx = tx-sx
dy = ty-sy
print((dx*"R"+dy*"U"+dx*"L"+(dy+1)*"D"+(dx+1)*"R"+(dy+1)*"U"+"L"+"U"+(dx+1)*"L"+(dy+1)*"D"+"R")) | 10 | 4 | 204 | 158 | sx, sy, tx, ty = list(map(int, input().split()))
dx = tx - sx
dy = ty - sy
p1 = dx * "R" + dy * "U"
p2 = dx * "L" + dy * "D"
p3 = "D" + (1 + dx) * "R" + (1 + dy) * "U" + "L"
p4 = "U" + (1 + dx) * "L" + (1 + dy) * "D" + "R"
print((p1 + p2 + p3 + p4))
| sx, sy, tx, ty = list(map(int, input().split()))
dx = tx - sx
dy = ty - sy
print(
(
dx * "R"
+ dy * "U"
+ dx * "L"
+ (dy + 1) * "D"
+ (dx + 1) * "R"
+ (dy + 1) * "U"
+ "L"
+ "U"
+ (dx + 1) * "L"
+ (dy + 1) * "D"
+ "R"
)
)
| false | 60 | [
"-p1 = dx * \"R\" + dy * \"U\"",
"-p2 = dx * \"L\" + dy * \"D\"",
"-p3 = \"D\" + (1 + dx) * \"R\" + (1 + dy) * \"U\" + \"L\"",
"-p4 = \"U\" + (1 + dx) * \"L\" + (1 + dy) * \"D\" + \"R\"",
"-print((p1 + p2 + p3 + p4))",
"+print(",
"+ (",
"+ dx * \"R\"",
"+ + dy * \"U\"",
"+ + dx * \"L\"",
"+ + (dy + 1) * \"D\"",
"+ + (dx + 1) * \"R\"",
"+ + (dy + 1) * \"U\"",
"+ + \"L\"",
"+ + \"U\"",
"+ + (dx + 1) * \"L\"",
"+ + (dy + 1) * \"D\"",
"+ + \"R\"",
"+ )",
"+)"
] | false | 0.045421 | 0.047043 | 0.965522 | [
"s431611922",
"s962596034"
] |
u002663801 | p02556 | python | s671896022 | s085380337 | 440 | 318 | 9,180 | 97,148 | Accepted | Accepted | 27.73 | n = int(eval(input()))
max1 = -1 * (10 ** 10)
min1 = 10 ** 10
max0 = -1 * (10 ** 10)
min0 = 10 ** 10
for i in range(n):
x,y = list(map(int,input().split()))
k0 = x - y
k1 = x + y
if k0 > max0:
max0 = k0
if k0 < min0:
min0 = k0
if k1 > max1:
max1 = k1
if k1 < min1:
min1 = k1
ans = int(max(max1-min1,max0-min0))
print(ans) | n = int(eval(input()))
z = list()
w = list()
for i in range(n):
x,y = list(map(int,input().split()))
z.append(x + y)
w.append(x - y)
ans = max(max(z) - min(z),max(w)-min(w))
print(ans) | 24 | 13 | 403 | 206 | n = int(eval(input()))
max1 = -1 * (10**10)
min1 = 10**10
max0 = -1 * (10**10)
min0 = 10**10
for i in range(n):
x, y = list(map(int, input().split()))
k0 = x - y
k1 = x + y
if k0 > max0:
max0 = k0
if k0 < min0:
min0 = k0
if k1 > max1:
max1 = k1
if k1 < min1:
min1 = k1
ans = int(max(max1 - min1, max0 - min0))
print(ans)
| n = int(eval(input()))
z = list()
w = list()
for i in range(n):
x, y = list(map(int, input().split()))
z.append(x + y)
w.append(x - y)
ans = max(max(z) - min(z), max(w) - min(w))
print(ans)
| false | 45.833333 | [
"-max1 = -1 * (10**10)",
"-min1 = 10**10",
"-max0 = -1 * (10**10)",
"-min0 = 10**10",
"+z = list()",
"+w = list()",
"- k0 = x - y",
"- k1 = x + y",
"- if k0 > max0:",
"- max0 = k0",
"- if k0 < min0:",
"- min0 = k0",
"- if k1 > max1:",
"- max1 = k1",
"- if k1 < min1:",
"- min1 = k1",
"-ans = int(max(max1 - min1, max0 - min0))",
"+ z.append(x + y)",
"+ w.append(x - y)",
"+ans = max(max(z) - min(z), max(w) - min(w))"
] | false | 0.034301 | 0.034142 | 1.004658 | [
"s671896022",
"s085380337"
] |
u973013625 | p03448 | python | s670029632 | s743875058 | 60 | 45 | 8,276 | 8,276 | Accepted | Accepted | 25 | A, B, C, X = [int(eval(input())) for _ in range(4)]
y = []
for a in range(A + 1):
for b in range(B + 1):
for c in range(C + 1):
y.append(500 * a + 100 * b + 50 * c)
print((y.count(X))) | A, B, C, X = [int(eval(input())) for _ in range(4)]
print(([500 * a + 100 * b + 50 * c for c in range(C + 1) for b in range(B + 1) for a in range(A + 1)].count(X))) | 9 | 2 | 210 | 157 | A, B, C, X = [int(eval(input())) for _ in range(4)]
y = []
for a in range(A + 1):
for b in range(B + 1):
for c in range(C + 1):
y.append(500 * a + 100 * b + 50 * c)
print((y.count(X)))
| A, B, C, X = [int(eval(input())) for _ in range(4)]
print(
(
[
500 * a + 100 * b + 50 * c
for c in range(C + 1)
for b in range(B + 1)
for a in range(A + 1)
].count(X)
)
)
| false | 77.777778 | [
"-y = []",
"-for a in range(A + 1):",
"- for b in range(B + 1):",
"- for c in range(C + 1):",
"- y.append(500 * a + 100 * b + 50 * c)",
"-print((y.count(X)))",
"+print(",
"+ (",
"+ [",
"+ 500 * a + 100 * b + 50 * c",
"+ for c in range(C + 1)",
"+ for b in range(B + 1)",
"+ for a in range(A + 1)",
"+ ].count(X)",
"+ )",
"+)"
] | false | 0.117672 | 0.099626 | 1.181132 | [
"s670029632",
"s743875058"
] |
u127499732 | p02678 | python | s858079783 | s149344183 | 433 | 388 | 56,540 | 56,848 | Accepted | Accepted | 10.39 | def main():
from collections import deque
n, m, *ab = list(map(int, open(0).read().split()))
l = {i: [] for i in range(n + 1)}
for i, j in zip(*[iter(ab)] * 2):
l[i] += [j]
l[j] += [i]
ll = [None] * (n + 1)
vis = [False] * (n + 1)
que = deque([1])
vis[1] = True
while que:
now = que.popleft()
nx = l[now]
for i in nx:
if vis[i]:
continue
vis[i] = True
ll[i] = now
que.append(i)
if all(vis[1:]):
print("Yes")
s = "\n".join(map(str, ll[2:]))
print(s)
else:
print("No")
if __name__ == '__main__':
main()
| def main():
from collections import deque
n, m, *ab = list(map(int, open(0).read().split()))
l = {i: [] for i in range(n + 1)}
for i, j in zip(*[iter(ab)] * 2):
l[i].append(j)
l[j].append(i)
ll = [None] * (n + 1)
vis = [False] * (n + 1)
que = deque([1])
vis[1] = True
while que:
now = que.popleft()
nx = l[now]
for i in nx:
if vis[i]:
continue
vis[i] = True
ll[i] = now
que.append(i)
if all(vis[1:]):
print("Yes")
s = "\n".join(map(str, ll[2:]))
print(s)
else:
print("No")
if __name__ == '__main__':
main()
| 32 | 32 | 714 | 720 | def main():
from collections import deque
n, m, *ab = list(map(int, open(0).read().split()))
l = {i: [] for i in range(n + 1)}
for i, j in zip(*[iter(ab)] * 2):
l[i] += [j]
l[j] += [i]
ll = [None] * (n + 1)
vis = [False] * (n + 1)
que = deque([1])
vis[1] = True
while que:
now = que.popleft()
nx = l[now]
for i in nx:
if vis[i]:
continue
vis[i] = True
ll[i] = now
que.append(i)
if all(vis[1:]):
print("Yes")
s = "\n".join(map(str, ll[2:]))
print(s)
else:
print("No")
if __name__ == "__main__":
main()
| def main():
from collections import deque
n, m, *ab = list(map(int, open(0).read().split()))
l = {i: [] for i in range(n + 1)}
for i, j in zip(*[iter(ab)] * 2):
l[i].append(j)
l[j].append(i)
ll = [None] * (n + 1)
vis = [False] * (n + 1)
que = deque([1])
vis[1] = True
while que:
now = que.popleft()
nx = l[now]
for i in nx:
if vis[i]:
continue
vis[i] = True
ll[i] = now
que.append(i)
if all(vis[1:]):
print("Yes")
s = "\n".join(map(str, ll[2:]))
print(s)
else:
print("No")
if __name__ == "__main__":
main()
| false | 0 | [
"- l[i] += [j]",
"- l[j] += [i]",
"+ l[i].append(j)",
"+ l[j].append(i)"
] | false | 0.03853 | 0.044359 | 0.868582 | [
"s858079783",
"s149344183"
] |
u606878291 | p03031 | python | s192358563 | s131637844 | 26 | 22 | 3,064 | 3,064 | Accepted | Accepted | 15.38 | import math
def number2bit(n):
return int(math.pow(2, n - 1))
def count_bit(n):
count = 0
while n > 0:
if n & 1 == 1:
count += 1
n >>= 1
return count
N, M = list(map(int, input().split(' ')))
lights = [set(tuple(map(int, input().split(' ')))[1:]) for _ in range(M)]
light_bits = [sum(map(number2bit, light)) for light in lights]
mods = tuple(map(int, input().split(' ')))
count = 0
for i in range(int(math.pow(2, N))):
for j, light_bit in enumerate(light_bits):
if count_bit(i & light_bit) % 2 != mods[j]:
break
else:
count += 1
print(count)
| import math
def number2bit(n):
return int(math.pow(2, n - 1))
def count_bit(n):
return bin(n)[2:].count('1')
N, M = list(map(int, input().split(' ')))
lights = [tuple(map(int, input().split(' ')))[1:] for _ in range(M)]
light_bits = [sum(map(number2bit, light)) for light in lights]
mods = tuple(map(int, input().split(' ')))
count = 0
for i in range(int('1' + '0' * N, base=2)):
for light_bit, mod in zip(light_bits, mods):
if count_bit(i & light_bit) % 2 != mod:
break
else:
count += 1
print(count)
| 30 | 25 | 653 | 571 | import math
def number2bit(n):
return int(math.pow(2, n - 1))
def count_bit(n):
count = 0
while n > 0:
if n & 1 == 1:
count += 1
n >>= 1
return count
N, M = list(map(int, input().split(" ")))
lights = [set(tuple(map(int, input().split(" ")))[1:]) for _ in range(M)]
light_bits = [sum(map(number2bit, light)) for light in lights]
mods = tuple(map(int, input().split(" ")))
count = 0
for i in range(int(math.pow(2, N))):
for j, light_bit in enumerate(light_bits):
if count_bit(i & light_bit) % 2 != mods[j]:
break
else:
count += 1
print(count)
| import math
def number2bit(n):
return int(math.pow(2, n - 1))
def count_bit(n):
return bin(n)[2:].count("1")
N, M = list(map(int, input().split(" ")))
lights = [tuple(map(int, input().split(" ")))[1:] for _ in range(M)]
light_bits = [sum(map(number2bit, light)) for light in lights]
mods = tuple(map(int, input().split(" ")))
count = 0
for i in range(int("1" + "0" * N, base=2)):
for light_bit, mod in zip(light_bits, mods):
if count_bit(i & light_bit) % 2 != mod:
break
else:
count += 1
print(count)
| false | 16.666667 | [
"- count = 0",
"- while n > 0:",
"- if n & 1 == 1:",
"- count += 1",
"- n >>= 1",
"- return count",
"+ return bin(n)[2:].count(\"1\")",
"-lights = [set(tuple(map(int, input().split(\" \")))[1:]) for _ in range(M)]",
"+lights = [tuple(map(int, input().split(\" \")))[1:] for _ in range(M)]",
"-for i in range(int(math.pow(2, N))):",
"- for j, light_bit in enumerate(light_bits):",
"- if count_bit(i & light_bit) % 2 != mods[j]:",
"+for i in range(int(\"1\" + \"0\" * N, base=2)):",
"+ for light_bit, mod in zip(light_bits, mods):",
"+ if count_bit(i & light_bit) % 2 != mod:"
] | false | 0.045362 | 0.089271 | 0.508135 | [
"s192358563",
"s131637844"
] |
u780475861 | p03721 | python | s416164653 | s681688672 | 405 | 276 | 22,872 | 22,912 | Accepted | Accepted | 31.85 | n, k = list(map(int,input().split()))
lst = [[int(i) for i in input().split()] for _ in range(n)]
lst.sort(key = lambda x: x[0])
for [i, j] in lst:
if j >= k:
print(i)
quit()
else:
k -= j | import sys
input = sys.stdin.readline
n, k = list(map(int,input().split()))
lst = [[int(i) for i in input().split()] for _ in range(n)]
lst.sort(key = lambda x: x[0])
for [i, j] in lst:
if j >= k:
print(i)
quit()
else:
k -= j | 12 | 12 | 227 | 263 | n, k = list(map(int, input().split()))
lst = [[int(i) for i in input().split()] for _ in range(n)]
lst.sort(key=lambda x: x[0])
for [i, j] in lst:
if j >= k:
print(i)
quit()
else:
k -= j
| import sys
input = sys.stdin.readline
n, k = list(map(int, input().split()))
lst = [[int(i) for i in input().split()] for _ in range(n)]
lst.sort(key=lambda x: x[0])
for [i, j] in lst:
if j >= k:
print(i)
quit()
else:
k -= j
| false | 0 | [
"+import sys",
"+",
"+input = sys.stdin.readline"
] | false | 0.04511 | 0.045703 | 0.987024 | [
"s416164653",
"s681688672"
] |
u857547702 | p02712 | python | s527361803 | s962052375 | 201 | 96 | 30,160 | 103,812 | Accepted | Accepted | 52.24 | N=int(eval(input()))
a=[]
z=0
for i in range(1,N+1):
if i%3==0:
z=0
elif i%5==0:
z=0
elif i%3==0 and i%5==0:
z=0
else:
a.append(i)
print((sum(a))) | N=int(eval(input()))
count=[]
for i in range(1,N+1):
if i%3!=0 and i%5!=0:
count.append(i)
print((sum(count))) | 13 | 6 | 198 | 120 | N = int(eval(input()))
a = []
z = 0
for i in range(1, N + 1):
if i % 3 == 0:
z = 0
elif i % 5 == 0:
z = 0
elif i % 3 == 0 and i % 5 == 0:
z = 0
else:
a.append(i)
print((sum(a)))
| N = int(eval(input()))
count = []
for i in range(1, N + 1):
if i % 3 != 0 and i % 5 != 0:
count.append(i)
print((sum(count)))
| false | 53.846154 | [
"-a = []",
"-z = 0",
"+count = []",
"- if i % 3 == 0:",
"- z = 0",
"- elif i % 5 == 0:",
"- z = 0",
"- elif i % 3 == 0 and i % 5 == 0:",
"- z = 0",
"- else:",
"- a.append(i)",
"-print((sum(a)))",
"+ if i % 3 != 0 and i % 5 != 0:",
"+ count.append(i)",
"+print((sum(count)))"
] | false | 0.251872 | 0.115511 | 2.180505 | [
"s527361803",
"s962052375"
] |
u408071652 | p02694 | python | s743247928 | s795460169 | 25 | 22 | 9,152 | 9,160 | Accepted | Accepted | 12 | x = int(eval(input()))
m =100
i=0
while m <x:
m = m*1.01
m = int(m)
i+=1
print(i) | X = int(eval(input()))
depo =100
i=1
while depo > 1:
depo = int(depo*1.01)
if depo >= X:
break
i +=1
print(i) | 8 | 11 | 94 | 139 | x = int(eval(input()))
m = 100
i = 0
while m < x:
m = m * 1.01
m = int(m)
i += 1
print(i)
| X = int(eval(input()))
depo = 100
i = 1
while depo > 1:
depo = int(depo * 1.01)
if depo >= X:
break
i += 1
print(i)
| false | 27.272727 | [
"-x = int(eval(input()))",
"-m = 100",
"-i = 0",
"-while m < x:",
"- m = m * 1.01",
"- m = int(m)",
"+X = int(eval(input()))",
"+depo = 100",
"+i = 1",
"+while depo > 1:",
"+ depo = int(depo * 1.01)",
"+ if depo >= X:",
"+ break"
] | false | 0.033694 | 0.116217 | 0.289919 | [
"s743247928",
"s795460169"
] |
u740284863 | p03681 | python | s957180276 | s558749287 | 400 | 229 | 4,736 | 4,092 | Accepted | Accepted | 42.75 | import math
n = sorted(list(map(int,input().split())))
n[1] %= (10**9 + 7)
n[0] %= (10**9 + 7)
if n[1] - n[0] >= 2:
ans = 0
elif n[1] - n[0] == 0:
ans = math.factorial(n[1]) **2 * 2
else:
ans = n[1] * math.factorial(n[0])**2
print((ans % (10**9 + 7) )) | import math
n = sorted(list(map(int,input().split())))
n[1] %= (10**9 + 7)
n[0] %= (10**9 + 7)
if n[1] - n[0] >= 2:
ans = 0
elif n[1] - n[0] == 0:
ans = (math.factorial(n[1])%(10**9 + 7)) **2 * 2
else:
ans = n[1] * (math.factorial(n[0]) % (10**9 + 7))**2
print((ans % (10**9 + 7) )) | 11 | 11 | 272 | 302 | import math
n = sorted(list(map(int, input().split())))
n[1] %= 10**9 + 7
n[0] %= 10**9 + 7
if n[1] - n[0] >= 2:
ans = 0
elif n[1] - n[0] == 0:
ans = math.factorial(n[1]) ** 2 * 2
else:
ans = n[1] * math.factorial(n[0]) ** 2
print((ans % (10**9 + 7)))
| import math
n = sorted(list(map(int, input().split())))
n[1] %= 10**9 + 7
n[0] %= 10**9 + 7
if n[1] - n[0] >= 2:
ans = 0
elif n[1] - n[0] == 0:
ans = (math.factorial(n[1]) % (10**9 + 7)) ** 2 * 2
else:
ans = n[1] * (math.factorial(n[0]) % (10**9 + 7)) ** 2
print((ans % (10**9 + 7)))
| false | 0 | [
"- ans = math.factorial(n[1]) ** 2 * 2",
"+ ans = (math.factorial(n[1]) % (10**9 + 7)) ** 2 * 2",
"- ans = n[1] * math.factorial(n[0]) ** 2",
"+ ans = n[1] * (math.factorial(n[0]) % (10**9 + 7)) ** 2"
] | false | 0.0599 | 0.045569 | 1.314491 | [
"s957180276",
"s558749287"
] |
u602252807 | p02983 | python | s969956310 | s300577764 | 806 | 61 | 3,060 | 3,060 | Accepted | Accepted | 92.43 | l,r = list(map(int,input().split()))
l2 = l % 2019
r2 = r % 2019
if r - l >= 2019:
print((0))
exit()
else:
result = 2018
for i in range(l,r):
for j in range(i+1,r+1):
result = min(result,(i*j)% 2019)
print(result) | l,r = list(map(int,input().split()))
l2 = l % 2019
r2 = r % 2019
if r - l >= 2019:
print((0))
exit()
else:
result = 2018
for i in range(l,r):
for j in range(i+1,r+1):
result = min(result,(i*j)% 2019)
if result == 0:
print((0))
exit()
print(result)
| 12 | 15 | 256 | 336 | l, r = list(map(int, input().split()))
l2 = l % 2019
r2 = r % 2019
if r - l >= 2019:
print((0))
exit()
else:
result = 2018
for i in range(l, r):
for j in range(i + 1, r + 1):
result = min(result, (i * j) % 2019)
print(result)
| l, r = list(map(int, input().split()))
l2 = l % 2019
r2 = r % 2019
if r - l >= 2019:
print((0))
exit()
else:
result = 2018
for i in range(l, r):
for j in range(i + 1, r + 1):
result = min(result, (i * j) % 2019)
if result == 0:
print((0))
exit()
print(result)
| false | 20 | [
"+ if result == 0:",
"+ print((0))",
"+ exit()"
] | false | 0.054148 | 0.037195 | 1.45579 | [
"s969956310",
"s300577764"
] |
u380524497 | p03361 | python | s487441805 | s481511688 | 24 | 19 | 3,064 | 3,064 | Accepted | Accepted | 20.83 | h, w = list(map(int, input().split()))
canvas = [eval(input()) for _ in range(h)]
dx_list = [0, 1, 0, -1]
dy_list = [-1, 0, 1, 0]
clear = True
for y in range(h):
for x in range(w):
if canvas[y][x] == '.':
continue
else:
count = 0
for d in range(4):
dx = x + dx_list[d]
dy = y + dy_list[d]
if 0 <= dx <= w-1 and 0 <= dy <= h-1:
if canvas[dy][dx] == '#':
count += 1
if count == 0:
clear = False
break
if clear is False:
break
if clear:
print('Yes')
else:
print('No')
| h, w = list(map(int, input().split()))
grid = ['.'*(w+2)]
for _ in range(h):
line = '.' + eval(input()) + '.'
grid.append(line)
grid.append('.'*(w+2))
for i in range(1, h+1):
for j in range(1, w+1):
if grid[i][j] == '.':
continue
else:
up = grid[i-1][j]
right = grid[i][j+1]
left = grid[i][j-1]
down = grid[i+1][j]
if up + right + left + down == '....':
print('No')
exit()
print('Yes') | 30 | 22 | 698 | 529 | h, w = list(map(int, input().split()))
canvas = [eval(input()) for _ in range(h)]
dx_list = [0, 1, 0, -1]
dy_list = [-1, 0, 1, 0]
clear = True
for y in range(h):
for x in range(w):
if canvas[y][x] == ".":
continue
else:
count = 0
for d in range(4):
dx = x + dx_list[d]
dy = y + dy_list[d]
if 0 <= dx <= w - 1 and 0 <= dy <= h - 1:
if canvas[dy][dx] == "#":
count += 1
if count == 0:
clear = False
break
if clear is False:
break
if clear:
print("Yes")
else:
print("No")
| h, w = list(map(int, input().split()))
grid = ["." * (w + 2)]
for _ in range(h):
line = "." + eval(input()) + "."
grid.append(line)
grid.append("." * (w + 2))
for i in range(1, h + 1):
for j in range(1, w + 1):
if grid[i][j] == ".":
continue
else:
up = grid[i - 1][j]
right = grid[i][j + 1]
left = grid[i][j - 1]
down = grid[i + 1][j]
if up + right + left + down == "....":
print("No")
exit()
print("Yes")
| false | 26.666667 | [
"-canvas = [eval(input()) for _ in range(h)]",
"-dx_list = [0, 1, 0, -1]",
"-dy_list = [-1, 0, 1, 0]",
"-clear = True",
"-for y in range(h):",
"- for x in range(w):",
"- if canvas[y][x] == \".\":",
"+grid = [\".\" * (w + 2)]",
"+for _ in range(h):",
"+ line = \".\" + eval(input()) + \".\"",
"+ grid.append(line)",
"+grid.append(\".\" * (w + 2))",
"+for i in range(1, h + 1):",
"+ for j in range(1, w + 1):",
"+ if grid[i][j] == \".\":",
"- count = 0",
"- for d in range(4):",
"- dx = x + dx_list[d]",
"- dy = y + dy_list[d]",
"- if 0 <= dx <= w - 1 and 0 <= dy <= h - 1:",
"- if canvas[dy][dx] == \"#\":",
"- count += 1",
"- if count == 0:",
"- clear = False",
"- break",
"- if clear is False:",
"- break",
"-if clear:",
"- print(\"Yes\")",
"-else:",
"- print(\"No\")",
"+ up = grid[i - 1][j]",
"+ right = grid[i][j + 1]",
"+ left = grid[i][j - 1]",
"+ down = grid[i + 1][j]",
"+ if up + right + left + down == \"....\":",
"+ print(\"No\")",
"+ exit()",
"+print(\"Yes\")"
] | false | 0.037864 | 0.037417 | 1.011942 | [
"s487441805",
"s481511688"
] |
u644907318 | p03494 | python | s675030138 | s103116267 | 168 | 88 | 38,512 | 62,868 | Accepted | Accepted | 47.62 | N = int(eval(input()))
A = list(map(int,input().split()))
kmin = 100
for i in range(N):
a = A[i]
k = 0
while a%2==0:
k += 1
a = a//2
kmin = min(kmin,k)
print(kmin) | N = int(eval(input()))
A = list(map(int,input().split()))
cmin = 104
for i in range(N):
cnt = 1
while A[i]%(2**cnt)==0:
cnt += 1
cmin = min(cmin,cnt-1)
print(cmin) | 11 | 9 | 199 | 185 | N = int(eval(input()))
A = list(map(int, input().split()))
kmin = 100
for i in range(N):
a = A[i]
k = 0
while a % 2 == 0:
k += 1
a = a // 2
kmin = min(kmin, k)
print(kmin)
| N = int(eval(input()))
A = list(map(int, input().split()))
cmin = 104
for i in range(N):
cnt = 1
while A[i] % (2**cnt) == 0:
cnt += 1
cmin = min(cmin, cnt - 1)
print(cmin)
| false | 18.181818 | [
"-kmin = 100",
"+cmin = 104",
"- a = A[i]",
"- k = 0",
"- while a % 2 == 0:",
"- k += 1",
"- a = a // 2",
"- kmin = min(kmin, k)",
"-print(kmin)",
"+ cnt = 1",
"+ while A[i] % (2**cnt) == 0:",
"+ cnt += 1",
"+ cmin = min(cmin, cnt - 1)",
"+print(cmin)"
] | false | 0.044979 | 0.201521 | 0.2232 | [
"s675030138",
"s103116267"
] |
u492910842 | p03448 | python | s555529698 | s909087651 | 184 | 78 | 39,536 | 67,364 | Accepted | Accepted | 57.61 | import math
a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
x = int(eval(input()))
ans = 0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
if i*500+j*100+k*50 == x:
ans += 1
print(ans)
| a=int(eval(input()))
b=int(eval(input()))
c=int(eval(input()))
x=int(eval(input()))
ans=0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
if x==500*i+100*j+50*k:
ans+=1
print(ans)
| 15 | 13 | 234 | 211 | import math
a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
x = int(eval(input()))
ans = 0
for i in range(a + 1):
for j in range(b + 1):
for k in range(c + 1):
if i * 500 + j * 100 + k * 50 == x:
ans += 1
print(ans)
| a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
x = int(eval(input()))
ans = 0
for i in range(a + 1):
for j in range(b + 1):
for k in range(c + 1):
if x == 500 * i + 100 * j + 50 * k:
ans += 1
print(ans)
| false | 13.333333 | [
"-import math",
"-",
"- if i * 500 + j * 100 + k * 50 == x:",
"+ if x == 500 * i + 100 * j + 50 * k:"
] | false | 0.172559 | 0.154701 | 1.115441 | [
"s555529698",
"s909087651"
] |
u646336881 | p02692 | python | s036203630 | s411686824 | 408 | 133 | 87,284 | 95,048 | Accepted | Accepted | 67.4 | #!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys
YES = "Yes" # type: str
NO = "No" # type: str
def solve(N: int, A: int, B: int, C: int, s: "List[int]"):
v = [A, B, C]
ans = []
if sum(v) == 0:
return None
if sum(v) == 1:
for l, r in s:
if v[l] + v[r] == 0:
return None
if v[l] == 0:
ans.append(l)
else:
ans.append(r)
v[l], v[r] = v[r], v[l]
return ans
if sum(v) > 1:
for i in range(N):
l, r = s[i]
if v[l] + v[r] == 0:
return None
if v[r] == 0 or v[l] >= v[r] and i != N - 1 and r in s[i + 1]:
ans.append(r)
v[l] -= 1
v[r] += 1
else:
ans.append(l)
v[l] += 1
v[r] -= 1
return ans
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
def s2i(s: str):
return ord(s[0])-ord('A'), ord(s[1])-ord('A')
def i2s(i: int):
return chr(i + ord('A'))
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
A = int(next(tokens)) # type: int
B = int(next(tokens)) # type: int
C = int(next(tokens)) # type: int
s = [s2i(next(tokens)) for _ in range(N)] # type: "List[int]"
ans = solve(N, A, B, C, s)
if ans == None:
print(NO)
else:
print(YES)
print(("\n".join(list(map(i2s, ans)))))
if __name__ == '__main__':
main()
| #!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys
YES = "Yes" # type: str
NO = "No" # type: str
def solve(N: int, A: int, B: int, C: int, s: "List[int]"):
v = [A, B, C]
ans = []
for i in range(N):
l, r = s[i]
if v[l] + v[r] == 0:
return None
if v[r] == 0 or v[l] >= v[r] and i != N - 1 and r in s[i + 1]:
ans.append(r)
v[l] -= 1
v[r] += 1
else:
ans.append(l)
v[l] += 1
v[r] -= 1
return ans
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
def s2index(s: "List[str]"):
return [ord(c)-ord('A') for c in s]
def index2s(i: int):
return chr(i + ord('A'))
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
A = int(next(tokens)) # type: int
B = int(next(tokens)) # type: int
C = int(next(tokens)) # type: int
s = [s2index(next(tokens)) for _ in range(N)] # type: "List[int]"
ans = solve(N, A, B, C, s)
if ans == None:
print(NO)
else:
print(YES)
print(("\n".join(list(map(index2s, ans)))))
if __name__ == '__main__':
main()
| 67 | 55 | 1,724 | 1,353 | #!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys
YES = "Yes" # type: str
NO = "No" # type: str
def solve(N: int, A: int, B: int, C: int, s: "List[int]"):
v = [A, B, C]
ans = []
if sum(v) == 0:
return None
if sum(v) == 1:
for l, r in s:
if v[l] + v[r] == 0:
return None
if v[l] == 0:
ans.append(l)
else:
ans.append(r)
v[l], v[r] = v[r], v[l]
return ans
if sum(v) > 1:
for i in range(N):
l, r = s[i]
if v[l] + v[r] == 0:
return None
if v[r] == 0 or v[l] >= v[r] and i != N - 1 and r in s[i + 1]:
ans.append(r)
v[l] -= 1
v[r] += 1
else:
ans.append(l)
v[l] += 1
v[r] -= 1
return ans
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
def s2i(s: str):
return ord(s[0]) - ord("A"), ord(s[1]) - ord("A")
def i2s(i: int):
return chr(i + ord("A"))
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
A = int(next(tokens)) # type: int
B = int(next(tokens)) # type: int
C = int(next(tokens)) # type: int
s = [s2i(next(tokens)) for _ in range(N)] # type: "List[int]"
ans = solve(N, A, B, C, s)
if ans == None:
print(NO)
else:
print(YES)
print(("\n".join(list(map(i2s, ans)))))
if __name__ == "__main__":
main()
| #!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys
YES = "Yes" # type: str
NO = "No" # type: str
def solve(N: int, A: int, B: int, C: int, s: "List[int]"):
v = [A, B, C]
ans = []
for i in range(N):
l, r = s[i]
if v[l] + v[r] == 0:
return None
if v[r] == 0 or v[l] >= v[r] and i != N - 1 and r in s[i + 1]:
ans.append(r)
v[l] -= 1
v[r] += 1
else:
ans.append(l)
v[l] += 1
v[r] -= 1
return ans
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
def s2index(s: "List[str]"):
return [ord(c) - ord("A") for c in s]
def index2s(i: int):
return chr(i + ord("A"))
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
A = int(next(tokens)) # type: int
B = int(next(tokens)) # type: int
C = int(next(tokens)) # type: int
s = [s2index(next(tokens)) for _ in range(N)] # type: "List[int]"
ans = solve(N, A, B, C, s)
if ans == None:
print(NO)
else:
print(YES)
print(("\n".join(list(map(index2s, ans)))))
if __name__ == "__main__":
main()
| false | 17.910448 | [
"- if sum(v) == 0:",
"- return None",
"- if sum(v) == 1:",
"- for l, r in s:",
"- if v[l] + v[r] == 0:",
"- return None",
"- if v[l] == 0:",
"- ans.append(l)",
"- else:",
"- ans.append(r)",
"- v[l], v[r] = v[r], v[l]",
"- return ans",
"- if sum(v) > 1:",
"- for i in range(N):",
"- l, r = s[i]",
"- if v[l] + v[r] == 0:",
"- return None",
"- if v[r] == 0 or v[l] >= v[r] and i != N - 1 and r in s[i + 1]:",
"- ans.append(r)",
"- v[l] -= 1",
"- v[r] += 1",
"- else:",
"- ans.append(l)",
"- v[l] += 1",
"- v[r] -= 1",
"- return ans",
"+ for i in range(N):",
"+ l, r = s[i]",
"+ if v[l] + v[r] == 0:",
"+ return None",
"+ if v[r] == 0 or v[l] >= v[r] and i != N - 1 and r in s[i + 1]:",
"+ ans.append(r)",
"+ v[l] -= 1",
"+ v[r] += 1",
"+ else:",
"+ ans.append(l)",
"+ v[l] += 1",
"+ v[r] -= 1",
"+ return ans",
"- def s2i(s: str):",
"- return ord(s[0]) - ord(\"A\"), ord(s[1]) - ord(\"A\")",
"+ def s2index(s: \"List[str]\"):",
"+ return [ord(c) - ord(\"A\") for c in s]",
"- def i2s(i: int):",
"+ def index2s(i: int):",
"- s = [s2i(next(tokens)) for _ in range(N)] # type: \"List[int]\"",
"+ s = [s2index(next(tokens)) for _ in range(N)] # type: \"List[int]\"",
"- print((\"\\n\".join(list(map(i2s, ans)))))",
"+ print((\"\\n\".join(list(map(index2s, ans)))))"
] | false | 0.045012 | 0.045048 | 0.99919 | [
"s036203630",
"s411686824"
] |
u838644735 | p03645 | python | s838201160 | s144320788 | 1,078 | 905 | 101,080 | 59,096 | Accepted | Accepted | 16.05 | def solve():
N, M = list(map(int, input().split()))
T = {}
for i in range(M):
a, b = list(map(int, input().split()))
if a not in T:
T[a] = []
T[a].append(b)
if b not in T:
T[b] = []
T[b].append(a)
# print(N, M, T)
FROM_1 = T[1]
for f in FROM_1:
if N in T[f]:
print('POSSIBLE')
exit()
print('IMPOSSIBLE')
if __name__ == '__main__':
solve()
| def solve():
N, M = map(int, input().split())
FROM_1 = set()
TO_N = set()
for i in range(M):
a, b = map(int, input().split())
if a == 1:
FROM_1.add(b)
elif a == N:
TO_N.add(b)
if b == 1:
FROM_1.add(a)
elif b == N:
TO_N.add(a)
ans = FROM_1 & TO_N
print('POSSIBLE') if ans else print('IMPOSSIBLE')
if __name__ == '__main__':
solve()
| 22 | 19 | 478 | 466 | def solve():
N, M = list(map(int, input().split()))
T = {}
for i in range(M):
a, b = list(map(int, input().split()))
if a not in T:
T[a] = []
T[a].append(b)
if b not in T:
T[b] = []
T[b].append(a)
# print(N, M, T)
FROM_1 = T[1]
for f in FROM_1:
if N in T[f]:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
if __name__ == "__main__":
solve()
| def solve():
N, M = map(int, input().split())
FROM_1 = set()
TO_N = set()
for i in range(M):
a, b = map(int, input().split())
if a == 1:
FROM_1.add(b)
elif a == N:
TO_N.add(b)
if b == 1:
FROM_1.add(a)
elif b == N:
TO_N.add(a)
ans = FROM_1 & TO_N
print("POSSIBLE") if ans else print("IMPOSSIBLE")
if __name__ == "__main__":
solve()
| false | 13.636364 | [
"- N, M = list(map(int, input().split()))",
"- T = {}",
"+ N, M = map(int, input().split())",
"+ FROM_1 = set()",
"+ TO_N = set()",
"- a, b = list(map(int, input().split()))",
"- if a not in T:",
"- T[a] = []",
"- T[a].append(b)",
"- if b not in T:",
"- T[b] = []",
"- T[b].append(a)",
"- # print(N, M, T)",
"- FROM_1 = T[1]",
"- for f in FROM_1:",
"- if N in T[f]:",
"- print(\"POSSIBLE\")",
"- exit()",
"- print(\"IMPOSSIBLE\")",
"+ a, b = map(int, input().split())",
"+ if a == 1:",
"+ FROM_1.add(b)",
"+ elif a == N:",
"+ TO_N.add(b)",
"+ if b == 1:",
"+ FROM_1.add(a)",
"+ elif b == N:",
"+ TO_N.add(a)",
"+ ans = FROM_1 & TO_N",
"+ print(\"POSSIBLE\") if ans else print(\"IMPOSSIBLE\")"
] | false | 0.037386 | 0.031389 | 1.191038 | [
"s838201160",
"s144320788"
] |
u163320134 | p02614 | python | s405702011 | s521633695 | 150 | 81 | 9,348 | 68,144 | Accepted | Accepted | 46 | import copy
h,w,k=list(map(int,input().split()))
board=[list(eval(input())) for _ in range(h)]
ans=0
boards=[]
for i in range(2**h):
tmp=copy.deepcopy(board)
bit1=format(i,'b')
bit1='0'*(h-len(bit1))+bit1
for th in range(h):
if bit1[th]=='0':
continue
for tw in range(w):
tmp[th][tw]='.'
boards.append(tmp)
for i in range(len(boards)):
for j in range(2**w):
tmp=copy.deepcopy(boards[i])
bit2=format(j,'b')
bit2='0'*(w-len(bit2))+bit2
for tw in range(w):
if bit2[tw]=='0':
continue
for th in range(h):
tmp[th][tw]='.'
cnt=0
for th in range(h):
for tw in range(w):
if tmp[th][tw]=='#':
cnt+=1
if cnt==k:
ans+=1
print(ans) | h,w,k=list(map(int,input().split()))
board=[list(eval(input())) for _ in range(h)]
ans=0
for paint_h in range(2**h):
for paint_w in range(2**w):
cnt=0
for i in range(h):
for j in range(w):
if (paint_h>>i)&1==0 and (paint_w>>j)&1==0 and board[i][j]=='#':
cnt+=1
if cnt==k:
ans+=1
print(ans) | 34 | 13 | 759 | 333 | import copy
h, w, k = list(map(int, input().split()))
board = [list(eval(input())) for _ in range(h)]
ans = 0
boards = []
for i in range(2**h):
tmp = copy.deepcopy(board)
bit1 = format(i, "b")
bit1 = "0" * (h - len(bit1)) + bit1
for th in range(h):
if bit1[th] == "0":
continue
for tw in range(w):
tmp[th][tw] = "."
boards.append(tmp)
for i in range(len(boards)):
for j in range(2**w):
tmp = copy.deepcopy(boards[i])
bit2 = format(j, "b")
bit2 = "0" * (w - len(bit2)) + bit2
for tw in range(w):
if bit2[tw] == "0":
continue
for th in range(h):
tmp[th][tw] = "."
cnt = 0
for th in range(h):
for tw in range(w):
if tmp[th][tw] == "#":
cnt += 1
if cnt == k:
ans += 1
print(ans)
| h, w, k = list(map(int, input().split()))
board = [list(eval(input())) for _ in range(h)]
ans = 0
for paint_h in range(2**h):
for paint_w in range(2**w):
cnt = 0
for i in range(h):
for j in range(w):
if (
(paint_h >> i) & 1 == 0
and (paint_w >> j) & 1 == 0
and board[i][j] == "#"
):
cnt += 1
if cnt == k:
ans += 1
print(ans)
| false | 61.764706 | [
"-import copy",
"-",
"-boards = []",
"-for i in range(2**h):",
"- tmp = copy.deepcopy(board)",
"- bit1 = format(i, \"b\")",
"- bit1 = \"0\" * (h - len(bit1)) + bit1",
"- for th in range(h):",
"- if bit1[th] == \"0\":",
"- continue",
"- for tw in range(w):",
"- tmp[th][tw] = \".\"",
"- boards.append(tmp)",
"-for i in range(len(boards)):",
"- for j in range(2**w):",
"- tmp = copy.deepcopy(boards[i])",
"- bit2 = format(j, \"b\")",
"- bit2 = \"0\" * (w - len(bit2)) + bit2",
"- for tw in range(w):",
"- if bit2[tw] == \"0\":",
"- continue",
"- for th in range(h):",
"- tmp[th][tw] = \".\"",
"+for paint_h in range(2**h):",
"+ for paint_w in range(2**w):",
"- for th in range(h):",
"- for tw in range(w):",
"- if tmp[th][tw] == \"#\":",
"+ for i in range(h):",
"+ for j in range(w):",
"+ if (",
"+ (paint_h >> i) & 1 == 0",
"+ and (paint_w >> j) & 1 == 0",
"+ and board[i][j] == \"#\"",
"+ ):"
] | false | 0.055172 | 0.036225 | 1.523027 | [
"s405702011",
"s521633695"
] |
u253681061 | p03835 | python | s005167186 | s080563088 | 1,770 | 1,353 | 3,060 | 2,940 | Accepted | Accepted | 23.56 | import itertools
k,s = [int(x) for x in input().split()]
ans = 0
for i in range(k+1):
for j in range(k+1):
if s - i - j >= 0 and s - i - j <= k:
ans += 1
print(ans) | k,s = [int(x) for x in input().split()]
ans = 0
for x in range(k+1):
for y in range(k+1):
if 0 <= s - (x+y) <= k:
ans += 1
print(ans) | 10 | 8 | 199 | 165 | import itertools
k, s = [int(x) for x in input().split()]
ans = 0
for i in range(k + 1):
for j in range(k + 1):
if s - i - j >= 0 and s - i - j <= k:
ans += 1
print(ans)
| k, s = [int(x) for x in input().split()]
ans = 0
for x in range(k + 1):
for y in range(k + 1):
if 0 <= s - (x + y) <= k:
ans += 1
print(ans)
| false | 20 | [
"-import itertools",
"-",
"-for i in range(k + 1):",
"- for j in range(k + 1):",
"- if s - i - j >= 0 and s - i - j <= k:",
"+for x in range(k + 1):",
"+ for y in range(k + 1):",
"+ if 0 <= s - (x + y) <= k:"
] | false | 0.038953 | 0.038525 | 1.011128 | [
"s005167186",
"s080563088"
] |
u861038878 | p02936 | python | s300928836 | s069258970 | 1,924 | 1,115 | 107,524 | 62,592 | Accepted | Accepted | 42.05 | n, q = list(map(int, input().split()))
ct = [0] * (n+1)
o = [0] * (n+1)
g = [[] for _ in range(n+1)]
for i in range(n-1):
a,b= list(map(int, input().split()))
g[a].append(b)
g[b].append(a)
for i in range(q):
p,x= list(map(int, input().split()))
o[p] += x
todo = [1]
seen = [False] * (n+1)
while todo:
p = todo.pop(-1)
ct[p] += o[p]
seen[p] = True
for i in g[p]:
if seen[i]:
ct[p] += ct[i]
else:
todo.append(i)
print((*ct[1:]))
| import sys
input = sys.stdin.readline
n, q = list(map(int, input().split()))
ct = [0] * (n+1)
o = [0] * (n+1)
g = [[] for _ in range(n+1)]
for i in range(n-1):
a,b= list(map(int, input().split()))
g[a].append(b)
g[b].append(a)
for i in range(q):
p,x= list(map(int, input().split()))
o[p] += x
todo = [1]
seen = [False] * (n+1)
while todo:
p = todo.pop(-1)
ct[p] += o[p]
seen[p] = True
for i in g[p]:
if seen[i]:
ct[p] += ct[i]
else:
todo.append(i)
print((*ct[1:]))
| 28 | 31 | 477 | 519 | n, q = list(map(int, input().split()))
ct = [0] * (n + 1)
o = [0] * (n + 1)
g = [[] for _ in range(n + 1)]
for i in range(n - 1):
a, b = list(map(int, input().split()))
g[a].append(b)
g[b].append(a)
for i in range(q):
p, x = list(map(int, input().split()))
o[p] += x
todo = [1]
seen = [False] * (n + 1)
while todo:
p = todo.pop(-1)
ct[p] += o[p]
seen[p] = True
for i in g[p]:
if seen[i]:
ct[p] += ct[i]
else:
todo.append(i)
print((*ct[1:]))
| import sys
input = sys.stdin.readline
n, q = list(map(int, input().split()))
ct = [0] * (n + 1)
o = [0] * (n + 1)
g = [[] for _ in range(n + 1)]
for i in range(n - 1):
a, b = list(map(int, input().split()))
g[a].append(b)
g[b].append(a)
for i in range(q):
p, x = list(map(int, input().split()))
o[p] += x
todo = [1]
seen = [False] * (n + 1)
while todo:
p = todo.pop(-1)
ct[p] += o[p]
seen[p] = True
for i in g[p]:
if seen[i]:
ct[p] += ct[i]
else:
todo.append(i)
print((*ct[1:]))
| false | 9.677419 | [
"+import sys",
"+",
"+input = sys.stdin.readline"
] | false | 0.130282 | 0.037308 | 3.492033 | [
"s300928836",
"s069258970"
] |
u156163787 | p03805 | python | s833720570 | s271937091 | 33 | 29 | 3,064 | 3,060 | Accepted | Accepted | 12.12 | from itertools import permutations
n,m=list(map(int,input().split()))
es=set()
for _ in range(m):
u,v=list(map(int,input().split()))
u,v=u-1,v-1
es|={(u,v),(v,u)}
res=0
for p in permutations(list(range(n))):
if p[0]!=0: continue
if all((p[i],p[i+1]) in es for i in range(n-1)):
res+=1
print(res)
| from itertools import permutations
n,m=list(map(int,input().split()))
es=set()
for _ in range(m):
u,v=list(map(int,input().split()))
es|={(u-1,v-1),(v-1,u-1)}
print((sum(all((u,v) in es for u,v in zip(p,p[1:]))
for p in permutations(list(range(n))) if p[0]==0)))
| 15 | 10 | 322 | 272 | from itertools import permutations
n, m = list(map(int, input().split()))
es = set()
for _ in range(m):
u, v = list(map(int, input().split()))
u, v = u - 1, v - 1
es |= {(u, v), (v, u)}
res = 0
for p in permutations(list(range(n))):
if p[0] != 0:
continue
if all((p[i], p[i + 1]) in es for i in range(n - 1)):
res += 1
print(res)
| from itertools import permutations
n, m = list(map(int, input().split()))
es = set()
for _ in range(m):
u, v = list(map(int, input().split()))
es |= {(u - 1, v - 1), (v - 1, u - 1)}
print(
(
sum(
all((u, v) in es for u, v in zip(p, p[1:]))
for p in permutations(list(range(n)))
if p[0] == 0
)
)
)
| false | 33.333333 | [
"- u, v = u - 1, v - 1",
"- es |= {(u, v), (v, u)}",
"-res = 0",
"-for p in permutations(list(range(n))):",
"- if p[0] != 0:",
"- continue",
"- if all((p[i], p[i + 1]) in es for i in range(n - 1)):",
"- res += 1",
"-print(res)",
"+ es |= {(u - 1, v - 1), (v - 1, u - 1)}",
"+print(",
"+ (",
"+ sum(",
"+ all((u, v) in es for u, v in zip(p, p[1:]))",
"+ for p in permutations(list(range(n)))",
"+ if p[0] == 0",
"+ )",
"+ )",
"+)"
] | false | 0.059451 | 0.05448 | 1.091251 | [
"s833720570",
"s271937091"
] |
u970197315 | p03013 | python | s899240371 | s037188500 | 187 | 155 | 7,848 | 13,488 | Accepted | Accepted | 17.11 | n,m=list(map(int,input().split()))
dp=[0]*(n+3)
a=[int(eval(input())) for i in range(m)]
mod=10**9+7
for i in range(m):
dp[a[i]]=-1
dp[0]=1
if dp[1]!=-1:
dp[1]+=dp[0]
for i in range(n+1):
if dp[i+2]==-1:
continue
if dp[i]!=-1:
dp[i+2]+=dp[i]
if dp[i+1]!=-1:
dp[i+2]+=dp[i+1]
dp[i+2]%=mod
print((dp[n]%mod)) | n,m = list(map(int,input().split()))
a = []
stairs = [0]*(n+2)
for _ in range(m):
a = int(eval(input()))
stairs[a] = 1
mod = 10**9 + 7
dp = [0]*(n+2)
dp[0] = 1
for i in range(n):
if i <= 1:
if stairs[i+1] == 0:
dp[i+1] += dp[i]
dp[i+1] %= mod
stairs[i+1] = 1
if stairs[i+2] == 0:
dp[i+2] += dp[i+1]+dp[i]
dp[i+2] %= mod
stairs[i+2] = 1
print((dp[n]%mod))
| 20 | 23 | 361 | 450 | n, m = list(map(int, input().split()))
dp = [0] * (n + 3)
a = [int(eval(input())) for i in range(m)]
mod = 10**9 + 7
for i in range(m):
dp[a[i]] = -1
dp[0] = 1
if dp[1] != -1:
dp[1] += dp[0]
for i in range(n + 1):
if dp[i + 2] == -1:
continue
if dp[i] != -1:
dp[i + 2] += dp[i]
if dp[i + 1] != -1:
dp[i + 2] += dp[i + 1]
dp[i + 2] %= mod
print((dp[n] % mod))
| n, m = list(map(int, input().split()))
a = []
stairs = [0] * (n + 2)
for _ in range(m):
a = int(eval(input()))
stairs[a] = 1
mod = 10**9 + 7
dp = [0] * (n + 2)
dp[0] = 1
for i in range(n):
if i <= 1:
if stairs[i + 1] == 0:
dp[i + 1] += dp[i]
dp[i + 1] %= mod
stairs[i + 1] = 1
if stairs[i + 2] == 0:
dp[i + 2] += dp[i + 1] + dp[i]
dp[i + 2] %= mod
stairs[i + 2] = 1
print((dp[n] % mod))
| false | 13.043478 | [
"-dp = [0] * (n + 3)",
"-a = [int(eval(input())) for i in range(m)]",
"+a = []",
"+stairs = [0] * (n + 2)",
"+for _ in range(m):",
"+ a = int(eval(input()))",
"+ stairs[a] = 1",
"-for i in range(m):",
"- dp[a[i]] = -1",
"+dp = [0] * (n + 2)",
"-if dp[1] != -1:",
"- dp[1] += dp[0]",
"-for i in range(n + 1):",
"- if dp[i + 2] == -1:",
"- continue",
"- if dp[i] != -1:",
"- dp[i + 2] += dp[i]",
"- if dp[i + 1] != -1:",
"- dp[i + 2] += dp[i + 1]",
"- dp[i + 2] %= mod",
"+for i in range(n):",
"+ if i <= 1:",
"+ if stairs[i + 1] == 0:",
"+ dp[i + 1] += dp[i]",
"+ dp[i + 1] %= mod",
"+ stairs[i + 1] = 1",
"+ if stairs[i + 2] == 0:",
"+ dp[i + 2] += dp[i + 1] + dp[i]",
"+ dp[i + 2] %= mod",
"+ stairs[i + 2] = 1"
] | false | 0.036424 | 0.03515 | 1.036259 | [
"s899240371",
"s037188500"
] |
u494058663 | p03038 | python | s351656597 | s779716643 | 647 | 567 | 26,616 | 23,996 | Accepted | Accepted | 12.36 | import copy
N,M = list(map(int,input().split()))
A = [int(i) for i in input().split()]
A.sort()
A_copy = copy.deepcopy(A)
CB = []
for i in range(M):
b,c = list(map(int,input().split()))
CB.append([c,b])
CB.sort(reverse = True)
tmp = 0
for c,b in CB:
for i in range(b):
if tmp+i >= N:
print((sum(A)))
exit()
if A_copy[tmp+i]<c:
A[tmp+i] = c
else:
break
tmp += b
print((sum(A)))
| n,m = list(map(int,input().split()))
A = [int(i) for i in input().split()]
A.sort()
CB = []
for i in range(m):
b,c = list(map(int,input().split()))
CB.append([c,b])
CB.sort(reverse=True)
ans = sum(A)
index = 0
for c,b in CB:
for i in range(b):
if index >=n:
print(ans)
exit()
if A[index] < c:
ans += c-A[index]
A[index] = c
index += 1
else:
print(ans)
exit()
print(ans)
| 23 | 24 | 484 | 500 | import copy
N, M = list(map(int, input().split()))
A = [int(i) for i in input().split()]
A.sort()
A_copy = copy.deepcopy(A)
CB = []
for i in range(M):
b, c = list(map(int, input().split()))
CB.append([c, b])
CB.sort(reverse=True)
tmp = 0
for c, b in CB:
for i in range(b):
if tmp + i >= N:
print((sum(A)))
exit()
if A_copy[tmp + i] < c:
A[tmp + i] = c
else:
break
tmp += b
print((sum(A)))
| n, m = list(map(int, input().split()))
A = [int(i) for i in input().split()]
A.sort()
CB = []
for i in range(m):
b, c = list(map(int, input().split()))
CB.append([c, b])
CB.sort(reverse=True)
ans = sum(A)
index = 0
for c, b in CB:
for i in range(b):
if index >= n:
print(ans)
exit()
if A[index] < c:
ans += c - A[index]
A[index] = c
index += 1
else:
print(ans)
exit()
print(ans)
| false | 4.166667 | [
"-import copy",
"-",
"-N, M = list(map(int, input().split()))",
"+n, m = list(map(int, input().split()))",
"-A_copy = copy.deepcopy(A)",
"-for i in range(M):",
"+for i in range(m):",
"-tmp = 0",
"+ans = sum(A)",
"+index = 0",
"- if tmp + i >= N:",
"- print((sum(A)))",
"+ if index >= n:",
"+ print(ans)",
"- if A_copy[tmp + i] < c:",
"- A[tmp + i] = c",
"+ if A[index] < c:",
"+ ans += c - A[index]",
"+ A[index] = c",
"+ index += 1",
"- break",
"- tmp += b",
"-print((sum(A)))",
"+ print(ans)",
"+ exit()",
"+print(ans)"
] | false | 0.127684 | 0.041704 | 3.061642 | [
"s351656597",
"s779716643"
] |
u164727245 | p02689 | python | s901786989 | s955201735 | 352 | 174 | 67,612 | 37,208 | Accepted | Accepted | 50.57 | # coding: utf-8
def solve(*args: str) -> str:
n, m = list(map(int, args[0].split()))
H = list(map(int, args[1].split()))
AB = [tuple(map(int, ab.split())) for ab in args[2:]]
R = [set() for _ in range(n)]
for a, b in AB:
R[a-1].add(b-1)
R[b-1].add(a-1)
ret = 0
for i, D in enumerate(R):
if len(D) == 0 or max([H[d] for d in D]) < H[i]:
ret += 1
return str(ret)
if __name__ == "__main__":
print((solve(*(open(0).read().splitlines()))))
| # coding: utf-8
def solve(*args: str) -> str:
n, m = list(map(int, args[0].split()))
H = [0]+list(map(int, args[1].split()))
AB = [tuple(map(int, ab.split())) for ab in args[2:]]
G = [True]*(n+1)
for a, b in AB:
G[a] &= H[b] < H[a]
G[b] &= H[a] < H[b]
return str(sum(G[1:]))
if __name__ == "__main__":
print((solve(*(open(0).read().splitlines()))))
| 23 | 18 | 528 | 408 | # coding: utf-8
def solve(*args: str) -> str:
n, m = list(map(int, args[0].split()))
H = list(map(int, args[1].split()))
AB = [tuple(map(int, ab.split())) for ab in args[2:]]
R = [set() for _ in range(n)]
for a, b in AB:
R[a - 1].add(b - 1)
R[b - 1].add(a - 1)
ret = 0
for i, D in enumerate(R):
if len(D) == 0 or max([H[d] for d in D]) < H[i]:
ret += 1
return str(ret)
if __name__ == "__main__":
print((solve(*(open(0).read().splitlines()))))
| # coding: utf-8
def solve(*args: str) -> str:
n, m = list(map(int, args[0].split()))
H = [0] + list(map(int, args[1].split()))
AB = [tuple(map(int, ab.split())) for ab in args[2:]]
G = [True] * (n + 1)
for a, b in AB:
G[a] &= H[b] < H[a]
G[b] &= H[a] < H[b]
return str(sum(G[1:]))
if __name__ == "__main__":
print((solve(*(open(0).read().splitlines()))))
| false | 21.73913 | [
"- H = list(map(int, args[1].split()))",
"+ H = [0] + list(map(int, args[1].split()))",
"- R = [set() for _ in range(n)]",
"+ G = [True] * (n + 1)",
"- R[a - 1].add(b - 1)",
"- R[b - 1].add(a - 1)",
"- ret = 0",
"- for i, D in enumerate(R):",
"- if len(D) == 0 or max([H[d] for d in D]) < H[i]:",
"- ret += 1",
"- return str(ret)",
"+ G[a] &= H[b] < H[a]",
"+ G[b] &= H[a] < H[b]",
"+ return str(sum(G[1:]))"
] | false | 0.04642 | 0.117667 | 0.394503 | [
"s901786989",
"s955201735"
] |
u516272298 | p03360 | python | s941124052 | s846223992 | 20 | 17 | 3,060 | 2,940 | Accepted | Accepted | 15 | a,b,c = list(map(int,input().split()))
k = int(eval(input()))
print((a+b+c+max(a,b,c)*2**k-max(a,b,c))) | a,b,c = list(map(int,input().split()))
k = int(eval(input()))
l = [a,b,c]
print((max(l)*2**k + sum(l) - max(l))) | 3 | 4 | 97 | 101 | a, b, c = list(map(int, input().split()))
k = int(eval(input()))
print((a + b + c + max(a, b, c) * 2**k - max(a, b, c)))
| a, b, c = list(map(int, input().split()))
k = int(eval(input()))
l = [a, b, c]
print((max(l) * 2**k + sum(l) - max(l)))
| false | 25 | [
"-print((a + b + c + max(a, b, c) * 2**k - max(a, b, c)))",
"+l = [a, b, c]",
"+print((max(l) * 2**k + sum(l) - max(l)))"
] | false | 0.039237 | 0.040245 | 0.974964 | [
"s941124052",
"s846223992"
] |
u970197315 | p02995 | python | s960143483 | s474829122 | 40 | 35 | 5,076 | 5,076 | Accepted | Accepted | 12.5 | # ABC131 C Anti-Division
from fractions import gcd
a,b,c,d = list(map(int,input().split()))
n = b-a+1
cd = (c*d)//gcd(c,d)
a_c = (a-1)//c
a_d = (a-1)//d
a_cd = (a-1)//cd
b_c = b//c
b_d = b//d
b_cd = b//cd
print((n- ((b_c-a_c)+(b_d-a_d)-((b_cd-a_cd))))) | from fractions import gcd
a,b,c,d=list(map(int,input().split()))
cd=(c*d)//gcd(c,d)
bc=b//c
bd=b//d
bcd=b//(cd)
b_cnt=b-(bc+bd-bcd)
ac=(a-1)//c
ad=(a-1)//d
acd=(a-1)//(cd)
a_cnt=a-1-(ac+ad-acd)
print((b_cnt-a_cnt)) | 15 | 15 | 261 | 223 | # ABC131 C Anti-Division
from fractions import gcd
a, b, c, d = list(map(int, input().split()))
n = b - a + 1
cd = (c * d) // gcd(c, d)
a_c = (a - 1) // c
a_d = (a - 1) // d
a_cd = (a - 1) // cd
b_c = b // c
b_d = b // d
b_cd = b // cd
print((n - ((b_c - a_c) + (b_d - a_d) - ((b_cd - a_cd)))))
| from fractions import gcd
a, b, c, d = list(map(int, input().split()))
cd = (c * d) // gcd(c, d)
bc = b // c
bd = b // d
bcd = b // (cd)
b_cnt = b - (bc + bd - bcd)
ac = (a - 1) // c
ad = (a - 1) // d
acd = (a - 1) // (cd)
a_cnt = a - 1 - (ac + ad - acd)
print((b_cnt - a_cnt))
| false | 0 | [
"-# ABC131 C Anti-Division",
"-n = b - a + 1",
"-a_c = (a - 1) // c",
"-a_d = (a - 1) // d",
"-a_cd = (a - 1) // cd",
"-b_c = b // c",
"-b_d = b // d",
"-b_cd = b // cd",
"-print((n - ((b_c - a_c) + (b_d - a_d) - ((b_cd - a_cd)))))",
"+bc = b // c",
"+bd = b // d",
"+bcd = b // (cd)",
"+b_cnt = b - (bc + bd - bcd)",
"+ac = (a - 1) // c",
"+ad = (a - 1) // d",
"+acd = (a - 1) // (cd)",
"+a_cnt = a - 1 - (ac + ad - acd)",
"+print((b_cnt - a_cnt))"
] | false | 0.048598 | 0.058377 | 0.832487 | [
"s960143483",
"s474829122"
] |
u156815136 | p02879 | python | s225709205 | s697348500 | 35 | 20 | 5,048 | 3,316 | Accepted | Accepted | 42.86 | import itertools
import fractions
def main():
a,b = list(map(int,input().split()))
print((a*b if a<10 and b<10 else -1))
if __name__ == '__main__':
main() | #from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import defaultdict
#import bisect
#
# d = m - k[i] - k[j]
# if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも!!
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
return list(map(int,input().split()))
def I():
return int(eval(input()))
a,b = readInts()
if 1 <= a <= 9 and 1 <= b <= 9:
print((a*b))
else:
print((-1)) | 7 | 31 | 158 | 691 | import itertools
import fractions
def main():
a, b = list(map(int, input().split()))
print((a * b if a < 10 and b < 10 else -1))
if __name__ == "__main__":
main()
| # from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
# from fractions import gcd
# from itertools import combinations # (string,3) 3回
# from collections import deque
from collections import defaultdict
# import bisect
#
# d = m - k[i] - k[j]
# if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも!!
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
# mod = 9982443453
def readInts():
return list(map(int, input().split()))
def I():
return int(eval(input()))
a, b = readInts()
if 1 <= a <= 9 and 1 <= b <= 9:
print((a * b))
else:
print((-1))
| false | 77.419355 | [
"-import itertools",
"-import fractions",
"+# from statistics import median",
"+# import collections",
"+# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]",
"+# from fractions import gcd",
"+# from itertools import combinations # (string,3) 3回",
"+# from collections import deque",
"+from collections import defaultdict",
"+",
"+# import bisect",
"+#",
"+# d = m - k[i] - k[j]",
"+# if kk[bisect.bisect_right(kk,d) - 1] == d:",
"+#",
"+#",
"+#",
"+# pythonで無理なときは、pypyでやると正解するかも!!",
"+#",
"+#",
"+import sys",
"+",
"+sys.setrecursionlimit(10000000)",
"+mod = 10**9 + 7",
"+# mod = 9982443453",
"+def readInts():",
"+ return list(map(int, input().split()))",
"-def main():",
"- a, b = list(map(int, input().split()))",
"- print((a * b if a < 10 and b < 10 else -1))",
"+def I():",
"+ return int(eval(input()))",
"-if __name__ == \"__main__\":",
"- main()",
"+a, b = readInts()",
"+if 1 <= a <= 9 and 1 <= b <= 9:",
"+ print((a * b))",
"+else:",
"+ print((-1))"
] | false | 0.035189 | 0.042463 | 0.828693 | [
"s225709205",
"s697348500"
] |
u133936772 | p02923 | python | s030213194 | s019893441 | 89 | 80 | 14,252 | 11,136 | Accepted | Accepted | 10.11 | n = int(eval(input()))
l = list(map(int, input().split()))
cnt = 0
ans = 0
for i in range(n-1):
if l[i] < l[i+1]:
cnt = 0
else:
cnt += 1
ans = max(ans, cnt)
print(ans) | eval(input())
a=c=t=0
for i in map(int,input().split()):
if i>t: c=0
else: c+=1; a=max(a,c)
t=i
print(a) | 14 | 7 | 193 | 110 | n = int(eval(input()))
l = list(map(int, input().split()))
cnt = 0
ans = 0
for i in range(n - 1):
if l[i] < l[i + 1]:
cnt = 0
else:
cnt += 1
ans = max(ans, cnt)
print(ans)
| eval(input())
a = c = t = 0
for i in map(int, input().split()):
if i > t:
c = 0
else:
c += 1
a = max(a, c)
t = i
print(a)
| false | 50 | [
"-n = int(eval(input()))",
"-l = list(map(int, input().split()))",
"-cnt = 0",
"-ans = 0",
"-for i in range(n - 1):",
"- if l[i] < l[i + 1]:",
"- cnt = 0",
"+eval(input())",
"+a = c = t = 0",
"+for i in map(int, input().split()):",
"+ if i > t:",
"+ c = 0",
"- cnt += 1",
"- ans = max(ans, cnt)",
"-print(ans)",
"+ c += 1",
"+ a = max(a, c)",
"+ t = i",
"+print(a)"
] | false | 0.045798 | 0.085459 | 0.535906 | [
"s030213194",
"s019893441"
] |
u130900604 | p03339 | python | s884217987 | s424599468 | 282 | 153 | 33,140 | 21,428 | Accepted | Accepted | 45.74 | n=int(eval(input()))
s=eval(input())
e=[int("E"==i) for i in s]
for i in range(1,n):
e[i]+=e[i-1]
ans=[]
for j in range(n):
left=j-0
right=n-j-1
# leftにWは何個?
# leftのEは、
if j-1>=0:
etmp=e[j-1]
else:
etmp=0
leftw=left-etmp
# rightにEは何個?
# rightのEは、
eee=e[n-1]-e[j]
ans+=(leftw+eee),
print((min(ans)))
| """
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
int main()
{
long N;
std::cin >> N;
std::string S;
std::cin >> S;
long count=0;
std::vector<long> counters;
for(long i=1; i<N; i++){
if(S[i]=='E'){
count++;
}
}
counters.push_back(count);
for(long i=1; i<N; i++){
if(S[i]=='E'){
count-=1;
}
if(S[i-1]=='W'){
count++;
}
counters.push_back(count);
}
std::sort(counters.begin(),counters.end());
std::cout << counters[0] << std::endl;
return 0;
}
"""
n=int(eval(input()))
s=eval(input())
cnt=0
for i in range(1,n):
if s[i]=="E":cnt+=1
ans=[]
ans.append(cnt)
for i in range(1,n):
if s[i]=="E":
cnt-=1
if s[i-1]=="W":
cnt+=1
ans.append(cnt)
print((min(ans)))
| 24 | 48 | 339 | 898 | n = int(eval(input()))
s = eval(input())
e = [int("E" == i) for i in s]
for i in range(1, n):
e[i] += e[i - 1]
ans = []
for j in range(n):
left = j - 0
right = n - j - 1
# leftにWは何個?
# leftのEは、
if j - 1 >= 0:
etmp = e[j - 1]
else:
etmp = 0
leftw = left - etmp
# rightにEは何個?
# rightのEは、
eee = e[n - 1] - e[j]
ans += ((leftw + eee),)
print((min(ans)))
| """
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
int main()
{
long N;
std::cin >> N;
std::string S;
std::cin >> S;
long count=0;
std::vector<long> counters;
for(long i=1; i<N; i++){
if(S[i]=='E'){
count++;
}
}
counters.push_back(count);
for(long i=1; i<N; i++){
if(S[i]=='E'){
count-=1;
}
if(S[i-1]=='W'){
count++;
}
counters.push_back(count);
}
std::sort(counters.begin(),counters.end());
std::cout << counters[0] << std::endl;
return 0;
}
"""
n = int(eval(input()))
s = eval(input())
cnt = 0
for i in range(1, n):
if s[i] == "E":
cnt += 1
ans = []
ans.append(cnt)
for i in range(1, n):
if s[i] == "E":
cnt -= 1
if s[i - 1] == "W":
cnt += 1
ans.append(cnt)
print((min(ans)))
| false | 50 | [
"+\"\"\"",
"+#include <iostream>",
"+#include <cmath>",
"+#include <vector>",
"+#include <algorithm>",
"+#include <iomanip>",
"+int main()",
"+{",
"+ long N;",
"+ std::cin >> N;",
"+ std::string S;",
"+ std::cin >> S;",
"+ long count=0;",
"+ std::vector<long> counters;",
"+ for(long i=1; i<N; i++){",
"+ if(S[i]=='E'){",
"+ count++;",
"+ }",
"+ }",
"+ counters.push_back(count);",
"+ for(long i=1; i<N; i++){",
"+ if(S[i]=='E'){",
"+ count-=1;",
"+ }",
"+ if(S[i-1]=='W'){",
"+ count++;",
"+ }",
"+ counters.push_back(count);",
"+ }",
"+ std::sort(counters.begin(),counters.end());",
"+ std::cout << counters[0] << std::endl;",
"+ return 0;",
"+}",
"+\"\"\"",
"-e = [int(\"E\" == i) for i in s]",
"+cnt = 0",
"- e[i] += e[i - 1]",
"+ if s[i] == \"E\":",
"+ cnt += 1",
"-for j in range(n):",
"- left = j - 0",
"- right = n - j - 1",
"- # leftにWは何個?",
"- # leftのEは、",
"- if j - 1 >= 0:",
"- etmp = e[j - 1]",
"- else:",
"- etmp = 0",
"- leftw = left - etmp",
"- # rightにEは何個?",
"- # rightのEは、",
"- eee = e[n - 1] - e[j]",
"- ans += ((leftw + eee),)",
"+ans.append(cnt)",
"+for i in range(1, n):",
"+ if s[i] == \"E\":",
"+ cnt -= 1",
"+ if s[i - 1] == \"W\":",
"+ cnt += 1",
"+ ans.append(cnt)"
] | false | 0.043979 | 0.119234 | 0.368845 | [
"s884217987",
"s424599468"
] |
u225388820 | p04001 | python | s455939560 | s730008219 | 175 | 19 | 39,280 | 3,060 | Accepted | Accepted | 89.14 | s=eval(input())
n=len(s)
a=2**(n-1)
t = [bin(i)[2:] for i in range(a)]
for i in range(a):
t[i]='0'*(n-1-len(t[i]))+t[i]
t[i]=t[i][::-1]
ans=0
#print(s)
#print(t)
for i in range(a):
k=0
for j in range(n-1):
if t[i][j]=="1":
ans+=int(s[k:j+1])
#print(s[k:j+1])
k=j+1
#print(ans,i,j)
#print("ah",s[k:n])
ans+=int(s[k:n])
print(ans) | s=eval(input())
n=len(s)-1
ans=0
for i in range(2**n):
k=0
for j in range(n):
if (i>>j)&1:
ans+=int(s[k:j+1])
k=j+1
ans+=int(s[k:])
print(ans) | 21 | 11 | 423 | 190 | s = eval(input())
n = len(s)
a = 2 ** (n - 1)
t = [bin(i)[2:] for i in range(a)]
for i in range(a):
t[i] = "0" * (n - 1 - len(t[i])) + t[i]
t[i] = t[i][::-1]
ans = 0
# print(s)
# print(t)
for i in range(a):
k = 0
for j in range(n - 1):
if t[i][j] == "1":
ans += int(s[k : j + 1])
# print(s[k:j+1])
k = j + 1
# print(ans,i,j)
# print("ah",s[k:n])
ans += int(s[k:n])
print(ans)
| s = eval(input())
n = len(s) - 1
ans = 0
for i in range(2**n):
k = 0
for j in range(n):
if (i >> j) & 1:
ans += int(s[k : j + 1])
k = j + 1
ans += int(s[k:])
print(ans)
| false | 47.619048 | [
"-n = len(s)",
"-a = 2 ** (n - 1)",
"-t = [bin(i)[2:] for i in range(a)]",
"-for i in range(a):",
"- t[i] = \"0\" * (n - 1 - len(t[i])) + t[i]",
"- t[i] = t[i][::-1]",
"+n = len(s) - 1",
"-# print(s)",
"-# print(t)",
"-for i in range(a):",
"+for i in range(2**n):",
"- for j in range(n - 1):",
"- if t[i][j] == \"1\":",
"+ for j in range(n):",
"+ if (i >> j) & 1:",
"- # print(s[k:j+1])",
"- # print(ans,i,j)",
"- # print(\"ah\",s[k:n])",
"- ans += int(s[k:n])",
"+ ans += int(s[k:])"
] | false | 0.117054 | 0.169478 | 0.690675 | [
"s455939560",
"s730008219"
] |
u257162238 | p03078 | python | s734881301 | s592163780 | 1,131 | 45 | 69,092 | 10,768 | Accepted | Accepted | 96.02 | import sys
input = sys.stdin.readline
from itertools import product
def read():
X, Y, Z, K = list(map(int, input().strip().split()))
A = list(map(int, input().strip().split()))
B = list(map(int, input().strip().split()))
C = list(map(int, input().strip().split()))
return X, Y, Z, K, A, B, C
def solve(X, Y, Z, K, A, B, C, INF=10000000001):
# 美味しさの上位K=3000件を出力する
AB = [a+b for a, b in product(A, B)]
AB.sort(reverse=True)
AB = AB[:K]
C.sort(reverse=True)
D = [AB[k] + C[0] for k in range(len(AB))]
E = [0 for k in range(len(AB))]
j = 0
for k in range(K):
hi = 0
# find
for i in range(len(D)):
if D[hi] < D[i]:
hi = i
# print
print((D[hi]))
# update
E[hi] += 1
if E[hi] >= len(C):
D[hi] = -INF
else:
D[hi] = AB[hi] + C[E[hi]]
if __name__ == '__main__':
inputs = read()
solve(*inputs)
| import sys
input = sys.stdin.readline
import heapq
from collections import defaultdict
def read():
X, Y, Z, K = list(map(int, input().strip().split()))
A = list(map(int, input().strip().split()))
B = list(map(int, input().strip().split()))
C = list(map(int, input().strip().split()))
return X, Y, Z, K, A, B, C
def solve(X, Y, Z, K, A, B, C, INF=10000000001):
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
used = defaultdict(bool)
h = []
p, q, r = 0, 0, 0
heapq.heappush(h, (-A[p] - B[q] - C[r], p, q, r))
used[(p, q, r)] = True
for k in range(K):
a, p, q, r = heapq.heappop(h)
print((-a))
if p+1 < len(A) and not used[(p+1, q, r)]:
heapq.heappush(h, (-A[p+1] - B[q] - C[r], p+1, q, r))
used[(p+1, q, r)] = True
if q+1 < len(B) and not used[(p, q+1, r)]:
heapq.heappush(h, (-A[p] - B[q+1] - C[r], p, q+1, r))
used[(p, q+1, r)] = True
if r+1 < len(C) and not used[(p, q, r+1)]:
heapq.heappush(h, (-A[p] - B[q] - C[r+1], p, q, r+1))
used[(p, q, r+1)] = True
if __name__ == '__main__':
inputs = read()
solve(*inputs)
| 44 | 41 | 1,015 | 1,250 | import sys
input = sys.stdin.readline
from itertools import product
def read():
X, Y, Z, K = list(map(int, input().strip().split()))
A = list(map(int, input().strip().split()))
B = list(map(int, input().strip().split()))
C = list(map(int, input().strip().split()))
return X, Y, Z, K, A, B, C
def solve(X, Y, Z, K, A, B, C, INF=10000000001):
# 美味しさの上位K=3000件を出力する
AB = [a + b for a, b in product(A, B)]
AB.sort(reverse=True)
AB = AB[:K]
C.sort(reverse=True)
D = [AB[k] + C[0] for k in range(len(AB))]
E = [0 for k in range(len(AB))]
j = 0
for k in range(K):
hi = 0
# find
for i in range(len(D)):
if D[hi] < D[i]:
hi = i
# print
print((D[hi]))
# update
E[hi] += 1
if E[hi] >= len(C):
D[hi] = -INF
else:
D[hi] = AB[hi] + C[E[hi]]
if __name__ == "__main__":
inputs = read()
solve(*inputs)
| import sys
input = sys.stdin.readline
import heapq
from collections import defaultdict
def read():
X, Y, Z, K = list(map(int, input().strip().split()))
A = list(map(int, input().strip().split()))
B = list(map(int, input().strip().split()))
C = list(map(int, input().strip().split()))
return X, Y, Z, K, A, B, C
def solve(X, Y, Z, K, A, B, C, INF=10000000001):
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
used = defaultdict(bool)
h = []
p, q, r = 0, 0, 0
heapq.heappush(h, (-A[p] - B[q] - C[r], p, q, r))
used[(p, q, r)] = True
for k in range(K):
a, p, q, r = heapq.heappop(h)
print((-a))
if p + 1 < len(A) and not used[(p + 1, q, r)]:
heapq.heappush(h, (-A[p + 1] - B[q] - C[r], p + 1, q, r))
used[(p + 1, q, r)] = True
if q + 1 < len(B) and not used[(p, q + 1, r)]:
heapq.heappush(h, (-A[p] - B[q + 1] - C[r], p, q + 1, r))
used[(p, q + 1, r)] = True
if r + 1 < len(C) and not used[(p, q, r + 1)]:
heapq.heappush(h, (-A[p] - B[q] - C[r + 1], p, q, r + 1))
used[(p, q, r + 1)] = True
if __name__ == "__main__":
inputs = read()
solve(*inputs)
| false | 6.818182 | [
"-from itertools import product",
"+import heapq",
"+from collections import defaultdict",
"- # 美味しさの上位K=3000件を出力する",
"- AB = [a + b for a, b in product(A, B)]",
"- AB.sort(reverse=True)",
"- AB = AB[:K]",
"+ A.sort(reverse=True)",
"+ B.sort(reverse=True)",
"- D = [AB[k] + C[0] for k in range(len(AB))]",
"- E = [0 for k in range(len(AB))]",
"- j = 0",
"+ used = defaultdict(bool)",
"+ h = []",
"+ p, q, r = 0, 0, 0",
"+ heapq.heappush(h, (-A[p] - B[q] - C[r], p, q, r))",
"+ used[(p, q, r)] = True",
"- hi = 0",
"- # find",
"- for i in range(len(D)):",
"- if D[hi] < D[i]:",
"- hi = i",
"- # print",
"- print((D[hi]))",
"- # update",
"- E[hi] += 1",
"- if E[hi] >= len(C):",
"- D[hi] = -INF",
"- else:",
"- D[hi] = AB[hi] + C[E[hi]]",
"+ a, p, q, r = heapq.heappop(h)",
"+ print((-a))",
"+ if p + 1 < len(A) and not used[(p + 1, q, r)]:",
"+ heapq.heappush(h, (-A[p + 1] - B[q] - C[r], p + 1, q, r))",
"+ used[(p + 1, q, r)] = True",
"+ if q + 1 < len(B) and not used[(p, q + 1, r)]:",
"+ heapq.heappush(h, (-A[p] - B[q + 1] - C[r], p, q + 1, r))",
"+ used[(p, q + 1, r)] = True",
"+ if r + 1 < len(C) and not used[(p, q, r + 1)]:",
"+ heapq.heappush(h, (-A[p] - B[q] - C[r + 1], p, q, r + 1))",
"+ used[(p, q, r + 1)] = True"
] | false | 0.080911 | 0.03559 | 2.273455 | [
"s734881301",
"s592163780"
] |
u320511454 | p03060 | python | s344919578 | s480889871 | 359 | 26 | 73,000 | 9,180 | Accepted | Accepted | 92.76 | import itertools
n=int(eval(input()))
lis=[list(map(int,input().split())) for _ in range(2)]
ans=0
for li in itertools.product([0,1], repeat=n):
v=0
for id,l in enumerate(li):
if l:
v += lis[0][id] - lis[1][id]
if v > ans:
ans=v
print(ans) | n,a=int(eval(input())),0
V=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=[0 for _ in range(n)]
for i in range(n):
ans = V[i] - C[i]
if ans > 0:
a += ans
print(a) | 16 | 11 | 282 | 199 | import itertools
n = int(eval(input()))
lis = [list(map(int, input().split())) for _ in range(2)]
ans = 0
for li in itertools.product([0, 1], repeat=n):
v = 0
for id, l in enumerate(li):
if l:
v += lis[0][id] - lis[1][id]
if v > ans:
ans = v
print(ans)
| n, a = int(eval(input())), 0
V = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = [0 for _ in range(n)]
for i in range(n):
ans = V[i] - C[i]
if ans > 0:
a += ans
print(a)
| false | 31.25 | [
"-import itertools",
"-",
"-n = int(eval(input()))",
"-lis = [list(map(int, input().split())) for _ in range(2)]",
"-ans = 0",
"-for li in itertools.product([0, 1], repeat=n):",
"- v = 0",
"- for id, l in enumerate(li):",
"- if l:",
"- v += lis[0][id] - lis[1][id]",
"- if v > ans:",
"- ans = v",
"-print(ans)",
"+n, a = int(eval(input())), 0",
"+V = list(map(int, input().split()))",
"+C = list(map(int, input().split()))",
"+ans = [0 for _ in range(n)]",
"+for i in range(n):",
"+ ans = V[i] - C[i]",
"+ if ans > 0:",
"+ a += ans",
"+print(a)"
] | false | 0.032281 | 0.035901 | 0.899179 | [
"s344919578",
"s480889871"
] |
u562935282 | p03796 | python | s349802236 | s025018042 | 43 | 39 | 2,940 | 3,572 | Accepted | Accepted | 9.3 | n = int(eval(input()))
ans = 1
for i in range(1, n + 1):
ans *= i
ans %= 10**9 + 7
print(ans) | from functools import reduce
def main():
from functools import reduce
MOD = 10 ** 9 + 7
def mod_mul(a, b):
return a * b % MOD
N = int(eval(input()))
ans = reduce(mod_mul, list(range(1, N + 1)))
print(ans)
if __name__ == '__main__':
main()
# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())
| 6 | 24 | 100 | 396 | n = int(eval(input()))
ans = 1
for i in range(1, n + 1):
ans *= i
ans %= 10**9 + 7
print(ans)
| from functools import reduce
def main():
from functools import reduce
MOD = 10**9 + 7
def mod_mul(a, b):
return a * b % MOD
N = int(eval(input()))
ans = reduce(mod_mul, list(range(1, N + 1)))
print(ans)
if __name__ == "__main__":
main()
# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())
| false | 75 | [
"-n = int(eval(input()))",
"-ans = 1",
"-for i in range(1, n + 1):",
"- ans *= i",
"- ans %= 10**9 + 7",
"-print(ans)",
"+from functools import reduce",
"+",
"+",
"+def main():",
"+ from functools import reduce",
"+",
"+ MOD = 10**9 + 7",
"+",
"+ def mod_mul(a, b):",
"+ return a * b % MOD",
"+",
"+ N = int(eval(input()))",
"+ ans = reduce(mod_mul, list(range(1, N + 1)))",
"+ print(ans)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()",
"+# import sys",
"+#",
"+# sys.setrecursionlimit(10 ** 7)",
"+#",
"+# input = sys.stdin.readline",
"+# rstrip()",
"+# int(input())",
"+# map(int, input().split())"
] | false | 0.057279 | 0.057095 | 1.003215 | [
"s349802236",
"s025018042"
] |
u498487134 | p03044 | python | s528325235 | s389133215 | 762 | 470 | 79,276 | 99,148 | Accepted | Accepted | 38.32 | import queue
import sys
input = sys.stdin.readline
N=int(input())
adj=[[] for _ in range(N)]
for i in range(N-1):
u,vv,w=map(int,input().split())
u-=1
vv-=1
adj[u].append((vv,w%2))
adj[vv].append((u,w%2))
q=queue.Queue()
ans=[0]*N
q.put((0,-1,0))#v,par,col
while not q.empty():
v,p,c=q.get()
for i in range(len(adj[v])):
n_v=adj[v][i][0]
if n_v!=p:
n_c=(c+adj[v][i][1])%2
ans[n_v]=n_c
q.put((n_v,v,n_c))
[print(ans[i]) for i in range(N)]
| import sys
input = sys.stdin.readline
def I(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))
def main():
mod=10**9+7
N=I()
adj=[[]for _ in range(N)]
for i in range(N-1):
u,v,w=MI()
u-=1
v-=1
adj[u].append((v,w))
adj[v].append((u,w))
ans=[-1]*N
import queue
q=queue.Queue()
q.put(0)
ans[0]=0
while not q.empty():
v=q.get()
for nv,w in adj[v]:
if ans[nv]==-1:
if ans[v]==0 and w%2==0:
ans[nv]=0
elif ans[v]==0 and w%2==1:
ans[nv]=1
elif ans[v]==1 and w%2==0:
ans[nv]=1
else:
ans[nv]=0
q.put(nv)
for i in range(N):
print((ans[i]))
main()
| 29 | 46 | 563 | 978 | import queue
import sys
input = sys.stdin.readline
N = int(input())
adj = [[] for _ in range(N)]
for i in range(N - 1):
u, vv, w = map(int, input().split())
u -= 1
vv -= 1
adj[u].append((vv, w % 2))
adj[vv].append((u, w % 2))
q = queue.Queue()
ans = [0] * N
q.put((0, -1, 0)) # v,par,col
while not q.empty():
v, p, c = q.get()
for i in range(len(adj[v])):
n_v = adj[v][i][0]
if n_v != p:
n_c = (c + adj[v][i][1]) % 2
ans[n_v] = n_c
q.put((n_v, v, n_c))
[print(ans[i]) for i in range(N)]
| import sys
input = sys.stdin.readline
def I():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def LI():
return list(map(int, input().split()))
def main():
mod = 10**9 + 7
N = I()
adj = [[] for _ in range(N)]
for i in range(N - 1):
u, v, w = MI()
u -= 1
v -= 1
adj[u].append((v, w))
adj[v].append((u, w))
ans = [-1] * N
import queue
q = queue.Queue()
q.put(0)
ans[0] = 0
while not q.empty():
v = q.get()
for nv, w in adj[v]:
if ans[nv] == -1:
if ans[v] == 0 and w % 2 == 0:
ans[nv] = 0
elif ans[v] == 0 and w % 2 == 1:
ans[nv] = 1
elif ans[v] == 1 and w % 2 == 0:
ans[nv] = 1
else:
ans[nv] = 0
q.put(nv)
for i in range(N):
print((ans[i]))
main()
| false | 36.956522 | [
"-import queue",
"-N = int(input())",
"-adj = [[] for _ in range(N)]",
"-for i in range(N - 1):",
"- u, vv, w = map(int, input().split())",
"- u -= 1",
"- vv -= 1",
"- adj[u].append((vv, w % 2))",
"- adj[vv].append((u, w % 2))",
"-q = queue.Queue()",
"-ans = [0] * N",
"-q.put((0, -1, 0)) # v,par,col",
"-while not q.empty():",
"- v, p, c = q.get()",
"- for i in range(len(adj[v])):",
"- n_v = adj[v][i][0]",
"- if n_v != p:",
"- n_c = (c + adj[v][i][1]) % 2",
"- ans[n_v] = n_c",
"- q.put((n_v, v, n_c))",
"-[print(ans[i]) for i in range(N)]",
"+",
"+",
"+def I():",
"+ return int(eval(input()))",
"+",
"+",
"+def MI():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def LI():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def main():",
"+ mod = 10**9 + 7",
"+ N = I()",
"+ adj = [[] for _ in range(N)]",
"+ for i in range(N - 1):",
"+ u, v, w = MI()",
"+ u -= 1",
"+ v -= 1",
"+ adj[u].append((v, w))",
"+ adj[v].append((u, w))",
"+ ans = [-1] * N",
"+ import queue",
"+",
"+ q = queue.Queue()",
"+ q.put(0)",
"+ ans[0] = 0",
"+ while not q.empty():",
"+ v = q.get()",
"+ for nv, w in adj[v]:",
"+ if ans[nv] == -1:",
"+ if ans[v] == 0 and w % 2 == 0:",
"+ ans[nv] = 0",
"+ elif ans[v] == 0 and w % 2 == 1:",
"+ ans[nv] = 1",
"+ elif ans[v] == 1 and w % 2 == 0:",
"+ ans[nv] = 1",
"+ else:",
"+ ans[nv] = 0",
"+ q.put(nv)",
"+ for i in range(N):",
"+ print((ans[i]))",
"+",
"+",
"+main()"
] | false | 0.089782 | 0.09043 | 0.992837 | [
"s528325235",
"s389133215"
] |
u989345508 | p02688 | python | s781247386 | s156215445 | 24 | 22 | 9,116 | 9,036 | Accepted | Accepted | 8.33 | n,k=list(map(int,input().split()))
ans=[0]*n
for i in range(k):
d=int(eval(input()))
a=list(map(int,input().split()))
for j in a:
ans[j-1]=1
print((n-sum(ans)))
| N, K = list(map(int, input().split()))
A = set()
for _ in range(K):
d = eval(input())
A = A.union(set(map(int, input().split())))
print((N - len(A))) | 9 | 6 | 176 | 144 | n, k = list(map(int, input().split()))
ans = [0] * n
for i in range(k):
d = int(eval(input()))
a = list(map(int, input().split()))
for j in a:
ans[j - 1] = 1
print((n - sum(ans)))
| N, K = list(map(int, input().split()))
A = set()
for _ in range(K):
d = eval(input())
A = A.union(set(map(int, input().split())))
print((N - len(A)))
| false | 33.333333 | [
"-n, k = list(map(int, input().split()))",
"-ans = [0] * n",
"-for i in range(k):",
"- d = int(eval(input()))",
"- a = list(map(int, input().split()))",
"- for j in a:",
"- ans[j - 1] = 1",
"-print((n - sum(ans)))",
"+N, K = list(map(int, input().split()))",
"+A = set()",
"+for _ in range(K):",
"+ d = eval(input())",
"+ A = A.union(set(map(int, input().split())))",
"+print((N - len(A)))"
] | false | 0.04247 | 0.15808 | 0.268659 | [
"s781247386",
"s156215445"
] |
u589886885 | p02380 | python | s946697673 | s115048833 | 40 | 20 | 7,912 | 7,896 | Accepted | Accepted | 50 | import math
import sys
a, b, C = [int(x) for x in sys.stdin.readline().split()]
C = math.radians(C)
l = a + b + math.sqrt(a * a + b * b - 2 * a * b * math.cos(C))
h = b * math.sin(C)
s = a * h / 2
print(s)
print(l)
print(h) | import math
a, b, C = [int(x) for x in input().split()]
C = math.radians(C)
l = a + b + math.sqrt(a * a + b * b - 2 * a * b * math.cos(C))
h = b * math.sin(C)
s = a * h / 2
print(s)
print(l)
print(h) | 11 | 10 | 234 | 209 | import math
import sys
a, b, C = [int(x) for x in sys.stdin.readline().split()]
C = math.radians(C)
l = a + b + math.sqrt(a * a + b * b - 2 * a * b * math.cos(C))
h = b * math.sin(C)
s = a * h / 2
print(s)
print(l)
print(h)
| import math
a, b, C = [int(x) for x in input().split()]
C = math.radians(C)
l = a + b + math.sqrt(a * a + b * b - 2 * a * b * math.cos(C))
h = b * math.sin(C)
s = a * h / 2
print(s)
print(l)
print(h)
| false | 9.090909 | [
"-import sys",
"-a, b, C = [int(x) for x in sys.stdin.readline().split()]",
"+a, b, C = [int(x) for x in input().split()]"
] | false | 0.047703 | 0.041304 | 1.154918 | [
"s946697673",
"s115048833"
] |
u606045429 | p02998 | python | s126336295 | s817060651 | 356 | 261 | 38,580 | 26,876 | Accepted | Accepted | 26.69 | from collections import Counter
def main():
MAX = 10 ** 5 + 1
data = [-1] * (2 * MAX)
def find(x):
if data[x] < 0:
return x
else:
data[x] = find(data[x])
return data[x]
def union(x, y):
x, y = find(x), find(y)
if x != y:
if data[y] < data[x]:
x, y = y, x
data[x] += data[y]
data[y] = x
return (x != y)
N, *XY = list(map(int, open(0).read().split()))
for x, y in zip(*[iter(XY)] * 2):
union(x, y + MAX)
X = Counter(find(i) for i in range(MAX))
Y = Counter(find(i) for i in range(MAX, MAX * 2))
res = sum(X[i] * Y[i] for i in range(MAX * 2))
print((res - N))
if __name__ == '__main__':
main() | def main():
MAX = 10 ** 5 + 1
data = [-1] * (2 * MAX)
def find(x):
if data[x] < 0:
return x
else:
data[x] = find(data[x])
return data[x]
def union(x, y):
x, y = find(x), find(y)
if x != y:
if data[y] < data[x]:
x, y = y, x
data[x] += data[y]
data[y] = x
return (x != y)
N, *XY = list(map(int, open(0).read().split()))
for x, y in zip(*[iter(XY)] * 2):
union(x, y + MAX)
X = [0] * (MAX * 2)
Y = [0] * (MAX * 2)
for i in range(MAX):
X[find(i)] += 1
for i in range(MAX, MAX * 2):
Y[find(i)] += 1
res = sum(X[i] * Y[i] for i in range(MAX * 2))
print((res - N))
if __name__ == '__main__':
main()
| 39 | 42 | 812 | 840 | from collections import Counter
def main():
MAX = 10**5 + 1
data = [-1] * (2 * MAX)
def find(x):
if data[x] < 0:
return x
else:
data[x] = find(data[x])
return data[x]
def union(x, y):
x, y = find(x), find(y)
if x != y:
if data[y] < data[x]:
x, y = y, x
data[x] += data[y]
data[y] = x
return x != y
N, *XY = list(map(int, open(0).read().split()))
for x, y in zip(*[iter(XY)] * 2):
union(x, y + MAX)
X = Counter(find(i) for i in range(MAX))
Y = Counter(find(i) for i in range(MAX, MAX * 2))
res = sum(X[i] * Y[i] for i in range(MAX * 2))
print((res - N))
if __name__ == "__main__":
main()
| def main():
MAX = 10**5 + 1
data = [-1] * (2 * MAX)
def find(x):
if data[x] < 0:
return x
else:
data[x] = find(data[x])
return data[x]
def union(x, y):
x, y = find(x), find(y)
if x != y:
if data[y] < data[x]:
x, y = y, x
data[x] += data[y]
data[y] = x
return x != y
N, *XY = list(map(int, open(0).read().split()))
for x, y in zip(*[iter(XY)] * 2):
union(x, y + MAX)
X = [0] * (MAX * 2)
Y = [0] * (MAX * 2)
for i in range(MAX):
X[find(i)] += 1
for i in range(MAX, MAX * 2):
Y[find(i)] += 1
res = sum(X[i] * Y[i] for i in range(MAX * 2))
print((res - N))
if __name__ == "__main__":
main()
| false | 7.142857 | [
"-from collections import Counter",
"-",
"-",
"- X = Counter(find(i) for i in range(MAX))",
"- Y = Counter(find(i) for i in range(MAX, MAX * 2))",
"+ X = [0] * (MAX * 2)",
"+ Y = [0] * (MAX * 2)",
"+ for i in range(MAX):",
"+ X[find(i)] += 1",
"+ for i in range(MAX, MAX * 2):",
"+ Y[find(i)] += 1"
] | false | 0.34305 | 0.102102 | 3.359895 | [
"s126336295",
"s817060651"
] |
u968166680 | p02883 | python | s496135827 | s596422742 | 373 | 342 | 138,360 | 138,776 | Accepted | Accepted | 8.31 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
N, K, *AF = list(map(int, read().split()))
A = AF[:N]
F = AF[N:]
A.sort()
F.sort(reverse=True)
C = [a * f for a, f in zip(A, F)]
def is_ok(cost):
k = 0
for c, f in zip(C, F):
if c > cost:
k += (c - cost + f - 1) // f
return k <= K
ok = max(C)
ng = -1
while ok - ng > 1:
mid = (ok + ng) // 2
if is_ok(mid):
ok = mid
else:
ng = mid
print(ok)
return
if __name__ == '__main__':
main()
| import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
N, K, *AF = list(map(int, read().split()))
A = AF[:N]
F = AF[N:]
A.sort()
F.sort(reverse=True)
C = [a * f for a, f in zip(A, F)]
def is_ok(cost):
k = 0
for i in range(N):
if C[i] > cost:
k += (C[i] - cost + F[i] - 1) // F[i]
return k <= K
ok = max(C)
ng = -1
while ok - ng > 1:
mid = (ok + ng) // 2
if is_ok(mid):
ok = mid
else:
ng = mid
print(ok)
return
if __name__ == '__main__':
main()
| 41 | 41 | 745 | 753 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def main():
N, K, *AF = list(map(int, read().split()))
A = AF[:N]
F = AF[N:]
A.sort()
F.sort(reverse=True)
C = [a * f for a, f in zip(A, F)]
def is_ok(cost):
k = 0
for c, f in zip(C, F):
if c > cost:
k += (c - cost + f - 1) // f
return k <= K
ok = max(C)
ng = -1
while ok - ng > 1:
mid = (ok + ng) // 2
if is_ok(mid):
ok = mid
else:
ng = mid
print(ok)
return
if __name__ == "__main__":
main()
| import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def main():
N, K, *AF = list(map(int, read().split()))
A = AF[:N]
F = AF[N:]
A.sort()
F.sort(reverse=True)
C = [a * f for a, f in zip(A, F)]
def is_ok(cost):
k = 0
for i in range(N):
if C[i] > cost:
k += (C[i] - cost + F[i] - 1) // F[i]
return k <= K
ok = max(C)
ng = -1
while ok - ng > 1:
mid = (ok + ng) // 2
if is_ok(mid):
ok = mid
else:
ng = mid
print(ok)
return
if __name__ == "__main__":
main()
| false | 0 | [
"- for c, f in zip(C, F):",
"- if c > cost:",
"- k += (c - cost + f - 1) // f",
"+ for i in range(N):",
"+ if C[i] > cost:",
"+ k += (C[i] - cost + F[i] - 1) // F[i]"
] | false | 0.036395 | 0.035997 | 1.011036 | [
"s496135827",
"s596422742"
] |
u968404618 | p03767 | python | s777426735 | s411037646 | 222 | 155 | 37,084 | 42,812 | Accepted | Accepted | 30.18 | n = int(eval(input()))
a = sorted(list(map(int, input().split())), reverse=True)
ans = 0
for i in range(1, 2*n, 2):
ans += a[i]
print(ans) | n = int(eval(input()))
A = sorted(list(map(int, input().split())), reverse=True)
#print(A)
ans = 0
for i in range(1, 2*n+1, 2):
ans += A[i]
print(ans) | 9 | 8 | 147 | 154 | n = int(eval(input()))
a = sorted(list(map(int, input().split())), reverse=True)
ans = 0
for i in range(1, 2 * n, 2):
ans += a[i]
print(ans)
| n = int(eval(input()))
A = sorted(list(map(int, input().split())), reverse=True)
# print(A)
ans = 0
for i in range(1, 2 * n + 1, 2):
ans += A[i]
print(ans)
| false | 11.111111 | [
"-a = sorted(list(map(int, input().split())), reverse=True)",
"+A = sorted(list(map(int, input().split())), reverse=True)",
"+# print(A)",
"-for i in range(1, 2 * n, 2):",
"- ans += a[i]",
"+for i in range(1, 2 * n + 1, 2):",
"+ ans += A[i]"
] | false | 0.071207 | 0.037014 | 1.923801 | [
"s777426735",
"s411037646"
] |
u811733736 | p00092 | python | s723567884 | s576872602 | 4,910 | 3,510 | 35,460 | 35,048 | Accepted | Accepted | 28.51 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0092
"""
import sys
def find_square0(data):
max_size = 0
dp = [] # dp??¨???2?¬??????????
# '.'????????????1??????'*'????????????0????????????
for row in data:
temp = []
for c in row:
if c == '.':
temp.append(1)
else:
temp.append(0)
dp.append(temp)
# ????±?????????????????????????????????£????????????????????£?????¢????¢??????§??????????????§????????????
for y in range(1, len(dp)):
for x in range(1, len(dp[0])):
if dp[y][x] == 1:
dp[y][x] = min(dp[y-1][x-1], dp[y-1][x], dp[y][x-1]) + 1
if dp[y][x] > max_size:
max_size = dp[y][x]
return max_size
def find_square2(data):
max_size = 0
dp = [[0]*len(data[0]) for _ in range(len(data))] # dp??¨???2?¬???????????????¨??????0??§?????????
# '.'????????????1???
for y, row in enumerate(data):
for x, c in enumerate(row):
if c == '.':
dp[y][x] = 1
# (?????¨???(curr_row)??¨???????????????(prev_row)????????¢????????????????????§?????????????????????)
prev_row = dp[0]
for curr_row in dp[1:]:
for x, t in enumerate(curr_row[1:], start=1):
if t == 1:
curr_row[x] = min(prev_row[x-1], prev_row[x], curr_row[x-1]) + 1
if curr_row[x] > max_size:
max_size = curr_row[x]
prev_row = curr_row
return max_size
def find_square3(data):
from array import array
max_size = 0
dp = [array('I', [0]*len(data[0])) for _ in range(len(data))] # ????¬?????????????array??????????????§?¢????
# '.'????????????1???
for y, row in enumerate(data):
for x, c in enumerate(row):
if c == '.':
dp[y][x] = 1
prev_row = dp[0]
for curr_row in dp[1:]:
for x, t in enumerate(curr_row[1:], start=1):
if t == 1:
curr_row[x] = min(prev_row[x-1], prev_row[x], curr_row[x-1]) + 1
if curr_row[x] > max_size:
max_size = curr_row[x]
prev_row = curr_row
return max_size
def find_square4(data):
max_size = 0
dp = [0 for _ in range(1024*1024)]
# '.'????????????1???
for y, row in enumerate(data):
for x, c in enumerate(row):
if c == '.':
dp[y*1024+x] = 1
# ????±?????????????????????????????????£????????????????????£?????¢????¢??????§??????????????§????????????
for y in range(1, len(data)):
for x in range(1, len(data)):
if dp[y*1024+x] == 1:
dp[y*1024+x] = min(dp[(y-1)*1024+x-1], dp[(y-1)*1024+x], dp[y*1024+x-1]) + 1
if dp[y*1024+x] > max_size:
max_size = dp[y*1024+x]
return max_size
def main(args):
while True:
n = int(eval(input()))
if n == 0:
break
data = [eval(input()) for _ in range(n)]
result = find_square4(data)
print(result)
if __name__ == '__main__':
main(sys.argv[1:]) | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0092
"""
import sys
def find_square0(data):
max_size = 0
dp = [] # dp??¨???2?¬??????????
# '.'????????????1??????'*'????????????0????????????
for row in data:
temp = []
for c in row:
if c == '.':
temp.append(1)
else:
temp.append(0)
dp.append(temp)
# ????±?????????????????????????????????£????????????????????£?????¢????¢??????§??????????????§????????????
for y in range(1, len(dp)):
for x in range(1, len(dp[0])):
if dp[y][x] == 1:
dp[y][x] = min(dp[y-1][x-1], dp[y-1][x], dp[y][x-1]) + 1
if dp[y][x] > max_size:
max_size = dp[y][x]
return max_size
def find_square2(data):
max_size = 0
dp = [[0]*len(data[0]) for _ in range(len(data))] # dp??¨???2?¬???????????????¨??????0??§?????????
# '.'????????????1???
for y, row in enumerate(data):
for x, c in enumerate(row):
if c == '.':
dp[y][x] = 1
# (?????¨???(curr_row)??¨???????????????(prev_row)????????¢????????????????????§?????????????????????)
prev_row = dp[0]
for curr_row in dp[1:]:
for x, t in enumerate(curr_row[1:], start=1):
if t == 1:
curr_row[x] = min(prev_row[x-1], prev_row[x], curr_row[x-1]) + 1
if curr_row[x] > max_size:
max_size = curr_row[x]
prev_row = curr_row
return max_size
def find_square3(data):
from array import array
max_size = 0
dp = [array('I', [0]*len(data[0])) for _ in range(len(data))] # ????¬?????????????array??????????????§?¢????
# '.'????????????1???
for y, row in enumerate(data):
for x, c in enumerate(row):
if c == '.':
dp[y][x] = 1
prev_row = dp[0]
for curr_row in dp[1:]:
for x, t in enumerate(curr_row[1:], start=1):
if t == 1:
curr_row[x] = min(prev_row[x-1], prev_row[x], curr_row[x-1]) + 1
if curr_row[x] > max_size:
max_size = curr_row[x]
prev_row = curr_row
return max_size
def find_square4(data):
# 4.91[s]
max_size = 0
dp = [0 for _ in range(1024*1024)]
# '.'????????????1???
for y, row in enumerate(data):
for x, c in enumerate(row):
if c == '.':
dp[y*1024+x] = 1
# ????±?????????????????????????????????£????????????????????£?????¢????¢??????§??????????????§????????????
for y in range(1, len(data)):
for x in range(1, len(data)):
if dp[y*1024+x] == 1:
dp[y*1024+x] = min(dp[(y-1)*1024+x-1], dp[(y-1)*1024+x], dp[y*1024+x-1]) + 1
if dp[y*1024+x] > max_size:
max_size = dp[y*1024+x]
return max_size
def main(args):
while True:
n = int(eval(input()))
if n == 0:
break
data = [eval(input()) for _ in range(n)]
result = find_square0(data)
print(result)
if __name__ == '__main__':
main(sys.argv[1:]) | 104 | 105 | 3,251 | 3,266 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0092
"""
import sys
def find_square0(data):
max_size = 0
dp = [] # dp??¨???2?¬??????????
# '.'????????????1??????'*'????????????0????????????
for row in data:
temp = []
for c in row:
if c == ".":
temp.append(1)
else:
temp.append(0)
dp.append(temp)
# ????±?????????????????????????????????£????????????????????£?????¢????¢??????§??????????????§????????????
for y in range(1, len(dp)):
for x in range(1, len(dp[0])):
if dp[y][x] == 1:
dp[y][x] = min(dp[y - 1][x - 1], dp[y - 1][x], dp[y][x - 1]) + 1
if dp[y][x] > max_size:
max_size = dp[y][x]
return max_size
def find_square2(data):
max_size = 0
dp = [
[0] * len(data[0]) for _ in range(len(data))
] # dp??¨???2?¬???????????????¨??????0??§?????????
# '.'????????????1???
for y, row in enumerate(data):
for x, c in enumerate(row):
if c == ".":
dp[y][x] = 1
# (?????¨???(curr_row)??¨???????????????(prev_row)????????¢????????????????????§?????????????????????)
prev_row = dp[0]
for curr_row in dp[1:]:
for x, t in enumerate(curr_row[1:], start=1):
if t == 1:
curr_row[x] = min(prev_row[x - 1], prev_row[x], curr_row[x - 1]) + 1
if curr_row[x] > max_size:
max_size = curr_row[x]
prev_row = curr_row
return max_size
def find_square3(data):
from array import array
max_size = 0
dp = [
array("I", [0] * len(data[0])) for _ in range(len(data))
] # ????¬?????????????array??????????????§?¢????
# '.'????????????1???
for y, row in enumerate(data):
for x, c in enumerate(row):
if c == ".":
dp[y][x] = 1
prev_row = dp[0]
for curr_row in dp[1:]:
for x, t in enumerate(curr_row[1:], start=1):
if t == 1:
curr_row[x] = min(prev_row[x - 1], prev_row[x], curr_row[x - 1]) + 1
if curr_row[x] > max_size:
max_size = curr_row[x]
prev_row = curr_row
return max_size
def find_square4(data):
max_size = 0
dp = [0 for _ in range(1024 * 1024)]
# '.'????????????1???
for y, row in enumerate(data):
for x, c in enumerate(row):
if c == ".":
dp[y * 1024 + x] = 1
# ????±?????????????????????????????????£????????????????????£?????¢????¢??????§??????????????§????????????
for y in range(1, len(data)):
for x in range(1, len(data)):
if dp[y * 1024 + x] == 1:
dp[y * 1024 + x] = (
min(
dp[(y - 1) * 1024 + x - 1],
dp[(y - 1) * 1024 + x],
dp[y * 1024 + x - 1],
)
+ 1
)
if dp[y * 1024 + x] > max_size:
max_size = dp[y * 1024 + x]
return max_size
def main(args):
while True:
n = int(eval(input()))
if n == 0:
break
data = [eval(input()) for _ in range(n)]
result = find_square4(data)
print(result)
if __name__ == "__main__":
main(sys.argv[1:])
| # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0092
"""
import sys
def find_square0(data):
max_size = 0
dp = [] # dp??¨???2?¬??????????
# '.'????????????1??????'*'????????????0????????????
for row in data:
temp = []
for c in row:
if c == ".":
temp.append(1)
else:
temp.append(0)
dp.append(temp)
# ????±?????????????????????????????????£????????????????????£?????¢????¢??????§??????????????§????????????
for y in range(1, len(dp)):
for x in range(1, len(dp[0])):
if dp[y][x] == 1:
dp[y][x] = min(dp[y - 1][x - 1], dp[y - 1][x], dp[y][x - 1]) + 1
if dp[y][x] > max_size:
max_size = dp[y][x]
return max_size
def find_square2(data):
max_size = 0
dp = [
[0] * len(data[0]) for _ in range(len(data))
] # dp??¨???2?¬???????????????¨??????0??§?????????
# '.'????????????1???
for y, row in enumerate(data):
for x, c in enumerate(row):
if c == ".":
dp[y][x] = 1
# (?????¨???(curr_row)??¨???????????????(prev_row)????????¢????????????????????§?????????????????????)
prev_row = dp[0]
for curr_row in dp[1:]:
for x, t in enumerate(curr_row[1:], start=1):
if t == 1:
curr_row[x] = min(prev_row[x - 1], prev_row[x], curr_row[x - 1]) + 1
if curr_row[x] > max_size:
max_size = curr_row[x]
prev_row = curr_row
return max_size
def find_square3(data):
from array import array
max_size = 0
dp = [
array("I", [0] * len(data[0])) for _ in range(len(data))
] # ????¬?????????????array??????????????§?¢????
# '.'????????????1???
for y, row in enumerate(data):
for x, c in enumerate(row):
if c == ".":
dp[y][x] = 1
prev_row = dp[0]
for curr_row in dp[1:]:
for x, t in enumerate(curr_row[1:], start=1):
if t == 1:
curr_row[x] = min(prev_row[x - 1], prev_row[x], curr_row[x - 1]) + 1
if curr_row[x] > max_size:
max_size = curr_row[x]
prev_row = curr_row
return max_size
def find_square4(data):
# 4.91[s]
max_size = 0
dp = [0 for _ in range(1024 * 1024)]
# '.'????????????1???
for y, row in enumerate(data):
for x, c in enumerate(row):
if c == ".":
dp[y * 1024 + x] = 1
# ????±?????????????????????????????????£????????????????????£?????¢????¢??????§??????????????§????????????
for y in range(1, len(data)):
for x in range(1, len(data)):
if dp[y * 1024 + x] == 1:
dp[y * 1024 + x] = (
min(
dp[(y - 1) * 1024 + x - 1],
dp[(y - 1) * 1024 + x],
dp[y * 1024 + x - 1],
)
+ 1
)
if dp[y * 1024 + x] > max_size:
max_size = dp[y * 1024 + x]
return max_size
def main(args):
while True:
n = int(eval(input()))
if n == 0:
break
data = [eval(input()) for _ in range(n)]
result = find_square0(data)
print(result)
if __name__ == "__main__":
main(sys.argv[1:])
| false | 0.952381 | [
"+ # 4.91[s]",
"- result = find_square4(data)",
"+ result = find_square0(data)"
] | false | 0.100758 | 0.098733 | 1.020507 | [
"s723567884",
"s576872602"
] |
u667084803 | p02925 | python | s687936900 | s383481076 | 1,154 | 1,027 | 35,612 | 35,604 | Accepted | Accepted | 11.01 | N = int(eval(input()))
A = [[x-1 for x in list(map(int, input().split()))[::-1]] for _ in range(N)]
def can_match(i, A, next_set):
if not A[i]:
return
j = A[i][-1]
if A[j][-1] == i:
if i < j:
next_set.add((i,j))
else:
next_set.add((j,i))
next_set = set()
for i in range(N):
can_match(i, A, next_set)
day = 0
battle = 0
while next_set:
day += 1
current_set, next_set = next_set.copy(), set()
for match in current_set:
battle += 1
del A[match[0]][-1]
can_match(match[0], A, next_set)
del A[match[1]][-1]
can_match(match[1], A, next_set)
if battle == N*(N-1)//2:
print(day)
else:
print((-1)) | N = int(eval(input()))
A = [[x-1 for x in list(map(int, input().split()))[::-1]] for _ in range(N)]
def can_match(i, A, next_set):
if not A[i]:
return
j = A[i][-1]
if A[j][-1] == i:
if i < j:
next_set.add((i,j))
else:
next_set.add((j,i))
next_set = set()
for i in range(N):
can_match(i, A, next_set)
day = 0
battle = 0
while next_set:
day += 1
current_set, next_set = next_set, set()
for match in current_set:
battle += 1
del A[match[0]][-1]
can_match(match[0], A, next_set)
del A[match[1]][-1]
can_match(match[1], A, next_set)
if battle == N*(N-1)//2:
print(day)
else:
print((-1)) | 33 | 33 | 690 | 683 | N = int(eval(input()))
A = [[x - 1 for x in list(map(int, input().split()))[::-1]] for _ in range(N)]
def can_match(i, A, next_set):
if not A[i]:
return
j = A[i][-1]
if A[j][-1] == i:
if i < j:
next_set.add((i, j))
else:
next_set.add((j, i))
next_set = set()
for i in range(N):
can_match(i, A, next_set)
day = 0
battle = 0
while next_set:
day += 1
current_set, next_set = next_set.copy(), set()
for match in current_set:
battle += 1
del A[match[0]][-1]
can_match(match[0], A, next_set)
del A[match[1]][-1]
can_match(match[1], A, next_set)
if battle == N * (N - 1) // 2:
print(day)
else:
print((-1))
| N = int(eval(input()))
A = [[x - 1 for x in list(map(int, input().split()))[::-1]] for _ in range(N)]
def can_match(i, A, next_set):
if not A[i]:
return
j = A[i][-1]
if A[j][-1] == i:
if i < j:
next_set.add((i, j))
else:
next_set.add((j, i))
next_set = set()
for i in range(N):
can_match(i, A, next_set)
day = 0
battle = 0
while next_set:
day += 1
current_set, next_set = next_set, set()
for match in current_set:
battle += 1
del A[match[0]][-1]
can_match(match[0], A, next_set)
del A[match[1]][-1]
can_match(match[1], A, next_set)
if battle == N * (N - 1) // 2:
print(day)
else:
print((-1))
| false | 0 | [
"- current_set, next_set = next_set.copy(), set()",
"+ current_set, next_set = next_set, set()"
] | false | 0.04194 | 0.044271 | 0.947338 | [
"s687936900",
"s383481076"
] |
u924406834 | p03331 | python | s466907925 | s359042780 | 19 | 17 | 3,316 | 2,940 | Accepted | Accepted | 10.53 | N = int(eval(input()))
if N % 10 == 0:
print((10))
else:
a = [int(x) for x in str(N)]
print((sum(a))) | n = int(eval(input()))
if n%10 == 0:
print((10))
else:
nums = list(map(int,[x for x in str(n)]))
print((sum(nums))) | 6 | 6 | 109 | 122 | N = int(eval(input()))
if N % 10 == 0:
print((10))
else:
a = [int(x) for x in str(N)]
print((sum(a)))
| n = int(eval(input()))
if n % 10 == 0:
print((10))
else:
nums = list(map(int, [x for x in str(n)]))
print((sum(nums)))
| false | 0 | [
"-N = int(eval(input()))",
"-if N % 10 == 0:",
"+n = int(eval(input()))",
"+if n % 10 == 0:",
"- a = [int(x) for x in str(N)]",
"- print((sum(a)))",
"+ nums = list(map(int, [x for x in str(n)]))",
"+ print((sum(nums)))"
] | false | 0.069133 | 0.067778 | 1.019982 | [
"s466907925",
"s359042780"
] |
u784022244 | p03329 | python | s223022383 | s598213647 | 1,667 | 506 | 14,008 | 3,828 | Accepted | Accepted | 69.65 | import numpy as np
from math import log
N=int(eval(input()))
L=[1]
for i in range(1,N):
if 6**i<=N:
L.append(6**i)
else:
break
for i in range(1,N):
if 9**i<=N:
L.append(9**i)
else:
break
L=np.array(L)
dp=np.ones((N+1))*100000
dp[0]=0
dp[1]=1
for i in range(2,N+1):
dp[i]=(dp[i-L]+1).min()
print((int(dp[N]))) | N=int(eval(input()))
L=[1]
for i in range(1,100):
a=6**i
if a<=100000:
L.append(a)
else:
break
for i in range(1,100):
a=9**i
if a<=100000:
L.append(a)
else:
break
dp=[1000000]*(N+1)
dp[0]=0
for i in range(1,N+1):
sub=10**5
for l in L:
if i-l>=0:
sub=min(sub, dp[i-l]+1)
dp[i]=sub
print((dp[N])) | 23 | 24 | 376 | 398 | import numpy as np
from math import log
N = int(eval(input()))
L = [1]
for i in range(1, N):
if 6**i <= N:
L.append(6**i)
else:
break
for i in range(1, N):
if 9**i <= N:
L.append(9**i)
else:
break
L = np.array(L)
dp = np.ones((N + 1)) * 100000
dp[0] = 0
dp[1] = 1
for i in range(2, N + 1):
dp[i] = (dp[i - L] + 1).min()
print((int(dp[N])))
| N = int(eval(input()))
L = [1]
for i in range(1, 100):
a = 6**i
if a <= 100000:
L.append(a)
else:
break
for i in range(1, 100):
a = 9**i
if a <= 100000:
L.append(a)
else:
break
dp = [1000000] * (N + 1)
dp[0] = 0
for i in range(1, N + 1):
sub = 10**5
for l in L:
if i - l >= 0:
sub = min(sub, dp[i - l] + 1)
dp[i] = sub
print((dp[N]))
| false | 4.166667 | [
"-import numpy as np",
"-from math import log",
"-",
"-for i in range(1, N):",
"- if 6**i <= N:",
"- L.append(6**i)",
"+for i in range(1, 100):",
"+ a = 6**i",
"+ if a <= 100000:",
"+ L.append(a)",
"-for i in range(1, N):",
"- if 9**i <= N:",
"- L.append(9**i)",
"+for i in range(1, 100):",
"+ a = 9**i",
"+ if a <= 100000:",
"+ L.append(a)",
"-L = np.array(L)",
"-dp = np.ones((N + 1)) * 100000",
"+dp = [1000000] * (N + 1)",
"-dp[1] = 1",
"-for i in range(2, N + 1):",
"- dp[i] = (dp[i - L] + 1).min()",
"-print((int(dp[N])))",
"+for i in range(1, N + 1):",
"+ sub = 10**5",
"+ for l in L:",
"+ if i - l >= 0:",
"+ sub = min(sub, dp[i - l] + 1)",
"+ dp[i] = sub",
"+print((dp[N]))"
] | false | 0.72444 | 0.133092 | 5.443157 | [
"s223022383",
"s598213647"
] |
u761320129 | p03273 | python | s649285963 | s478511894 | 70 | 22 | 3,064 | 3,064 | Accepted | Accepted | 68.57 | H,W = list(map(int,input().split()))
src = [eval(input()) for i in range(H)]
cols = list(zip(*src))
for row in src:
if all([c=='.' for c in row]): continue
out = ''
for i,c in enumerate(row):
if all([c=='.' for c in cols[i]]): continue
out += c
print(out) | H,W = list(map(int,input().split()))
src = [eval(input()) for i in range(H)]
del_r = []
for i in range(H):
if all([c=='.' for c in src[i]]):
del_r.append(i)
del_c = []
for i,col in enumerate(zip(*src)):
if all([c=='.' for c in col]):
del_c.append(i)
for i in range(H):
if i in del_r: continue
ans = ''
for j in range(W):
if j in del_c: continue
ans += src[i][j]
print(ans) | 10 | 20 | 284 | 438 | H, W = list(map(int, input().split()))
src = [eval(input()) for i in range(H)]
cols = list(zip(*src))
for row in src:
if all([c == "." for c in row]):
continue
out = ""
for i, c in enumerate(row):
if all([c == "." for c in cols[i]]):
continue
out += c
print(out)
| H, W = list(map(int, input().split()))
src = [eval(input()) for i in range(H)]
del_r = []
for i in range(H):
if all([c == "." for c in src[i]]):
del_r.append(i)
del_c = []
for i, col in enumerate(zip(*src)):
if all([c == "." for c in col]):
del_c.append(i)
for i in range(H):
if i in del_r:
continue
ans = ""
for j in range(W):
if j in del_c:
continue
ans += src[i][j]
print(ans)
| false | 50 | [
"-cols = list(zip(*src))",
"-for row in src:",
"- if all([c == \".\" for c in row]):",
"+del_r = []",
"+for i in range(H):",
"+ if all([c == \".\" for c in src[i]]):",
"+ del_r.append(i)",
"+del_c = []",
"+for i, col in enumerate(zip(*src)):",
"+ if all([c == \".\" for c in col]):",
"+ del_c.append(i)",
"+for i in range(H):",
"+ if i in del_r:",
"- out = \"\"",
"- for i, c in enumerate(row):",
"- if all([c == \".\" for c in cols[i]]):",
"+ ans = \"\"",
"+ for j in range(W):",
"+ if j in del_c:",
"- out += c",
"- print(out)",
"+ ans += src[i][j]",
"+ print(ans)"
] | false | 0.045215 | 0.045252 | 0.999168 | [
"s649285963",
"s478511894"
] |
u391533749 | p03371 | python | s377151264 | s727829008 | 149 | 105 | 12,028 | 11,884 | Accepted | Accepted | 29.53 | A, B, C, X, Y = list(map(int, input().split()))
price = 0
P = []
s = 0
t = 0
u = 0
if A + B <= 2*C:
price = A*X + B*Y
else:
sa = abs(X - Y)
price = C*2*(min(X, Y)-sa)
XX = X - (min(X, Y)-sa)
YY = Y - (min(X, Y)-sa)
dai = max(XX, YY)
syou = min(XX, YY)
for i in range(dai+1):
u = i*2
if syou>=i:
s = XX - i
t = YY - i
else:
if X >= Y:
s = XX - i
t = 0
else:
s = 0
t = YY - i
P.append(A*s + B*t + C*u)
price += min(P)
print(price) | A, B, C, X, Y = list(map(int, input().split()))
prise = A*X + B*Y
x = X
y = Y
anset = set()
anset.add(prise)
while max(x, y)>0:
if x > 0:
prise -= A
if y > 0:
prise -= B
prise += C * 2
anset.add(prise)
x -= 1
y -= 1
print((min(anset))) | 32 | 19 | 635 | 288 | A, B, C, X, Y = list(map(int, input().split()))
price = 0
P = []
s = 0
t = 0
u = 0
if A + B <= 2 * C:
price = A * X + B * Y
else:
sa = abs(X - Y)
price = C * 2 * (min(X, Y) - sa)
XX = X - (min(X, Y) - sa)
YY = Y - (min(X, Y) - sa)
dai = max(XX, YY)
syou = min(XX, YY)
for i in range(dai + 1):
u = i * 2
if syou >= i:
s = XX - i
t = YY - i
else:
if X >= Y:
s = XX - i
t = 0
else:
s = 0
t = YY - i
P.append(A * s + B * t + C * u)
price += min(P)
print(price)
| A, B, C, X, Y = list(map(int, input().split()))
prise = A * X + B * Y
x = X
y = Y
anset = set()
anset.add(prise)
while max(x, y) > 0:
if x > 0:
prise -= A
if y > 0:
prise -= B
prise += C * 2
anset.add(prise)
x -= 1
y -= 1
print((min(anset)))
| false | 40.625 | [
"-price = 0",
"-P = []",
"-s = 0",
"-t = 0",
"-u = 0",
"-if A + B <= 2 * C:",
"- price = A * X + B * Y",
"-else:",
"- sa = abs(X - Y)",
"- price = C * 2 * (min(X, Y) - sa)",
"- XX = X - (min(X, Y) - sa)",
"- YY = Y - (min(X, Y) - sa)",
"- dai = max(XX, YY)",
"- syou = min(XX, YY)",
"- for i in range(dai + 1):",
"- u = i * 2",
"- if syou >= i:",
"- s = XX - i",
"- t = YY - i",
"- else:",
"- if X >= Y:",
"- s = XX - i",
"- t = 0",
"- else:",
"- s = 0",
"- t = YY - i",
"- P.append(A * s + B * t + C * u)",
"- price += min(P)",
"-print(price)",
"+prise = A * X + B * Y",
"+x = X",
"+y = Y",
"+anset = set()",
"+anset.add(prise)",
"+while max(x, y) > 0:",
"+ if x > 0:",
"+ prise -= A",
"+ if y > 0:",
"+ prise -= B",
"+ prise += C * 2",
"+ anset.add(prise)",
"+ x -= 1",
"+ y -= 1",
"+print((min(anset)))"
] | false | 0.084942 | 0.069562 | 1.221099 | [
"s377151264",
"s727829008"
] |
u934442292 | p02743 | python | s636259440 | s849640742 | 36 | 17 | 5,204 | 2,940 | Accepted | Accepted | 52.78 | from decimal import Decimal
a, b, c = [int(i) for i in input().strip().split()]
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
print("Yes")
else:
print("No")
| import sys
input = sys.stdin.readline
def main():
a, b, c = list(map(int, input().split()))
y = (c - (a+b))**2 - 4*a*b
if c-(a+b) > 0 and y > 0:
print("Yes")
else:
print("No")
if __name__ == "__main__":
main()
| 8 | 16 | 186 | 260 | from decimal import Decimal
a, b, c = [int(i) for i in input().strip().split()]
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
print("Yes")
else:
print("No")
| import sys
input = sys.stdin.readline
def main():
a, b, c = list(map(int, input().split()))
y = (c - (a + b)) ** 2 - 4 * a * b
if c - (a + b) > 0 and y > 0:
print("Yes")
else:
print("No")
if __name__ == "__main__":
main()
| false | 50 | [
"-from decimal import Decimal",
"+import sys",
"-a, b, c = [int(i) for i in input().strip().split()]",
"-if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():",
"- print(\"Yes\")",
"-else:",
"- print(\"No\")",
"+input = sys.stdin.readline",
"+",
"+",
"+def main():",
"+ a, b, c = list(map(int, input().split()))",
"+ y = (c - (a + b)) ** 2 - 4 * a * b",
"+ if c - (a + b) > 0 and y > 0:",
"+ print(\"Yes\")",
"+ else:",
"+ print(\"No\")",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.042555 | 0.085868 | 0.495587 | [
"s636259440",
"s849640742"
] |
u373274281 | p03828 | python | s380726789 | s866625158 | 40 | 20 | 3,064 | 3,064 | Accepted | Accepted | 50 | n = int(eval(input()))
m = 10**9+7
primes = [2,3,5,7,11,13,17,19,23,29,31]
D = [0]*1001
for i in range(2, n+1):
v = i
for p in range(2, 1000):
while(v % p == 0):
D[p] += 1
v //= p
if v == 1:
break
if(v == i):
D[i] += 1
score = 1
for d in D:
score = score * (d + 1)
print((score % m))
| n = int(eval(input()))
m = 10**9+7
primes = [2,3,5,7,11,13,17,19,23,29,31]
D = [0]*1001
for i in range(2, n+1):
for p in primes:
while(i % p == 0):
D[p] += 1
i //= p
if i > 1:
D[i] += 1
score = 1
for d in D:
score = (score * (d + 1)) % m
print(score)
| 21 | 17 | 375 | 315 | n = int(eval(input()))
m = 10**9 + 7
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
D = [0] * 1001
for i in range(2, n + 1):
v = i
for p in range(2, 1000):
while v % p == 0:
D[p] += 1
v //= p
if v == 1:
break
if v == i:
D[i] += 1
score = 1
for d in D:
score = score * (d + 1)
print((score % m))
| n = int(eval(input()))
m = 10**9 + 7
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
D = [0] * 1001
for i in range(2, n + 1):
for p in primes:
while i % p == 0:
D[p] += 1
i //= p
if i > 1:
D[i] += 1
score = 1
for d in D:
score = (score * (d + 1)) % m
print(score)
| false | 19.047619 | [
"- v = i",
"- for p in range(2, 1000):",
"- while v % p == 0:",
"+ for p in primes:",
"+ while i % p == 0:",
"- v //= p",
"- if v == 1:",
"- break",
"- if v == i:",
"+ i //= p",
"+ if i > 1:",
"- score = score * (d + 1)",
"-print((score % m))",
"+ score = (score * (d + 1)) % m",
"+print(score)"
] | false | 0.045154 | 0.127499 | 0.354149 | [
"s380726789",
"s866625158"
] |
u337626942 | p02755 | python | s091958449 | s066611554 | 21 | 19 | 2,940 | 3,060 | Accepted | Accepted | 9.52 | import math
A, B=list(map(int,input().split()))
for i in range(10000):
if math.floor(i*0.08)==A and math.floor(i*0.1)==B:
print(i)
exit()
print((-1)) | import math
A, B=list(map(int,input().split()))
for i in range(1001):
if math.floor(i*0.08)==A and math.floor(i*0.1)==B:
print(i)
exit()
print((-1)) | 7 | 7 | 167 | 166 | import math
A, B = list(map(int, input().split()))
for i in range(10000):
if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B:
print(i)
exit()
print((-1))
| import math
A, B = list(map(int, input().split()))
for i in range(1001):
if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B:
print(i)
exit()
print((-1))
| false | 0 | [
"-for i in range(10000):",
"+for i in range(1001):"
] | false | 0.038961 | 0.037036 | 1.051966 | [
"s091958449",
"s066611554"
] |
u098012509 | p03069 | python | s443094354 | s465770064 | 162 | 106 | 9,716 | 9,392 | Accepted | Accepted | 34.57 | import sys
import collections
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
def main():
N = int(eval(input()))
S = input().strip()
c = collections.Counter(S)
c2 = collections.Counter()
ans = min(c['.'], c['#'])
for i in range(N):
c2[S[i]] += 1
ans = min(ans, c2['#'] + c['.'] - c2['.'])
print(ans)
if __name__ == '__main__':
main()
| N = int(eval(input()))
S = input().strip()
bcnt = S.count("#")
wcnt = N - bcnt
ans = wcnt
cntb = 0
cntw = 0
for i in range(N):
if S[i] == "#":
cntb += 1
else:
cntw += 1
ans = min(ans, cntb + wcnt - cntw)
print(ans)
| 25 | 20 | 419 | 262 | import sys
import collections
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
def main():
N = int(eval(input()))
S = input().strip()
c = collections.Counter(S)
c2 = collections.Counter()
ans = min(c["."], c["#"])
for i in range(N):
c2[S[i]] += 1
ans = min(ans, c2["#"] + c["."] - c2["."])
print(ans)
if __name__ == "__main__":
main()
| N = int(eval(input()))
S = input().strip()
bcnt = S.count("#")
wcnt = N - bcnt
ans = wcnt
cntb = 0
cntw = 0
for i in range(N):
if S[i] == "#":
cntb += 1
else:
cntw += 1
ans = min(ans, cntb + wcnt - cntw)
print(ans)
| false | 20 | [
"-import sys",
"-import collections",
"-",
"-sys.setrecursionlimit(10**8)",
"-input = sys.stdin.readline",
"-",
"-",
"-def main():",
"- N = int(eval(input()))",
"- S = input().strip()",
"- c = collections.Counter(S)",
"- c2 = collections.Counter()",
"- ans = min(c[\".\"], c[\"#\"])",
"- for i in range(N):",
"- c2[S[i]] += 1",
"- ans = min(ans, c2[\"#\"] + c[\".\"] - c2[\".\"])",
"- print(ans)",
"-",
"-",
"-if __name__ == \"__main__\":",
"- main()",
"+N = int(eval(input()))",
"+S = input().strip()",
"+bcnt = S.count(\"#\")",
"+wcnt = N - bcnt",
"+ans = wcnt",
"+cntb = 0",
"+cntw = 0",
"+for i in range(N):",
"+ if S[i] == \"#\":",
"+ cntb += 1",
"+ else:",
"+ cntw += 1",
"+ ans = min(ans, cntb + wcnt - cntw)",
"+print(ans)"
] | false | 0.037277 | 0.036369 | 1.024966 | [
"s443094354",
"s465770064"
] |
u611853667 | p00424 | python | s458437662 | s759837683 | 100 | 90 | 4,308 | 4,308 | Accepted | Accepted | 10 | while True:
dict = {}
n = eval(input())
if n == 0:break
for x in range(n):
a, b = input().split()
dict[a.strip()] = b.strip()
res = ""
for x in range(eval(input())):
a = input().strip()
if a in dict:
res += dict[a]
else:
res += a
print(res) | while True:
dict = {}
n = eval(input())
if n == 0:break
for x in range(n):
a, b = input().split()
dict[a] = b
res = ""
for x in range(eval(input())):
a = input()[0]
if a in dict:
res += dict[a]
else:
res += a
print(res) | 15 | 15 | 274 | 253 | while True:
dict = {}
n = eval(input())
if n == 0:
break
for x in range(n):
a, b = input().split()
dict[a.strip()] = b.strip()
res = ""
for x in range(eval(input())):
a = input().strip()
if a in dict:
res += dict[a]
else:
res += a
print(res)
| while True:
dict = {}
n = eval(input())
if n == 0:
break
for x in range(n):
a, b = input().split()
dict[a] = b
res = ""
for x in range(eval(input())):
a = input()[0]
if a in dict:
res += dict[a]
else:
res += a
print(res)
| false | 0 | [
"- dict[a.strip()] = b.strip()",
"+ dict[a] = b",
"- a = input().strip()",
"+ a = input()[0]"
] | false | 0.036585 | 0.03253 | 1.124623 | [
"s458437662",
"s759837683"
] |
u489959379 | p02712 | python | s395657732 | s995639836 | 156 | 101 | 30,124 | 9,184 | Accepted | Accepted | 35.26 | n = int(eval(input()))
res = []
for i in range(n + 1):
if i % 3 != 0 and i % 5 != 0:
res.append(i)
print((sum(res))) | import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n = int(eval(input()))
res = 0
for i in range(1, n + 1):
if i % 3 == 0 or i % 5 == 0:
continue
else:
res += i
print(res)
if __name__ == '__main__':
resolve()
| 7 | 22 | 127 | 336 | n = int(eval(input()))
res = []
for i in range(n + 1):
if i % 3 != 0 and i % 5 != 0:
res.append(i)
print((sum(res)))
| import sys
sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
n = int(eval(input()))
res = 0
for i in range(1, n + 1):
if i % 3 == 0 or i % 5 == 0:
continue
else:
res += i
print(res)
if __name__ == "__main__":
resolve()
| false | 68.181818 | [
"-n = int(eval(input()))",
"-res = []",
"-for i in range(n + 1):",
"- if i % 3 != 0 and i % 5 != 0:",
"- res.append(i)",
"-print((sum(res)))",
"+import sys",
"+",
"+sys.setrecursionlimit(10**7)",
"+f_inf = float(\"inf\")",
"+mod = 10**9 + 7",
"+",
"+",
"+def resolve():",
"+ n = int(eval(input()))",
"+ res = 0",
"+ for i in range(1, n + 1):",
"+ if i % 3 == 0 or i % 5 == 0:",
"+ continue",
"+ else:",
"+ res += i",
"+ print(res)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ resolve()"
] | false | 0.115385 | 0.078363 | 1.472444 | [
"s395657732",
"s995639836"
] |
u023229441 | p02969 | python | s860887252 | s734561581 | 20 | 17 | 3,316 | 2,940 | Accepted | Accepted | 15 | k=int(eval(input()))
print((3*k*k)) | print((3*int(eval(input()))**2)) | 3 | 1 | 30 | 24 | k = int(eval(input()))
print((3 * k * k))
| print((3 * int(eval(input())) ** 2))
| false | 66.666667 | [
"-k = int(eval(input()))",
"-print((3 * k * k))",
"+print((3 * int(eval(input())) ** 2))"
] | false | 0.04019 | 0.040546 | 0.991235 | [
"s860887252",
"s734561581"
] |
u094191970 | p03030 | python | s898028958 | s573056209 | 29 | 23 | 9,096 | 9,156 | Accepted | Accepted | 20.69 | n=int(eval(input()))
l=[]
for i in range(n):
s,p=input().split()
p=int(p)*-1
l.append([s,p,i+1])
l.sort()
for i in l:
print((i[-1])) | n=int(eval(input()))
l=[]
for i in range(n):
s,p=input().split()
p=-int(p)
l.append([s,p,i+1])
l.sort()
for i in l:
print((i[-1])) | 11 | 11 | 144 | 142 | n = int(eval(input()))
l = []
for i in range(n):
s, p = input().split()
p = int(p) * -1
l.append([s, p, i + 1])
l.sort()
for i in l:
print((i[-1]))
| n = int(eval(input()))
l = []
for i in range(n):
s, p = input().split()
p = -int(p)
l.append([s, p, i + 1])
l.sort()
for i in l:
print((i[-1]))
| false | 0 | [
"- p = int(p) * -1",
"+ p = -int(p)"
] | false | 0.03565 | 0.038858 | 0.917428 | [
"s898028958",
"s573056209"
] |
u576432509 | p02844 | python | s253895288 | s676359854 | 167 | 140 | 4,584 | 4,584 | Accepted | Accepted | 16.17 |
n=int(eval(input()))
s=tuple(eval(input()))
m=[[] for i in range(10)]
for i in range(n):
m[int(s[i])].append(i)
yn=""
icnt=0
for i in range(0,1000):
yn=""
stri=format(i,"03d")
stri=list(map(int,stri))
if len(m[stri[0]])>0:
m01=m[stri[0]][0]
else:
continue
if len(m[stri[1]])>0:
for ii in m[stri[1]]:
if m01<ii:
m02=ii
yn="yes2"
break
if yn!="yes2":
continue
if len(m[stri[2]])>0:
for ii in m[stri[2]]:
if m02<ii:
yn="yes3"
break
if yn!="yes3":
continue
else:
icnt+=1
print(icnt)
| n=int(eval(input()))
s=tuple(eval(input()))
m=[[] for i in range(10)]
for i in range(n):
m[int(s[i])].append(i)
yn=""
icnt=0
for i in range(0,1000):
yn=""
stri=format(i,"03d")
stri=list(map(int,stri))
if len(m[stri[0]])>0:
m01=m[stri[0]][0]
else:
continue
for ii in m[stri[1]]:
if m01<ii:
m02=ii
yn="yes2"
break
if yn!="yes2":
continue
for ii in m[stri[2]]:
if m02<ii:
icnt+=1
break
print(icnt)
| 40 | 33 | 727 | 567 | n = int(eval(input()))
s = tuple(eval(input()))
m = [[] for i in range(10)]
for i in range(n):
m[int(s[i])].append(i)
yn = ""
icnt = 0
for i in range(0, 1000):
yn = ""
stri = format(i, "03d")
stri = list(map(int, stri))
if len(m[stri[0]]) > 0:
m01 = m[stri[0]][0]
else:
continue
if len(m[stri[1]]) > 0:
for ii in m[stri[1]]:
if m01 < ii:
m02 = ii
yn = "yes2"
break
if yn != "yes2":
continue
if len(m[stri[2]]) > 0:
for ii in m[stri[2]]:
if m02 < ii:
yn = "yes3"
break
if yn != "yes3":
continue
else:
icnt += 1
print(icnt)
| n = int(eval(input()))
s = tuple(eval(input()))
m = [[] for i in range(10)]
for i in range(n):
m[int(s[i])].append(i)
yn = ""
icnt = 0
for i in range(0, 1000):
yn = ""
stri = format(i, "03d")
stri = list(map(int, stri))
if len(m[stri[0]]) > 0:
m01 = m[stri[0]][0]
else:
continue
for ii in m[stri[1]]:
if m01 < ii:
m02 = ii
yn = "yes2"
break
if yn != "yes2":
continue
for ii in m[stri[2]]:
if m02 < ii:
icnt += 1
break
print(icnt)
| false | 17.5 | [
"- if len(m[stri[1]]) > 0:",
"- for ii in m[stri[1]]:",
"- if m01 < ii:",
"- m02 = ii",
"- yn = \"yes2\"",
"- break",
"+ for ii in m[stri[1]]:",
"+ if m01 < ii:",
"+ m02 = ii",
"+ yn = \"yes2\"",
"+ break",
"- if len(m[stri[2]]) > 0:",
"- for ii in m[stri[2]]:",
"- if m02 < ii:",
"- yn = \"yes3\"",
"- break",
"- if yn != \"yes3\":",
"- continue",
"- else:",
"- icnt += 1",
"+ for ii in m[stri[2]]:",
"+ if m02 < ii:",
"+ icnt += 1",
"+ break"
] | false | 0.074142 | 0.119565 | 0.620102 | [
"s253895288",
"s676359854"
] |
u506910932 | p02574 | python | s100269257 | s623593050 | 759 | 639 | 134,420 | 126,936 | Accepted | Accepted | 15.81 | import sys
from math import gcd
input = lambda: sys.stdin.readline().rstrip()
n = int(eval(input()))
A = list(map(int, input().split()))
nowgcd = A[0]
# 全体のGCDを取る
for i in A:
nowgcd = gcd(nowgcd, i)
if nowgcd != 1:
print('not coprime')
exit()
# osa_k法で前処理
MAXN = 10**6 + 5
sieve = [i for i in range(MAXN + 1)]
p = 2
while p * p <= MAXN:
# まだチェックされていないなら
if sieve[p] == p:
# 次のqの倍数からp刻みでチェック入れていく
for q in range(2 * p, MAXN + 1, p):
if sieve[q] == q:
sieve[q] = p
p += 1
check = set()
for a in A:
tmp = set()
while (a > 1):
tmp.add(sieve[a])
a //= sieve[a]
for p in tmp:
if p in check:
print('setwise coprime')
exit()
check.add(p)
print('pairwise coprime')
| import sys
from math import gcd
def osa_k(sieve, MAXN):
p = 2
while p * p <= MAXN:
# まだチェックされていないなら
if sieve[p] == p:
# 次のqの倍数からp刻みでチェック入れていく
for q in range(2 * p, MAXN + 1, p):
if sieve[q] == q:
sieve[q] = p
p += 1
input = lambda: sys.stdin.readline().rstrip()
n = int(eval(input()))
A = list(map(int, input().split()))
nowgcd = A[0]
# 全体のGCDを取る
for i in A:
nowgcd = gcd(nowgcd, i)
if nowgcd != 1:
print('not coprime')
exit()
MAXN = 10**6 + 5
sieve = [i for i in range(MAXN + 1)]
p = 2
osa_k(sieve, MAXN)
check = set()
for a in A:
tmp = set()
while (a > 1):
tmp.add(sieve[a])
a //= sieve[a]
for p in tmp:
if p in check:
print('setwise coprime')
exit()
check.add(p)
print('pairwise coprime')
| 38 | 44 | 825 | 907 | import sys
from math import gcd
input = lambda: sys.stdin.readline().rstrip()
n = int(eval(input()))
A = list(map(int, input().split()))
nowgcd = A[0]
# 全体のGCDを取る
for i in A:
nowgcd = gcd(nowgcd, i)
if nowgcd != 1:
print("not coprime")
exit()
# osa_k法で前処理
MAXN = 10**6 + 5
sieve = [i for i in range(MAXN + 1)]
p = 2
while p * p <= MAXN:
# まだチェックされていないなら
if sieve[p] == p:
# 次のqの倍数からp刻みでチェック入れていく
for q in range(2 * p, MAXN + 1, p):
if sieve[q] == q:
sieve[q] = p
p += 1
check = set()
for a in A:
tmp = set()
while a > 1:
tmp.add(sieve[a])
a //= sieve[a]
for p in tmp:
if p in check:
print("setwise coprime")
exit()
check.add(p)
print("pairwise coprime")
| import sys
from math import gcd
def osa_k(sieve, MAXN):
p = 2
while p * p <= MAXN:
# まだチェックされていないなら
if sieve[p] == p:
# 次のqの倍数からp刻みでチェック入れていく
for q in range(2 * p, MAXN + 1, p):
if sieve[q] == q:
sieve[q] = p
p += 1
input = lambda: sys.stdin.readline().rstrip()
n = int(eval(input()))
A = list(map(int, input().split()))
nowgcd = A[0]
# 全体のGCDを取る
for i in A:
nowgcd = gcd(nowgcd, i)
if nowgcd != 1:
print("not coprime")
exit()
MAXN = 10**6 + 5
sieve = [i for i in range(MAXN + 1)]
p = 2
osa_k(sieve, MAXN)
check = set()
for a in A:
tmp = set()
while a > 1:
tmp.add(sieve[a])
a //= sieve[a]
for p in tmp:
if p in check:
print("setwise coprime")
exit()
check.add(p)
print("pairwise coprime")
| false | 13.636364 | [
"+",
"+",
"+def osa_k(sieve, MAXN):",
"+ p = 2",
"+ while p * p <= MAXN:",
"+ # まだチェックされていないなら",
"+ if sieve[p] == p:",
"+ # 次のqの倍数からp刻みでチェック入れていく",
"+ for q in range(2 * p, MAXN + 1, p):",
"+ if sieve[q] == q:",
"+ sieve[q] = p",
"+ p += 1",
"+",
"-# osa_k法で前処理",
"-while p * p <= MAXN:",
"- # まだチェックされていないなら",
"- if sieve[p] == p:",
"- # 次のqの倍数からp刻みでチェック入れていく",
"- for q in range(2 * p, MAXN + 1, p):",
"- if sieve[q] == q:",
"- sieve[q] = p",
"- p += 1",
"+osa_k(sieve, MAXN)"
] | false | 0.943452 | 0.459596 | 2.052787 | [
"s100269257",
"s623593050"
] |
u583507988 | p02888 | python | s231028940 | s862578208 | 1,003 | 344 | 9,196 | 68,272 | Accepted | Accepted | 65.7 | import bisect
n=int(eval(input()))
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n-2):
for j in range(i+1,n-1):
res=l[i]+l[j]
mid=bisect.bisect_left(l,res)
ans+=mid-j-1
print(ans) | import bisect
n=int(eval(input()))
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n-2):
for j in range(i+1,n-1):
res=l[i]+l[j]
ans+=bisect.bisect_left(l,res)-1-j
print(ans) | 11 | 10 | 214 | 201 | import bisect
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n - 2):
for j in range(i + 1, n - 1):
res = l[i] + l[j]
mid = bisect.bisect_left(l, res)
ans += mid - j - 1
print(ans)
| import bisect
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n - 2):
for j in range(i + 1, n - 1):
res = l[i] + l[j]
ans += bisect.bisect_left(l, res) - 1 - j
print(ans)
| false | 9.090909 | [
"- mid = bisect.bisect_left(l, res)",
"- ans += mid - j - 1",
"+ ans += bisect.bisect_left(l, res) - 1 - j"
] | false | 0.097832 | 0.038221 | 2.559604 | [
"s231028940",
"s862578208"
] |
u620157187 | p02934 | python | s738866325 | s090871465 | 1,977 | 147 | 21,664 | 12,400 | Accepted | Accepted | 92.56 | import numpy as np
N = int(eval(input()))
A_array = np.array([int(x) for x in input().split()])
a_array = np.sum(1/A_array)
print((1/a_array)) | import numpy as np
N = int(eval(input()))
A = [int(x) for x in input().split()]
A_sum = 0
for i in A:
A_sum += 1/i
print((1/A_sum)) | 7 | 10 | 142 | 143 | import numpy as np
N = int(eval(input()))
A_array = np.array([int(x) for x in input().split()])
a_array = np.sum(1 / A_array)
print((1 / a_array))
| import numpy as np
N = int(eval(input()))
A = [int(x) for x in input().split()]
A_sum = 0
for i in A:
A_sum += 1 / i
print((1 / A_sum))
| false | 30 | [
"-A_array = np.array([int(x) for x in input().split()])",
"-a_array = np.sum(1 / A_array)",
"-print((1 / a_array))",
"+A = [int(x) for x in input().split()]",
"+A_sum = 0",
"+for i in A:",
"+ A_sum += 1 / i",
"+print((1 / A_sum))"
] | false | 0.506228 | 0.034538 | 14.657338 | [
"s738866325",
"s090871465"
] |
u644907318 | p02954 | python | s578409830 | s061535623 | 118 | 92 | 17,844 | 83,948 | Accepted | Accepted | 22.03 | S = input().strip()
N = len(S)
A = []
cur = 0
for i in range(1,N):
if S[i]=="R" and S[i-1]=="L":
x = S[cur:i]
A.append((cur,x))
cur = i
A.append((cur,S[cur:N]))
B = [0 for _ in range(N)]
while A:
cur,x = A.pop()
n = len(x)
for i in range(1,n):
if x[i]=="L" and x[i-1]=="R":
ind = i
break
if n%2==0:
B[cur+ind]=n//2
B[cur+ind-1]=n//2
else:
if ind%2==0:
B[cur+ind] = (n+1)//2
B[cur+ind-1]=n//2
else:
B[cur+ind] = n//2
B[cur+ind-1]=(n+1)//2
print((*B)) | S = input().strip()
N = len(S)
A = [0 for _ in range(N)]
flag = 0
curR = 0
for i in range(N):
if flag==0 and S[i]=="L":
curL = i
nR = i-curR
flag = 1
if flag==1 and S[i]=="R":
curR = i
nL = i-curL
flag = 0
if (nR+nL)%2==0:
A[curL-1]=(nR+nL)//2
A[curL] = (nR+nL)//2
else:
if nR>nL and (nR-1)%2==0:
A[curL-1]=(nR+nL+1)//2
A[curL] = (nR+nL)//2
elif nR>nL and (nR-1)%2==1:
A[curL-1]=(nR+nL)//2
A[curL] = (nR+nL+1)//2
elif nL>nR and (nL-1)%2==0:
A[curL-1]=(nR+nL)//2
A[curL]=(nR+nL+1)//2
elif nL>nR and (nL-1)%2==1:
A[curL-1]=(nR+nL+1)//2
A[curL]=(nR+nL)//2
nL = N-curL
if (nR+nL)%2==0:
A[curL-1]=(nR+nL)//2
A[curL] = (nR+nL)//2
else:
if nR>nL and (nR-1)%2==0:
A[curL-1]=(nR+nL+1)//2
A[curL] = (nR+nL)//2
elif nR>nL and (nR-1)%2==1:
A[curL-1]=(nR+nL)//2
A[curL] = (nR+nL+1)//2
elif nL>nR and (nL-1)%2==0:
A[curL-1]=(nR+nL)//2
A[curL]=(nR+nL+1)//2
elif nL>nR and (nL-1)%2==1:
A[curL-1]=(nR+nL+1)//2
A[curL]=(nR+nL)//2
print((*A)) | 29 | 48 | 635 | 1,328 | S = input().strip()
N = len(S)
A = []
cur = 0
for i in range(1, N):
if S[i] == "R" and S[i - 1] == "L":
x = S[cur:i]
A.append((cur, x))
cur = i
A.append((cur, S[cur:N]))
B = [0 for _ in range(N)]
while A:
cur, x = A.pop()
n = len(x)
for i in range(1, n):
if x[i] == "L" and x[i - 1] == "R":
ind = i
break
if n % 2 == 0:
B[cur + ind] = n // 2
B[cur + ind - 1] = n // 2
else:
if ind % 2 == 0:
B[cur + ind] = (n + 1) // 2
B[cur + ind - 1] = n // 2
else:
B[cur + ind] = n // 2
B[cur + ind - 1] = (n + 1) // 2
print((*B))
| S = input().strip()
N = len(S)
A = [0 for _ in range(N)]
flag = 0
curR = 0
for i in range(N):
if flag == 0 and S[i] == "L":
curL = i
nR = i - curR
flag = 1
if flag == 1 and S[i] == "R":
curR = i
nL = i - curL
flag = 0
if (nR + nL) % 2 == 0:
A[curL - 1] = (nR + nL) // 2
A[curL] = (nR + nL) // 2
else:
if nR > nL and (nR - 1) % 2 == 0:
A[curL - 1] = (nR + nL + 1) // 2
A[curL] = (nR + nL) // 2
elif nR > nL and (nR - 1) % 2 == 1:
A[curL - 1] = (nR + nL) // 2
A[curL] = (nR + nL + 1) // 2
elif nL > nR and (nL - 1) % 2 == 0:
A[curL - 1] = (nR + nL) // 2
A[curL] = (nR + nL + 1) // 2
elif nL > nR and (nL - 1) % 2 == 1:
A[curL - 1] = (nR + nL + 1) // 2
A[curL] = (nR + nL) // 2
nL = N - curL
if (nR + nL) % 2 == 0:
A[curL - 1] = (nR + nL) // 2
A[curL] = (nR + nL) // 2
else:
if nR > nL and (nR - 1) % 2 == 0:
A[curL - 1] = (nR + nL + 1) // 2
A[curL] = (nR + nL) // 2
elif nR > nL and (nR - 1) % 2 == 1:
A[curL - 1] = (nR + nL) // 2
A[curL] = (nR + nL + 1) // 2
elif nL > nR and (nL - 1) % 2 == 0:
A[curL - 1] = (nR + nL) // 2
A[curL] = (nR + nL + 1) // 2
elif nL > nR and (nL - 1) % 2 == 1:
A[curL - 1] = (nR + nL + 1) // 2
A[curL] = (nR + nL) // 2
print((*A))
| false | 39.583333 | [
"-A = []",
"-cur = 0",
"-for i in range(1, N):",
"- if S[i] == \"R\" and S[i - 1] == \"L\":",
"- x = S[cur:i]",
"- A.append((cur, x))",
"- cur = i",
"-A.append((cur, S[cur:N]))",
"-B = [0 for _ in range(N)]",
"-while A:",
"- cur, x = A.pop()",
"- n = len(x)",
"- for i in range(1, n):",
"- if x[i] == \"L\" and x[i - 1] == \"R\":",
"- ind = i",
"- break",
"- if n % 2 == 0:",
"- B[cur + ind] = n // 2",
"- B[cur + ind - 1] = n // 2",
"- else:",
"- if ind % 2 == 0:",
"- B[cur + ind] = (n + 1) // 2",
"- B[cur + ind - 1] = n // 2",
"+A = [0 for _ in range(N)]",
"+flag = 0",
"+curR = 0",
"+for i in range(N):",
"+ if flag == 0 and S[i] == \"L\":",
"+ curL = i",
"+ nR = i - curR",
"+ flag = 1",
"+ if flag == 1 and S[i] == \"R\":",
"+ curR = i",
"+ nL = i - curL",
"+ flag = 0",
"+ if (nR + nL) % 2 == 0:",
"+ A[curL - 1] = (nR + nL) // 2",
"+ A[curL] = (nR + nL) // 2",
"- B[cur + ind] = n // 2",
"- B[cur + ind - 1] = (n + 1) // 2",
"-print((*B))",
"+ if nR > nL and (nR - 1) % 2 == 0:",
"+ A[curL - 1] = (nR + nL + 1) // 2",
"+ A[curL] = (nR + nL) // 2",
"+ elif nR > nL and (nR - 1) % 2 == 1:",
"+ A[curL - 1] = (nR + nL) // 2",
"+ A[curL] = (nR + nL + 1) // 2",
"+ elif nL > nR and (nL - 1) % 2 == 0:",
"+ A[curL - 1] = (nR + nL) // 2",
"+ A[curL] = (nR + nL + 1) // 2",
"+ elif nL > nR and (nL - 1) % 2 == 1:",
"+ A[curL - 1] = (nR + nL + 1) // 2",
"+ A[curL] = (nR + nL) // 2",
"+nL = N - curL",
"+if (nR + nL) % 2 == 0:",
"+ A[curL - 1] = (nR + nL) // 2",
"+ A[curL] = (nR + nL) // 2",
"+else:",
"+ if nR > nL and (nR - 1) % 2 == 0:",
"+ A[curL - 1] = (nR + nL + 1) // 2",
"+ A[curL] = (nR + nL) // 2",
"+ elif nR > nL and (nR - 1) % 2 == 1:",
"+ A[curL - 1] = (nR + nL) // 2",
"+ A[curL] = (nR + nL + 1) // 2",
"+ elif nL > nR and (nL - 1) % 2 == 0:",
"+ A[curL - 1] = (nR + nL) // 2",
"+ A[curL] = (nR + nL + 1) // 2",
"+ elif nL > nR and (nL - 1) % 2 == 1:",
"+ A[curL - 1] = (nR + nL + 1) // 2",
"+ A[curL] = (nR + nL) // 2",
"+print((*A))"
] | false | 0.063187 | 0.032842 | 1.923982 | [
"s578409830",
"s061535623"
] |
u761087127 | p02695 | python | s594643412 | s616970309 | 1,237 | 422 | 9,260 | 9,208 | Accepted | Accepted | 65.89 | N, M, Q = [int(n) for n in input().split()]
a, b, c, d = [list(x) for x in zip(*[[int(n) for n in input().split()] for _ in range(Q)])]
ans = 0
def dfs(A):
global ans
if len(A) == N+1:
now = 0
for i in range(Q):
if A[b[i]] - A[a[i]] == c[i]:
now += d[i]
ans = max(ans, now)
return
tail = A[-1] if len(A) > 0 else 1
for v in range(tail, M+1):
A.append(v)
dfs(A)
A.pop()
dfs([])
print(ans) | N, M, Q = [int(n) for n in input().split()]
a, b, c, d = [list(x) for x in zip(*[[int(n) for n in input().split()] for _ in range(Q)])]
ans = 0
def dfs(A):
global ans
if len(A) == N:
now = 0
for i in range(Q):
if A[b[i]-1] - A[a[i]-1] == c[i]: now += d[i]
ans = max(ans, now)
return
for v in range(A[-1], M+1):
A.append(v)
dfs(A)
A.pop()
dfs([1])
print(ans)
| 20 | 20 | 507 | 460 | N, M, Q = [int(n) for n in input().split()]
a, b, c, d = [
list(x) for x in zip(*[[int(n) for n in input().split()] for _ in range(Q)])
]
ans = 0
def dfs(A):
global ans
if len(A) == N + 1:
now = 0
for i in range(Q):
if A[b[i]] - A[a[i]] == c[i]:
now += d[i]
ans = max(ans, now)
return
tail = A[-1] if len(A) > 0 else 1
for v in range(tail, M + 1):
A.append(v)
dfs(A)
A.pop()
dfs([])
print(ans)
| N, M, Q = [int(n) for n in input().split()]
a, b, c, d = [
list(x) for x in zip(*[[int(n) for n in input().split()] for _ in range(Q)])
]
ans = 0
def dfs(A):
global ans
if len(A) == N:
now = 0
for i in range(Q):
if A[b[i] - 1] - A[a[i] - 1] == c[i]:
now += d[i]
ans = max(ans, now)
return
for v in range(A[-1], M + 1):
A.append(v)
dfs(A)
A.pop()
dfs([1])
print(ans)
| false | 0 | [
"- if len(A) == N + 1:",
"+ if len(A) == N:",
"- if A[b[i]] - A[a[i]] == c[i]:",
"+ if A[b[i] - 1] - A[a[i] - 1] == c[i]:",
"- tail = A[-1] if len(A) > 0 else 1",
"- for v in range(tail, M + 1):",
"+ for v in range(A[-1], M + 1):",
"-dfs([])",
"+dfs([1])"
] | false | 0.079953 | 0.044776 | 1.785626 | [
"s594643412",
"s616970309"
] |
u912237403 | p00001 | python | s311379787 | s940958786 | 20 | 10 | 4,192 | 4,188 | Accepted | Accepted | 50 | x=sorted([eval(input()) for i in range(10)])[:-4:-1]
for i in x:print(i) | for i in sorted([eval(input()) for i in range(10)])[:-4:-1]:print(i) | 2 | 1 | 66 | 61 | x = sorted([eval(input()) for i in range(10)])[:-4:-1]
for i in x:
print(i)
| for i in sorted([eval(input()) for i in range(10)])[:-4:-1]:
print(i)
| false | 50 | [
"-x = sorted([eval(input()) for i in range(10)])[:-4:-1]",
"-for i in x:",
"+for i in sorted([eval(input()) for i in range(10)])[:-4:-1]:"
] | false | 0.114971 | 0.146857 | 0.782878 | [
"s311379787",
"s940958786"
] |
u252828980 | p03645 | python | s850739241 | s005813521 | 923 | 710 | 38,368 | 43,308 | Accepted | Accepted | 23.08 | n, m = list(map(int, input().split()))
L = [[]*n for i in range(n)]
for i in range(m):
a,b = list(map(int, input().split()))
L[a-1] += [b]
L[b-1] += [a]
#print(L)
for i in L[0]:
if n in L[i-1]:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
| n, m = list(map(int, input().split()))
L = []
for i in range(m):
a,b = list(map(int, input().split()))
L.append((a,b))
st,go = set(),set()
for i in range(m):
if 1 in L[i]:
st.add(L[i][1])
if n in L[i]:
go.add(L[i][0])
if set(st)&set(go):
print("POSSIBLE")
else:
print("IMPOSSIBLE") | 12 | 17 | 270 | 327 | n, m = list(map(int, input().split()))
L = [[] * n for i in range(n)]
for i in range(m):
a, b = list(map(int, input().split()))
L[a - 1] += [b]
L[b - 1] += [a]
# print(L)
for i in L[0]:
if n in L[i - 1]:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
| n, m = list(map(int, input().split()))
L = []
for i in range(m):
a, b = list(map(int, input().split()))
L.append((a, b))
st, go = set(), set()
for i in range(m):
if 1 in L[i]:
st.add(L[i][1])
if n in L[i]:
go.add(L[i][0])
if set(st) & set(go):
print("POSSIBLE")
else:
print("IMPOSSIBLE")
| false | 29.411765 | [
"-L = [[] * n for i in range(n)]",
"+L = []",
"- L[a - 1] += [b]",
"- L[b - 1] += [a]",
"-# print(L)",
"-for i in L[0]:",
"- if n in L[i - 1]:",
"- print(\"POSSIBLE\")",
"- exit()",
"-print(\"IMPOSSIBLE\")",
"+ L.append((a, b))",
"+st, go = set(), set()",
"+for i in range(m):",
"+ if 1 in L[i]:",
"+ st.add(L[i][1])",
"+ if n in L[i]:",
"+ go.add(L[i][0])",
"+if set(st) & set(go):",
"+ print(\"POSSIBLE\")",
"+else:",
"+ print(\"IMPOSSIBLE\")"
] | false | 0.043537 | 0.045795 | 0.950688 | [
"s850739241",
"s005813521"
] |
u126844573 | p03416 | python | s504550017 | s308128906 | 74 | 65 | 3,444 | 2,940 | Accepted | Accepted | 12.16 | A, B = list(map(int, input().split()))
count = 0
for q in range(A, B + 1):
w = str(q)
if w[:2] == (w[-1] + w[-2]):
count += 1
print(count)
| a, b = list(map(int, input().split()))
ans = 0
for q in range(a, b + 1):
if q == int(str(q)[::-1]):
ans += 1
print(ans) | 8 | 6 | 157 | 130 | A, B = list(map(int, input().split()))
count = 0
for q in range(A, B + 1):
w = str(q)
if w[:2] == (w[-1] + w[-2]):
count += 1
print(count)
| a, b = list(map(int, input().split()))
ans = 0
for q in range(a, b + 1):
if q == int(str(q)[::-1]):
ans += 1
print(ans)
| false | 25 | [
"-A, B = list(map(int, input().split()))",
"-count = 0",
"-for q in range(A, B + 1):",
"- w = str(q)",
"- if w[:2] == (w[-1] + w[-2]):",
"- count += 1",
"-print(count)",
"+a, b = list(map(int, input().split()))",
"+ans = 0",
"+for q in range(a, b + 1):",
"+ if q == int(str(q)[::-1]):",
"+ ans += 1",
"+print(ans)"
] | false | 0.047242 | 0.046563 | 1.014571 | [
"s504550017",
"s308128906"
] |
u841531687 | p03162 | python | s794022524 | s639011578 | 935 | 665 | 47,336 | 74,072 | Accepted | Accepted | 28.88 | N = int(eval(input()))
plans = [list(map(int, input().split())) for _ in range(N)]
dp = [[0] * (3) for _ in range(N+1)]
def chmax(a, b):
if a >= b:
return a
else:
return b
for i in range(N):
for j in range(3):
for k in range(3):
if j == k:
continue
else:
dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + plans[i][k])
res = 0
for j in range(3):
res = chmax(res, dp[-1][j])
print(res) | N = int(eval(input()))
h = [list(map(int, input().split())) for _ in range(N)] #1-index
def chmax(a,b):
if a >= b:
return a
else:
return b
dp = [[0]*(3) for _ in range(N+2)]
for i in range(N):
for j in range(3):
for k in range(3):
if (j == k): continue
dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + h[i][k])
print((max(dp[N]))) | 22 | 16 | 505 | 392 | N = int(eval(input()))
plans = [list(map(int, input().split())) for _ in range(N)]
dp = [[0] * (3) for _ in range(N + 1)]
def chmax(a, b):
if a >= b:
return a
else:
return b
for i in range(N):
for j in range(3):
for k in range(3):
if j == k:
continue
else:
dp[i + 1][k] = chmax(dp[i + 1][k], dp[i][j] + plans[i][k])
res = 0
for j in range(3):
res = chmax(res, dp[-1][j])
print(res)
| N = int(eval(input()))
h = [list(map(int, input().split())) for _ in range(N)] # 1-index
def chmax(a, b):
if a >= b:
return a
else:
return b
dp = [[0] * (3) for _ in range(N + 2)]
for i in range(N):
for j in range(3):
for k in range(3):
if j == k:
continue
dp[i + 1][k] = chmax(dp[i + 1][k], dp[i][j] + h[i][k])
print((max(dp[N])))
| false | 27.272727 | [
"-plans = [list(map(int, input().split())) for _ in range(N)]",
"-dp = [[0] * (3) for _ in range(N + 1)]",
"+h = [list(map(int, input().split())) for _ in range(N)] # 1-index",
"+dp = [[0] * (3) for _ in range(N + 2)]",
"- else:",
"- dp[i + 1][k] = chmax(dp[i + 1][k], dp[i][j] + plans[i][k])",
"-res = 0",
"-for j in range(3):",
"- res = chmax(res, dp[-1][j])",
"-print(res)",
"+ dp[i + 1][k] = chmax(dp[i + 1][k], dp[i][j] + h[i][k])",
"+print((max(dp[N])))"
] | false | 0.041868 | 0.043137 | 0.970589 | [
"s794022524",
"s639011578"
] |
u767664985 | p02720 | python | s368620546 | s570374710 | 501 | 272 | 10,720 | 12,228 | Accepted | Accepted | 45.71 | from heapq import heapify, heappop, heappush
# 次の桁の生成ルール ex. 1 -> 10, 11, 12
def next_int(n):
nums = {0: [0, 1],
1: [0, 1, 2],
2: [1, 2, 3],
3: [2, 3, 4],
4: [3, 4, 5],
5: [4, 5, 6],
6: [5, 6, 7],
7: [6, 7, 8],
8: [7, 8, 9],
9: [8, 9]}
return nums[n]
K = int(eval(input()))
queue = [1, 2, 3, 4, 5, 6, 7, 8, 9] # とりあえず 1 桁目を初期値にとる
heapify(queue)
for _ in range(K-1):
now = heappop(queue) # 最小値を取り出す
# 取り出した値を使って次の桁を生成し queue に投げる
for next_i in next_int(int(str(now)[-1])):
heappush(queue, int(str(now)+str(next_i)))
print((heappop(queue))) # K 回目に取り出す最小値
| from heapq import heapify, heappop, heappush
# 次の桁の生成ルール ex. 1 -> 10, 11, 12
def next_int(n):
nums = {0: [0, 1],
1: [0, 1, 2],
2: [1, 2, 3],
3: [2, 3, 4],
4: [3, 4, 5],
5: [4, 5, 6],
6: [5, 6, 7],
7: [6, 7, 8],
8: [7, 8, 9],
9: [8, 9]}
return nums[n]
K = int(eval(input()))
queue = [1, 2, 3, 4, 5, 6, 7, 8, 9] # とりあえず 1 桁目を初期値にとる
heapify(queue)
for _ in range(K-1):
now = heappop(queue) # 最小値を取り出す
# 取り出した値を使って次の桁を生成し queue に投げる
for next_i in next_int(now%10):
heappush(queue, now*10 + next_i)
print((heappop(queue))) # K 回目に取り出す最小値
| 27 | 27 | 715 | 694 | from heapq import heapify, heappop, heappush
# 次の桁の生成ルール ex. 1 -> 10, 11, 12
def next_int(n):
nums = {
0: [0, 1],
1: [0, 1, 2],
2: [1, 2, 3],
3: [2, 3, 4],
4: [3, 4, 5],
5: [4, 5, 6],
6: [5, 6, 7],
7: [6, 7, 8],
8: [7, 8, 9],
9: [8, 9],
}
return nums[n]
K = int(eval(input()))
queue = [1, 2, 3, 4, 5, 6, 7, 8, 9] # とりあえず 1 桁目を初期値にとる
heapify(queue)
for _ in range(K - 1):
now = heappop(queue) # 最小値を取り出す
# 取り出した値を使って次の桁を生成し queue に投げる
for next_i in next_int(int(str(now)[-1])):
heappush(queue, int(str(now) + str(next_i)))
print((heappop(queue))) # K 回目に取り出す最小値
| from heapq import heapify, heappop, heappush
# 次の桁の生成ルール ex. 1 -> 10, 11, 12
def next_int(n):
nums = {
0: [0, 1],
1: [0, 1, 2],
2: [1, 2, 3],
3: [2, 3, 4],
4: [3, 4, 5],
5: [4, 5, 6],
6: [5, 6, 7],
7: [6, 7, 8],
8: [7, 8, 9],
9: [8, 9],
}
return nums[n]
K = int(eval(input()))
queue = [1, 2, 3, 4, 5, 6, 7, 8, 9] # とりあえず 1 桁目を初期値にとる
heapify(queue)
for _ in range(K - 1):
now = heappop(queue) # 最小値を取り出す
# 取り出した値を使って次の桁を生成し queue に投げる
for next_i in next_int(now % 10):
heappush(queue, now * 10 + next_i)
print((heappop(queue))) # K 回目に取り出す最小値
| false | 0 | [
"- for next_i in next_int(int(str(now)[-1])):",
"- heappush(queue, int(str(now) + str(next_i)))",
"+ for next_i in next_int(now % 10):",
"+ heappush(queue, now * 10 + next_i)"
] | false | 0.079126 | 0.058245 | 1.358515 | [
"s368620546",
"s570374710"
] |
u729133443 | p02888 | python | s913622729 | s675222922 | 1,440 | 1,049 | 49,344 | 3,188 | Accepted | Accepted | 27.15 | from bisect import*
n,*l=list(map(int,open(0).read().split()))
l.sort()
A=0
for i in range(n):
a=l[i]
for j in range(i+1,n):
b=l[j]
k1=max(j+1,bisect(l,b-a))
k2=bisect_left(l,a+b)
A+=max(0,k2-k1)
print(A) | from bisect import*
n,*l=list(map(int,open(0).read().split()))
l.sort()
print((sum(~j+bisect_left(l,l[i]+l[j],j+1)for i in range(n)for j in range(i+1,n)))) | 12 | 4 | 249 | 150 | from bisect import *
n, *l = list(map(int, open(0).read().split()))
l.sort()
A = 0
for i in range(n):
a = l[i]
for j in range(i + 1, n):
b = l[j]
k1 = max(j + 1, bisect(l, b - a))
k2 = bisect_left(l, a + b)
A += max(0, k2 - k1)
print(A)
| from bisect import *
n, *l = list(map(int, open(0).read().split()))
l.sort()
print(
(
sum(
~j + bisect_left(l, l[i] + l[j], j + 1)
for i in range(n)
for j in range(i + 1, n)
)
)
)
| false | 66.666667 | [
"-A = 0",
"-for i in range(n):",
"- a = l[i]",
"- for j in range(i + 1, n):",
"- b = l[j]",
"- k1 = max(j + 1, bisect(l, b - a))",
"- k2 = bisect_left(l, a + b)",
"- A += max(0, k2 - k1)",
"-print(A)",
"+print(",
"+ (",
"+ sum(",
"+ ~j + bisect_left(l, l[i] + l[j], j + 1)",
"+ for i in range(n)",
"+ for j in range(i + 1, n)",
"+ )",
"+ )",
"+)"
] | false | 0.038325 | 0.04233 | 0.905392 | [
"s913622729",
"s675222922"
] |
u623231048 | p02996 | python | s060927214 | s821731949 | 1,045 | 588 | 53,600 | 53,608 | Accepted | Accepted | 43.73 | n = int(eval(input()))
li = [list(map(int,input().split())) for _ in range(n)]
li.sort(key = lambda x: x[1])
time = 0
for i,j in li:
time += i
if time > j:
print('No')
exit()
print('Yes')
| import sys
input = sys.stdin.readline
n = int(eval(input()))
li = [list(map(int,input().split())) for _ in range(n)]
li.sort(key = lambda x: x[1])
time = 0
for i,j in li:
time += i
if time > j:
print('No')
exit()
print('Yes')
| 14 | 17 | 223 | 265 | n = int(eval(input()))
li = [list(map(int, input().split())) for _ in range(n)]
li.sort(key=lambda x: x[1])
time = 0
for i, j in li:
time += i
if time > j:
print("No")
exit()
print("Yes")
| import sys
input = sys.stdin.readline
n = int(eval(input()))
li = [list(map(int, input().split())) for _ in range(n)]
li.sort(key=lambda x: x[1])
time = 0
for i, j in li:
time += i
if time > j:
print("No")
exit()
print("Yes")
| false | 17.647059 | [
"+import sys",
"+",
"+input = sys.stdin.readline"
] | false | 0.041352 | 0.036479 | 1.133592 | [
"s060927214",
"s821731949"
] |
u965436898 | p03244 | python | s078235334 | s091975757 | 117 | 80 | 16,228 | 18,548 | Accepted | Accepted | 31.62 | from collections import Counter
n = int(eval(input()))
V = list(map(int,input().split()))
if len(set(V)) == 1:
print((n//2))
else:
odd = []
even = []
for i in range(len(V)):
if i % 2 == 0:
even.append(V[i])
else:
odd.append(V[i])
max_even,max_e_count = Counter(even).most_common(1)[0]
max_odd,max_o_count = Counter(odd).most_common(1)[0]
if max_even == max_odd:
sec_even,sec_e_count = Counter(even).most_common(2)[1]
sec_odd,sec_o_count = Counter(odd).most_common(2)[1]
even_rank2 = len(odd) - max_o_count + len(even) - sec_e_count
odd_rank2 = len(odd) - sec_o_count + len(even) - max_e_count
print((min(even_rank2,odd_rank2)))
else:
print((len(odd) - max_o_count + len(even) - max_e_count)) | import itertools
from collections import Counter
N = int(eval(input()))
V = list(map(int,input().split()))
even_counter = Counter(V[::2])
odd_counter = Counter(V[1::2])
even_counter[-1] = 0
odd_counter[-1] = 0
even = even_counter.most_common(2)
odd = odd_counter.most_common(2)
ans = N
for (k1,v1),(k2,v2) in itertools.product(even,odd):
if k1 == k2:
continue
ans = min(ans,N - v1 - v2)
print(ans) | 23 | 16 | 761 | 414 | from collections import Counter
n = int(eval(input()))
V = list(map(int, input().split()))
if len(set(V)) == 1:
print((n // 2))
else:
odd = []
even = []
for i in range(len(V)):
if i % 2 == 0:
even.append(V[i])
else:
odd.append(V[i])
max_even, max_e_count = Counter(even).most_common(1)[0]
max_odd, max_o_count = Counter(odd).most_common(1)[0]
if max_even == max_odd:
sec_even, sec_e_count = Counter(even).most_common(2)[1]
sec_odd, sec_o_count = Counter(odd).most_common(2)[1]
even_rank2 = len(odd) - max_o_count + len(even) - sec_e_count
odd_rank2 = len(odd) - sec_o_count + len(even) - max_e_count
print((min(even_rank2, odd_rank2)))
else:
print((len(odd) - max_o_count + len(even) - max_e_count))
| import itertools
from collections import Counter
N = int(eval(input()))
V = list(map(int, input().split()))
even_counter = Counter(V[::2])
odd_counter = Counter(V[1::2])
even_counter[-1] = 0
odd_counter[-1] = 0
even = even_counter.most_common(2)
odd = odd_counter.most_common(2)
ans = N
for (k1, v1), (k2, v2) in itertools.product(even, odd):
if k1 == k2:
continue
ans = min(ans, N - v1 - v2)
print(ans)
| false | 30.434783 | [
"+import itertools",
"-n = int(eval(input()))",
"+N = int(eval(input()))",
"-if len(set(V)) == 1:",
"- print((n // 2))",
"-else:",
"- odd = []",
"- even = []",
"- for i in range(len(V)):",
"- if i % 2 == 0:",
"- even.append(V[i])",
"- else:",
"- odd.append(V[i])",
"- max_even, max_e_count = Counter(even).most_common(1)[0]",
"- max_odd, max_o_count = Counter(odd).most_common(1)[0]",
"- if max_even == max_odd:",
"- sec_even, sec_e_count = Counter(even).most_common(2)[1]",
"- sec_odd, sec_o_count = Counter(odd).most_common(2)[1]",
"- even_rank2 = len(odd) - max_o_count + len(even) - sec_e_count",
"- odd_rank2 = len(odd) - sec_o_count + len(even) - max_e_count",
"- print((min(even_rank2, odd_rank2)))",
"- else:",
"- print((len(odd) - max_o_count + len(even) - max_e_count))",
"+even_counter = Counter(V[::2])",
"+odd_counter = Counter(V[1::2])",
"+even_counter[-1] = 0",
"+odd_counter[-1] = 0",
"+even = even_counter.most_common(2)",
"+odd = odd_counter.most_common(2)",
"+ans = N",
"+for (k1, v1), (k2, v2) in itertools.product(even, odd):",
"+ if k1 == k2:",
"+ continue",
"+ ans = min(ans, N - v1 - v2)",
"+print(ans)"
] | false | 0.007781 | 0.035548 | 0.218876 | [
"s078235334",
"s091975757"
] |
u532966492 | p02728 | python | s681623960 | s979048295 | 2,161 | 1,280 | 161,080 | 148,024 | Accepted | Accepted | 40.77 | def main():
n = int(eval(input()))
ab = [list(map(int, input().split())) for _ in [0]*(n-1)]
g = [[] for _ in [0]*n]
[g[a-1].append(b-1) for a, b in ab]
[g[b-1].append(a-1) for a, b in ab]
mod = 10**9+7
fact = [1, 1]
for i in range(2, n+1):
fact.append(fact[-1]*i % mod)
def inv_n(n):
return pow(n, mod-2, mod)
def nCr(n, r, mod=10**9+7):
return pow(fact[n-r]*fact[r] % mod, mod-2, mod)*fact[n] % mod
class rerooting():
# addは頂点iに頂点jを根とする部分木(DPの値:x)をくっつけるときの補正
def __init__(self, tree, ini):
# merge:頂点aにbをマージするときのモノイド
# adj_bu:ボトムアップ時の調整(a:値,i:頂点)
# adj_td:トップダウン時の調整(a:値,i:頂点,p:親)
# adj_fin:最終調整(a:値,i:頂点)
def merge(a, b): return a * b % mod
def adj_bu(a, i): return a * inv_n(size[i]) % mod
def adj_td(a, i, p): return a * inv_n(n-size[i]) % mod
def adj_fin(a, i): return a * fact[n-1] % mod
# トポロジカルソートをする
# T:木の隣接グラフ表現をset化
# P:親
# q:キュー
# order:トポソしたもの
T = [set(i) for i in tree]
P = [-1]*n
q = [0]
order = []
while q:
i = q.pop()
order.append(i)
for a in T[i]:
if a != P[i]:
P[a] = i
T[a].remove(i)
q.append(a)
# Tをリストに変換
T = [list(i) for i in T]
# サイズの処理を先に行う
# size[i]:0を根とする根付き木における、iを根とする部分木の大きさ
size = [1]*n
for i in order[1:][::-1]:
size[P[i]] += size[i]
# ボトムアップ処理をする
# ME:マージした値を一時保存
# DP:DP値、MEを調整したもの
ME = [ini]*n
DP = [0]*n
for i in order[1:][::-1]:
DP[i] = adj_bu(ME[i], i)
p = P[i]
ME[p] = merge(ME[p], DP[i])
DP[order[0]] = adj_fin(ME[order[0]], order[0])
TD = [ini]*n
# トップダウン処理をする
for i in order:
# 左からDP(結果はTDに入れている)
ac = TD[i]
for j in T[i]:
TD[j] = ac
ac = merge(ac, DP[j])
# 右からDP(結果はacに入れている、一度しか使わないのでacで問題ない)
ac = ini
for j in T[i][::-1]:
TD[j] = adj_td(merge(TD[j], ac), j, i)
ac = merge(ac, DP[j])
DP[j] = adj_fin(merge(ME[j], TD[j]), j)
for i in DP:
print(i)
rerooting(g, 1)
main() | def main():
from sys import stdin
input = stdin.readline
n = int(eval(input()))
ab = [list(map(int, input().split())) for _ in [0]*(n-1)]
g = [set() for _ in [0]*n]
for a, b in ab:
g[a-1].add(b-1)
g[b-1].add(a-1)
mod = 10**9+7
fact = [1, 1]
inv = [pow(i, mod-2, mod) for i in range(n+1)]
for i in range(2, n+1):
fact.append(fact[-1]*i % mod)
class rerooting():
# addは頂点iに頂点jを根とする部分木(DPの値:x)をくっつけるときの補正
def __init__(self, tree, ini):
# merge:頂点aにbをマージするときのモノイド
# adj_bu:ボトムアップ時の調整(a:値,i:頂点)
# adj_td:トップダウン時の調整(a:値,i:頂点,p:親)
# adj_fin:最終調整(a:値,i:頂点)
def merge(a, b): return a * b % mod
def adj_bu(a, i): return a * inv[size[i]] % mod
def adj_td(a, i, p): return a * inv[n-size[i]] % mod
def adj_fin(a, i): return a * fact[n-1] % mod
# トポロジカルソートをする
# T:木の隣接グラフ表現をset化
# P:親
# q:キュー
# order:トポソしたもの
T = g
P = [-1]*n
q = [0]
order = []
while q:
i = q.pop()
order.append(i)
for a in T[i]:
if a != P[i]:
P[a] = i
T[a].remove(i)
q.append(a)
# Tをリストに変換
T = [list(i) for i in T]
# サイズの処理を先に行う
# size[i]:0を根とする根付き木における、iを根とする部分木の大きさ
size = [1]*n
for i in order[1:][::-1]:
size[P[i]] += size[i]
# ボトムアップ処理をする
# ME:マージした値を一時保存
# DP:DP値、MEを調整したもの
ME = [ini]*n
DP = [0]*n
for i in order[1:][::-1]:
DP[i] = adj_bu(ME[i], i)
p = P[i]
ME[p] = merge(ME[p], DP[i])
DP[order[0]] = adj_fin(ME[order[0]], order[0])
TD = [ini]*n
# トップダウン処理をする
for i in order:
# 左からDP(結果はTDに入れている)
ac = TD[i]
for j in T[i]:
TD[j] = ac
ac = merge(ac, DP[j])
# 右からDP(結果はacに入れている、一度しか使わないのでacで問題ない)
ac = ini
for j in T[i][::-1]:
TD[j] = adj_td(merge(TD[j], ac), j, i)
ac = merge(ac, DP[j])
DP[j] = adj_fin(merge(ME[j], TD[j]), j)
for i in DP:
print(i)
rerooting(g, 1)
main()
| 90 | 88 | 2,734 | 2,647 | def main():
n = int(eval(input()))
ab = [list(map(int, input().split())) for _ in [0] * (n - 1)]
g = [[] for _ in [0] * n]
[g[a - 1].append(b - 1) for a, b in ab]
[g[b - 1].append(a - 1) for a, b in ab]
mod = 10**9 + 7
fact = [1, 1]
for i in range(2, n + 1):
fact.append(fact[-1] * i % mod)
def inv_n(n):
return pow(n, mod - 2, mod)
def nCr(n, r, mod=10**9 + 7):
return pow(fact[n - r] * fact[r] % mod, mod - 2, mod) * fact[n] % mod
class rerooting:
# addは頂点iに頂点jを根とする部分木(DPの値:x)をくっつけるときの補正
def __init__(self, tree, ini):
# merge:頂点aにbをマージするときのモノイド
# adj_bu:ボトムアップ時の調整(a:値,i:頂点)
# adj_td:トップダウン時の調整(a:値,i:頂点,p:親)
# adj_fin:最終調整(a:値,i:頂点)
def merge(a, b):
return a * b % mod
def adj_bu(a, i):
return a * inv_n(size[i]) % mod
def adj_td(a, i, p):
return a * inv_n(n - size[i]) % mod
def adj_fin(a, i):
return a * fact[n - 1] % mod
# トポロジカルソートをする
# T:木の隣接グラフ表現をset化
# P:親
# q:キュー
# order:トポソしたもの
T = [set(i) for i in tree]
P = [-1] * n
q = [0]
order = []
while q:
i = q.pop()
order.append(i)
for a in T[i]:
if a != P[i]:
P[a] = i
T[a].remove(i)
q.append(a)
# Tをリストに変換
T = [list(i) for i in T]
# サイズの処理を先に行う
# size[i]:0を根とする根付き木における、iを根とする部分木の大きさ
size = [1] * n
for i in order[1:][::-1]:
size[P[i]] += size[i]
# ボトムアップ処理をする
# ME:マージした値を一時保存
# DP:DP値、MEを調整したもの
ME = [ini] * n
DP = [0] * n
for i in order[1:][::-1]:
DP[i] = adj_bu(ME[i], i)
p = P[i]
ME[p] = merge(ME[p], DP[i])
DP[order[0]] = adj_fin(ME[order[0]], order[0])
TD = [ini] * n
# トップダウン処理をする
for i in order:
# 左からDP(結果はTDに入れている)
ac = TD[i]
for j in T[i]:
TD[j] = ac
ac = merge(ac, DP[j])
# 右からDP(結果はacに入れている、一度しか使わないのでacで問題ない)
ac = ini
for j in T[i][::-1]:
TD[j] = adj_td(merge(TD[j], ac), j, i)
ac = merge(ac, DP[j])
DP[j] = adj_fin(merge(ME[j], TD[j]), j)
for i in DP:
print(i)
rerooting(g, 1)
main()
| def main():
from sys import stdin
input = stdin.readline
n = int(eval(input()))
ab = [list(map(int, input().split())) for _ in [0] * (n - 1)]
g = [set() for _ in [0] * n]
for a, b in ab:
g[a - 1].add(b - 1)
g[b - 1].add(a - 1)
mod = 10**9 + 7
fact = [1, 1]
inv = [pow(i, mod - 2, mod) for i in range(n + 1)]
for i in range(2, n + 1):
fact.append(fact[-1] * i % mod)
class rerooting:
# addは頂点iに頂点jを根とする部分木(DPの値:x)をくっつけるときの補正
def __init__(self, tree, ini):
# merge:頂点aにbをマージするときのモノイド
# adj_bu:ボトムアップ時の調整(a:値,i:頂点)
# adj_td:トップダウン時の調整(a:値,i:頂点,p:親)
# adj_fin:最終調整(a:値,i:頂点)
def merge(a, b):
return a * b % mod
def adj_bu(a, i):
return a * inv[size[i]] % mod
def adj_td(a, i, p):
return a * inv[n - size[i]] % mod
def adj_fin(a, i):
return a * fact[n - 1] % mod
# トポロジカルソートをする
# T:木の隣接グラフ表現をset化
# P:親
# q:キュー
# order:トポソしたもの
T = g
P = [-1] * n
q = [0]
order = []
while q:
i = q.pop()
order.append(i)
for a in T[i]:
if a != P[i]:
P[a] = i
T[a].remove(i)
q.append(a)
# Tをリストに変換
T = [list(i) for i in T]
# サイズの処理を先に行う
# size[i]:0を根とする根付き木における、iを根とする部分木の大きさ
size = [1] * n
for i in order[1:][::-1]:
size[P[i]] += size[i]
# ボトムアップ処理をする
# ME:マージした値を一時保存
# DP:DP値、MEを調整したもの
ME = [ini] * n
DP = [0] * n
for i in order[1:][::-1]:
DP[i] = adj_bu(ME[i], i)
p = P[i]
ME[p] = merge(ME[p], DP[i])
DP[order[0]] = adj_fin(ME[order[0]], order[0])
TD = [ini] * n
# トップダウン処理をする
for i in order:
# 左からDP(結果はTDに入れている)
ac = TD[i]
for j in T[i]:
TD[j] = ac
ac = merge(ac, DP[j])
# 右からDP(結果はacに入れている、一度しか使わないのでacで問題ない)
ac = ini
for j in T[i][::-1]:
TD[j] = adj_td(merge(TD[j], ac), j, i)
ac = merge(ac, DP[j])
DP[j] = adj_fin(merge(ME[j], TD[j]), j)
for i in DP:
print(i)
rerooting(g, 1)
main()
| false | 2.222222 | [
"+ from sys import stdin",
"+",
"+ input = stdin.readline",
"- g = [[] for _ in [0] * n]",
"- [g[a - 1].append(b - 1) for a, b in ab]",
"- [g[b - 1].append(a - 1) for a, b in ab]",
"+ g = [set() for _ in [0] * n]",
"+ for a, b in ab:",
"+ g[a - 1].add(b - 1)",
"+ g[b - 1].add(a - 1)",
"+ inv = [pow(i, mod - 2, mod) for i in range(n + 1)]",
"-",
"- def inv_n(n):",
"- return pow(n, mod - 2, mod)",
"-",
"- def nCr(n, r, mod=10**9 + 7):",
"- return pow(fact[n - r] * fact[r] % mod, mod - 2, mod) * fact[n] % mod",
"- return a * inv_n(size[i]) % mod",
"+ return a * inv[size[i]] % mod",
"- return a * inv_n(n - size[i]) % mod",
"+ return a * inv[n - size[i]] % mod",
"- T = [set(i) for i in tree]",
"+ T = g"
] | false | 0.037973 | 0.03805 | 0.997969 | [
"s681623960",
"s979048295"
] |
u312025627 | p03077 | python | s166711011 | s939412661 | 185 | 161 | 38,256 | 38,256 | Accepted | Accepted | 12.97 | def main():
N = int(eval(input()))
T = [int(eval(input())) for i in range(5)]
minT = min(T)
bo = (N + minT - 1)//minT
print((4+bo))
if __name__ == '__main__':
main()
| def main():
N = int(eval(input()))
A = [int(eval(input())) for i in range(5)]
print((0--N//min(A) + 4))
if __name__ == '__main__':
main()
| 10 | 8 | 187 | 149 | def main():
N = int(eval(input()))
T = [int(eval(input())) for i in range(5)]
minT = min(T)
bo = (N + minT - 1) // minT
print((4 + bo))
if __name__ == "__main__":
main()
| def main():
N = int(eval(input()))
A = [int(eval(input())) for i in range(5)]
print((0 - -N // min(A) + 4))
if __name__ == "__main__":
main()
| false | 20 | [
"- T = [int(eval(input())) for i in range(5)]",
"- minT = min(T)",
"- bo = (N + minT - 1) // minT",
"- print((4 + bo))",
"+ A = [int(eval(input())) for i in range(5)]",
"+ print((0 - -N // min(A) + 4))"
] | false | 0.04326 | 0.107651 | 0.401852 | [
"s166711011",
"s939412661"
] |
u440566786 | p02579 | python | s655756312 | s379297985 | 1,452 | 918 | 94,620 | 133,264 | Accepted | Accepted | 36.78 | import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from collections import deque
from itertools import product
def resolve():
m, n = list(map(int, input().split()))
si, sj = [int(x) - 1 for x in input().split()]
ti, tj = [int(x) - 1 for x in input().split()]
grid = [eval(input()) for _ in range(m)]
queue = deque([(si, sj)])
dist = [[INF] * n for _ in range(m)]
dist[si][sj] = 0
while queue:
i, j = queue.popleft()
for di, dj in product(list(range(-2, 3)), repeat = 2):
if di == dj == 0:
continue
ni, nj = i + di, j + dj
if not (0 <= ni < m and 0 <= nj < n):
continue
if grid[ni][nj] == '#':
continue
dd = int(abs(di) + abs(dj) > 1)
nd = dist[i][j] + dd
if nd < dist[ni][nj]:
dist[ni][nj] = nd
if dd == 0:
queue.appendleft((ni, nj))
else:
queue.append((ni, nj))
ans = dist[ti][tj]
if ans == INF:
ans = -1
print(ans)
resolve() | import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from collections import deque
from itertools import product
def resolve():
m, n = list(map(int, input().split()))
si, sj = [int(x) - 1 for x in input().split()]
ti, tj = [int(x) - 1 for x in input().split()]
grid = [eval(input()) for _ in range(m)]
queue = deque([(si, sj, 0)])
dist = [[INF] * n for _ in range(m)]
dist[si][sj] = 0
while queue:
i, j, d = queue.popleft()
if d > dist[i][j]:
continue
for di, dj in product(list(range(-2, 3)), repeat = 2):
if di == dj == 0:
continue
ni, nj = i + di, j + dj
if not (0 <= ni < m and 0 <= nj < n):
continue
if grid[ni][nj] == '#':
continue
dd = int(abs(di) + abs(dj) > 1)
nd = dist[i][j] + dd
if nd < dist[ni][nj]:
dist[ni][nj] = nd
if dd == 0:
queue.appendleft((ni, nj, nd))
else:
queue.append((ni, nj, nd))
ans = dist[ti][tj]
if ans == INF:
ans = -1
print(ans)
resolve() | 41 | 43 | 1,232 | 1,296 | import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda: sys.stdin.readline().rstrip()
from collections import deque
from itertools import product
def resolve():
m, n = list(map(int, input().split()))
si, sj = [int(x) - 1 for x in input().split()]
ti, tj = [int(x) - 1 for x in input().split()]
grid = [eval(input()) for _ in range(m)]
queue = deque([(si, sj)])
dist = [[INF] * n for _ in range(m)]
dist[si][sj] = 0
while queue:
i, j = queue.popleft()
for di, dj in product(list(range(-2, 3)), repeat=2):
if di == dj == 0:
continue
ni, nj = i + di, j + dj
if not (0 <= ni < m and 0 <= nj < n):
continue
if grid[ni][nj] == "#":
continue
dd = int(abs(di) + abs(dj) > 1)
nd = dist[i][j] + dd
if nd < dist[ni][nj]:
dist[ni][nj] = nd
if dd == 0:
queue.appendleft((ni, nj))
else:
queue.append((ni, nj))
ans = dist[ti][tj]
if ans == INF:
ans = -1
print(ans)
resolve()
| import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda: sys.stdin.readline().rstrip()
from collections import deque
from itertools import product
def resolve():
m, n = list(map(int, input().split()))
si, sj = [int(x) - 1 for x in input().split()]
ti, tj = [int(x) - 1 for x in input().split()]
grid = [eval(input()) for _ in range(m)]
queue = deque([(si, sj, 0)])
dist = [[INF] * n for _ in range(m)]
dist[si][sj] = 0
while queue:
i, j, d = queue.popleft()
if d > dist[i][j]:
continue
for di, dj in product(list(range(-2, 3)), repeat=2):
if di == dj == 0:
continue
ni, nj = i + di, j + dj
if not (0 <= ni < m and 0 <= nj < n):
continue
if grid[ni][nj] == "#":
continue
dd = int(abs(di) + abs(dj) > 1)
nd = dist[i][j] + dd
if nd < dist[ni][nj]:
dist[ni][nj] = nd
if dd == 0:
queue.appendleft((ni, nj, nd))
else:
queue.append((ni, nj, nd))
ans = dist[ti][tj]
if ans == INF:
ans = -1
print(ans)
resolve()
| false | 4.651163 | [
"- queue = deque([(si, sj)])",
"+ queue = deque([(si, sj, 0)])",
"- i, j = queue.popleft()",
"+ i, j, d = queue.popleft()",
"+ if d > dist[i][j]:",
"+ continue",
"- queue.appendleft((ni, nj))",
"+ queue.appendleft((ni, nj, nd))",
"- queue.append((ni, nj))",
"+ queue.append((ni, nj, nd))"
] | false | 0.052318 | 0.050861 | 1.028639 | [
"s655756312",
"s379297985"
] |
u430928274 | p02823 | python | s336609424 | s114757671 | 29 | 26 | 9,092 | 9,092 | Accepted | Accepted | 10.34 | n, a, b = list(map(int, input().split()))
if (b-a)%2 == 0 :
print(((b-a)//2))
else :
print(((b-a)//2 + min(a-1,n-b) + 1))
| n, a, b = list(map(int, input().split()))
print(((b-a)//2 + min(a-1,n-b) + 1 if (b-a)%2 else (b-a)//2)) | 5 | 2 | 124 | 96 | n, a, b = list(map(int, input().split()))
if (b - a) % 2 == 0:
print(((b - a) // 2))
else:
print(((b - a) // 2 + min(a - 1, n - b) + 1))
| n, a, b = list(map(int, input().split()))
print(((b - a) // 2 + min(a - 1, n - b) + 1 if (b - a) % 2 else (b - a) // 2))
| false | 60 | [
"-if (b - a) % 2 == 0:",
"- print(((b - a) // 2))",
"-else:",
"- print(((b - a) // 2 + min(a - 1, n - b) + 1))",
"+print(((b - a) // 2 + min(a - 1, n - b) + 1 if (b - a) % 2 else (b - a) // 2))"
] | false | 0.066475 | 0.046728 | 1.422592 | [
"s336609424",
"s114757671"
] |
u021548497 | p02996 | python | s143214820 | s352869039 | 1,027 | 929 | 35,608 | 29,400 | Accepted | Accepted | 9.54 | n = int(eval(input()))
work = [0]*n
for i in range(n):
a, b = list(map(int, input().split()))
work[i] = [b, a]
work.sort()
key = 0
ans = True
for i in range(n):
if key + work[i][1]> work[i][0]:
ans = False
break
key += work[i][1]
if ans:
print("Yes")
else:
print("No") | n = int(eval(input()))
jobs = [None]*n
for i in range(n):
a, b = list(map(int, input().split()))
jobs[i] = (b, a)
jobs.sort()
ans = True
sub = 0
for i in range(n):
b, a = jobs[i][0], jobs[i][1]
sub += a
if sub > b:
ans = False
break
print(("Yes" if ans else "No")) | 20 | 19 | 298 | 290 | n = int(eval(input()))
work = [0] * n
for i in range(n):
a, b = list(map(int, input().split()))
work[i] = [b, a]
work.sort()
key = 0
ans = True
for i in range(n):
if key + work[i][1] > work[i][0]:
ans = False
break
key += work[i][1]
if ans:
print("Yes")
else:
print("No")
| n = int(eval(input()))
jobs = [None] * n
for i in range(n):
a, b = list(map(int, input().split()))
jobs[i] = (b, a)
jobs.sort()
ans = True
sub = 0
for i in range(n):
b, a = jobs[i][0], jobs[i][1]
sub += a
if sub > b:
ans = False
break
print(("Yes" if ans else "No"))
| false | 5 | [
"-work = [0] * n",
"+jobs = [None] * n",
"- work[i] = [b, a]",
"-work.sort()",
"-key = 0",
"+ jobs[i] = (b, a)",
"+jobs.sort()",
"+sub = 0",
"- if key + work[i][1] > work[i][0]:",
"+ b, a = jobs[i][0], jobs[i][1]",
"+ sub += a",
"+ if sub > b:",
"- key += work[i][1]",
"-if ans:",
"- print(\"Yes\")",
"-else:",
"- print(\"No\")",
"+print((\"Yes\" if ans else \"No\"))"
] | false | 0.036505 | 0.034501 | 1.058083 | [
"s143214820",
"s352869039"
] |
u745812846 | p02780 | python | s454345072 | s080782650 | 200 | 180 | 25,152 | 24,812 | Accepted | Accepted | 10 | from itertools import accumulate
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [0]+[(p+1)/2 for p in P]
S_list = []
S = 0
for i in range(N+1):
S += P[i]
S_list.append(S)
B = []
for j in range(N-K+1):
B.append(S_list[j+K]-S_list[j])
ans = max(B)
print(ans)
| N, K = list(map(int,input().split()))
P = list(map(int,input().split()))
P = [(p+1)/2 for p in P]
sm = sum(P[:K]) # 先頭のK個の和を計算
ans = sm # 最大値(答え)を保存する
for i in range(N-K):
sm = sm - P[i] + P[K+i] # 窓をずらす
ans = max(ans, sm) # 最大値(答え)を更新
print (ans) | 17 | 9 | 318 | 262 | from itertools import accumulate
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [0] + [(p + 1) / 2 for p in P]
S_list = []
S = 0
for i in range(N + 1):
S += P[i]
S_list.append(S)
B = []
for j in range(N - K + 1):
B.append(S_list[j + K] - S_list[j])
ans = max(B)
print(ans)
| N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [(p + 1) / 2 for p in P]
sm = sum(P[:K]) # 先頭のK個の和を計算
ans = sm # 最大値(答え)を保存する
for i in range(N - K):
sm = sm - P[i] + P[K + i] # 窓をずらす
ans = max(ans, sm) # 最大値(答え)を更新
print(ans)
| false | 47.058824 | [
"-from itertools import accumulate",
"-",
"-P = [0] + [(p + 1) / 2 for p in P]",
"-S_list = []",
"-S = 0",
"-for i in range(N + 1):",
"- S += P[i]",
"- S_list.append(S)",
"-B = []",
"-for j in range(N - K + 1):",
"- B.append(S_list[j + K] - S_list[j])",
"-ans = max(B)",
"+P = [(p + 1) / 2 for p in P]",
"+sm = sum(P[:K]) # 先頭のK個の和を計算",
"+ans = sm # 最大値(答え)を保存する",
"+for i in range(N - K):",
"+ sm = sm - P[i] + P[K + i] # 窓をずらす",
"+ ans = max(ans, sm) # 最大値(答え)を更新"
] | false | 0.036516 | 0.04314 | 0.846437 | [
"s454345072",
"s080782650"
] |
u813450984 | p03846 | python | s762461782 | s348606467 | 64 | 46 | 14,436 | 14,008 | Accepted | Accepted | 28.12 | n = int(eval(input()))
l = list(map(int, input().split()))
mod = 10**9 + 7
def f():
memo = {}
for i in l:
if i in memo:
memo[i] += 1
else:
memo[i] = 1
for k, v in list(memo.items()):
if k == 0 and not v == 1:
return 0
elif not k == 0 and not v == 2:
return 0
return 2**(n//2) % mod
print((f())) | n = int(eval(input()))
l = list(map(int, input().split()))
mod = 10**9+7
if n % 2 == 0 and len(set(l)) == n//2:
print((2**(n//2)%mod))
elif not n % 2 == 0 and l.count(0) == 1:
print((2**((n-1)//2)%mod))
else:
print((0)) | 21 | 9 | 356 | 221 | n = int(eval(input()))
l = list(map(int, input().split()))
mod = 10**9 + 7
def f():
memo = {}
for i in l:
if i in memo:
memo[i] += 1
else:
memo[i] = 1
for k, v in list(memo.items()):
if k == 0 and not v == 1:
return 0
elif not k == 0 and not v == 2:
return 0
return 2 ** (n // 2) % mod
print((f()))
| n = int(eval(input()))
l = list(map(int, input().split()))
mod = 10**9 + 7
if n % 2 == 0 and len(set(l)) == n // 2:
print((2 ** (n // 2) % mod))
elif not n % 2 == 0 and l.count(0) == 1:
print((2 ** ((n - 1) // 2) % mod))
else:
print((0))
| false | 57.142857 | [
"-",
"-",
"-def f():",
"- memo = {}",
"- for i in l:",
"- if i in memo:",
"- memo[i] += 1",
"- else:",
"- memo[i] = 1",
"- for k, v in list(memo.items()):",
"- if k == 0 and not v == 1:",
"- return 0",
"- elif not k == 0 and not v == 2:",
"- return 0",
"- return 2 ** (n // 2) % mod",
"-",
"-",
"-print((f()))",
"+if n % 2 == 0 and len(set(l)) == n // 2:",
"+ print((2 ** (n // 2) % mod))",
"+elif not n % 2 == 0 and l.count(0) == 1:",
"+ print((2 ** ((n - 1) // 2) % mod))",
"+else:",
"+ print((0))"
] | false | 0.031947 | 0.041143 | 0.776494 | [
"s762461782",
"s348606467"
] |
u366959492 | p03371 | python | s820603890 | s273095747 | 164 | 67 | 38,384 | 61,948 | Accepted | Accepted | 59.15 | a,b,c,x,y=list(map(int,input().split()))
ans=0
if a+b>c*2:
z=min(x,y)
ans+=z*c*2
x-=z
y-=z
if a>c*2:
ans+=x*c*2
x=0
y=max(0,y-x)
if b>c*2:
ans+=y*c*2
y=0
x=max(0,x-y)
ans+=x*a
ans+=y*b
print(ans)
| a,b,c,x,y=list(map(int,input().split()))
ans=0
if a+b>c*2:
z=min(x,y)
ans+=z*c*2
x-=z
y-=z
if a>c*2:
ans+=x*c*2
y=max(0,y-x)
x=0
if b>c*2:
ans+=y*c*2
x=max(0,x-y)
y=0
ans+=a*x
ans+=b*y
print(ans)
| 21 | 21 | 253 | 257 | a, b, c, x, y = list(map(int, input().split()))
ans = 0
if a + b > c * 2:
z = min(x, y)
ans += z * c * 2
x -= z
y -= z
if a > c * 2:
ans += x * c * 2
x = 0
y = max(0, y - x)
if b > c * 2:
ans += y * c * 2
y = 0
x = max(0, x - y)
ans += x * a
ans += y * b
print(ans)
| a, b, c, x, y = list(map(int, input().split()))
ans = 0
if a + b > c * 2:
z = min(x, y)
ans += z * c * 2
x -= z
y -= z
if a > c * 2:
ans += x * c * 2
y = max(0, y - x)
x = 0
if b > c * 2:
ans += y * c * 2
x = max(0, x - y)
y = 0
ans += a * x
ans += b * y
print(ans)
| false | 0 | [
"+ y = max(0, y - x)",
"- y = max(0, y - x)",
"+ x = max(0, x - y)",
"- x = max(0, x - y)",
"-ans += x * a",
"-ans += y * b",
"+ans += a * x",
"+ans += b * y"
] | false | 0.046478 | 0.036615 | 1.269355 | [
"s820603890",
"s273095747"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.