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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u608088992 | p02844 | python | s878702053 | s455333574 | 893 | 776 | 25,716 | 57,160 | Accepted | Accepted | 13.1 | def solve():
N = int(eval(input()))
S = list(eval(input()))
right = [set() for _ in range(N)]
for i in reversed(list(range(N - 1))): right[i] = right[i + 1] | {S[i + 1]}
left = {S[0]}
PIN = set()
for i in range(1, N - 1):
for ln in left:
for rn in right[i]:
p = ln + S[i] + rn
PIN |= {p}
left |= {S[i]}
print((len(PIN)))
return 0
if __name__ == "__main__":
solve() | import sys
def solve():
input = sys.stdin.readline
N = int(eval(input()))
S = input().strip("\n")
Left = [set() for _ in range(N)]
Right = [set() for _ in range(N)]
Left[0] |= {S[0]}
Right[N-1] |= {S[N-1]}
for i in range(1, N):
Left[i] = Left[i-1] | {S[i]}
Right[N-i-1] = Right[N-i] | {S[N-i-1]}
used = set()
for i in range(1, N - 1):
mid = S[i]
for l in Left[i-1]:
for r in Right[i+1]:
used |= {l + mid + r}
print((len(used)))
return 0
if __name__ == "__main__":
solve() | 19 | 25 | 464 | 602 | def solve():
N = int(eval(input()))
S = list(eval(input()))
right = [set() for _ in range(N)]
for i in reversed(list(range(N - 1))):
right[i] = right[i + 1] | {S[i + 1]}
left = {S[0]}
PIN = set()
for i in range(1, N - 1):
for ln in left:
for rn in right[i]:
p = ln + S[i] + rn
PIN |= {p}
left |= {S[i]}
print((len(PIN)))
return 0
if __name__ == "__main__":
solve()
| import sys
def solve():
input = sys.stdin.readline
N = int(eval(input()))
S = input().strip("\n")
Left = [set() for _ in range(N)]
Right = [set() for _ in range(N)]
Left[0] |= {S[0]}
Right[N - 1] |= {S[N - 1]}
for i in range(1, N):
Left[i] = Left[i - 1] | {S[i]}
Right[N - i - 1] = Right[N - i] | {S[N - i - 1]}
used = set()
for i in range(1, N - 1):
mid = S[i]
for l in Left[i - 1]:
for r in Right[i + 1]:
used |= {l + mid + r}
print((len(used)))
return 0
if __name__ == "__main__":
solve()
| false | 24 | [
"+import sys",
"+",
"+",
"+ input = sys.stdin.readline",
"- S = list(eval(input()))",
"- right = [set() for _ in range(N)]",
"- for i in reversed(list(range(N - 1))):",
"- right[i] = right[i + 1] | {S[i + 1]}",
"- left = {S[0]}",
"- PIN = set()",
"+ S = input().strip(\"\\n\")",
"+ Left = [set() for _ in range(N)]",
"+ Right = [set() for _ in range(N)]",
"+ Left[0] |= {S[0]}",
"+ Right[N - 1] |= {S[N - 1]}",
"+ for i in range(1, N):",
"+ Left[i] = Left[i - 1] | {S[i]}",
"+ Right[N - i - 1] = Right[N - i] | {S[N - i - 1]}",
"+ used = set()",
"- for ln in left:",
"- for rn in right[i]:",
"- p = ln + S[i] + rn",
"- PIN |= {p}",
"- left |= {S[i]}",
"- print((len(PIN)))",
"+ mid = S[i]",
"+ for l in Left[i - 1]:",
"+ for r in Right[i + 1]:",
"+ used |= {l + mid + r}",
"+ print((len(used)))"
] | false | 0.06677 | 0.03328 | 2.006285 | [
"s878702053",
"s455333574"
] |
u330661451 | p02888 | python | s363616113 | s647471623 | 1,217 | 1,023 | 3,188 | 3,188 | Accepted | Accepted | 15.94 | from bisect import bisect_left
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):
ans += bisect_left(l,l[i]+l[j])-j-1
print(ans) | from bisect import bisect_left
def main():
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):
ans += bisect_left(l,l[i]+l[j])-j-1
print(ans)
if __name__ == '__main__':
main() | 12 | 16 | 218 | 305 | from bisect import bisect_left
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):
ans += bisect_left(l, l[i] + l[j]) - j - 1
print(ans)
| from bisect import bisect_left
def main():
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):
ans += bisect_left(l, l[i] + l[j]) - j - 1
print(ans)
if __name__ == "__main__":
main()
| false | 25 | [
"-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):",
"- ans += bisect_left(l, l[i] + l[j]) - j - 1",
"-print(ans)",
"+",
"+def main():",
"+ 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):",
"+ ans += bisect_left(l, l[i] + l[j]) - j - 1",
"+ print(ans)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.050222 | 0.049584 | 1.012866 | [
"s363616113",
"s647471623"
] |
u957470671 | p02315 | python | s028542362 | s611470450 | 1,220 | 920 | 133,760 | 25,500 | Accepted | Accepted | 24.59 | M = {}
N, W = [int(x) for x in input().split()]
items = []
for i in range(N):
items.append(tuple(int(x) for x in input().split()))
def dfs(i, j):
if (i, j) in M:
return M[i, j]
if i == N:
return 0
v, w = items[i]
if w <= j:
r = max(dfs(i+1, j), v + dfs(i+1, j-w))
else:
r = dfs(i+1, j)
M[i, j] = r
return r
print((dfs(0, W))) | N, W = [int(x) for x in input().split()]
items = []
for i in range(N):
items.append(tuple(int(x) for x in input().split()))
DP = [[0] * (W+1) for _ in range(N+1)]
# DP[i+1][j] = max(DP[i][j], v + DP[i][j-w])
for i in range(N):
for j in range(W+1):
v, w = items[i]
if w <= j:
DP[i+1][j] = max(DP[i][j], v + DP[i][j-w])
else:
DP[i+1][j] = DP[i][j]
print((DP[-1][-1])) | 24 | 17 | 416 | 438 | M = {}
N, W = [int(x) for x in input().split()]
items = []
for i in range(N):
items.append(tuple(int(x) for x in input().split()))
def dfs(i, j):
if (i, j) in M:
return M[i, j]
if i == N:
return 0
v, w = items[i]
if w <= j:
r = max(dfs(i + 1, j), v + dfs(i + 1, j - w))
else:
r = dfs(i + 1, j)
M[i, j] = r
return r
print((dfs(0, W)))
| N, W = [int(x) for x in input().split()]
items = []
for i in range(N):
items.append(tuple(int(x) for x in input().split()))
DP = [[0] * (W + 1) for _ in range(N + 1)]
# DP[i+1][j] = max(DP[i][j], v + DP[i][j-w])
for i in range(N):
for j in range(W + 1):
v, w = items[i]
if w <= j:
DP[i + 1][j] = max(DP[i][j], v + DP[i][j - w])
else:
DP[i + 1][j] = DP[i][j]
print((DP[-1][-1]))
| false | 29.166667 | [
"-M = {}",
"-",
"-",
"-def dfs(i, j):",
"- if (i, j) in M:",
"- return M[i, j]",
"- if i == N:",
"- return 0",
"- v, w = items[i]",
"- if w <= j:",
"- r = max(dfs(i + 1, j), v + dfs(i + 1, j - w))",
"- else:",
"- r = dfs(i + 1, j)",
"- M[i, j] = r",
"- return r",
"-",
"-",
"-print((dfs(0, W)))",
"+DP = [[0] * (W + 1) for _ in range(N + 1)]",
"+# DP[i+1][j] = max(DP[i][j], v + DP[i][j-w])",
"+for i in range(N):",
"+ for j in range(W + 1):",
"+ v, w = items[i]",
"+ if w <= j:",
"+ DP[i + 1][j] = max(DP[i][j], v + DP[i][j - w])",
"+ else:",
"+ DP[i + 1][j] = DP[i][j]",
"+print((DP[-1][-1]))"
] | false | 0.043057 | 0.047643 | 0.903752 | [
"s028542362",
"s611470450"
] |
u089142196 | p03634 | python | s875764516 | s374591768 | 1,511 | 771 | 60,300 | 60,320 | Accepted | Accepted | 48.97 | from collections import deque
N=int(eval(input()))
a=[0]*(N-1)
b=[0]*(N-1)
c=[0]*(N-1)
L=[ [] for _ in range(N)]
for i in range(N-1):
a[i],b[i],c[i]= list(map(int,input().split()))
L[a[i]-1].append((b[i]-1,c[i]))
L[b[i]-1].append((a[i]-1,c[i]))
Q,K= list(map(int,input().split()))
#Lの中のitemの0は接続先、1は距離
d=[ -1 for i in range(N)]
def BFS(x):
v=deque([x])
d[x]=0
while len(v)>0:
s=v.popleft() #sはint
for item in L[s]:
if d[item[0]]==-1:
d[item[0]]=d[s]+item[1]
v.append(item[0])
BFS(K-1)
x=[0]*Q
y=[0]*Q
for i in range(Q):
x[i],y[i] = list(map(int,input().split()))
print((d[x[i]-1]+d[y[i]-1])) | from collections import deque
from sys import stdin
input=stdin.readline
N=int(eval(input()))
a=[0]*(N-1)
b=[0]*(N-1)
c=[0]*(N-1)
L=[ [] for _ in range(N)]
for i in range(N-1):
a[i],b[i],c[i]= list(map(int,input().split()))
L[a[i]-1].append((b[i]-1,c[i]))
L[b[i]-1].append((a[i]-1,c[i]))
Q,K= list(map(int,input().split()))
#Lの中のitemの0は接続先、1は距離
d=[ -1 for i in range(N)]
def BFS(x):
v=deque([x])
d[x]=0
while len(v)>0:
s=v.popleft() #sはint
for item in L[s]:
if d[item[0]]==-1:
d[item[0]]=d[s]+item[1]
v.append(item[0])
BFS(K-1)
x=[0]*Q
y=[0]*Q
for i in range(Q):
x[i],y[i] = list(map(int,input().split()))
print((d[x[i]-1]+d[y[i]-1])) | 34 | 36 | 661 | 706 | from collections import deque
N = int(eval(input()))
a = [0] * (N - 1)
b = [0] * (N - 1)
c = [0] * (N - 1)
L = [[] for _ in range(N)]
for i in range(N - 1):
a[i], b[i], c[i] = list(map(int, input().split()))
L[a[i] - 1].append((b[i] - 1, c[i]))
L[b[i] - 1].append((a[i] - 1, c[i]))
Q, K = list(map(int, input().split()))
# Lの中のitemの0は接続先、1は距離
d = [-1 for i in range(N)]
def BFS(x):
v = deque([x])
d[x] = 0
while len(v) > 0:
s = v.popleft() # sはint
for item in L[s]:
if d[item[0]] == -1:
d[item[0]] = d[s] + item[1]
v.append(item[0])
BFS(K - 1)
x = [0] * Q
y = [0] * Q
for i in range(Q):
x[i], y[i] = list(map(int, input().split()))
print((d[x[i] - 1] + d[y[i] - 1]))
| from collections import deque
from sys import stdin
input = stdin.readline
N = int(eval(input()))
a = [0] * (N - 1)
b = [0] * (N - 1)
c = [0] * (N - 1)
L = [[] for _ in range(N)]
for i in range(N - 1):
a[i], b[i], c[i] = list(map(int, input().split()))
L[a[i] - 1].append((b[i] - 1, c[i]))
L[b[i] - 1].append((a[i] - 1, c[i]))
Q, K = list(map(int, input().split()))
# Lの中のitemの0は接続先、1は距離
d = [-1 for i in range(N)]
def BFS(x):
v = deque([x])
d[x] = 0
while len(v) > 0:
s = v.popleft() # sはint
for item in L[s]:
if d[item[0]] == -1:
d[item[0]] = d[s] + item[1]
v.append(item[0])
BFS(K - 1)
x = [0] * Q
y = [0] * Q
for i in range(Q):
x[i], y[i] = list(map(int, input().split()))
print((d[x[i] - 1] + d[y[i] - 1]))
| false | 5.555556 | [
"+from sys import stdin",
"+input = stdin.readline"
] | false | 0.034096 | 0.037105 | 0.918909 | [
"s875764516",
"s374591768"
] |
u124605948 | p03379 | python | s183193809 | s265432379 | 312 | 175 | 30,756 | 30,772 | Accepted | Accepted | 43.91 | import bisect
n = int(eval(input()))
X = list(map(int, input().split()))
sorted_x = sorted(X)
l, r = sorted_x[n//2], sorted_x[n//2-1]
for x in X:
if bisect.bisect_left(sorted_x, x) < n // 2:
print(l)
else:
print(r) | n = int(eval(input()))
X = list(map(int, input().split()))
sorted_x = sorted(X)
l, r = sorted_x[n//2-1], sorted_x[n//2]
for x in X:
if x < r:
print(r)
else:
print(l) | 14 | 12 | 249 | 197 | import bisect
n = int(eval(input()))
X = list(map(int, input().split()))
sorted_x = sorted(X)
l, r = sorted_x[n // 2], sorted_x[n // 2 - 1]
for x in X:
if bisect.bisect_left(sorted_x, x) < n // 2:
print(l)
else:
print(r)
| n = int(eval(input()))
X = list(map(int, input().split()))
sorted_x = sorted(X)
l, r = sorted_x[n // 2 - 1], sorted_x[n // 2]
for x in X:
if x < r:
print(r)
else:
print(l)
| false | 14.285714 | [
"-import bisect",
"-",
"-l, r = sorted_x[n // 2], sorted_x[n // 2 - 1]",
"+l, r = sorted_x[n // 2 - 1], sorted_x[n // 2]",
"- if bisect.bisect_left(sorted_x, x) < n // 2:",
"+ if x < r:",
"+ print(r)",
"+ else:",
"- else:",
"- print(r)"
] | false | 0.041262 | 0.040507 | 1.01865 | [
"s183193809",
"s265432379"
] |
u328751895 | p03796 | python | s352207432 | s117573330 | 40 | 35 | 3,572 | 2,940 | Accepted | Accepted | 12.5 | from functools import reduce
N = int(eval(input()))
div = pow(10, 9) + 7
print((reduce(lambda ans, n: ans * n % div, list(range(1, N + 1))))) | N = int(eval(input()))
div = 10 ** 9 + 7
ans = 1
for i in range(2, N + 1):
ans = ans * i % div
print(ans) | 5 | 7 | 132 | 110 | from functools import reduce
N = int(eval(input()))
div = pow(10, 9) + 7
print((reduce(lambda ans, n: ans * n % div, list(range(1, N + 1)))))
| N = int(eval(input()))
div = 10**9 + 7
ans = 1
for i in range(2, N + 1):
ans = ans * i % div
print(ans)
| false | 28.571429 | [
"-from functools import reduce",
"-",
"-div = pow(10, 9) + 7",
"-print((reduce(lambda ans, n: ans * n % div, list(range(1, N + 1)))))",
"+div = 10**9 + 7",
"+ans = 1",
"+for i in range(2, N + 1):",
"+ ans = ans * i % div",
"+print(ans)"
] | false | 0.042539 | 0.047548 | 0.894661 | [
"s352207432",
"s117573330"
] |
u588341295 | p03062 | python | s014536966 | s812749944 | 125 | 65 | 14,512 | 14,496 | Accepted | Accepted | 48 | # -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
N=INT()
A=LIST()
mn=INF
cnt=0
zero=False
for i in range(N):
mn=min(mn, abs(A[i]))
if A[i]<0:
cnt+=1
if A[i]==0:
zero=True
A[i]=abs(A[i])
if zero:
print((sum(A)))
elif cnt%2==0:
print((sum(A)))
else:
print((sum(A)-mn*2))
| # -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
N = INT()
A = LIST()
has_zero = False
cnt = 0
for a in A:
if a < 0:
cnt += 1
elif a == 0:
has_zero = True
A2 = [abs(a) for a in A]
if has_zero or cnt % 2 == 0:
print((sum(A2)))
else:
print((sum(A2) - min(A2) * 2))
| 39 | 36 | 847 | 956 | # -*- coding: utf-8 -*-
import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1):
return int(-(-x // y))
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST():
return list(map(int, input().split()))
def Yes():
print("Yes")
def No():
print("No")
def YES():
print("YES")
def NO():
print("NO")
sys.setrecursionlimit(10**9)
INF = float("inf")
MOD = 10**9 + 7
N = INT()
A = LIST()
mn = INF
cnt = 0
zero = False
for i in range(N):
mn = min(mn, abs(A[i]))
if A[i] < 0:
cnt += 1
if A[i] == 0:
zero = True
A[i] = abs(A[i])
if zero:
print((sum(A)))
elif cnt % 2 == 0:
print((sum(A)))
else:
print((sum(A) - mn * 2))
| # -*- coding: utf-8 -*-
import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1):
return int(-(-x // y))
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST(N=None):
return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes():
print("Yes")
def No():
print("No")
def YES():
print("YES")
def NO():
print("NO")
sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7
N = INT()
A = LIST()
has_zero = False
cnt = 0
for a in A:
if a < 0:
cnt += 1
elif a == 0:
has_zero = True
A2 = [abs(a) for a in A]
if has_zero or cnt % 2 == 0:
print((sum(A2)))
else:
print((sum(A2) - min(A2) * 2))
| false | 7.692308 | [
"+def list4d(a, b, c, d, e):",
"+ return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]",
"+",
"+",
"-def LIST():",
"- return list(map(int, input().split()))",
"+def LIST(N=None):",
"+ return list(MAP()) if N is None else [INT() for i in range(N)]",
"-INF = float(\"inf\")",
"+INF = 10**18",
"-mn = INF",
"+has_zero = False",
"-zero = False",
"-for i in range(N):",
"- mn = min(mn, abs(A[i]))",
"- if A[i] < 0:",
"+for a in A:",
"+ if a < 0:",
"- if A[i] == 0:",
"- zero = True",
"- A[i] = abs(A[i])",
"-if zero:",
"- print((sum(A)))",
"-elif cnt % 2 == 0:",
"- print((sum(A)))",
"+ elif a == 0:",
"+ has_zero = True",
"+A2 = [abs(a) for a in A]",
"+if has_zero or cnt % 2 == 0:",
"+ print((sum(A2)))",
"- print((sum(A) - mn * 2))",
"+ print((sum(A2) - min(A2) * 2))"
] | false | 0.007976 | 0.041864 | 0.190532 | [
"s014536966",
"s812749944"
] |
u024442309 | p02730 | python | s001065658 | s161790315 | 20 | 18 | 3,060 | 3,064 | Accepted | Accepted | 10 | S = input()
N = len(S)
def is_palindrome(s):
return s == s[::-1]
if is_palindrome(S) \
and is_palindrome(S[:int((N-1)/2)]) \
and is_palindrome(S[int((N+3)/2-1):]):
print('Yes')
else:
print('No')
| S = input()
N = len(S)
def is_palindrome(s):
return s == s[::-1]
if is_palindrome(S) \
and is_palindrome(S[:int((N-1)/2)]) \
and S[int((N+3)/2-1):] == S[:int((N-1)/2)]:
print('Yes')
else:
print('No')
| 12 | 12 | 213 | 218 | S = input()
N = len(S)
def is_palindrome(s):
return s == s[::-1]
if (
is_palindrome(S)
and is_palindrome(S[: int((N - 1) / 2)])
and is_palindrome(S[int((N + 3) / 2 - 1) :])
):
print("Yes")
else:
print("No")
| S = input()
N = len(S)
def is_palindrome(s):
return s == s[::-1]
if (
is_palindrome(S)
and is_palindrome(S[: int((N - 1) / 2)])
and S[int((N + 3) / 2 - 1) :] == S[: int((N - 1) / 2)]
):
print("Yes")
else:
print("No")
| false | 0 | [
"- and is_palindrome(S[int((N + 3) / 2 - 1) :])",
"+ and S[int((N + 3) / 2 - 1) :] == S[: int((N - 1) / 2)]"
] | false | 0.038514 | 0.033709 | 1.142554 | [
"s001065658",
"s161790315"
] |
u121921603 | p03353 | python | s453454680 | s031165843 | 200 | 174 | 40,944 | 39,280 | Accepted | Accepted | 13 | s=eval(input())
K=int(eval(input()))
a=[]
for i in range(K):
for j in range(len(s)-i):
a.append(s[j:j+i+1])
a.sort()
cnt=1
i=1
while cnt<K:
if a[i]!=a[i-1]:
cnt+=1
i+=1
print((a[i-1]))
| s=eval(input())
K=int(eval(input()))
a=set()
for i in range(K):
for j in range(len(s)-i):
a.add(s[j:j+i+1])
a=sorted(list(a))
print((a[K-1]))
| 15 | 9 | 214 | 149 | s = eval(input())
K = int(eval(input()))
a = []
for i in range(K):
for j in range(len(s) - i):
a.append(s[j : j + i + 1])
a.sort()
cnt = 1
i = 1
while cnt < K:
if a[i] != a[i - 1]:
cnt += 1
i += 1
print((a[i - 1]))
| s = eval(input())
K = int(eval(input()))
a = set()
for i in range(K):
for j in range(len(s) - i):
a.add(s[j : j + i + 1])
a = sorted(list(a))
print((a[K - 1]))
| false | 40 | [
"-a = []",
"+a = set()",
"- a.append(s[j : j + i + 1])",
"-a.sort()",
"-cnt = 1",
"-i = 1",
"-while cnt < K:",
"- if a[i] != a[i - 1]:",
"- cnt += 1",
"- i += 1",
"-print((a[i - 1]))",
"+ a.add(s[j : j + i + 1])",
"+a = sorted(list(a))",
"+print((a[K - 1]))"
] | false | 0.080629 | 0.105481 | 0.76439 | [
"s453454680",
"s031165843"
] |
u366959492 | p02888 | python | s994243408 | s158867122 | 1,638 | 759 | 49,784 | 44,636 | Accepted | Accepted | 53.66 | n=int(eval(input()))
l=list(map(int,input().split()))
l.sort()
ans=0
import bisect
for i in range(n):
for j in range(n):
if i<j:
a=l[i]
b=l[j]
x=bisect.bisect_left(l,a+b)
y=bisect.bisect_right(l,b-a)
if b-a>=a:
ans+=max(0,x-y-1)
else:
ans+=max(0,x-y-2)
print((ans//3))
| n=int(eval(input()))
l=list(map(int,input().split()))
l.sort()
from bisect import bisect_left
ans=0
for i in range(n):
for j in range(i+1,n):
a=l[i]
b=l[j]
ans+=max(0,bisect_left(l,a+b)-j-1)
print(ans)
| 17 | 11 | 393 | 234 | n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
ans = 0
import bisect
for i in range(n):
for j in range(n):
if i < j:
a = l[i]
b = l[j]
x = bisect.bisect_left(l, a + b)
y = bisect.bisect_right(l, b - a)
if b - a >= a:
ans += max(0, x - y - 1)
else:
ans += max(0, x - y - 2)
print((ans // 3))
| n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
from bisect import bisect_left
ans = 0
for i in range(n):
for j in range(i + 1, n):
a = l[i]
b = l[j]
ans += max(0, bisect_left(l, a + b) - j - 1)
print(ans)
| false | 35.294118 | [
"+from bisect import bisect_left",
"+",
"-import bisect",
"-",
"- for j in range(n):",
"- if i < j:",
"- a = l[i]",
"- b = l[j]",
"- x = bisect.bisect_left(l, a + b)",
"- y = bisect.bisect_right(l, b - a)",
"- if b - a >= a:",
"- ans += max(0, x - y - 1)",
"- else:",
"- ans += max(0, x - y - 2)",
"-print((ans // 3))",
"+ for j in range(i + 1, n):",
"+ a = l[i]",
"+ b = l[j]",
"+ ans += max(0, bisect_left(l, a + b) - j - 1)",
"+print(ans)"
] | false | 0.036621 | 0.042587 | 0.859904 | [
"s994243408",
"s158867122"
] |
u613920660 | p03329 | python | s219820070 | s012820523 | 860 | 678 | 9,868 | 9,716 | Accepted | Accepted | 21.16 | N=int(eval(input()))
inf=100000
dp=[inf for _ in range(N+1)]
dp[0]=0
for n in range(1,N+1):
num=100000
i=0
j=0
while 9**(i+1)<=n:
i+=1
while 6**(j+1)<=n:
j+=1
for k in range(i+1):
num=min(num,dp[n-9**k]+1)
for k in range(j+1):
num=min(num,dp[n-6**k]+1)
dp[n]=min(dp[n],num)
print((dp[N])) | def main3():
import sys
sys.setrecursionlimit(100000000)
N=int(eval(input()))
dp=[-1 for n in range(N+1)]
dp[0]=0
dp[1]=1
def rec(x,dp):
if x==1:
return dp[1]
elif x==0:
return dp[0]
else:
l=[]
i=0
j=0
while 9**(i+1)<=x:
i+=1
while 6**(j+1)<=x:
j+=1
for k in reversed(list(range(i+1))):
tmp=x-9**k
if dp[tmp]!=-1:
l.append(dp[tmp]+1)
else:
l.append(rec(tmp,dp)+1)
for k in reversed(list(range(j+1))):
tmp=x-6**k
if dp[tmp]!=-1:
l.append(dp[tmp]+1)
else:
l.append(rec(tmp,dp)+1)
dp[x]=min(l)
return dp[x]
return rec(N,dp)
if __name__=="__main__":
print((main3())) | 18 | 40 | 361 | 992 | N = int(eval(input()))
inf = 100000
dp = [inf for _ in range(N + 1)]
dp[0] = 0
for n in range(1, N + 1):
num = 100000
i = 0
j = 0
while 9 ** (i + 1) <= n:
i += 1
while 6 ** (j + 1) <= n:
j += 1
for k in range(i + 1):
num = min(num, dp[n - 9**k] + 1)
for k in range(j + 1):
num = min(num, dp[n - 6**k] + 1)
dp[n] = min(dp[n], num)
print((dp[N]))
| def main3():
import sys
sys.setrecursionlimit(100000000)
N = int(eval(input()))
dp = [-1 for n in range(N + 1)]
dp[0] = 0
dp[1] = 1
def rec(x, dp):
if x == 1:
return dp[1]
elif x == 0:
return dp[0]
else:
l = []
i = 0
j = 0
while 9 ** (i + 1) <= x:
i += 1
while 6 ** (j + 1) <= x:
j += 1
for k in reversed(list(range(i + 1))):
tmp = x - 9**k
if dp[tmp] != -1:
l.append(dp[tmp] + 1)
else:
l.append(rec(tmp, dp) + 1)
for k in reversed(list(range(j + 1))):
tmp = x - 6**k
if dp[tmp] != -1:
l.append(dp[tmp] + 1)
else:
l.append(rec(tmp, dp) + 1)
dp[x] = min(l)
return dp[x]
return rec(N, dp)
if __name__ == "__main__":
print((main3()))
| false | 55 | [
"-N = int(eval(input()))",
"-inf = 100000",
"-dp = [inf for _ in range(N + 1)]",
"-dp[0] = 0",
"-for n in range(1, N + 1):",
"- num = 100000",
"- i = 0",
"- j = 0",
"- while 9 ** (i + 1) <= n:",
"- i += 1",
"- while 6 ** (j + 1) <= n:",
"- j += 1",
"- for k in range(i + 1):",
"- num = min(num, dp[n - 9**k] + 1)",
"- for k in range(j + 1):",
"- num = min(num, dp[n - 6**k] + 1)",
"- dp[n] = min(dp[n], num)",
"-print((dp[N]))",
"+def main3():",
"+ import sys",
"+",
"+ sys.setrecursionlimit(100000000)",
"+ N = int(eval(input()))",
"+ dp = [-1 for n in range(N + 1)]",
"+ dp[0] = 0",
"+ dp[1] = 1",
"+",
"+ def rec(x, dp):",
"+ if x == 1:",
"+ return dp[1]",
"+ elif x == 0:",
"+ return dp[0]",
"+ else:",
"+ l = []",
"+ i = 0",
"+ j = 0",
"+ while 9 ** (i + 1) <= x:",
"+ i += 1",
"+ while 6 ** (j + 1) <= x:",
"+ j += 1",
"+ for k in reversed(list(range(i + 1))):",
"+ tmp = x - 9**k",
"+ if dp[tmp] != -1:",
"+ l.append(dp[tmp] + 1)",
"+ else:",
"+ l.append(rec(tmp, dp) + 1)",
"+ for k in reversed(list(range(j + 1))):",
"+ tmp = x - 6**k",
"+ if dp[tmp] != -1:",
"+ l.append(dp[tmp] + 1)",
"+ else:",
"+ l.append(rec(tmp, dp) + 1)",
"+ dp[x] = min(l)",
"+ return dp[x]",
"+",
"+ return rec(N, dp)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ print((main3()))"
] | false | 0.224651 | 0.177522 | 1.265481 | [
"s219820070",
"s012820523"
] |
u612975321 | p03472 | python | s200598175 | s222687695 | 979 | 235 | 17,188 | 17,260 | Accepted | Accepted | 76 | n, h = list(map(int,input().split()))
a = []
b = []
for i in range(n):
ca, cb = list(map(int,input().split()))
a.append(ca)
b.append(cb)
amax = max(a)
b.sort(reverse=True)
cnt = 0
while h > 0:
if b and b[0] > amax:
h -= b.pop(0)
cnt += 1
else:
cnt += h//amax
h -= amax * (h//amax)
if h > 0:
h -= amax
cnt += 1
print(cnt)
| n, h = list(map(int,input().split()))
a = []
b = []
for i in range(n):
ca, cb = list(map(int,input().split()))
a.append(ca)
b.append(cb)
amax = max(a)
b.sort(reverse=True)
cnt = 0
bsum = 0
for i in range(n):
if b[i] <= amax or bsum >= h:
break
else:
bsum += b[i]
cnt += 1
h -= bsum
if h > 0:
cnt += h//amax
h -= amax * (h//amax)
if h > 0:
h -= amax
cnt += 1
print(cnt)
| 22 | 26 | 415 | 443 | n, h = list(map(int, input().split()))
a = []
b = []
for i in range(n):
ca, cb = list(map(int, input().split()))
a.append(ca)
b.append(cb)
amax = max(a)
b.sort(reverse=True)
cnt = 0
while h > 0:
if b and b[0] > amax:
h -= b.pop(0)
cnt += 1
else:
cnt += h // amax
h -= amax * (h // amax)
if h > 0:
h -= amax
cnt += 1
print(cnt)
| n, h = list(map(int, input().split()))
a = []
b = []
for i in range(n):
ca, cb = list(map(int, input().split()))
a.append(ca)
b.append(cb)
amax = max(a)
b.sort(reverse=True)
cnt = 0
bsum = 0
for i in range(n):
if b[i] <= amax or bsum >= h:
break
else:
bsum += b[i]
cnt += 1
h -= bsum
if h > 0:
cnt += h // amax
h -= amax * (h // amax)
if h > 0:
h -= amax
cnt += 1
print(cnt)
| false | 15.384615 | [
"-while h > 0:",
"- if b and b[0] > amax:",
"- h -= b.pop(0)",
"+bsum = 0",
"+for i in range(n):",
"+ if b[i] <= amax or bsum >= h:",
"+ break",
"+ else:",
"+ bsum += b[i]",
"- else:",
"- cnt += h // amax",
"- h -= amax * (h // amax)",
"- if h > 0:",
"- h -= amax",
"- cnt += 1",
"+h -= bsum",
"+if h > 0:",
"+ cnt += h // amax",
"+ h -= amax * (h // amax)",
"+if h > 0:",
"+ h -= amax",
"+ cnt += 1"
] | false | 0.035132 | 0.036592 | 0.960109 | [
"s200598175",
"s222687695"
] |
u576917603 | p02881 | python | s523468163 | s096060012 | 152 | 114 | 3,060 | 3,268 | Accepted | Accepted | 25 | n=int(eval(input()))
mini=float('inf')
for i in range(1,int(n**0.5)+1):
if n%i==0:
mini=min(i+(n/i)-2,mini)
print((int(mini))) | n=int(eval(input()))
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
# divisors.sort()
return divisors
lis=make_divisors(n)
x=lis[-1]
if n%x**2==0:
print((x*2-2))
exit()
print((lis[-1]+lis[-2]-2)) | 6 | 17 | 135 | 369 | n = int(eval(input()))
mini = float("inf")
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
mini = min(i + (n / i) - 2, mini)
print((int(mini)))
| n = int(eval(input()))
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
# divisors.sort()
return divisors
lis = make_divisors(n)
x = lis[-1]
if n % x**2 == 0:
print((x * 2 - 2))
exit()
print((lis[-1] + lis[-2] - 2))
| false | 64.705882 | [
"-mini = float(\"inf\")",
"-for i in range(1, int(n**0.5) + 1):",
"- if n % i == 0:",
"- mini = min(i + (n / i) - 2, mini)",
"-print((int(mini)))",
"+",
"+",
"+def make_divisors(n):",
"+ divisors = []",
"+ for i in range(1, int(n**0.5) + 1):",
"+ if n % i == 0:",
"+ divisors.append(i)",
"+ if i != n // i:",
"+ divisors.append(n // i)",
"+ # divisors.sort()",
"+ return divisors",
"+",
"+",
"+lis = make_divisors(n)",
"+x = lis[-1]",
"+if n % x**2 == 0:",
"+ print((x * 2 - 2))",
"+ exit()",
"+print((lis[-1] + lis[-2] - 2))"
] | false | 0.182538 | 0.051356 | 3.554337 | [
"s523468163",
"s096060012"
] |
u667024514 | p03673 | python | s644329643 | s170351704 | 85 | 66 | 25,924 | 27,384 | Accepted | Accepted | 22.35 | n = int(eval(input()))
lis = []
li = list(map(str,input().split()))
if n % 2 == 0:
b = li[1::2]
for m in range(n//2):lis.append(b[-(m + 1)])
print((" ".join(lis[::] + li[::2])))
else:
b = li[::2]
for m in range((n//2)+1):lis.append(b[-(m + 1)])
print((" ".join(lis[::]+li[1::2]))) | n = int(eval(input()))
lis = list(map(str,input().split()))
li = lis[::2]
l = lis[1::2]
if n % 2 == 0:
l = l[::-1]
ans = l+li
print((" ".join(ans)))
else:
li = li[::-1]
ans = li+l
print((" ".join(ans)))
| 11 | 13 | 304 | 218 | n = int(eval(input()))
lis = []
li = list(map(str, input().split()))
if n % 2 == 0:
b = li[1::2]
for m in range(n // 2):
lis.append(b[-(m + 1)])
print((" ".join(lis[::] + li[::2])))
else:
b = li[::2]
for m in range((n // 2) + 1):
lis.append(b[-(m + 1)])
print((" ".join(lis[::] + li[1::2])))
| n = int(eval(input()))
lis = list(map(str, input().split()))
li = lis[::2]
l = lis[1::2]
if n % 2 == 0:
l = l[::-1]
ans = l + li
print((" ".join(ans)))
else:
li = li[::-1]
ans = li + l
print((" ".join(ans)))
| false | 15.384615 | [
"-lis = []",
"-li = list(map(str, input().split()))",
"+lis = list(map(str, input().split()))",
"+li = lis[::2]",
"+l = lis[1::2]",
"- b = li[1::2]",
"- for m in range(n // 2):",
"- lis.append(b[-(m + 1)])",
"- print((\" \".join(lis[::] + li[::2])))",
"+ l = l[::-1]",
"+ ans = l + li",
"+ print((\" \".join(ans)))",
"- b = li[::2]",
"- for m in range((n // 2) + 1):",
"- lis.append(b[-(m + 1)])",
"- print((\" \".join(lis[::] + li[1::2])))",
"+ li = li[::-1]",
"+ ans = li + l",
"+ print((\" \".join(ans)))"
] | false | 0.043006 | 0.037347 | 1.151545 | [
"s644329643",
"s170351704"
] |
u190405389 | p02714 | python | s252552694 | s008870502 | 163 | 144 | 74,376 | 68,204 | Accepted | Accepted | 11.66 | n = int(eval(input()))
s = eval(input())
R = [0]
G = [0]
B = [0]
for i in range(n):
R.append(R[-1])
G.append(G[-1])
B.append(B[-1])
if s[i]=='R':
R[-1]+=1
elif s[i]=='G':
G[-1]+=1
else:
B[-1]+=1
ans = 0
for j in range(1,n-1):
if s[j]=='R':
ans += G[j]*(B[n]-B[j+1])
ans += B[j]*(G[n]-G[j+1])
for i in range(j):
if j+i+1<n:
if s[j-i-1]=='B' and s[j+i+1]=='G':
ans-=1
elif s[j-i-1]=='G' and s[j+i+1]=='B':
ans-=1
else:
break
elif s[j]=='G':
ans += R[j]*(B[n]-B[j+1])
ans += B[j]*(R[n]-R[j+1])
for i in range(j):
if j+i+1<n:
if s[j-i-1]=='R' and s[j+i+1]=='B':
ans-=1
elif s[j-i-1]=='B' and s[j+i+1]=='R':
ans-=1
else:
break
elif s[j]=='B':
ans += G[j]*(R[n]-R[j+1])
ans += R[j]*(G[n]-G[j+1])
for i in range(j):
if j+i+1<n:
if s[j-i-1]=='R' and s[j+i+1]=='G':
ans-=1
elif s[j-i-1]=='G' and s[j+i+1]=='R':
ans-=1
else:
break
print(ans)
| n = int(eval(input()))
s = eval(input())
R = s.count('R')
G = s.count('G')
B = s.count('B')
ans = R*G*B
for i in range(n-2):
for j in range(i+1,n-1):
k = j*2-i
if k<n:
if s[i]!=s[j]!=s[k]!=s[i]:
ans -=1
print(ans) | 60 | 16 | 1,356 | 267 | n = int(eval(input()))
s = eval(input())
R = [0]
G = [0]
B = [0]
for i in range(n):
R.append(R[-1])
G.append(G[-1])
B.append(B[-1])
if s[i] == "R":
R[-1] += 1
elif s[i] == "G":
G[-1] += 1
else:
B[-1] += 1
ans = 0
for j in range(1, n - 1):
if s[j] == "R":
ans += G[j] * (B[n] - B[j + 1])
ans += B[j] * (G[n] - G[j + 1])
for i in range(j):
if j + i + 1 < n:
if s[j - i - 1] == "B" and s[j + i + 1] == "G":
ans -= 1
elif s[j - i - 1] == "G" and s[j + i + 1] == "B":
ans -= 1
else:
break
elif s[j] == "G":
ans += R[j] * (B[n] - B[j + 1])
ans += B[j] * (R[n] - R[j + 1])
for i in range(j):
if j + i + 1 < n:
if s[j - i - 1] == "R" and s[j + i + 1] == "B":
ans -= 1
elif s[j - i - 1] == "B" and s[j + i + 1] == "R":
ans -= 1
else:
break
elif s[j] == "B":
ans += G[j] * (R[n] - R[j + 1])
ans += R[j] * (G[n] - G[j + 1])
for i in range(j):
if j + i + 1 < n:
if s[j - i - 1] == "R" and s[j + i + 1] == "G":
ans -= 1
elif s[j - i - 1] == "G" and s[j + i + 1] == "R":
ans -= 1
else:
break
print(ans)
| n = int(eval(input()))
s = eval(input())
R = s.count("R")
G = s.count("G")
B = s.count("B")
ans = R * G * B
for i in range(n - 2):
for j in range(i + 1, n - 1):
k = j * 2 - i
if k < n:
if s[i] != s[j] != s[k] != s[i]:
ans -= 1
print(ans)
| false | 73.333333 | [
"-R = [0]",
"-G = [0]",
"-B = [0]",
"-for i in range(n):",
"- R.append(R[-1])",
"- G.append(G[-1])",
"- B.append(B[-1])",
"- if s[i] == \"R\":",
"- R[-1] += 1",
"- elif s[i] == \"G\":",
"- G[-1] += 1",
"- else:",
"- B[-1] += 1",
"-ans = 0",
"-for j in range(1, n - 1):",
"- if s[j] == \"R\":",
"- ans += G[j] * (B[n] - B[j + 1])",
"- ans += B[j] * (G[n] - G[j + 1])",
"- for i in range(j):",
"- if j + i + 1 < n:",
"- if s[j - i - 1] == \"B\" and s[j + i + 1] == \"G\":",
"- ans -= 1",
"- elif s[j - i - 1] == \"G\" and s[j + i + 1] == \"B\":",
"- ans -= 1",
"- else:",
"- break",
"- elif s[j] == \"G\":",
"- ans += R[j] * (B[n] - B[j + 1])",
"- ans += B[j] * (R[n] - R[j + 1])",
"- for i in range(j):",
"- if j + i + 1 < n:",
"- if s[j - i - 1] == \"R\" and s[j + i + 1] == \"B\":",
"- ans -= 1",
"- elif s[j - i - 1] == \"B\" and s[j + i + 1] == \"R\":",
"- ans -= 1",
"- else:",
"- break",
"- elif s[j] == \"B\":",
"- ans += G[j] * (R[n] - R[j + 1])",
"- ans += R[j] * (G[n] - G[j + 1])",
"- for i in range(j):",
"- if j + i + 1 < n:",
"- if s[j - i - 1] == \"R\" and s[j + i + 1] == \"G\":",
"- ans -= 1",
"- elif s[j - i - 1] == \"G\" and s[j + i + 1] == \"R\":",
"- ans -= 1",
"- else:",
"- break",
"+R = s.count(\"R\")",
"+G = s.count(\"G\")",
"+B = s.count(\"B\")",
"+ans = R * G * B",
"+for i in range(n - 2):",
"+ for j in range(i + 1, n - 1):",
"+ k = j * 2 - i",
"+ if k < n:",
"+ if s[i] != s[j] != s[k] != s[i]:",
"+ ans -= 1"
] | false | 0.045082 | 0.039988 | 1.1274 | [
"s252552694",
"s008870502"
] |
u759412327 | p02983 | python | s267202192 | s713991391 | 1,413 | 708 | 9,176 | 9,072 | Accepted | Accepted | 49.89 | L,R = list(map(int,input().split()))
ans = 2020
for i in range(L,min(L+2019,R)):
for j in range(L+1,min(L+2019,R)+1):
ans = min(ans,i*j%2019)
print(ans) | L,R = list(map(int,input().split()))
R = min(R,L+2019)
ans = 2019
for i in range(L,R+1):
for j in range(i+1,R+1):
ans = min(ans,i*j%2019)
print(ans) | 8 | 9 | 161 | 158 | L, R = list(map(int, input().split()))
ans = 2020
for i in range(L, min(L + 2019, R)):
for j in range(L + 1, min(L + 2019, R) + 1):
ans = min(ans, i * j % 2019)
print(ans)
| L, R = list(map(int, input().split()))
R = min(R, L + 2019)
ans = 2019
for i in range(L, R + 1):
for j in range(i + 1, R + 1):
ans = min(ans, i * j % 2019)
print(ans)
| false | 11.111111 | [
"-ans = 2020",
"-for i in range(L, min(L + 2019, R)):",
"- for j in range(L + 1, min(L + 2019, R) + 1):",
"+R = min(R, L + 2019)",
"+ans = 2019",
"+for i in range(L, R + 1):",
"+ for j in range(i + 1, R + 1):"
] | false | 0.050263 | 0.150449 | 0.334088 | [
"s267202192",
"s713991391"
] |
u301195216 | p02818 | python | s183438567 | s612772120 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | A, B, K = list(map(int, input().split()))
if A-K >= 0:
print((A-K, B))
elif A-K < 0:
if B-(K-A)>=0:
print((0, B-(K-A)))
else:
print((0, 0)) | A, B, K = list(map(int, input().split()))
if A-K >= 0:
print((A-K, B))
elif A-K < 0:
print((0, max(0, B - (K - A)))) | 9 | 6 | 164 | 120 | A, B, K = list(map(int, input().split()))
if A - K >= 0:
print((A - K, B))
elif A - K < 0:
if B - (K - A) >= 0:
print((0, B - (K - A)))
else:
print((0, 0))
| A, B, K = list(map(int, input().split()))
if A - K >= 0:
print((A - K, B))
elif A - K < 0:
print((0, max(0, B - (K - A))))
| false | 33.333333 | [
"- if B - (K - A) >= 0:",
"- print((0, B - (K - A)))",
"- else:",
"- print((0, 0))",
"+ print((0, max(0, B - (K - A))))"
] | false | 0.068655 | 0.068808 | 0.997781 | [
"s183438567",
"s612772120"
] |
u707124227 | p02803 | python | s789777289 | s646915608 | 441 | 176 | 3,316 | 3,828 | Accepted | Accepted | 60.09 | from collections import deque
h,w=list(map(int,input().split()))
s=[eval(input())for _ in range(h)]
a=[[400]*w for _ in range(h)]
ans=0
def bfs(b,i,j):
b[i][j]=0
seen=[[0]*w for _ in range(h)]
todo=deque([(i,j)])
while len(todo)>0:
x,y=todo.popleft()
if seen[x][y]==1:
continue
seen[x][y]=1
if x>0 and seen[x-1][y]==0 and s[x-1][y]=='.':
b[x-1][y]=b[x][y]+1
todo.append((x-1,y))
if x>0 and s[x-1][y]=='#':
seen[x-1][y]=1
if x<h-1 and seen[x+1][y]==0 and s[x+1][y]=='.':
b[x+1][y]=b[x][y]+1
todo.append((x+1,y))
if x<h-1 and s[x+1][y]=='#':
seen[x+1][y]=1
if y>0 and seen[x][y-1]==0 and s[x][y-1]=='.':
b[x][y-1]=b[x][y]+1
todo.append((x,y-1))
if y>0 and s[x][y-1]=='#':
seen[x][y-1]=1
if y<w-1 and seen[x][y+1]==0 and s[x][y+1]=='.':
b[x][y+1]=b[x][y]+1
todo.append((x,y+1))
if y<w-1 and s[x][y+1]=='#':
seen[x][y+1]=1
ret=0
for bi in b:
for bij in bi:
if bij<400:
ret=max(ret,bij)
#print(b)
return ret
for i in range(h):
for j in range(w):
if s[i][j]=='.':
b=a
ans=max(ans,bfs(b,i,j))
print(ans)
| h,w=list(map(int,input().split()))
s=[eval(input()) for _ in range(h)]
from collections import deque
def bfs(i,j):
if s[i][j]=='#':
return 0
ret=-1
todo=[]
next_todo=[(i,j)]
seen=[[0]*w for _ in range(h)]
seen[i][j]=1
while next_todo:
ret+=1
todo=deque(next_todo)
next_todo=[]
while todo:
hi,wi=todo.popleft()
if hi>0 and seen[hi-1][wi]==0 and s[hi-1][wi]=='.':
seen[hi-1][wi]=1
next_todo.append((hi-1,wi))
if hi<h-1 and seen[hi+1][wi]==0 and s[hi+1][wi]=='.':
seen[hi+1][wi]=1
next_todo.append((hi+1,wi))
if wi>0 and seen[hi][wi-1]==0 and s[hi][wi-1]=='.':
seen[hi][wi-1]=1
next_todo.append((hi,wi-1))
if wi<w-1 and seen[hi][wi+1]==0 and s[hi][wi+1]=='.':
seen[hi][wi+1]=1
next_todo.append((hi,wi+1))
return ret
ans=0
for i in range(h):
for j in range(w):
ans=max(ans,bfs(i,j))
print(ans)
| 48 | 35 | 1,382 | 1,084 | from collections import deque
h, w = list(map(int, input().split()))
s = [eval(input()) for _ in range(h)]
a = [[400] * w for _ in range(h)]
ans = 0
def bfs(b, i, j):
b[i][j] = 0
seen = [[0] * w for _ in range(h)]
todo = deque([(i, j)])
while len(todo) > 0:
x, y = todo.popleft()
if seen[x][y] == 1:
continue
seen[x][y] = 1
if x > 0 and seen[x - 1][y] == 0 and s[x - 1][y] == ".":
b[x - 1][y] = b[x][y] + 1
todo.append((x - 1, y))
if x > 0 and s[x - 1][y] == "#":
seen[x - 1][y] = 1
if x < h - 1 and seen[x + 1][y] == 0 and s[x + 1][y] == ".":
b[x + 1][y] = b[x][y] + 1
todo.append((x + 1, y))
if x < h - 1 and s[x + 1][y] == "#":
seen[x + 1][y] = 1
if y > 0 and seen[x][y - 1] == 0 and s[x][y - 1] == ".":
b[x][y - 1] = b[x][y] + 1
todo.append((x, y - 1))
if y > 0 and s[x][y - 1] == "#":
seen[x][y - 1] = 1
if y < w - 1 and seen[x][y + 1] == 0 and s[x][y + 1] == ".":
b[x][y + 1] = b[x][y] + 1
todo.append((x, y + 1))
if y < w - 1 and s[x][y + 1] == "#":
seen[x][y + 1] = 1
ret = 0
for bi in b:
for bij in bi:
if bij < 400:
ret = max(ret, bij)
# print(b)
return ret
for i in range(h):
for j in range(w):
if s[i][j] == ".":
b = a
ans = max(ans, bfs(b, i, j))
print(ans)
| h, w = list(map(int, input().split()))
s = [eval(input()) for _ in range(h)]
from collections import deque
def bfs(i, j):
if s[i][j] == "#":
return 0
ret = -1
todo = []
next_todo = [(i, j)]
seen = [[0] * w for _ in range(h)]
seen[i][j] = 1
while next_todo:
ret += 1
todo = deque(next_todo)
next_todo = []
while todo:
hi, wi = todo.popleft()
if hi > 0 and seen[hi - 1][wi] == 0 and s[hi - 1][wi] == ".":
seen[hi - 1][wi] = 1
next_todo.append((hi - 1, wi))
if hi < h - 1 and seen[hi + 1][wi] == 0 and s[hi + 1][wi] == ".":
seen[hi + 1][wi] = 1
next_todo.append((hi + 1, wi))
if wi > 0 and seen[hi][wi - 1] == 0 and s[hi][wi - 1] == ".":
seen[hi][wi - 1] = 1
next_todo.append((hi, wi - 1))
if wi < w - 1 and seen[hi][wi + 1] == 0 and s[hi][wi + 1] == ".":
seen[hi][wi + 1] = 1
next_todo.append((hi, wi + 1))
return ret
ans = 0
for i in range(h):
for j in range(w):
ans = max(ans, bfs(i, j))
print(ans)
| false | 27.083333 | [
"+h, w = list(map(int, input().split()))",
"+s = [eval(input()) for _ in range(h)]",
"-h, w = list(map(int, input().split()))",
"-s = [eval(input()) for _ in range(h)]",
"-a = [[400] * w for _ in range(h)]",
"-ans = 0",
"-",
"-def bfs(b, i, j):",
"- b[i][j] = 0",
"+def bfs(i, j):",
"+ if s[i][j] == \"#\":",
"+ return 0",
"+ ret = -1",
"+ todo = []",
"+ next_todo = [(i, j)]",
"- todo = deque([(i, j)])",
"- while len(todo) > 0:",
"- x, y = todo.popleft()",
"- if seen[x][y] == 1:",
"- continue",
"- seen[x][y] = 1",
"- if x > 0 and seen[x - 1][y] == 0 and s[x - 1][y] == \".\":",
"- b[x - 1][y] = b[x][y] + 1",
"- todo.append((x - 1, y))",
"- if x > 0 and s[x - 1][y] == \"#\":",
"- seen[x - 1][y] = 1",
"- if x < h - 1 and seen[x + 1][y] == 0 and s[x + 1][y] == \".\":",
"- b[x + 1][y] = b[x][y] + 1",
"- todo.append((x + 1, y))",
"- if x < h - 1 and s[x + 1][y] == \"#\":",
"- seen[x + 1][y] = 1",
"- if y > 0 and seen[x][y - 1] == 0 and s[x][y - 1] == \".\":",
"- b[x][y - 1] = b[x][y] + 1",
"- todo.append((x, y - 1))",
"- if y > 0 and s[x][y - 1] == \"#\":",
"- seen[x][y - 1] = 1",
"- if y < w - 1 and seen[x][y + 1] == 0 and s[x][y + 1] == \".\":",
"- b[x][y + 1] = b[x][y] + 1",
"- todo.append((x, y + 1))",
"- if y < w - 1 and s[x][y + 1] == \"#\":",
"- seen[x][y + 1] = 1",
"- ret = 0",
"- for bi in b:",
"- for bij in bi:",
"- if bij < 400:",
"- ret = max(ret, bij)",
"- # print(b)",
"+ seen[i][j] = 1",
"+ while next_todo:",
"+ ret += 1",
"+ todo = deque(next_todo)",
"+ next_todo = []",
"+ while todo:",
"+ hi, wi = todo.popleft()",
"+ if hi > 0 and seen[hi - 1][wi] == 0 and s[hi - 1][wi] == \".\":",
"+ seen[hi - 1][wi] = 1",
"+ next_todo.append((hi - 1, wi))",
"+ if hi < h - 1 and seen[hi + 1][wi] == 0 and s[hi + 1][wi] == \".\":",
"+ seen[hi + 1][wi] = 1",
"+ next_todo.append((hi + 1, wi))",
"+ if wi > 0 and seen[hi][wi - 1] == 0 and s[hi][wi - 1] == \".\":",
"+ seen[hi][wi - 1] = 1",
"+ next_todo.append((hi, wi - 1))",
"+ if wi < w - 1 and seen[hi][wi + 1] == 0 and s[hi][wi + 1] == \".\":",
"+ seen[hi][wi + 1] = 1",
"+ next_todo.append((hi, wi + 1))",
"+ans = 0",
"- if s[i][j] == \".\":",
"- b = a",
"- ans = max(ans, bfs(b, i, j))",
"+ ans = max(ans, bfs(i, j))"
] | false | 0.059351 | 0.136374 | 0.43521 | [
"s789777289",
"s646915608"
] |
u319245933 | p02773 | python | s825952933 | s436545025 | 514 | 266 | 35,600 | 49,524 | Accepted | Accepted | 48.25 | # coding: utf-8
def main():
n = int(eval(input()))
lines = []
for i in range(0, n):
lines.append(eval(input()))
dct = {}
for l in lines:
if l in dct:
dct[l] += 1;
else:
dct[l] = 1;
cmax = max(dct.values())
print(('\n'.join(sorted([k for k,v in list(dct.items()) if v == cmax]))))
if __name__ == '__main__':
main()
| import collections
N,*S = open(0).read().split()
C = collections.Counter(S)
i = C.most_common()[0][1]
print(*sorted([k for k,v in C.most_common() if v == i]), sep='\n')
| 21 | 7 | 399 | 176 | # coding: utf-8
def main():
n = int(eval(input()))
lines = []
for i in range(0, n):
lines.append(eval(input()))
dct = {}
for l in lines:
if l in dct:
dct[l] += 1
else:
dct[l] = 1
cmax = max(dct.values())
print(("\n".join(sorted([k for k, v in list(dct.items()) if v == cmax]))))
if __name__ == "__main__":
main()
| import collections
N, *S = open(0).read().split()
C = collections.Counter(S)
i = C.most_common()[0][1]
print(*sorted([k for k, v in C.most_common() if v == i]), sep="\n")
| false | 66.666667 | [
"-# coding: utf-8",
"-def main():",
"- n = int(eval(input()))",
"- lines = []",
"- for i in range(0, n):",
"- lines.append(eval(input()))",
"- dct = {}",
"- for l in lines:",
"- if l in dct:",
"- dct[l] += 1",
"- else:",
"- dct[l] = 1",
"- cmax = max(dct.values())",
"- print((\"\\n\".join(sorted([k for k, v in list(dct.items()) if v == cmax]))))",
"+import collections",
"-",
"-if __name__ == \"__main__\":",
"- main()",
"+N, *S = open(0).read().split()",
"+C = collections.Counter(S)",
"+i = C.most_common()[0][1]",
"+print(*sorted([k for k, v in C.most_common() if v == i]), sep=\"\\n\")"
] | false | 0.058563 | 0.074017 | 0.79122 | [
"s825952933",
"s436545025"
] |
u062147869 | p03277 | python | s907110903 | s901946821 | 982 | 907 | 120,472 | 120,216 | Accepted | Accepted | 7.64 | class BIT():
def __init__(self,number):
self.n=number
self.list=[0]*(number+1)
def add(self,i,x):#ith added x 1indexed
while i<=self.n:
self.list[i]+=x
i+=i&-i
def search(self,i):#1-i sum
s=0
while i>0:
s+=self.list[i]
i-=i&-i
return s
def suma(self,i,j):#i,i+1,..j sum
return self.search(j)-self.search(i-1)
N=int(eval(input()))
A=[int(i) for i in input().split()]
if ((N*(N+1))//2)%2==1:
a=((N*(N+1))//2)//2+1
else:
a=((N*(N+1))//2)//2
#a=((N*(N+1))//2)-((N*(N+1))//2)//2-1
def f(s):#ans is ijou s
X=[1 if a>=s else -1 for a in A]
p=[0]*(N+1)
for i in range(1,N+1):
p[i]=p[i-1]+X[i-1]
tree=BIT(2*N+1)
num=0
for i in range(1,N+2):
num+=tree.search(p[i-1]+N+1)
tree.add(p[i-1]+N+1,1)
if num>=a:
return True
else:
return False
x=10**9+1
y=-1
while x-y>1:
mid=(x+y)//2
if f(mid):
y=mid
else:
x=mid
print(y)
| class BIT():
def __init__(self,number):
self.n=number
self.list=[0]*(number+1)
def add(self,i,x):#ith added x 1indexed
while i<=self.n:
self.list[i]+=x
i+=i&-i
def search(self,i):#1-i sum
s=0
while i>0:
s+=self.list[i]
i-=i&-i
return s
def suma(self,i,j):#i,i+1,..j sum
return self.search(j)-self.search(i-1)
N=int(eval(input()))
A=[int(i) for i in input().split()]
if ((N*(N+1))//2)%2==1:
a=((N*(N+1))//2)//2+1
else:
a=((N*(N+1))//2)//2
#a=((N*(N+1))//2)-((N*(N+1))//2)//2-1
def f(s):#ans is ijou s
X=[1 if a>=s else -1 for a in A]
p=[0]*(N+1)
ma=0
mi=0
for i in range(1,N+1):
p[i]=p[i-1]+X[i-1]
ma=max(p[i],ma)
mi=min(p[i],mi)
tree=BIT(ma-mi+1)
num=0
for i in range(1,N+2):
num+=tree.search(p[i-1]-mi+1)
tree.add(p[i-1]-mi+1,1)
if num>=a:
return True
else:
return False
x=10**9+1
y=-1
while x-y>1:
mid=(x+y)//2
if f(mid):
y=mid
else:
x=mid
print(y)
| 50 | 53 | 1,105 | 1,177 | class BIT:
def __init__(self, number):
self.n = number
self.list = [0] * (number + 1)
def add(self, i, x): # ith added x 1indexed
while i <= self.n:
self.list[i] += x
i += i & -i
def search(self, i): # 1-i sum
s = 0
while i > 0:
s += self.list[i]
i -= i & -i
return s
def suma(self, i, j): # i,i+1,..j sum
return self.search(j) - self.search(i - 1)
N = int(eval(input()))
A = [int(i) for i in input().split()]
if ((N * (N + 1)) // 2) % 2 == 1:
a = ((N * (N + 1)) // 2) // 2 + 1
else:
a = ((N * (N + 1)) // 2) // 2
# a=((N*(N+1))//2)-((N*(N+1))//2)//2-1
def f(s): # ans is ijou s
X = [1 if a >= s else -1 for a in A]
p = [0] * (N + 1)
for i in range(1, N + 1):
p[i] = p[i - 1] + X[i - 1]
tree = BIT(2 * N + 1)
num = 0
for i in range(1, N + 2):
num += tree.search(p[i - 1] + N + 1)
tree.add(p[i - 1] + N + 1, 1)
if num >= a:
return True
else:
return False
x = 10**9 + 1
y = -1
while x - y > 1:
mid = (x + y) // 2
if f(mid):
y = mid
else:
x = mid
print(y)
| class BIT:
def __init__(self, number):
self.n = number
self.list = [0] * (number + 1)
def add(self, i, x): # ith added x 1indexed
while i <= self.n:
self.list[i] += x
i += i & -i
def search(self, i): # 1-i sum
s = 0
while i > 0:
s += self.list[i]
i -= i & -i
return s
def suma(self, i, j): # i,i+1,..j sum
return self.search(j) - self.search(i - 1)
N = int(eval(input()))
A = [int(i) for i in input().split()]
if ((N * (N + 1)) // 2) % 2 == 1:
a = ((N * (N + 1)) // 2) // 2 + 1
else:
a = ((N * (N + 1)) // 2) // 2
# a=((N*(N+1))//2)-((N*(N+1))//2)//2-1
def f(s): # ans is ijou s
X = [1 if a >= s else -1 for a in A]
p = [0] * (N + 1)
ma = 0
mi = 0
for i in range(1, N + 1):
p[i] = p[i - 1] + X[i - 1]
ma = max(p[i], ma)
mi = min(p[i], mi)
tree = BIT(ma - mi + 1)
num = 0
for i in range(1, N + 2):
num += tree.search(p[i - 1] - mi + 1)
tree.add(p[i - 1] - mi + 1, 1)
if num >= a:
return True
else:
return False
x = 10**9 + 1
y = -1
while x - y > 1:
mid = (x + y) // 2
if f(mid):
y = mid
else:
x = mid
print(y)
| false | 5.660377 | [
"+ ma = 0",
"+ mi = 0",
"- tree = BIT(2 * N + 1)",
"+ ma = max(p[i], ma)",
"+ mi = min(p[i], mi)",
"+ tree = BIT(ma - mi + 1)",
"- num += tree.search(p[i - 1] + N + 1)",
"- tree.add(p[i - 1] + N + 1, 1)",
"+ num += tree.search(p[i - 1] - mi + 1)",
"+ tree.add(p[i - 1] - mi + 1, 1)"
] | false | 0.04969 | 0.049515 | 1.003523 | [
"s907110903",
"s901946821"
] |
u814986259 | p03470 | python | s865461862 | s416877174 | 21 | 17 | 3,316 | 2,940 | Accepted | Accepted | 19.05 | N=int(eval(input()))
d=[int(eval(input())) for i in range(N)]
import collections
table=collections.defaultdict(int)
for i in range(N):
table[d[i]]+=1
print((len(list(table.values())))) | N = int(eval(input()))
d = set()
for i in range(N):
a = eval(input())
d.add(a)
print((len(d))) | 7 | 6 | 172 | 89 | N = int(eval(input()))
d = [int(eval(input())) for i in range(N)]
import collections
table = collections.defaultdict(int)
for i in range(N):
table[d[i]] += 1
print((len(list(table.values()))))
| N = int(eval(input()))
d = set()
for i in range(N):
a = eval(input())
d.add(a)
print((len(d)))
| false | 14.285714 | [
"-d = [int(eval(input())) for i in range(N)]",
"-import collections",
"-",
"-table = collections.defaultdict(int)",
"+d = set()",
"- table[d[i]] += 1",
"-print((len(list(table.values()))))",
"+ a = eval(input())",
"+ d.add(a)",
"+print((len(d)))"
] | false | 0.048672 | 0.047389 | 1.027062 | [
"s865461862",
"s416877174"
] |
u761529120 | p03628 | python | s501108219 | s443423944 | 168 | 69 | 38,384 | 61,876 | Accepted | Accepted | 58.93 | def main():
N = int(eval(input()))
S1 = eval(input())
S2 = eval(input())
cnt = 0
MOD = 10 ** 9 + 7
i = 0
while i < N:
if i == 0:
if S1[i] == S2[i]:
cnt += 3
cnt %= MOD
i += 1
else:
cnt += 6
cnt %= MOD
i += 2
else:
if S1[i] == S2[i]:
if S1[i-1] == S2[i-1]:
cnt *= 2
cnt %= MOD
i += 1
else:
cnt *= 1
cnt %= MOD
i += 1
else:
if S1[i-1] == S2[i-1]:
cnt *= 2
cnt %= MOD
i += 2
else:
cnt *= 3
cnt %= MOD
i += 2
print(cnt)
if __name__ == "__main__":
main() | def main():
N = int(eval(input()))
S1 = eval(input())
S2 = eval(input())
MOD = 10 ** 9 + 7
ans = 1
cnt = 0
while cnt < N:
if cnt == 0:
if S1[cnt] == S2[cnt]:
ans *= 3
cnt += 1
else:
ans *= 6
cnt += 2
else:
if S1[cnt] == S2[cnt]:
if S1[cnt-1] == S2[cnt-1]:
ans *= 2
else:
ans *= 1
cnt += 1
else:
if S1[cnt-1] == S2[cnt-1]:
ans *= 2
else:
ans *= 3
cnt += 2
ans %= MOD
print(ans)
if __name__ == "__main__":
main() | 44 | 35 | 979 | 777 | def main():
N = int(eval(input()))
S1 = eval(input())
S2 = eval(input())
cnt = 0
MOD = 10**9 + 7
i = 0
while i < N:
if i == 0:
if S1[i] == S2[i]:
cnt += 3
cnt %= MOD
i += 1
else:
cnt += 6
cnt %= MOD
i += 2
else:
if S1[i] == S2[i]:
if S1[i - 1] == S2[i - 1]:
cnt *= 2
cnt %= MOD
i += 1
else:
cnt *= 1
cnt %= MOD
i += 1
else:
if S1[i - 1] == S2[i - 1]:
cnt *= 2
cnt %= MOD
i += 2
else:
cnt *= 3
cnt %= MOD
i += 2
print(cnt)
if __name__ == "__main__":
main()
| def main():
N = int(eval(input()))
S1 = eval(input())
S2 = eval(input())
MOD = 10**9 + 7
ans = 1
cnt = 0
while cnt < N:
if cnt == 0:
if S1[cnt] == S2[cnt]:
ans *= 3
cnt += 1
else:
ans *= 6
cnt += 2
else:
if S1[cnt] == S2[cnt]:
if S1[cnt - 1] == S2[cnt - 1]:
ans *= 2
else:
ans *= 1
cnt += 1
else:
if S1[cnt - 1] == S2[cnt - 1]:
ans *= 2
else:
ans *= 3
cnt += 2
ans %= MOD
print(ans)
if __name__ == "__main__":
main()
| false | 20.454545 | [
"+ MOD = 10**9 + 7",
"+ ans = 1",
"- MOD = 10**9 + 7",
"- i = 0",
"- while i < N:",
"- if i == 0:",
"- if S1[i] == S2[i]:",
"- cnt += 3",
"- cnt %= MOD",
"- i += 1",
"+ while cnt < N:",
"+ if cnt == 0:",
"+ if S1[cnt] == S2[cnt]:",
"+ ans *= 3",
"+ cnt += 1",
"- cnt += 6",
"- cnt %= MOD",
"- i += 2",
"+ ans *= 6",
"+ cnt += 2",
"- if S1[i] == S2[i]:",
"- if S1[i - 1] == S2[i - 1]:",
"- cnt *= 2",
"- cnt %= MOD",
"- i += 1",
"+ if S1[cnt] == S2[cnt]:",
"+ if S1[cnt - 1] == S2[cnt - 1]:",
"+ ans *= 2",
"- cnt *= 1",
"- cnt %= MOD",
"- i += 1",
"+ ans *= 1",
"+ cnt += 1",
"- if S1[i - 1] == S2[i - 1]:",
"- cnt *= 2",
"- cnt %= MOD",
"- i += 2",
"+ if S1[cnt - 1] == S2[cnt - 1]:",
"+ ans *= 2",
"- cnt *= 3",
"- cnt %= MOD",
"- i += 2",
"- print(cnt)",
"+ ans *= 3",
"+ cnt += 2",
"+ ans %= MOD",
"+ print(ans)"
] | false | 0.102947 | 0.048194 | 2.136109 | [
"s501108219",
"s443423944"
] |
u883621917 | p03830 | python | s946086792 | s322576882 | 195 | 72 | 39,280 | 67,800 | Accepted | Accepted | 63.08 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
n = int(eval(input()))
MOD = 10 ** 9 + 7
factorial = [0] * (n+1)
factorial[0] = 1
for i in range(1, n+1):
factorial[i] = factorial[i-1] * i
prime_factors = []
target = factorial[n]
i = 2
while i ** 2 <= target:
if target % i != 0:
i += 1
continue
ext = 0
while target % i == 0:
ext += 1
target //= i
prime_factors.append((i, ext))
i += 1
if target != 1:
prime_factors.append((target, 1))
ans = 1
for pf in prime_factors:
ans = (ans * (pf[1] + 1)) % MOD
print(ans)
| import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
n = int(eval(input()))
MOD = 10 ** 9 + 7
factorial = [0] * (n+1)
factorial[0] = 1
for i in range(1, n+1):
factorial[i] = (factorial[i-1] * i)
n = factorial[n]
prime_factors = []
i = 2
while i ** 2 <= n:
ext = 0
while n % i == 0:
ext += 1
n //= i
if ext:
prime_factors.append((i, ext))
i += 1
if n != 1:
prime_factors.append((n, 1))
ans = 1
for pf, num in prime_factors:
ans = (ans * (num + 1)) % MOD
print(ans)
| 36 | 30 | 634 | 559 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n = int(eval(input()))
MOD = 10**9 + 7
factorial = [0] * (n + 1)
factorial[0] = 1
for i in range(1, n + 1):
factorial[i] = factorial[i - 1] * i
prime_factors = []
target = factorial[n]
i = 2
while i**2 <= target:
if target % i != 0:
i += 1
continue
ext = 0
while target % i == 0:
ext += 1
target //= i
prime_factors.append((i, ext))
i += 1
if target != 1:
prime_factors.append((target, 1))
ans = 1
for pf in prime_factors:
ans = (ans * (pf[1] + 1)) % MOD
print(ans)
| import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n = int(eval(input()))
MOD = 10**9 + 7
factorial = [0] * (n + 1)
factorial[0] = 1
for i in range(1, n + 1):
factorial[i] = factorial[i - 1] * i
n = factorial[n]
prime_factors = []
i = 2
while i**2 <= n:
ext = 0
while n % i == 0:
ext += 1
n //= i
if ext:
prime_factors.append((i, ext))
i += 1
if n != 1:
prime_factors.append((n, 1))
ans = 1
for pf, num in prime_factors:
ans = (ans * (num + 1)) % MOD
print(ans)
| false | 16.666667 | [
"+n = factorial[n]",
"-target = factorial[n]",
"-while i**2 <= target:",
"- if target % i != 0:",
"- i += 1",
"- continue",
"+while i**2 <= n:",
"- while target % i == 0:",
"+ while n % i == 0:",
"- target //= i",
"- prime_factors.append((i, ext))",
"+ n //= i",
"+ if ext:",
"+ prime_factors.append((i, ext))",
"-if target != 1:",
"- prime_factors.append((target, 1))",
"+if n != 1:",
"+ prime_factors.append((n, 1))",
"-for pf in prime_factors:",
"- ans = (ans * (pf[1] + 1)) % MOD",
"+for pf, num in prime_factors:",
"+ ans = (ans * (num + 1)) % MOD"
] | false | 0.076676 | 0.054331 | 1.411277 | [
"s946086792",
"s322576882"
] |
u073549161 | p02973 | python | s702714292 | s110211866 | 640 | 260 | 53,336 | 11,036 | Accepted | Accepted | 59.38 | def bisect_right(a, x, lo=0, hi=None):
if lo < 0:
raise ValueError('lo must be non-negative')
if hi is None:
hi = len(a)
while lo < hi:
mid = (lo + hi) // 2
if x > a[mid]:
hi = mid
else:
lo = mid + 1
return lo
import collections
n = int(eval(input()))
dat = []
for i in range(n):
dat.append(int(eval(input())))
res = collections.deque([])
res.append(dat[0])
import bisect
for i in range(1, n):
a = bisect_right(res, dat[i])
#print("2 : {0}".format(a))
if a == len(res):
res.append(dat[i])
else:
res[a] = dat[i]
print((len(res)))
#print(res) | n = int(eval(input()))
dat = []
for i in range(n):
dat.append(int(eval(input())))
res = []
res.append(0 - dat[0])
import bisect
for i in range(1, n):
#print(res)
a = bisect.bisect_right(res, 0 - dat[i])
#print("a={0}".format(a))
if a == len(res):
res.append( (0 - dat[i]) )
else:
res[a] = (0 - dat[i])
print((len(res))) | 33 | 20 | 678 | 368 | def bisect_right(a, x, lo=0, hi=None):
if lo < 0:
raise ValueError("lo must be non-negative")
if hi is None:
hi = len(a)
while lo < hi:
mid = (lo + hi) // 2
if x > a[mid]:
hi = mid
else:
lo = mid + 1
return lo
import collections
n = int(eval(input()))
dat = []
for i in range(n):
dat.append(int(eval(input())))
res = collections.deque([])
res.append(dat[0])
import bisect
for i in range(1, n):
a = bisect_right(res, dat[i])
# print("2 : {0}".format(a))
if a == len(res):
res.append(dat[i])
else:
res[a] = dat[i]
print((len(res)))
# print(res)
| n = int(eval(input()))
dat = []
for i in range(n):
dat.append(int(eval(input())))
res = []
res.append(0 - dat[0])
import bisect
for i in range(1, n):
# print(res)
a = bisect.bisect_right(res, 0 - dat[i])
# print("a={0}".format(a))
if a == len(res):
res.append((0 - dat[i]))
else:
res[a] = 0 - dat[i]
print((len(res)))
| false | 39.393939 | [
"-def bisect_right(a, x, lo=0, hi=None):",
"- if lo < 0:",
"- raise ValueError(\"lo must be non-negative\")",
"- if hi is None:",
"- hi = len(a)",
"- while lo < hi:",
"- mid = (lo + hi) // 2",
"- if x > a[mid]:",
"- hi = mid",
"- else:",
"- lo = mid + 1",
"- return lo",
"-",
"-",
"-import collections",
"-",
"-res = collections.deque([])",
"-res.append(dat[0])",
"+res = []",
"+res.append(0 - dat[0])",
"- a = bisect_right(res, dat[i])",
"- # print(\"2 : {0}\".format(a))",
"+ # print(res)",
"+ a = bisect.bisect_right(res, 0 - dat[i])",
"+ # print(\"a={0}\".format(a))",
"- res.append(dat[i])",
"+ res.append((0 - dat[i]))",
"- res[a] = dat[i]",
"+ res[a] = 0 - dat[i]",
"-# print(res)"
] | false | 0.155453 | 0.137143 | 1.133509 | [
"s702714292",
"s110211866"
] |
u566872786 | p00009 | python | s751486986 | s116067750 | 4,170 | 2,350 | 11,084 | 11,460 | Accepted | Accepted | 43.65 | import sys
MAX = 999999
def is_prime(n):
if n == 2:return True
if n % 2 == 0:return False
for i in range(3,int(n**0.5)+1,2):
if n % i == 0:return False
return True
def prime_list(n):
result = []
if n >= 2:result.append(2)
for i in range(3,n+1,2):
if is_prime(i):result.append(i)
return result
L = prime_list(int(MAX**0.5))
def is_prime_2(n):
a = int(n ** 0.5)
for i in L:
if i > a:return True
if n % i == 0:return False
return True
def prime_count(n):
result = 0
if n >= 2:result+=1
for i in range(3,n+1,2):
if is_prime_2(i):result+=1
return result
L2 = prime_list(MAX)
def prime_count_2(n):
for i,v in enumerate(L2):
if v > n:return i
return len(L2)
for n in sys.stdin:
print((prime_count_2(int(n)))) | import sys
import time
MAX = 999999
def is_prime(n):
if n == 2:return True
if n % 2 == 0:return False
for i in range(3,int(n**0.5)+1,2):
if n % i == 0:return False
return True
def prime_list(n):
return ([2] if n > 1 else []) + [i for i in range(3,n+1,2) if is_prime(i)]
L = prime_list(int(MAX**0.5))
def is_prime_2(n):
a = int(n ** 0.5)
for i in L:
if i > a:return True
if n % i == 0:return False
return True
def prime_count(n):
result = 0
if n >= 2:result+=1
for i in range(3,n+1,2):
if is_prime_2(i):result+=1
return result
def prime_list2(n):
return ([2] if n > 1 else []) + [i for i in range(3,n+1,2) if is_prime_2(i)]
L2 = prime_list2(MAX)
def prime_count_2(n):
for i,v in enumerate(L2):
if v > n:return i
return len(L2)
for n in sys.stdin:
print((prime_count_2(int(n)))) | 43 | 43 | 810 | 878 | import sys
MAX = 999999
def is_prime(n):
if n == 2:
return True
if n % 2 == 0:
return False
for i in range(3, int(n**0.5) + 1, 2):
if n % i == 0:
return False
return True
def prime_list(n):
result = []
if n >= 2:
result.append(2)
for i in range(3, n + 1, 2):
if is_prime(i):
result.append(i)
return result
L = prime_list(int(MAX**0.5))
def is_prime_2(n):
a = int(n**0.5)
for i in L:
if i > a:
return True
if n % i == 0:
return False
return True
def prime_count(n):
result = 0
if n >= 2:
result += 1
for i in range(3, n + 1, 2):
if is_prime_2(i):
result += 1
return result
L2 = prime_list(MAX)
def prime_count_2(n):
for i, v in enumerate(L2):
if v > n:
return i
return len(L2)
for n in sys.stdin:
print((prime_count_2(int(n))))
| import sys
import time
MAX = 999999
def is_prime(n):
if n == 2:
return True
if n % 2 == 0:
return False
for i in range(3, int(n**0.5) + 1, 2):
if n % i == 0:
return False
return True
def prime_list(n):
return ([2] if n > 1 else []) + [i for i in range(3, n + 1, 2) if is_prime(i)]
L = prime_list(int(MAX**0.5))
def is_prime_2(n):
a = int(n**0.5)
for i in L:
if i > a:
return True
if n % i == 0:
return False
return True
def prime_count(n):
result = 0
if n >= 2:
result += 1
for i in range(3, n + 1, 2):
if is_prime_2(i):
result += 1
return result
def prime_list2(n):
return ([2] if n > 1 else []) + [i for i in range(3, n + 1, 2) if is_prime_2(i)]
L2 = prime_list2(MAX)
def prime_count_2(n):
for i, v in enumerate(L2):
if v > n:
return i
return len(L2)
for n in sys.stdin:
print((prime_count_2(int(n))))
| false | 0 | [
"+import time",
"- result = []",
"- if n >= 2:",
"- result.append(2)",
"- for i in range(3, n + 1, 2):",
"- if is_prime(i):",
"- result.append(i)",
"- return result",
"+ return ([2] if n > 1 else []) + [i for i in range(3, n + 1, 2) if is_prime(i)]",
"-L2 = prime_list(MAX)",
"+def prime_list2(n):",
"+ return ([2] if n > 1 else []) + [i for i in range(3, n + 1, 2) if is_prime_2(i)]",
"+",
"+",
"+L2 = prime_list2(MAX)"
] | false | 2.724172 | 1.305908 | 2.086037 | [
"s751486986",
"s116067750"
] |
u513081876 | p03607 | python | s836401965 | s077521832 | 229 | 161 | 21,344 | 20,720 | Accepted | Accepted | 29.69 | import collections
N = int(eval(input()))
A = [int(eval(input())) for i in range(N)]
ans = 0
num = collections.Counter(A).most_common()
for a, b in num:
if b % 2 != 0:
ans += 1
print(ans) | import collections
N = int(eval(input()))
A = [int(eval(input())) for i in range(N)]
ans = 0
dict = collections.Counter(A)
for a, b in list(dict.items()):
if b % 2 != 0:
ans += 1
print(ans) | 12 | 10 | 201 | 193 | import collections
N = int(eval(input()))
A = [int(eval(input())) for i in range(N)]
ans = 0
num = collections.Counter(A).most_common()
for a, b in num:
if b % 2 != 0:
ans += 1
print(ans)
| import collections
N = int(eval(input()))
A = [int(eval(input())) for i in range(N)]
ans = 0
dict = collections.Counter(A)
for a, b in list(dict.items()):
if b % 2 != 0:
ans += 1
print(ans)
| false | 16.666667 | [
"-num = collections.Counter(A).most_common()",
"-for a, b in num:",
"+dict = collections.Counter(A)",
"+for a, b in list(dict.items()):"
] | false | 0.043822 | 0.045099 | 0.971682 | [
"s836401965",
"s077521832"
] |
u457901067 | p03040 | python | s530781390 | s910236944 | 918 | 787 | 104,120 | 104,248 | Accepted | Accepted | 14.27 | import heapq
Q = int(eval(input()))
# 中央値の左側の値、右側の値を管理する
# heapqとする。rightは最小が興味あるが、leftは最大なので、-1をかけて扱う
left, right = [], []
# 両方のSUMも管理する必要がある。毎回SUMしてたら間に合わん
Lsum, Rsum = 0,0
Lcnt, Rcnt = 0,0
B = 0
for _ in range(Q):
q = list(map(int, input().split()))
if len(q) == 1:
# 2
# heapqってPeakできないの・・・?
l = (-1) * heapq.heappop(left)
heapq.heappush(left,(-1)*l)
# (l-l1) + (l-l2) + ... + (l-l) + (r-l) + ... + (r1 - l)
print((l, Rsum//2 - Lsum//2 + B))
#print(left,right, Lsum, Rsum)
else:
# 1
_,a,b = q
B += b
# まず双方にaを突っ込む
heapq.heappush(left,(-1)*a)
heapq.heappush(right,a)
Lsum += a
Lcnt += 1
Rsum += a
Rcnt += 1
# leftの最大値と、rightの最小値の関係が崩れていたら、交換する
l = (-1) * heapq.heappop(left)
r = heapq.heappop(right)
if l>=r:
Lsum = Lsum - l + r
Rsum = Rsum - r + l
l,r = r,l
heapq.heappush(left,(-1)*l)
heapq.heappush(right,r) | import heapq
Q = int(eval(input()))
# 中央値の左側の値、右側の値を管理する
# heapqとする。rightは最小が興味あるが、leftは最大なので、-1をかけて扱う
left, right = [], []
# 両方のSUMも管理する必要がある。毎回SUMしてたら間に合わん
Lsum, Rsum = 0,0
Lcnt, Rcnt = 0,0
B = 0
for _ in range(Q):
q = list(map(int, input().split()))
if len(q) == 1:
# 2
# heapqってPeakできないの・・・?
l = (-1) *left[0]
#l = (-1) * heapq.heappop(left)
#heapq.heappush(left,(-1)*l)
# (l-l1) + (l-l2) + ... + (l-l) + (r-l) + ... + (r1 - l)
print((l, Rsum//2 - Lsum//2 + B))
#print(left,right, Lsum, Rsum)
else:
# 1
_,a,b = q
B += b
# まず双方にaを突っ込む
heapq.heappush(left,(-1)*a)
heapq.heappush(right,a)
Lsum += a
Lcnt += 1
Rsum += a
Rcnt += 1
# leftの最大値と、rightの最小値の関係が崩れていたら、交換する
l = (-1)*left[0]
r = right[0]
#l = (-1) * heapq.heappop(left)
#r = heapq.heappop(right)
if l>=r:
Lsum = Lsum - l + r
Rsum = Rsum - r + l
l,r = r,l
_ = heapq.heappop(left)
_ = heapq.heappop(right)
heapq.heappush(left,(-1)*l)
heapq.heappush(right,r)
| 40 | 45 | 961 | 1,088 | import heapq
Q = int(eval(input()))
# 中央値の左側の値、右側の値を管理する
# heapqとする。rightは最小が興味あるが、leftは最大なので、-1をかけて扱う
left, right = [], []
# 両方のSUMも管理する必要がある。毎回SUMしてたら間に合わん
Lsum, Rsum = 0, 0
Lcnt, Rcnt = 0, 0
B = 0
for _ in range(Q):
q = list(map(int, input().split()))
if len(q) == 1:
# 2
# heapqってPeakできないの・・・?
l = (-1) * heapq.heappop(left)
heapq.heappush(left, (-1) * l)
# (l-l1) + (l-l2) + ... + (l-l) + (r-l) + ... + (r1 - l)
print((l, Rsum // 2 - Lsum // 2 + B))
# print(left,right, Lsum, Rsum)
else:
# 1
_, a, b = q
B += b
# まず双方にaを突っ込む
heapq.heappush(left, (-1) * a)
heapq.heappush(right, a)
Lsum += a
Lcnt += 1
Rsum += a
Rcnt += 1
# leftの最大値と、rightの最小値の関係が崩れていたら、交換する
l = (-1) * heapq.heappop(left)
r = heapq.heappop(right)
if l >= r:
Lsum = Lsum - l + r
Rsum = Rsum - r + l
l, r = r, l
heapq.heappush(left, (-1) * l)
heapq.heappush(right, r)
| import heapq
Q = int(eval(input()))
# 中央値の左側の値、右側の値を管理する
# heapqとする。rightは最小が興味あるが、leftは最大なので、-1をかけて扱う
left, right = [], []
# 両方のSUMも管理する必要がある。毎回SUMしてたら間に合わん
Lsum, Rsum = 0, 0
Lcnt, Rcnt = 0, 0
B = 0
for _ in range(Q):
q = list(map(int, input().split()))
if len(q) == 1:
# 2
# heapqってPeakできないの・・・?
l = (-1) * left[0]
# l = (-1) * heapq.heappop(left)
# heapq.heappush(left,(-1)*l)
# (l-l1) + (l-l2) + ... + (l-l) + (r-l) + ... + (r1 - l)
print((l, Rsum // 2 - Lsum // 2 + B))
# print(left,right, Lsum, Rsum)
else:
# 1
_, a, b = q
B += b
# まず双方にaを突っ込む
heapq.heappush(left, (-1) * a)
heapq.heappush(right, a)
Lsum += a
Lcnt += 1
Rsum += a
Rcnt += 1
# leftの最大値と、rightの最小値の関係が崩れていたら、交換する
l = (-1) * left[0]
r = right[0]
# l = (-1) * heapq.heappop(left)
# r = heapq.heappop(right)
if l >= r:
Lsum = Lsum - l + r
Rsum = Rsum - r + l
l, r = r, l
_ = heapq.heappop(left)
_ = heapq.heappop(right)
heapq.heappush(left, (-1) * l)
heapq.heappush(right, r)
| false | 11.111111 | [
"- l = (-1) * heapq.heappop(left)",
"- heapq.heappush(left, (-1) * l)",
"+ l = (-1) * left[0]",
"+ # l = (-1) * heapq.heappop(left)",
"+ # heapq.heappush(left,(-1)*l)",
"- l = (-1) * heapq.heappop(left)",
"- r = heapq.heappop(right)",
"+ l = (-1) * left[0]",
"+ r = right[0]",
"+ # l = (-1) * heapq.heappop(left)",
"+ # r = heapq.heappop(right)",
"+ _ = heapq.heappop(left)",
"+ _ = heapq.heappop(right)"
] | false | 0.042193 | 0.13276 | 0.317815 | [
"s530781390",
"s910236944"
] |
u368796742 | p02558 | python | s387360676 | s368515448 | 408 | 374 | 12,112 | 12,004 | Accepted | Accepted | 8.33 | import sys
input = sys.stdin.readline
class Unionfind:
def __init__(self,n):
self.uf = [-1]*n
def find(self,x):
if self.uf[x] < 0:
return x
else:
self.uf[x] = self.find(self.uf[x])
return self.uf[x]
def same(self,x,y):
return self.find(x) == self.find(y)
def union(self,x,y):
x = self.find(x)
y = self.find(y)
if x == y:
return False
if self.uf[x] > self.uf[y]:
x,y = y,x
self.uf[x] += self.uf[y]
self.uf[y] = x
return True
def size(self,x):
x = self.find(x)
return -self.uf[x]
n,q = list(map(int,input().split()))
U = Unionfind(n)
for i in range(q):
t,u,v = list(map(int,input().split()))
if t == 0:
U.union(u,v)
else:
print((int(U.same(u,v)))) | import sys
input = sys.stdin.readline
class Unionfind:
def __init__(self,n):
self.uf = [-1]*n
def find(self,x):
if self.uf[x] < 0:
return x
else:
self.uf[x] = self.find(self.uf[x])
return self.uf[x]
def same(self,x,y):
return self.find(x) == self.find(y)
def union(self,x,y):
x = self.find(x)
y = self.find(y)
if x == y:
return False
if self.uf[x] > self.uf[y]:
x,y = y,x
self.uf[x] += self.uf[y]
self.uf[y] = x
return True
def size(self,x):
x = self.find(x)
return -self.uf[x]
def main():
n,q = list(map(int,input().split()))
U = Unionfind(n)
for i in range(q):
t,u,v = list(map(int,input().split()))
if t == 0:
U.union(u,v)
else:
print((int(U.same(u,v))))
if __name__ == "__main__":
main() | 40 | 43 | 897 | 982 | import sys
input = sys.stdin.readline
class Unionfind:
def __init__(self, n):
self.uf = [-1] * n
def find(self, x):
if self.uf[x] < 0:
return x
else:
self.uf[x] = self.find(self.uf[x])
return self.uf[x]
def same(self, x, y):
return self.find(x) == self.find(y)
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return False
if self.uf[x] > self.uf[y]:
x, y = y, x
self.uf[x] += self.uf[y]
self.uf[y] = x
return True
def size(self, x):
x = self.find(x)
return -self.uf[x]
n, q = list(map(int, input().split()))
U = Unionfind(n)
for i in range(q):
t, u, v = list(map(int, input().split()))
if t == 0:
U.union(u, v)
else:
print((int(U.same(u, v))))
| import sys
input = sys.stdin.readline
class Unionfind:
def __init__(self, n):
self.uf = [-1] * n
def find(self, x):
if self.uf[x] < 0:
return x
else:
self.uf[x] = self.find(self.uf[x])
return self.uf[x]
def same(self, x, y):
return self.find(x) == self.find(y)
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return False
if self.uf[x] > self.uf[y]:
x, y = y, x
self.uf[x] += self.uf[y]
self.uf[y] = x
return True
def size(self, x):
x = self.find(x)
return -self.uf[x]
def main():
n, q = list(map(int, input().split()))
U = Unionfind(n)
for i in range(q):
t, u, v = list(map(int, input().split()))
if t == 0:
U.union(u, v)
else:
print((int(U.same(u, v))))
if __name__ == "__main__":
main()
| false | 6.976744 | [
"-n, q = list(map(int, input().split()))",
"-U = Unionfind(n)",
"-for i in range(q):",
"- t, u, v = list(map(int, input().split()))",
"- if t == 0:",
"- U.union(u, v)",
"- else:",
"- print((int(U.same(u, v))))",
"+def main():",
"+ n, q = list(map(int, input().split()))",
"+ U = Unionfind(n)",
"+ for i in range(q):",
"+ t, u, v = list(map(int, input().split()))",
"+ if t == 0:",
"+ U.union(u, v)",
"+ else:",
"+ print((int(U.same(u, v))))",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.050772 | 0.037215 | 1.364283 | [
"s387360676",
"s368515448"
] |
u201387466 | p02659 | python | s170703294 | s517279795 | 34 | 31 | 10,492 | 10,716 | Accepted | Accepted | 8.82 | import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
A,B = list(map(float,input().split()))
if math.floor(A) == 0 or B <= 0.005:
print((0))
else:
A = int(A)
B *= 100.0
B = round(B)
c = A*B
c = round(c)
print((c // 100))
| import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
A,B = list(map(Decimal,input().split()))
if round(A) == 0 or B <= 0.005:
print((0))
else:
print((math.floor(A*B)))
| 50 | 46 | 1,204 | 1,156 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# import numpy as np
INF = float("inf")
# d = defaultdict(int)
# d = defaultdict(list)
# N = int(input())
# A = list(map(int,input().split()))
# S = list(input())[:-1]
# S.remove("\n")
# N,M = map(int,input().split())
# S,T = map(str,input().split())
# A = [int(input()) for _ in range(N)]
# S = [list(input())[:-1] for _ in range(N)]
# A = [list(map(int,input().split())) for _ in range(N)]
A, B = list(map(float, input().split()))
if math.floor(A) == 0 or B <= 0.005:
print((0))
else:
A = int(A)
B *= 100.0
B = round(B)
c = A * B
c = round(c)
print((c // 100))
| import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# import numpy as np
INF = float("inf")
# d = defaultdict(int)
# d = defaultdict(list)
# N = int(input())
# A = list(map(int,input().split()))
# S = list(input())[:-1]
# S.remove("\n")
# N,M = map(int,input().split())
# S,T = map(str,input().split())
# A = [int(input()) for _ in range(N)]
# S = [list(input())[:-1] for _ in range(N)]
# A = [list(map(int,input().split())) for _ in range(N)]
A, B = list(map(Decimal, input().split()))
if round(A) == 0 or B <= 0.005:
print((0))
else:
print((math.floor(A * B)))
| false | 8 | [
"+from decimal import Decimal",
"-A, B = list(map(float, input().split()))",
"-if math.floor(A) == 0 or B <= 0.005:",
"+A, B = list(map(Decimal, input().split()))",
"+if round(A) == 0 or B <= 0.005:",
"- A = int(A)",
"- B *= 100.0",
"- B = round(B)",
"- c = A * B",
"- c = round(c)",
"- print((c // 100))",
"+ print((math.floor(A * B)))"
] | false | 0.072833 | 0.042286 | 1.722406 | [
"s170703294",
"s517279795"
] |
u034128150 | p02913 | python | s382190281 | s609787167 | 508 | 93 | 77,320 | 75,820 | Accepted | Accepted | 81.69 | N = int(eval(input()))
S = eval(input())
ans = 0
while S:
Z = [0] * N
i = 1
j = 0
while i < N:
while i + j < N and S[j] == S[i + j]:
j += 1
Z[i] = j
if j == 0:
i += 1
else:
k = 1
while k < j and k + Z[k] < j:
Z[i + k] = Z[k]
k += 1
i += k
j -= k
ans = max(ans, max(min(i, z) for i, z in enumerate(Z)))
S = S[1:]
N -= 1
print(ans) | N = int(eval(input()))
S = eval(input())
MOD = 2 ** 61 - 1
root = 10000
rhs = [0]
for h in map(ord, S):
rhs.append((root * rhs[-1] + h) % MOD)
pws = [1]
for i in range(N):
pws.append(pws[-1] * root % MOD)
ok = 0
ng = N
while ng - ok > 1:
mid = (ok + ng) // 2
hashes = dict()
flg = False
for i in range(N - mid + 1):
hashofsub = (rhs[i+mid] - rhs[i] * pws[mid]) % MOD
if hashofsub in hashes:
if i >= hashes[hashofsub] + mid:
flg = True
break
else:
hashes[hashofsub] = i
if flg:
ok = mid
else:
ng = mid
print(ok) | 30 | 35 | 520 | 670 | N = int(eval(input()))
S = eval(input())
ans = 0
while S:
Z = [0] * N
i = 1
j = 0
while i < N:
while i + j < N and S[j] == S[i + j]:
j += 1
Z[i] = j
if j == 0:
i += 1
else:
k = 1
while k < j and k + Z[k] < j:
Z[i + k] = Z[k]
k += 1
i += k
j -= k
ans = max(ans, max(min(i, z) for i, z in enumerate(Z)))
S = S[1:]
N -= 1
print(ans)
| N = int(eval(input()))
S = eval(input())
MOD = 2**61 - 1
root = 10000
rhs = [0]
for h in map(ord, S):
rhs.append((root * rhs[-1] + h) % MOD)
pws = [1]
for i in range(N):
pws.append(pws[-1] * root % MOD)
ok = 0
ng = N
while ng - ok > 1:
mid = (ok + ng) // 2
hashes = dict()
flg = False
for i in range(N - mid + 1):
hashofsub = (rhs[i + mid] - rhs[i] * pws[mid]) % MOD
if hashofsub in hashes:
if i >= hashes[hashofsub] + mid:
flg = True
break
else:
hashes[hashofsub] = i
if flg:
ok = mid
else:
ng = mid
print(ok)
| false | 14.285714 | [
"-ans = 0",
"-while S:",
"- Z = [0] * N",
"- i = 1",
"- j = 0",
"- while i < N:",
"- while i + j < N and S[j] == S[i + j]:",
"- j += 1",
"- Z[i] = j",
"- if j == 0:",
"- i += 1",
"+MOD = 2**61 - 1",
"+root = 10000",
"+rhs = [0]",
"+for h in map(ord, S):",
"+ rhs.append((root * rhs[-1] + h) % MOD)",
"+pws = [1]",
"+for i in range(N):",
"+ pws.append(pws[-1] * root % MOD)",
"+ok = 0",
"+ng = N",
"+while ng - ok > 1:",
"+ mid = (ok + ng) // 2",
"+ hashes = dict()",
"+ flg = False",
"+ for i in range(N - mid + 1):",
"+ hashofsub = (rhs[i + mid] - rhs[i] * pws[mid]) % MOD",
"+ if hashofsub in hashes:",
"+ if i >= hashes[hashofsub] + mid:",
"+ flg = True",
"+ break",
"- k = 1",
"- while k < j and k + Z[k] < j:",
"- Z[i + k] = Z[k]",
"- k += 1",
"- i += k",
"- j -= k",
"- ans = max(ans, max(min(i, z) for i, z in enumerate(Z)))",
"- S = S[1:]",
"- N -= 1",
"-print(ans)",
"+ hashes[hashofsub] = i",
"+ if flg:",
"+ ok = mid",
"+ else:",
"+ ng = mid",
"+print(ok)"
] | false | 0.040462 | 0.034205 | 1.182938 | [
"s382190281",
"s609787167"
] |
u175034939 | p03061 | python | s512114464 | s715964276 | 197 | 95 | 84,772 | 85,828 | Accepted | Accepted | 51.78 | import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
from math import gcd
class SegTree:
def __init__(self, N, ele):
self.num = 2**(N-1).bit_length()
self.el = ele
self.data = [ele]*(2*self.num)
def calc(self, x, y):
return gcd(x, y)
def update(self, idx, x):
idx += (self.num - 1)
self.data[idx] = x
while idx > 0:
idx = (idx-1)//2
self.data[idx] = self.calc(self.data[2*idx+1], self.data[2*idx+2])
def prod(self, l, r):
L = l + self.num
R = r + self.num
res = self.el
while L < R:
if L & 1:
res = self.calc(res, self.data[L-1])
L += 1
if R & 1:
R -= 1
res = self.calc(res, self.data[R-1])
L >>= 1
R >>= 1
return res
def get(self, idx):
idx += (self.num - 1)
return self.data[idx]
n = int(eval(input()))
A = list(map(int, input().split()))
seg = SegTree(n, 0)
for i, a in enumerate(A):
seg.update(i, a)
ans = 0
for i in range(n):
g = seg.get(i)
seg.update(i, 0)
ans = max(ans, seg.prod(0, n))
seg.update(i, g)
print(ans) | from math import gcd
n = int(eval(input()))
A = [0] + list(map(int, input().split())) + [0]
n += 2
L, R = [0]*n, [0]*n
gl, gr = 0, 0
for i in range(n):
gl = gcd(gl, A[i])
gr = gcd(gr, A[n-i-1])
L[i] = gl
R[n-i-1] = gr
ans = L[-1]
for i in range(n-2):
ans = max(ans, gcd(L[i], R[i+2]))
print(ans) | 54 | 17 | 1,283 | 327 | import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
from math import gcd
class SegTree:
def __init__(self, N, ele):
self.num = 2 ** (N - 1).bit_length()
self.el = ele
self.data = [ele] * (2 * self.num)
def calc(self, x, y):
return gcd(x, y)
def update(self, idx, x):
idx += self.num - 1
self.data[idx] = x
while idx > 0:
idx = (idx - 1) // 2
self.data[idx] = self.calc(self.data[2 * idx + 1], self.data[2 * idx + 2])
def prod(self, l, r):
L = l + self.num
R = r + self.num
res = self.el
while L < R:
if L & 1:
res = self.calc(res, self.data[L - 1])
L += 1
if R & 1:
R -= 1
res = self.calc(res, self.data[R - 1])
L >>= 1
R >>= 1
return res
def get(self, idx):
idx += self.num - 1
return self.data[idx]
n = int(eval(input()))
A = list(map(int, input().split()))
seg = SegTree(n, 0)
for i, a in enumerate(A):
seg.update(i, a)
ans = 0
for i in range(n):
g = seg.get(i)
seg.update(i, 0)
ans = max(ans, seg.prod(0, n))
seg.update(i, g)
print(ans)
| from math import gcd
n = int(eval(input()))
A = [0] + list(map(int, input().split())) + [0]
n += 2
L, R = [0] * n, [0] * n
gl, gr = 0, 0
for i in range(n):
gl = gcd(gl, A[i])
gr = gcd(gr, A[n - i - 1])
L[i] = gl
R[n - i - 1] = gr
ans = L[-1]
for i in range(n - 2):
ans = max(ans, gcd(L[i], R[i + 2]))
print(ans)
| false | 68.518519 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**8)",
"-input = sys.stdin.readline",
"-",
"-class SegTree:",
"- def __init__(self, N, ele):",
"- self.num = 2 ** (N - 1).bit_length()",
"- self.el = ele",
"- self.data = [ele] * (2 * self.num)",
"-",
"- def calc(self, x, y):",
"- return gcd(x, y)",
"-",
"- def update(self, idx, x):",
"- idx += self.num - 1",
"- self.data[idx] = x",
"- while idx > 0:",
"- idx = (idx - 1) // 2",
"- self.data[idx] = self.calc(self.data[2 * idx + 1], self.data[2 * idx + 2])",
"-",
"- def prod(self, l, r):",
"- L = l + self.num",
"- R = r + self.num",
"- res = self.el",
"- while L < R:",
"- if L & 1:",
"- res = self.calc(res, self.data[L - 1])",
"- L += 1",
"- if R & 1:",
"- R -= 1",
"- res = self.calc(res, self.data[R - 1])",
"- L >>= 1",
"- R >>= 1",
"- return res",
"-",
"- def get(self, idx):",
"- idx += self.num - 1",
"- return self.data[idx]",
"-",
"-",
"-A = list(map(int, input().split()))",
"-seg = SegTree(n, 0)",
"-for i, a in enumerate(A):",
"- seg.update(i, a)",
"-ans = 0",
"+A = [0] + list(map(int, input().split())) + [0]",
"+n += 2",
"+L, R = [0] * n, [0] * n",
"+gl, gr = 0, 0",
"- g = seg.get(i)",
"- seg.update(i, 0)",
"- ans = max(ans, seg.prod(0, n))",
"- seg.update(i, g)",
"+ gl = gcd(gl, A[i])",
"+ gr = gcd(gr, A[n - i - 1])",
"+ L[i] = gl",
"+ R[n - i - 1] = gr",
"+ans = L[-1]",
"+for i in range(n - 2):",
"+ ans = max(ans, gcd(L[i], R[i + 2]))"
] | false | 0.045602 | 0.131494 | 0.346798 | [
"s512114464",
"s715964276"
] |
u392319141 | p02728 | python | s633646277 | s736317805 | 1,719 | 1,577 | 86,544 | 86,544 | Accepted | Accepted | 8.26 | import sys
input = sys.stdin.buffer.readline
class Combination:
def __init__(self, size, mod=10**9 + 7):
self.size = size + 2
self.mod = mod
self.fact = [1, 1] + [0] * size
self.factInv = [1, 1] + [0] * size
self.inv = [0, 1] + [0] * size
for i in range(2, self.size):
self.fact[i] = self.fact[i - 1] * i % self.mod
self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod
def npr(self, n, r):
if n < r or n < 0 or r < 0:
return 0
return self.fact[n] * self.factInv[n - r] % self.mod
def ncr(self, n, r):
if n < r or n < 0 or r < 0:
return 0
return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod
def nhr(self, n, r): # 重複組合せ
return self.ncr(n + r - 1, n - 1)
def factN(self, n):
if n < 0:
return 0
return self.fact[n]
def factInvN(self, n):
if n < 0:
return 0
return self.factInv[n]
N = int(input())
MOD = 10**9 + 7
comb = Combination(N + 100)
edges = [[] for _ in range(N + 1)]
for _ in range(N - 1):
fr, to = map(int, input().split())
edges[fr].append(to)
edges[to].append(fr)
order = []
parent = [0] * (N + 1)
st = [1]
while st:
now = st.pop()
order.append(now)
for to in edges[now]:
if to == parent[now]:
continue
st.append(to)
parent[to] = now
size = [1] * (N + 1)
for v in order[::-1]:
size[parent[v]] += size[v]
dpLeaf = [1] * (N + 1)
for v in order[:: -1]:
pr = parent[v]
dpLeaf[v] = dpLeaf[v] * comb.factN(size[v] - 1) % MOD
dpLeaf[pr] = dpLeaf[pr] * dpLeaf[v] * comb.factInvN(size[v]) % MOD
ans = [0] * (N + 1)
ans[1] = dpLeaf[1]
for v in order[1:]:
pr = parent[v]
x = ans[pr]
x *= comb.factN(N - 1 - size[v]) * comb.factInvN(N - size[v])
x *= size[v]
ans[v] = x % MOD
print(*(ans[1:]), sep='\n')
| import sys
input = sys.stdin.buffer.readline
class Combination:
def __init__(self, size, mod=10**9 + 7):
self.size = size + 2
self.mod = mod
self.fact = [1, 1] + [0] * size
self.factInv = [1, 1] + [0] * size
self.inv = [0, 1] + [0] * size
for i in range(2, self.size):
self.fact[i] = self.fact[i - 1] * i % self.mod
self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod
def npr(self, n, r):
if n < r or n < 0 or r < 0:
return 0
return self.fact[n] * self.factInv[n - r] % self.mod
def ncr(self, n, r):
if n < r or n < 0 or r < 0:
return 0
return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod
def nhr(self, n, r): # 重複組合せ
return self.ncr(n + r - 1, n - 1)
def factN(self, n):
if n < 0:
return 0
return self.fact[n]
def factInvN(self, n):
if n < 0:
return 0
return self.factInv[n]
N = int(input())
MOD = 10**9 + 7
comb = Combination(N + 100)
edges = [[] for _ in range(N + 1)]
for _ in range(N - 1):
fr, to = map(int, input().split())
edges[fr].append(to)
edges[to].append(fr)
order = []
parent = [0] * (N + 1)
st = [1]
while st:
now = st.pop()
order.append(now)
for to in edges[now]:
if to == parent[now]:
continue
st.append(to)
parent[to] = now
size = [1] * (N + 1)
for v in order[::-1]:
size[parent[v]] += size[v]
dpLeaf = [1] * (N + 1)
for v in order[:: -1]:
pr = parent[v]
dpLeaf[v] = dpLeaf[v] * comb.factN(size[v] - 1) % MOD
dpLeaf[pr] = dpLeaf[pr] * dpLeaf[v] * comb.factInvN(size[v]) % MOD
ans = [0] * (N + 1)
ans[1] = dpLeaf[1]
for v in order[1:]:
pr = parent[v]
ans[v] = ans[pr] * comb.factN(N - 1 - size[v]) * comb.factInvN(N - size[v]) * size[v] % MOD
print(*(ans[1:]), sep='\n')
| 82 | 78 | 2,130 | 2,101 | import sys
input = sys.stdin.buffer.readline
class Combination:
def __init__(self, size, mod=10**9 + 7):
self.size = size + 2
self.mod = mod
self.fact = [1, 1] + [0] * size
self.factInv = [1, 1] + [0] * size
self.inv = [0, 1] + [0] * size
for i in range(2, self.size):
self.fact[i] = self.fact[i - 1] * i % self.mod
self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod
def npr(self, n, r):
if n < r or n < 0 or r < 0:
return 0
return self.fact[n] * self.factInv[n - r] % self.mod
def ncr(self, n, r):
if n < r or n < 0 or r < 0:
return 0
return (
self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod
)
def nhr(self, n, r): # 重複組合せ
return self.ncr(n + r - 1, n - 1)
def factN(self, n):
if n < 0:
return 0
return self.fact[n]
def factInvN(self, n):
if n < 0:
return 0
return self.factInv[n]
N = int(input())
MOD = 10**9 + 7
comb = Combination(N + 100)
edges = [[] for _ in range(N + 1)]
for _ in range(N - 1):
fr, to = map(int, input().split())
edges[fr].append(to)
edges[to].append(fr)
order = []
parent = [0] * (N + 1)
st = [1]
while st:
now = st.pop()
order.append(now)
for to in edges[now]:
if to == parent[now]:
continue
st.append(to)
parent[to] = now
size = [1] * (N + 1)
for v in order[::-1]:
size[parent[v]] += size[v]
dpLeaf = [1] * (N + 1)
for v in order[::-1]:
pr = parent[v]
dpLeaf[v] = dpLeaf[v] * comb.factN(size[v] - 1) % MOD
dpLeaf[pr] = dpLeaf[pr] * dpLeaf[v] * comb.factInvN(size[v]) % MOD
ans = [0] * (N + 1)
ans[1] = dpLeaf[1]
for v in order[1:]:
pr = parent[v]
x = ans[pr]
x *= comb.factN(N - 1 - size[v]) * comb.factInvN(N - size[v])
x *= size[v]
ans[v] = x % MOD
print(*(ans[1:]), sep="\n")
| import sys
input = sys.stdin.buffer.readline
class Combination:
def __init__(self, size, mod=10**9 + 7):
self.size = size + 2
self.mod = mod
self.fact = [1, 1] + [0] * size
self.factInv = [1, 1] + [0] * size
self.inv = [0, 1] + [0] * size
for i in range(2, self.size):
self.fact[i] = self.fact[i - 1] * i % self.mod
self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod
def npr(self, n, r):
if n < r or n < 0 or r < 0:
return 0
return self.fact[n] * self.factInv[n - r] % self.mod
def ncr(self, n, r):
if n < r or n < 0 or r < 0:
return 0
return (
self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod
)
def nhr(self, n, r): # 重複組合せ
return self.ncr(n + r - 1, n - 1)
def factN(self, n):
if n < 0:
return 0
return self.fact[n]
def factInvN(self, n):
if n < 0:
return 0
return self.factInv[n]
N = int(input())
MOD = 10**9 + 7
comb = Combination(N + 100)
edges = [[] for _ in range(N + 1)]
for _ in range(N - 1):
fr, to = map(int, input().split())
edges[fr].append(to)
edges[to].append(fr)
order = []
parent = [0] * (N + 1)
st = [1]
while st:
now = st.pop()
order.append(now)
for to in edges[now]:
if to == parent[now]:
continue
st.append(to)
parent[to] = now
size = [1] * (N + 1)
for v in order[::-1]:
size[parent[v]] += size[v]
dpLeaf = [1] * (N + 1)
for v in order[::-1]:
pr = parent[v]
dpLeaf[v] = dpLeaf[v] * comb.factN(size[v] - 1) % MOD
dpLeaf[pr] = dpLeaf[pr] * dpLeaf[v] * comb.factInvN(size[v]) % MOD
ans = [0] * (N + 1)
ans[1] = dpLeaf[1]
for v in order[1:]:
pr = parent[v]
ans[v] = (
ans[pr]
* comb.factN(N - 1 - size[v])
* comb.factInvN(N - size[v])
* size[v]
% MOD
)
print(*(ans[1:]), sep="\n")
| false | 4.878049 | [
"- x = ans[pr]",
"- x *= comb.factN(N - 1 - size[v]) * comb.factInvN(N - size[v])",
"- x *= size[v]",
"- ans[v] = x % MOD",
"+ ans[v] = (",
"+ ans[pr]",
"+ * comb.factN(N - 1 - size[v])",
"+ * comb.factInvN(N - size[v])",
"+ * size[v]",
"+ % MOD",
"+ )"
] | false | 0.049503 | 0.049475 | 1.000568 | [
"s633646277",
"s736317805"
] |
u840247626 | p02264 | python | s740509038 | s202458339 | 400 | 260 | 12,536 | 12,556 | Accepted | Accepted | 35 | from collections import deque
n,q = list(map(int,input().split()))
queue = deque()
for i in range(n):
name,time = input().split()
queue.append((name, int(time)))
t = 0
while queue:
name,time = queue.popleft()
t += min(q, time)
if time > q:
queue.append((name, time-q))
else:
print((name,t))
| import sys
from collections import deque
n,q = list(map(int,input().split()))
f = lambda n,t: (n,int(t))
queue = deque(f(*l.split()) for l in sys.stdin)
t = 0
while queue:
name,time = queue.popleft()
t += min(q, time)
if time > q:
queue.append((name, time-q))
else:
print((name,t))
| 16 | 15 | 310 | 298 | from collections import deque
n, q = list(map(int, input().split()))
queue = deque()
for i in range(n):
name, time = input().split()
queue.append((name, int(time)))
t = 0
while queue:
name, time = queue.popleft()
t += min(q, time)
if time > q:
queue.append((name, time - q))
else:
print((name, t))
| import sys
from collections import deque
n, q = list(map(int, input().split()))
f = lambda n, t: (n, int(t))
queue = deque(f(*l.split()) for l in sys.stdin)
t = 0
while queue:
name, time = queue.popleft()
t += min(q, time)
if time > q:
queue.append((name, time - q))
else:
print((name, t))
| false | 6.25 | [
"+import sys",
"-queue = deque()",
"-for i in range(n):",
"- name, time = input().split()",
"- queue.append((name, int(time)))",
"+f = lambda n, t: (n, int(t))",
"+queue = deque(f(*l.split()) for l in sys.stdin)"
] | false | 0.112342 | 0.037847 | 2.968328 | [
"s740509038",
"s202458339"
] |
u413165887 | p03141 | python | s173628444 | s499121656 | 1,973 | 499 | 23,260 | 23,260 | Accepted | Accepted | 74.71 | def main():
n = int(eval(input()))
df = []
for _ in range(n):
a, b = list(map(int, input().split(' ')))
df.append([a+b, a, b])
df.sort(reverse = True)
result = 0
for i in range(n):
if i%2 == 0:
x = df.pop(0)
result += x[1]
else:
x = df.pop(0)
result -= x[2]
print(result)
if __name__ == '__main__':
main() | n = int(eval(input()))
ab = []
for i in range(n):
a, b = list(map(int, input().split(' ')))
ab.append([a+b, a, b])
ab.sort(reverse = True)
result = 0
for i in range(n):
if i%2 == 0:
result += ab[i][1]
else:
result -= ab[i][2]
print(result) | 18 | 13 | 422 | 271 | def main():
n = int(eval(input()))
df = []
for _ in range(n):
a, b = list(map(int, input().split(" ")))
df.append([a + b, a, b])
df.sort(reverse=True)
result = 0
for i in range(n):
if i % 2 == 0:
x = df.pop(0)
result += x[1]
else:
x = df.pop(0)
result -= x[2]
print(result)
if __name__ == "__main__":
main()
| n = int(eval(input()))
ab = []
for i in range(n):
a, b = list(map(int, input().split(" ")))
ab.append([a + b, a, b])
ab.sort(reverse=True)
result = 0
for i in range(n):
if i % 2 == 0:
result += ab[i][1]
else:
result -= ab[i][2]
print(result)
| false | 27.777778 | [
"-def main():",
"- n = int(eval(input()))",
"- df = []",
"- for _ in range(n):",
"- a, b = list(map(int, input().split(\" \")))",
"- df.append([a + b, a, b])",
"- df.sort(reverse=True)",
"- result = 0",
"- for i in range(n):",
"- if i % 2 == 0:",
"- x = df.pop(0)",
"- result += x[1]",
"- else:",
"- x = df.pop(0)",
"- result -= x[2]",
"- print(result)",
"-",
"-",
"-if __name__ == \"__main__\":",
"- main()",
"+n = int(eval(input()))",
"+ab = []",
"+for i in range(n):",
"+ a, b = list(map(int, input().split(\" \")))",
"+ ab.append([a + b, a, b])",
"+ab.sort(reverse=True)",
"+result = 0",
"+for i in range(n):",
"+ if i % 2 == 0:",
"+ result += ab[i][1]",
"+ else:",
"+ result -= ab[i][2]",
"+print(result)"
] | false | 0.043139 | 0.063994 | 0.6741 | [
"s173628444",
"s499121656"
] |
u367701763 | p03163 | python | s961621636 | s519644085 | 155 | 138 | 74,288 | 74,080 | Accepted | Accepted | 10.97 | import sys
input = sys.stdin.readline
def max2(x, y):
""" pythonの組み込み関数 max は2変数に対しては遅い!! """
if x > y:
return x
else:
return y
def knapsack_weight(single=True):
"""
重さが小さい時のナップサックDP
:param single: True = 重複なし
"""
""" dp[weight <= W] = 重さ上限を固定した時の最大価値 """
dp_min = 0 # 総和価値の最小値
dp = [dp_min] * (W + 1)
for item in range(N):
if single:
S = reversed(list(range(weight_list[item], W + 1)))
else:
S = list(range(weight_list[item], W + 1))
for weight in S:
dp[weight] = max2(dp[weight], dp[weight - weight_list[item]] + price_list[item])
return dp[W]
#######################################################################################################
N, W = list(map(int, input().split())) # N: 品物の種類 W: 重量制限
price_list = []
weight_list = []
for _ in range(N):
weight, price = list(map(int, input().split()))
price_list.append(price)
weight_list.append(weight)
print((knapsack_weight(single=True)))
################################################################################################################################################
| import sys
input = sys.stdin.readline
def max2(x, y):
""" pythonの組み込み関数 max は2変数に対しては遅い!! """
if x > y:
return x
else:
return y
def knapsack_weight(single=True):
"""
重さが小さい時のナップサックDP
:param single: True = 重複なし
"""
N, W = list(map(int, input().split())) # N: 品物の種類 W: 重量制限
""" dp[weight <= W] = 重さ上限を固定した時の最大価値 """
dp_min = 0 # 総和価値の最小値
dp = [dp_min] * (W + 1)
for _ in range(N):
w, price = list(map(int, input().split()))
if single:
S = reversed(list(range(w, W + 1)))
else:
S = list(range(w, W + 1))
for weight in S:
dp[weight] = max2(dp[weight], dp[weight - w] + price)
return dp[W]
#######################################################################################################
print((knapsack_weight(single=True)))
| 46 | 37 | 1,242 | 884 | import sys
input = sys.stdin.readline
def max2(x, y):
"""pythonの組み込み関数 max は2変数に対しては遅い!!"""
if x > y:
return x
else:
return y
def knapsack_weight(single=True):
"""
重さが小さい時のナップサックDP
:param single: True = 重複なし
"""
""" dp[weight <= W] = 重さ上限を固定した時の最大価値 """
dp_min = 0 # 総和価値の最小値
dp = [dp_min] * (W + 1)
for item in range(N):
if single:
S = reversed(list(range(weight_list[item], W + 1)))
else:
S = list(range(weight_list[item], W + 1))
for weight in S:
dp[weight] = max2(
dp[weight], dp[weight - weight_list[item]] + price_list[item]
)
return dp[W]
#######################################################################################################
N, W = list(map(int, input().split())) # N: 品物の種類 W: 重量制限
price_list = []
weight_list = []
for _ in range(N):
weight, price = list(map(int, input().split()))
price_list.append(price)
weight_list.append(weight)
print((knapsack_weight(single=True)))
################################################################################################################################################
| import sys
input = sys.stdin.readline
def max2(x, y):
"""pythonの組み込み関数 max は2変数に対しては遅い!!"""
if x > y:
return x
else:
return y
def knapsack_weight(single=True):
"""
重さが小さい時のナップサックDP
:param single: True = 重複なし
"""
N, W = list(map(int, input().split())) # N: 品物の種類 W: 重量制限
""" dp[weight <= W] = 重さ上限を固定した時の最大価値 """
dp_min = 0 # 総和価値の最小値
dp = [dp_min] * (W + 1)
for _ in range(N):
w, price = list(map(int, input().split()))
if single:
S = reversed(list(range(w, W + 1)))
else:
S = list(range(w, W + 1))
for weight in S:
dp[weight] = max2(dp[weight], dp[weight - w] + price)
return dp[W]
#######################################################################################################
print((knapsack_weight(single=True)))
| false | 19.565217 | [
"+ N, W = list(map(int, input().split())) # N: 品物の種類 W: 重量制限",
"- for item in range(N):",
"+ for _ in range(N):",
"+ w, price = list(map(int, input().split()))",
"- S = reversed(list(range(weight_list[item], W + 1)))",
"+ S = reversed(list(range(w, W + 1)))",
"- S = list(range(weight_list[item], W + 1))",
"+ S = list(range(w, W + 1))",
"- dp[weight] = max2(",
"- dp[weight], dp[weight - weight_list[item]] + price_list[item]",
"- )",
"+ dp[weight] = max2(dp[weight], dp[weight - w] + price)",
"-N, W = list(map(int, input().split())) # N: 品物の種類 W: 重量制限",
"-price_list = []",
"-weight_list = []",
"-for _ in range(N):",
"- weight, price = list(map(int, input().split()))",
"- price_list.append(price)",
"- weight_list.append(weight)",
"-################################################################################################################################################"
] | false | 0.040161 | 0.041226 | 0.974162 | [
"s961621636",
"s519644085"
] |
u606045429 | p03149 | python | s012836518 | s011351181 | 20 | 17 | 3,316 | 2,940 | Accepted | Accepted | 15 | N = [int(_) for _ in input().split()]
if 1 in N and 9 in N and 7 in N and 4 in N:
print("YES")
else:
print("NO") | N = [int(_) for _ in input().split()]
N.sort()
if N == [1, 4, 7, 9]:
print("YES")
else:
print("NO")
| 6 | 7 | 126 | 115 | N = [int(_) for _ in input().split()]
if 1 in N and 9 in N and 7 in N and 4 in N:
print("YES")
else:
print("NO")
| N = [int(_) for _ in input().split()]
N.sort()
if N == [1, 4, 7, 9]:
print("YES")
else:
print("NO")
| false | 14.285714 | [
"-if 1 in N and 9 in N and 7 in N and 4 in N:",
"+N.sort()",
"+if N == [1, 4, 7, 9]:"
] | false | 0.048808 | 0.048978 | 0.996527 | [
"s012836518",
"s011351181"
] |
u141610915 | p03196 | python | s821348877 | s467499969 | 190 | 78 | 40,044 | 66,116 | Accepted | Accepted | 58.95 | import sys
input = sys.stdin.readline
N, P = list(map(int, input().split()))
if N == 1:
print(P)
exit(0)
i = 2
x = P + 0
l = []
s = set()
while i * i <= P:
while x % i == 0:
x //= i
l.append(i)
s.add(i)
i += 1
if x >= 2:
l.append(x)
s.add(x)
#print(l)
res = 1
for y in s:
t = l.count(y)
if t >= N:
res *= pow(y, (t // N))
print(res) | import sys
from collections import Counter
input = sys.stdin.readline
N, P = list(map(int, input().split()))
c = Counter()
x = 2
while x * x <= P:
while P % x == 0:
P //= x
c[x] += 1
x += 1
if P > 1: c[P] += 1
#print(c)
res = 1
for k in list(c.keys()):
v = c[k]
res *= pow(k, v // N)
print(res) | 27 | 18 | 385 | 315 | import sys
input = sys.stdin.readline
N, P = list(map(int, input().split()))
if N == 1:
print(P)
exit(0)
i = 2
x = P + 0
l = []
s = set()
while i * i <= P:
while x % i == 0:
x //= i
l.append(i)
s.add(i)
i += 1
if x >= 2:
l.append(x)
s.add(x)
# print(l)
res = 1
for y in s:
t = l.count(y)
if t >= N:
res *= pow(y, (t // N))
print(res)
| import sys
from collections import Counter
input = sys.stdin.readline
N, P = list(map(int, input().split()))
c = Counter()
x = 2
while x * x <= P:
while P % x == 0:
P //= x
c[x] += 1
x += 1
if P > 1:
c[P] += 1
# print(c)
res = 1
for k in list(c.keys()):
v = c[k]
res *= pow(k, v // N)
print(res)
| false | 33.333333 | [
"+from collections import Counter",
"-if N == 1:",
"- print(P)",
"- exit(0)",
"-i = 2",
"-x = P + 0",
"-l = []",
"-s = set()",
"-while i * i <= P:",
"- while x % i == 0:",
"- x //= i",
"- l.append(i)",
"- s.add(i)",
"- i += 1",
"-if x >= 2:",
"- l.append(x)",
"- s.add(x)",
"-# print(l)",
"+c = Counter()",
"+x = 2",
"+while x * x <= P:",
"+ while P % x == 0:",
"+ P //= x",
"+ c[x] += 1",
"+ x += 1",
"+if P > 1:",
"+ c[P] += 1",
"+# print(c)",
"-for y in s:",
"- t = l.count(y)",
"- if t >= N:",
"- res *= pow(y, (t // N))",
"+for k in list(c.keys()):",
"+ v = c[k]",
"+ res *= pow(k, v // N)"
] | false | 0.040707 | 0.037435 | 1.087393 | [
"s821348877",
"s467499969"
] |
u444722572 | p02779 | python | s101500647 | s100424035 | 165 | 84 | 21,940 | 26,804 | Accepted | Accepted | 49.09 | import sys
def solve():
readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
a.sort()
for i in range(1, n):
if a[i] == a[i-1]:
print("NO")
exit()
print("YES")
if __name__ == '__main__':
solve()
| N=int(eval(input()))
A=list(map(int,input().split()))
flg=0
if len(set(A))==N:
flg=1
print(("YES" if flg else "NO"))
| 18 | 7 | 344 | 127 | import sys
def solve():
readline = sys.stdin.buffer.readline
mod = 10**9 + 7
n = int(readline())
a = list(map(int, readline().split()))
a.sort()
for i in range(1, n):
if a[i] == a[i - 1]:
print("NO")
exit()
print("YES")
if __name__ == "__main__":
solve()
| N = int(eval(input()))
A = list(map(int, input().split()))
flg = 0
if len(set(A)) == N:
flg = 1
print(("YES" if flg else "NO"))
| false | 61.111111 | [
"-import sys",
"-",
"-",
"-def solve():",
"- readline = sys.stdin.buffer.readline",
"- mod = 10**9 + 7",
"- n = int(readline())",
"- a = list(map(int, readline().split()))",
"- a.sort()",
"- for i in range(1, n):",
"- if a[i] == a[i - 1]:",
"- print(\"NO\")",
"- exit()",
"- print(\"YES\")",
"-",
"-",
"-if __name__ == \"__main__\":",
"- solve()",
"+N = int(eval(input()))",
"+A = list(map(int, input().split()))",
"+flg = 0",
"+if len(set(A)) == N:",
"+ flg = 1",
"+print((\"YES\" if flg else \"NO\"))"
] | false | 0.046067 | 0.087611 | 0.525813 | [
"s101500647",
"s100424035"
] |
u670180528 | p03408 | python | s632648195 | s389379105 | 24 | 21 | 3,444 | 3,316 | Accepted | Accepted | 12.5 | from collections import*;a,b=eval('Counter([input()for _ in[0]*int(input())]),'*2);print((max([0]+[v for v inlist((a-b).values())]))) | from collections import Counter as c;n,*s=open(0);n=int(n);print((max([0]+[v for v inlist((c(s[:n])-c(s[n+1:])).values())]))) | 1 | 1 | 125 | 117 | from collections import*;a,b=eval('Counter([input()for _ in[0]*int(input())]),'*2);print((max([0]+[v for v inlist((a-b).values())]))) | from collections import Counter as c;n,*s=open(0);n=int(n);print((max([0]+[v for v inlist((c(s[:n])-c(s[n+1:])).values())]))) | false | 0 | [
"-from collections import*;a,b=eval('Counter([input()for _ in[0]*int(input())]),'*2);print((max([0]+[v for v inlist((a-b).values())])))",
"+from collections import Counter as c;n,*s=open(0);n=int(n);print((max([0]+[v for v inlist((c(s[:n])-c(s[n+1:])).values())])))"
] | false | 0.041071 | 0.042333 | 0.970176 | [
"s632648195",
"s389379105"
] |
u871867619 | p03470 | python | s030904064 | s684127318 | 149 | 19 | 12,472 | 2,940 | Accepted | Accepted | 87.25 | import numpy as np
n = int(eval(input()))
d = [int(eval(input())) for i in range(n)]
print((len(np.unique(d)))) | n = int(eval(input()))
d = {int(eval(input())) for i in range(n)}
print((len(d))) | 6 | 4 | 108 | 75 | import numpy as np
n = int(eval(input()))
d = [int(eval(input())) for i in range(n)]
print((len(np.unique(d))))
| n = int(eval(input()))
d = {int(eval(input())) for i in range(n)}
print((len(d)))
| false | 33.333333 | [
"-import numpy as np",
"-",
"-d = [int(eval(input())) for i in range(n)]",
"-print((len(np.unique(d))))",
"+d = {int(eval(input())) for i in range(n)}",
"+print((len(d)))"
] | false | 0.71303 | 0.044463 | 16.036462 | [
"s030904064",
"s684127318"
] |
u777181309 | p02397 | python | s768792284 | s083518291 | 60 | 50 | 5,612 | 5,616 | Accepted | Accepted | 16.67 |
while True:
a, b = list(map(int, input().split()))
if (a == 0) & (b == 0):
break
if a < b:
print((a, b))
else:
print((b, a))
| while True:
a, b = list(map(int, input().split()))
if a == 0 and b == 0:
break
if a < b:
print((a, b))
else:
print((b, a))
| 11 | 10 | 176 | 172 | while True:
a, b = list(map(int, input().split()))
if (a == 0) & (b == 0):
break
if a < b:
print((a, b))
else:
print((b, a))
| while True:
a, b = list(map(int, input().split()))
if a == 0 and b == 0:
break
if a < b:
print((a, b))
else:
print((b, a))
| false | 9.090909 | [
"- if (a == 0) & (b == 0):",
"+ if a == 0 and b == 0:"
] | false | 0.043072 | 0.038225 | 1.126803 | [
"s768792284",
"s083518291"
] |
u391731808 | p03017 | python | s493707589 | s236397201 | 173 | 18 | 40,816 | 3,572 | Accepted | Accepted | 89.6 | N,A,B,C,D=list(map(int,input().split()))
S=eval(input())
if C<D:
if "##" in S[A-1:C] or "##" in S[B-1:D]:
print("No")
else:
print("Yes")
else:
if (not ("##" in S[A-1:C])) and ("..." in S[B-2:D+1]):
print("Yes")
else:
print("No") | N,A,B,C,D = list(map(int,input().split()))
S = eval(input())
ans = ("##" not in S[A-1:C]) and ("##" not in S[B-1:D])
if D<C:
ans = ans and "..." in S[B-2:D+1]
print(("Yes" if ans else "No")) | 13 | 6 | 277 | 185 | N, A, B, C, D = list(map(int, input().split()))
S = eval(input())
if C < D:
if "##" in S[A - 1 : C] or "##" in S[B - 1 : D]:
print("No")
else:
print("Yes")
else:
if (not ("##" in S[A - 1 : C])) and ("..." in S[B - 2 : D + 1]):
print("Yes")
else:
print("No")
| N, A, B, C, D = list(map(int, input().split()))
S = eval(input())
ans = ("##" not in S[A - 1 : C]) and ("##" not in S[B - 1 : D])
if D < C:
ans = ans and "..." in S[B - 2 : D + 1]
print(("Yes" if ans else "No"))
| false | 53.846154 | [
"-if C < D:",
"- if \"##\" in S[A - 1 : C] or \"##\" in S[B - 1 : D]:",
"- print(\"No\")",
"- else:",
"- print(\"Yes\")",
"-else:",
"- if (not (\"##\" in S[A - 1 : C])) and (\"...\" in S[B - 2 : D + 1]):",
"- print(\"Yes\")",
"- else:",
"- print(\"No\")",
"+ans = (\"##\" not in S[A - 1 : C]) and (\"##\" not in S[B - 1 : D])",
"+if D < C:",
"+ ans = ans and \"...\" in S[B - 2 : D + 1]",
"+print((\"Yes\" if ans else \"No\"))"
] | false | 0.126623 | 0.032745 | 3.866955 | [
"s493707589",
"s236397201"
] |
u579833671 | p02389 | python | s530037780 | s016438133 | 30 | 10 | 6,724 | 4,184 | Accepted | Accepted | 66.67 | a, b = list(map(int, input().split()))
print(((a * b), 2 * (a + b))) | a, b = list(map(int, input().split()))
print(a * b, 2 * (a + b)) | 2 | 2 | 61 | 62 | a, b = list(map(int, input().split()))
print(((a * b), 2 * (a + b)))
| a, b = list(map(int, input().split()))
print(a * b, 2 * (a + b))
| false | 0 | [
"-print(((a * b), 2 * (a + b)))",
"+print(a * b, 2 * (a + b))"
] | false | 0.034328 | 0.063731 | 0.538641 | [
"s530037780",
"s016438133"
] |
u760248716 | p03975 | python | s022422560 | s464271129 | 164 | 17 | 38,256 | 2,940 | Accepted | Accepted | 89.63 | n,a,b=list(map(int,input().split()))
c=0
for _ in range(n):
t=int(eval(input()))
if t<a or b<=t:
c+=1
print(c) | def r(t,a,b):return t<a or b<=t
n,a,b=list(map(int,input().split()));print((sum(r(int(eval(input())),a,b)for _ in[0]*n))) | 7 | 2 | 112 | 108 | n, a, b = list(map(int, input().split()))
c = 0
for _ in range(n):
t = int(eval(input()))
if t < a or b <= t:
c += 1
print(c)
| def r(t, a, b):
return t < a or b <= t
n, a, b = list(map(int, input().split()))
print((sum(r(int(eval(input())), a, b) for _ in [0] * n)))
| false | 71.428571 | [
"+def r(t, a, b):",
"+ return t < a or b <= t",
"+",
"+",
"-c = 0",
"-for _ in range(n):",
"- t = int(eval(input()))",
"- if t < a or b <= t:",
"- c += 1",
"-print(c)",
"+print((sum(r(int(eval(input())), a, b) for _ in [0] * n)))"
] | false | 0.033264 | 0.035835 | 0.928257 | [
"s022422560",
"s464271129"
] |
u201856486 | p03147 | python | s879092101 | s064321289 | 20 | 18 | 3,060 | 2,940 | Accepted | Accepted | 10 | n=int(eval(input()))
h=list(map(int,input().split()))
print((sum([max(0,h[i+1]-h[i]) for i in range(n-1)])+h[0])) | n=int(eval(input()))
h=list(map(int,input().split()))
print((sum(max(0,h[i+1]-h[i])for i in range(n-1))+h[0])) | 3 | 3 | 107 | 104 | n = int(eval(input()))
h = list(map(int, input().split()))
print((sum([max(0, h[i + 1] - h[i]) for i in range(n - 1)]) + h[0]))
| n = int(eval(input()))
h = list(map(int, input().split()))
print((sum(max(0, h[i + 1] - h[i]) for i in range(n - 1)) + h[0]))
| false | 0 | [
"-print((sum([max(0, h[i + 1] - h[i]) for i in range(n - 1)]) + h[0]))",
"+print((sum(max(0, h[i + 1] - h[i]) for i in range(n - 1)) + h[0]))"
] | false | 0.043627 | 0.043573 | 1.001247 | [
"s879092101",
"s064321289"
] |
u077291787 | p03252 | python | s799874175 | s234475512 | 66 | 56 | 3,632 | 3,632 | Accepted | Accepted | 15.15 | # ABC110C - String Transformation
def main():
s, t = [input().rstrip() for _ in range(2)]
d = {}
for i, j in zip(s, t):
if i not in d:
d[i] = j
else:
if d[i] != j:
print("No")
break
else:
print(("Yes" if len(set(s)) == len(set(t)) else "No"))
if __name__ == "__main__":
main() | # ABC110C - String Transformation
def main():
s, t = [input().rstrip() for _ in range(2)]
d1, d2 = {}, {}
for i, j in zip(s, t):
if i not in d1:
d1[i] = j
if j not in d2:
d2[j] = i
if d1[i] != j or d2[j] != i:
print("No")
break
else:
print("Yes")
if __name__ == "__main__":
main() | 17 | 18 | 392 | 399 | # ABC110C - String Transformation
def main():
s, t = [input().rstrip() for _ in range(2)]
d = {}
for i, j in zip(s, t):
if i not in d:
d[i] = j
else:
if d[i] != j:
print("No")
break
else:
print(("Yes" if len(set(s)) == len(set(t)) else "No"))
if __name__ == "__main__":
main()
| # ABC110C - String Transformation
def main():
s, t = [input().rstrip() for _ in range(2)]
d1, d2 = {}, {}
for i, j in zip(s, t):
if i not in d1:
d1[i] = j
if j not in d2:
d2[j] = i
if d1[i] != j or d2[j] != i:
print("No")
break
else:
print("Yes")
if __name__ == "__main__":
main()
| false | 5.555556 | [
"- d = {}",
"+ d1, d2 = {}, {}",
"- if i not in d:",
"- d[i] = j",
"- else:",
"- if d[i] != j:",
"- print(\"No\")",
"- break",
"+ if i not in d1:",
"+ d1[i] = j",
"+ if j not in d2:",
"+ d2[j] = i",
"+ if d1[i] != j or d2[j] != i:",
"+ print(\"No\")",
"+ break",
"- print((\"Yes\" if len(set(s)) == len(set(t)) else \"No\"))",
"+ print(\"Yes\")"
] | false | 0.042689 | 0.037142 | 1.149359 | [
"s799874175",
"s234475512"
] |
u779170803 | p03835 | python | s658644269 | s225934341 | 1,657 | 782 | 2,940 | 3,064 | Accepted | Accepted | 52.81 | #input
K,S = list(map(int,input().split()))
#count
counter = 0
for x in range(0,K+1):
for y in range(0,K+1):
z = S - x - y
if 0 <= z <= K:
counter = counter + 1
#print
print(counter) | INT = lambda: int(eval(input()))
INTM = lambda: list(map(int,input().split()))
STRM = lambda: list(map(str,input().split()))
STR = lambda: str(eval(input()))
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
k,s=INTM()
ct=0
for x in range(k+1):
for y in range(k+1):
z=s-x-y
if 0<=z and z<=k:
ct+=1
print(ct)
if __name__ == '__main__':
do() | 13 | 17 | 223 | 452 | # input
K, S = list(map(int, input().split()))
# count
counter = 0
for x in range(0, K + 1):
for y in range(0, K + 1):
z = S - x - y
if 0 <= z <= K:
counter = counter + 1
# print
print(counter)
| INT = lambda: int(eval(input()))
INTM = lambda: list(map(int, input().split()))
STRM = lambda: list(map(str, input().split()))
STR = lambda: str(eval(input()))
LIST = lambda: list(map(int, input().split()))
LISTS = lambda: list(map(str, input().split()))
def do():
k, s = INTM()
ct = 0
for x in range(k + 1):
for y in range(k + 1):
z = s - x - y
if 0 <= z and z <= k:
ct += 1
print(ct)
if __name__ == "__main__":
do()
| false | 23.529412 | [
"-# input",
"-K, S = list(map(int, input().split()))",
"-# count",
"-counter = 0",
"-for x in range(0, K + 1):",
"- for y in range(0, K + 1):",
"- z = S - x - y",
"- if 0 <= z <= K:",
"- counter = counter + 1",
"-# print",
"-print(counter)",
"+INT = lambda: int(eval(input()))",
"+INTM = lambda: list(map(int, input().split()))",
"+STRM = lambda: list(map(str, input().split()))",
"+STR = lambda: str(eval(input()))",
"+LIST = lambda: list(map(int, input().split()))",
"+LISTS = lambda: list(map(str, input().split()))",
"+",
"+",
"+def do():",
"+ k, s = INTM()",
"+ ct = 0",
"+ for x in range(k + 1):",
"+ for y in range(k + 1):",
"+ z = s - x - y",
"+ if 0 <= z and z <= k:",
"+ ct += 1",
"+ print(ct)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ do()"
] | false | 0.037146 | 0.059022 | 0.629367 | [
"s658644269",
"s225934341"
] |
u606090886 | p03127 | python | s112864406 | s014275276 | 131 | 96 | 14,252 | 14,252 | Accepted | Accepted | 26.72 | n = int(eval(input()))
a = list(map(int,input().split()))
a.sort()
gcd = a[-1]
def Euclid(n1,n2):
if n1 % n2 == 0:
return n2
return Euclid(n2,n1%n2)
for i in range(n-1):
gcd = Euclid(gcd,a[(-1)*(i+2)])
print(gcd)
| n = int(eval(input()))
a = list(map(int,input().split()))
gcd = a[-1]
def Euclid(n1,n2):
if n1 % n2 == 0:
return n2
return Euclid(n2,n1%n2)
for i in range(n-1):
gcd = Euclid(gcd,a[(-1)*(i+2)])
print(gcd)
| 11 | 10 | 237 | 227 | n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
gcd = a[-1]
def Euclid(n1, n2):
if n1 % n2 == 0:
return n2
return Euclid(n2, n1 % n2)
for i in range(n - 1):
gcd = Euclid(gcd, a[(-1) * (i + 2)])
print(gcd)
| n = int(eval(input()))
a = list(map(int, input().split()))
gcd = a[-1]
def Euclid(n1, n2):
if n1 % n2 == 0:
return n2
return Euclid(n2, n1 % n2)
for i in range(n - 1):
gcd = Euclid(gcd, a[(-1) * (i + 2)])
print(gcd)
| false | 9.090909 | [
"-a.sort()"
] | false | 0.03059 | 0.042169 | 0.725401 | [
"s112864406",
"s014275276"
] |
u467736898 | p02728 | python | s291934974 | s521700306 | 2,002 | 1,725 | 175,736 | 167,040 | Accepted | Accepted | 13.84 | from functools import reduce
# 木を単方向に
def rerooting(n, edges, identity, merge, add_node):
# 全方位木 dp
# 参考1: https://qiita.com/keymoon/items/2a52f1b0fb7ef67fb89e
# 参考2: https://atcoder.jp/contests/abc160/submissions/15255726
from functools import reduce
G = [[] for _ in range(n)]
for a, b in edges:
G[a].append(b)
G[b].append(a)
# step 1
order = [] # 行きがけ順
stack = [0]
while stack:
v = stack.pop()
order.append(v)
for u in G[v]:
stack.append(u)
G[u].remove(v)
# 下から登る
dp_down = [0]*n # 自身とその下
for v in order[:0:-1]:
dp_down[v] = add_node(reduce(
merge, (dp_down[u] for u in G[v]), identity
), v)
# step 2
# 上から降りる
dp_up = [identity] * n # 親とその先
for v in order:
Gv = G[v]
if len(Gv) == 0:
continue
cum = identity
right = [identity]
for u in Gv[:0:-1]:
cum = merge(dp_down[u], cum)
right.append(cum)
right.reverse()
cum = dp_up[v]
for u, cum_r in zip(Gv, right):
dp_up[u] = add_node(merge(cum, cum_r), v)
cum = merge(cum, dp_down[u])
results = [add_node(
merge(
reduce(merge, (dp_down[u] for u in Gv), identity),
dp_up[v]
), v
) for v, Gv in enumerate(G)]
return results
class Combination:
def __init__(self, n_max, mod=10**9+7):
# O(n_max + log(mod))
self.mod = mod
f = 1
self.fac = fac = [f]
for i in range(1, n_max+1):
f = f * i % mod
fac.append(f)
f = pow(f, mod-2, mod)
self.facinv = facinv = [f]
for i in range(n_max, 0, -1):
f = f * i % mod
facinv.append(f)
facinv.reverse()
def __call__(self, n, r): # self.C と同じ
return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod
def main():
N = int(eval(input()))
AB = [list([int(x)-1 for x in input().split()]) for _ in range(N-1)]
mod = 10**9 + 7
comb = Combination(202020)
identity = (1, 0)
fac, facinv = comb.fac, comb.facinv
def merge(a, b):
a0, a1 = a
b0, b1 = b
return a0*b0*fac[a1+b1]*facinv[a1]*facinv[b1]%mod, a1+b1
def add_node(a, idx):
a0, a1 = a
return a0, a1+1
Ans = rerooting(N, AB, identity, merge, add_node)
print(("\n".join(str(ans) for ans, _ in Ans)))
main()
| # 入力高速化
import sys
from functools import reduce
def rerooting(n, edges, identity, merge, add_node):
# 全方位木 dp
# 参考1: https://qiita.com/keymoon/items/2a52f1b0fb7ef67fb89e
# 参考2: https://atcoder.jp/contests/abc160/submissions/15255726
from functools import reduce
G = [[] for _ in range(n)]
for a, b in edges:
G[a].append(b)
G[b].append(a)
# step 1
order = [] # 行きがけ順
stack = [0]
while stack:
v = stack.pop()
order.append(v)
for u in G[v]:
stack.append(u)
G[u].remove(v)
# 下から登る
dp_down = [0]*n # 自身とその下
for v in order[:0:-1]:
dp_down[v] = add_node(reduce(
merge, (dp_down[u] for u in G[v]), identity
), v)
# step 2
# 上から降りる
dp_up = [identity] * n # 親とその先
for v in order:
Gv = G[v]
if len(Gv) == 0:
continue
cum = identity
right = [identity]
for u in Gv[:0:-1]:
cum = merge(dp_down[u], cum)
right.append(cum)
right.reverse()
cum = dp_up[v]
for u, cum_r in zip(Gv, right):
dp_up[u] = add_node(merge(cum, cum_r), v)
cum = merge(cum, dp_down[u])
results = [add_node(
merge(
reduce(merge, (dp_down[u] for u in Gv), identity),
dp_up[v]
), v
) for v, Gv in enumerate(G)]
return results
class Combination:
def __init__(self, n_max, mod=10**9+7):
# O(n_max + log(mod))
self.mod = mod
f = 1
self.fac = fac = [f]
for i in range(1, n_max+1):
f = f * i % mod
fac.append(f)
f = pow(f, mod-2, mod)
self.facinv = facinv = [f]
for i in range(n_max, 0, -1):
f = f * i % mod
facinv.append(f)
facinv.reverse()
def __call__(self, n, r): # self.C と同じ
return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod
def main():
N = int(sys.stdin.buffer.readline())
m = list(map(int, sys.stdin.buffer.read().split()))
AB = tuple((a-1, b-1) for a, b in zip(m, m))
mod = 10**9 + 7
comb = Combination(202020)
identity = (1, 0)
fac, facinv = comb.fac, comb.facinv
def merge(a, b):
a0, a1 = a
b0, b1 = b
return a0*b0*fac[a1+b1]*facinv[a1]*facinv[b1]%mod, a1+b1
def add_node(a, idx):
a0, a1 = a
return a0, a1+1
Ans = rerooting(N, AB, identity, merge, add_node)
print(("\n".join(str(ans) for ans, _ in Ans)))
main()
| 87 | 91 | 2,559 | 2,616 | from functools import reduce
# 木を単方向に
def rerooting(n, edges, identity, merge, add_node):
# 全方位木 dp
# 参考1: https://qiita.com/keymoon/items/2a52f1b0fb7ef67fb89e
# 参考2: https://atcoder.jp/contests/abc160/submissions/15255726
from functools import reduce
G = [[] for _ in range(n)]
for a, b in edges:
G[a].append(b)
G[b].append(a)
# step 1
order = [] # 行きがけ順
stack = [0]
while stack:
v = stack.pop()
order.append(v)
for u in G[v]:
stack.append(u)
G[u].remove(v)
# 下から登る
dp_down = [0] * n # 自身とその下
for v in order[:0:-1]:
dp_down[v] = add_node(reduce(merge, (dp_down[u] for u in G[v]), identity), v)
# step 2
# 上から降りる
dp_up = [identity] * n # 親とその先
for v in order:
Gv = G[v]
if len(Gv) == 0:
continue
cum = identity
right = [identity]
for u in Gv[:0:-1]:
cum = merge(dp_down[u], cum)
right.append(cum)
right.reverse()
cum = dp_up[v]
for u, cum_r in zip(Gv, right):
dp_up[u] = add_node(merge(cum, cum_r), v)
cum = merge(cum, dp_down[u])
results = [
add_node(merge(reduce(merge, (dp_down[u] for u in Gv), identity), dp_up[v]), v)
for v, Gv in enumerate(G)
]
return results
class Combination:
def __init__(self, n_max, mod=10**9 + 7):
# O(n_max + log(mod))
self.mod = mod
f = 1
self.fac = fac = [f]
for i in range(1, n_max + 1):
f = f * i % mod
fac.append(f)
f = pow(f, mod - 2, mod)
self.facinv = facinv = [f]
for i in range(n_max, 0, -1):
f = f * i % mod
facinv.append(f)
facinv.reverse()
def __call__(self, n, r): # self.C と同じ
return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod
def main():
N = int(eval(input()))
AB = [list([int(x) - 1 for x in input().split()]) for _ in range(N - 1)]
mod = 10**9 + 7
comb = Combination(202020)
identity = (1, 0)
fac, facinv = comb.fac, comb.facinv
def merge(a, b):
a0, a1 = a
b0, b1 = b
return a0 * b0 * fac[a1 + b1] * facinv[a1] * facinv[b1] % mod, a1 + b1
def add_node(a, idx):
a0, a1 = a
return a0, a1 + 1
Ans = rerooting(N, AB, identity, merge, add_node)
print(("\n".join(str(ans) for ans, _ in Ans)))
main()
| # 入力高速化
import sys
from functools import reduce
def rerooting(n, edges, identity, merge, add_node):
# 全方位木 dp
# 参考1: https://qiita.com/keymoon/items/2a52f1b0fb7ef67fb89e
# 参考2: https://atcoder.jp/contests/abc160/submissions/15255726
from functools import reduce
G = [[] for _ in range(n)]
for a, b in edges:
G[a].append(b)
G[b].append(a)
# step 1
order = [] # 行きがけ順
stack = [0]
while stack:
v = stack.pop()
order.append(v)
for u in G[v]:
stack.append(u)
G[u].remove(v)
# 下から登る
dp_down = [0] * n # 自身とその下
for v in order[:0:-1]:
dp_down[v] = add_node(reduce(merge, (dp_down[u] for u in G[v]), identity), v)
# step 2
# 上から降りる
dp_up = [identity] * n # 親とその先
for v in order:
Gv = G[v]
if len(Gv) == 0:
continue
cum = identity
right = [identity]
for u in Gv[:0:-1]:
cum = merge(dp_down[u], cum)
right.append(cum)
right.reverse()
cum = dp_up[v]
for u, cum_r in zip(Gv, right):
dp_up[u] = add_node(merge(cum, cum_r), v)
cum = merge(cum, dp_down[u])
results = [
add_node(merge(reduce(merge, (dp_down[u] for u in Gv), identity), dp_up[v]), v)
for v, Gv in enumerate(G)
]
return results
class Combination:
def __init__(self, n_max, mod=10**9 + 7):
# O(n_max + log(mod))
self.mod = mod
f = 1
self.fac = fac = [f]
for i in range(1, n_max + 1):
f = f * i % mod
fac.append(f)
f = pow(f, mod - 2, mod)
self.facinv = facinv = [f]
for i in range(n_max, 0, -1):
f = f * i % mod
facinv.append(f)
facinv.reverse()
def __call__(self, n, r): # self.C と同じ
return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod
def main():
N = int(sys.stdin.buffer.readline())
m = list(map(int, sys.stdin.buffer.read().split()))
AB = tuple((a - 1, b - 1) for a, b in zip(m, m))
mod = 10**9 + 7
comb = Combination(202020)
identity = (1, 0)
fac, facinv = comb.fac, comb.facinv
def merge(a, b):
a0, a1 = a
b0, b1 = b
return a0 * b0 * fac[a1 + b1] * facinv[a1] * facinv[b1] % mod, a1 + b1
def add_node(a, idx):
a0, a1 = a
return a0, a1 + 1
Ans = rerooting(N, AB, identity, merge, add_node)
print(("\n".join(str(ans) for ans, _ in Ans)))
main()
| false | 4.395604 | [
"+# 入力高速化",
"+import sys",
"-# 木を単方向に",
"+",
"- N = int(eval(input()))",
"- AB = [list([int(x) - 1 for x in input().split()]) for _ in range(N - 1)]",
"+ N = int(sys.stdin.buffer.readline())",
"+ m = list(map(int, sys.stdin.buffer.read().split()))",
"+ AB = tuple((a - 1, b - 1) for a, b in zip(m, m))"
] | false | 0.261542 | 0.227367 | 1.150305 | [
"s291934974",
"s521700306"
] |
u935984175 | p02936 | python | s739559779 | s043425299 | 1,988 | 1,470 | 126,140 | 56,124 | Accepted | Accepted | 26.06 | from collections import deque
def solve():
N, Q = list(map(int, input().split()))
ab = [[0, 0] for _ in range(N-1)]
for i in range(N-1):
ab[i] = list(map(int, input().split()))
px = [[0, 0] for _ in range(Q)]
for i in range(Q):
px[i] = list(map(int, input().split()))
graph = [[] for _ in range(N+1)]
for a, b in ab:
graph[a].append(b)
graph[b].append(a)
val = [0 for _ in range(N+1)]
for p, x in px:
val[p] += x
que = deque([1])
parent = [0 for _ in range(N+1)]
while que:
i = que.popleft()
for j in graph[i]:
if j == parent[i]:
continue
parent[j] = i
que.append(j)
val[j] += val[i]
print((*val[1:]))
if __name__ == '__main__':
solve() | from collections import deque
def solve():
N, Q = list(map(int, input().split()))
graph = [[] for _ in range(N + 1)]
for i in range(N-1):
a, b = list(map(int, input().split()))
graph[a].append(b)
graph[b].append(a)
val = [0 for _ in range(N + 1)]
for i in range(Q):
p, x = list(map(int, input().split()))
val[p] += x
que = deque([1])
parent = [0 for _ in range(N+1)]
while que:
i = que.popleft()
for j in graph[i]:
if j == parent[i]:
continue
parent[j] = i
que.append(j)
val[j] += val[i]
print((*val[1:]))
if __name__ == '__main__':
solve() | 37 | 31 | 848 | 716 | from collections import deque
def solve():
N, Q = list(map(int, input().split()))
ab = [[0, 0] for _ in range(N - 1)]
for i in range(N - 1):
ab[i] = list(map(int, input().split()))
px = [[0, 0] for _ in range(Q)]
for i in range(Q):
px[i] = list(map(int, input().split()))
graph = [[] for _ in range(N + 1)]
for a, b in ab:
graph[a].append(b)
graph[b].append(a)
val = [0 for _ in range(N + 1)]
for p, x in px:
val[p] += x
que = deque([1])
parent = [0 for _ in range(N + 1)]
while que:
i = que.popleft()
for j in graph[i]:
if j == parent[i]:
continue
parent[j] = i
que.append(j)
val[j] += val[i]
print((*val[1:]))
if __name__ == "__main__":
solve()
| from collections import deque
def solve():
N, Q = list(map(int, input().split()))
graph = [[] for _ in range(N + 1)]
for i in range(N - 1):
a, b = list(map(int, input().split()))
graph[a].append(b)
graph[b].append(a)
val = [0 for _ in range(N + 1)]
for i in range(Q):
p, x = list(map(int, input().split()))
val[p] += x
que = deque([1])
parent = [0 for _ in range(N + 1)]
while que:
i = que.popleft()
for j in graph[i]:
if j == parent[i]:
continue
parent[j] = i
que.append(j)
val[j] += val[i]
print((*val[1:]))
if __name__ == "__main__":
solve()
| false | 16.216216 | [
"- ab = [[0, 0] for _ in range(N - 1)]",
"+ graph = [[] for _ in range(N + 1)]",
"- ab[i] = list(map(int, input().split()))",
"- px = [[0, 0] for _ in range(Q)]",
"- for i in range(Q):",
"- px[i] = list(map(int, input().split()))",
"- graph = [[] for _ in range(N + 1)]",
"- for a, b in ab:",
"+ a, b = list(map(int, input().split()))",
"- for p, x in px:",
"+ for i in range(Q):",
"+ p, x = list(map(int, input().split()))"
] | false | 0.037289 | 0.036425 | 1.023729 | [
"s739559779",
"s043425299"
] |
u186838327 | p03137 | python | s266755258 | s278266094 | 110 | 101 | 13,968 | 90,964 | Accepted | Accepted | 8.18 | n, m = list(map(int, input().split()))
l = list(map(int, input().split()))
if n >= m:
print((0))
exit()
l.sort()
d = [0]*(m-1)
for i in range(m-1):
d[i] = l[i+1] - l[i]
d.sort()
print((sum(d[0:(m-n)])))
| n, m = list(map(int, input().split()))
X = list(map(int, input().split()))
if n >= m:
print((0))
exit()
X.sort()
if n == 1:
print((X[-1]-X[0]))
exit()
Y = []
for i in range(m-1):
Y.append(X[i+1]-X[i])
#print(Y)
Y.sort()
ans = sum(Y[0:-(n-1)])
print(ans)
| 17 | 20 | 221 | 287 | n, m = list(map(int, input().split()))
l = list(map(int, input().split()))
if n >= m:
print((0))
exit()
l.sort()
d = [0] * (m - 1)
for i in range(m - 1):
d[i] = l[i + 1] - l[i]
d.sort()
print((sum(d[0 : (m - n)])))
| n, m = list(map(int, input().split()))
X = list(map(int, input().split()))
if n >= m:
print((0))
exit()
X.sort()
if n == 1:
print((X[-1] - X[0]))
exit()
Y = []
for i in range(m - 1):
Y.append(X[i + 1] - X[i])
# print(Y)
Y.sort()
ans = sum(Y[0 : -(n - 1)])
print(ans)
| false | 15 | [
"-l = list(map(int, input().split()))",
"+X = list(map(int, input().split()))",
"-l.sort()",
"-d = [0] * (m - 1)",
"+X.sort()",
"+if n == 1:",
"+ print((X[-1] - X[0]))",
"+ exit()",
"+Y = []",
"- d[i] = l[i + 1] - l[i]",
"-d.sort()",
"-print((sum(d[0 : (m - n)])))",
"+ Y.append(X[i + 1] - X[i])",
"+# print(Y)",
"+Y.sort()",
"+ans = sum(Y[0 : -(n - 1)])",
"+print(ans)"
] | false | 0.039329 | 0.043628 | 0.901454 | [
"s266755258",
"s278266094"
] |
u127499732 | p03274 | python | s141657970 | s545249323 | 71 | 58 | 14,052 | 14,052 | Accepted | Accepted | 18.31 | def main():
n, k, *x = list(map(int, open(0).read().split()))
x = tuple(x)
l = x[0 + k - 1] - x[0] + min(abs(x[0 + k - 1]), abs(x[0]))
for i in range(n - k + 1):
y = x[i + k - 1] - x[i] + min(abs(x[i + k - 1]), abs(x[i]))
if y < l:
l = y
print(l)
if __name__ == '__main__':
main()
| def main():
n, k, *x = list(map(int, open(0).read().split()))
l = x[0 + k - 1] - x[0] + min(abs(x[0 + k - 1]), abs(x[0]))
for i, j in zip(x, x[k - 1:]):
y = j - i + min(abs(i), abs(j))
if y < l:
l = y
print(l)
if __name__ == '__main__':
main()
| 15 | 14 | 345 | 303 | def main():
n, k, *x = list(map(int, open(0).read().split()))
x = tuple(x)
l = x[0 + k - 1] - x[0] + min(abs(x[0 + k - 1]), abs(x[0]))
for i in range(n - k + 1):
y = x[i + k - 1] - x[i] + min(abs(x[i + k - 1]), abs(x[i]))
if y < l:
l = y
print(l)
if __name__ == "__main__":
main()
| def main():
n, k, *x = list(map(int, open(0).read().split()))
l = x[0 + k - 1] - x[0] + min(abs(x[0 + k - 1]), abs(x[0]))
for i, j in zip(x, x[k - 1 :]):
y = j - i + min(abs(i), abs(j))
if y < l:
l = y
print(l)
if __name__ == "__main__":
main()
| false | 6.666667 | [
"- x = tuple(x)",
"- for i in range(n - k + 1):",
"- y = x[i + k - 1] - x[i] + min(abs(x[i + k - 1]), abs(x[i]))",
"+ for i, j in zip(x, x[k - 1 :]):",
"+ y = j - i + min(abs(i), abs(j))"
] | false | 0.045671 | 0.035893 | 1.272429 | [
"s141657970",
"s545249323"
] |
u934442292 | p03583 | python | s033082844 | s536766317 | 706 | 564 | 109,372 | 109,628 | Accepted | Accepted | 20.11 | import sys
from numba import njit
input = sys.stdin.readline
@njit
def solve(N):
for h in range(1, 3501):
for n in range(1, 3501):
a = N * h * n
b = 4 * h * n - (h + n) * N
if b > 0 and a % b == 0:
w = a // b
return h, n, w
def main():
N = int(eval(input()))
h, n, w = solve(N)
print((h, n, w))
if __name__ == "__main__":
main()
| import sys
from numba import njit
input = sys.stdin.readline
@njit("Tuple((i8,i8,i8))(i8)")
def solve(N):
for h in range(1, 3501):
for n in range(1, 3501):
a = N * h * n
b = 4 * h * n - (h + n) * N
if b > 0 and a % b == 0:
w = a // b
return h, n, w
return -1, -1, -1
def main():
N = int(eval(input()))
h, n, w = solve(N)
print((h, n, w))
if __name__ == "__main__":
main()
| 25 | 27 | 448 | 498 | import sys
from numba import njit
input = sys.stdin.readline
@njit
def solve(N):
for h in range(1, 3501):
for n in range(1, 3501):
a = N * h * n
b = 4 * h * n - (h + n) * N
if b > 0 and a % b == 0:
w = a // b
return h, n, w
def main():
N = int(eval(input()))
h, n, w = solve(N)
print((h, n, w))
if __name__ == "__main__":
main()
| import sys
from numba import njit
input = sys.stdin.readline
@njit("Tuple((i8,i8,i8))(i8)")
def solve(N):
for h in range(1, 3501):
for n in range(1, 3501):
a = N * h * n
b = 4 * h * n - (h + n) * N
if b > 0 and a % b == 0:
w = a // b
return h, n, w
return -1, -1, -1
def main():
N = int(eval(input()))
h, n, w = solve(N)
print((h, n, w))
if __name__ == "__main__":
main()
| false | 7.407407 | [
"-@njit",
"+@njit(\"Tuple((i8,i8,i8))(i8)\")",
"+ return -1, -1, -1"
] | false | 0.116357 | 0.040337 | 2.884663 | [
"s033082844",
"s536766317"
] |
u076937067 | p02388 | python | s387539776 | s886277908 | 30 | 10 | 6,724 | 6,344 | Accepted | Accepted | 66.67 | v=eval(input())
v=int(v)
print((v**3)) | x=eval(input())
print(x**3) | 3 | 2 | 32 | 21 | v = eval(input())
v = int(v)
print((v**3))
| x = eval(input())
print(x**3)
| false | 33.333333 | [
"-v = eval(input())",
"-v = int(v)",
"-print((v**3))",
"+x = eval(input())",
"+print(x**3)"
] | false | 0.032051 | 0.04543 | 0.705494 | [
"s387539776",
"s886277908"
] |
u562935282 | p03208 | python | s625712181 | s088903705 | 253 | 224 | 8,280 | 8,280 | Accepted | Accepted | 11.46 | n, k = list(map(int, input().split()))
h = [int(eval(input())) for _ in range(n)]
h = sorted(h)
d = float('inf')
i = 0
while i + k - 1 < n:
d = min(h[i + k - 1] - h[i], d)
i += 1
print(d)
| n, k = list(map(int, input().split()))
h = [int(eval(input())) for _ in range(n)]
h = sorted(h)
print((min(h[i + k - 1] - h[i] for i in range(n - k + 1))))
| 11 | 4 | 196 | 145 | n, k = list(map(int, input().split()))
h = [int(eval(input())) for _ in range(n)]
h = sorted(h)
d = float("inf")
i = 0
while i + k - 1 < n:
d = min(h[i + k - 1] - h[i], d)
i += 1
print(d)
| n, k = list(map(int, input().split()))
h = [int(eval(input())) for _ in range(n)]
h = sorted(h)
print((min(h[i + k - 1] - h[i] for i in range(n - k + 1))))
| false | 63.636364 | [
"-d = float(\"inf\")",
"-i = 0",
"-while i + k - 1 < n:",
"- d = min(h[i + k - 1] - h[i], d)",
"- i += 1",
"-print(d)",
"+print((min(h[i + k - 1] - h[i] for i in range(n - k + 1))))"
] | false | 0.045471 | 0.045764 | 0.993609 | [
"s625712181",
"s088903705"
] |
u562935282 | p02959 | python | s474077500 | s381860152 | 159 | 127 | 18,476 | 24,152 | Accepted | Accepted | 20.13 | def main():
N = int(eval(input()))
*A, = list(map(int, input().split()))
*B, = list(map(int, input().split()))
ans = 0
for i, can_beat in enumerate(B):
beat = min(A[i], can_beat)
A[i] -= beat
can_beat -= beat
ans += beat
beat = min(A[i + 1], can_beat)
A[i + 1] -= beat
ans += beat
print(ans)
if __name__ == '__main__':
main()
| def main():
N = int(eval(input()))
*A, = list(map(int, input().split()))
*B, = list(map(int, input().split()))
ans = 0
for i in range(N):
beaten = min(A[i], B[i])
A[i] -= beaten
B[i] -= beaten
ans += beaten
if B[i]:
beaten = min(A[i + 1], B[i])
A[i + 1] -= beaten
B[i] -= beaten
ans += beaten
print(ans)
if __name__ == '__main__':
main()
| 21 | 23 | 417 | 463 | def main():
N = int(eval(input()))
(*A,) = list(map(int, input().split()))
(*B,) = list(map(int, input().split()))
ans = 0
for i, can_beat in enumerate(B):
beat = min(A[i], can_beat)
A[i] -= beat
can_beat -= beat
ans += beat
beat = min(A[i + 1], can_beat)
A[i + 1] -= beat
ans += beat
print(ans)
if __name__ == "__main__":
main()
| def main():
N = int(eval(input()))
(*A,) = list(map(int, input().split()))
(*B,) = list(map(int, input().split()))
ans = 0
for i in range(N):
beaten = min(A[i], B[i])
A[i] -= beaten
B[i] -= beaten
ans += beaten
if B[i]:
beaten = min(A[i + 1], B[i])
A[i + 1] -= beaten
B[i] -= beaten
ans += beaten
print(ans)
if __name__ == "__main__":
main()
| false | 8.695652 | [
"- for i, can_beat in enumerate(B):",
"- beat = min(A[i], can_beat)",
"- A[i] -= beat",
"- can_beat -= beat",
"- ans += beat",
"- beat = min(A[i + 1], can_beat)",
"- A[i + 1] -= beat",
"- ans += beat",
"+ for i in range(N):",
"+ beaten = min(A[i], B[i])",
"+ A[i] -= beaten",
"+ B[i] -= beaten",
"+ ans += beaten",
"+ if B[i]:",
"+ beaten = min(A[i + 1], B[i])",
"+ A[i + 1] -= beaten",
"+ B[i] -= beaten",
"+ ans += beaten"
] | false | 0.007871 | 0.036985 | 0.212814 | [
"s474077500",
"s381860152"
] |
u186838327 | p03327 | python | s613027851 | s781627347 | 165 | 62 | 38,256 | 61,900 | Accepted | Accepted | 62.42 | n = int(eval(input()))
if n <= 999:
print('ABC')
else:
print('ABD')
| n = int(eval(input()))
if n >= 1000:
print('ABD')
else:
print('ABC')
| 5 | 5 | 74 | 75 | n = int(eval(input()))
if n <= 999:
print("ABC")
else:
print("ABD")
| n = int(eval(input()))
if n >= 1000:
print("ABD")
else:
print("ABC")
| false | 0 | [
"-if n <= 999:",
"+if n >= 1000:",
"+ print(\"ABD\")",
"+else:",
"-else:",
"- print(\"ABD\")"
] | false | 0.046717 | 0.144709 | 0.322833 | [
"s613027851",
"s781627347"
] |
u373047809 | p02605 | python | s879852967 | s090041309 | 1,403 | 1,128 | 131,280 | 131,388 | Accepted | Accepted | 19.6 | _,*a=list(map(str.split,open(0)))
U,R,D,L="URDL"
d={i:[]for i in"URDL"}
for *z,u in a:d[u]+=[*list(map(int,z))],
N=9e9
P,M="x+y,","x-y,"
for A,B,S in(U,D,"x,y,"),(R,L,"y,x,"),(R,U,P+M),(D,L,P+M),(U,L,M+P),(R,D,M+P):
n=p=-9e9
for x,y,r in sorted(eval(f"[({S}Q)for P,Q in[(A,1),(B,0)]for x,y in d[P]]")):
if x-n:
if r:n,p=x,y
elif r:p=y
else:N=min(N,y-p)
print((["SAFE",N*5][N!=9e9])) | _,*a=list(map(str.split,open(0)))
U,R,D,L="URDL"
d={i:[]for i in"URDL"}
for *z,u in a:d[u]+=[*list(map(int,z))],
N=9e9
P,M="x+y,","x-y,"
for A,B,S in(U,D,"x,y,"),(R,L,"y,x,"),(R,U,P+M),(D,L,P+M),(U,L,M+P),(R,D,M+P):
n=p=-9e9
for x,y,r in sorted(eval(f"[({S}Q)for P,Q in[(A,1),(B,0)]for x,y in d[P]]")):
if x-n:
if r:n,p=x,y
elif r:p=y
else:N=min(N,y-p)
print((["SAFE",N*5][N<9e9])) | 14 | 14 | 392 | 391 | _, *a = list(map(str.split, open(0)))
U, R, D, L = "URDL"
d = {i: [] for i in "URDL"}
for *z, u in a:
d[u] += ([*list(map(int, z))],)
N = 9e9
P, M = "x+y,", "x-y,"
for A, B, S in (
(U, D, "x,y,"),
(R, L, "y,x,"),
(R, U, P + M),
(D, L, P + M),
(U, L, M + P),
(R, D, M + P),
):
n = p = -9e9
for x, y, r in sorted(eval(f"[({S}Q)for P,Q in[(A,1),(B,0)]for x,y in d[P]]")):
if x - n:
if r:
n, p = x, y
elif r:
p = y
else:
N = min(N, y - p)
print((["SAFE", N * 5][N != 9e9]))
| _, *a = list(map(str.split, open(0)))
U, R, D, L = "URDL"
d = {i: [] for i in "URDL"}
for *z, u in a:
d[u] += ([*list(map(int, z))],)
N = 9e9
P, M = "x+y,", "x-y,"
for A, B, S in (
(U, D, "x,y,"),
(R, L, "y,x,"),
(R, U, P + M),
(D, L, P + M),
(U, L, M + P),
(R, D, M + P),
):
n = p = -9e9
for x, y, r in sorted(eval(f"[({S}Q)for P,Q in[(A,1),(B,0)]for x,y in d[P]]")):
if x - n:
if r:
n, p = x, y
elif r:
p = y
else:
N = min(N, y - p)
print((["SAFE", N * 5][N < 9e9]))
| false | 0 | [
"-print(([\"SAFE\", N * 5][N != 9e9]))",
"+print(([\"SAFE\", N * 5][N < 9e9]))"
] | false | 0.038835 | 0.042383 | 0.916295 | [
"s879852967",
"s090041309"
] |
u930705402 | p02955 | python | s390178824 | s505708016 | 590 | 502 | 3,444 | 3,188 | Accepted | Accepted | 14.92 | from collections import deque
def isok(x):
que=deque(sorted(z%x for z in a))
res=0
while que:
l=que[0]
if l==0:
que.popleft()
continue
r=que[-1]
if r==0:
que.pop()
continue
d=min(l,x-r)
que[0]-=d
que[-1]=(que[-1]+d)%x
res+=d
return res
def factor(N):
arr=[]
for i in range(1,int(N**0.5)+1):
if(N%i==0):
arr.append(i)
if(N//i!=i):
arr.append(N//i)
return arr
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
sum_=sum(a)
fac=sorted(factor(sum_),reverse=True)
ans=1
for x in fac:
c=isok(x)
if c<=k:
ans=x
break
print(ans)
| def factor(N):
arr=[]
for i in range(1,int(N**0.5)+1):
if(N%i==0):
arr.append(i)
if(N//i!=i):
arr.append(N//i)
return arr
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
sum_=sum(a)
fac=sorted(factor(sum_),reverse=True)
ans=1
for x in fac:
li=sorted(z%x for z in a)
res=0
cum=[0]*(n+1)
for i in range(n):
cum[i+1]=cum[i]+li[i]
for i in range(1,n):
l,r=cum[i],x*(n-i)-(cum[n]-cum[i])
if l==r and r<=k:
ans=max(ans,x)
print(ans) | 40 | 26 | 794 | 583 | from collections import deque
def isok(x):
que = deque(sorted(z % x for z in a))
res = 0
while que:
l = que[0]
if l == 0:
que.popleft()
continue
r = que[-1]
if r == 0:
que.pop()
continue
d = min(l, x - r)
que[0] -= d
que[-1] = (que[-1] + d) % x
res += d
return res
def factor(N):
arr = []
for i in range(1, int(N**0.5) + 1):
if N % i == 0:
arr.append(i)
if N // i != i:
arr.append(N // i)
return arr
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
sum_ = sum(a)
fac = sorted(factor(sum_), reverse=True)
ans = 1
for x in fac:
c = isok(x)
if c <= k:
ans = x
break
print(ans)
| def factor(N):
arr = []
for i in range(1, int(N**0.5) + 1):
if N % i == 0:
arr.append(i)
if N // i != i:
arr.append(N // i)
return arr
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
sum_ = sum(a)
fac = sorted(factor(sum_), reverse=True)
ans = 1
for x in fac:
li = sorted(z % x for z in a)
res = 0
cum = [0] * (n + 1)
for i in range(n):
cum[i + 1] = cum[i] + li[i]
for i in range(1, n):
l, r = cum[i], x * (n - i) - (cum[n] - cum[i])
if l == r and r <= k:
ans = max(ans, x)
print(ans)
| false | 35 | [
"-from collections import deque",
"-",
"-",
"-def isok(x):",
"- que = deque(sorted(z % x for z in a))",
"- res = 0",
"- while que:",
"- l = que[0]",
"- if l == 0:",
"- que.popleft()",
"- continue",
"- r = que[-1]",
"- if r == 0:",
"- que.pop()",
"- continue",
"- d = min(l, x - r)",
"- que[0] -= d",
"- que[-1] = (que[-1] + d) % x",
"- res += d",
"- return res",
"-",
"-",
"- c = isok(x)",
"- if c <= k:",
"- ans = x",
"- break",
"+ li = sorted(z % x for z in a)",
"+ res = 0",
"+ cum = [0] * (n + 1)",
"+ for i in range(n):",
"+ cum[i + 1] = cum[i] + li[i]",
"+ for i in range(1, n):",
"+ l, r = cum[i], x * (n - i) - (cum[n] - cum[i])",
"+ if l == r and r <= k:",
"+ ans = max(ans, x)"
] | false | 0.040316 | 0.039486 | 1.021025 | [
"s390178824",
"s505708016"
] |
u708255304 | p03290 | python | s739135359 | s290279029 | 129 | 51 | 3,064 | 3,188 | Accepted | Accepted | 60.47 | "All Green"
"""
考え方
その点数の問題を全て解く or 1問も解かないをbit全探索で分けて処理を行い、目標点に到達していない
ならば、配点の高い問題から一問ずつ解いて確認していく。
"""
D, G = list(map(int, input().split())) # 与えられる問題数のスコアのレンジD, 目標の点数G
PC = [] # 100i点の問題の個数とコンプリートボーナス
ans = 99999999
for i in range(D):
p, c = list(map(int, input().split()))
score = (i+1)*100
PC.append([score, p, c])
for mask in range(1 << D): # D種類の問題について解くか解かないかの二択を考える
solved_amount = 0
my_score = 0
for i in range(D):
score, p, c = PC[i] # その問題のscore, 問題数のp, コンプリートしたらc
if (mask >> i) & 1: # ビットが立つならその問題を全て解くことにする
solved_amount += p # 解いた問題数を増やして
my_score += score * p + c # スコアを加算する
for i in range(D-1, -1, -1): # 目標点Gに達していない時の処理、配点の高い問題から考えている
if my_score >= G: # すでに目標点数に到達していたら終了して、解いた問題の量を保持しにいく
break
if (mask >> i) & 1: # すでにその問題を解いていたらもう解けないので次の配点の問題へ
continue
score, p, c = PC[i] # 今部分的に解こうとしている問題のscore, 問題数のp, コンプリートしたらc
# 今スコアは超えていない状態
for _ in range(p):
# 一問ずつ解いて超えるラインを探す
solved_amount += 1
my_score += score
if my_score >= G:
break
if my_score >= G:
ans = min(ans, solved_amount)
print(ans)
| # この問題はbit全探索で解く
D, G = list(map(int, input().split())) # 1~Dのスコア帯, 目標の点数G
# 問題を受け取る
problems = [list(map(int, input().split())) for _ in range(D)] # pi問存在している, ボーナスci点
# 状態を列挙する
all_status = []
for i in range(1 << D):
tmp = []
for j in range(D):
if (i >> j) & 1:
tmp.append(1)
else:
tmp.append(0)
all_status.append(tmp)
# 状態の列挙が終わった
ans = float('inf')
for status in all_status:
# status中の1が立っている部分の問題を全て解く
score = 0
solve_count = 0
for i in range(len(status)):
if status[i] == 1:
# i番目の問題を全て解く
score += (i+1)*100*problems[i][0] + problems[i][1]
solve_count += problems[i][0]
# 対象の問題を全部解き終えた
if score >= G:
ans = min(ans, solve_count)
else:
# 足りない問題を解く
for i in reversed(list(range(len(status)))):
if status[i] == 0: # 解いていない問題の中で一番ポイントが高いものを解く
for j in range(problems[i][0]): # 1問ずつ解く
score += (i+1)*100
solve_count += 1
if score >= G:
ans = min(ans, solve_count)
break
break
print(ans)
| 45 | 41 | 1,273 | 1,221 | "All Green"
"""
考え方
その点数の問題を全て解く or 1問も解かないをbit全探索で分けて処理を行い、目標点に到達していない
ならば、配点の高い問題から一問ずつ解いて確認していく。
"""
D, G = list(map(int, input().split())) # 与えられる問題数のスコアのレンジD, 目標の点数G
PC = [] # 100i点の問題の個数とコンプリートボーナス
ans = 99999999
for i in range(D):
p, c = list(map(int, input().split()))
score = (i + 1) * 100
PC.append([score, p, c])
for mask in range(1 << D): # D種類の問題について解くか解かないかの二択を考える
solved_amount = 0
my_score = 0
for i in range(D):
score, p, c = PC[i] # その問題のscore, 問題数のp, コンプリートしたらc
if (mask >> i) & 1: # ビットが立つならその問題を全て解くことにする
solved_amount += p # 解いた問題数を増やして
my_score += score * p + c # スコアを加算する
for i in range(D - 1, -1, -1): # 目標点Gに達していない時の処理、配点の高い問題から考えている
if my_score >= G: # すでに目標点数に到達していたら終了して、解いた問題の量を保持しにいく
break
if (mask >> i) & 1: # すでにその問題を解いていたらもう解けないので次の配点の問題へ
continue
score, p, c = PC[i] # 今部分的に解こうとしている問題のscore, 問題数のp, コンプリートしたらc
# 今スコアは超えていない状態
for _ in range(p):
# 一問ずつ解いて超えるラインを探す
solved_amount += 1
my_score += score
if my_score >= G:
break
if my_score >= G:
ans = min(ans, solved_amount)
print(ans)
| # この問題はbit全探索で解く
D, G = list(map(int, input().split())) # 1~Dのスコア帯, 目標の点数G
# 問題を受け取る
problems = [list(map(int, input().split())) for _ in range(D)] # pi問存在している, ボーナスci点
# 状態を列挙する
all_status = []
for i in range(1 << D):
tmp = []
for j in range(D):
if (i >> j) & 1:
tmp.append(1)
else:
tmp.append(0)
all_status.append(tmp)
# 状態の列挙が終わった
ans = float("inf")
for status in all_status:
# status中の1が立っている部分の問題を全て解く
score = 0
solve_count = 0
for i in range(len(status)):
if status[i] == 1:
# i番目の問題を全て解く
score += (i + 1) * 100 * problems[i][0] + problems[i][1]
solve_count += problems[i][0]
# 対象の問題を全部解き終えた
if score >= G:
ans = min(ans, solve_count)
else:
# 足りない問題を解く
for i in reversed(list(range(len(status)))):
if status[i] == 0: # 解いていない問題の中で一番ポイントが高いものを解く
for j in range(problems[i][0]): # 1問ずつ解く
score += (i + 1) * 100
solve_count += 1
if score >= G:
ans = min(ans, solve_count)
break
break
print(ans)
| false | 8.888889 | [
"-\"All Green\"",
"-\"\"\"",
"-考え方",
"-その点数の問題を全て解く or 1問も解かないをbit全探索で分けて処理を行い、目標点に到達していない",
"-ならば、配点の高い問題から一問ずつ解いて確認していく。",
"-\"\"\"",
"-D, G = list(map(int, input().split())) # 与えられる問題数のスコアのレンジD, 目標の点数G",
"-PC = [] # 100i点の問題の個数とコンプリートボーナス",
"-ans = 99999999",
"-for i in range(D):",
"- p, c = list(map(int, input().split()))",
"- score = (i + 1) * 100",
"- PC.append([score, p, c])",
"-for mask in range(1 << D): # D種類の問題について解くか解かないかの二択を考える",
"- solved_amount = 0",
"- my_score = 0",
"- for i in range(D):",
"- score, p, c = PC[i] # その問題のscore, 問題数のp, コンプリートしたらc",
"- if (mask >> i) & 1: # ビットが立つならその問題を全て解くことにする",
"- solved_amount += p # 解いた問題数を増やして",
"- my_score += score * p + c # スコアを加算する",
"- for i in range(D - 1, -1, -1): # 目標点Gに達していない時の処理、配点の高い問題から考えている",
"- if my_score >= G: # すでに目標点数に到達していたら終了して、解いた問題の量を保持しにいく",
"- break",
"- if (mask >> i) & 1: # すでにその問題を解いていたらもう解けないので次の配点の問題へ",
"- continue",
"- score, p, c = PC[i] # 今部分的に解こうとしている問題のscore, 問題数のp, コンプリートしたらc",
"- # 今スコアは超えていない状態",
"- for _ in range(p):",
"- # 一問ずつ解いて超えるラインを探す",
"- solved_amount += 1",
"- my_score += score",
"- if my_score >= G:",
"+# この問題はbit全探索で解く",
"+D, G = list(map(int, input().split())) # 1~Dのスコア帯, 目標の点数G",
"+# 問題を受け取る",
"+problems = [list(map(int, input().split())) for _ in range(D)] # pi問存在している, ボーナスci点",
"+# 状態を列挙する",
"+all_status = []",
"+for i in range(1 << D):",
"+ tmp = []",
"+ for j in range(D):",
"+ if (i >> j) & 1:",
"+ tmp.append(1)",
"+ else:",
"+ tmp.append(0)",
"+ all_status.append(tmp)",
"+# 状態の列挙が終わった",
"+ans = float(\"inf\")",
"+for status in all_status:",
"+ # status中の1が立っている部分の問題を全て解く",
"+ score = 0",
"+ solve_count = 0",
"+ for i in range(len(status)):",
"+ if status[i] == 1:",
"+ # i番目の問題を全て解く",
"+ score += (i + 1) * 100 * problems[i][0] + problems[i][1]",
"+ solve_count += problems[i][0]",
"+ # 対象の問題を全部解き終えた",
"+ if score >= G:",
"+ ans = min(ans, solve_count)",
"+ else:",
"+ # 足りない問題を解く",
"+ for i in reversed(list(range(len(status)))):",
"+ if status[i] == 0: # 解いていない問題の中で一番ポイントが高いものを解く",
"+ for j in range(problems[i][0]): # 1問ずつ解く",
"+ score += (i + 1) * 100",
"+ solve_count += 1",
"+ if score >= G:",
"+ ans = min(ans, solve_count)",
"+ break",
"- if my_score >= G:",
"- ans = min(ans, solved_amount)"
] | false | 0.033613 | 0.036394 | 0.923596 | [
"s739135359",
"s290279029"
] |
u991567869 | p02732 | python | s773030945 | s415653504 | 352 | 325 | 24,744 | 26,140 | Accepted | Accepted | 7.67 | n = int(eval(input()))
a = list(map(int, input().split()))
b = [0]*n
ans = 0
for i in range(n):
b[a[i] - 1] += 1
for i in range(n):
ans += b[i]*(b[i] - 1)//2
for i in range(n):
print((ans - b[a[i] - 1] + 1)) | n = int(eval(input()))
a = list(map(int, input().split()))
d = {}
total = 0
for i in a:
if i not in d:
d[i] = 1
else:
total += d[i]
d[i] += 1
for i in range(n):
ans = total - (d[a[i]] - 1)
print(ans) | 13 | 15 | 226 | 249 | n = int(eval(input()))
a = list(map(int, input().split()))
b = [0] * n
ans = 0
for i in range(n):
b[a[i] - 1] += 1
for i in range(n):
ans += b[i] * (b[i] - 1) // 2
for i in range(n):
print((ans - b[a[i] - 1] + 1))
| n = int(eval(input()))
a = list(map(int, input().split()))
d = {}
total = 0
for i in a:
if i not in d:
d[i] = 1
else:
total += d[i]
d[i] += 1
for i in range(n):
ans = total - (d[a[i]] - 1)
print(ans)
| false | 13.333333 | [
"-b = [0] * n",
"-ans = 0",
"+d = {}",
"+total = 0",
"+for i in a:",
"+ if i not in d:",
"+ d[i] = 1",
"+ else:",
"+ total += d[i]",
"+ d[i] += 1",
"- b[a[i] - 1] += 1",
"-for i in range(n):",
"- ans += b[i] * (b[i] - 1) // 2",
"-for i in range(n):",
"- print((ans - b[a[i] - 1] + 1))",
"+ ans = total - (d[a[i]] - 1)",
"+ print(ans)"
] | false | 0.062884 | 0.036043 | 1.744661 | [
"s773030945",
"s415653504"
] |
u926046014 | p03266 | python | s775712296 | s715174385 | 69 | 26 | 61,724 | 9,148 | Accepted | Accepted | 62.32 | n,k=list(map(int,input().split()))
ans=0
baisuu=n//k
ans+=baisuu**3
if k%2==0:
if baisuu*k+k//2<=n:
hanbun=baisuu+1
else:
hanbun=baisuu
ans+=hanbun**3
print(ans) | def main():
n,k=list(map(int,input().split()))
ans=0
baisuu=n//k
ans+=baisuu**3
if k%2==0:
if baisuu*k+k//2<=n:
hanbun=baisuu+1
else:
hanbun=baisuu
ans+=hanbun**3
print(ans)
if __name__=="__main__":
main() | 11 | 14 | 189 | 288 | n, k = list(map(int, input().split()))
ans = 0
baisuu = n // k
ans += baisuu**3
if k % 2 == 0:
if baisuu * k + k // 2 <= n:
hanbun = baisuu + 1
else:
hanbun = baisuu
ans += hanbun**3
print(ans)
| def main():
n, k = list(map(int, input().split()))
ans = 0
baisuu = n // k
ans += baisuu**3
if k % 2 == 0:
if baisuu * k + k // 2 <= n:
hanbun = baisuu + 1
else:
hanbun = baisuu
ans += hanbun**3
print(ans)
if __name__ == "__main__":
main()
| false | 21.428571 | [
"-n, k = list(map(int, input().split()))",
"-ans = 0",
"-baisuu = n // k",
"-ans += baisuu**3",
"-if k % 2 == 0:",
"- if baisuu * k + k // 2 <= n:",
"- hanbun = baisuu + 1",
"- else:",
"- hanbun = baisuu",
"- ans += hanbun**3",
"-print(ans)",
"+def main():",
"+ n, k = list(map(int, input().split()))",
"+ ans = 0",
"+ baisuu = n // k",
"+ ans += baisuu**3",
"+ if k % 2 == 0:",
"+ if baisuu * k + k // 2 <= n:",
"+ hanbun = baisuu + 1",
"+ else:",
"+ hanbun = baisuu",
"+ ans += hanbun**3",
"+ print(ans)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.0458 | 0.112912 | 0.405629 | [
"s775712296",
"s715174385"
] |
u021019433 | p03053 | python | s223264515 | s214364473 | 645 | 579 | 132,432 | 132,432 | Accepted | Accepted | 10.23 | h, w = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(h)]
d = (-1, 0), (1, 0), (0, -1), (0, 1)
p = [(i, j) for i in range(h) for j in range(w) if a[i][j] == '#']
def f():
for i, j in p:
for di, dj in d:
di += i
dj += j
if 0 <= di < h and 0 <= dj < w and a[di][dj] == '.':
a[di][dj] = '#'
yield di, dj
n = h * w - len(p)
r = 0
while n:
r += 1
p = list(f())
n -= len(p)
print(r)
| h, w = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(h)]
d = (-1, 0), (1, 0), (0, -1), (0, 1)
p = [(i, j) for i in range(h) for j in range(w) if a[i][j] == '#']
n = h * w - len(p)
r = 0
while n:
r += 1
s = []
for i, j in p:
for di, dj in d:
di += i
dj += j
if 0 <= di < h and 0 <= dj < w and a[di][dj] == '.':
a[di][dj] = '#'
s.append((di, dj))
p = s
n -= len(p)
print(r)
| 21 | 19 | 504 | 500 | h, w = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(h)]
d = (-1, 0), (1, 0), (0, -1), (0, 1)
p = [(i, j) for i in range(h) for j in range(w) if a[i][j] == "#"]
def f():
for i, j in p:
for di, dj in d:
di += i
dj += j
if 0 <= di < h and 0 <= dj < w and a[di][dj] == ".":
a[di][dj] = "#"
yield di, dj
n = h * w - len(p)
r = 0
while n:
r += 1
p = list(f())
n -= len(p)
print(r)
| h, w = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(h)]
d = (-1, 0), (1, 0), (0, -1), (0, 1)
p = [(i, j) for i in range(h) for j in range(w) if a[i][j] == "#"]
n = h * w - len(p)
r = 0
while n:
r += 1
s = []
for i, j in p:
for di, dj in d:
di += i
dj += j
if 0 <= di < h and 0 <= dj < w and a[di][dj] == ".":
a[di][dj] = "#"
s.append((di, dj))
p = s
n -= len(p)
print(r)
| false | 9.52381 | [
"-",
"-",
"-def f():",
"+n = h * w - len(p)",
"+r = 0",
"+while n:",
"+ r += 1",
"+ s = []",
"- yield di, dj",
"-",
"-",
"-n = h * w - len(p)",
"-r = 0",
"-while n:",
"- r += 1",
"- p = list(f())",
"+ s.append((di, dj))",
"+ p = s"
] | false | 0.038293 | 0.038087 | 1.0054 | [
"s223264515",
"s214364473"
] |
u993622994 | p03994 | python | s555065581 | s569794729 | 111 | 101 | 7,484 | 4,088 | Accepted | Accepted | 9.01 | import string
S = list(input())
K = int(input())
alpha = string.ascii_lowercase
s = len(S)
for i in range(s):
num = (26 - alpha.index(S[i])) % 26
if num <= K:
K -= num
S[i] = 'a'
else:
pass
if K > 0:
num = (alpha.index(S[-1]) + K) % 26
S[-1] = alpha[num]
else:
pass
print(*S, sep='')
| import string
s = eval(input())
K = int(eval(input()))
alp = string.ascii_lowercase
ans = ''
for i in range(len(s)-1):
num = (len(alp) - alp.index(s[i])) % 26
if num <= K:
K -= num
ans += 'a'
else:
ans += s[i]
if K > 0:
num = (alp.index(s[-1]) + K) % 26
ans += alp[num]
else:
ans += s[-1]
print(ans) | 23 | 23 | 358 | 362 | import string
S = list(input())
K = int(input())
alpha = string.ascii_lowercase
s = len(S)
for i in range(s):
num = (26 - alpha.index(S[i])) % 26
if num <= K:
K -= num
S[i] = "a"
else:
pass
if K > 0:
num = (alpha.index(S[-1]) + K) % 26
S[-1] = alpha[num]
else:
pass
print(*S, sep="")
| import string
s = eval(input())
K = int(eval(input()))
alp = string.ascii_lowercase
ans = ""
for i in range(len(s) - 1):
num = (len(alp) - alp.index(s[i])) % 26
if num <= K:
K -= num
ans += "a"
else:
ans += s[i]
if K > 0:
num = (alp.index(s[-1]) + K) % 26
ans += alp[num]
else:
ans += s[-1]
print(ans)
| false | 0 | [
"-S = list(input())",
"-K = int(input())",
"-alpha = string.ascii_lowercase",
"-s = len(S)",
"-for i in range(s):",
"- num = (26 - alpha.index(S[i])) % 26",
"+s = eval(input())",
"+K = int(eval(input()))",
"+alp = string.ascii_lowercase",
"+ans = \"\"",
"+for i in range(len(s) - 1):",
"+ num = (len(alp) - alp.index(s[i])) % 26",
"- S[i] = \"a\"",
"+ ans += \"a\"",
"- pass",
"+ ans += s[i]",
"- num = (alpha.index(S[-1]) + K) % 26",
"- S[-1] = alpha[num]",
"+ num = (alp.index(s[-1]) + K) % 26",
"+ ans += alp[num]",
"- pass",
"-print(*S, sep=\"\")",
"+ ans += s[-1]",
"+print(ans)"
] | false | 0.111539 | 0.110137 | 1.01273 | [
"s555065581",
"s569794729"
] |
u553987207 | p02881 | python | s269193035 | s539944629 | 295 | 225 | 2,940 | 9,100 | Accepted | Accepted | 23.73 | N = int(eval(input()))
ans = N - 1
i = 2
while i * i <= N:
if N % i == 0:
j = N // i
ans = min(ans, i + j - 2)
i += 1
print(ans) | N = int(eval(input()))
ans = N - 1
i = 2
while i * i <= N:
if N % i == 0:
ans = min(ans, i + N // i - 2)
i += 1
print(ans) | 9 | 8 | 154 | 139 | N = int(eval(input()))
ans = N - 1
i = 2
while i * i <= N:
if N % i == 0:
j = N // i
ans = min(ans, i + j - 2)
i += 1
print(ans)
| N = int(eval(input()))
ans = N - 1
i = 2
while i * i <= N:
if N % i == 0:
ans = min(ans, i + N // i - 2)
i += 1
print(ans)
| false | 11.111111 | [
"- j = N // i",
"- ans = min(ans, i + j - 2)",
"+ ans = min(ans, i + N // i - 2)"
] | false | 0.043172 | 0.041116 | 1.050015 | [
"s269193035",
"s539944629"
] |
u597455618 | p03241 | python | s023595819 | s986783637 | 35 | 32 | 9,136 | 9,320 | Accepted | Accepted | 8.57 | def divisor(n):
i = 1
res = []
while i*i <= n:
if n%i == 0:
res.append(i)
if n//i not in res:
res.append(n//i)
i += 1
res.sort()
return res
def main():
n, m = list(map(int, input().split()))
md = divisor(m)
ans = 0
for i in md:
if (m - n*i)%i == 0 and (m - n*i) >= 0:
ans = i
else:
break
print(ans)
if __name__ == '__main__':
main() | def divisor(n):
i = 1
res = []
for i in range(1, int(n**.5) + 1):
if n%i == 0:
res.append(i)
if n//i not in res:
res.append(n//i)
res.sort()
return res
def main():
n, m = list(map(int, input().split()))
md = divisor(m)
ans = 0
for i in md:
if (m - n*i)%i == 0 and (m - n*i) >= 0:
ans = i
else:
break
print(ans)
if __name__ == '__main__':
main() | 25 | 24 | 492 | 495 | def divisor(n):
i = 1
res = []
while i * i <= n:
if n % i == 0:
res.append(i)
if n // i not in res:
res.append(n // i)
i += 1
res.sort()
return res
def main():
n, m = list(map(int, input().split()))
md = divisor(m)
ans = 0
for i in md:
if (m - n * i) % i == 0 and (m - n * i) >= 0:
ans = i
else:
break
print(ans)
if __name__ == "__main__":
main()
| def divisor(n):
i = 1
res = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
res.append(i)
if n // i not in res:
res.append(n // i)
res.sort()
return res
def main():
n, m = list(map(int, input().split()))
md = divisor(m)
ans = 0
for i in md:
if (m - n * i) % i == 0 and (m - n * i) >= 0:
ans = i
else:
break
print(ans)
if __name__ == "__main__":
main()
| false | 4 | [
"- while i * i <= n:",
"+ for i in range(1, int(n**0.5) + 1):",
"- i += 1"
] | false | 0.04239 | 0.047578 | 0.890958 | [
"s023595819",
"s986783637"
] |
u169696482 | p02796 | python | s834619386 | s031129522 | 860 | 346 | 59,224 | 21,756 | Accepted | Accepted | 59.77 | n = int(eval(input()))
X = []
for i in range(n):
x, l = list(map(int, input().split()))
X.append([x-l, x+l])
X.sort()
temp = X[0][1]
count = n
for i in range(1,n):
if temp>X[i][0]:
count -= 1
temp = min(temp, X[i][1])
else:
temp = X[i][1]
print(count) | import sys
input = sys.stdin.readline
n = int(eval(input()))
X = []
for i in range(n):
x, l = list(map(int, input().split()))
X.append([x-l, x+l])
X.sort()
temp = X[0][1]
count = n
for i in range(1,n):
if temp>X[i][0]:
count -= 1
temp = min(temp, X[i][1])
else:
temp = X[i][1]
print(count)
| 15 | 17 | 273 | 314 | n = int(eval(input()))
X = []
for i in range(n):
x, l = list(map(int, input().split()))
X.append([x - l, x + l])
X.sort()
temp = X[0][1]
count = n
for i in range(1, n):
if temp > X[i][0]:
count -= 1
temp = min(temp, X[i][1])
else:
temp = X[i][1]
print(count)
| import sys
input = sys.stdin.readline
n = int(eval(input()))
X = []
for i in range(n):
x, l = list(map(int, input().split()))
X.append([x - l, x + l])
X.sort()
temp = X[0][1]
count = n
for i in range(1, n):
if temp > X[i][0]:
count -= 1
temp = min(temp, X[i][1])
else:
temp = X[i][1]
print(count)
| false | 11.764706 | [
"+import sys",
"+",
"+input = sys.stdin.readline"
] | false | 0.045561 | 0.050677 | 0.899054 | [
"s834619386",
"s031129522"
] |
u633333374 | p01267 | python | s589349868 | s133743911 | 690 | 630 | 6,208 | 6,384 | Accepted | Accepted | 8.7 | while 1:
n,a,b,c,x=list(map(int,input().split()))
if n==0:break
reel=list(map(int,input().split()))
roop,i=-1,0
while i<n:
roop+=1
if roop>10000:
roop=-1
break
if x==reel[i]:
i+=1
x=(a*x+b)%c
print(roop) | while True:
N,A,B,C,X = list(map(int,input().split()))
if N == A == B == C == X == 0:break
sum = 0
Z = 0
Y = [int(x) for x in input().split()]
if X == Y[0]:
Y.pop(0)
if len(Y) == 0:
Z = 1
while Z == 0:
if sum == 10000:
sum = -2
Z = 1
sum += 1
X = (A*X+B)%C
if X == Y[0]:
Y.pop(0)
if len(Y) == 0:
Z = 1
print(sum) | 14 | 21 | 303 | 449 | while 1:
n, a, b, c, x = list(map(int, input().split()))
if n == 0:
break
reel = list(map(int, input().split()))
roop, i = -1, 0
while i < n:
roop += 1
if roop > 10000:
roop = -1
break
if x == reel[i]:
i += 1
x = (a * x + b) % c
print(roop)
| while True:
N, A, B, C, X = list(map(int, input().split()))
if N == A == B == C == X == 0:
break
sum = 0
Z = 0
Y = [int(x) for x in input().split()]
if X == Y[0]:
Y.pop(0)
if len(Y) == 0:
Z = 1
while Z == 0:
if sum == 10000:
sum = -2
Z = 1
sum += 1
X = (A * X + B) % C
if X == Y[0]:
Y.pop(0)
if len(Y) == 0:
Z = 1
print(sum)
| false | 33.333333 | [
"-while 1:",
"- n, a, b, c, x = list(map(int, input().split()))",
"- if n == 0:",
"+while True:",
"+ N, A, B, C, X = list(map(int, input().split()))",
"+ if N == A == B == C == X == 0:",
"- reel = list(map(int, input().split()))",
"- roop, i = -1, 0",
"- while i < n:",
"- roop += 1",
"- if roop > 10000:",
"- roop = -1",
"- break",
"- if x == reel[i]:",
"- i += 1",
"- x = (a * x + b) % c",
"- print(roop)",
"+ sum = 0",
"+ Z = 0",
"+ Y = [int(x) for x in input().split()]",
"+ if X == Y[0]:",
"+ Y.pop(0)",
"+ if len(Y) == 0:",
"+ Z = 1",
"+ while Z == 0:",
"+ if sum == 10000:",
"+ sum = -2",
"+ Z = 1",
"+ sum += 1",
"+ X = (A * X + B) % C",
"+ if X == Y[0]:",
"+ Y.pop(0)",
"+ if len(Y) == 0:",
"+ Z = 1",
"+ print(sum)"
] | false | 0.063718 | 0.089797 | 0.709578 | [
"s589349868",
"s133743911"
] |
u156815136 | p03013 | python | s984191390 | s493042799 | 254 | 195 | 7,668 | 6,972 | Accepted | Accepted | 23.23 | MOD = 10**9 + 7
n,m = list(map(int,input().split()))
ban = [False] * (n + 1)
for i in range(m):
a = int(eval(input()))
ban[a] = True
dp = [0] * (n + 1)
dp[0] = 1
for i in range(n):
dp[i] %= MOD
if ban[i]:dp[i] = 0
#print(i, dp[i])
if i + 1 <= n:
dp[i + 1] += dp[i]
if i + 2 <= n:
dp[i + 2] += dp[i]
print((dp[n] % MOD))
| n,m = list(map(int,input().split()))
dp = [0] * (n+1) + [0] * 10
mod = 10**9 + 7
for i in range(m):
dp[int(eval(input()))] = -1 # 壊れているので、-1としておこう?
dp[0] = 0 # 0段目にいるとしよう
# 1段目が行けなかったら...?
dp[1] = 1 if dp[1] != -1 else -1 # 1段目にいく方法は1通り?
dp[2] = -1 if dp[2] == -1 else (1 if dp[2] != -1 and dp[1] == -1 else 2) # 2段目に行く方法は2通り?
for i in range(3,n+1):
if dp[i] != -1 and dp[i-1] != -1:
dp[i] += dp[i-1]
dp[i] %= mod
if i > 1:
if dp[i] != -1 and dp[i-2] != -1:
dp[i] += dp[i-2]
dp[i] %= mod
#print(dp)
print((dp[n]%mod))
| 23 | 21 | 378 | 586 | MOD = 10**9 + 7
n, m = list(map(int, input().split()))
ban = [False] * (n + 1)
for i in range(m):
a = int(eval(input()))
ban[a] = True
dp = [0] * (n + 1)
dp[0] = 1
for i in range(n):
dp[i] %= MOD
if ban[i]:
dp[i] = 0
# print(i, dp[i])
if i + 1 <= n:
dp[i + 1] += dp[i]
if i + 2 <= n:
dp[i + 2] += dp[i]
print((dp[n] % MOD))
| n, m = list(map(int, input().split()))
dp = [0] * (n + 1) + [0] * 10
mod = 10**9 + 7
for i in range(m):
dp[int(eval(input()))] = -1 # 壊れているので、-1としておこう?
dp[0] = 0 # 0段目にいるとしよう
# 1段目が行けなかったら...?
dp[1] = 1 if dp[1] != -1 else -1 # 1段目にいく方法は1通り?
dp[2] = (
-1 if dp[2] == -1 else (1 if dp[2] != -1 and dp[1] == -1 else 2)
) # 2段目に行く方法は2通り?
for i in range(3, n + 1):
if dp[i] != -1 and dp[i - 1] != -1:
dp[i] += dp[i - 1]
dp[i] %= mod
if i > 1:
if dp[i] != -1 and dp[i - 2] != -1:
dp[i] += dp[i - 2]
dp[i] %= mod
# print(dp)
print((dp[n] % mod))
| false | 8.695652 | [
"-MOD = 10**9 + 7",
"-ban = [False] * (n + 1)",
"+dp = [0] * (n + 1) + [0] * 10",
"+mod = 10**9 + 7",
"- a = int(eval(input()))",
"- ban[a] = True",
"-dp = [0] * (n + 1)",
"-dp[0] = 1",
"-for i in range(n):",
"- dp[i] %= MOD",
"- if ban[i]:",
"- dp[i] = 0",
"- # print(i, dp[i])",
"- if i + 1 <= n:",
"- dp[i + 1] += dp[i]",
"- if i + 2 <= n:",
"- dp[i + 2] += dp[i]",
"-print((dp[n] % MOD))",
"+ dp[int(eval(input()))] = -1 # 壊れているので、-1としておこう?",
"+dp[0] = 0 # 0段目にいるとしよう",
"+# 1段目が行けなかったら...?",
"+dp[1] = 1 if dp[1] != -1 else -1 # 1段目にいく方法は1通り?",
"+dp[2] = (",
"+ -1 if dp[2] == -1 else (1 if dp[2] != -1 and dp[1] == -1 else 2)",
"+) # 2段目に行く方法は2通り?",
"+for i in range(3, n + 1):",
"+ if dp[i] != -1 and dp[i - 1] != -1:",
"+ dp[i] += dp[i - 1]",
"+ dp[i] %= mod",
"+ if i > 1:",
"+ if dp[i] != -1 and dp[i - 2] != -1:",
"+ dp[i] += dp[i - 2]",
"+ dp[i] %= mod",
"+# print(dp)",
"+print((dp[n] % mod))"
] | false | 0.037276 | 0.106606 | 0.349662 | [
"s984191390",
"s493042799"
] |
u625007136 | p02689 | python | s205065196 | s134846210 | 374 | 193 | 32,820 | 31,944 | Accepted | Accepted | 48.4 | import sys
input = sys.stdin.readline
def ppp(n,m,h,ab):
g = [1] * n
for l,r in ab:
if h[l-1] >= h[r-1]:
g[r-1] = 0
if h[l-1] <= h[r-1]:
g[l-1] = 0
print((sum(g)))
if __name__ == "__main__":
n,m = list(map(int,input().split()))
h = list(map(int,input().split()))
ab = [list(map(int,input().split())) for _ in range(m)]
ab_sorted = sorted(ab)
ppp(n,m,h,ab_sorted)
| import sys
input = sys.stdin.readline
def ppp(n,m,h,ab):
g = [1] * n
for l,r in ab:
if h[l-1] >= h[r-1]:
g[r-1] = 0
if h[l-1] <= h[r-1]:
g[l-1] = 0
print((sum(g)))
if __name__ == "__main__":
n,m = list(map(int,input().split()))
h = list(map(int,input().split()))
ab = [list(map(int,input().split())) for _ in range(m)]
ppp(n,m,h,ab)
| 17 | 16 | 444 | 409 | import sys
input = sys.stdin.readline
def ppp(n, m, h, ab):
g = [1] * n
for l, r in ab:
if h[l - 1] >= h[r - 1]:
g[r - 1] = 0
if h[l - 1] <= h[r - 1]:
g[l - 1] = 0
print((sum(g)))
if __name__ == "__main__":
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
ab_sorted = sorted(ab)
ppp(n, m, h, ab_sorted)
| import sys
input = sys.stdin.readline
def ppp(n, m, h, ab):
g = [1] * n
for l, r in ab:
if h[l - 1] >= h[r - 1]:
g[r - 1] = 0
if h[l - 1] <= h[r - 1]:
g[l - 1] = 0
print((sum(g)))
if __name__ == "__main__":
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
ppp(n, m, h, ab)
| false | 5.882353 | [
"- ab_sorted = sorted(ab)",
"- ppp(n, m, h, ab_sorted)",
"+ ppp(n, m, h, ab)"
] | false | 0.03636 | 0.034528 | 1.053085 | [
"s205065196",
"s134846210"
] |
u189487046 | p03779 | python | s953034082 | s247885834 | 35 | 27 | 4,884 | 2,940 | Accepted | Accepted | 22.86 | def create_koho(X):
koho = [1]
koho_sum = 1
i = 1
while koho_sum < X:
i += 1
koho.append(i)
koho_sum += i
return koho
X = int(eval(input()))
koho = create_koho(X)
nokori = X
ans = 0
for i in reversed(koho):
if nokori >= i:
nokori -= i
ans += 1
print((len(koho)))
| X = int(eval(input()))
i = 1
koho_sum = i
while koho_sum < X:
i += 1
koho_sum += i
print(i)
| 22 | 8 | 344 | 102 | def create_koho(X):
koho = [1]
koho_sum = 1
i = 1
while koho_sum < X:
i += 1
koho.append(i)
koho_sum += i
return koho
X = int(eval(input()))
koho = create_koho(X)
nokori = X
ans = 0
for i in reversed(koho):
if nokori >= i:
nokori -= i
ans += 1
print((len(koho)))
| X = int(eval(input()))
i = 1
koho_sum = i
while koho_sum < X:
i += 1
koho_sum += i
print(i)
| false | 63.636364 | [
"-def create_koho(X):",
"- koho = [1]",
"- koho_sum = 1",
"- i = 1",
"- while koho_sum < X:",
"- i += 1",
"- koho.append(i)",
"- koho_sum += i",
"- return koho",
"-",
"-",
"-koho = create_koho(X)",
"-nokori = X",
"-ans = 0",
"-for i in reversed(koho):",
"- if nokori >= i:",
"- nokori -= i",
"- ans += 1",
"-print((len(koho)))",
"+i = 1",
"+koho_sum = i",
"+while koho_sum < X:",
"+ i += 1",
"+ koho_sum += i",
"+print(i)"
] | false | 0.039826 | 0.041002 | 0.971319 | [
"s953034082",
"s247885834"
] |
u525065967 | p02612 | python | s708374990 | s405012442 | 34 | 31 | 9,124 | 8,956 | Accepted | Accepted | 8.82 | n = int(eval(input()))
ans = 1000 - n%1000
if ans == 1000: ans = 0
print(ans)
| r = 1000 - int(eval(input())) % 1000
print((r if r < 1000 else 0))
| 4 | 2 | 75 | 60 | n = int(eval(input()))
ans = 1000 - n % 1000
if ans == 1000:
ans = 0
print(ans)
| r = 1000 - int(eval(input())) % 1000
print((r if r < 1000 else 0))
| false | 50 | [
"-n = int(eval(input()))",
"-ans = 1000 - n % 1000",
"-if ans == 1000:",
"- ans = 0",
"-print(ans)",
"+r = 1000 - int(eval(input())) % 1000",
"+print((r if r < 1000 else 0))"
] | false | 0.041442 | 0.03569 | 1.161179 | [
"s708374990",
"s405012442"
] |
u885899351 | p03625 | python | s324179589 | s863128635 | 154 | 133 | 21,540 | 21,540 | Accepted | Accepted | 13.64 | from collections import Counter
n=eval(input())
a=sorted(list(map(int,input().split())))[::-1]
ca=Counter(a).most_common()
if ca[1][1]<2:
if ca[0][1]<4:print((0))
else:print((ca[0][0]**2))
else:
l=[]
for i,j in ca:
for _ in range(j//2):l.append(i)
l.sort()
print((l[-1]*l[-2])) | from collections import Counter
n=eval(input())
a=sorted(list(map(int,input().split())))[::-1]
ca=Counter(a).most_common()
if ca[1][1]<2:
if ca[0][1]<4:print((0))
else:print((ca[0][0]**2))
else:
l=[]
for i,j in ca:
if j<2:break
elif j<4:l.append(i)
else:
l.append(i)
l.append(i)
l.sort()
print((l[-1]*l[-2])) | 13 | 17 | 309 | 384 | from collections import Counter
n = eval(input())
a = sorted(list(map(int, input().split())))[::-1]
ca = Counter(a).most_common()
if ca[1][1] < 2:
if ca[0][1] < 4:
print((0))
else:
print((ca[0][0] ** 2))
else:
l = []
for i, j in ca:
for _ in range(j // 2):
l.append(i)
l.sort()
print((l[-1] * l[-2]))
| from collections import Counter
n = eval(input())
a = sorted(list(map(int, input().split())))[::-1]
ca = Counter(a).most_common()
if ca[1][1] < 2:
if ca[0][1] < 4:
print((0))
else:
print((ca[0][0] ** 2))
else:
l = []
for i, j in ca:
if j < 2:
break
elif j < 4:
l.append(i)
else:
l.append(i)
l.append(i)
l.sort()
print((l[-1] * l[-2]))
| false | 23.529412 | [
"- for _ in range(j // 2):",
"+ if j < 2:",
"+ break",
"+ elif j < 4:",
"+ l.append(i)",
"+ else:",
"+ l.append(i)"
] | false | 0.043904 | 0.044125 | 0.994989 | [
"s324179589",
"s863128635"
] |
u562935282 | p03128 | python | s929104509 | s327256597 | 137 | 79 | 30,196 | 3,316 | Accepted | Accepted | 42.34 | def chmax(x, y):
if x == '-':
return y
lx = len(x)
ly = len(y)
if lx < ly:
return y
elif lx == ly:
if x < y: return y
else: return x
else:
return x
N, M = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt = [N + 1, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = ['-' for _ in range(N + 10 + 1)]
dp[0] = ''
# dp[j]: j 本使ってできる最大の数
for i in range(N + 1):
# print(dp)
if dp[i] == '-': continue
for aa in a:
dp[i + cnt[aa]] = chmax(dp[i + cnt[aa]], dp[i] + str(aa))
print((dp[N]))
| INF = float('inf')
N, M = list(map(int, input().split()))
a = list(map(int, input().split()))
num = [N + 1, 2, 5, 5, 4, 5, 6, 3, 7, 6]
# num[数字] = 必要なマッチ棒の本数
# 数字0は使用できない
dp = [-INF for _ in range(N + 1)]
dp[0] = 0
# dp[マッチ棒の本数] = 構成可能な最大桁数
# 最大桁数を求めるので、初期値-INFとして、maxで更新
for i in range(1, N + 1):
for aa in a:
# aa: 使用可能な数字
idx = i - num[aa]
if idx >= 0:
dp[i] = max(dp[i], dp[idx] + 1)
a = list(sorted(a, reverse=True))
# 降順ソート
need = dp[N]
# 構成可能な最大整数が必要とする桁数
rest = N
# 使用可能なマッチ棒の本数
ans = ''
while need > 0:
for aa in a:
# aa: 使用可能な数字(降順)
idx = rest - num[aa]
if idx >= 0:
# マッチ棒の本数が足りるため、数字aaを使用できる場合
if dp[idx] == need - 1:
ans += str(aa)
# ans末尾にaaを追記
rest -= num[aa]
need -= 1
break
# 次の桁の調査でaa[0]から試すため
print(ans)
| 30 | 48 | 594 | 963 | def chmax(x, y):
if x == "-":
return y
lx = len(x)
ly = len(y)
if lx < ly:
return y
elif lx == ly:
if x < y:
return y
else:
return x
else:
return x
N, M = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt = [N + 1, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = ["-" for _ in range(N + 10 + 1)]
dp[0] = ""
# dp[j]: j 本使ってできる最大の数
for i in range(N + 1):
# print(dp)
if dp[i] == "-":
continue
for aa in a:
dp[i + cnt[aa]] = chmax(dp[i + cnt[aa]], dp[i] + str(aa))
print((dp[N]))
| INF = float("inf")
N, M = list(map(int, input().split()))
a = list(map(int, input().split()))
num = [N + 1, 2, 5, 5, 4, 5, 6, 3, 7, 6]
# num[数字] = 必要なマッチ棒の本数
# 数字0は使用できない
dp = [-INF for _ in range(N + 1)]
dp[0] = 0
# dp[マッチ棒の本数] = 構成可能な最大桁数
# 最大桁数を求めるので、初期値-INFとして、maxで更新
for i in range(1, N + 1):
for aa in a:
# aa: 使用可能な数字
idx = i - num[aa]
if idx >= 0:
dp[i] = max(dp[i], dp[idx] + 1)
a = list(sorted(a, reverse=True))
# 降順ソート
need = dp[N]
# 構成可能な最大整数が必要とする桁数
rest = N
# 使用可能なマッチ棒の本数
ans = ""
while need > 0:
for aa in a:
# aa: 使用可能な数字(降順)
idx = rest - num[aa]
if idx >= 0:
# マッチ棒の本数が足りるため、数字aaを使用できる場合
if dp[idx] == need - 1:
ans += str(aa)
# ans末尾にaaを追記
rest -= num[aa]
need -= 1
break
# 次の桁の調査でaa[0]から試すため
print(ans)
| false | 37.5 | [
"-def chmax(x, y):",
"- if x == \"-\":",
"- return y",
"- lx = len(x)",
"- ly = len(y)",
"- if lx < ly:",
"- return y",
"- elif lx == ly:",
"- if x < y:",
"- return y",
"- else:",
"- return x",
"- else:",
"- return x",
"-",
"-",
"+INF = float(\"inf\")",
"-cnt = [N + 1, 2, 5, 5, 4, 5, 6, 3, 7, 6]",
"-dp = [\"-\" for _ in range(N + 10 + 1)]",
"-dp[0] = \"\"",
"-# dp[j]: j 本使ってできる最大の数",
"-for i in range(N + 1):",
"- # print(dp)",
"- if dp[i] == \"-\":",
"- continue",
"+num = [N + 1, 2, 5, 5, 4, 5, 6, 3, 7, 6]",
"+# num[数字] = 必要なマッチ棒の本数",
"+# 数字0は使用できない",
"+dp = [-INF for _ in range(N + 1)]",
"+dp[0] = 0",
"+# dp[マッチ棒の本数] = 構成可能な最大桁数",
"+# 最大桁数を求めるので、初期値-INFとして、maxで更新",
"+for i in range(1, N + 1):",
"- dp[i + cnt[aa]] = chmax(dp[i + cnt[aa]], dp[i] + str(aa))",
"-print((dp[N]))",
"+ # aa: 使用可能な数字",
"+ idx = i - num[aa]",
"+ if idx >= 0:",
"+ dp[i] = max(dp[i], dp[idx] + 1)",
"+a = list(sorted(a, reverse=True))",
"+# 降順ソート",
"+need = dp[N]",
"+# 構成可能な最大整数が必要とする桁数",
"+rest = N",
"+# 使用可能なマッチ棒の本数",
"+ans = \"\"",
"+while need > 0:",
"+ for aa in a:",
"+ # aa: 使用可能な数字(降順)",
"+ idx = rest - num[aa]",
"+ if idx >= 0:",
"+ # マッチ棒の本数が足りるため、数字aaを使用できる場合",
"+ if dp[idx] == need - 1:",
"+ ans += str(aa)",
"+ # ans末尾にaaを追記",
"+ rest -= num[aa]",
"+ need -= 1",
"+ break",
"+ # 次の桁の調査でaa[0]から試すため",
"+print(ans)"
] | false | 0.045145 | 0.045068 | 1.001719 | [
"s929104509",
"s327256597"
] |
u901757711 | p02700 | python | s495145905 | s676774648 | 23 | 20 | 9,148 | 9,148 | Accepted | Accepted | 13.04 | a, b, c, d = list(map(int, input().split()))
x = -(-a // d)
y = -(-c // b)
if x >= y:
print("Yes")
else:
print("No") | a,b,c,d = list(map(int, input().split()))
while True:
c -= b
a -= d
if c <= 0:
print("Yes")
break
elif a <= 0:
print("No")
break | 9 | 11 | 126 | 181 | a, b, c, d = list(map(int, input().split()))
x = -(-a // d)
y = -(-c // b)
if x >= y:
print("Yes")
else:
print("No")
| a, b, c, d = list(map(int, input().split()))
while True:
c -= b
a -= d
if c <= 0:
print("Yes")
break
elif a <= 0:
print("No")
break
| false | 18.181818 | [
"-x = -(-a // d)",
"-y = -(-c // b)",
"-if x >= y:",
"- print(\"Yes\")",
"-else:",
"- print(\"No\")",
"+while True:",
"+ c -= b",
"+ a -= d",
"+ if c <= 0:",
"+ print(\"Yes\")",
"+ break",
"+ elif a <= 0:",
"+ print(\"No\")",
"+ break"
] | false | 0.065572 | 0.039031 | 1.679989 | [
"s495145905",
"s676774648"
] |
u037430802 | p03713 | python | s400471649 | s840728183 | 533 | 473 | 3,064 | 3,064 | Accepted | Accepted | 11.26 | H, W = list(map(int, input().split()))
if H % 3 == 0 or W % 3 == 0:
print((0))
exit()
ans = H*W
# 高さを変えて調べる
for h in range(1, H+1):
a = h*W
#残りを高さで割る場合
b = ((H-h)//2) * W
c = H*W - a - b
ans = min(ans, max([a,b,c]) - min([a,b,c]))
#残りを幅で割る場合
b = (H-h) * (W//2)
c = H*W - a - b
ans = min(ans, max([a,b,c]) - min([a,b,c]))
# 幅を変えて調べる
for w in range(1, W+1):
a = H*w
#残りを高さで割る場合
b = (W-w) * (H//2)
c = H*W - a - b
ans = min(ans, max([a,b,c]) - min([a,b,c]))
#残りを幅で割る場合
b = ((W-w)//2) * H
c = H*W - a - b
ans = min(ans, max([a,b,c]) - min([a,b,c]))
print(ans) |
H,W = list(map(int, input().split()))
ans = H * W
# 1つめは縦を1ずつ増やしていく場合
for h in range(1, H):
a = h * W
# 残りについて、縦で分割する場合
b = ((H - h) // 2) * W
c = H * W - a - b
ans = min(ans, max(a,b,c) - min(a,b,c))
# 残りについて、横で分割する場合
b = (H - h) * (W // 2)
c = H * W - a - b
ans = min(ans, max(a,b,c) - min(a,b,c))
# 1つめは横を1ずつ増やしていく場合
for w in range(1, W):
a = w * H
# 残りについて、縦で分割する場合
b = (W - w) * (H//2)
c = H * W - a - b
ans = min(ans, max(a,b,c) - min(a,b,c))
# 残りについて、横で分割する場合
b = ((W - w) // 2) * H
c = H * W - a - b
ans = min(ans, max(a,b,c) - min(a,b,c))
print(ans) | 39 | 38 | 676 | 690 | H, W = list(map(int, input().split()))
if H % 3 == 0 or W % 3 == 0:
print((0))
exit()
ans = H * W
# 高さを変えて調べる
for h in range(1, H + 1):
a = h * W
# 残りを高さで割る場合
b = ((H - h) // 2) * W
c = H * W - a - b
ans = min(ans, max([a, b, c]) - min([a, b, c]))
# 残りを幅で割る場合
b = (H - h) * (W // 2)
c = H * W - a - b
ans = min(ans, max([a, b, c]) - min([a, b, c]))
# 幅を変えて調べる
for w in range(1, W + 1):
a = H * w
# 残りを高さで割る場合
b = (W - w) * (H // 2)
c = H * W - a - b
ans = min(ans, max([a, b, c]) - min([a, b, c]))
# 残りを幅で割る場合
b = ((W - w) // 2) * H
c = H * W - a - b
ans = min(ans, max([a, b, c]) - min([a, b, c]))
print(ans)
| H, W = list(map(int, input().split()))
ans = H * W
# 1つめは縦を1ずつ増やしていく場合
for h in range(1, H):
a = h * W
# 残りについて、縦で分割する場合
b = ((H - h) // 2) * W
c = H * W - a - b
ans = min(ans, max(a, b, c) - min(a, b, c))
# 残りについて、横で分割する場合
b = (H - h) * (W // 2)
c = H * W - a - b
ans = min(ans, max(a, b, c) - min(a, b, c))
# 1つめは横を1ずつ増やしていく場合
for w in range(1, W):
a = w * H
# 残りについて、縦で分割する場合
b = (W - w) * (H // 2)
c = H * W - a - b
ans = min(ans, max(a, b, c) - min(a, b, c))
# 残りについて、横で分割する場合
b = ((W - w) // 2) * H
c = H * W - a - b
ans = min(ans, max(a, b, c) - min(a, b, c))
print(ans)
| false | 2.564103 | [
"-if H % 3 == 0 or W % 3 == 0:",
"- print((0))",
"- exit()",
"-# 高さを変えて調べる",
"-for h in range(1, H + 1):",
"+# 1つめは縦を1ずつ増やしていく場合",
"+for h in range(1, H):",
"- # 残りを高さで割る場合",
"+ # 残りについて、縦で分割する場合",
"- ans = min(ans, max([a, b, c]) - min([a, b, c]))",
"- # 残りを幅で割る場合",
"+ ans = min(ans, max(a, b, c) - min(a, b, c))",
"+ # 残りについて、横で分割する場合",
"- ans = min(ans, max([a, b, c]) - min([a, b, c]))",
"-# 幅を変えて調べる",
"-for w in range(1, W + 1):",
"- a = H * w",
"- # 残りを高さで割る場合",
"+ ans = min(ans, max(a, b, c) - min(a, b, c))",
"+# 1つめは横を1ずつ増やしていく場合",
"+for w in range(1, W):",
"+ a = w * H",
"+ # 残りについて、縦で分割する場合",
"- ans = min(ans, max([a, b, c]) - min([a, b, c]))",
"- # 残りを幅で割る場合",
"+ ans = min(ans, max(a, b, c) - min(a, b, c))",
"+ # 残りについて、横で分割する場合",
"- ans = min(ans, max([a, b, c]) - min([a, b, c]))",
"+ ans = min(ans, max(a, b, c) - min(a, b, c))"
] | false | 1.103701 | 0.287984 | 3.832505 | [
"s400471649",
"s840728183"
] |
u129214942 | p03206 | python | s279467414 | s388441463 | 1,956 | 16 | 22,296 | 2,940 | Accepted | Accepted | 99.18 | import numpy as np
# 初期値を入力
D = int(eval(input()))
# メインプログラム
if D == 22:
print("Christmas Eve Eve Eve")
elif D == 23:
print("Christmas Eve Eve")
elif D == 24:
print("Christmas Eve")
elif D == 25:
print("Christmas")
|
D = int(eval(input()))
if D == 22:
print("Christmas Eve Eve Eve")
elif D == 23:
print("Christmas Eve Eve")
elif D == 24:
print("Christmas Eve")
elif D == 25:
print("Christmas")
| 16 | 12 | 245 | 201 | import numpy as np
# 初期値を入力
D = int(eval(input()))
# メインプログラム
if D == 22:
print("Christmas Eve Eve Eve")
elif D == 23:
print("Christmas Eve Eve")
elif D == 24:
print("Christmas Eve")
elif D == 25:
print("Christmas")
| D = int(eval(input()))
if D == 22:
print("Christmas Eve Eve Eve")
elif D == 23:
print("Christmas Eve Eve")
elif D == 24:
print("Christmas Eve")
elif D == 25:
print("Christmas")
| false | 25 | [
"-import numpy as np",
"-",
"-# 初期値を入力",
"-# メインプログラム"
] | false | 0.041054 | 0.040499 | 1.0137 | [
"s279467414",
"s388441463"
] |
u562935282 | p02768 | python | s690657999 | s831275358 | 370 | 142 | 57,248 | 3,064 | Accepted | Accepted | 61.62 | def main():
mod = 10 ** 9 + 7
n, a, b = list(map(int, input().split()))
ma = max(a, b)
tbl = [0] * (ma + 1)
# f = 1
# for i in range(1, ma + 1):
# f = (f * i) % mod
#
# invs = [1] * (ma + 1)
# invs[ma] = pow(f, mod - 2, mod)
# for x in range(ma - 1, 0, -1):
# invs[x] = invs[x + 1] * (x + 1) % mod
t = 1
for i in range(1, max(a, b) + 1):
t = (t * (n - i + 1) * pow(i, mod - 2, mod)) % mod
tbl[i] = t
ans = pow(2, n, mod) - 1 - tbl[a] - tbl[b]
print((ans % mod))
if __name__ == '__main__':
main()
| mod = 10 ** 9 + 7
n, a, b = list(map(int, input().split()))
def choose(n, a, mod=mod):
x, y = 1, 1
for i in range(a):
x = x * (n - i) % mod
y = y * (i + 1) % mod
return x * pow(y, mod - 2, mod)
ret = pow(2, n, mod)
ret -= 1
ret -= choose(n, a)
ret -= choose(n, b)
ret %= mod
print(ret)
| 28 | 20 | 614 | 333 | def main():
mod = 10**9 + 7
n, a, b = list(map(int, input().split()))
ma = max(a, b)
tbl = [0] * (ma + 1)
# f = 1
# for i in range(1, ma + 1):
# f = (f * i) % mod
#
# invs = [1] * (ma + 1)
# invs[ma] = pow(f, mod - 2, mod)
# for x in range(ma - 1, 0, -1):
# invs[x] = invs[x + 1] * (x + 1) % mod
t = 1
for i in range(1, max(a, b) + 1):
t = (t * (n - i + 1) * pow(i, mod - 2, mod)) % mod
tbl[i] = t
ans = pow(2, n, mod) - 1 - tbl[a] - tbl[b]
print((ans % mod))
if __name__ == "__main__":
main()
| mod = 10**9 + 7
n, a, b = list(map(int, input().split()))
def choose(n, a, mod=mod):
x, y = 1, 1
for i in range(a):
x = x * (n - i) % mod
y = y * (i + 1) % mod
return x * pow(y, mod - 2, mod)
ret = pow(2, n, mod)
ret -= 1
ret -= choose(n, a)
ret -= choose(n, b)
ret %= mod
print(ret)
| false | 28.571429 | [
"-def main():",
"- mod = 10**9 + 7",
"- n, a, b = list(map(int, input().split()))",
"- ma = max(a, b)",
"- tbl = [0] * (ma + 1)",
"- # f = 1",
"- # for i in range(1, ma + 1):",
"- # f = (f * i) % mod",
"- #",
"- # invs = [1] * (ma + 1)",
"- # invs[ma] = pow(f, mod - 2, mod)",
"- # for x in range(ma - 1, 0, -1):",
"- # invs[x] = invs[x + 1] * (x + 1) % mod",
"- t = 1",
"- for i in range(1, max(a, b) + 1):",
"- t = (t * (n - i + 1) * pow(i, mod - 2, mod)) % mod",
"- tbl[i] = t",
"- ans = pow(2, n, mod) - 1 - tbl[a] - tbl[b]",
"- print((ans % mod))",
"+mod = 10**9 + 7",
"+n, a, b = list(map(int, input().split()))",
"-if __name__ == \"__main__\":",
"- main()",
"+def choose(n, a, mod=mod):",
"+ x, y = 1, 1",
"+ for i in range(a):",
"+ x = x * (n - i) % mod",
"+ y = y * (i + 1) % mod",
"+ return x * pow(y, mod - 2, mod)",
"+",
"+",
"+ret = pow(2, n, mod)",
"+ret -= 1",
"+ret -= choose(n, a)",
"+ret -= choose(n, b)",
"+ret %= mod",
"+print(ret)"
] | false | 0.999984 | 0.108389 | 9.225905 | [
"s690657999",
"s831275358"
] |
u645250356 | p04033 | python | s564813370 | s128884212 | 186 | 36 | 38,384 | 5,076 | Accepted | Accepted | 80.65 | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))
a,b = inpl()
if a <= 0 and b >= 0:
print('Zero')
else:
if a > 0:
print('Positive')
else:
if (b - a) % 2 == 0:
print('Negative')
else:
print('Positive')
| from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
a,b = inpl()
if a>0 and b>0:
res = 1
elif a*b<=0:
res = 0
else:
if abs(a-b)%2:
res = 1
else:
res = -1
if res == 1:
print('Positive')
elif res == 0:
print('Zero')
else:
print('Negative') | 22 | 25 | 601 | 567 | from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, pprint
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
def inp():
return int(sys.stdin.readline())
def inpl():
return list(map(int, sys.stdin.readline().split()))
def inpln(n):
return list(int(sys.stdin.readline()) for i in range(n))
a, b = inpl()
if a <= 0 and b >= 0:
print("Zero")
else:
if a > 0:
print("Positive")
else:
if (b - a) % 2 == 0:
print("Negative")
else:
print("Positive")
| from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, fractions, pprint
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")
def inp():
return int(sys.stdin.readline())
def inpl():
return list(map(int, sys.stdin.readline().split()))
a, b = inpl()
if a > 0 and b > 0:
res = 1
elif a * b <= 0:
res = 0
else:
if abs(a - b) % 2:
res = 1
else:
res = -1
if res == 1:
print("Positive")
elif res == 0:
print("Zero")
else:
print("Negative")
| false | 12 | [
"-import sys, bisect, math, itertools, pprint",
"+import sys, bisect, math, itertools, fractions, pprint",
"+INF = float(\"inf\")",
"-def inpln(n):",
"- return list(int(sys.stdin.readline()) for i in range(n))",
"-",
"-",
"-if a <= 0 and b >= 0:",
"+if a > 0 and b > 0:",
"+ res = 1",
"+elif a * b <= 0:",
"+ res = 0",
"+else:",
"+ if abs(a - b) % 2:",
"+ res = 1",
"+ else:",
"+ res = -1",
"+if res == 1:",
"+ print(\"Positive\")",
"+elif res == 0:",
"- if a > 0:",
"- print(\"Positive\")",
"- else:",
"- if (b - a) % 2 == 0:",
"- print(\"Negative\")",
"- else:",
"- print(\"Positive\")",
"+ print(\"Negative\")"
] | false | 0.041149 | 0.039637 | 1.038138 | [
"s564813370",
"s128884212"
] |
u926412290 | p02597 | python | s909274709 | s049558341 | 96 | 65 | 77,292 | 63,008 | Accepted | Accepted | 32.29 | N = int(eval(input()))
c = list(eval(input()))
ans = 0
FLG = False
j = N - 1
for i, color in enumerate(c):
if color == "W":
while c[j] == "W":
j -= 1
if j <= i:
FLG = True
break
if FLG:
break
ans += 1
c[i], c[j] = c[j], c[i]
print(ans) | N = int(eval(input()))
c = eval(input())
x = c.count("R")
print((c[x:].count("R")))
| 18 | 4 | 345 | 73 | N = int(eval(input()))
c = list(eval(input()))
ans = 0
FLG = False
j = N - 1
for i, color in enumerate(c):
if color == "W":
while c[j] == "W":
j -= 1
if j <= i:
FLG = True
break
if FLG:
break
ans += 1
c[i], c[j] = c[j], c[i]
print(ans)
| N = int(eval(input()))
c = eval(input())
x = c.count("R")
print((c[x:].count("R")))
| false | 77.777778 | [
"-c = list(eval(input()))",
"-ans = 0",
"-FLG = False",
"-j = N - 1",
"-for i, color in enumerate(c):",
"- if color == \"W\":",
"- while c[j] == \"W\":",
"- j -= 1",
"- if j <= i:",
"- FLG = True",
"- break",
"- if FLG:",
"- break",
"- ans += 1",
"- c[i], c[j] = c[j], c[i]",
"-print(ans)",
"+c = eval(input())",
"+x = c.count(\"R\")",
"+print((c[x:].count(\"R\")))"
] | false | 0.036705 | 0.037111 | 0.989069 | [
"s909274709",
"s049558341"
] |
u614314290 | p03078 | python | s402850552 | s395531406 | 777 | 40 | 4,468 | 4,672 | Accepted | Accepted | 94.85 | import heapq
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
a = sorted(A, reverse=True)
b = sorted(B, reverse=True)
c = sorted(C, reverse=True)
added = [(0, 0, 0)]
cakes = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]
for k in range(K):
v = heapq.heappop(cakes)
print((-v[0]))
va, vb, vc = v[1:]
if va < X - 1 and (va + 1, vb, vc) not in added:
heapq.heappush(cakes, (-(a[va + 1] + b[vb] + c[vc]), va + 1, vb, vc))
added += [(va + 1, vb, vc)]
if vb < Y - 1 and (va, vb + 1, vc) not in added:
heapq.heappush(cakes, (-(a[va] + b[vb + 1] + c[vc]), va, vb + 1, vc))
added += [(va, vb + 1, vc)]
if vc < Z - 1 and (va, vb, vc + 1) not in added:
heapq.heappush(cakes, (-(a[va] + b[vb] + c[vc + 1]), va, vb, vc + 1))
added += [(va, vb, vc + 1)]
| # データ構造:ヒープ
import heapq
class heapque:
def __init__(self, *args):
self.que = []
for arg in args:
self.push(arg)
def push(self, v):
heapq.heappush(self.que, v)
def pop(self):
return heapq.heappop(self.que)
# 定数
INF = float("inf")
MOD = int(1e9 + 7)
# エントリーポイント
def main():
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
a = sorted(A, reverse=True)
b = sorted(B, reverse=True)
c = sorted(C, reverse=True)
heap = heapque((-(a[0] + b[0] + c[0]), (0, 0, 0)))
used = {(0, 0, 0)}
for _ in range(K):
cur = heap.pop()
print((-cur[0]))
ai, bi, ci = cur[1]
ns = ((min(ai + 1, X - 1), bi, ci), (ai, min(bi + 1, Y - 1), ci), (ai, bi, min(ci + 1, Z - 1)))
for n in ns:
if n in used: continue
heap.push((-(a[n[0]] + b[n[1]] + c[n[2]]), n))
used |= {n}
main()
| 26 | 40 | 870 | 1,059 | import heapq
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
a = sorted(A, reverse=True)
b = sorted(B, reverse=True)
c = sorted(C, reverse=True)
added = [(0, 0, 0)]
cakes = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]
for k in range(K):
v = heapq.heappop(cakes)
print((-v[0]))
va, vb, vc = v[1:]
if va < X - 1 and (va + 1, vb, vc) not in added:
heapq.heappush(cakes, (-(a[va + 1] + b[vb] + c[vc]), va + 1, vb, vc))
added += [(va + 1, vb, vc)]
if vb < Y - 1 and (va, vb + 1, vc) not in added:
heapq.heappush(cakes, (-(a[va] + b[vb + 1] + c[vc]), va, vb + 1, vc))
added += [(va, vb + 1, vc)]
if vc < Z - 1 and (va, vb, vc + 1) not in added:
heapq.heappush(cakes, (-(a[va] + b[vb] + c[vc + 1]), va, vb, vc + 1))
added += [(va, vb, vc + 1)]
| # データ構造:ヒープ
import heapq
class heapque:
def __init__(self, *args):
self.que = []
for arg in args:
self.push(arg)
def push(self, v):
heapq.heappush(self.que, v)
def pop(self):
return heapq.heappop(self.que)
# 定数
INF = float("inf")
MOD = int(1e9 + 7)
# エントリーポイント
def main():
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
a = sorted(A, reverse=True)
b = sorted(B, reverse=True)
c = sorted(C, reverse=True)
heap = heapque((-(a[0] + b[0] + c[0]), (0, 0, 0)))
used = {(0, 0, 0)}
for _ in range(K):
cur = heap.pop()
print((-cur[0]))
ai, bi, ci = cur[1]
ns = (
(min(ai + 1, X - 1), bi, ci),
(ai, min(bi + 1, Y - 1), ci),
(ai, bi, min(ci + 1, Z - 1)),
)
for n in ns:
if n in used:
continue
heap.push((-(a[n[0]] + b[n[1]] + c[n[2]]), n))
used |= {n}
main()
| false | 35 | [
"+# データ構造:ヒープ",
"-X, Y, Z, K = list(map(int, input().split()))",
"-A = list(map(int, input().split()))",
"-B = list(map(int, input().split()))",
"-C = list(map(int, input().split()))",
"-a = sorted(A, reverse=True)",
"-b = sorted(B, reverse=True)",
"-c = sorted(C, reverse=True)",
"-added = [(0, 0, 0)]",
"-cakes = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]",
"-for k in range(K):",
"- v = heapq.heappop(cakes)",
"- print((-v[0]))",
"- va, vb, vc = v[1:]",
"- if va < X - 1 and (va + 1, vb, vc) not in added:",
"- heapq.heappush(cakes, (-(a[va + 1] + b[vb] + c[vc]), va + 1, vb, vc))",
"- added += [(va + 1, vb, vc)]",
"- if vb < Y - 1 and (va, vb + 1, vc) not in added:",
"- heapq.heappush(cakes, (-(a[va] + b[vb + 1] + c[vc]), va, vb + 1, vc))",
"- added += [(va, vb + 1, vc)]",
"- if vc < Z - 1 and (va, vb, vc + 1) not in added:",
"- heapq.heappush(cakes, (-(a[va] + b[vb] + c[vc + 1]), va, vb, vc + 1))",
"- added += [(va, vb, vc + 1)]",
"+",
"+class heapque:",
"+ def __init__(self, *args):",
"+ self.que = []",
"+ for arg in args:",
"+ self.push(arg)",
"+",
"+ def push(self, v):",
"+ heapq.heappush(self.que, v)",
"+",
"+ def pop(self):",
"+ return heapq.heappop(self.que)",
"+",
"+",
"+# 定数",
"+INF = float(\"inf\")",
"+MOD = int(1e9 + 7)",
"+# エントリーポイント",
"+def main():",
"+ X, Y, Z, K = list(map(int, input().split()))",
"+ A = list(map(int, input().split()))",
"+ B = list(map(int, input().split()))",
"+ C = list(map(int, input().split()))",
"+ a = sorted(A, reverse=True)",
"+ b = sorted(B, reverse=True)",
"+ c = sorted(C, reverse=True)",
"+ heap = heapque((-(a[0] + b[0] + c[0]), (0, 0, 0)))",
"+ used = {(0, 0, 0)}",
"+ for _ in range(K):",
"+ cur = heap.pop()",
"+ print((-cur[0]))",
"+ ai, bi, ci = cur[1]",
"+ ns = (",
"+ (min(ai + 1, X - 1), bi, ci),",
"+ (ai, min(bi + 1, Y - 1), ci),",
"+ (ai, bi, min(ci + 1, Z - 1)),",
"+ )",
"+ for n in ns:",
"+ if n in used:",
"+ continue",
"+ heap.push((-(a[n[0]] + b[n[1]] + c[n[2]]), n))",
"+ used |= {n}",
"+",
"+",
"+main()"
] | false | 0.078888 | 0.035687 | 2.210529 | [
"s402850552",
"s395531406"
] |
u794544096 | p03544 | python | s838703099 | s166313006 | 415 | 72 | 79,916 | 61,500 | Accepted | Accepted | 82.65 | n = int(eval(input()))
ans = 0
l = [2, 1]
for i in range(n-1):
l.append(l[i]+l[i+1])
print((l[n])) | n = int(eval(input()))
l = [2, 1]
for i in range(n-1):
l.append(l[i]+l[i+1])
print((l[n])) | 8 | 7 | 103 | 94 | n = int(eval(input()))
ans = 0
l = [2, 1]
for i in range(n - 1):
l.append(l[i] + l[i + 1])
print((l[n]))
| n = int(eval(input()))
l = [2, 1]
for i in range(n - 1):
l.append(l[i] + l[i + 1])
print((l[n]))
| false | 12.5 | [
"-ans = 0"
] | false | 0.085964 | 0.047176 | 1.822205 | [
"s838703099",
"s166313006"
] |
u981931040 | p03951 | python | s642503319 | s704756506 | 31 | 26 | 9,180 | 9,156 | Accepted | Accepted | 16.13 | N = int(eval(input()))
s = eval(input())
t = eval(input())
idx = 0
for i in range(N):
tmp_s = s[N - i - 1:]
tmp_t = t[:i + 1]
if tmp_s == tmp_t:
idx = i + 1
print((len(s + t[idx:])))
| N = int(eval(input()))
s = eval(input())
t = eval(input())
ans = s
for i in range(N + 1):
tmp_ans = s + t[i:]
# print(tmp_ans)
if tmp_ans[:N] == s and tmp_ans[-N:] == t:
ans = tmp_ans
print((len(ans)))
| 11 | 10 | 194 | 211 | N = int(eval(input()))
s = eval(input())
t = eval(input())
idx = 0
for i in range(N):
tmp_s = s[N - i - 1 :]
tmp_t = t[: i + 1]
if tmp_s == tmp_t:
idx = i + 1
print((len(s + t[idx:])))
| N = int(eval(input()))
s = eval(input())
t = eval(input())
ans = s
for i in range(N + 1):
tmp_ans = s + t[i:]
# print(tmp_ans)
if tmp_ans[:N] == s and tmp_ans[-N:] == t:
ans = tmp_ans
print((len(ans)))
| false | 9.090909 | [
"-idx = 0",
"-for i in range(N):",
"- tmp_s = s[N - i - 1 :]",
"- tmp_t = t[: i + 1]",
"- if tmp_s == tmp_t:",
"- idx = i + 1",
"-print((len(s + t[idx:])))",
"+ans = s",
"+for i in range(N + 1):",
"+ tmp_ans = s + t[i:]",
"+ # print(tmp_ans)",
"+ if tmp_ans[:N] == s and tmp_ans[-N:] == t:",
"+ ans = tmp_ans",
"+print((len(ans)))"
] | false | 0.041664 | 0.113428 | 0.367319 | [
"s642503319",
"s704756506"
] |
u375477204 | p02952 | python | s116137788 | s432801802 | 63 | 17 | 2,940 | 2,940 | Accepted | Accepted | 73.02 | N = int(eval(input()))
s = 0
for i in range(1, N+1):
if len(str(i))%2 == 1:
s = s+1
print (s) | N = int(eval(input()))
s = len(str(N))
t = 0
for i in range(0,s//2):
t = t+9*10**(i*2)
if s%2 == 1:
t = t+N-10**(s-1)+1
print (t) | 6 | 8 | 104 | 138 | N = int(eval(input()))
s = 0
for i in range(1, N + 1):
if len(str(i)) % 2 == 1:
s = s + 1
print(s)
| N = int(eval(input()))
s = len(str(N))
t = 0
for i in range(0, s // 2):
t = t + 9 * 10 ** (i * 2)
if s % 2 == 1:
t = t + N - 10 ** (s - 1) + 1
print(t)
| false | 25 | [
"-s = 0",
"-for i in range(1, N + 1):",
"- if len(str(i)) % 2 == 1:",
"- s = s + 1",
"-print(s)",
"+s = len(str(N))",
"+t = 0",
"+for i in range(0, s // 2):",
"+ t = t + 9 * 10 ** (i * 2)",
"+if s % 2 == 1:",
"+ t = t + N - 10 ** (s - 1) + 1",
"+print(t)"
] | false | 0.051798 | 0.07977 | 0.64935 | [
"s116137788",
"s432801802"
] |
u597374218 | p02628 | python | s692487048 | s364740060 | 34 | 29 | 9,124 | 9,180 | Accepted | Accepted | 14.71 | N,K=list(map(int,input().split()))
p=sorted(map(int,input().split()))
print((sum(p[:K]))) | N, K = list(map(int, input().split()))
p = sorted(map(int, input().split()))
print((sum(p[0:K]))) | 3 | 3 | 83 | 91 | N, K = list(map(int, input().split()))
p = sorted(map(int, input().split()))
print((sum(p[:K])))
| N, K = list(map(int, input().split()))
p = sorted(map(int, input().split()))
print((sum(p[0:K])))
| false | 0 | [
"-print((sum(p[:K])))",
"+print((sum(p[0:K])))"
] | false | 0.032995 | 0.032828 | 1.005096 | [
"s692487048",
"s364740060"
] |
u536034761 | p02923 | python | s299469409 | s641071016 | 94 | 74 | 14,636 | 20,644 | Accepted | Accepted | 21.28 | from collections import deque
N = int(eval(input()))
H = deque(list(map(int, input().split())))
ans = 0
n = 0
tmp = H.popleft()
while H:
nxt = H.popleft()
if tmp >= nxt:
n += 1
ans = max(ans, n)
else:
n = 0
tmp = nxt
print(ans) | N = int(eval(input()))
H = list(map(int, input().split()))
ans = 0
cnt = 0
pre = H[0]
for h in H[1:]:
if h <= pre:
cnt += 1
else:
ans = max(ans, cnt)
cnt = 0
pre = h
if cnt != 1:
ans = max(ans, cnt)
print(ans)
| 15 | 17 | 249 | 262 | from collections import deque
N = int(eval(input()))
H = deque(list(map(int, input().split())))
ans = 0
n = 0
tmp = H.popleft()
while H:
nxt = H.popleft()
if tmp >= nxt:
n += 1
ans = max(ans, n)
else:
n = 0
tmp = nxt
print(ans)
| N = int(eval(input()))
H = list(map(int, input().split()))
ans = 0
cnt = 0
pre = H[0]
for h in H[1:]:
if h <= pre:
cnt += 1
else:
ans = max(ans, cnt)
cnt = 0
pre = h
if cnt != 1:
ans = max(ans, cnt)
print(ans)
| false | 11.764706 | [
"-from collections import deque",
"-",
"-H = deque(list(map(int, input().split())))",
"+H = list(map(int, input().split()))",
"-n = 0",
"-tmp = H.popleft()",
"-while H:",
"- nxt = H.popleft()",
"- if tmp >= nxt:",
"- n += 1",
"- ans = max(ans, n)",
"+cnt = 0",
"+pre = H[0]",
"+for h in H[1:]:",
"+ if h <= pre:",
"+ cnt += 1",
"- n = 0",
"- tmp = nxt",
"+ ans = max(ans, cnt)",
"+ cnt = 0",
"+ pre = h",
"+if cnt != 1:",
"+ ans = max(ans, cnt)"
] | false | 0.008115 | 0.058593 | 0.138493 | [
"s299469409",
"s641071016"
] |
u345621867 | p02683 | python | s694467612 | s046154211 | 197 | 165 | 27,104 | 27,100 | Accepted | Accepted | 16.24 | import numpy as np
N, M, X = list(map(int,input().split()))
C = []
A = []
for i in range(N):
c = 0
a = []
c, *a = list(map(int,input().split()))
C.append(c)
A.append(a)
A = np.array(A)
inf = float("inf")
res = inf
for bit in range(1 << N):
Cost = 0
Wise = np.zeros(M)
for i in range(N):
if (bit >> i) & 1:# i冊目を買うときの処理
Cost += C[i]
Wise += A[i]
Wise = Wise.tolist()
#else:# i冊目を買わないときの処理(今回は何もしないので省略)
if min(Wise) >= X and Cost <= res:
res = Cost
if res == inf:
print("-1")
else:
print(res)
"""
n,m,x = map(int,input().split())
c=[]
a=[]
INF = float("inf")
stock = INF
for _ in range(n):
c_temp,*a_temp = list(map(int,input().split()))
c.append(c_temp)
a.append(a_temp)
#すべての組み合わせを計算
for bit in range(1 << n):
cost_total = 0
smart_total = [0]*m
#1セットごとの処理
for i in range(n):
#一冊ごとの処理
if (bit >> i) & 1:
# i冊目を買うときの処理
smart = []
cost_total += c[i]
smart = a[i]
for j , sm in enumerate(smart):
smart_total[j] += sm
#else:
# i冊目を買わないときの処理(今回は何もしないので省略)
judege = True
for i in range(m):
if smart_total[i] < x:
judege = False
if judege:
stock = min(cost_total,stock)
if stock == INF:
print("-1")
else:
print(stock)""" | import numpy as np
N, M, X = list(map(int,input().split()))
C = []
A = []
for i in range(N):
c = 0
a = []
c, *a = list(map(int,input().split()))
C.append(c)
A.append(a)
inf = float("inf")
res = inf
for bit in range(1 << N):
Cost = 0
Wise = [0] * M
for i in range(N):
if (bit >> i) & 1:# i冊目を買うときの処理
Cost += C[i]
for j, a in enumerate(A[i]):
Wise[j] += a
#else:# i冊目を買わないときの処理(今回は何もしないので省略)
if min(Wise) >= X and Cost <= res:
res = Cost
if res == inf:
print("-1")
else:
print(res)
| 73 | 27 | 1,479 | 606 | import numpy as np
N, M, X = list(map(int, input().split()))
C = []
A = []
for i in range(N):
c = 0
a = []
c, *a = list(map(int, input().split()))
C.append(c)
A.append(a)
A = np.array(A)
inf = float("inf")
res = inf
for bit in range(1 << N):
Cost = 0
Wise = np.zeros(M)
for i in range(N):
if (bit >> i) & 1: # i冊目を買うときの処理
Cost += C[i]
Wise += A[i]
Wise = Wise.tolist()
# else:# i冊目を買わないときの処理(今回は何もしないので省略)
if min(Wise) >= X and Cost <= res:
res = Cost
if res == inf:
print("-1")
else:
print(res)
"""
n,m,x = map(int,input().split())
c=[]
a=[]
INF = float("inf")
stock = INF
for _ in range(n):
c_temp,*a_temp = list(map(int,input().split()))
c.append(c_temp)
a.append(a_temp)
#すべての組み合わせを計算
for bit in range(1 << n):
cost_total = 0
smart_total = [0]*m
#1セットごとの処理
for i in range(n):
#一冊ごとの処理
if (bit >> i) & 1:
# i冊目を買うときの処理
smart = []
cost_total += c[i]
smart = a[i]
for j , sm in enumerate(smart):
smart_total[j] += sm
#else:
# i冊目を買わないときの処理(今回は何もしないので省略)
judege = True
for i in range(m):
if smart_total[i] < x:
judege = False
if judege:
stock = min(cost_total,stock)
if stock == INF:
print("-1")
else:
print(stock)"""
| import numpy as np
N, M, X = list(map(int, input().split()))
C = []
A = []
for i in range(N):
c = 0
a = []
c, *a = list(map(int, input().split()))
C.append(c)
A.append(a)
inf = float("inf")
res = inf
for bit in range(1 << N):
Cost = 0
Wise = [0] * M
for i in range(N):
if (bit >> i) & 1: # i冊目を買うときの処理
Cost += C[i]
for j, a in enumerate(A[i]):
Wise[j] += a
# else:# i冊目を買わないときの処理(今回は何もしないので省略)
if min(Wise) >= X and Cost <= res:
res = Cost
if res == inf:
print("-1")
else:
print(res)
| false | 63.013699 | [
"-A = np.array(A)",
"- Wise = np.zeros(M)",
"+ Wise = [0] * M",
"- Wise += A[i]",
"- Wise = Wise.tolist()",
"+ for j, a in enumerate(A[i]):",
"+ Wise[j] += a",
"-\"\"\"",
"-n,m,x = map(int,input().split())",
"-c=[]",
"-a=[]",
"-INF = float(\"inf\")",
"-stock = INF",
"-for _ in range(n):",
"- c_temp,*a_temp = list(map(int,input().split()))",
"- c.append(c_temp)",
"- a.append(a_temp)",
"-#すべての組み合わせを計算",
"-for bit in range(1 << n):",
"- cost_total = 0",
"- smart_total = [0]*m",
"- #1セットごとの処理",
"- for i in range(n):",
"- #一冊ごとの処理",
"- if (bit >> i) & 1:",
"- # i冊目を買うときの処理",
"- smart = []",
"- cost_total += c[i]",
"- smart = a[i]",
"- for j , sm in enumerate(smart):",
"- smart_total[j] += sm",
"- #else:",
"- # i冊目を買わないときの処理(今回は何もしないので省略)",
"- judege = True",
"- for i in range(m):",
"- if smart_total[i] < x:",
"- judege = False",
"- if judege:",
"- stock = min(cost_total,stock)",
"-if stock == INF:",
"- print(\"-1\")",
"-else:",
"- print(stock)\"\"\""
] | false | 0.182192 | 0.037171 | 4.901473 | [
"s694467612",
"s046154211"
] |
u861141787 | p03545 | python | s303412931 | s802631782 | 174 | 17 | 38,384 | 3,064 | Accepted | Accepted | 90.23 | a = list(eval(input()))
for x in range(8):
s = ""
sum = int(a[0])
s += a[0]
for i in range(3):
if ( x & ( 1 << i)):
sum += int(a[i+1])
s += "+"
s += a[i+1]
else:
sum -=int(a[i+1])
s += "-"
s += a[i+1]
if sum == 7:
print((s + "=7"))
break | S = eval(input())
N = 3
for x in range(1<<N):
ans = S[0]
sum = int(S[0])
for i in range(N):
if x & (1 << i):
ans += "+" + S[i+1]
sum += int(S[i+1])
else:
ans += "-" + S[i+1]
sum -= int(S[i+1])
if sum == 7:
break
print((ans + "=7")) | 20 | 18 | 379 | 331 | a = list(eval(input()))
for x in range(8):
s = ""
sum = int(a[0])
s += a[0]
for i in range(3):
if x & (1 << i):
sum += int(a[i + 1])
s += "+"
s += a[i + 1]
else:
sum -= int(a[i + 1])
s += "-"
s += a[i + 1]
if sum == 7:
print((s + "=7"))
break
| S = eval(input())
N = 3
for x in range(1 << N):
ans = S[0]
sum = int(S[0])
for i in range(N):
if x & (1 << i):
ans += "+" + S[i + 1]
sum += int(S[i + 1])
else:
ans += "-" + S[i + 1]
sum -= int(S[i + 1])
if sum == 7:
break
print((ans + "=7"))
| false | 10 | [
"-a = list(eval(input()))",
"-for x in range(8):",
"- s = \"\"",
"- sum = int(a[0])",
"- s += a[0]",
"- for i in range(3):",
"+S = eval(input())",
"+N = 3",
"+for x in range(1 << N):",
"+ ans = S[0]",
"+ sum = int(S[0])",
"+ for i in range(N):",
"- sum += int(a[i + 1])",
"- s += \"+\"",
"- s += a[i + 1]",
"+ ans += \"+\" + S[i + 1]",
"+ sum += int(S[i + 1])",
"- sum -= int(a[i + 1])",
"- s += \"-\"",
"- s += a[i + 1]",
"+ ans += \"-\" + S[i + 1]",
"+ sum -= int(S[i + 1])",
"- print((s + \"=7\"))",
"+print((ans + \"=7\"))"
] | false | 0.040868 | 0.040798 | 1.001716 | [
"s303412931",
"s802631782"
] |
u077291787 | p02726 | python | s619921267 | s187158600 | 1,243 | 900 | 3,188 | 3,316 | Accepted | Accepted | 27.59 | # D - Line++
def main():
N, X, Y = list(map(int, input().split()))
dist_cnt = [0] * N
calc_min_dist = lambda x, y: min(y - x, abs(X - x) + abs(Y - y) + 1) # assume x < y
for i in range(1, N + 1):
for j in range(i + 1, N + 1):
dist_cnt[calc_min_dist(i, j)] += 1
print(("\n".join(map(str, dist_cnt[1:]))))
if __name__ == "__main__":
main()
| # D - Line++
def main():
N, X, Y = list(map(int, input().split()))
dist_cnt = [0] * N
for i in range(1, N + 1):
for j in range(i + 1, N + 1):
dist_cnt[min(j - i, abs(X - i) + abs(j - Y) + 1)] += 1
print(("\n".join(map(str, dist_cnt[1:]))))
if __name__ == "__main__":
main()
| 13 | 12 | 389 | 319 | # D - Line++
def main():
N, X, Y = list(map(int, input().split()))
dist_cnt = [0] * N
calc_min_dist = lambda x, y: min(y - x, abs(X - x) + abs(Y - y) + 1) # assume x < y
for i in range(1, N + 1):
for j in range(i + 1, N + 1):
dist_cnt[calc_min_dist(i, j)] += 1
print(("\n".join(map(str, dist_cnt[1:]))))
if __name__ == "__main__":
main()
| # D - Line++
def main():
N, X, Y = list(map(int, input().split()))
dist_cnt = [0] * N
for i in range(1, N + 1):
for j in range(i + 1, N + 1):
dist_cnt[min(j - i, abs(X - i) + abs(j - Y) + 1)] += 1
print(("\n".join(map(str, dist_cnt[1:]))))
if __name__ == "__main__":
main()
| false | 7.692308 | [
"- calc_min_dist = lambda x, y: min(y - x, abs(X - x) + abs(Y - y) + 1) # assume x < y",
"- dist_cnt[calc_min_dist(i, j)] += 1",
"+ dist_cnt[min(j - i, abs(X - i) + abs(j - Y) + 1)] += 1"
] | false | 0.037464 | 0.041577 | 0.901072 | [
"s619921267",
"s187158600"
] |
u956268964 | p02570 | python | s272164378 | s657242620 | 29 | 26 | 9,084 | 9,128 | Accepted | Accepted | 10.34 | D, T, S = list(map(int, input().split()))
if D / S <= T:
print("Yes")
else:
print("No")
| D, T, S = list(map(int, input().split()))
if D <= T * S:
print("Yes")
else:
print("No")
| 7 | 6 | 105 | 96 | D, T, S = list(map(int, input().split()))
if D / S <= T:
print("Yes")
else:
print("No")
| D, T, S = list(map(int, input().split()))
if D <= T * S:
print("Yes")
else:
print("No")
| false | 14.285714 | [
"-if D / S <= T:",
"+if D <= T * S:"
] | false | 0.045974 | 0.04661 | 0.98634 | [
"s272164378",
"s657242620"
] |
u143509139 | p02679 | python | s099263722 | s903429818 | 1,731 | 661 | 117,940 | 174,436 | Accepted | Accepted | 61.81 | from functools import cmp_to_key
MOD = 10 ** 9 + 7
def func(a, b):
if a[0] * b[1] == a[1] * b[0]:
return 0
elif a[0] * b[1] < a[1] * b[0]:
return - 1
else:
return 1
n = int(eval(input()))
a = [0] * n
b = [0] * n
i = 0
f = 0
while i < n:
a[i], b[i] = list(map(int, input().split()))
if a[i] == 0 and b[i] == 0:
f += 1
n -= 1
continue
if a[i] < 0:
a[i] = -a[i]
b[i] = -b[i]
if a[i] == 0 and b[i] < 0:
b[i] = -b[i]
i += 1
l = sorted(zip(a, b), key=cmp_to_key(func))
if l[0][1] > 0:
li = [[1, 0, l[0][0], l[0][1]]]
else:
li = []
for i in range(1, n):
a, b = l[i - 1]
c, d = l[i]
if d <= 0:
break
if li and a * d == b * c:
li[-1][0] += 1
else:
li.append([1, 0, c, d])
idx = 0
cnt = 0
for j in range(n):
a, b = l[j]
if b > 0:
continue
a, b = -b, a
while idx < len(li) and li[idx][2] * b < li[idx][3] * a:
idx += 1
if idx < len(li) and li[idx][2] * b == li[idx][3] * a:
li[idx][1] += 1
else:
cnt += 1
ans = 1
for a, b, c, d in li:
ans *= (pow(2, a, MOD) + pow(2, b, MOD) - 1)
ans %= MOD
print(((ans * (pow(2, cnt, MOD)) - 1 + f) % MOD))
| from math import gcd
from collections import defaultdict
MOD = 10 ** 9 + 7
n = int(eval(input()))
d = defaultdict(int)
tmp = 0
for i in range(n):
a, b = list(map(int, input().split()))
if a == b == 0:
tmp += 1
else:
if b < 0 or (b == 0 and a <= 0):
a = -a
b = -b
g = gcd(a, b)
a = a // g
b = b // g
d[(a, b)] += 1
if a <= 0:
d[(b, -a)]
else:
d[(-b, a)]
ans = 1
for k, v in list(d.items()):
a, b = k
if a <= 0:
continue
c = d[(-b, a)]
ans *= pow(2, v) + pow(2, c) - 1
ans %= MOD
print(((ans + tmp - 1) % MOD))
| 63 | 33 | 1,303 | 675 | from functools import cmp_to_key
MOD = 10**9 + 7
def func(a, b):
if a[0] * b[1] == a[1] * b[0]:
return 0
elif a[0] * b[1] < a[1] * b[0]:
return -1
else:
return 1
n = int(eval(input()))
a = [0] * n
b = [0] * n
i = 0
f = 0
while i < n:
a[i], b[i] = list(map(int, input().split()))
if a[i] == 0 and b[i] == 0:
f += 1
n -= 1
continue
if a[i] < 0:
a[i] = -a[i]
b[i] = -b[i]
if a[i] == 0 and b[i] < 0:
b[i] = -b[i]
i += 1
l = sorted(zip(a, b), key=cmp_to_key(func))
if l[0][1] > 0:
li = [[1, 0, l[0][0], l[0][1]]]
else:
li = []
for i in range(1, n):
a, b = l[i - 1]
c, d = l[i]
if d <= 0:
break
if li and a * d == b * c:
li[-1][0] += 1
else:
li.append([1, 0, c, d])
idx = 0
cnt = 0
for j in range(n):
a, b = l[j]
if b > 0:
continue
a, b = -b, a
while idx < len(li) and li[idx][2] * b < li[idx][3] * a:
idx += 1
if idx < len(li) and li[idx][2] * b == li[idx][3] * a:
li[idx][1] += 1
else:
cnt += 1
ans = 1
for a, b, c, d in li:
ans *= pow(2, a, MOD) + pow(2, b, MOD) - 1
ans %= MOD
print(((ans * (pow(2, cnt, MOD)) - 1 + f) % MOD))
| from math import gcd
from collections import defaultdict
MOD = 10**9 + 7
n = int(eval(input()))
d = defaultdict(int)
tmp = 0
for i in range(n):
a, b = list(map(int, input().split()))
if a == b == 0:
tmp += 1
else:
if b < 0 or (b == 0 and a <= 0):
a = -a
b = -b
g = gcd(a, b)
a = a // g
b = b // g
d[(a, b)] += 1
if a <= 0:
d[(b, -a)]
else:
d[(-b, a)]
ans = 1
for k, v in list(d.items()):
a, b = k
if a <= 0:
continue
c = d[(-b, a)]
ans *= pow(2, v) + pow(2, c) - 1
ans %= MOD
print(((ans + tmp - 1) % MOD))
| false | 47.619048 | [
"-from functools import cmp_to_key",
"+from math import gcd",
"+from collections import defaultdict",
"-",
"-",
"-def func(a, b):",
"- if a[0] * b[1] == a[1] * b[0]:",
"- return 0",
"- elif a[0] * b[1] < a[1] * b[0]:",
"- return -1",
"+n = int(eval(input()))",
"+d = defaultdict(int)",
"+tmp = 0",
"+for i in range(n):",
"+ a, b = list(map(int, input().split()))",
"+ if a == b == 0:",
"+ tmp += 1",
"- return 1",
"-",
"-",
"-n = int(eval(input()))",
"-a = [0] * n",
"-b = [0] * n",
"-i = 0",
"-f = 0",
"-while i < n:",
"- a[i], b[i] = list(map(int, input().split()))",
"- if a[i] == 0 and b[i] == 0:",
"- f += 1",
"- n -= 1",
"+ if b < 0 or (b == 0 and a <= 0):",
"+ a = -a",
"+ b = -b",
"+ g = gcd(a, b)",
"+ a = a // g",
"+ b = b // g",
"+ d[(a, b)] += 1",
"+ if a <= 0:",
"+ d[(b, -a)]",
"+ else:",
"+ d[(-b, a)]",
"+ans = 1",
"+for k, v in list(d.items()):",
"+ a, b = k",
"+ if a <= 0:",
"- if a[i] < 0:",
"- a[i] = -a[i]",
"- b[i] = -b[i]",
"- if a[i] == 0 and b[i] < 0:",
"- b[i] = -b[i]",
"- i += 1",
"-l = sorted(zip(a, b), key=cmp_to_key(func))",
"-if l[0][1] > 0:",
"- li = [[1, 0, l[0][0], l[0][1]]]",
"-else:",
"- li = []",
"-for i in range(1, n):",
"- a, b = l[i - 1]",
"- c, d = l[i]",
"- if d <= 0:",
"- break",
"- if li and a * d == b * c:",
"- li[-1][0] += 1",
"- else:",
"- li.append([1, 0, c, d])",
"-idx = 0",
"-cnt = 0",
"-for j in range(n):",
"- a, b = l[j]",
"- if b > 0:",
"- continue",
"- a, b = -b, a",
"- while idx < len(li) and li[idx][2] * b < li[idx][3] * a:",
"- idx += 1",
"- if idx < len(li) and li[idx][2] * b == li[idx][3] * a:",
"- li[idx][1] += 1",
"- else:",
"- cnt += 1",
"-ans = 1",
"-for a, b, c, d in li:",
"- ans *= pow(2, a, MOD) + pow(2, b, MOD) - 1",
"+ c = d[(-b, a)]",
"+ ans *= pow(2, v) + pow(2, c) - 1",
"-print(((ans * (pow(2, cnt, MOD)) - 1 + f) % MOD))",
"+print(((ans + tmp - 1) % MOD))"
] | false | 0.037023 | 0.03749 | 0.987549 | [
"s099263722",
"s903429818"
] |
u737758066 | p02718 | python | s346114029 | s331915351 | 180 | 18 | 38,384 | 3,060 | Accepted | Accepted | 90 | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
s = sum(a)
p = s / (4 * m)
cnt = 0
for i in range(n):
if a[i] >= p:
cnt += 1
if cnt >= m:
print('Yes')
else:
print('No')
| n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=True)
su = sum(a)
for i in range(m):
if a[i] < su/(4*m):
print("No")
exit(0)
print("Yes") | 12 | 12 | 221 | 207 | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
s = sum(a)
p = s / (4 * m)
cnt = 0
for i in range(n):
if a[i] >= p:
cnt += 1
if cnt >= m:
print("Yes")
else:
print("No")
| n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=True)
su = sum(a)
for i in range(m):
if a[i] < su / (4 * m):
print("No")
exit(0)
print("Yes")
| false | 0 | [
"-s = sum(a)",
"-p = s / (4 * m)",
"-cnt = 0",
"-for i in range(n):",
"- if a[i] >= p:",
"- cnt += 1",
"-if cnt >= m:",
"- print(\"Yes\")",
"-else:",
"- print(\"No\")",
"+a.sort(reverse=True)",
"+su = sum(a)",
"+for i in range(m):",
"+ if a[i] < su / (4 * m):",
"+ print(\"No\")",
"+ exit(0)",
"+print(\"Yes\")"
] | false | 0.048292 | 0.044516 | 1.084823 | [
"s346114029",
"s331915351"
] |
u850516963 | p02953 | python | s859001772 | s152168386 | 239 | 64 | 63,984 | 15,020 | Accepted | Accepted | 73.22 | N = int(eval(input()))
H = list(map(int, input().split()))
pre = -999
for i in range(N):
if pre <= H[i]-1:
pre = H[i]-1
elif pre <= H[i]:
pre = H[i]
else:
print("No")
exit()
print("Yes") | N = int(eval(input()))
H = list(map(int, input().split()))
next = 10**9
for i in range(N-1,0,-1):
if H[i] <= next:
next = H[i]
elif H[i]-1 <= next:
next = H[i]-1
else:
print("No")
exit()
print("Yes") | 14 | 14 | 219 | 232 | N = int(eval(input()))
H = list(map(int, input().split()))
pre = -999
for i in range(N):
if pre <= H[i] - 1:
pre = H[i] - 1
elif pre <= H[i]:
pre = H[i]
else:
print("No")
exit()
print("Yes")
| N = int(eval(input()))
H = list(map(int, input().split()))
next = 10**9
for i in range(N - 1, 0, -1):
if H[i] <= next:
next = H[i]
elif H[i] - 1 <= next:
next = H[i] - 1
else:
print("No")
exit()
print("Yes")
| false | 0 | [
"-pre = -999",
"-for i in range(N):",
"- if pre <= H[i] - 1:",
"- pre = H[i] - 1",
"- elif pre <= H[i]:",
"- pre = H[i]",
"+next = 10**9",
"+for i in range(N - 1, 0, -1):",
"+ if H[i] <= next:",
"+ next = H[i]",
"+ elif H[i] - 1 <= next:",
"+ next = H[i] - 1"
] | false | 0.036792 | 0.072586 | 0.506874 | [
"s859001772",
"s152168386"
] |
u078349616 | p03698 | python | s456733447 | s282575389 | 32 | 17 | 3,828 | 2,940 | Accepted | Accepted | 46.88 | from collections import defaultdict
S = eval(input())
d = defaultdict(int)
for i in range(len(S)):
d[S[i]] += 1
for val in list(d.values()):
if val != 1:
print("no")
exit()
print("yes") | L = list(eval(input()))
S = set(L)
if len(L) == len(S):
print("yes")
else:
print("no") | 10 | 6 | 194 | 89 | from collections import defaultdict
S = eval(input())
d = defaultdict(int)
for i in range(len(S)):
d[S[i]] += 1
for val in list(d.values()):
if val != 1:
print("no")
exit()
print("yes")
| L = list(eval(input()))
S = set(L)
if len(L) == len(S):
print("yes")
else:
print("no")
| false | 40 | [
"-from collections import defaultdict",
"-",
"-S = eval(input())",
"-d = defaultdict(int)",
"-for i in range(len(S)):",
"- d[S[i]] += 1",
"-for val in list(d.values()):",
"- if val != 1:",
"- print(\"no\")",
"- exit()",
"-print(\"yes\")",
"+L = list(eval(input()))",
"+S = set(L)",
"+if len(L) == len(S):",
"+ print(\"yes\")",
"+else:",
"+ print(\"no\")"
] | false | 0.037349 | 0.035333 | 1.057064 | [
"s456733447",
"s282575389"
] |
u490642448 | p04017 | python | s133488363 | s268470669 | 817 | 651 | 209,596 | 159,884 | Accepted | Accepted | 20.32 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import bisect
n = int(readline())
x = list(map(int,readline().split()))
l = int(readline())
q = int(readline())
ab = list(map(int,read().split()))
dbl_l = [[] for _ in range(n)]
dbl_r = [[] for _ in range(n)]
for dbl,xx in zip([dbl_l,dbl_r],[x,x[::-1]]):
j = 0
for i in range(n):
while(j < n-1):
if(abs(xx[j+1] - xx[i]) > l):
break
j += 1
dbl[i].append(j)
for i in range(30):
if(dbl[0][-1] == n-1):
break
for j in range(n):
dbl[j].append(dbl[ dbl[j][i] ][i])
def calc(a,b,dbl):
if(dbl[a][0] >= b):
return 1
ind = bisect.bisect_left(dbl[a],b) - 1
return 2**ind + calc(dbl[a][ind],b,dbl)
ans = []
it = iter(ab)
for a,b in zip(it,it):
a -= 1
b -= 1
if(a<b):
ans.append(calc(a,b,dbl_l))
else:
a,b = n-1-a,n-1-b
ans.append(calc(a,b,dbl_r))
print(('\n'.join(map(str,ans)))) | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import bisect
n = int(readline())
x = list(map(int,readline().split()))
l = int(readline())
q = int(readline())
ab = list(map(int,read().split()))
dbl = [[] for _ in range(n)]
j = 0
for i in range(n):
while(j < n-1):
if(abs(x[j+1] - x[i]) > l):
break
j += 1
dbl[i].append(j)
for i in range(30):
if(dbl[0][-1] == n-1):
break
for j in range(n):
dbl[j].append(dbl[ dbl[j][i] ][i])
def calc(a,b):
if(dbl[a][0] >= b):
return 1
ind = bisect.bisect_left(dbl[a],b) - 1
return 2**ind + calc(dbl[a][ind],b)
ans = []
it = iter(ab)
for a,b in zip(it,it):
a -= 1
b -= 1
a,b = min(a,b),max(a,b)
ans.append(calc(a,b))
print(('\n'.join(map(str,ans)))) | 47 | 42 | 1,101 | 892 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import bisect
n = int(readline())
x = list(map(int, readline().split()))
l = int(readline())
q = int(readline())
ab = list(map(int, read().split()))
dbl_l = [[] for _ in range(n)]
dbl_r = [[] for _ in range(n)]
for dbl, xx in zip([dbl_l, dbl_r], [x, x[::-1]]):
j = 0
for i in range(n):
while j < n - 1:
if abs(xx[j + 1] - xx[i]) > l:
break
j += 1
dbl[i].append(j)
for i in range(30):
if dbl[0][-1] == n - 1:
break
for j in range(n):
dbl[j].append(dbl[dbl[j][i]][i])
def calc(a, b, dbl):
if dbl[a][0] >= b:
return 1
ind = bisect.bisect_left(dbl[a], b) - 1
return 2**ind + calc(dbl[a][ind], b, dbl)
ans = []
it = iter(ab)
for a, b in zip(it, it):
a -= 1
b -= 1
if a < b:
ans.append(calc(a, b, dbl_l))
else:
a, b = n - 1 - a, n - 1 - b
ans.append(calc(a, b, dbl_r))
print(("\n".join(map(str, ans))))
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import bisect
n = int(readline())
x = list(map(int, readline().split()))
l = int(readline())
q = int(readline())
ab = list(map(int, read().split()))
dbl = [[] for _ in range(n)]
j = 0
for i in range(n):
while j < n - 1:
if abs(x[j + 1] - x[i]) > l:
break
j += 1
dbl[i].append(j)
for i in range(30):
if dbl[0][-1] == n - 1:
break
for j in range(n):
dbl[j].append(dbl[dbl[j][i]][i])
def calc(a, b):
if dbl[a][0] >= b:
return 1
ind = bisect.bisect_left(dbl[a], b) - 1
return 2**ind + calc(dbl[a][ind], b)
ans = []
it = iter(ab)
for a, b in zip(it, it):
a -= 1
b -= 1
a, b = min(a, b), max(a, b)
ans.append(calc(a, b))
print(("\n".join(map(str, ans))))
| false | 10.638298 | [
"-dbl_l = [[] for _ in range(n)]",
"-dbl_r = [[] for _ in range(n)]",
"-for dbl, xx in zip([dbl_l, dbl_r], [x, x[::-1]]):",
"- j = 0",
"- for i in range(n):",
"- while j < n - 1:",
"- if abs(xx[j + 1] - xx[i]) > l:",
"- break",
"- j += 1",
"- dbl[i].append(j)",
"- for i in range(30):",
"- if dbl[0][-1] == n - 1:",
"+dbl = [[] for _ in range(n)]",
"+j = 0",
"+for i in range(n):",
"+ while j < n - 1:",
"+ if abs(x[j + 1] - x[i]) > l:",
"- for j in range(n):",
"- dbl[j].append(dbl[dbl[j][i]][i])",
"+ j += 1",
"+ dbl[i].append(j)",
"+for i in range(30):",
"+ if dbl[0][-1] == n - 1:",
"+ break",
"+ for j in range(n):",
"+ dbl[j].append(dbl[dbl[j][i]][i])",
"-def calc(a, b, dbl):",
"+def calc(a, b):",
"- return 2**ind + calc(dbl[a][ind], b, dbl)",
"+ return 2**ind + calc(dbl[a][ind], b)",
"- if a < b:",
"- ans.append(calc(a, b, dbl_l))",
"- else:",
"- a, b = n - 1 - a, n - 1 - b",
"- ans.append(calc(a, b, dbl_r))",
"+ a, b = min(a, b), max(a, b)",
"+ ans.append(calc(a, b))"
] | false | 0.109042 | 0.118075 | 0.923499 | [
"s133488363",
"s268470669"
] |
u620084012 | p03997 | python | s075143584 | s043317871 | 39 | 18 | 3,064 | 2,940 | Accepted | Accepted | 53.85 | a = int(eval(input()))
b = int(eval(input()))
h = int(eval(input()))
print(((a+b)*h//2)) | a = int(eval(input()))
b = int(eval(input()))
h = int(eval(input()))
print((((a+b)*h)//2))
| 5 | 4 | 73 | 74 | a = int(eval(input()))
b = int(eval(input()))
h = int(eval(input()))
print(((a + b) * h // 2))
| a = int(eval(input()))
b = int(eval(input()))
h = int(eval(input()))
print((((a + b) * h) // 2))
| false | 20 | [
"-print(((a + b) * h // 2))",
"+print((((a + b) * h) // 2))"
] | false | 0.038455 | 0.007387 | 5.206125 | [
"s075143584",
"s043317871"
] |
u788068140 | p03111 | python | s160802561 | s654300935 | 508 | 314 | 4,624 | 5,020 | Accepted | Accepted | 38.19 | import math
N, A, B, C = 5, 100, 90, 80
ARR = [
98,
40,
30,
21,
80
]
# N,A,B,C = 8, 100, 90, 80
# ARR = [
# 100,
# 100,
# 90,
# 90,
# 90,
# 80,
# 80,
# 80,
# ]
# N,A,B,C,= 8, 1000, 800, 100
# ARR = [
# 300,
# 333,
# 400,
# 444,
# 500,
# 555,
# 600,
# 666,
# ]
N,A,B,C = list(map(int,input().split()))
ARR = []
for i in range(N):
ARR.append(int(eval(input())))
def calculate(n, arr, a, b, c):
result = []
for i in range(4 ** n):
materialA = set()
materialB = set()
materialC = set()
materialNone = set()
for j in range(n):
s = (i >> 2 * j & 1)
t = (i >> (2 * j + 1) & 1)
if (s == 0) and (t == 0):
materialA.add(j)
if (s == 1) and (t == 0):
materialB.add(j)
if (s == 0) and (t == 1):
materialC.add(j)
if (s == 1) and (t == 1):
materialNone.add(j)
ok, mp = judge(n, arr, a, b, c, materialA, materialB, materialC, materialNone)
if ok:
result.append(mp)
print((int(min(result))))
def judge(n, arr, a, b, c, materialA, materialB, materialC, materialNone):
if materialNone == n:
return False, -1
if len(materialA) == 0:
return False, -1
if len(materialB) == 0:
return False, -1
if len(materialC) == 0:
return False, -1
mpA = 0
a = a - calculateResult(arr,materialA)
mpA += math.fabs(a)
if len(materialA) > 1:
mpA += 10 * (len(materialA) - 1)
mpB = 0
b = b - calculateResult(arr,materialB)
mpB += math.fabs(b)
if len(materialB) > 1:
mpB += 10 * (len(materialB) - 1)
mpC = 0
c = c - calculateResult(arr,materialC)
mpC += math.fabs(c)
if len(materialC) > 1:
mpC += 10 * (len(materialC) - 1)
return True,mpA+mpB+mpC
def calculateResult(arr,material):
result = 0
for m in material:
result = result + arr[m]
return result
calculate(N, ARR, A, B, C)
| import math
# N, A, B, C = 7, 100, 90, 80
# ARR = [
# 98,
# 40,
# 30,
# 21,
# 80,
# 25,
# 100
# ]
N, A, B, C = list(map(int, input().split()))
ARR = []
for i in range(N):
ARR.append(int(eval(input())))
result = []
def dfs(deep, crr):
if deep == N:
ok, res = calculate(crr)
if ok:
result.append(int(res))
else:
for i in range(4):
crr[deep] = i
dfs(deep + 1, crr)
def calculate(crr):
sA = []
sB = []
sC = []
sN = []
for index, cr in enumerate(crr):
if cr == 0:
sN.append(ARR[index])
if cr == 1:
sA.append(ARR[index])
if cr == 2:
sB.append(ARR[index])
if cr == 3:
sC.append(ARR[index])
if len(sA) == 0:
return False, -1
if len(sB) == 0:
return False, -1
if len(sC) == 0:
return False, -1
s1 = (len(sA) - 1) * 10 + math.fabs(sum(sA) - A)
s2 = (len(sB) - 1) * 10 + math.fabs(sum(sB) - B)
s3 = (len(sC) - 1) * 10 + math.fabs(sum(sC) - C)
return True, s1 + s2 + s3
dfs(0, [0 for i in range(N)])
print((min(result))) | 107 | 63 | 2,195 | 1,220 | import math
N, A, B, C = 5, 100, 90, 80
ARR = [98, 40, 30, 21, 80]
# N,A,B,C = 8, 100, 90, 80
# ARR = [
# 100,
# 100,
# 90,
# 90,
# 90,
# 80,
# 80,
# 80,
# ]
# N,A,B,C,= 8, 1000, 800, 100
# ARR = [
# 300,
# 333,
# 400,
# 444,
# 500,
# 555,
# 600,
# 666,
# ]
N, A, B, C = list(map(int, input().split()))
ARR = []
for i in range(N):
ARR.append(int(eval(input())))
def calculate(n, arr, a, b, c):
result = []
for i in range(4**n):
materialA = set()
materialB = set()
materialC = set()
materialNone = set()
for j in range(n):
s = i >> 2 * j & 1
t = i >> (2 * j + 1) & 1
if (s == 0) and (t == 0):
materialA.add(j)
if (s == 1) and (t == 0):
materialB.add(j)
if (s == 0) and (t == 1):
materialC.add(j)
if (s == 1) and (t == 1):
materialNone.add(j)
ok, mp = judge(n, arr, a, b, c, materialA, materialB, materialC, materialNone)
if ok:
result.append(mp)
print((int(min(result))))
def judge(n, arr, a, b, c, materialA, materialB, materialC, materialNone):
if materialNone == n:
return False, -1
if len(materialA) == 0:
return False, -1
if len(materialB) == 0:
return False, -1
if len(materialC) == 0:
return False, -1
mpA = 0
a = a - calculateResult(arr, materialA)
mpA += math.fabs(a)
if len(materialA) > 1:
mpA += 10 * (len(materialA) - 1)
mpB = 0
b = b - calculateResult(arr, materialB)
mpB += math.fabs(b)
if len(materialB) > 1:
mpB += 10 * (len(materialB) - 1)
mpC = 0
c = c - calculateResult(arr, materialC)
mpC += math.fabs(c)
if len(materialC) > 1:
mpC += 10 * (len(materialC) - 1)
return True, mpA + mpB + mpC
def calculateResult(arr, material):
result = 0
for m in material:
result = result + arr[m]
return result
calculate(N, ARR, A, B, C)
| import math
# N, A, B, C = 7, 100, 90, 80
# ARR = [
# 98,
# 40,
# 30,
# 21,
# 80,
# 25,
# 100
# ]
N, A, B, C = list(map(int, input().split()))
ARR = []
for i in range(N):
ARR.append(int(eval(input())))
result = []
def dfs(deep, crr):
if deep == N:
ok, res = calculate(crr)
if ok:
result.append(int(res))
else:
for i in range(4):
crr[deep] = i
dfs(deep + 1, crr)
def calculate(crr):
sA = []
sB = []
sC = []
sN = []
for index, cr in enumerate(crr):
if cr == 0:
sN.append(ARR[index])
if cr == 1:
sA.append(ARR[index])
if cr == 2:
sB.append(ARR[index])
if cr == 3:
sC.append(ARR[index])
if len(sA) == 0:
return False, -1
if len(sB) == 0:
return False, -1
if len(sC) == 0:
return False, -1
s1 = (len(sA) - 1) * 10 + math.fabs(sum(sA) - A)
s2 = (len(sB) - 1) * 10 + math.fabs(sum(sB) - B)
s3 = (len(sC) - 1) * 10 + math.fabs(sum(sC) - C)
return True, s1 + s2 + s3
dfs(0, [0 for i in range(N)])
print((min(result)))
| false | 41.121495 | [
"-N, A, B, C = 5, 100, 90, 80",
"-ARR = [98, 40, 30, 21, 80]",
"-# N,A,B,C = 8, 100, 90, 80",
"+# N, A, B, C = 7, 100, 90, 80",
"-# 100,",
"-# 100,",
"-# 90,",
"-# 90,",
"-# 90,",
"+# 98,",
"+# 40,",
"+# 30,",
"+# 21,",
"-# 80,",
"-# 80,",
"-# ]",
"-# N,A,B,C,= 8, 1000, 800, 100",
"-# ARR = [",
"-# 300,",
"-# 333,",
"-# 400,",
"-# 444,",
"-# 500,",
"-# 555,",
"-# 600,",
"-# 666,",
"+# 25,",
"+# 100",
"+result = []",
"-def calculate(n, arr, a, b, c):",
"- result = []",
"- for i in range(4**n):",
"- materialA = set()",
"- materialB = set()",
"- materialC = set()",
"- materialNone = set()",
"- for j in range(n):",
"- s = i >> 2 * j & 1",
"- t = i >> (2 * j + 1) & 1",
"- if (s == 0) and (t == 0):",
"- materialA.add(j)",
"- if (s == 1) and (t == 0):",
"- materialB.add(j)",
"- if (s == 0) and (t == 1):",
"- materialC.add(j)",
"- if (s == 1) and (t == 1):",
"- materialNone.add(j)",
"- ok, mp = judge(n, arr, a, b, c, materialA, materialB, materialC, materialNone)",
"+def dfs(deep, crr):",
"+ if deep == N:",
"+ ok, res = calculate(crr)",
"- result.append(mp)",
"- print((int(min(result))))",
"+ result.append(int(res))",
"+ else:",
"+ for i in range(4):",
"+ crr[deep] = i",
"+ dfs(deep + 1, crr)",
"-def judge(n, arr, a, b, c, materialA, materialB, materialC, materialNone):",
"- if materialNone == n:",
"+def calculate(crr):",
"+ sA = []",
"+ sB = []",
"+ sC = []",
"+ sN = []",
"+ for index, cr in enumerate(crr):",
"+ if cr == 0:",
"+ sN.append(ARR[index])",
"+ if cr == 1:",
"+ sA.append(ARR[index])",
"+ if cr == 2:",
"+ sB.append(ARR[index])",
"+ if cr == 3:",
"+ sC.append(ARR[index])",
"+ if len(sA) == 0:",
"- if len(materialA) == 0:",
"+ if len(sB) == 0:",
"- if len(materialB) == 0:",
"+ if len(sC) == 0:",
"- if len(materialC) == 0:",
"- return False, -1",
"- mpA = 0",
"- a = a - calculateResult(arr, materialA)",
"- mpA += math.fabs(a)",
"- if len(materialA) > 1:",
"- mpA += 10 * (len(materialA) - 1)",
"- mpB = 0",
"- b = b - calculateResult(arr, materialB)",
"- mpB += math.fabs(b)",
"- if len(materialB) > 1:",
"- mpB += 10 * (len(materialB) - 1)",
"- mpC = 0",
"- c = c - calculateResult(arr, materialC)",
"- mpC += math.fabs(c)",
"- if len(materialC) > 1:",
"- mpC += 10 * (len(materialC) - 1)",
"- return True, mpA + mpB + mpC",
"+ s1 = (len(sA) - 1) * 10 + math.fabs(sum(sA) - A)",
"+ s2 = (len(sB) - 1) * 10 + math.fabs(sum(sB) - B)",
"+ s3 = (len(sC) - 1) * 10 + math.fabs(sum(sC) - C)",
"+ return True, s1 + s2 + s3",
"-def calculateResult(arr, material):",
"- result = 0",
"- for m in material:",
"- result = result + arr[m]",
"- return result",
"-",
"-",
"-calculate(N, ARR, A, B, C)",
"+dfs(0, [0 for i in range(N)])",
"+print((min(result)))"
] | false | 0.588476 | 1.014255 | 0.580205 | [
"s160802561",
"s654300935"
] |
u780475861 | p02794 | python | s293643117 | s831590343 | 1,962 | 315 | 216,660 | 62,640 | Accepted | Accepted | 83.94 | from collections import defaultdict
def dfs(s, t):
visited = 0
q = [(s, 0)]
while q:
v, used = q.pop()
if v == t:
return used
visited |= used
for lb, u in graph[v]:
if lb & visited:
continue
q.append((u, used | lb))
n = int(eval(input()))
graph = [[] for _ in range(n + 1)]
for i in range(n - 1):
a, b = list(map(int, input().split()))
lb = 1 << i
graph[a].append((lb, b))
graph[b].append((lb, a))
conditions = []
m = int(eval(input()))
for i in range(m):
u, v = list(map(int, input().split()))
conditions.append(dfs(u, v))
link_conditions = [int(''.join(b), 2) for b in zip(*list(map(('{:0' + str(n - 1) + 'b}').format, conditions)))]
dp = defaultdict(int)
dp[0] = 1
for lc in link_conditions:
for fulfilled, pattern in list(dp.items()):
dp[fulfilled | lc] += pattern
print((dp[(1 << m) - 1]))
| # https://atcoder.jp/contests/abc152/submissions/9619555
import numpy as np
import sys
readline = sys.stdin.readline
N = int(readline())
graph = [[] for _ in range(N + 1)]
for i in range(N - 1):
a, b = list(map(int, readline().split()))
lb = 1 << i
graph[a].append((lb, b))
graph[b].append((lb, a))
M = int(readline())
def get_path(U, V):
visited = 0
q = [(U, 0)]
while q:
v, used = q.pop()
if v == V:
return used
visited |= used
for lb, u in graph[v]:
if lb & visited:
continue
q.append((u, used | lb))
condition_path = []
for i in range(M):
u, v = list(map(int, readline().split()))
condition_path.append(get_path(u, v))
def popcnt(n):
c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)
c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)
c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f)
c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff)
c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff)
c = (c & 0x00000000ffffffff) + ((c >> 32) & 0x00000000ffffffff)
return c
sgn = np.where(popcnt(np.arange(1 << M)) % 2, -1, 1)
S = np.zeros(1 << M, np.int64)
for i in range(M):
S[1 << i:1 << (i + 1)] = S[:1 << i] | condition_path[i]
n_edges = popcnt(S)
x = 1 << (N - 1 - n_edges)
answer = np.sum(x * sgn)
print(answer) | 39 | 57 | 940 | 1,480 | from collections import defaultdict
def dfs(s, t):
visited = 0
q = [(s, 0)]
while q:
v, used = q.pop()
if v == t:
return used
visited |= used
for lb, u in graph[v]:
if lb & visited:
continue
q.append((u, used | lb))
n = int(eval(input()))
graph = [[] for _ in range(n + 1)]
for i in range(n - 1):
a, b = list(map(int, input().split()))
lb = 1 << i
graph[a].append((lb, b))
graph[b].append((lb, a))
conditions = []
m = int(eval(input()))
for i in range(m):
u, v = list(map(int, input().split()))
conditions.append(dfs(u, v))
link_conditions = [
int("".join(b), 2)
for b in zip(*list(map(("{:0" + str(n - 1) + "b}").format, conditions)))
]
dp = defaultdict(int)
dp[0] = 1
for lc in link_conditions:
for fulfilled, pattern in list(dp.items()):
dp[fulfilled | lc] += pattern
print((dp[(1 << m) - 1]))
| # https://atcoder.jp/contests/abc152/submissions/9619555
import numpy as np
import sys
readline = sys.stdin.readline
N = int(readline())
graph = [[] for _ in range(N + 1)]
for i in range(N - 1):
a, b = list(map(int, readline().split()))
lb = 1 << i
graph[a].append((lb, b))
graph[b].append((lb, a))
M = int(readline())
def get_path(U, V):
visited = 0
q = [(U, 0)]
while q:
v, used = q.pop()
if v == V:
return used
visited |= used
for lb, u in graph[v]:
if lb & visited:
continue
q.append((u, used | lb))
condition_path = []
for i in range(M):
u, v = list(map(int, readline().split()))
condition_path.append(get_path(u, v))
def popcnt(n):
c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)
c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)
c = (c & 0x0F0F0F0F0F0F0F0F) + ((c >> 4) & 0x0F0F0F0F0F0F0F0F)
c = (c & 0x00FF00FF00FF00FF) + ((c >> 8) & 0x00FF00FF00FF00FF)
c = (c & 0x0000FFFF0000FFFF) + ((c >> 16) & 0x0000FFFF0000FFFF)
c = (c & 0x00000000FFFFFFFF) + ((c >> 32) & 0x00000000FFFFFFFF)
return c
sgn = np.where(popcnt(np.arange(1 << M)) % 2, -1, 1)
S = np.zeros(1 << M, np.int64)
for i in range(M):
S[1 << i : 1 << (i + 1)] = S[: 1 << i] | condition_path[i]
n_edges = popcnt(S)
x = 1 << (N - 1 - n_edges)
answer = np.sum(x * sgn)
print(answer)
| false | 31.578947 | [
"-from collections import defaultdict",
"+# https://atcoder.jp/contests/abc152/submissions/9619555",
"+import numpy as np",
"+import sys",
"+",
"+readline = sys.stdin.readline",
"+N = int(readline())",
"+graph = [[] for _ in range(N + 1)]",
"+for i in range(N - 1):",
"+ a, b = list(map(int, readline().split()))",
"+ lb = 1 << i",
"+ graph[a].append((lb, b))",
"+ graph[b].append((lb, a))",
"+M = int(readline())",
"-def dfs(s, t):",
"+def get_path(U, V):",
"- q = [(s, 0)]",
"+ q = [(U, 0)]",
"- if v == t:",
"+ if v == V:",
"-n = int(eval(input()))",
"-graph = [[] for _ in range(n + 1)]",
"-for i in range(n - 1):",
"- a, b = list(map(int, input().split()))",
"- lb = 1 << i",
"- graph[a].append((lb, b))",
"- graph[b].append((lb, a))",
"-conditions = []",
"-m = int(eval(input()))",
"-for i in range(m):",
"- u, v = list(map(int, input().split()))",
"- conditions.append(dfs(u, v))",
"-link_conditions = [",
"- int(\"\".join(b), 2)",
"- for b in zip(*list(map((\"{:0\" + str(n - 1) + \"b}\").format, conditions)))",
"-]",
"-dp = defaultdict(int)",
"-dp[0] = 1",
"-for lc in link_conditions:",
"- for fulfilled, pattern in list(dp.items()):",
"- dp[fulfilled | lc] += pattern",
"-print((dp[(1 << m) - 1]))",
"+condition_path = []",
"+for i in range(M):",
"+ u, v = list(map(int, readline().split()))",
"+ condition_path.append(get_path(u, v))",
"+",
"+",
"+def popcnt(n):",
"+ c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)",
"+ c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)",
"+ c = (c & 0x0F0F0F0F0F0F0F0F) + ((c >> 4) & 0x0F0F0F0F0F0F0F0F)",
"+ c = (c & 0x00FF00FF00FF00FF) + ((c >> 8) & 0x00FF00FF00FF00FF)",
"+ c = (c & 0x0000FFFF0000FFFF) + ((c >> 16) & 0x0000FFFF0000FFFF)",
"+ c = (c & 0x00000000FFFFFFFF) + ((c >> 32) & 0x00000000FFFFFFFF)",
"+ return c",
"+",
"+",
"+sgn = np.where(popcnt(np.arange(1 << M)) % 2, -1, 1)",
"+S = np.zeros(1 << M, np.int64)",
"+for i in range(M):",
"+ S[1 << i : 1 << (i + 1)] = S[: 1 << i] | condition_path[i]",
"+n_edges = popcnt(S)",
"+x = 1 << (N - 1 - n_edges)",
"+answer = np.sum(x * sgn)",
"+print(answer)"
] | false | 0.066402 | 0.247525 | 0.268263 | [
"s293643117",
"s831590343"
] |
u088552457 | p03043 | python | s297474747 | s271080958 | 334 | 69 | 68,204 | 67,820 | Accepted | Accepted | 79.34 | def count_section_by_zero(data):
count = 0
flg = False
start = 0
for i, d in enumerate(data):
if flg is False and d != 0:
count += 1
flg = True
if d == 0:
flg = False
return count
def input_list():
return list(map(int, input().split()))
def input_list_str():
return list(map(str, input().split()))
def lcm_base(x, y):
return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
return reduce(lcm_base, numbers, 1)
def gcd(*numbers):
return reduce(fractions.gcd, numbers)
def gcd_list(numbers):
return reduce(fractions.gcd, numbers)
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
# 2で割り切れる回数
def divide_two(arg):
c = 0
while True:
if c >= 2:
break
if arg % 2 != 0:
break
arg //= 2
c += 1
return c
# 素因数分解
def prime_factorize(n):
a = []
while n % 2 == 0:
a.append(2)
n //= 2
f = 3
while f * f <= n:
if n % f == 0:
a.append(f)
n //= f
else:
f += 2
if n != 1:
a.append(n)
return a
def main():
n, k = input_list()
ans = 0
for i in range(1, n+1):
t = 1.0
while i < k:
i *= 2
t /= 2
ans += t
print((ans/n))
import math
import fractions
import collections
import itertools
from functools import reduce
main() | # import sys
# input = sys.stdin.readline
import collections
import itertools
def main():
n, k = input_list()
res = 0.0
for v in range(n):
i = v + 1
t = 1.0
ii = i
while ii < k:
ii *= 2
t /= 2.0
res += t
res /= n
print(res)
def input_list():
return list(map(int, input().split()))
def input_list_str():
return list(map(str, input().split()))
if __name__ == "__main__":
main()
| 80 | 31 | 1,479 | 510 | def count_section_by_zero(data):
count = 0
flg = False
start = 0
for i, d in enumerate(data):
if flg is False and d != 0:
count += 1
flg = True
if d == 0:
flg = False
return count
def input_list():
return list(map(int, input().split()))
def input_list_str():
return list(map(str, input().split()))
def lcm_base(x, y):
return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
return reduce(lcm_base, numbers, 1)
def gcd(*numbers):
return reduce(fractions.gcd, numbers)
def gcd_list(numbers):
return reduce(fractions.gcd, numbers)
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
# 2で割り切れる回数
def divide_two(arg):
c = 0
while True:
if c >= 2:
break
if arg % 2 != 0:
break
arg //= 2
c += 1
return c
# 素因数分解
def prime_factorize(n):
a = []
while n % 2 == 0:
a.append(2)
n //= 2
f = 3
while f * f <= n:
if n % f == 0:
a.append(f)
n //= f
else:
f += 2
if n != 1:
a.append(n)
return a
def main():
n, k = input_list()
ans = 0
for i in range(1, n + 1):
t = 1.0
while i < k:
i *= 2
t /= 2
ans += t
print((ans / n))
import math
import fractions
import collections
import itertools
from functools import reduce
main()
| # import sys
# input = sys.stdin.readline
import collections
import itertools
def main():
n, k = input_list()
res = 0.0
for v in range(n):
i = v + 1
t = 1.0
ii = i
while ii < k:
ii *= 2
t /= 2.0
res += t
res /= n
print(res)
def input_list():
return list(map(int, input().split()))
def input_list_str():
return list(map(str, input().split()))
if __name__ == "__main__":
main()
| false | 61.25 | [
"-def count_section_by_zero(data):",
"- count = 0",
"- flg = False",
"- start = 0",
"- for i, d in enumerate(data):",
"- if flg is False and d != 0:",
"- count += 1",
"- flg = True",
"- if d == 0:",
"- flg = False",
"- return count",
"+# import sys",
"+# input = sys.stdin.readline",
"+import collections",
"+import itertools",
"+",
"+",
"+def main():",
"+ n, k = input_list()",
"+ res = 0.0",
"+ for v in range(n):",
"+ i = v + 1",
"+ t = 1.0",
"+ ii = i",
"+ while ii < k:",
"+ ii *= 2",
"+ t /= 2.0",
"+ res += t",
"+ res /= n",
"+ print(res)",
"-def lcm_base(x, y):",
"- return (x * y) // fractions.gcd(x, y)",
"-",
"-",
"-def lcm_list(numbers):",
"- return reduce(lcm_base, numbers, 1)",
"-",
"-",
"-def gcd(*numbers):",
"- return reduce(fractions.gcd, numbers)",
"-",
"-",
"-def gcd_list(numbers):",
"- return reduce(fractions.gcd, numbers)",
"-",
"-",
"-def combinations_count(n, r):",
"- return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))",
"-",
"-",
"-# 2で割り切れる回数",
"-def divide_two(arg):",
"- c = 0",
"- while True:",
"- if c >= 2:",
"- break",
"- if arg % 2 != 0:",
"- break",
"- arg //= 2",
"- c += 1",
"- return c",
"-",
"-",
"-# 素因数分解",
"-def prime_factorize(n):",
"- a = []",
"- while n % 2 == 0:",
"- a.append(2)",
"- n //= 2",
"- f = 3",
"- while f * f <= n:",
"- if n % f == 0:",
"- a.append(f)",
"- n //= f",
"- else:",
"- f += 2",
"- if n != 1:",
"- a.append(n)",
"- return a",
"-",
"-",
"-def main():",
"- n, k = input_list()",
"- ans = 0",
"- for i in range(1, n + 1):",
"- t = 1.0",
"- while i < k:",
"- i *= 2",
"- t /= 2",
"- ans += t",
"- print((ans / n))",
"-",
"-",
"-import math",
"-import fractions",
"-import collections",
"-import itertools",
"-from functools import reduce",
"-",
"-main()",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.048032 | 0.051075 | 0.940421 | [
"s297474747",
"s271080958"
] |
u499381410 | p02974 | python | s712480604 | s410408048 | 644 | 533 | 238,984 | 96,220 | Accepted | Accepted | 17.24 | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string
INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7
n, k = LI()
dp = [[[0]*n**2*4 for _ in range(n+1)] for _ in range(n+1)]
dp[0][0][0] = 1
for i in range(n):
for j in range(i+1):
for l in range(k+1):
dp[i+1][j+1][l+2*(j+1)] += dp[i][j][l]
dp[i+1][j+1][l+2*(j+1)]%=mod
dp[i+1][j][l+2*j] += dp[i][j][l]*(j*2+1)
dp[i+1][j][l+2 * j] %= mod
if j!= 0:
dp[i+1][j-1][l+(j-1)*2] += dp[i][j][l]*j*j
dp[i+1][j-1][l+(j-1)*2]%=mod
print((dp[n][0][k]%mod))
| from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string
INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7
n, k = LI()
dp = [[[0]*(k+2*(n+1)) for _ in range(n+1)] for _ in range(n+1)]
dp[0][0][0] = 1
for i in range(n):
for j in range(i+1):
for l in range(k+1):
dp[i+1][j+1][l+2*(j+1)] += dp[i][j][l]
dp[i+1][j+1][l+2*(j+1)]%=mod
dp[i+1][j][l+2*j] += dp[i][j][l]*(j*2+1)
dp[i+1][j][l+2 * j] %= mod
if j!= 0:
dp[i+1][j-1][l+(j-1)*2] += dp[i][j][l]*j*j
dp[i+1][j-1][l+(j-1)*2]%=mod
print((dp[n][0][k]%mod))
| 43 | 43 | 1,320 | 1,325 | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string
INF = float("inf")
def LI():
return list(map(int, sys.stdin.readline().split()))
def I():
return int(sys.stdin.readline())
def LS():
return sys.stdin.readline().split()
def S():
return sys.stdin.readline().strip()
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
def SRL(n):
return [list(S()) for i in range(n)]
def MSRL(n):
return [[int(j) for j in list(S())] for i in range(n)]
mod = 10**9 + 7
n, k = LI()
dp = [[[0] * n**2 * 4 for _ in range(n + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
for i in range(n):
for j in range(i + 1):
for l in range(k + 1):
dp[i + 1][j + 1][l + 2 * (j + 1)] += dp[i][j][l]
dp[i + 1][j + 1][l + 2 * (j + 1)] %= mod
dp[i + 1][j][l + 2 * j] += dp[i][j][l] * (j * 2 + 1)
dp[i + 1][j][l + 2 * j] %= mod
if j != 0:
dp[i + 1][j - 1][l + (j - 1) * 2] += dp[i][j][l] * j * j
dp[i + 1][j - 1][l + (j - 1) * 2] %= mod
print((dp[n][0][k] % mod))
| from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string
INF = float("inf")
def LI():
return list(map(int, sys.stdin.readline().split()))
def I():
return int(sys.stdin.readline())
def LS():
return sys.stdin.readline().split()
def S():
return sys.stdin.readline().strip()
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
def SRL(n):
return [list(S()) for i in range(n)]
def MSRL(n):
return [[int(j) for j in list(S())] for i in range(n)]
mod = 10**9 + 7
n, k = LI()
dp = [[[0] * (k + 2 * (n + 1)) for _ in range(n + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
for i in range(n):
for j in range(i + 1):
for l in range(k + 1):
dp[i + 1][j + 1][l + 2 * (j + 1)] += dp[i][j][l]
dp[i + 1][j + 1][l + 2 * (j + 1)] %= mod
dp[i + 1][j][l + 2 * j] += dp[i][j][l] * (j * 2 + 1)
dp[i + 1][j][l + 2 * j] %= mod
if j != 0:
dp[i + 1][j - 1][l + (j - 1) * 2] += dp[i][j][l] * j * j
dp[i + 1][j - 1][l + (j - 1) * 2] %= mod
print((dp[n][0][k] % mod))
| false | 0 | [
"-dp = [[[0] * n**2 * 4 for _ in range(n + 1)] for _ in range(n + 1)]",
"+dp = [[[0] * (k + 2 * (n + 1)) for _ in range(n + 1)] for _ in range(n + 1)]"
] | false | 0.215529 | 0.056509 | 3.814053 | [
"s712480604",
"s410408048"
] |