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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u475675023 | p03524 | python | s826834956 | s628276491 | 24 | 19 | 4,084 | 3,188 | Accepted | Accepted | 20.83 | s=eval(input())
a=s.count('a')
b=s.count('b')
c=s.count('c')
if len(set(list(s)))==1 and len(s)>1:
print('NO')
elif len(set(list(s)))==2 and len(s)>2:
print('NO')
elif abs(a-b)<=1 and abs(b-c)<=1 and abs(c-a)<=1:
print('YES')
else:
print('NO') | s=eval(input())
a=s.count('a')
b=s.count('b')
c=s.count('c')
if abs(a-b)<=1 and abs(b-c)<=1 and abs(c-a)<=1:
print('YES')
else:
print('NO') | 12 | 8 | 256 | 144 | s = eval(input())
a = s.count("a")
b = s.count("b")
c = s.count("c")
if len(set(list(s))) == 1 and len(s) > 1:
print("NO")
elif len(set(list(s))) == 2 and len(s) > 2:
print("NO")
elif abs(a - b) <= 1 and abs(b - c) <= 1 and abs(c - a) <= 1:
print("YES")
else:
print("NO")
| s = eval(input())
a = s.count("a")
b = s.count("b")
c = s.count("c")
if abs(a - b) <= 1 and abs(b - c) <= 1 and abs(c - a) <= 1:
print("YES")
else:
print("NO")
| false | 33.333333 | [
"-if len(set(list(s))) == 1 and len(s) > 1:",
"- print(\"NO\")",
"-elif len(set(list(s))) == 2 and len(s) > 2:",
"- print(\"NO\")",
"-elif abs(a - b) <= 1 and abs(b - c) <= 1 and abs(c - a) <= 1:",
"+if abs(a - b) <= 1 and abs(b - c) <= 1 and abs(c - a) <= 1:"
]
| false | 0.114618 | 0.03421 | 3.350398 | [
"s826834956",
"s628276491"
]
|
u133936772 | p03503 | python | s093466136 | s479516885 | 211 | 59 | 3,188 | 3,188 | Accepted | Accepted | 72.04 | f=lambda:[list(map(int,input().split())) for _ in range(n)]
n=int(eval(input()))
llf,llp=f(),f()
a=-10**9
import itertools as it
for t in it.product([0,1],repeat=10):
if sum(t):
lc=[sum(t[i]*lf[i] for i in range(10)) for lf in llf]
a=max(a,sum(llp[i][lc[i]] for i in range(n)))
print(a) | I=input;R=range;n=int(I())
lf=[int(I()[::2],2) for _ in R(n)]
lp=[list(map(int,I().split())) for _ in R(n)]
print((max(sum(p[bin(i&f).count('1')] for f,p in zip(lf,lp)) for i in R(1,1024)))) | 10 | 4 | 299 | 191 | f = lambda: [list(map(int, input().split())) for _ in range(n)]
n = int(eval(input()))
llf, llp = f(), f()
a = -(10**9)
import itertools as it
for t in it.product([0, 1], repeat=10):
if sum(t):
lc = [sum(t[i] * lf[i] for i in range(10)) for lf in llf]
a = max(a, sum(llp[i][lc[i]] for i in range(n)))
print(a)
| I = input
R = range
n = int(I())
lf = [int(I()[::2], 2) for _ in R(n)]
lp = [list(map(int, I().split())) for _ in R(n)]
print((max(sum(p[bin(i & f).count("1")] for f, p in zip(lf, lp)) for i in R(1, 1024))))
| false | 60 | [
"-f = lambda: [list(map(int, input().split())) for _ in range(n)]",
"-n = int(eval(input()))",
"-llf, llp = f(), f()",
"-a = -(10**9)",
"-import itertools as it",
"-",
"-for t in it.product([0, 1], repeat=10):",
"- if sum(t):",
"- lc = [sum(t[i] * lf[i] for i in range(10)) for lf in llf]",
"- a = max(a, sum(llp[i][lc[i]] for i in range(n)))",
"-print(a)",
"+I = input",
"+R = range",
"+n = int(I())",
"+lf = [int(I()[::2], 2) for _ in R(n)]",
"+lp = [list(map(int, I().split())) for _ in R(n)]",
"+print((max(sum(p[bin(i & f).count(\"1\")] for f, p in zip(lf, lp)) for i in R(1, 1024))))"
]
| false | 0.062973 | 0.038158 | 1.650315 | [
"s093466136",
"s479516885"
]
|
u970269944 | p00462 | python | s676019758 | s505429009 | 370 | 340 | 16,380 | 15,572 | Accepted | Accepted | 8.11 | mapping = {}
def find(l, e, start, end):
global mapping
if e in mapping:
return mapping[e]
mid = (start+end)//2
if (l[mid] == e):
mapping[e] = (e, e)
return mapping[e]
elif (l[mid] > e):
if (l[mid-1] < e):
mapping[e] = (l[mid-1], l[mid])
return mapping[e]
return find(l, e, start, mid)
elif (l[mid] < e):
if (l[mid+1] > e):
mapping[e] = (l[mid], l[mid+1])
return mapping[e]
return find(l, e, mid, end)
def print_sum(input):
global mapping
mapping = {}
d, n, m = input[0], input[1], input[2]
S, K = input[3:3+n-1], input[3+n-1:]
S = sorted(S)
S = [S[-1]-d, 0] + S + [d]
sum = 0
for k in K:
low, high = find(S, k, 0, len(S))
sum += min(k-low, high-k)
print(sum)
while (True):
d = int(input())
if d == 0: break
n, m = int(input()), int(input())
input = [d, n, m]
for i in range(n-1+m):
next_int = int(input())
input.append(next_int)
print_sum(input) | def find(l, e, start, end):
mid = (start+end)//2
if (l[mid] == e):
return (e, e)
elif (l[mid] > e):
if (l[mid-1] < e):
return (l[mid-1], l[mid])
return find(l, e, start, mid)
elif (l[mid] < e):
if (l[mid+1] > e):
return (l[mid], l[mid+1])
return find(l, e, mid, end)
def print_sum(input):
d, n, m = input[0], input[1], input[2]
S, K = input[3:3+n-1], input[3+n-1:]
S = sorted(S)
S = [S[-1]-d, 0] + S + [d]
sum = 0
for k in K:
low, high = find(S, k, 0, len(S))
sum += min(k-low, high-k)
print(sum)
while (True):
d = int(input())
if d == 0: break
n, m = int(input()), int(input())
input = [d, n, m]
for i in range(n-1+m):
next_int = int(input())
input.append(next_int)
print_sum(input) | 42 | 33 | 960 | 773 | mapping = {}
def find(l, e, start, end):
global mapping
if e in mapping:
return mapping[e]
mid = (start + end) // 2
if l[mid] == e:
mapping[e] = (e, e)
return mapping[e]
elif l[mid] > e:
if l[mid - 1] < e:
mapping[e] = (l[mid - 1], l[mid])
return mapping[e]
return find(l, e, start, mid)
elif l[mid] < e:
if l[mid + 1] > e:
mapping[e] = (l[mid], l[mid + 1])
return mapping[e]
return find(l, e, mid, end)
def print_sum(input):
global mapping
mapping = {}
d, n, m = input[0], input[1], input[2]
S, K = input[3 : 3 + n - 1], input[3 + n - 1 :]
S = sorted(S)
S = [S[-1] - d, 0] + S + [d]
sum = 0
for k in K:
low, high = find(S, k, 0, len(S))
sum += min(k - low, high - k)
print(sum)
while True:
d = int(input())
if d == 0:
break
n, m = int(input()), int(input())
input = [d, n, m]
for i in range(n - 1 + m):
next_int = int(input())
input.append(next_int)
print_sum(input)
| def find(l, e, start, end):
mid = (start + end) // 2
if l[mid] == e:
return (e, e)
elif l[mid] > e:
if l[mid - 1] < e:
return (l[mid - 1], l[mid])
return find(l, e, start, mid)
elif l[mid] < e:
if l[mid + 1] > e:
return (l[mid], l[mid + 1])
return find(l, e, mid, end)
def print_sum(input):
d, n, m = input[0], input[1], input[2]
S, K = input[3 : 3 + n - 1], input[3 + n - 1 :]
S = sorted(S)
S = [S[-1] - d, 0] + S + [d]
sum = 0
for k in K:
low, high = find(S, k, 0, len(S))
sum += min(k - low, high - k)
print(sum)
while True:
d = int(input())
if d == 0:
break
n, m = int(input()), int(input())
input = [d, n, m]
for i in range(n - 1 + m):
next_int = int(input())
input.append(next_int)
print_sum(input)
| false | 21.428571 | [
"-mapping = {}",
"-",
"-",
"- global mapping",
"- if e in mapping:",
"- return mapping[e]",
"- mapping[e] = (e, e)",
"- return mapping[e]",
"+ return (e, e)",
"- mapping[e] = (l[mid - 1], l[mid])",
"- return mapping[e]",
"+ return (l[mid - 1], l[mid])",
"- mapping[e] = (l[mid], l[mid + 1])",
"- return mapping[e]",
"+ return (l[mid], l[mid + 1])",
"- global mapping",
"- mapping = {}"
]
| false | 0.112596 | 0.104598 | 1.076466 | [
"s676019758",
"s505429009"
]
|
u281610856 | p02723 | python | s028879304 | s721591275 | 41 | 18 | 3,060 | 2,940 | Accepted | Accepted | 56.1 | s = eval(input())
if s[2] == s[3] and s[4] == s[5]:
print('Yes')
else:
print('No') | import sys
input = sys.stdin.readline
def main():
s = eval(input())
if s[2] == s[3] and s[4] == s[5]:
print("Yes")
else:
print("No")
if __name__ == '__main__':
main() | 5 | 13 | 88 | 207 | s = eval(input())
if s[2] == s[3] and s[4] == s[5]:
print("Yes")
else:
print("No")
| import sys
input = sys.stdin.readline
def main():
s = eval(input())
if s[2] == s[3] and s[4] == s[5]:
print("Yes")
else:
print("No")
if __name__ == "__main__":
main()
| false | 61.538462 | [
"-s = eval(input())",
"-if s[2] == s[3] and s[4] == s[5]:",
"- print(\"Yes\")",
"-else:",
"- print(\"No\")",
"+import sys",
"+",
"+input = sys.stdin.readline",
"+",
"+",
"+def main():",
"+ s = eval(input())",
"+ if s[2] == s[3] and s[4] == s[5]:",
"+ print(\"Yes\")",
"+ else:",
"+ print(\"No\")",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
]
| false | 0.040285 | 0.076033 | 0.529831 | [
"s028879304",
"s721591275"
]
|
u644907318 | p03229 | python | s258527446 | s157885009 | 646 | 203 | 60,248 | 95,044 | Accepted | Accepted | 68.58 | from collections import deque
N = int(eval(input()))
A = deque(sorted([int(eval(input())) for _ in range(N)]))
B = deque([])
B.append(A.popleft())
cnt = 0
while A:
a0 = A[0]
a1 = A[-1]
b0 = B[0]
b1 = B[-1]
c00 = abs(a0-b0)
c01 = abs(a0-b1)
c10 = abs(a1-b0)
c11 = abs(a1-b1)
cmax = max(c00,c01,c10,c11)
if cmax == c00:
B.appendleft(A.popleft())
elif cmax == c01:
B.append(A.popleft())
elif cmax == c10:
B.appendleft(A.pop())
else:
B.append(A.pop())
cnt += cmax
print(cnt) | N = int(eval(input()))
A = sorted([int(eval(input())) for _ in range(N)])
if N%2==0:
B = A[:N//2]
C = A[N//2:]
C = C[::-1]
D1 = []
D2 = []
for i in range(N//2-1):
D1.append(B[i])
D1.append(C[i])
D2.append(C[i])
D2.append(B[i])
D1.append(B[-1])
D1.insert(0,C[-1])
D2.append(C[-1])
D2.insert(0,B[-1])
cnt1 = 0
cnt2 = 0
for i in range(1,N):
cnt1 += abs(D1[i]-D1[i-1])
cnt2 += abs(D2[i]-D2[i-1])
print((max(cnt1,cnt2)))
else:
B = A[:N//2]
C = A[N//2+1:]
C = C[::-1]
D1 = []
D2 = []
for i in range(N//2):
D1.append(B[i])
D1.append(C[i])
D2.append(C[i])
D2.append(B[i])
cnt1 = 0
cnt2 = 0
for i in range(1,N-1):
cnt1 += abs(D1[i]-D1[i-1])
cnt2 += abs(D2[i]-D2[i-1])
cnt1 += max(A[N//2]-D1[0],D1[-1]-A[N//2])
cnt2 += max(D2[0]-A[N//2],A[N//2]-D2[-1])
print((max(cnt1,cnt2))) | 26 | 42 | 571 | 991 | from collections import deque
N = int(eval(input()))
A = deque(sorted([int(eval(input())) for _ in range(N)]))
B = deque([])
B.append(A.popleft())
cnt = 0
while A:
a0 = A[0]
a1 = A[-1]
b0 = B[0]
b1 = B[-1]
c00 = abs(a0 - b0)
c01 = abs(a0 - b1)
c10 = abs(a1 - b0)
c11 = abs(a1 - b1)
cmax = max(c00, c01, c10, c11)
if cmax == c00:
B.appendleft(A.popleft())
elif cmax == c01:
B.append(A.popleft())
elif cmax == c10:
B.appendleft(A.pop())
else:
B.append(A.pop())
cnt += cmax
print(cnt)
| N = int(eval(input()))
A = sorted([int(eval(input())) for _ in range(N)])
if N % 2 == 0:
B = A[: N // 2]
C = A[N // 2 :]
C = C[::-1]
D1 = []
D2 = []
for i in range(N // 2 - 1):
D1.append(B[i])
D1.append(C[i])
D2.append(C[i])
D2.append(B[i])
D1.append(B[-1])
D1.insert(0, C[-1])
D2.append(C[-1])
D2.insert(0, B[-1])
cnt1 = 0
cnt2 = 0
for i in range(1, N):
cnt1 += abs(D1[i] - D1[i - 1])
cnt2 += abs(D2[i] - D2[i - 1])
print((max(cnt1, cnt2)))
else:
B = A[: N // 2]
C = A[N // 2 + 1 :]
C = C[::-1]
D1 = []
D2 = []
for i in range(N // 2):
D1.append(B[i])
D1.append(C[i])
D2.append(C[i])
D2.append(B[i])
cnt1 = 0
cnt2 = 0
for i in range(1, N - 1):
cnt1 += abs(D1[i] - D1[i - 1])
cnt2 += abs(D2[i] - D2[i - 1])
cnt1 += max(A[N // 2] - D1[0], D1[-1] - A[N // 2])
cnt2 += max(D2[0] - A[N // 2], A[N // 2] - D2[-1])
print((max(cnt1, cnt2)))
| false | 38.095238 | [
"-from collections import deque",
"-",
"-A = deque(sorted([int(eval(input())) for _ in range(N)]))",
"-B = deque([])",
"-B.append(A.popleft())",
"-cnt = 0",
"-while A:",
"- a0 = A[0]",
"- a1 = A[-1]",
"- b0 = B[0]",
"- b1 = B[-1]",
"- c00 = abs(a0 - b0)",
"- c01 = abs(a0 - b1)",
"- c10 = abs(a1 - b0)",
"- c11 = abs(a1 - b1)",
"- cmax = max(c00, c01, c10, c11)",
"- if cmax == c00:",
"- B.appendleft(A.popleft())",
"- elif cmax == c01:",
"- B.append(A.popleft())",
"- elif cmax == c10:",
"- B.appendleft(A.pop())",
"- else:",
"- B.append(A.pop())",
"- cnt += cmax",
"-print(cnt)",
"+A = sorted([int(eval(input())) for _ in range(N)])",
"+if N % 2 == 0:",
"+ B = A[: N // 2]",
"+ C = A[N // 2 :]",
"+ C = C[::-1]",
"+ D1 = []",
"+ D2 = []",
"+ for i in range(N // 2 - 1):",
"+ D1.append(B[i])",
"+ D1.append(C[i])",
"+ D2.append(C[i])",
"+ D2.append(B[i])",
"+ D1.append(B[-1])",
"+ D1.insert(0, C[-1])",
"+ D2.append(C[-1])",
"+ D2.insert(0, B[-1])",
"+ cnt1 = 0",
"+ cnt2 = 0",
"+ for i in range(1, N):",
"+ cnt1 += abs(D1[i] - D1[i - 1])",
"+ cnt2 += abs(D2[i] - D2[i - 1])",
"+ print((max(cnt1, cnt2)))",
"+else:",
"+ B = A[: N // 2]",
"+ C = A[N // 2 + 1 :]",
"+ C = C[::-1]",
"+ D1 = []",
"+ D2 = []",
"+ for i in range(N // 2):",
"+ D1.append(B[i])",
"+ D1.append(C[i])",
"+ D2.append(C[i])",
"+ D2.append(B[i])",
"+ cnt1 = 0",
"+ cnt2 = 0",
"+ for i in range(1, N - 1):",
"+ cnt1 += abs(D1[i] - D1[i - 1])",
"+ cnt2 += abs(D2[i] - D2[i - 1])",
"+ cnt1 += max(A[N // 2] - D1[0], D1[-1] - A[N // 2])",
"+ cnt2 += max(D2[0] - A[N // 2], A[N // 2] - D2[-1])",
"+ print((max(cnt1, cnt2)))"
]
| false | 0.040755 | 0.076485 | 0.532855 | [
"s258527446",
"s157885009"
]
|
u748241164 | p03835 | python | s692697699 | s351549572 | 1,468 | 1,042 | 2,940 | 9,160 | Accepted | Accepted | 29.02 | K, S = list(map(int, input().split()))
count= 0
for i in range(K+1):# X
for j in range(K+1):#Y
Z = S - i - j
if 0 <= Z <= K:
count += 1
#print(i,j,Z)
print(count) | K, S = list(map(int, input().split()))
ans = 0
for i in range(K + 1):
for j in range(K + 1):
#print(i, j)
if 0 <= S - i - j <= K:
ans += 1
print(ans) | 11 | 10 | 190 | 182 | K, S = list(map(int, input().split()))
count = 0
for i in range(K + 1): # X
for j in range(K + 1): # Y
Z = S - i - j
if 0 <= Z <= K:
count += 1
# print(i,j,Z)
print(count)
| K, S = list(map(int, input().split()))
ans = 0
for i in range(K + 1):
for j in range(K + 1):
# print(i, j)
if 0 <= S - i - j <= K:
ans += 1
print(ans)
| false | 9.090909 | [
"-count = 0",
"-for i in range(K + 1): # X",
"- for j in range(K + 1): # Y",
"- Z = S - i - j",
"- if 0 <= Z <= K:",
"- count += 1",
"- # print(i,j,Z)",
"-print(count)",
"+ans = 0",
"+for i in range(K + 1):",
"+ for j in range(K + 1):",
"+ # print(i, j)",
"+ if 0 <= S - i - j <= K:",
"+ ans += 1",
"+print(ans)"
]
| false | 0.055113 | 0.140604 | 0.391972 | [
"s692697699",
"s351549572"
]
|
u935558307 | p02990 | python | s848538600 | s425604097 | 480 | 275 | 79,856 | 167,936 | Accepted | Accepted | 42.71 | """
問題文は言い換えると、青いボールの連続する区間の数がi個になるような並べ方はいくつあるか。というもの
上記のような並べ方はさらに4種類に分けられる。
(1). 両端が青色になるような並べ方
(2). 両端が赤色になるような並べ方
(3). 左端が赤色、右端が青色になるような並べ方
(4). 左端が青色、右端が赤色になるような並べ方
(1)の場合:A(K個並んでいるの青ボールの隙間にi-1個の赤ボールグループをぶっこむ箇所の場合の数) × B(i-1個のグループに割り振る赤ボールの数)
Aは(k-1)個の隙間から(i-1)個の隙間を選ぶ場合の数なので、(k-1)C(i-1)で計算できる。Bは各グループに最低1個は赤色のボールを割り当てるとして残りN-K-(i-1)をどう分けるか、の場合の数なので、(N-K-(i-1)+(i-2))C(i-2)で計算できる。
(2)の場合:A(K個並んでいるの青ボールの隙間にi-1個の赤ボールグループをぶっこむ箇所の場合の数) × B(i+1個のグループに割り振る赤ボールの数)
Aは(1)と同様なので省略。Bは各グループに最低1個は赤色のボールを割り当てるとして残りN-K-(i+1)をどう分けるか、の場合の数なので、(N-K-(i+1)+i)C(i)で計算できる。
(3)の場合:A(K個並んでいるの青ボールの隙間にi-1個の赤ボールグループをぶっこむ箇所の場合の数) × B(i個のグループに割り振る赤ボールの数)
Aは(1)と同様なので省略。Bは各グループに最低1個は赤色のボールを割り当てるとして残りN-K-iをどう分けるか、の場合の数なので、(N-K-i+(i-1))C(i-1)で計算できる。
(4)は(3)と同様なので省略
なお、赤のボールの数が分割するグループの数以上存在していないと行けないことに注意。
"""
def choose(n,k):
import math
return math.factorial(n)//(math.factorial(n-k)*math.factorial(k))
mod = 10**9 +7
N,K = list(map(int,input().split()))
for i in range(1,K+1):
ans = 0
A = choose(K-1,i-1)
#(1)の場合の数を求める
if N-K >= i-1:
if i-2>=0:
B = choose(N-K-(i-1)+(i-2),i-2)
ans += A*B
ans %= mod
elif N==K:
ans += 1
if N-K >= i+1:
B = choose(N-K-(i+1)+i,i)
ans += A*B
ans %= mod
if N-K >= i:
B = choose(N-K-i+(i-1),i-1)
ans += A*B*2
ans %= mod
print(ans)
| """
Kをi分割する場合の数=cmb(K+i-1,i-1)
両端が赤になる場合、両端が青になる場合、左端のみ赤になる場合、右端のみ赤になる場合についてそれぞれ計算すればよい。
"""
def cmb(n, r, p):
if (r < 0) or (n < r):
return 0
r = min(r, n - r)
return fact[n] * factinv[r] * factinv[n-r] % p
p = 10 ** 9 + 7
N = 10 ** 6 # N は必要分だけ用意する
fact = [1, 1] # fact[n] = (n! mod p)
factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1] # factinv 計算用
for i in range(2, N + 1):
fact.append((fact[-1] * i) % p)
inv.append((-inv[p % i] * (p // i)) % p)
factinv.append((factinv[-1] * inv[-1]) % p)
N,K = list(map(int,input().split()))
for i in range(1,K+1):
ans = 0
#Kをi分割する場合の数
divideK = cmb(K-i+i-1,i-1,p)
#両端が赤の場合の置き方
ans += divideK*cmb(N-K-(i+1)+i,i,p)%p
ans %= p
#両端が青の場合の置き方
if i > 1:
ans += divideK*cmb(N-K-(i-1)+i-2,i-2,p)%p
ans %= p
elif N-K == 0:
ans += 1
#左端のみが赤になる場合の置き方,右端のみが赤になる場合の置き方
ans += divideK*cmb(N-K-i+i-1,i-1,p)*2%p
ans %= p
print(ans) | 52 | 39 | 1,458 | 1,016 | """
問題文は言い換えると、青いボールの連続する区間の数がi個になるような並べ方はいくつあるか。というもの
上記のような並べ方はさらに4種類に分けられる。
(1). 両端が青色になるような並べ方
(2). 両端が赤色になるような並べ方
(3). 左端が赤色、右端が青色になるような並べ方
(4). 左端が青色、右端が赤色になるような並べ方
(1)の場合:A(K個並んでいるの青ボールの隙間にi-1個の赤ボールグループをぶっこむ箇所の場合の数) × B(i-1個のグループに割り振る赤ボールの数)
Aは(k-1)個の隙間から(i-1)個の隙間を選ぶ場合の数なので、(k-1)C(i-1)で計算できる。Bは各グループに最低1個は赤色のボールを割り当てるとして残りN-K-(i-1)をどう分けるか、の場合の数なので、(N-K-(i-1)+(i-2))C(i-2)で計算できる。
(2)の場合:A(K個並んでいるの青ボールの隙間にi-1個の赤ボールグループをぶっこむ箇所の場合の数) × B(i+1個のグループに割り振る赤ボールの数)
Aは(1)と同様なので省略。Bは各グループに最低1個は赤色のボールを割り当てるとして残りN-K-(i+1)をどう分けるか、の場合の数なので、(N-K-(i+1)+i)C(i)で計算できる。
(3)の場合:A(K個並んでいるの青ボールの隙間にi-1個の赤ボールグループをぶっこむ箇所の場合の数) × B(i個のグループに割り振る赤ボールの数)
Aは(1)と同様なので省略。Bは各グループに最低1個は赤色のボールを割り当てるとして残りN-K-iをどう分けるか、の場合の数なので、(N-K-i+(i-1))C(i-1)で計算できる。
(4)は(3)と同様なので省略
なお、赤のボールの数が分割するグループの数以上存在していないと行けないことに注意。
"""
def choose(n, k):
import math
return math.factorial(n) // (math.factorial(n - k) * math.factorial(k))
mod = 10**9 + 7
N, K = list(map(int, input().split()))
for i in range(1, K + 1):
ans = 0
A = choose(K - 1, i - 1)
# (1)の場合の数を求める
if N - K >= i - 1:
if i - 2 >= 0:
B = choose(N - K - (i - 1) + (i - 2), i - 2)
ans += A * B
ans %= mod
elif N == K:
ans += 1
if N - K >= i + 1:
B = choose(N - K - (i + 1) + i, i)
ans += A * B
ans %= mod
if N - K >= i:
B = choose(N - K - i + (i - 1), i - 1)
ans += A * B * 2
ans %= mod
print(ans)
| """
Kをi分割する場合の数=cmb(K+i-1,i-1)
両端が赤になる場合、両端が青になる場合、左端のみ赤になる場合、右端のみ赤になる場合についてそれぞれ計算すればよい。
"""
def cmb(n, r, p):
if (r < 0) or (n < r):
return 0
r = min(r, n - r)
return fact[n] * factinv[r] * factinv[n - r] % p
p = 10**9 + 7
N = 10**6 # N は必要分だけ用意する
fact = [1, 1] # fact[n] = (n! mod p)
factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1] # factinv 計算用
for i in range(2, N + 1):
fact.append((fact[-1] * i) % p)
inv.append((-inv[p % i] * (p // i)) % p)
factinv.append((factinv[-1] * inv[-1]) % p)
N, K = list(map(int, input().split()))
for i in range(1, K + 1):
ans = 0
# Kをi分割する場合の数
divideK = cmb(K - i + i - 1, i - 1, p)
# 両端が赤の場合の置き方
ans += divideK * cmb(N - K - (i + 1) + i, i, p) % p
ans %= p
# 両端が青の場合の置き方
if i > 1:
ans += divideK * cmb(N - K - (i - 1) + i - 2, i - 2, p) % p
ans %= p
elif N - K == 0:
ans += 1
# 左端のみが赤になる場合の置き方,右端のみが赤になる場合の置き方
ans += divideK * cmb(N - K - i + i - 1, i - 1, p) * 2 % p
ans %= p
print(ans)
| false | 25 | [
"-問題文は言い換えると、青いボールの連続する区間の数がi個になるような並べ方はいくつあるか。というもの",
"-上記のような並べ方はさらに4種類に分けられる。",
"-(1). 両端が青色になるような並べ方",
"-(2). 両端が赤色になるような並べ方",
"-(3). 左端が赤色、右端が青色になるような並べ方",
"-(4). 左端が青色、右端が赤色になるような並べ方",
"-(1)の場合:A(K個並んでいるの青ボールの隙間にi-1個の赤ボールグループをぶっこむ箇所の場合の数) × B(i-1個のグループに割り振る赤ボールの数)",
"-Aは(k-1)個の隙間から(i-1)個の隙間を選ぶ場合の数なので、(k-1)C(i-1)で計算できる。Bは各グループに最低1個は赤色のボールを割り当てるとして残りN-K-(i-1)をどう分けるか、の場合の数なので、(N-K-(i-1)+(i-2))C(i-2)で計算できる。",
"-(2)の場合:A(K個並んでいるの青ボールの隙間にi-1個の赤ボールグループをぶっこむ箇所の場合の数) × B(i+1個のグループに割り振る赤ボールの数)",
"-Aは(1)と同様なので省略。Bは各グループに最低1個は赤色のボールを割り当てるとして残りN-K-(i+1)をどう分けるか、の場合の数なので、(N-K-(i+1)+i)C(i)で計算できる。",
"-(3)の場合:A(K個並んでいるの青ボールの隙間にi-1個の赤ボールグループをぶっこむ箇所の場合の数) × B(i個のグループに割り振る赤ボールの数)",
"-Aは(1)と同様なので省略。Bは各グループに最低1個は赤色のボールを割り当てるとして残りN-K-iをどう分けるか、の場合の数なので、(N-K-i+(i-1))C(i-1)で計算できる。",
"-(4)は(3)と同様なので省略",
"-なお、赤のボールの数が分割するグループの数以上存在していないと行けないことに注意。",
"+Kをi分割する場合の数=cmb(K+i-1,i-1)",
"+両端が赤になる場合、両端が青になる場合、左端のみ赤になる場合、右端のみ赤になる場合についてそれぞれ計算すればよい。",
"-def choose(n, k):",
"- import math",
"-",
"- return math.factorial(n) // (math.factorial(n - k) * math.factorial(k))",
"+def cmb(n, r, p):",
"+ if (r < 0) or (n < r):",
"+ return 0",
"+ r = min(r, n - r)",
"+ return fact[n] * factinv[r] * factinv[n - r] % p",
"-mod = 10**9 + 7",
"+p = 10**9 + 7",
"+N = 10**6 # N は必要分だけ用意する",
"+fact = [1, 1] # fact[n] = (n! mod p)",
"+factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p)",
"+inv = [0, 1] # factinv 計算用",
"+for i in range(2, N + 1):",
"+ fact.append((fact[-1] * i) % p)",
"+ inv.append((-inv[p % i] * (p // i)) % p)",
"+ factinv.append((factinv[-1] * inv[-1]) % p)",
"- A = choose(K - 1, i - 1)",
"- # (1)の場合の数を求める",
"- if N - K >= i - 1:",
"- if i - 2 >= 0:",
"- B = choose(N - K - (i - 1) + (i - 2), i - 2)",
"- ans += A * B",
"- ans %= mod",
"- elif N == K:",
"- ans += 1",
"- if N - K >= i + 1:",
"- B = choose(N - K - (i + 1) + i, i)",
"- ans += A * B",
"- ans %= mod",
"- if N - K >= i:",
"- B = choose(N - K - i + (i - 1), i - 1)",
"- ans += A * B * 2",
"- ans %= mod",
"+ # Kをi分割する場合の数",
"+ divideK = cmb(K - i + i - 1, i - 1, p)",
"+ # 両端が赤の場合の置き方",
"+ ans += divideK * cmb(N - K - (i + 1) + i, i, p) % p",
"+ ans %= p",
"+ # 両端が青の場合の置き方",
"+ if i > 1:",
"+ ans += divideK * cmb(N - K - (i - 1) + i - 2, i - 2, p) % p",
"+ ans %= p",
"+ elif N - K == 0:",
"+ ans += 1",
"+ # 左端のみが赤になる場合の置き方,右端のみが赤になる場合の置き方",
"+ ans += divideK * cmb(N - K - i + i - 1, i - 1, p) * 2 % p",
"+ ans %= p"
]
| false | 0.040388 | 1.949591 | 0.020716 | [
"s848538600",
"s425604097"
]
|
u997641430 | p02642 | python | s718985336 | s564519389 | 1,244 | 417 | 104,020 | 218,320 | Accepted | Accepted | 66.48 | n = int(eval(input()))
*A, = list(map(int, input().split()))
maxA = max(A)
# C[a] = A内のaの個数
C = {a: 0 for a in A}
for a in A:
C[a] += 1
# D[a]=1: Aにaより小さいaの約数が存在する
D = {a: 0 for a in A}
for a in A:
if C[a] > 0:
tmp = 2
while a * tmp <= maxA:
D[a * tmp] = 1
tmp += 1
ans = 0
for a in A:
if C[a] == 1 and D[a] == 0:
ans += 1
print(ans)
| n = int(eval(input()))
*A, = list(map(int, input().split()))
maxA = max(A)
C = {a: 0 for a in A}
for a in A:
C[a] += 1
D = {a: 0 for a in A}
for a in A:
if C[a] > 1:
D[a] = 1
for b in range(2 * a, maxA + 1, a):
D[b] = 1
print((sum([D[a] == 0 for a in A])))
| 20 | 13 | 401 | 283 | n = int(eval(input()))
(*A,) = list(map(int, input().split()))
maxA = max(A)
# C[a] = A内のaの個数
C = {a: 0 for a in A}
for a in A:
C[a] += 1
# D[a]=1: Aにaより小さいaの約数が存在する
D = {a: 0 for a in A}
for a in A:
if C[a] > 0:
tmp = 2
while a * tmp <= maxA:
D[a * tmp] = 1
tmp += 1
ans = 0
for a in A:
if C[a] == 1 and D[a] == 0:
ans += 1
print(ans)
| n = int(eval(input()))
(*A,) = list(map(int, input().split()))
maxA = max(A)
C = {a: 0 for a in A}
for a in A:
C[a] += 1
D = {a: 0 for a in A}
for a in A:
if C[a] > 1:
D[a] = 1
for b in range(2 * a, maxA + 1, a):
D[b] = 1
print((sum([D[a] == 0 for a in A])))
| false | 35 | [
"-# C[a] = A内のaの個数",
"-# D[a]=1: Aにaより小さいaの約数が存在する",
"- if C[a] > 0:",
"- tmp = 2",
"- while a * tmp <= maxA:",
"- D[a * tmp] = 1",
"- tmp += 1",
"-ans = 0",
"-for a in A:",
"- if C[a] == 1 and D[a] == 0:",
"- ans += 1",
"-print(ans)",
"+ if C[a] > 1:",
"+ D[a] = 1",
"+ for b in range(2 * a, maxA + 1, a):",
"+ D[b] = 1",
"+print((sum([D[a] == 0 for a in A])))"
]
| false | 0.12944 | 0.067602 | 1.914743 | [
"s718985336",
"s564519389"
]
|
u047102107 | p02862 | python | s037782822 | s448571464 | 485 | 234 | 40,172 | 72,704 | Accepted | Accepted | 51.75 | X, Y = list(map(int, input().split()))
MOD = int(1e9 + 7)
def modinv(a, mod=MOD):
return pow(a, mod-2, mod)
def combination(n, r, mod=MOD):
r = min(r, n - r)
res = 1
for i in range(r):
res = res * (n - i) * modinv(i+1, mod) % mod
return res
if (X + Y) % 3 != 0:
print((0))
exit()
b = (2 * Y - X) // 3
a = X - Y + b
if a < 0 or b < 0:
print((0))
exit()
print((combination(a+b, a, MOD))) | # https://atcoder.jp/contests/abc145/tasks/abc145_d
X, Y = list(map(int, input().split()))
MOD = int(1e9 + 7)
def combination(n, r, mod=MOD):
def modinv(a, mod=MOD):
return pow(a, mod-2, mod)
# nCr with MOD
r = min(r, n - r)
res = 1
for i in range(r):
res = res * (n - i) * modinv(i+1, mod) % mod
return res
# 1回の移動で3増えるので,X+Yは3の倍数 (0, 0) start
if (X + Y) % 3 != 0:
ans = 0
print((0))
else:
# X+Yは3の倍数
# (+1, +2)をn回,(+2, +1)をm回実行
# n + 2m = X
# 2n + m = Y
# 3 m = 2 X - Y
# m = (2 X - Y) // 3
# n = X - 2 * m
m = (2 * X - Y) // 3
n = X - 2 * m
if m < 0 or n < 0:
print((0))
else:
print((combination(m + n, m, MOD)))
| 26 | 35 | 455 | 761 | X, Y = list(map(int, input().split()))
MOD = int(1e9 + 7)
def modinv(a, mod=MOD):
return pow(a, mod - 2, mod)
def combination(n, r, mod=MOD):
r = min(r, n - r)
res = 1
for i in range(r):
res = res * (n - i) * modinv(i + 1, mod) % mod
return res
if (X + Y) % 3 != 0:
print((0))
exit()
b = (2 * Y - X) // 3
a = X - Y + b
if a < 0 or b < 0:
print((0))
exit()
print((combination(a + b, a, MOD)))
| # https://atcoder.jp/contests/abc145/tasks/abc145_d
X, Y = list(map(int, input().split()))
MOD = int(1e9 + 7)
def combination(n, r, mod=MOD):
def modinv(a, mod=MOD):
return pow(a, mod - 2, mod)
# nCr with MOD
r = min(r, n - r)
res = 1
for i in range(r):
res = res * (n - i) * modinv(i + 1, mod) % mod
return res
# 1回の移動で3増えるので,X+Yは3の倍数 (0, 0) start
if (X + Y) % 3 != 0:
ans = 0
print((0))
else:
# X+Yは3の倍数
# (+1, +2)をn回,(+2, +1)をm回実行
# n + 2m = X
# 2n + m = Y
# 3 m = 2 X - Y
# m = (2 X - Y) // 3
# n = X - 2 * m
m = (2 * X - Y) // 3
n = X - 2 * m
if m < 0 or n < 0:
print((0))
else:
print((combination(m + n, m, MOD)))
| false | 25.714286 | [
"+# https://atcoder.jp/contests/abc145/tasks/abc145_d",
"-def modinv(a, mod=MOD):",
"- return pow(a, mod - 2, mod)",
"+def combination(n, r, mod=MOD):",
"+ def modinv(a, mod=MOD):",
"+ return pow(a, mod - 2, mod)",
"-",
"-def combination(n, r, mod=MOD):",
"+ # nCr with MOD",
"+# 1回の移動で3増えるので,X+Yは3の倍数 (0, 0) start",
"+ ans = 0",
"- exit()",
"-b = (2 * Y - X) // 3",
"-a = X - Y + b",
"-if a < 0 or b < 0:",
"- print((0))",
"- exit()",
"-print((combination(a + b, a, MOD)))",
"+else:",
"+ # X+Yは3の倍数",
"+ # (+1, +2)をn回,(+2, +1)をm回実行",
"+ # n + 2m = X",
"+ # 2n + m = Y",
"+ # 3 m = 2 X - Y",
"+ # m = (2 X - Y) // 3",
"+ # n = X - 2 * m",
"+ m = (2 * X - Y) // 3",
"+ n = X - 2 * m",
"+ if m < 0 or n < 0:",
"+ print((0))",
"+ else:",
"+ print((combination(m + n, m, MOD)))"
]
| false | 0.511871 | 0.436356 | 1.173059 | [
"s037782822",
"s448571464"
]
|
u129978636 | p03944 | python | s669222889 | s639785960 | 19 | 17 | 3,064 | 3,064 | Accepted | Accepted | 10.53 | w,h,n=list(map(int,input().split()))
x=[]
y=[]
a=[]
ax=0
ix=w
ay=0
iy=h
for i in range(n):
x1,y1,a1=list(map(int,input().split()))
x.append(x1)
y.append(y1)
a.append(a1)
for j in range(n):
if(a[j]==1):
ax=max(ax,x[j])
elif(a[j]==2):
ix=min(ix,x[j])
elif(a[j]==3):
ay=max(ay,y[j])
else:
iy=min(iy,y[j])
if(ax>=ix or ay>=iy):
print('0')
exit()
else:
print(((ix-ax)*(iy-ay))) | w,h,n=list(map(int,input().split()))
ax=0
ix=w
ay=0
iy=h
for i in range(n):
x,y,a=list(map(int,input().split()))
if(a==1):
ax=max(ax,x)
elif(a==2):
ix=min(ix,x)
elif(a==3):
ay=max(ay,y)
else:
iy=min(iy,y)
if(ax>=ix or ay>=iy):
print('0')
exit()
else:
print(((ix-ax)*(iy-ay))) | 31 | 23 | 468 | 350 | w, h, n = list(map(int, input().split()))
x = []
y = []
a = []
ax = 0
ix = w
ay = 0
iy = h
for i in range(n):
x1, y1, a1 = list(map(int, input().split()))
x.append(x1)
y.append(y1)
a.append(a1)
for j in range(n):
if a[j] == 1:
ax = max(ax, x[j])
elif a[j] == 2:
ix = min(ix, x[j])
elif a[j] == 3:
ay = max(ay, y[j])
else:
iy = min(iy, y[j])
if ax >= ix or ay >= iy:
print("0")
exit()
else:
print(((ix - ax) * (iy - ay)))
| w, h, n = list(map(int, input().split()))
ax = 0
ix = w
ay = 0
iy = h
for i in range(n):
x, y, a = list(map(int, input().split()))
if a == 1:
ax = max(ax, x)
elif a == 2:
ix = min(ix, x)
elif a == 3:
ay = max(ay, y)
else:
iy = min(iy, y)
if ax >= ix or ay >= iy:
print("0")
exit()
else:
print(((ix - ax) * (iy - ay)))
| false | 25.806452 | [
"-x = []",
"-y = []",
"-a = []",
"- x1, y1, a1 = list(map(int, input().split()))",
"- x.append(x1)",
"- y.append(y1)",
"- a.append(a1)",
"-for j in range(n):",
"- if a[j] == 1:",
"- ax = max(ax, x[j])",
"- elif a[j] == 2:",
"- ix = min(ix, x[j])",
"- elif a[j] == 3:",
"- ay = max(ay, y[j])",
"+ x, y, a = list(map(int, input().split()))",
"+ if a == 1:",
"+ ax = max(ax, x)",
"+ elif a == 2:",
"+ ix = min(ix, x)",
"+ elif a == 3:",
"+ ay = max(ay, y)",
"- iy = min(iy, y[j])",
"+ iy = min(iy, y)"
]
| false | 0.065342 | 0.067506 | 0.967942 | [
"s669222889",
"s639785960"
]
|
u761320129 | p03416 | python | s423626594 | s565540311 | 65 | 53 | 3,736 | 2,940 | Accepted | Accepted | 18.46 | A,B = list(map(int,input().split()))
print(([str(n)==str(n)[::-1] for n in range(A,B+1)].count(True))) | A,B = list(map(int,input().split()))
ans = 0
for n in range(A,B+1):
s = str(n)
if s == s[::-1]:
ans += 1
print(ans) | 2 | 7 | 95 | 131 | A, B = list(map(int, input().split()))
print(([str(n) == str(n)[::-1] for n in range(A, B + 1)].count(True)))
| A, B = list(map(int, input().split()))
ans = 0
for n in range(A, B + 1):
s = str(n)
if s == s[::-1]:
ans += 1
print(ans)
| false | 71.428571 | [
"-print(([str(n) == str(n)[::-1] for n in range(A, B + 1)].count(True)))",
"+ans = 0",
"+for n in range(A, B + 1):",
"+ s = str(n)",
"+ if s == s[::-1]:",
"+ ans += 1",
"+print(ans)"
]
| false | 0.066453 | 0.056499 | 1.176183 | [
"s423626594",
"s565540311"
]
|
u254871849 | p03068 | python | s206472339 | s126334363 | 25 | 17 | 3,768 | 3,064 | Accepted | Accepted | 32 | # 2019-11-23 01:28:44(JST)
import sys
from string import ascii_lowercase as alphabet
def main():
n, s, k = sys.stdin.read().split()
n, k = list(map(int, [n, k]))
c = s[k-1]
for l in alphabet:
if l != c:
s = s.replace(l, '*')
print(s)
if __name__ == '__main__':
main()
| # 2019-11-23 01:28:44(JST)
import sys
def main():
n, s, k = sys.stdin.read().split()
n, k = list(map(int, [n, k]))
c = s[k-1]
letters = set(s) - set(c)
for l in letters:
s = s.replace(l, '*')
print(s)
if __name__ == '__main__':
main()
| 19 | 17 | 338 | 294 | # 2019-11-23 01:28:44(JST)
import sys
from string import ascii_lowercase as alphabet
def main():
n, s, k = sys.stdin.read().split()
n, k = list(map(int, [n, k]))
c = s[k - 1]
for l in alphabet:
if l != c:
s = s.replace(l, "*")
print(s)
if __name__ == "__main__":
main()
| # 2019-11-23 01:28:44(JST)
import sys
def main():
n, s, k = sys.stdin.read().split()
n, k = list(map(int, [n, k]))
c = s[k - 1]
letters = set(s) - set(c)
for l in letters:
s = s.replace(l, "*")
print(s)
if __name__ == "__main__":
main()
| false | 10.526316 | [
"-from string import ascii_lowercase as alphabet",
"- for l in alphabet:",
"- if l != c:",
"- s = s.replace(l, \"*\")",
"+ letters = set(s) - set(c)",
"+ for l in letters:",
"+ s = s.replace(l, \"*\")"
]
| false | 0.073992 | 0.062396 | 1.185839 | [
"s206472339",
"s126334363"
]
|
u046158516 | p02722 | python | s643395037 | s023269231 | 159 | 94 | 67,888 | 66,656 | Accepted | Accepted | 40.88 | N=int(eval(input()))
k=2
ans=1
factors=[]
i=1
while i*i<N-1:
if (N-1)%i==0:
ans+=1
i+=1
while k*k<=N:
n=0
while pow(k,n)<=N:
if (N-pow(k,n))%(pow(k,n+1))==0:
ans+=1
break
n+=1
k+=1
print(ans) | n=int(eval(input()))
ans=set()
ans.add(n)
i=2
x = 1
while x * x <= n-1 :
if (n-1) % x == 0:
ans.add(x)
ans.add((n-1)//x)
x += 1
while i*i<=n:
t=n
while t%i==0:
t/=i
if t%i==1:
ans.add(i)
i+=1
print((len(ans)-1)) | 18 | 18 | 236 | 258 | N = int(eval(input()))
k = 2
ans = 1
factors = []
i = 1
while i * i < N - 1:
if (N - 1) % i == 0:
ans += 1
i += 1
while k * k <= N:
n = 0
while pow(k, n) <= N:
if (N - pow(k, n)) % (pow(k, n + 1)) == 0:
ans += 1
break
n += 1
k += 1
print(ans)
| n = int(eval(input()))
ans = set()
ans.add(n)
i = 2
x = 1
while x * x <= n - 1:
if (n - 1) % x == 0:
ans.add(x)
ans.add((n - 1) // x)
x += 1
while i * i <= n:
t = n
while t % i == 0:
t /= i
if t % i == 1:
ans.add(i)
i += 1
print((len(ans) - 1))
| false | 0 | [
"-N = int(eval(input()))",
"-k = 2",
"-ans = 1",
"-factors = []",
"-i = 1",
"-while i * i < N - 1:",
"- if (N - 1) % i == 0:",
"- ans += 1",
"+n = int(eval(input()))",
"+ans = set()",
"+ans.add(n)",
"+i = 2",
"+x = 1",
"+while x * x <= n - 1:",
"+ if (n - 1) % x == 0:",
"+ ans.add(x)",
"+ ans.add((n - 1) // x)",
"+ x += 1",
"+while i * i <= n:",
"+ t = n",
"+ while t % i == 0:",
"+ t /= i",
"+ if t % i == 1:",
"+ ans.add(i)",
"-while k * k <= N:",
"- n = 0",
"- while pow(k, n) <= N:",
"- if (N - pow(k, n)) % (pow(k, n + 1)) == 0:",
"- ans += 1",
"- break",
"- n += 1",
"- k += 1",
"-print(ans)",
"+print((len(ans) - 1))"
]
| false | 1.226186 | 0.365832 | 3.351774 | [
"s643395037",
"s023269231"
]
|
u620084012 | p03371 | python | s111828656 | s759676083 | 232 | 205 | 3,060 | 2,940 | Accepted | Accepted | 11.64 | A,B,C,X,Y = list(map(int, input().split()))
ans = A*X+B*Y
for k in range(2*max(X,Y)+1):
ans = min(ans,2*C*k+A*max(0,X-k)+B*max(0,Y-k))
print(ans) | A, B, C, X, Y = list(map(int,input().split()))
ans = A*X + B*Y
for k in range(X+Y+1):
ans = min(ans,A*max(0,X-k)+B*max(0,Y-k)+2*k*C)
print(ans)
| 7 | 7 | 151 | 150 | A, B, C, X, Y = list(map(int, input().split()))
ans = A * X + B * Y
for k in range(2 * max(X, Y) + 1):
ans = min(ans, 2 * C * k + A * max(0, X - k) + B * max(0, Y - k))
print(ans)
| A, B, C, X, Y = list(map(int, input().split()))
ans = A * X + B * Y
for k in range(X + Y + 1):
ans = min(ans, A * max(0, X - k) + B * max(0, Y - k) + 2 * k * C)
print(ans)
| false | 0 | [
"-for k in range(2 * max(X, Y) + 1):",
"- ans = min(ans, 2 * C * k + A * max(0, X - k) + B * max(0, Y - k))",
"+for k in range(X + Y + 1):",
"+ ans = min(ans, A * max(0, X - k) + B * max(0, Y - k) + 2 * k * C)"
]
| false | 0.297322 | 0.092164 | 3.225995 | [
"s111828656",
"s759676083"
]
|
u391731808 | p03050 | python | s139119496 | s786728034 | 189 | 120 | 40,300 | 3,424 | Accepted | Accepted | 36.51 | N=int(eval(input()))
ans = 0
for r in range(1,int(N**(0.5))+10):
if (N-r)%r==0:
m = (N-r)//r
if m!=0 and r == N//m:
ans += m
print(ans) | def get_divisor(n):
a,b = [],[]
for i in range(1,int(n**0.5)+1):
if n%i==0:
a.append(i)
b.append(n//i)
if a[-1]==b[-1]:b.pop()
a.extend(b[::-1])
return a
N = int(eval(input()))
ans = 0
for m in get_divisor(N):
m-=1
if m==0 : continue
if N//m == N%m: ans+=m
print(ans) | 8 | 17 | 168 | 342 | N = int(eval(input()))
ans = 0
for r in range(1, int(N ** (0.5)) + 10):
if (N - r) % r == 0:
m = (N - r) // r
if m != 0 and r == N // m:
ans += m
print(ans)
| def get_divisor(n):
a, b = [], []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
a.append(i)
b.append(n // i)
if a[-1] == b[-1]:
b.pop()
a.extend(b[::-1])
return a
N = int(eval(input()))
ans = 0
for m in get_divisor(N):
m -= 1
if m == 0:
continue
if N // m == N % m:
ans += m
print(ans)
| false | 52.941176 | [
"+def get_divisor(n):",
"+ a, b = [], []",
"+ for i in range(1, int(n**0.5) + 1):",
"+ if n % i == 0:",
"+ a.append(i)",
"+ b.append(n // i)",
"+ if a[-1] == b[-1]:",
"+ b.pop()",
"+ a.extend(b[::-1])",
"+ return a",
"+",
"+",
"-for r in range(1, int(N ** (0.5)) + 10):",
"- if (N - r) % r == 0:",
"- m = (N - r) // r",
"- if m != 0 and r == N // m:",
"- ans += m",
"+for m in get_divisor(N):",
"+ m -= 1",
"+ if m == 0:",
"+ continue",
"+ if N // m == N % m:",
"+ ans += m"
]
| false | 0.210512 | 0.195708 | 1.075642 | [
"s139119496",
"s786728034"
]
|
u369133448 | p02641 | python | s430663003 | s385423109 | 22 | 20 | 9,228 | 9,064 | Accepted | Accepted | 9.09 | x,n=list(map(int,input().split()))
if n==0:
print(x)
else:
p=list(map(int,input().split()))
dic={}
for i in p:
d=abs(i-x)
if d in dic:
dic[d].append(i)
else:
dic[d]=[i]
sortdic = sorted(list(dic.items()), key=lambda x:x[0])
chk=0
ans=-1
for k,v in sortdic:
if chk==k:
if chk!=0 and len(v)!=2:
if v[0]>x:
ans=x-k
else:
ans=x+k
break
else:
ans=x-chk
break
chk+=1
if ans==-1:
ans=x-chk
print(ans) | x,y=list(map(int,input().split()))
if y==0:
print(x)
exit()
p=list(map(int,input().split()))
for i in range(200):
if not x-i in p:
print((x-i))
exit()
if not x+i in p:
print((x+i))
exit() | 30 | 12 | 532 | 212 | x, n = list(map(int, input().split()))
if n == 0:
print(x)
else:
p = list(map(int, input().split()))
dic = {}
for i in p:
d = abs(i - x)
if d in dic:
dic[d].append(i)
else:
dic[d] = [i]
sortdic = sorted(list(dic.items()), key=lambda x: x[0])
chk = 0
ans = -1
for k, v in sortdic:
if chk == k:
if chk != 0 and len(v) != 2:
if v[0] > x:
ans = x - k
else:
ans = x + k
break
else:
ans = x - chk
break
chk += 1
if ans == -1:
ans = x - chk
print(ans)
| x, y = list(map(int, input().split()))
if y == 0:
print(x)
exit()
p = list(map(int, input().split()))
for i in range(200):
if not x - i in p:
print((x - i))
exit()
if not x + i in p:
print((x + i))
exit()
| false | 60 | [
"-x, n = list(map(int, input().split()))",
"-if n == 0:",
"+x, y = list(map(int, input().split()))",
"+if y == 0:",
"-else:",
"- p = list(map(int, input().split()))",
"- dic = {}",
"- for i in p:",
"- d = abs(i - x)",
"- if d in dic:",
"- dic[d].append(i)",
"- else:",
"- dic[d] = [i]",
"- sortdic = sorted(list(dic.items()), key=lambda x: x[0])",
"- chk = 0",
"- ans = -1",
"- for k, v in sortdic:",
"- if chk == k:",
"- if chk != 0 and len(v) != 2:",
"- if v[0] > x:",
"- ans = x - k",
"- else:",
"- ans = x + k",
"- break",
"- else:",
"- ans = x - chk",
"- break",
"- chk += 1",
"- if ans == -1:",
"- ans = x - chk",
"- print(ans)",
"+ exit()",
"+p = list(map(int, input().split()))",
"+for i in range(200):",
"+ if not x - i in p:",
"+ print((x - i))",
"+ exit()",
"+ if not x + i in p:",
"+ print((x + i))",
"+ exit()"
]
| false | 0.047405 | 0.038562 | 1.229328 | [
"s430663003",
"s385423109"
]
|
u332906195 | p02787 | python | s641327316 | s083199459 | 570 | 507 | 42,844 | 42,972 | Accepted | Accepted | 11.05 | H, N = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[1])
dp = [0] * (H + 1)
for h in range(1, H + 1):
dp[h] = min([dp[max(h - a, 0)] + b for a, b in AB])
print((dp[-1]))
| H, N = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for _ in range(N)]
dp = [0] * (H + 1)
for h in range(1, H + 1):
dp[h] = min([dp[max(h - a, 0)] + b for a, b in AB])
print((dp[-1]))
| 9 | 8 | 244 | 215 | H, N = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[1])
dp = [0] * (H + 1)
for h in range(1, H + 1):
dp[h] = min([dp[max(h - a, 0)] + b for a, b in AB])
print((dp[-1]))
| H, N = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for _ in range(N)]
dp = [0] * (H + 1)
for h in range(1, H + 1):
dp[h] = min([dp[max(h - a, 0)] + b for a, b in AB])
print((dp[-1]))
| false | 11.111111 | [
"-AB.sort(key=lambda x: x[1])"
]
| false | 0.076544 | 0.077025 | 0.993745 | [
"s641327316",
"s083199459"
]
|
u347640436 | p03634 | python | s160934782 | s981065501 | 725 | 655 | 54,520 | 61,784 | Accepted | Accepted | 9.66 | # ダイクストラ法
from heapq import heappop, heappush
N = int(input())
links = [[] for _ in range(N + 1)]
for _ in range(N - 1):
a, b, c = map(int, input().split())
links[a].append((b, c))
links[b].append((a, c))
Q, K = map(int, input().split())
d = [float('inf')] * (N + 1)
d[K] = 0
#prev = [None] * (N + 1)
q = [(0, K)]
while q:
_, u = heappop(q)
for v, c in links[u]:
alt = d[u] + c
if d[v] > alt:
d[v] = alt
#prev[v] = u
heappush(q, (alt, v))
result = []
for _ in range(Q):
x, y = map(int, input().split())
result.append(d[x] + d[y])
print(*result, sep='\n')
#print('\n'.join(str(v) for v in result))
| # 幅優先探索
from collections import deque
N = int(eval(input()))
links = [[] for _ in range(N + 1)]
for _ in range(N - 1):
a, b, c = list(map(int, input().split()))
links[a].append((b, c))
links[b].append((a, c))
Q, K = list(map(int, input().split()))
d = [float('inf')] * (N + 1)
d[K] = 0
q = deque([K])
while q:
i = q.popleft()
for j, c in links[i]:
if d[i] + c < d[j]:
d[j] = d[i] + c
q.append(j)
result = []
for _ in range(Q):
x, y = list(map(int, input().split()))
result.append(d[x] + d[y])
print(('\n'.join(str(v) for v in result)))
#print(*result, sep='\n')
| 31 | 28 | 711 | 627 | # ダイクストラ法
from heapq import heappop, heappush
N = int(input())
links = [[] for _ in range(N + 1)]
for _ in range(N - 1):
a, b, c = map(int, input().split())
links[a].append((b, c))
links[b].append((a, c))
Q, K = map(int, input().split())
d = [float("inf")] * (N + 1)
d[K] = 0
# prev = [None] * (N + 1)
q = [(0, K)]
while q:
_, u = heappop(q)
for v, c in links[u]:
alt = d[u] + c
if d[v] > alt:
d[v] = alt
# prev[v] = u
heappush(q, (alt, v))
result = []
for _ in range(Q):
x, y = map(int, input().split())
result.append(d[x] + d[y])
print(*result, sep="\n")
# print('\n'.join(str(v) for v in result))
| # 幅優先探索
from collections import deque
N = int(eval(input()))
links = [[] for _ in range(N + 1)]
for _ in range(N - 1):
a, b, c = list(map(int, input().split()))
links[a].append((b, c))
links[b].append((a, c))
Q, K = list(map(int, input().split()))
d = [float("inf")] * (N + 1)
d[K] = 0
q = deque([K])
while q:
i = q.popleft()
for j, c in links[i]:
if d[i] + c < d[j]:
d[j] = d[i] + c
q.append(j)
result = []
for _ in range(Q):
x, y = list(map(int, input().split()))
result.append(d[x] + d[y])
print(("\n".join(str(v) for v in result)))
# print(*result, sep='\n')
| false | 9.677419 | [
"-# ダイクストラ法",
"-from heapq import heappop, heappush",
"+# 幅優先探索",
"+from collections import deque",
"-N = int(input())",
"+N = int(eval(input()))",
"- a, b, c = map(int, input().split())",
"+ a, b, c = list(map(int, input().split()))",
"-Q, K = map(int, input().split())",
"+Q, K = list(map(int, input().split()))",
"-# prev = [None] * (N + 1)",
"-q = [(0, K)]",
"+q = deque([K])",
"- _, u = heappop(q)",
"- for v, c in links[u]:",
"- alt = d[u] + c",
"- if d[v] > alt:",
"- d[v] = alt",
"- # prev[v] = u",
"- heappush(q, (alt, v))",
"+ i = q.popleft()",
"+ for j, c in links[i]:",
"+ if d[i] + c < d[j]:",
"+ d[j] = d[i] + c",
"+ q.append(j)",
"- x, y = map(int, input().split())",
"+ x, y = list(map(int, input().split()))",
"-print(*result, sep=\"\\n\")",
"-# print('\\n'.join(str(v) for v in result))",
"+print((\"\\n\".join(str(v) for v in result)))",
"+# print(*result, sep='\\n')"
]
| false | 0.050806 | 0.050413 | 1.007801 | [
"s160934782",
"s981065501"
]
|
u588341295 | p03372 | python | s752920131 | s632061308 | 643 | 562 | 28,432 | 20,312 | Accepted | Accepted | 12.6 | # -*- coding: utf-8 -*-
"""
参考:http://blog.livedoor.jp/misteer/archives/9017497.html
https://www.hamayanhamayan.com/entry/2018/04/21/225805
・累積和
・累積max
"""
N, C = list(map(int, input().split()))
x, v = [0], [0]
for i in range(N):
_x, _v = list(map(int, input().split()))
x.append(_x)
v.append(_v)
# 累積和
sm_r = [0] * (N+1)
for i in range(1, N+1):
sm_r[i] = sm_r[i-1] + v[i] - (x[i] - x[i-1])
sm_l = [0] * (N+1)
sm_l[N] = v[N] - (C - x[N])
for i in range(N-1, 0, -1):
sm_l[i] = sm_l[i+1] + v[i] - (x[i+1] - x[i])
# 累積max
mx_r = [0] * (N+2)
cal = 0
for i in range(1, N+1):
cal += v[i] - (x[i] - x[i-1])
mx_r[i] = max(cal, mx_r[i-1])
mx_l = [0] * (N+2)
mx_l[N] = cal = v[N] - (C - x[N])
for i in range(N-1, 0, -1):
cal += v[i] - (x[i+1] - x[i])
mx_l[i] = max(cal, mx_l[i+1])
ans = 0
for i in range(N+1):
# 右回り→左回り(max(右回りのみ, 逆走もする, 今までの最大))
ans = max(sm_r[i], sm_r[i] - x[i] + mx_l[i+1], ans)
# 左回り→右回り
if i != 0:
ans = max(sm_l[i], sm_l[i] - (C - x[i]) + mx_r[i-1], ans)
print(ans)
| # -*- coding: utf-8 -*-
"""
参考:http://blog.livedoor.jp/misteer/archives/9017497.html
https://www.hamayanhamayan.com/entry/2018/04/21/225805
・累積max(累積和の応用)
・先に回る方向がiより手前にmaxがあったとしても、
そのパターンは別の周回のiで考慮されているので、
始点まで戻るマイナス分が多くなっていても問題ない。
どのみち先に回る方向で最終的にansに採用されるのはiまで行った時のはず。
"""
N, C = list(map(int, input().split()))
x, v = [0], [0]
for i in range(N):
_x, _v = list(map(int, input().split()))
x.append(_x)
v.append(_v)
# 累積max
mx_r = [0] * (N+2)
cal = 0
for i in range(1, N+1):
cal += v[i] - (x[i] - x[i-1])
mx_r[i] = max(cal, mx_r[i-1])
mx_l = [0] * (N+2)
cal = v[N] - (C - x[N])
mx_l[N] = cal
for i in range(N-1, 0, -1):
cal += v[i] - (x[i+1] - x[i])
mx_l[i] = max(cal, mx_l[i+1])
ans = 0
for i in range(N+1):
# 右回り→左回り(max(右回りのみ, 逆走もする, 今までの最大))
ans = max(mx_r[i], mx_r[i] - x[i] + mx_l[i+1], ans)
# 左回り→右回り
if i != 0:
ans = max(mx_l[i], mx_l[i] - (C - x[i]) + mx_r[i-1], ans)
print(ans)
| 43 | 39 | 1,075 | 975 | # -*- coding: utf-8 -*-
"""
参考:http://blog.livedoor.jp/misteer/archives/9017497.html
https://www.hamayanhamayan.com/entry/2018/04/21/225805
・累積和
・累積max
"""
N, C = list(map(int, input().split()))
x, v = [0], [0]
for i in range(N):
_x, _v = list(map(int, input().split()))
x.append(_x)
v.append(_v)
# 累積和
sm_r = [0] * (N + 1)
for i in range(1, N + 1):
sm_r[i] = sm_r[i - 1] + v[i] - (x[i] - x[i - 1])
sm_l = [0] * (N + 1)
sm_l[N] = v[N] - (C - x[N])
for i in range(N - 1, 0, -1):
sm_l[i] = sm_l[i + 1] + v[i] - (x[i + 1] - x[i])
# 累積max
mx_r = [0] * (N + 2)
cal = 0
for i in range(1, N + 1):
cal += v[i] - (x[i] - x[i - 1])
mx_r[i] = max(cal, mx_r[i - 1])
mx_l = [0] * (N + 2)
mx_l[N] = cal = v[N] - (C - x[N])
for i in range(N - 1, 0, -1):
cal += v[i] - (x[i + 1] - x[i])
mx_l[i] = max(cal, mx_l[i + 1])
ans = 0
for i in range(N + 1):
# 右回り→左回り(max(右回りのみ, 逆走もする, 今までの最大))
ans = max(sm_r[i], sm_r[i] - x[i] + mx_l[i + 1], ans)
# 左回り→右回り
if i != 0:
ans = max(sm_l[i], sm_l[i] - (C - x[i]) + mx_r[i - 1], ans)
print(ans)
| # -*- coding: utf-8 -*-
"""
参考:http://blog.livedoor.jp/misteer/archives/9017497.html
https://www.hamayanhamayan.com/entry/2018/04/21/225805
・累積max(累積和の応用)
・先に回る方向がiより手前にmaxがあったとしても、
そのパターンは別の周回のiで考慮されているので、
始点まで戻るマイナス分が多くなっていても問題ない。
どのみち先に回る方向で最終的にansに採用されるのはiまで行った時のはず。
"""
N, C = list(map(int, input().split()))
x, v = [0], [0]
for i in range(N):
_x, _v = list(map(int, input().split()))
x.append(_x)
v.append(_v)
# 累積max
mx_r = [0] * (N + 2)
cal = 0
for i in range(1, N + 1):
cal += v[i] - (x[i] - x[i - 1])
mx_r[i] = max(cal, mx_r[i - 1])
mx_l = [0] * (N + 2)
cal = v[N] - (C - x[N])
mx_l[N] = cal
for i in range(N - 1, 0, -1):
cal += v[i] - (x[i + 1] - x[i])
mx_l[i] = max(cal, mx_l[i + 1])
ans = 0
for i in range(N + 1):
# 右回り→左回り(max(右回りのみ, 逆走もする, 今までの最大))
ans = max(mx_r[i], mx_r[i] - x[i] + mx_l[i + 1], ans)
# 左回り→右回り
if i != 0:
ans = max(mx_l[i], mx_l[i] - (C - x[i]) + mx_r[i - 1], ans)
print(ans)
| false | 9.302326 | [
"-・累積和",
"-・累積max",
"+・累積max(累積和の応用)",
"+・先に回る方向がiより手前にmaxがあったとしても、",
"+ そのパターンは別の周回のiで考慮されているので、",
"+ 始点まで戻るマイナス分が多くなっていても問題ない。",
"+ どのみち先に回る方向で最終的にansに採用されるのはiまで行った時のはず。",
"-# 累積和",
"-sm_r = [0] * (N + 1)",
"-for i in range(1, N + 1):",
"- sm_r[i] = sm_r[i - 1] + v[i] - (x[i] - x[i - 1])",
"-sm_l = [0] * (N + 1)",
"-sm_l[N] = v[N] - (C - x[N])",
"-for i in range(N - 1, 0, -1):",
"- sm_l[i] = sm_l[i + 1] + v[i] - (x[i + 1] - x[i])",
"-mx_l[N] = cal = v[N] - (C - x[N])",
"+cal = v[N] - (C - x[N])",
"+mx_l[N] = cal",
"- ans = max(sm_r[i], sm_r[i] - x[i] + mx_l[i + 1], ans)",
"+ ans = max(mx_r[i], mx_r[i] - x[i] + mx_l[i + 1], ans)",
"- ans = max(sm_l[i], sm_l[i] - (C - x[i]) + mx_r[i - 1], ans)",
"+ ans = max(mx_l[i], mx_l[i] - (C - x[i]) + mx_r[i - 1], ans)"
]
| false | 0.044959 | 0.035159 | 1.278746 | [
"s752920131",
"s632061308"
]
|
u863442865 | p03610 | python | s692488425 | s757195404 | 36 | 18 | 4,340 | 3,188 | Accepted | Accepted | 50 | s = eval(input())
res = []
for i,x in enumerate(list(s)):
if i%2==0:
res.append(x)
print((''.join(res))) | s = eval(input())
print((s[::2]))
| 6 | 2 | 113 | 27 | s = eval(input())
res = []
for i, x in enumerate(list(s)):
if i % 2 == 0:
res.append(x)
print(("".join(res)))
| s = eval(input())
print((s[::2]))
| false | 66.666667 | [
"-res = []",
"-for i, x in enumerate(list(s)):",
"- if i % 2 == 0:",
"- res.append(x)",
"-print((\"\".join(res)))",
"+print((s[::2]))"
]
| false | 0.039934 | 0.081612 | 0.489319 | [
"s692488425",
"s757195404"
]
|
u067227603 | p02837 | python | s145130027 | s995473510 | 1,281 | 75 | 3,444 | 9,212 | Accepted | Accepted | 94.15 | N = int(eval(input()))
A = []
XY = []
honest_count = []
for i in range (N):
a = int(eval(input()))
A.append(a)
inter = []
for x in range(a):
xy = list(map(int, input().split()))
inter.append(xy)
XY.append(inter)
for i in range(2 ** N):
pt = [0] * N
ck = 1
for j in range(N):
if (i >> j) & 1:
pt[N - j - 1] = 1
for k in range(N): # k人目が正直者の場合チェック
if pt[k] == 1:
for l in range(A[k]):
if XY[k][l][1] != pt[XY[k][l][0] - 1]:
ck = 0
if ck == 1:
honest_count.append(sum(pt))
print((max(honest_count))) | import itertools
n = int(eval(input()))
l = []
for i in range(n):
d = int(eval(input()))
for dd in range(d):
x, y = list(map(int, input().split()))
l.append([i, x-1, y])
ans = 0
for p in itertools.product([0, 1], repeat=n):
for ll in l:
if p[ll[0]] == 1 and p[ll[1]] != ll[2]:
break
else:
ans = max(ans, sum(p))
print(ans) | 31 | 17 | 657 | 381 | N = int(eval(input()))
A = []
XY = []
honest_count = []
for i in range(N):
a = int(eval(input()))
A.append(a)
inter = []
for x in range(a):
xy = list(map(int, input().split()))
inter.append(xy)
XY.append(inter)
for i in range(2**N):
pt = [0] * N
ck = 1
for j in range(N):
if (i >> j) & 1:
pt[N - j - 1] = 1
for k in range(N): # k人目が正直者の場合チェック
if pt[k] == 1:
for l in range(A[k]):
if XY[k][l][1] != pt[XY[k][l][0] - 1]:
ck = 0
if ck == 1:
honest_count.append(sum(pt))
print((max(honest_count)))
| import itertools
n = int(eval(input()))
l = []
for i in range(n):
d = int(eval(input()))
for dd in range(d):
x, y = list(map(int, input().split()))
l.append([i, x - 1, y])
ans = 0
for p in itertools.product([0, 1], repeat=n):
for ll in l:
if p[ll[0]] == 1 and p[ll[1]] != ll[2]:
break
else:
ans = max(ans, sum(p))
print(ans)
| false | 45.16129 | [
"-N = int(eval(input()))",
"-A = []",
"-XY = []",
"-honest_count = []",
"-for i in range(N):",
"- a = int(eval(input()))",
"- A.append(a)",
"- inter = []",
"- for x in range(a):",
"- xy = list(map(int, input().split()))",
"- inter.append(xy)",
"- XY.append(inter)",
"-for i in range(2**N):",
"- pt = [0] * N",
"- ck = 1",
"- for j in range(N):",
"- if (i >> j) & 1:",
"- pt[N - j - 1] = 1",
"- for k in range(N): # k人目が正直者の場合チェック",
"- if pt[k] == 1:",
"- for l in range(A[k]):",
"- if XY[k][l][1] != pt[XY[k][l][0] - 1]:",
"- ck = 0",
"- if ck == 1:",
"- honest_count.append(sum(pt))",
"-print((max(honest_count)))",
"+import itertools",
"+",
"+n = int(eval(input()))",
"+l = []",
"+for i in range(n):",
"+ d = int(eval(input()))",
"+ for dd in range(d):",
"+ x, y = list(map(int, input().split()))",
"+ l.append([i, x - 1, y])",
"+ans = 0",
"+for p in itertools.product([0, 1], repeat=n):",
"+ for ll in l:",
"+ if p[ll[0]] == 1 and p[ll[1]] != ll[2]:",
"+ break",
"+ else:",
"+ ans = max(ans, sum(p))",
"+print(ans)"
]
| false | 0.093777 | 0.035924 | 2.610435 | [
"s145130027",
"s995473510"
]
|
u863955163 | p02767 | python | s781770579 | s336508953 | 21 | 17 | 3,060 | 2,940 | Accepted | Accepted | 19.05 | N = int(eval(input()))
X = [int(i) for i in input().split()]
L, R = min(X), max(X)
ans = 10**1000
for i in range(L, R+1):
box = 0
for j in range(N):
box += (X[j] - i)**2
if ans > box:
ans = box
print(ans)
| N = int(eval(input()))
X = [int(i) for i in input().split()]
P = round(sum(X)/N)
ans = 0
for i in range(N):
ans += (X[i]-P)**2
print(ans)
| 13 | 7 | 241 | 142 | N = int(eval(input()))
X = [int(i) for i in input().split()]
L, R = min(X), max(X)
ans = 10**1000
for i in range(L, R + 1):
box = 0
for j in range(N):
box += (X[j] - i) ** 2
if ans > box:
ans = box
print(ans)
| N = int(eval(input()))
X = [int(i) for i in input().split()]
P = round(sum(X) / N)
ans = 0
for i in range(N):
ans += (X[i] - P) ** 2
print(ans)
| false | 46.153846 | [
"-L, R = min(X), max(X)",
"-ans = 10**1000",
"-for i in range(L, R + 1):",
"- box = 0",
"- for j in range(N):",
"- box += (X[j] - i) ** 2",
"- if ans > box:",
"- ans = box",
"+P = round(sum(X) / N)",
"+ans = 0",
"+for i in range(N):",
"+ ans += (X[i] - P) ** 2"
]
| false | 0.040861 | 0.057593 | 0.709487 | [
"s781770579",
"s336508953"
]
|
u654470292 | p03253 | python | s192160540 | s237660756 | 1,986 | 176 | 115,164 | 38,512 | Accepted | Accepted | 91.14 | import sys
import math
def input():
return sys.stdin.readline()[:-1]
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def trial_division(n):
factor = []
tmp = int(math.sqrt(n)) + 1
for num in range(2,tmp):
while n % num == 0:
n //= num
factor.append(num)
if n!=1:
factor.append(n)
return factor
n,m=list(map(int,input().split()))
mod=10**9+7
if m==1:
print((1))
quit()
li=trial_division(m)
tmp=li[0]
countli=[]
count=1
for i in range(1,len(li)):
if tmp!=li[i]:
countli.append(count)
count=1
else:
count+=1
tmp=li[i]
countli.append(count)
ans=1
for i in range(len(countli)):
ans*=combinations_count(countli[i]+n-1,countli[i])
print((ans%mod)) | import sys
import math
def input():
return sys.stdin.readline()[:-1]
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def trial_division(n):
factor = []
tmp = int(math.sqrt(n)) + 1
for num in range(2,tmp):
while n % num == 0:
n //= num
factor.append(num)
if n!=1:
factor.append(n)
return factor
n,m=list(map(int,input().split()))
mod=10**9+7
if m==1:
print((1))
quit()
li=trial_division(m)
tmp=li[0]
countli=[]
count=1
for i in range(1,len(li)):
if tmp!=li[i]:
countli.append(count)
count=1
else:
count+=1
tmp=li[i]
countli.append(count)
ans=1
for i in range(len(countli)):
r=countli[i]
s=n+r-1
r=min(r,n-1)
p=1
for j in range(r):
p*=s-j
p//=j+1
ans*=p
ans%=mod
print((ans%mod)) | 40 | 49 | 842 | 933 | import sys
import math
def input():
return sys.stdin.readline()[:-1]
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def trial_division(n):
factor = []
tmp = int(math.sqrt(n)) + 1
for num in range(2, tmp):
while n % num == 0:
n //= num
factor.append(num)
if n != 1:
factor.append(n)
return factor
n, m = list(map(int, input().split()))
mod = 10**9 + 7
if m == 1:
print((1))
quit()
li = trial_division(m)
tmp = li[0]
countli = []
count = 1
for i in range(1, len(li)):
if tmp != li[i]:
countli.append(count)
count = 1
else:
count += 1
tmp = li[i]
countli.append(count)
ans = 1
for i in range(len(countli)):
ans *= combinations_count(countli[i] + n - 1, countli[i])
print((ans % mod))
| import sys
import math
def input():
return sys.stdin.readline()[:-1]
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def trial_division(n):
factor = []
tmp = int(math.sqrt(n)) + 1
for num in range(2, tmp):
while n % num == 0:
n //= num
factor.append(num)
if n != 1:
factor.append(n)
return factor
n, m = list(map(int, input().split()))
mod = 10**9 + 7
if m == 1:
print((1))
quit()
li = trial_division(m)
tmp = li[0]
countli = []
count = 1
for i in range(1, len(li)):
if tmp != li[i]:
countli.append(count)
count = 1
else:
count += 1
tmp = li[i]
countli.append(count)
ans = 1
for i in range(len(countli)):
r = countli[i]
s = n + r - 1
r = min(r, n - 1)
p = 1
for j in range(r):
p *= s - j
p //= j + 1
ans *= p
ans %= mod
print((ans % mod))
| false | 18.367347 | [
"- ans *= combinations_count(countli[i] + n - 1, countli[i])",
"+ r = countli[i]",
"+ s = n + r - 1",
"+ r = min(r, n - 1)",
"+ p = 1",
"+ for j in range(r):",
"+ p *= s - j",
"+ p //= j + 1",
"+ ans *= p",
"+ ans %= mod"
]
| false | 0.444766 | 0.048013 | 9.263447 | [
"s192160540",
"s237660756"
]
|
u728566015 | p02720 | python | s369752350 | s409004186 | 328 | 179 | 10,740 | 11,776 | Accepted | Accepted | 45.43 | import heapq
K = int(eval(input()))
def fun(h, n):
tmp = str(n)
if tmp[-1] == '0':
heapq.heappush(h, int(tmp + '0'))
heapq.heappush(h, int(tmp + '1'))
elif tmp[-1] == '9':
heapq.heappush(h, int(tmp + '8'))
heapq.heappush(h, int(tmp + '9'))
else:
heapq.heappush(h, int(tmp + str(int(tmp[-1]) - 1)))
heapq.heappush(h, int(tmp + tmp[-1]))
heapq.heappush(h, int(tmp + str(int(tmp[-1]) + 1)))
h = list(range(1, 10))
while K > 0:
tmp = heapq.heappop(h)
fun(h, tmp)
K -= 1
else:
print(tmp) | import heapq
K = int(eval(input()))
def fun(h, n):
tmp = n % 10
if tmp != 0:
heapq.heappush(h, 10 * n + tmp - 1)
heapq.heappush(h, 10 * n + tmp)
if tmp != 9:
heapq.heappush(h, 10 * n + tmp + 1)
h = list(range(1, 10))
while K > 0:
n = heapq.heappop(h)
fun(h, n)
K -= 1
else:
print(n) | 25 | 20 | 592 | 347 | import heapq
K = int(eval(input()))
def fun(h, n):
tmp = str(n)
if tmp[-1] == "0":
heapq.heappush(h, int(tmp + "0"))
heapq.heappush(h, int(tmp + "1"))
elif tmp[-1] == "9":
heapq.heappush(h, int(tmp + "8"))
heapq.heappush(h, int(tmp + "9"))
else:
heapq.heappush(h, int(tmp + str(int(tmp[-1]) - 1)))
heapq.heappush(h, int(tmp + tmp[-1]))
heapq.heappush(h, int(tmp + str(int(tmp[-1]) + 1)))
h = list(range(1, 10))
while K > 0:
tmp = heapq.heappop(h)
fun(h, tmp)
K -= 1
else:
print(tmp)
| import heapq
K = int(eval(input()))
def fun(h, n):
tmp = n % 10
if tmp != 0:
heapq.heappush(h, 10 * n + tmp - 1)
heapq.heappush(h, 10 * n + tmp)
if tmp != 9:
heapq.heappush(h, 10 * n + tmp + 1)
h = list(range(1, 10))
while K > 0:
n = heapq.heappop(h)
fun(h, n)
K -= 1
else:
print(n)
| false | 20 | [
"- tmp = str(n)",
"- if tmp[-1] == \"0\":",
"- heapq.heappush(h, int(tmp + \"0\"))",
"- heapq.heappush(h, int(tmp + \"1\"))",
"- elif tmp[-1] == \"9\":",
"- heapq.heappush(h, int(tmp + \"8\"))",
"- heapq.heappush(h, int(tmp + \"9\"))",
"- else:",
"- heapq.heappush(h, int(tmp + str(int(tmp[-1]) - 1)))",
"- heapq.heappush(h, int(tmp + tmp[-1]))",
"- heapq.heappush(h, int(tmp + str(int(tmp[-1]) + 1)))",
"+ tmp = n % 10",
"+ if tmp != 0:",
"+ heapq.heappush(h, 10 * n + tmp - 1)",
"+ heapq.heappush(h, 10 * n + tmp)",
"+ if tmp != 9:",
"+ heapq.heappush(h, 10 * n + tmp + 1)",
"- tmp = heapq.heappop(h)",
"- fun(h, tmp)",
"+ n = heapq.heappop(h)",
"+ fun(h, n)",
"- print(tmp)",
"+ print(n)"
]
| false | 0.107533 | 0.052195 | 2.060201 | [
"s369752350",
"s409004186"
]
|
u576432509 | p03637 | python | s935268973 | s232662199 | 158 | 73 | 14,480 | 14,252 | Accepted | Accepted | 53.8 | def mp2(k):
kk=k
mp=0
while kk>=1:
kr=kk%2
if kr==0:
kk=kk//2
mp=mp+1
# print(kk,kr,mp)
else:
# print(kk,kr,mp)
return mp
return mp
n=int(eval(input()))
a=list(map(int,input().split()))
cnt0=0
cnt1=0
cnt2=0
for i in range(n):
m=min(2,mp2(a[i]))
if m==0:
cnt0=cnt0+1
elif m==1:
cnt1=cnt1+1
elif m==2:
cnt2=cnt2+1
#print(cnt0,cnt1,cnt2)
if cnt1==0:
if cnt2>=cnt0-1:
print("Yes")
else:
print("No")
else:
if cnt2>=cnt0:
print("Yes")
else:
print("No")
| n=int(eval(input()))
a=list(map(int,input().split()))
b4=0
b2=0
b1=0
for i in range(n):
if a[i]%4==0:
b4+=1
elif a[i]%2==0:
b2+=1
else:
b1+=1
if b2==0:
if b1<=b4+1:
print("Yes")
else:
print("No")
else:
if b1<=b4:
print("Yes")
else:
print("No")
| 42 | 25 | 681 | 364 | def mp2(k):
kk = k
mp = 0
while kk >= 1:
kr = kk % 2
if kr == 0:
kk = kk // 2
mp = mp + 1
# print(kk,kr,mp)
else:
# print(kk,kr,mp)
return mp
return mp
n = int(eval(input()))
a = list(map(int, input().split()))
cnt0 = 0
cnt1 = 0
cnt2 = 0
for i in range(n):
m = min(2, mp2(a[i]))
if m == 0:
cnt0 = cnt0 + 1
elif m == 1:
cnt1 = cnt1 + 1
elif m == 2:
cnt2 = cnt2 + 1
# print(cnt0,cnt1,cnt2)
if cnt1 == 0:
if cnt2 >= cnt0 - 1:
print("Yes")
else:
print("No")
else:
if cnt2 >= cnt0:
print("Yes")
else:
print("No")
| n = int(eval(input()))
a = list(map(int, input().split()))
b4 = 0
b2 = 0
b1 = 0
for i in range(n):
if a[i] % 4 == 0:
b4 += 1
elif a[i] % 2 == 0:
b2 += 1
else:
b1 += 1
if b2 == 0:
if b1 <= b4 + 1:
print("Yes")
else:
print("No")
else:
if b1 <= b4:
print("Yes")
else:
print("No")
| false | 40.47619 | [
"-def mp2(k):",
"- kk = k",
"- mp = 0",
"- while kk >= 1:",
"- kr = kk % 2",
"- if kr == 0:",
"- kk = kk // 2",
"- mp = mp + 1",
"- # print(kk,kr,mp)",
"- else:",
"- # print(kk,kr,mp)",
"- return mp",
"- return mp",
"-",
"-",
"-cnt0 = 0",
"-cnt1 = 0",
"-cnt2 = 0",
"+b4 = 0",
"+b2 = 0",
"+b1 = 0",
"- m = min(2, mp2(a[i]))",
"- if m == 0:",
"- cnt0 = cnt0 + 1",
"- elif m == 1:",
"- cnt1 = cnt1 + 1",
"- elif m == 2:",
"- cnt2 = cnt2 + 1",
"-# print(cnt0,cnt1,cnt2)",
"-if cnt1 == 0:",
"- if cnt2 >= cnt0 - 1:",
"+ if a[i] % 4 == 0:",
"+ b4 += 1",
"+ elif a[i] % 2 == 0:",
"+ b2 += 1",
"+ else:",
"+ b1 += 1",
"+if b2 == 0:",
"+ if b1 <= b4 + 1:",
"- if cnt2 >= cnt0:",
"+ if b1 <= b4:"
]
| false | 0.04404 | 0.047704 | 0.923179 | [
"s935268973",
"s232662199"
]
|
u022979415 | p03633 | python | s965613941 | s162043314 | 44 | 38 | 5,512 | 5,384 | Accepted | Accepted | 13.64 | from functools import reduce
from fractions import gcd
def find_lcm(a, b):
return a * b // gcd(a, b)
def main():
n = int(eval(input()))
t = [int(eval(input())) for _ in range(n)]
print((reduce(find_lcm, t)))
if __name__ == '__main__':
main()
| from functools import reduce
from fractions import gcd
def lcm(a, b):
return a * b // gcd(a, b)
def main():
n = int(eval(input()))
t = [int(eval(input())) for _ in range(n)]
print((reduce(lcm, t)))
if __name__ == '__main__':
main()
| 17 | 17 | 271 | 261 | from functools import reduce
from fractions import gcd
def find_lcm(a, b):
return a * b // gcd(a, b)
def main():
n = int(eval(input()))
t = [int(eval(input())) for _ in range(n)]
print((reduce(find_lcm, t)))
if __name__ == "__main__":
main()
| from functools import reduce
from fractions import gcd
def lcm(a, b):
return a * b // gcd(a, b)
def main():
n = int(eval(input()))
t = [int(eval(input())) for _ in range(n)]
print((reduce(lcm, t)))
if __name__ == "__main__":
main()
| false | 0 | [
"-def find_lcm(a, b):",
"+def lcm(a, b):",
"- print((reduce(find_lcm, t)))",
"+ print((reduce(lcm, t)))"
]
| false | 0.047908 | 0.182033 | 0.263181 | [
"s965613941",
"s162043314"
]
|
u606045429 | p02883 | python | s203018535 | s556818631 | 701 | 418 | 127,928 | 53,188 | Accepted | Accepted | 40.37 | def main():
N, K, *I = list(map(int, open(0).read().split()))
A, F = I[:N], I[N:]
A.sort()
F.sort(reverse=True)
ng, ok = -1, 10 ** 12
while abs(ok - ng) > 1:
mid = (ok + ng) // 2
if sum(max(0, a - mid // f) for a, f in zip(A, F)) <= K:
ok = mid
else:
ng = mid
print(ok)
if __name__ == '__main__':
main()
| from numpy import array, int64, minimum
def main():
N, K, *I = list(map(int, open(0).read().split()))
A, F = array(I[:N], int64), array(I[N:], int64)
A.sort()
F.sort()
F = F[::-1]
sum_A = A.sum()
ng, ok = -1, 10 ** 12
while ng + 1 < ok:
mid = (ok + ng) // 2
if (sum_A - minimum(A, mid // F).sum()) <= K:
ok = mid
else:
ng = mid
print(ok)
if __name__ == '__main__':
main()
| 20 | 25 | 402 | 485 | def main():
N, K, *I = list(map(int, open(0).read().split()))
A, F = I[:N], I[N:]
A.sort()
F.sort(reverse=True)
ng, ok = -1, 10**12
while abs(ok - ng) > 1:
mid = (ok + ng) // 2
if sum(max(0, a - mid // f) for a, f in zip(A, F)) <= K:
ok = mid
else:
ng = mid
print(ok)
if __name__ == "__main__":
main()
| from numpy import array, int64, minimum
def main():
N, K, *I = list(map(int, open(0).read().split()))
A, F = array(I[:N], int64), array(I[N:], int64)
A.sort()
F.sort()
F = F[::-1]
sum_A = A.sum()
ng, ok = -1, 10**12
while ng + 1 < ok:
mid = (ok + ng) // 2
if (sum_A - minimum(A, mid // F).sum()) <= K:
ok = mid
else:
ng = mid
print(ok)
if __name__ == "__main__":
main()
| false | 20 | [
"+from numpy import array, int64, minimum",
"+",
"+",
"- A, F = I[:N], I[N:]",
"+ A, F = array(I[:N], int64), array(I[N:], int64)",
"- F.sort(reverse=True)",
"+ F.sort()",
"+ F = F[::-1]",
"+ sum_A = A.sum()",
"- while abs(ok - ng) > 1:",
"+ while ng + 1 < ok:",
"- if sum(max(0, a - mid // f) for a, f in zip(A, F)) <= K:",
"+ if (sum_A - minimum(A, mid // F).sum()) <= K:"
]
| false | 0.101381 | 0.37376 | 0.271247 | [
"s203018535",
"s556818631"
]
|
u272525952 | p03324 | python | s901637745 | s778729736 | 183 | 168 | 38,384 | 38,484 | Accepted | Accepted | 8.2 | a,b=list(map(int,input().split()))
if a==0 and b!=100:
print(b)
elif a==0 and b==100:
print((101))
elif a==1 and b!=100:
print((b*100))
elif a==1 and b==100:
print((10100))
elif a==2 and b!=100:
print((b*10000))
else:
print((101*10**4))
| a,b=list(map(int,input().split()))
if b==100:
print((101*100**a))
else:
print((b*100**a)) | 15 | 5 | 262 | 87 | a, b = list(map(int, input().split()))
if a == 0 and b != 100:
print(b)
elif a == 0 and b == 100:
print((101))
elif a == 1 and b != 100:
print((b * 100))
elif a == 1 and b == 100:
print((10100))
elif a == 2 and b != 100:
print((b * 10000))
else:
print((101 * 10**4))
| a, b = list(map(int, input().split()))
if b == 100:
print((101 * 100**a))
else:
print((b * 100**a))
| false | 66.666667 | [
"-if a == 0 and b != 100:",
"- print(b)",
"-elif a == 0 and b == 100:",
"- print((101))",
"-elif a == 1 and b != 100:",
"- print((b * 100))",
"-elif a == 1 and b == 100:",
"- print((10100))",
"-elif a == 2 and b != 100:",
"- print((b * 10000))",
"+if b == 100:",
"+ print((101 * 100**a))",
"- print((101 * 10**4))",
"+ print((b * 100**a))"
]
| false | 0.00874 | 0.035837 | 0.243889 | [
"s901637745",
"s778729736"
]
|
u535803878 | p02788 | python | s141527041 | s495945179 | 807 | 661 | 95,440 | 97,032 | Accepted | Accepted | 18.09 | import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
### BIT
def init(bit, values):
for i,v in enumerate(values):
update(bit,i,v)
#a1 ~ aiまでの和 O(logn)
def query(bit,i):
res = 0
while i > 0:
res += bit[i]
i -= i&(-i)
return res
#ai += x(logN)
def update(bit,i,x):
while i <= len(bit)-1:
bit[i] += x
i += i&(-i)
return
n,d,a = list(map(int, input().split()))
xh = [None]*n
# h = [None]*n
for i in range(n):
xh[i] = tuple(map(int, input().split()))
xh.sort()
bit = [0] * (n+1)
r = 0
val = 0
done = False
for l,(x,h) in enumerate(xh):
bound = x+2*d
while r<n and xh[r][0]<=bound:
r += 1
nokori = h + query(bit, l+1)
if nokori>0:
# print(nokori, a, l, r, bit)
num = nokori//a + int(nokori%a!=0)
val += num
update(bit, l+1, -num*a)
if r<n:
update(bit, r+1, num*a)
print(val) | import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
n,d,a = list(map(int, input().split()))
xh = [None]*n
# h = [None]*n
for i in range(n):
xh[i] = tuple(map(int, input().split()))
xh.sort()
r = 0
val = 0
from queue import deque
q = deque([])
s = 0
for l,(x,h) in enumerate(xh):
bound = x+2*d
while q and l>=q[0][1]:
s -= q[0][0]
q.popleft()
while r<n and xh[r][0]<=bound:
r += 1
nokori = h - s
if nokori>0:
num = nokori//a + int(nokori%a!=0)
val += num
q.append((num*a, r))
s += num*a
print(val) | 49 | 34 | 1,048 | 705 | import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
### BIT
def init(bit, values):
for i, v in enumerate(values):
update(bit, i, v)
# a1 ~ aiまでの和 O(logn)
def query(bit, i):
res = 0
while i > 0:
res += bit[i]
i -= i & (-i)
return res
# ai += x(logN)
def update(bit, i, x):
while i <= len(bit) - 1:
bit[i] += x
i += i & (-i)
return
n, d, a = list(map(int, input().split()))
xh = [None] * n
# h = [None]*n
for i in range(n):
xh[i] = tuple(map(int, input().split()))
xh.sort()
bit = [0] * (n + 1)
r = 0
val = 0
done = False
for l, (x, h) in enumerate(xh):
bound = x + 2 * d
while r < n and xh[r][0] <= bound:
r += 1
nokori = h + query(bit, l + 1)
if nokori > 0:
# print(nokori, a, l, r, bit)
num = nokori // a + int(nokori % a != 0)
val += num
update(bit, l + 1, -num * a)
if r < n:
update(bit, r + 1, num * a)
print(val)
| import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
n, d, a = list(map(int, input().split()))
xh = [None] * n
# h = [None]*n
for i in range(n):
xh[i] = tuple(map(int, input().split()))
xh.sort()
r = 0
val = 0
from queue import deque
q = deque([])
s = 0
for l, (x, h) in enumerate(xh):
bound = x + 2 * d
while q and l >= q[0][1]:
s -= q[0][0]
q.popleft()
while r < n and xh[r][0] <= bound:
r += 1
nokori = h - s
if nokori > 0:
num = nokori // a + int(nokori % a != 0)
val += num
q.append((num * a, r))
s += num * a
print(val)
| false | 30.612245 | [
"-### BIT",
"-def init(bit, values):",
"- for i, v in enumerate(values):",
"- update(bit, i, v)",
"-",
"-",
"-# a1 ~ aiまでの和 O(logn)",
"-def query(bit, i):",
"- res = 0",
"- while i > 0:",
"- res += bit[i]",
"- i -= i & (-i)",
"- return res",
"-",
"-",
"-# ai += x(logN)",
"-def update(bit, i, x):",
"- while i <= len(bit) - 1:",
"- bit[i] += x",
"- i += i & (-i)",
"- return",
"-",
"-",
"-bit = [0] * (n + 1)",
"-done = False",
"+from queue import deque",
"+",
"+q = deque([])",
"+s = 0",
"+ while q and l >= q[0][1]:",
"+ s -= q[0][0]",
"+ q.popleft()",
"- nokori = h + query(bit, l + 1)",
"+ nokori = h - s",
"- # print(nokori, a, l, r, bit)",
"- update(bit, l + 1, -num * a)",
"- if r < n:",
"- update(bit, r + 1, num * a)",
"+ q.append((num * a, r))",
"+ s += num * a"
]
| false | 0.107196 | 0.153164 | 0.69988 | [
"s141527041",
"s495945179"
]
|
u729133443 | p03698 | python | s702873264 | s523823246 | 174 | 18 | 38,256 | 2,940 | Accepted | Accepted | 89.66 | s=eval(input());print(('yneos'[len(s)!=len(set(s))::2])) | s=eval(input());print(('yneos'[len(s)>len(set(s))::2])) | 1 | 1 | 48 | 47 | s = eval(input())
print(("yneos"[len(s) != len(set(s)) :: 2]))
| s = eval(input())
print(("yneos"[len(s) > len(set(s)) :: 2]))
| false | 0 | [
"-print((\"yneos\"[len(s) != len(set(s)) :: 2]))",
"+print((\"yneos\"[len(s) > len(set(s)) :: 2]))"
]
| false | 0.085628 | 0.036057 | 2.374764 | [
"s702873264",
"s523823246"
]
|
u047796752 | p03739 | python | s074065483 | s342146782 | 263 | 99 | 59,120 | 84,380 | Accepted | Accepted | 62.36 | import sys
input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int, input().split()))
b = a[:]
acc = 0
for i in range(n):
if i%2==0:
if acc+b[i]<=0:
b[i] += 1-(acc+b[i])
else:
if acc+b[i]>=0:
b[i] -= acc+b[i]+1
acc += b[i]
c = a[:]
acc = 0
for i in range(n):
if i%2==0:
if acc+c[i]>=0:
c[i] -= acc+c[i]+1
else:
if acc+c[i]<=0:
c[i] += 1-(acc+c[i])
acc += c[i]
ans = min(sum(abs(ai-bi) for ai, bi in zip(a, b)), sum(abs(ai-ci) for ai, ci in zip(a, c)))
print(ans) | import sys
input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int, input().split()))
cnt1, now = 0, 0
for i in range(n):
now += a[i]
if i%2==0:
if now<=0:
cnt1 += 1-now
now = 1
else:
if now>=0:
cnt1 += now+1
now = -1
cnt2, now = 0, 0
for i in range(n):
now += a[i]
if i%2==1:
if now<=0:
cnt2 += 1-now
now = 1
else:
if now>=0:
cnt2 += now+1
now = -1
print((min(cnt1, cnt2))) | 35 | 34 | 622 | 581 | import sys
input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int, input().split()))
b = a[:]
acc = 0
for i in range(n):
if i % 2 == 0:
if acc + b[i] <= 0:
b[i] += 1 - (acc + b[i])
else:
if acc + b[i] >= 0:
b[i] -= acc + b[i] + 1
acc += b[i]
c = a[:]
acc = 0
for i in range(n):
if i % 2 == 0:
if acc + c[i] >= 0:
c[i] -= acc + c[i] + 1
else:
if acc + c[i] <= 0:
c[i] += 1 - (acc + c[i])
acc += c[i]
ans = min(
sum(abs(ai - bi) for ai, bi in zip(a, b)), sum(abs(ai - ci) for ai, ci in zip(a, c))
)
print(ans)
| import sys
input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int, input().split()))
cnt1, now = 0, 0
for i in range(n):
now += a[i]
if i % 2 == 0:
if now <= 0:
cnt1 += 1 - now
now = 1
else:
if now >= 0:
cnt1 += now + 1
now = -1
cnt2, now = 0, 0
for i in range(n):
now += a[i]
if i % 2 == 1:
if now <= 0:
cnt2 += 1 - now
now = 1
else:
if now >= 0:
cnt2 += now + 1
now = -1
print((min(cnt1, cnt2)))
| false | 2.857143 | [
"-b = a[:]",
"-acc = 0",
"+cnt1, now = 0, 0",
"+ now += a[i]",
"- if acc + b[i] <= 0:",
"- b[i] += 1 - (acc + b[i])",
"+ if now <= 0:",
"+ cnt1 += 1 - now",
"+ now = 1",
"- if acc + b[i] >= 0:",
"- b[i] -= acc + b[i] + 1",
"- acc += b[i]",
"-c = a[:]",
"-acc = 0",
"+ if now >= 0:",
"+ cnt1 += now + 1",
"+ now = -1",
"+cnt2, now = 0, 0",
"- if i % 2 == 0:",
"- if acc + c[i] >= 0:",
"- c[i] -= acc + c[i] + 1",
"+ now += a[i]",
"+ if i % 2 == 1:",
"+ if now <= 0:",
"+ cnt2 += 1 - now",
"+ now = 1",
"- if acc + c[i] <= 0:",
"- c[i] += 1 - (acc + c[i])",
"- acc += c[i]",
"-ans = min(",
"- sum(abs(ai - bi) for ai, bi in zip(a, b)), sum(abs(ai - ci) for ai, ci in zip(a, c))",
"-)",
"-print(ans)",
"+ if now >= 0:",
"+ cnt2 += now + 1",
"+ now = -1",
"+print((min(cnt1, cnt2)))"
]
| false | 0.032588 | 0.035612 | 0.91508 | [
"s074065483",
"s342146782"
]
|
u977389981 | p02981 | python | s097039038 | s978123162 | 182 | 17 | 38,384 | 2,940 | Accepted | Accepted | 90.66 | N, A, B = list(map(int, input().split()))
print((min(A * N, B))) | N, A, B = list(map(int, input().split()))
print((min(N * A, B))) | 3 | 2 | 59 | 57 | N, A, B = list(map(int, input().split()))
print((min(A * N, B)))
| N, A, B = list(map(int, input().split()))
print((min(N * A, B)))
| false | 33.333333 | [
"-print((min(A * N, B)))",
"+print((min(N * A, B)))"
]
| false | 0.065063 | 0.033519 | 1.941073 | [
"s097039038",
"s978123162"
]
|
u922449550 | p02574 | python | s663167267 | s467429934 | 891 | 527 | 150,048 | 228,172 | Accepted | Accepted | 40.85 | import numpy as np
N = int(eval(input()))
A = list(map(int, input().split()))
exist = [0] * (10**6 + 1)
for a in A:
exist[a] += 1
if np.gcd.reduce(A) != 1:
print('not coprime')
elif np.all([sum(exist[i::i]) <= 1 for i in range(2, 10**6+1)]):
print('pairwise coprime')
else:
print('setwise coprime') | from math import gcd
N = int(eval(input()))
A = list(map(int, input().split()))
exist = [0] * (10**6 + 1)
for a in A:
exist[a] += 1
g = A[0]
for a in A[1:]:
g = gcd(g, a)
if g != 1:
print('not coprime')
elif all([sum(exist[i::i]) <= 1 for i in range(2, 10**6+1)]):
print('pairwise coprime')
else:
print('setwise coprime') | 14 | 18 | 323 | 355 | import numpy as np
N = int(eval(input()))
A = list(map(int, input().split()))
exist = [0] * (10**6 + 1)
for a in A:
exist[a] += 1
if np.gcd.reduce(A) != 1:
print("not coprime")
elif np.all([sum(exist[i::i]) <= 1 for i in range(2, 10**6 + 1)]):
print("pairwise coprime")
else:
print("setwise coprime")
| from math import gcd
N = int(eval(input()))
A = list(map(int, input().split()))
exist = [0] * (10**6 + 1)
for a in A:
exist[a] += 1
g = A[0]
for a in A[1:]:
g = gcd(g, a)
if g != 1:
print("not coprime")
elif all([sum(exist[i::i]) <= 1 for i in range(2, 10**6 + 1)]):
print("pairwise coprime")
else:
print("setwise coprime")
| false | 22.222222 | [
"-import numpy as np",
"+from math import gcd",
"-if np.gcd.reduce(A) != 1:",
"+g = A[0]",
"+for a in A[1:]:",
"+ g = gcd(g, a)",
"+if g != 1:",
"-elif np.all([sum(exist[i::i]) <= 1 for i in range(2, 10**6 + 1)]):",
"+elif all([sum(exist[i::i]) <= 1 for i in range(2, 10**6 + 1)]):"
]
| false | 0.885689 | 1.086014 | 0.815541 | [
"s663167267",
"s467429934"
]
|
u671060652 | p03208 | python | s842224473 | s713060072 | 658 | 205 | 76,116 | 87,332 | Accepted | Accepted | 68.84 | import itertools
import math
import fractions
import functools
import copy
n, k = list(map(int, input().split()))
h = []
for i in range(n):
h.append(int(eval(input())))
h.sort()
minimum = 10**10
for i in range(n-k+1):
minimum = min(minimum,h[i+k-1]-h[i])
print(minimum) | def main():
# n = int(input())
n, m = list(map(int, input().split()))
# v = list(map(int, input().split()))
# s = input()
h = [int(eval(input())) for _ in range(n)]
h.sort()
temp = []
for i in range(n-m+1):
temp.append(h[i+m-1]-h[i])
temp.sort()
print((temp[0]))
if __name__ == '__main__':
main()
| 17 | 19 | 284 | 358 | import itertools
import math
import fractions
import functools
import copy
n, k = list(map(int, input().split()))
h = []
for i in range(n):
h.append(int(eval(input())))
h.sort()
minimum = 10**10
for i in range(n - k + 1):
minimum = min(minimum, h[i + k - 1] - h[i])
print(minimum)
| def main():
# n = int(input())
n, m = list(map(int, input().split()))
# v = list(map(int, input().split()))
# s = input()
h = [int(eval(input())) for _ in range(n)]
h.sort()
temp = []
for i in range(n - m + 1):
temp.append(h[i + m - 1] - h[i])
temp.sort()
print((temp[0]))
if __name__ == "__main__":
main()
| false | 10.526316 | [
"-import itertools",
"-import math",
"-import fractions",
"-import functools",
"-import copy",
"+def main():",
"+ # n = int(input())",
"+ n, m = list(map(int, input().split()))",
"+ # v = list(map(int, input().split()))",
"+ # s = input()",
"+ h = [int(eval(input())) for _ in range(n)]",
"+ h.sort()",
"+ temp = []",
"+ for i in range(n - m + 1):",
"+ temp.append(h[i + m - 1] - h[i])",
"+ temp.sort()",
"+ print((temp[0]))",
"-n, k = list(map(int, input().split()))",
"-h = []",
"-for i in range(n):",
"- h.append(int(eval(input())))",
"-h.sort()",
"-minimum = 10**10",
"-for i in range(n - k + 1):",
"- minimum = min(minimum, h[i + k - 1] - h[i])",
"-print(minimum)",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
]
| false | 0.045477 | 0.04135 | 1.09982 | [
"s842224473",
"s713060072"
]
|
u561083515 | p03352 | python | s633334903 | s683187005 | 21 | 17 | 2,940 | 2,940 | Accepted | Accepted | 19.05 | X = int(eval(input()))
ans = 0
for i in range(1,1001):
for j in range(2,11):
tmp = i ** j
if tmp <= X:
ans = max(ans, i ** j)
print(ans) | X = int(eval(input()))
ans = 1
for i in range(2,int(X**.5)+1):
j = 2
while i ** j <= X:
ans = max(ans, i ** j)
j += 1
print(ans) | 10 | 10 | 173 | 157 | X = int(eval(input()))
ans = 0
for i in range(1, 1001):
for j in range(2, 11):
tmp = i**j
if tmp <= X:
ans = max(ans, i**j)
print(ans)
| X = int(eval(input()))
ans = 1
for i in range(2, int(X**0.5) + 1):
j = 2
while i**j <= X:
ans = max(ans, i**j)
j += 1
print(ans)
| false | 0 | [
"-ans = 0",
"-for i in range(1, 1001):",
"- for j in range(2, 11):",
"- tmp = i**j",
"- if tmp <= X:",
"- ans = max(ans, i**j)",
"+ans = 1",
"+for i in range(2, int(X**0.5) + 1):",
"+ j = 2",
"+ while i**j <= X:",
"+ ans = max(ans, i**j)",
"+ j += 1"
]
| false | 0.05702 | 0.047962 | 1.188861 | [
"s633334903",
"s683187005"
]
|
u970308980 | p03061 | python | s730911478 | s718397977 | 265 | 188 | 65,124 | 16,144 | Accepted | Accepted | 29.06 | # 最大公約数
def gcd(a, b):
while b:
a, b = b, a % b
return a
N = int(eval(input()))
A = list(map(int, input().split()))
L = [0 for _ in range(N)]
R = [0 for _ in range(N)]
L[0] = A[0]
R[N-1] = A[N-1]
for i in range(1, N):
L[i] = gcd(L[i-1], A[i])
for i in reversed(list(range(N-1))):
R[i] = gcd(R[i+1], A[i])
ans = 0
for i in range(N):
if i == 0:
ans = max(ans, R[i+1])
elif i == N-1:
ans = max(ans, L[i-1])
else:
ans = max(ans, gcd(L[i-1], R[i+1]))
print(ans) | from itertools import accumulate
from fractions import gcd
N = int(eval(input()))
A = list(map(int, input().split()))
cum_gcd_l = list(accumulate(A, gcd))
cum_gcd_r = list(accumulate(reversed(A), gcd))
ans = 0
for i in range(N):
if i == 0:
tmp = cum_gcd_r[-2]
elif i == N-1:
tmp = cum_gcd_l[-2]
else:
tmp = gcd(cum_gcd_l[i-1], cum_gcd_r[N-i-2])
ans = max(tmp, ans)
print(ans)
| 33 | 22 | 545 | 437 | # 最大公約数
def gcd(a, b):
while b:
a, b = b, a % b
return a
N = int(eval(input()))
A = list(map(int, input().split()))
L = [0 for _ in range(N)]
R = [0 for _ in range(N)]
L[0] = A[0]
R[N - 1] = A[N - 1]
for i in range(1, N):
L[i] = gcd(L[i - 1], A[i])
for i in reversed(list(range(N - 1))):
R[i] = gcd(R[i + 1], A[i])
ans = 0
for i in range(N):
if i == 0:
ans = max(ans, R[i + 1])
elif i == N - 1:
ans = max(ans, L[i - 1])
else:
ans = max(ans, gcd(L[i - 1], R[i + 1]))
print(ans)
| from itertools import accumulate
from fractions import gcd
N = int(eval(input()))
A = list(map(int, input().split()))
cum_gcd_l = list(accumulate(A, gcd))
cum_gcd_r = list(accumulate(reversed(A), gcd))
ans = 0
for i in range(N):
if i == 0:
tmp = cum_gcd_r[-2]
elif i == N - 1:
tmp = cum_gcd_l[-2]
else:
tmp = gcd(cum_gcd_l[i - 1], cum_gcd_r[N - i - 2])
ans = max(tmp, ans)
print(ans)
| false | 33.333333 | [
"-# 最大公約数",
"-def gcd(a, b):",
"- while b:",
"- a, b = b, a % b",
"- return a",
"-",
"+from itertools import accumulate",
"+from fractions import gcd",
"-L = [0 for _ in range(N)]",
"-R = [0 for _ in range(N)]",
"-L[0] = A[0]",
"-R[N - 1] = A[N - 1]",
"-for i in range(1, N):",
"- L[i] = gcd(L[i - 1], A[i])",
"-for i in reversed(list(range(N - 1))):",
"- R[i] = gcd(R[i + 1], A[i])",
"+cum_gcd_l = list(accumulate(A, gcd))",
"+cum_gcd_r = list(accumulate(reversed(A), gcd))",
"- ans = max(ans, R[i + 1])",
"+ tmp = cum_gcd_r[-2]",
"- ans = max(ans, L[i - 1])",
"+ tmp = cum_gcd_l[-2]",
"- ans = max(ans, gcd(L[i - 1], R[i + 1]))",
"+ tmp = gcd(cum_gcd_l[i - 1], cum_gcd_r[N - i - 2])",
"+ ans = max(tmp, ans)"
]
| false | 0.044262 | 0.05098 | 0.868216 | [
"s730911478",
"s718397977"
]
|
u285891772 | p03231 | python | s598737579 | s540895315 | 88 | 39 | 5,460 | 5,472 | Accepted | Accepted | 55.68 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(str, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *
N, M = MAP()
S = eval(input())
T = eval(input())
if S[0] != T[0]:
print((-1))
exit()
G = gcd(N, M)
n = N//G
m = M//G
for i in range(G):
if S[::n][i] != T[::m][i]:
print((-1))
break
else:
print((N*M//G))
| import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(str, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *
N, M = MAP()
S = eval(input())
T = eval(input())
L = N*M//gcd(N, M)
G = gcd(N, M)
for i in range(G):
if S[N//G*i] != T[M//G*i]:
print((-1))
break
else:
print(L)
| 41 | 38 | 1,113 | 1,071 | import sys, re
from collections import deque, defaultdict, Counter
from math import (
ceil,
sqrt,
hypot,
factorial,
pi,
sin,
cos,
tan,
asin,
acos,
atan,
radians,
degrees,
) # , log2
from itertools import (
accumulate,
permutations,
combinations,
combinations_with_replacement,
product,
groupby,
)
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input():
return sys.stdin.readline().strip()
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST():
return list(map(str, input().split()))
def ZIP(n):
return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
# from decimal import *
N, M = MAP()
S = eval(input())
T = eval(input())
if S[0] != T[0]:
print((-1))
exit()
G = gcd(N, M)
n = N // G
m = M // G
for i in range(G):
if S[::n][i] != T[::m][i]:
print((-1))
break
else:
print((N * M // G))
| import sys, re
from collections import deque, defaultdict, Counter
from math import (
ceil,
sqrt,
hypot,
factorial,
pi,
sin,
cos,
tan,
asin,
acos,
atan,
radians,
degrees,
) # , log2
from itertools import (
accumulate,
permutations,
combinations,
combinations_with_replacement,
product,
groupby,
)
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input():
return sys.stdin.readline().strip()
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST():
return list(map(str, input().split()))
def ZIP(n):
return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
# from decimal import *
N, M = MAP()
S = eval(input())
T = eval(input())
L = N * M // gcd(N, M)
G = gcd(N, M)
for i in range(G):
if S[N // G * i] != T[M // G * i]:
print((-1))
break
else:
print(L)
| false | 7.317073 | [
"-if S[0] != T[0]:",
"- print((-1))",
"- exit()",
"+L = N * M // gcd(N, M)",
"-n = N // G",
"-m = M // G",
"- if S[::n][i] != T[::m][i]:",
"+ if S[N // G * i] != T[M // G * i]:",
"- print((N * M // G))",
"+ print(L)"
]
| false | 0.04553 | 0.046038 | 0.988961 | [
"s598737579",
"s540895315"
]
|
u606523772 | p02791 | python | s014065423 | s049397659 | 131 | 112 | 24,744 | 24,744 | Accepted | Accepted | 14.5 | N = int(eval(input()))
P = list(map(int, input().split()))
cnt = 0
P_min = 200000
for i in range(N):
if P_min > P[i]:
P_min = P[i]
if P_min == P[i]:
cnt += 1
print(cnt) | N = int(eval(input()))
A_list = list(map(int, input().split()))
min1 = A_list[0]
cnt = 0
for i in range(N):
if A_list[i] <= min1:
min1 = A_list[i]
cnt += 1
print(cnt) | 10 | 9 | 195 | 188 | N = int(eval(input()))
P = list(map(int, input().split()))
cnt = 0
P_min = 200000
for i in range(N):
if P_min > P[i]:
P_min = P[i]
if P_min == P[i]:
cnt += 1
print(cnt)
| N = int(eval(input()))
A_list = list(map(int, input().split()))
min1 = A_list[0]
cnt = 0
for i in range(N):
if A_list[i] <= min1:
min1 = A_list[i]
cnt += 1
print(cnt)
| false | 10 | [
"-P = list(map(int, input().split()))",
"+A_list = list(map(int, input().split()))",
"+min1 = A_list[0]",
"-P_min = 200000",
"- if P_min > P[i]:",
"- P_min = P[i]",
"- if P_min == P[i]:",
"+ if A_list[i] <= min1:",
"+ min1 = A_list[i]"
]
| false | 0.046188 | 0.045457 | 1.016084 | [
"s014065423",
"s049397659"
]
|
u275666666 | p02689 | python | s098538824 | s928206831 | 386 | 307 | 121,048 | 127,268 | Accepted | Accepted | 20.47 | def get_unique_list(seq):
seen = []
return [x for x in seq if x not in seen and not seen.append(x)]
N,M=list(map(int, input().split()))
H=list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(int(M))]
AB_unique=list(map(list, set(map(tuple, AB))))
AB_road=[True]*N
for AB in AB_unique:
if H[AB[0]-1] > H[AB[1]-1]:
AB_road[AB[1]-1]=False
elif H[AB[0]-1] < H[AB[1]-1]:
AB_road[AB[0]-1]=False
else:
AB_road[AB[1]-1]=False
AB_road[AB[0]-1]=False
print((AB_road.count(True))) | N,M=list(map(int, input().split()))
H=list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(int(M))]
AB_unique=list(map(list, set(map(tuple, AB))))
AB_road=[[] for i in range(N)]
for AB in AB_unique:
if H[AB[0]-1] > H[AB[1]-1]:
AB_road[AB[1]-1].append(AB[0])
elif H[AB[0]-1] < H[AB[1]-1]:
AB_road[AB[0]-1].append(AB[1])
else:
AB_road[AB[1]-1].append(AB[0])
AB_road[AB[0]-1].append(AB[1])
print((AB_road.count([]))) | 21 | 17 | 569 | 500 | def get_unique_list(seq):
seen = []
return [x for x in seq if x not in seen and not seen.append(x)]
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(int(M))]
AB_unique = list(map(list, set(map(tuple, AB))))
AB_road = [True] * N
for AB in AB_unique:
if H[AB[0] - 1] > H[AB[1] - 1]:
AB_road[AB[1] - 1] = False
elif H[AB[0] - 1] < H[AB[1] - 1]:
AB_road[AB[0] - 1] = False
else:
AB_road[AB[1] - 1] = False
AB_road[AB[0] - 1] = False
print((AB_road.count(True)))
| N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(int(M))]
AB_unique = list(map(list, set(map(tuple, AB))))
AB_road = [[] for i in range(N)]
for AB in AB_unique:
if H[AB[0] - 1] > H[AB[1] - 1]:
AB_road[AB[1] - 1].append(AB[0])
elif H[AB[0] - 1] < H[AB[1] - 1]:
AB_road[AB[0] - 1].append(AB[1])
else:
AB_road[AB[1] - 1].append(AB[0])
AB_road[AB[0] - 1].append(AB[1])
print((AB_road.count([])))
| false | 19.047619 | [
"-def get_unique_list(seq):",
"- seen = []",
"- return [x for x in seq if x not in seen and not seen.append(x)]",
"-",
"-",
"-AB_road = [True] * N",
"+AB_road = [[] for i in range(N)]",
"- AB_road[AB[1] - 1] = False",
"+ AB_road[AB[1] - 1].append(AB[0])",
"- AB_road[AB[0] - 1] = False",
"+ AB_road[AB[0] - 1].append(AB[1])",
"- AB_road[AB[1] - 1] = False",
"- AB_road[AB[0] - 1] = False",
"-print((AB_road.count(True)))",
"+ AB_road[AB[1] - 1].append(AB[0])",
"+ AB_road[AB[0] - 1].append(AB[1])",
"+print((AB_road.count([])))"
]
| false | 0.04543 | 0.086269 | 0.526617 | [
"s098538824",
"s928206831"
]
|
u729133443 | p03146 | python | s262491485 | s618962068 | 165 | 20 | 38,384 | 2,940 | Accepted | Accepted | 87.88 | def fun(n):
if n%2:return 3*n+1
return n//2
a=[0]+[int(eval(input()))]
i=1
while not fun(a[i]) in a:a.append(fun(a[i]));i+=1
print((i+1)) | s=int(eval(input()))
i=2
while~-s:s=[s//2,s*3+1][s%2];i+=1
print((max(i,4))) | 7 | 4 | 143 | 71 | def fun(n):
if n % 2:
return 3 * n + 1
return n // 2
a = [0] + [int(eval(input()))]
i = 1
while not fun(a[i]) in a:
a.append(fun(a[i]))
i += 1
print((i + 1))
| s = int(eval(input()))
i = 2
while ~-s:
s = [s // 2, s * 3 + 1][s % 2]
i += 1
print((max(i, 4)))
| false | 42.857143 | [
"-def fun(n):",
"- if n % 2:",
"- return 3 * n + 1",
"- return n // 2",
"-",
"-",
"-a = [0] + [int(eval(input()))]",
"-i = 1",
"-while not fun(a[i]) in a:",
"- a.append(fun(a[i]))",
"+s = int(eval(input()))",
"+i = 2",
"+while ~-s:",
"+ s = [s // 2, s * 3 + 1][s % 2]",
"-print((i + 1))",
"+print((max(i, 4)))"
]
| false | 0.079497 | 0.042205 | 1.883573 | [
"s262491485",
"s618962068"
]
|
u906501980 | p03379 | python | s592210041 | s206470781 | 324 | 299 | 26,772 | 26,772 | Accepted | Accepted | 7.72 | n=int(eval(input()))
x=list(map(int,input().split()))
y = sorted(x)
x1, x2 = y[n//2-1], y[n//2]
for i in range(n):
if x[i]<=x1:
print(x2)
else:
print(x1)
| n = int(eval(input()))
x = list(map(int,input().split()))
y = sorted(x)
x1, x2 = y[n//2-1], y[n//2]
for i, xx in enumerate(x):
if xx<=x1:
print(x2)
else:
print(x1)
| 9 | 9 | 180 | 190 | n = int(eval(input()))
x = list(map(int, input().split()))
y = sorted(x)
x1, x2 = y[n // 2 - 1], y[n // 2]
for i in range(n):
if x[i] <= x1:
print(x2)
else:
print(x1)
| n = int(eval(input()))
x = list(map(int, input().split()))
y = sorted(x)
x1, x2 = y[n // 2 - 1], y[n // 2]
for i, xx in enumerate(x):
if xx <= x1:
print(x2)
else:
print(x1)
| false | 0 | [
"-for i in range(n):",
"- if x[i] <= x1:",
"+for i, xx in enumerate(x):",
"+ if xx <= x1:"
]
| false | 0.046683 | 0.048377 | 0.964983 | [
"s592210041",
"s206470781"
]
|
u308684517 | p03814 | python | s984478014 | s771280999 | 61 | 35 | 3,512 | 3,516 | Accepted | Accepted | 42.62 | s = eval(input())
flag = True
for i in range(len(s)):
if s[i] == "A" and flag :
a = i
flag = False
if s[i] == "Z" and not flag:
z = i
print((z-a+1)) | s = eval(input())
flag = True
for i in range(len(s)):
if s[i] == "A":
a = i
break
for i in range(len(s)-1, 0, -1):
if s[i] == "Z":
z = i
break
print((z-a+1)) | 9 | 11 | 180 | 203 | s = eval(input())
flag = True
for i in range(len(s)):
if s[i] == "A" and flag:
a = i
flag = False
if s[i] == "Z" and not flag:
z = i
print((z - a + 1))
| s = eval(input())
flag = True
for i in range(len(s)):
if s[i] == "A":
a = i
break
for i in range(len(s) - 1, 0, -1):
if s[i] == "Z":
z = i
break
print((z - a + 1))
| false | 18.181818 | [
"- if s[i] == \"A\" and flag:",
"+ if s[i] == \"A\":",
"- flag = False",
"- if s[i] == \"Z\" and not flag:",
"+ break",
"+for i in range(len(s) - 1, 0, -1):",
"+ if s[i] == \"Z\":",
"+ break"
]
| false | 0.040683 | 0.041043 | 0.991235 | [
"s984478014",
"s771280999"
]
|
u379629675 | p02913 | python | s069648551 | s130074679 | 94 | 67 | 5,372 | 4,204 | Accepted | Accepted | 28.72 | import sys
from collections import defaultdict
# input関係の定義
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def fi(): return float(input())
def mfi(): return map(float, input().rstrip().split())
def lmfi(): return list(map(float, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template
# BEGIN CUT HERE
class RollingHash():
BASE1 = 1007
BASE2 = 2009
MOD1 = 1000000007
MOD2 = 1000000009
def __init__(self, s):
self.n = len(s)
self.hash1 = [0] * (self.n + 1)
self.hash2 = [0] * (self.n + 1)
self.power1 = [1] * (self.n + 1)
self.power2 = [1] * (self.n + 1)
for i, e in enumerate(s):
self.hash1[i + 1] = (self.hash1[i] * self.__class__.BASE1 + ord(e)) % self.__class__.MOD1
self.hash2[i + 1] = (self.hash2[i] * self.__class__.BASE2 + ord(e)) % self.__class__.MOD2
self.power1[i + 1] = (self.power1[i] * self.__class__.BASE1) % self.__class__.MOD1
self.power2[i + 1] = (self.power2[i] * self.__class__.BASE2) % self.__class__.MOD2
def get(self, l: int, r: int):
res1 = self.hash1[r] - self.hash1[l] * self.power1[r - l] % self.__class__.MOD1
if(res1 < 0):
res1 += self.__class__.MOD1
res2 = self.hash2[r] - self.hash2[l] * self.power2[r - l] % self.__class__.MOD2
if(res2 < 0):
res2 += self.__class__.MOD2
return (res1, res2)
# END CUT HERE
def ABC131E():
N = ii()
S = li()
rh = RollingHash(S)
def check(n: int):
d = dict()
for i in range(N - n + 1):
p = rh.get(i, i + n)
if p in d.keys():
if(i - d[p] >= n):
return True
else:
d[p] = i
return False
ok, ng = 0, N // 2 + 1
while ng - ok > 1:
mid = (ok + ng) // 2
if check(mid):
ok = mid
else:
ng = mid
print(ok)
if __name__ == '__main__':
ABC131E()
| import sys
# input関係の定義
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def fi(): return float(input())
def mfi(): return map(float, input().rstrip().split())
def lmfi(): return list(map(float, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template
# BEGIN CUT HERE
class RollingHash():
BASE1 = 1007
BASE2 = 2009
MOD1 = 1000000007
MOD2 = 1000000009
def __init__(self, s, opt=2):
self.n = len(s)
self.opt = opt
self.hash1 = [0] * (self.n + 1)
self.power1 = [1] * (self.n + 1)
if opt == 2:
self.hash2 = [0] * (self.n + 1)
self.power2 = [1] * (self.n + 1)
for i, e in enumerate(s):
self.hash1[i + 1] = (self.hash1[i] * self.__class__.BASE1 + ord(e)) % self.__class__.MOD1
self.power1[i + 1] = (self.power1[i] * self.__class__.BASE1) % self.__class__.MOD1
if opt == 2:
self.hash2[i + 1] = (self.hash2[i] * self.__class__.BASE2 + ord(e)) % self.__class__.MOD2
self.power2[i + 1] = (self.power2[i] * self.__class__.BASE2) % self.__class__.MOD2
def get(self, l: int, r: int):
res1 = self.hash1[r] - self.hash1[l] * self.power1[r - l] % self.__class__.MOD1
if(res1 < 0):
res1 += self.__class__.MOD1
if self.opt == 2:
res2 = self.hash2[r] - self.hash2[l] * self.power2[r - l] % self.__class__.MOD2
if(res2 < 0):
res2 += self.__class__.MOD2
return (res1, res2) if self.opt == 2 else res1
# END CUT HERE
# notypehinting
def ABC131E():
N = ii()
S = li()
rh = RollingHash(S, opt=1)
def check(n: int):
d = dict()
for i in range(N - n + 1):
p = rh.get(i, i + n)
if p in d.keys():
if(i - d[p] >= n):
return True
else:
d[p] = i
return False
ok, ng = 0, N // 2 + 1
while ng - ok > 1:
mid = (ok + ng) // 2
if check(mid):
ok = mid
else:
ng = mid
print(ok)
if __name__ == '__main__':
ABC131E()
| 72 | 76 | 2,382 | 2,530 | import sys
from collections import defaultdict
# input関係の定義
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii():
return int(input())
def mi():
return map(int, input().rstrip().split())
def lmi():
return list(map(int, input().rstrip().split()))
def fi():
return float(input())
def mfi():
return map(float, input().rstrip().split())
def lmfi():
return list(map(float, input().rstrip().split()))
def li():
return list(input().rstrip())
def debug(*args, sep=" ", end="\n"):
print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg):
print(*arg)
sys.exit()
# template
# BEGIN CUT HERE
class RollingHash:
BASE1 = 1007
BASE2 = 2009
MOD1 = 1000000007
MOD2 = 1000000009
def __init__(self, s):
self.n = len(s)
self.hash1 = [0] * (self.n + 1)
self.hash2 = [0] * (self.n + 1)
self.power1 = [1] * (self.n + 1)
self.power2 = [1] * (self.n + 1)
for i, e in enumerate(s):
self.hash1[i + 1] = (
self.hash1[i] * self.__class__.BASE1 + ord(e)
) % self.__class__.MOD1
self.hash2[i + 1] = (
self.hash2[i] * self.__class__.BASE2 + ord(e)
) % self.__class__.MOD2
self.power1[i + 1] = (
self.power1[i] * self.__class__.BASE1
) % self.__class__.MOD1
self.power2[i + 1] = (
self.power2[i] * self.__class__.BASE2
) % self.__class__.MOD2
def get(self, l: int, r: int):
res1 = self.hash1[r] - self.hash1[l] * self.power1[r - l] % self.__class__.MOD1
if res1 < 0:
res1 += self.__class__.MOD1
res2 = self.hash2[r] - self.hash2[l] * self.power2[r - l] % self.__class__.MOD2
if res2 < 0:
res2 += self.__class__.MOD2
return (res1, res2)
# END CUT HERE
def ABC131E():
N = ii()
S = li()
rh = RollingHash(S)
def check(n: int):
d = dict()
for i in range(N - n + 1):
p = rh.get(i, i + n)
if p in d.keys():
if i - d[p] >= n:
return True
else:
d[p] = i
return False
ok, ng = 0, N // 2 + 1
while ng - ok > 1:
mid = (ok + ng) // 2
if check(mid):
ok = mid
else:
ng = mid
print(ok)
if __name__ == "__main__":
ABC131E()
| import sys
# input関係の定義
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii():
return int(input())
def mi():
return map(int, input().rstrip().split())
def lmi():
return list(map(int, input().rstrip().split()))
def fi():
return float(input())
def mfi():
return map(float, input().rstrip().split())
def lmfi():
return list(map(float, input().rstrip().split()))
def li():
return list(input().rstrip())
def debug(*args, sep=" ", end="\n"):
print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg):
print(*arg)
sys.exit()
# template
# BEGIN CUT HERE
class RollingHash:
BASE1 = 1007
BASE2 = 2009
MOD1 = 1000000007
MOD2 = 1000000009
def __init__(self, s, opt=2):
self.n = len(s)
self.opt = opt
self.hash1 = [0] * (self.n + 1)
self.power1 = [1] * (self.n + 1)
if opt == 2:
self.hash2 = [0] * (self.n + 1)
self.power2 = [1] * (self.n + 1)
for i, e in enumerate(s):
self.hash1[i + 1] = (
self.hash1[i] * self.__class__.BASE1 + ord(e)
) % self.__class__.MOD1
self.power1[i + 1] = (
self.power1[i] * self.__class__.BASE1
) % self.__class__.MOD1
if opt == 2:
self.hash2[i + 1] = (
self.hash2[i] * self.__class__.BASE2 + ord(e)
) % self.__class__.MOD2
self.power2[i + 1] = (
self.power2[i] * self.__class__.BASE2
) % self.__class__.MOD2
def get(self, l: int, r: int):
res1 = self.hash1[r] - self.hash1[l] * self.power1[r - l] % self.__class__.MOD1
if res1 < 0:
res1 += self.__class__.MOD1
if self.opt == 2:
res2 = (
self.hash2[r] - self.hash2[l] * self.power2[r - l] % self.__class__.MOD2
)
if res2 < 0:
res2 += self.__class__.MOD2
return (res1, res2) if self.opt == 2 else res1
# END CUT HERE
# notypehinting
def ABC131E():
N = ii()
S = li()
rh = RollingHash(S, opt=1)
def check(n: int):
d = dict()
for i in range(N - n + 1):
p = rh.get(i, i + n)
if p in d.keys():
if i - d[p] >= n:
return True
else:
d[p] = i
return False
ok, ng = 0, N // 2 + 1
while ng - ok > 1:
mid = (ok + ng) // 2
if check(mid):
ok = mid
else:
ng = mid
print(ok)
if __name__ == "__main__":
ABC131E()
| false | 5.263158 | [
"-from collections import defaultdict",
"- def __init__(self, s):",
"+ def __init__(self, s, opt=2):",
"+ self.opt = opt",
"- self.hash2 = [0] * (self.n + 1)",
"- self.power2 = [1] * (self.n + 1)",
"+ if opt == 2:",
"+ self.hash2 = [0] * (self.n + 1)",
"+ self.power2 = [1] * (self.n + 1)",
"- self.hash2[i + 1] = (",
"- self.hash2[i] * self.__class__.BASE2 + ord(e)",
"- ) % self.__class__.MOD2",
"- self.power2[i + 1] = (",
"- self.power2[i] * self.__class__.BASE2",
"- ) % self.__class__.MOD2",
"+ if opt == 2:",
"+ self.hash2[i + 1] = (",
"+ self.hash2[i] * self.__class__.BASE2 + ord(e)",
"+ ) % self.__class__.MOD2",
"+ self.power2[i + 1] = (",
"+ self.power2[i] * self.__class__.BASE2",
"+ ) % self.__class__.MOD2",
"- res2 = self.hash2[r] - self.hash2[l] * self.power2[r - l] % self.__class__.MOD2",
"- if res2 < 0:",
"- res2 += self.__class__.MOD2",
"- return (res1, res2)",
"+ if self.opt == 2:",
"+ res2 = (",
"+ self.hash2[r] - self.hash2[l] * self.power2[r - l] % self.__class__.MOD2",
"+ )",
"+ if res2 < 0:",
"+ res2 += self.__class__.MOD2",
"+ return (res1, res2) if self.opt == 2 else res1",
"+# notypehinting",
"- rh = RollingHash(S)",
"+ rh = RollingHash(S, opt=1)"
]
| false | 0.083341 | 0.087256 | 0.955133 | [
"s069648551",
"s130074679"
]
|
u644516473 | p03475 | python | s210875631 | s003131184 | 77 | 71 | 3,188 | 3,188 | Accepted | Accepted | 7.79 | import sys
readline = sys.stdin.readline
N = int(readline())
CSF = []
for i in range(N-1):
CSF.append(tuple(map(int, readline().split())))
for i in range(N):
time = 0
for c, s, f in CSF[i:N-1]:
if time < s:
time = s
else:
time = (time+f-1)//f*f
time += c
print(time)
| import sys
readline = sys.stdin.readline
N = int(readline())
CSF = [tuple(map(int, readline().split())) for _ in range(N-1)]
for i in range(N):
time = 0
for c, s, f in CSF[i:N-1]:
if time < s:
time = s
else:
time = (time+f-1)//f*f
time += c
print(time)
| 16 | 14 | 347 | 327 | import sys
readline = sys.stdin.readline
N = int(readline())
CSF = []
for i in range(N - 1):
CSF.append(tuple(map(int, readline().split())))
for i in range(N):
time = 0
for c, s, f in CSF[i : N - 1]:
if time < s:
time = s
else:
time = (time + f - 1) // f * f
time += c
print(time)
| import sys
readline = sys.stdin.readline
N = int(readline())
CSF = [tuple(map(int, readline().split())) for _ in range(N - 1)]
for i in range(N):
time = 0
for c, s, f in CSF[i : N - 1]:
if time < s:
time = s
else:
time = (time + f - 1) // f * f
time += c
print(time)
| false | 12.5 | [
"-CSF = []",
"-for i in range(N - 1):",
"- CSF.append(tuple(map(int, readline().split())))",
"+CSF = [tuple(map(int, readline().split())) for _ in range(N - 1)]"
]
| false | 0.038326 | 0.038769 | 0.988572 | [
"s210875631",
"s003131184"
]
|
u226849101 | p02693 | python | s731371097 | s363688900 | 25 | 21 | 9,172 | 9,104 | Accepted | Accepted | 16 | K=int(eval(input()))
A,B=list(map(int,input().split()))
flag = False
for i in range(A,B+1):
if i%K==0:
flag=True
break
if flag:
print("OK")
else:
print("NG") | k =int(eval(input()))
a , b=list(map(int,input().split()))
flag = False
if b-a >= k:
flag=True
else:
for i in range(a,b+1):
if i%k==0:
flag=True
if flag :
print("OK")
else:
print("NG")
| 13 | 16 | 187 | 218 | K = int(eval(input()))
A, B = list(map(int, input().split()))
flag = False
for i in range(A, B + 1):
if i % K == 0:
flag = True
break
if flag:
print("OK")
else:
print("NG")
| k = int(eval(input()))
a, b = list(map(int, input().split()))
flag = False
if b - a >= k:
flag = True
else:
for i in range(a, b + 1):
if i % k == 0:
flag = True
if flag:
print("OK")
else:
print("NG")
| false | 18.75 | [
"-K = int(eval(input()))",
"-A, B = list(map(int, input().split()))",
"+k = int(eval(input()))",
"+a, b = list(map(int, input().split()))",
"-for i in range(A, B + 1):",
"- if i % K == 0:",
"- flag = True",
"- break",
"+if b - a >= k:",
"+ flag = True",
"+else:",
"+ for i in range(a, b + 1):",
"+ if i % k == 0:",
"+ flag = True"
]
| false | 0.065491 | 0.036174 | 1.81045 | [
"s731371097",
"s363688900"
]
|
u200887663 | p03325 | python | s183370603 | s438176673 | 62 | 52 | 4,212 | 10,064 | Accepted | Accepted | 16.13 | n=int(eval(input()))
#a,b,n=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
def div2(v):
res=0
if v==0:
return res
while v%2==0:
v=v//2
res+=1
return res
ans=0
for ai in al:
ans+=div2(ai)
print(ans)
| n = int(eval(input()))
#n, W = map(int, input().split())
al = list(map(int, input().split()))
#al=[list(input()) for i in range(n)]
def div2(v, a):
res = 0
if v == 0:
return res
while v % a == 0:
v = v//a
res += 1
return res
ans = 0
for a in al:
ans += div2(a, 2)
print(ans)
| 18 | 20 | 321 | 336 | n = int(eval(input()))
# a,b,n=map(int,input().split())
al = list(map(int, input().split()))
# l=[list(map(int,input().split())) for i in range(n)]
def div2(v):
res = 0
if v == 0:
return res
while v % 2 == 0:
v = v // 2
res += 1
return res
ans = 0
for ai in al:
ans += div2(ai)
print(ans)
| n = int(eval(input()))
# n, W = map(int, input().split())
al = list(map(int, input().split()))
# al=[list(input()) for i in range(n)]
def div2(v, a):
res = 0
if v == 0:
return res
while v % a == 0:
v = v // a
res += 1
return res
ans = 0
for a in al:
ans += div2(a, 2)
print(ans)
| false | 10 | [
"-# a,b,n=map(int,input().split())",
"+# n, W = map(int, input().split())",
"-# l=[list(map(int,input().split())) for i in range(n)]",
"-def div2(v):",
"+# al=[list(input()) for i in range(n)]",
"+def div2(v, a):",
"- while v % 2 == 0:",
"- v = v // 2",
"+ while v % a == 0:",
"+ v = v // a",
"-for ai in al:",
"- ans += div2(ai)",
"+for a in al:",
"+ ans += div2(a, 2)"
]
| false | 0.036402 | 0.04255 | 0.855528 | [
"s183370603",
"s438176673"
]
|
u475503988 | p02973 | python | s514654530 | s186748549 | 525 | 411 | 8,188 | 8,060 | Accepted | Accepted | 21.71 | from collections import deque
import bisect
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
d = deque()
for i in range(N):
p = bisect.bisect_left(d, A[i])
if p==0:
d.appendleft(A[i])
else:
d[p-1] = A[i]
ans = len(d)
print(ans)
| import sys
input = sys.stdin.readline
from collections import deque
import bisect
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
d = deque()
for i in range(N):
p = bisect.bisect_left(d, A[i])
if p==0:
d.appendleft(A[i])
else:
d[p-1] = A[i]
ans = len(d)
print(ans)
| 15 | 17 | 277 | 317 | from collections import deque
import bisect
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
d = deque()
for i in range(N):
p = bisect.bisect_left(d, A[i])
if p == 0:
d.appendleft(A[i])
else:
d[p - 1] = A[i]
ans = len(d)
print(ans)
| import sys
input = sys.stdin.readline
from collections import deque
import bisect
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
d = deque()
for i in range(N):
p = bisect.bisect_left(d, A[i])
if p == 0:
d.appendleft(A[i])
else:
d[p - 1] = A[i]
ans = len(d)
print(ans)
| false | 11.764706 | [
"+import sys",
"+",
"+input = sys.stdin.readline"
]
| false | 0.03827 | 0.040143 | 0.953347 | [
"s514654530",
"s186748549"
]
|
u562935282 | p03372 | python | s212142781 | s098191107 | 669 | 469 | 37,576 | 33,608 | Accepted | Accepted | 29.9 | def main():
from collections import namedtuple
Dish = namedtuple('Dish', 'idx x v')
n, c = list(map(int, input().split()))
ds = []
for i in range(n):
x, v = list(map(int, input().split()))
ds.append(Dish(idx=i, x=x, v=v))
gol = [0] * n # 時計回りの最大値
s = 0
ma = 0
for d in ds:
s += d.v
ma = max(ma, s - d.x)
gol[d.idx] = ma
gor = [0] * n # 反時計回りの最大値
s = 0
ma = 0
for d in reversed(ds):
s += d.v
ma = max(ma, s - (c - d.x))
gor[d.idx] = ma
gol0 = [0] * n # 時計回りから0に戻ったときのカロリー
for d in reversed(ds):
gol0[d.idx] = gol[d.idx] - d.x
gor0 = [0] * n # 反時計回りから0に戻ったときのカロリー
for d in reversed(ds):
gor0[d.idx] = gor[d.idx] - (c - d.x)
ret = max(max(gol), max(gor))
for l in range(n - 1):
t = gol0[l] + gor[l + 1]
ret = max(ret, t)
for r in range(n - 1, 0, -1):
t = gor0[r] + gol[r - 1]
ret = max(ret, t)
print(ret)
if __name__ == '__main__':
main()
| def main():
from collections import namedtuple
import sys
input = sys.stdin.readline
Sushi = namedtuple('Sushi', 'x cal')
n, c = list(map(int, input().split()))
a = []
for _ in range(n):
x, v = list(map(int, input().split()))
a.append(Sushi(x=x, cal=v))
# x昇順ソート済
clock = [0] * (n + 1) # 注目する寿司以前で離脱する最大摂取カロリー
clock_to_0 = [0] * (n + 1) # 時計回り->初期位置
ma = 0 # 注目する寿司以前で離脱する最大摂取カロリー
curr = 0 # 現在のカロリー(移動によるカロリー消費を無視)
for i, s in enumerate(a, start=1):
curr += s.cal
ma = max(ma, curr - s.x)
clock[i] = ma
clock_to_0[i] = curr - s.x * 2
anti = [0] * (n + 1) # 注目する寿司以前で離脱する最大摂取カロリー
anti_to_0 = [0] * (n + 1) # 反時計回り->初期位置
ma = 0 # 注目する寿司以前で離脱する最大摂取カロリー
curr = 0 # 現在のカロリー(移動によるカロリー消費を無視)
for i, s in zip(list(range(n, -1, -1)), reversed(a)):
curr += s.cal
ma = max(ma, curr - (c - s.x))
anti[i] = ma
anti_to_0[i] = curr - (c - s.x) * 2
ans = 0
for exit_pos in range(1, n + 1):
ans = max(
ans,
clock_to_0[exit_pos - 1] + anti[exit_pos],
anti_to_0[(exit_pos + 1) % (n + 1)] + clock[exit_pos]
)
print(ans)
if __name__ == '__main__':
main()
| 50 | 48 | 1,089 | 1,301 | def main():
from collections import namedtuple
Dish = namedtuple("Dish", "idx x v")
n, c = list(map(int, input().split()))
ds = []
for i in range(n):
x, v = list(map(int, input().split()))
ds.append(Dish(idx=i, x=x, v=v))
gol = [0] * n # 時計回りの最大値
s = 0
ma = 0
for d in ds:
s += d.v
ma = max(ma, s - d.x)
gol[d.idx] = ma
gor = [0] * n # 反時計回りの最大値
s = 0
ma = 0
for d in reversed(ds):
s += d.v
ma = max(ma, s - (c - d.x))
gor[d.idx] = ma
gol0 = [0] * n # 時計回りから0に戻ったときのカロリー
for d in reversed(ds):
gol0[d.idx] = gol[d.idx] - d.x
gor0 = [0] * n # 反時計回りから0に戻ったときのカロリー
for d in reversed(ds):
gor0[d.idx] = gor[d.idx] - (c - d.x)
ret = max(max(gol), max(gor))
for l in range(n - 1):
t = gol0[l] + gor[l + 1]
ret = max(ret, t)
for r in range(n - 1, 0, -1):
t = gor0[r] + gol[r - 1]
ret = max(ret, t)
print(ret)
if __name__ == "__main__":
main()
| def main():
from collections import namedtuple
import sys
input = sys.stdin.readline
Sushi = namedtuple("Sushi", "x cal")
n, c = list(map(int, input().split()))
a = []
for _ in range(n):
x, v = list(map(int, input().split()))
a.append(Sushi(x=x, cal=v))
# x昇順ソート済
clock = [0] * (n + 1) # 注目する寿司以前で離脱する最大摂取カロリー
clock_to_0 = [0] * (n + 1) # 時計回り->初期位置
ma = 0 # 注目する寿司以前で離脱する最大摂取カロリー
curr = 0 # 現在のカロリー(移動によるカロリー消費を無視)
for i, s in enumerate(a, start=1):
curr += s.cal
ma = max(ma, curr - s.x)
clock[i] = ma
clock_to_0[i] = curr - s.x * 2
anti = [0] * (n + 1) # 注目する寿司以前で離脱する最大摂取カロリー
anti_to_0 = [0] * (n + 1) # 反時計回り->初期位置
ma = 0 # 注目する寿司以前で離脱する最大摂取カロリー
curr = 0 # 現在のカロリー(移動によるカロリー消費を無視)
for i, s in zip(list(range(n, -1, -1)), reversed(a)):
curr += s.cal
ma = max(ma, curr - (c - s.x))
anti[i] = ma
anti_to_0[i] = curr - (c - s.x) * 2
ans = 0
for exit_pos in range(1, n + 1):
ans = max(
ans,
clock_to_0[exit_pos - 1] + anti[exit_pos],
anti_to_0[(exit_pos + 1) % (n + 1)] + clock[exit_pos],
)
print(ans)
if __name__ == "__main__":
main()
| false | 4 | [
"+ import sys",
"- Dish = namedtuple(\"Dish\", \"idx x v\")",
"+ input = sys.stdin.readline",
"+ Sushi = namedtuple(\"Sushi\", \"x cal\")",
"- ds = []",
"- for i in range(n):",
"+ a = []",
"+ for _ in range(n):",
"- ds.append(Dish(idx=i, x=x, v=v))",
"- gol = [0] * n # 時計回りの最大値",
"- s = 0",
"- ma = 0",
"- for d in ds:",
"- s += d.v",
"- ma = max(ma, s - d.x)",
"- gol[d.idx] = ma",
"- gor = [0] * n # 反時計回りの最大値",
"- s = 0",
"- ma = 0",
"- for d in reversed(ds):",
"- s += d.v",
"- ma = max(ma, s - (c - d.x))",
"- gor[d.idx] = ma",
"- gol0 = [0] * n # 時計回りから0に戻ったときのカロリー",
"- for d in reversed(ds):",
"- gol0[d.idx] = gol[d.idx] - d.x",
"- gor0 = [0] * n # 反時計回りから0に戻ったときのカロリー",
"- for d in reversed(ds):",
"- gor0[d.idx] = gor[d.idx] - (c - d.x)",
"- ret = max(max(gol), max(gor))",
"- for l in range(n - 1):",
"- t = gol0[l] + gor[l + 1]",
"- ret = max(ret, t)",
"- for r in range(n - 1, 0, -1):",
"- t = gor0[r] + gol[r - 1]",
"- ret = max(ret, t)",
"- print(ret)",
"+ a.append(Sushi(x=x, cal=v))",
"+ # x昇順ソート済",
"+ clock = [0] * (n + 1) # 注目する寿司以前で離脱する最大摂取カロリー",
"+ clock_to_0 = [0] * (n + 1) # 時計回り->初期位置",
"+ ma = 0 # 注目する寿司以前で離脱する最大摂取カロリー",
"+ curr = 0 # 現在のカロリー(移動によるカロリー消費を無視)",
"+ for i, s in enumerate(a, start=1):",
"+ curr += s.cal",
"+ ma = max(ma, curr - s.x)",
"+ clock[i] = ma",
"+ clock_to_0[i] = curr - s.x * 2",
"+ anti = [0] * (n + 1) # 注目する寿司以前で離脱する最大摂取カロリー",
"+ anti_to_0 = [0] * (n + 1) # 反時計回り->初期位置",
"+ ma = 0 # 注目する寿司以前で離脱する最大摂取カロリー",
"+ curr = 0 # 現在のカロリー(移動によるカロリー消費を無視)",
"+ for i, s in zip(list(range(n, -1, -1)), reversed(a)):",
"+ curr += s.cal",
"+ ma = max(ma, curr - (c - s.x))",
"+ anti[i] = ma",
"+ anti_to_0[i] = curr - (c - s.x) * 2",
"+ ans = 0",
"+ for exit_pos in range(1, n + 1):",
"+ ans = max(",
"+ ans,",
"+ clock_to_0[exit_pos - 1] + anti[exit_pos],",
"+ anti_to_0[(exit_pos + 1) % (n + 1)] + clock[exit_pos],",
"+ )",
"+ print(ans)"
]
| false | 0.159069 | 0.162125 | 0.981152 | [
"s212142781",
"s098191107"
]
|
u581187895 | p03633 | python | s590015278 | s906035213 | 35 | 17 | 5,128 | 3,060 | Accepted | Accepted | 51.43 | from functools import reduce
from fractions import gcd
n = int(eval(input()))
arr = [int(eval(input())) for i in range(n)]
def lcm(x, y):
return (x*y)//gcd(x,y)
def lcmm(l):
return reduce(lcm, l)
print((lcmm(arr)))
| def gcd(a, b):
while b:
a, b = b, a%b
return a
def lcm(a, b):
return a*b // gcd(a, b)
N = int(eval(input()))
T = [int(eval(input())) for _ in range(N)]
ans = 1
for t in T:
ans = lcm(ans, t)
print(ans)
| 13 | 17 | 221 | 226 | from functools import reduce
from fractions import gcd
n = int(eval(input()))
arr = [int(eval(input())) for i in range(n)]
def lcm(x, y):
return (x * y) // gcd(x, y)
def lcmm(l):
return reduce(lcm, l)
print((lcmm(arr)))
| def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // gcd(a, b)
N = int(eval(input()))
T = [int(eval(input())) for _ in range(N)]
ans = 1
for t in T:
ans = lcm(ans, t)
print(ans)
| false | 23.529412 | [
"-from functools import reduce",
"-from fractions import gcd",
"-",
"-n = int(eval(input()))",
"-arr = [int(eval(input())) for i in range(n)]",
"+def gcd(a, b):",
"+ while b:",
"+ a, b = b, a % b",
"+ return a",
"-def lcm(x, y):",
"- return (x * y) // gcd(x, y)",
"+def lcm(a, b):",
"+ return a * b // gcd(a, b)",
"-def lcmm(l):",
"- return reduce(lcm, l)",
"-",
"-",
"-print((lcmm(arr)))",
"+N = int(eval(input()))",
"+T = [int(eval(input())) for _ in range(N)]",
"+ans = 1",
"+for t in T:",
"+ ans = lcm(ans, t)",
"+print(ans)"
]
| false | 0.093674 | 0.125877 | 0.74417 | [
"s590015278",
"s906035213"
]
|
u513081876 | p03435 | python | s440927259 | s422920670 | 149 | 18 | 14,428 | 3,064 | Accepted | Accepted | 87.92 | import numpy as np
c = [[], [], []]
for i in range(3):
c[i] = list(map(int, input().split()))
d = np.array(c)
if len(set(d[1]-d[0])) == 1 and len(set(d[2]-d[0])) == 1:
print('Yes')
else:
print('No') | c = [[int(i) for i in input().split()] for i in range(3)]
for a1 in range(101):
b1 = c[0][0] - a1
b2 = c[0][1] - a1
b3 = c[0][2] - a1
if 0 <= b1 <= 100 or 0 <= b2 <= 100 or 0 <= b3 <= 100:
if c[1][0] - b1 == c[1][1] - b2 == c[1][2] -b3 and 0<=c[1][0] <= 100 and c[2][0] - b1 == c[2][1] - b2 == c[2][2] -b3 and 0<=c[2][0] <= 100:
print('Yes')
break
else:
print('No') | 11 | 12 | 222 | 429 | import numpy as np
c = [[], [], []]
for i in range(3):
c[i] = list(map(int, input().split()))
d = np.array(c)
if len(set(d[1] - d[0])) == 1 and len(set(d[2] - d[0])) == 1:
print("Yes")
else:
print("No")
| c = [[int(i) for i in input().split()] for i in range(3)]
for a1 in range(101):
b1 = c[0][0] - a1
b2 = c[0][1] - a1
b3 = c[0][2] - a1
if 0 <= b1 <= 100 or 0 <= b2 <= 100 or 0 <= b3 <= 100:
if (
c[1][0] - b1 == c[1][1] - b2 == c[1][2] - b3
and 0 <= c[1][0] <= 100
and c[2][0] - b1 == c[2][1] - b2 == c[2][2] - b3
and 0 <= c[2][0] <= 100
):
print("Yes")
break
else:
print("No")
| false | 8.333333 | [
"-import numpy as np",
"-",
"-c = [[], [], []]",
"-for i in range(3):",
"- c[i] = list(map(int, input().split()))",
"-d = np.array(c)",
"-if len(set(d[1] - d[0])) == 1 and len(set(d[2] - d[0])) == 1:",
"- print(\"Yes\")",
"+c = [[int(i) for i in input().split()] for i in range(3)]",
"+for a1 in range(101):",
"+ b1 = c[0][0] - a1",
"+ b2 = c[0][1] - a1",
"+ b3 = c[0][2] - a1",
"+ if 0 <= b1 <= 100 or 0 <= b2 <= 100 or 0 <= b3 <= 100:",
"+ if (",
"+ c[1][0] - b1 == c[1][1] - b2 == c[1][2] - b3",
"+ and 0 <= c[1][0] <= 100",
"+ and c[2][0] - b1 == c[2][1] - b2 == c[2][2] - b3",
"+ and 0 <= c[2][0] <= 100",
"+ ):",
"+ print(\"Yes\")",
"+ break"
]
| false | 0.695923 | 0.03663 | 18.998491 | [
"s440927259",
"s422920670"
]
|
u223904637 | p02845 | python | s690888878 | s339653457 | 245 | 161 | 53,996 | 20,572 | Accepted | Accepted | 34.29 | n=int(eval(input()))
l=list(map(int,input().split()))
mod=10**9+7
ans=1
rgb=[0]*3
for i in range(n):
f=0
for j in range(3):
if l[i]==rgb[j]:
if f==0:
rgb[j]+=1
f+=1
ans*=f
ans%=mod
print(ans) | mod=10**9+7
n=int(eval(input()))
l=list(map(int,input().split()))
ans=1
rgb=[0,0,0]
for i in range(n):
c=0
for j in range(3):
if l[i]==rgb[j]:
c+=1
if c==0:
print((0))
exit()
p=rgb.index(l[i])
if not 0<=p<=2:
print((0))
exit()
rgb[p]+=1
ans*=c
ans%=mod
print(ans)
| 15 | 21 | 263 | 358 | n = int(eval(input()))
l = list(map(int, input().split()))
mod = 10**9 + 7
ans = 1
rgb = [0] * 3
for i in range(n):
f = 0
for j in range(3):
if l[i] == rgb[j]:
if f == 0:
rgb[j] += 1
f += 1
ans *= f
ans %= mod
print(ans)
| mod = 10**9 + 7
n = int(eval(input()))
l = list(map(int, input().split()))
ans = 1
rgb = [0, 0, 0]
for i in range(n):
c = 0
for j in range(3):
if l[i] == rgb[j]:
c += 1
if c == 0:
print((0))
exit()
p = rgb.index(l[i])
if not 0 <= p <= 2:
print((0))
exit()
rgb[p] += 1
ans *= c
ans %= mod
print(ans)
| false | 28.571429 | [
"+mod = 10**9 + 7",
"-mod = 10**9 + 7",
"-rgb = [0] * 3",
"+rgb = [0, 0, 0]",
"- f = 0",
"+ c = 0",
"- if f == 0:",
"- rgb[j] += 1",
"- f += 1",
"- ans *= f",
"+ c += 1",
"+ if c == 0:",
"+ print((0))",
"+ exit()",
"+ p = rgb.index(l[i])",
"+ if not 0 <= p <= 2:",
"+ print((0))",
"+ exit()",
"+ rgb[p] += 1",
"+ ans *= c"
]
| false | 0.045552 | 0.042646 | 1.068139 | [
"s690888878",
"s339653457"
]
|
u813450984 | p03331 | python | s488297221 | s885715716 | 1,263 | 179 | 3,060 | 3,060 | Accepted | Accepted | 85.83 | n = int(eval(input()))
ans = float('Inf')
for i in range(1, n):
if i > n//2:
break
if eval('+'.join(str(i))) + eval('+'.join(str(n - i))) < ans:
ans = eval('+'.join(str(i))) + eval('+'.join(str(n - i)))
print(ans) | n = int(eval(input()))
ans = float('Inf')
for i in range(1, n//2+1):
if sum(list(map(int, str(i)))) + sum(list(map(int, str(n - i)))) < ans:
ans = sum(list(map(int, str(i)))) + sum(list(map(int, str(n - i))))
print(ans) | 8 | 6 | 226 | 224 | n = int(eval(input()))
ans = float("Inf")
for i in range(1, n):
if i > n // 2:
break
if eval("+".join(str(i))) + eval("+".join(str(n - i))) < ans:
ans = eval("+".join(str(i))) + eval("+".join(str(n - i)))
print(ans)
| n = int(eval(input()))
ans = float("Inf")
for i in range(1, n // 2 + 1):
if sum(list(map(int, str(i)))) + sum(list(map(int, str(n - i)))) < ans:
ans = sum(list(map(int, str(i)))) + sum(list(map(int, str(n - i))))
print(ans)
| false | 25 | [
"-for i in range(1, n):",
"- if i > n // 2:",
"- break",
"- if eval(\"+\".join(str(i))) + eval(\"+\".join(str(n - i))) < ans:",
"- ans = eval(\"+\".join(str(i))) + eval(\"+\".join(str(n - i)))",
"+for i in range(1, n // 2 + 1):",
"+ if sum(list(map(int, str(i)))) + sum(list(map(int, str(n - i)))) < ans:",
"+ ans = sum(list(map(int, str(i)))) + sum(list(map(int, str(n - i))))"
]
| false | 0.445283 | 0.058231 | 7.646839 | [
"s488297221",
"s885715716"
]
|
u918601425 | p03137 | python | s141960852 | s951275649 | 122 | 103 | 13,840 | 13,832 | Accepted | Accepted | 15.57 | N,M= [int(s) for s in input().split()]
lst = [int(s) for s in input().split()]
lst.sort()
gap=[]
for i in range(1,M):
gap.append(lst[i]-lst[i-1])
gap.sort()
ans=0
for i in range(M-N):
ans+=gap[i]
print(ans) | N,M=[int(s) for s in input().split()]
if N>=M:
print((0))
else:
ls=[int(s) for s in input().split()]
ls.sort()
d=[ls[i+1]-ls[i] for i in range(M-1)]
d.sort()
print((sum(d[:M-N]))) | 11 | 9 | 220 | 195 | N, M = [int(s) for s in input().split()]
lst = [int(s) for s in input().split()]
lst.sort()
gap = []
for i in range(1, M):
gap.append(lst[i] - lst[i - 1])
gap.sort()
ans = 0
for i in range(M - N):
ans += gap[i]
print(ans)
| N, M = [int(s) for s in input().split()]
if N >= M:
print((0))
else:
ls = [int(s) for s in input().split()]
ls.sort()
d = [ls[i + 1] - ls[i] for i in range(M - 1)]
d.sort()
print((sum(d[: M - N])))
| false | 18.181818 | [
"-lst = [int(s) for s in input().split()]",
"-lst.sort()",
"-gap = []",
"-for i in range(1, M):",
"- gap.append(lst[i] - lst[i - 1])",
"-gap.sort()",
"-ans = 0",
"-for i in range(M - N):",
"- ans += gap[i]",
"-print(ans)",
"+if N >= M:",
"+ print((0))",
"+else:",
"+ ls = [int(s) for s in input().split()]",
"+ ls.sort()",
"+ d = [ls[i + 1] - ls[i] for i in range(M - 1)]",
"+ d.sort()",
"+ print((sum(d[: M - N])))"
]
| false | 0.044233 | 0.044452 | 0.995073 | [
"s141960852",
"s951275649"
]
|
u332906195 | p03212 | python | s184703481 | s824452436 | 128 | 37 | 3,064 | 3,316 | Accepted | Accepted | 71.09 | # -*- coding: utf-8 -*-
N = int(eval(input()))
ans = 0
cursor = "357"
def increment(cursor):
l = len(cursor)
ret = [''] * (l + 1)
if cursor[-1] == '7':
ret[-1] = '3'
ret[-2] = '3'
elif cursor[-1] == '5':
ret[-1] = '7'
elif cursor[-1] == '3':
ret[-1] = '5'
for i in range(l-1):
if ret[-(2 + i)] == '3':
if cursor[-(2 + i)] == '7':
ret[-(2 + i)] = '3'
ret[-(3 + i)] = '3'
elif cursor[-(2 + i)] == '5':
ret[-(2 + i)] = '7'
elif cursor[-(2 + i)] == '3':
ret[-(2 + i)] = '5'
else:
ret[-(2 + i)] = cursor[-(2 + i)]
return ''.join(ret)
while N >= int(cursor):
if '7' in cursor and '5' in cursor and '3' in cursor:
ans += 1
cursor = increment(cursor)
print(ans)
| from itertools import product
N = int(eval(input()))
ans, L = 0, len(str(N))
for i in range(L + 1):
for p in product(("7", "5", "3"), repeat=i):
if "7" in p and "5" in p and "3" in p:
if (i == L and int(''.join(p)) <= N) or i < L:
ans += 1
print(ans)
| 40 | 10 | 900 | 295 | # -*- coding: utf-8 -*-
N = int(eval(input()))
ans = 0
cursor = "357"
def increment(cursor):
l = len(cursor)
ret = [""] * (l + 1)
if cursor[-1] == "7":
ret[-1] = "3"
ret[-2] = "3"
elif cursor[-1] == "5":
ret[-1] = "7"
elif cursor[-1] == "3":
ret[-1] = "5"
for i in range(l - 1):
if ret[-(2 + i)] == "3":
if cursor[-(2 + i)] == "7":
ret[-(2 + i)] = "3"
ret[-(3 + i)] = "3"
elif cursor[-(2 + i)] == "5":
ret[-(2 + i)] = "7"
elif cursor[-(2 + i)] == "3":
ret[-(2 + i)] = "5"
else:
ret[-(2 + i)] = cursor[-(2 + i)]
return "".join(ret)
while N >= int(cursor):
if "7" in cursor and "5" in cursor and "3" in cursor:
ans += 1
cursor = increment(cursor)
print(ans)
| from itertools import product
N = int(eval(input()))
ans, L = 0, len(str(N))
for i in range(L + 1):
for p in product(("7", "5", "3"), repeat=i):
if "7" in p and "5" in p and "3" in p:
if (i == L and int("".join(p)) <= N) or i < L:
ans += 1
print(ans)
| false | 75 | [
"-# -*- coding: utf-8 -*-",
"+from itertools import product",
"+",
"-ans = 0",
"-cursor = \"357\"",
"-",
"-",
"-def increment(cursor):",
"- l = len(cursor)",
"- ret = [\"\"] * (l + 1)",
"- if cursor[-1] == \"7\":",
"- ret[-1] = \"3\"",
"- ret[-2] = \"3\"",
"- elif cursor[-1] == \"5\":",
"- ret[-1] = \"7\"",
"- elif cursor[-1] == \"3\":",
"- ret[-1] = \"5\"",
"- for i in range(l - 1):",
"- if ret[-(2 + i)] == \"3\":",
"- if cursor[-(2 + i)] == \"7\":",
"- ret[-(2 + i)] = \"3\"",
"- ret[-(3 + i)] = \"3\"",
"- elif cursor[-(2 + i)] == \"5\":",
"- ret[-(2 + i)] = \"7\"",
"- elif cursor[-(2 + i)] == \"3\":",
"- ret[-(2 + i)] = \"5\"",
"- else:",
"- ret[-(2 + i)] = cursor[-(2 + i)]",
"- return \"\".join(ret)",
"-",
"-",
"-while N >= int(cursor):",
"- if \"7\" in cursor and \"5\" in cursor and \"3\" in cursor:",
"- ans += 1",
"- cursor = increment(cursor)",
"+ans, L = 0, len(str(N))",
"+for i in range(L + 1):",
"+ for p in product((\"7\", \"5\", \"3\"), repeat=i):",
"+ if \"7\" in p and \"5\" in p and \"3\" in p:",
"+ if (i == L and int(\"\".join(p)) <= N) or i < L:",
"+ ans += 1"
]
| false | 0.050147 | 0.041042 | 1.221853 | [
"s184703481",
"s824452436"
]
|
u018679195 | p03071 | python | s049081598 | s334844996 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | line = eval(input())
a, b = [int(n) for n in line.split()]
apb = a+b
aa = a+(a-1)
bb = b+(b-1)
print((max(apb, max(bb, aa)))) | a = [int(x) for x in input().split()]
a.sort()
maior = 0
maior += a[-1]
a[-1] -= 1
a.sort()
maior += a[-1]
print(maior)
| 10 | 12 | 130 | 135 | line = eval(input())
a, b = [int(n) for n in line.split()]
apb = a + b
aa = a + (a - 1)
bb = b + (b - 1)
print((max(apb, max(bb, aa))))
| a = [int(x) for x in input().split()]
a.sort()
maior = 0
maior += a[-1]
a[-1] -= 1
a.sort()
maior += a[-1]
print(maior)
| false | 16.666667 | [
"-line = eval(input())",
"-a, b = [int(n) for n in line.split()]",
"-apb = a + b",
"-aa = a + (a - 1)",
"-bb = b + (b - 1)",
"-print((max(apb, max(bb, aa))))",
"+a = [int(x) for x in input().split()]",
"+a.sort()",
"+maior = 0",
"+maior += a[-1]",
"+a[-1] -= 1",
"+a.sort()",
"+maior += a[-1]",
"+print(maior)"
]
| false | 0.044656 | 0.044601 | 1.001235 | [
"s049081598",
"s334844996"
]
|
u596276291 | p03813 | python | s956356646 | s104091292 | 32 | 27 | 3,316 | 3,952 | Accepted | Accepted | 15.62 | from collections import defaultdict
def main():
print(("ABC" if int(eval(input())) < 1200 else "ARC"))
if __name__ == '__main__':
main()
| from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]
def inside(y, x, H, W):
return 0 <= y < H and 0 <= x < W
def ceil(a, b):
return (a + b - 1) // b
def main():
x = int(eval(input()))
if x < 1200:
print("ABC")
else:
print("ARC")
if __name__ == '__main__':
main()
| 9 | 33 | 149 | 813 | from collections import defaultdict
def main():
print(("ABC" if int(eval(input())) < 1200 else "ARC"))
if __name__ == "__main__":
main()
| from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]
def inside(y, x, H, W):
return 0 <= y < H and 0 <= x < W
def ceil(a, b):
return (a + b - 1) // b
def main():
x = int(eval(input()))
if x < 1200:
print("ABC")
else:
print("ARC")
if __name__ == "__main__":
main()
| false | 72.727273 | [
"-from collections import defaultdict",
"+from collections import defaultdict, Counter",
"+from itertools import product, groupby, count, permutations, combinations",
"+from math import pi, sqrt",
"+from collections import deque",
"+from bisect import bisect, bisect_left, bisect_right",
"+from string import ascii_lowercase",
"+from functools import lru_cache",
"+import sys",
"+",
"+sys.setrecursionlimit(10000)",
"+INF = float(\"inf\")",
"+YES, Yes, yes, NO, No, no = \"YES\", \"Yes\", \"yes\", \"NO\", \"No\", \"no\"",
"+dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]",
"+dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]",
"+",
"+",
"+def inside(y, x, H, W):",
"+ return 0 <= y < H and 0 <= x < W",
"+",
"+",
"+def ceil(a, b):",
"+ return (a + b - 1) // b",
"- print((\"ABC\" if int(eval(input())) < 1200 else \"ARC\"))",
"+ x = int(eval(input()))",
"+ if x < 1200:",
"+ print(\"ABC\")",
"+ else:",
"+ print(\"ARC\")"
]
| false | 0.052155 | 0.036902 | 1.41333 | [
"s956356646",
"s104091292"
]
|
u266014018 | p02721 | python | s537597021 | s937496988 | 275 | 160 | 17,508 | 26,224 | Accepted | Accepted | 41.82 | import sys
def yutori():
N, K, C = list(map(int,sys.stdin.readline().split()))
S = [i for i in sys.stdin.readline()]
l = [i+1 for i in range(N) if S[i] == 'o']
Left = []
Right = []
for u in l:
if Left == []:
Left.append(u)
if u > Left[-1] + C:
Left.append(u)
if len(Right) == K:
break
if len(Left) <K:
exit()
for u in l[::-1]:
if Right== []:
Right.append(u)
if u < Right[-1] - C:
Right.append(u)
if len(Right) == K:
break
if len(Right) <K:
exit()
for i in range(K):
if Left[i] == Right[-i-1]:
print((Left[i]))
yutori()
| def main():
import sys
def input(): return sys.stdin.readline().rstrip()
n, k, c = list(map(int, input().split()))
s = [True if i == 'o' else False for i in eval(input())]
L = [0]*k
R = [0]*k
i = n-1
now = k-1
while 0 <= now:
if s[i]:
R[now] = i
i -= c
now -= 1
i -= 1
i = 0
now = 0
while now < k:
if s[i]:
L[now] = i
if L[now] == R[now]:
print((i+1))
i += c
now += 1
i += 1
if __name__ == '__main__':
main()
| 34 | 33 | 761 | 628 | import sys
def yutori():
N, K, C = list(map(int, sys.stdin.readline().split()))
S = [i for i in sys.stdin.readline()]
l = [i + 1 for i in range(N) if S[i] == "o"]
Left = []
Right = []
for u in l:
if Left == []:
Left.append(u)
if u > Left[-1] + C:
Left.append(u)
if len(Right) == K:
break
if len(Left) < K:
exit()
for u in l[::-1]:
if Right == []:
Right.append(u)
if u < Right[-1] - C:
Right.append(u)
if len(Right) == K:
break
if len(Right) < K:
exit()
for i in range(K):
if Left[i] == Right[-i - 1]:
print((Left[i]))
yutori()
| def main():
import sys
def input():
return sys.stdin.readline().rstrip()
n, k, c = list(map(int, input().split()))
s = [True if i == "o" else False for i in eval(input())]
L = [0] * k
R = [0] * k
i = n - 1
now = k - 1
while 0 <= now:
if s[i]:
R[now] = i
i -= c
now -= 1
i -= 1
i = 0
now = 0
while now < k:
if s[i]:
L[now] = i
if L[now] == R[now]:
print((i + 1))
i += c
now += 1
i += 1
if __name__ == "__main__":
main()
| false | 2.941176 | [
"-import sys",
"+def main():",
"+ import sys",
"+",
"+ def input():",
"+ return sys.stdin.readline().rstrip()",
"+",
"+ n, k, c = list(map(int, input().split()))",
"+ s = [True if i == \"o\" else False for i in eval(input())]",
"+ L = [0] * k",
"+ R = [0] * k",
"+ i = n - 1",
"+ now = k - 1",
"+ while 0 <= now:",
"+ if s[i]:",
"+ R[now] = i",
"+ i -= c",
"+ now -= 1",
"+ i -= 1",
"+ i = 0",
"+ now = 0",
"+ while now < k:",
"+ if s[i]:",
"+ L[now] = i",
"+ if L[now] == R[now]:",
"+ print((i + 1))",
"+ i += c",
"+ now += 1",
"+ i += 1",
"-def yutori():",
"- N, K, C = list(map(int, sys.stdin.readline().split()))",
"- S = [i for i in sys.stdin.readline()]",
"- l = [i + 1 for i in range(N) if S[i] == \"o\"]",
"- Left = []",
"- Right = []",
"- for u in l:",
"- if Left == []:",
"- Left.append(u)",
"- if u > Left[-1] + C:",
"- Left.append(u)",
"- if len(Right) == K:",
"- break",
"- if len(Left) < K:",
"- exit()",
"- for u in l[::-1]:",
"- if Right == []:",
"- Right.append(u)",
"- if u < Right[-1] - C:",
"- Right.append(u)",
"- if len(Right) == K:",
"- break",
"- if len(Right) < K:",
"- exit()",
"- for i in range(K):",
"- if Left[i] == Right[-i - 1]:",
"- print((Left[i]))",
"-",
"-",
"-yutori()",
"+if __name__ == \"__main__\":",
"+ main()"
]
| false | 0.043635 | 0.042548 | 1.025536 | [
"s537597021",
"s937496988"
]
|
u767797498 | p02623 | python | s113529247 | s054122762 | 1,230 | 677 | 41,460 | 41,456 | Accepted | Accepted | 44.96 | # -*- coding: utf-8 -*-
import io
import sys
import math
def solve(n,m,k,a_lst,b_lst):
#机ごと、読書時間の累積をリストにする。ただし、リスト化はk時間内で読める範囲とする
aa_lst = make_sum_list(a_lst,k)
bb_lst = make_sum_list(b_lst,k)
len_aa = len(aa_lst)
len_bb = len(bb_lst)
#A,Bいずれかが一冊も読めないケースを考慮
if len_aa == 0: return len_bb
elif len_bb == 0: return len_aa
#全て読めるケースを考慮
if aa_lst[-1] + bb_lst[-1] <= k: return len_aa + len_bb
#A,Bいずれかのみ読むケースを考慮
max_read = max(len_aa,len_bb)
#リスト範囲でA+Bの最大値を探索する。2分探索を用いる
for i in reversed(list(range(len_aa))):
limit = k - aa_lst[i]
read = i + 1
if read + len_bb + 1 <= max_read:
#以後 read は増えない
break
imax = len_bb-1
imin = 0
imid = len_bb // 2
while True:
logd(f"imid: {imid}")
if bb_lst[imid] <= limit:
#OK。大を調べる
if imax - imid <= 1:
#探査終了
if bb_lst[imax] <= limit:
read += imax + 1
else:
read += imid + 1
break
imin = imid
else:
#NG。小を調べる
if imid - imin <= 1:
#探査完了
if bb_lst[imin] <= limit:
read += imin + 1
break
imax = imid
imid = (imin + imax) // 2
max_read = max(read,max_read)
return max_read
def make_sum_list(lst,max):
sum_lst = []
sum = 0
for n in lst:
sum += n
if sum > max:
break
sum_lst.append(sum)
return sum_lst
def main():
n,m,k = list(map(int, input().split()))
a_lst = list(map(int, input().split()))
b_lst = list(map(int, input().split()))
ans = solve(n,m,k,a_lst,b_lst)
print(ans)
### DEBUG I/O ###
_INPUT = """\
3 4 240
60 90 120
80 150 80 150
"""
_DEBUG = 0
def logd(str):
if _DEBUG:
print(f"[deb] {str}")
### MAIN ###
if __name__ == "__main__":
if _DEBUG:
sys.stdin = io.StringIO(_INPUT)
print("!! Debug Mode !!")
main()
| # -*- coding: utf-8 -*-
import io
import sys
import math
def solve(n,m,k,a_lst,b_lst):
#机ごと、読書時間の累積をリストにする。ただし、リスト化はk時間内で読める範囲とする
aa_lst = make_sum_list(a_lst,k)
bb_lst = make_sum_list(b_lst,k)
len_aa = len(aa_lst)
len_bb = len(bb_lst)
#A,Bいずれかが一冊も読めないケースを考慮
if len_aa == 0: return len_bb
elif len_bb == 0: return len_aa
#全て読めるケースを考慮
if aa_lst[-1] + bb_lst[-1] <= k: return len_aa + len_bb
#A,Bいずれかのみ読むケースを考慮
max_read = max(len_aa,len_bb)
#リスト範囲でA+Bの最大値を探索する。2分探索を用いる
for i in reversed(list(range(len_aa))):
limit = k - aa_lst[i]
read = i + 1
if read + len_bb + 1 <= max_read:
#以後 read は増えない
break
imax = len_bb-1
imin = 0
imid = len_bb // 2
while True:
if _DEB: logd(f"imid: {imid}")
if bb_lst[imid] <= limit:
#OK。大を調べる
if imax - imid <= 1:
#探査終了
if bb_lst[imax] <= limit:
read += imax + 1
else:
read += imid + 1
break
imin = imid
else:
#NG。小を調べる
if imid - imin <= 1:
#探査完了
if bb_lst[imin] <= limit:
read += imin + 1
break
imax = imid
imid = (imin + imax) // 2
max_read = max(read,max_read)
return max_read
def make_sum_list(lst,max):
sum_lst = []
sum = 0
for n in lst:
sum += n
if sum > max:
break
sum_lst.append(sum)
return sum_lst
def main():
n,m,k = list(map(int, input().split()))
a_lst = list(map(int, input().split()))
b_lst = list(map(int, input().split()))
ans = solve(n,m,k,a_lst,b_lst)
print(ans)
### DEBUG I/O ###
_INPUT = """\
3 4 240
60 90 120
80 150 80 150
"""
_DEB = 0
def logd(str):
if _DEB:
print(f"[deb] {str}")
### MAIN ###
if __name__ == "__main__":
if _DEB:
sys.stdin = io.StringIO(_INPUT)
print("!! Debug Mode !!")
main()
| 96 | 96 | 2,264 | 2,267 | # -*- coding: utf-8 -*-
import io
import sys
import math
def solve(n, m, k, a_lst, b_lst):
# 机ごと、読書時間の累積をリストにする。ただし、リスト化はk時間内で読める範囲とする
aa_lst = make_sum_list(a_lst, k)
bb_lst = make_sum_list(b_lst, k)
len_aa = len(aa_lst)
len_bb = len(bb_lst)
# A,Bいずれかが一冊も読めないケースを考慮
if len_aa == 0:
return len_bb
elif len_bb == 0:
return len_aa
# 全て読めるケースを考慮
if aa_lst[-1] + bb_lst[-1] <= k:
return len_aa + len_bb
# A,Bいずれかのみ読むケースを考慮
max_read = max(len_aa, len_bb)
# リスト範囲でA+Bの最大値を探索する。2分探索を用いる
for i in reversed(list(range(len_aa))):
limit = k - aa_lst[i]
read = i + 1
if read + len_bb + 1 <= max_read:
# 以後 read は増えない
break
imax = len_bb - 1
imin = 0
imid = len_bb // 2
while True:
logd(f"imid: {imid}")
if bb_lst[imid] <= limit:
# OK。大を調べる
if imax - imid <= 1:
# 探査終了
if bb_lst[imax] <= limit:
read += imax + 1
else:
read += imid + 1
break
imin = imid
else:
# NG。小を調べる
if imid - imin <= 1:
# 探査完了
if bb_lst[imin] <= limit:
read += imin + 1
break
imax = imid
imid = (imin + imax) // 2
max_read = max(read, max_read)
return max_read
def make_sum_list(lst, max):
sum_lst = []
sum = 0
for n in lst:
sum += n
if sum > max:
break
sum_lst.append(sum)
return sum_lst
def main():
n, m, k = list(map(int, input().split()))
a_lst = list(map(int, input().split()))
b_lst = list(map(int, input().split()))
ans = solve(n, m, k, a_lst, b_lst)
print(ans)
### DEBUG I/O ###
_INPUT = """\
3 4 240
60 90 120
80 150 80 150
"""
_DEBUG = 0
def logd(str):
if _DEBUG:
print(f"[deb] {str}")
### MAIN ###
if __name__ == "__main__":
if _DEBUG:
sys.stdin = io.StringIO(_INPUT)
print("!! Debug Mode !!")
main()
| # -*- coding: utf-8 -*-
import io
import sys
import math
def solve(n, m, k, a_lst, b_lst):
# 机ごと、読書時間の累積をリストにする。ただし、リスト化はk時間内で読める範囲とする
aa_lst = make_sum_list(a_lst, k)
bb_lst = make_sum_list(b_lst, k)
len_aa = len(aa_lst)
len_bb = len(bb_lst)
# A,Bいずれかが一冊も読めないケースを考慮
if len_aa == 0:
return len_bb
elif len_bb == 0:
return len_aa
# 全て読めるケースを考慮
if aa_lst[-1] + bb_lst[-1] <= k:
return len_aa + len_bb
# A,Bいずれかのみ読むケースを考慮
max_read = max(len_aa, len_bb)
# リスト範囲でA+Bの最大値を探索する。2分探索を用いる
for i in reversed(list(range(len_aa))):
limit = k - aa_lst[i]
read = i + 1
if read + len_bb + 1 <= max_read:
# 以後 read は増えない
break
imax = len_bb - 1
imin = 0
imid = len_bb // 2
while True:
if _DEB:
logd(f"imid: {imid}")
if bb_lst[imid] <= limit:
# OK。大を調べる
if imax - imid <= 1:
# 探査終了
if bb_lst[imax] <= limit:
read += imax + 1
else:
read += imid + 1
break
imin = imid
else:
# NG。小を調べる
if imid - imin <= 1:
# 探査完了
if bb_lst[imin] <= limit:
read += imin + 1
break
imax = imid
imid = (imin + imax) // 2
max_read = max(read, max_read)
return max_read
def make_sum_list(lst, max):
sum_lst = []
sum = 0
for n in lst:
sum += n
if sum > max:
break
sum_lst.append(sum)
return sum_lst
def main():
n, m, k = list(map(int, input().split()))
a_lst = list(map(int, input().split()))
b_lst = list(map(int, input().split()))
ans = solve(n, m, k, a_lst, b_lst)
print(ans)
### DEBUG I/O ###
_INPUT = """\
3 4 240
60 90 120
80 150 80 150
"""
_DEB = 0
def logd(str):
if _DEB:
print(f"[deb] {str}")
### MAIN ###
if __name__ == "__main__":
if _DEB:
sys.stdin = io.StringIO(_INPUT)
print("!! Debug Mode !!")
main()
| false | 0 | [
"- logd(f\"imid: {imid}\")",
"+ if _DEB:",
"+ logd(f\"imid: {imid}\")",
"-_DEBUG = 0",
"+_DEB = 0",
"- if _DEBUG:",
"+ if _DEB:",
"- if _DEBUG:",
"+ if _DEB:"
]
| false | 0.03566 | 0.038164 | 0.934398 | [
"s113529247",
"s054122762"
]
|
u977389981 | p03252 | python | s269021834 | s342607187 | 252 | 42 | 4,144 | 3,888 | Accepted | Accepted | 83.33 | from collections import Counter
S = eval(input())
T = eval(input())
lenS = len(Counter(S))
lenT = len(Counter(T))
flag = 0
if lenS == lenT:
for i in range(lenS):
if Counter(S).most_common()[i][1] == Counter(T).most_common()[i][1]:
continue
else:
flag = 1
break
else:
flag = 1
if flag == 0:
print('Yes')
else:
print('No') | from collections import Counter
S = sorted(Counter(eval(input())).values())
T = sorted(Counter(eval(input())).values())
if S == T:
print('Yes')
else:
print('No') | 23 | 9 | 406 | 167 | from collections import Counter
S = eval(input())
T = eval(input())
lenS = len(Counter(S))
lenT = len(Counter(T))
flag = 0
if lenS == lenT:
for i in range(lenS):
if Counter(S).most_common()[i][1] == Counter(T).most_common()[i][1]:
continue
else:
flag = 1
break
else:
flag = 1
if flag == 0:
print("Yes")
else:
print("No")
| from collections import Counter
S = sorted(Counter(eval(input())).values())
T = sorted(Counter(eval(input())).values())
if S == T:
print("Yes")
else:
print("No")
| false | 60.869565 | [
"-S = eval(input())",
"-T = eval(input())",
"-lenS = len(Counter(S))",
"-lenT = len(Counter(T))",
"-flag = 0",
"-if lenS == lenT:",
"- for i in range(lenS):",
"- if Counter(S).most_common()[i][1] == Counter(T).most_common()[i][1]:",
"- continue",
"- else:",
"- flag = 1",
"- break",
"-else:",
"- flag = 1",
"-if flag == 0:",
"+S = sorted(Counter(eval(input())).values())",
"+T = sorted(Counter(eval(input())).values())",
"+if S == T:"
]
| false | 0.093199 | 0.035749 | 2.607006 | [
"s269021834",
"s342607187"
]
|
u272557899 | p03078 | python | s375392019 | s179632642 | 739 | 393 | 151,640 | 56,536 | Accepted | Accepted | 46.82 | x, y, z, k = list(map(int, input().split()))
a = [int(m) for m in input().split()]
b = [int(m) for m in input().split()]
c = [int(m) for m in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
s = []
for i in range(x):
for j in range(y):
s.append(a[i] + b[j])
s.sort(reverse=True)
s1 = []
for i in range(min(x * y, k)):
s1.append(s[i])
t = []
for i in range(min(x * y, k)):
for j in range(z):
t.append(s1[i] + c[j])
t.sort(reverse=True)
for i in range(k):
print((t[i])) | from heapq import heappush, heappop
x, y, z, k = list(map(int, input().split()))
a = [int(m) for m in input().split()]
b = [int(m) for m in input().split()]
c = [int(m) for m in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
Q = [[-(a[0] + b[0] + c[0]), 0, 0, 0]]
ansli = []
se = set()
se.add("0,0,0")
for i in range(k):
tmp = heappop(Q)
ansli.append(tmp)
if tmp[1] != x - 1 and str(tmp[1] + 1) + "," + str(tmp[2]) + "," + str(tmp[3]) not in se:
heappush(Q, [-(a[tmp[1] + 1] + b[tmp[2]] + c[tmp[3]]), tmp[1] + 1, tmp[2], tmp[3]])
se.add(str(tmp[1] + 1) + "," + str(tmp[2]) + "," + str(tmp[3]))
if tmp[2] != y - 1 and str(tmp[1]) + "," + str(tmp[2] + 1) + "," + str(tmp[3]) not in se:
heappush(Q, [-(a[tmp[1]] + b[tmp[2] + 1] + c[tmp[3]]), tmp[1], tmp[2] + 1, tmp[3]])
se.add(str(tmp[1]) + "," + str(tmp[2] + 1) + "," + str(tmp[3]))
if tmp[3] != z - 1 and str(tmp[1]) + "," + str(tmp[2]) + "," + str(tmp[3] + 1) not in se:
heappush(Q, [-(a[tmp[1]] + b[tmp[2]] + c[tmp[3] + 1]), tmp[1], tmp[2], tmp[3] + 1])
se.add(str(tmp[1]) + "," + str(tmp[2]) + "," + str(tmp[3] + 1))
for i in range(k):
print((-ansli[i][0])) | 26 | 28 | 551 | 1,236 | x, y, z, k = list(map(int, input().split()))
a = [int(m) for m in input().split()]
b = [int(m) for m in input().split()]
c = [int(m) for m in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
s = []
for i in range(x):
for j in range(y):
s.append(a[i] + b[j])
s.sort(reverse=True)
s1 = []
for i in range(min(x * y, k)):
s1.append(s[i])
t = []
for i in range(min(x * y, k)):
for j in range(z):
t.append(s1[i] + c[j])
t.sort(reverse=True)
for i in range(k):
print((t[i]))
| from heapq import heappush, heappop
x, y, z, k = list(map(int, input().split()))
a = [int(m) for m in input().split()]
b = [int(m) for m in input().split()]
c = [int(m) for m in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
Q = [[-(a[0] + b[0] + c[0]), 0, 0, 0]]
ansli = []
se = set()
se.add("0,0,0")
for i in range(k):
tmp = heappop(Q)
ansli.append(tmp)
if (
tmp[1] != x - 1
and str(tmp[1] + 1) + "," + str(tmp[2]) + "," + str(tmp[3]) not in se
):
heappush(
Q, [-(a[tmp[1] + 1] + b[tmp[2]] + c[tmp[3]]), tmp[1] + 1, tmp[2], tmp[3]]
)
se.add(str(tmp[1] + 1) + "," + str(tmp[2]) + "," + str(tmp[3]))
if (
tmp[2] != y - 1
and str(tmp[1]) + "," + str(tmp[2] + 1) + "," + str(tmp[3]) not in se
):
heappush(
Q, [-(a[tmp[1]] + b[tmp[2] + 1] + c[tmp[3]]), tmp[1], tmp[2] + 1, tmp[3]]
)
se.add(str(tmp[1]) + "," + str(tmp[2] + 1) + "," + str(tmp[3]))
if (
tmp[3] != z - 1
and str(tmp[1]) + "," + str(tmp[2]) + "," + str(tmp[3] + 1) not in se
):
heappush(
Q, [-(a[tmp[1]] + b[tmp[2]] + c[tmp[3] + 1]), tmp[1], tmp[2], tmp[3] + 1]
)
se.add(str(tmp[1]) + "," + str(tmp[2]) + "," + str(tmp[3] + 1))
for i in range(k):
print((-ansli[i][0]))
| false | 7.142857 | [
"+from heapq import heappush, heappop",
"+",
"-s = []",
"-for i in range(x):",
"- for j in range(y):",
"- s.append(a[i] + b[j])",
"-s.sort(reverse=True)",
"-s1 = []",
"-for i in range(min(x * y, k)):",
"- s1.append(s[i])",
"-t = []",
"-for i in range(min(x * y, k)):",
"- for j in range(z):",
"- t.append(s1[i] + c[j])",
"-t.sort(reverse=True)",
"+Q = [[-(a[0] + b[0] + c[0]), 0, 0, 0]]",
"+ansli = []",
"+se = set()",
"+se.add(\"0,0,0\")",
"- print((t[i]))",
"+ tmp = heappop(Q)",
"+ ansli.append(tmp)",
"+ if (",
"+ tmp[1] != x - 1",
"+ and str(tmp[1] + 1) + \",\" + str(tmp[2]) + \",\" + str(tmp[3]) not in se",
"+ ):",
"+ heappush(",
"+ Q, [-(a[tmp[1] + 1] + b[tmp[2]] + c[tmp[3]]), tmp[1] + 1, tmp[2], tmp[3]]",
"+ )",
"+ se.add(str(tmp[1] + 1) + \",\" + str(tmp[2]) + \",\" + str(tmp[3]))",
"+ if (",
"+ tmp[2] != y - 1",
"+ and str(tmp[1]) + \",\" + str(tmp[2] + 1) + \",\" + str(tmp[3]) not in se",
"+ ):",
"+ heappush(",
"+ Q, [-(a[tmp[1]] + b[tmp[2] + 1] + c[tmp[3]]), tmp[1], tmp[2] + 1, tmp[3]]",
"+ )",
"+ se.add(str(tmp[1]) + \",\" + str(tmp[2] + 1) + \",\" + str(tmp[3]))",
"+ if (",
"+ tmp[3] != z - 1",
"+ and str(tmp[1]) + \",\" + str(tmp[2]) + \",\" + str(tmp[3] + 1) not in se",
"+ ):",
"+ heappush(",
"+ Q, [-(a[tmp[1]] + b[tmp[2]] + c[tmp[3] + 1]), tmp[1], tmp[2], tmp[3] + 1]",
"+ )",
"+ se.add(str(tmp[1]) + \",\" + str(tmp[2]) + \",\" + str(tmp[3] + 1))",
"+for i in range(k):",
"+ print((-ansli[i][0]))"
]
| false | 0.0654 | 0.043268 | 1.511534 | [
"s375392019",
"s179632642"
]
|
u345966487 | p03311 | python | s073912925 | s937098455 | 252 | 204 | 26,180 | 25,184 | Accepted | Accepted | 19.05 | N = int(eval(input()))
A = list(map(int,input().split()))
B = sorted(A[i] - i - 1 for i in range(N))
def sad(b):
return sum(abs(A[i] - i - 1 - b)for i in range(N))
print((min(sad(B[N//2]),sad(B[min(N//2+1,N-1)]))))
| N=int(eval(input()))
B=sorted(int(x)-i-1 for i,x in enumerate(input().split()))
def sad(x):
return sum(abs(b-x)for b in B)
print((sad(B[N//2])))
| 6 | 5 | 216 | 145 | N = int(eval(input()))
A = list(map(int, input().split()))
B = sorted(A[i] - i - 1 for i in range(N))
def sad(b):
return sum(abs(A[i] - i - 1 - b) for i in range(N))
print((min(sad(B[N // 2]), sad(B[min(N // 2 + 1, N - 1)]))))
| N = int(eval(input()))
B = sorted(int(x) - i - 1 for i, x in enumerate(input().split()))
def sad(x):
return sum(abs(b - x) for b in B)
print((sad(B[N // 2])))
| false | 16.666667 | [
"-A = list(map(int, input().split()))",
"-B = sorted(A[i] - i - 1 for i in range(N))",
"+B = sorted(int(x) - i - 1 for i, x in enumerate(input().split()))",
"-def sad(b):",
"- return sum(abs(A[i] - i - 1 - b) for i in range(N))",
"+def sad(x):",
"+ return sum(abs(b - x) for b in B)",
"-print((min(sad(B[N // 2]), sad(B[min(N // 2 + 1, N - 1)]))))",
"+print((sad(B[N // 2])))"
]
| false | 0.048648 | 0.171332 | 0.283942 | [
"s073912925",
"s937098455"
]
|
u670567845 | p03408 | python | s129634504 | s553210642 | 467 | 80 | 82,828 | 67,160 | Accepted | Accepted | 82.87 | import collections
n = int(eval(input()))
b = [eval(input()) for _ in range(n)]
m = int(eval(input()))
r = [eval(input()) for _ in range(m)]
bc = collections.Counter(b)
rc = collections.Counter(r)
ans = 0
for x in list(bc.keys()):
ans = max(ans, bc[x]-rc[x])
print(ans) | import collections
n = int(eval(input()))
s = [eval(input()) for _ in range(n)]
m = int(eval(input()))
t = [eval(input()) for _ in range(m)]
sc = collections.Counter(s)
tc = collections.Counter(t)
ans = 0
for x in list(sc.keys()):
ans = max(ans,sc[x]-tc[x])
print(ans) | 11 | 12 | 251 | 252 | import collections
n = int(eval(input()))
b = [eval(input()) for _ in range(n)]
m = int(eval(input()))
r = [eval(input()) for _ in range(m)]
bc = collections.Counter(b)
rc = collections.Counter(r)
ans = 0
for x in list(bc.keys()):
ans = max(ans, bc[x] - rc[x])
print(ans)
| import collections
n = int(eval(input()))
s = [eval(input()) for _ in range(n)]
m = int(eval(input()))
t = [eval(input()) for _ in range(m)]
sc = collections.Counter(s)
tc = collections.Counter(t)
ans = 0
for x in list(sc.keys()):
ans = max(ans, sc[x] - tc[x])
print(ans)
| false | 8.333333 | [
"-b = [eval(input()) for _ in range(n)]",
"+s = [eval(input()) for _ in range(n)]",
"-r = [eval(input()) for _ in range(m)]",
"-bc = collections.Counter(b)",
"-rc = collections.Counter(r)",
"+t = [eval(input()) for _ in range(m)]",
"+sc = collections.Counter(s)",
"+tc = collections.Counter(t)",
"-for x in list(bc.keys()):",
"- ans = max(ans, bc[x] - rc[x])",
"+for x in list(sc.keys()):",
"+ ans = max(ans, sc[x] - tc[x])"
]
| false | 0.079991 | 0.036668 | 2.181501 | [
"s129634504",
"s553210642"
]
|
u027685417 | p02898 | python | s486281517 | s787050349 | 63 | 49 | 11,912 | 11,912 | Accepted | Accepted | 22.22 | N, K = list(map(int, input().split()))
list_h = list(map(int, input().split()))
list_h.sort()
list_h.insert(0, 0)
list_h.append(500)
L, R = 0, N + 1
while R - L > 1:
C = (L + R) // 2
if list_h[C] >= K:
R = C
else:
L = C
print((len(list_h[R:-1])))
| N, K = list(map(int, input().split()))
list_h = list(map(int, input().split()))
count = 0
for i in list_h:
if i >= K:
count += 1
print(count)
| 16 | 9 | 285 | 158 | N, K = list(map(int, input().split()))
list_h = list(map(int, input().split()))
list_h.sort()
list_h.insert(0, 0)
list_h.append(500)
L, R = 0, N + 1
while R - L > 1:
C = (L + R) // 2
if list_h[C] >= K:
R = C
else:
L = C
print((len(list_h[R:-1])))
| N, K = list(map(int, input().split()))
list_h = list(map(int, input().split()))
count = 0
for i in list_h:
if i >= K:
count += 1
print(count)
| false | 43.75 | [
"-list_h.sort()",
"-list_h.insert(0, 0)",
"-list_h.append(500)",
"-L, R = 0, N + 1",
"-while R - L > 1:",
"- C = (L + R) // 2",
"- if list_h[C] >= K:",
"- R = C",
"- else:",
"- L = C",
"-print((len(list_h[R:-1])))",
"+count = 0",
"+for i in list_h:",
"+ if i >= K:",
"+ count += 1",
"+print(count)"
]
| false | 0.038081 | 0.047577 | 0.800396 | [
"s486281517",
"s787050349"
]
|
u680851063 | p03111 | python | s941291882 | s431743349 | 305 | 254 | 12,788 | 3,316 | Accepted | Accepted | 16.72 | # DFS, パターン列挙_竹'n'本の使用パターン
n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
stack = [[0],[1],[2],[-1]] # 初期化_ここでは竹の使用パターン4つを設置
ptns = [] # パターン候補の器_初期化
while stack: # stackが空になるまでループ
tmp = stack.pop() # パターンの候補を pop
if len(tmp) == n: # 条件に合えば append
ptns.append(tmp)
elif len(tmp) < n: # 条件に合わなければ...
w = tmp + [0] # パターンの候補を作成して...
x = tmp + [1] # 〃
y = tmp + [2] # 〃
z = tmp + [-1]
stack += [w, x, y, z] # 積む
#print(ptns) # 竹の使用パターン
ans = 10**9
for i in range(len(ptns)):
if 0 not in ptns[i] or 1 not in ptns[i] or 2 not in ptns[i]:
continue
abc = [0, 0, 0, -30]
for j in range(n):
tmp = ptns[i][j]
if tmp >= 0:
abc[tmp] += l[j]
abc[3] += 10
mp = abc[3]
mp += abs(abc[0] - a)
mp += abs(abc[1] - b)
mp += abs(abc[2] - c)
ans = min(ans, mp)
print(ans)
'''
# パターン列挙と探索を並行して処理
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
stack = [[0],[1],[2],[-1]]
ans = 10**9
while stack:
tmp = stack.pop()
if len(tmp) == n:
if 0 not in tmp or 1 not in tmp or 2 not in tmp:
continue
abc = [0, 0, 0, -30]
for j in range(n):
if tmp[j] >= 0:
abc[tmp[j]] += l[j]
abc[3] += 10
mp = abc[3]
mp += abs(abc[0] - a)
mp += abs(abc[1] - b)
mp += abs(abc[2] - c)
ans = min(ans, mp)
elif len(tmp) < n:
w = tmp + [0]
x = tmp + [1]
y = tmp + [2]
z = tmp + [-1]
stack += [w, x, y, z]
print(ans)
''' | # DFS, パターン列挙_竹'n'本の使用パターン
'''
from collections import deque
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
queue = deque([[0],[1],[2],[-1]]) # 初期化_ここでは竹の使用パターン4つを設置
ptns = [] # パターン候補の器_初期化
while queue: # stackが空になるまでループ
tmp = queue.pop() # パターンの候補を pop
if len(tmp) == n: # 条件に合えば append
ptns.append(tmp)
elif len(tmp) < n: # 条件に合わなければ...
w = tmp + [0] # パターンの候補を作成して...
x = tmp + [1] # 〃
y = tmp + [2] # 〃
z = tmp + [-1]
queue += [w, x, y, z] # 積む
#print(ptns) # 竹の使用パターン
ans = 10**9
for i in range(len(ptns)):
if 0 not in ptns[i] or 1 not in ptns[i] or 2 not in ptns[i]:
continue
abc = [0, 0, 0, -30]
for j in range(n):
tmp = ptns[i][j]
if tmp >= 0:
abc[tmp] += l[j]
abc[3] += 10
mp = abc[3]
mp += abs(abc[0] - a)
mp += abs(abc[1] - b)
mp += abs(abc[2] - c)
ans = min(ans, mp)
print(ans)
'''
# パターン列挙と探索を並行して処理
from collections import deque
n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
queue = deque([[0],[1],[2],[-1]])
ans = 10**9
while queue:
tmp = queue.pop()
if len(tmp) == n:
if 0 not in tmp or 1 not in tmp or 2 not in tmp:
continue
abc = [0, 0, 0, -30]
for j in range(n):
if tmp[j] >= 0:
abc[tmp[j]] += l[j]
abc[3] += 10
mp = abc[3]
mp += abs(abc[0] - a)
mp += abs(abc[1] - b)
mp += abs(abc[2] - c)
ans = min(ans, mp)
elif len(tmp) < n:
w = tmp + [0]
x = tmp + [1]
y = tmp + [2]
z = tmp + [-1]
queue += [w, x, y, z]
print(ans)
| 73 | 76 | 1,720 | 1,799 | # DFS, パターン列挙_竹'n'本の使用パターン
n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
stack = [[0], [1], [2], [-1]] # 初期化_ここでは竹の使用パターン4つを設置
ptns = [] # パターン候補の器_初期化
while stack: # stackが空になるまでループ
tmp = stack.pop() # パターンの候補を pop
if len(tmp) == n: # 条件に合えば append
ptns.append(tmp)
elif len(tmp) < n: # 条件に合わなければ...
w = tmp + [0] # パターンの候補を作成して...
x = tmp + [1] # 〃
y = tmp + [2] # 〃
z = tmp + [-1]
stack += [w, x, y, z] # 積む
# print(ptns) # 竹の使用パターン
ans = 10**9
for i in range(len(ptns)):
if 0 not in ptns[i] or 1 not in ptns[i] or 2 not in ptns[i]:
continue
abc = [0, 0, 0, -30]
for j in range(n):
tmp = ptns[i][j]
if tmp >= 0:
abc[tmp] += l[j]
abc[3] += 10
mp = abc[3]
mp += abs(abc[0] - a)
mp += abs(abc[1] - b)
mp += abs(abc[2] - c)
ans = min(ans, mp)
print(ans)
"""
# パターン列挙と探索を並行して処理
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
stack = [[0],[1],[2],[-1]]
ans = 10**9
while stack:
tmp = stack.pop()
if len(tmp) == n:
if 0 not in tmp or 1 not in tmp or 2 not in tmp:
continue
abc = [0, 0, 0, -30]
for j in range(n):
if tmp[j] >= 0:
abc[tmp[j]] += l[j]
abc[3] += 10
mp = abc[3]
mp += abs(abc[0] - a)
mp += abs(abc[1] - b)
mp += abs(abc[2] - c)
ans = min(ans, mp)
elif len(tmp) < n:
w = tmp + [0]
x = tmp + [1]
y = tmp + [2]
z = tmp + [-1]
stack += [w, x, y, z]
print(ans)
"""
| # DFS, パターン列挙_竹'n'本の使用パターン
"""
from collections import deque
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
queue = deque([[0],[1],[2],[-1]]) # 初期化_ここでは竹の使用パターン4つを設置
ptns = [] # パターン候補の器_初期化
while queue: # stackが空になるまでループ
tmp = queue.pop() # パターンの候補を pop
if len(tmp) == n: # 条件に合えば append
ptns.append(tmp)
elif len(tmp) < n: # 条件に合わなければ...
w = tmp + [0] # パターンの候補を作成して...
x = tmp + [1] # 〃
y = tmp + [2] # 〃
z = tmp + [-1]
queue += [w, x, y, z] # 積む
#print(ptns) # 竹の使用パターン
ans = 10**9
for i in range(len(ptns)):
if 0 not in ptns[i] or 1 not in ptns[i] or 2 not in ptns[i]:
continue
abc = [0, 0, 0, -30]
for j in range(n):
tmp = ptns[i][j]
if tmp >= 0:
abc[tmp] += l[j]
abc[3] += 10
mp = abc[3]
mp += abs(abc[0] - a)
mp += abs(abc[1] - b)
mp += abs(abc[2] - c)
ans = min(ans, mp)
print(ans)
"""
# パターン列挙と探索を並行して処理
from collections import deque
n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
queue = deque([[0], [1], [2], [-1]])
ans = 10**9
while queue:
tmp = queue.pop()
if len(tmp) == n:
if 0 not in tmp or 1 not in tmp or 2 not in tmp:
continue
abc = [0, 0, 0, -30]
for j in range(n):
if tmp[j] >= 0:
abc[tmp[j]] += l[j]
abc[3] += 10
mp = abc[3]
mp += abs(abc[0] - a)
mp += abs(abc[1] - b)
mp += abs(abc[2] - c)
ans = min(ans, mp)
elif len(tmp) < n:
w = tmp + [0]
x = tmp + [1]
y = tmp + [2]
z = tmp + [-1]
queue += [w, x, y, z]
print(ans)
| false | 3.947368 | [
"-n, a, b, c = list(map(int, input().split()))",
"-l = [int(eval(input())) for _ in range(n)]",
"-stack = [[0], [1], [2], [-1]] # 初期化_ここでは竹の使用パターン4つを設置",
"-ptns = [] # パターン候補の器_初期化",
"-while stack: # stackが空になるまでループ",
"- tmp = stack.pop() # パターンの候補を pop",
"- if len(tmp) == n: # 条件に合えば append",
"+\"\"\"",
"+from collections import deque",
"+n, a, b, c = map(int, input().split())",
"+l = [int(input()) for _ in range(n)]",
"+queue = deque([[0],[1],[2],[-1]]) # 初期化_ここでは竹の使用パターン4つを設置",
"+ptns = [] # パターン候補の器_初期化",
"+while queue: # stackが空になるまでループ",
"+ tmp = queue.pop() # パターンの候補を pop",
"+ if len(tmp) == n: # 条件に合えば append",
"- elif len(tmp) < n: # 条件に合わなければ...",
"- w = tmp + [0] # パターンの候補を作成して...",
"- x = tmp + [1] # 〃",
"- y = tmp + [2] # 〃",
"+ elif len(tmp) < n: # 条件に合わなければ...",
"+ w = tmp + [0] # パターンの候補を作成して...",
"+ x = tmp + [1] # 〃",
"+ y = tmp + [2] # 〃",
"- stack += [w, x, y, z] # 積む",
"-# print(ptns) # 竹の使用パターン",
"+ queue += [w, x, y, z] # 積む",
"+#print(ptns) # 竹の使用パターン",
"-n, a, b, c = map(int, input().split())",
"-l = [int(input()) for _ in range(n)]",
"-stack = [[0],[1],[2],[-1]]",
"+from collections import deque",
"+",
"+n, a, b, c = list(map(int, input().split()))",
"+l = [int(eval(input())) for _ in range(n)]",
"+queue = deque([[0], [1], [2], [-1]])",
"-while stack:",
"- tmp = stack.pop()",
"+while queue:",
"+ tmp = queue.pop()",
"- stack += [w, x, y, z]",
"+ queue += [w, x, y, z]",
"-\"\"\""
]
| false | 0.391801 | 0.218421 | 1.793786 | [
"s941291882",
"s431743349"
]
|
u078276601 | p02623 | python | s308368744 | s181382490 | 291 | 237 | 47,372 | 50,624 | Accepted | Accepted | 18.56 | n,m,k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a,b = [0], [0]
for i in range(n):
a.append(a[i]+A[i])
for j in range(m):
b.append(b[j]+B[j])
ans, j = 0, m
for i in range(n+1):
if a[i] > k:
break
while a[i] + b[j] > k:
j -= 1
ans = max(ans, i+j)
print(ans) | import itertools
n,m,k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
acc_A = [0]+list(itertools.accumulate(A))
acc_B = [0]+list(itertools.accumulate(B))
ans, j = 0, m
for i in range(n+1):
if acc_A[i] > k:
break
while acc_A[i] + acc_B[j] > k:
j -= 1
ans = max(ans, i+j)
print(ans)
| 19 | 18 | 374 | 399 | n, m, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(n):
a.append(a[i] + A[i])
for j in range(m):
b.append(b[j] + B[j])
ans, j = 0, m
for i in range(n + 1):
if a[i] > k:
break
while a[i] + b[j] > k:
j -= 1
ans = max(ans, i + j)
print(ans)
| import itertools
n, m, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
acc_A = [0] + list(itertools.accumulate(A))
acc_B = [0] + list(itertools.accumulate(B))
ans, j = 0, m
for i in range(n + 1):
if acc_A[i] > k:
break
while acc_A[i] + acc_B[j] > k:
j -= 1
ans = max(ans, i + j)
print(ans)
| false | 5.263158 | [
"+import itertools",
"+",
"-a, b = [0], [0]",
"-for i in range(n):",
"- a.append(a[i] + A[i])",
"-for j in range(m):",
"- b.append(b[j] + B[j])",
"+acc_A = [0] + list(itertools.accumulate(A))",
"+acc_B = [0] + list(itertools.accumulate(B))",
"- if a[i] > k:",
"+ if acc_A[i] > k:",
"- while a[i] + b[j] > k:",
"+ while acc_A[i] + acc_B[j] > k:"
]
| false | 0.048615 | 0.039213 | 1.239763 | [
"s308368744",
"s181382490"
]
|
u612243550 | p02259 | python | s913152147 | s958250548 | 30 | 20 | 7,664 | 7,672 | Accepted | Accepted | 33.33 | n = int(eval(input()))
A = input().split(' ')
count = 0
flag = True
while flag:
flag = False
for j in reversed(list(range(1, n))):
if int(A[j]) < int(A[j-1]):
(A[j-1], A[j]) = (A[j], A[j-1])
count += 1
flag = True
print((" ".join(A)))
print(count) | n = int(eval(input()))
A = input().split(' ')
count = 0
flag = True
while flag:
flag = False
i = 0
for j in reversed(list(range(i + 1, n))):
if int(A[j]) < int(A[j-1]):
(A[j-1], A[j]) = (A[j], A[j-1])
count += 1
flag = True
i += 1
print((" ".join(A)))
print(count) | 15 | 20 | 301 | 334 | n = int(eval(input()))
A = input().split(" ")
count = 0
flag = True
while flag:
flag = False
for j in reversed(list(range(1, n))):
if int(A[j]) < int(A[j - 1]):
(A[j - 1], A[j]) = (A[j], A[j - 1])
count += 1
flag = True
print((" ".join(A)))
print(count)
| n = int(eval(input()))
A = input().split(" ")
count = 0
flag = True
while flag:
flag = False
i = 0
for j in reversed(list(range(i + 1, n))):
if int(A[j]) < int(A[j - 1]):
(A[j - 1], A[j]) = (A[j], A[j - 1])
count += 1
flag = True
i += 1
print((" ".join(A)))
print(count)
| false | 25 | [
"- for j in reversed(list(range(1, n))):",
"+ i = 0",
"+ for j in reversed(list(range(i + 1, n))):",
"+ i += 1"
]
| false | 0.066897 | 0.067788 | 0.986857 | [
"s913152147",
"s958250548"
]
|
u698919163 | p02678 | python | s894320667 | s863691553 | 623 | 466 | 34,192 | 121,876 | Accepted | Accepted | 25.2 | from collections import deque
import sys
N,M = list(map(int,input().split()))
graph = [[] for _ in range(N + 1)]
for i in range(M):
a,b = list(map(int,input().split()))
graph[a].append(b)
graph[b].append(a)
que = deque([1])
ans = [0]*(N+1)
while que:
x = deque.popleft(que)
for i in graph[x]:
if ans[i] != 0:
continue
ans[i] = x
que.append(i)
for i in range(2,N+1):
if ans[i] == 0:
print('No')
sys.exit()
print('Yes')
for i in range(2,N+1):
print((ans[i])) | N,M = list(map(int,input().split()))
AB = [list(map(int,input().split())) for i in range(M)]
ans = [-1] * (N+1)
graph = [[] for _ in range(N+1)]
for a,b in AB:
graph[a].append(b)
graph[b].append(a)
from collections import deque
import sys
ans = [-1] * (N+1)
todo = deque([(1,0)])
while todo:
x,parent = deque.popleft(todo)
#ans[x] = parent
for y in graph[x]:
# if y == parent:
# continue
if ans[y] != -1:
continue
ans[y] = x
todo.append((y,x))
for i in range(2,N+1):
if ans[i] == -1:
print('No')
sys.exit()
print('Yes')
for i in range(2,N+1):
print((ans[i])) | 29 | 34 | 571 | 710 | from collections import deque
import sys
N, M = list(map(int, input().split()))
graph = [[] for _ in range(N + 1)]
for i in range(M):
a, b = list(map(int, input().split()))
graph[a].append(b)
graph[b].append(a)
que = deque([1])
ans = [0] * (N + 1)
while que:
x = deque.popleft(que)
for i in graph[x]:
if ans[i] != 0:
continue
ans[i] = x
que.append(i)
for i in range(2, N + 1):
if ans[i] == 0:
print("No")
sys.exit()
print("Yes")
for i in range(2, N + 1):
print((ans[i]))
| N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(M)]
ans = [-1] * (N + 1)
graph = [[] for _ in range(N + 1)]
for a, b in AB:
graph[a].append(b)
graph[b].append(a)
from collections import deque
import sys
ans = [-1] * (N + 1)
todo = deque([(1, 0)])
while todo:
x, parent = deque.popleft(todo)
# ans[x] = parent
for y in graph[x]:
# if y == parent:
# continue
if ans[y] != -1:
continue
ans[y] = x
todo.append((y, x))
for i in range(2, N + 1):
if ans[i] == -1:
print("No")
sys.exit()
print("Yes")
for i in range(2, N + 1):
print((ans[i]))
| false | 14.705882 | [
"+N, M = list(map(int, input().split()))",
"+AB = [list(map(int, input().split())) for i in range(M)]",
"+ans = [-1] * (N + 1)",
"+graph = [[] for _ in range(N + 1)]",
"+for a, b in AB:",
"+ graph[a].append(b)",
"+ graph[b].append(a)",
"-N, M = list(map(int, input().split()))",
"-graph = [[] for _ in range(N + 1)]",
"-for i in range(M):",
"- a, b = list(map(int, input().split()))",
"- graph[a].append(b)",
"- graph[b].append(a)",
"-que = deque([1])",
"-ans = [0] * (N + 1)",
"-while que:",
"- x = deque.popleft(que)",
"- for i in graph[x]:",
"- if ans[i] != 0:",
"+ans = [-1] * (N + 1)",
"+todo = deque([(1, 0)])",
"+while todo:",
"+ x, parent = deque.popleft(todo)",
"+ # ans[x] = parent",
"+ for y in graph[x]:",
"+ # if y == parent:",
"+ # continue",
"+ if ans[y] != -1:",
"- ans[i] = x",
"- que.append(i)",
"+ ans[y] = x",
"+ todo.append((y, x))",
"- if ans[i] == 0:",
"+ if ans[i] == -1:"
]
| false | 0.041841 | 0.041488 | 1.008502 | [
"s894320667",
"s863691553"
]
|
u092650292 | p02958 | python | s585715983 | s956440216 | 348 | 24 | 21,596 | 3,700 | Accepted | Accepted | 93.1 | import numpy as np
def main():
n = int(eval(input()))
p = list(map(int,input().split()))
a = np.array(list(range(1,n+1)))
p = np.array(p)
ans = len(np.where((a-p)!=0)[0])
if ans <= 2:
print('YES')
else:
print('NO')
main() | #from math import gcd
from math import factorial as f
from math import ceil,floor,sqrt
import bisect
import re
import heapq
from copy import deepcopy
import itertools
from sys import exit
ii = lambda : int(eval(input()))
mi = lambda : list(map(int,input().split()))
li = lambda : list(map(int,input().split()))
yes = "Yes"
no = "No"
def main():
n=ii()
p = li()
cnt = 0
for i in range(1,n+1):
if i!=p[i-1]:
cnt+=1
if cnt<=2:
print('YES')
else:
print('NO')
main()
| 21 | 41 | 288 | 565 | import numpy as np
def main():
n = int(eval(input()))
p = list(map(int, input().split()))
a = np.array(list(range(1, n + 1)))
p = np.array(p)
ans = len(np.where((a - p) != 0)[0])
if ans <= 2:
print("YES")
else:
print("NO")
main()
| # from math import gcd
from math import factorial as f
from math import ceil, floor, sqrt
import bisect
import re
import heapq
from copy import deepcopy
import itertools
from sys import exit
ii = lambda: int(eval(input()))
mi = lambda: list(map(int, input().split()))
li = lambda: list(map(int, input().split()))
yes = "Yes"
no = "No"
def main():
n = ii()
p = li()
cnt = 0
for i in range(1, n + 1):
if i != p[i - 1]:
cnt += 1
if cnt <= 2:
print("YES")
else:
print("NO")
main()
| false | 48.780488 | [
"-import numpy as np",
"+# from math import gcd",
"+from math import factorial as f",
"+from math import ceil, floor, sqrt",
"+import bisect",
"+import re",
"+import heapq",
"+from copy import deepcopy",
"+import itertools",
"+from sys import exit",
"+",
"+ii = lambda: int(eval(input()))",
"+mi = lambda: list(map(int, input().split()))",
"+li = lambda: list(map(int, input().split()))",
"+yes = \"Yes\"",
"+no = \"No\"",
"- n = int(eval(input()))",
"- p = list(map(int, input().split()))",
"- a = np.array(list(range(1, n + 1)))",
"- p = np.array(p)",
"- ans = len(np.where((a - p) != 0)[0])",
"- if ans <= 2:",
"+ n = ii()",
"+ p = li()",
"+ cnt = 0",
"+ for i in range(1, n + 1):",
"+ if i != p[i - 1]:",
"+ cnt += 1",
"+ if cnt <= 2:"
]
| false | 0.389757 | 0.03665 | 10.634559 | [
"s585715983",
"s956440216"
]
|
u608088992 | p03127 | python | s393779202 | s016807087 | 109 | 85 | 14,224 | 20,016 | Accepted | Accepted | 22.02 | N = int(eval(input()))
A = [int(a) for a in input().split()]
def GCD(a, b):
a, b = max(a, b), min(a, b)
while a % b != 0:
a, b = b, a%b
return b
Ans = GCD(A[0], A[1])
for i in range(2, N):
Ans = GCD(Ans, A[i])
print(Ans) | import sys
def gcd(a, b):
a, b = max(a, b), min(a, b)
while a % b > 0:
a, b = b, a % b
return b
def solve():
input = sys.stdin.readline
N = int(eval(input()))
A = [int(i) for i in input().split()]
gcdA = A[0]
for a in A: gcdA = gcd(gcdA, a)
print(gcdA)
return 0
if __name__ == "__main__":
solve() | 13 | 20 | 252 | 365 | N = int(eval(input()))
A = [int(a) for a in input().split()]
def GCD(a, b):
a, b = max(a, b), min(a, b)
while a % b != 0:
a, b = b, a % b
return b
Ans = GCD(A[0], A[1])
for i in range(2, N):
Ans = GCD(Ans, A[i])
print(Ans)
| import sys
def gcd(a, b):
a, b = max(a, b), min(a, b)
while a % b > 0:
a, b = b, a % b
return b
def solve():
input = sys.stdin.readline
N = int(eval(input()))
A = [int(i) for i in input().split()]
gcdA = A[0]
for a in A:
gcdA = gcd(gcdA, a)
print(gcdA)
return 0
if __name__ == "__main__":
solve()
| false | 35 | [
"-N = int(eval(input()))",
"-A = [int(a) for a in input().split()]",
"+import sys",
"-def GCD(a, b):",
"+def gcd(a, b):",
"- while a % b != 0:",
"+ while a % b > 0:",
"-Ans = GCD(A[0], A[1])",
"-for i in range(2, N):",
"- Ans = GCD(Ans, A[i])",
"-print(Ans)",
"+def solve():",
"+ input = sys.stdin.readline",
"+ N = int(eval(input()))",
"+ A = [int(i) for i in input().split()]",
"+ gcdA = A[0]",
"+ for a in A:",
"+ gcdA = gcd(gcdA, a)",
"+ print(gcdA)",
"+ return 0",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ solve()"
]
| false | 0.046702 | 0.045179 | 1.03372 | [
"s393779202",
"s016807087"
]
|
u282228874 | p03111 | python | s284950684 | s261754080 | 73 | 61 | 3,064 | 3,064 | Accepted | Accepted | 16.44 | N,A,B,C = list(map(int,input().split()))
l = [int(eval(input())) for i in range(N)]
INF = 10**9+7
def dfs(count,a,b,c):
if count == N:
if min(a,b,c) > 0:
return abs(a-A)+abs(b-B)+abs(c-C)-30
else:
return INF
non = dfs(count+1,a,b,c)
useA = dfs(count+1,a+l[count],b,c)+10
useB = dfs(count+1,a,b+l[count],c)+10
useC = dfs(count+1,a,b,c+l[count])+10
return min(non,useA,useB,useC)
print((dfs(0,0,0,0))) | N,A,B,C = list(map(int,input().split()))
L = [int(eval(input())) for i in range(N)]
def dfs(cnt,la,lb,lc,cost):
if cnt == N:
if la == 0 or lb == 0 or lc == 0:
return 10**10
else:
return cost+abs(A-la)+abs(B-lb)+abs(C-lc)-30
else:
a = dfs(cnt+1,la+L[cnt],lb,lc,cost+10)
b = dfs(cnt+1,la,lb+L[cnt],lc,cost+10)
c = dfs(cnt+1,la,lb,lc+L[cnt],cost+10)
d = dfs(cnt+1,la,lb,lc,cost)
return min(a,b,c,d)
print((dfs(0,0,0,0,0))) | 17 | 17 | 419 | 512 | N, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for i in range(N)]
INF = 10**9 + 7
def dfs(count, a, b, c):
if count == N:
if min(a, b, c) > 0:
return abs(a - A) + abs(b - B) + abs(c - C) - 30
else:
return INF
non = dfs(count + 1, a, b, c)
useA = dfs(count + 1, a + l[count], b, c) + 10
useB = dfs(count + 1, a, b + l[count], c) + 10
useC = dfs(count + 1, a, b, c + l[count]) + 10
return min(non, useA, useB, useC)
print((dfs(0, 0, 0, 0)))
| N, A, B, C = list(map(int, input().split()))
L = [int(eval(input())) for i in range(N)]
def dfs(cnt, la, lb, lc, cost):
if cnt == N:
if la == 0 or lb == 0 or lc == 0:
return 10**10
else:
return cost + abs(A - la) + abs(B - lb) + abs(C - lc) - 30
else:
a = dfs(cnt + 1, la + L[cnt], lb, lc, cost + 10)
b = dfs(cnt + 1, la, lb + L[cnt], lc, cost + 10)
c = dfs(cnt + 1, la, lb, lc + L[cnt], cost + 10)
d = dfs(cnt + 1, la, lb, lc, cost)
return min(a, b, c, d)
print((dfs(0, 0, 0, 0, 0)))
| false | 0 | [
"-l = [int(eval(input())) for i in range(N)]",
"-INF = 10**9 + 7",
"+L = [int(eval(input())) for i in range(N)]",
"-def dfs(count, a, b, c):",
"- if count == N:",
"- if min(a, b, c) > 0:",
"- return abs(a - A) + abs(b - B) + abs(c - C) - 30",
"+def dfs(cnt, la, lb, lc, cost):",
"+ if cnt == N:",
"+ if la == 0 or lb == 0 or lc == 0:",
"+ return 10**10",
"- return INF",
"- non = dfs(count + 1, a, b, c)",
"- useA = dfs(count + 1, a + l[count], b, c) + 10",
"- useB = dfs(count + 1, a, b + l[count], c) + 10",
"- useC = dfs(count + 1, a, b, c + l[count]) + 10",
"- return min(non, useA, useB, useC)",
"+ return cost + abs(A - la) + abs(B - lb) + abs(C - lc) - 30",
"+ else:",
"+ a = dfs(cnt + 1, la + L[cnt], lb, lc, cost + 10)",
"+ b = dfs(cnt + 1, la, lb + L[cnt], lc, cost + 10)",
"+ c = dfs(cnt + 1, la, lb, lc + L[cnt], cost + 10)",
"+ d = dfs(cnt + 1, la, lb, lc, cost)",
"+ return min(a, b, c, d)",
"-print((dfs(0, 0, 0, 0)))",
"+print((dfs(0, 0, 0, 0, 0)))"
]
| false | 0.059719 | 0.077302 | 0.772541 | [
"s284950684",
"s261754080"
]
|
u562935282 | p02659 | python | s923208044 | s581386615 | 26 | 22 | 10,068 | 9,176 | Accepted | Accepted | 15.38 | def main():
from decimal import Decimal
A, B = list(map(Decimal, input().split()))
print((int(A * B)))
if __name__ == '__main__':
main()
# import sys
# input = sys.stdin.readline
#
# sys.setrecursionlimit(10 ** 7)
#
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
# while abs(ok - ng) > 1:
# mid = (ok + ng) // 2
# if func(mid):
# ok = mid
# else:
# ng = mid
# return ok
| def main():
A, B = input().split()
A = int(A)
B_int, B_frac = list(map(int, B.split('.'))) # 整数部分, 小数部分
L = len(str(B_frac)) # 小数部分の桁数
ans = (A * (B_int * 100 + B_frac)) // 100
print(ans)
if __name__ == '__main__':
main()
| 25 | 14 | 505 | 264 | def main():
from decimal import Decimal
A, B = list(map(Decimal, input().split()))
print((int(A * B)))
if __name__ == "__main__":
main()
# import sys
# input = sys.stdin.readline
#
# sys.setrecursionlimit(10 ** 7)
#
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
# while abs(ok - ng) > 1:
# mid = (ok + ng) // 2
# if func(mid):
# ok = mid
# else:
# ng = mid
# return ok
| def main():
A, B = input().split()
A = int(A)
B_int, B_frac = list(map(int, B.split("."))) # 整数部分, 小数部分
L = len(str(B_frac)) # 小数部分の桁数
ans = (A * (B_int * 100 + B_frac)) // 100
print(ans)
if __name__ == "__main__":
main()
| false | 44 | [
"- from decimal import Decimal",
"-",
"- A, B = list(map(Decimal, input().split()))",
"- print((int(A * B)))",
"+ A, B = input().split()",
"+ A = int(A)",
"+ B_int, B_frac = list(map(int, B.split(\".\"))) # 整数部分, 小数部分",
"+ L = len(str(B_frac)) # 小数部分の桁数",
"+ ans = (A * (B_int * 100 + B_frac)) // 100",
"+ print(ans)",
"-# import sys",
"-# input = sys.stdin.readline",
"-#",
"-# sys.setrecursionlimit(10 ** 7)",
"-#",
"-# (int(x)-1 for x in input().split())",
"-# rstrip()",
"-#",
"-# def binary_search(*, ok, ng, func):",
"-# while abs(ok - ng) > 1:",
"-# mid = (ok + ng) // 2",
"-# if func(mid):",
"-# ok = mid",
"-# else:",
"-# ng = mid",
"-# return ok"
]
| false | 0.050702 | 0.047102 | 1.07644 | [
"s923208044",
"s581386615"
]
|
u045176840 | p03448 | python | s713382080 | s662847536 | 53 | 29 | 9,108 | 9,136 | Accepted | Accepted | 45.28 | # import numpy as np
A_init = 500
B_init = 100
C_init = 50
A_n = int(eval(input()))
B_n = int(eval(input()))
C_n = int(eval(input()))
X = int(eval(input()))
cnt = 0
for a in range(A_n+1):
if A_init * a <= X:
for b in range(B_n+1):
if (A_init * a + B_init * b) <= X:
for c in range(C_n+1):
if (A_init * a + B_init * b + C_init * c) == X: cnt += 1
else:
break
else:
break
# print(np.count_nonzero([k+[i for i in All_list] == X for k in All_list]))
print(cnt) | # import numpy as np
A_init = 500
B_init = 100
C_init = 50
A_n = int(eval(input()))
B_n = int(eval(input()))
C_n = int(eval(input()))
X = int(eval(input()))
cnt = 0
for a in range(A_n+1):
if A_init * a <= X:
for b in range(B_n+1):
if (A_init * a + B_init * b) <= X:
K = X - (A_init * a + B_init * b)
if K % 50 == 0 and K / C_init <= C_n:
cnt += 1
else:
break
else:
break
# print(np.count_nonzero([k+[i for i in All_list] == X for k in All_list]))
print(cnt) | 25 | 26 | 560 | 578 | # import numpy as np
A_init = 500
B_init = 100
C_init = 50
A_n = int(eval(input()))
B_n = int(eval(input()))
C_n = int(eval(input()))
X = int(eval(input()))
cnt = 0
for a in range(A_n + 1):
if A_init * a <= X:
for b in range(B_n + 1):
if (A_init * a + B_init * b) <= X:
for c in range(C_n + 1):
if (A_init * a + B_init * b + C_init * c) == X:
cnt += 1
else:
break
else:
break
# print(np.count_nonzero([k+[i for i in All_list] == X for k in All_list]))
print(cnt)
| # import numpy as np
A_init = 500
B_init = 100
C_init = 50
A_n = int(eval(input()))
B_n = int(eval(input()))
C_n = int(eval(input()))
X = int(eval(input()))
cnt = 0
for a in range(A_n + 1):
if A_init * a <= X:
for b in range(B_n + 1):
if (A_init * a + B_init * b) <= X:
K = X - (A_init * a + B_init * b)
if K % 50 == 0 and K / C_init <= C_n:
cnt += 1
else:
break
else:
break
# print(np.count_nonzero([k+[i for i in All_list] == X for k in All_list]))
print(cnt)
| false | 3.846154 | [
"- for c in range(C_n + 1):",
"- if (A_init * a + B_init * b + C_init * c) == X:",
"- cnt += 1",
"+ K = X - (A_init * a + B_init * b)",
"+ if K % 50 == 0 and K / C_init <= C_n:",
"+ cnt += 1"
]
| false | 0.051732 | 0.03997 | 1.294259 | [
"s713382080",
"s662847536"
]
|
u309018392 | p02712 | python | s927507696 | s947350406 | 216 | 147 | 52,684 | 52,832 | Accepted | Accepted | 31.94 | n = int(eval(input()))
a = []
for i in range(1,n+1):
a.append(i)
new_a = [i for i in a if i%3 != 0 and i%5 != 0]
print((sum(new_a))) | n = int(eval(input()))
a = list(range(1,n+1))
new_a = [i for i in a if i%3 != 0 and i%5 != 0]
print((sum(new_a))) | 6 | 4 | 134 | 109 | n = int(eval(input()))
a = []
for i in range(1, n + 1):
a.append(i)
new_a = [i for i in a if i % 3 != 0 and i % 5 != 0]
print((sum(new_a)))
| n = int(eval(input()))
a = list(range(1, n + 1))
new_a = [i for i in a if i % 3 != 0 and i % 5 != 0]
print((sum(new_a)))
| false | 33.333333 | [
"-a = []",
"-for i in range(1, n + 1):",
"- a.append(i)",
"+a = list(range(1, n + 1))"
]
| false | 0.56311 | 0.181468 | 3.10308 | [
"s927507696",
"s947350406"
]
|
u265939044 | p03457 | python | s656026712 | s034699562 | 495 | 430 | 32,148 | 32,148 | Accepted | Accepted | 13.13 | T = 0
X = 1
Y = 2
item = eval(input())
tabiji = [[0,0,0]]
for i in range(1, int(item)+1):
tabiji.append(input().split(' '))
a = 'Yes'
for i in range(0, len(tabiji)-1):
time = int(tabiji[i+1][T]) - int(tabiji[i][T])
dX = int(tabiji[i+1][X]) - int(tabiji[i][X])
dY = int(tabiji[i+1][Y]) - int(tabiji[i][Y])
for j in range(time):
if dX > 0:
dX -= 1
elif dX < 0:
dX += 1
elif dY > 0:
dY -= 1
elif dY < 0:
dY += 1
if dX == 0 and dY == 0 and (time - j+1) % 2 == 1:
a = 'No'
break
elif dX == 0 and dY == 0 and (time - j+1) % 2 == 0:
break
if dX != 0 or dY != 0:
a = 'No'
print(a) | T = 0
X = 1
Y = 2
item = eval(input())
tabiji = [[0,0,0]]
for i in range(1, int(item)+1):
tabiji.append(input().split(' '))
a = 'Yes'
for i in range(0, len(tabiji)-1):
time = int(tabiji[i+1][T]) - int(tabiji[i][T])
dX = abs(int(tabiji[i+1][X]) - int(tabiji[i][X]))
dY = abs(int(tabiji[i+1][Y]) - int(tabiji[i][Y]))
dtime = time - dX - dY
if dtime < 0 or dtime % 2 == 1:
a = 'No'
print(a) | 31 | 18 | 762 | 432 | T = 0
X = 1
Y = 2
item = eval(input())
tabiji = [[0, 0, 0]]
for i in range(1, int(item) + 1):
tabiji.append(input().split(" "))
a = "Yes"
for i in range(0, len(tabiji) - 1):
time = int(tabiji[i + 1][T]) - int(tabiji[i][T])
dX = int(tabiji[i + 1][X]) - int(tabiji[i][X])
dY = int(tabiji[i + 1][Y]) - int(tabiji[i][Y])
for j in range(time):
if dX > 0:
dX -= 1
elif dX < 0:
dX += 1
elif dY > 0:
dY -= 1
elif dY < 0:
dY += 1
if dX == 0 and dY == 0 and (time - j + 1) % 2 == 1:
a = "No"
break
elif dX == 0 and dY == 0 and (time - j + 1) % 2 == 0:
break
if dX != 0 or dY != 0:
a = "No"
print(a)
| T = 0
X = 1
Y = 2
item = eval(input())
tabiji = [[0, 0, 0]]
for i in range(1, int(item) + 1):
tabiji.append(input().split(" "))
a = "Yes"
for i in range(0, len(tabiji) - 1):
time = int(tabiji[i + 1][T]) - int(tabiji[i][T])
dX = abs(int(tabiji[i + 1][X]) - int(tabiji[i][X]))
dY = abs(int(tabiji[i + 1][Y]) - int(tabiji[i][Y]))
dtime = time - dX - dY
if dtime < 0 or dtime % 2 == 1:
a = "No"
print(a)
| false | 41.935484 | [
"- dX = int(tabiji[i + 1][X]) - int(tabiji[i][X])",
"- dY = int(tabiji[i + 1][Y]) - int(tabiji[i][Y])",
"- for j in range(time):",
"- if dX > 0:",
"- dX -= 1",
"- elif dX < 0:",
"- dX += 1",
"- elif dY > 0:",
"- dY -= 1",
"- elif dY < 0:",
"- dY += 1",
"- if dX == 0 and dY == 0 and (time - j + 1) % 2 == 1:",
"- a = \"No\"",
"- break",
"- elif dX == 0 and dY == 0 and (time - j + 1) % 2 == 0:",
"- break",
"- if dX != 0 or dY != 0:",
"+ dX = abs(int(tabiji[i + 1][X]) - int(tabiji[i][X]))",
"+ dY = abs(int(tabiji[i + 1][Y]) - int(tabiji[i][Y]))",
"+ dtime = time - dX - dY",
"+ if dtime < 0 or dtime % 2 == 1:"
]
| false | 0.052597 | 0.034476 | 1.525603 | [
"s656026712",
"s034699562"
]
|
u379959788 | p03241 | python | s331062307 | s541951234 | 694 | 20 | 3,060 | 3,188 | Accepted | Accepted | 97.12 | def is_prime(N):
if N == 1:
return False
for k in range(2, int(N**0.5) + 1):
if N % k == 0:
return False
return True
N, M = list(map(int, input().split()))
k = 0
if N != 1:
if is_prime(M):
print((1))
exit()
while True:
if M % (N + k) == 0:
ans = M // (N+k)
break
k += 1
print(ans) | import bisect
def make_divisors(N):
divisors = []
for i in range(1, int(N**0.5)+1):
if N % i == 0:
divisors.append(i)
if i != N // i:
divisors.append(N//i)
divisors.sort()
return divisors
N, M = list(map(int, input().split()))
lst = make_divisors(M)
print((lst[bisect.bisect_right(lst, M//N)-1])) | 21 | 13 | 378 | 364 | def is_prime(N):
if N == 1:
return False
for k in range(2, int(N**0.5) + 1):
if N % k == 0:
return False
return True
N, M = list(map(int, input().split()))
k = 0
if N != 1:
if is_prime(M):
print((1))
exit()
while True:
if M % (N + k) == 0:
ans = M // (N + k)
break
k += 1
print(ans)
| import bisect
def make_divisors(N):
divisors = []
for i in range(1, int(N**0.5) + 1):
if N % i == 0:
divisors.append(i)
if i != N // i:
divisors.append(N // i)
divisors.sort()
return divisors
N, M = list(map(int, input().split()))
lst = make_divisors(M)
print((lst[bisect.bisect_right(lst, M // N) - 1]))
| false | 38.095238 | [
"-def is_prime(N):",
"- if N == 1:",
"- return False",
"- for k in range(2, int(N**0.5) + 1):",
"- if N % k == 0:",
"- return False",
"- return True",
"+import bisect",
"+",
"+",
"+def make_divisors(N):",
"+ divisors = []",
"+ for i in range(1, int(N**0.5) + 1):",
"+ if N % i == 0:",
"+ divisors.append(i)",
"+ if i != N // i:",
"+ divisors.append(N // i)",
"+ divisors.sort()",
"+ return divisors",
"-k = 0",
"-if N != 1:",
"- if is_prime(M):",
"- print((1))",
"- exit()",
"-while True:",
"- if M % (N + k) == 0:",
"- ans = M // (N + k)",
"- break",
"- k += 1",
"-print(ans)",
"+lst = make_divisors(M)",
"+print((lst[bisect.bisect_right(lst, M // N) - 1]))"
]
| false | 0.106012 | 0.037858 | 2.800243 | [
"s331062307",
"s541951234"
]
|
u467736898 | p02575 | python | s231234324 | s428222815 | 1,741 | 694 | 146,000 | 53,596 | Accepted | Accepted | 60.14 | H, W = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(H)]
A = W+1
identity = -(1<<62)
sqrtA = 500
n_buckets = A // sqrtA + 1
Data = [0] * (n_buckets * sqrtA)
Data[0] = 1<<30
Bucket_min = [0] * n_buckets
Lazy = [identity] * n_buckets
def eval_data(k):
if Lazy[k] != identity:
l, r = k*sqrtA, (k+1) * sqrtA
for i in range(l, r):
Data[i] = i-Lazy[k]
Lazy[k] = identity
def update(s, t, x):
for k in range(s//sqrtA, (t-1)//sqrtA+1):
l, r = k*sqrtA, (k+1)*sqrtA
if s <= l and r <= t:
Bucket_min[k] = l-x
Lazy[k] = x
else:
eval_data(k)
for i in range(max(l,s), min(r,t)):
Data[i] = i-x
Bucket_min[k] = min(Data[l:r])
def get_min(s, t):
res = 1 << 62
bl, br = s//sqrtA+1, t//sqrtA
if bl > br:
eval_data(br)
return min(Data[s:t])
if bl < br:
res = min(Bucket_min[bl:br])
ll, rr = bl*sqrtA, br*sqrtA
if s < ll:
eval_data(bl-1)
mi = min(Data[s:ll])
if res > mi:
res = mi
if rr < t:
eval_data(br)
mi = min(Data[rr:t])
if res > mi:
res = mi
return res
Ans = []
for i, (a, b) in enumerate(AB, 1):
update(a, b+1, a-1-get_min(a-1, a))
ans = get_min(1, W+1)
Ans.append(ans + i if ans < 1<<25 else -1)
print(("\n".join(map(str, Ans))))
| def numba_compile(numba_config):
import os, sys
if sys.argv[-1] == "ONLINE_JUDGE":
from numba import njit
from numba.pycc import CC
cc = CC("my_module")
for func, signature in numba_config:
globals()[func.__name__] = njit(signature)(func)
cc.export(func.__name__, signature)(func)
cc.compile()
exit()
elif os.name == "posix":
exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
for func, _ in numba_config:
globals()[func.__name__] = vars()[func.__name__]
else:
from numba import njit
for func, signature in numba_config:
globals()[func.__name__] = njit(signature, cache=True)(func)
print("compiled!", file=sys.stderr)
import sys
import numpy as np
def solve(H, W, AB):
A = W+1
identity = -(1<<62)
sqrtA = 500
n_buckets = A // sqrtA + 1
Data = np.zeros(n_buckets * sqrtA, dtype=np.int64)
Data[0] = 1<<30
Bucket_min = np.zeros(n_buckets, dtype=np.int64)
Lazy = np.full(n_buckets, identity, dtype=np.int64)
def eval_data(k):
if Lazy[k] != identity:
l, r = k*sqrtA, (k+1) * sqrtA
for i in range(l, r):
Data[i] = i-Lazy[k]
Lazy[k] = identity
def update(s, t, x):
for k in range(s//sqrtA, (t-1)//sqrtA+1):
l, r = k*sqrtA, (k+1)*sqrtA
if s <= l and r <= t:
Bucket_min[k] = l-x
Lazy[k] = x
else:
eval_data(k)
for i in range(max(l,s), min(r,t)):
Data[i] = i-x
Bucket_min[k] = Data[l:r].min()
def get_min(s, t):
res = 1 << 62
bl, br = s//sqrtA+1, t//sqrtA
if bl > br:
eval_data(br)
return Data[s:t].min()
if bl < br:
res = Bucket_min[bl:br].min()
ll, rr = bl*sqrtA, br*sqrtA
if s < ll:
eval_data(bl-1)
mi = Data[s:ll].min()
if res > mi:
res = mi
if rr < t:
eval_data(br)
mi = Data[rr:t].min()
if res > mi:
res = mi
return res
Ans = np.zeros(H, dtype=np.int64)
for i in range(H):
a, b = AB[i]
update(a, b+1, a-1-get_min(a-1, a))
ans = get_min(1, W+1)
Ans[i] = ans+i+1 if ans < 1<<25 else -1
return Ans
numba_compile([
[solve, "i8[:](i8,i8,i8[:,:])"]
])
def main():
H, W = map(int, sys.stdin.buffer.readline().split())
AB = np.array(sys.stdin.buffer.read().split(), dtype=np.int64).reshape(H, 2)
Ans = solve(H, W, AB)
print("\n".join(map(str, Ans.tolist())))
main()
| 58 | 94 | 1,495 | 2,859 | H, W = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(H)]
A = W + 1
identity = -(1 << 62)
sqrtA = 500
n_buckets = A // sqrtA + 1
Data = [0] * (n_buckets * sqrtA)
Data[0] = 1 << 30
Bucket_min = [0] * n_buckets
Lazy = [identity] * n_buckets
def eval_data(k):
if Lazy[k] != identity:
l, r = k * sqrtA, (k + 1) * sqrtA
for i in range(l, r):
Data[i] = i - Lazy[k]
Lazy[k] = identity
def update(s, t, x):
for k in range(s // sqrtA, (t - 1) // sqrtA + 1):
l, r = k * sqrtA, (k + 1) * sqrtA
if s <= l and r <= t:
Bucket_min[k] = l - x
Lazy[k] = x
else:
eval_data(k)
for i in range(max(l, s), min(r, t)):
Data[i] = i - x
Bucket_min[k] = min(Data[l:r])
def get_min(s, t):
res = 1 << 62
bl, br = s // sqrtA + 1, t // sqrtA
if bl > br:
eval_data(br)
return min(Data[s:t])
if bl < br:
res = min(Bucket_min[bl:br])
ll, rr = bl * sqrtA, br * sqrtA
if s < ll:
eval_data(bl - 1)
mi = min(Data[s:ll])
if res > mi:
res = mi
if rr < t:
eval_data(br)
mi = min(Data[rr:t])
if res > mi:
res = mi
return res
Ans = []
for i, (a, b) in enumerate(AB, 1):
update(a, b + 1, a - 1 - get_min(a - 1, a))
ans = get_min(1, W + 1)
Ans.append(ans + i if ans < 1 << 25 else -1)
print(("\n".join(map(str, Ans))))
| def numba_compile(numba_config):
import os, sys
if sys.argv[-1] == "ONLINE_JUDGE":
from numba import njit
from numba.pycc import CC
cc = CC("my_module")
for func, signature in numba_config:
globals()[func.__name__] = njit(signature)(func)
cc.export(func.__name__, signature)(func)
cc.compile()
exit()
elif os.name == "posix":
exec(
f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}"
)
for func, _ in numba_config:
globals()[func.__name__] = vars()[func.__name__]
else:
from numba import njit
for func, signature in numba_config:
globals()[func.__name__] = njit(signature, cache=True)(func)
print("compiled!", file=sys.stderr)
import sys
import numpy as np
def solve(H, W, AB):
A = W + 1
identity = -(1 << 62)
sqrtA = 500
n_buckets = A // sqrtA + 1
Data = np.zeros(n_buckets * sqrtA, dtype=np.int64)
Data[0] = 1 << 30
Bucket_min = np.zeros(n_buckets, dtype=np.int64)
Lazy = np.full(n_buckets, identity, dtype=np.int64)
def eval_data(k):
if Lazy[k] != identity:
l, r = k * sqrtA, (k + 1) * sqrtA
for i in range(l, r):
Data[i] = i - Lazy[k]
Lazy[k] = identity
def update(s, t, x):
for k in range(s // sqrtA, (t - 1) // sqrtA + 1):
l, r = k * sqrtA, (k + 1) * sqrtA
if s <= l and r <= t:
Bucket_min[k] = l - x
Lazy[k] = x
else:
eval_data(k)
for i in range(max(l, s), min(r, t)):
Data[i] = i - x
Bucket_min[k] = Data[l:r].min()
def get_min(s, t):
res = 1 << 62
bl, br = s // sqrtA + 1, t // sqrtA
if bl > br:
eval_data(br)
return Data[s:t].min()
if bl < br:
res = Bucket_min[bl:br].min()
ll, rr = bl * sqrtA, br * sqrtA
if s < ll:
eval_data(bl - 1)
mi = Data[s:ll].min()
if res > mi:
res = mi
if rr < t:
eval_data(br)
mi = Data[rr:t].min()
if res > mi:
res = mi
return res
Ans = np.zeros(H, dtype=np.int64)
for i in range(H):
a, b = AB[i]
update(a, b + 1, a - 1 - get_min(a - 1, a))
ans = get_min(1, W + 1)
Ans[i] = ans + i + 1 if ans < 1 << 25 else -1
return Ans
numba_compile([[solve, "i8[:](i8,i8,i8[:,:])"]])
def main():
H, W = map(int, sys.stdin.buffer.readline().split())
AB = np.array(sys.stdin.buffer.read().split(), dtype=np.int64).reshape(H, 2)
Ans = solve(H, W, AB)
print("\n".join(map(str, Ans.tolist())))
main()
| false | 38.297872 | [
"-H, W = list(map(int, input().split()))",
"-AB = [list(map(int, input().split())) for _ in range(H)]",
"-A = W + 1",
"-identity = -(1 << 62)",
"-sqrtA = 500",
"-n_buckets = A // sqrtA + 1",
"-Data = [0] * (n_buckets * sqrtA)",
"-Data[0] = 1 << 30",
"-Bucket_min = [0] * n_buckets",
"-Lazy = [identity] * n_buckets",
"+def numba_compile(numba_config):",
"+ import os, sys",
"+",
"+ if sys.argv[-1] == \"ONLINE_JUDGE\":",
"+ from numba import njit",
"+ from numba.pycc import CC",
"+",
"+ cc = CC(\"my_module\")",
"+ for func, signature in numba_config:",
"+ globals()[func.__name__] = njit(signature)(func)",
"+ cc.export(func.__name__, signature)(func)",
"+ cc.compile()",
"+ exit()",
"+ elif os.name == \"posix\":",
"+ exec(",
"+ f\"from my_module import {','.join(func.__name__ for func, _ in numba_config)}\"",
"+ )",
"+ for func, _ in numba_config:",
"+ globals()[func.__name__] = vars()[func.__name__]",
"+ else:",
"+ from numba import njit",
"+",
"+ for func, signature in numba_config:",
"+ globals()[func.__name__] = njit(signature, cache=True)(func)",
"+ print(\"compiled!\", file=sys.stderr)",
"-def eval_data(k):",
"- if Lazy[k] != identity:",
"- l, r = k * sqrtA, (k + 1) * sqrtA",
"- for i in range(l, r):",
"- Data[i] = i - Lazy[k]",
"- Lazy[k] = identity",
"+import sys",
"+import numpy as np",
"-def update(s, t, x):",
"- for k in range(s // sqrtA, (t - 1) // sqrtA + 1):",
"- l, r = k * sqrtA, (k + 1) * sqrtA",
"- if s <= l and r <= t:",
"- Bucket_min[k] = l - x",
"- Lazy[k] = x",
"- else:",
"- eval_data(k)",
"- for i in range(max(l, s), min(r, t)):",
"- Data[i] = i - x",
"- Bucket_min[k] = min(Data[l:r])",
"+def solve(H, W, AB):",
"+ A = W + 1",
"+ identity = -(1 << 62)",
"+ sqrtA = 500",
"+ n_buckets = A // sqrtA + 1",
"+ Data = np.zeros(n_buckets * sqrtA, dtype=np.int64)",
"+ Data[0] = 1 << 30",
"+ Bucket_min = np.zeros(n_buckets, dtype=np.int64)",
"+ Lazy = np.full(n_buckets, identity, dtype=np.int64)",
"+",
"+ def eval_data(k):",
"+ if Lazy[k] != identity:",
"+ l, r = k * sqrtA, (k + 1) * sqrtA",
"+ for i in range(l, r):",
"+ Data[i] = i - Lazy[k]",
"+ Lazy[k] = identity",
"+",
"+ def update(s, t, x):",
"+ for k in range(s // sqrtA, (t - 1) // sqrtA + 1):",
"+ l, r = k * sqrtA, (k + 1) * sqrtA",
"+ if s <= l and r <= t:",
"+ Bucket_min[k] = l - x",
"+ Lazy[k] = x",
"+ else:",
"+ eval_data(k)",
"+ for i in range(max(l, s), min(r, t)):",
"+ Data[i] = i - x",
"+ Bucket_min[k] = Data[l:r].min()",
"+",
"+ def get_min(s, t):",
"+ res = 1 << 62",
"+ bl, br = s // sqrtA + 1, t // sqrtA",
"+ if bl > br:",
"+ eval_data(br)",
"+ return Data[s:t].min()",
"+ if bl < br:",
"+ res = Bucket_min[bl:br].min()",
"+ ll, rr = bl * sqrtA, br * sqrtA",
"+ if s < ll:",
"+ eval_data(bl - 1)",
"+ mi = Data[s:ll].min()",
"+ if res > mi:",
"+ res = mi",
"+ if rr < t:",
"+ eval_data(br)",
"+ mi = Data[rr:t].min()",
"+ if res > mi:",
"+ res = mi",
"+ return res",
"+",
"+ Ans = np.zeros(H, dtype=np.int64)",
"+ for i in range(H):",
"+ a, b = AB[i]",
"+ update(a, b + 1, a - 1 - get_min(a - 1, a))",
"+ ans = get_min(1, W + 1)",
"+ Ans[i] = ans + i + 1 if ans < 1 << 25 else -1",
"+ return Ans",
"-def get_min(s, t):",
"- res = 1 << 62",
"- bl, br = s // sqrtA + 1, t // sqrtA",
"- if bl > br:",
"- eval_data(br)",
"- return min(Data[s:t])",
"- if bl < br:",
"- res = min(Bucket_min[bl:br])",
"- ll, rr = bl * sqrtA, br * sqrtA",
"- if s < ll:",
"- eval_data(bl - 1)",
"- mi = min(Data[s:ll])",
"- if res > mi:",
"- res = mi",
"- if rr < t:",
"- eval_data(br)",
"- mi = min(Data[rr:t])",
"- if res > mi:",
"- res = mi",
"- return res",
"+numba_compile([[solve, \"i8[:](i8,i8,i8[:,:])\"]])",
"-Ans = []",
"-for i, (a, b) in enumerate(AB, 1):",
"- update(a, b + 1, a - 1 - get_min(a - 1, a))",
"- ans = get_min(1, W + 1)",
"- Ans.append(ans + i if ans < 1 << 25 else -1)",
"-print((\"\\n\".join(map(str, Ans))))",
"+def main():",
"+ H, W = map(int, sys.stdin.buffer.readline().split())",
"+ AB = np.array(sys.stdin.buffer.read().split(), dtype=np.int64).reshape(H, 2)",
"+ Ans = solve(H, W, AB)",
"+ print(\"\\n\".join(map(str, Ans.tolist())))",
"+",
"+",
"+main()"
]
| false | 0.04417 | 0.27979 | 0.157867 | [
"s231234324",
"s428222815"
]
|
u646336881 | p02681 | python | s286859398 | s678710997 | 186 | 110 | 70,304 | 70,292 | Accepted | Accepted | 40.86 | #!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import itertools
import math
import sys
INF = float('inf')
YES = "Yes" # type: str
NO = "No" # type: str
def solve(S: str, T: str):
return [NO, YES][len(S)+1 == len(T) and S == T[:-1]]
def main():
sys.setrecursionlimit(10 ** 6)
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
S = next(tokens) # type: str
T = next(tokens) # type: str
print((solve(S, T)))
if __name__ == '__main__':
main()
| #!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import itertools
import math
import sys
INF = float('inf')
YES = "Yes" # type: str
NO = "No" # type: str
def solve(S: str, T: str):
return [NO, YES][S == T[:-1]]
def main():
sys.setrecursionlimit(10 ** 6)
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
S = next(tokens) # type: str
T = next(tokens) # type: str
print((solve(S, T)))
if __name__ == '__main__':
main()
| 32 | 32 | 665 | 642 | #!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import itertools
import math
import sys
INF = float("inf")
YES = "Yes" # type: str
NO = "No" # type: str
def solve(S: str, T: str):
return [NO, YES][len(S) + 1 == len(T) and S == T[:-1]]
def main():
sys.setrecursionlimit(10**6)
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
S = next(tokens) # type: str
T = next(tokens) # type: str
print((solve(S, T)))
if __name__ == "__main__":
main()
| #!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import itertools
import math
import sys
INF = float("inf")
YES = "Yes" # type: str
NO = "No" # type: str
def solve(S: str, T: str):
return [NO, YES][S == T[:-1]]
def main():
sys.setrecursionlimit(10**6)
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
S = next(tokens) # type: str
T = next(tokens) # type: str
print((solve(S, T)))
if __name__ == "__main__":
main()
| false | 0 | [
"- return [NO, YES][len(S) + 1 == len(T) and S == T[:-1]]",
"+ return [NO, YES][S == T[:-1]]"
]
| false | 0.038336 | 0.038769 | 0.98883 | [
"s286859398",
"s678710997"
]
|
u260980560 | p01101 | python | s894927988 | s079791112 | 1,350 | 50 | 7,680 | 7,764 | Accepted | Accepted | 96.3 | while 1:
n, m = list(map(int, input().split()))
if n == m == 0:
break
*A,=list(map(int, input().split()))
s=0
for i in range(n):
for j in range(i):
if s<A[i]+A[j]<=m:
s = A[i]+A[j]
print((s or"NONE")) | while 1:
n, m = list(map(int, input().split()))
if n == m == 0:
break
A=sorted(map(int, input().split()))
def f():
j = n-1
yield 0
for i in range(n):
while j >= 0 and m < A[i]+A[j]:
j -= 1
if j <= i:
break
if j >= 0:
yield A[i]+A[j]
print((max(f()) or"NONE")) | 11 | 16 | 264 | 402 | while 1:
n, m = list(map(int, input().split()))
if n == m == 0:
break
(*A,) = list(map(int, input().split()))
s = 0
for i in range(n):
for j in range(i):
if s < A[i] + A[j] <= m:
s = A[i] + A[j]
print((s or "NONE"))
| while 1:
n, m = list(map(int, input().split()))
if n == m == 0:
break
A = sorted(map(int, input().split()))
def f():
j = n - 1
yield 0
for i in range(n):
while j >= 0 and m < A[i] + A[j]:
j -= 1
if j <= i:
break
if j >= 0:
yield A[i] + A[j]
print((max(f()) or "NONE"))
| false | 31.25 | [
"- (*A,) = list(map(int, input().split()))",
"- s = 0",
"- for i in range(n):",
"- for j in range(i):",
"- if s < A[i] + A[j] <= m:",
"- s = A[i] + A[j]",
"- print((s or \"NONE\"))",
"+ A = sorted(map(int, input().split()))",
"+",
"+ def f():",
"+ j = n - 1",
"+ yield 0",
"+ for i in range(n):",
"+ while j >= 0 and m < A[i] + A[j]:",
"+ j -= 1",
"+ if j <= i:",
"+ break",
"+ if j >= 0:",
"+ yield A[i] + A[j]",
"+",
"+ print((max(f()) or \"NONE\"))"
]
| false | 0.145925 | 0.036759 | 3.969825 | [
"s894927988",
"s079791112"
]
|
u968404618 | p02619 | python | s405511903 | s471529054 | 38 | 32 | 9,268 | 9,324 | Accepted | Accepted | 15.79 | D = int(eval(input()))
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
T = [int(eval(input()))-1 for _ in range(D)]
last = [0] * 26
score = 0
for d in range(D):
v = T[d]
score += S[d][v]
for i in range(26):
if i == v:
last[i] = 0
else:
last[i] += 1
score -= C[i] * last[i]
print(score) | d = int(eval(input()))
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(d)]
T = [int(eval(input())) for _ in range(d)]
last = [0] * 26
score = 0
for i, (s, t) in enumerate(zip(S, T), 1):
score += s[t-1]
last[t-1] = i
for j in range(26):
score -= C[j] * (i - last[j])
print(score)
| 17 | 15 | 398 | 351 | D = int(eval(input()))
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
T = [int(eval(input())) - 1 for _ in range(D)]
last = [0] * 26
score = 0
for d in range(D):
v = T[d]
score += S[d][v]
for i in range(26):
if i == v:
last[i] = 0
else:
last[i] += 1
score -= C[i] * last[i]
print(score)
| d = int(eval(input()))
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(d)]
T = [int(eval(input())) for _ in range(d)]
last = [0] * 26
score = 0
for i, (s, t) in enumerate(zip(S, T), 1):
score += s[t - 1]
last[t - 1] = i
for j in range(26):
score -= C[j] * (i - last[j])
print(score)
| false | 11.764706 | [
"-D = int(eval(input()))",
"+d = int(eval(input()))",
"-S = [list(map(int, input().split())) for _ in range(D)]",
"-T = [int(eval(input())) - 1 for _ in range(D)]",
"+S = [list(map(int, input().split())) for _ in range(d)]",
"+T = [int(eval(input())) for _ in range(d)]",
"-for d in range(D):",
"- v = T[d]",
"- score += S[d][v]",
"- for i in range(26):",
"- if i == v:",
"- last[i] = 0",
"- else:",
"- last[i] += 1",
"- score -= C[i] * last[i]",
"+for i, (s, t) in enumerate(zip(S, T), 1):",
"+ score += s[t - 1]",
"+ last[t - 1] = i",
"+ for j in range(26):",
"+ score -= C[j] * (i - last[j])"
]
| false | 0.070996 | 0.105378 | 0.673726 | [
"s405511903",
"s471529054"
]
|
u489762173 | p02995 | python | s459583966 | s065397916 | 41 | 17 | 5,372 | 3,064 | Accepted | Accepted | 58.54 | import sys
input = sys.stdin.readline
import fractions
def main():
A, B, C, D = list(map(int, input().split()))
Aone = A - 1
CDlcm = int(C / fractions.gcd(C, D) * D)
Bc = B // C
Bd = B // D
Blcm = B // CDlcm
Bdec = B - Bc - Bd + Blcm
# print(Bc,Bd,Blcm)
Ac = Aone // C
Ad = Aone // D
Alcm = Aone // CDlcm
Adec = Aone - Ac - Ad + Alcm
# print(Ac,Ad,Alcm)
print((Bdec - Adec))
main() | import sys
def gcd(a, b):
if a < b:
a, b = b, a
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // (gcd(a, b))
def main():
A, B, C, D = list(map(int, input().split()))
Aone = A - 1
CDlcm = lcm(C, D)
Bc = B // C
Bd = B // D
Blcm = B // CDlcm
Bdec = B - Bc - Bd + Blcm
# print(Bc,Bd,Blcm)
Ac = Aone // C
Ad = Aone // D
Alcm = Aone // CDlcm
Adec = Aone - Ac - Ad + Alcm
# print(Ac,Ad,Alcm)
print((Bdec - Adec))
main() | 28 | 39 | 464 | 572 | import sys
input = sys.stdin.readline
import fractions
def main():
A, B, C, D = list(map(int, input().split()))
Aone = A - 1
CDlcm = int(C / fractions.gcd(C, D) * D)
Bc = B // C
Bd = B // D
Blcm = B // CDlcm
Bdec = B - Bc - Bd + Blcm
# print(Bc,Bd,Blcm)
Ac = Aone // C
Ad = Aone // D
Alcm = Aone // CDlcm
Adec = Aone - Ac - Ad + Alcm
# print(Ac,Ad,Alcm)
print((Bdec - Adec))
main()
| import sys
def gcd(a, b):
if a < b:
a, b = b, a
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // (gcd(a, b))
def main():
A, B, C, D = list(map(int, input().split()))
Aone = A - 1
CDlcm = lcm(C, D)
Bc = B // C
Bd = B // D
Blcm = B // CDlcm
Bdec = B - Bc - Bd + Blcm
# print(Bc,Bd,Blcm)
Ac = Aone // C
Ad = Aone // D
Alcm = Aone // CDlcm
Adec = Aone - Ac - Ad + Alcm
# print(Ac,Ad,Alcm)
print((Bdec - Adec))
main()
| false | 28.205128 | [
"-input = sys.stdin.readline",
"-import fractions",
"+",
"+def gcd(a, b):",
"+ if a < b:",
"+ a, b = b, a",
"+ while b:",
"+ a, b = b, a % b",
"+ return a",
"+",
"+",
"+def lcm(a, b):",
"+ return a * b // (gcd(a, b))",
"- CDlcm = int(C / fractions.gcd(C, D) * D)",
"+ CDlcm = lcm(C, D)"
]
| false | 0.045016 | 0.03384 | 1.330287 | [
"s459583966",
"s065397916"
]
|
u852690916 | p02777 | python | s916171576 | s987447471 | 180 | 17 | 38,384 | 3,060 | Accepted | Accepted | 90.56 | S,T=input().split()
A,B=list(map(int, input().split()))
U=eval(input())
if S==U:
print((A-1,B))
else:
print((A,B-1)) | S,T=input().split()
A,B=list(map(int, input().split()))
U=eval(input())
A-=1 if S==U else 0
B-=1 if T==U else 0
print((A,B)) | 8 | 6 | 116 | 115 | S, T = input().split()
A, B = list(map(int, input().split()))
U = eval(input())
if S == U:
print((A - 1, B))
else:
print((A, B - 1))
| S, T = input().split()
A, B = list(map(int, input().split()))
U = eval(input())
A -= 1 if S == U else 0
B -= 1 if T == U else 0
print((A, B))
| false | 25 | [
"-if S == U:",
"- print((A - 1, B))",
"-else:",
"- print((A, B - 1))",
"+A -= 1 if S == U else 0",
"+B -= 1 if T == U else 0",
"+print((A, B))"
]
| false | 0.112096 | 0.035394 | 3.167082 | [
"s916171576",
"s987447471"
]
|
u480138356 | p03283 | python | s189737861 | s744859742 | 2,498 | 1,333 | 15,064 | 15,256 | Accepted | Accepted | 46.64 | # import sys
import numpy as np
# input = sys.stdin.readline
def main():
N, M, Q = list(map(int, input().split()))
check = np.zeros((N+1, N+1))
for i in range(M):
l, r = list(map(int, input().split()))
check[r][l] += 1
# print(check)
for i in range(1, N+1):
check[i] += check[i-1]
for i in range(1, N+1):
check[:,i] += check[:,i-1]
# print(check)
for i in range(Q):
p, q = list(map(int, input().split()))
print((int(check[q][q] - check[q][p-1] - check[p-1][q] + check[p-1][p-1])))
if __name__ == "__main__":
main()
| import sys
import numpy as np
input = sys.stdin.readline
def main():
N, M, Q = list(map(int, input().split()))
check = np.zeros((N+1, N+1))
for i in range(M):
l, r = list(map(int, input().split()))
check[r][l] += 1
# print(check)
for i in range(1, N+1):
check[i] += check[i-1]
for i in range(1, N+1):
check[:,i] += check[:,i-1]
# print(check)
for i in range(Q):
p, q = list(map(int, input().split()))
print((int(check[q][q] - check[q][p-1] - check[p-1][q] + check[p-1][p-1])))
if __name__ == "__main__":
main()
| 26 | 26 | 610 | 606 | # import sys
import numpy as np
# input = sys.stdin.readline
def main():
N, M, Q = list(map(int, input().split()))
check = np.zeros((N + 1, N + 1))
for i in range(M):
l, r = list(map(int, input().split()))
check[r][l] += 1
# print(check)
for i in range(1, N + 1):
check[i] += check[i - 1]
for i in range(1, N + 1):
check[:, i] += check[:, i - 1]
# print(check)
for i in range(Q):
p, q = list(map(int, input().split()))
print(
(int(check[q][q] - check[q][p - 1] - check[p - 1][q] + check[p - 1][p - 1]))
)
if __name__ == "__main__":
main()
| import sys
import numpy as np
input = sys.stdin.readline
def main():
N, M, Q = list(map(int, input().split()))
check = np.zeros((N + 1, N + 1))
for i in range(M):
l, r = list(map(int, input().split()))
check[r][l] += 1
# print(check)
for i in range(1, N + 1):
check[i] += check[i - 1]
for i in range(1, N + 1):
check[:, i] += check[:, i - 1]
# print(check)
for i in range(Q):
p, q = list(map(int, input().split()))
print(
(int(check[q][q] - check[q][p - 1] - check[p - 1][q] + check[p - 1][p - 1]))
)
if __name__ == "__main__":
main()
| false | 0 | [
"-# import sys",
"+import sys",
"-# input = sys.stdin.readline",
"+input = sys.stdin.readline",
"+",
"+"
]
| false | 0.279296 | 1.113632 | 0.250798 | [
"s189737861",
"s744859742"
]
|
u116038906 | p02780 | python | s915508625 | s955976052 | 201 | 163 | 29,764 | 32,640 | Accepted | Accepted | 18.91 | # 初期入力
N,K = (int(x) for x in input().split(" "))
A = list(map(int, input().split()))
# 1からnまでの和 S_n = n*(n+1)/2 さいころの期待値は S_n /n
kitaiti = [ (i+1)/2 for i in A ]
# N個のサイコロの期待値の累積和 S
S = [0] * (N +1)
#S[0] = kitaiti[0]
#S =[0]
# S[0] = 0
for i in range(1,N +1):
S[i] = S[i-1] + kitaiti[i-1]
# 隣接するK個の期待値の和 S_K
S_K = []
for i,v in enumerate(S[:(-1)*K ]):
S_K.append( S[i + K ] - S[i] )
"""
print(kitaiti)
print(S)
print(S_K)
"""
print((max(S_K))) | # 初期入力
#import numpy as np
import sys
input = sys.stdin.readline
N,K = (int(i) for i in input().split())
p = list(map(int, input().split()))
expected_value =[(i+1)/2 for i in p] #各さいころの期待値
#隣接する数列の和
adjacent_sum =[0]*N
adjacent_sum[0] =sum(expected_value[:K])
ans =[0]*N
ans[0] =adjacent_sum[0]
for i in range(1,N-K+1):
adjacent_sum[i] =adjacent_sum[i-1] -expected_value[i-1] +expected_value[i+K-1]
ans[i] =adjacent_sum[i]
print((max(ans))) | 25 | 18 | 478 | 466 | # 初期入力
N, K = (int(x) for x in input().split(" "))
A = list(map(int, input().split()))
# 1からnまでの和 S_n = n*(n+1)/2 さいころの期待値は S_n /n
kitaiti = [(i + 1) / 2 for i in A]
# N個のサイコロの期待値の累積和 S
S = [0] * (N + 1)
# S[0] = kitaiti[0]
# S =[0]
# S[0] = 0
for i in range(1, N + 1):
S[i] = S[i - 1] + kitaiti[i - 1]
# 隣接するK個の期待値の和 S_K
S_K = []
for i, v in enumerate(S[: (-1) * K]):
S_K.append(S[i + K] - S[i])
"""
print(kitaiti)
print(S)
print(S_K)
"""
print((max(S_K)))
| # 初期入力
# import numpy as np
import sys
input = sys.stdin.readline
N, K = (int(i) for i in input().split())
p = list(map(int, input().split()))
expected_value = [(i + 1) / 2 for i in p] # 各さいころの期待値
# 隣接する数列の和
adjacent_sum = [0] * N
adjacent_sum[0] = sum(expected_value[:K])
ans = [0] * N
ans[0] = adjacent_sum[0]
for i in range(1, N - K + 1):
adjacent_sum[i] = (
adjacent_sum[i - 1] - expected_value[i - 1] + expected_value[i + K - 1]
)
ans[i] = adjacent_sum[i]
print((max(ans)))
| false | 28 | [
"-N, K = (int(x) for x in input().split(\" \"))",
"-A = list(map(int, input().split()))",
"-# 1からnまでの和 S_n = n*(n+1)/2 さいころの期待値は S_n /n",
"-kitaiti = [(i + 1) / 2 for i in A]",
"-# N個のサイコロの期待値の累積和 S",
"-S = [0] * (N + 1)",
"-# S[0] = kitaiti[0]",
"-# S =[0]",
"-# S[0] = 0",
"-for i in range(1, N + 1):",
"- S[i] = S[i - 1] + kitaiti[i - 1]",
"-# 隣接するK個の期待値の和 S_K",
"-S_K = []",
"-for i, v in enumerate(S[: (-1) * K]):",
"- S_K.append(S[i + K] - S[i])",
"-\"\"\"",
"-print(kitaiti)",
"-print(S)",
"-print(S_K)",
"-\"\"\"",
"-print((max(S_K)))",
"+# import numpy as np",
"+import sys",
"+",
"+input = sys.stdin.readline",
"+N, K = (int(i) for i in input().split())",
"+p = list(map(int, input().split()))",
"+expected_value = [(i + 1) / 2 for i in p] # 各さいころの期待値",
"+# 隣接する数列の和",
"+adjacent_sum = [0] * N",
"+adjacent_sum[0] = sum(expected_value[:K])",
"+ans = [0] * N",
"+ans[0] = adjacent_sum[0]",
"+for i in range(1, N - K + 1):",
"+ adjacent_sum[i] = (",
"+ adjacent_sum[i - 1] - expected_value[i - 1] + expected_value[i + K - 1]",
"+ )",
"+ ans[i] = adjacent_sum[i]",
"+print((max(ans)))"
]
| false | 0.11714 | 0.113128 | 1.035463 | [
"s915508625",
"s955976052"
]
|
u960080897 | p02579 | python | s131859250 | s712541213 | 835 | 770 | 119,912 | 108,676 | Accepted | Accepted | 7.78 | # Date [ 2020-08-22 21:07:07 ]
# Problem [ d.py ]
# Author Koki_tkg
import sys; from decimal import Decimal
import math; from itertools import combinations, product
import bisect; from collections import Counter, deque, defaultdict
# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846
def read_str(): return sys.stdin.readline().strip()
def read_int(): return int(sys.stdin.readline().strip())
def read_ints(): return list(map(int, sys.stdin.readline().strip().split()))
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)
import numpy as np
from numba import i8, njit, u1, b1
from heapq import heappop, heappush
@njit(i8(b1[:,:], i8, i8, i8, i8), cache=True)
def solve(grid, ch, cw, dh, dw):
h, w = grid.shape
dist = np.full((h, w), INF, dtype=np.int64)
dist[ch][cw] = 0
que = [(0, ch, cw)]
while que:
cnt, y, x = heappop(que)
if y == dh and x == dw:
break
for dy in range(-2, 3):
for dx in range(-2, 3):
if dx == 0 and dy == 0:
continue
if abs(dx) == 2 or abs(dy) == 2 or (abs(dx) == 1 and abs(dy) == 1):
warp = 1
else:
warp = 0
nx, ny = x + dx, y + dy
if nx < 0 or nx >= w or ny < 0 or ny >= h or grid[ny][nx]:
continue
if dist[ny][nx] > cnt + warp:
dist[ny][nx] = cnt + warp
heappush(que, (cnt + warp, ny, nx))
if dist[dh][dw] == INF:
return - 1
else:
return dist[dh][dw]
def Main():
H, W = read_ints()
ch, cw = read_ints(); ch -= 1; cw -= 1
dh, dw = read_ints(); dh -= 1; dw -= 1
grid = np.array([[g == '#' for g in read_str()] for _ in range(H)])
print((solve(grid, ch, cw, dh, dw)))
def cc_export(config):
from numba.pycc import CC
cc = CC('my_module')
for func, signature in config:
vars()[func.__name__] = njit(signature)(func)
cc.export(func.__name__, signature)(func)
cc.compile()
if __name__ == '__main__':
Main()
| # Date [ 2020-08-22 21:07:07 ]
# Problem [ d.py ]
# Author Koki_tkg
import sys; from decimal import Decimal
import math; from itertools import combinations, product
import bisect; from collections import Counter, deque, defaultdict
# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846
def read_str(): return sys.stdin.readline().strip()
def read_int(): return int(sys.stdin.readline().strip())
def read_ints(): return list(map(int, sys.stdin.readline().strip().split()))
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)
import numpy as np
from numba import i8, njit, u1, b1
from heapq import heappop, heappush
#@njit(i8(b1[:,:], i8, i8, i8, i8), cache=True)
def solve(grid, ch, cw, dh, dw):
h, w = grid.shape
dist = np.full((h, w), INF, dtype=np.int64)
dist[ch][cw] = 0
que = [(0, ch, cw)]
while que:
cnt, y, x = heappop(que)
if y == dh and x == dw:
break
for dy in range(-2, 3):
for dx in range(-2, 3):
if dx == 0 and dy == 0:
continue
if abs(dx) == 2 or abs(dy) == 2 or (abs(dx) == 1 and abs(dy) == 1):
warp = 1
else:
warp = 0
nx, ny = x + dx, y + dy
if nx < 0 or nx >= w or ny < 0 or ny >= h or grid[ny][nx]:
continue
if dist[ny][nx] > cnt + warp:
dist[ny][nx] = cnt + warp
heappush(que, (cnt + warp, ny, nx))
if dist[dh][dw] == INF:
return - 1
else:
return dist[dh][dw]
def Main():
H, W = read_ints()
ch, cw = read_ints(); ch -= 1; cw -= 1
dh, dw = read_ints(); dh -= 1; dw -= 1
grid = np.array([[g == '#' for g in read_str()] for _ in range(H)])
print((solve(grid, ch, cw, dh, dw)))
def cc_export():
from numba.pycc import CC
cc = CC('my_module')
cc.export('solve','(b1[:,:], i8, i8, i8, i8,)')(solve)
cc.compile()
if __name__ == '__main__':
if sys.argv[-1] == 'ONLINE_JUDGE':
cc_export()
exit()
from my_module import solve
Main()
| 82 | 84 | 2,437 | 2,460 | # Date [ 2020-08-22 21:07:07 ]
# Problem [ d.py ]
# Author Koki_tkg
import sys
from decimal import Decimal
import math
from itertools import combinations, product
import bisect
from collections import Counter, deque, defaultdict
# sys.setrecursionlimit(10 ** 6)
MOD = 10**9 + 7
INF = 10**9
PI = 3.14159265358979323846
def read_str():
return sys.stdin.readline().strip()
def read_int():
return int(sys.stdin.readline().strip())
def read_ints():
return list(map(int, sys.stdin.readline().strip().split()))
def read_str_list():
return list(sys.stdin.readline().strip().split())
def read_int_list():
return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int:
return (a * b) // math.gcd(a, b)
import numpy as np
from numba import i8, njit, u1, b1
from heapq import heappop, heappush
@njit(i8(b1[:, :], i8, i8, i8, i8), cache=True)
def solve(grid, ch, cw, dh, dw):
h, w = grid.shape
dist = np.full((h, w), INF, dtype=np.int64)
dist[ch][cw] = 0
que = [(0, ch, cw)]
while que:
cnt, y, x = heappop(que)
if y == dh and x == dw:
break
for dy in range(-2, 3):
for dx in range(-2, 3):
if dx == 0 and dy == 0:
continue
if abs(dx) == 2 or abs(dy) == 2 or (abs(dx) == 1 and abs(dy) == 1):
warp = 1
else:
warp = 0
nx, ny = x + dx, y + dy
if nx < 0 or nx >= w or ny < 0 or ny >= h or grid[ny][nx]:
continue
if dist[ny][nx] > cnt + warp:
dist[ny][nx] = cnt + warp
heappush(que, (cnt + warp, ny, nx))
if dist[dh][dw] == INF:
return -1
else:
return dist[dh][dw]
def Main():
H, W = read_ints()
ch, cw = read_ints()
ch -= 1
cw -= 1
dh, dw = read_ints()
dh -= 1
dw -= 1
grid = np.array([[g == "#" for g in read_str()] for _ in range(H)])
print((solve(grid, ch, cw, dh, dw)))
def cc_export(config):
from numba.pycc import CC
cc = CC("my_module")
for func, signature in config:
vars()[func.__name__] = njit(signature)(func)
cc.export(func.__name__, signature)(func)
cc.compile()
if __name__ == "__main__":
Main()
| # Date [ 2020-08-22 21:07:07 ]
# Problem [ d.py ]
# Author Koki_tkg
import sys
from decimal import Decimal
import math
from itertools import combinations, product
import bisect
from collections import Counter, deque, defaultdict
# sys.setrecursionlimit(10 ** 6)
MOD = 10**9 + 7
INF = 10**9
PI = 3.14159265358979323846
def read_str():
return sys.stdin.readline().strip()
def read_int():
return int(sys.stdin.readline().strip())
def read_ints():
return list(map(int, sys.stdin.readline().strip().split()))
def read_str_list():
return list(sys.stdin.readline().strip().split())
def read_int_list():
return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int:
return (a * b) // math.gcd(a, b)
import numpy as np
from numba import i8, njit, u1, b1
from heapq import heappop, heappush
# @njit(i8(b1[:,:], i8, i8, i8, i8), cache=True)
def solve(grid, ch, cw, dh, dw):
h, w = grid.shape
dist = np.full((h, w), INF, dtype=np.int64)
dist[ch][cw] = 0
que = [(0, ch, cw)]
while que:
cnt, y, x = heappop(que)
if y == dh and x == dw:
break
for dy in range(-2, 3):
for dx in range(-2, 3):
if dx == 0 and dy == 0:
continue
if abs(dx) == 2 or abs(dy) == 2 or (abs(dx) == 1 and abs(dy) == 1):
warp = 1
else:
warp = 0
nx, ny = x + dx, y + dy
if nx < 0 or nx >= w or ny < 0 or ny >= h or grid[ny][nx]:
continue
if dist[ny][nx] > cnt + warp:
dist[ny][nx] = cnt + warp
heappush(que, (cnt + warp, ny, nx))
if dist[dh][dw] == INF:
return -1
else:
return dist[dh][dw]
def Main():
H, W = read_ints()
ch, cw = read_ints()
ch -= 1
cw -= 1
dh, dw = read_ints()
dh -= 1
dw -= 1
grid = np.array([[g == "#" for g in read_str()] for _ in range(H)])
print((solve(grid, ch, cw, dh, dw)))
def cc_export():
from numba.pycc import CC
cc = CC("my_module")
cc.export("solve", "(b1[:,:], i8, i8, i8, i8,)")(solve)
cc.compile()
if __name__ == "__main__":
if sys.argv[-1] == "ONLINE_JUDGE":
cc_export()
exit()
from my_module import solve
Main()
| false | 2.380952 | [
"-",
"-@njit(i8(b1[:, :], i8, i8, i8, i8), cache=True)",
"+# @njit(i8(b1[:,:], i8, i8, i8, i8), cache=True)",
"-def cc_export(config):",
"+def cc_export():",
"- for func, signature in config:",
"- vars()[func.__name__] = njit(signature)(func)",
"- cc.export(func.__name__, signature)(func)",
"+ cc.export(\"solve\", \"(b1[:,:], i8, i8, i8, i8,)\")(solve)",
"+ if sys.argv[-1] == \"ONLINE_JUDGE\":",
"+ cc_export()",
"+ exit()",
"+ from my_module import solve",
"+"
]
| false | 0.263099 | 0.313068 | 0.840391 | [
"s131859250",
"s712541213"
]
|
u266874640 | p02831 | python | s770336809 | s291817977 | 53 | 35 | 5,560 | 5,048 | Accepted | Accepted | 33.96 | import fractions
A, B = list(map(int, input().split()))
print((A*B // fractions.gcd(A, B))) | import fractions
A, B = list(map(int,input().split()))
def lcm(A,B):
return (A*B) // fractions.gcd(A,B)
print((lcm(A,B)))
| 3 | 5 | 85 | 122 | import fractions
A, B = list(map(int, input().split()))
print((A * B // fractions.gcd(A, B)))
| import fractions
A, B = list(map(int, input().split()))
def lcm(A, B):
return (A * B) // fractions.gcd(A, B)
print((lcm(A, B)))
| false | 40 | [
"-print((A * B // fractions.gcd(A, B)))",
"+",
"+",
"+def lcm(A, B):",
"+ return (A * B) // fractions.gcd(A, B)",
"+",
"+",
"+print((lcm(A, B)))"
]
| false | 0.107555 | 0.108661 | 0.989822 | [
"s770336809",
"s291817977"
]
|
u814781830 | p02695 | python | s984331042 | s035750894 | 369 | 274 | 77,772 | 75,668 | Accepted | Accepted | 25.75 | N, M, Q = list(map(int, input().split()))
abcd = [list(map(int, input().split())) for _ in range(Q)]
def calc(p):
ret = 0
# 各条件を満たしていれば、dを加算していく
for a, b, c, d in abcd:
if p[b-1] - p[a-1] == c:
ret += d
return ret
ans = [0]
def dfs(s):
if len(s) == N:
ans[0] = max(ans[0], calc(s))
return
for i in range(s[-1],M+1):
dfs(s+[i])
for i in range(1, M+1):
dfs([i])
print((ans[0]))
| N, M, Q = list(map(int, input().split()))
abcd = [tuple(map(int, input().split())) for _ in range(Q)]
ans = 0
def calc(p):
ret = 0
for a, b, c, d in abcd:
a, b = a-1, b-1
if p[b] - p[a] == c:
ret += d
return ret
def dfs(a, d):
global ans
if d == N:
ans = max(ans, calc(a))
return
for i in range(a[-1], M+1):
dfs(a+[i], d+1)
for i in range(1, M+1):
dfs([i], 1)
print(ans)
| 24 | 23 | 468 | 470 | N, M, Q = list(map(int, input().split()))
abcd = [list(map(int, input().split())) for _ in range(Q)]
def calc(p):
ret = 0
# 各条件を満たしていれば、dを加算していく
for a, b, c, d in abcd:
if p[b - 1] - p[a - 1] == c:
ret += d
return ret
ans = [0]
def dfs(s):
if len(s) == N:
ans[0] = max(ans[0], calc(s))
return
for i in range(s[-1], M + 1):
dfs(s + [i])
for i in range(1, M + 1):
dfs([i])
print((ans[0]))
| N, M, Q = list(map(int, input().split()))
abcd = [tuple(map(int, input().split())) for _ in range(Q)]
ans = 0
def calc(p):
ret = 0
for a, b, c, d in abcd:
a, b = a - 1, b - 1
if p[b] - p[a] == c:
ret += d
return ret
def dfs(a, d):
global ans
if d == N:
ans = max(ans, calc(a))
return
for i in range(a[-1], M + 1):
dfs(a + [i], d + 1)
for i in range(1, M + 1):
dfs([i], 1)
print(ans)
| false | 4.166667 | [
"-abcd = [list(map(int, input().split())) for _ in range(Q)]",
"+abcd = [tuple(map(int, input().split())) for _ in range(Q)]",
"+ans = 0",
"- # 各条件を満たしていれば、dを加算していく",
"- if p[b - 1] - p[a - 1] == c:",
"+ a, b = a - 1, b - 1",
"+ if p[b] - p[a] == c:",
"-ans = [0]",
"-",
"-",
"-def dfs(s):",
"- if len(s) == N:",
"- ans[0] = max(ans[0], calc(s))",
"+def dfs(a, d):",
"+ global ans",
"+ if d == N:",
"+ ans = max(ans, calc(a))",
"- for i in range(s[-1], M + 1):",
"- dfs(s + [i])",
"+ for i in range(a[-1], M + 1):",
"+ dfs(a + [i], d + 1)",
"- dfs([i])",
"-print((ans[0]))",
"+ dfs([i], 1)",
"+print(ans)"
]
| false | 0.007247 | 0.278487 | 0.026023 | [
"s984331042",
"s035750894"
]
|
u619144316 | p02803 | python | s641934359 | s745994701 | 643 | 27 | 3,444 | 3,444 | Accepted | Accepted | 95.8 | from collections import defaultdict,deque
H, W = list(map(int,input().split()))
MAP = []
for _ in range(H):
MAP.append(tuple(map(str,eval(input()))))
move = [[0,1],[0,-1],[1,0],[-1,0]]
MAX = 0
def bfs(s):
global MAX
stack = deque([])
stack.append(tuple(s))
depth =dict()
depth[tuple(s)] = 0
while stack:
v = stack.popleft()
for m in move:
a = tuple([v[0]+m[0], v[1] + m[1]])
if a[0] < H and a[0] >= 0 and a[1] < W and a[1] >= 0:
if MAP[a[0]][a[1]] == '.' and not a in depth:
stack.append(a)
depth[a] = depth[v] + 1
for d in list(depth.values()):
MAX = max(MAX,d)
for i in range(0,H):
for j in range(0,W):
if MAP[i][j] == '.':
bfs(tuple([i,j]))
print(MAX) | from collections import defaultdict,deque
H, W = list(map(int,input().split()))
MAP = []
for _ in range(H):
MAP.append(list(map(str,eval(input()))))
move = [[0,1],[0,-1],[1,0],[-1,0]]
def bfs(s):
MAX = 0
stack = deque([])
stack.append(tuple(s))
depth =dict()
depth[tuple(s)] = 0
goal = s
while stack:
v = stack.popleft()
for m in move:
a = tuple([v[0]+m[0], v[1] + m[1]])
if a[0] < H and a[0] >= 0 and a[1] < W and a[1] >= 0:
if MAP[a[0]][a[1]] == '.' and not a in depth:
stack.append(a)
depth[a] = depth[v] + 1
for k,d in list(depth.items()):
if MAX < d:
MAX = d
goal = k
return MAX, goal
for r in range(0,H):
if "." in MAP[r]:
start = [r, MAP[r].index(".")]
MAX, goal = bfs(tuple(start))
MAX, _ = bfs(tuple(goal))
print(MAX)
exit()
| 33 | 40 | 835 | 943 | from collections import defaultdict, deque
H, W = list(map(int, input().split()))
MAP = []
for _ in range(H):
MAP.append(tuple(map(str, eval(input()))))
move = [[0, 1], [0, -1], [1, 0], [-1, 0]]
MAX = 0
def bfs(s):
global MAX
stack = deque([])
stack.append(tuple(s))
depth = dict()
depth[tuple(s)] = 0
while stack:
v = stack.popleft()
for m in move:
a = tuple([v[0] + m[0], v[1] + m[1]])
if a[0] < H and a[0] >= 0 and a[1] < W and a[1] >= 0:
if MAP[a[0]][a[1]] == "." and not a in depth:
stack.append(a)
depth[a] = depth[v] + 1
for d in list(depth.values()):
MAX = max(MAX, d)
for i in range(0, H):
for j in range(0, W):
if MAP[i][j] == ".":
bfs(tuple([i, j]))
print(MAX)
| from collections import defaultdict, deque
H, W = list(map(int, input().split()))
MAP = []
for _ in range(H):
MAP.append(list(map(str, eval(input()))))
move = [[0, 1], [0, -1], [1, 0], [-1, 0]]
def bfs(s):
MAX = 0
stack = deque([])
stack.append(tuple(s))
depth = dict()
depth[tuple(s)] = 0
goal = s
while stack:
v = stack.popleft()
for m in move:
a = tuple([v[0] + m[0], v[1] + m[1]])
if a[0] < H and a[0] >= 0 and a[1] < W and a[1] >= 0:
if MAP[a[0]][a[1]] == "." and not a in depth:
stack.append(a)
depth[a] = depth[v] + 1
for k, d in list(depth.items()):
if MAX < d:
MAX = d
goal = k
return MAX, goal
for r in range(0, H):
if "." in MAP[r]:
start = [r, MAP[r].index(".")]
MAX, goal = bfs(tuple(start))
MAX, _ = bfs(tuple(goal))
print(MAX)
exit()
| false | 17.5 | [
"- MAP.append(tuple(map(str, eval(input()))))",
"+ MAP.append(list(map(str, eval(input()))))",
"-MAX = 0",
"- global MAX",
"+ MAX = 0",
"+ goal = s",
"- for d in list(depth.values()):",
"- MAX = max(MAX, d)",
"+ for k, d in list(depth.items()):",
"+ if MAX < d:",
"+ MAX = d",
"+ goal = k",
"+ return MAX, goal",
"-for i in range(0, H):",
"- for j in range(0, W):",
"- if MAP[i][j] == \".\":",
"- bfs(tuple([i, j]))",
"+for r in range(0, H):",
"+ if \".\" in MAP[r]:",
"+ start = [r, MAP[r].index(\".\")]",
"+MAX, goal = bfs(tuple(start))",
"+MAX, _ = bfs(tuple(goal))",
"+exit()"
]
| false | 0.122699 | 0.035615 | 3.445129 | [
"s641934359",
"s745994701"
]
|
u802963389 | p03287 | python | s408447672 | s410423221 | 117 | 99 | 16,796 | 18,844 | Accepted | Accepted | 15.38 | from collections import defaultdict
n, m = list(map(int, input().split()))
A = list(map(int, input().split()))
accum = [0] * (n + 1)
for i in range(n):
accum[i + 1] = accum[i] + A[i]
box = defaultdict(int)
for i in accum:
box[i % m] += 1
ans = 0
for v in list(box.values()):
ans += v * (v - 1) // 2
print(ans) | # D - Candy Distribution
# https://atcoder.jp/contests/abc105/tasks/abc105_d
from collections import Counter
n, m = list(map(int, input().split()))
A = list(map(int, input().split()))
accr = [0] * (n + 1)
for i in range(n):
accr[i + 1] = accr[i] + A[i]
li = [i % m for i in accr]
C = Counter(li)
ans = 0
for v in list(C.values()):
if v > 1:
ans += v * (v - 1) // 2
print(ans)
| 20 | 23 | 335 | 402 | from collections import defaultdict
n, m = list(map(int, input().split()))
A = list(map(int, input().split()))
accum = [0] * (n + 1)
for i in range(n):
accum[i + 1] = accum[i] + A[i]
box = defaultdict(int)
for i in accum:
box[i % m] += 1
ans = 0
for v in list(box.values()):
ans += v * (v - 1) // 2
print(ans)
| # D - Candy Distribution
# https://atcoder.jp/contests/abc105/tasks/abc105_d
from collections import Counter
n, m = list(map(int, input().split()))
A = list(map(int, input().split()))
accr = [0] * (n + 1)
for i in range(n):
accr[i + 1] = accr[i] + A[i]
li = [i % m for i in accr]
C = Counter(li)
ans = 0
for v in list(C.values()):
if v > 1:
ans += v * (v - 1) // 2
print(ans)
| false | 13.043478 | [
"-from collections import defaultdict",
"+# D - Candy Distribution",
"+# https://atcoder.jp/contests/abc105/tasks/abc105_d",
"+from collections import Counter",
"-accum = [0] * (n + 1)",
"+accr = [0] * (n + 1)",
"- accum[i + 1] = accum[i] + A[i]",
"-box = defaultdict(int)",
"-for i in accum:",
"- box[i % m] += 1",
"+ accr[i + 1] = accr[i] + A[i]",
"+li = [i % m for i in accr]",
"+C = Counter(li)",
"-for v in list(box.values()):",
"- ans += v * (v - 1) // 2",
"+for v in list(C.values()):",
"+ if v > 1:",
"+ ans += v * (v - 1) // 2"
]
| false | 0.03438 | 0.053611 | 0.64129 | [
"s408447672",
"s410423221"
]
|
u088552457 | p03937 | python | s182413469 | s239975660 | 164 | 62 | 38,256 | 62,020 | Accepted | Accepted | 62.2 | import sys
input = sys.stdin.readline
import collections
def main():
h, w = input_list()
masu = []
c = 0
for _ in range(h):
c += input().count('#')
if h + w - 1 == c:
print('Possible')
else:
print('Impossible')
def input_list():
return list(map(int, input().split()))
def input_list_str():
return list(map(str, input().split()))
if __name__ == "__main__":
main()
| # import sys
# input = sys.stdin.readline
import itertools
# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
h, w = input_list()
count = 0
for _ in range(h):
s = list(eval(input()))
count += s.count('#')
if h+w-1 == count:
print('Possible')
else:
print('Impossible')
def input_list():
return list(map(int, input().split()))
def input_list_str():
return list(map(str, input().split()))
if __name__ == "__main__":
main()
| 25 | 28 | 453 | 533 | import sys
input = sys.stdin.readline
import collections
def main():
h, w = input_list()
masu = []
c = 0
for _ in range(h):
c += input().count("#")
if h + w - 1 == c:
print("Possible")
else:
print("Impossible")
def input_list():
return list(map(int, input().split()))
def input_list_str():
return list(map(str, input().split()))
if __name__ == "__main__":
main()
| # import sys
# input = sys.stdin.readline
import itertools
# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
h, w = input_list()
count = 0
for _ in range(h):
s = list(eval(input()))
count += s.count("#")
if h + w - 1 == count:
print("Possible")
else:
print("Impossible")
def input_list():
return list(map(int, input().split()))
def input_list_str():
return list(map(str, input().split()))
if __name__ == "__main__":
main()
| false | 10.714286 | [
"-import sys",
"+# import sys",
"+# input = sys.stdin.readline",
"+import itertools",
"-input = sys.stdin.readline",
"-import collections",
"-",
"-",
"+# 持っているビスケットを叩き、1枚増やす",
"+# ビスケット A枚を 1円に交換する",
"+# 1円をビスケット B枚に交換する",
"- masu = []",
"- c = 0",
"+ count = 0",
"- c += input().count(\"#\")",
"- if h + w - 1 == c:",
"+ s = list(eval(input()))",
"+ count += s.count(\"#\")",
"+ if h + w - 1 == count:"
]
| false | 0.042477 | 0.035695 | 1.189994 | [
"s182413469",
"s239975660"
]
|
u043048943 | p03078 | python | s851383304 | s851606142 | 491 | 380 | 105,176 | 57,820 | Accepted | Accepted | 22.61 | #coding:utf-8
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True
def main():
X,Y,Z,K = LMIIS()
A = LMIIS()
B = LMIIS()
C = LMIIS()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
ans = []
for ai in range(X):
for bi in range(Y):
if ai * bi > K:
break
for ci in range(Z):
if ai * bi * ci > K:
break
ans.append(A[ai]+B[bi]+C[ci])
ans.sort(reverse=True)
for i in range(K):
print(ans[i])
if __name__ == '__main__':
main()
| #coding:utf-8
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True
def main():
X,Y,Z,K = LMIIS()
A = LMIIS()
B = LMIIS()
C = LMIIS()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
from heapq import heappush,heappop
from collections import defaultdict
d = defaultdict(lambda:False)
h = []
ai = bi = ci = 0
heappush(h,(-(A[ai]+B[bi]+C[ci]),ai,bi,ci))
d[(0,0,0)] = True
for _ in range(K):
v,ai,bi,ci = heappop(h)
print(-v)
if ai+1 < X and d[(ai+1,bi,ci)] == False:
heappush(h,(-(A[ai+1]+B[bi]+C[ci]),ai+1,bi,ci))
d[(ai+1,bi,ci)] = True
if bi+1 < Y and d[(ai,bi+1,ci)] == False:
heappush(h,(-(A[ai]+B[bi+1]+C[ci]),ai,bi+1,ci))
d[(ai,bi+1,ci)] = True
if ci+1 < Z and d[(ai,bi,ci+1)] == False:
heappush(h,(-(A[ai]+B[bi]+C[ci+1]),ai,bi,ci+1))
d[(ai,bi,ci+1)] = True
if __name__ == '__main__':
main()
| 40 | 46 | 862 | 1,246 | # coding:utf-8
import sys
sys.setrecursionlimit(2**31 - 1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda: list(map(int, input().split()))
II = lambda: int(input())
dbg = lambda *something: print(*something) if DEBUG is True else 0
DEBUG = True
def main():
X, Y, Z, K = LMIIS()
A = LMIIS()
B = LMIIS()
C = LMIIS()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
ans = []
for ai in range(X):
for bi in range(Y):
if ai * bi > K:
break
for ci in range(Z):
if ai * bi * ci > K:
break
ans.append(A[ai] + B[bi] + C[ci])
ans.sort(reverse=True)
for i in range(K):
print(ans[i])
if __name__ == "__main__":
main()
| # coding:utf-8
import sys
sys.setrecursionlimit(2**31 - 1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda: list(map(int, input().split()))
II = lambda: int(input())
dbg = lambda *something: print(*something) if DEBUG is True else 0
DEBUG = True
def main():
X, Y, Z, K = LMIIS()
A = LMIIS()
B = LMIIS()
C = LMIIS()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
from heapq import heappush, heappop
from collections import defaultdict
d = defaultdict(lambda: False)
h = []
ai = bi = ci = 0
heappush(h, (-(A[ai] + B[bi] + C[ci]), ai, bi, ci))
d[(0, 0, 0)] = True
for _ in range(K):
v, ai, bi, ci = heappop(h)
print(-v)
if ai + 1 < X and d[(ai + 1, bi, ci)] == False:
heappush(h, (-(A[ai + 1] + B[bi] + C[ci]), ai + 1, bi, ci))
d[(ai + 1, bi, ci)] = True
if bi + 1 < Y and d[(ai, bi + 1, ci)] == False:
heappush(h, (-(A[ai] + B[bi + 1] + C[ci]), ai, bi + 1, ci))
d[(ai, bi + 1, ci)] = True
if ci + 1 < Z and d[(ai, bi, ci + 1)] == False:
heappush(h, (-(A[ai] + B[bi] + C[ci + 1]), ai, bi, ci + 1))
d[(ai, bi, ci + 1)] = True
if __name__ == "__main__":
main()
| false | 13.043478 | [
"- ans = []",
"- for ai in range(X):",
"- for bi in range(Y):",
"- if ai * bi > K:",
"- break",
"- for ci in range(Z):",
"- if ai * bi * ci > K:",
"- break",
"- ans.append(A[ai] + B[bi] + C[ci])",
"- ans.sort(reverse=True)",
"- for i in range(K):",
"- print(ans[i])",
"+ from heapq import heappush, heappop",
"+ from collections import defaultdict",
"+",
"+ d = defaultdict(lambda: False)",
"+ h = []",
"+ ai = bi = ci = 0",
"+ heappush(h, (-(A[ai] + B[bi] + C[ci]), ai, bi, ci))",
"+ d[(0, 0, 0)] = True",
"+ for _ in range(K):",
"+ v, ai, bi, ci = heappop(h)",
"+ print(-v)",
"+ if ai + 1 < X and d[(ai + 1, bi, ci)] == False:",
"+ heappush(h, (-(A[ai + 1] + B[bi] + C[ci]), ai + 1, bi, ci))",
"+ d[(ai + 1, bi, ci)] = True",
"+ if bi + 1 < Y and d[(ai, bi + 1, ci)] == False:",
"+ heappush(h, (-(A[ai] + B[bi + 1] + C[ci]), ai, bi + 1, ci))",
"+ d[(ai, bi + 1, ci)] = True",
"+ if ci + 1 < Z and d[(ai, bi, ci + 1)] == False:",
"+ heappush(h, (-(A[ai] + B[bi] + C[ci + 1]), ai, bi, ci + 1))",
"+ d[(ai, bi, ci + 1)] = True"
]
| false | 0.061578 | 0.040478 | 1.521252 | [
"s851383304",
"s851606142"
]
|
u806201407 | p03776 | python | s209700321 | s302848696 | 20 | 18 | 3,188 | 3,064 | Accepted | Accepted | 10 | from builtins import print
def comb(n, m) :
ans = 1
for i in range(n) :
ans *= i+1
for i in range(m) :
ans //= i+1
for i in range(n-m) :
ans //= i+1
return ans
N, A, B = map(int, input().split())
val = list(reversed(sorted((map(int, input().split())))))
ret = 0
prev = [0, 1]
for i in range(A, B+1) :
cur = [ sum( [ val[j] for j in range(i) ]) , i]
if i > A :
if prev[0] * cur[1] > prev[1] * cur[0] :
break
cntLarge = [ 1 if v > val[A] else 0 for v in val ].count(1)
ret += comb( val.count(val[i-1]) ,i - cntLarge)
prev = cur
print(format(prev[0] / prev[1], '.12f'))
print(ret)
| import math
def comb(n, m) :
fact = math.factorial
return fact(n) // fact(m) // fact(n-m)
N, A, B = list(map(int, input().split()))
val = list(reversed(sorted(map(int, input().split()))))
ret = 0
prev = [0, 1]
for i in range(A, B + 1):
cur = [sum([val[j] for j in range(i)]), i]
if i > A and prev[0] * cur[1] > prev[1] * cur[0]:
break
ret += comb(val.count(val[i-1]), val[:i].count(val[i-1]))
prev = cur
print((format(prev[0] / prev[1], '.12f')))
print(ret)
| 31 | 20 | 700 | 505 | from builtins import print
def comb(n, m):
ans = 1
for i in range(n):
ans *= i + 1
for i in range(m):
ans //= i + 1
for i in range(n - m):
ans //= i + 1
return ans
N, A, B = map(int, input().split())
val = list(reversed(sorted((map(int, input().split())))))
ret = 0
prev = [0, 1]
for i in range(A, B + 1):
cur = [sum([val[j] for j in range(i)]), i]
if i > A:
if prev[0] * cur[1] > prev[1] * cur[0]:
break
cntLarge = [1 if v > val[A] else 0 for v in val].count(1)
ret += comb(val.count(val[i - 1]), i - cntLarge)
prev = cur
print(format(prev[0] / prev[1], ".12f"))
print(ret)
| import math
def comb(n, m):
fact = math.factorial
return fact(n) // fact(m) // fact(n - m)
N, A, B = list(map(int, input().split()))
val = list(reversed(sorted(map(int, input().split()))))
ret = 0
prev = [0, 1]
for i in range(A, B + 1):
cur = [sum([val[j] for j in range(i)]), i]
if i > A and prev[0] * cur[1] > prev[1] * cur[0]:
break
ret += comb(val.count(val[i - 1]), val[:i].count(val[i - 1]))
prev = cur
print((format(prev[0] / prev[1], ".12f")))
print(ret)
| false | 35.483871 | [
"-from builtins import print",
"+import math",
"- ans = 1",
"- for i in range(n):",
"- ans *= i + 1",
"- for i in range(m):",
"- ans //= i + 1",
"- for i in range(n - m):",
"- ans //= i + 1",
"- return ans",
"+ fact = math.factorial",
"+ return fact(n) // fact(m) // fact(n - m)",
"-N, A, B = map(int, input().split())",
"-val = list(reversed(sorted((map(int, input().split())))))",
"+N, A, B = list(map(int, input().split()))",
"+val = list(reversed(sorted(map(int, input().split()))))",
"- if i > A:",
"- if prev[0] * cur[1] > prev[1] * cur[0]:",
"- break",
"- cntLarge = [1 if v > val[A] else 0 for v in val].count(1)",
"- ret += comb(val.count(val[i - 1]), i - cntLarge)",
"+ if i > A and prev[0] * cur[1] > prev[1] * cur[0]:",
"+ break",
"+ ret += comb(val.count(val[i - 1]), val[:i].count(val[i - 1]))",
"-print(format(prev[0] / prev[1], \".12f\"))",
"+print((format(prev[0] / prev[1], \".12f\")))"
]
| false | 0.034764 | 0.035392 | 0.98228 | [
"s209700321",
"s302848696"
]
|
u620084012 | p03761 | python | s850841686 | s362540663 | 169 | 22 | 38,640 | 3,316 | Accepted | Accepted | 86.98 | n = int(eval(input()))
S = "abcdefghijklmnopqrstuvwxyz"
C = [[0 for k in range(n)] for l in range(26)]
for k in range(n):
t = eval(input())
for e in t:
C[ord(e)-97][k] += 1
ans = ""
for k in range(26):
ans += S[k]*min(C[k])
print(ans)
| from collections import Counter
N = int(eval(input()))
W = [Counter(eval(input())) for k in range(N)]
A = [100000]*26
S = "abcdefghijklmnopqrstuvwxyz"
for e in W:
for s in S:
A[ord(s)-97] = min(A[ord(s)-97],e[s])
ans = ""
for k in range(26):
ans += S[k]*A[k]
print(ans)
| 11 | 13 | 253 | 287 | n = int(eval(input()))
S = "abcdefghijklmnopqrstuvwxyz"
C = [[0 for k in range(n)] for l in range(26)]
for k in range(n):
t = eval(input())
for e in t:
C[ord(e) - 97][k] += 1
ans = ""
for k in range(26):
ans += S[k] * min(C[k])
print(ans)
| from collections import Counter
N = int(eval(input()))
W = [Counter(eval(input())) for k in range(N)]
A = [100000] * 26
S = "abcdefghijklmnopqrstuvwxyz"
for e in W:
for s in S:
A[ord(s) - 97] = min(A[ord(s) - 97], e[s])
ans = ""
for k in range(26):
ans += S[k] * A[k]
print(ans)
| false | 15.384615 | [
"-n = int(eval(input()))",
"+from collections import Counter",
"+",
"+N = int(eval(input()))",
"+W = [Counter(eval(input())) for k in range(N)]",
"+A = [100000] * 26",
"-C = [[0 for k in range(n)] for l in range(26)]",
"-for k in range(n):",
"- t = eval(input())",
"- for e in t:",
"- C[ord(e) - 97][k] += 1",
"+for e in W:",
"+ for s in S:",
"+ A[ord(s) - 97] = min(A[ord(s) - 97], e[s])",
"- ans += S[k] * min(C[k])",
"+ ans += S[k] * A[k]"
]
| false | 0.056019 | 0.035943 | 1.558541 | [
"s850841686",
"s362540663"
]
|
u197300773 | p02781 | python | s708413666 | s552250455 | 446 | 18 | 3,192 | 3,064 | Accepted | Accepted | 95.96 | import math
import sys
comb=[0,0,0,1,3,6,10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666, 703, 741, 780, 820, 861, 903, 946, 990, 1035, 1081, 1128, 1176, 1225, 1275, 1326, 1378, 1431, 1485, 1540, 1596, 1653, 1711, 1770, 1830, 1891, 1953, 2016, 2080, 2145, 2211, 2278, 2346, 2415, 2485, 2556, 2628, 2701, 2775, 2850, 2926, 3003, 3081, 3160, 3240, 3321, 3403, 3486, 3570, 3655, 3741, 3828, 3916, 4005, 4095, 4186, 4278, 4371, 4465, 4560, 4656, 4753, 4851, 4950]
n=int(eval(input()))
k=int(eval(input()))
s=str(n)
L=len(s)
ans=0
if n<k:
ans=0
elif k==1:
for i in range(L):
for a in range(1,10):
if a*(10**i)<=n:
ans+=1
elif k==2:
for i in range(1,L):
for j in range(i):
for a in range(1,10):
for b in range(1,10):
if a*(10**i)+b*(10**j)<=n: ans+=1
elif k==3 and L<4:
for a in range(1,10):
for b in range(1,10):
for c in range(1,10):
if a*100+b*10+c<=n: ans+=1
elif k==3 and L>=4:
ans=sum(comb[:L])*9**3
ans+=comb[L]* 81 * (int(s[0])-1)
m=int(s[1:])
for i in range(1,L-1):
for j in range(i):
for a in range(1,10):
for b in range(1,10):
if a*(10**i)+b*(10**j)<=m: ans+=1
print(ans) | import math
import sys
n=int(eval(input()))
k=int(eval(input()))
s=str(n)
l=len(s)
dp0=[[0 for j in range(k+1)] for i in range(l)]
dp1=[[0 for j in range(k+1)] for i in range(l)]
x=int(s[0])
dp0[0][1]=x-1
dp0[0][0]=1
dp1[0][1]=1
for i in range(1,l):
x=int(s[i])
dp0[i][0]=1
for j in range(1,k+1):
dp0[i][j]+=dp0[i-1][j-1]*9+dp0[i-1][j]
if x>0:
dp0[i][j]+=dp1[i-1][j-1]*(x-1)+dp1[i-1][j]
dp1[i][j]=dp1[i-1][j-1]
else:
dp1[i][j]=dp1[i-1][j]
print((dp0[l-1][k]+dp1[l-1][k]))
| 45 | 26 | 1,439 | 558 | import math
import sys
comb = [
0,
0,
0,
1,
3,
6,
10,
15,
21,
28,
36,
45,
55,
66,
78,
91,
105,
120,
136,
153,
171,
190,
210,
231,
253,
276,
300,
325,
351,
378,
406,
435,
465,
496,
528,
561,
595,
630,
666,
703,
741,
780,
820,
861,
903,
946,
990,
1035,
1081,
1128,
1176,
1225,
1275,
1326,
1378,
1431,
1485,
1540,
1596,
1653,
1711,
1770,
1830,
1891,
1953,
2016,
2080,
2145,
2211,
2278,
2346,
2415,
2485,
2556,
2628,
2701,
2775,
2850,
2926,
3003,
3081,
3160,
3240,
3321,
3403,
3486,
3570,
3655,
3741,
3828,
3916,
4005,
4095,
4186,
4278,
4371,
4465,
4560,
4656,
4753,
4851,
4950,
]
n = int(eval(input()))
k = int(eval(input()))
s = str(n)
L = len(s)
ans = 0
if n < k:
ans = 0
elif k == 1:
for i in range(L):
for a in range(1, 10):
if a * (10**i) <= n:
ans += 1
elif k == 2:
for i in range(1, L):
for j in range(i):
for a in range(1, 10):
for b in range(1, 10):
if a * (10**i) + b * (10**j) <= n:
ans += 1
elif k == 3 and L < 4:
for a in range(1, 10):
for b in range(1, 10):
for c in range(1, 10):
if a * 100 + b * 10 + c <= n:
ans += 1
elif k == 3 and L >= 4:
ans = sum(comb[:L]) * 9**3
ans += comb[L] * 81 * (int(s[0]) - 1)
m = int(s[1:])
for i in range(1, L - 1):
for j in range(i):
for a in range(1, 10):
for b in range(1, 10):
if a * (10**i) + b * (10**j) <= m:
ans += 1
print(ans)
| import math
import sys
n = int(eval(input()))
k = int(eval(input()))
s = str(n)
l = len(s)
dp0 = [[0 for j in range(k + 1)] for i in range(l)]
dp1 = [[0 for j in range(k + 1)] for i in range(l)]
x = int(s[0])
dp0[0][1] = x - 1
dp0[0][0] = 1
dp1[0][1] = 1
for i in range(1, l):
x = int(s[i])
dp0[i][0] = 1
for j in range(1, k + 1):
dp0[i][j] += dp0[i - 1][j - 1] * 9 + dp0[i - 1][j]
if x > 0:
dp0[i][j] += dp1[i - 1][j - 1] * (x - 1) + dp1[i - 1][j]
dp1[i][j] = dp1[i - 1][j - 1]
else:
dp1[i][j] = dp1[i - 1][j]
print((dp0[l - 1][k] + dp1[l - 1][k]))
| false | 42.222222 | [
"-comb = [",
"- 0,",
"- 0,",
"- 0,",
"- 1,",
"- 3,",
"- 6,",
"- 10,",
"- 15,",
"- 21,",
"- 28,",
"- 36,",
"- 45,",
"- 55,",
"- 66,",
"- 78,",
"- 91,",
"- 105,",
"- 120,",
"- 136,",
"- 153,",
"- 171,",
"- 190,",
"- 210,",
"- 231,",
"- 253,",
"- 276,",
"- 300,",
"- 325,",
"- 351,",
"- 378,",
"- 406,",
"- 435,",
"- 465,",
"- 496,",
"- 528,",
"- 561,",
"- 595,",
"- 630,",
"- 666,",
"- 703,",
"- 741,",
"- 780,",
"- 820,",
"- 861,",
"- 903,",
"- 946,",
"- 990,",
"- 1035,",
"- 1081,",
"- 1128,",
"- 1176,",
"- 1225,",
"- 1275,",
"- 1326,",
"- 1378,",
"- 1431,",
"- 1485,",
"- 1540,",
"- 1596,",
"- 1653,",
"- 1711,",
"- 1770,",
"- 1830,",
"- 1891,",
"- 1953,",
"- 2016,",
"- 2080,",
"- 2145,",
"- 2211,",
"- 2278,",
"- 2346,",
"- 2415,",
"- 2485,",
"- 2556,",
"- 2628,",
"- 2701,",
"- 2775,",
"- 2850,",
"- 2926,",
"- 3003,",
"- 3081,",
"- 3160,",
"- 3240,",
"- 3321,",
"- 3403,",
"- 3486,",
"- 3570,",
"- 3655,",
"- 3741,",
"- 3828,",
"- 3916,",
"- 4005,",
"- 4095,",
"- 4186,",
"- 4278,",
"- 4371,",
"- 4465,",
"- 4560,",
"- 4656,",
"- 4753,",
"- 4851,",
"- 4950,",
"-]",
"-L = len(s)",
"-ans = 0",
"-if n < k:",
"- ans = 0",
"-elif k == 1:",
"- for i in range(L):",
"- for a in range(1, 10):",
"- if a * (10**i) <= n:",
"- ans += 1",
"-elif k == 2:",
"- for i in range(1, L):",
"- for j in range(i):",
"- for a in range(1, 10):",
"- for b in range(1, 10):",
"- if a * (10**i) + b * (10**j) <= n:",
"- ans += 1",
"-elif k == 3 and L < 4:",
"- for a in range(1, 10):",
"- for b in range(1, 10):",
"- for c in range(1, 10):",
"- if a * 100 + b * 10 + c <= n:",
"- ans += 1",
"-elif k == 3 and L >= 4:",
"- ans = sum(comb[:L]) * 9**3",
"- ans += comb[L] * 81 * (int(s[0]) - 1)",
"- m = int(s[1:])",
"- for i in range(1, L - 1):",
"- for j in range(i):",
"- for a in range(1, 10):",
"- for b in range(1, 10):",
"- if a * (10**i) + b * (10**j) <= m:",
"- ans += 1",
"-print(ans)",
"+l = len(s)",
"+dp0 = [[0 for j in range(k + 1)] for i in range(l)]",
"+dp1 = [[0 for j in range(k + 1)] for i in range(l)]",
"+x = int(s[0])",
"+dp0[0][1] = x - 1",
"+dp0[0][0] = 1",
"+dp1[0][1] = 1",
"+for i in range(1, l):",
"+ x = int(s[i])",
"+ dp0[i][0] = 1",
"+ for j in range(1, k + 1):",
"+ dp0[i][j] += dp0[i - 1][j - 1] * 9 + dp0[i - 1][j]",
"+ if x > 0:",
"+ dp0[i][j] += dp1[i - 1][j - 1] * (x - 1) + dp1[i - 1][j]",
"+ dp1[i][j] = dp1[i - 1][j - 1]",
"+ else:",
"+ dp1[i][j] = dp1[i - 1][j]",
"+print((dp0[l - 1][k] + dp1[l - 1][k]))"
]
| false | 0.080976 | 0.03547 | 2.282957 | [
"s708413666",
"s552250455"
]
|
u080364835 | p02971 | python | s326388092 | s488411680 | 389 | 356 | 27,376 | 19,064 | Accepted | Accepted | 8.48 | from collections import Counter
n = int(eval(input()))
al = [int(eval(input())) for _ in range(n)]
al_s = sorted(al, reverse=True)
c = Counter(al_s)
ck = list(c.keys())
cv = list(c.values())
for a in al:
if a == ck[0]:
if cv[0] == 1:
print((ck[1]))
else:
print((ck[0]))
else:
print((ck[0]))
| n = int(eval(input()))
al = list(int(eval(input())) for _ in range(n))
al_s = sorted(al)
fir = al_s[-1]
sec = al_s[-2]
for a in al:
if a == fir:
print(sec)
else:
print(fir)
| 19 | 12 | 351 | 198 | from collections import Counter
n = int(eval(input()))
al = [int(eval(input())) for _ in range(n)]
al_s = sorted(al, reverse=True)
c = Counter(al_s)
ck = list(c.keys())
cv = list(c.values())
for a in al:
if a == ck[0]:
if cv[0] == 1:
print((ck[1]))
else:
print((ck[0]))
else:
print((ck[0]))
| n = int(eval(input()))
al = list(int(eval(input())) for _ in range(n))
al_s = sorted(al)
fir = al_s[-1]
sec = al_s[-2]
for a in al:
if a == fir:
print(sec)
else:
print(fir)
| false | 36.842105 | [
"-from collections import Counter",
"-",
"-al = [int(eval(input())) for _ in range(n)]",
"-al_s = sorted(al, reverse=True)",
"-c = Counter(al_s)",
"-ck = list(c.keys())",
"-cv = list(c.values())",
"+al = list(int(eval(input())) for _ in range(n))",
"+al_s = sorted(al)",
"+fir = al_s[-1]",
"+sec = al_s[-2]",
"- if a == ck[0]:",
"- if cv[0] == 1:",
"- print((ck[1]))",
"- else:",
"- print((ck[0]))",
"+ if a == fir:",
"+ print(sec)",
"- print((ck[0]))",
"+ print(fir)"
]
| false | 0.036074 | 0.035218 | 1.024302 | [
"s326388092",
"s488411680"
]
|
u558242240 | p02744 | python | s061160598 | s997365817 | 581 | 529 | 28,968 | 4,404 | Accepted | Accepted | 8.95 | n = int(eval(input()))
ans = []
def dfs(x):
if len(x) == n:
ans.append(x)
return
for i in range(max(x)+1):
y = x.copy()
y.append(i+1)
dfs(y)
dfs([1])
#print(ans)
for ai in ans:
print((''.join([chr(ord('a') + x - 1) for x in ai])))
#r = ['a','b','c','d','e','f','g','h','i','j']
#for ai in ans:
# print(''.join(map(lambda x: str(r[x-1]), ai)))
| n = int(eval(input()))
ans = []
def dfs(x):
if len(x) == n:
print((''.join([chr(ord('a') + i - 1) for i in x])))
return
for i in range(max(x)+1):
y = x.copy()
y.append(i+1)
dfs(y)
dfs([1])
| 22 | 12 | 421 | 246 | n = int(eval(input()))
ans = []
def dfs(x):
if len(x) == n:
ans.append(x)
return
for i in range(max(x) + 1):
y = x.copy()
y.append(i + 1)
dfs(y)
dfs([1])
# print(ans)
for ai in ans:
print(("".join([chr(ord("a") + x - 1) for x in ai])))
# r = ['a','b','c','d','e','f','g','h','i','j']
# for ai in ans:
# print(''.join(map(lambda x: str(r[x-1]), ai)))
| n = int(eval(input()))
ans = []
def dfs(x):
if len(x) == n:
print(("".join([chr(ord("a") + i - 1) for i in x])))
return
for i in range(max(x) + 1):
y = x.copy()
y.append(i + 1)
dfs(y)
dfs([1])
| false | 45.454545 | [
"- ans.append(x)",
"+ print((\"\".join([chr(ord(\"a\") + i - 1) for i in x])))",
"-# print(ans)",
"-for ai in ans:",
"- print((\"\".join([chr(ord(\"a\") + x - 1) for x in ai])))",
"-# r = ['a','b','c','d','e','f','g','h','i','j']",
"-# for ai in ans:",
"-# print(''.join(map(lambda x: str(r[x-1]), ai)))"
]
| false | 0.03787 | 0.038227 | 0.990648 | [
"s061160598",
"s997365817"
]
|
u281303342 | p03458 | python | s004237403 | s199069234 | 1,847 | 1,284 | 101,884 | 101,888 | Accepted | Accepted | 30.48 | import numpy as np
import sys
def sum2d(i1,j1,i2,j2):
A[i1][j1] += 1
A[i1][j2] -= 1
A[i2][j1] -= 1
A[i2][j2] += 1
N,K = list(map(int,input().split()))
XYC = [list(input().split()) for _ in range(N)]
A = [[0 for _ in range(K*2+1)] for _ in range(K*2+1)]
for x,y,c in XYC:
i = (int(x) if c=="W" else int(x)+K) % (K*2)
j = int(y) % (K*2)
i0 = i%K
j0 = j%K
if (i<K and j<K) or (i>=K and j>=K):
sum2d(0,0,i0,j0) # 左上
sum2d(i0+K,0,K*2,j0) # 右上
sum2d(i0,j0,i0+K,j0+K) # 真ん中
sum2d(0,j0+K,i0,K*2) # 左下
sum2d(i0+K,j0+K,K*2,K*2) # 右下
else:
sum2d(i0,0,i0+K,j0) # 上
sum2d(0,j0,i0,j0+K) # 左
sum2d(i0+K,j0,K*2,j0+K) # 右
sum2d(i0,j0+K,i0+K,K*2) # 下
# 2次元累積和
AA = np.array(A)
for i in range(K*2):
AA[i+1, :] += AA[i, :]
for j in range(K*2):
AA[:, j+1] += AA[:, j]
print((AA.max()))
| # python 3.4.3
import sys
input = sys.stdin.readline
import numpy as np
# -------------------------------------------------------------
# function
# -------------------------------------------------------------
def sum2d(i1,j1,i2,j2):
A[i1][j1] += 1
A[i1][j2] -= 1
A[i2][j1] -= 1
A[i2][j2] += 1
# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,K = list(map(int,input().split()))
XYC = [list(input().split()) for _ in range(N)]
A = [[0 for _ in range(K*2+1)] for _ in range(K*2+1)]
for x,y,c in XYC:
# 白はそのまま, 黒はx軸方向にKずらして白として扱う
i = (int(x) if c=="W" else int(x)+K) % (K*2)
j = int(y) % (K*2)
i0 = i%K
j0 = j%K
# 分割区画の左下が白の場合 (白は5箇所)
# a * b
# * c *
# d * e
if (i<K and j<K) or (i>=K and j>=K):
sum2d(0,0,i0,j0) # (a)左上
sum2d(i0+K,0,K*2,j0) # (b)右上
sum2d(i0,j0,i0+K,j0+K) # (c)真ん中
sum2d(0,j0+K,i0,K*2) # (d)左下
sum2d(i0+K,j0+K,K*2,K*2) # (e)右下
# 分割区画の左下が黒の場合 (白は4箇所)
# * a *
# b * c
# * d *
else:
sum2d(i0,0,i0+K,j0) # (a)上
sum2d(0,j0,i0,j0+K) # (b)左
sum2d(i0+K,j0,K*2,j0+K) # (c)右
sum2d(i0,j0+K,i0+K,K*2) # (d)下
# 2次元累積和
AA = np.array(A)
for i in range(K*2):
AA[i+1, :] += AA[i, :]
for j in range(K*2):
AA[:, j+1] += AA[:, j]
print((AA.max()))
| 41 | 60 | 925 | 1,462 | import numpy as np
import sys
def sum2d(i1, j1, i2, j2):
A[i1][j1] += 1
A[i1][j2] -= 1
A[i2][j1] -= 1
A[i2][j2] += 1
N, K = list(map(int, input().split()))
XYC = [list(input().split()) for _ in range(N)]
A = [[0 for _ in range(K * 2 + 1)] for _ in range(K * 2 + 1)]
for x, y, c in XYC:
i = (int(x) if c == "W" else int(x) + K) % (K * 2)
j = int(y) % (K * 2)
i0 = i % K
j0 = j % K
if (i < K and j < K) or (i >= K and j >= K):
sum2d(0, 0, i0, j0) # 左上
sum2d(i0 + K, 0, K * 2, j0) # 右上
sum2d(i0, j0, i0 + K, j0 + K) # 真ん中
sum2d(0, j0 + K, i0, K * 2) # 左下
sum2d(i0 + K, j0 + K, K * 2, K * 2) # 右下
else:
sum2d(i0, 0, i0 + K, j0) # 上
sum2d(0, j0, i0, j0 + K) # 左
sum2d(i0 + K, j0, K * 2, j0 + K) # 右
sum2d(i0, j0 + K, i0 + K, K * 2) # 下
# 2次元累積和
AA = np.array(A)
for i in range(K * 2):
AA[i + 1, :] += AA[i, :]
for j in range(K * 2):
AA[:, j + 1] += AA[:, j]
print((AA.max()))
| # python 3.4.3
import sys
input = sys.stdin.readline
import numpy as np
# -------------------------------------------------------------
# function
# -------------------------------------------------------------
def sum2d(i1, j1, i2, j2):
A[i1][j1] += 1
A[i1][j2] -= 1
A[i2][j1] -= 1
A[i2][j2] += 1
# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N, K = list(map(int, input().split()))
XYC = [list(input().split()) for _ in range(N)]
A = [[0 for _ in range(K * 2 + 1)] for _ in range(K * 2 + 1)]
for x, y, c in XYC:
# 白はそのまま, 黒はx軸方向にKずらして白として扱う
i = (int(x) if c == "W" else int(x) + K) % (K * 2)
j = int(y) % (K * 2)
i0 = i % K
j0 = j % K
# 分割区画の左下が白の場合 (白は5箇所)
# a * b
# * c *
# d * e
if (i < K and j < K) or (i >= K and j >= K):
sum2d(0, 0, i0, j0) # (a)左上
sum2d(i0 + K, 0, K * 2, j0) # (b)右上
sum2d(i0, j0, i0 + K, j0 + K) # (c)真ん中
sum2d(0, j0 + K, i0, K * 2) # (d)左下
sum2d(i0 + K, j0 + K, K * 2, K * 2) # (e)右下
# 分割区画の左下が黒の場合 (白は4箇所)
# * a *
# b * c
# * d *
else:
sum2d(i0, 0, i0 + K, j0) # (a)上
sum2d(0, j0, i0, j0 + K) # (b)左
sum2d(i0 + K, j0, K * 2, j0 + K) # (c)右
sum2d(i0, j0 + K, i0 + K, K * 2) # (d)下
# 2次元累積和
AA = np.array(A)
for i in range(K * 2):
AA[i + 1, :] += AA[i, :]
for j in range(K * 2):
AA[:, j + 1] += AA[:, j]
print((AA.max()))
| false | 31.666667 | [
"-import numpy as np",
"+# python 3.4.3",
"+input = sys.stdin.readline",
"+import numpy as np",
"+# function",
"+# main",
"+ # 白はそのまま, 黒はx軸方向にKずらして白として扱う",
"+ # 分割区画の左下が白の場合 (白は5箇所)",
"+ # a * b",
"+ # * c *",
"+ # d * e",
"- sum2d(0, 0, i0, j0) # 左上",
"- sum2d(i0 + K, 0, K * 2, j0) # 右上",
"- sum2d(i0, j0, i0 + K, j0 + K) # 真ん中",
"- sum2d(0, j0 + K, i0, K * 2) # 左下",
"- sum2d(i0 + K, j0 + K, K * 2, K * 2) # 右下",
"+ sum2d(0, 0, i0, j0) # (a)左上",
"+ sum2d(i0 + K, 0, K * 2, j0) # (b)右上",
"+ sum2d(i0, j0, i0 + K, j0 + K) # (c)真ん中",
"+ sum2d(0, j0 + K, i0, K * 2) # (d)左下",
"+ sum2d(i0 + K, j0 + K, K * 2, K * 2) # (e)右下",
"+ # 分割区画の左下が黒の場合 (白は4箇所)",
"+ # * a *",
"+ # b * c",
"+ # * d *",
"- sum2d(i0, 0, i0 + K, j0) # 上",
"- sum2d(0, j0, i0, j0 + K) # 左",
"- sum2d(i0 + K, j0, K * 2, j0 + K) # 右",
"- sum2d(i0, j0 + K, i0 + K, K * 2) # 下",
"+ sum2d(i0, 0, i0 + K, j0) # (a)上",
"+ sum2d(0, j0, i0, j0 + K) # (b)左",
"+ sum2d(i0 + K, j0, K * 2, j0 + K) # (c)右",
"+ sum2d(i0, j0 + K, i0 + K, K * 2) # (d)下"
]
| false | 0.311574 | 0.561712 | 0.554686 | [
"s004237403",
"s199069234"
]
|
u525065967 | p02695 | python | s946161450 | s770632039 | 1,046 | 698 | 9,168 | 9,172 | Accepted | Accepted | 33.27 | n,m,q = list(map(int,input().split()))
abcd = [[*list(map(int,input().split()))] for _ in range(q)]
from itertools import *
ans = 0
for A in combinations_with_replacement(list(range(1, m+1)), n): # nHr
now = 0
for a,b,c,d in abcd:
if A[b-1] - A[a-1] == c: now += d
ans = max(ans, now)
print(ans)
| n,m,q = list(map(int,input().split()))
abcd = [[*list(map(int,input().split()))] for _ in range(q)]
from itertools import *
ans = 0
for A in combinations_with_replacement(list(range(1, m+1)), n): # nHr
now = sum(d if A[b-1] - A[a-1] == c else 0 for a,b,c,d in abcd)
ans = max(ans, now)
print(ans)
| 10 | 8 | 307 | 294 | n, m, q = list(map(int, input().split()))
abcd = [[*list(map(int, input().split()))] for _ in range(q)]
from itertools import *
ans = 0
for A in combinations_with_replacement(list(range(1, m + 1)), n): # nHr
now = 0
for a, b, c, d in abcd:
if A[b - 1] - A[a - 1] == c:
now += d
ans = max(ans, now)
print(ans)
| n, m, q = list(map(int, input().split()))
abcd = [[*list(map(int, input().split()))] for _ in range(q)]
from itertools import *
ans = 0
for A in combinations_with_replacement(list(range(1, m + 1)), n): # nHr
now = sum(d if A[b - 1] - A[a - 1] == c else 0 for a, b, c, d in abcd)
ans = max(ans, now)
print(ans)
| false | 20 | [
"- now = 0",
"- for a, b, c, d in abcd:",
"- if A[b - 1] - A[a - 1] == c:",
"- now += d",
"+ now = sum(d if A[b - 1] - A[a - 1] == c else 0 for a, b, c, d in abcd)"
]
| false | 0.053213 | 0.05771 | 0.922074 | [
"s946161450",
"s770632039"
]
|
u084357428 | p03308 | python | s499939100 | s064699784 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | n=int(eval(input()))
a=[int(_) for _ in input().split()]
ans = 0
for i in range(1,n):
for j in range(i):
ans = max(ans,abs(a[i]-a[j]))
print(ans) | n=int(eval(input()))
a=list(map(int,input().split()))
print((max(a)-min(a))) | 7 | 3 | 157 | 70 | n = int(eval(input()))
a = [int(_) for _ in input().split()]
ans = 0
for i in range(1, n):
for j in range(i):
ans = max(ans, abs(a[i] - a[j]))
print(ans)
| n = int(eval(input()))
a = list(map(int, input().split()))
print((max(a) - min(a)))
| false | 57.142857 | [
"-a = [int(_) for _ in input().split()]",
"-ans = 0",
"-for i in range(1, n):",
"- for j in range(i):",
"- ans = max(ans, abs(a[i] - a[j]))",
"-print(ans)",
"+a = list(map(int, input().split()))",
"+print((max(a) - min(a)))"
]
| false | 0.038917 | 0.04974 | 0.782412 | [
"s499939100",
"s064699784"
]
|
u325206354 | p03796 | python | s729287294 | s832482671 | 44 | 35 | 2,940 | 2,940 | Accepted | Accepted | 20.45 | X=10**9+7
def A(c,d):
return c*d%X
a=int(eval(input()))
x=1
for i in range(1,a+1):
x = A(x,i)
print(x)
| X=10**9+7
a=int(eval(input()))
x=1
for i in range(1,a+1):
x = x*i%X
print(x)
| 11 | 8 | 118 | 84 | X = 10**9 + 7
def A(c, d):
return c * d % X
a = int(eval(input()))
x = 1
for i in range(1, a + 1):
x = A(x, i)
print(x)
| X = 10**9 + 7
a = int(eval(input()))
x = 1
for i in range(1, a + 1):
x = x * i % X
print(x)
| false | 27.272727 | [
"-",
"-",
"-def A(c, d):",
"- return c * d % X",
"-",
"-",
"- x = A(x, i)",
"+ x = x * i % X"
]
| false | 0.047425 | 0.087627 | 0.541216 | [
"s729287294",
"s832482671"
]
|
u414920281 | p03805 | python | s924610813 | s501515767 | 35 | 24 | 3,064 | 3,064 | Accepted | Accepted | 31.43 | import itertools
n,m=list(map(int,input().split()))
path=[[False]*n for i in range(n)]
for i in range(m):
a,b=list(map(int,input().split()))
a-=1
b-=1
path[a][b]=True
path[b][a]=True
ans=0;
for i in itertools.permutations(list(range(n)),n):
if i[0]==0:
for j in range(n):
if j==n-1:
ans+=1
break
if not path[i[j]][i[j+1]]:
break
print(ans) | def dfs(a,count,seen):
nseen=seen[:]
ans=0
nseen[a] = 1;
if count==n-1:
return 1
else:
for i in g[a]:
if not seen[i]:
ans+=dfs(i,count+1,nseen)
return ans
n,m=list(map(int,input().split()))
g=[[]*n for i in range(n)]
for i in range(m):
a,b=list(map(int,input().split()))
a-=1
b-=1
g[a].append(b)
g[b].append(a)
seen=[0]*n
print((dfs(0,0,seen)))
| 20 | 21 | 445 | 443 | import itertools
n, m = list(map(int, input().split()))
path = [[False] * n for i in range(n)]
for i in range(m):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
path[a][b] = True
path[b][a] = True
ans = 0
for i in itertools.permutations(list(range(n)), n):
if i[0] == 0:
for j in range(n):
if j == n - 1:
ans += 1
break
if not path[i[j]][i[j + 1]]:
break
print(ans)
| def dfs(a, count, seen):
nseen = seen[:]
ans = 0
nseen[a] = 1
if count == n - 1:
return 1
else:
for i in g[a]:
if not seen[i]:
ans += dfs(i, count + 1, nseen)
return ans
n, m = list(map(int, input().split()))
g = [[] * n for i in range(n)]
for i in range(m):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
g[a].append(b)
g[b].append(a)
seen = [0] * n
print((dfs(0, 0, seen)))
| false | 4.761905 | [
"-import itertools",
"+def dfs(a, count, seen):",
"+ nseen = seen[:]",
"+ ans = 0",
"+ nseen[a] = 1",
"+ if count == n - 1:",
"+ return 1",
"+ else:",
"+ for i in g[a]:",
"+ if not seen[i]:",
"+ ans += dfs(i, count + 1, nseen)",
"+ return ans",
"+",
"-path = [[False] * n for i in range(n)]",
"+g = [[] * n for i in range(n)]",
"- path[a][b] = True",
"- path[b][a] = True",
"-ans = 0",
"-for i in itertools.permutations(list(range(n)), n):",
"- if i[0] == 0:",
"- for j in range(n):",
"- if j == n - 1:",
"- ans += 1",
"- break",
"- if not path[i[j]][i[j + 1]]:",
"- break",
"-print(ans)",
"+ g[a].append(b)",
"+ g[b].append(a)",
"+seen = [0] * n",
"+print((dfs(0, 0, seen)))"
]
| false | 0.059167 | 0.046273 | 1.278641 | [
"s924610813",
"s501515767"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.