user_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 1
value | submission_id_v0 stringlengths 10 10 | submission_id_v1 stringlengths 10 10 | cpu_time_v0 int64 10 38.3k | cpu_time_v1 int64 0 24.7k | memory_v0 int64 2.57k 1.02M | memory_v1 int64 2.57k 869k | status_v0 stringclasses 1
value | status_v1 stringclasses 1
value | improvement_frac float64 7.51 100 | input stringlengths 20 4.55k | target stringlengths 17 3.34k | code_v0_loc int64 1 148 | code_v1_loc int64 1 184 | code_v0_num_chars int64 13 4.55k | code_v1_num_chars int64 14 3.34k | code_v0_no_empty_lines stringlengths 21 6.88k | code_v1_no_empty_lines stringlengths 20 4.93k | code_same bool 1
class | relative_loc_diff_percent float64 0 79.8 | diff list | diff_only_import_comment bool 1
class | measured_runtime_v0 float64 0.01 4.45 | measured_runtime_v1 float64 0.01 4.31 | runtime_lift float64 0 359 | key list |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u004423772 | p02888 | python | s110015405 | s314006259 | 760 | 248 | 42,844 | 40,816 | Accepted | Accepted | 67.37 | import sys
input = sys.stdin.readline
import bisect
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):
idx = bisect.bisect_left(L, L[i]+L[j], j+1, N)
ans += idx-j-1
pri... | import sys
input = sys.stdin.readline
import bisect
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
MAX = 2000
C = [0] * MAX
S = [0] * (MAX+1)
for val in L:
C[val] += 1
for i in range(MAX):
S[i+1] = C[i] + S[i]
ans = 0
... | 15 | 26 | 361 | 650 | import sys
input = sys.stdin.readline
import bisect
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):
idx = bisect.bisect_left(L, L[i] + L[j], j + 1, N)
ans += idx - j - 1
... | import sys
input = sys.stdin.readline
import bisect
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
MAX = 2000
C = [0] * MAX
S = [0] * (MAX + 1)
for val in L:
C[val] += 1
for i in range(MAX):
S[i + 1] = C[i] + S[i]
ans = 0
for i ... | false | 42.307692 | [
"+ MAX = 2000",
"+ C = [0] * MAX",
"+ S = [0] * (MAX + 1)",
"+ for val in L:",
"+ C[val] += 1",
"+ for i in range(MAX):",
"+ S[i + 1] = C[i] + S[i]",
"- for i in range(N - 2):",
"- for j in range(i + 1, N - 1):",
"- idx = bisect.bisect_left(L, L[i]... | false | 0.059819 | 0.042826 | 1.396796 | [
"s110015405",
"s314006259"
] |
u056626722 | p02595 | python | s054027317 | s660025405 | 440 | 386 | 9,116 | 9,132 | Accepted | Accepted | 12.27 | n,d = list(map(int, input().split()))
dotCount = 0
square_d = d*d
for i in range(n):
#print(i)
x,y = list(map(int, input().split()))
if square_d >= x**2 + y**2:
dotCount += 1
print(dotCount)
| coordinate_number,distance = list(map(int, input().split()))
within_distance = 0
square_distance = distance*distance
for i in range(coordinate_number):
x,y = list(map(int, input().split()))
if square_distance >= x*x + y*y:
within_distance += 1
print(within_distance)
| 11 | 10 | 205 | 274 | n, d = list(map(int, input().split()))
dotCount = 0
square_d = d * d
for i in range(n):
# print(i)
x, y = list(map(int, input().split()))
if square_d >= x**2 + y**2:
dotCount += 1
print(dotCount)
| coordinate_number, distance = list(map(int, input().split()))
within_distance = 0
square_distance = distance * distance
for i in range(coordinate_number):
x, y = list(map(int, input().split()))
if square_distance >= x * x + y * y:
within_distance += 1
print(within_distance)
| false | 9.090909 | [
"-n, d = list(map(int, input().split()))",
"-dotCount = 0",
"-square_d = d * d",
"-for i in range(n):",
"- # print(i)",
"+coordinate_number, distance = list(map(int, input().split()))",
"+within_distance = 0",
"+square_distance = distance * distance",
"+for i in range(coordinate_number):",
"- ... | false | 0.084636 | 0.058412 | 1.448933 | [
"s054027317",
"s660025405"
] |
u815878613 | p03835 | python | s020746466 | s415122712 | 1,536 | 1,227 | 2,940 | 2,940 | Accepted | Accepted | 20.12 | K, S = list(map(int, input().split()))
cnt = 0
for i in range(K + 1):
for j in range(K + 1):
k = S - i - j
if 0 <= k <= K:
cnt += 1
print(cnt)
| K, S = list(map(int, input().split()))
cnt = 0
for i in range(K+1):
for j in range(K+1):
if 0 <= S - i - j <= K:
cnt += 1
print(cnt)
| 10 | 9 | 180 | 161 | K, S = list(map(int, input().split()))
cnt = 0
for i in range(K + 1):
for j in range(K + 1):
k = S - i - j
if 0 <= k <= K:
cnt += 1
print(cnt)
| K, S = list(map(int, input().split()))
cnt = 0
for i in range(K + 1):
for j in range(K + 1):
if 0 <= S - i - j <= K:
cnt += 1
print(cnt)
| false | 10 | [
"- k = S - i - j",
"- if 0 <= k <= K:",
"+ if 0 <= S - i - j <= K:"
] | false | 0.136064 | 0.086421 | 1.574443 | [
"s020746466",
"s415122712"
] |
u687053495 | p03078 | python | s307316770 | s469783595 | 1,747 | 521 | 140,840 | 127,456 | Accepted | Accepted | 70.18 |
X, Y, Z, K = list(map(int, input().split()))
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
result = []
for x in range(X):
for y in range(Y):
if x * y > K:
break
... | from heapq import heappop, heappush
X, Y, Z, K = list(map(int, input().split()))
A = sorted(list(map(int,input().split())), reverse=True)
B = sorted(list(map(int,input().split())), reverse=True)
C = sorted(list(map(int,input().split())), reverse=True)
queue = []
for x in range(X):
for y in range(Y):
i... | 19 | 22 | 477 | 516 | X, Y, Z, K = list(map(int, input().split()))
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
result = []
for x in range(X):
for y in range(Y):
if x * y > K:
break
... | from heapq import heappop, heappush
X, Y, Z, K = list(map(int, input().split()))
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
queue = []
for x in range(X):
for y in range(Y):
if ... | false | 13.636364 | [
"+from heapq import heappop, heappush",
"+",
"-result = []",
"+queue = []",
"- result.append(A[x] + B[y] + C[z])",
"-for k in list(sorted(result, reverse=True))[:K]:",
"- print(k)",
"+ val = A[x] + B[y] + C[z]",
"+ heappush(queue, -val)",
"+for _ in range(K):",
... | false | 0.044216 | 0.043529 | 1.015788 | [
"s307316770",
"s469783595"
] |
u519939795 | p03544 | python | s251180971 | s330033065 | 35 | 18 | 4,068 | 2,940 | Accepted | Accepted | 48.57 | from functools import lru_cache
N = int(eval(input()))
@lru_cache(maxsize=None)
def luca(n):
if n == 0:
return 2
if n == 1:
return 1
return luca(n - 1) + luca(n - 2)
print((luca(N))) | n = int(eval(input()))
luca = [0]*(n+1)
luca[0] = 2
luca[1] = 1
for i in range(2, n+1):
luca[i] = luca[i-1] + luca[i-2]
print((luca[n]))
| 14 | 7 | 223 | 139 | from functools import lru_cache
N = int(eval(input()))
@lru_cache(maxsize=None)
def luca(n):
if n == 0:
return 2
if n == 1:
return 1
return luca(n - 1) + luca(n - 2)
print((luca(N)))
| n = int(eval(input()))
luca = [0] * (n + 1)
luca[0] = 2
luca[1] = 1
for i in range(2, n + 1):
luca[i] = luca[i - 1] + luca[i - 2]
print((luca[n]))
| false | 50 | [
"-from functools import lru_cache",
"-",
"-N = int(eval(input()))",
"-",
"-",
"-@lru_cache(maxsize=None)",
"-def luca(n):",
"- if n == 0:",
"- return 2",
"- if n == 1:",
"- return 1",
"- return luca(n - 1) + luca(n - 2)",
"-",
"-",
"-print((luca(N)))",
"+n = int(... | false | 0.007188 | 0.038204 | 0.188151 | [
"s251180971",
"s330033065"
] |
u930705402 | p02623 | python | s563546972 | s924076520 | 194 | 175 | 110,836 | 111,400 | Accepted | Accepted | 9.79 | from bisect import bisect_left
N,M,K=list(map(int,input().split()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
cumA=[0]*(N+1)
cumB=[0]*(M+1)
for i in range(N):
cumA[i+1]=cumA[i]+A[i]
for i in range(M):
cumB[i+1]=cumB[i]+B[i]
ans=0
for i in range(N+1):
r=K-cumA[i]
... | def bisect(x):
l,r=-1,M+1
while(r-l>1):
mid=(l+r)//2
if cumB[mid]>=x:
r=mid
else:
l=mid
return l
N,M,K=list(map(int,input().split()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
cumB=[0]*(M+1)
for i in range(M):
cumB[i... | 26 | 27 | 498 | 487 | from bisect import bisect_left
N, M, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
cumA = [0] * (N + 1)
cumB = [0] * (M + 1)
for i in range(N):
cumA[i + 1] = cumA[i] + A[i]
for i in range(M):
cumB[i + 1] = cumB[i] + B[i]
ans = 0
for i in range(N + 1... | def bisect(x):
l, r = -1, M + 1
while r - l > 1:
mid = (l + r) // 2
if cumB[mid] >= x:
r = mid
else:
l = mid
return l
N, M, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
cumB = [0] * (M + 1)
for i... | false | 3.703704 | [
"-from bisect import bisect_left",
"+def bisect(x):",
"+ l, r = -1, M + 1",
"+ while r - l > 1:",
"+ mid = (l + r) // 2",
"+ if cumB[mid] >= x:",
"+ r = mid",
"+ else:",
"+ l = mid",
"+ return l",
"+",
"-cumA = [0] * (N + 1)",
"-for i in ra... | false | 0.039427 | 0.046229 | 0.852866 | [
"s563546972",
"s924076520"
] |
u241159583 | p03944 | python | s425255598 | s297280789 | 31 | 26 | 9,164 | 9,256 | Accepted | Accepted | 16.13 | w,h,n = list(map(int, input().split()))
xya = [list(map(int, input().split())) for _ in range(n)]
X = [0,w]
Y = [0,h]
for x,y,a in xya:
if a == 1:
X[0] = max(X[0], x)
elif a == 2:
X[1] = min(X[1], x)
elif a == 3:
Y[0] = max(Y[0], y)
else:
Y[1] = min(Y[1], y)
... | w,h,n = list(map(int, input().split()))
xya = [list(map(int, input().split())) for _ in range(n)]
W = [0,w]
H = [0,h]
for x,y,a in xya:
if a == 1:
W[0] = max(W[0],x)
elif a == 2:
W[1] = min(W[1], x)
elif a == 3:
H[0] = max(H[0],y)
else:
H[1] = min(H[1], y)
... | 15 | 15 | 399 | 378 | w, h, n = list(map(int, input().split()))
xya = [list(map(int, input().split())) for _ in range(n)]
X = [0, w]
Y = [0, h]
for x, y, a in xya:
if a == 1:
X[0] = max(X[0], x)
elif a == 2:
X[1] = min(X[1], x)
elif a == 3:
Y[0] = max(Y[0], y)
else:
Y[1] = min(Y[1], y)
if X[0]... | w, h, n = list(map(int, input().split()))
xya = [list(map(int, input().split())) for _ in range(n)]
W = [0, w]
H = [0, h]
for x, y, a in xya:
if a == 1:
W[0] = max(W[0], x)
elif a == 2:
W[1] = min(W[1], x)
elif a == 3:
H[0] = max(H[0], y)
else:
H[1] = min(H[1], y)
print((... | false | 0 | [
"-X = [0, w]",
"-Y = [0, h]",
"+W = [0, w]",
"+H = [0, h]",
"- X[0] = max(X[0], x)",
"+ W[0] = max(W[0], x)",
"- X[1] = min(X[1], x)",
"+ W[1] = min(W[1], x)",
"- Y[0] = max(Y[0], y)",
"+ H[0] = max(H[0], y)",
"- Y[1] = min(Y[1], y)",
"-if X[0] ... | false | 0.034845 | 0.041206 | 0.845629 | [
"s425255598",
"s297280789"
] |
u579324544 | p02921 | python | s167796891 | s211949887 | 179 | 17 | 38,384 | 2,940 | Accepted | Accepted | 90.5 |
if __name__ == "__main__":
a = eval(input())
b = eval(input())
print((sum([a[i] == b[i] for i in range(3)])))
| #n = input()
#a = list(map(int, input().split()))
#b = list(map(int, input().split()))
#c = list(map(int, input().split()))
a = eval(input())
b = eval(input())
r = 0
for i,j in zip(a, b):
r += i == j
print(r) | 7 | 10 | 120 | 209 | if __name__ == "__main__":
a = eval(input())
b = eval(input())
print((sum([a[i] == b[i] for i in range(3)])))
| # n = input()
# a = list(map(int, input().split()))
# b = list(map(int, input().split()))
# c = list(map(int, input().split()))
a = eval(input())
b = eval(input())
r = 0
for i, j in zip(a, b):
r += i == j
print(r)
| false | 30 | [
"-if __name__ == \"__main__\":",
"- a = eval(input())",
"- b = eval(input())",
"- print((sum([a[i] == b[i] for i in range(3)])))",
"+# n = input()",
"+# a = list(map(int, input().split()))",
"+# b = list(map(int, input().split()))",
"+# c = list(map(int, input().split()))",
"+a = eval(input... | false | 0.045722 | 0.043225 | 1.057772 | [
"s167796891",
"s211949887"
] |
u075595666 | p03999 | python | s532630845 | s693540188 | 24 | 20 | 3,060 | 3,064 | Accepted | Accepted | 16.67 | s = eval(input())
chk = []
def f(a,b):
if a==len(b):
chk.append(eval(b))
else:
return f(a+1,b),f(a+2,b[:a]+'+'+b[a:])
f(1,s)
print((sum(chk))) | s = eval(input())
l = len(s)-1
ans = 0
for j in range(2**l):
L = 0
for i in range(l):
if (j>>i)&1 == 1:
m = s[L:i+1]
ans += int(m)
L = i+1
ans += int(s[L:])
print(ans) | 9 | 13 | 154 | 203 | s = eval(input())
chk = []
def f(a, b):
if a == len(b):
chk.append(eval(b))
else:
return f(a + 1, b), f(a + 2, b[:a] + "+" + b[a:])
f(1, s)
print((sum(chk)))
| s = eval(input())
l = len(s) - 1
ans = 0
for j in range(2**l):
L = 0
for i in range(l):
if (j >> i) & 1 == 1:
m = s[L : i + 1]
ans += int(m)
L = i + 1
ans += int(s[L:])
print(ans)
| false | 30.769231 | [
"-chk = []",
"-",
"-",
"-def f(a, b):",
"- if a == len(b):",
"- chk.append(eval(b))",
"- else:",
"- return f(a + 1, b), f(a + 2, b[:a] + \"+\" + b[a:])",
"-",
"-",
"-f(1, s)",
"-print((sum(chk)))",
"+l = len(s) - 1",
"+ans = 0",
"+for j in range(2**l):",
"+ L = 0... | false | 0.049638 | 0.049569 | 1.001393 | [
"s532630845",
"s693540188"
] |
u790048565 | p03162 | python | s611708354 | s723642229 | 906 | 364 | 40,264 | 69,340 | Accepted | Accepted | 59.82 | N = int(eval(input()))
ABC = []
for _ in range(N):
a, b, c = list(map(int, input().split()))
ABC.append((a, b, c))
dp = [[0] * 3 for i in range(N)]
for i, abc in enumerate(ABC):
for k in range(3):
if (i == 0):
dp[i][k] = abc[k]
else:
max_dp_i = dp[i][k]
for j in range(3... | import sys
input = sys.stdin.readline
N = int(eval(input()))
ABC = []
for _ in range(N):
a, b, c = list(map(int, input().split()))
ABC.append((a, b, c))
dp = [[0] * 3 for _ in range(N)]
for day, abc in enumerate(ABC):
for t_act in range(3):
if (day == 0):
dp[day][t_act] = abc[t_act]
... | 24 | 27 | 501 | 582 | N = int(eval(input()))
ABC = []
for _ in range(N):
a, b, c = list(map(int, input().split()))
ABC.append((a, b, c))
dp = [[0] * 3 for i in range(N)]
for i, abc in enumerate(ABC):
for k in range(3):
if i == 0:
dp[i][k] = abc[k]
else:
max_dp_i = dp[i][k]
for ... | import sys
input = sys.stdin.readline
N = int(eval(input()))
ABC = []
for _ in range(N):
a, b, c = list(map(int, input().split()))
ABC.append((a, b, c))
dp = [[0] * 3 for _ in range(N)]
for day, abc in enumerate(ABC):
for t_act in range(3):
if day == 0:
dp[day][t_act] = abc[t_act]
... | false | 11.111111 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"-dp = [[0] * 3 for i in range(N)]",
"-for i, abc in enumerate(ABC):",
"- for k in range(3):",
"- if i == 0:",
"- dp[i][k] = abc[k]",
"- else:",
"- max_dp_i = dp[i][k]",
"- for j in range(3):",
... | false | 0.043896 | 0.044619 | 0.98378 | [
"s611708354",
"s723642229"
] |
u593063683 | p03967 | python | s296029639 | s766317527 | 60 | 54 | 3,316 | 3,316 | Accepted | Accepted | 10 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/2/
Solved on 2019/2/
@author: shinjisu
"""
# ARC 062 C AtCoDeer and Rock-Paper
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n
def getIntLines(n): return ... | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/2/
Solved on 2019/2/
@author: shinjisu
"""
# ARC 062 C AtCoDeer and Rock-Paper
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n
def getIntLines(n): return ... | 84 | 94 | 1,590 | 1,746 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/2/
Solved on 2019/2/
@author: shinjisu
"""
# ARC 062 C AtCoDeer and Rock-Paper
def getInt():
return int(input())
def getIntList():
return [int(x) for x in input().split()]
def zeros(n):
return [0] * n
def getIntLines(n):
return [in... | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/2/
Solved on 2019/2/
@author: shinjisu
"""
# ARC 062 C AtCoDeer and Rock-Paper
def getInt():
return int(input())
def getIntList():
return [int(x) for x in input().split()]
def zeros(n):
return [0] * n
def getIntLines(n):
return [in... | false | 10.638298 | [
"- if S[i] == GU:",
"- if paCount < guCount:",
"- te = PA",
"- paCount += 1",
"- else:",
"- te = GU",
"- guCount += 1",
"+ if paCount < guCount:",
"+ te = PA",
"+ paCount += 1",
... | false | 0.044416 | 0.044549 | 0.997009 | [
"s296029639",
"s766317527"
] |
u576432509 | p03212 | python | s109186897 | s636085810 | 184 | 58 | 3,064 | 3,060 | Accepted | Accepted | 68.48 | def sigm(nk):
s=3**3*(3**(nk-2)-1)/(3-1)
s=s-3*2**3*(2**(nk-2)-1)/(2-1)
s=s+(nk-2)*3
return int(s)
n=int(eval(input()))
if n<357:
print((0))
else:
x0=[357,375,537,573,735,753]
x1=[3,5,7]
m=0
nk=len(str(n))
if nk==3:
for j in range(6):
x=... |
import itertools
n=int(eval(input()))
kn=len(str(n))
icnt=0
for kkn in range(3,kn+1):
for i in itertools.product([3,5,7], repeat=kkn):
if (3 in i) and (5 in i) and (7 in i):
ni=0
for ii in i:
ni=ni*10+ii
# print("1:",i,ni)
if ... | 35 | 18 | 813 | 363 | def sigm(nk):
s = 3**3 * (3 ** (nk - 2) - 1) / (3 - 1)
s = s - 3 * 2**3 * (2 ** (nk - 2) - 1) / (2 - 1)
s = s + (nk - 2) * 3
return int(s)
n = int(eval(input()))
if n < 357:
print((0))
else:
x0 = [357, 375, 537, 573, 735, 753]
x1 = [3, 5, 7]
m = 0
nk = len(str(n))
if nk == 3:
... | import itertools
n = int(eval(input()))
kn = len(str(n))
icnt = 0
for kkn in range(3, kn + 1):
for i in itertools.product([3, 5, 7], repeat=kkn):
if (3 in i) and (5 in i) and (7 in i):
ni = 0
for ii in i:
ni = ni * 10 + ii
# print("1:",i,ni)
... | false | 48.571429 | [
"-def sigm(nk):",
"- s = 3**3 * (3 ** (nk - 2) - 1) / (3 - 1)",
"- s = s - 3 * 2**3 * (2 ** (nk - 2) - 1) / (2 - 1)",
"- s = s + (nk - 2) * 3",
"- return int(s)",
"-",
"+import itertools",
"-if n < 357:",
"- print((0))",
"-else:",
"- x0 = [357, 375, 537, 573, 735, 753]",
"- ... | false | 0.086633 | 0.05138 | 1.686119 | [
"s109186897",
"s636085810"
] |
u426534722 | p02248 | python | s080891082 | s909106276 | 1,210 | 910 | 47,924 | 117,852 | Accepted | Accepted | 24.79 | def kmpTable(w):
lw = len(w)
nx = [-1] * (lw + 1)
j = -1
for i in range(lw):
while j >= 0 and w[i] != w[j]:
j = nx[j]
j += 1
nx[i + 1] = j
return nx
def kmpSearch(s, w):
ls = len(s)
start = 0
w_idx = 0
ret = []
nx = kmpTable(w)
... | def kmpTable(w):
lw = len(w)
nx = [-1] * (lw + 1)
j = -1
for i in range(lw):
while j >= 0 and w[i] != w[j]:
j = nx[j]
j += 1
nx[i + 1] = j
return nx
def kmpSearch(s, w):
ls = len(s)
start = 0
w_idx = 0
ret = []
nx = kmpTable(w)
... | 36 | 36 | 842 | 860 | def kmpTable(w):
lw = len(w)
nx = [-1] * (lw + 1)
j = -1
for i in range(lw):
while j >= 0 and w[i] != w[j]:
j = nx[j]
j += 1
nx[i + 1] = j
return nx
def kmpSearch(s, w):
ls = len(s)
start = 0
w_idx = 0
ret = []
nx = kmpTable(w)
while star... | def kmpTable(w):
lw = len(w)
nx = [-1] * (lw + 1)
j = -1
for i in range(lw):
while j >= 0 and w[i] != w[j]:
j = nx[j]
j += 1
nx[i + 1] = j
return nx
def kmpSearch(s, w):
ls = len(s)
start = 0
w_idx = 0
ret = []
nx = kmpTable(w)
while star... | false | 0 | [
"-for i in ans:",
"- print(i)",
"+if ans:",
"+ print((\"\\n\".join(map(str, ans))))"
] | false | 0.054122 | 0.037538 | 1.4418 | [
"s080891082",
"s909106276"
] |
u268793453 | p04046 | python | s327541177 | s635896283 | 388 | 281 | 31,064 | 20,524 | Accepted | Accepted | 27.58 | import scipy.misc as scm
h, w, a, b = [int(i) for i in input().split()]
p = 10**9 + 7
ans = 0
def fact(n, p=10**9 + 7):
f = [1]
for i in range(1, n+1):
f.append(f[-1]*i%p)
return f
def invfact(n, f, p=10**9 + 7):
inv = [pow(f[n], p-2, p)]
for i in range(n, 0, -1):
... | h, w, a, b = [int(i) for i in input().split()]
p = 10 ** 9 + 7
ans = 0
c = h-a-1
def fact(n, p=10**9 + 7):
f = [1]
for i in range(1, n+1):
f.append(f[-1]*i%p)
return f
def invfact(n, f, p=10**9 + 7):
inv = [pow(f[n], p-2, p)]
for i in range(n, 0, -1):
inv.append(i... | 27 | 29 | 561 | 584 | import scipy.misc as scm
h, w, a, b = [int(i) for i in input().split()]
p = 10**9 + 7
ans = 0
def fact(n, p=10**9 + 7):
f = [1]
for i in range(1, n + 1):
f.append(f[-1] * i % p)
return f
def invfact(n, f, p=10**9 + 7):
inv = [pow(f[n], p - 2, p)]
for i in range(n, 0, -1):
inv.ap... | h, w, a, b = [int(i) for i in input().split()]
p = 10**9 + 7
ans = 0
c = h - a - 1
def fact(n, p=10**9 + 7):
f = [1]
for i in range(1, n + 1):
f.append(f[-1] * i % p)
return f
def invfact(n, f, p=10**9 + 7):
inv = [pow(f[n], p - 2, p)]
for i in range(n, 0, -1):
inv.append(inv[-1]... | false | 6.896552 | [
"-import scipy.misc as scm",
"-",
"+c = h - a - 1",
"-f = fact(h + w)",
"-rf = invfact(h + w, f)",
"-for i in range(b, w):",
"- ans += (",
"- (f[h - a + i - 1] * rf[h - a - 1] % p * rf[i] % p)",
"- * (f[a + w - i - 2] * rf[a - 1] % p * rf[w - i - 1] % p)",
"- % p",
"- ... | false | 0.043689 | 0.039728 | 1.099687 | [
"s327541177",
"s635896283"
] |
u481187938 | p02762 | python | s665140659 | s289307755 | 1,146 | 953 | 95,404 | 95,428 | Accepted | Accepted | 16.84 | #!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline... | #!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline... | 115 | 113 | 2,581 | 2,526 | #!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LI1():
return [int(x) - 1 for x in sys.stdin.readline().s... | #!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LI1():
return [int(x) - 1 for x in sys.stdin.readline().s... | false | 1.73913 | [
"- self.parent = [i for i in range(n)]",
"- self.rank = [0 for _ in range(n)]",
"+ self._parent = [i for i in range(n)]",
"+ self._rank = [0 for _ in range(n)]",
"- if self.parent[x] == x:",
"+ if self._parent[x] == x:",
"- px = self.parent[x]",
"+ ... | false | 0.045807 | 0.037472 | 1.222452 | [
"s665140659",
"s289307755"
] |
u459419927 | p02695 | python | s060156694 | s809390107 | 1,658 | 601 | 9,252 | 9,116 | Accepted | Accepted | 63.75 | from sys import stdin
import itertools
N,M,Q=list(map(int, (stdin.readline().strip().split())))
q=[]
num_list=[]
number=[]
score=[0]
for i in range(1,M+1):number.append(i)
for _ in range(Q):
a,b,c,d=list(map(int, (stdin.readline().strip().split())))
q.append([a,b,c,d])
def dfs(num_list,i):
if i=... | from sys import stdin
import itertools
N,M,Q=list(map(int, (stdin.readline().strip().split())))
q=[]
num_list=[]
number=[]
score=[0]
daburi=[]
for i in range(1,M+1):number.append(i)
for _ in range(Q):
a,b,c,d=list(map(int, (stdin.readline().strip().split())))
q.append([a,b,c,d])
def dfs(num_list,i):... | 31 | 31 | 722 | 706 | from sys import stdin
import itertools
N, M, Q = list(map(int, (stdin.readline().strip().split())))
q = []
num_list = []
number = []
score = [0]
for i in range(1, M + 1):
number.append(i)
for _ in range(Q):
a, b, c, d = list(map(int, (stdin.readline().strip().split())))
q.append([a, b, c, d])
def dfs(num... | from sys import stdin
import itertools
N, M, Q = list(map(int, (stdin.readline().strip().split())))
q = []
num_list = []
number = []
score = [0]
daburi = []
for i in range(1, M + 1):
number.append(i)
for _ in range(Q):
a, b, c, d = list(map(int, (stdin.readline().strip().split())))
q.append([a, b, c, d])
... | false | 0 | [
"+daburi = []",
"- dfs(num_list, i + 1)"
] | false | 0.298883 | 0.053286 | 5.608998 | [
"s060156694",
"s809390107"
] |
u297574184 | p02793 | python | s598356814 | s840925889 | 1,881 | 459 | 4,708 | 85,972 | Accepted | Accepted | 75.6 | from functools import reduce
def solve():
MOD = 10**9 + 7
def gcd(a, b):
while b:
a, b = b, a%b
return a
def lcm(a, b):
return a // gcd(a, b) * b
N = int(eval(input()))
As = list(map(int, input().split()))
lcmA = reduce(lcm, As)
#print(... | from collections import Counter
def solve():
MOD = 10**9 + 7
N = int(eval(input()))
As = list(map(int, input().split()))
def getPrimeFactors(x):
anss = []
while x%2 == 0:
anss.append(2)
x //= 2
for d in range(3, int(x**0.5)+1, 2):
... | 26 | 51 | 433 | 1,053 | from functools import reduce
def solve():
MOD = 10**9 + 7
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a // gcd(a, b) * b
N = int(eval(input()))
As = list(map(int, input().split()))
lcmA = reduce(lcm, As)
# print('lcmA:', lcm... | from collections import Counter
def solve():
MOD = 10**9 + 7
N = int(eval(input()))
As = list(map(int, input().split()))
def getPrimeFactors(x):
anss = []
while x % 2 == 0:
anss.append(2)
x //= 2
for d in range(3, int(x**0.5) + 1, 2):
while ... | false | 49.019608 | [
"-from functools import reduce",
"+from collections import Counter",
"-",
"- def gcd(a, b):",
"- while b:",
"- a, b = b, a % b",
"- return a",
"-",
"- def lcm(a, b):",
"- return a // gcd(a, b) * b",
"-",
"- lcmA = reduce(lcm, As)",
"- # print('lcmA... | false | 0.007252 | 0.495195 | 0.014645 | [
"s598356814",
"s840925889"
] |
u773265208 | p02970 | python | s373892065 | s663114391 | 19 | 17 | 3,188 | 3,064 | Accepted | Accepted | 10.53 | import math
n,d = list(map(int,input().split()))
r = 2 * d + 1
ans = math.ceil(n / r)
print(ans) | import math
n,d = list(map(int,input().split()))
print((math.ceil(n / (2*d+1))))
| 9 | 5 | 102 | 79 | import math
n, d = list(map(int, input().split()))
r = 2 * d + 1
ans = math.ceil(n / r)
print(ans)
| import math
n, d = list(map(int, input().split()))
print((math.ceil(n / (2 * d + 1))))
| false | 44.444444 | [
"-r = 2 * d + 1",
"-ans = math.ceil(n / r)",
"-print(ans)",
"+print((math.ceil(n / (2 * d + 1))))"
] | false | 0.043606 | 0.044653 | 0.976553 | [
"s373892065",
"s663114391"
] |
u714225686 | p03266 | python | s775576920 | s158981475 | 41 | 36 | 5,456 | 5,072 | Accepted | Accepted | 12.2 | import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce
def lcm(a, b):
return a * b // gcd(a, b)
def combination_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)... | import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce
def lcm(a, b):
return a * b // gcd(a, b)
def combination_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)... | 57 | 58 | 1,240 | 1,273 | import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce
def lcm(a, b):
return a * b // gcd(a, b)
def combination_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def perm... | import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce
def lcm(a, b):
return a * b // gcd(a, b)
def combination_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def perm... | false | 1.724138 | [
"- b = (N + (K // 2)) // K",
"+ # b = (N + (K // 2)) // K",
"+ b = N // (K // 2) - a"
] | false | 0.149062 | 0.14713 | 1.013135 | [
"s775576920",
"s158981475"
] |
u127499732 | p03325 | python | s708940547 | s340814180 | 58 | 24 | 4,084 | 4,084 | Accepted | Accepted | 58.62 | def factor(n, i):
count = 0
while n % i == 0:
count += 1
n = n // i
return count
def main():
n, *a = list(map(int, open(0).read().split()))
ans = sum([factor(x, 2) for x in a])
print(ans)
if __name__ == '__main__':
main()
| def main():
n, *a = list(map(int, open(0).read().split()))
ans = sum([bin(b)[::-1].index("1") for b in a])
print(ans)
if __name__ == '__main__':
main()
| 16 | 8 | 279 | 171 | def factor(n, i):
count = 0
while n % i == 0:
count += 1
n = n // i
return count
def main():
n, *a = list(map(int, open(0).read().split()))
ans = sum([factor(x, 2) for x in a])
print(ans)
if __name__ == "__main__":
main()
| def main():
n, *a = list(map(int, open(0).read().split()))
ans = sum([bin(b)[::-1].index("1") for b in a])
print(ans)
if __name__ == "__main__":
main()
| false | 50 | [
"-def factor(n, i):",
"- count = 0",
"- while n % i == 0:",
"- count += 1",
"- n = n // i",
"- return count",
"-",
"-",
"- ans = sum([factor(x, 2) for x in a])",
"+ ans = sum([bin(b)[::-1].index(\"1\") for b in a])"
] | false | 0.076072 | 0.038131 | 1.99501 | [
"s708940547",
"s340814180"
] |
u823885866 | p02773 | python | s155049478 | s040723641 | 587 | 512 | 44,480 | 44,480 | Accepted | Accepted | 12.78 | import sys
import math
import itertools
import numpy
import collections
rl = sys.stdin.readline
n = int(rl())
li = []
for _ in range(n):
li.append(rl().rstrip())
c = collections.Counter(li)
max_cnt = 0
li = []
for k, v in list(c.items()):
if v < max_cnt:
continue
elif v == max_... | import sys
import math
import itertools
import numpy
import collections
rl = sys.stdin.readline
n = int(rl())
li = []
for _ in range(n):
li.append(rl().rstrip())
c = collections.Counter(li)
max_cnt = 0
li = []
for k, v in list(c.items()):
if v < max_cnt:
continue
elif v == max_... | 31 | 29 | 438 | 430 | import sys
import math
import itertools
import numpy
import collections
rl = sys.stdin.readline
n = int(rl())
li = []
for _ in range(n):
li.append(rl().rstrip())
c = collections.Counter(li)
max_cnt = 0
li = []
for k, v in list(c.items()):
if v < max_cnt:
continue
elif v == max_cnt:
li.appen... | import sys
import math
import itertools
import numpy
import collections
rl = sys.stdin.readline
n = int(rl())
li = []
for _ in range(n):
li.append(rl().rstrip())
c = collections.Counter(li)
max_cnt = 0
li = []
for k, v in list(c.items()):
if v < max_cnt:
continue
elif v == max_cnt:
li.appen... | false | 6.451613 | [
"-for i in li:",
"- print(i)",
"+print((\"\\n\".join(li)))"
] | false | 0.042584 | 0.041658 | 1.022226 | [
"s155049478",
"s040723641"
] |
u977349332 | p03457 | python | s519657852 | s158057058 | 351 | 198 | 3,060 | 3,060 | Accepted | Accepted | 43.59 | import math
import sys
n = int(eval(input()))
for i in range(n):
t,x,y = list(map(int, input().split()))
d = abs(x)+abs(y)
if d > t or (d - t) % 2 != 0:
print('No')
exit()
print('Yes')
| import math
import sys
n = int(eval(input()))
for i in range(n):
t,x,y = list(map(int, sys.stdin.readline().split()))
d = abs(x)+abs(y)
if d > t or (d - t) % 2 != 0:
print('No')
exit()
print('Yes')
| 14 | 14 | 197 | 210 | import math
import sys
n = int(eval(input()))
for i in range(n):
t, x, y = list(map(int, input().split()))
d = abs(x) + abs(y)
if d > t or (d - t) % 2 != 0:
print("No")
exit()
print("Yes")
| import math
import sys
n = int(eval(input()))
for i in range(n):
t, x, y = list(map(int, sys.stdin.readline().split()))
d = abs(x) + abs(y)
if d > t or (d - t) % 2 != 0:
print("No")
exit()
print("Yes")
| false | 0 | [
"- t, x, y = list(map(int, input().split()))",
"+ t, x, y = list(map(int, sys.stdin.readline().split()))"
] | false | 0.037615 | 0.073594 | 0.511112 | [
"s519657852",
"s158057058"
] |
u919633157 | p03944 | python | s765599022 | s364575974 | 27 | 17 | 3,188 | 3,064 | Accepted | Accepted | 37.04 |
def re(x,y,a,rect):
if a==1:
for i in range(1,len(rect)):
rect[i][1:x+1]=[0]*x
elif a==2:
for i in range(1,len(rect)):
rect[i]=rect[i][:x+1]+[0]*(len(rect[i])-x-1)
elif a==3:
for i in range(1,y+1):
rect[i]=[0]*(len(rect[y]))
else:
... | w,h,n=list(map(int,input().split()))
left,right,down,up=0,w,0,h
for i in range(n):
x,y,a=list(map(int,input().split()))
if a==1:left=max(left,x)
elif a==2: right=min(right,x)
elif a==3: down=max(down,y)
elif a==4: up=min(up,y)
print((max(0,right-left)*max(0,up-down))) | 34 | 9 | 678 | 282 | def re(x, y, a, rect):
if a == 1:
for i in range(1, len(rect)):
rect[i][1 : x + 1] = [0] * x
elif a == 2:
for i in range(1, len(rect)):
rect[i] = rect[i][: x + 1] + [0] * (len(rect[i]) - x - 1)
elif a == 3:
for i in range(1, y + 1):
rect[i] = [0] *... | w, h, n = list(map(int, input().split()))
left, right, down, up = 0, w, 0, h
for i in range(n):
x, y, a = list(map(int, input().split()))
if a == 1:
left = max(left, x)
elif a == 2:
right = min(right, x)
elif a == 3:
down = max(down, y)
elif a == 4:
up = min(up, y)
pr... | false | 73.529412 | [
"-def re(x, y, a, rect):",
"+w, h, n = list(map(int, input().split()))",
"+left, right, down, up = 0, w, 0, h",
"+for i in range(n):",
"+ x, y, a = list(map(int, input().split()))",
"- for i in range(1, len(rect)):",
"- rect[i][1 : x + 1] = [0] * x",
"+ left = max(left, x)"... | false | 0.046456 | 0.045209 | 1.027586 | [
"s765599022",
"s364575974"
] |
u241159583 | p02630 | python | s404031920 | s564773595 | 564 | 373 | 24,128 | 36,748 | Accepted | Accepted | 33.87 | from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
l = Counter(a)
q = int(eval(input()))
ans = sum(a)
for _ in range(q):
b,c = list(map(int, input().split()))
tmp = l[b]
l[c] += tmp
l[b] = 0
ans += (c-b) * tmp
print(ans) | from collections import Counter
n = int(eval(input()))
A = list(map(int, input().split()))
a = Counter(A)
q = int(eval(input()))
bc = [list(map(int, input().split())) for _ in range(q)]
ans = sum(A)
for b,c in bc:
ans -= b*a[b]
ans += c*a[b]
if b in a:
if c in a: a[c] += a[b]
e... | 14 | 16 | 280 | 358 | from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
l = Counter(a)
q = int(eval(input()))
ans = sum(a)
for _ in range(q):
b, c = list(map(int, input().split()))
tmp = l[b]
l[c] += tmp
l[b] = 0
ans += (c - b) * tmp
print(ans)
| from collections import Counter
n = int(eval(input()))
A = list(map(int, input().split()))
a = Counter(A)
q = int(eval(input()))
bc = [list(map(int, input().split())) for _ in range(q)]
ans = sum(A)
for b, c in bc:
ans -= b * a[b]
ans += c * a[b]
if b in a:
if c in a:
a[c] += a[b]
... | false | 12.5 | [
"-a = list(map(int, input().split()))",
"-l = Counter(a)",
"+A = list(map(int, input().split()))",
"+a = Counter(A)",
"-ans = sum(a)",
"-for _ in range(q):",
"- b, c = list(map(int, input().split()))",
"- tmp = l[b]",
"- l[c] += tmp",
"- l[b] = 0",
"- ans += (c - b) * tmp",
"+bc... | false | 0.09245 | 0.047787 | 1.934628 | [
"s404031920",
"s564773595"
] |
u729133443 | p02948 | python | s701367802 | s474351470 | 1,402 | 1,163 | 374,404 | 371,436 | Accepted | Accepted | 17.05 | from heapq import*
(N,M),*t=[list(map(int,s.split()))for s in open(0)]
z,*q=[0]*50*M
v=[[]for _ in q]
for a,b in t:v[a-1]+=b,
for i in v[:M]:[heappush(q,-j)for j in i];z-=heappop(q)
print(z) | from heapq import*
(N,M),*t=[list(map(int,s.split()))for s in open(0)]
q=[0]*50*M
v=[[]for _ in q]
for a,b in t:v[a-1]+=b,
print((sum(([heappush(q,-j)for j in i],-heappop(q))[1]for i in v[:M]))) | 7 | 6 | 190 | 191 | from heapq import *
(N, M), *t = [list(map(int, s.split())) for s in open(0)]
z, *q = [0] * 50 * M
v = [[] for _ in q]
for a, b in t:
v[a - 1] += (b,)
for i in v[:M]:
[heappush(q, -j) for j in i]
z -= heappop(q)
print(z)
| from heapq import *
(N, M), *t = [list(map(int, s.split())) for s in open(0)]
q = [0] * 50 * M
v = [[] for _ in q]
for a, b in t:
v[a - 1] += (b,)
print((sum(([heappush(q, -j) for j in i], -heappop(q))[1] for i in v[:M])))
| false | 14.285714 | [
"-z, *q = [0] * 50 * M",
"+q = [0] * 50 * M",
"-for i in v[:M]:",
"- [heappush(q, -j) for j in i]",
"- z -= heappop(q)",
"-print(z)",
"+print((sum(([heappush(q, -j) for j in i], -heappop(q))[1] for i in v[:M])))"
] | false | 0.037747 | 0.037581 | 1.00443 | [
"s701367802",
"s474351470"
] |
u191874006 | p02700 | python | s271629744 | s702007931 | 104 | 66 | 65,316 | 65,628 | Accepted | Accepted | 36.54 | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from... | #!/usr/bin/env python3
#B
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
... | 30 | 25 | 725 | 662 | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collectio... | #!/usr/bin/env python3
# B
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from colle... | false | 16.666667 | [
"+# B",
"-while 1:",
"- if c - b <= 0:",
"- print(\"Yes\")",
"- quit()",
"- if a - d <= 0:",
"- print(\"No\")",
"- quit()",
"- c -= b",
"- a -= d",
"+if math.ceil(c / b) <= math.ceil(a / d):",
"+ print(\"Yes\")",
"+else:",
"+ print(\"No\")"
] | false | 0.037851 | 0.045041 | 0.840379 | [
"s271629744",
"s702007931"
] |
u387774811 | p02901 | python | s952472110 | s083408104 | 910 | 782 | 142,552 | 138,460 | Accepted | Accepted | 14.07 | N,M=list(map(int,input().split()))
lst=[0]*M
for i in range(M):
a,b=list(map(int,input().split()))
c=list(map(int,input().split()))
d=0
for n in range(b):
d+=2**(c[n]-1)
lst[i]=(a,d)
ans=[[float("inf") for e in range(2**N)] for f in range(M+1)]
ans[0][0]=0
for j in range(M):
for i in range(2**N):
... | import sys
input = sys.stdin.readline
N,M=list(map(int,input().split()))
lst=[0]*M
for i in range(M):
a,b=list(map(int,input().split()))
c=set(map(int,input().split()))
d=0
for n in c:
d+=2**(n-1)
lst[i]=(a,d)
ans=[[float("inf") for e in range(2**N)] for f in range(M+1)]
ans[0][0]=0
for j in range(... | 19 | 21 | 455 | 484 | N, M = list(map(int, input().split()))
lst = [0] * M
for i in range(M):
a, b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = 0
for n in range(b):
d += 2 ** (c[n] - 1)
lst[i] = (a, d)
ans = [[float("inf") for e in range(2**N)] for f in range(M + 1)]
ans[0][0] = 0... | import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))
lst = [0] * M
for i in range(M):
a, b = list(map(int, input().split()))
c = set(map(int, input().split()))
d = 0
for n in c:
d += 2 ** (n - 1)
lst[i] = (a, d)
ans = [[float("inf") for e in range(2**N)] for f in... | false | 9.52381 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"- c = list(map(int, input().split()))",
"+ c = set(map(int, input().split()))",
"- for n in range(b):",
"- d += 2 ** (c[n] - 1)",
"+ for n in c:",
"+ d += 2 ** (n - 1)"
] | false | 0.040027 | 0.038308 | 1.044869 | [
"s952472110",
"s083408104"
] |
u150984829 | p00448 | python | s061436159 | s069822213 | 12,100 | 10,920 | 6,916 | 6,916 | Accepted | Accepted | 9.75 | for e in iter(input,'0 0'):
r,_=list(map(int,e.split()))
d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]
a=0
for i in range(1<<r):
b=0
for j in d:
c=bin(i^j).count('1')
b+=[r-c,c][c>r//2]
if b>a:a=b
print(a)
| for e in iter(input,'0 0'):
r,_=list(map(int,e.split()))
d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]
a=0
for i in range(1<<r):
b=0
for j in d:
c=bin(i^j).count('1')
b+=c if c>r//2else r-c
a=max(a,b)
print(a)
| 11 | 11 | 248 | 252 | for e in iter(input, "0 0"):
r, _ = list(map(int, e.split()))
d = [int("".join(x), 2) for x in zip(*[input().split() for _ in [0] * r])]
a = 0
for i in range(1 << r):
b = 0
for j in d:
c = bin(i ^ j).count("1")
b += [r - c, c][c > r // 2]
if b > a:
... | for e in iter(input, "0 0"):
r, _ = list(map(int, e.split()))
d = [int("".join(x), 2) for x in zip(*[input().split() for _ in [0] * r])]
a = 0
for i in range(1 << r):
b = 0
for j in d:
c = bin(i ^ j).count("1")
b += c if c > r // 2 else r - c
a = max(a, b)... | false | 0 | [
"- b += [r - c, c][c > r // 2]",
"- if b > a:",
"- a = b",
"+ b += c if c > r // 2 else r - c",
"+ a = max(a, b)"
] | false | 0.038646 | 0.038755 | 0.997176 | [
"s061436159",
"s069822213"
] |
u759412327 | p03503 | python | s123708428 | s622135176 | 299 | 59 | 9,208 | 9,200 | Accepted | Accepted | 80.27 | N = int(eval(input()))
F = [list(map(int,input().split())) for n in range(N)]
P = [list(map(int,input().split())) for n in range(N)]
ans = []
for i in range(1,1024):
p = 0
for j in range(N):
c = 0
for k in range(10):
if (i>>k&1) & F[j][k]:
c+=1
p+=P[j][c]
ans+=[p]
pr... | N = int(eval(input()))
F = [int("".join(input().split()),2) for n in range(N)]
P = [list(map(int,input().split())) for n in range(N)]
print((max(sum(p[bin(n&f).count("1")]for f,p in zip(F,P)) for n in range(1,1024)))) | 16 | 4 | 327 | 212 | N = int(eval(input()))
F = [list(map(int, input().split())) for n in range(N)]
P = [list(map(int, input().split())) for n in range(N)]
ans = []
for i in range(1, 1024):
p = 0
for j in range(N):
c = 0
for k in range(10):
if (i >> k & 1) & F[j][k]:
c += 1
p += P... | N = int(eval(input()))
F = [int("".join(input().split()), 2) for n in range(N)]
P = [list(map(int, input().split())) for n in range(N)]
print(
(max(sum(p[bin(n & f).count("1")] for f, p in zip(F, P)) for n in range(1, 1024)))
)
| false | 75 | [
"-F = [list(map(int, input().split())) for n in range(N)]",
"+F = [int(\"\".join(input().split()), 2) for n in range(N)]",
"-ans = []",
"-for i in range(1, 1024):",
"- p = 0",
"- for j in range(N):",
"- c = 0",
"- for k in range(10):",
"- if (i >> k & 1) & F[j][k]:",
... | false | 0.055005 | 0.039164 | 1.404451 | [
"s123708428",
"s622135176"
] |
u949338836 | p02267 | python | s105618600 | s832633573 | 80 | 20 | 8,472 | 8,176 | Accepted | Accepted | 75 | #coding:utf-8
#1_4_A
def isFound(array, x):
""" linear search """
array.append(x)
i = 0
while array[i] != x:
i += 1
if i == len(array)-1:
return False
return True
n = int(eval(input()))
S = list(map(int, input().split()))
q = int(eval(input()))
T = list(map(int, i... | #coding:utf-8
#1_4_A
n = int(eval(input()))
S = set(map(int, input().split()))
q = int(eval(input()))
T = set(map(int, input().split()))
print((len(S & T))) | 23 | 8 | 419 | 150 | # coding:utf-8
# 1_4_A
def isFound(array, x):
"""linear search"""
array.append(x)
i = 0
while array[i] != x:
i += 1
if i == len(array) - 1:
return False
return True
n = int(eval(input()))
S = list(map(int, input().split()))
q = int(eval(input()))
T = list(map(int, input().split... | # coding:utf-8
# 1_4_A
n = int(eval(input()))
S = set(map(int, input().split()))
q = int(eval(input()))
T = set(map(int, input().split()))
print((len(S & T)))
| false | 65.217391 | [
"-def isFound(array, x):",
"- \"\"\"linear search\"\"\"",
"- array.append(x)",
"- i = 0",
"- while array[i] != x:",
"- i += 1",
"- if i == len(array) - 1:",
"- return False",
"- return True",
"-",
"-",
"-S = list(map(int, input().split()))",
"+S = set(map(int,... | false | 0.093096 | 0.04017 | 2.317527 | [
"s105618600",
"s832633573"
] |
u604655161 | p02658 | python | s383140805 | s926519863 | 66 | 51 | 21,660 | 21,640 | Accepted | Accepted | 22.73 | N = int(eval(input()))
A = [int(x) for x in input().split()]
reg = A[0]
flg=True
if 0 in A:
print((0))
flg=False
reg=0
for i in range(1, N):
reg *= A[i]
if reg>10**18:
print((-1))
flg=False
break
if flg:
print(reg) | def ABC_169_B():
N=int(eval(input()))
A = input().split()
A = [int(s) for s in A]
sum=1
flg=0
if A.count(0)>=1:
print((0))
flg=1
if flg==0:
for i in range(len(A)):
sum=(sum*A[i])
if sum>10**18:
print((-1))
flg... | 17 | 24 | 269 | 425 | N = int(eval(input()))
A = [int(x) for x in input().split()]
reg = A[0]
flg = True
if 0 in A:
print((0))
flg = False
reg = 0
for i in range(1, N):
reg *= A[i]
if reg > 10**18:
print((-1))
flg = False
break
if flg:
print(reg)
| def ABC_169_B():
N = int(eval(input()))
A = input().split()
A = [int(s) for s in A]
sum = 1
flg = 0
if A.count(0) >= 1:
print((0))
flg = 1
if flg == 0:
for i in range(len(A)):
sum = sum * A[i]
if sum > 10**18:
print((-1))
... | false | 29.166667 | [
"-N = int(eval(input()))",
"-A = [int(x) for x in input().split()]",
"-reg = A[0]",
"-flg = True",
"-if 0 in A:",
"- print((0))",
"- flg = False",
"- reg = 0",
"-for i in range(1, N):",
"- reg *= A[i]",
"- if reg > 10**18:",
"- print((-1))",
"- flg = False",
"-... | false | 0.091656 | 0.046149 | 1.986073 | [
"s383140805",
"s926519863"
] |
u021019433 | p02803 | python | s058794513 | s198852908 | 754 | 673 | 3,444 | 3,316 | Accepted | Accepted | 10.74 | from collections import deque
from copy import deepcopy
h, w = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(h)]
r = 0
for i in range(h):
for j in range(w):
if a[i][j] == '.':
b = deepcopy(a)
q = deque()
b[i][j] = 0
q.append((i, j))
while(q):
... | from collections import deque
h, w = list(map(int, input().split()))
a = [eval(input()) for _ in range(h)]
r = 0
for i in range(h):
for j in range(w):
if a[i][j] == '.':
b = list(map(list, a))
q = deque()
b[i][j] = 0
q.append((i, j))
while(q):
i, j = q.popleft()... | 25 | 24 | 677 | 651 | from collections import deque
from copy import deepcopy
h, w = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(h)]
r = 0
for i in range(h):
for j in range(w):
if a[i][j] == ".":
b = deepcopy(a)
q = deque()
b[i][j] = 0
q.append((i, j))
... | from collections import deque
h, w = list(map(int, input().split()))
a = [eval(input()) for _ in range(h)]
r = 0
for i in range(h):
for j in range(w):
if a[i][j] == ".":
b = list(map(list, a))
q = deque()
b[i][j] = 0
q.append((i, j))
while q:
... | false | 4 | [
"-from copy import deepcopy",
"-a = [list(eval(input())) for _ in range(h)]",
"+a = [eval(input()) for _ in range(h)]",
"- b = deepcopy(a)",
"+ b = list(map(list, a))"
] | false | 0.044927 | 0.1518 | 0.295963 | [
"s058794513",
"s198852908"
] |
u858742833 | p02936 | python | s564001110 | s138940453 | 2,000 | 1,700 | 146,936 | 88,736 | Accepted | Accepted | 15 | import sys
sys.setrecursionlimit(10**7)
def main():
N, Q = [int(i) for i in input().split()]
V = [set() for _ in range(N)]
for _ in range(N - 1):
a, b = [int(i) - 1 for i in input().split()]
V[a].add(b)
V[b].add(a)
C = [0] * N
for _ in range(Q):
p, x = [i... | def main():
N, Q = [int(i) for i in input().split()]
V = [set() for _ in range(N)]
for _ in range(N - 1):
a, b = [int(i) - 1 for i in input().split()]
V[a].add(b)
V[b].add(a)
C = [0] * N
for _ in range(Q):
p, x = [int(i) for i in input().split()]
C[p... | 26 | 21 | 653 | 556 | import sys
sys.setrecursionlimit(10**7)
def main():
N, Q = [int(i) for i in input().split()]
V = [set() for _ in range(N)]
for _ in range(N - 1):
a, b = [int(i) - 1 for i in input().split()]
V[a].add(b)
V[b].add(a)
C = [0] * N
for _ in range(Q):
p, x = [int(i) for ... | def main():
N, Q = [int(i) for i in input().split()]
V = [set() for _ in range(N)]
for _ in range(N - 1):
a, b = [int(i) - 1 for i in input().split()]
V[a].add(b)
V[b].add(a)
C = [0] * N
for _ in range(Q):
p, x = [int(i) for i in input().split()]
C[p - 1] += x... | false | 19.230769 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**7)",
"-",
"-",
"- nxt = []",
"- for n, x in cur:",
"- C[n] = x = C[n] + x",
"- for c in V[n]:",
"- V[c].remove(n)",
"- nxt.append((c, x))",
"- cur = nxt",
"+ n, x =... | false | 0.038434 | 0.038223 | 1.005525 | [
"s564001110",
"s138940453"
] |
u186838327 | p03987 | python | s180085487 | s913647668 | 591 | 302 | 41,968 | 107,576 | Accepted | Accepted | 48.9 | n = int(eval(input()))
A = list(map(int, input().split()))
P = [0]*n
for i, a in enumerate(A):
P[a-1] = i
import heapq
q = []
heapq.heapify(q)
R = [n-1]*n
for i, a in enumerate(A):
while q and q[0]*(-1) > a:
v = heapq.heappop(q)*(-1)
R[v-1] = i-1
heapq.heappush(q, a*(-1))
... | n = int(eval(input()))
A = list(map(int, input().split()))
A = [a-1 for a in A]
P = [-1]*n
for i, a in enumerate(A):
P[a] = i
R = [n]*n
q = []
import heapq
heapq.heapify(q)
for i in range(n):
while q:
if -q[0] > A[i]:
v = -heapq.heappop(q)
R[v] = i
else... | 35 | 39 | 641 | 712 | n = int(eval(input()))
A = list(map(int, input().split()))
P = [0] * n
for i, a in enumerate(A):
P[a - 1] = i
import heapq
q = []
heapq.heapify(q)
R = [n - 1] * n
for i, a in enumerate(A):
while q and q[0] * (-1) > a:
v = heapq.heappop(q) * (-1)
R[v - 1] = i - 1
heapq.heappush(q, a * (-1))
... | n = int(eval(input()))
A = list(map(int, input().split()))
A = [a - 1 for a in A]
P = [-1] * n
for i, a in enumerate(A):
P[a] = i
R = [n] * n
q = []
import heapq
heapq.heapify(q)
for i in range(n):
while q:
if -q[0] > A[i]:
v = -heapq.heappop(q)
R[v] = i
else:
... | false | 10.25641 | [
"-P = [0] * n",
"+A = [a - 1 for a in A]",
"+P = [-1] * n",
"- P[a - 1] = i",
"+ P[a] = i",
"+R = [n] * n",
"+q = []",
"+heapq.heapify(q)",
"+for i in range(n):",
"+ while q:",
"+ if -q[0] > A[i]:",
"+ v = -heapq.heappop(q)",
"+ R[v] = i",
"+ el... | false | 0.036784 | 0.036116 | 1.018504 | [
"s180085487",
"s913647668"
] |
u222668979 | p02690 | python | s669417486 | s703713065 | 53 | 47 | 9,316 | 9,484 | Accepted | Accepted | 11.32 | from itertools import combinations
x = int(eval(input()))
num = [i**5 for i in range(1000)]
for a, b in combinations(num, 2):
if a - b == x:
print((int(a**0.2), int(b**0.2)))
elif a + b == x:
print((int(a**0.2), -int(b**0.2)))
elif b - a == x:
print((int(b**0.2), int(a**... | from itertools import combinations
x = int(eval(input()))
num = [i**5 for i in range(1000)]
for a, b in combinations(num, 2):
if a - b == x:
print((int(a**0.2), int(b**0.2)))
elif a + b == x:
print((int(a**0.2), -int(b**0.2)))
elif b - a == x:
print((int(b**0.2), int(a**... | 17 | 15 | 419 | 355 | from itertools import combinations
x = int(eval(input()))
num = [i**5 for i in range(1000)]
for a, b in combinations(num, 2):
if a - b == x:
print((int(a**0.2), int(b**0.2)))
elif a + b == x:
print((int(a**0.2), -int(b**0.2)))
elif b - a == x:
print((int(b**0.2), int(a**0.2)))
e... | from itertools import combinations
x = int(eval(input()))
num = [i**5 for i in range(1000)]
for a, b in combinations(num, 2):
if a - b == x:
print((int(a**0.2), int(b**0.2)))
elif a + b == x:
print((int(a**0.2), -int(b**0.2)))
elif b - a == x:
print((int(b**0.2), int(a**0.2)))
e... | false | 11.764706 | [
"- elif b + a == x:",
"- print((int(b**0.2), -int(a**0.2)))"
] | false | 0.113073 | 0.072428 | 1.56118 | [
"s669417486",
"s703713065"
] |
u256678932 | p02406 | python | s099159544 | s442919261 | 40 | 20 | 6,108 | 6,240 | Accepted | Accepted | 50 | def call_filter(x):
if x % 3 == 0: return True
while x > 0:
if x % 10 == 3: return True
x = int(x/10)
return False
def call(n):
for i in [x for x in range(1, n+1) if call_filter(x)]:
print(' {}'.format(i), end='')
print()
n = int(input())
call(n)
| def calc(n):
for i in range(1, n+1):
if i % 3 == 0:
print("", i, end='')
continue
x = i
while x > 0:
if x % 10 == 3:
print("", i, end='')
break
x = x // 10
print()
calc(int(input()))
| 17 | 19 | 312 | 319 | def call_filter(x):
if x % 3 == 0:
return True
while x > 0:
if x % 10 == 3:
return True
x = int(x / 10)
return False
def call(n):
for i in [x for x in range(1, n + 1) if call_filter(x)]:
print(" {}".format(i), end="")
print()
n = int(input())
call(n)
| def calc(n):
for i in range(1, n + 1):
if i % 3 == 0:
print("", i, end="")
continue
x = i
while x > 0:
if x % 10 == 3:
print("", i, end="")
break
x = x // 10
print()
calc(int(input()))
| false | 10.526316 | [
"-def call_filter(x):",
"- if x % 3 == 0:",
"- return True",
"- while x > 0:",
"- if x % 10 == 3:",
"- return True",
"- x = int(x / 10)",
"- return False",
"-",
"-",
"-def call(n):",
"- for i in [x for x in range(1, n + 1) if call_filter(x)]:",
"- ... | false | 0.046986 | 0.046549 | 1.009369 | [
"s099159544",
"s442919261"
] |
u096025032 | p02969 | python | s228179644 | s102813329 | 29 | 25 | 9,092 | 9,088 | Accepted | Accepted | 13.79 | print((3*(int(eval(input()))**2))) | print((3*int(eval(input()))**2)) | 1 | 1 | 26 | 24 | print((3 * (int(eval(input())) ** 2)))
| print((3 * int(eval(input())) ** 2))
| false | 0 | [
"-print((3 * (int(eval(input())) ** 2)))",
"+print((3 * int(eval(input())) ** 2))"
] | false | 0.044879 | 0.043322 | 1.035932 | [
"s228179644",
"s102813329"
] |
u197457087 | p02607 | python | s743217599 | s671423218 | 63 | 26 | 61,572 | 9,168 | Accepted | Accepted | 58.73 | N = int(eval(input()))
A = list(map(int,input().split()))
ans = 0
for i in range(N):
if (i+1)%2 == 1 and A[i]%2 == 1:
ans +=1
print(ans) | N = int(eval(input()))
A = list(map(int,input().split()))
ans = 0
for i in range(N):
if i%2 == 0 and A[i]%2 == 1:
ans +=1
print(ans) | 8 | 7 | 144 | 138 | N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for i in range(N):
if (i + 1) % 2 == 1 and A[i] % 2 == 1:
ans += 1
print(ans)
| N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for i in range(N):
if i % 2 == 0 and A[i] % 2 == 1:
ans += 1
print(ans)
| false | 12.5 | [
"- if (i + 1) % 2 == 1 and A[i] % 2 == 1:",
"+ if i % 2 == 0 and A[i] % 2 == 1:"
] | false | 0.039309 | 0.035573 | 1.105024 | [
"s743217599",
"s671423218"
] |
u761320129 | p03032 | python | s209607363 | s090448601 | 42 | 29 | 3,064 | 3,064 | Accepted | Accepted | 30.95 | N,K = list(map(int,input().split()))
V = list(map(int,input().split()))
ans = 0
for l in range(N):
for r in range(N-l+1):
arr = V[:l] + ([] if r==0 else V[-r:])
k = len(arr)
if k > K: continue
score = sum(arr)
arr.sort()
i = 0
while k < K and i < len(arr):
if arr[i] >= ... | N,K = list(map(int,input().split()))
V = list(map(int,input().split()))
ans = 0
for l in range(N):
if l > K: break
for r in range(N-l+1):
if l+r > K: break
vs = V[:l] + (V[-r:] if r>0 else [])
vs.sort()
k = K-l-r
t = 0
for v in vs:
if v <... | 19 | 19 | 412 | 435 | N, K = list(map(int, input().split()))
V = list(map(int, input().split()))
ans = 0
for l in range(N):
for r in range(N - l + 1):
arr = V[:l] + ([] if r == 0 else V[-r:])
k = len(arr)
if k > K:
continue
score = sum(arr)
arr.sort()
i = 0
while k < K ... | N, K = list(map(int, input().split()))
V = list(map(int, input().split()))
ans = 0
for l in range(N):
if l > K:
break
for r in range(N - l + 1):
if l + r > K:
break
vs = V[:l] + (V[-r:] if r > 0 else [])
vs.sort()
k = K - l - r
t = 0
for v in v... | false | 0 | [
"+ if l > K:",
"+ break",
"- arr = V[:l] + ([] if r == 0 else V[-r:])",
"- k = len(arr)",
"- if k > K:",
"- continue",
"- score = sum(arr)",
"- arr.sort()",
"- i = 0",
"- while k < K and i < len(arr):",
"- if arr[i]... | false | 0.039586 | 0.037964 | 1.042727 | [
"s209607363",
"s090448601"
] |
u633068244 | p01223 | python | s157653911 | s370356924 | 20 | 10 | 4,224 | 4,228 | Accepted | Accepted | 50 | for i in range(eval(input())):
n=eval(input())
a=list(map(int,input().split()))
l=[a[i+1]-a[i] for i in range(n-1)]
print(max(0,max(l)),abs(min(0,min(l)))) | for j in [1]*eval(input()):
n=eval(input())
a=list(map(int,input().split()))
l=[a[i+1]-a[i] for i in range(n-1)]
print(max(0,max(l)),-min(-0,min(l))) | 5 | 5 | 148 | 142 | for i in range(eval(input())):
n = eval(input())
a = list(map(int, input().split()))
l = [a[i + 1] - a[i] for i in range(n - 1)]
print(max(0, max(l)), abs(min(0, min(l))))
| for j in [1] * eval(input()):
n = eval(input())
a = list(map(int, input().split()))
l = [a[i + 1] - a[i] for i in range(n - 1)]
print(max(0, max(l)), -min(-0, min(l)))
| false | 0 | [
"-for i in range(eval(input())):",
"+for j in [1] * eval(input()):",
"- print(max(0, max(l)), abs(min(0, min(l))))",
"+ print(max(0, max(l)), -min(-0, min(l)))"
] | false | 0.111381 | 0.16313 | 0.682779 | [
"s157653911",
"s370356924"
] |
u426108351 | p03013 | python | s500285436 | s464338155 | 571 | 186 | 47,192 | 7,668 | Accepted | Accepted | 67.43 | N, M = list(map(int, input().split()))
kaidan = [True] * (N+2)
for i in range(M):
kaidan[int(eval(input()))] = False
dp = [0]*(N+2)
dp[0] = 1
for i in range(N):
if kaidan[i+2]:
dp[i+2] += dp[i]
dp[i+2] %= 1000000007
if kaidan[i+1]:
dp[i+1] += dp[i]
dp[i+1] %= 10... | N, M = list(map(int, input().split()))
kaidan = [True] * (N+3)
for i in range(M):
kaidan[int(eval(input()))] = False
dp = [0]*(N+3)
dp[0] = 1
for i in range(N):
if kaidan[i+2]:
dp[i+2] += dp[i]
dp[i+2] %= 1000000007
if kaidan[i+1]:
dp[i+1] += dp[i]
dp[i+1] %= 10... | 16 | 16 | 333 | 333 | N, M = list(map(int, input().split()))
kaidan = [True] * (N + 2)
for i in range(M):
kaidan[int(eval(input()))] = False
dp = [0] * (N + 2)
dp[0] = 1
for i in range(N):
if kaidan[i + 2]:
dp[i + 2] += dp[i]
dp[i + 2] %= 1000000007
if kaidan[i + 1]:
dp[i + 1] += dp[i]
dp[i + 1] %... | N, M = list(map(int, input().split()))
kaidan = [True] * (N + 3)
for i in range(M):
kaidan[int(eval(input()))] = False
dp = [0] * (N + 3)
dp[0] = 1
for i in range(N):
if kaidan[i + 2]:
dp[i + 2] += dp[i]
dp[i + 2] %= 1000000007
if kaidan[i + 1]:
dp[i + 1] += dp[i]
dp[i + 1] %... | false | 0 | [
"-kaidan = [True] * (N + 2)",
"+kaidan = [True] * (N + 3)",
"-dp = [0] * (N + 2)",
"+dp = [0] * (N + 3)"
] | false | 0.041211 | 0.108915 | 0.378378 | [
"s500285436",
"s464338155"
] |
u532966492 | p03488 | python | s188972883 | s417433045 | 576 | 506 | 3,692 | 3,692 | Accepted | Accepted | 12.15 | from itertools import accumulate
S=list(map(len,input().split("T")))
x,y=list(map(int,input().split()))
x=abs(x-S[0])
y=abs(y)
L=S[2::2]
R=S[1::2]
La=list(accumulate(L))
Ra=list(accumulate(R))
sumL=sum(L)
sumR=sum(R)
flag=0
if sumL>=x and sumR>=y and (sumL-x)%2==0 and (sumR-y)%2==0 and flag==0:
setL1={... | S=list(map(len,input().split("T")))
x,y=list(map(int,input().split()))
x=abs(x-S[0])
y=abs(y)
L=S[2::2]
R=S[1::2]
sumL=sum(L)
sumR=sum(R)
flag=0
if sumL>=x and sumR>=y and (sumL-x)%2==0 and (sumR-y)%2==0 and flag==0:
setL1={0}
setR1={0}
gL=(sumL-x)//2
gR=(sumR-y)//2
if gL==0:
... | 54 | 51 | 1,231 | 1,149 | from itertools import accumulate
S = list(map(len, input().split("T")))
x, y = list(map(int, input().split()))
x = abs(x - S[0])
y = abs(y)
L = S[2::2]
R = S[1::2]
La = list(accumulate(L))
Ra = list(accumulate(R))
sumL = sum(L)
sumR = sum(R)
flag = 0
if (
sumL >= x
and sumR >= y
and (sumL - x) % 2 == 0
... | S = list(map(len, input().split("T")))
x, y = list(map(int, input().split()))
x = abs(x - S[0])
y = abs(y)
L = S[2::2]
R = S[1::2]
sumL = sum(L)
sumR = sum(R)
flag = 0
if (
sumL >= x
and sumR >= y
and (sumL - x) % 2 == 0
and (sumR - y) % 2 == 0
and flag == 0
):
setL1 = {0}
setR1 = {0}
gL... | false | 5.555556 | [
"-from itertools import accumulate",
"-",
"-La = list(accumulate(L))",
"-Ra = list(accumulate(R))"
] | false | 0.078776 | 0.041029 | 1.920008 | [
"s188972883",
"s417433045"
] |
u576432509 | p03290 | python | s160081583 | s373644130 | 293 | 22 | 3,188 | 3,064 | Accepted | Accepted | 92.49 | d,g=list(map(int,input().split()))
spc=[]
c=[]
for i in range(d):
pi,ci=list(map(int,input().split()))
si=pi*100*(i+1)+ci
av=si//pi
spc.append([av,si,pi,ci,100*(i+1)])
#print(spc)
spc.sort(reverse=True)
#print(spc)
#r=g
#icnt=0
#for i in range(d):
# r=r-spc[i][1]
# icnt=icnt+spc... |
import itertools
d,g=list(map(int,input().split()))
pc=[[0]*2 for i in range(d)]
for i in range(d):
pc[i]=list(map(int,input().split()))
icntmin=10*100+1
for j in itertools.product([0,1], repeat=d):
icnt=0
gcnt=0
for i in range(d):
if j[i]==1:
icnt+=pc[i][0]
... | 57 | 34 | 1,252 | 745 | d, g = list(map(int, input().split()))
spc = []
c = []
for i in range(d):
pi, ci = list(map(int, input().split()))
si = pi * 100 * (i + 1) + ci
av = si // pi
spc.append([av, si, pi, ci, 100 * (i + 1)])
# print(spc)
spc.sort(reverse=True)
# print(spc)
# r=g
# icnt=0
# for i in range(d):
# r=r-spc[i][1]... | import itertools
d, g = list(map(int, input().split()))
pc = [[0] * 2 for i in range(d)]
for i in range(d):
pc[i] = list(map(int, input().split()))
icntmin = 10 * 100 + 1
for j in itertools.product([0, 1], repeat=d):
icnt = 0
gcnt = 0
for i in range(d):
if j[i] == 1:
icnt += pc[i][0... | false | 40.350877 | [
"+import itertools",
"+",
"-spc = []",
"-c = []",
"+pc = [[0] * 2 for i in range(d)]",
"- pi, ci = list(map(int, input().split()))",
"- si = pi * 100 * (i + 1) + ci",
"- av = si // pi",
"- spc.append([av, si, pi, ci, 100 * (i + 1)])",
"-# print(spc)",
"-spc.sort(reverse=True)",
"-#... | false | 0.039021 | 0.03923 | 0.994689 | [
"s160081583",
"s373644130"
] |
u188827677 | p02861 | python | s021027635 | s791860924 | 286 | 25 | 9,404 | 9,392 | Accepted | Accepted | 91.26 | from itertools import permutations
n = int(eval(input()))
xy = [list(map(int, input().split())) for _ in range(n)]
ans = 0
count = 0
for i in permutations(list(range(n)), n):
for j in range(n-1):
ans += ((xy[i[j]][0] - xy[i[j+1]][0])**2 + (xy[i[j]][1] - xy[i[j+1]][1])**2)**0.5
count += 1
print((ans... | n = int(eval(input()))
xy = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in range(n):
for j in range(n):
if i == j: continue
ans += ((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2)**0.5
print((ans/n)) | 12 | 9 | 314 | 237 | from itertools import permutations
n = int(eval(input()))
xy = [list(map(int, input().split())) for _ in range(n)]
ans = 0
count = 0
for i in permutations(list(range(n)), n):
for j in range(n - 1):
ans += (
(xy[i[j]][0] - xy[i[j + 1]][0]) ** 2 + (xy[i[j]][1] - xy[i[j + 1]][1]) ** 2
) **... | n = int(eval(input()))
xy = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in range(n):
for j in range(n):
if i == j:
continue
ans += ((xy[i][0] - xy[j][0]) ** 2 + (xy[i][1] - xy[j][1]) ** 2) ** 0.5
print((ans / n))
| false | 25 | [
"-from itertools import permutations",
"-",
"-count = 0",
"-for i in permutations(list(range(n)), n):",
"- for j in range(n - 1):",
"- ans += (",
"- (xy[i[j]][0] - xy[i[j + 1]][0]) ** 2 + (xy[i[j]][1] - xy[i[j + 1]][1]) ** 2",
"- ) ** 0.5",
"- count += 1",
"-print((a... | false | 0.152333 | 0.040027 | 3.805726 | [
"s021027635",
"s791860924"
] |
u497046426 | p03724 | python | s521398434 | s033955541 | 369 | 311 | 20,568 | 3,828 | Accepted | Accepted | 15.72 | N, M = list(map(int, input().split()))
paths = [tuple(map(int, input().split())) for _ in range(M)]
e_vals = [0]*(N+1)
for u, v in paths:
if u > v: u, v = v, u
e_vals[u] += 1; e_vals[v] -= 1;
for i in range(1, N+1):
e_vals[i] += e_vals[i-1]
if e_vals[i] % 2 == 1: print('NO'); break;
else: print... | N, M = list(map(int, input().split()))
cnt = [True]*N
for _ in range(M):
a, b = list(map(int, input().split()))
cnt[a-1] = not cnt[a-1]; cnt[b-1] = not cnt[b-1];
print(('YES' if all(cnt) else 'NO')) | 10 | 6 | 321 | 197 | N, M = list(map(int, input().split()))
paths = [tuple(map(int, input().split())) for _ in range(M)]
e_vals = [0] * (N + 1)
for u, v in paths:
if u > v:
u, v = v, u
e_vals[u] += 1
e_vals[v] -= 1
for i in range(1, N + 1):
e_vals[i] += e_vals[i - 1]
if e_vals[i] % 2 == 1:
print("NO")
... | N, M = list(map(int, input().split()))
cnt = [True] * N
for _ in range(M):
a, b = list(map(int, input().split()))
cnt[a - 1] = not cnt[a - 1]
cnt[b - 1] = not cnt[b - 1]
print(("YES" if all(cnt) else "NO"))
| false | 40 | [
"-paths = [tuple(map(int, input().split())) for _ in range(M)]",
"-e_vals = [0] * (N + 1)",
"-for u, v in paths:",
"- if u > v:",
"- u, v = v, u",
"- e_vals[u] += 1",
"- e_vals[v] -= 1",
"-for i in range(1, N + 1):",
"- e_vals[i] += e_vals[i - 1]",
"- if e_vals[i] % 2 == 1:",... | false | 0.109805 | 0.037952 | 2.893253 | [
"s521398434",
"s033955541"
] |
u049979154 | p02577 | python | s047454029 | s212069051 | 710 | 203 | 11,084 | 9,296 | Accepted | Accepted | 71.41 | n = int(eval(input()))
result = sum(list(map(int, str(n))))
if result % 9 == 0:
print('Yes')
else:
print('No') | n = int(eval(input()))
if n % 9 == 0:
print('Yes')
else:
print('No') | 8 | 6 | 121 | 72 | n = int(eval(input()))
result = sum(list(map(int, str(n))))
if result % 9 == 0:
print("Yes")
else:
print("No")
| n = int(eval(input()))
if n % 9 == 0:
print("Yes")
else:
print("No")
| false | 25 | [
"-result = sum(list(map(int, str(n))))",
"-if result % 9 == 0:",
"+if n % 9 == 0:"
] | false | 0.034301 | 0.037574 | 0.912894 | [
"s047454029",
"s212069051"
] |
u891635666 | p03837 | python | s948070649 | s055626862 | 609 | 539 | 3,444 | 3,444 | Accepted | Accepted | 11.49 | n, m = list(map(int, input().split()))
cs = [[float('inf')] * n for _ in range(n)]
for i in range(n):
cs[i][i] = 0
es = []
for _ in range(m):
a, b, c = list(map(int, input().split()))
a -= 1
b -= 1
es.append((a, b, c))
cs[a][b] = cs[b][a] = c
for k in range(n):
for i in range(n):... | n, m = list(map(int, input().split()))
cs = [[float('inf')] * n for _ in range(n)]
ns = [[0] * n for _ in range(n)]
for i in range(n):
cs[i][i] = 0
for _ in range(m):
a, b, c = list(map(int, input().split()))
a -= 1
b -= 1
cs[a][b] = cs[b][a] = c
ns[a][b] = b
ns[b][a] = a
for k i... | 16 | 29 | 447 | 767 | n, m = list(map(int, input().split()))
cs = [[float("inf")] * n for _ in range(n)]
for i in range(n):
cs[i][i] = 0
es = []
for _ in range(m):
a, b, c = list(map(int, input().split()))
a -= 1
b -= 1
es.append((a, b, c))
cs[a][b] = cs[b][a] = c
for k in range(n):
for i in range(n):
for... | n, m = list(map(int, input().split()))
cs = [[float("inf")] * n for _ in range(n)]
ns = [[0] * n for _ in range(n)]
for i in range(n):
cs[i][i] = 0
for _ in range(m):
a, b, c = list(map(int, input().split()))
a -= 1
b -= 1
cs[a][b] = cs[b][a] = c
ns[a][b] = b
ns[b][a] = a
for k in range(n):
... | false | 44.827586 | [
"+ns = [[0] * n for _ in range(n)]",
"-es = []",
"- es.append((a, b, c))",
"+ ns[a][b] = b",
"+ ns[b][a] = a",
"- cs[i][j] = min(cs[i][j], cs[i][k] + cs[k][j])",
"-print((sum([1 for a, b, c in es if cs[a][b] != c])))",
"+ s = cs[i][k] + cs[k][j]",
"+ if s < ... | false | 0.137489 | 0.093175 | 1.475592 | [
"s948070649",
"s055626862"
] |
u606045429 | p03075 | python | s549513733 | s862867268 | 20 | 18 | 3,316 | 2,940 | Accepted | Accepted | 10 | *A, k = [int(eval(input())) for _ in range(6)]
for ai in A:
for aj in A:
if abs(aj - ai) > k:
print(":(")
quit()
print("Yay!") | *A, k = [int(eval(input())) for _ in range(6)]
if abs(A[0] - A[-1]) > k:
print(":(")
else:
print("Yay!")
| 8 | 5 | 164 | 111 | *A, k = [int(eval(input())) for _ in range(6)]
for ai in A:
for aj in A:
if abs(aj - ai) > k:
print(":(")
quit()
print("Yay!")
| *A, k = [int(eval(input())) for _ in range(6)]
if abs(A[0] - A[-1]) > k:
print(":(")
else:
print("Yay!")
| false | 37.5 | [
"-for ai in A:",
"- for aj in A:",
"- if abs(aj - ai) > k:",
"- print(\":(\")",
"- quit()",
"-print(\"Yay!\")",
"+if abs(A[0] - A[-1]) > k:",
"+ print(\":(\")",
"+else:",
"+ print(\"Yay!\")"
] | false | 0.095651 | 0.090524 | 1.056639 | [
"s549513733",
"s862867268"
] |
u347600233 | p02608 | python | s192397828 | s542137698 | 976 | 194 | 9,364 | 9,588 | Accepted | Accepted | 80.12 | n = int(input())
ans = [0] * (n + 1)
for x in range(1, int(n**0.5) + 1):
for y in range(1, int(n**0.5) + 1):
for z in range(1, int(n**0.5) + 1):
if x**2 + y**2 + z**2 + x*y + y*z + z*x <= n:
ans[x**2 + y**2 + z**2 + x*y + y*z + z*x] += 1
print(*ans[1:], sep='\n')
| n = int(input())
ans = [0] * (n + 1)
a = [1, 3, 6]
for x in range(1, int(n**0.5) + 1):
for y in range(x, int(n**0.5) + 1):
for z in range(y, int(n**0.5) + 1):
v = x**2 + y**2 + z**2 + x*y + y*z + z*x
if v <= n:
ans[v] += a[len(set([x, y, z])) - 1]
print(*ans[... | 8 | 10 | 310 | 334 | n = int(input())
ans = [0] * (n + 1)
for x in range(1, int(n**0.5) + 1):
for y in range(1, int(n**0.5) + 1):
for z in range(1, int(n**0.5) + 1):
if x**2 + y**2 + z**2 + x * y + y * z + z * x <= n:
ans[x**2 + y**2 + z**2 + x * y + y * z + z * x] += 1
print(*ans[1:], sep="\n")
| n = int(input())
ans = [0] * (n + 1)
a = [1, 3, 6]
for x in range(1, int(n**0.5) + 1):
for y in range(x, int(n**0.5) + 1):
for z in range(y, int(n**0.5) + 1):
v = x**2 + y**2 + z**2 + x * y + y * z + z * x
if v <= n:
ans[v] += a[len(set([x, y, z])) - 1]
print(*ans[1:]... | false | 20 | [
"+a = [1, 3, 6]",
"- for y in range(1, int(n**0.5) + 1):",
"- for z in range(1, int(n**0.5) + 1):",
"- if x**2 + y**2 + z**2 + x * y + y * z + z * x <= n:",
"- ans[x**2 + y**2 + z**2 + x * y + y * z + z * x] += 1",
"+ for y in range(x, int(n**0.5) + 1):",
"+ ... | false | 0.0356 | 0.035348 | 1.007136 | [
"s192397828",
"s542137698"
] |
u163320134 | p02834 | python | s756819390 | s113539225 | 984 | 497 | 101,548 | 34,276 | Accepted | Accepted | 49.49 | import collections
import sys
sys.setrecursionlimit(10**7)
def dfs(u):
for v in g[u]:
if checked[v]==1:
continue
else:
checked[v]=1
depth2[u]=max(depth2[u],dfs(v)+1)
return depth2[u]
n,u,v=list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(n-1):
a,... | import collections
n,u,v=list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(n-1):
a,b=list(map(int,input().split()))
g[a].append(b)
g[b].append(a)
q=collections.deque()
q.append((v,0))
checked=[0]*(n+1)
dist1=[0]*(n+1)
while len(q)!=0:
tv,td=q.popleft()
checked[tv]=1
di... | 63 | 37 | 1,132 | 737 | import collections
import sys
sys.setrecursionlimit(10**7)
def dfs(u):
for v in g[u]:
if checked[v] == 1:
continue
else:
checked[v] = 1
depth2[u] = max(depth2[u], dfs(v) + 1)
return depth2[u]
n, u, v = list(map(int, input().split()))
g = [[] for _ in rang... | import collections
n, u, v = list(map(int, input().split()))
g = [[] for _ in range(n + 1)]
for _ in range(n - 1):
a, b = list(map(int, input().split()))
g[a].append(b)
g[b].append(a)
q = collections.deque()
q.append((v, 0))
checked = [0] * (n + 1)
dist1 = [0] * (n + 1)
while len(q) != 0:
tv, td = q.po... | false | 41.269841 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**7)",
"-",
"-",
"-def dfs(u):",
"- for v in g[u]:",
"- if checked[v] == 1:",
"- continue",
"- else:",
"- checked[v] = 1",
"- depth2[u] = max(depth2[u], dfs(v) + 1)",
"- return depth2[u]",
"-... | false | 0.039446 | 0.088472 | 0.445855 | [
"s756819390",
"s113539225"
] |
u627143908 | p02681 | python | s486076487 | s152973496 | 23 | 19 | 9,024 | 9,000 | Accepted | Accepted | 17.39 | s = eval(input())
t = eval(input())
l = len(t)-1
if s == t[:l]:
print('Yes')
else:
print('No') | s = input()
t = input()
l = len(t)-1
print('Yes') if s == t[:l] else print('No')
| 7 | 4 | 96 | 83 | s = eval(input())
t = eval(input())
l = len(t) - 1
if s == t[:l]:
print("Yes")
else:
print("No")
| s = input()
t = input()
l = len(t) - 1
print("Yes") if s == t[:l] else print("No")
| false | 42.857143 | [
"-s = eval(input())",
"-t = eval(input())",
"+s = input()",
"+t = input()",
"-if s == t[:l]:",
"- print(\"Yes\")",
"-else:",
"- print(\"No\")",
"+print(\"Yes\") if s == t[:l] else print(\"No\")"
] | false | 0.042319 | 0.040208 | 1.052501 | [
"s486076487",
"s152973496"
] |
u668503853 | p03457 | python | s741196988 | s518971724 | 447 | 317 | 27,300 | 3,060 | Accepted | Accepted | 29.08 | N=int(eval(input()))
li=[list(map(int,input().split())) for _ in range(N)]
li.insert(0,[0,0,0])
ans="Yes"
for i in range(N):
if li[i+1][0]-li[i][0]<abs(li[i+1][1]-li[i][1])+abs(li[i+1][2]-li[i][2]) or (li[i+1][0]-li[i][0])%2!=abs(li[i+1][1]-li[i][1]+li[i+1][2]-li[i][2])%2:
ans="No"
print(ans) | N=int(eval(input()))
ans="Yes"
for _ in range(N):
t,x,y=list(map(int,input().split()))
if t<x+y or t%2!=(x+y)%2:
ans="No"
print(ans) | 8 | 7 | 300 | 134 | N = int(eval(input()))
li = [list(map(int, input().split())) for _ in range(N)]
li.insert(0, [0, 0, 0])
ans = "Yes"
for i in range(N):
if (
li[i + 1][0] - li[i][0]
< abs(li[i + 1][1] - li[i][1]) + abs(li[i + 1][2] - li[i][2])
or (li[i + 1][0] - li[i][0]) % 2
!= abs(li[i + 1][1] - li[... | N = int(eval(input()))
ans = "Yes"
for _ in range(N):
t, x, y = list(map(int, input().split()))
if t < x + y or t % 2 != (x + y) % 2:
ans = "No"
print(ans)
| false | 12.5 | [
"-li = [list(map(int, input().split())) for _ in range(N)]",
"-li.insert(0, [0, 0, 0])",
"-for i in range(N):",
"- if (",
"- li[i + 1][0] - li[i][0]",
"- < abs(li[i + 1][1] - li[i][1]) + abs(li[i + 1][2] - li[i][2])",
"- or (li[i + 1][0] - li[i][0]) % 2",
"- != abs(li[i ... | false | 0.036648 | 0.036508 | 1.00384 | [
"s741196988",
"s518971724"
] |
u179169725 | p03356 | python | s144877747 | s736713798 | 722 | 609 | 89,304 | 13,876 | Accepted | Accepted | 15.65 | # https://atcoder.jp/contests/arc097/tasks/arc097_b
# Pについてp_xとp_yでuniteしていくと、スワップできる集合が獲得できる
# 1,2,3...i...Nにできるかだが, iについてp_iとiがスワップできるかはunion-findで探せばよい
import sys
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
def read_tuple(H):
'''
H is number of ro... | # https://atcoder.jp/contests/arc097/tasks/arc097_b
# Pについてp_xとp_yでuniteしていくと、スワップできる集合が獲得できる
# 1,2,3...i...Nにできるかだが, iについてp_iとiがスワップできるかはunion-findで探せばよい
import sys
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
def read_tuple(H):
'''
H is number of ro... | 84 | 79 | 2,038 | 1,814 | # https://atcoder.jp/contests/arc097/tasks/arc097_b
# Pについてp_xとp_yでuniteしていくと、スワップできる集合が獲得できる
# 1,2,3...i...Nにできるかだが, iについてp_iとiがスワップできるかはunion-findで探せばよい
import sys
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
def read_tuple(H):
"""
H is number of rows
"""
r... | # https://atcoder.jp/contests/arc097/tasks/arc097_b
# Pについてp_xとp_yでuniteしていくと、スワップできる集合が獲得できる
# 1,2,3...i...Nにできるかだが, iについてp_iとiがスワップできるかはunion-findで探せばよい
import sys
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
def read_tuple(H):
"""
H is number of rows
"""
r... | false | 5.952381 | [
"-from collections import defaultdict, Counter, deque",
"-from operator import itemgetter",
"-from itertools import product, permutations, combinations",
"-from bisect import bisect_left, bisect_right # , insort_left, insort_right",
"-"
] | false | 0.126239 | 0.047519 | 2.656598 | [
"s144877747",
"s736713798"
] |
u510829608 | p02259 | python | s260273718 | s867773214 | 40 | 20 | 7,700 | 7,688 | Accepted | Accepted | 50 | n = int(eval(input()))
li = list(map(int, input().split()))
cnt = 0
flag = True
while flag:
flag = False
for i in range(n-1,0,-1):
if li[i] < li[i-1]:
li[i], li[i-1] = li[i-1], li[i]
flag = True
cnt +=1
print((*li))
print(cnt) | N = int(eval(input()))
A = list(map(int, input().split()))
def bubblesort(A, N):
flag = True
i = 0
cnt = 0
while flag:
flag = False
for j in range(N-1, i, -1):
if A[j] < A[j-1]:
A[j], A[j-1] = A[j-1], A[j]
flag = True
... | 16 | 19 | 249 | 397 | n = int(eval(input()))
li = list(map(int, input().split()))
cnt = 0
flag = True
while flag:
flag = False
for i in range(n - 1, 0, -1):
if li[i] < li[i - 1]:
li[i], li[i - 1] = li[i - 1], li[i]
flag = True
cnt += 1
print((*li))
print(cnt)
| N = int(eval(input()))
A = list(map(int, input().split()))
def bubblesort(A, N):
flag = True
i = 0
cnt = 0
while flag:
flag = False
for j in range(N - 1, i, -1):
if A[j] < A[j - 1]:
A[j], A[j - 1] = A[j - 1], A[j]
flag = True
... | false | 15.789474 | [
"-n = int(eval(input()))",
"-li = list(map(int, input().split()))",
"-cnt = 0",
"-flag = True",
"-while flag:",
"- flag = False",
"- for i in range(n - 1, 0, -1):",
"- if li[i] < li[i - 1]:",
"- li[i], li[i - 1] = li[i - 1], li[i]",
"- flag = True",
"- ... | false | 0.038237 | 0.039322 | 0.972416 | [
"s260273718",
"s867773214"
] |
u347640436 | p02845 | python | s729156812 | s133335456 | 173 | 134 | 13,964 | 20,768 | Accepted | Accepted | 22.54 | N = int(eval(input()))
A = list(map(int, input().split()))
result = 1
t = [0, 0, 0]
for i in range(N):
a = A[i]
f = -1
k = 0
for j in range(3):
if t[j] == a:
k += 1
if f == -1:
t[j] += 1
f = j
result = (result * k) % 1000000007
print(result)
| N = int(eval(input()))
A = list(map(int, input().split()))
m = 1000000007
result = 1
t = [0, 0, 0]
for i in range(N):
a = A[i]
f = -1
k = 0
for j in range(3):
if t[j] == a:
k += 1
if f == -1:
t[j] += 1
f = j
result *=... | 17 | 20 | 295 | 349 | N = int(eval(input()))
A = list(map(int, input().split()))
result = 1
t = [0, 0, 0]
for i in range(N):
a = A[i]
f = -1
k = 0
for j in range(3):
if t[j] == a:
k += 1
if f == -1:
t[j] += 1
f = j
result = (result * k) % 1000000007
print(re... | N = int(eval(input()))
A = list(map(int, input().split()))
m = 1000000007
result = 1
t = [0, 0, 0]
for i in range(N):
a = A[i]
f = -1
k = 0
for j in range(3):
if t[j] == a:
k += 1
if f == -1:
t[j] += 1
f = j
result *= k
result %= m
... | false | 15 | [
"+m = 1000000007",
"- result = (result * k) % 1000000007",
"+ result *= k",
"+ result %= m"
] | false | 0.133225 | 0.043903 | 3.034515 | [
"s729156812",
"s133335456"
] |
u620084012 | p04033 | python | s158892527 | s180562353 | 38 | 17 | 3,188 | 2,940 | Accepted | Accepted | 55.26 | a, b =list(map(int,input().split()))
if a*b <= 0:
print("Zero")
elif a > 0 and b > 0:
print("Positive")
elif (a-b)%2 == 0:
print("Negative")
else:
print("Positive") | import sys
def input():
return sys.stdin.readline()[:-1]
def main():
a, b = list(map(int,input().split()))
if a > 0 and b > 0:
print("Positive")
elif a*b <= 0:
print("Zero")
else:
if (b-a)%2 == 1:
print("Positive")
else:
print("Neg... | 10 | 16 | 184 | 362 | a, b = list(map(int, input().split()))
if a * b <= 0:
print("Zero")
elif a > 0 and b > 0:
print("Positive")
elif (a - b) % 2 == 0:
print("Negative")
else:
print("Positive")
| import sys
def input():
return sys.stdin.readline()[:-1]
def main():
a, b = list(map(int, input().split()))
if a > 0 and b > 0:
print("Positive")
elif a * b <= 0:
print("Zero")
else:
if (b - a) % 2 == 1:
print("Positive")
else:
print("Negat... | false | 37.5 | [
"-a, b = list(map(int, input().split()))",
"-if a * b <= 0:",
"- print(\"Zero\")",
"-elif a > 0 and b > 0:",
"- print(\"Positive\")",
"-elif (a - b) % 2 == 0:",
"- print(\"Negative\")",
"-else:",
"- print(\"Positive\")",
"+import sys",
"+",
"+",
"+def input():",
"+ return sy... | false | 0.040106 | 0.042424 | 0.945356 | [
"s158892527",
"s180562353"
] |
u379959788 | p03212 | python | s158525925 | s229820265 | 93 | 77 | 3,064 | 3,064 | Accepted | Accepted | 17.2 | N = int(eval(input()))
def dfs(s):
if int(s) > N:
return 0
ans = 1 if all (s.count(c) > 0 for c in "753") else 0
for c in "753":
ans += dfs(s+c)
return ans
print((dfs('0'))) | # ABC114
N = int(eval(input()))
def dfs(num):
if num > N:
return 0
flag = True
for s in "357":
if str(num).count(s) >= 1:
pass
else:
flag = False
ret = 1 if flag else 0
for c in [3, 5, 7]:
ret += dfs(num * 10 + c)
return r... | 11 | 19 | 213 | 342 | N = int(eval(input()))
def dfs(s):
if int(s) > N:
return 0
ans = 1 if all(s.count(c) > 0 for c in "753") else 0
for c in "753":
ans += dfs(s + c)
return ans
print((dfs("0")))
| # ABC114
N = int(eval(input()))
def dfs(num):
if num > N:
return 0
flag = True
for s in "357":
if str(num).count(s) >= 1:
pass
else:
flag = False
ret = 1 if flag else 0
for c in [3, 5, 7]:
ret += dfs(num * 10 + c)
return ret
ans = dfs(0... | false | 42.105263 | [
"+# ABC114",
"-def dfs(s):",
"- if int(s) > N:",
"+def dfs(num):",
"+ if num > N:",
"- ans = 1 if all(s.count(c) > 0 for c in \"753\") else 0",
"- for c in \"753\":",
"- ans += dfs(s + c)",
"- return ans",
"+ flag = True",
"+ for s in \"357\":",
"+ if str(num... | false | 0.143077 | 0.107819 | 1.327014 | [
"s158525925",
"s229820265"
] |
u077141270 | p02900 | python | s004478251 | s015229758 | 302 | 190 | 65,640 | 40,044 | Accepted | Accepted | 37.09 | import sys
import fractions
input = sys.stdin.readline
A, B = (int(i) for i in input().split())
gcd = fractions.gcd(A, B)
temp = gcd
count = 1
for i in range(2, int(-(-gcd**0.5//1))+1):
if temp%i == 0:
cnt = 0
while temp%i ==0:
cnt +=1
temp //= i
count ... | import sys
input = sys.stdin.readline
A, B = (int(i) for i in input().split())
def mygcd(a, b):
while b!=0:
a,b = b, a%b
return a
gcd = mygcd(A, B)
temp = gcd
count = 1
for i in range(2, int(-(-gcd**0.5//1))+1):
if temp%i == 0:
cnt = 0
while temp%i ==0:
... | 19 | 23 | 370 | 417 | import sys
import fractions
input = sys.stdin.readline
A, B = (int(i) for i in input().split())
gcd = fractions.gcd(A, B)
temp = gcd
count = 1
for i in range(2, int(-(-(gcd**0.5) // 1)) + 1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
count +=... | import sys
input = sys.stdin.readline
A, B = (int(i) for i in input().split())
def mygcd(a, b):
while b != 0:
a, b = b, a % b
return a
gcd = mygcd(A, B)
temp = gcd
count = 1
for i in range(2, int(-(-(gcd**0.5) // 1)) + 1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
... | false | 17.391304 | [
"-import fractions",
"-gcd = fractions.gcd(A, B)",
"+",
"+",
"+def mygcd(a, b):",
"+ while b != 0:",
"+ a, b = b, a % b",
"+ return a",
"+",
"+",
"+gcd = mygcd(A, B)"
] | false | 0.058615 | 0.084328 | 0.695091 | [
"s004478251",
"s015229758"
] |
u433375322 | p02570 | python | s939601012 | s079036106 | 35 | 31 | 9,152 | 9,156 | Accepted | Accepted | 11.43 | D,T,s=list(map(int,input().split()))
if s*T-D>=0:
print("Yes")
else:
print("No") | d,t,s=list(map(int,input().split()))
if d<=t*s:
print("Yes")
else:
print("No") | 5 | 5 | 82 | 84 | D, T, s = list(map(int, input().split()))
if s * T - D >= 0:
print("Yes")
else:
print("No")
| d, t, s = list(map(int, input().split()))
if d <= t * s:
print("Yes")
else:
print("No")
| false | 0 | [
"-D, T, s = list(map(int, input().split()))",
"-if s * T - D >= 0:",
"+d, t, s = list(map(int, input().split()))",
"+if d <= t * s:"
] | false | 0.04524 | 0.036974 | 1.223556 | [
"s939601012",
"s079036106"
] |
u391475811 | p03557 | python | s706157091 | s311781121 | 364 | 330 | 23,232 | 23,232 | Accepted | Accepted | 9.34 | import bisect
N=int(eval(input()))
A=[int(x) for x in input().split()]
B=[int(x) for x in input().split()]
C=[int(x) for x in input().split()]
A.sort()
B.sort()
C.sort()
ans=0
for i in range(N):
a=bisect.bisect_right(C,B[i])
b=bisect.bisect_left(A,B[i])
ans+=(N-a)*b
print(ans) | import bisect
N=int(eval(input()))
A=[int(x) for x in input().split()]
B=[int(x) for x in input().split()]
C=[int(x) for x in input().split()]
A.sort()
B.sort()
C.sort()
ans=0
for i in range(N):
ans+=(bisect.bisect_left(A,B[i])*(N-bisect.bisect_right(C,B[i])))
print(ans) | 16 | 17 | 294 | 288 | import bisect
N = int(eval(input()))
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
A.sort()
B.sort()
C.sort()
ans = 0
for i in range(N):
a = bisect.bisect_right(C, B[i])
b = bisect.bisect_left(A, B[i])
ans += (N - a) * b
print(ans)
| import bisect
N = int(eval(input()))
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
A.sort()
B.sort()
C.sort()
ans = 0
for i in range(N):
ans += bisect.bisect_left(A, B[i]) * (N - bisect.bisect_right(C, B[i]))
print(ans)
| false | 5.882353 | [
"- a = bisect.bisect_right(C, B[i])",
"- b = bisect.bisect_left(A, B[i])",
"- ans += (N - a) * b",
"+ ans += bisect.bisect_left(A, B[i]) * (N - bisect.bisect_right(C, B[i]))"
] | false | 0.040744 | 0.03935 | 1.035435 | [
"s706157091",
"s311781121"
] |
u077291787 | p03073 | python | s406718506 | s556656869 | 26 | 18 | 3,188 | 3,188 | Accepted | Accepted | 30.77 | # ABC124C - Coloring Colorfully
def main():
S = eval(input())
a = sum(i != "1" for i in S[::2]) + sum(i != "0" for i in S[1::2])
b = len(S) - a
print((min(a, b)))
if __name__ == "__main__":
main() | # ABC124C - Coloring Colorfully
def main():
S = eval(input())
a = S[::2].count("1") + S[1::2].count("0")
b = len(S) - a
print((min(a, b)))
if __name__ == "__main__":
main() | 10 | 10 | 219 | 195 | # ABC124C - Coloring Colorfully
def main():
S = eval(input())
a = sum(i != "1" for i in S[::2]) + sum(i != "0" for i in S[1::2])
b = len(S) - a
print((min(a, b)))
if __name__ == "__main__":
main()
| # ABC124C - Coloring Colorfully
def main():
S = eval(input())
a = S[::2].count("1") + S[1::2].count("0")
b = len(S) - a
print((min(a, b)))
if __name__ == "__main__":
main()
| false | 0 | [
"- a = sum(i != \"1\" for i in S[::2]) + sum(i != \"0\" for i in S[1::2])",
"+ a = S[::2].count(\"1\") + S[1::2].count(\"0\")"
] | false | 0.046779 | 0.065602 | 0.713068 | [
"s406718506",
"s556656869"
] |
u678167152 | p03352 | python | s762864513 | s123671846 | 181 | 28 | 38,256 | 9,392 | Accepted | Accepted | 84.53 | pow = [1]
for p in range(2,32):
i=2
while p**i<=1000:
pow.append(p**i)
i += 1
#print(pow)
X = int(eval(input()))
x = X
while x>0:
if x in pow:
ans = x
break
x -= 1
print(ans) | #素因数分解して列挙する関数、約数列挙ではない!
from collections import Counter
def factorize(n):
b = 2
fct = []
while b * b <= n:
while n % b == 0:
n //= b
fct.append(b)
b = b + 1
if n > 1:
fct.append(n)
f = list(Counter(fct).values())
if 1 not in f and len(set(f))==1:
return True
ret... | 15 | 23 | 206 | 436 | pow = [1]
for p in range(2, 32):
i = 2
while p**i <= 1000:
pow.append(p**i)
i += 1
# print(pow)
X = int(eval(input()))
x = X
while x > 0:
if x in pow:
ans = x
break
x -= 1
print(ans)
| # 素因数分解して列挙する関数、約数列挙ではない!
from collections import Counter
def factorize(n):
b = 2
fct = []
while b * b <= n:
while n % b == 0:
n //= b
fct.append(b)
b = b + 1
if n > 1:
fct.append(n)
f = list(Counter(fct).values())
if 1 not in f and len(set(f)) =... | false | 34.782609 | [
"-pow = [1]",
"-for p in range(2, 32):",
"- i = 2",
"- while p**i <= 1000:",
"- pow.append(p**i)",
"- i += 1",
"-# print(pow)",
"+# 素因数分解して列挙する関数、約数列挙ではない!",
"+from collections import Counter",
"+",
"+",
"+def factorize(n):",
"+ b = 2",
"+ fct = []",
"+ while... | false | 0.033576 | 0.04065 | 0.825979 | [
"s762864513",
"s123671846"
] |
u133936772 | p03637 | python | s959525123 | s996776568 | 64 | 54 | 20,132 | 16,952 | Accepted | Accepted | 15.62 | n,*l=list(map(int,open(0).read().split()))
d={1:0,2:0,4:0}
for i in l:
if i%2: d[1]+=1
elif i%4: d[2]+=1
else: d[4]+=1
if d[2]: print(('YNeos'[d[1]>d[4]::2]))
else: print(('YNeos'[d[1]-1>d[4]::2])) | eval(input())
l=[int(i)%4 for i in input().split()]
c=l.count
print(('YNeos'[c(0)+c(2)//2<len(l)//2::2])) | 8 | 4 | 200 | 100 | n, *l = list(map(int, open(0).read().split()))
d = {1: 0, 2: 0, 4: 0}
for i in l:
if i % 2:
d[1] += 1
elif i % 4:
d[2] += 1
else:
d[4] += 1
if d[2]:
print(("YNeos"[d[1] > d[4] :: 2]))
else:
print(("YNeos"[d[1] - 1 > d[4] :: 2]))
| eval(input())
l = [int(i) % 4 for i in input().split()]
c = l.count
print(("YNeos"[c(0) + c(2) // 2 < len(l) // 2 :: 2]))
| false | 50 | [
"-n, *l = list(map(int, open(0).read().split()))",
"-d = {1: 0, 2: 0, 4: 0}",
"-for i in l:",
"- if i % 2:",
"- d[1] += 1",
"- elif i % 4:",
"- d[2] += 1",
"- else:",
"- d[4] += 1",
"-if d[2]:",
"- print((\"YNeos\"[d[1] > d[4] :: 2]))",
"-else:",
"- print(... | false | 0.037447 | 0.036993 | 1.012294 | [
"s959525123",
"s996776568"
] |
u104282757 | p03312 | python | s320812117 | s138900372 | 577 | 448 | 93,176 | 95,096 | Accepted | Accepted | 22.36 | # D
N = int(eval(input()))
A_list = list(map(int, input().split()))
# cumsum from left
a = 0
A_left = []
for i in range(N):
a += A_list[i]
A_left.append(a)
# cumsum from right
a = 0
A_right = []
for i in range(N):
a += A_list[N-1-i]
A_right.append(a)
def binary_search_left(s):
... | # D
n = int(eval(input()))
A_list = list(map(int, input().split()))
# cumsum from left
a = 0
A_left = []
for i in range(n):
a += A_list[i]
A_left.append(a)
res = A_left[n-1]
i = 0
j = 1
k = 2
while j <= n - 3:
while True:
if abs(A_left[j] / 2 - A_left[i]) > abs(A_left[j] / 2 -... | 78 | 35 | 1,547 | 830 | # D
N = int(eval(input()))
A_list = list(map(int, input().split()))
# cumsum from left
a = 0
A_left = []
for i in range(N):
a += A_list[i]
A_left.append(a)
# cumsum from right
a = 0
A_right = []
for i in range(N):
a += A_list[N - 1 - i]
A_right.append(a)
def binary_search_left(s):
m = 0
l = 0
... | # D
n = int(eval(input()))
A_list = list(map(int, input().split()))
# cumsum from left
a = 0
A_left = []
for i in range(n):
a += A_list[i]
A_left.append(a)
res = A_left[n - 1]
i = 0
j = 1
k = 2
while j <= n - 3:
while True:
if abs(A_left[j] / 2 - A_left[i]) > abs(A_left[j] / 2 - A_left[i + 1]):
... | false | 55.128205 | [
"-N = int(eval(input()))",
"+n = int(eval(input()))",
"-for i in range(N):",
"+for i in range(n):",
"-# cumsum from right",
"-a = 0",
"-A_right = []",
"-for i in range(N):",
"- a += A_list[N - 1 - i]",
"- A_right.append(a)",
"-",
"-",
"-def binary_search_left(s):",
"- m = 0",
"-... | false | 0.048261 | 0.269977 | 0.178758 | [
"s320812117",
"s138900372"
] |
u987164499 | p03262 | python | s453179605 | s189198671 | 120 | 110 | 16,276 | 14,224 | Accepted | Accepted | 8.33 | from sys import stdin
import fractions
n,x = [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int,stdin.readline().rstrip().split()))
lin = []
for i in range(len(li)):
lin.append(abs(li[i]-x))
poi = lin[0]
for i in range(len(lin)-1):
poi = fractions.gcd(poi,lin[i+1])
print(poi... | n,x = list(map(int,input().split()))
li = list(map(int,input().split()))
lin = [abs(i-x) for i in li]
from fractions import gcd
now = lin[0]
for i in range(1,n):
p = gcd(now,lin[i])
now = p
print(now) | 15 | 12 | 321 | 216 | from sys import stdin
import fractions
n, x = [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int, stdin.readline().rstrip().split()))
lin = []
for i in range(len(li)):
lin.append(abs(li[i] - x))
poi = lin[0]
for i in range(len(lin) - 1):
poi = fractions.gcd(poi, lin[i + 1])
print(poi)
| n, x = list(map(int, input().split()))
li = list(map(int, input().split()))
lin = [abs(i - x) for i in li]
from fractions import gcd
now = lin[0]
for i in range(1, n):
p = gcd(now, lin[i])
now = p
print(now)
| false | 20 | [
"-from sys import stdin",
"-import fractions",
"+n, x = list(map(int, input().split()))",
"+li = list(map(int, input().split()))",
"+lin = [abs(i - x) for i in li]",
"+from fractions import gcd",
"-n, x = [int(x) for x in stdin.readline().rstrip().split()]",
"-li = list(map(int, stdin.readline().rstri... | false | 0.070813 | 0.046204 | 1.532596 | [
"s453179605",
"s189198671"
] |
u802963389 | p03061 | python | s787692952 | s584990857 | 208 | 171 | 16,112 | 21,808 | Accepted | Accepted | 17.79 | from fractions import gcd
N = int(eval(input()))
a = list(map(int, input().split()))
l = [0] * N
r = [0] * N
m = [0] * N
for i in range(N):
if i == 0:
l[i] = 0
else:
l[i] = gcd(l[i-1], a[i-1])
for j in reversed(list(range(N))):
if j == N - 1:
r[j] = 0
else:
r[j] = gcd(r[j+1], ... | from math import gcd
n = int(eval(input()))
A = list(map(int, input().split()))
L = [0] * n
L[0] = A[0]
for i, a in enumerate(A):
L[i] = gcd(L[max(0, i - 1)], a)
R = [0] * n
R[0] = A[-1]
for i, a in enumerate(A[::-1]):
R[i] = gcd(R[max(0, i - 1)], a)
ans = 0
for i in range(n):
if i == 0:
... | 24 | 25 | 408 | 468 | from fractions import gcd
N = int(eval(input()))
a = list(map(int, input().split()))
l = [0] * N
r = [0] * N
m = [0] * N
for i in range(N):
if i == 0:
l[i] = 0
else:
l[i] = gcd(l[i - 1], a[i - 1])
for j in reversed(list(range(N))):
if j == N - 1:
r[j] = 0
else:
r[j] = gc... | from math import gcd
n = int(eval(input()))
A = list(map(int, input().split()))
L = [0] * n
L[0] = A[0]
for i, a in enumerate(A):
L[i] = gcd(L[max(0, i - 1)], a)
R = [0] * n
R[0] = A[-1]
for i, a in enumerate(A[::-1]):
R[i] = gcd(R[max(0, i - 1)], a)
ans = 0
for i in range(n):
if i == 0:
ans = max(... | false | 4 | [
"-from fractions import gcd",
"+from math import gcd",
"-N = int(eval(input()))",
"-a = list(map(int, input().split()))",
"-l = [0] * N",
"-r = [0] * N",
"-m = [0] * N",
"-for i in range(N):",
"+n = int(eval(input()))",
"+A = list(map(int, input().split()))",
"+L = [0] * n",
"+L[0] = A[0]",
... | false | 0.050313 | 0.040231 | 1.25059 | [
"s787692952",
"s584990857"
] |
u294542073 | p02813 | python | s439147740 | s614348970 | 28 | 18 | 8,052 | 3,064 | Accepted | Accepted | 35.71 | import itertools
n = int(eval(input()))
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
# 多分1~4で3!の順列になる
ls = list(itertools.permutations(list(range(1,n+1)))) #順列生成
# 絶対値absで辞書順のpからqをひく
print((abs(ls.index(p)-ls.index(q)))) | N = int(eval(input()))
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
fac = [0] * 8
# 1番目の桁
fac[1] = 1
for i in range(2, N):
# 最上位の桁が7の場合7!の6周目終わりが30240番目が先頭になる。
fac[i] = i * fac[i - 1]
a = 0
l = list(range(1, N + 1))
# l=3の時fac[2] 2!の2周目終わった時点え次のスタートが5になる
# 5の1番目のルートとなる
... | 9 | 25 | 242 | 533 | import itertools
n = int(eval(input()))
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
# 多分1~4で3!の順列になる
ls = list(itertools.permutations(list(range(1, n + 1)))) # 順列生成
# 絶対値absで辞書順のpからqをひく
print((abs(ls.index(p) - ls.index(q))))
| N = int(eval(input()))
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
fac = [0] * 8
# 1番目の桁
fac[1] = 1
for i in range(2, N):
# 最上位の桁が7の場合7!の6周目終わりが30240番目が先頭になる。
fac[i] = i * fac[i - 1]
a = 0
l = list(range(1, N + 1))
# l=3の時fac[2] 2!の2周目終わった時点え次のスタートが5になる
# 5の1番目のルートとなる
for i in range(... | false | 64 | [
"-import itertools",
"-",
"-n = int(eval(input()))",
"-p = tuple(map(int, input().split()))",
"-q = tuple(map(int, input().split()))",
"-# 多分1~4で3!の順列になる",
"-ls = list(itertools.permutations(list(range(1, n + 1)))) # 順列生成",
"-# 絶対値absで辞書順のpからqをひく",
"-print((abs(ls.index(p) - ls.index(q))))",
"+N ... | false | 0.052957 | 0.039658 | 1.335349 | [
"s439147740",
"s614348970"
] |
u545368057 | p03088 | python | s058473352 | s664290041 | 58 | 41 | 3,572 | 3,316 | Accepted | Accepted | 29.31 | """
1.4種類の文字ATGC
2.AGCを作ってはならない
3.隣り合う文字を1箇所だけ入れ替えても、AGCになってはならない
3. が厄介
変えないAGC
0-1 A*GC
1-2 GAC
2-3 ACG
3-4 AG*C
とりあえず3文字分テーブルに持たせながらdp?
"""
mod = 10**9 + 7
N = int(eval(input()))
dp =[[[[0]*5 for i in range(5)] for j in range(5)] for n in range(108)]
nul = 0
A = 1
G = 2
C = 3
T = 4
"""... | n = int(eval(input()))
MOD = 10**9+7
d = {"A":0, "C":1, "G":2, "T":3}
dic = {}
dic_r = {}
for i0 in "ACGT":
for i1 in "ACGT":
for i2 in "ACGT":
v = 4**2*d[i2] + 4*d[i1] + d[i0]
k = i2+i1+i0
dic[k] = v
dic_r[v] = k
dp = [[0] * 64 for i in range(n)... | 51 | 55 | 1,155 | 1,630 | """
1.4種類の文字ATGC
2.AGCを作ってはならない
3.隣り合う文字を1箇所だけ入れ替えても、AGCになってはならない
3. が厄介
変えないAGC
0-1 A*GC
1-2 GAC
2-3 ACG
3-4 AG*C
とりあえず3文字分テーブルに持たせながらdp?
"""
mod = 10**9 + 7
N = int(eval(input()))
dp = [[[[0] * 5 for i in range(5)] for j in range(5)] for n in range(108)]
nul = 0
A = 1
G = 2
C = 3
T = 4
"""
AGC
0-1 A*GC
1-2 GAC
2-3 A... | n = int(eval(input()))
MOD = 10**9 + 7
d = {"A": 0, "C": 1, "G": 2, "T": 3}
dic = {}
dic_r = {}
for i0 in "ACGT":
for i1 in "ACGT":
for i2 in "ACGT":
v = 4**2 * d[i2] + 4 * d[i1] + d[i0]
k = i2 + i1 + i0
dic[k] = v
dic_r[v] = k
dp = [[0] * 64 for i in range(n)... | false | 7.272727 | [
"-\"\"\"",
"-1.4種類の文字ATGC",
"-2.AGCを作ってはならない",
"-3.隣り合う文字を1箇所だけ入れ替えても、AGCになってはならない",
"-3. が厄介",
"-変えないAGC",
"-0-1 A*GC",
"-1-2 GAC",
"-2-3 ACG",
"-3-4 AG*C",
"-とりあえず3文字分テーブルに持たせながらdp?",
"-\"\"\"",
"-mod = 10**9 + 7",
"-N = int(eval(input()))",
"-dp = [[[[0] * 5 for i in range(5)] for j i... | false | 0.070106 | 0.057159 | 1.226494 | [
"s058473352",
"s664290041"
] |
u581187895 | p02889 | python | s029306490 | s176331963 | 833 | 754 | 78,864 | 46,280 | Accepted | Accepted | 9.48 |
def resolve():
INF = 10 ** 18
N, M, L = list(map(int, input().split()))
G = [[INF] * N for _ in range(N)]
for _ in range(M):
a, b, c = list(map(int, input().split()))
a -= 1
b -= 1
G[a][b] = G[b][a] = c
for k in range(N):
for i in range(N):
... |
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix
def resolve():
INF = 10 ** 18
N, M, L = list(map(int, input().split()))
G = [[INF] * N for _ in range(N)]
for _ in range(M):
a, b, c = list(map(int, input().split()))
a -= 1
... | 38 | 34 | 967 | 873 | def resolve():
INF = 10**18
N, M, L = list(map(int, input().split()))
G = [[INF] * N for _ in range(N)]
for _ in range(M):
a, b, c = list(map(int, input().split()))
a -= 1
b -= 1
G[a][b] = G[b][a] = c
for k in range(N):
for i in range(N):
for j in ... | import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix
def resolve():
INF = 10**18
N, M, L = list(map(int, input().split()))
G = [[INF] * N for _ in range(N)]
for _ in range(M):
a, b, c = list(map(int, input().split()))
a -= 1
b -... | false | 10.526316 | [
"+import numpy as np",
"+from scipy.sparse.csgraph import floyd_warshall",
"+from scipy.sparse import csr_matrix",
"+",
"+",
"- for k in range(N):",
"- for i in range(N):",
"- for j in range(N):",
"- G[i][j] = min(G[i][j], G[i][k] + G[k][j])",
"- Cost = [[INF... | false | 0.043377 | 0.387428 | 0.111961 | [
"s029306490",
"s176331963"
] |
u562935282 | p03173 | python | s082637647 | s296167393 | 506 | 420 | 46,556 | 42,732 | Accepted | Accepted | 17 | inf = float('inf')
n = int(eval(input()))
a = tuple(int(x) for x in input().split())
d = [[inf] * n for _ in range(n)]
for i in range(n):
d[i][i] = 0
c = [0]
for aa in a:
c.append(c[-1] + aa)
for i in range(n - 1, -1, -1):
for j in range(i + 1, n):
for k in range(i, j):
... | inf = 10 ** 16
n = int(eval(input()))
a = tuple(int(x) for x in input().split())
d = [[inf] * n for _ in range(n)]
for i in range(n):
d[i][i] = 0
c = [0]
for aa in a:
c.append(c[-1] + aa)
for i in range(n - 1, -1, -1):
for j in range(i + 1, n):
for k in range(i, j):
#... | 22 | 22 | 473 | 469 | inf = float("inf")
n = int(eval(input()))
a = tuple(int(x) for x in input().split())
d = [[inf] * n for _ in range(n)]
for i in range(n):
d[i][i] = 0
c = [0]
for aa in a:
c.append(c[-1] + aa)
for i in range(n - 1, -1, -1):
for j in range(i + 1, n):
for k in range(i, j):
# [i, k], (k, j]
... | inf = 10**16
n = int(eval(input()))
a = tuple(int(x) for x in input().split())
d = [[inf] * n for _ in range(n)]
for i in range(n):
d[i][i] = 0
c = [0]
for aa in a:
c.append(c[-1] + aa)
for i in range(n - 1, -1, -1):
for j in range(i + 1, n):
for k in range(i, j):
# [i, k], (k, j]
... | false | 0 | [
"-inf = float(\"inf\")",
"+inf = 10**16"
] | false | 0.03798 | 0.037672 | 1.008181 | [
"s082637647",
"s296167393"
] |
u167988719 | p03112 | python | s135932146 | s083535151 | 1,067 | 948 | 21,864 | 21,832 | Accepted | Accepted | 11.15 | from bisect import bisect_left
INF = 2 * 10**10
A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]
ans = []
for x in X:
sr = bisect_left(S, x)
sl = sr -1
if sr != len(S) and S[sr] == x:
sl... | from bisect import bisect_left
INF = 2 * 10**10
A, B, Q = map(int, input().split())
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]
X = [int(input()) for _ in range(Q)]
ans = []
for x in X:
sr = bisect_left(S, x)
sl = sr if S[sr] == x els... | 28 | 24 | 946 | 693 | from bisect import bisect_left
INF = 2 * 10**10
A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]
ans = []
for x in X:
sr = bisect_left(S, x)
sl = sr - 1
if sr != len(S) and S[sr] == x:
sl = sr
tr =... | from bisect import bisect_left
INF = 2 * 10**10
A, B, Q = map(int, input().split())
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]
X = [int(input()) for _ in range(Q)]
ans = []
for x in X:
sr = bisect_left(S, x)
sl = sr if S[sr] == x else sr - 1
... | false | 14.285714 | [
"-S = [int(input()) for _ in range(A)]",
"-T = [int(input()) for _ in range(B)]",
"+S = [-INF] + [int(input()) for _ in range(A)] + [INF]",
"+T = [-INF] + [int(input()) for _ in range(B)] + [INF]",
"- sl = sr - 1",
"- if sr != len(S) and S[sr] == x:",
"- sl = sr",
"+ sl = sr if S[sr] =... | false | 0.077564 | 0.037076 | 2.092003 | [
"s135932146",
"s083535151"
] |
u493520238 | p03213 | python | s930893642 | s824142429 | 179 | 61 | 38,384 | 62,744 | Accepted | Accepted | 65.92 | # 60 -> {2:2, 3:1, 5:1}
def factorization(n):
pf_cnt = {}
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
if temp%i == 0:
cnt = 0
while temp%i == 0:
cnt += 1
temp //= i
pf_cnt[i] = cnt
if temp != 1: pf_cnt[temp] =... | def p_factorization(n):
if n == 1: return {}
pf_cnt = {}
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
if temp%i == 0:
cnt = 0
while temp%i == 0:
cnt += 1
temp //= i
pf_cnt[i] = cnt
if temp != 1: pf_cnt[temp... | 50 | 45 | 1,003 | 877 | # 60 -> {2:2, 3:1, 5:1}
def factorization(n):
pf_cnt = {}
temp = n
for i in range(2, int(-(-(n**0.5) // 1)) + 1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
pf_cnt[i] = cnt
if temp != 1:
pf_cnt[te... | def p_factorization(n):
if n == 1:
return {}
pf_cnt = {}
temp = n
for i in range(2, int(-(-(n**0.5) // 1)) + 1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
pf_cnt[i] = cnt
if temp != 1:
... | false | 10 | [
"-# 60 -> {2:2, 3:1, 5:1}",
"-def factorization(n):",
"+def p_factorization(n):",
"+ if n == 1:",
"+ return {}",
"- if not pf_cnt:",
"- pf_cnt[n] = 1",
"-prime_cnts = {}",
"+pd = {}",
"- fac = factorization(i)",
"- for prime, cnt in list(fac.items()):",
"- prim... | false | 0.03771 | 0.045616 | 0.826685 | [
"s930893642",
"s824142429"
] |
u332906195 | p03557 | python | s688050893 | s836747591 | 377 | 304 | 23,488 | 23,032 | Accepted | Accepted | 19.36 | # -*- coding: utf-8 -*-
import bisect
n = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
Ac, Cc = [0]*n, [0]*n
# Ap, Cp = 0, 0
for i in range(n):
Ac[i] = bisect.bisect_left(A, B[i... | import bisect
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
print((sum([bisect.bisect_left(A, b) * (N - bisect.bisect(C, b)) for b in B])))
| 29 | 9 | 556 | 252 | # -*- coding: utf-8 -*-
import bisect
n = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
Ac, Cc = [0] * n, [0] * n
# Ap, Cp = 0, 0
for i in range(n):
Ac[i] = bisect.bisect_left(A, B[i]) # [Ap:], B[i])
# ... | import bisect
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
print((sum([bisect.bisect_left(A, b) * (N - bisect.bisect(C, b)) for b in B])))
| false | 68.965517 | [
"-# -*- coding: utf-8 -*-",
"-n = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-B = list(map(int, input().split()))",
"-C = list(map(int, input().split()))",
"-A.sort()",
"-B.sort()",
"-C.sort()",
"-Ac, Cc = [0] * n, [0] * n",
"-# Ap, Cp = 0, 0",
"-for i in range(n):",
"- A... | false | 0.043518 | 0.036412 | 1.195156 | [
"s688050893",
"s836747591"
] |
u253681061 | p03945 | python | s612648255 | s456348514 | 44 | 36 | 3,956 | 3,188 | Accepted | Accepted | 18.18 | s = list(eval(input()))
ans = 0
for i in range(1,len(s)):
if s[i-1] != s[i]:
ans += 1
print(ans) | s = eval(input())
ans = 0
tmp = s[0]
for x in s[1:]:
if x != tmp:
ans += 1
tmp = x
print(ans) | 8 | 10 | 111 | 118 | s = list(eval(input()))
ans = 0
for i in range(1, len(s)):
if s[i - 1] != s[i]:
ans += 1
print(ans)
| s = eval(input())
ans = 0
tmp = s[0]
for x in s[1:]:
if x != tmp:
ans += 1
tmp = x
print(ans)
| false | 20 | [
"-s = list(eval(input()))",
"+s = eval(input())",
"-for i in range(1, len(s)):",
"- if s[i - 1] != s[i]:",
"+tmp = s[0]",
"+for x in s[1:]:",
"+ if x != tmp:",
"+ tmp = x"
] | false | 0.046338 | 0.046466 | 0.997229 | [
"s612648255",
"s456348514"
] |
u599114793 | p03627 | python | s035995352 | s535437748 | 211 | 192 | 21,384 | 21,412 | Accepted | Accepted | 9 | n = int(eval(input()))
a = list(map(int,input().split()))
bar = dict()
for i in range(n):
if a[i] not in bar:
bar[a[i]] = 0
bar[a[i]] += 1
l_bar = list(bar.items())
l_bar.sort(reverse=True)
cnt = 0
hen1 = 0
hen2 = 0
for i in range(len(l_bar)):
if l_bar[i][1] >= 4 and cnt == 0:
... | import collections
n = int(eval(input()))
a = list(map(int,input().split()))
a = collections.Counter(a)
a = list(a.items())
a.sort(reverse=True)
e1 = 0
e2 = 0
for i in range(len(a)):
if a[i][1] >= 4 and e1 == 0:
e1 = e2 = a[i][0]
break
elif a[i][1] >= 2:
if e1 == 0:
... | 30 | 21 | 608 | 410 | n = int(eval(input()))
a = list(map(int, input().split()))
bar = dict()
for i in range(n):
if a[i] not in bar:
bar[a[i]] = 0
bar[a[i]] += 1
l_bar = list(bar.items())
l_bar.sort(reverse=True)
cnt = 0
hen1 = 0
hen2 = 0
for i in range(len(l_bar)):
if l_bar[i][1] >= 4 and cnt == 0:
print((l_bar[... | import collections
n = int(eval(input()))
a = list(map(int, input().split()))
a = collections.Counter(a)
a = list(a.items())
a.sort(reverse=True)
e1 = 0
e2 = 0
for i in range(len(a)):
if a[i][1] >= 4 and e1 == 0:
e1 = e2 = a[i][0]
break
elif a[i][1] >= 2:
if e1 == 0:
e1 = a[... | false | 30 | [
"+import collections",
"+",
"-bar = dict()",
"-for i in range(n):",
"- if a[i] not in bar:",
"- bar[a[i]] = 0",
"- bar[a[i]] += 1",
"-l_bar = list(bar.items())",
"-l_bar.sort(reverse=True)",
"-cnt = 0",
"-hen1 = 0",
"-hen2 = 0",
"-for i in range(len(l_bar)):",
"- if l_bar[i... | false | 0.04287 | 0.043865 | 0.977326 | [
"s035995352",
"s535437748"
] |
u532966492 | p03073 | python | s784795158 | s031865177 | 105 | 54 | 9,588 | 7,188 | Accepted | Accepted | 48.57 | S=eval(input())
N=len(S)
A="".join([str(i%2) for i in range(N)])
B="".join([str((i+1)%2) for i in range(N)])
print((min(sum([1 for i in range(N) if S[i]!=A[i]]),sum([1 for i in range(N) if S[i]!=B[i]])))) | S=eval(input())
N=len(S)
A=len([i for i in range(N) if str(i%2)==S[i]])
print((min(A,N-A))) | 5 | 4 | 200 | 86 | S = eval(input())
N = len(S)
A = "".join([str(i % 2) for i in range(N)])
B = "".join([str((i + 1) % 2) for i in range(N)])
print(
(
min(
sum([1 for i in range(N) if S[i] != A[i]]),
sum([1 for i in range(N) if S[i] != B[i]]),
)
)
)
| S = eval(input())
N = len(S)
A = len([i for i in range(N) if str(i % 2) == S[i]])
print((min(A, N - A)))
| false | 20 | [
"-A = \"\".join([str(i % 2) for i in range(N)])",
"-B = \"\".join([str((i + 1) % 2) for i in range(N)])",
"-print(",
"- (",
"- min(",
"- sum([1 for i in range(N) if S[i] != A[i]]),",
"- sum([1 for i in range(N) if S[i] != B[i]]),",
"- )",
"- )",
"-)",
"+... | false | 0.034802 | 0.036334 | 0.957825 | [
"s784795158",
"s031865177"
] |
u205580583 | p03494 | python | s124853487 | s322100165 | 20 | 18 | 3,060 | 2,940 | Accepted | Accepted | 10 | input_n = eval(input())
input_a = input().split()
cnt = 0
end_flg = True
while end_flg:
for i in range(int(input_n)):
if int(input_a[i]) % 2 == 0:
input_a[i] = int(input_a[i])/2
else:
end_flg = False
break
if end_flg == False:break
cnt+=1... | def div_cnt(input_n):
cnt = 0
while input_n % 2 == 0:
input_n /= 2
cnt += 1
return cnt
input_n = int(eval(input()))
input_a = list(map(int,input().split()))
cnt = min(list(map(div_cnt,input_a)))
print(cnt) | 18 | 13 | 328 | 236 | input_n = eval(input())
input_a = input().split()
cnt = 0
end_flg = True
while end_flg:
for i in range(int(input_n)):
if int(input_a[i]) % 2 == 0:
input_a[i] = int(input_a[i]) / 2
else:
end_flg = False
break
if end_flg == False:
break
cnt += 1
prin... | def div_cnt(input_n):
cnt = 0
while input_n % 2 == 0:
input_n /= 2
cnt += 1
return cnt
input_n = int(eval(input()))
input_a = list(map(int, input().split()))
cnt = min(list(map(div_cnt, input_a)))
print(cnt)
| false | 27.777778 | [
"-input_n = eval(input())",
"-input_a = input().split()",
"-cnt = 0",
"-end_flg = True",
"-while end_flg:",
"- for i in range(int(input_n)):",
"- if int(input_a[i]) % 2 == 0:",
"- input_a[i] = int(input_a[i]) / 2",
"- else:",
"- end_flg = False",
"- ... | false | 0.049705 | 0.032973 | 1.507435 | [
"s124853487",
"s322100165"
] |
u803865203 | p03478 | python | s903723954 | s782391329 | 39 | 35 | 3,060 | 3,060 | Accepted | Accepted | 10.26 | N,A,B = list(map(int,input().split()))
ans = 0
for i in range(int(N)+1):
array = list(map(int,list(str(i))))
if(sum(array)>=A and sum(array)<=B):
ans += int(i)
print(ans)
| N,A,B = list(map(int,input().split()))
ans = 0
for i in range(1,int(N)+1):
sum = 0
num = i
while(True):
sum += num%10
num = num//10
if(num == 0):
if(sum >= A and sum <= B):
ans += i
break
else:
break... | 7 | 15 | 187 | 327 | N, A, B = list(map(int, input().split()))
ans = 0
for i in range(int(N) + 1):
array = list(map(int, list(str(i))))
if sum(array) >= A and sum(array) <= B:
ans += int(i)
print(ans)
| N, A, B = list(map(int, input().split()))
ans = 0
for i in range(1, int(N) + 1):
sum = 0
num = i
while True:
sum += num % 10
num = num // 10
if num == 0:
if sum >= A and sum <= B:
ans += i
break
else:
break
print... | false | 53.333333 | [
"-for i in range(int(N) + 1):",
"- array = list(map(int, list(str(i))))",
"- if sum(array) >= A and sum(array) <= B:",
"- ans += int(i)",
"+for i in range(1, int(N) + 1):",
"+ sum = 0",
"+ num = i",
"+ while True:",
"+ sum += num % 10",
"+ num = num // 10",
"+... | false | 0.037256 | 0.035988 | 1.035224 | [
"s903723954",
"s782391329"
] |
u036104576 | p03379 | python | s406244482 | s249341937 | 184 | 170 | 32,424 | 30,836 | Accepted | Accepted | 7.61 | import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# map(int, ... | N = int(eval(input()))
X = list(map(int, input().split()))
A = sorted(X)
med1 = A[N // 2 - 1]
med2 = A[N // 2]
for x in X:
if x <= med1:
print(med2)
else:
print(med1) | 30 | 10 | 554 | 194 | import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# map(int, input().split())
N = i... | N = int(eval(input()))
X = list(map(int, input().split()))
A = sorted(X)
med1 = A[N // 2 - 1]
med2 = A[N // 2]
for x in X:
if x <= med1:
print(med2)
else:
print(med1)
| false | 66.666667 | [
"-import sys",
"-import itertools",
"-",
"-# import numpy as np",
"-import time",
"-import math",
"-import heapq",
"-from collections import defaultdict",
"-",
"-sys.setrecursionlimit(10**7)",
"-INF = 10**18",
"-MOD = 10**9 + 7",
"-read = sys.stdin.buffer.read",
"-readline = sys.stdin.buff... | false | 0.039476 | 0.037398 | 1.055564 | [
"s406244482",
"s249341937"
] |
u698693989 | p02398 | python | s390601896 | s752129976 | 30 | 20 | 7,664 | 5,596 | Accepted | Accepted | 33.33 | a,b,c=list(map(int,input().split()))
count=0
for i in range(a,b+1):
if c % i == 0:
count+=1
print(count) | num=input().split()
a=int(num[0])
b=int(num[1])
c=int(num[2])
count=0
while True:
if a<=b:
if c%a==0:
count+=1
a+=1
else:
break
print(count)
| 6 | 14 | 184 | 177 | a, b, c = list(map(int, input().split()))
count = 0
for i in range(a, b + 1):
if c % i == 0:
count += 1
print(count)
| num = input().split()
a = int(num[0])
b = int(num[1])
c = int(num[2])
count = 0
while True:
if a <= b:
if c % a == 0:
count += 1
a += 1
else:
break
print(count)
| false | 57.142857 | [
"-a, b, c = list(map(int, input().split()))",
"+num = input().split()",
"+a = int(num[0])",
"+b = int(num[1])",
"+c = int(num[2])",
"-for i in range(a, b + 1):",
"- if c % i == 0:",
"- count += 1",
"+while True:",
"+ if a <= b:",
"+ if c % a == 0:",
"+ count += 1... | false | 0.0698 | 0.067656 | 1.031693 | [
"s390601896",
"s752129976"
] |
u077291787 | p03661 | python | s012093936 | s683717072 | 129 | 111 | 26,092 | 26,092 | Accepted | Accepted | 13.95 | from itertools import accumulate
def main():
n = int(eval(input()))
lst = tuple(accumulate(list(map(int, input().rstrip().split()))))
ans = min(abs(lst[-1] - i * 2) for i in lst[:-1])
print(ans)
if __name__ == "__main__":
main() | from itertools import accumulate
def main():
n = int(eval(input()))
lst = tuple(accumulate(list(map(int, input().rstrip().split()))))
total = lst[-1]
ans = min(abs(total - i * 2) for i in lst[:-1])
print(ans)
if __name__ == "__main__":
main() | 12 | 13 | 251 | 270 | from itertools import accumulate
def main():
n = int(eval(input()))
lst = tuple(accumulate(list(map(int, input().rstrip().split()))))
ans = min(abs(lst[-1] - i * 2) for i in lst[:-1])
print(ans)
if __name__ == "__main__":
main()
| from itertools import accumulate
def main():
n = int(eval(input()))
lst = tuple(accumulate(list(map(int, input().rstrip().split()))))
total = lst[-1]
ans = min(abs(total - i * 2) for i in lst[:-1])
print(ans)
if __name__ == "__main__":
main()
| false | 7.692308 | [
"- ans = min(abs(lst[-1] - i * 2) for i in lst[:-1])",
"+ total = lst[-1]",
"+ ans = min(abs(total - i * 2) for i in lst[:-1])"
] | false | 0.04149 | 0.04032 | 1.029016 | [
"s012093936",
"s683717072"
] |
u352394527 | p00721 | python | s858721357 | s776104189 | 3,480 | 2,240 | 5,900 | 5,900 | Accepted | Accepted | 35.63 | from heapq import heappush, heappop
INF = 10 ** 10
direct = ((0, -1), (0, 1), (-1, 0), (1, 0))
def dist(fr, to, mp):
que = []
heappush(que, (0, fr))
visited = [[False] * len(mp[0]) for _ in range(len(mp))]
visited[fr[1]][fr[0]] = True
while que:
d, point = heappop(que)
x, y = point
... | from heapq import heappush, heappop
INF = 10 ** 10
direct = ((0, -1), (0, 1), (-1, 0), (1, 0))
def dist(fr, to, mp):
que = []
heappush(que, (0, fr))
visited = [[False] * len(mp[0]) for _ in range(len(mp))]
visited[fr[1]][fr[0]] = True
while que:
d, point = heappop(que)
x, y = point
... | 78 | 82 | 1,987 | 1,996 | from heapq import heappush, heappop
INF = 10**10
direct = ((0, -1), (0, 1), (-1, 0), (1, 0))
def dist(fr, to, mp):
que = []
heappush(que, (0, fr))
visited = [[False] * len(mp[0]) for _ in range(len(mp))]
visited[fr[1]][fr[0]] = True
while que:
d, point = heappop(que)
x, y = point
... | from heapq import heappush, heappop
INF = 10**10
direct = ((0, -1), (0, 1), (-1, 0), (1, 0))
def dist(fr, to, mp):
que = []
heappush(que, (0, fr))
visited = [[False] * len(mp[0]) for _ in range(len(mp))]
visited[fr[1]][fr[0]] = True
while que:
d, point = heappop(que)
x, y = point
... | false | 4.878049 | [
"- return sum([10**i for i in rest])",
"+ ret = 0",
"+ for i in rest:",
"+ ret += 10**i",
"+ return ret",
"- if my_hash(rest) in dp[fr]:",
"- return dp[fr][my_hash(rest)]",
"+ h = my_hash(rest)",
"+ if h in dp[fr]:",
"+ return dp[fr][h]",
"- dp[fr][my... | false | 0.046068 | 0.046608 | 0.988408 | [
"s858721357",
"s776104189"
] |
u281303342 | p03449 | python | s690541173 | s180715052 | 19 | 17 | 3,060 | 3,064 | Accepted | Accepted | 10.53 | N = int(eval(input()))
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
Ans = 0
for x in range(N):
ans = 0
for i in range(N):
if i <= x:
ans += A1[i]
if i >= x:
ans += A2[i]
Ans = max(Ans,ans)
print(Ans) | # atcoder : python3 (3.4.3)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
mod = 10**9+7
# main
N = int(eval(input()))
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
ans = 0
for i in range(N):
ans = max(ans, sum(A1[0:i+1])+sum(A2[i:]))
print(ans) | 15 | 16 | 288 | 307 | N = int(eval(input()))
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
Ans = 0
for x in range(N):
ans = 0
for i in range(N):
if i <= x:
ans += A1[i]
if i >= x:
ans += A2[i]
Ans = max(Ans, ans)
print(Ans)
| # atcoder : python3 (3.4.3)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
mod = 10**9 + 7
# main
N = int(eval(input()))
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
ans = 0
for i in range(N):
ans = max(ans, sum(A1[0 : i + 1]) + sum(A2[i:]))
print(ans)
| false | 6.25 | [
"+# atcoder : python3 (3.4.3)",
"+import sys",
"+",
"+input = sys.stdin.readline",
"+sys.setrecursionlimit(10**6)",
"+mod = 10**9 + 7",
"+# main",
"-Ans = 0",
"-for x in range(N):",
"- ans = 0",
"- for i in range(N):",
"- if i <= x:",
"- ans += A1[i]",
"- if ... | false | 0.063875 | 0.069027 | 0.925363 | [
"s690541173",
"s180715052"
] |
u297574184 | p02813 | python | s275040727 | s347477814 | 38 | 35 | 3,060 | 9,124 | Accepted | Accepted | 7.89 | from itertools import permutations
N = int(eval(input()))
Ps = list(map(int, input().split()))
Qs = list(map(int, input().split()))
for i, Rs in enumerate(permutations(list(range(1, N+1))), 1):
Rs = list(Rs)
if Ps == Rs:
a = i
if Qs == Rs:
b = i
print((abs(a-b)))
| from itertools import permutations
N = int(eval(input()))
Ps = tuple(map(int, input().split()))
Qs = tuple(map(int, input().split()))
noP, noQ = 0, 0
for no, Rs in enumerate(permutations(list(range(1, N+1)), r=N), start=1):
if Ps == Rs:
noP = no
if Qs == Rs:
noQ = no
print((abs(n... | 14 | 14 | 294 | 316 | from itertools import permutations
N = int(eval(input()))
Ps = list(map(int, input().split()))
Qs = list(map(int, input().split()))
for i, Rs in enumerate(permutations(list(range(1, N + 1))), 1):
Rs = list(Rs)
if Ps == Rs:
a = i
if Qs == Rs:
b = i
print((abs(a - b)))
| from itertools import permutations
N = int(eval(input()))
Ps = tuple(map(int, input().split()))
Qs = tuple(map(int, input().split()))
noP, noQ = 0, 0
for no, Rs in enumerate(permutations(list(range(1, N + 1)), r=N), start=1):
if Ps == Rs:
noP = no
if Qs == Rs:
noQ = no
print((abs(noP - noQ)))
| false | 0 | [
"-Ps = list(map(int, input().split()))",
"-Qs = list(map(int, input().split()))",
"-for i, Rs in enumerate(permutations(list(range(1, N + 1))), 1):",
"- Rs = list(Rs)",
"+Ps = tuple(map(int, input().split()))",
"+Qs = tuple(map(int, input().split()))",
"+noP, noQ = 0, 0",
"+for no, Rs in enumerate(... | false | 0.094673 | 0.087218 | 1.085486 | [
"s275040727",
"s347477814"
] |
u150984829 | p00468 | python | s364439514 | s196923491 | 60 | 50 | 6,300 | 6,300 | Accepted | Accepted | 16.67 | import sys
r=sys.stdin.readline
for e in iter(r,'0\n'):
R=[[]for _ in[0]*-~int(e)]
for _ in[0]*int(r()):
a,b=list(map(int,r().split()))
R[a]+=[b];R[b]+=[a]
for m in R[1][:]:R[1]+=R[m]
print((len({*R[1]}-{1})))
| def s():
import sys
r=sys.stdin.readline
for e in iter(r,'0\n'):
R=[[]for _ in[0]*-~int(e)]
for _ in[0]*int(r()):
a,b=list(map(int,r().split()))
R[a]+=[b];R[b]+=[a]
for m in R[1][:]:R[1]+=R[m]
print((len({*R[1]}-{1})))
if'__main__'==__name__:s()
| 9 | 11 | 218 | 265 | import sys
r = sys.stdin.readline
for e in iter(r, "0\n"):
R = [[] for _ in [0] * -~int(e)]
for _ in [0] * int(r()):
a, b = list(map(int, r().split()))
R[a] += [b]
R[b] += [a]
for m in R[1][:]:
R[1] += R[m]
print((len({*R[1]} - {1})))
| def s():
import sys
r = sys.stdin.readline
for e in iter(r, "0\n"):
R = [[] for _ in [0] * -~int(e)]
for _ in [0] * int(r()):
a, b = list(map(int, r().split()))
R[a] += [b]
R[b] += [a]
for m in R[1][:]:
R[1] += R[m]
print((len(... | false | 18.181818 | [
"-import sys",
"+def s():",
"+ import sys",
"-r = sys.stdin.readline",
"-for e in iter(r, \"0\\n\"):",
"- R = [[] for _ in [0] * -~int(e)]",
"- for _ in [0] * int(r()):",
"- a, b = list(map(int, r().split()))",
"- R[a] += [b]",
"- R[b] += [a]",
"- for m in R[1][:... | false | 0.037435 | 0.037513 | 0.997914 | [
"s364439514",
"s196923491"
] |
u994988729 | p02887 | python | s790700221 | s872848100 | 46 | 30 | 3,316 | 3,316 | Accepted | Accepted | 34.78 | n = int(eval(input()))
s = eval(input())+"?"
ans = 0
now = "?"
for i in range(n+1):
if i == 0:
now = s[i]
continue
if s[i] == now:
continue
else:
ans += 1
now = s[i]
print(ans)
| N = int(eval(input()))
S = eval(input())
now = "?"
ans = N
for s in S:
if s == now:
ans -= 1
continue
else:
now = s
print(ans)
| 17 | 13 | 236 | 161 | n = int(eval(input()))
s = eval(input()) + "?"
ans = 0
now = "?"
for i in range(n + 1):
if i == 0:
now = s[i]
continue
if s[i] == now:
continue
else:
ans += 1
now = s[i]
print(ans)
| N = int(eval(input()))
S = eval(input())
now = "?"
ans = N
for s in S:
if s == now:
ans -= 1
continue
else:
now = s
print(ans)
| false | 23.529412 | [
"-n = int(eval(input()))",
"-s = eval(input()) + \"?\"",
"-ans = 0",
"+N = int(eval(input()))",
"+S = eval(input())",
"-for i in range(n + 1):",
"- if i == 0:",
"- now = s[i]",
"- continue",
"- if s[i] == now:",
"+ans = N",
"+for s in S:",
"+ if s == now:",
"+ ... | false | 0.038782 | 0.036978 | 1.048791 | [
"s790700221",
"s872848100"
] |
u037430802 | p03339 | python | s599915026 | s714144274 | 295 | 241 | 17,636 | 55,132 | Accepted | Accepted | 18.31 | n = int(eval(input()))
s = eval(input())
a = [0] * (n+1)
b = [0] * (n+1)
ans = 3 * 10 ** 5
aN = s.count("E")
for i in range(n):
if s[i] == "E":
a[i+1] = a[i] + 1
b[i+1] = b[i]
else:
a[i+1] = a[i]
b[i+1] = b[i] + 1
#print(ans, aN-a[i+1]+b[i])
ans = min(ans, aN-a[i+1]+b[i])... | N = int(eval(input()))
S = eval(input())
re = [0] * N # 右からの累積和
le = [0] * N # からの累積和
INF = float("inf")
for i in range(1,N):
if S[i-1] == "E":
le[i] = le[i-1] + 1
else:
le[i] = le[i-1]
if S[N-i] == "E":
re[N-1-i] = re[N-i] + 1
else:
re[N-1-i] = r... | 23 | 25 | 334 | 410 | n = int(eval(input()))
s = eval(input())
a = [0] * (n + 1)
b = [0] * (n + 1)
ans = 3 * 10**5
aN = s.count("E")
for i in range(n):
if s[i] == "E":
a[i + 1] = a[i] + 1
b[i + 1] = b[i]
else:
a[i + 1] = a[i]
b[i + 1] = b[i] + 1
# print(ans, aN-a[i+1]+b[i])
ans = min(ans, aN -... | N = int(eval(input()))
S = eval(input())
re = [0] * N # 右からの累積和
le = [0] * N # からの累積和
INF = float("inf")
for i in range(1, N):
if S[i - 1] == "E":
le[i] = le[i - 1] + 1
else:
le[i] = le[i - 1]
if S[N - i] == "E":
re[N - 1 - i] = re[N - i] + 1
else:
re[N - 1 - i] = re[N ... | false | 8 | [
"-n = int(eval(input()))",
"-s = eval(input())",
"-a = [0] * (n + 1)",
"-b = [0] * (n + 1)",
"-ans = 3 * 10**5",
"-aN = s.count(\"E\")",
"-for i in range(n):",
"- if s[i] == \"E\":",
"- a[i + 1] = a[i] + 1",
"- b[i + 1] = b[i]",
"+N = int(eval(input()))",
"+S = eval(input())",... | false | 0.041265 | 0.04127 | 0.999872 | [
"s599915026",
"s714144274"
] |
u670180528 | p02947 | python | s508331904 | s138520704 | 676 | 365 | 70,616 | 20,028 | Accepted | Accepted | 46.01 | from operator import mul
from functools import reduce
def cmb(n,r):
if r==0 or n==r:return 1
r = min(n-r,r)
ue = reduce(mul, list(range(n, n-r, -1)))
shita = reduce(mul, list(range(1,r+1)))
return ue//shita
n=int(eval(input()))
l=[eval(input()) for i in range(n)]
for i in range(n):
l... | from operator import mul
from functools import reduce
from collections import Counter
def cmb(n,r):
if n < r:return 0
if r == 0 or n-r == 0:return 1
r = min(n-r,r)
up = reduce(mul, list(range(n, n-r, -1)))
down = reduce(mul, list(range(1,r+1)))
return up//down
l = []
for i in range(int(eval(inp... | 28 | 20 | 507 | 424 | from operator import mul
from functools import reduce
def cmb(n, r):
if r == 0 or n == r:
return 1
r = min(n - r, r)
ue = reduce(mul, list(range(n, n - r, -1)))
shita = reduce(mul, list(range(1, r + 1)))
return ue // shita
n = int(eval(input()))
l = [eval(input()) for i in range(n)]
for ... | from operator import mul
from functools import reduce
from collections import Counter
def cmb(n, r):
if n < r:
return 0
if r == 0 or n - r == 0:
return 1
r = min(n - r, r)
up = reduce(mul, list(range(n, n - r, -1)))
down = reduce(mul, list(range(1, r + 1)))
return up // down
... | false | 28.571429 | [
"+from collections import Counter",
"- if r == 0 or n == r:",
"+ if n < r:",
"+ return 0",
"+ if r == 0 or n - r == 0:",
"- ue = reduce(mul, list(range(n, n - r, -1)))",
"- shita = reduce(mul, list(range(1, r + 1)))",
"- return ue // shita",
"+ up = reduce(mul, list(range... | false | 0.040605 | 0.03946 | 1.029035 | [
"s508331904",
"s138520704"
] |
u392319141 | p02781 | python | s509102110 | s255721763 | 99 | 50 | 3,064 | 4,828 | Accepted | Accepted | 49.49 | N = eval(input())
K = int(eval(input()))
def search(d, k, isLess):
if k == K:
return 1
if d == len(N):
return 0
ret = search(d + 1, k, isLess or int(N[d]) > 0)
if k < K:
if isLess:
ret += search(d + 1, k + 1, True) * 9
elif int(N[d]) > 0:
... | from functools import lru_cache
N = eval(input())
K = int(eval(input()))
@lru_cache(maxsize=None)
def search(d, cnt, isLess):
if d == len(N):
return cnt == K
a = int(N[d])
if isLess:
return search(d + 1, cnt + 1, isLess) * 9 + search(d + 1, cnt, isLess)
ret = 0
f... | 21 | 21 | 457 | 428 | N = eval(input())
K = int(eval(input()))
def search(d, k, isLess):
if k == K:
return 1
if d == len(N):
return 0
ret = search(d + 1, k, isLess or int(N[d]) > 0)
if k < K:
if isLess:
ret += search(d + 1, k + 1, True) * 9
elif int(N[d]) > 0:
ret += ... | from functools import lru_cache
N = eval(input())
K = int(eval(input()))
@lru_cache(maxsize=None)
def search(d, cnt, isLess):
if d == len(N):
return cnt == K
a = int(N[d])
if isLess:
return search(d + 1, cnt + 1, isLess) * 9 + search(d + 1, cnt, isLess)
ret = 0
for i in range(a + ... | false | 0 | [
"+from functools import lru_cache",
"+",
"-def search(d, k, isLess):",
"- if k == K:",
"- return 1",
"+@lru_cache(maxsize=None)",
"+def search(d, cnt, isLess):",
"- return 0",
"- ret = search(d + 1, k, isLess or int(N[d]) > 0)",
"- if k < K:",
"- if isLess:",
"- ... | false | 0.047095 | 0.047464 | 0.99223 | [
"s509102110",
"s255721763"
] |
u497952650 | p03575 | python | s693497833 | s850696182 | 907 | 305 | 9,740 | 17,568 | Accepted | Accepted | 66.37 | from copy import deepcopy
from collections import deque
from heapq import heappush, heappop
def warshallfloyd(cost,V):
INF = float("inf")
for k in range(V):
for i in range(V):
for j in range(V):
if cost[i][k]!=INF and cost[k][j]!=INF:
cost[i][... | from scipy.sparse.csgraph import floyd_warshall
from copy import deepcopy
def check(a):
dist = floyd_warshall(a)
for i in dist:
if float("inf") in i:
return True
return False
N,M = list(map(int,input().split()))
edge = [[float("inf") for i in range(N)] for j in range(N)]... | 38 | 33 | 883 | 628 | from copy import deepcopy
from collections import deque
from heapq import heappush, heappop
def warshallfloyd(cost, V):
INF = float("inf")
for k in range(V):
for i in range(V):
for j in range(V):
if cost[i][k] != INF and cost[k][j] != INF:
cost[i][j] = m... | from scipy.sparse.csgraph import floyd_warshall
from copy import deepcopy
def check(a):
dist = floyd_warshall(a)
for i in dist:
if float("inf") in i:
return True
return False
N, M = list(map(int, input().split()))
edge = [[float("inf") for i in range(N)] for j in range(N)]
ab = []
fo... | false | 13.157895 | [
"+from scipy.sparse.csgraph import floyd_warshall",
"-from collections import deque",
"-from heapq import heappush, heappop",
"-def warshallfloyd(cost, V):",
"- INF = float(\"inf\")",
"- for k in range(V):",
"- for i in range(V):",
"- for j in range(V):",
"- if... | false | 0.038618 | 0.250558 | 0.154127 | [
"s693497833",
"s850696182"
] |
u525065967 | p02550 | python | s695158501 | s034161037 | 67 | 52 | 19,256 | 13,724 | Accepted | Accepted | 22.39 | n, x, m = list(map(int, input().split()))
mn = min(n, m)
P = [] # (x,pre_sum)
sum_p = 0 # sum of pre + cycle
X = [-1] * m # for cycle check
for i in range(mn):
if X[x] > -1:
cyc_len = len(P) - X[x]
pre = P[X[x]][1]
cyc = (sum_p - pre) * ((n - X[x]) // cyc_len)
nxt = P[X[x] ... | n, x, m = list(map(int, input().split()))
mn = min(n, m)
P = [] # (x,pre_sum)
sum_p = 0 # sum of pre + cycle
X = [-1] * m # for cycle check
for i in range(mn):
if X[x] > -1:
cyc_len = len(P) - X[x]
pre = P[X[x]]
cyc = (sum_p - pre) * ((n - X[x]) // cyc_len)
nxt = P[X[x] + (... | 18 | 18 | 489 | 475 | n, x, m = list(map(int, input().split()))
mn = min(n, m)
P = [] # (x,pre_sum)
sum_p = 0 # sum of pre + cycle
X = [-1] * m # for cycle check
for i in range(mn):
if X[x] > -1:
cyc_len = len(P) - X[x]
pre = P[X[x]][1]
cyc = (sum_p - pre) * ((n - X[x]) // cyc_len)
nxt = P[X[x] + (n - ... | n, x, m = list(map(int, input().split()))
mn = min(n, m)
P = [] # (x,pre_sum)
sum_p = 0 # sum of pre + cycle
X = [-1] * m # for cycle check
for i in range(mn):
if X[x] > -1:
cyc_len = len(P) - X[x]
pre = P[X[x]]
cyc = (sum_p - pre) * ((n - X[x]) // cyc_len)
nxt = P[X[x] + (n - X[x... | false | 0 | [
"- pre = P[X[x]][1]",
"+ pre = P[X[x]]",
"- nxt = P[X[x] + (n - X[x]) % cyc_len][1] - P[X[x]][1]",
"+ nxt = P[X[x] + (n - X[x]) % cyc_len] - P[X[x]]",
"- P.append([x, sum_p])",
"+ P.append(sum_p)"
] | false | 0.039334 | 0.105188 | 0.373945 | [
"s695158501",
"s034161037"
] |
u303739137 | p02912 | python | s880193949 | s647698087 | 1,244 | 227 | 15,020 | 14,224 | Accepted | Accepted | 81.75 | n, m = list(map(int, input().split()))
aa = list(map(int, input().split()))
from queue import PriorityQueue
q = PriorityQueue()
for a in aa:
q.put(-a)
for i in range(m):
g = q.get()
q.put(-(-g // 2))
cost = 0
for a in aa:
cost -=q.get()
print(cost) | n, m = list(map(int, input().split()))
aa = list(map(int, input().split()))
import heapq
for i in range(len(aa)):
aa[i] = -aa[i]
heapq.heapify(aa)
for i in range(m):
v = heapq.heappop(aa)
heapq.heappush(aa,-(-v // 2))
cost = 0
for i in range(len(aa)):
cost -=heapq.heappop(aa)
print(cost) | 15 | 15 | 274 | 314 | n, m = list(map(int, input().split()))
aa = list(map(int, input().split()))
from queue import PriorityQueue
q = PriorityQueue()
for a in aa:
q.put(-a)
for i in range(m):
g = q.get()
q.put(-(-g // 2))
cost = 0
for a in aa:
cost -= q.get()
print(cost)
| n, m = list(map(int, input().split()))
aa = list(map(int, input().split()))
import heapq
for i in range(len(aa)):
aa[i] = -aa[i]
heapq.heapify(aa)
for i in range(m):
v = heapq.heappop(aa)
heapq.heappush(aa, -(-v // 2))
cost = 0
for i in range(len(aa)):
cost -= heapq.heappop(aa)
print(cost)
| false | 0 | [
"-from queue import PriorityQueue",
"+import heapq",
"-q = PriorityQueue()",
"-for a in aa:",
"- q.put(-a)",
"+for i in range(len(aa)):",
"+ aa[i] = -aa[i]",
"+heapq.heapify(aa)",
"- g = q.get()",
"- q.put(-(-g // 2))",
"+ v = heapq.heappop(aa)",
"+ heapq.heappush(aa, -(-v //... | false | 0.103854 | 0.038469 | 2.699667 | [
"s880193949",
"s647698087"
] |
u644907318 | p02844 | python | s693706140 | s321851595 | 1,203 | 149 | 45,532 | 70,384 | Accepted | Accepted | 87.61 | N = int(eval(input()))
S = input().strip()
cnt = 0
for i in range(10):
for j in range(10):
for k in range(10):
flag = 0
for n in range(N):
if flag==0 and S[n]==str(i):
flag = 1
elif flag==1 and S[n]==str(j):
... | def chk(x):
cur = 0
cnt = 0
while cur<N:
if S[cur]==str(x[cnt]):
cnt += 1
if cnt==3:
break
cur += 1
if cnt==3:
return 1
else:
return 0
N = int(eval(input()))
S = input().strip()
cnt = 0
for i in range(0,10):
... | 18 | 22 | 497 | 414 | N = int(eval(input()))
S = input().strip()
cnt = 0
for i in range(10):
for j in range(10):
for k in range(10):
flag = 0
for n in range(N):
if flag == 0 and S[n] == str(i):
flag = 1
elif flag == 1 and S[n] == str(j):
... | def chk(x):
cur = 0
cnt = 0
while cur < N:
if S[cur] == str(x[cnt]):
cnt += 1
if cnt == 3:
break
cur += 1
if cnt == 3:
return 1
else:
return 0
N = int(eval(input()))
S = input().strip()
cnt = 0
for i in range(0, 10):
for j... | false | 18.181818 | [
"+def chk(x):",
"+ cur = 0",
"+ cnt = 0",
"+ while cur < N:",
"+ if S[cur] == str(x[cnt]):",
"+ cnt += 1",
"+ if cnt == 3:",
"+ break",
"+ cur += 1",
"+ if cnt == 3:",
"+ return 1",
"+ else:",
"+ return 0",
"+"... | false | 0.065388 | 0.040167 | 1.627882 | [
"s693706140",
"s321851595"
] |
u912237403 | p02416 | python | s912239593 | s522368084 | 20 | 10 | 4,240 | 4,208 | Accepted | Accepted | 50 | import sys
for line in sys.stdin:
if int(line) == 0: break
s = 0
for c in line.strip('\n'):
s += '0123456789'.index(c)
print(s) | while True:
x = input()
if x == '0':break
print(sum(['0123456789'.index(c) for c in x])) | 8 | 4 | 158 | 106 | import sys
for line in sys.stdin:
if int(line) == 0:
break
s = 0
for c in line.strip("\n"):
s += "0123456789".index(c)
print(s)
| while True:
x = input()
if x == "0":
break
print(sum(["0123456789".index(c) for c in x]))
| false | 50 | [
"-import sys",
"-",
"-for line in sys.stdin:",
"- if int(line) == 0:",
"+while True:",
"+ x = input()",
"+ if x == \"0\":",
"- s = 0",
"- for c in line.strip(\"\\n\"):",
"- s += \"0123456789\".index(c)",
"- print(s)",
"+ print(sum([\"0123456789\".index(c) for c in x... | false | 0.034877 | 0.040319 | 0.86501 | [
"s912239593",
"s522368084"
] |
u503294750 | p03037 | python | s745531686 | s948427213 | 234 | 216 | 27,104 | 9,108 | Accepted | Accepted | 7.69 | N,M=list(map(int,input().split()))
s=[list(map(int,input().split())) for x in range(M)]
max_left=0
min_right=N
for i in range(M):
if s[i][0]>max_left:
max_left=s[i][0]
if s[i][1]<min_right:
min_right=s[i][1]
cnt=0
for j in range(max_left,min_right+1):
cnt+=1
print(c... | n, m = list(map(int, input().split()))
max_left = 1
min_right = n
for i in range(m):
left, right = list(map(int, input().split()))
max_left = max(max_left, left)
min_right = min(min_right, right)
print((max(min_right - max_left + 1, 0))) | 16 | 11 | 317 | 251 | N, M = list(map(int, input().split()))
s = [list(map(int, input().split())) for x in range(M)]
max_left = 0
min_right = N
for i in range(M):
if s[i][0] > max_left:
max_left = s[i][0]
if s[i][1] < min_right:
min_right = s[i][1]
cnt = 0
for j in range(max_left, min_right + 1):
cnt += 1
print(c... | n, m = list(map(int, input().split()))
max_left = 1
min_right = n
for i in range(m):
left, right = list(map(int, input().split()))
max_left = max(max_left, left)
min_right = min(min_right, right)
print((max(min_right - max_left + 1, 0)))
| false | 31.25 | [
"-N, M = list(map(int, input().split()))",
"-s = [list(map(int, input().split())) for x in range(M)]",
"-max_left = 0",
"-min_right = N",
"-for i in range(M):",
"- if s[i][0] > max_left:",
"- max_left = s[i][0]",
"- if s[i][1] < min_right:",
"- min_right = s[i][1]",
"-cnt = 0",... | false | 0.044487 | 0.072241 | 0.615815 | [
"s745531686",
"s948427213"
] |
u094191970 | p02970 | python | s250341345 | s344030139 | 31 | 27 | 9,064 | 9,100 | Accepted | Accepted | 12.9 | from sys import stdin
nii=lambda:list(map(int,stdin.readline().split()))
lnii=lambda:list(map(int,stdin.readline().split()))
n,d=nii()
print(((n+d*2+1-1)//(d*2+1))) | from sys import stdin
nii=lambda:list(map(int,stdin.readline().split()))
lnii=lambda:list(map(int,stdin.readline().split()))
n,d=nii()
num=d*2+1
print(((n+num-1)//num)) | 6 | 7 | 162 | 167 | from sys import stdin
nii = lambda: list(map(int, stdin.readline().split()))
lnii = lambda: list(map(int, stdin.readline().split()))
n, d = nii()
print(((n + d * 2 + 1 - 1) // (d * 2 + 1)))
| from sys import stdin
nii = lambda: list(map(int, stdin.readline().split()))
lnii = lambda: list(map(int, stdin.readline().split()))
n, d = nii()
num = d * 2 + 1
print(((n + num - 1) // num))
| false | 14.285714 | [
"-print(((n + d * 2 + 1 - 1) // (d * 2 + 1)))",
"+num = d * 2 + 1",
"+print(((n + num - 1) // num))"
] | false | 0.04288 | 0.156325 | 0.274301 | [
"s250341345",
"s344030139"
] |
u059210959 | p02996 | python | s058113030 | s619705666 | 1,200 | 709 | 97,352 | 31,932 | Accepted | Accepted | 40.92 | # encoding:utf-8
import copy
import random
import bisect #bisect_left これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
def LI(): return list(map(int, sys.stdin.readline().split()))
N = int(eval(input()))
BA = [[] for i ... | # encoding:utf-8
import copy
import random
import bisect #bisect_left これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
def LI(): return list(map(int, sys.stdin.readline().split()))
N = int(eval(input()))
BA = [[] for i ... | 32 | 30 | 624 | 540 | # encoding:utf-8
import copy
import random
import bisect # bisect_left これで二部探索の大小検索が行える
import fractions # 最小公倍数などはこっち
import math
import sys
mod = 10**9 + 7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
def LI():
return list(map(int, sys.stdin.readline().split()))
N = int(eval(input()))
BA = [[] for i i... | # encoding:utf-8
import copy
import random
import bisect # bisect_left これで二部探索の大小検索が行える
import fractions # 最小公倍数などはこっち
import math
import sys
mod = 10**9 + 7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
def LI():
return list(map(int, sys.stdin.readline().split()))
N = int(eval(input()))
BA = [[] for i i... | false | 6.25 | [
"-part_A = [0 for i in range(N)]",
"+tmp = 0",
"- B, A = BA[i]",
"- part_A[i] = A + part_A[i - 1]",
"-for i in range(N):",
"- B, A = BA[i]",
"- if B - part_A[i] < 0:",
"+ b, a = BA[i]",
"+ tmp += a",
"+ if b - tmp < 0:"
] | false | 0.06001 | 0.104188 | 0.575979 | [
"s058113030",
"s619705666"
] |
u173148629 | p02732 | python | s542703950 | s266845127 | 405 | 362 | 26,140 | 26,140 | Accepted | Accepted | 10.62 | N=int(eval(input()))
A=list(map(int,input().split()))
B={}
for i in range(N):
if A[i] not in B:
B[A[i]]=1
else:
B[A[i]]+=1
total=0
for k,v in list(B.items()):
total+=v*(v-1)//2
for i in range(N):
ans=total
ans-=B[A[i]]-1
print(ans)
| N=int(eval(input()))
A=list(map(int,input().split()))
from collections import Counter
B=Counter(A)
total=0
for v in list(B.values()):
total+=v*(v-1)//2
for i in range(N):
ans=total
ans-=B[A[i]]-1
print(ans)
| 19 | 15 | 282 | 229 | N = int(eval(input()))
A = list(map(int, input().split()))
B = {}
for i in range(N):
if A[i] not in B:
B[A[i]] = 1
else:
B[A[i]] += 1
total = 0
for k, v in list(B.items()):
total += v * (v - 1) // 2
for i in range(N):
ans = total
ans -= B[A[i]] - 1
print(ans)
| N = int(eval(input()))
A = list(map(int, input().split()))
from collections import Counter
B = Counter(A)
total = 0
for v in list(B.values()):
total += v * (v - 1) // 2
for i in range(N):
ans = total
ans -= B[A[i]] - 1
print(ans)
| false | 21.052632 | [
"-B = {}",
"-for i in range(N):",
"- if A[i] not in B:",
"- B[A[i]] = 1",
"- else:",
"- B[A[i]] += 1",
"+from collections import Counter",
"+",
"+B = Counter(A)",
"-for k, v in list(B.items()):",
"+for v in list(B.values()):"
] | false | 0.040577 | 0.094821 | 0.42793 | [
"s542703950",
"s266845127"
] |
u123745130 | p02947 | python | s332623237 | s242670888 | 880 | 461 | 29,072 | 29,072 | Accepted | Accepted | 47.61 | import math
def comb(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n=int(eval(input()))
l=[list(eval(input())) for _ in range(n)]
dic_l={}
cnt=0
ans_lst=[]
for i in range(n):
l[i].sort()
l[i]=str(l[i])
if l[i] not in dic_l:
dic_l[l[i]]=1
else:
dic_l[l... | n=int(eval(input()))
l=[list(eval(input())) for _ in range(n)]
dic_l={}
cnt=0
ans_lst=[]
for i in range(n):
l[i].sort()
l[i]=str(l[i])
if l[i] not in dic_l:
dic_l[l[i]]=1
else:
dic_l[l[i]]+=1
for j in list(dic_l.values()):
if j>=2:
ans_lst.append(j)
cnt += int(j*(j-1)/2)
print(... | 21 | 17 | 411 | 306 | import math
def comb(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(eval(input()))
l = [list(eval(input())) for _ in range(n)]
dic_l = {}
cnt = 0
ans_lst = []
for i in range(n):
l[i].sort()
l[i] = str(l[i])
if l[i] not in dic_l:
dic_l[l[i]] = 1
els... | n = int(eval(input()))
l = [list(eval(input())) for _ in range(n)]
dic_l = {}
cnt = 0
ans_lst = []
for i in range(n):
l[i].sort()
l[i] = str(l[i])
if l[i] not in dic_l:
dic_l[l[i]] = 1
else:
dic_l[l[i]] += 1
for j in list(dic_l.values()):
if j >= 2:
ans_lst.append(j)
... | false | 19.047619 | [
"-import math",
"-",
"-",
"-def comb(n, r):",
"- return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))",
"-",
"-",
"- cnt += comb(j, 2)",
"+ cnt += int(j * (j - 1) / 2)"
] | false | 0.047437 | 0.087698 | 0.54091 | [
"s332623237",
"s242670888"
] |
u001024152 | p03196 | python | s268461412 | s157449637 | 256 | 177 | 49,004 | 38,512 | Accepted | Accepted | 30.86 | from collections import defaultdict
from math import sqrt
N,P = list(map(int, input().split()))
is_prime = [True]*(10**6+1)
is_prime[0] = is_prime[1] = False
def sieve(n:int):
"""Sieve of Eratoshenes
return the number of prime number (0, n]"""
global is_prime
for i in range(2, n+1):
if... | from collections import defaultdict
from math import sqrt
N,P = list(map(int, input().split()))
def factorize(a:int):
"""prime factorization O(sqrt(N))
return dict of prime factor
"""
ps = {}
i = 2
nokori = a
while i*i <= nokori:
if nokori%i==0:
cnt = 0
... | 32 | 29 | 755 | 603 | from collections import defaultdict
from math import sqrt
N, P = list(map(int, input().split()))
is_prime = [True] * (10**6 + 1)
is_prime[0] = is_prime[1] = False
def sieve(n: int):
"""Sieve of Eratoshenes
return the number of prime number (0, n]"""
global is_prime
for i in range(2, n + 1):
i... | from collections import defaultdict
from math import sqrt
N, P = list(map(int, input().split()))
def factorize(a: int):
"""prime factorization O(sqrt(N))
return dict of prime factor
"""
ps = {}
i = 2
nokori = a
while i * i <= nokori:
if nokori % i == 0:
cnt = 0
... | false | 9.375 | [
"-is_prime = [True] * (10**6 + 1)",
"-is_prime[0] = is_prime[1] = False",
"-def sieve(n: int):",
"- \"\"\"Sieve of Eratoshenes",
"- return the number of prime number (0, n]\"\"\"",
"- global is_prime",
"- for i in range(2, n + 1):",
"- if is_prime[i]:",
"- # 素数の倍数は合成数",... | false | 0.547704 | 0.05601 | 9.778642 | [
"s268461412",
"s157449637"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.