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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u373047809
|
p03252
|
python
|
s455351710
|
s400357765
| 42 | 34 | 3,888 | 3,504 |
Accepted
|
Accepted
| 19.05 |
from collections import*
c = Counter
f = lambda: c(list(c(eval(input())).values()))
print(("YNeos"[f()!=f()::2]))
|
def f():
i = eval(input())
return sorted(i.count(j) for j in set(i))
print(("YNeos"[f()!=f()::2]))
| 4 | 4 | 102 | 97 |
from collections import *
c = Counter
f = lambda: c(list(c(eval(input())).values()))
print(("YNeos"[f() != f() :: 2]))
|
def f():
i = eval(input())
return sorted(i.count(j) for j in set(i))
print(("YNeos"[f() != f() :: 2]))
| false | 0 |
[
"-from collections import *",
"+def f():",
"+ i = eval(input())",
"+ return sorted(i.count(j) for j in set(i))",
"-c = Counter",
"-f = lambda: c(list(c(eval(input())).values()))",
"+"
] | false | 0.05216 | 0.046264 | 1.127446 |
[
"s455351710",
"s400357765"
] |
u594862874
|
p02711
|
python
|
s778311138
|
s092536003
| 22 | 19 | 9,112 | 9,076 |
Accepted
|
Accepted
| 13.64 |
N = eval(input())
print(('Yes' if '7' in str(N) else 'No'))
|
N = eval(input())
if len(str(N)) == 3:
print(('Yes' if '7' in str(N) else 'No'))
| 3 | 4 | 54 | 80 |
N = eval(input())
print(("Yes" if "7" in str(N) else "No"))
|
N = eval(input())
if len(str(N)) == 3:
print(("Yes" if "7" in str(N) else "No"))
| false | 25 |
[
"-print((\"Yes\" if \"7\" in str(N) else \"No\"))",
"+if len(str(N)) == 3:",
"+ print((\"Yes\" if \"7\" in str(N) else \"No\"))"
] | false | 0.08119 | 0.041727 | 1.945733 |
[
"s778311138",
"s092536003"
] |
u729133443
|
p02845
|
python
|
s171224249
|
s621041700
| 286 | 100 | 60,068 | 19,368 |
Accepted
|
Accepted
| 65.03 |
n,*a=list(map(int,open(0).read().split()))
c=1
d=[0]*3
for b in a:
c=c*sum(t==b for t in d)%(10**9+7)
for i,t in enumerate(d):
if t==b:
d[i]+=1
break
print(c)
|
_,a=open(0)
c=1
d=[3]+[0]*10**6
for a in map(int,a.split()):
c=c*d[a]%(10**9+7)
d[a]-=1
d[a+1]+=1
print(c)
| 10 | 8 | 181 | 119 |
n, *a = list(map(int, open(0).read().split()))
c = 1
d = [0] * 3
for b in a:
c = c * sum(t == b for t in d) % (10**9 + 7)
for i, t in enumerate(d):
if t == b:
d[i] += 1
break
print(c)
|
_, a = open(0)
c = 1
d = [3] + [0] * 10**6
for a in map(int, a.split()):
c = c * d[a] % (10**9 + 7)
d[a] -= 1
d[a + 1] += 1
print(c)
| false | 20 |
[
"-n, *a = list(map(int, open(0).read().split()))",
"+_, a = open(0)",
"-d = [0] * 3",
"-for b in a:",
"- c = c * sum(t == b for t in d) % (10**9 + 7)",
"- for i, t in enumerate(d):",
"- if t == b:",
"- d[i] += 1",
"- break",
"+d = [3] + [0] * 10**6",
"+for a in map(int, a.split()):",
"+ c = c * d[a] % (10**9 + 7)",
"+ d[a] -= 1",
"+ d[a + 1] += 1"
] | false | 0.035581 | 0.104717 | 0.339786 |
[
"s171224249",
"s621041700"
] |
u251515715
|
p03160
|
python
|
s201815988
|
s430194070
| 323 | 127 | 22,700 | 13,980 |
Accepted
|
Accepted
| 60.68 |
import numpy as np
n = int(eval(input()))
h = list(map(int,input().split()))
dp=[np.inf]*n
dp[0]=0
for i in range(1,n):
dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
if i > 1:
dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
print((dp[-1]))
|
n=int(eval(input()))
h=list(map(int,input().split()))
if n==2:
print((abs(h[1]-h[0])))
else:
dp=[0]*(n-1)
dp[0]=abs(h[1]-h[0])
dp[1]=min(dp[0]+abs(h[2]-h[1]),abs(h[2]-h[0]))
for i in range(2,n-1):
dp[i]=min(dp[i-1]+abs(h[i+1]-h[i]),dp[i-2]+abs(h[i+1]-h[i-1]))
print((dp[-1]))
| 10 | 13 | 242 | 333 |
import numpy as np
n = int(eval(input()))
h = list(map(int, input().split()))
dp = [np.inf] * n
dp[0] = 0
for i in range(1, n):
dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
if i > 1:
dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[-1]))
|
n = int(eval(input()))
h = list(map(int, input().split()))
if n == 2:
print((abs(h[1] - h[0])))
else:
dp = [0] * (n - 1)
dp[0] = abs(h[1] - h[0])
dp[1] = min(dp[0] + abs(h[2] - h[1]), abs(h[2] - h[0]))
for i in range(2, n - 1):
dp[i] = min(
dp[i - 1] + abs(h[i + 1] - h[i]), dp[i - 2] + abs(h[i + 1] - h[i - 1])
)
print((dp[-1]))
| false | 23.076923 |
[
"-import numpy as np",
"-",
"-dp = [np.inf] * n",
"-dp[0] = 0",
"-for i in range(1, n):",
"- dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))",
"- if i > 1:",
"- dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))",
"-print((dp[-1]))",
"+if n == 2:",
"+ print((abs(h[1] - h[0])))",
"+else:",
"+ dp = [0] * (n - 1)",
"+ dp[0] = abs(h[1] - h[0])",
"+ dp[1] = min(dp[0] + abs(h[2] - h[1]), abs(h[2] - h[0]))",
"+ for i in range(2, n - 1):",
"+ dp[i] = min(",
"+ dp[i - 1] + abs(h[i + 1] - h[i]), dp[i - 2] + abs(h[i + 1] - h[i - 1])",
"+ )",
"+ print((dp[-1]))"
] | false | 0.177169 | 0.035661 | 4.968204 |
[
"s201815988",
"s430194070"
] |
u835283937
|
p03774
|
python
|
s099864719
|
s625364094
| 188 | 20 | 39,792 | 3,064 |
Accepted
|
Accepted
| 89.36 |
def main():
N, M = list(map(int, input().split()))
students = [input().split() for _ in range(N)]
checkpoints = [input().split() for _ in range(M) ]
nearest = [None]*N
for i, s in enumerate(students) :
min_d = 10**9
index = 0
for j, p in enumerate(checkpoints, 1) :
a, b = list(map(int, s))
c, d = list(map(int, p))
d = abs(a - c) + abs(b - d)
if min_d > d:
min_d = d
index = j
nearest[i] = index
for i in range(N):
print((nearest[i]))
main()
|
def main():
N, M = list(map(int, input().split()))
students = [input().split() for _ in range(N)]
checkpoints = [input().split() for _ in range(M) ]
nearest = [None]*N
for i, s in enumerate(students) :
min_d = 10**9
for j, p in enumerate(checkpoints, 1) :
a, b = list(map(int, s))
c, d = list(map(int, p))
d = abs(a - c) + abs(b - d)
if min_d > d:
min_d = d
nearest[i] = j
for i in range(N):
print((nearest[i]))
main()
| 24 | 21 | 598 | 553 |
def main():
N, M = list(map(int, input().split()))
students = [input().split() for _ in range(N)]
checkpoints = [input().split() for _ in range(M)]
nearest = [None] * N
for i, s in enumerate(students):
min_d = 10**9
index = 0
for j, p in enumerate(checkpoints, 1):
a, b = list(map(int, s))
c, d = list(map(int, p))
d = abs(a - c) + abs(b - d)
if min_d > d:
min_d = d
index = j
nearest[i] = index
for i in range(N):
print((nearest[i]))
main()
|
def main():
N, M = list(map(int, input().split()))
students = [input().split() for _ in range(N)]
checkpoints = [input().split() for _ in range(M)]
nearest = [None] * N
for i, s in enumerate(students):
min_d = 10**9
for j, p in enumerate(checkpoints, 1):
a, b = list(map(int, s))
c, d = list(map(int, p))
d = abs(a - c) + abs(b - d)
if min_d > d:
min_d = d
nearest[i] = j
for i in range(N):
print((nearest[i]))
main()
| false | 12.5 |
[
"- index = 0",
"- index = j",
"- nearest[i] = index",
"+ nearest[i] = j"
] | false | 0.088837 | 0.038049 | 2.334794 |
[
"s099864719",
"s625364094"
] |
u077291787
|
p03472
|
python
|
s198491194
|
s288837754
| 230 | 109 | 25,176 | 25,124 |
Accepted
|
Accepted
| 52.61 |
# ABC085D - Katana Thrower
import sys
input = sys.stdin.readline
def main():
N, H = tuple(map(int, input().split()))
AB = tuple(tuple(map(int, input().split())) for _ in range(N))
A, B = list(zip(*AB))
x = max(A)
B = sorted([i for i in B if i > x], reverse=1)
ans = 0
for i in B:
ans += 1
H -= i
if H <= 0:
break
else:
ans += (H + x - 1) // x
print(ans)
if __name__ == "__main__":
main()
|
# ABC085D - Katana Thrower
def main():
N, H, *AB = list(map(int, open(0).read().split()))
A = AB[::2]
x = max(A)
B = sorted([i for i in AB[1::2] if i > x], reverse=1)
ans = 0
for i in B:
ans += 1
H -= i
if H <= 0:
break
else:
ans += (H + x - 1) // x
print(ans)
if __name__ == "__main__":
main()
| 23 | 19 | 490 | 388 |
# ABC085D - Katana Thrower
import sys
input = sys.stdin.readline
def main():
N, H = tuple(map(int, input().split()))
AB = tuple(tuple(map(int, input().split())) for _ in range(N))
A, B = list(zip(*AB))
x = max(A)
B = sorted([i for i in B if i > x], reverse=1)
ans = 0
for i in B:
ans += 1
H -= i
if H <= 0:
break
else:
ans += (H + x - 1) // x
print(ans)
if __name__ == "__main__":
main()
|
# ABC085D - Katana Thrower
def main():
N, H, *AB = list(map(int, open(0).read().split()))
A = AB[::2]
x = max(A)
B = sorted([i for i in AB[1::2] if i > x], reverse=1)
ans = 0
for i in B:
ans += 1
H -= i
if H <= 0:
break
else:
ans += (H + x - 1) // x
print(ans)
if __name__ == "__main__":
main()
| false | 17.391304 |
[
"-import sys",
"-",
"-input = sys.stdin.readline",
"-",
"-",
"- N, H = tuple(map(int, input().split()))",
"- AB = tuple(tuple(map(int, input().split())) for _ in range(N))",
"- A, B = list(zip(*AB))",
"+ N, H, *AB = list(map(int, open(0).read().split()))",
"+ A = AB[::2]",
"- B = sorted([i for i in B if i > x], reverse=1)",
"+ B = sorted([i for i in AB[1::2] if i > x], reverse=1)"
] | false | 0.040732 | 0.046624 | 0.873613 |
[
"s198491194",
"s288837754"
] |
u102461423
|
p03653
|
python
|
s315859455
|
s362043633
| 554 | 488 | 127,464 | 110,540 |
Accepted
|
Accepted
| 11.91 |
import sys
import numpy as np
import heapq as hp
from numba import njit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@njit('i8[:],i8[:],i8', cache=True)
def compute(A, B, X):
"""左からn番の人まで。AからX人とる。ときの最大スコアを返す。"""
result = np.zeros(len(A), np.int64)
result[X - 1] = A[:X].sum()
q = []
for i in range(X):
q.append(A[i] - B[i])
hp.heapify(q)
for i in range(X, len(A)):
x = result[i - 1] + A[i] # とりあえず A をとる
loss = hp.heappushpop(q, A[i] - B[i]) # ひとつ B に取り換えたときのロス
result[i] = x - loss
return result
@njit('(i8[:],i8,i8,i8)', cache=True)
def main(ABC, X, Y, Z):
A = ABC[::3]
B = ABC[1::3]
C = ABC[2::3]
ind = np.argsort(C - A)
A, B, C = A[ind], B[ind], C[ind]
q = [0] * 0
q = [0] * 0
dp1 = compute(A, B, X)
dp2 = compute(C[::-1], B[::-1], Z)[::-1]
x = dp1[X - 1:X + Y] + dp2[X:X + Y + 1]
return x.max()
X, Y, Z = list(map(int, readline().split()))
ABC = np.array(read().split(), np.int64)
print((main(ABC, X, Y, Z)))
|
import sys
import numpy as np
import heapq as hp
from numba import njit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def compute(A, B, X):
"""左からn番の人まで。AからX人とる。ときの最大スコアを返す。"""
result = np.zeros(len(A), np.int64)
result[X - 1] = A[:X].sum()
q = []
for i in range(X):
q.append(A[i] - B[i])
hp.heapify(q)
for i in range(X, len(A)):
x = result[i - 1] + A[i] # とりあえず A をとる
loss = hp.heappushpop(q, A[i] - B[i]) # ひとつ B に取り換えたときのロス
result[i] = x - loss
return result
def main(ABC, X, Y, Z):
A = ABC[::3]
B = ABC[1::3]
C = ABC[2::3]
ind = np.argsort(C - A)
A, B, C = A[ind], B[ind], C[ind]
q = [0] * 0
q = [0] * 0
dp1 = compute(A, B, X)
dp2 = compute(C[::-1], B[::-1], Z)[::-1]
x = dp1[X - 1:X + Y] + dp2[X:X + Y + 1]
return x.max()
if sys.argv[-1] == 'ONLINE_JUDGE':
import numba
from numba.pycc import CC
i8 = numba.from_dtype(np.int64)
u1 = numba.from_dtype(np.dtype('U1'))
sig1 = (i8[:], i8[:], i8)
sig2 = (i8[:], i8, i8, i8)
cc = CC('my_module')
cc.export('compute', sig1)(compute)
compute = numba.njit(compute)
cc.export('main', sig2)(main)
cc.compile()
from my_module import main
X, Y, Z = list(map(int, readline().split()))
ABC = np.array(read().split(), np.int64)
print((main(ABC, X, Y, Z)))
| 43 | 57 | 1,123 | 1,464 |
import sys
import numpy as np
import heapq as hp
from numba import njit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@njit("i8[:],i8[:],i8", cache=True)
def compute(A, B, X):
"""左からn番の人まで。AからX人とる。ときの最大スコアを返す。"""
result = np.zeros(len(A), np.int64)
result[X - 1] = A[:X].sum()
q = []
for i in range(X):
q.append(A[i] - B[i])
hp.heapify(q)
for i in range(X, len(A)):
x = result[i - 1] + A[i] # とりあえず A をとる
loss = hp.heappushpop(q, A[i] - B[i]) # ひとつ B に取り換えたときのロス
result[i] = x - loss
return result
@njit("(i8[:],i8,i8,i8)", cache=True)
def main(ABC, X, Y, Z):
A = ABC[::3]
B = ABC[1::3]
C = ABC[2::3]
ind = np.argsort(C - A)
A, B, C = A[ind], B[ind], C[ind]
q = [0] * 0
q = [0] * 0
dp1 = compute(A, B, X)
dp2 = compute(C[::-1], B[::-1], Z)[::-1]
x = dp1[X - 1 : X + Y] + dp2[X : X + Y + 1]
return x.max()
X, Y, Z = list(map(int, readline().split()))
ABC = np.array(read().split(), np.int64)
print((main(ABC, X, Y, Z)))
|
import sys
import numpy as np
import heapq as hp
from numba import njit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def compute(A, B, X):
"""左からn番の人まで。AからX人とる。ときの最大スコアを返す。"""
result = np.zeros(len(A), np.int64)
result[X - 1] = A[:X].sum()
q = []
for i in range(X):
q.append(A[i] - B[i])
hp.heapify(q)
for i in range(X, len(A)):
x = result[i - 1] + A[i] # とりあえず A をとる
loss = hp.heappushpop(q, A[i] - B[i]) # ひとつ B に取り換えたときのロス
result[i] = x - loss
return result
def main(ABC, X, Y, Z):
A = ABC[::3]
B = ABC[1::3]
C = ABC[2::3]
ind = np.argsort(C - A)
A, B, C = A[ind], B[ind], C[ind]
q = [0] * 0
q = [0] * 0
dp1 = compute(A, B, X)
dp2 = compute(C[::-1], B[::-1], Z)[::-1]
x = dp1[X - 1 : X + Y] + dp2[X : X + Y + 1]
return x.max()
if sys.argv[-1] == "ONLINE_JUDGE":
import numba
from numba.pycc import CC
i8 = numba.from_dtype(np.int64)
u1 = numba.from_dtype(np.dtype("U1"))
sig1 = (i8[:], i8[:], i8)
sig2 = (i8[:], i8, i8, i8)
cc = CC("my_module")
cc.export("compute", sig1)(compute)
compute = numba.njit(compute)
cc.export("main", sig2)(main)
cc.compile()
from my_module import main
X, Y, Z = list(map(int, readline().split()))
ABC = np.array(read().split(), np.int64)
print((main(ABC, X, Y, Z)))
| false | 24.561404 |
[
"-@njit(\"i8[:],i8[:],i8\", cache=True)",
"-@njit(\"(i8[:],i8,i8,i8)\", cache=True)",
"+if sys.argv[-1] == \"ONLINE_JUDGE\":",
"+ import numba",
"+ from numba.pycc import CC",
"+",
"+ i8 = numba.from_dtype(np.int64)",
"+ u1 = numba.from_dtype(np.dtype(\"U1\"))",
"+ sig1 = (i8[:], i8[:], i8)",
"+ sig2 = (i8[:], i8, i8, i8)",
"+ cc = CC(\"my_module\")",
"+ cc.export(\"compute\", sig1)(compute)",
"+ compute = numba.njit(compute)",
"+ cc.export(\"main\", sig2)(main)",
"+ cc.compile()",
"+from my_module import main",
"+"
] | false | 0.257926 | 0.272199 | 0.947565 |
[
"s315859455",
"s362043633"
] |
u671861352
|
p02972
|
python
|
s557103313
|
s869355125
| 418 | 356 | 8,784 | 13,108 |
Accepted
|
Accepted
| 14.83 |
N = int(input())
A = list(map(int, input().split()))
b = [0] * (N + 1)
half = N // 2
b[half + 1:] = A[half:]
for i in range(half, 1, -1):
s = sum([b[j] for j in range(i * 2, N + 1, i)]) % 2
if s != A[i - 1]:
b[i] = 1
s = sum(b)
if s % 2 != A[0]:
b[1] = 1
s += 1
print(s)
for i, b_ in enumerate(b[:]):
if b_ == 1:
print(i, end=" ")
|
N = int(eval(input()))
A = list(map(int, input().split()))
b = [0] * (N + 1)
half = N // 2
b[half + 1:] = A[half:]
for i in range(half, 1, -1):
s = sum([b[j] for j in range(i * 2, N + 1, i)]) % 2
if s != A[i - 1]:
b[i] = 1
s = sum(b)
if s % 2 != A[0]:
b[1] = 1
s += 1
print(s)
print((*[i for i in range(1, N + 1) if b[i] == 1]))
| 18 | 16 | 384 | 360 |
N = int(input())
A = list(map(int, input().split()))
b = [0] * (N + 1)
half = N // 2
b[half + 1 :] = A[half:]
for i in range(half, 1, -1):
s = sum([b[j] for j in range(i * 2, N + 1, i)]) % 2
if s != A[i - 1]:
b[i] = 1
s = sum(b)
if s % 2 != A[0]:
b[1] = 1
s += 1
print(s)
for i, b_ in enumerate(b[:]):
if b_ == 1:
print(i, end=" ")
|
N = int(eval(input()))
A = list(map(int, input().split()))
b = [0] * (N + 1)
half = N // 2
b[half + 1 :] = A[half:]
for i in range(half, 1, -1):
s = sum([b[j] for j in range(i * 2, N + 1, i)]) % 2
if s != A[i - 1]:
b[i] = 1
s = sum(b)
if s % 2 != A[0]:
b[1] = 1
s += 1
print(s)
print((*[i for i in range(1, N + 1) if b[i] == 1]))
| false | 11.111111 |
[
"-N = int(input())",
"+N = int(eval(input()))",
"-for i, b_ in enumerate(b[:]):",
"- if b_ == 1:",
"- print(i, end=\" \")",
"+print((*[i for i in range(1, N + 1) if b[i] == 1]))"
] | false | 0.044675 | 0.043494 | 1.027143 |
[
"s557103313",
"s869355125"
] |
u156815136
|
p03721
|
python
|
s433177087
|
s242225512
| 446 | 294 | 24,568 | 19,880 |
Accepted
|
Accepted
| 34.08 |
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
# d = m - k[i] - k[j]
# if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも!!
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
def readInts():
return list(map(int,input().split()))
def main():
n,k = readInts()
sum_ = 0
l = []
for i in range(n):
a,b = readInts()
l.append([a,b])
l = sorted(l,key = lambda x:x[0])
for a,b in l:
sum_ += b
if sum_ >= k:
print(a)
exit()
if __name__ == '__main__':
main()
|
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
# d = m - k[i] - k[j]
# if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも!!
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
return list(map(int,input().split()))
def I():
return int(eval(input()))
n,k = readInts()
dic = defaultdict(int)
d = set()
for i in range(n):
a,b = readInts()
d.add(a)
dic[a] += b
d = sorted(list(d))
ans = 0
for v in d:
if ans + dic[v] >= k:
print(v)
exit()
ans += dic[v]
| 42 | 42 | 870 | 915 |
from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
# d = m - k[i] - k[j]
# if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも!!
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
def readInts():
return list(map(int, input().split()))
def main():
n, k = readInts()
sum_ = 0
l = []
for i in range(n):
a, b = readInts()
l.append([a, b])
l = sorted(l, key=lambda x: x[0])
for a, b in l:
sum_ += b
if sum_ >= k:
print(a)
exit()
if __name__ == "__main__":
main()
|
# from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations, permutations, accumulate # (string,3) 3回
# from collections import deque
from collections import deque, defaultdict, Counter
import decimal
import re
# import bisect
#
# d = m - k[i] - k[j]
# if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも!!
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
# mod = 9982443453
def readInts():
return list(map(int, input().split()))
def I():
return int(eval(input()))
n, k = readInts()
dic = defaultdict(int)
d = set()
for i in range(n):
a, b = readInts()
d.add(a)
dic[a] += b
d = sorted(list(d))
ans = 0
for v in d:
if ans + dic[v] >= k:
print(v)
exit()
ans += dic[v]
| false | 0 |
[
"-from statistics import median",
"-",
"+# from statistics import median",
"-from itertools import combinations # (string,3) 3回",
"-from collections import deque",
"-from collections import defaultdict",
"-import bisect",
"+from itertools import combinations, permutations, accumulate # (string,3) 3回",
"+# from collections import deque",
"+from collections import deque, defaultdict, Counter",
"+import decimal",
"+import re",
"+",
"+# import bisect",
"-",
"-",
"+# mod = 9982443453",
"-def main():",
"- n, k = readInts()",
"- sum_ = 0",
"- l = []",
"- for i in range(n):",
"- a, b = readInts()",
"- l.append([a, b])",
"- l = sorted(l, key=lambda x: x[0])",
"- for a, b in l:",
"- sum_ += b",
"- if sum_ >= k:",
"- print(a)",
"- exit()",
"+def I():",
"+ return int(eval(input()))",
"-if __name__ == \"__main__\":",
"- main()",
"+n, k = readInts()",
"+dic = defaultdict(int)",
"+d = set()",
"+for i in range(n):",
"+ a, b = readInts()",
"+ d.add(a)",
"+ dic[a] += b",
"+d = sorted(list(d))",
"+ans = 0",
"+for v in d:",
"+ if ans + dic[v] >= k:",
"+ print(v)",
"+ exit()",
"+ ans += dic[v]"
] | false | 0.033157 | 0.035377 | 0.937249 |
[
"s433177087",
"s242225512"
] |
u724687935
|
p02793
|
python
|
s468983813
|
s891032918
| 1,866 | 915 | 6,200 | 67,416 |
Accepted
|
Accepted
| 50.96 |
from fractions import gcd
MOD = 10 ** 9 + 7
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort(reverse=True)
lcm = A[0]
for a in A:
lcm = (lcm * a) // gcd(lcm, a)
ans = 0
for a in A:
ans += (lcm % MOD) * pow(a, MOD - 2, MOD)
ans %= MOD
print(ans)
|
from fractions import gcd
MOD = 10 ** 9 + 7
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort(reverse=True)
lcm = A[0]
for a in A:
lcm = (lcm * a) // gcd(lcm, a)
ans = 0
lcm %= MOD
for a in A:
ans += lcm * pow(a, MOD - 2, MOD)
ans %= MOD
print(ans)
| 19 | 20 | 292 | 296 |
from fractions import gcd
MOD = 10**9 + 7
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort(reverse=True)
lcm = A[0]
for a in A:
lcm = (lcm * a) // gcd(lcm, a)
ans = 0
for a in A:
ans += (lcm % MOD) * pow(a, MOD - 2, MOD)
ans %= MOD
print(ans)
|
from fractions import gcd
MOD = 10**9 + 7
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort(reverse=True)
lcm = A[0]
for a in A:
lcm = (lcm * a) // gcd(lcm, a)
ans = 0
lcm %= MOD
for a in A:
ans += lcm * pow(a, MOD - 2, MOD)
ans %= MOD
print(ans)
| false | 5 |
[
"+lcm %= MOD",
"- ans += (lcm % MOD) * pow(a, MOD - 2, MOD)",
"+ ans += lcm * pow(a, MOD - 2, MOD)"
] | false | 0.043882 | 0.108999 | 0.402592 |
[
"s468983813",
"s891032918"
] |
u312025627
|
p02788
|
python
|
s662527468
|
s645686195
| 1,899 | 1,711 | 102,692 | 100,772 |
Accepted
|
Accepted
| 9.9 |
def main():
N, D, A = (int(i) for i in input().split())
P = [[int(i) for i in input().split()] for j in range(N)]
P.sort()
X = [x[0] for x in P]
H = [h[1] for h in P]
diff = [H[0]] + [H[i+1] - H[i] for i in range(N-1)]
BIT = [0] * (N+1)
def BIT_query(idx):
""" A1 ~ Aiまでの和(1-index) """
res_sum = 0
while idx > 0:
res_sum += BIT[idx]
idx -= idx & -idx
return res_sum
def BIT_update(idx, x):
""" Aiにxを加算(1-index) """
while idx <= N:
BIT[idx] += x
idx += idx & -idx
return
def BIT_init(A):
for i, e in enumerate(A):
BIT_update(i+1, e)
BIT_init(diff)
from bisect import bisect_right
ans = 0
for left in range(N):
x = P[left][0]
h = BIT_query(left+1)
if h > 0:
cur = (h + A - 1) // A
damage = cur * A
BIT_update(left+1, -damage)
right = bisect_right(X, x + 2*D)
BIT_update(right+1, damage)
ans += cur
print(ans)
if __name__ == '__main__':
main()
|
def main():
N, D, A = (int(i) for i in input().split())
P = [[int(i) for i in input().split()] for j in range(N)]
P.sort()
X = [x[0] for x in P]
H = [h[1] for h in P]
diff = [H[0]] + [H[i+1] - H[i] for i in range(N-1)]
BIT = [0] * (N+1)
def BIT_query(idx):
""" A1 ~ Aiまでの和(1-index) """
res_sum = 0
while idx > 0:
res_sum += BIT[idx]
idx -= idx & -idx
return res_sum
def BIT_update(idx, x):
""" Aiにxを加算(1-index) """
while idx <= N:
BIT[idx] += x
idx += idx & -idx
return
def BIT_init(A):
for i, e in enumerate(A):
BIT_update(i+1, e)
BIT_init(diff)
ans = 0
right = 0
for left in range(N):
x = P[left][0]
h = BIT_query(left+1)
while right < N and P[right][0] <= x + 2*D:
right += 1
if h > 0:
cur = (h + A - 1) // A
damage = cur * A
BIT_update(left+1, -damage)
BIT_update(right+1, damage)
ans += cur
print(ans)
if __name__ == '__main__':
main()
| 46 | 47 | 1,176 | 1,185 |
def main():
N, D, A = (int(i) for i in input().split())
P = [[int(i) for i in input().split()] for j in range(N)]
P.sort()
X = [x[0] for x in P]
H = [h[1] for h in P]
diff = [H[0]] + [H[i + 1] - H[i] for i in range(N - 1)]
BIT = [0] * (N + 1)
def BIT_query(idx):
"""A1 ~ Aiまでの和(1-index)"""
res_sum = 0
while idx > 0:
res_sum += BIT[idx]
idx -= idx & -idx
return res_sum
def BIT_update(idx, x):
"""Aiにxを加算(1-index)"""
while idx <= N:
BIT[idx] += x
idx += idx & -idx
return
def BIT_init(A):
for i, e in enumerate(A):
BIT_update(i + 1, e)
BIT_init(diff)
from bisect import bisect_right
ans = 0
for left in range(N):
x = P[left][0]
h = BIT_query(left + 1)
if h > 0:
cur = (h + A - 1) // A
damage = cur * A
BIT_update(left + 1, -damage)
right = bisect_right(X, x + 2 * D)
BIT_update(right + 1, damage)
ans += cur
print(ans)
if __name__ == "__main__":
main()
|
def main():
N, D, A = (int(i) for i in input().split())
P = [[int(i) for i in input().split()] for j in range(N)]
P.sort()
X = [x[0] for x in P]
H = [h[1] for h in P]
diff = [H[0]] + [H[i + 1] - H[i] for i in range(N - 1)]
BIT = [0] * (N + 1)
def BIT_query(idx):
"""A1 ~ Aiまでの和(1-index)"""
res_sum = 0
while idx > 0:
res_sum += BIT[idx]
idx -= idx & -idx
return res_sum
def BIT_update(idx, x):
"""Aiにxを加算(1-index)"""
while idx <= N:
BIT[idx] += x
idx += idx & -idx
return
def BIT_init(A):
for i, e in enumerate(A):
BIT_update(i + 1, e)
BIT_init(diff)
ans = 0
right = 0
for left in range(N):
x = P[left][0]
h = BIT_query(left + 1)
while right < N and P[right][0] <= x + 2 * D:
right += 1
if h > 0:
cur = (h + A - 1) // A
damage = cur * A
BIT_update(left + 1, -damage)
BIT_update(right + 1, damage)
ans += cur
print(ans)
if __name__ == "__main__":
main()
| false | 2.12766 |
[
"- from bisect import bisect_right",
"-",
"+ right = 0",
"+ while right < N and P[right][0] <= x + 2 * D:",
"+ right += 1",
"- right = bisect_right(X, x + 2 * D)"
] | false | 0.050373 | 0.044764 | 1.125305 |
[
"s662527468",
"s645686195"
] |
u729133443
|
p03703
|
python
|
s084497565
|
s107603535
| 1,388 | 420 | 45,008 | 113,552 |
Accepted
|
Accepted
| 69.74 |
class BIT:
def __init__(self,n):
self.size=n
self.tree=[0]*-~n
def sum(self,i):
s=0
while i:
s+=self.tree[i]
i-=i&-i
return s
def add(self,i,x):
while i<=self.size:
self.tree[i]+=x
i+=i&-i
n,k,*a=list(map(int,open(0).read().split()))
a=[t-k for t in a]
for i in range(1,n):
a[i]+=a[i-1]
d={}
for i,v in enumerate(sorted(set(a+[0])),1):
d[v]=i
for i in range(n):
a[i]=d[a[i]]
b=BIT(max(a))
b.add(d[0],1)
c=0
for i,p in enumerate(a):
c+=b.sum(p)
b.add(p,1)
print(c)
|
class BIT:
def __init__(self,n):
self.size=n
self.tree=[0]*-~n
def sum(self,i):
s=0
while i:
s+=self.tree[i]
i-=i&-i
return s
def add(self,i,x):
while i<=self.size:
self.tree[i]+=x
i+=i&-i
n,k,*a=list(map(int,open(0).read().split()))
a=[t-k for t in a]
for i in range(1,n):
a[i]+=a[i-1]
d={}
for i,v in enumerate(sorted(set(a+[0])),1):
d[v]=i
for i in range(n):
a[i]=d[a[i]]
b=BIT(max(a))
b.add(d[0],1)
c=0
for p in a:
c+=b.sum(p)
b.add(p,1)
print(c)
| 30 | 30 | 614 | 601 |
class BIT:
def __init__(self, n):
self.size = n
self.tree = [0] * -~n
def sum(self, i):
s = 0
while i:
s += self.tree[i]
i -= i & -i
return s
def add(self, i, x):
while i <= self.size:
self.tree[i] += x
i += i & -i
n, k, *a = list(map(int, open(0).read().split()))
a = [t - k for t in a]
for i in range(1, n):
a[i] += a[i - 1]
d = {}
for i, v in enumerate(sorted(set(a + [0])), 1):
d[v] = i
for i in range(n):
a[i] = d[a[i]]
b = BIT(max(a))
b.add(d[0], 1)
c = 0
for i, p in enumerate(a):
c += b.sum(p)
b.add(p, 1)
print(c)
|
class BIT:
def __init__(self, n):
self.size = n
self.tree = [0] * -~n
def sum(self, i):
s = 0
while i:
s += self.tree[i]
i -= i & -i
return s
def add(self, i, x):
while i <= self.size:
self.tree[i] += x
i += i & -i
n, k, *a = list(map(int, open(0).read().split()))
a = [t - k for t in a]
for i in range(1, n):
a[i] += a[i - 1]
d = {}
for i, v in enumerate(sorted(set(a + [0])), 1):
d[v] = i
for i in range(n):
a[i] = d[a[i]]
b = BIT(max(a))
b.add(d[0], 1)
c = 0
for p in a:
c += b.sum(p)
b.add(p, 1)
print(c)
| false | 0 |
[
"-for i, p in enumerate(a):",
"+for p in a:"
] | false | 0.092201 | 0.087622 | 1.052264 |
[
"s084497565",
"s107603535"
] |
u983918956
|
p03069
|
python
|
s391020141
|
s208593929
| 239 | 132 | 12,776 | 3,500 |
Accepted
|
Accepted
| 44.77 |
N = int(eval(input()))
S = eval(input())
b = [0] * (N+1)
w = [0] * (N+1)
for i, s in enumerate(S):
b[i+1] = b[i]
w[i+1] = w[i]
if s == "#":
b[i+1] += 1
if s == ".":
w[i+1] += 1
ans = float('inf')
for i in range(N+1):
ans = min(ans, b[i] + w[N] - w[i])
print(ans)
|
N = int(eval(input()))
S = eval(input())
w_N = S.count(".")
ans = w_N
b = 0
w = 0
for i, s in enumerate(S):
if s == "#":
b += 1
if s == ".":
w += 1
ans = min(ans,b + w_N - w)
print(ans)
| 20 | 16 | 310 | 219 |
N = int(eval(input()))
S = eval(input())
b = [0] * (N + 1)
w = [0] * (N + 1)
for i, s in enumerate(S):
b[i + 1] = b[i]
w[i + 1] = w[i]
if s == "#":
b[i + 1] += 1
if s == ".":
w[i + 1] += 1
ans = float("inf")
for i in range(N + 1):
ans = min(ans, b[i] + w[N] - w[i])
print(ans)
|
N = int(eval(input()))
S = eval(input())
w_N = S.count(".")
ans = w_N
b = 0
w = 0
for i, s in enumerate(S):
if s == "#":
b += 1
if s == ".":
w += 1
ans = min(ans, b + w_N - w)
print(ans)
| false | 20 |
[
"-b = [0] * (N + 1)",
"-w = [0] * (N + 1)",
"+w_N = S.count(\".\")",
"+ans = w_N",
"+b = 0",
"+w = 0",
"- b[i + 1] = b[i]",
"- w[i + 1] = w[i]",
"- b[i + 1] += 1",
"+ b += 1",
"- w[i + 1] += 1",
"-ans = float(\"inf\")",
"-for i in range(N + 1):",
"- ans = min(ans, b[i] + w[N] - w[i])",
"+ w += 1",
"+ ans = min(ans, b + w_N - w)"
] | false | 0.046421 | 0.037132 | 1.250152 |
[
"s391020141",
"s208593929"
] |
u217303170
|
p03698
|
python
|
s106366961
|
s901405935
| 29 | 26 | 8,984 | 9,088 |
Accepted
|
Accepted
| 10.34 |
s = eval(input())
n = len(s)
rs = sorted(s)
cnt = 0
ans = 'no'
for i in range(0, n-1):
if rs[i] != rs[i+1]:
cnt += 1
if cnt == n-1:
ans = 'yes'
print(ans)
exit()
print(ans)
|
s = eval(input())
rs = set(s)
if len(s) == len(rs):
print('yes')
else:
print('no')
| 13 | 6 | 235 | 90 |
s = eval(input())
n = len(s)
rs = sorted(s)
cnt = 0
ans = "no"
for i in range(0, n - 1):
if rs[i] != rs[i + 1]:
cnt += 1
if cnt == n - 1:
ans = "yes"
print(ans)
exit()
print(ans)
|
s = eval(input())
rs = set(s)
if len(s) == len(rs):
print("yes")
else:
print("no")
| false | 53.846154 |
[
"-n = len(s)",
"-rs = sorted(s)",
"-cnt = 0",
"-ans = \"no\"",
"-for i in range(0, n - 1):",
"- if rs[i] != rs[i + 1]:",
"- cnt += 1",
"- if cnt == n - 1:",
"- ans = \"yes\"",
"- print(ans)",
"- exit()",
"-print(ans)",
"+rs = set(s)",
"+if len(s) == len(rs):",
"+ print(\"yes\")",
"+else:",
"+ print(\"no\")"
] | false | 0.068178 | 0.078683 | 0.866486 |
[
"s106366961",
"s901405935"
] |
u192154323
|
p03160
|
python
|
s001004073
|
s433255267
| 171 | 141 | 18,836 | 13,928 |
Accepted
|
Accepted
| 17.54 |
n = int(eval(input()))
h_ls = list(map(int, input().split()))
h_ls = h_ls
# ここからはh_lsのインデックスを基準に
one_cost = [0] * (n)
for i in range(n-1):
one_cost[i+1] = abs(h_ls[i+1] - h_ls[i])
two_cost = [0] * (n)
for i in range(n-2):
two_cost[i+2] = abs(h_ls[i+2] - h_ls[i])
mincost_ls = [0] * (n)
mincost_ls[1] = one_cost[1]
for i in range(n-2):
mincost_ls[i+2] = min(mincost_ls[i+1] + one_cost[i+2], mincost_ls[i] + two_cost[i+2])
print((mincost_ls[-1]))
|
n = int(eval(input()))
h_ls = list(map(int, input().split()))
h_ls = h_ls
mincost_ls = [float('inf')] * n
mincost_ls[0] = 0
mincost_ls[1] = abs(h_ls[1] - h_ls[0])
for i in range(n-2):
mincost_ls[i+2] = min(mincost_ls[i+1] + abs(h_ls[i+2] - h_ls[i+1]),
mincost_ls[i] + abs(h_ls[i+2] - h_ls[i]))
print((mincost_ls[-1]))
| 17 | 11 | 467 | 333 |
n = int(eval(input()))
h_ls = list(map(int, input().split()))
h_ls = h_ls
# ここからはh_lsのインデックスを基準に
one_cost = [0] * (n)
for i in range(n - 1):
one_cost[i + 1] = abs(h_ls[i + 1] - h_ls[i])
two_cost = [0] * (n)
for i in range(n - 2):
two_cost[i + 2] = abs(h_ls[i + 2] - h_ls[i])
mincost_ls = [0] * (n)
mincost_ls[1] = one_cost[1]
for i in range(n - 2):
mincost_ls[i + 2] = min(
mincost_ls[i + 1] + one_cost[i + 2], mincost_ls[i] + two_cost[i + 2]
)
print((mincost_ls[-1]))
|
n = int(eval(input()))
h_ls = list(map(int, input().split()))
h_ls = h_ls
mincost_ls = [float("inf")] * n
mincost_ls[0] = 0
mincost_ls[1] = abs(h_ls[1] - h_ls[0])
for i in range(n - 2):
mincost_ls[i + 2] = min(
mincost_ls[i + 1] + abs(h_ls[i + 2] - h_ls[i + 1]),
mincost_ls[i] + abs(h_ls[i + 2] - h_ls[i]),
)
print((mincost_ls[-1]))
| false | 35.294118 |
[
"-# ここからはh_lsのインデックスを基準に",
"-one_cost = [0] * (n)",
"-for i in range(n - 1):",
"- one_cost[i + 1] = abs(h_ls[i + 1] - h_ls[i])",
"-two_cost = [0] * (n)",
"-for i in range(n - 2):",
"- two_cost[i + 2] = abs(h_ls[i + 2] - h_ls[i])",
"-mincost_ls = [0] * (n)",
"-mincost_ls[1] = one_cost[1]",
"+mincost_ls = [float(\"inf\")] * n",
"+mincost_ls[0] = 0",
"+mincost_ls[1] = abs(h_ls[1] - h_ls[0])",
"- mincost_ls[i + 1] + one_cost[i + 2], mincost_ls[i] + two_cost[i + 2]",
"+ mincost_ls[i + 1] + abs(h_ls[i + 2] - h_ls[i + 1]),",
"+ mincost_ls[i] + abs(h_ls[i + 2] - h_ls[i]),"
] | false | 0.048358 | 0.048444 | 0.998218 |
[
"s001004073",
"s433255267"
] |
u287500079
|
p02885
|
python
|
s103570675
|
s003268080
| 20 | 17 | 3,316 | 2,940 |
Accepted
|
Accepted
| 15 |
a,b = list(map(int,input().split()))
if b * 2 >= a:
print((0))
else:
print((a-2*b))
|
a,b = list(map(int,input().split()))
print((max(0,a-2*b)))
'''
if b * 2 >= a:
print(0)
else:
print(a-2*b)
'''
| 7 | 9 | 93 | 118 |
a, b = list(map(int, input().split()))
if b * 2 >= a:
print((0))
else:
print((a - 2 * b))
|
a, b = list(map(int, input().split()))
print((max(0, a - 2 * b)))
"""
if b * 2 >= a:
print(0)
else:
print(a-2*b)
"""
| false | 22.222222 |
[
"+print((max(0, a - 2 * b)))",
"+\"\"\"",
"- print((0))",
"+ print(0)",
"- print((a - 2 * b))",
"+ print(a-2*b)",
"+\"\"\""
] | false | 0.057932 | 0.070663 | 0.819834 |
[
"s103570675",
"s003268080"
] |
u952708174
|
p03828
|
python
|
s541323929
|
s921301460
| 52 | 39 | 3,064 | 3,316 |
Accepted
|
Accepted
| 25 |
def c_factors_of_factorial(N):
def exponential_list(n):
# ret[k]: n!を素因数分解したときのkの指数
ret = {}
for j in range(2, n + 1):
current = j
ret[j] = 0
for k in range(2, j + 1):
while current % k == 0:
ret[k] += 1
current //= k
if ret[j] == 0:
ret.pop(j)
return ret
exp_list = exponential_list(N)
ans = 1
for e in list(exp_list.values()):
ans *= e + 1
ans %= 10**9 + 7
return ans
N = int(eval(input()))
print((c_factors_of_factorial(N)))
|
def c_factors_of_factorial(N):
import math
def prime_decomposition(n):
# nを素因数分解
from collections import defaultdict
i = 2
table = defaultdict(int)
while i**2 <= n:
while n % i == 0:
n //= i
table[i] += 1
i += 1
if n > 1:
table[n] += 1
return table
exp_list = prime_decomposition(math.factorial(N))
ans = 1
for v in list(exp_list.values()):
ans = (ans * (v + 1)) % (10**9 + 7)
return ans
N = int(eval(input()))
print((c_factors_of_factorial(N)))
| 24 | 25 | 626 | 614 |
def c_factors_of_factorial(N):
def exponential_list(n):
# ret[k]: n!を素因数分解したときのkの指数
ret = {}
for j in range(2, n + 1):
current = j
ret[j] = 0
for k in range(2, j + 1):
while current % k == 0:
ret[k] += 1
current //= k
if ret[j] == 0:
ret.pop(j)
return ret
exp_list = exponential_list(N)
ans = 1
for e in list(exp_list.values()):
ans *= e + 1
ans %= 10**9 + 7
return ans
N = int(eval(input()))
print((c_factors_of_factorial(N)))
|
def c_factors_of_factorial(N):
import math
def prime_decomposition(n):
# nを素因数分解
from collections import defaultdict
i = 2
table = defaultdict(int)
while i**2 <= n:
while n % i == 0:
n //= i
table[i] += 1
i += 1
if n > 1:
table[n] += 1
return table
exp_list = prime_decomposition(math.factorial(N))
ans = 1
for v in list(exp_list.values()):
ans = (ans * (v + 1)) % (10**9 + 7)
return ans
N = int(eval(input()))
print((c_factors_of_factorial(N)))
| false | 4 |
[
"- def exponential_list(n):",
"- # ret[k]: n!を素因数分解したときのkの指数",
"- ret = {}",
"- for j in range(2, n + 1):",
"- current = j",
"- ret[j] = 0",
"- for k in range(2, j + 1):",
"- while current % k == 0:",
"- ret[k] += 1",
"- current //= k",
"- if ret[j] == 0:",
"- ret.pop(j)",
"- return ret",
"+ import math",
"- exp_list = exponential_list(N)",
"+ def prime_decomposition(n):",
"+ # nを素因数分解",
"+ from collections import defaultdict",
"+",
"+ i = 2",
"+ table = defaultdict(int)",
"+ while i**2 <= n:",
"+ while n % i == 0:",
"+ n //= i",
"+ table[i] += 1",
"+ i += 1",
"+ if n > 1:",
"+ table[n] += 1",
"+ return table",
"+",
"+ exp_list = prime_decomposition(math.factorial(N))",
"- for e in list(exp_list.values()):",
"- ans *= e + 1",
"- ans %= 10**9 + 7",
"+ for v in list(exp_list.values()):",
"+ ans = (ans * (v + 1)) % (10**9 + 7)"
] | false | 0.140047 | 0.197674 | 0.708476 |
[
"s541323929",
"s921301460"
] |
u836939578
|
p03855
|
python
|
s497118646
|
s922031916
| 1,471 | 899 | 119,256 | 108,888 |
Accepted
|
Accepted
| 38.89 |
from collections import*
class UnionFind:
def __init__(self, n):
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
N, K, L = list(map(int, input().split()))
road = UnionFind(N)
rail = UnionFind(N)
for i in range(K):
p, q = list(map(int, input().split()))
road.union(p-1, q-1)
for i in range(L):
p, q = list(map(int, input().split()))
rail.union(p-1, q-1)
d = defaultdict(int)
for i in range(N):
d[(road.find(i), rail.find(i))] += 1
print((*[d[(road.find(i), rail.find(i))] for i in range(N)]))
|
from collections import defaultdict
import sys
input = lambda: sys.stdin.readline().rstrip()
class UnionFind:
def __init__(self, n):
self.parents = [-1]*n
def find(self, x):
if self.parents[x] < 0:
return x
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x,y = y,x
self.parents[x] += self.parents[y]
self.parents[y] = x
N,K,L = list(map(int, input().split()))
road_union = UnionFind(N)
rails_union = UnionFind(N)
for i in range(K):
p,q = list(map(int, input().split()))
p -= 1
q -= 1
road_union.union(p,q)
for i in range(L):
r,s = list(map(int, input().split()))
r -= 1
s -= 1
rails_union.union(r,s)
d = defaultdict(int)
for i in range(N):
d[(road_union.find(i), rails_union.find(i))] += 1
print((*[d[(road_union.find(i),rails_union.find(i))] for i in range(N)]))
| 42 | 54 | 959 | 1,116 |
from collections import *
class UnionFind:
def __init__(self, n):
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
N, K, L = list(map(int, input().split()))
road = UnionFind(N)
rail = UnionFind(N)
for i in range(K):
p, q = list(map(int, input().split()))
road.union(p - 1, q - 1)
for i in range(L):
p, q = list(map(int, input().split()))
rail.union(p - 1, q - 1)
d = defaultdict(int)
for i in range(N):
d[(road.find(i), rail.find(i))] += 1
print((*[d[(road.find(i), rail.find(i))] for i in range(N)]))
|
from collections import defaultdict
import sys
input = lambda: sys.stdin.readline().rstrip()
class UnionFind:
def __init__(self, n):
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
N, K, L = list(map(int, input().split()))
road_union = UnionFind(N)
rails_union = UnionFind(N)
for i in range(K):
p, q = list(map(int, input().split()))
p -= 1
q -= 1
road_union.union(p, q)
for i in range(L):
r, s = list(map(int, input().split()))
r -= 1
s -= 1
rails_union.union(r, s)
d = defaultdict(int)
for i in range(N):
d[(road_union.find(i), rails_union.find(i))] += 1
print((*[d[(road_union.find(i), rails_union.find(i))] for i in range(N)]))
| false | 22.222222 |
[
"-from collections import *",
"+from collections import defaultdict",
"+import sys",
"+",
"+input = lambda: sys.stdin.readline().rstrip()",
"-road = UnionFind(N)",
"-rail = UnionFind(N)",
"+road_union = UnionFind(N)",
"+rails_union = UnionFind(N)",
"- road.union(p - 1, q - 1)",
"+ p -= 1",
"+ q -= 1",
"+ road_union.union(p, q)",
"- p, q = list(map(int, input().split()))",
"- rail.union(p - 1, q - 1)",
"+ r, s = list(map(int, input().split()))",
"+ r -= 1",
"+ s -= 1",
"+ rails_union.union(r, s)",
"- d[(road.find(i), rail.find(i))] += 1",
"-print((*[d[(road.find(i), rail.find(i))] for i in range(N)]))",
"+ d[(road_union.find(i), rails_union.find(i))] += 1",
"+print((*[d[(road_union.find(i), rails_union.find(i))] for i in range(N)]))"
] | false | 0.104544 | 0.039441 | 2.650674 |
[
"s497118646",
"s922031916"
] |
u387562669
|
p03775
|
python
|
s693678421
|
s888914189
| 53 | 28 | 3,060 | 3,060 |
Accepted
|
Accepted
| 47.17 |
import math
def main():
#infile = open("compprog.txt", mode="r")
n = int(eval(input()))
res = f(1, n)
i = 2
while i <= math.sqrt(n):
if n % i == 0:
this_f = f(i, n // i)
res = this_f if this_f < res else res
i += 1
print(res)
#infile.close()
def f(a, b):
return max(len(str(a)), len(str(b)))
if __name__ == "__main__":
main()
|
import math
def main():
n = int(eval(input()))
res = f(1, n)
for i in range(1, int(math.sqrt(n)) + 1):
if n % i == 0:
res = min(res, f(i, n // i))
print(res)
def f(a, b):
return max(len(str(a)), len(str(b)))
if __name__ == "__main__":
main()
| 23 | 18 | 424 | 303 |
import math
def main():
# infile = open("compprog.txt", mode="r")
n = int(eval(input()))
res = f(1, n)
i = 2
while i <= math.sqrt(n):
if n % i == 0:
this_f = f(i, n // i)
res = this_f if this_f < res else res
i += 1
print(res)
# infile.close()
def f(a, b):
return max(len(str(a)), len(str(b)))
if __name__ == "__main__":
main()
|
import math
def main():
n = int(eval(input()))
res = f(1, n)
for i in range(1, int(math.sqrt(n)) + 1):
if n % i == 0:
res = min(res, f(i, n // i))
print(res)
def f(a, b):
return max(len(str(a)), len(str(b)))
if __name__ == "__main__":
main()
| false | 21.73913 |
[
"- # infile = open(\"compprog.txt\", mode=\"r\")",
"- i = 2",
"- while i <= math.sqrt(n):",
"+ for i in range(1, int(math.sqrt(n)) + 1):",
"- this_f = f(i, n // i)",
"- res = this_f if this_f < res else res",
"- i += 1",
"+ res = min(res, f(i, n // i))",
"- # infile.close()"
] | false | 0.044923 | 0.079426 | 0.565598 |
[
"s693678421",
"s888914189"
] |
u708255304
|
p02990
|
python
|
s122306937
|
s628042963
| 329 | 23 | 5,748 | 3,696 |
Accepted
|
Accepted
| 93.01 |
def culc_factrial(n):
factrial = [1] * (n+1)
for i in range(1, n+1):
factrial[i] = factrial[i-1] * i
return factrial
N, K = list(map(int, input().split()))
factrial = culc_factrial(2000)
for i in range(1, K+1):
hoge = factrial[N-K+1] // (factrial[i]*factrial[N-K+1-i])
fuga = factrial[K-1] // (factrial[i-1]*factrial[K-i])
print((hoge*fuga % (1000000007)))
|
# 二項係数を"やるだけ"にしてくれるライブラリ
MAX = 3000
MOD = 1000000007
factrial = [0]*MAX
inverse = [0]*MAX
factrial_inverse = [0]*MAX
# テーブルを作る前処理
def COMinit():
global factrial, inverse, factrial_inverse
factrial[0] = 1
factrial[1] = 1
inverse[1] = 1
factrial_inverse[0] = 1
factrial_inverse[1] = 1
for i in range(2, MAX):
factrial[i] = factrial[i-1] * i % MOD
inverse[i] = MOD - inverse[MOD % i] * (MOD//i) % MOD
factrial_inverse[i] = factrial_inverse[i-1] * inverse[i] % MOD
# 二項係数計算
def COM(n, k):
global factrial, inverse, factrial_inverse
if n < k:
return 0
if n < 0 or k < 0:
return 0
return factrial[n] * (factrial_inverse[k] * factrial_inverse[n-k] % MOD) % MOD
# 前処理完了
COMinit()
N, K = list(map(int, input().split())) # 合計N個のボール, K個の青いボール, N-K個の赤いボール
for i in range(1, K+1):
print((COM(N-K+1, i) * COM(K-1, i-1) % MOD))
| 15 | 39 | 399 | 940 |
def culc_factrial(n):
factrial = [1] * (n + 1)
for i in range(1, n + 1):
factrial[i] = factrial[i - 1] * i
return factrial
N, K = list(map(int, input().split()))
factrial = culc_factrial(2000)
for i in range(1, K + 1):
hoge = factrial[N - K + 1] // (factrial[i] * factrial[N - K + 1 - i])
fuga = factrial[K - 1] // (factrial[i - 1] * factrial[K - i])
print((hoge * fuga % (1000000007)))
|
# 二項係数を"やるだけ"にしてくれるライブラリ
MAX = 3000
MOD = 1000000007
factrial = [0] * MAX
inverse = [0] * MAX
factrial_inverse = [0] * MAX
# テーブルを作る前処理
def COMinit():
global factrial, inverse, factrial_inverse
factrial[0] = 1
factrial[1] = 1
inverse[1] = 1
factrial_inverse[0] = 1
factrial_inverse[1] = 1
for i in range(2, MAX):
factrial[i] = factrial[i - 1] * i % MOD
inverse[i] = MOD - inverse[MOD % i] * (MOD // i) % MOD
factrial_inverse[i] = factrial_inverse[i - 1] * inverse[i] % MOD
# 二項係数計算
def COM(n, k):
global factrial, inverse, factrial_inverse
if n < k:
return 0
if n < 0 or k < 0:
return 0
return factrial[n] * (factrial_inverse[k] * factrial_inverse[n - k] % MOD) % MOD
# 前処理完了
COMinit()
N, K = list(map(int, input().split())) # 合計N個のボール, K個の青いボール, N-K個の赤いボール
for i in range(1, K + 1):
print((COM(N - K + 1, i) * COM(K - 1, i - 1) % MOD))
| false | 61.538462 |
[
"-def culc_factrial(n):",
"- factrial = [1] * (n + 1)",
"- for i in range(1, n + 1):",
"- factrial[i] = factrial[i - 1] * i",
"- return factrial",
"+# 二項係数を\"やるだけ\"にしてくれるライブラリ",
"+MAX = 3000",
"+MOD = 1000000007",
"+factrial = [0] * MAX",
"+inverse = [0] * MAX",
"+factrial_inverse = [0] * MAX",
"+# テーブルを作る前処理",
"+def COMinit():",
"+ global factrial, inverse, factrial_inverse",
"+ factrial[0] = 1",
"+ factrial[1] = 1",
"+ inverse[1] = 1",
"+ factrial_inverse[0] = 1",
"+ factrial_inverse[1] = 1",
"+ for i in range(2, MAX):",
"+ factrial[i] = factrial[i - 1] * i % MOD",
"+ inverse[i] = MOD - inverse[MOD % i] * (MOD // i) % MOD",
"+ factrial_inverse[i] = factrial_inverse[i - 1] * inverse[i] % MOD",
"-N, K = list(map(int, input().split()))",
"-factrial = culc_factrial(2000)",
"+# 二項係数計算",
"+def COM(n, k):",
"+ global factrial, inverse, factrial_inverse",
"+ if n < k:",
"+ return 0",
"+ if n < 0 or k < 0:",
"+ return 0",
"+ return factrial[n] * (factrial_inverse[k] * factrial_inverse[n - k] % MOD) % MOD",
"+",
"+",
"+# 前処理完了",
"+COMinit()",
"+N, K = list(map(int, input().split())) # 合計N個のボール, K個の青いボール, N-K個の赤いボール",
"- hoge = factrial[N - K + 1] // (factrial[i] * factrial[N - K + 1 - i])",
"- fuga = factrial[K - 1] // (factrial[i - 1] * factrial[K - i])",
"- print((hoge * fuga % (1000000007)))",
"+ print((COM(N - K + 1, i) * COM(K - 1, i - 1) % MOD))"
] | false | 0.270071 | 0.039335 | 6.865834 |
[
"s122306937",
"s628042963"
] |
u774160580
|
p02983
|
python
|
s251641335
|
s150098514
| 966 | 768 | 2,940 | 2,940 |
Accepted
|
Accepted
| 20.5 |
L, R = list(map(int, input().split()))
ans = 2018
for i in range(L, min(R, L + 2019) + 1):
for j in range(i + 1, min(R, L + 2019) + 1):
ans = min(ans, ((i % 2019) * (j % 2019)) % 2019)
print(ans)
|
L, R = list(map(int, input().split()))
ans = 2018
for i in range(L, min(L + 2019, R) + 1):
for j in range(i + 1, min(L + 2019, R) + 1):
ans = min(ans, (i * j) % 2019)
print(ans)
| 6 | 6 | 213 | 189 |
L, R = list(map(int, input().split()))
ans = 2018
for i in range(L, min(R, L + 2019) + 1):
for j in range(i + 1, min(R, L + 2019) + 1):
ans = min(ans, ((i % 2019) * (j % 2019)) % 2019)
print(ans)
|
L, R = list(map(int, input().split()))
ans = 2018
for i in range(L, min(L + 2019, R) + 1):
for j in range(i + 1, min(L + 2019, R) + 1):
ans = min(ans, (i * j) % 2019)
print(ans)
| false | 0 |
[
"-for i in range(L, min(R, L + 2019) + 1):",
"- for j in range(i + 1, min(R, L + 2019) + 1):",
"- ans = min(ans, ((i % 2019) * (j % 2019)) % 2019)",
"+for i in range(L, min(L + 2019, R) + 1):",
"+ for j in range(i + 1, min(L + 2019, R) + 1):",
"+ ans = min(ans, (i * j) % 2019)"
] | false | 0.105298 | 0.14094 | 0.747112 |
[
"s251641335",
"s150098514"
] |
u432356156
|
p03075
|
python
|
s982072334
|
s330959127
| 308 | 19 | 21,368 | 3,060 |
Accepted
|
Accepted
| 93.83 |
import numpy as np
num = [] #5このアンテナ
for i in range(5): #入力
a = eval(input())
num.append(int(a))
k=int(eval(input()))
num.sort()
ran=num[4]-num[0]
if ran > k:
print(":(")
else:
print("Yay!")
|
a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
d = int(eval(input()))
e = int(eval(input()))
k = int(eval(input()))
if(e-a <= k):
print("Yay!")
else:
print(":(")
| 18 | 11 | 217 | 167 |
import numpy as np
num = [] # 5このアンテナ
for i in range(5): # 入力
a = eval(input())
num.append(int(a))
k = int(eval(input()))
num.sort()
ran = num[4] - num[0]
if ran > k:
print(":(")
else:
print("Yay!")
|
a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
d = int(eval(input()))
e = int(eval(input()))
k = int(eval(input()))
if e - a <= k:
print("Yay!")
else:
print(":(")
| false | 38.888889 |
[
"-import numpy as np",
"-",
"-num = [] # 5このアンテナ",
"-for i in range(5): # 入力",
"- a = eval(input())",
"- num.append(int(a))",
"+a = int(eval(input()))",
"+b = int(eval(input()))",
"+c = int(eval(input()))",
"+d = int(eval(input()))",
"+e = int(eval(input()))",
"-num.sort()",
"-ran = num[4] - num[0]",
"-if ran > k:",
"+if e - a <= k:",
"+ print(\"Yay!\")",
"+else:",
"-else:",
"- print(\"Yay!\")"
] | false | 0.043838 | 0.036314 | 1.207204 |
[
"s982072334",
"s330959127"
] |
u222801992
|
p03163
|
python
|
s212495429
|
s976993052
| 301 | 276 | 41,452 | 43,184 |
Accepted
|
Accepted
| 8.31 |
n,W=list(map(int,input().split()))
w=[0]*n
v=[0]*n
for i in range(n):
w[i],v[i]=list(map(int,input().split()))
dp=[0]*(W+1)
for i in range(n):
j=W
while j>=w[i]:
dp[j]=max(dp[j],dp[j-w[i]]+v[i])
j-=1
print((dp[W]))
|
"""
【01ナップザック問題】
重さと価値がそれぞれw_i,v_iであるようなn個の品物がある.
これらの品物の中から, 重さの総和がWを超えないように選んだ時の,
価値の総和の最大値を求めよ.
1<=n<=100, 1<=w_i,v_i<=100, 1<=W<=10000
"""
#------------------------------------------------------------------------------
#入力,準備
n,W= list(map(int,input().split()))
w=[0]*n
v=[0]*n
for i in range(n):
w[i],v[i]=list(map(int,input().split()))
dp=[0]*(W+1)
#メイン
#dp[j] : 重さの総和がjを超えないように選んだ時の価値の総和の最大値
for i in range(n):
j=W
while j>=w[i]:
dp[j]=max(dp[j],dp[j-w[i]]+v[i])
j-=1
print((dp[W]))
| 13 | 26 | 241 | 531 |
n, W = list(map(int, input().split()))
w = [0] * n
v = [0] * n
for i in range(n):
w[i], v[i] = list(map(int, input().split()))
dp = [0] * (W + 1)
for i in range(n):
j = W
while j >= w[i]:
dp[j] = max(dp[j], dp[j - w[i]] + v[i])
j -= 1
print((dp[W]))
|
"""
【01ナップザック問題】
重さと価値がそれぞれw_i,v_iであるようなn個の品物がある.
これらの品物の中から, 重さの総和がWを超えないように選んだ時の,
価値の総和の最大値を求めよ.
1<=n<=100, 1<=w_i,v_i<=100, 1<=W<=10000
"""
# ------------------------------------------------------------------------------
# 入力,準備
n, W = list(map(int, input().split()))
w = [0] * n
v = [0] * n
for i in range(n):
w[i], v[i] = list(map(int, input().split()))
dp = [0] * (W + 1)
# メイン
# dp[j] : 重さの総和がjを超えないように選んだ時の価値の総和の最大値
for i in range(n):
j = W
while j >= w[i]:
dp[j] = max(dp[j], dp[j - w[i]] + v[i])
j -= 1
print((dp[W]))
| false | 50 |
[
"+\"\"\"",
"+【01ナップザック問題】",
"+重さと価値がそれぞれw_i,v_iであるようなn個の品物がある.",
"+これらの品物の中から, 重さの総和がWを超えないように選んだ時の,",
"+価値の総和の最大値を求めよ.",
"+1<=n<=100, 1<=w_i,v_i<=100, 1<=W<=10000",
"+\"\"\"",
"+# 入力,準備",
"+# メイン",
"+# dp[j] : 重さの総和がjを超えないように選んだ時の価値の総和の最大値"
] | false | 0.008097 | 0.038942 | 0.207934 |
[
"s212495429",
"s976993052"
] |
u505420467
|
p02767
|
python
|
s460952740
|
s317423987
| 19 | 17 | 3,064 | 2,940 |
Accepted
|
Accepted
| 10.53 |
n = int(eval(input()))
x = list(map(int, input().split()))
avg = round(sum(x) / n)
ans = 0
for i in x:
ans += (i - avg) ** 2
print(ans)
|
if __name__ == '__main__':
n = int(eval(input()))
x = list(map(int, input().split()))
p = round(sum(x) / n)
ans = 0
for i in x:
ans += (i - p) ** 2
print(ans)
| 11 | 8 | 147 | 192 |
n = int(eval(input()))
x = list(map(int, input().split()))
avg = round(sum(x) / n)
ans = 0
for i in x:
ans += (i - avg) ** 2
print(ans)
|
if __name__ == "__main__":
n = int(eval(input()))
x = list(map(int, input().split()))
p = round(sum(x) / n)
ans = 0
for i in x:
ans += (i - p) ** 2
print(ans)
| false | 27.272727 |
[
"-n = int(eval(input()))",
"-x = list(map(int, input().split()))",
"-avg = round(sum(x) / n)",
"-ans = 0",
"-for i in x:",
"- ans += (i - avg) ** 2",
"-print(ans)",
"+if __name__ == \"__main__\":",
"+ n = int(eval(input()))",
"+ x = list(map(int, input().split()))",
"+ p = round(sum(x) / n)",
"+ ans = 0",
"+ for i in x:",
"+ ans += (i - p) ** 2",
"+ print(ans)"
] | false | 0.069813 | 0.070244 | 0.993863 |
[
"s460952740",
"s317423987"
] |
u740284863
|
p03807
|
python
|
s012139535
|
s004256300
| 50 | 44 | 14,112 | 14,112 |
Accepted
|
Accepted
| 12 |
n = int(eval(input()))
A = list(map(int,input().split()))
A = [_ % 2 for _ in A]
if sum(A) % 2 == 0:
print("YES")
else:
print("NO")
|
n = int(eval(input()))
A = list(map(int,input().split()))
if sum(A) % 2 == 0:
print("YES")
else:
print("NO")
| 7 | 6 | 140 | 116 |
n = int(eval(input()))
A = list(map(int, input().split()))
A = [_ % 2 for _ in A]
if sum(A) % 2 == 0:
print("YES")
else:
print("NO")
|
n = int(eval(input()))
A = list(map(int, input().split()))
if sum(A) % 2 == 0:
print("YES")
else:
print("NO")
| false | 14.285714 |
[
"-A = [_ % 2 for _ in A]"
] | false | 0.048963 | 0.035481 | 1.379984 |
[
"s012139535",
"s004256300"
] |
u345966487
|
p03674
|
python
|
s335102653
|
s591118230
| 511 | 408 | 75,060 | 62,772 |
Accepted
|
Accepted
| 20.16 |
n,*a=list(map(int,open(0).read().split()));b={};M=10**9+7
for i,x in enumerate(a):b.setdefault(x,[]).append(i)
p=n+1;q=r=1;d=[abs(j[0]-j[1])for x,j in list(b.items())if len(j)>1][0]
for k in range(n+1):print(((p-q)%M));q=q*(n-d-k)*r%M;r=pow(k+2,M-2,M);p=p*(n-k)*r%M
|
n,*a=list(map(int,open(0).read().split()));b={};M=10**9+7;p=n+1;q=r=1
for i,x in enumerate(a):
if x in b:d=i-b[x];break
b[x]=i
for k in range(n+1):print(((p-q)%M));q=q*(n-d-k)*r%M;r=pow(k+2,M-2,M);p=p*(n-k)*r%M
| 4 | 5 | 254 | 208 |
n, *a = list(map(int, open(0).read().split()))
b = {}
M = 10**9 + 7
for i, x in enumerate(a):
b.setdefault(x, []).append(i)
p = n + 1
q = r = 1
d = [abs(j[0] - j[1]) for x, j in list(b.items()) if len(j) > 1][0]
for k in range(n + 1):
print(((p - q) % M))
q = q * (n - d - k) * r % M
r = pow(k + 2, M - 2, M)
p = p * (n - k) * r % M
|
n, *a = list(map(int, open(0).read().split()))
b = {}
M = 10**9 + 7
p = n + 1
q = r = 1
for i, x in enumerate(a):
if x in b:
d = i - b[x]
break
b[x] = i
for k in range(n + 1):
print(((p - q) % M))
q = q * (n - d - k) * r % M
r = pow(k + 2, M - 2, M)
p = p * (n - k) * r % M
| false | 20 |
[
"-for i, x in enumerate(a):",
"- b.setdefault(x, []).append(i)",
"-d = [abs(j[0] - j[1]) for x, j in list(b.items()) if len(j) > 1][0]",
"+for i, x in enumerate(a):",
"+ if x in b:",
"+ d = i - b[x]",
"+ break",
"+ b[x] = i"
] | false | 0.053086 | 0.040951 | 1.296345 |
[
"s335102653",
"s591118230"
] |
u980205854
|
p03053
|
python
|
s134236156
|
s820246499
| 439 | 342 | 83,928 | 122,008 |
Accepted
|
Accepted
| 22.1 |
# A - Darker and Darker
from collections import deque
H,W = list(map(int,input().split()))
B = [[-1] * W for _ in range(H)]
queue = deque([])
for i in range(H):
A = eval(input())
for j in range(W):
if A[j]=='#':
B[i][j] = 0
queue.append((i,j))
ans = 0
while queue:
I,J = queue.popleft()
for di,dj in ((-1,0),(1,0),(0,-1),(0,1)):
i,j = I+di,J+dj
if 0<=i<H and 0<=j<W:
if B[i][j]<0:
B[i][j] = B[I][J]+1
ans = max(ans,B[i][j])
queue.append((i,j))
print(ans)
|
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians
sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7
def lcm(x,y):
return x*y//gcd(x,y)
def lgcd(l):
return reduce(gcd,l)
def llcm(l):
return reduce(lcm,l)
def powmod(n,i,mod=MOD):
return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
return x.bit_length()
def div10(x):
return len(str(x))-(x==0)
def intput():
return int(input())
def mint():
return map(int,input().split())
def lint():
return list(map(int,input().split()))
def ilint():
return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
print(l[0] if x else l[1])
def lprint(l, sep='\n'):
for x in l:
print(x, end=sep)
def ston(c, c0='a'):
return ord(c)-ord(c0)
def ntos(x, c0='a'):
return chr(x+ord(c0))
class counter(dict):
def __init__(self, *args):
super().__init__(args)
def add(self,x,d=1):
self.setdefault(x,0)
self[x] += d
def list(self):
l = []
for k in self:
l.extend([k]*self[k])
return l
class comb():
def __init__(self, n, mod=None):
self.l = [1]
self.n = n
self.mod = mod
def get(self,k):
l,n,mod = self.l, self.n, self.mod
k = n-k if k>n//2 else k
while len(l)<=k:
i = len(l)
l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
return l[k]
def pf(x,mode='counter'):
C = counter()
p = 2
while x>1:
k = 0
while x%p==0:
x //= p
k += 1
if k>0:
C.add(p,k)
p = p+2-(p==2) if p*p<x else x
if mode=='counter':
return C
S = set([1])
for k in C:
T = deepcopy(S)
for x in T:
for i in range(1,C[k]+1):
S.add(x*(k**i))
if mode=='set':
return S
if mode=='list':
return sorted(list(S))
######################################################
H,W=mint()
A=[input() for _ in range(H)]
C=[[0]*W for _ in range(H)]
for i,j in product(range(H),range(W)):
if A[i][j]=='.':
C[i][j]=INF
for i,j in product(range(H),range(1,W)):
C[i][j] = min(C[i][j],C[i][j-1]+1)
for i,j in product(range(1,H),range(W)):
C[i][j] = min(C[i][j],C[i-1][j]+1)
for i,j in product(range(H),range(W-2,-1,-1)):
C[i][j] = min(C[i][j],C[i][j+1]+1)
for i,j in product(range(H-2,-1,-1),range(W)):
C[i][j] = min(C[i][j],C[i+1][j]+1)
print(max([max(c) for c in C]))
| 28 | 108 | 599 | 2,994 |
# A - Darker and Darker
from collections import deque
H, W = list(map(int, input().split()))
B = [[-1] * W for _ in range(H)]
queue = deque([])
for i in range(H):
A = eval(input())
for j in range(W):
if A[j] == "#":
B[i][j] = 0
queue.append((i, j))
ans = 0
while queue:
I, J = queue.popleft()
for di, dj in ((-1, 0), (1, 0), (0, -1), (0, 1)):
i, j = I + di, J + dj
if 0 <= i < H and 0 <= j < W:
if B[i][j] < 0:
B[i][j] = B[I][J] + 1
ans = max(ans, B[i][j])
queue.append((i, j))
print(ans)
|
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians
sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9 + 7
def lcm(x, y):
return x * y // gcd(x, y)
def lgcd(l):
return reduce(gcd, l)
def llcm(l):
return reduce(lcm, l)
def powmod(n, i, mod=MOD):
return pow(n, mod - 1 + i, mod) if i < 0 else pow(n, i, mod)
def div2(x):
return x.bit_length()
def div10(x):
return len(str(x)) - (x == 0)
def intput():
return int(input())
def mint():
return map(int, input().split())
def lint():
return list(map(int, input().split()))
def ilint():
return int(input()), list(map(int, input().split()))
def judge(x, l=["Yes", "No"]):
print(l[0] if x else l[1])
def lprint(l, sep="\n"):
for x in l:
print(x, end=sep)
def ston(c, c0="a"):
return ord(c) - ord(c0)
def ntos(x, c0="a"):
return chr(x + ord(c0))
class counter(dict):
def __init__(self, *args):
super().__init__(args)
def add(self, x, d=1):
self.setdefault(x, 0)
self[x] += d
def list(self):
l = []
for k in self:
l.extend([k] * self[k])
return l
class comb:
def __init__(self, n, mod=None):
self.l = [1]
self.n = n
self.mod = mod
def get(self, k):
l, n, mod = self.l, self.n, self.mod
k = n - k if k > n // 2 else k
while len(l) <= k:
i = len(l)
l.append(
l[i - 1] * (n + 1 - i) // i
if mod == None
else (l[i - 1] * (n + 1 - i) * powmod(i, -1, mod)) % mod
)
return l[k]
def pf(x, mode="counter"):
C = counter()
p = 2
while x > 1:
k = 0
while x % p == 0:
x //= p
k += 1
if k > 0:
C.add(p, k)
p = p + 2 - (p == 2) if p * p < x else x
if mode == "counter":
return C
S = set([1])
for k in C:
T = deepcopy(S)
for x in T:
for i in range(1, C[k] + 1):
S.add(x * (k**i))
if mode == "set":
return S
if mode == "list":
return sorted(list(S))
######################################################
H, W = mint()
A = [input() for _ in range(H)]
C = [[0] * W for _ in range(H)]
for i, j in product(range(H), range(W)):
if A[i][j] == ".":
C[i][j] = INF
for i, j in product(range(H), range(1, W)):
C[i][j] = min(C[i][j], C[i][j - 1] + 1)
for i, j in product(range(1, H), range(W)):
C[i][j] = min(C[i][j], C[i - 1][j] + 1)
for i, j in product(range(H), range(W - 2, -1, -1)):
C[i][j] = min(C[i][j], C[i][j + 1] + 1)
for i, j in product(range(H - 2, -1, -1), range(W)):
C[i][j] = min(C[i][j], C[i + 1][j] + 1)
print(max([max(c) for c in C]))
| false | 74.074074 |
[
"-# A - Darker and Darker",
"+import sys",
"+from sys import exit",
"+from copy import deepcopy",
"+from bisect import bisect_left, bisect_right, insort_left, insort_right",
"+from heapq import heapify, heappop, heappush",
"+from itertools import product, permutations, combinations, combinations_with_replacement",
"+from functools import reduce",
"+from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians",
"-H, W = list(map(int, input().split()))",
"-B = [[-1] * W for _ in range(H)]",
"-queue = deque([])",
"-for i in range(H):",
"- A = eval(input())",
"- for j in range(W):",
"- if A[j] == \"#\":",
"- B[i][j] = 0",
"- queue.append((i, j))",
"-ans = 0",
"-while queue:",
"- I, J = queue.popleft()",
"- for di, dj in ((-1, 0), (1, 0), (0, -1), (0, 1)):",
"- i, j = I + di, J + dj",
"- if 0 <= i < H and 0 <= j < W:",
"- if B[i][j] < 0:",
"- B[i][j] = B[I][J] + 1",
"- ans = max(ans, B[i][j])",
"- queue.append((i, j))",
"-print(ans)",
"+sys.setrecursionlimit(10**6)",
"+INF = 10**20",
"+eps = 1.0e-20",
"+MOD = 10**9 + 7",
"+",
"+",
"+def lcm(x, y):",
"+ return x * y // gcd(x, y)",
"+",
"+",
"+def lgcd(l):",
"+ return reduce(gcd, l)",
"+",
"+",
"+def llcm(l):",
"+ return reduce(lcm, l)",
"+",
"+",
"+def powmod(n, i, mod=MOD):",
"+ return pow(n, mod - 1 + i, mod) if i < 0 else pow(n, i, mod)",
"+",
"+",
"+def div2(x):",
"+ return x.bit_length()",
"+",
"+",
"+def div10(x):",
"+ return len(str(x)) - (x == 0)",
"+",
"+",
"+def intput():",
"+ return int(input())",
"+",
"+",
"+def mint():",
"+ return map(int, input().split())",
"+",
"+",
"+def lint():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def ilint():",
"+ return int(input()), list(map(int, input().split()))",
"+",
"+",
"+def judge(x, l=[\"Yes\", \"No\"]):",
"+ print(l[0] if x else l[1])",
"+",
"+",
"+def lprint(l, sep=\"\\n\"):",
"+ for x in l:",
"+ print(x, end=sep)",
"+",
"+",
"+def ston(c, c0=\"a\"):",
"+ return ord(c) - ord(c0)",
"+",
"+",
"+def ntos(x, c0=\"a\"):",
"+ return chr(x + ord(c0))",
"+",
"+",
"+class counter(dict):",
"+ def __init__(self, *args):",
"+ super().__init__(args)",
"+",
"+ def add(self, x, d=1):",
"+ self.setdefault(x, 0)",
"+ self[x] += d",
"+",
"+ def list(self):",
"+ l = []",
"+ for k in self:",
"+ l.extend([k] * self[k])",
"+ return l",
"+",
"+",
"+class comb:",
"+ def __init__(self, n, mod=None):",
"+ self.l = [1]",
"+ self.n = n",
"+ self.mod = mod",
"+",
"+ def get(self, k):",
"+ l, n, mod = self.l, self.n, self.mod",
"+ k = n - k if k > n // 2 else k",
"+ while len(l) <= k:",
"+ i = len(l)",
"+ l.append(",
"+ l[i - 1] * (n + 1 - i) // i",
"+ if mod == None",
"+ else (l[i - 1] * (n + 1 - i) * powmod(i, -1, mod)) % mod",
"+ )",
"+ return l[k]",
"+",
"+",
"+def pf(x, mode=\"counter\"):",
"+ C = counter()",
"+ p = 2",
"+ while x > 1:",
"+ k = 0",
"+ while x % p == 0:",
"+ x //= p",
"+ k += 1",
"+ if k > 0:",
"+ C.add(p, k)",
"+ p = p + 2 - (p == 2) if p * p < x else x",
"+ if mode == \"counter\":",
"+ return C",
"+ S = set([1])",
"+ for k in C:",
"+ T = deepcopy(S)",
"+ for x in T:",
"+ for i in range(1, C[k] + 1):",
"+ S.add(x * (k**i))",
"+ if mode == \"set\":",
"+ return S",
"+ if mode == \"list\":",
"+ return sorted(list(S))",
"+",
"+",
"+######################################################",
"+H, W = mint()",
"+A = [input() for _ in range(H)]",
"+C = [[0] * W for _ in range(H)]",
"+for i, j in product(range(H), range(W)):",
"+ if A[i][j] == \".\":",
"+ C[i][j] = INF",
"+for i, j in product(range(H), range(1, W)):",
"+ C[i][j] = min(C[i][j], C[i][j - 1] + 1)",
"+for i, j in product(range(1, H), range(W)):",
"+ C[i][j] = min(C[i][j], C[i - 1][j] + 1)",
"+for i, j in product(range(H), range(W - 2, -1, -1)):",
"+ C[i][j] = min(C[i][j], C[i][j + 1] + 1)",
"+for i, j in product(range(H - 2, -1, -1), range(W)):",
"+ C[i][j] = min(C[i][j], C[i + 1][j] + 1)",
"+print(max([max(c) for c in C]))"
] | false | 0.048462 | 0.168927 | 0.286882 |
[
"s134236156",
"s820246499"
] |
u698868214
|
p03612
|
python
|
s598980282
|
s089409202
| 81 | 74 | 20,436 | 20,520 |
Accepted
|
Accepted
| 8.64 |
N = int(eval(input()))
P = list(map(int,input().split()))
ls = [""] * N
cnt = 0
for i in range(N):
if P[i] == i + 1:
ls[i] = "#"
else:
ls[i] = "."
if ls[-1] == "#":
if ls[-2] == "#":
ls[-1], ls[-2] = ".", "."
else:
ls[-1] = "."
cnt += 1
for j in range(N-1):
if ls[j] == "#":
if ls[j+1] == "#":
ls[j+1] = "."
cnt += 1
print(cnt)
|
N = int(eval(input()))
P = list(map(int,input().split()))
ans = 0
if P[-1] == N:
ans += 1
P[-1] = -1
if P[-2] == N - 1:
P[-2] = -1
for i in range(N-1):
if P[i] == i + 1:
ans += 1
if P[i+1] == i + 2:
P[i+1] = -1
print(ans)
| 26 | 18 | 401 | 268 |
N = int(eval(input()))
P = list(map(int, input().split()))
ls = [""] * N
cnt = 0
for i in range(N):
if P[i] == i + 1:
ls[i] = "#"
else:
ls[i] = "."
if ls[-1] == "#":
if ls[-2] == "#":
ls[-1], ls[-2] = ".", "."
else:
ls[-1] = "."
cnt += 1
for j in range(N - 1):
if ls[j] == "#":
if ls[j + 1] == "#":
ls[j + 1] = "."
cnt += 1
print(cnt)
|
N = int(eval(input()))
P = list(map(int, input().split()))
ans = 0
if P[-1] == N:
ans += 1
P[-1] = -1
if P[-2] == N - 1:
P[-2] = -1
for i in range(N - 1):
if P[i] == i + 1:
ans += 1
if P[i + 1] == i + 2:
P[i + 1] = -1
print(ans)
| false | 30.769231 |
[
"-ls = [\"\"] * N",
"-cnt = 0",
"-for i in range(N):",
"+ans = 0",
"+if P[-1] == N:",
"+ ans += 1",
"+ P[-1] = -1",
"+ if P[-2] == N - 1:",
"+ P[-2] = -1",
"+for i in range(N - 1):",
"- ls[i] = \"#\"",
"- else:",
"- ls[i] = \".\"",
"-if ls[-1] == \"#\":",
"- if ls[-2] == \"#\":",
"- ls[-1], ls[-2] = \".\", \".\"",
"- else:",
"- ls[-1] = \".\"",
"- cnt += 1",
"-for j in range(N - 1):",
"- if ls[j] == \"#\":",
"- if ls[j + 1] == \"#\":",
"- ls[j + 1] = \".\"",
"- cnt += 1",
"-print(cnt)",
"+ ans += 1",
"+ if P[i + 1] == i + 2:",
"+ P[i + 1] = -1",
"+print(ans)"
] | false | 0.0423 | 0.04264 | 0.992011 |
[
"s598980282",
"s089409202"
] |
u372550522
|
p03476
|
python
|
s727515292
|
s873232165
| 1,835 | 1,128 | 3,572 | 9,172 |
Accepted
|
Accepted
| 38.53 |
def is_prime(n):
if n < 2:
return False
for i in range(2, int(n**0.5)+1):
if n % i == 0:
return False
return True
def bisect(lst, isok, ok, ng):
while(abs(ok-ng)>1):
mid = (ok+ng)//2
if isok(lst[mid]):
ok = mid
else:
ng = mid
return ok
s = []
for i in range(10**5):
if i%2 == 1 and is_prime(i) and is_prime((i+1)//2):
s.append(i)
s.sort()
q = int(eval(input()))
for k in range(q):
l, r = list(map(int, input().split()))
l0 = bisect(s, lambda x:x >= l, len(s), -1)
r0 = bisect(s, lambda x:x <= r, -1, len(s))
print((max(0, r0-l0+1)))
|
def is_prime(n):
if n < 2:
return False
for i in range(2, int(n**0.5)+1):
if n % i == 0:
return False
return True
s = [0] * (100001)
for i in range(1, 10**5+1):
if i%2 == 1 and is_prime(i) and is_prime((i+1)//2):
s[i-1] = 1
lst = [0] * (100001)
for i in range(10**5):
lst[i+1] = lst[i] + s[i]
q = int(eval(input()))
for k in range(q):
l, r = list(map(int, input().split()))
print((lst[r]-lst[l-1]))
| 30 | 21 | 675 | 472 |
def is_prime(n):
if n < 2:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
def bisect(lst, isok, ok, ng):
while abs(ok - ng) > 1:
mid = (ok + ng) // 2
if isok(lst[mid]):
ok = mid
else:
ng = mid
return ok
s = []
for i in range(10**5):
if i % 2 == 1 and is_prime(i) and is_prime((i + 1) // 2):
s.append(i)
s.sort()
q = int(eval(input()))
for k in range(q):
l, r = list(map(int, input().split()))
l0 = bisect(s, lambda x: x >= l, len(s), -1)
r0 = bisect(s, lambda x: x <= r, -1, len(s))
print((max(0, r0 - l0 + 1)))
|
def is_prime(n):
if n < 2:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
s = [0] * (100001)
for i in range(1, 10**5 + 1):
if i % 2 == 1 and is_prime(i) and is_prime((i + 1) // 2):
s[i - 1] = 1
lst = [0] * (100001)
for i in range(10**5):
lst[i + 1] = lst[i] + s[i]
q = int(eval(input()))
for k in range(q):
l, r = list(map(int, input().split()))
print((lst[r] - lst[l - 1]))
| false | 30 |
[
"-def bisect(lst, isok, ok, ng):",
"- while abs(ok - ng) > 1:",
"- mid = (ok + ng) // 2",
"- if isok(lst[mid]):",
"- ok = mid",
"- else:",
"- ng = mid",
"- return ok",
"-",
"-",
"-s = []",
"+s = [0] * (100001)",
"+for i in range(1, 10**5 + 1):",
"+ if i % 2 == 1 and is_prime(i) and is_prime((i + 1) // 2):",
"+ s[i - 1] = 1",
"+lst = [0] * (100001)",
"- if i % 2 == 1 and is_prime(i) and is_prime((i + 1) // 2):",
"- s.append(i)",
"-s.sort()",
"+ lst[i + 1] = lst[i] + s[i]",
"- l0 = bisect(s, lambda x: x >= l, len(s), -1)",
"- r0 = bisect(s, lambda x: x <= r, -1, len(s))",
"- print((max(0, r0 - l0 + 1)))",
"+ print((lst[r] - lst[l - 1]))"
] | false | 0.386831 | 1.435529 | 0.269469 |
[
"s727515292",
"s873232165"
] |
u708019102
|
p03160
|
python
|
s336628059
|
s329185894
| 183 | 133 | 13,924 | 13,928 |
Accepted
|
Accepted
| 27.32 |
N = int(eval(input()))
h = [int(x) for x in input().split()]
DP = [10000] * N
DP[0] = 0
DP[1] = max(h[0]-h[1],h[1]-h[0])
for i in range(2,N):
DP[i] = min(DP[i-2] + max(h[i]-h[i-2],h[i-2]-h[i]),DP[i-1] + max(h[i]-h[i-1],h[i-1]-h[i]))
print((DP[N-1]))
|
N = int(eval(input()))
h = [int(x) for x in input().split()]
DP=[0]*(N+1)
DP[2] = DP[1] + abs(h[0]-h[1])
for i in range(3,N+1):
DP[i] = min(DP[i-2] + abs(h[i-3]-h[i-1]),DP[i-1] + abs(h[i-2]-h[i-1]))
print((DP[N]))
| 8 | 7 | 250 | 215 |
N = int(eval(input()))
h = [int(x) for x in input().split()]
DP = [10000] * N
DP[0] = 0
DP[1] = max(h[0] - h[1], h[1] - h[0])
for i in range(2, N):
DP[i] = min(
DP[i - 2] + max(h[i] - h[i - 2], h[i - 2] - h[i]),
DP[i - 1] + max(h[i] - h[i - 1], h[i - 1] - h[i]),
)
print((DP[N - 1]))
|
N = int(eval(input()))
h = [int(x) for x in input().split()]
DP = [0] * (N + 1)
DP[2] = DP[1] + abs(h[0] - h[1])
for i in range(3, N + 1):
DP[i] = min(
DP[i - 2] + abs(h[i - 3] - h[i - 1]), DP[i - 1] + abs(h[i - 2] - h[i - 1])
)
print((DP[N]))
| false | 12.5 |
[
"-DP = [10000] * N",
"-DP[0] = 0",
"-DP[1] = max(h[0] - h[1], h[1] - h[0])",
"-for i in range(2, N):",
"+DP = [0] * (N + 1)",
"+DP[2] = DP[1] + abs(h[0] - h[1])",
"+for i in range(3, N + 1):",
"- DP[i - 2] + max(h[i] - h[i - 2], h[i - 2] - h[i]),",
"- DP[i - 1] + max(h[i] - h[i - 1], h[i - 1] - h[i]),",
"+ DP[i - 2] + abs(h[i - 3] - h[i - 1]), DP[i - 1] + abs(h[i - 2] - h[i - 1])",
"-print((DP[N - 1]))",
"+print((DP[N]))"
] | false | 0.052003 | 0.037023 | 1.404587 |
[
"s336628059",
"s329185894"
] |
u610120522
|
p02694
|
python
|
s405904470
|
s397496632
| 24 | 21 | 9,112 | 9,108 |
Accepted
|
Accepted
| 12.5 |
X = int(eval(input()))
count = 0
money = int(100)
while True:
money = int(money * 1.01)
count += 1
if money >= X:
print(count)
break
|
X = int(eval(input()))
count = 0
money = 100
while True:
money = int(money * 1.01)
count += 1
if money >= X:
print(count)
break
| 10 | 10 | 151 | 146 |
X = int(eval(input()))
count = 0
money = int(100)
while True:
money = int(money * 1.01)
count += 1
if money >= X:
print(count)
break
|
X = int(eval(input()))
count = 0
money = 100
while True:
money = int(money * 1.01)
count += 1
if money >= X:
print(count)
break
| false | 0 |
[
"-money = int(100)",
"+money = 100"
] | false | 0.038759 | 0.060177 | 0.644087 |
[
"s405904470",
"s397496632"
] |
u203843959
|
p03030
|
python
|
s029105575
|
s220289426
| 20 | 17 | 3,064 | 3,060 |
Accepted
|
Accepted
| 15 |
N=int(eval(input()))
rest_list = []
for i in range(N):
Si, Pi = input().split()
Pi = int(Pi)
rest_list.append((i+1,Si,Pi))
for i in range(N-1):
for j in range(i+1,N):
ii,Si,Pi = rest_list[i]
jj,Sj,Pj = rest_list[j]
if Si > Sj or (Si == Sj and Pi < Pj):
rest_list[i], rest_list[j] = (jj,Sj,Pj),(ii,Si,Pi)
for i in range(N):
i,Si,Pi = rest_list[i]
print(i)
|
N=int(eval(input()))
rest_list=[]
for i in range(N):
S,P=input().split()
rest_list.append((S,-int(P),i+1))
rest_list.sort()
for s,p,i in rest_list:
print(i)
| 19 | 9 | 420 | 165 |
N = int(eval(input()))
rest_list = []
for i in range(N):
Si, Pi = input().split()
Pi = int(Pi)
rest_list.append((i + 1, Si, Pi))
for i in range(N - 1):
for j in range(i + 1, N):
ii, Si, Pi = rest_list[i]
jj, Sj, Pj = rest_list[j]
if Si > Sj or (Si == Sj and Pi < Pj):
rest_list[i], rest_list[j] = (jj, Sj, Pj), (ii, Si, Pi)
for i in range(N):
i, Si, Pi = rest_list[i]
print(i)
|
N = int(eval(input()))
rest_list = []
for i in range(N):
S, P = input().split()
rest_list.append((S, -int(P), i + 1))
rest_list.sort()
for s, p, i in rest_list:
print(i)
| false | 52.631579 |
[
"- Si, Pi = input().split()",
"- Pi = int(Pi)",
"- rest_list.append((i + 1, Si, Pi))",
"-for i in range(N - 1):",
"- for j in range(i + 1, N):",
"- ii, Si, Pi = rest_list[i]",
"- jj, Sj, Pj = rest_list[j]",
"- if Si > Sj or (Si == Sj and Pi < Pj):",
"- rest_list[i], rest_list[j] = (jj, Sj, Pj), (ii, Si, Pi)",
"-for i in range(N):",
"- i, Si, Pi = rest_list[i]",
"+ S, P = input().split()",
"+ rest_list.append((S, -int(P), i + 1))",
"+rest_list.sort()",
"+for s, p, i in rest_list:"
] | false | 0.091459 | 0.046414 | 1.970523 |
[
"s029105575",
"s220289426"
] |
u731368968
|
p02702
|
python
|
s866087201
|
s415697491
| 138 | 79 | 76,532 | 75,768 |
Accepted
|
Accepted
| 42.75 |
S = eval(input())
mod = [0]
for d, c in enumerate(S[::-1]):
mod.append((int(c) * pow(10, d, 2019) + mod[-1]) % 2019)
from collections import *
print((sum(v * (v - 1) // 2 for v in list(Counter(mod).values()))))
|
mod = [0]
pw = 1
for c in input()[::-1]:
mod.append((int(c) * pw + mod[-1]) % 2019)
pw = pw * 10 % 2019
from collections import *
print((sum(v * (v - 1) // 2 for v in list(Counter(mod).values()))))
| 6 | 7 | 206 | 204 |
S = eval(input())
mod = [0]
for d, c in enumerate(S[::-1]):
mod.append((int(c) * pow(10, d, 2019) + mod[-1]) % 2019)
from collections import *
print((sum(v * (v - 1) // 2 for v in list(Counter(mod).values()))))
|
mod = [0]
pw = 1
for c in input()[::-1]:
mod.append((int(c) * pw + mod[-1]) % 2019)
pw = pw * 10 % 2019
from collections import *
print((sum(v * (v - 1) // 2 for v in list(Counter(mod).values()))))
| false | 14.285714 |
[
"-S = eval(input())",
"-for d, c in enumerate(S[::-1]):",
"- mod.append((int(c) * pow(10, d, 2019) + mod[-1]) % 2019)",
"+pw = 1",
"+for c in input()[::-1]:",
"+ mod.append((int(c) * pw + mod[-1]) % 2019)",
"+ pw = pw * 10 % 2019"
] | false | 0.093849 | 0.068446 | 1.371141 |
[
"s866087201",
"s415697491"
] |
u944886577
|
p02639
|
python
|
s603907984
|
s945990510
| 29 | 26 | 8,952 | 9,064 |
Accepted
|
Accepted
| 10.34 |
a=[]
a=input().split()
for i in range(5):
if a[i]=='0':
print((str(i+1)))
else:
pass
|
s=list(map(int,input().split()))
for i in range(5):
if s[i]==0:
print((i+1))
exit()
else:
pass
| 7 | 7 | 95 | 117 |
a = []
a = input().split()
for i in range(5):
if a[i] == "0":
print((str(i + 1)))
else:
pass
|
s = list(map(int, input().split()))
for i in range(5):
if s[i] == 0:
print((i + 1))
exit()
else:
pass
| false | 0 |
[
"-a = []",
"-a = input().split()",
"+s = list(map(int, input().split()))",
"- if a[i] == \"0\":",
"- print((str(i + 1)))",
"+ if s[i] == 0:",
"+ print((i + 1))",
"+ exit()"
] | false | 0.128784 | 0.118469 | 1.087065 |
[
"s603907984",
"s945990510"
] |
u514401521
|
p02689
|
python
|
s526872231
|
s553332078
| 424 | 362 | 29,512 | 29,532 |
Accepted
|
Accepted
| 14.62 |
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
ten = [[] for _ in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
ten[a].append(b)
ten[b].append(a)
ans = 0
for i in range(N):
flag = True
for j in ten[i]:
if H[i] <= H[j]:
flag = False
if flag:
ans += 1
print(ans)
|
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
l = [[] for _ in range(N)]
for _ in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
l[a].append(b)
l[b].append(a)
ng = 0
for i in range(N):
for other in l[i]:
if H[i] <= H[other]:
ng += 1
break
ans = N - ng
print(ans)
| 19 | 21 | 391 | 375 |
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
ten = [[] for _ in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
ten[a].append(b)
ten[b].append(a)
ans = 0
for i in range(N):
flag = True
for j in ten[i]:
if H[i] <= H[j]:
flag = False
if flag:
ans += 1
print(ans)
|
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
l = [[] for _ in range(N)]
for _ in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
l[a].append(b)
l[b].append(a)
ng = 0
for i in range(N):
for other in l[i]:
if H[i] <= H[other]:
ng += 1
break
ans = N - ng
print(ans)
| false | 9.52381 |
[
"-ten = [[] for _ in range(N)]",
"-for i in range(M):",
"+l = [[] for _ in range(N)]",
"+for _ in range(M):",
"- ten[a].append(b)",
"- ten[b].append(a)",
"-ans = 0",
"+ l[a].append(b)",
"+ l[b].append(a)",
"+ng = 0",
"- flag = True",
"- for j in ten[i]:",
"- if H[i] <= H[j]:",
"- flag = False",
"- if flag:",
"- ans += 1",
"+ for other in l[i]:",
"+ if H[i] <= H[other]:",
"+ ng += 1",
"+ break",
"+ans = N - ng"
] | false | 0.03694 | 0.048074 | 0.768398 |
[
"s526872231",
"s553332078"
] |
u766926358
|
p00481
|
python
|
s394990781
|
s421965666
| 15,090 | 11,990 | 36,500 | 42,372 |
Accepted
|
Accepted
| 20.54 |
h,w,n = list(map(int, input().split()))
stage = [eval(input()) for i in range(h)]
starts = [str(i) for i in range(n)]
goals = [str(i+1) for i in range(n)]
starts_y = [0 for i in range(n)]
starts_x = [0 for i in range(n)]
goals_y = [0 for i in range(n)]
goals_x = [0 for i in range(n)]
starts[0] = "S"
for y in range(h):
for x in range(w):
if stage[y][x] in starts:
starts_y[starts.index(stage[y][x])] = y
starts_x[starts.index(stage[y][x])] = x
if stage[y][x] in goals:
goals_y[goals.index(stage[y][x])] = y
goals_x[goals.index(stage[y][x])] = x
sum = 0
for start_y, start_x, goal_y, goal_x in zip(starts_y, starts_x, goals_y, goals_x):
bfs_map = [[-1 for j in range(w)] for i in range(h)]
data_y = [start_y]
data_x = [start_x]
bfs_map[start_y][start_x] = 0
goal = False
while (data_y) and not goal:
y = data_y.pop(0)
x = data_x.pop(0)
goal = False
for i in range(4):
ny = y + [0,1,0,-1][i]
nx = x + [1,0,-1,0][i]
if ny >= 0 and ny < h and nx >= 0 and nx < w:
if bfs_map[ny][nx] == -1 and stage[ny][nx] != "X":
bfs_map[ny][nx] = bfs_map[y][x]+1
data_y.append(ny)
data_x.append(nx)
if bfs_map[goal_y][goal_x] != -1:
sum += bfs_map[goal_y][goal_x]
goal = True
break
print(sum)
|
#import time, sys#
from collections import deque
H, W, N = list(map(int, input().split()))
field = [list(eval(input())) for i in range(H)]
'''
20 30 9
.......X..8.XXXX.XX..XX.X.XX..
X.XX....X.XX..X.X.X....XXXX..X
..X.X..XX..X.....XX.X..X.XX...
....X.X.X.XXX.X..X..X.X..XX.X.
..XXX.XX...X.X....X.X..X..X...
..X...........X.X...X.1.XX...X
.X.X....X..XX..XX......9.X...4
..X....X........X......X......
....XXX.X...XX.X.....X.X..X.X.
..S..XXX..X....X.X.......X..X.
.5...XX..X.X..X....X...XXX....
..X...X.X....X....X..X.2X.....
XXXXXXXX.X.XX..XX..XX.......X.
.....X...........3..XX.XXX.X.X
..X.....X..X..XX.XX..X.X...XX.
...X..X.XXX.XX......X...X..XXX
.X.XX.X.........X.X...X...X..X
..X...X..X..XX..XXX..X.XX...X.
X....X.X....X...X.X..XX.XX..X.
...X6X..X........X.X.....7.X..
'''
#input = input().split('\n')#
#H, W, N = map(int, input.pop(0).split())#
#field = [line for line in input]#
node_posi = [0 for i in range(N+1)]
#s1 = time.time()#
nodes = 'S123456789'
for i in range(H):
for j in range(W):
if field[i][j] in nodes:
node_posi[nodes.index(field[i][j])] = [j, i]
#e1 = time.time()#
#print("b:{}".format(e1-s1))#
cost = 0
#count = 1#
for i in range(len(node_posi)-1):
#s2 = time.time()#
searched = [[-1]*W for i in range(H)]
start, goal = node_posi[i], node_posi[i+1]
Q = deque([start])
searched[start[1]][start[0]] = 0
goal_flag = False
while Q and not goal_flag:
x, y = Q.popleft()
goal_flag = False
for q in range(4):
nx = x + [1,0,-1,0][q]
ny = y + [0,1,0,-1][q]
if nx >= 0 and nx < W and ny >= 0 and ny < H:
if searched[ny][nx] == -1 and field[ny][nx] != 'X':
Q.append([nx, ny])
searched[ny][nx] = searched[y][x] + 1
if ([nx, ny] == goal):
cost += searched[ny][nx]
goal_flag = True
break
#s = "\n".join(["".join(map(lambda x: str(x)[:1], j)) for j in searched])#
#sys.stdout.write("\r{}".format(s))#
#sys.stdout.flush()#
#e2 = time.time()#
#print("{}:{}".format(count, e2-s2))#
#count += 1#
print(cost)
| 49 | 78 | 1,298 | 2,067 |
h, w, n = list(map(int, input().split()))
stage = [eval(input()) for i in range(h)]
starts = [str(i) for i in range(n)]
goals = [str(i + 1) for i in range(n)]
starts_y = [0 for i in range(n)]
starts_x = [0 for i in range(n)]
goals_y = [0 for i in range(n)]
goals_x = [0 for i in range(n)]
starts[0] = "S"
for y in range(h):
for x in range(w):
if stage[y][x] in starts:
starts_y[starts.index(stage[y][x])] = y
starts_x[starts.index(stage[y][x])] = x
if stage[y][x] in goals:
goals_y[goals.index(stage[y][x])] = y
goals_x[goals.index(stage[y][x])] = x
sum = 0
for start_y, start_x, goal_y, goal_x in zip(starts_y, starts_x, goals_y, goals_x):
bfs_map = [[-1 for j in range(w)] for i in range(h)]
data_y = [start_y]
data_x = [start_x]
bfs_map[start_y][start_x] = 0
goal = False
while (data_y) and not goal:
y = data_y.pop(0)
x = data_x.pop(0)
goal = False
for i in range(4):
ny = y + [0, 1, 0, -1][i]
nx = x + [1, 0, -1, 0][i]
if ny >= 0 and ny < h and nx >= 0 and nx < w:
if bfs_map[ny][nx] == -1 and stage[ny][nx] != "X":
bfs_map[ny][nx] = bfs_map[y][x] + 1
data_y.append(ny)
data_x.append(nx)
if bfs_map[goal_y][goal_x] != -1:
sum += bfs_map[goal_y][goal_x]
goal = True
break
print(sum)
|
# import time, sys#
from collections import deque
H, W, N = list(map(int, input().split()))
field = [list(eval(input())) for i in range(H)]
"""
20 30 9
.......X..8.XXXX.XX..XX.X.XX..
X.XX....X.XX..X.X.X....XXXX..X
..X.X..XX..X.....XX.X..X.XX...
....X.X.X.XXX.X..X..X.X..XX.X.
..XXX.XX...X.X....X.X..X..X...
..X...........X.X...X.1.XX...X
.X.X....X..XX..XX......9.X...4
..X....X........X......X......
....XXX.X...XX.X.....X.X..X.X.
..S..XXX..X....X.X.......X..X.
.5...XX..X.X..X....X...XXX....
..X...X.X....X....X..X.2X.....
XXXXXXXX.X.XX..XX..XX.......X.
.....X...........3..XX.XXX.X.X
..X.....X..X..XX.XX..X.X...XX.
...X..X.XXX.XX......X...X..XXX
.X.XX.X.........X.X...X...X..X
..X...X..X..XX..XXX..X.XX...X.
X....X.X....X...X.X..XX.XX..X.
...X6X..X........X.X.....7.X..
"""
# input = input().split('\n')#
# H, W, N = map(int, input.pop(0).split())#
# field = [line for line in input]#
node_posi = [0 for i in range(N + 1)]
# s1 = time.time()#
nodes = "S123456789"
for i in range(H):
for j in range(W):
if field[i][j] in nodes:
node_posi[nodes.index(field[i][j])] = [j, i]
# e1 = time.time()#
# print("b:{}".format(e1-s1))#
cost = 0
# count = 1#
for i in range(len(node_posi) - 1):
# s2 = time.time()#
searched = [[-1] * W for i in range(H)]
start, goal = node_posi[i], node_posi[i + 1]
Q = deque([start])
searched[start[1]][start[0]] = 0
goal_flag = False
while Q and not goal_flag:
x, y = Q.popleft()
goal_flag = False
for q in range(4):
nx = x + [1, 0, -1, 0][q]
ny = y + [0, 1, 0, -1][q]
if nx >= 0 and nx < W and ny >= 0 and ny < H:
if searched[ny][nx] == -1 and field[ny][nx] != "X":
Q.append([nx, ny])
searched[ny][nx] = searched[y][x] + 1
if [nx, ny] == goal:
cost += searched[ny][nx]
goal_flag = True
break
# s = "\n".join(["".join(map(lambda x: str(x)[:1], j)) for j in searched])#
# sys.stdout.write("\r{}".format(s))#
# sys.stdout.flush()#
# e2 = time.time()#
# print("{}:{}".format(count, e2-s2))#
# count += 1#
print(cost)
| false | 37.179487 |
[
"-h, w, n = list(map(int, input().split()))",
"-stage = [eval(input()) for i in range(h)]",
"-starts = [str(i) for i in range(n)]",
"-goals = [str(i + 1) for i in range(n)]",
"-starts_y = [0 for i in range(n)]",
"-starts_x = [0 for i in range(n)]",
"-goals_y = [0 for i in range(n)]",
"-goals_x = [0 for i in range(n)]",
"-starts[0] = \"S\"",
"-for y in range(h):",
"- for x in range(w):",
"- if stage[y][x] in starts:",
"- starts_y[starts.index(stage[y][x])] = y",
"- starts_x[starts.index(stage[y][x])] = x",
"- if stage[y][x] in goals:",
"- goals_y[goals.index(stage[y][x])] = y",
"- goals_x[goals.index(stage[y][x])] = x",
"-sum = 0",
"-for start_y, start_x, goal_y, goal_x in zip(starts_y, starts_x, goals_y, goals_x):",
"- bfs_map = [[-1 for j in range(w)] for i in range(h)]",
"- data_y = [start_y]",
"- data_x = [start_x]",
"- bfs_map[start_y][start_x] = 0",
"- goal = False",
"- while (data_y) and not goal:",
"- y = data_y.pop(0)",
"- x = data_x.pop(0)",
"- goal = False",
"- for i in range(4):",
"- ny = y + [0, 1, 0, -1][i]",
"- nx = x + [1, 0, -1, 0][i]",
"- if ny >= 0 and ny < h and nx >= 0 and nx < w:",
"- if bfs_map[ny][nx] == -1 and stage[ny][nx] != \"X\":",
"- bfs_map[ny][nx] = bfs_map[y][x] + 1",
"- data_y.append(ny)",
"- data_x.append(nx)",
"- if bfs_map[goal_y][goal_x] != -1:",
"- sum += bfs_map[goal_y][goal_x]",
"- goal = True",
"- break",
"-print(sum)",
"+# import time, sys#",
"+from collections import deque",
"+",
"+H, W, N = list(map(int, input().split()))",
"+field = [list(eval(input())) for i in range(H)]",
"+\"\"\"",
"+20 30 9",
"+.......X..8.XXXX.XX..XX.X.XX..",
"+X.XX....X.XX..X.X.X....XXXX..X",
"+..X.X..XX..X.....XX.X..X.XX...",
"+....X.X.X.XXX.X..X..X.X..XX.X.",
"+..XXX.XX...X.X....X.X..X..X...",
"+..X...........X.X...X.1.XX...X",
"+.X.X....X..XX..XX......9.X...4",
"+..X....X........X......X......",
"+....XXX.X...XX.X.....X.X..X.X.",
"+..S..XXX..X....X.X.......X..X.",
"+.5...XX..X.X..X....X...XXX....",
"+..X...X.X....X....X..X.2X.....",
"+XXXXXXXX.X.XX..XX..XX.......X.",
"+.....X...........3..XX.XXX.X.X",
"+..X.....X..X..XX.XX..X.X...XX.",
"+...X..X.XXX.XX......X...X..XXX",
"+.X.XX.X.........X.X...X...X..X",
"+..X...X..X..XX..XXX..X.XX...X.",
"+X....X.X....X...X.X..XX.XX..X.",
"+...X6X..X........X.X.....7.X..",
"+\"\"\"",
"+# input = input().split('\\n')#",
"+# H, W, N = map(int, input.pop(0).split())#",
"+# field = [line for line in input]#",
"+node_posi = [0 for i in range(N + 1)]",
"+# s1 = time.time()#",
"+nodes = \"S123456789\"",
"+for i in range(H):",
"+ for j in range(W):",
"+ if field[i][j] in nodes:",
"+ node_posi[nodes.index(field[i][j])] = [j, i]",
"+# e1 = time.time()#",
"+# print(\"b:{}\".format(e1-s1))#",
"+cost = 0",
"+# count = 1#",
"+for i in range(len(node_posi) - 1):",
"+ # s2 = time.time()#",
"+ searched = [[-1] * W for i in range(H)]",
"+ start, goal = node_posi[i], node_posi[i + 1]",
"+ Q = deque([start])",
"+ searched[start[1]][start[0]] = 0",
"+ goal_flag = False",
"+ while Q and not goal_flag:",
"+ x, y = Q.popleft()",
"+ goal_flag = False",
"+ for q in range(4):",
"+ nx = x + [1, 0, -1, 0][q]",
"+ ny = y + [0, 1, 0, -1][q]",
"+ if nx >= 0 and nx < W and ny >= 0 and ny < H:",
"+ if searched[ny][nx] == -1 and field[ny][nx] != \"X\":",
"+ Q.append([nx, ny])",
"+ searched[ny][nx] = searched[y][x] + 1",
"+ if [nx, ny] == goal:",
"+ cost += searched[ny][nx]",
"+ goal_flag = True",
"+ break",
"+ # s = \"\\n\".join([\"\".join(map(lambda x: str(x)[:1], j)) for j in searched])#",
"+ # sys.stdout.write(\"\\r{}\".format(s))#",
"+ # sys.stdout.flush()#",
"+ # e2 = time.time()#",
"+ # print(\"{}:{}\".format(count, e2-s2))#",
"+ # count += 1#",
"+print(cost)"
] | false | 0.040693 | 0.039144 | 1.03958 |
[
"s394990781",
"s421965666"
] |
u279460955
|
p03221
|
python
|
s395238631
|
s666115027
| 928 | 717 | 109,400 | 122,584 |
Accepted
|
Accepted
| 22.74 |
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(eval(input()))
def Is(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return eval(input())
def Ss(): return input().split()
def LS(): return list(eval(input()))
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #
n, m = Is()
PY = []
for i in range(m):
p, y = Is()
PY.append((i, p, y))
PY.sort(key=itemgetter(1, 2))
ANS = [[0]*2 for _ in range(m)]
tmp = -1
count = -1
for i, p, y in PY:
if tmp != p:
count = 1
tmp = p
else:
count += 1
ANS[i][0] = p
ANS[i][1] = count
for a, b, in ANS:
print(("{}{}".format(str(a).zfill(6), str(b).zfill(6))))
|
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(eval(input()))
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return eval(input())
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #
def compress(A):
return {element: i+1 for i, element in enumerate(sorted(set(A)))}
n, m = Is()
PY = TIR(m)
A = [list() for _ in range(n+1)]
for p, y in PY:
A[p].append(y)
B = [compress(a) for a in A]
for p, y in PY:
ans = str(p).zfill(6) + str(B[p][y]).zfill(6)
print(ans)
| 48 | 42 | 1,546 | 1,446 |
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import (
permutations,
accumulate,
combinations,
combinations_with_replacement,
)
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input():
return sys.stdin.readline().rstrip()
def I():
return int(eval(input()))
def Is():
return list(map(int, input().split()))
def LI():
return list(map(int, input().split()))
def TI():
return tuple(map(int, input().split()))
def IR(n):
return [I() for _ in range(n)]
def LIR(n):
return [LI() for _ in range(n)]
def TIR(n):
return [TI() for _ in range(n)]
def S():
return eval(input())
def Ss():
return input().split()
def LS():
return list(eval(input()))
def SR(n):
return [S() for _ in range(n)]
def SsR(n):
return [Ss() for _ in range(n)]
def LSR(n):
return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9 + 7
INF = 10**18
# ----------------------------------------------------------- #
n, m = Is()
PY = []
for i in range(m):
p, y = Is()
PY.append((i, p, y))
PY.sort(key=itemgetter(1, 2))
ANS = [[0] * 2 for _ in range(m)]
tmp = -1
count = -1
for i, p, y in PY:
if tmp != p:
count = 1
tmp = p
else:
count += 1
ANS[i][0] = p
ANS[i][1] = count
for (
a,
b,
) in ANS:
print(("{}{}".format(str(a).zfill(6), str(b).zfill(6))))
|
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import (
permutations,
accumulate,
combinations,
combinations_with_replacement,
)
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache # @lru_cache(None)
from fractions import gcd
import sys
def input():
return sys.stdin.readline().rstrip()
def I():
return int(eval(input()))
def Is():
return (int(x) for x in input().split())
def LI():
return list(Is())
def TI():
return tuple(Is())
def IR(n):
return [I() for _ in range(n)]
def LIR(n):
return [LI() for _ in range(n)]
def TIR(n):
return [TI() for _ in range(n)]
def S():
return eval(input())
def Ss():
return input().split()
def LS():
return list(S())
def SR(n):
return [S() for _ in range(n)]
def SsR(n):
return [Ss() for _ in range(n)]
def LSR(n):
return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9 + 7
INF = 10**18
# ----------------------------------------------------------- #
def compress(A):
return {element: i + 1 for i, element in enumerate(sorted(set(A)))}
n, m = Is()
PY = TIR(m)
A = [list() for _ in range(n + 1)]
for p, y in PY:
A[p].append(y)
B = [compress(a) for a in A]
for p, y in PY:
ans = str(p).zfill(6) + str(B[p][y]).zfill(6)
print(ans)
| false | 12.5 |
[
"-from functools import reduce",
"+from functools import reduce, lru_cache # @lru_cache(None)",
"- return list(map(int, input().split()))",
"+ return (int(x) for x in input().split())",
"- return list(map(int, input().split()))",
"+ return list(Is())",
"- return tuple(map(int, input().split()))",
"+ return tuple(Is())",
"- return list(eval(input()))",
"+ return list(S())",
"+def compress(A):",
"+ return {element: i + 1 for i, element in enumerate(sorted(set(A)))}",
"+",
"+",
"-PY = []",
"-for i in range(m):",
"- p, y = Is()",
"- PY.append((i, p, y))",
"-PY.sort(key=itemgetter(1, 2))",
"-ANS = [[0] * 2 for _ in range(m)]",
"-tmp = -1",
"-count = -1",
"-for i, p, y in PY:",
"- if tmp != p:",
"- count = 1",
"- tmp = p",
"- else:",
"- count += 1",
"- ANS[i][0] = p",
"- ANS[i][1] = count",
"-for (",
"- a,",
"- b,",
"-) in ANS:",
"- print((\"{}{}\".format(str(a).zfill(6), str(b).zfill(6))))",
"+PY = TIR(m)",
"+A = [list() for _ in range(n + 1)]",
"+for p, y in PY:",
"+ A[p].append(y)",
"+B = [compress(a) for a in A]",
"+for p, y in PY:",
"+ ans = str(p).zfill(6) + str(B[p][y]).zfill(6)",
"+ print(ans)"
] | false | 0.033288 | 0.035546 | 0.936481 |
[
"s395238631",
"s666115027"
] |
u952708174
|
p03504
|
python
|
s165570876
|
s578627189
| 1,518 | 1,289 | 26,808 | 24,336 |
Accepted
|
Accepted
| 15.09 |
def d_recording(N, C, R):
# N:録画する番組の数
# C:テレビが受信できるチャンネルの数
# R:録画する番組の情報 [開始時刻s,終了時刻t,チャンネルc]
from itertools import accumulate
start = [row[0] for row in R]
end = [row[1] for row in R]
channel_num = [row[2] for row in R]
# いつまで録画機を動かすか。0.5を単位時間とするので*2
# 時刻を0からスタートさせるので+2
l = max(end) * 2 + 2
running_recorder = [0 for _ in range(l)] # [k]:ある時刻に動作中の録画機の数
for channel in range(1, C + 1):
rec = [0 for _ in range(l)] # [k]:チャンネルkを録画しているか否か
# 累積和を取る
for s, t, c in zip(start, end, channel_num):
if c == channel:
# 録画開始時刻の0.5前を+1,終了時刻を-1
# (終了時刻は含まないという録画機の条件より、このようにする)
rec[s * 2 - 1] += 1
rec[t * 2] -= 1
rec = accumulate(rec)
# あるチャンネルを録画している時間帯では、録画機を1個使わねばならない
for j, running in enumerate(rec):
if running > 0:
running_recorder[j] += 1
ans = max(running_recorder)
return ans
N, C = [int(i) for i in input().split()]
R = [[int(i) for i in input().split()] for j in range(N)]
print((d_recording(N, C, R)))
|
def d_recording(N, C, R):
# N:録画する番組の数
# C:テレビが受信できるチャンネルの数
# R:録画する番組の情報 [開始時刻s,終了時刻t,チャンネルc]
from itertools import accumulate
# いつまで録画機を動かすか。終了時刻の最大値10**5, 単位時間を0.5とするので*2
# 時刻を0からスタートさせるので+1, 累積和のために+1
l = 10**5 * 2 + 2
running_recorder = [0] * l # [k]:ある時刻に動作中の録画機の数
for channel in range(1, C + 1):
rec = [0] * l # [k]:チャンネルkを録画しているか否か
# 累積和を取る
for s, t, c in R:
if c == channel:
# 録画開始時刻の0.5前を+1,終了時刻を-1
# (終了時刻は含まないという録画機の条件より、このようにする)
rec[s * 2 - 1] += 1
rec[t * 2] -= 1
rec = accumulate(rec)
# あるチャンネルを録画している時間帯では、録画機を1個使わねばならない
for j, running in enumerate(rec):
if running > 0:
running_recorder[j] += 1
ans = max(running_recorder)
return ans
N, C = [int(i) for i in input().split()]
R = [[int(i) for i in input().split()] for j in range(N)]
print((d_recording(N, C, R)))
| 34 | 31 | 1,149 | 1,008 |
def d_recording(N, C, R):
# N:録画する番組の数
# C:テレビが受信できるチャンネルの数
# R:録画する番組の情報 [開始時刻s,終了時刻t,チャンネルc]
from itertools import accumulate
start = [row[0] for row in R]
end = [row[1] for row in R]
channel_num = [row[2] for row in R]
# いつまで録画機を動かすか。0.5を単位時間とするので*2
# 時刻を0からスタートさせるので+2
l = max(end) * 2 + 2
running_recorder = [0 for _ in range(l)] # [k]:ある時刻に動作中の録画機の数
for channel in range(1, C + 1):
rec = [0 for _ in range(l)] # [k]:チャンネルkを録画しているか否か
# 累積和を取る
for s, t, c in zip(start, end, channel_num):
if c == channel:
# 録画開始時刻の0.5前を+1,終了時刻を-1
# (終了時刻は含まないという録画機の条件より、このようにする)
rec[s * 2 - 1] += 1
rec[t * 2] -= 1
rec = accumulate(rec)
# あるチャンネルを録画している時間帯では、録画機を1個使わねばならない
for j, running in enumerate(rec):
if running > 0:
running_recorder[j] += 1
ans = max(running_recorder)
return ans
N, C = [int(i) for i in input().split()]
R = [[int(i) for i in input().split()] for j in range(N)]
print((d_recording(N, C, R)))
|
def d_recording(N, C, R):
# N:録画する番組の数
# C:テレビが受信できるチャンネルの数
# R:録画する番組の情報 [開始時刻s,終了時刻t,チャンネルc]
from itertools import accumulate
# いつまで録画機を動かすか。終了時刻の最大値10**5, 単位時間を0.5とするので*2
# 時刻を0からスタートさせるので+1, 累積和のために+1
l = 10**5 * 2 + 2
running_recorder = [0] * l # [k]:ある時刻に動作中の録画機の数
for channel in range(1, C + 1):
rec = [0] * l # [k]:チャンネルkを録画しているか否か
# 累積和を取る
for s, t, c in R:
if c == channel:
# 録画開始時刻の0.5前を+1,終了時刻を-1
# (終了時刻は含まないという録画機の条件より、このようにする)
rec[s * 2 - 1] += 1
rec[t * 2] -= 1
rec = accumulate(rec)
# あるチャンネルを録画している時間帯では、録画機を1個使わねばならない
for j, running in enumerate(rec):
if running > 0:
running_recorder[j] += 1
ans = max(running_recorder)
return ans
N, C = [int(i) for i in input().split()]
R = [[int(i) for i in input().split()] for j in range(N)]
print((d_recording(N, C, R)))
| false | 8.823529 |
[
"- start = [row[0] for row in R]",
"- end = [row[1] for row in R]",
"- channel_num = [row[2] for row in R]",
"- # いつまで録画機を動かすか。0.5を単位時間とするので*2",
"- # 時刻を0からスタートさせるので+2",
"- l = max(end) * 2 + 2",
"- running_recorder = [0 for _ in range(l)] # [k]:ある時刻に動作中の録画機の数",
"+ # いつまで録画機を動かすか。終了時刻の最大値10**5, 単位時間を0.5とするので*2",
"+ # 時刻を0からスタートさせるので+1, 累積和のために+1",
"+ l = 10**5 * 2 + 2",
"+ running_recorder = [0] * l # [k]:ある時刻に動作中の録画機の数",
"- rec = [0 for _ in range(l)] # [k]:チャンネルkを録画しているか否か",
"+ rec = [0] * l # [k]:チャンネルkを録画しているか否か",
"- for s, t, c in zip(start, end, channel_num):",
"+ for s, t, c in R:"
] | false | 0.061845 | 0.120092 | 0.514979 |
[
"s165570876",
"s578627189"
] |
u753803401
|
p04000
|
python
|
s744081603
|
s431276712
| 1,543 | 1,010 | 189,996 | 191,996 |
Accepted
|
Accepted
| 34.54 |
import sys
import bisect
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache
def slove():
input = sys.stdin.readline
mod = 10 ** 9 + 7
h, w, n = list(map(int, input().rstrip('\n').split()))
d = collections.defaultdict(int)
for i in range(n):
a, b = list(map(int, input().rstrip('\n').split()))
a -= 1
b -= 1
for j in range(max(1, a - 1), min(h-1, a + 2)):
for k in range(max(1, b - 1), min(w-1, b + 2)):
d[j, k] += 1
ls = [0] * 10
for k, v in sorted(list(d.items()), key=lambda x: x[1]):
ls[v] += 1
ls[0] = (h - 3 + 1) * (w - 3 + 1) - sum(ls)
for i in range(10):
print((ls[i]))
if __name__ == '__main__':
slove()
|
import sys
import collections
def solve():
sys.setrecursionlimit(2000)
input = sys.stdin.readline
mod = 10 ** 9 + 7
h, w, n = list(map(int, input().rstrip('\n').split()))
d = collections.defaultdict(int)
for _ in range(n):
a, b = list(map(int, input().rstrip('\n').split()))
for i in range(-1, 2):
for j in range(-1, 2):
if 1 <= a-1+i < h-1 and 1 <= b-1+j < w-1:
d[a-1+i, b-1+j] += 1
nd = []
for k, v in list(d.items()):
nd.append(v)
nd = collections.Counter(nd)
print(((h - 2) * (w - 2) - sum(nd.values())))
for i in range(1, 10):
print((nd[i]))
if __name__ == '__main__':
solve()
| 33 | 27 | 852 | 730 |
import sys
import bisect
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache
def slove():
input = sys.stdin.readline
mod = 10**9 + 7
h, w, n = list(map(int, input().rstrip("\n").split()))
d = collections.defaultdict(int)
for i in range(n):
a, b = list(map(int, input().rstrip("\n").split()))
a -= 1
b -= 1
for j in range(max(1, a - 1), min(h - 1, a + 2)):
for k in range(max(1, b - 1), min(w - 1, b + 2)):
d[j, k] += 1
ls = [0] * 10
for k, v in sorted(list(d.items()), key=lambda x: x[1]):
ls[v] += 1
ls[0] = (h - 3 + 1) * (w - 3 + 1) - sum(ls)
for i in range(10):
print((ls[i]))
if __name__ == "__main__":
slove()
|
import sys
import collections
def solve():
sys.setrecursionlimit(2000)
input = sys.stdin.readline
mod = 10**9 + 7
h, w, n = list(map(int, input().rstrip("\n").split()))
d = collections.defaultdict(int)
for _ in range(n):
a, b = list(map(int, input().rstrip("\n").split()))
for i in range(-1, 2):
for j in range(-1, 2):
if 1 <= a - 1 + i < h - 1 and 1 <= b - 1 + j < w - 1:
d[a - 1 + i, b - 1 + j] += 1
nd = []
for k, v in list(d.items()):
nd.append(v)
nd = collections.Counter(nd)
print(((h - 2) * (w - 2) - sum(nd.values())))
for i in range(1, 10):
print((nd[i]))
if __name__ == "__main__":
solve()
| false | 18.181818 |
[
"-import bisect",
"-import fractions",
"-import heapq",
"-import math",
"-from operator import mul",
"-from functools import reduce",
"-from functools import lru_cache",
"-def slove():",
"+def solve():",
"+ sys.setrecursionlimit(2000)",
"- for i in range(n):",
"+ for _ in range(n):",
"- a -= 1",
"- b -= 1",
"- for j in range(max(1, a - 1), min(h - 1, a + 2)):",
"- for k in range(max(1, b - 1), min(w - 1, b + 2)):",
"- d[j, k] += 1",
"- ls = [0] * 10",
"- for k, v in sorted(list(d.items()), key=lambda x: x[1]):",
"- ls[v] += 1",
"- ls[0] = (h - 3 + 1) * (w - 3 + 1) - sum(ls)",
"- for i in range(10):",
"- print((ls[i]))",
"+ for i in range(-1, 2):",
"+ for j in range(-1, 2):",
"+ if 1 <= a - 1 + i < h - 1 and 1 <= b - 1 + j < w - 1:",
"+ d[a - 1 + i, b - 1 + j] += 1",
"+ nd = []",
"+ for k, v in list(d.items()):",
"+ nd.append(v)",
"+ nd = collections.Counter(nd)",
"+ print(((h - 2) * (w - 2) - sum(nd.values())))",
"+ for i in range(1, 10):",
"+ print((nd[i]))",
"- slove()",
"+ solve()"
] | false | 0.037357 | 0.061412 | 0.608306 |
[
"s744081603",
"s431276712"
] |
u753803401
|
p02918
|
python
|
s866543205
|
s134990353
| 195 | 175 | 41,072 | 45,296 |
Accepted
|
Accepted
| 10.26 |
def slove():
import sys
input = sys.stdin.readline
n, k = list(map(int, input().rstrip('\n').split()))
s = str(input().rstrip('\n'))
c = 0
cl = 0
mcl = 0
cr = 0
mcr = 0
for i in range(n):
if i != 0:
if s[i] != s[i-1]:
c += 1
if s[i] == "R":
cr += 1
mcl += max((cl - 1), 0)
cl = 0
else:
cl += 1
mcr += max((cr - 1), 0)
cr = 0
if i == n - 1:
mcl += max((cl - 1), 0)
mcr += max((cr - 1), 0)
print((min(mcl + mcr + k * 2, n - 1)))
if __name__ == '__main__':
slove()
|
import sys
def solve():
input = sys.stdin.readline
mod = 10 ** 9 + 7
n, k = list(map(int, input().rstrip('\n').split()))
s = str(input().rstrip('\n'))
ls = []
cnt = 1
for i in range(1, n):
if s[i] != s[i-1]:
ls.append(cnt-1)
cnt = 1
else:
cnt += 1
ls.append(cnt-1)
print((min(n-1, sum(ls) + k * 2)))
if __name__ == '__main__':
solve()
| 33 | 22 | 717 | 450 |
def slove():
import sys
input = sys.stdin.readline
n, k = list(map(int, input().rstrip("\n").split()))
s = str(input().rstrip("\n"))
c = 0
cl = 0
mcl = 0
cr = 0
mcr = 0
for i in range(n):
if i != 0:
if s[i] != s[i - 1]:
c += 1
if s[i] == "R":
cr += 1
mcl += max((cl - 1), 0)
cl = 0
else:
cl += 1
mcr += max((cr - 1), 0)
cr = 0
if i == n - 1:
mcl += max((cl - 1), 0)
mcr += max((cr - 1), 0)
print((min(mcl + mcr + k * 2, n - 1)))
if __name__ == "__main__":
slove()
|
import sys
def solve():
input = sys.stdin.readline
mod = 10**9 + 7
n, k = list(map(int, input().rstrip("\n").split()))
s = str(input().rstrip("\n"))
ls = []
cnt = 1
for i in range(1, n):
if s[i] != s[i - 1]:
ls.append(cnt - 1)
cnt = 1
else:
cnt += 1
ls.append(cnt - 1)
print((min(n - 1, sum(ls) + k * 2)))
if __name__ == "__main__":
solve()
| false | 33.333333 |
[
"-def slove():",
"- import sys",
"+import sys",
"+",
"+def solve():",
"+ mod = 10**9 + 7",
"- c = 0",
"- cl = 0",
"- mcl = 0",
"- cr = 0",
"- mcr = 0",
"- for i in range(n):",
"- if i != 0:",
"- if s[i] != s[i - 1]:",
"- c += 1",
"- if s[i] == \"R\":",
"- cr += 1",
"- mcl += max((cl - 1), 0)",
"- cl = 0",
"+ ls = []",
"+ cnt = 1",
"+ for i in range(1, n):",
"+ if s[i] != s[i - 1]:",
"+ ls.append(cnt - 1)",
"+ cnt = 1",
"- cl += 1",
"- mcr += max((cr - 1), 0)",
"- cr = 0",
"- if i == n - 1:",
"- mcl += max((cl - 1), 0)",
"- mcr += max((cr - 1), 0)",
"- print((min(mcl + mcr + k * 2, n - 1)))",
"+ cnt += 1",
"+ ls.append(cnt - 1)",
"+ print((min(n - 1, sum(ls) + k * 2)))",
"- slove()",
"+ solve()"
] | false | 0.046916 | 0.085812 | 0.546736 |
[
"s866543205",
"s134990353"
] |
u968166680
|
p02727
|
python
|
s285455095
|
s424531344
| 187 | 153 | 121,668 | 29,020 |
Accepted
|
Accepted
| 18.18 |
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
X, Y, A, B, C, *PQR = list(map(int, read().split()))
P = PQR[:A]
Q = PQR[A : A + B]
R = PQR[A + B :]
P.sort(reverse=True)
Q.sort(reverse=True)
vec = P[:X] + Q[:Y] + R
vec.sort(reverse=True)
ans = sum(vec[: X + Y])
print(ans)
return
if __name__ == '__main__':
main()
|
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
X, Y, A, B, C = list(map(int, readline().split()))
P = list(map(int, readline().split()))
Q = list(map(int, readline().split()))
R = list(map(int, readline().split()))
P.sort(reverse=True)
Q.sort(reverse=True)
apple = P[:X] + Q[:Y] + R
apple.sort(reverse=True)
print((sum(apple[: X + Y])))
return
if __name__ == '__main__':
main()
| 29 | 29 | 513 | 573 |
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def main():
X, Y, A, B, C, *PQR = list(map(int, read().split()))
P = PQR[:A]
Q = PQR[A : A + B]
R = PQR[A + B :]
P.sort(reverse=True)
Q.sort(reverse=True)
vec = P[:X] + Q[:Y] + R
vec.sort(reverse=True)
ans = sum(vec[: X + Y])
print(ans)
return
if __name__ == "__main__":
main()
|
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def main():
X, Y, A, B, C = list(map(int, readline().split()))
P = list(map(int, readline().split()))
Q = list(map(int, readline().split()))
R = list(map(int, readline().split()))
P.sort(reverse=True)
Q.sort(reverse=True)
apple = P[:X] + Q[:Y] + R
apple.sort(reverse=True)
print((sum(apple[: X + Y])))
return
if __name__ == "__main__":
main()
| false | 0 |
[
"- X, Y, A, B, C, *PQR = list(map(int, read().split()))",
"- P = PQR[:A]",
"- Q = PQR[A : A + B]",
"- R = PQR[A + B :]",
"+ X, Y, A, B, C = list(map(int, readline().split()))",
"+ P = list(map(int, readline().split()))",
"+ Q = list(map(int, readline().split()))",
"+ R = list(map(int, readline().split()))",
"- vec = P[:X] + Q[:Y] + R",
"- vec.sort(reverse=True)",
"- ans = sum(vec[: X + Y])",
"- print(ans)",
"+ apple = P[:X] + Q[:Y] + R",
"+ apple.sort(reverse=True)",
"+ print((sum(apple[: X + Y])))"
] | false | 0.078385 | 0.036624 | 2.140287 |
[
"s285455095",
"s424531344"
] |
u533713111
|
p02969
|
python
|
s744971854
|
s206943146
| 19 | 17 | 3,316 | 2,940 |
Accepted
|
Accepted
| 10.53 |
r = int(eval(input()))
print((3 * r ** 2))
|
r = int(eval(input()))
print((3 * r * r))
| 2 | 2 | 35 | 34 |
r = int(eval(input()))
print((3 * r**2))
|
r = int(eval(input()))
print((3 * r * r))
| false | 0 |
[
"-print((3 * r**2))",
"+print((3 * r * r))"
] | false | 0.046779 | 0.048047 | 0.973604 |
[
"s744971854",
"s206943146"
] |
u084320347
|
p02946
|
python
|
s650986051
|
s317280452
| 169 | 17 | 38,256 | 3,060 |
Accepted
|
Accepted
| 89.94 |
k,x=map(int,input().split())
a=list(range(-k+1,k))
for b in a:
print(x+b,"",end="")
|
k,x = list(map(int,input().split()))
l = []
cnt = -(k-1)
for i in range(k+k-1):
l.append(x+cnt)
cnt+=1
for i in l:
print(i,end=" ")
| 6 | 11 | 94 | 156 |
k, x = map(int, input().split())
a = list(range(-k + 1, k))
for b in a:
print(x + b, "", end="")
|
k, x = list(map(int, input().split()))
l = []
cnt = -(k - 1)
for i in range(k + k - 1):
l.append(x + cnt)
cnt += 1
for i in l:
print(i, end=" ")
| false | 45.454545 |
[
"-k, x = map(int, input().split())",
"-a = list(range(-k + 1, k))",
"-for b in a:",
"- print(x + b, \"\", end=\"\")",
"+k, x = list(map(int, input().split()))",
"+l = []",
"+cnt = -(k - 1)",
"+for i in range(k + k - 1):",
"+ l.append(x + cnt)",
"+ cnt += 1",
"+for i in l:",
"+ print(i, end=\" \")"
] | false | 0.07618 | 0.034595 | 2.202089 |
[
"s650986051",
"s317280452"
] |
u918601425
|
p03043
|
python
|
s440554231
|
s234474826
| 109 | 49 | 2,940 | 3,060 |
Accepted
|
Accepted
| 55.05 |
import math
N,K=[int(s) for s in input().split()]
a=0
for i in range(N):
a+=2**(-max([0,math.ceil(math.log2(K/(i+1)))]))
print((a/N))
|
N,K=[int(s) for s in input().split()]
a=0
for i in range(N):
x=i+1
n=0
while x<K:
n+=1
x*=2
a+=2**(-n)
print((a/N))
| 6 | 10 | 138 | 138 |
import math
N, K = [int(s) for s in input().split()]
a = 0
for i in range(N):
a += 2 ** (-max([0, math.ceil(math.log2(K / (i + 1)))]))
print((a / N))
|
N, K = [int(s) for s in input().split()]
a = 0
for i in range(N):
x = i + 1
n = 0
while x < K:
n += 1
x *= 2
a += 2 ** (-n)
print((a / N))
| false | 40 |
[
"-import math",
"-",
"- a += 2 ** (-max([0, math.ceil(math.log2(K / (i + 1)))]))",
"+ x = i + 1",
"+ n = 0",
"+ while x < K:",
"+ n += 1",
"+ x *= 2",
"+ a += 2 ** (-n)"
] | false | 0.17448 | 0.057405 | 3.039432 |
[
"s440554231",
"s234474826"
] |
u903005414
|
p03370
|
python
|
s211703548
|
s725013593
| 30 | 26 | 9,116 | 9,004 |
Accepted
|
Accepted
| 13.33 |
N, X = list(map(int, input().split()))
M = sorted([int(eval(input())) for _ in range(N)])
if X >= sum(M):
min_M = min(M)
ans = (X - sum(M)) // min_M + N
else:
current = 0
for i, m in enumerate(M, start=1):
current += m
if current > X:
ans = i
print(ans)
|
N, X = list(map(int, input().split()))
M = sorted([int(eval(input())) for _ in range(N)])
ans = (X - sum(M)) // min(M) + N
print(ans)
| 13 | 4 | 299 | 125 |
N, X = list(map(int, input().split()))
M = sorted([int(eval(input())) for _ in range(N)])
if X >= sum(M):
min_M = min(M)
ans = (X - sum(M)) // min_M + N
else:
current = 0
for i, m in enumerate(M, start=1):
current += m
if current > X:
ans = i
print(ans)
|
N, X = list(map(int, input().split()))
M = sorted([int(eval(input())) for _ in range(N)])
ans = (X - sum(M)) // min(M) + N
print(ans)
| false | 69.230769 |
[
"-if X >= sum(M):",
"- min_M = min(M)",
"- ans = (X - sum(M)) // min_M + N",
"-else:",
"- current = 0",
"- for i, m in enumerate(M, start=1):",
"- current += m",
"- if current > X:",
"- ans = i",
"+ans = (X - sum(M)) // min(M) + N"
] | false | 0.037293 | 0.041638 | 0.895656 |
[
"s211703548",
"s725013593"
] |
u075012704
|
p03253
|
python
|
s646068980
|
s844747775
| 28 | 24 | 3,444 | 3,444 |
Accepted
|
Accepted
| 14.29 |
from collections import Counter
from itertools import combinations_with_replacement
N, M = list(map(int, input().split()))
mod = 10 ** 9 + 7
# 重複組み合わせ
def nHk(n, k):
value = 1
nk = n + k - 1
k = min(nk-k, k)
for i in range(k):
value = (value * nk) % mod
nk -= 1
for x in range(1, k + 1):
value = (value * pow(x, mod-2, mod)) % mod
return value
# 素因数分解
def prime_factorization(n):
table = []
for x in range(2, int(n**0.5)+1):
while n % x == 0:
table.append(x)
n //= x
if n > 1:
table.append(n)
return table
ans = 1
T = prime_factorization(M)
C = Counter(T)
for v in list(C.values()):
ans = ans * nHk(N, v) % mod
print(ans)
|
from collections import Counter
N, M = list(map(int, input().split()))
mod = 10 ** 9 + 7
# 素因数分解
def prime_factorization(n):
table = []
for x in range(2, int(n ** 0.5) + 1):
while n % x == 0:
table.append(x)
n //= x
if n > 1:
table.append(n)
return table
# 重複組み合わせ
def nHk(n, k):
value = 1
nk = n + k - 1
k = min(nk-k, k)
for i in range(k):
value = (value * nk) % mod
nk -= 1
for x in range(1, k + 1):
value = (value * pow(x, mod-2, mod)) % mod
return value
T = prime_factorization(M)
C = Counter(T)
ans = 1
for v in list(C.values()):
ans *= nHk(N, v)
ans %= mod
print(ans)
| 37 | 39 | 760 | 720 |
from collections import Counter
from itertools import combinations_with_replacement
N, M = list(map(int, input().split()))
mod = 10**9 + 7
# 重複組み合わせ
def nHk(n, k):
value = 1
nk = n + k - 1
k = min(nk - k, k)
for i in range(k):
value = (value * nk) % mod
nk -= 1
for x in range(1, k + 1):
value = (value * pow(x, mod - 2, mod)) % mod
return value
# 素因数分解
def prime_factorization(n):
table = []
for x in range(2, int(n**0.5) + 1):
while n % x == 0:
table.append(x)
n //= x
if n > 1:
table.append(n)
return table
ans = 1
T = prime_factorization(M)
C = Counter(T)
for v in list(C.values()):
ans = ans * nHk(N, v) % mod
print(ans)
|
from collections import Counter
N, M = list(map(int, input().split()))
mod = 10**9 + 7
# 素因数分解
def prime_factorization(n):
table = []
for x in range(2, int(n**0.5) + 1):
while n % x == 0:
table.append(x)
n //= x
if n > 1:
table.append(n)
return table
# 重複組み合わせ
def nHk(n, k):
value = 1
nk = n + k - 1
k = min(nk - k, k)
for i in range(k):
value = (value * nk) % mod
nk -= 1
for x in range(1, k + 1):
value = (value * pow(x, mod - 2, mod)) % mod
return value
T = prime_factorization(M)
C = Counter(T)
ans = 1
for v in list(C.values()):
ans *= nHk(N, v)
ans %= mod
print(ans)
| false | 5.128205 |
[
"-from itertools import combinations_with_replacement",
"+# 素因数分解",
"+def prime_factorization(n):",
"+ table = []",
"+ for x in range(2, int(n**0.5) + 1):",
"+ while n % x == 0:",
"+ table.append(x)",
"+ n //= x",
"+ if n > 1:",
"+ table.append(n)",
"+ return table",
"+",
"+",
"-# 素因数分解",
"-def prime_factorization(n):",
"- table = []",
"- for x in range(2, int(n**0.5) + 1):",
"- while n % x == 0:",
"- table.append(x)",
"- n //= x",
"- if n > 1:",
"- table.append(n)",
"- return table",
"-",
"-",
"-ans = 1",
"+ans = 1",
"- ans = ans * nHk(N, v) % mod",
"+ ans *= nHk(N, v)",
"+ ans %= mod"
] | false | 0.04609 | 0.123877 | 0.372066 |
[
"s646068980",
"s844747775"
] |
u150984829
|
p00076
|
python
|
s921499806
|
s341604292
| 30 | 20 | 5,636 | 5,628 |
Accepted
|
Accepted
| 33.33 |
import sys
for e in sys.stdin:
n=int(e)
if n<0:break
z=1
for _ in range(n-1):
d=z*1j
d/=abs(d)
z+=d
print(f'{z.real}\n{z.imag}')
|
import sys
for e in sys.stdin:
n=int(e)
if n<0:break
z=1
for _ in range(n-1):
d=z*1j
d/=abs(d)
z+=d
print((z.real))
print((z.imag))
| 10 | 11 | 149 | 150 |
import sys
for e in sys.stdin:
n = int(e)
if n < 0:
break
z = 1
for _ in range(n - 1):
d = z * 1j
d /= abs(d)
z += d
print(f"{z.real}\n{z.imag}")
|
import sys
for e in sys.stdin:
n = int(e)
if n < 0:
break
z = 1
for _ in range(n - 1):
d = z * 1j
d /= abs(d)
z += d
print((z.real))
print((z.imag))
| false | 9.090909 |
[
"- print(f\"{z.real}\\n{z.imag}\")",
"+ print((z.real))",
"+ print((z.imag))"
] | false | 0.074735 | 0.046188 | 1.618055 |
[
"s921499806",
"s341604292"
] |
u577415482
|
p02678
|
python
|
s762545482
|
s332646188
| 922 | 842 | 34,860 | 34,860 |
Accepted
|
Accepted
| 8.68 |
from collections import deque
N,M = list(map(int, input().split()))
root = [[] for _ in range(N)]
for _ in range(M):
a,b = list(map(int,input().split()))
root[a - 1].append(b)
root[b - 1].append(a)
q = deque()
q.append(1)
ans = [0 for _ in range(N)]
while len(q) > 0:
v = q.popleft()
for ike in root[v - 1]:
q.append(ike)
if(ans[ike - 1] == 0):
ans[ike - 1] = v
root[v-1].clear()
print('Yes')
for a in ans[1::]:
print(a)
|
from collections import deque
N,M = list(map(int, input().split()))
root = [[] for _ in range(N)]
for _ in range(M):
a,b = list(map(int,input().split()))
root[a - 1].append(b)
root[b - 1].append(a)
q = deque()
q.append(1)
ans = [0]*N
while len(q) > 0:
v = q.popleft()
for ike in root[v - 1]:
q.append(ike)
if(ans[ike - 1] == 0):
ans[ike - 1] = v
root[v-1].clear()
print('Yes')
for a in ans[1::]:
print(a)
| 26 | 26 | 454 | 438 |
from collections import deque
N, M = list(map(int, input().split()))
root = [[] for _ in range(N)]
for _ in range(M):
a, b = list(map(int, input().split()))
root[a - 1].append(b)
root[b - 1].append(a)
q = deque()
q.append(1)
ans = [0 for _ in range(N)]
while len(q) > 0:
v = q.popleft()
for ike in root[v - 1]:
q.append(ike)
if ans[ike - 1] == 0:
ans[ike - 1] = v
root[v - 1].clear()
print("Yes")
for a in ans[1::]:
print(a)
|
from collections import deque
N, M = list(map(int, input().split()))
root = [[] for _ in range(N)]
for _ in range(M):
a, b = list(map(int, input().split()))
root[a - 1].append(b)
root[b - 1].append(a)
q = deque()
q.append(1)
ans = [0] * N
while len(q) > 0:
v = q.popleft()
for ike in root[v - 1]:
q.append(ike)
if ans[ike - 1] == 0:
ans[ike - 1] = v
root[v - 1].clear()
print("Yes")
for a in ans[1::]:
print(a)
| false | 0 |
[
"-ans = [0 for _ in range(N)]",
"+ans = [0] * N"
] | false | 0.037439 | 0.036234 | 1.033269 |
[
"s762545482",
"s332646188"
] |
u875291233
|
p02625
|
python
|
s625140458
|
s077423326
| 898 | 356 | 68,144 | 28,560 |
Accepted
|
Accepted
| 60.36 |
SIZE=5*10**5; MOD=10**9+7 #998244353 #ここを変更する
SIZE += 1
inv = [0]*SIZE # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
fac[i] = fac[i-1]*i%MOD
finv[-1] = pow(fac[-1],MOD-2,MOD)
for i in range(SIZE-1,0,-1):
finv[i-1] = finv[i]*i%MOD
inv[i] = finv[i]*fac[i-1]%MOD
def choose(n,r): # nCk mod MOD の計算
if 0 <= r <= n:
return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
else:
return 0
def f(x,y):
return fac[x]*finv[x-y]%MOD
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
n,m = list(map(int,readline().split()))
ans = 0
r = 1
for u in range(n+1):
ans += r*f(m-u,n-u)*choose(n,u)%MOD
ans %= MOD
r *= -1
print((ans*f(m,n)%MOD))
|
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
n,m = list(map(int,readline().split()))
"""
漸化式は f(m,n) = (m-1)f(m-1,n-1) + (n-1)f(m-2,n-2)
初期条件 f(m-n,0)=1, f(m-n+1,1)=m-n
"""
MOD = 10**9+7
res = [0]*(n+1)
res[0] = 1
res[1] = m-n
for i in range(2,n+1):
res[i] = (m-n+i-1)*res[i-1] + (i-1)*res[i-2]
res[i] %= MOD
#print(res)
ans = res[n]
for i in range(m,m-n,-1):
ans *= i
ans %= MOD
print(ans)
| 44 | 26 | 896 | 481 |
SIZE = 5 * 10**5
MOD = 10**9 + 7 # 998244353 #ここを変更する
SIZE += 1
inv = [0] * SIZE # inv[j] = j^{-1} mod MOD
fac = [0] * SIZE # fac[j] = j! mod MOD
finv = [0] * SIZE # finv[j] = (j!)^{-1} mod MOD
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2, SIZE):
fac[i] = fac[i - 1] * i % MOD
finv[-1] = pow(fac[-1], MOD - 2, MOD)
for i in range(SIZE - 1, 0, -1):
finv[i - 1] = finv[i] * i % MOD
inv[i] = finv[i] * fac[i - 1] % MOD
def choose(n, r): # nCk mod MOD の計算
if 0 <= r <= n:
return (fac[n] * finv[r] % MOD) * finv[n - r] % MOD
else:
return 0
def f(x, y):
return fac[x] * finv[x - y] % MOD
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
n, m = list(map(int, readline().split()))
ans = 0
r = 1
for u in range(n + 1):
ans += r * f(m - u, n - u) * choose(n, u) % MOD
ans %= MOD
r *= -1
print((ans * f(m, n) % MOD))
|
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
n, m = list(map(int, readline().split()))
"""
漸化式は f(m,n) = (m-1)f(m-1,n-1) + (n-1)f(m-2,n-2)
初期条件 f(m-n,0)=1, f(m-n+1,1)=m-n
"""
MOD = 10**9 + 7
res = [0] * (n + 1)
res[0] = 1
res[1] = m - n
for i in range(2, n + 1):
res[i] = (m - n + i - 1) * res[i - 1] + (i - 1) * res[i - 2]
res[i] %= MOD
# print(res)
ans = res[n]
for i in range(m, m - n, -1):
ans *= i
ans %= MOD
print(ans)
| false | 40.909091 |
[
"-SIZE = 5 * 10**5",
"-MOD = 10**9 + 7 # 998244353 #ここを変更する",
"-SIZE += 1",
"-inv = [0] * SIZE # inv[j] = j^{-1} mod MOD",
"-fac = [0] * SIZE # fac[j] = j! mod MOD",
"-finv = [0] * SIZE # finv[j] = (j!)^{-1} mod MOD",
"-fac[0] = fac[1] = 1",
"-finv[0] = finv[1] = 1",
"-for i in range(2, SIZE):",
"- fac[i] = fac[i - 1] * i % MOD",
"-finv[-1] = pow(fac[-1], MOD - 2, MOD)",
"-for i in range(SIZE - 1, 0, -1):",
"- finv[i - 1] = finv[i] * i % MOD",
"- inv[i] = finv[i] * fac[i - 1] % MOD",
"-",
"-",
"-def choose(n, r): # nCk mod MOD の計算",
"- if 0 <= r <= n:",
"- return (fac[n] * finv[r] % MOD) * finv[n - r] % MOD",
"- else:",
"- return 0",
"-",
"-",
"-def f(x, y):",
"- return fac[x] * finv[x - y] % MOD",
"-",
"-",
"-ans = 0",
"-r = 1",
"-for u in range(n + 1):",
"- ans += r * f(m - u, n - u) * choose(n, u) % MOD",
"+\"\"\"",
"+漸化式は f(m,n) = (m-1)f(m-1,n-1) + (n-1)f(m-2,n-2)",
"+初期条件 f(m-n,0)=1, f(m-n+1,1)=m-n",
"+\"\"\"",
"+MOD = 10**9 + 7",
"+res = [0] * (n + 1)",
"+res[0] = 1",
"+res[1] = m - n",
"+for i in range(2, n + 1):",
"+ res[i] = (m - n + i - 1) * res[i - 1] + (i - 1) * res[i - 2]",
"+ res[i] %= MOD",
"+# print(res)",
"+ans = res[n]",
"+for i in range(m, m - n, -1):",
"+ ans *= i",
"- r *= -1",
"-print((ans * f(m, n) % MOD))",
"+print(ans)"
] | false | 0.957659 | 0.187835 | 5.098402 |
[
"s625140458",
"s077423326"
] |
u835534360
|
p03161
|
python
|
s467011612
|
s684557878
| 516 | 225 | 92,684 | 92,780 |
Accepted
|
Accepted
| 56.4 |
import sys
def main():
INF=sys.maxsize
N,K=tuple(map(int,sys.stdin.readline().split()))
h=tuple(map(int,sys.stdin.readline().split()))
dp=[INF for _ in range(N)]
dp[0]=0
for i in range(N-1):
for j in range(1,K+1):
if i+j<N:dp[i+j]=min([dp[i+j],dp[i]+abs(h[i+j]-h[i])])
print((dp[N-1]))
if __name__=='__main__':main()
|
import sys
def main():
INF=sys.maxsize
N,K=tuple(map(int,sys.stdin.readline().split()))
h=tuple(map(int,sys.stdin.readline().split()))
dp=[INF for _ in range(N)]
dp[0]=0
for i in range(1,N):
for j in range(1,K+1):
if i-j>=0:
dij=dp[i-j]+abs(h[i]-h[i-j])
if dij<dp[i]:dp[i] = dij
print((dp[N-1]))
if __name__=='__main__':main()
| 12 | 14 | 373 | 417 |
import sys
def main():
INF = sys.maxsize
N, K = tuple(map(int, sys.stdin.readline().split()))
h = tuple(map(int, sys.stdin.readline().split()))
dp = [INF for _ in range(N)]
dp[0] = 0
for i in range(N - 1):
for j in range(1, K + 1):
if i + j < N:
dp[i + j] = min([dp[i + j], dp[i] + abs(h[i + j] - h[i])])
print((dp[N - 1]))
if __name__ == "__main__":
main()
|
import sys
def main():
INF = sys.maxsize
N, K = tuple(map(int, sys.stdin.readline().split()))
h = tuple(map(int, sys.stdin.readline().split()))
dp = [INF for _ in range(N)]
dp[0] = 0
for i in range(1, N):
for j in range(1, K + 1):
if i - j >= 0:
dij = dp[i - j] + abs(h[i] - h[i - j])
if dij < dp[i]:
dp[i] = dij
print((dp[N - 1]))
if __name__ == "__main__":
main()
| false | 14.285714 |
[
"- for i in range(N - 1):",
"+ for i in range(1, N):",
"- if i + j < N:",
"- dp[i + j] = min([dp[i + j], dp[i] + abs(h[i + j] - h[i])])",
"+ if i - j >= 0:",
"+ dij = dp[i - j] + abs(h[i] - h[i - j])",
"+ if dij < dp[i]:",
"+ dp[i] = dij"
] | false | 0.039925 | 0.076056 | 0.524943 |
[
"s467011612",
"s684557878"
] |
u197955752
|
p02713
|
python
|
s871084152
|
s876046185
| 1,306 | 515 | 9,180 | 9,208 |
Accepted
|
Accepted
| 60.57 |
import math
K = int(eval(input()))
ans = 0
for a in range(1, K + 1):
for b in range(1, K + 1):
d = math.gcd(a, b)
for c in range(1, K + 1):
ans += math.gcd(d, c)
print(ans)
|
import math
K = int(eval(input()))
ans = 0
for a in range(1, K + 1):
for b in range(a, K + 1):
ab = math.gcd(a, b)
for c in range(b, K + 1):
abc = math.gcd(ab, c)
if a == b == c:
m = 1
elif a == b or b == c or c == a:
m = 3
else:
m = 6
ans += m * abc
print(ans)
| 11 | 19 | 210 | 404 |
import math
K = int(eval(input()))
ans = 0
for a in range(1, K + 1):
for b in range(1, K + 1):
d = math.gcd(a, b)
for c in range(1, K + 1):
ans += math.gcd(d, c)
print(ans)
|
import math
K = int(eval(input()))
ans = 0
for a in range(1, K + 1):
for b in range(a, K + 1):
ab = math.gcd(a, b)
for c in range(b, K + 1):
abc = math.gcd(ab, c)
if a == b == c:
m = 1
elif a == b or b == c or c == a:
m = 3
else:
m = 6
ans += m * abc
print(ans)
| false | 42.105263 |
[
"- for b in range(1, K + 1):",
"- d = math.gcd(a, b)",
"- for c in range(1, K + 1):",
"- ans += math.gcd(d, c)",
"+ for b in range(a, K + 1):",
"+ ab = math.gcd(a, b)",
"+ for c in range(b, K + 1):",
"+ abc = math.gcd(ab, c)",
"+ if a == b == c:",
"+ m = 1",
"+ elif a == b or b == c or c == a:",
"+ m = 3",
"+ else:",
"+ m = 6",
"+ ans += m * abc"
] | false | 0.130506 | 0.067808 | 1.924637 |
[
"s871084152",
"s876046185"
] |
u026788530
|
p02685
|
python
|
s825227000
|
s735250100
| 1,965 | 1,563 | 32,672 | 26,324 |
Accepted
|
Accepted
| 20.46 |
MOD = 10000000007
lim = 200000
MOD = 998244353
inv_t = [-1 for i in range(lim+1)]
factrial = [-1 for i in range(lim+1)]
factrial_inv = [-1 for i in range(lim+1)]
def set_inv(max=lim):
inv_t[0] = 0
for i in range(1, max):
if inv_t[i] == -1:
_ = mod_inv(i)
inv_t[i] = _
def mod_inv(x, mod=MOD):
y, u, v, _x = mod, 1, 0, x
while y:
t = _x//y
_x -= t*y
_x, y = y, _x
u -= t*v
u, v = v, u
u %= mod
if u < 0:
u += mod
return u
def mod_pow(a, n, mod=MOD):
res = 1
while n:
if n & 1:
res = res*a % mod
a = a*a % mod
n >>= 1
return res
def set_factrial(max=lim, mod=MOD):
c = 1
factrial[0] = factrial_inv[0] = 1
for i in range(1, max):
c *= i
c %= mod
factrial[i] = c
factrial_inv[i] = mod_inv(c, mod)
def comb(a, b, mod=MOD):
if factrial == -1:
set_factrial()
return (factrial[a]*factrial_inv[b]*factrial_inv[a-b]) % MOD
n, m, k = [int(_) for _ in input().split()]
ans = 0
set_inv()
set_factrial()
for i in range(k+1):
ans += m*comb(n-1, i)*mod_pow(m-1, n-1 - i)
ans %= MOD
# print(ans)
print(ans)
|
MOD = 998244353
lim = 200000
inv_t = [-1 for i in range(lim+1)]
factrial = [-1 for i in range(lim+1)]
factrial_inv = [-1 for i in range(lim+1)]
def set_inv(max=lim):
inv_t[0] = 0
for i in range(1, max):
inv_t[i] == mod_inv(i)
def mod_inv(x, mod=MOD):
y, u, v, _x = mod, 1, 0, x
while y:
t = _x//y
_x -= t*y
_x, y = y, _x
u -= t*v
u, v = v, u
u %= mod
if u < 0:
u += mod
return u
def mod_pow(a, n, mod=MOD):
res = 1
while n:
if n & 1:
res = res*a % mod
a = a*a % mod
n >>= 1
return res
def set_factrial(max=lim, mod=MOD):
c = 1
factrial[0] = factrial_inv[0] = 1
for i in range(1, max):
c *= i
c %= mod
factrial[i] = c
factrial_inv[i] = mod_inv(c, mod)
def comb(a, b, mod=MOD):
if factrial[0] == -1:
set_factrial()
return (factrial[a]*factrial_inv[b]*factrial_inv[a-b]) % mod
n, m, k = [int(_) for _ in input().split()]
ans = 0
for i in range(k+1):
ans += m*comb(n-1, i)*mod_pow(m-1, n-1 - i)
ans %= MOD
# print(ans)
print(ans)
| 66 | 61 | 1,296 | 1,203 |
MOD = 10000000007
lim = 200000
MOD = 998244353
inv_t = [-1 for i in range(lim + 1)]
factrial = [-1 for i in range(lim + 1)]
factrial_inv = [-1 for i in range(lim + 1)]
def set_inv(max=lim):
inv_t[0] = 0
for i in range(1, max):
if inv_t[i] == -1:
_ = mod_inv(i)
inv_t[i] = _
def mod_inv(x, mod=MOD):
y, u, v, _x = mod, 1, 0, x
while y:
t = _x // y
_x -= t * y
_x, y = y, _x
u -= t * v
u, v = v, u
u %= mod
if u < 0:
u += mod
return u
def mod_pow(a, n, mod=MOD):
res = 1
while n:
if n & 1:
res = res * a % mod
a = a * a % mod
n >>= 1
return res
def set_factrial(max=lim, mod=MOD):
c = 1
factrial[0] = factrial_inv[0] = 1
for i in range(1, max):
c *= i
c %= mod
factrial[i] = c
factrial_inv[i] = mod_inv(c, mod)
def comb(a, b, mod=MOD):
if factrial == -1:
set_factrial()
return (factrial[a] * factrial_inv[b] * factrial_inv[a - b]) % MOD
n, m, k = [int(_) for _ in input().split()]
ans = 0
set_inv()
set_factrial()
for i in range(k + 1):
ans += m * comb(n - 1, i) * mod_pow(m - 1, n - 1 - i)
ans %= MOD
# print(ans)
print(ans)
|
MOD = 998244353
lim = 200000
inv_t = [-1 for i in range(lim + 1)]
factrial = [-1 for i in range(lim + 1)]
factrial_inv = [-1 for i in range(lim + 1)]
def set_inv(max=lim):
inv_t[0] = 0
for i in range(1, max):
inv_t[i] == mod_inv(i)
def mod_inv(x, mod=MOD):
y, u, v, _x = mod, 1, 0, x
while y:
t = _x // y
_x -= t * y
_x, y = y, _x
u -= t * v
u, v = v, u
u %= mod
if u < 0:
u += mod
return u
def mod_pow(a, n, mod=MOD):
res = 1
while n:
if n & 1:
res = res * a % mod
a = a * a % mod
n >>= 1
return res
def set_factrial(max=lim, mod=MOD):
c = 1
factrial[0] = factrial_inv[0] = 1
for i in range(1, max):
c *= i
c %= mod
factrial[i] = c
factrial_inv[i] = mod_inv(c, mod)
def comb(a, b, mod=MOD):
if factrial[0] == -1:
set_factrial()
return (factrial[a] * factrial_inv[b] * factrial_inv[a - b]) % mod
n, m, k = [int(_) for _ in input().split()]
ans = 0
for i in range(k + 1):
ans += m * comb(n - 1, i) * mod_pow(m - 1, n - 1 - i)
ans %= MOD
# print(ans)
print(ans)
| false | 7.575758 |
[
"-MOD = 10000000007",
"+MOD = 998244353",
"-MOD = 998244353",
"- if inv_t[i] == -1:",
"- _ = mod_inv(i)",
"- inv_t[i] = _",
"+ inv_t[i] == mod_inv(i)",
"- if factrial == -1:",
"+ if factrial[0] == -1:",
"- return (factrial[a] * factrial_inv[b] * factrial_inv[a - b]) % MOD",
"+ return (factrial[a] * factrial_inv[b] * factrial_inv[a - b]) % mod",
"-set_inv()",
"-set_factrial()"
] | false | 2.052804 | 1.047779 | 1.959196 |
[
"s825227000",
"s735250100"
] |
u606045429
|
p03297
|
python
|
s578857468
|
s154514849
| 41 | 20 | 5,472 | 3,064 |
Accepted
|
Accepted
| 51.22 |
from fractions import gcd
T = int(eval(input()))
for _ in range(T):
a, b, c, d = list(map(int, input().split()))
if a < b or d < b:
flag = False
elif c >= b - 1:
flag = True
else:
g = gcd(b, d)
flag = (b + a % g - g) <= c
if flag:
print("Yes")
else:
print("No")
|
def gcd(a, b):
return a if b == 0 else gcd(b, a % b)
T = int(eval(input()))
for _ in range(T):
a, b, c, d = list(map(int, input().split()))
if a < b or d < b:
flag = False
elif c >= b - 1:
flag = True
else:
g = gcd(b, d)
flag = (b + a % g - g) <= c
if flag:
print("Yes")
else:
print("No")
| 19 | 20 | 345 | 376 |
from fractions import gcd
T = int(eval(input()))
for _ in range(T):
a, b, c, d = list(map(int, input().split()))
if a < b or d < b:
flag = False
elif c >= b - 1:
flag = True
else:
g = gcd(b, d)
flag = (b + a % g - g) <= c
if flag:
print("Yes")
else:
print("No")
|
def gcd(a, b):
return a if b == 0 else gcd(b, a % b)
T = int(eval(input()))
for _ in range(T):
a, b, c, d = list(map(int, input().split()))
if a < b or d < b:
flag = False
elif c >= b - 1:
flag = True
else:
g = gcd(b, d)
flag = (b + a % g - g) <= c
if flag:
print("Yes")
else:
print("No")
| false | 5 |
[
"-from fractions import gcd",
"+def gcd(a, b):",
"+ return a if b == 0 else gcd(b, a % b)",
"+"
] | false | 0.043826 | 0.036388 | 1.204421 |
[
"s578857468",
"s154514849"
] |
u533039576
|
p02913
|
python
|
s955930290
|
s289417136
| 694 | 407 | 49,244 | 42,204 |
Accepted
|
Accepted
| 41.35 |
def z_algorithm(s):
n = len(s)
z = [0] * n
z[0] = n
i = 1
lcp = 0
while i < n:
while i+lcp < n and s[i+lcp] == s[lcp]:
lcp += 1
z[i] = lcp
if lcp == 0:
i += 1
continue
k = 1
while i+k < n and k+z[k] < lcp:
z[i+k] = z[k]
k += 1
i += k
lcp -= k
return z
n = int(eval(input()))
s = eval(input())
ans = 0
for i in range(n):
z = z_algorithm(s[i:])
for j in range(1, n-i):
ans = max(ans, min(j, z[j]))
print(ans)
|
n = int(eval(input()))
s = eval(input())
ans = 0
for i in range(1, n):
cnt = 0
for j in range(n-i):
if s[i+j] == s[j]:
cnt += 1
else:
ans = max(ans, min(cnt, i))
cnt = 0
ans = max(ans, min(cnt, i))
print(ans)
| 37 | 15 | 600 | 277 |
def z_algorithm(s):
n = len(s)
z = [0] * n
z[0] = n
i = 1
lcp = 0
while i < n:
while i + lcp < n and s[i + lcp] == s[lcp]:
lcp += 1
z[i] = lcp
if lcp == 0:
i += 1
continue
k = 1
while i + k < n and k + z[k] < lcp:
z[i + k] = z[k]
k += 1
i += k
lcp -= k
return z
n = int(eval(input()))
s = eval(input())
ans = 0
for i in range(n):
z = z_algorithm(s[i:])
for j in range(1, n - i):
ans = max(ans, min(j, z[j]))
print(ans)
|
n = int(eval(input()))
s = eval(input())
ans = 0
for i in range(1, n):
cnt = 0
for j in range(n - i):
if s[i + j] == s[j]:
cnt += 1
else:
ans = max(ans, min(cnt, i))
cnt = 0
ans = max(ans, min(cnt, i))
print(ans)
| false | 59.459459 |
[
"-def z_algorithm(s):",
"- n = len(s)",
"- z = [0] * n",
"- z[0] = n",
"- i = 1",
"- lcp = 0",
"- while i < n:",
"- while i + lcp < n and s[i + lcp] == s[lcp]:",
"- lcp += 1",
"- z[i] = lcp",
"- if lcp == 0:",
"- i += 1",
"- continue",
"- k = 1",
"- while i + k < n and k + z[k] < lcp:",
"- z[i + k] = z[k]",
"- k += 1",
"- i += k",
"- lcp -= k",
"- return z",
"-",
"-",
"-for i in range(n):",
"- z = z_algorithm(s[i:])",
"- for j in range(1, n - i):",
"- ans = max(ans, min(j, z[j]))",
"+for i in range(1, n):",
"+ cnt = 0",
"+ for j in range(n - i):",
"+ if s[i + j] == s[j]:",
"+ cnt += 1",
"+ else:",
"+ ans = max(ans, min(cnt, i))",
"+ cnt = 0",
"+ ans = max(ans, min(cnt, i))"
] | false | 0.036625 | 0.038311 | 0.955984 |
[
"s955930290",
"s289417136"
] |
u200916944
|
p02861
|
python
|
s316338225
|
s220458831
| 324 | 273 | 14,376 | 9,408 |
Accepted
|
Accepted
| 15.74 |
N = int(eval(input()))
XYS = [list(map(int, input().split())) for _ in range(N)]
s = 0
def perm(ns):
acc = []
def fill(ms, remains):
if remains:
for m in remains:
fill(ms + [m], [x for x in remains if x != m])
else:
acc.append(ms)
fill([], ns)
return acc
s = 0
for indexes in perm(list(range(N))):
xys = [XYS[i] for i in indexes]
x0, y0 = xys[0]
for x1, y1 in xys:
s += ((x0 - x1)**2 + (y0 - y1)**2) ** 0.5
x0 = x1
y0 = y1
nf = 1
for i in range(1, N+1):
nf *= i
ans = s / nf
print(ans)
|
from itertools import permutations as perm
N = int(eval(input()))
XYS = [list(map(int, input().split())) for _ in range(N)]
s = 0
for indexes in perm(list(range(N))):
xys = [XYS[i] for i in indexes]
x0, y0 = xys[0]
for x1, y1 in xys:
s += ((x0 - x1)**2 + (y0 - y1)**2) ** 0.5
x0 = x1
y0 = y1
nf = 1
for i in range(1, N+1):
nf *= i
ans = s / nf
print(ans)
| 29 | 19 | 622 | 409 |
N = int(eval(input()))
XYS = [list(map(int, input().split())) for _ in range(N)]
s = 0
def perm(ns):
acc = []
def fill(ms, remains):
if remains:
for m in remains:
fill(ms + [m], [x for x in remains if x != m])
else:
acc.append(ms)
fill([], ns)
return acc
s = 0
for indexes in perm(list(range(N))):
xys = [XYS[i] for i in indexes]
x0, y0 = xys[0]
for x1, y1 in xys:
s += ((x0 - x1) ** 2 + (y0 - y1) ** 2) ** 0.5
x0 = x1
y0 = y1
nf = 1
for i in range(1, N + 1):
nf *= i
ans = s / nf
print(ans)
|
from itertools import permutations as perm
N = int(eval(input()))
XYS = [list(map(int, input().split())) for _ in range(N)]
s = 0
for indexes in perm(list(range(N))):
xys = [XYS[i] for i in indexes]
x0, y0 = xys[0]
for x1, y1 in xys:
s += ((x0 - x1) ** 2 + (y0 - y1) ** 2) ** 0.5
x0 = x1
y0 = y1
nf = 1
for i in range(1, N + 1):
nf *= i
ans = s / nf
print(ans)
| false | 34.482759 |
[
"+from itertools import permutations as perm",
"+",
"-s = 0",
"-",
"-",
"-def perm(ns):",
"- acc = []",
"-",
"- def fill(ms, remains):",
"- if remains:",
"- for m in remains:",
"- fill(ms + [m], [x for x in remains if x != m])",
"- else:",
"- acc.append(ms)",
"-",
"- fill([], ns)",
"- return acc",
"-",
"-"
] | false | 0.091496 | 0.006827 | 13.401497 |
[
"s316338225",
"s220458831"
] |
u130900604
|
p02832
|
python
|
s820179351
|
s125862290
| 158 | 113 | 26,012 | 24,900 |
Accepted
|
Accepted
| 28.48 |
n=int(eval(input()))
a=list(map(int,input().split()))
cnt=0
#n=200000
if 1 not in a:
print((-1));exit()
from collections import*
b=deque(a)
#print(b)
i=1
while True:
if len(b)==0:
break
if b[0]==i:
cnt+=0
b.popleft()
i+=1
else:
cnt+=1
b.popleft()
#print(b,cnt)
print(cnt)
|
from collections import*
n,*a=list(map(int,open(0).read().split()))
def main():
if 1 not in a:
print((-1));exit()
b=deque(a)
#print(b)
i=1
cnt=0
while True:
if len(b)==0:
break
if b[0]!=i:
cnt+=1
b.popleft()
else:#b[0]==i
cnt+=0
b.popleft()
i+=1
#print(b,cnt)
print(cnt)
main()
| 23 | 34 | 327 | 388 |
n = int(eval(input()))
a = list(map(int, input().split()))
cnt = 0
# n=200000
if 1 not in a:
print((-1))
exit()
from collections import *
b = deque(a)
# print(b)
i = 1
while True:
if len(b) == 0:
break
if b[0] == i:
cnt += 0
b.popleft()
i += 1
else:
cnt += 1
b.popleft()
# print(b,cnt)
print(cnt)
|
from collections import *
n, *a = list(map(int, open(0).read().split()))
def main():
if 1 not in a:
print((-1))
exit()
b = deque(a)
# print(b)
i = 1
cnt = 0
while True:
if len(b) == 0:
break
if b[0] != i:
cnt += 1
b.popleft()
else: # b[0]==i
cnt += 0
b.popleft()
i += 1
# print(b,cnt)
print(cnt)
main()
| false | 32.352941 |
[
"-n = int(eval(input()))",
"-a = list(map(int, input().split()))",
"-cnt = 0",
"-# n=200000",
"-if 1 not in a:",
"- print((-1))",
"- exit()",
"-b = deque(a)",
"-# print(b)",
"-i = 1",
"-while True:",
"- if len(b) == 0:",
"- break",
"- if b[0] == i:",
"- cnt += 0",
"- b.popleft()",
"- i += 1",
"- else:",
"- cnt += 1",
"- b.popleft()",
"- # print(b,cnt)",
"-print(cnt)",
"+n, *a = list(map(int, open(0).read().split()))",
"+",
"+",
"+def main():",
"+ if 1 not in a:",
"+ print((-1))",
"+ exit()",
"+ b = deque(a)",
"+ # print(b)",
"+ i = 1",
"+ cnt = 0",
"+ while True:",
"+ if len(b) == 0:",
"+ break",
"+ if b[0] != i:",
"+ cnt += 1",
"+ b.popleft()",
"+ else: # b[0]==i",
"+ cnt += 0",
"+ b.popleft()",
"+ i += 1",
"+ # print(b,cnt)",
"+ print(cnt)",
"+",
"+",
"+main()"
] | false | 0.081713 | 0.085115 | 0.960026 |
[
"s820179351",
"s125862290"
] |
u145950990
|
p02996
|
python
|
s388078214
|
s150165657
| 940 | 589 | 53,728 | 112,688 |
Accepted
|
Accepted
| 37.34 |
n = int(eval(input()))
d = [list(map(int,input().split())) for i in range(n)]
d.sort(key=lambda x: x[1])
ans = 'Yes'
t = 0
for i in d:
t += i[0]
if t>i[1]:ans='No'
print(ans)
|
n = int(eval(input()))
from bisect import bisect
ab = [list(map(int,input().split())) for i in range(n)]
ab.sort(key = lambda x: x[1])
ok = True
last = 0
for a,b in ab:
if b-a>=last:
last += a
else:
ok = not ok
break
print(('Yes' if ok else 'No'))
| 9 | 14 | 184 | 286 |
n = int(eval(input()))
d = [list(map(int, input().split())) for i in range(n)]
d.sort(key=lambda x: x[1])
ans = "Yes"
t = 0
for i in d:
t += i[0]
if t > i[1]:
ans = "No"
print(ans)
|
n = int(eval(input()))
from bisect import bisect
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort(key=lambda x: x[1])
ok = True
last = 0
for a, b in ab:
if b - a >= last:
last += a
else:
ok = not ok
break
print(("Yes" if ok else "No"))
| false | 35.714286 |
[
"-d = [list(map(int, input().split())) for i in range(n)]",
"-d.sort(key=lambda x: x[1])",
"-ans = \"Yes\"",
"-t = 0",
"-for i in d:",
"- t += i[0]",
"- if t > i[1]:",
"- ans = \"No\"",
"-print(ans)",
"+from bisect import bisect",
"+",
"+ab = [list(map(int, input().split())) for i in range(n)]",
"+ab.sort(key=lambda x: x[1])",
"+ok = True",
"+last = 0",
"+for a, b in ab:",
"+ if b - a >= last:",
"+ last += a",
"+ else:",
"+ ok = not ok",
"+ break",
"+print((\"Yes\" if ok else \"No\"))"
] | false | 0.042335 | 0.0372 | 1.138044 |
[
"s388078214",
"s150165657"
] |
u282676559
|
p03545
|
python
|
s456240074
|
s076815411
| 20 | 17 | 3,060 | 3,060 |
Accepted
|
Accepted
| 15 |
A = eval(input())
for i in range(8):
B = format(i, '03b').replace('0','-').replace('1','+')
ans = ''.join([a+b for b,a in zip(B,A)]) + A[-1]
if eval(ans) == 7:
print((ans+'=7'))
exit()
|
A = eval(input())
for i in range(8):
B = format(i, '03b').replace('0','+').replace('1','-')
ans = ''.join([a+b for b,a in zip(B,A)]) + A[-1]
if eval(ans) == 7:
print((ans+'=7'))
exit()
| 7 | 7 | 196 | 196 |
A = eval(input())
for i in range(8):
B = format(i, "03b").replace("0", "-").replace("1", "+")
ans = "".join([a + b for b, a in zip(B, A)]) + A[-1]
if eval(ans) == 7:
print((ans + "=7"))
exit()
|
A = eval(input())
for i in range(8):
B = format(i, "03b").replace("0", "+").replace("1", "-")
ans = "".join([a + b for b, a in zip(B, A)]) + A[-1]
if eval(ans) == 7:
print((ans + "=7"))
exit()
| false | 0 |
[
"- B = format(i, \"03b\").replace(\"0\", \"-\").replace(\"1\", \"+\")",
"+ B = format(i, \"03b\").replace(\"0\", \"+\").replace(\"1\", \"-\")"
] | false | 0.072286 | 0.074137 | 0.975026 |
[
"s456240074",
"s076815411"
] |
u017810624
|
p02720
|
python
|
s315669496
|
s360679608
| 377 | 289 | 78,092 | 65,500 |
Accepted
|
Accepted
| 23.34 |
k=int(eval(input()))
l=[]
for i1 in range(10):
l.append(i1)
for i2 in range(max(i1-1,0),min(i1+2,10)):
l.append(i1*(10**1)+i2)
for i3 in range(max(i2-1,0),min(i2+2,10)):
l.append(i1*(10**2)+i2*(10**1)+i3)
for i4 in range(max(i3-1,0),min(i3+2,10)):
l.append(i1*(10**3)+i2*(10**2)+i3*(10**1)+i4)
for i5 in range(max(i4-1,0),min(i4+2,10)):
l.append(i1*(10**4)+i2*(10**3)+i3*(10**2)+i4*(10**1)+i5)
for i6 in range(max(i5-1,0),min(i5+2,10)):
l.append(i1*(10**5)+i2*(10**4)+i3*(10**3)+i4*(10**2)+i5*(10**1)+i6)
for i7 in range(max(i6-1,0),min(i6+2,10)):
l.append(i1*(10**6)+i2*(10**5)+i3*(10**4)+i4*(10**3)+i5*(10**2)+i6*(10**1)+i7)
for i8 in range(max(i7-1,0),min(i7+2,10)):
l.append(i1*(10**7)+i2*(10**6)+i3*(10**5)+i4*(10**4)+i5*(10**3)+i6*(10**2)+i7*(10**1)+i8)
for i9 in range(max(i8-1,0),min(i8+2,10)):
l.append(i1*(10**8)+i2*(10**7)+i3*(10**6)+i4*(10**5)+i5*(10**4)+i6*(10**3)+i7*(10**2)+i8*(10**1)+i9)
for i10 in range(max(i9-1,0),min(i9+2,10)):
l.append(i1*(10**9)+i2*(10**8)+i3*(10**7)+i4*(10**6)+i5*(10**5)+i6*(10**4)+i7*(10**3)+i8*(10**2)+i9*(10**1)+i10)
l=list(set(l))
l.sort()
print((l[k]))
|
import copy
k=int(eval(input()))
ans=[[str(i+1) for i in range(9)]]
l2=[]
for i in range(9):
l=ans[-1]
l2=[]
for j in range(len(l)):
if int(l[j][-1])!=0:
l2.append(l[j]+str(int(l[j][-1])-1))
l2.append(l[j]+str(int(l[j][-1])))
if int(l[j][-1])!=9:
l2.append(l[j]+str(int(l[j][-1])+1))
ans.append(l2)
l=copy.copy(l2)
a=[]
for i in range(10):
a=a+ans[i]
print((a[k-1]))
| 26 | 19 | 1,316 | 412 |
k = int(eval(input()))
l = []
for i1 in range(10):
l.append(i1)
for i2 in range(max(i1 - 1, 0), min(i1 + 2, 10)):
l.append(i1 * (10**1) + i2)
for i3 in range(max(i2 - 1, 0), min(i2 + 2, 10)):
l.append(i1 * (10**2) + i2 * (10**1) + i3)
for i4 in range(max(i3 - 1, 0), min(i3 + 2, 10)):
l.append(i1 * (10**3) + i2 * (10**2) + i3 * (10**1) + i4)
for i5 in range(max(i4 - 1, 0), min(i4 + 2, 10)):
l.append(
i1 * (10**4)
+ i2 * (10**3)
+ i3 * (10**2)
+ i4 * (10**1)
+ i5
)
for i6 in range(max(i5 - 1, 0), min(i5 + 2, 10)):
l.append(
i1 * (10**5)
+ i2 * (10**4)
+ i3 * (10**3)
+ i4 * (10**2)
+ i5 * (10**1)
+ i6
)
for i7 in range(max(i6 - 1, 0), min(i6 + 2, 10)):
l.append(
i1 * (10**6)
+ i2 * (10**5)
+ i3 * (10**4)
+ i4 * (10**3)
+ i5 * (10**2)
+ i6 * (10**1)
+ i7
)
for i8 in range(max(i7 - 1, 0), min(i7 + 2, 10)):
l.append(
i1 * (10**7)
+ i2 * (10**6)
+ i3 * (10**5)
+ i4 * (10**4)
+ i5 * (10**3)
+ i6 * (10**2)
+ i7 * (10**1)
+ i8
)
for i9 in range(max(i8 - 1, 0), min(i8 + 2, 10)):
l.append(
i1 * (10**8)
+ i2 * (10**7)
+ i3 * (10**6)
+ i4 * (10**5)
+ i5 * (10**4)
+ i6 * (10**3)
+ i7 * (10**2)
+ i8 * (10**1)
+ i9
)
for i10 in range(max(i9 - 1, 0), min(i9 + 2, 10)):
l.append(
i1 * (10**9)
+ i2 * (10**8)
+ i3 * (10**7)
+ i4 * (10**6)
+ i5 * (10**5)
+ i6 * (10**4)
+ i7 * (10**3)
+ i8 * (10**2)
+ i9 * (10**1)
+ i10
)
l = list(set(l))
l.sort()
print((l[k]))
|
import copy
k = int(eval(input()))
ans = [[str(i + 1) for i in range(9)]]
l2 = []
for i in range(9):
l = ans[-1]
l2 = []
for j in range(len(l)):
if int(l[j][-1]) != 0:
l2.append(l[j] + str(int(l[j][-1]) - 1))
l2.append(l[j] + str(int(l[j][-1])))
if int(l[j][-1]) != 9:
l2.append(l[j] + str(int(l[j][-1]) + 1))
ans.append(l2)
l = copy.copy(l2)
a = []
for i in range(10):
a = a + ans[i]
print((a[k - 1]))
| false | 26.923077 |
[
"+import copy",
"+",
"-l = []",
"-for i1 in range(10):",
"- l.append(i1)",
"- for i2 in range(max(i1 - 1, 0), min(i1 + 2, 10)):",
"- l.append(i1 * (10**1) + i2)",
"- for i3 in range(max(i2 - 1, 0), min(i2 + 2, 10)):",
"- l.append(i1 * (10**2) + i2 * (10**1) + i3)",
"- for i4 in range(max(i3 - 1, 0), min(i3 + 2, 10)):",
"- l.append(i1 * (10**3) + i2 * (10**2) + i3 * (10**1) + i4)",
"- for i5 in range(max(i4 - 1, 0), min(i4 + 2, 10)):",
"- l.append(",
"- i1 * (10**4)",
"- + i2 * (10**3)",
"- + i3 * (10**2)",
"- + i4 * (10**1)",
"- + i5",
"- )",
"- for i6 in range(max(i5 - 1, 0), min(i5 + 2, 10)):",
"- l.append(",
"- i1 * (10**5)",
"- + i2 * (10**4)",
"- + i3 * (10**3)",
"- + i4 * (10**2)",
"- + i5 * (10**1)",
"- + i6",
"- )",
"- for i7 in range(max(i6 - 1, 0), min(i6 + 2, 10)):",
"- l.append(",
"- i1 * (10**6)",
"- + i2 * (10**5)",
"- + i3 * (10**4)",
"- + i4 * (10**3)",
"- + i5 * (10**2)",
"- + i6 * (10**1)",
"- + i7",
"- )",
"- for i8 in range(max(i7 - 1, 0), min(i7 + 2, 10)):",
"- l.append(",
"- i1 * (10**7)",
"- + i2 * (10**6)",
"- + i3 * (10**5)",
"- + i4 * (10**4)",
"- + i5 * (10**3)",
"- + i6 * (10**2)",
"- + i7 * (10**1)",
"- + i8",
"- )",
"- for i9 in range(max(i8 - 1, 0), min(i8 + 2, 10)):",
"- l.append(",
"- i1 * (10**8)",
"- + i2 * (10**7)",
"- + i3 * (10**6)",
"- + i4 * (10**5)",
"- + i5 * (10**4)",
"- + i6 * (10**3)",
"- + i7 * (10**2)",
"- + i8 * (10**1)",
"- + i9",
"- )",
"- for i10 in range(max(i9 - 1, 0), min(i9 + 2, 10)):",
"- l.append(",
"- i1 * (10**9)",
"- + i2 * (10**8)",
"- + i3 * (10**7)",
"- + i4 * (10**6)",
"- + i5 * (10**5)",
"- + i6 * (10**4)",
"- + i7 * (10**3)",
"- + i8 * (10**2)",
"- + i9 * (10**1)",
"- + i10",
"- )",
"-l = list(set(l))",
"-l.sort()",
"-print((l[k]))",
"+ans = [[str(i + 1) for i in range(9)]]",
"+l2 = []",
"+for i in range(9):",
"+ l = ans[-1]",
"+ l2 = []",
"+ for j in range(len(l)):",
"+ if int(l[j][-1]) != 0:",
"+ l2.append(l[j] + str(int(l[j][-1]) - 1))",
"+ l2.append(l[j] + str(int(l[j][-1])))",
"+ if int(l[j][-1]) != 9:",
"+ l2.append(l[j] + str(int(l[j][-1]) + 1))",
"+ ans.append(l2)",
"+ l = copy.copy(l2)",
"+a = []",
"+for i in range(10):",
"+ a = a + ans[i]",
"+print((a[k - 1]))"
] | false | 0.007743 | 0.340352 | 0.022751 |
[
"s315669496",
"s360679608"
] |
u243714267
|
p02691
|
python
|
s703782309
|
s351112832
| 314 | 265 | 32,244 | 32,284 |
Accepted
|
Accepted
| 15.61 |
n = int(eval(input()))
a = list(map(int, input().split()))
fromLeft = [-1]*n
for i in range(n):
fromLeft[i] = a[i] - i
ans = 0
ldList = [0]*(n*2+5)
for i in reversed(list(range(n))):
if 0 <= fromLeft[i]+n+1 and fromLeft[i]+n+1 < n*2+5:
ldList[fromLeft[i]+n+1] += 1
if 0 <= -1*a[i]-i+n+1 and -1*a[i]-i+n+1 < n*2+5:
ans += ldList[-1*a[i]-i+n+1]
print(ans)
|
n = int(eval(input()))
a = list(map(int, input().split()))
fromLeftA = [-1]*n
for i in range(n):
fromLeftA[i] = a[i] - i
ans = 0
ldList = [0]*(n*2)
for i in reversed(list(range(n))):
if 0 <= fromLeftA[i]+n and fromLeftA[i]+n < n*2:
ldList[fromLeftA[i]+n] += 1
if 0 <= -1*a[i]-i+n and -1*a[i]-i+n < n*2:
ans += ldList[-1*a[i]-i+n]
print(ans)
| 19 | 18 | 393 | 378 |
n = int(eval(input()))
a = list(map(int, input().split()))
fromLeft = [-1] * n
for i in range(n):
fromLeft[i] = a[i] - i
ans = 0
ldList = [0] * (n * 2 + 5)
for i in reversed(list(range(n))):
if 0 <= fromLeft[i] + n + 1 and fromLeft[i] + n + 1 < n * 2 + 5:
ldList[fromLeft[i] + n + 1] += 1
if 0 <= -1 * a[i] - i + n + 1 and -1 * a[i] - i + n + 1 < n * 2 + 5:
ans += ldList[-1 * a[i] - i + n + 1]
print(ans)
|
n = int(eval(input()))
a = list(map(int, input().split()))
fromLeftA = [-1] * n
for i in range(n):
fromLeftA[i] = a[i] - i
ans = 0
ldList = [0] * (n * 2)
for i in reversed(list(range(n))):
if 0 <= fromLeftA[i] + n and fromLeftA[i] + n < n * 2:
ldList[fromLeftA[i] + n] += 1
if 0 <= -1 * a[i] - i + n and -1 * a[i] - i + n < n * 2:
ans += ldList[-1 * a[i] - i + n]
print(ans)
| false | 5.263158 |
[
"-fromLeft = [-1] * n",
"+fromLeftA = [-1] * n",
"- fromLeft[i] = a[i] - i",
"+ fromLeftA[i] = a[i] - i",
"-ldList = [0] * (n * 2 + 5)",
"+ldList = [0] * (n * 2)",
"- if 0 <= fromLeft[i] + n + 1 and fromLeft[i] + n + 1 < n * 2 + 5:",
"- ldList[fromLeft[i] + n + 1] += 1",
"- if 0 <= -1 * a[i] - i + n + 1 and -1 * a[i] - i + n + 1 < n * 2 + 5:",
"- ans += ldList[-1 * a[i] - i + n + 1]",
"+ if 0 <= fromLeftA[i] + n and fromLeftA[i] + n < n * 2:",
"+ ldList[fromLeftA[i] + n] += 1",
"+ if 0 <= -1 * a[i] - i + n and -1 * a[i] - i + n < n * 2:",
"+ ans += ldList[-1 * a[i] - i + n]"
] | false | 0.121035 | 0.051473 | 2.351438 |
[
"s703782309",
"s351112832"
] |
u018679195
|
p03264
|
python
|
s543546618
|
s972446675
| 19 | 17 | 3,188 | 3,064 |
Accepted
|
Accepted
| 10.53 |
n=int(eval(input()))
even=[]
odd=[]
for i in range (1,n+1,1):
if i%2==0:
even.append(i)
else:
odd.append(i)
result=[(x,y) for x in even for y in odd]
print((len(result)))
|
#hemasaidthatispair
k=int(eval(input()))
z=k**2//4
print(z)
| 10 | 4 | 195 | 56 |
n = int(eval(input()))
even = []
odd = []
for i in range(1, n + 1, 1):
if i % 2 == 0:
even.append(i)
else:
odd.append(i)
result = [(x, y) for x in even for y in odd]
print((len(result)))
|
# hemasaidthatispair
k = int(eval(input()))
z = k**2 // 4
print(z)
| false | 60 |
[
"-n = int(eval(input()))",
"-even = []",
"-odd = []",
"-for i in range(1, n + 1, 1):",
"- if i % 2 == 0:",
"- even.append(i)",
"- else:",
"- odd.append(i)",
"-result = [(x, y) for x in even for y in odd]",
"-print((len(result)))",
"+# hemasaidthatispair",
"+k = int(eval(input()))",
"+z = k**2 // 4",
"+print(z)"
] | false | 0.052501 | 0.050697 | 1.035584 |
[
"s543546618",
"s972446675"
] |
u571969099
|
p03371
|
python
|
s280321600
|
s392779179
| 228 | 209 | 3,060 | 3,060 |
Accepted
|
Accepted
| 8.33 |
a, b, c, x, y = [int(i) for i in input().split()]
ans = 10**18
for i in range(max(x, y)*2 + 1):
ans = min(ans, c * i + max(0,(x - i//2)) * a + max(0,(y - i//2)) * b)
print(ans)
|
a, b, c, x, y = list(map(int, input().split()))
ans = 10 ** 18
for i in range(10 ** 5 * 2):
ans = min(ans, i * 2 * c + max(0, x - i) * a + max(0, y - i) * b)
print(ans)
| 5 | 5 | 185 | 171 |
a, b, c, x, y = [int(i) for i in input().split()]
ans = 10**18
for i in range(max(x, y) * 2 + 1):
ans = min(ans, c * i + max(0, (x - i // 2)) * a + max(0, (y - i // 2)) * b)
print(ans)
|
a, b, c, x, y = list(map(int, input().split()))
ans = 10**18
for i in range(10**5 * 2):
ans = min(ans, i * 2 * c + max(0, x - i) * a + max(0, y - i) * b)
print(ans)
| false | 0 |
[
"-a, b, c, x, y = [int(i) for i in input().split()]",
"+a, b, c, x, y = list(map(int, input().split()))",
"-for i in range(max(x, y) * 2 + 1):",
"- ans = min(ans, c * i + max(0, (x - i // 2)) * a + max(0, (y - i // 2)) * b)",
"+for i in range(10**5 * 2):",
"+ ans = min(ans, i * 2 * c + max(0, x - i) * a + max(0, y - i) * b)"
] | false | 0.112095 | 0.419245 | 0.267374 |
[
"s280321600",
"s392779179"
] |
u152417130
|
p02537
|
python
|
s306600743
|
s422905535
| 1,385 | 520 | 140,164 | 94,712 |
Accepted
|
Accepted
| 62.45 |
class LazySegmentTree:
def __init__(self, data, default=0, func=max):
"""initialize the lazy segment tree with data"""
self._default = default
self._func = func
self._len = len(data)
self._size = _size = 1 << (self._len - 1).bit_length()
self._lazy = [0] * (2 * _size)
self.data = [default] * (2 * _size)
self.data[_size:_size + self._len] = data
for i in reversed(list(range(_size))):
self.data[i] = func(self.data[i + i], self.data[i + i + 1])
def __len__(self):
return self._len
def _push(self, idx):
"""push query on idx to its children"""
# Let the children know of the queries
q, self._lazy[idx] = self._lazy[idx], 0
if q:
self._lazy[2 * idx] = max(self._lazy[2 * idx],q)
self._lazy[2 * idx + 1] = max(self._lazy[2 * idx + 1],q)
self.data[2 * idx] = max(self.data[2 * idx], q)
self.data[2 * idx + 1] = max(self.data[2 * idx + 1], q)
def _update(self, idx):
"""updates the node idx to know of all queries applied to it via its ancestors"""
for i in reversed(list(range(1, idx.bit_length()))):
self._push(idx >> i)
def _build(self, idx):
"""make the changes to idx be known to its ancestors"""
idx >>= 1
while idx:
self.data[idx] = max(self.data[idx], self._func(self.data[2 * idx], self.data[2 * idx + 1]))
self._push(idx)
idx >>= 1
def add(self, start, stop, value):
"""lazily add value to [start, stop)"""
start = start_copy = start + self._size
stop = stop_copy = stop + self._size
while start < stop:
#print('a', start, stop)
if start & 1:
self._lazy[start] = max(self._lazy[start], value)
self.data[start] = max(self.data[start],value)
start += 1
if stop & 1:
stop -= 1
self._lazy[stop] = max(self._lazy[stop], value)
self.data[stop] = max(self.data[stop],value)
start >>= 1
stop >>= 1
# Tell all nodes above of the updated area of the updates
self._build(start_copy)
self._build(stop_copy - 1)
def query(self, start, stop, default=0):
"""func of data[start, stop)"""
start += self._size
stop += self._size
# Apply all the lazily stored queries
self._update(start)
self._update(stop - 1)
res = default
while start < stop:
if start & 1:
res = self._func(res, self.data[start])
start += 1
if stop & 1:
stop -= 1
res = self._func(res, self.data[stop])
start >>= 1
stop >>= 1
return res
def __repr__(self):
return "LazySegmentTree({0})".format(self.data)
import sys
input = sys.stdin.readline
n, k = list(map(int, input().split()))
seg = LazySegmentTree([0] * (1 << 20))
for _ in range(n):
v = int(eval(input()))
most = seg.query(v, v+1)
#print(most)
seg.add(max(0,v - k), v + k + 1, most + 1)
#print(seg.data)
print((seg.query(0, 1 << 20)))
|
class SegmentTree:
def __init__(self, data, default=0, func=max):
"""initialize the segment tree with data"""
self._default = default
self._func = func
self._len = len(data)
self._size = _size = 1 << (self._len - 1).bit_length()
self.data = [default] * (2 * _size)
self.data[_size:_size + self._len] = data
for i in reversed(list(range(_size))):
self.data[i] = func(self.data[i + i], self.data[i + i + 1])
def __delitem__(self, idx):
self[idx] = self._default
def __getitem__(self, idx):
return self.data[idx + self._size]
def __setitem__(self, idx, value):
idx += self._size
self.data[idx] = value
idx >>= 1
while idx:
self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
idx >>= 1
def __len__(self):
return self._len
def query(self, start, stop):
"""func of data[start, stop)"""
start += self._size
stop += self._size
res_left = res_right = self._default
while start < stop:
if start & 1:
res_left = self._func(res_left, self.data[start])
start += 1
if stop & 1:
stop -= 1
res_right = self._func(self.data[stop], res_right)
start >>= 1
stop >>= 1
return self._func(res_left, res_right)
def __repr__(self):
return "SegmentTree({0})".format(self.data)
import sys
input = sys.stdin.readline
n, k = list(map(int, input().split()))
seg = SegmentTree([0] * (1 << 20))
for _ in range(n):
v = int(eval(input()))
most = seg.query(max(0, v - k), v + k + 1)
seg[v] = most + 1
print((seg.query(0, 1 << 20)))
| 99 | 61 | 3,351 | 1,836 |
class LazySegmentTree:
def __init__(self, data, default=0, func=max):
"""initialize the lazy segment tree with data"""
self._default = default
self._func = func
self._len = len(data)
self._size = _size = 1 << (self._len - 1).bit_length()
self._lazy = [0] * (2 * _size)
self.data = [default] * (2 * _size)
self.data[_size : _size + self._len] = data
for i in reversed(list(range(_size))):
self.data[i] = func(self.data[i + i], self.data[i + i + 1])
def __len__(self):
return self._len
def _push(self, idx):
"""push query on idx to its children"""
# Let the children know of the queries
q, self._lazy[idx] = self._lazy[idx], 0
if q:
self._lazy[2 * idx] = max(self._lazy[2 * idx], q)
self._lazy[2 * idx + 1] = max(self._lazy[2 * idx + 1], q)
self.data[2 * idx] = max(self.data[2 * idx], q)
self.data[2 * idx + 1] = max(self.data[2 * idx + 1], q)
def _update(self, idx):
"""updates the node idx to know of all queries applied to it via its ancestors"""
for i in reversed(list(range(1, idx.bit_length()))):
self._push(idx >> i)
def _build(self, idx):
"""make the changes to idx be known to its ancestors"""
idx >>= 1
while idx:
self.data[idx] = max(
self.data[idx], self._func(self.data[2 * idx], self.data[2 * idx + 1])
)
self._push(idx)
idx >>= 1
def add(self, start, stop, value):
"""lazily add value to [start, stop)"""
start = start_copy = start + self._size
stop = stop_copy = stop + self._size
while start < stop:
# print('a', start, stop)
if start & 1:
self._lazy[start] = max(self._lazy[start], value)
self.data[start] = max(self.data[start], value)
start += 1
if stop & 1:
stop -= 1
self._lazy[stop] = max(self._lazy[stop], value)
self.data[stop] = max(self.data[stop], value)
start >>= 1
stop >>= 1
# Tell all nodes above of the updated area of the updates
self._build(start_copy)
self._build(stop_copy - 1)
def query(self, start, stop, default=0):
"""func of data[start, stop)"""
start += self._size
stop += self._size
# Apply all the lazily stored queries
self._update(start)
self._update(stop - 1)
res = default
while start < stop:
if start & 1:
res = self._func(res, self.data[start])
start += 1
if stop & 1:
stop -= 1
res = self._func(res, self.data[stop])
start >>= 1
stop >>= 1
return res
def __repr__(self):
return "LazySegmentTree({0})".format(self.data)
import sys
input = sys.stdin.readline
n, k = list(map(int, input().split()))
seg = LazySegmentTree([0] * (1 << 20))
for _ in range(n):
v = int(eval(input()))
most = seg.query(v, v + 1)
# print(most)
seg.add(max(0, v - k), v + k + 1, most + 1)
# print(seg.data)
print((seg.query(0, 1 << 20)))
|
class SegmentTree:
def __init__(self, data, default=0, func=max):
"""initialize the segment tree with data"""
self._default = default
self._func = func
self._len = len(data)
self._size = _size = 1 << (self._len - 1).bit_length()
self.data = [default] * (2 * _size)
self.data[_size : _size + self._len] = data
for i in reversed(list(range(_size))):
self.data[i] = func(self.data[i + i], self.data[i + i + 1])
def __delitem__(self, idx):
self[idx] = self._default
def __getitem__(self, idx):
return self.data[idx + self._size]
def __setitem__(self, idx, value):
idx += self._size
self.data[idx] = value
idx >>= 1
while idx:
self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
idx >>= 1
def __len__(self):
return self._len
def query(self, start, stop):
"""func of data[start, stop)"""
start += self._size
stop += self._size
res_left = res_right = self._default
while start < stop:
if start & 1:
res_left = self._func(res_left, self.data[start])
start += 1
if stop & 1:
stop -= 1
res_right = self._func(self.data[stop], res_right)
start >>= 1
stop >>= 1
return self._func(res_left, res_right)
def __repr__(self):
return "SegmentTree({0})".format(self.data)
import sys
input = sys.stdin.readline
n, k = list(map(int, input().split()))
seg = SegmentTree([0] * (1 << 20))
for _ in range(n):
v = int(eval(input()))
most = seg.query(max(0, v - k), v + k + 1)
seg[v] = most + 1
print((seg.query(0, 1 << 20)))
| false | 38.383838 |
[
"-class LazySegmentTree:",
"+class SegmentTree:",
"- \"\"\"initialize the lazy segment tree with data\"\"\"",
"+ \"\"\"initialize the segment tree with data\"\"\"",
"- self._lazy = [0] * (2 * _size)",
"+ def __delitem__(self, idx):",
"+ self[idx] = self._default",
"+",
"+ def __getitem__(self, idx):",
"+ return self.data[idx + self._size]",
"+",
"+ def __setitem__(self, idx, value):",
"+ idx += self._size",
"+ self.data[idx] = value",
"+ idx >>= 1",
"+ while idx:",
"+ self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])",
"+ idx >>= 1",
"+",
"- def _push(self, idx):",
"- \"\"\"push query on idx to its children\"\"\"",
"- # Let the children know of the queries",
"- q, self._lazy[idx] = self._lazy[idx], 0",
"- if q:",
"- self._lazy[2 * idx] = max(self._lazy[2 * idx], q)",
"- self._lazy[2 * idx + 1] = max(self._lazy[2 * idx + 1], q)",
"- self.data[2 * idx] = max(self.data[2 * idx], q)",
"- self.data[2 * idx + 1] = max(self.data[2 * idx + 1], q)",
"-",
"- def _update(self, idx):",
"- \"\"\"updates the node idx to know of all queries applied to it via its ancestors\"\"\"",
"- for i in reversed(list(range(1, idx.bit_length()))):",
"- self._push(idx >> i)",
"-",
"- def _build(self, idx):",
"- \"\"\"make the changes to idx be known to its ancestors\"\"\"",
"- idx >>= 1",
"- while idx:",
"- self.data[idx] = max(",
"- self.data[idx], self._func(self.data[2 * idx], self.data[2 * idx + 1])",
"- )",
"- self._push(idx)",
"- idx >>= 1",
"-",
"- def add(self, start, stop, value):",
"- \"\"\"lazily add value to [start, stop)\"\"\"",
"- start = start_copy = start + self._size",
"- stop = stop_copy = stop + self._size",
"+ def query(self, start, stop):",
"+ \"\"\"func of data[start, stop)\"\"\"",
"+ start += self._size",
"+ stop += self._size",
"+ res_left = res_right = self._default",
"- # print('a', start, stop)",
"- self._lazy[start] = max(self._lazy[start], value)",
"- self.data[start] = max(self.data[start], value)",
"+ res_left = self._func(res_left, self.data[start])",
"- self._lazy[stop] = max(self._lazy[stop], value)",
"- self.data[stop] = max(self.data[stop], value)",
"+ res_right = self._func(self.data[stop], res_right)",
"- # Tell all nodes above of the updated area of the updates",
"- self._build(start_copy)",
"- self._build(stop_copy - 1)",
"-",
"- def query(self, start, stop, default=0):",
"- \"\"\"func of data[start, stop)\"\"\"",
"- start += self._size",
"- stop += self._size",
"- # Apply all the lazily stored queries",
"- self._update(start)",
"- self._update(stop - 1)",
"- res = default",
"- while start < stop:",
"- if start & 1:",
"- res = self._func(res, self.data[start])",
"- start += 1",
"- if stop & 1:",
"- stop -= 1",
"- res = self._func(res, self.data[stop])",
"- start >>= 1",
"- stop >>= 1",
"- return res",
"+ return self._func(res_left, res_right)",
"- return \"LazySegmentTree({0})\".format(self.data)",
"+ return \"SegmentTree({0})\".format(self.data)",
"-seg = LazySegmentTree([0] * (1 << 20))",
"+seg = SegmentTree([0] * (1 << 20))",
"- most = seg.query(v, v + 1)",
"- # print(most)",
"- seg.add(max(0, v - k), v + k + 1, most + 1)",
"- # print(seg.data)",
"+ most = seg.query(max(0, v - k), v + k + 1)",
"+ seg[v] = most + 1"
] | false | 2.077542 | 1.049005 | 1.980487 |
[
"s306600743",
"s422905535"
] |
u997648604
|
p02720
|
python
|
s320392777
|
s678204350
| 175 | 151 | 46,064 | 77,288 |
Accepted
|
Accepted
| 13.71 |
import sys
sys.setrecursionlimit(10**9)
def main():
K = int(eval(input()))
if 0<=K<=10:
print(K)
exit()
lunlun = [i for i in range(1,10)]
m = 0
while len(lunlun) < K:
x = lunlun[m]
btm = x % 10
if btm - 1 >= 0:
lunlun.append(10*x+btm-1)
lunlun.append(10*x+btm)
if btm + 1 < 10:
lunlun.append(10*x+btm+1)
m += 1
print((lunlun[::-1][len(lunlun)-K]))
if __name__ == "__main__":
main()
|
import sys
sys.setrecursionlimit(10**9)
def mi(): return list(map(int,input().split()))
def ii(): return int(eval(input()))
def isp(): return input().split()
def deb(text): print(("-------\n{}\n-------".format(text)))
INF=10**20
def main():
K=ii()
L=list(range(10))
if K <= 9:
print(K)
exit()
# print(L)
head_i = 1
while len(L) < K+10:
assert head_i < len(L)
head = L[head_i]
head_tail = head % 10
for x in [head_tail-1,head_tail,head_tail+1]:
if x < 0 or x >= 10: continue
# print(head_i,head,head_tail)
# assert not head * 10 + x in L
L.append(head * 10 + x)
head_i += 1
# print(L)
print((L[K]))
if __name__ == "__main__":
main()
| 30 | 40 | 526 | 833 |
import sys
sys.setrecursionlimit(10**9)
def main():
K = int(eval(input()))
if 0 <= K <= 10:
print(K)
exit()
lunlun = [i for i in range(1, 10)]
m = 0
while len(lunlun) < K:
x = lunlun[m]
btm = x % 10
if btm - 1 >= 0:
lunlun.append(10 * x + btm - 1)
lunlun.append(10 * x + btm)
if btm + 1 < 10:
lunlun.append(10 * x + btm + 1)
m += 1
print((lunlun[::-1][len(lunlun) - K]))
if __name__ == "__main__":
main()
|
import sys
sys.setrecursionlimit(10**9)
def mi():
return list(map(int, input().split()))
def ii():
return int(eval(input()))
def isp():
return input().split()
def deb(text):
print(("-------\n{}\n-------".format(text)))
INF = 10**20
def main():
K = ii()
L = list(range(10))
if K <= 9:
print(K)
exit()
# print(L)
head_i = 1
while len(L) < K + 10:
assert head_i < len(L)
head = L[head_i]
head_tail = head % 10
for x in [head_tail - 1, head_tail, head_tail + 1]:
if x < 0 or x >= 10:
continue
# print(head_i,head,head_tail)
# assert not head * 10 + x in L
L.append(head * 10 + x)
head_i += 1
# print(L)
print((L[K]))
if __name__ == "__main__":
main()
| false | 25 |
[
"+def mi():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def ii():",
"+ return int(eval(input()))",
"+",
"+",
"+def isp():",
"+ return input().split()",
"+",
"+",
"+def deb(text):",
"+",
"+",
"+INF = 10**20",
"+",
"+",
"- K = int(eval(input()))",
"- if 0 <= K <= 10:",
"+ K = ii()",
"+ L = list(range(10))",
"+ if K <= 9:",
"- lunlun = [i for i in range(1, 10)]",
"- m = 0",
"- while len(lunlun) < K:",
"- x = lunlun[m]",
"- btm = x % 10",
"- if btm - 1 >= 0:",
"- lunlun.append(10 * x + btm - 1)",
"- lunlun.append(10 * x + btm)",
"- if btm + 1 < 10:",
"- lunlun.append(10 * x + btm + 1)",
"- m += 1",
"- print((lunlun[::-1][len(lunlun) - K]))",
"+ # print(L)",
"+ head_i = 1",
"+ while len(L) < K + 10:",
"+ assert head_i < len(L)",
"+ head = L[head_i]",
"+ head_tail = head % 10",
"+ for x in [head_tail - 1, head_tail, head_tail + 1]:",
"+ if x < 0 or x >= 10:",
"+ continue",
"+ # print(head_i,head,head_tail)",
"+ # assert not head * 10 + x in L",
"+ L.append(head * 10 + x)",
"+ head_i += 1",
"+ # print(L)",
"+ print((L[K]))"
] | false | 0.045945 | 0.091999 | 0.499406 |
[
"s320392777",
"s678204350"
] |
u691018832
|
p03607
|
python
|
s889534537
|
s891755913
| 136 | 82 | 21,356 | 16,612 |
Accepted
|
Accepted
| 39.71 |
import collections
import sys
input = sys.stdin.readline
n = int(eval(input()))
a = [0]*n
ans = 0
for i in range(n):
a[i] = int(eval(input()))
count_a = collections.Counter(a).most_common()
for i in range(len(count_a)):
if count_a[i][1]%2 != 0:
ans += 1
print(ans)
|
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
from collections import Counter
n = int(readline())
a = [int(readline()) for _ in range(n)]
ans = 0
for v in list(Counter(a).values()):
ans += 1 if v % 2 == 1 else 0
print(ans)
| 14 | 14 | 282 | 337 |
import collections
import sys
input = sys.stdin.readline
n = int(eval(input()))
a = [0] * n
ans = 0
for i in range(n):
a[i] = int(eval(input()))
count_a = collections.Counter(a).most_common()
for i in range(len(count_a)):
if count_a[i][1] % 2 != 0:
ans += 1
print(ans)
|
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
from collections import Counter
n = int(readline())
a = [int(readline()) for _ in range(n)]
ans = 0
for v in list(Counter(a).values()):
ans += 1 if v % 2 == 1 else 0
print(ans)
| false | 0 |
[
"-import collections",
"-input = sys.stdin.readline",
"-n = int(eval(input()))",
"-a = [0] * n",
"+read = sys.stdin.buffer.read",
"+readline = sys.stdin.buffer.readline",
"+readlines = sys.stdin.buffer.readlines",
"+sys.setrecursionlimit(10**7)",
"+from collections import Counter",
"+",
"+n = int(readline())",
"+a = [int(readline()) for _ in range(n)]",
"-for i in range(n):",
"- a[i] = int(eval(input()))",
"-count_a = collections.Counter(a).most_common()",
"-for i in range(len(count_a)):",
"- if count_a[i][1] % 2 != 0:",
"- ans += 1",
"+for v in list(Counter(a).values()):",
"+ ans += 1 if v % 2 == 1 else 0"
] | false | 0.036287 | 0.043153 | 0.840905 |
[
"s889534537",
"s891755913"
] |
u086503932
|
p03013
|
python
|
s436104592
|
s818353211
| 211 | 178 | 13,216 | 94,516 |
Accepted
|
Accepted
| 15.64 |
N, M = list(map(int, input().split()))
a = set([int(eval(input())) for _ in range(M)])
p = 10**9+7
# F[N+1]: 0 ~ N 段目にたどり着く移動方法の場合の数
F = [None] * (N+1)
F[0] = 1
F[1] = 1
for i in range(2, N+1):
if i-1 in a:
tmp1 = 0
else:
tmp1 = F[i-1]
if i-2 in a:
tmp2 = 0
else:
tmp2 = F[i-2]
F[i] = (tmp1 + tmp2) % p
# 基本的なDPの問題
# dp[v] = dp[v-1] + dp[v-2]だが、
# v-1, v-2は壊れていたら加算しない
print((F[N]))
|
N, M = list(map(int, input().split()))
a = [int(eval(input())) for _ in range(M)]
a = set(a)
m = 10**9+7
dp = [0] * (N+1)
dp[0] = 1
for i in range(N):
if i+1 not in a:
dp[i+1] = (dp[i+1] + dp[i]) % m
if i < N-1 and i+2 not in a:
dp[i+2] = (dp[i+2] + dp[i]) % m
print((dp[N]))
| 25 | 12 | 430 | 296 |
N, M = list(map(int, input().split()))
a = set([int(eval(input())) for _ in range(M)])
p = 10**9 + 7
# F[N+1]: 0 ~ N 段目にたどり着く移動方法の場合の数
F = [None] * (N + 1)
F[0] = 1
F[1] = 1
for i in range(2, N + 1):
if i - 1 in a:
tmp1 = 0
else:
tmp1 = F[i - 1]
if i - 2 in a:
tmp2 = 0
else:
tmp2 = F[i - 2]
F[i] = (tmp1 + tmp2) % p
# 基本的なDPの問題
# dp[v] = dp[v-1] + dp[v-2]だが、
# v-1, v-2は壊れていたら加算しない
print((F[N]))
|
N, M = list(map(int, input().split()))
a = [int(eval(input())) for _ in range(M)]
a = set(a)
m = 10**9 + 7
dp = [0] * (N + 1)
dp[0] = 1
for i in range(N):
if i + 1 not in a:
dp[i + 1] = (dp[i + 1] + dp[i]) % m
if i < N - 1 and i + 2 not in a:
dp[i + 2] = (dp[i + 2] + dp[i]) % m
print((dp[N]))
| false | 52 |
[
"-a = set([int(eval(input())) for _ in range(M)])",
"-p = 10**9 + 7",
"-# F[N+1]: 0 ~ N 段目にたどり着く移動方法の場合の数",
"-F = [None] * (N + 1)",
"-F[0] = 1",
"-F[1] = 1",
"-for i in range(2, N + 1):",
"- if i - 1 in a:",
"- tmp1 = 0",
"- else:",
"- tmp1 = F[i - 1]",
"- if i - 2 in a:",
"- tmp2 = 0",
"- else:",
"- tmp2 = F[i - 2]",
"- F[i] = (tmp1 + tmp2) % p",
"-# 基本的なDPの問題",
"-# dp[v] = dp[v-1] + dp[v-2]だが、",
"-# v-1, v-2は壊れていたら加算しない",
"-print((F[N]))",
"+a = [int(eval(input())) for _ in range(M)]",
"+a = set(a)",
"+m = 10**9 + 7",
"+dp = [0] * (N + 1)",
"+dp[0] = 1",
"+for i in range(N):",
"+ if i + 1 not in a:",
"+ dp[i + 1] = (dp[i + 1] + dp[i]) % m",
"+ if i < N - 1 and i + 2 not in a:",
"+ dp[i + 2] = (dp[i + 2] + dp[i]) % m",
"+print((dp[N]))"
] | false | 0.036356 | 0.035041 | 1.037535 |
[
"s436104592",
"s818353211"
] |
u619458041
|
p02983
|
python
|
s327802265
|
s890129861
| 625 | 50 | 3,060 | 3,060 |
Accepted
|
Accepted
| 92 |
import sys
def main():
input = sys.stdin.readline
L, R = list(map(int, input().split()))
R = min(R, L + 2019)
ans = 2019
for i in range(L, R):
for j in range(i+1, R+1):
ans = min(ans, (i*j)%2019)
return ans
if __name__ == '__main__':
print((main()))
|
import sys
def main():
input = sys.stdin.readline
L, R = list(map(int, input().split()))
R = min(R, L + 2019)
ans = 2019
for i in range(L, R):
for j in range(i+1, R+1):
ans = min(ans, (i*j)%2019)
if ans == 0:
return 0
return ans
if __name__ == '__main__':
print((main()))
| 17 | 19 | 311 | 363 |
import sys
def main():
input = sys.stdin.readline
L, R = list(map(int, input().split()))
R = min(R, L + 2019)
ans = 2019
for i in range(L, R):
for j in range(i + 1, R + 1):
ans = min(ans, (i * j) % 2019)
return ans
if __name__ == "__main__":
print((main()))
|
import sys
def main():
input = sys.stdin.readline
L, R = list(map(int, input().split()))
R = min(R, L + 2019)
ans = 2019
for i in range(L, R):
for j in range(i + 1, R + 1):
ans = min(ans, (i * j) % 2019)
if ans == 0:
return 0
return ans
if __name__ == "__main__":
print((main()))
| false | 10.526316 |
[
"+ if ans == 0:",
"+ return 0"
] | false | 0.12976 | 0.053189 | 2.439618 |
[
"s327802265",
"s890129861"
] |
u461993794
|
p02689
|
python
|
s893405714
|
s404123167
| 421 | 303 | 93,936 | 95,224 |
Accepted
|
Accepted
| 28.03 |
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
eg = [[] for _ in range(n + 1)]
for _ in range(m):
a, b = list(map(int, input().split()))
eg[a].append(b)
eg[b].append(a)
ans = 0
for i in range(1, n + 1):
high = True
for to in eg[i]:
if h[i - 1] <= h[to - 1]:
high = False
if high:
ans += 1
print(ans)
|
n, m = list(map(int, input().split()))
h = [0] + list(map(int, input().split()))
eg = [[] for _ in range(n + 1)]
for _ in range(m):
a, b = list(map(int, input().split()))
eg[a].append(b)
eg[b].append(a)
ans = 0
for i in range(1, n + 1):
high = True
for t in eg[i]:
if h[t] >= h[i]:
high = False
break
if high:
ans += 1
print(ans)
| 18 | 18 | 387 | 400 |
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
eg = [[] for _ in range(n + 1)]
for _ in range(m):
a, b = list(map(int, input().split()))
eg[a].append(b)
eg[b].append(a)
ans = 0
for i in range(1, n + 1):
high = True
for to in eg[i]:
if h[i - 1] <= h[to - 1]:
high = False
if high:
ans += 1
print(ans)
|
n, m = list(map(int, input().split()))
h = [0] + list(map(int, input().split()))
eg = [[] for _ in range(n + 1)]
for _ in range(m):
a, b = list(map(int, input().split()))
eg[a].append(b)
eg[b].append(a)
ans = 0
for i in range(1, n + 1):
high = True
for t in eg[i]:
if h[t] >= h[i]:
high = False
break
if high:
ans += 1
print(ans)
| false | 0 |
[
"-h = list(map(int, input().split()))",
"+h = [0] + list(map(int, input().split()))",
"- for to in eg[i]:",
"- if h[i - 1] <= h[to - 1]:",
"+ for t in eg[i]:",
"+ if h[t] >= h[i]:",
"+ break"
] | false | 0.098731 | 0.077462 | 1.274576 |
[
"s893405714",
"s404123167"
] |
u580362735
|
p03160
|
python
|
s218489972
|
s732737299
| 223 | 138 | 94,100 | 13,928 |
Accepted
|
Accepted
| 38.12 |
import sys
sys.setrecursionlimit(10**6)
N = int(eval(input()))
h = list(map(int,input().split()))
memo = [-1]*N
def calc_cost(i):
if memo[i] != -1:
return memo[i]
if i == 0:
return 0
elif i == 1:
return abs(h[0]-h[1])
a = calc_cost(i-1)+abs(h[i]-h[i-1])
b = calc_cost(i-2)+abs(h[i]-h[i-2])
memo[i] = min(a,b)
return(memo[i])
print((calc_cost(N-1)))
|
N = int(eval(input()))
h = list(map(int,input().split()))
memo = [0]*N
memo[0] = 0
memo[1] = abs(h[0]-h[1])
for i in range(2,N):
a = memo[i-1] + abs(h[i]-h[i-1])
b = memo[i-2] + abs(h[i]-h[i-2])
memo[i] = min(a,b)
print((memo[N-1]))
| 24 | 12 | 402 | 243 |
import sys
sys.setrecursionlimit(10**6)
N = int(eval(input()))
h = list(map(int, input().split()))
memo = [-1] * N
def calc_cost(i):
if memo[i] != -1:
return memo[i]
if i == 0:
return 0
elif i == 1:
return abs(h[0] - h[1])
a = calc_cost(i - 1) + abs(h[i] - h[i - 1])
b = calc_cost(i - 2) + abs(h[i] - h[i - 2])
memo[i] = min(a, b)
return memo[i]
print((calc_cost(N - 1)))
|
N = int(eval(input()))
h = list(map(int, input().split()))
memo = [0] * N
memo[0] = 0
memo[1] = abs(h[0] - h[1])
for i in range(2, N):
a = memo[i - 1] + abs(h[i] - h[i - 1])
b = memo[i - 2] + abs(h[i] - h[i - 2])
memo[i] = min(a, b)
print((memo[N - 1]))
| false | 50 |
[
"-import sys",
"-",
"-sys.setrecursionlimit(10**6)",
"-memo = [-1] * N",
"-",
"-",
"-def calc_cost(i):",
"- if memo[i] != -1:",
"- return memo[i]",
"- if i == 0:",
"- return 0",
"- elif i == 1:",
"- return abs(h[0] - h[1])",
"- a = calc_cost(i - 1) + abs(h[i] - h[i - 1])",
"- b = calc_cost(i - 2) + abs(h[i] - h[i - 2])",
"+memo = [0] * N",
"+memo[0] = 0",
"+memo[1] = abs(h[0] - h[1])",
"+for i in range(2, N):",
"+ a = memo[i - 1] + abs(h[i] - h[i - 1])",
"+ b = memo[i - 2] + abs(h[i] - h[i - 2])",
"- return memo[i]",
"-",
"-",
"-print((calc_cost(N - 1)))",
"+print((memo[N - 1]))"
] | false | 0.035579 | 0.054032 | 0.658472 |
[
"s218489972",
"s732737299"
] |
u450983668
|
p03160
|
python
|
s471754693
|
s913500056
| 136 | 120 | 13,928 | 13,716 |
Accepted
|
Accepted
| 11.76 |
# 検証のためのACの人のパクリですごめんなさい
N = int(eval(input()))
hs = [i for i in map(int, input().split())]
INF = 10*12
dp = [INF]*N
dp[0] = 0
dp[1] = abs(hs[0]-hs[1])
for i in range(2, N):
dp[i] = min(dp[i-1] +abs(hs[i]-hs[i-1]), dp[i-2] +abs(hs[i]-hs[i-2]))
print((dp[-1]))
|
def chmin(a, b):
if a > b:
return b
return a
def main():
N = int(eval(input()))
hs = [i for i in map(int, input().split())]
INF = 1e12
dp = [INF]*N
dp[0] = 0
for i in range(1, N):
dp[i] = chmin(dp[i], dp[i-1] + abs(hs[i]-hs[i-1]))
if i > 1:
dp[i] = chmin(dp[i], dp[i-2] + abs(hs[i]-hs[i-2]))
print((dp[N-1]))
return
if __name__ == '__main__':
main()
| 12 | 21 | 266 | 406 |
# 検証のためのACの人のパクリですごめんなさい
N = int(eval(input()))
hs = [i for i in map(int, input().split())]
INF = 10 * 12
dp = [INF] * N
dp[0] = 0
dp[1] = abs(hs[0] - hs[1])
for i in range(2, N):
dp[i] = min(dp[i - 1] + abs(hs[i] - hs[i - 1]), dp[i - 2] + abs(hs[i] - hs[i - 2]))
print((dp[-1]))
|
def chmin(a, b):
if a > b:
return b
return a
def main():
N = int(eval(input()))
hs = [i for i in map(int, input().split())]
INF = 1e12
dp = [INF] * N
dp[0] = 0
for i in range(1, N):
dp[i] = chmin(dp[i], dp[i - 1] + abs(hs[i] - hs[i - 1]))
if i > 1:
dp[i] = chmin(dp[i], dp[i - 2] + abs(hs[i] - hs[i - 2]))
print((dp[N - 1]))
return
if __name__ == "__main__":
main()
| false | 42.857143 |
[
"-# 検証のためのACの人のパクリですごめんなさい",
"-N = int(eval(input()))",
"-hs = [i for i in map(int, input().split())]",
"-INF = 10 * 12",
"-dp = [INF] * N",
"-dp[0] = 0",
"-dp[1] = abs(hs[0] - hs[1])",
"-for i in range(2, N):",
"- dp[i] = min(dp[i - 1] + abs(hs[i] - hs[i - 1]), dp[i - 2] + abs(hs[i] - hs[i - 2]))",
"-print((dp[-1]))",
"+def chmin(a, b):",
"+ if a > b:",
"+ return b",
"+ return a",
"+",
"+",
"+def main():",
"+ N = int(eval(input()))",
"+ hs = [i for i in map(int, input().split())]",
"+ INF = 1e12",
"+ dp = [INF] * N",
"+ dp[0] = 0",
"+ for i in range(1, N):",
"+ dp[i] = chmin(dp[i], dp[i - 1] + abs(hs[i] - hs[i - 1]))",
"+ if i > 1:",
"+ dp[i] = chmin(dp[i], dp[i - 2] + abs(hs[i] - hs[i - 2]))",
"+ print((dp[N - 1]))",
"+ return",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.115103 | 0.037186 | 3.095357 |
[
"s471754693",
"s913500056"
] |
u514894322
|
p02947
|
python
|
s482528412
|
s510731695
| 334 | 189 | 19,400 | 21,128 |
Accepted
|
Accepted
| 43.41 |
n = int(eval(input()))
sl = [''.join(sorted(eval(input()))) for _ in [0]*n]
count = 0
dict = {}
for s in sl:
if s in dict:
count += dict[s]
dict[s] += 1
else:
dict[s] = 1
print(count)
|
n,*sl, = [''.join(sorted(x)) for x in open(0).read().split()]
count = 0
dict = {}
for s in sl:
if s in dict:
count += dict[s]
dict[s] += 1
else:
dict[s] = 1
print(count)
| 11 | 10 | 198 | 198 |
n = int(eval(input()))
sl = ["".join(sorted(eval(input()))) for _ in [0] * n]
count = 0
dict = {}
for s in sl:
if s in dict:
count += dict[s]
dict[s] += 1
else:
dict[s] = 1
print(count)
|
(
n,
*sl,
) = ["".join(sorted(x)) for x in open(0).read().split()]
count = 0
dict = {}
for s in sl:
if s in dict:
count += dict[s]
dict[s] += 1
else:
dict[s] = 1
print(count)
| false | 9.090909 |
[
"-n = int(eval(input()))",
"-sl = [\"\".join(sorted(eval(input()))) for _ in [0] * n]",
"+(",
"+ n,",
"+ *sl,",
"+) = [\"\".join(sorted(x)) for x in open(0).read().split()]"
] | false | 0.036183 | 0.031953 | 1.132398 |
[
"s482528412",
"s510731695"
] |
u440566786
|
p02913
|
python
|
s519133303
|
s349674305
| 1,674 | 1,038 | 53,572 | 51,164 |
Accepted
|
Accepted
| 37.99 |
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
class SuffixArray:
"""
construct:
suffix array: O(N(logN)^2)
lcp array: O(N)
sparse table: O(NlogN)
query:
get_lcp: O(1)
"""
def __init__(self, s):
"""
s: str
"""
self.__s=s
self.__n=len(s)
self.__suffix_array()
self.__lcp_array()
self.__sparse_table()
# suffix array
def __suffix_array(self):
s=self.__s; n=self.__n
# initialize
sa=list(range(n))
rank=[ord(s[i]) for i in range(n)]
tmp=[0]*n
k=1
cmp_key=lambda i:(rank[i],rank[i+k] if i+k<n else -1)
# iterate
while(k<=n):
sa.sort(key=cmp_key)
tmp[sa[0]]=0
for i in range(1,n):
tmp[sa[i]]=tmp[sa[i-1]]+(cmp_key(sa[i-1])<cmp_key(sa[i]))
rank=tmp[:]
k<<=1
self.__sa=sa
self.__rank=rank
# LCP array
def __lcp_array(self):
n=self.__n; s=self.__s;
sa=self.__sa; rank=self.__rank
lcp=[0]*n
h=0
for i in range(n):
j=sa[rank[i]-1]
if h > 0: h -= 1
while j+h<n and i+h<n and s[j+h]==s[i+h]: h+=1
lcp[rank[i]]=h
self.__lcp=lcp
# sparse table (LCPのminをとるindexを持つ)
def __sparse_table(self):
n=self.__n
logn=max(0,(n-1).bit_length())
table=[[0]*n for _ in range(logn)]
table[0]=list(range(n))
# construct
for i in range(1,logn):
for k in range(n):
if k+(1<<(i-1))>=n:
table[i][k]=table[i-1][k]
continue
if self.__lcp[table[i-1][k]]<=self.__lcp[table[i-1][k+(1<<(i-1))]]:
table[i][k]=table[i-1][k]
else:
table[i][k]=table[i-1][k+(1<<(i-1))]
self.__table=table
def get_lcp(self,a,b):
"""
a,b: int 0<=a,b<n
return LCP length between s[a:] and s[b:]
"""
if a==b: return self.__n-a
l,r=self.__rank[a],self.__rank[b]
l,r=min(l,r)+1,max(l,r)+1
if r-l==1: return self.__lcp[l]
i=(r-l-1).bit_length()-1
if self.__lcp[self.__table[i][l]]<=self.__lcp[self.__table[i][r-(1<<i)]]:
return self.__lcp[self.__table[i][l]]
else:
return self.__lcp[self.__table[i][r-(1<<i)]]
def resolve():
n=int(eval(input()))
s=eval(input())
sa=SuffixArray(s)
ans=0
for i in range(n):
for j in range(n):
ans=max(ans,min(sa.get_lcp(i,j),j-i))
print(ans)
resolve()
|
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
class SuffixArray:
"""
construct:
suffix array: O(N(logN)^2)
lcp array: O(N)
sparse table: O(NlogN)
query:
get_lcp: O(1)
"""
def __init__(self, s):
"""
s: str
"""
self.__s=s
self.__n=len(s)
self.__suffix_array()
self.__lcp_array()
self.__sparse_table()
# suffix array
def __suffix_array(self):
s=self.__s; n=self.__n
# initialize
sa=list(range(n))
rank=[ord(s[i]) for i in range(n)]
tmp=[0]*n
k=1
cmp_key=lambda i:(rank[i],rank[i+k] if i+k<n else -1)
# iterate
while(k<=n):
sa.sort(key=cmp_key)
tmp[sa[0]]=0
for i in range(1,n):
tmp[sa[i]]=tmp[sa[i-1]]+(cmp_key(sa[i-1])<cmp_key(sa[i]))
rank=tmp[:]
k<<=1
self.__sa=sa
self.__rank=rank
# LCP array
def __lcp_array(self):
n=self.__n; s=self.__s;
sa=self.__sa; rank=self.__rank
lcp=[0]*n
h=0
for i in range(n):
j=sa[rank[i]-1]
if h > 0: h -= 1
while j+h<n and i+h<n and s[j+h]==s[i+h]: h+=1
lcp[rank[i]]=h
self.__lcp=lcp
# sparse table (LCPのminをとるindexを持つ)
def __sparse_table(self):
n=self.__n
logn=max(0,(n-1).bit_length())
table=[[0]*n for _ in range(logn)]
table[0]=list(range(n))
# construct
for i in range(1,logn):
for k in range(n):
if k+(1<<(i-1))>=n:
table[i][k]=table[i-1][k]
continue
if self.__lcp[table[i-1][k]]<=self.__lcp[table[i-1][k+(1<<(i-1))]]:
table[i][k]=table[i-1][k]
else:
table[i][k]=table[i-1][k+(1<<(i-1))]
self.__table=table
def get_lcp(self,a,b):
"""
a,b: int 0<=a,b<n
return LCP length between s[a:] and s[b:]
"""
if a==b: return self.__n-a
l,r=self.__rank[a],self.__rank[b]
l,r=min(l,r)+1,max(l,r)+1
if r-l==1: return self.__lcp[l]
i=(r-l-1).bit_length()-1
if self.__lcp[self.__table[i][l]]<=self.__lcp[self.__table[i][r-(1<<i)]]:
return self.__lcp[self.__table[i][l]]
else:
return self.__lcp[self.__table[i][r-(1<<i)]]
def resolve():
n=int(eval(input()))
s=eval(input())
sa=SuffixArray(s)
ans=0
for i in range(n):
for j in range(i+1,n):
ans=max(ans,min(sa.get_lcp(i,j),j-i))
print(ans)
resolve()
| 99 | 99 | 2,831 | 2,835 |
import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().rstrip()
class SuffixArray:
"""
construct:
suffix array: O(N(logN)^2)
lcp array: O(N)
sparse table: O(NlogN)
query:
get_lcp: O(1)
"""
def __init__(self, s):
"""
s: str
"""
self.__s = s
self.__n = len(s)
self.__suffix_array()
self.__lcp_array()
self.__sparse_table()
# suffix array
def __suffix_array(self):
s = self.__s
n = self.__n
# initialize
sa = list(range(n))
rank = [ord(s[i]) for i in range(n)]
tmp = [0] * n
k = 1
cmp_key = lambda i: (rank[i], rank[i + k] if i + k < n else -1)
# iterate
while k <= n:
sa.sort(key=cmp_key)
tmp[sa[0]] = 0
for i in range(1, n):
tmp[sa[i]] = tmp[sa[i - 1]] + (cmp_key(sa[i - 1]) < cmp_key(sa[i]))
rank = tmp[:]
k <<= 1
self.__sa = sa
self.__rank = rank
# LCP array
def __lcp_array(self):
n = self.__n
s = self.__s
sa = self.__sa
rank = self.__rank
lcp = [0] * n
h = 0
for i in range(n):
j = sa[rank[i] - 1]
if h > 0:
h -= 1
while j + h < n and i + h < n and s[j + h] == s[i + h]:
h += 1
lcp[rank[i]] = h
self.__lcp = lcp
# sparse table (LCPのminをとるindexを持つ)
def __sparse_table(self):
n = self.__n
logn = max(0, (n - 1).bit_length())
table = [[0] * n for _ in range(logn)]
table[0] = list(range(n))
# construct
for i in range(1, logn):
for k in range(n):
if k + (1 << (i - 1)) >= n:
table[i][k] = table[i - 1][k]
continue
if (
self.__lcp[table[i - 1][k]]
<= self.__lcp[table[i - 1][k + (1 << (i - 1))]]
):
table[i][k] = table[i - 1][k]
else:
table[i][k] = table[i - 1][k + (1 << (i - 1))]
self.__table = table
def get_lcp(self, a, b):
"""
a,b: int 0<=a,b<n
return LCP length between s[a:] and s[b:]
"""
if a == b:
return self.__n - a
l, r = self.__rank[a], self.__rank[b]
l, r = min(l, r) + 1, max(l, r) + 1
if r - l == 1:
return self.__lcp[l]
i = (r - l - 1).bit_length() - 1
if self.__lcp[self.__table[i][l]] <= self.__lcp[self.__table[i][r - (1 << i)]]:
return self.__lcp[self.__table[i][l]]
else:
return self.__lcp[self.__table[i][r - (1 << i)]]
def resolve():
n = int(eval(input()))
s = eval(input())
sa = SuffixArray(s)
ans = 0
for i in range(n):
for j in range(n):
ans = max(ans, min(sa.get_lcp(i, j), j - i))
print(ans)
resolve()
|
import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().rstrip()
class SuffixArray:
"""
construct:
suffix array: O(N(logN)^2)
lcp array: O(N)
sparse table: O(NlogN)
query:
get_lcp: O(1)
"""
def __init__(self, s):
"""
s: str
"""
self.__s = s
self.__n = len(s)
self.__suffix_array()
self.__lcp_array()
self.__sparse_table()
# suffix array
def __suffix_array(self):
s = self.__s
n = self.__n
# initialize
sa = list(range(n))
rank = [ord(s[i]) for i in range(n)]
tmp = [0] * n
k = 1
cmp_key = lambda i: (rank[i], rank[i + k] if i + k < n else -1)
# iterate
while k <= n:
sa.sort(key=cmp_key)
tmp[sa[0]] = 0
for i in range(1, n):
tmp[sa[i]] = tmp[sa[i - 1]] + (cmp_key(sa[i - 1]) < cmp_key(sa[i]))
rank = tmp[:]
k <<= 1
self.__sa = sa
self.__rank = rank
# LCP array
def __lcp_array(self):
n = self.__n
s = self.__s
sa = self.__sa
rank = self.__rank
lcp = [0] * n
h = 0
for i in range(n):
j = sa[rank[i] - 1]
if h > 0:
h -= 1
while j + h < n and i + h < n and s[j + h] == s[i + h]:
h += 1
lcp[rank[i]] = h
self.__lcp = lcp
# sparse table (LCPのminをとるindexを持つ)
def __sparse_table(self):
n = self.__n
logn = max(0, (n - 1).bit_length())
table = [[0] * n for _ in range(logn)]
table[0] = list(range(n))
# construct
for i in range(1, logn):
for k in range(n):
if k + (1 << (i - 1)) >= n:
table[i][k] = table[i - 1][k]
continue
if (
self.__lcp[table[i - 1][k]]
<= self.__lcp[table[i - 1][k + (1 << (i - 1))]]
):
table[i][k] = table[i - 1][k]
else:
table[i][k] = table[i - 1][k + (1 << (i - 1))]
self.__table = table
def get_lcp(self, a, b):
"""
a,b: int 0<=a,b<n
return LCP length between s[a:] and s[b:]
"""
if a == b:
return self.__n - a
l, r = self.__rank[a], self.__rank[b]
l, r = min(l, r) + 1, max(l, r) + 1
if r - l == 1:
return self.__lcp[l]
i = (r - l - 1).bit_length() - 1
if self.__lcp[self.__table[i][l]] <= self.__lcp[self.__table[i][r - (1 << i)]]:
return self.__lcp[self.__table[i][l]]
else:
return self.__lcp[self.__table[i][r - (1 << i)]]
def resolve():
n = int(eval(input()))
s = eval(input())
sa = SuffixArray(s)
ans = 0
for i in range(n):
for j in range(i + 1, n):
ans = max(ans, min(sa.get_lcp(i, j), j - i))
print(ans)
resolve()
| false | 0 |
[
"- for j in range(n):",
"+ for j in range(i + 1, n):"
] | false | 0.036106 | 0.049884 | 0.723793 |
[
"s519133303",
"s349674305"
] |
u827202523
|
p02838
|
python
|
s138635366
|
s291742763
| 1,172 | 287 | 123,592 | 110,608 |
Accepted
|
Accepted
| 75.51 |
def getN():
return int(eval(input()))
def getNM():
return list(map(int, input().split()))
def getList():
return list(map(int, input().split()))
from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
from heapq import *
import sys
# sys.setrecursionlimit(1000000)
INF = 10 ** 17
MOD = 1000000007
from fractions import *
def inverse(f):
# return Fraction(f.denominator,f.numerator)
return 1 / f
def combmod(n, k, mod=MOD):
ret = 1
for i in range(n - k + 1, n + 1):
ret *= i
ret %= mod
for i in range(1, k + 1):
ret *= pow(i, mod - 2, mod)
ret %= mod
return ret
MOD = 10 ** 9 + 7
def solve():
n = getN()
bit_array = [[0, 0] for i in range(61)]
nums = getList()
for num in nums:
digit = 0
while(digit < 61):
if num % 2 == 0:
bit_array[digit][0] += 1
else:
bit_array[digit][1] += 1
digit += 1
num //= 2
# print(bit_array)
ans = 0
for i, tgt in enumerate(bit_array):
ans += pow(2, i, MOD) * tgt[0] * tgt[1]
ans %= MOD
print(ans )
def main():
n = getN()
for _ in range(n):
solve()
if __name__ == "__main__":
solve()
|
import sys
from collections import defaultdict, deque, Counter
import math
# import copy
from bisect import bisect_left, bisect_right
import heapq
# sys.setrecursionlimit(1000000)
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(eval(input()))
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)
def nck(n, k, kaijyo):
return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD
def npk(n, k, kaijyo):
if k == 0 or k == n:
return n % MOD
return (kaijyo[n] * divide(kaijyo[n-k])) % MOD
def kaijyo(n):
ret = [1]
for i in range(1, n + 1):
ret.append((ret[-1] * i)% MOD)
return ret
def solve():
n = getN()
nums = getList()
keta = [[0, 0] for i in range(62)]
for num in nums:
tmp = num
for i in range(62):
if tmp % 2 == 1:
keta[i][1] += 1
else:
keta[i][0] += 1
tmp //= 2
ans = 0
dig = 0
for k1, k2 in keta:
ans += ((k1 * k2) * (2**dig)) % MOD
dig += 1
print((ans % MOD))
def main():
n = getN()
for _ in range(n):
solve()
if __name__ == "__main__":
# main()
solve()
| 76 | 73 | 1,404 | 1,401 |
def getN():
return int(eval(input()))
def getNM():
return list(map(int, input().split()))
def getList():
return list(map(int, input().split()))
from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
from heapq import *
import sys
# sys.setrecursionlimit(1000000)
INF = 10**17
MOD = 1000000007
from fractions import *
def inverse(f):
# return Fraction(f.denominator,f.numerator)
return 1 / f
def combmod(n, k, mod=MOD):
ret = 1
for i in range(n - k + 1, n + 1):
ret *= i
ret %= mod
for i in range(1, k + 1):
ret *= pow(i, mod - 2, mod)
ret %= mod
return ret
MOD = 10**9 + 7
def solve():
n = getN()
bit_array = [[0, 0] for i in range(61)]
nums = getList()
for num in nums:
digit = 0
while digit < 61:
if num % 2 == 0:
bit_array[digit][0] += 1
else:
bit_array[digit][1] += 1
digit += 1
num //= 2
# print(bit_array)
ans = 0
for i, tgt in enumerate(bit_array):
ans += pow(2, i, MOD) * tgt[0] * tgt[1]
ans %= MOD
print(ans)
def main():
n = getN()
for _ in range(n):
solve()
if __name__ == "__main__":
solve()
|
import sys
from collections import defaultdict, deque, Counter
import math
# import copy
from bisect import bisect_left, bisect_right
import heapq
# sys.setrecursionlimit(1000000)
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(eval(input()))
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
INF = 10**20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD - 2, MOD)
def nck(n, k, kaijyo):
return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD
def npk(n, k, kaijyo):
if k == 0 or k == n:
return n % MOD
return (kaijyo[n] * divide(kaijyo[n - k])) % MOD
def kaijyo(n):
ret = [1]
for i in range(1, n + 1):
ret.append((ret[-1] * i) % MOD)
return ret
def solve():
n = getN()
nums = getList()
keta = [[0, 0] for i in range(62)]
for num in nums:
tmp = num
for i in range(62):
if tmp % 2 == 1:
keta[i][1] += 1
else:
keta[i][0] += 1
tmp //= 2
ans = 0
dig = 0
for k1, k2 in keta:
ans += ((k1 * k2) * (2**dig)) % MOD
dig += 1
print((ans % MOD))
def main():
n = getN()
for _ in range(n):
solve()
if __name__ == "__main__":
# main()
solve()
| false | 3.947368 |
[
"-def getN():",
"- return int(eval(input()))",
"+import sys",
"+from collections import defaultdict, deque, Counter",
"+import math",
"+",
"+# import copy",
"+from bisect import bisect_left, bisect_right",
"+import heapq",
"+",
"+# sys.setrecursionlimit(1000000)",
"+# input aliases",
"+input = sys.stdin.readline",
"+getS = lambda: input().strip()",
"+getN = lambda: int(eval(input()))",
"+getList = lambda: list(map(int, input().split()))",
"+getZList = lambda: [int(x) - 1 for x in input().split()]",
"+INF = 10**20",
"+MOD = 10**9 + 7",
"+divide = lambda x: pow(x, MOD - 2, MOD)",
"-def getNM():",
"- return list(map(int, input().split()))",
"+def nck(n, k, kaijyo):",
"+ return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD",
"-def getList():",
"- return list(map(int, input().split()))",
"+def npk(n, k, kaijyo):",
"+ if k == 0 or k == n:",
"+ return n % MOD",
"+ return (kaijyo[n] * divide(kaijyo[n - k])) % MOD",
"-from collections import defaultdict, deque",
"-from sys import exit",
"-import math",
"-import copy",
"-from bisect import bisect_left, bisect_right",
"-from heapq import *",
"-import sys",
"-",
"-# sys.setrecursionlimit(1000000)",
"-INF = 10**17",
"-MOD = 1000000007",
"-from fractions import *",
"-",
"-",
"-def inverse(f):",
"- # return Fraction(f.denominator,f.numerator)",
"- return 1 / f",
"-",
"-",
"-def combmod(n, k, mod=MOD):",
"- ret = 1",
"- for i in range(n - k + 1, n + 1):",
"- ret *= i",
"- ret %= mod",
"- for i in range(1, k + 1):",
"- ret *= pow(i, mod - 2, mod)",
"- ret %= mod",
"+def kaijyo(n):",
"+ ret = [1]",
"+ for i in range(1, n + 1):",
"+ ret.append((ret[-1] * i) % MOD)",
"-",
"-",
"-MOD = 10**9 + 7",
"- bit_array = [[0, 0] for i in range(61)]",
"+ keta = [[0, 0] for i in range(62)]",
"- digit = 0",
"- while digit < 61:",
"- if num % 2 == 0:",
"- bit_array[digit][0] += 1",
"+ tmp = num",
"+ for i in range(62):",
"+ if tmp % 2 == 1:",
"+ keta[i][1] += 1",
"- bit_array[digit][1] += 1",
"- digit += 1",
"- num //= 2",
"- # print(bit_array)",
"+ keta[i][0] += 1",
"+ tmp //= 2",
"- for i, tgt in enumerate(bit_array):",
"- ans += pow(2, i, MOD) * tgt[0] * tgt[1]",
"- ans %= MOD",
"- print(ans)",
"+ dig = 0",
"+ for k1, k2 in keta:",
"+ ans += ((k1 * k2) * (2**dig)) % MOD",
"+ dig += 1",
"+ print((ans % MOD))",
"+ # main()"
] | false | 0.038097 | 0.036367 | 1.047584 |
[
"s138635366",
"s291742763"
] |
u815763296
|
p02727
|
python
|
s808334110
|
s220448157
| 366 | 186 | 29,820 | 29,276 |
Accepted
|
Accepted
| 49.18 |
import heapq
import sys
X, Y, A, B, C = list(map(int, input().split()))
Av = list(map(int, input().split()))
Bv = list(map(int, input().split()))
Cv = list(map(int, input().split()))
heapq.heapify(Av)
heapq.heapify(Bv)
heapq.heapify(Cv)
for i in range(A-X):
heapq.heappop(Av)
for i in range(B-Y):
heapq.heappop(Bv)
if C > X+Y:
for i in range(C-(X+Y)):
heapq.heappop(Cv)
NotTake = X+Y
else:
NotTake = C
total = X+Y
C = NotTake
for _ in range(NotTake):
Amin = heapq.heappop(Av)
Bmin = heapq.heappop(Bv)
Cmin = heapq.heappop(Cv)
if X > 0 and Amin == min(Amin, Bmin, Cmin):
heapq.heappush(Bv, Bmin)
heapq.heappush(Cv, Cmin)
X -= 1
elif Y > 0 and Bmin == min(Bmin, Cmin):
heapq.heappush(Av, Amin)
heapq.heappush(Cv, Cmin)
Y -= 1
elif C > 0:
heapq.heappush(Av, Amin)
heapq.heappush(Bv, Bmin)
C -= 1
if X == 0 or Y == 0 or C == 0:
break
NotTake = X+Y+C-total
if X == 0:
Iv = Bv
Jv = Cv
I = Y
J = C
elif Y == 0:
Iv = Av
Jv = Cv
I = X
J = C
else:
print((sum(Av)+sum(Bv)+sum(Cv)))
sys.exit()
for _ in range(NotTake):
Imin = heapq.heappop(Iv)
Jmin = heapq.heappop(Jv)
if I > 0 and Imin == min(Imin, Jmin):
heapq.heappush(Jv, Jmin)
I -= 1
elif J > 0:
heapq.heappush(Iv, Imin)
J -= 1
if J == 0 or I == 0:
break
print((sum(Av)+sum(Bv)+sum(Cv)))
|
def LI():
return list(map(int, input().split()))
X, Y, A, B, C = LI()
red = LI()
green = LI()
mu = LI()
red.sort(reverse=True)
green.sort(reverse=True)
ans = red[:X]+green[:Y]+mu
ans.sort(reverse=True)
total = 0
for i in range(X+Y):
total += ans[i]
print(total)
| 67 | 16 | 1,525 | 287 |
import heapq
import sys
X, Y, A, B, C = list(map(int, input().split()))
Av = list(map(int, input().split()))
Bv = list(map(int, input().split()))
Cv = list(map(int, input().split()))
heapq.heapify(Av)
heapq.heapify(Bv)
heapq.heapify(Cv)
for i in range(A - X):
heapq.heappop(Av)
for i in range(B - Y):
heapq.heappop(Bv)
if C > X + Y:
for i in range(C - (X + Y)):
heapq.heappop(Cv)
NotTake = X + Y
else:
NotTake = C
total = X + Y
C = NotTake
for _ in range(NotTake):
Amin = heapq.heappop(Av)
Bmin = heapq.heappop(Bv)
Cmin = heapq.heappop(Cv)
if X > 0 and Amin == min(Amin, Bmin, Cmin):
heapq.heappush(Bv, Bmin)
heapq.heappush(Cv, Cmin)
X -= 1
elif Y > 0 and Bmin == min(Bmin, Cmin):
heapq.heappush(Av, Amin)
heapq.heappush(Cv, Cmin)
Y -= 1
elif C > 0:
heapq.heappush(Av, Amin)
heapq.heappush(Bv, Bmin)
C -= 1
if X == 0 or Y == 0 or C == 0:
break
NotTake = X + Y + C - total
if X == 0:
Iv = Bv
Jv = Cv
I = Y
J = C
elif Y == 0:
Iv = Av
Jv = Cv
I = X
J = C
else:
print((sum(Av) + sum(Bv) + sum(Cv)))
sys.exit()
for _ in range(NotTake):
Imin = heapq.heappop(Iv)
Jmin = heapq.heappop(Jv)
if I > 0 and Imin == min(Imin, Jmin):
heapq.heappush(Jv, Jmin)
I -= 1
elif J > 0:
heapq.heappush(Iv, Imin)
J -= 1
if J == 0 or I == 0:
break
print((sum(Av) + sum(Bv) + sum(Cv)))
|
def LI():
return list(map(int, input().split()))
X, Y, A, B, C = LI()
red = LI()
green = LI()
mu = LI()
red.sort(reverse=True)
green.sort(reverse=True)
ans = red[:X] + green[:Y] + mu
ans.sort(reverse=True)
total = 0
for i in range(X + Y):
total += ans[i]
print(total)
| false | 76.119403 |
[
"-import heapq",
"-import sys",
"+def LI():",
"+ return list(map(int, input().split()))",
"-X, Y, A, B, C = list(map(int, input().split()))",
"-Av = list(map(int, input().split()))",
"-Bv = list(map(int, input().split()))",
"-Cv = list(map(int, input().split()))",
"-heapq.heapify(Av)",
"-heapq.heapify(Bv)",
"-heapq.heapify(Cv)",
"-for i in range(A - X):",
"- heapq.heappop(Av)",
"-for i in range(B - Y):",
"- heapq.heappop(Bv)",
"-if C > X + Y:",
"- for i in range(C - (X + Y)):",
"- heapq.heappop(Cv)",
"- NotTake = X + Y",
"-else:",
"- NotTake = C",
"-total = X + Y",
"-C = NotTake",
"-for _ in range(NotTake):",
"- Amin = heapq.heappop(Av)",
"- Bmin = heapq.heappop(Bv)",
"- Cmin = heapq.heappop(Cv)",
"- if X > 0 and Amin == min(Amin, Bmin, Cmin):",
"- heapq.heappush(Bv, Bmin)",
"- heapq.heappush(Cv, Cmin)",
"- X -= 1",
"- elif Y > 0 and Bmin == min(Bmin, Cmin):",
"- heapq.heappush(Av, Amin)",
"- heapq.heappush(Cv, Cmin)",
"- Y -= 1",
"- elif C > 0:",
"- heapq.heappush(Av, Amin)",
"- heapq.heappush(Bv, Bmin)",
"- C -= 1",
"- if X == 0 or Y == 0 or C == 0:",
"- break",
"-NotTake = X + Y + C - total",
"-if X == 0:",
"- Iv = Bv",
"- Jv = Cv",
"- I = Y",
"- J = C",
"-elif Y == 0:",
"- Iv = Av",
"- Jv = Cv",
"- I = X",
"- J = C",
"-else:",
"- print((sum(Av) + sum(Bv) + sum(Cv)))",
"- sys.exit()",
"-for _ in range(NotTake):",
"- Imin = heapq.heappop(Iv)",
"- Jmin = heapq.heappop(Jv)",
"- if I > 0 and Imin == min(Imin, Jmin):",
"- heapq.heappush(Jv, Jmin)",
"- I -= 1",
"- elif J > 0:",
"- heapq.heappush(Iv, Imin)",
"- J -= 1",
"- if J == 0 or I == 0:",
"- break",
"-print((sum(Av) + sum(Bv) + sum(Cv)))",
"+",
"+X, Y, A, B, C = LI()",
"+red = LI()",
"+green = LI()",
"+mu = LI()",
"+red.sort(reverse=True)",
"+green.sort(reverse=True)",
"+ans = red[:X] + green[:Y] + mu",
"+ans.sort(reverse=True)",
"+total = 0",
"+for i in range(X + Y):",
"+ total += ans[i]",
"+print(total)"
] | false | 0.036734 | 0.03851 | 0.953868 |
[
"s808334110",
"s220448157"
] |
u301624971
|
p02947
|
python
|
s986517644
|
s755603164
| 468 | 372 | 20,200 | 19,500 |
Accepted
|
Accepted
| 20.51 |
N=int(eval(input()))
s=[]
cnt=dict()
for _ in range(N):
tmp=list(eval(input()))
sotmp=sorted(tmp)
stmp=''.join(sotmp)
s.append(stmp)
ss=sorted(s)
for word in ss:
if((word in list(cnt.keys()))==False):
cnt[word]=0
else:
cnt[word]+=1
total=0
for value in list(cnt.values()):
total+=(1+value)*value//2
print(total)
|
def myAnswer(N:int,S:list) -> int:
counter = 0
dic = {}
for s in S:
if(s in list(dic.keys())):
dic[s]+=1
else:
dic[s] = 0
for value in list(dic.values()):
counter += (value * (value + 1)) // 2
return counter
def modelAnswer():
return
def main():
N = int(eval(input()))
S = ["".join(sorted(list(eval(input())))) for _ in range(N)]
print((myAnswer(N,S)))
if __name__ == '__main__':
main()
| 25 | 20 | 363 | 446 |
N = int(eval(input()))
s = []
cnt = dict()
for _ in range(N):
tmp = list(eval(input()))
sotmp = sorted(tmp)
stmp = "".join(sotmp)
s.append(stmp)
ss = sorted(s)
for word in ss:
if (word in list(cnt.keys())) == False:
cnt[word] = 0
else:
cnt[word] += 1
total = 0
for value in list(cnt.values()):
total += (1 + value) * value // 2
print(total)
|
def myAnswer(N: int, S: list) -> int:
counter = 0
dic = {}
for s in S:
if s in list(dic.keys()):
dic[s] += 1
else:
dic[s] = 0
for value in list(dic.values()):
counter += (value * (value + 1)) // 2
return counter
def modelAnswer():
return
def main():
N = int(eval(input()))
S = ["".join(sorted(list(eval(input())))) for _ in range(N)]
print((myAnswer(N, S)))
if __name__ == "__main__":
main()
| false | 20 |
[
"-N = int(eval(input()))",
"-s = []",
"-cnt = dict()",
"-for _ in range(N):",
"- tmp = list(eval(input()))",
"- sotmp = sorted(tmp)",
"- stmp = \"\".join(sotmp)",
"- s.append(stmp)",
"-ss = sorted(s)",
"-for word in ss:",
"- if (word in list(cnt.keys())) == False:",
"- cnt[word] = 0",
"- else:",
"- cnt[word] += 1",
"-total = 0",
"-for value in list(cnt.values()):",
"- total += (1 + value) * value // 2",
"-print(total)",
"+def myAnswer(N: int, S: list) -> int:",
"+ counter = 0",
"+ dic = {}",
"+ for s in S:",
"+ if s in list(dic.keys()):",
"+ dic[s] += 1",
"+ else:",
"+ dic[s] = 0",
"+ for value in list(dic.values()):",
"+ counter += (value * (value + 1)) // 2",
"+ return counter",
"+",
"+",
"+def modelAnswer():",
"+ return",
"+",
"+",
"+def main():",
"+ N = int(eval(input()))",
"+ S = [\"\".join(sorted(list(eval(input())))) for _ in range(N)]",
"+ print((myAnswer(N, S)))",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.060908 | 0.107708 | 0.565491 |
[
"s986517644",
"s755603164"
] |
u054514819
|
p02703
|
python
|
s236090066
|
s526658470
| 1,151 | 676 | 177,904 | 97,040 |
Accepted
|
Accepted
| 41.27 |
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
N, M, S = mapint()
S = min(S, N*50)
query = [[[] for _ in range(N*50+1)] for _ in range(N)]
for _ in range(M):
u, v, a, b = mapint()
for coin in range(a, N*50+1):
query[u-1][coin].append((v-1, a, b))
query[v-1][coin].append((u-1, a, b))
for i in range(N):
c, d = mapint()
for coin in range(N*50+1):
query[i][coin].append((i, -c, d))
inf = 10**18
dp = [[inf]*(N*50+1) for _ in range(N)]
dp[0][0] = 0
import heapq
queue = [(0, 0, S)]
checked = [0]*N
cnt = 0
while queue:
t, now, coin = heapq.heappop(queue)
if cnt==N:
break
if not checked[now]:
checked[now] = 1
cnt += 1
qlis = query[now][coin]
for nx, a, b in qlis:
if 0<=coin-a:
coin = min(coin, N*50+a)
if t+b<dp[nx][coin-a]:
dp[nx][coin-a] = t+b
heapq.heappush(queue, (t+b, nx, coin-a))
for i in range(1, N):
print((min(dp[i])))
|
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
N, M, S = mapint()
graph = [{} for _ in range(N)]
for _ in range(M):
u, v, a, t = mapint()
graph[u-1][v-1] = (a, t)
graph[v-1][u-1] = (a, t)
change = [list(mapint()) for _ in range(N)]
from heapq import heappop, heappush
# time, silver, vertex
Q = [(0, min(2500, S), 0)]
dist = [[10**18]*2501 for _ in range(N)]
dist[0][min(2500, S)] = 0
while Q:
t, s, v = heappop(Q)
rate, change_time = change[v]
if s<2500 and dist[v][min(2500, s+rate)]>t+change_time:
dist[v][min(2500, s+rate)] = t+change_time
heappush(Q, (t+change_time, min(2500, s+rate), v))
for nx in list(graph[v].keys()):
nx_s, nx_t = graph[v][nx]
if nx_s<=s and dist[nx][s-nx_s]>t+nx_t:
dist[nx][s-nx_s] = t+nx_t
heappush(Q, (t+nx_t, s-nx_s, nx))
for i in range(1, N):
print((min(dist[i])))
| 44 | 32 | 1,115 | 1,000 |
import sys
def input():
return sys.stdin.readline().strip()
def mapint():
return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
N, M, S = mapint()
S = min(S, N * 50)
query = [[[] for _ in range(N * 50 + 1)] for _ in range(N)]
for _ in range(M):
u, v, a, b = mapint()
for coin in range(a, N * 50 + 1):
query[u - 1][coin].append((v - 1, a, b))
query[v - 1][coin].append((u - 1, a, b))
for i in range(N):
c, d = mapint()
for coin in range(N * 50 + 1):
query[i][coin].append((i, -c, d))
inf = 10**18
dp = [[inf] * (N * 50 + 1) for _ in range(N)]
dp[0][0] = 0
import heapq
queue = [(0, 0, S)]
checked = [0] * N
cnt = 0
while queue:
t, now, coin = heapq.heappop(queue)
if cnt == N:
break
if not checked[now]:
checked[now] = 1
cnt += 1
qlis = query[now][coin]
for nx, a, b in qlis:
if 0 <= coin - a:
coin = min(coin, N * 50 + a)
if t + b < dp[nx][coin - a]:
dp[nx][coin - a] = t + b
heapq.heappush(queue, (t + b, nx, coin - a))
for i in range(1, N):
print((min(dp[i])))
|
import sys
def input():
return sys.stdin.readline().strip()
def mapint():
return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
N, M, S = mapint()
graph = [{} for _ in range(N)]
for _ in range(M):
u, v, a, t = mapint()
graph[u - 1][v - 1] = (a, t)
graph[v - 1][u - 1] = (a, t)
change = [list(mapint()) for _ in range(N)]
from heapq import heappop, heappush
# time, silver, vertex
Q = [(0, min(2500, S), 0)]
dist = [[10**18] * 2501 for _ in range(N)]
dist[0][min(2500, S)] = 0
while Q:
t, s, v = heappop(Q)
rate, change_time = change[v]
if s < 2500 and dist[v][min(2500, s + rate)] > t + change_time:
dist[v][min(2500, s + rate)] = t + change_time
heappush(Q, (t + change_time, min(2500, s + rate), v))
for nx in list(graph[v].keys()):
nx_s, nx_t = graph[v][nx]
if nx_s <= s and dist[nx][s - nx_s] > t + nx_t:
dist[nx][s - nx_s] = t + nx_t
heappush(Q, (t + nx_t, s - nx_s, nx))
for i in range(1, N):
print((min(dist[i])))
| false | 27.272727 |
[
"-S = min(S, N * 50)",
"-query = [[[] for _ in range(N * 50 + 1)] for _ in range(N)]",
"+graph = [{} for _ in range(N)]",
"- u, v, a, b = mapint()",
"- for coin in range(a, N * 50 + 1):",
"- query[u - 1][coin].append((v - 1, a, b))",
"- query[v - 1][coin].append((u - 1, a, b))",
"-for i in range(N):",
"- c, d = mapint()",
"- for coin in range(N * 50 + 1):",
"- query[i][coin].append((i, -c, d))",
"-inf = 10**18",
"-dp = [[inf] * (N * 50 + 1) for _ in range(N)]",
"-dp[0][0] = 0",
"-import heapq",
"+ u, v, a, t = mapint()",
"+ graph[u - 1][v - 1] = (a, t)",
"+ graph[v - 1][u - 1] = (a, t)",
"+change = [list(mapint()) for _ in range(N)]",
"+from heapq import heappop, heappush",
"-queue = [(0, 0, S)]",
"-checked = [0] * N",
"-cnt = 0",
"-while queue:",
"- t, now, coin = heapq.heappop(queue)",
"- if cnt == N:",
"- break",
"- if not checked[now]:",
"- checked[now] = 1",
"- cnt += 1",
"- qlis = query[now][coin]",
"- for nx, a, b in qlis:",
"- if 0 <= coin - a:",
"- coin = min(coin, N * 50 + a)",
"- if t + b < dp[nx][coin - a]:",
"- dp[nx][coin - a] = t + b",
"- heapq.heappush(queue, (t + b, nx, coin - a))",
"+# time, silver, vertex",
"+Q = [(0, min(2500, S), 0)]",
"+dist = [[10**18] * 2501 for _ in range(N)]",
"+dist[0][min(2500, S)] = 0",
"+while Q:",
"+ t, s, v = heappop(Q)",
"+ rate, change_time = change[v]",
"+ if s < 2500 and dist[v][min(2500, s + rate)] > t + change_time:",
"+ dist[v][min(2500, s + rate)] = t + change_time",
"+ heappush(Q, (t + change_time, min(2500, s + rate), v))",
"+ for nx in list(graph[v].keys()):",
"+ nx_s, nx_t = graph[v][nx]",
"+ if nx_s <= s and dist[nx][s - nx_s] > t + nx_t:",
"+ dist[nx][s - nx_s] = t + nx_t",
"+ heappush(Q, (t + nx_t, s - nx_s, nx))",
"- print((min(dp[i])))",
"+ print((min(dist[i])))"
] | false | 0.038061 | 0.183804 | 0.207073 |
[
"s236090066",
"s526658470"
] |
u018679195
|
p03272
|
python
|
s149240920
|
s170059315
| 20 | 18 | 2,940 | 2,940 |
Accepted
|
Accepted
| 10 |
val1,val2=input().split(" ")
val3=int(val1)-int(val2)+1
print(val3)
|
def main():
N, i = list(map(int, input().strip().split()))
print((N - i + 1))
if __name__ == "__main__":
main()
| 3 | 6 | 69 | 122 |
val1, val2 = input().split(" ")
val3 = int(val1) - int(val2) + 1
print(val3)
|
def main():
N, i = list(map(int, input().strip().split()))
print((N - i + 1))
if __name__ == "__main__":
main()
| false | 50 |
[
"-val1, val2 = input().split(\" \")",
"-val3 = int(val1) - int(val2) + 1",
"-print(val3)",
"+def main():",
"+ N, i = list(map(int, input().strip().split()))",
"+ print((N - i + 1))",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.037074 | 0.065739 | 0.563953 |
[
"s149240920",
"s170059315"
] |
u048945791
|
p03339
|
python
|
s802334363
|
s905637690
| 93 | 77 | 5,916 | 5,928 |
Accepted
|
Accepted
| 17.2 |
N = int(eval(input()))
S = eval(input())
cost = list(S).count("E")
ans = 1000000
for si in S:
if si == "E":
cost -= 1
elif si == "W":
if cost < ans:
ans = cost
cost += 1
else:
if cost < ans:
ans = cost
print(ans)
|
N = int(eval(input()))
S = eval(input())
cost = list(S).count("E")
ans = 1000000
for si in S:
if si == "E":
cost -= 1
else:
if cost < ans:
ans = cost
cost += 1
else:
if cost < ans:
ans = cost
print(ans)
| 17 | 17 | 274 | 264 |
N = int(eval(input()))
S = eval(input())
cost = list(S).count("E")
ans = 1000000
for si in S:
if si == "E":
cost -= 1
elif si == "W":
if cost < ans:
ans = cost
cost += 1
else:
if cost < ans:
ans = cost
print(ans)
|
N = int(eval(input()))
S = eval(input())
cost = list(S).count("E")
ans = 1000000
for si in S:
if si == "E":
cost -= 1
else:
if cost < ans:
ans = cost
cost += 1
else:
if cost < ans:
ans = cost
print(ans)
| false | 0 |
[
"- elif si == \"W\":",
"+ else:"
] | false | 0.043246 | 0.108858 | 0.397268 |
[
"s802334363",
"s905637690"
] |
u621935300
|
p03714
|
python
|
s888135886
|
s226856276
| 1,041 | 346 | 34,208 | 72,528 |
Accepted
|
Accepted
| 66.76 |
n=int(eval(input()))
import heapq
a=list(map(int, input().split()))
q=a[:n]
heapq.heapify(q)
x=[sum(q)]
for k in range(n,2*n):
v=heapq.heappushpop(q,a[k])
x.append(x[-1]+a[k]-v)
a=a[::-1]
q=[-v for v in a[:n]]
heapq.heapify(q)
y=[-sum(q)]
for k in range(n,2*n):
v=-heapq.heappushpop(q,-a[k])
y.append(y[-1]+a[k]-v)
print((max(v-w for v,w in zip(x,y[::-1]))))
|
from heapq import heapify,heappush, heappop
N=eval(input())
A=list(map( int, input().split() ))
q=A[:N]
heapify(q)
q_sum=sum(q)
B=[ float("-inf") for i in range(3*N)]
B[N-1]=q_sum
for i in range(N,2*N):
x=A[i]
if x>q[0]:
tmp=heappop(q)
q_sum-=tmp
q_sum+=x
heappush(q,x)
B[i]=q_sum
q=[x*-1 for x in A[2*N:]]
heapify(q)
q_sum=sum(q)*-1
B[2*N-1]-=q_sum
for i in range(2*N-1,N-1,-1):
x=A[i]*-1
if q[0]<x:
tmp=heappop(q)
q_sum-=tmp*-1
q_sum+=x*-1
heappush(q,x)
B[i-1]-=q_sum
print(max(B))
| 17 | 37 | 380 | 547 |
n = int(eval(input()))
import heapq
a = list(map(int, input().split()))
q = a[:n]
heapq.heapify(q)
x = [sum(q)]
for k in range(n, 2 * n):
v = heapq.heappushpop(q, a[k])
x.append(x[-1] + a[k] - v)
a = a[::-1]
q = [-v for v in a[:n]]
heapq.heapify(q)
y = [-sum(q)]
for k in range(n, 2 * n):
v = -heapq.heappushpop(q, -a[k])
y.append(y[-1] + a[k] - v)
print((max(v - w for v, w in zip(x, y[::-1]))))
|
from heapq import heapify, heappush, heappop
N = eval(input())
A = list(map(int, input().split()))
q = A[:N]
heapify(q)
q_sum = sum(q)
B = [float("-inf") for i in range(3 * N)]
B[N - 1] = q_sum
for i in range(N, 2 * N):
x = A[i]
if x > q[0]:
tmp = heappop(q)
q_sum -= tmp
q_sum += x
heappush(q, x)
B[i] = q_sum
q = [x * -1 for x in A[2 * N :]]
heapify(q)
q_sum = sum(q) * -1
B[2 * N - 1] -= q_sum
for i in range(2 * N - 1, N - 1, -1):
x = A[i] * -1
if q[0] < x:
tmp = heappop(q)
q_sum -= tmp * -1
q_sum += x * -1
heappush(q, x)
B[i - 1] -= q_sum
print(max(B))
| false | 54.054054 |
[
"-n = int(eval(input()))",
"-import heapq",
"+from heapq import heapify, heappush, heappop",
"-a = list(map(int, input().split()))",
"-q = a[:n]",
"-heapq.heapify(q)",
"-x = [sum(q)]",
"-for k in range(n, 2 * n):",
"- v = heapq.heappushpop(q, a[k])",
"- x.append(x[-1] + a[k] - v)",
"-a = a[::-1]",
"-q = [-v for v in a[:n]]",
"-heapq.heapify(q)",
"-y = [-sum(q)]",
"-for k in range(n, 2 * n):",
"- v = -heapq.heappushpop(q, -a[k])",
"- y.append(y[-1] + a[k] - v)",
"-print((max(v - w for v, w in zip(x, y[::-1]))))",
"+N = eval(input())",
"+A = list(map(int, input().split()))",
"+q = A[:N]",
"+heapify(q)",
"+q_sum = sum(q)",
"+B = [float(\"-inf\") for i in range(3 * N)]",
"+B[N - 1] = q_sum",
"+for i in range(N, 2 * N):",
"+ x = A[i]",
"+ if x > q[0]:",
"+ tmp = heappop(q)",
"+ q_sum -= tmp",
"+ q_sum += x",
"+ heappush(q, x)",
"+ B[i] = q_sum",
"+q = [x * -1 for x in A[2 * N :]]",
"+heapify(q)",
"+q_sum = sum(q) * -1",
"+B[2 * N - 1] -= q_sum",
"+for i in range(2 * N - 1, N - 1, -1):",
"+ x = A[i] * -1",
"+ if q[0] < x:",
"+ tmp = heappop(q)",
"+ q_sum -= tmp * -1",
"+ q_sum += x * -1",
"+ heappush(q, x)",
"+ B[i - 1] -= q_sum",
"+print(max(B))"
] | false | 0.04332 | 0.105484 | 0.410683 |
[
"s888135886",
"s226856276"
] |
u499381410
|
p03700
|
python
|
s398252081
|
s079000735
| 346 | 310 | 46,172 | 45,404 |
Accepted
|
Accepted
| 10.4 |
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
sys.setrecursionlimit(2147483647)
INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007
n, a, b = LI()
L = IR(n)
ok = max(L) // b + 1
ng = 0
while ok > ng + 1:
mid = (ok + ng) // 2
remain = mid
for i in range(n):
remain -= max(0, (L[i] - b * mid) // (a - b) + bool((L[i] - b * mid) % (a - b)))
if remain < 0:
ng = mid
break
else:
ok = mid
print(ok)
|
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007
n, a, b = LI()
H = IR(n)
ok = 10 ** 9
ng = 0
while ok > ng + 1:
mid = (ok + ng) // 2
ret = 0
for h in H:
remain = h - b * mid
if remain > 0:
ret += remain // (a - b) + bool(remain % (a - b))
if ret <= mid:
ok = mid
else:
ng = mid
print(ok)
| 48 | 47 | 1,304 | 1,304 |
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
sys.setrecursionlimit(2147483647)
INF = float("inf")
def LI():
return list(map(int, sys.stdin.readline().split()))
def I():
return int(sys.stdin.readline())
def LS():
return sys.stdin.readline().split()
def S():
return sys.stdin.readline().strip()
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
def SRL(n):
return [list(S()) for i in range(n)]
def MSRL(n):
return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007
n, a, b = LI()
L = IR(n)
ok = max(L) // b + 1
ng = 0
while ok > ng + 1:
mid = (ok + ng) // 2
remain = mid
for i in range(n):
remain -= max(0, (L[i] - b * mid) // (a - b) + bool((L[i] - b * mid) % (a - b)))
if remain < 0:
ng = mid
break
else:
ok = mid
print(ok)
|
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
sys.setrecursionlimit(2147483647)
INF = 10**20
def LI():
return list(map(int, sys.stdin.buffer.readline().split()))
def I():
return int(sys.stdin.buffer.readline())
def LS():
return sys.stdin.buffer.readline().rstrip().decode("utf-8").split()
def S():
return sys.stdin.buffer.readline().rstrip().decode("utf-8")
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
def SRL(n):
return [list(S()) for i in range(n)]
mod = 1000000007
n, a, b = LI()
H = IR(n)
ok = 10**9
ng = 0
while ok > ng + 1:
mid = (ok + ng) // 2
ret = 0
for h in H:
remain = h - b * mid
if remain > 0:
ret += remain // (a - b) + bool(remain % (a - b))
if ret <= mid:
ok = mid
else:
ng = mid
print(ok)
| false | 2.083333 |
[
"+from copy import deepcopy",
"-INF = float(\"inf\")",
"+INF = 10**20",
"- return list(map(int, sys.stdin.readline().split()))",
"+ return list(map(int, sys.stdin.buffer.readline().split()))",
"- return int(sys.stdin.readline())",
"+ return int(sys.stdin.buffer.readline())",
"- return sys.stdin.readline().split()",
"+ return sys.stdin.buffer.readline().rstrip().decode(\"utf-8\").split()",
"- return sys.stdin.readline().strip()",
"+ return sys.stdin.buffer.readline().rstrip().decode(\"utf-8\")",
"-def MSRL(n):",
"- return [[int(j) for j in list(S())] for i in range(n)]",
"-",
"-",
"-L = IR(n)",
"-ok = max(L) // b + 1",
"+H = IR(n)",
"+ok = 10**9",
"- remain = mid",
"- for i in range(n):",
"- remain -= max(0, (L[i] - b * mid) // (a - b) + bool((L[i] - b * mid) % (a - b)))",
"- if remain < 0:",
"- ng = mid",
"- break",
"+ ret = 0",
"+ for h in H:",
"+ remain = h - b * mid",
"+ if remain > 0:",
"+ ret += remain // (a - b) + bool(remain % (a - b))",
"+ if ret <= mid:",
"+ ok = mid",
"- ok = mid",
"+ ng = mid"
] | false | 0.041114 | 0.05019 | 0.819176 |
[
"s398252081",
"s079000735"
] |
u156815136
|
p03821
|
python
|
s224569634
|
s959062183
| 387 | 275 | 17,120 | 23,684 |
Accepted
|
Accepted
| 28.94 |
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
# d = m - k[i] - k[j]
# if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも!!
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
def readInts():
return list(map(int,input().split()))
def main():
n = int(eval(input()))
A = []
B = []
for i in range(n):
a,b = readInts()
A.append(a)
B.append(b)
l = 0
for i in range(n-1,-1,-1):
# 前回分からだんだん加算されていくパターン
A[i] += l
if A[i] % B[i] == 0:
continue
#print("before",A[i],B[i])
ama = A[i] % B[i] # 9 4 ≡ 1 増やす数は、4 - 1 = 3
up_ = B[i] - ama
#print("after",A[i]+up_,B[i])
l += up_
print(l)
if __name__ == '__main__':
main()
|
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
# d = m - k[i] - k[j]
# if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも!!
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
return list(map(int,input().split()))
def I():
return int(eval(input()))
n = I()
AB = []
for i in range(n):
a,b = readInts()
AB.append((a,b))
cnt = 0
for i in range(n-1,-1,-1):
a,b = AB[i]
a += cnt
cnt += (b - a%b) if a%b else 0
print(cnt)
| 47 | 39 | 1,071 | 864 |
from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
# d = m - k[i] - k[j]
# if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも!!
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
def readInts():
return list(map(int, input().split()))
def main():
n = int(eval(input()))
A = []
B = []
for i in range(n):
a, b = readInts()
A.append(a)
B.append(b)
l = 0
for i in range(n - 1, -1, -1):
# 前回分からだんだん加算されていくパターン
A[i] += l
if A[i] % B[i] == 0:
continue
# print("before",A[i],B[i])
ama = A[i] % B[i] # 9 4 ≡ 1 増やす数は、4 - 1 = 3
up_ = B[i] - ama
# print("after",A[i]+up_,B[i])
l += up_
print(l)
if __name__ == "__main__":
main()
|
# from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations, permutations, accumulate # (string,3) 3回
# from collections import deque
from collections import deque, defaultdict, Counter
import decimal
import re
# import bisect
#
# d = m - k[i] - k[j]
# if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも!!
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
# mod = 9982443453
def readInts():
return list(map(int, input().split()))
def I():
return int(eval(input()))
n = I()
AB = []
for i in range(n):
a, b = readInts()
AB.append((a, b))
cnt = 0
for i in range(n - 1, -1, -1):
a, b = AB[i]
a += cnt
cnt += (b - a % b) if a % b else 0
print(cnt)
| false | 17.021277 |
[
"-from statistics import median",
"-",
"+# from statistics import median",
"-from itertools import combinations # (string,3) 3回",
"-from collections import deque",
"-from collections import defaultdict",
"-import bisect",
"+from itertools import combinations, permutations, accumulate # (string,3) 3回",
"+# from collections import deque",
"+from collections import deque, defaultdict, Counter",
"+import decimal",
"+import re",
"+",
"+# import bisect",
"-",
"-",
"+# mod = 9982443453",
"-def main():",
"- n = int(eval(input()))",
"- A = []",
"- B = []",
"- for i in range(n):",
"- a, b = readInts()",
"- A.append(a)",
"- B.append(b)",
"- l = 0",
"- for i in range(n - 1, -1, -1):",
"- # 前回分からだんだん加算されていくパターン",
"- A[i] += l",
"- if A[i] % B[i] == 0:",
"- continue",
"- # print(\"before\",A[i],B[i])",
"- ama = A[i] % B[i] # 9 4 ≡ 1 増やす数は、4 - 1 = 3",
"- up_ = B[i] - ama",
"- # print(\"after\",A[i]+up_,B[i])",
"- l += up_",
"- print(l)",
"+def I():",
"+ return int(eval(input()))",
"-if __name__ == \"__main__\":",
"- main()",
"+n = I()",
"+AB = []",
"+for i in range(n):",
"+ a, b = readInts()",
"+ AB.append((a, b))",
"+cnt = 0",
"+for i in range(n - 1, -1, -1):",
"+ a, b = AB[i]",
"+ a += cnt",
"+ cnt += (b - a % b) if a % b else 0",
"+print(cnt)"
] | false | 0.124104 | 0.078645 | 1.578036 |
[
"s224569634",
"s959062183"
] |
u018679195
|
p02629
|
python
|
s697020465
|
s585832089
| 362 | 29 | 85,032 | 9,200 |
Accepted
|
Accepted
| 91.99 |
s = input()
n = int(s)
def main(n):
d = 1
n -= 1
while n - 26**d >= 0:
n -= 26**d
d += 1
ret = ''
for i in range(d):
ret += chr((n%26)+ord('a'))
n //= 26
return ret[::-1]
print(main(n))
|
a = int(eval(input()))
s = []
ret = ['z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z',
]
while a > 0:
a -= 1
shang = int(a / 26)
yushu = int(a % 26)
# print(shang, yushu)
s.append(yushu+1)
a = shang
s.reverse()
# print(s)
v = ''
for i in range(len(s)):
v += ret[s[i]]
print(v)
| 16 | 19 | 220 | 417 |
s = input()
n = int(s)
def main(n):
d = 1
n -= 1
while n - 26**d >= 0:
n -= 26**d
d += 1
ret = ""
for i in range(d):
ret += chr((n % 26) + ord("a"))
n //= 26
return ret[::-1]
print(main(n))
|
a = int(eval(input()))
s = []
ret = [
"z",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
]
while a > 0:
a -= 1
shang = int(a / 26)
yushu = int(a % 26)
# print(shang, yushu)
s.append(yushu + 1)
a = shang
s.reverse()
# print(s)
v = ""
for i in range(len(s)):
v += ret[s[i]]
print(v)
| false | 15.789474 |
[
"-s = input()",
"-n = int(s)",
"-",
"-",
"-def main(n):",
"- d = 1",
"- n -= 1",
"- while n - 26**d >= 0:",
"- n -= 26**d",
"- d += 1",
"- ret = \"\"",
"- for i in range(d):",
"- ret += chr((n % 26) + ord(\"a\"))",
"- n //= 26",
"- return ret[::-1]",
"-",
"-",
"-print(main(n))",
"+a = int(eval(input()))",
"+s = []",
"+ret = [",
"+ \"z\",",
"+ \"a\",",
"+ \"b\",",
"+ \"c\",",
"+ \"d\",",
"+ \"e\",",
"+ \"f\",",
"+ \"g\",",
"+ \"h\",",
"+ \"i\",",
"+ \"j\",",
"+ \"k\",",
"+ \"l\",",
"+ \"m\",",
"+ \"n\",",
"+ \"o\",",
"+ \"p\",",
"+ \"q\",",
"+ \"r\",",
"+ \"s\",",
"+ \"t\",",
"+ \"u\",",
"+ \"v\",",
"+ \"w\",",
"+ \"x\",",
"+ \"y\",",
"+ \"z\",",
"+]",
"+while a > 0:",
"+ a -= 1",
"+ shang = int(a / 26)",
"+ yushu = int(a % 26)",
"+ # print(shang, yushu)",
"+ s.append(yushu + 1)",
"+ a = shang",
"+s.reverse()",
"+# print(s)",
"+v = \"\"",
"+for i in range(len(s)):",
"+ v += ret[s[i]]",
"+print(v)"
] | false | 0.055941 | 0.063207 | 0.885049 |
[
"s697020465",
"s585832089"
] |
u787456042
|
p02888
|
python
|
s338805184
|
s100054693
| 1,978 | 1,498 | 3,188 | 3,188 |
Accepted
|
Accepted
| 24.27 |
from bisect import*
N,*L=list(map(int,open(0).read().split()));L.sort()
a=0
l=[]
r=[]
for i in range(1001):
l.append(bisect_left(L,i))
r.append(bisect(L,i))
for p in L:
for q in L:
x=p+q
y=abs(p-q)
a+=(l[x]if x<1001else N)-(r[y]if 0<y<1001else(y>1000)*N)
for p in L:
x=2*p
a-=3*(l[x]if x<1001else N)
print(((a+2*N)//6))
|
from bisect import*
N,*L=list(map(int,open(0).read().split()));L.sort()
a=0
for i in range(N):
for j in range(i+1,N):
a+=bisect_left(L,L[i]+L[j],j+1)-j-1
print(a)
| 17 | 7 | 371 | 173 |
from bisect import *
N, *L = list(map(int, open(0).read().split()))
L.sort()
a = 0
l = []
r = []
for i in range(1001):
l.append(bisect_left(L, i))
r.append(bisect(L, i))
for p in L:
for q in L:
x = p + q
y = abs(p - q)
a += (l[x] if x < 1001 else N) - (r[y] if 0 < y < 1001 else (y > 1000) * N)
for p in L:
x = 2 * p
a -= 3 * (l[x] if x < 1001 else N)
print(((a + 2 * N) // 6))
|
from bisect import *
N, *L = list(map(int, open(0).read().split()))
L.sort()
a = 0
for i in range(N):
for j in range(i + 1, N):
a += bisect_left(L, L[i] + L[j], j + 1) - j - 1
print(a)
| false | 58.823529 |
[
"-l = []",
"-r = []",
"-for i in range(1001):",
"- l.append(bisect_left(L, i))",
"- r.append(bisect(L, i))",
"-for p in L:",
"- for q in L:",
"- x = p + q",
"- y = abs(p - q)",
"- a += (l[x] if x < 1001 else N) - (r[y] if 0 < y < 1001 else (y > 1000) * N)",
"-for p in L:",
"- x = 2 * p",
"- a -= 3 * (l[x] if x < 1001 else N)",
"-print(((a + 2 * N) // 6))",
"+for i in range(N):",
"+ for j in range(i + 1, N):",
"+ a += bisect_left(L, L[i] + L[j], j + 1) - j - 1",
"+print(a)"
] | false | 0.041011 | 0.082904 | 0.494682 |
[
"s338805184",
"s100054693"
] |
u780342333
|
p02388
|
python
|
s309875639
|
s941075251
| 30 | 20 | 7,644 | 5,572 |
Accepted
|
Accepted
| 33.33 |
x = int(eval(input()))
print((x ** 3))
|
n = eval(input())
print(("{}".format(int(n) ** 3)))
| 2 | 2 | 31 | 46 |
x = int(eval(input()))
print((x**3))
|
n = eval(input())
print(("{}".format(int(n) ** 3)))
| false | 0 |
[
"-x = int(eval(input()))",
"-print((x**3))",
"+n = eval(input())",
"+print((\"{}\".format(int(n) ** 3)))"
] | false | 0.046314 | 0.046713 | 0.991462 |
[
"s309875639",
"s941075251"
] |
u875291233
|
p03857
|
python
|
s851911857
|
s454042607
| 727 | 401 | 101,204 | 131,156 |
Accepted
|
Accepted
| 44.84 |
# coding: utf-8
# Your code here!
class UnionFind:
def __init__(self, n):
self.parent = list(range(n)) #親ノード
self.size = [1]*n #グループの要素数
def root(self, x): #root(x): xの根ノードを返す.
while self.parent[x] != x:
self.parent[x] = self.parent[self.parent[x]]
x = self.parent[x]
return x
def merge(self, x, y): #merge(x,y): xのいる組とyのいる組をまとめる
x, y = self.root(x), self.root(y)
if x == y: return False
if self.size[x] < self.size[y]: x,y=y,x #xの要素数が大きいように
self.size[x] += self.size[y] #xの要素数を更新
self.parent[y] = x #yをxにつなぐ
return True
def issame(self, x, y): #same(x,y): xとyが同じ組ならTrue
return self.root(x) == self.root(y)
def getsize(self,x): #size(x): xのいるグループの要素数を返す
return self.size[self.root(x)]
import sys
input = sys.stdin.readline
n,k,l = [int(i) for i in input().split()]
UF1 = UnionFind(n)
for _ in range(k):
p,q = [int(i)-1 for i in input().split()]
UF1.merge(p,q)
UF2 = UnionFind(n)
for _ in range(l):
p,q = [int(i)-1 for i in input().split()]
UF2.merge(p,q)
a = dict()
for i in range(n):
r1,r2 = UF1.root(i), UF2.root(i)
if (r1,r2) not in a:
a[(r1,r2)] = 1
else:
a[(r1,r2)] += 1
print((*[a[(UF1.root(i), UF2.root(i))] for i in range(n)]))
|
class UnionFind:
def __init__(self, n):
self.parent = list(range(n)) #親ノード
self.size = [1]*n #グループの要素数
def root(self, x): #root(x): xの根ノードを返す.
while self.parent[x] != x:
self.parent[x] = self.parent[self.parent[x]]
x = self.parent[x]
return x
def merge(self, x, y): #merge(x,y): xのいる組とyのいる組をまとめる
x, y = self.root(x), self.root(y)
if x == y: return False
if self.size[x] < self.size[y]: x,y=y,x #xの要素数が大きいように
self.size[x] += self.size[y] #xの要素数を更新
self.parent[y] = x #yをxにつなぐ
return True
def issame(self, x, y): #same(x,y): xとyが同じ組ならTrue
return self.root(x) == self.root(y)
def getsize(self,x): #size(x): xのいるグループの要素数を返す
return self.size[self.root(x)]
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
n,k,l = list(map(int,readline().split()))
UF1 = UnionFind(n)
UF2 = UnionFind(n)
for _ in range(k):
p,q = list(map(int,readline().split()))
UF1.merge(p-1,q-1)
for _ in range(l):
r,s = list(map(int,readline().split()))
UF2.merge(r-1,s-1)
from collections import Counter
d = Counter()
for i in range(n):
p1 = UF1.root(i)
p2 = UF2.root(i)
d[(p1,p2)] += 1
ans = [0]*n
for i in range(n):
p1 = UF1.root(i)
p2 = UF2.root(i)
ans[i] = d[(p1,p2)]
print((*ans))
| 53 | 58 | 1,394 | 1,438 |
# coding: utf-8
# Your code here!
class UnionFind:
def __init__(self, n):
self.parent = list(range(n)) # 親ノード
self.size = [1] * n # グループの要素数
def root(self, x): # root(x): xの根ノードを返す.
while self.parent[x] != x:
self.parent[x] = self.parent[self.parent[x]]
x = self.parent[x]
return x
def merge(self, x, y): # merge(x,y): xのいる組とyのいる組をまとめる
x, y = self.root(x), self.root(y)
if x == y:
return False
if self.size[x] < self.size[y]:
x, y = y, x # xの要素数が大きいように
self.size[x] += self.size[y] # xの要素数を更新
self.parent[y] = x # yをxにつなぐ
return True
def issame(self, x, y): # same(x,y): xとyが同じ組ならTrue
return self.root(x) == self.root(y)
def getsize(self, x): # size(x): xのいるグループの要素数を返す
return self.size[self.root(x)]
import sys
input = sys.stdin.readline
n, k, l = [int(i) for i in input().split()]
UF1 = UnionFind(n)
for _ in range(k):
p, q = [int(i) - 1 for i in input().split()]
UF1.merge(p, q)
UF2 = UnionFind(n)
for _ in range(l):
p, q = [int(i) - 1 for i in input().split()]
UF2.merge(p, q)
a = dict()
for i in range(n):
r1, r2 = UF1.root(i), UF2.root(i)
if (r1, r2) not in a:
a[(r1, r2)] = 1
else:
a[(r1, r2)] += 1
print((*[a[(UF1.root(i), UF2.root(i))] for i in range(n)]))
|
class UnionFind:
def __init__(self, n):
self.parent = list(range(n)) # 親ノード
self.size = [1] * n # グループの要素数
def root(self, x): # root(x): xの根ノードを返す.
while self.parent[x] != x:
self.parent[x] = self.parent[self.parent[x]]
x = self.parent[x]
return x
def merge(self, x, y): # merge(x,y): xのいる組とyのいる組をまとめる
x, y = self.root(x), self.root(y)
if x == y:
return False
if self.size[x] < self.size[y]:
x, y = y, x # xの要素数が大きいように
self.size[x] += self.size[y] # xの要素数を更新
self.parent[y] = x # yをxにつなぐ
return True
def issame(self, x, y): # same(x,y): xとyが同じ組ならTrue
return self.root(x) == self.root(y)
def getsize(self, x): # size(x): xのいるグループの要素数を返す
return self.size[self.root(x)]
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
n, k, l = list(map(int, readline().split()))
UF1 = UnionFind(n)
UF2 = UnionFind(n)
for _ in range(k):
p, q = list(map(int, readline().split()))
UF1.merge(p - 1, q - 1)
for _ in range(l):
r, s = list(map(int, readline().split()))
UF2.merge(r - 1, s - 1)
from collections import Counter
d = Counter()
for i in range(n):
p1 = UF1.root(i)
p2 = UF2.root(i)
d[(p1, p2)] += 1
ans = [0] * n
for i in range(n):
p1 = UF1.root(i)
p2 = UF2.root(i)
ans[i] = d[(p1, p2)]
print((*ans))
| false | 8.62069 |
[
"-# coding: utf-8",
"-# Your code here!",
"+# coding: utf-8",
"+# Your code here!",
"-input = sys.stdin.readline",
"-n, k, l = [int(i) for i in input().split()]",
"+read = sys.stdin.read",
"+readline = sys.stdin.readline",
"+n, k, l = list(map(int, readline().split()))",
"+UF2 = UnionFind(n)",
"- p, q = [int(i) - 1 for i in input().split()]",
"- UF1.merge(p, q)",
"-UF2 = UnionFind(n)",
"+ p, q = list(map(int, readline().split()))",
"+ UF1.merge(p - 1, q - 1)",
"- p, q = [int(i) - 1 for i in input().split()]",
"- UF2.merge(p, q)",
"-a = dict()",
"+ r, s = list(map(int, readline().split()))",
"+ UF2.merge(r - 1, s - 1)",
"+from collections import Counter",
"+",
"+d = Counter()",
"- r1, r2 = UF1.root(i), UF2.root(i)",
"- if (r1, r2) not in a:",
"- a[(r1, r2)] = 1",
"- else:",
"- a[(r1, r2)] += 1",
"-print((*[a[(UF1.root(i), UF2.root(i))] for i in range(n)]))",
"+ p1 = UF1.root(i)",
"+ p2 = UF2.root(i)",
"+ d[(p1, p2)] += 1",
"+ans = [0] * n",
"+for i in range(n):",
"+ p1 = UF1.root(i)",
"+ p2 = UF2.root(i)",
"+ ans[i] = d[(p1, p2)]",
"+print((*ans))"
] | false | 0.037657 | 0.037293 | 1.009765 |
[
"s851911857",
"s454042607"
] |
u506858457
|
p02689
|
python
|
s289273879
|
s460771955
| 402 | 351 | 31,636 | 30,240 |
Accepted
|
Accepted
| 12.69 |
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))
N,M=MI()
Ten=[1 for _ in range(N)]
Michi=[[] for _ in range(N)]
H=LI()
for i in range(M):
a,b=MI()
a-=1
b-=1
Michi[a].append(b)
Michi[b].append(a)
for i in range(N):
for j in Michi[i]:
if H[i]<=H[j]:
Ten[i]=0
break
ans=sum(Ten)
print(ans)
|
def II(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))
N,M=MI()
H=LI()
ans=0
Michi=[[] for i in range(N)]
Ten=[1] *N
for i in range(M):
a,b=MI()
a-=1
b-=1
Michi[a].append(b)
Michi[b].append(a)
for j in range(N):
for k in Michi[j]:
if H[k]>=H[j]:
Ten[j]=0
break
ans=sum(Ten)
print(ans)
| 19 | 22 | 378 | 403 |
def MI():
return list(map(int, input().split()))
def LI():
return list(map(int, input().split()))
N, M = MI()
Ten = [1 for _ in range(N)]
Michi = [[] for _ in range(N)]
H = LI()
for i in range(M):
a, b = MI()
a -= 1
b -= 1
Michi[a].append(b)
Michi[b].append(a)
for i in range(N):
for j in Michi[i]:
if H[i] <= H[j]:
Ten[i] = 0
break
ans = sum(Ten)
print(ans)
|
def II():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def LI():
return list(map(int, input().split()))
N, M = MI()
H = LI()
ans = 0
Michi = [[] for i in range(N)]
Ten = [1] * N
for i in range(M):
a, b = MI()
a -= 1
b -= 1
Michi[a].append(b)
Michi[b].append(a)
for j in range(N):
for k in Michi[j]:
if H[k] >= H[j]:
Ten[j] = 0
break
ans = sum(Ten)
print(ans)
| false | 13.636364 |
[
"+def II():",
"+ return int(eval(input()))",
"+",
"+",
"-Ten = [1 for _ in range(N)]",
"-Michi = [[] for _ in range(N)]",
"+ans = 0",
"+Michi = [[] for i in range(N)]",
"+Ten = [1] * N",
"-for i in range(N):",
"- for j in Michi[i]:",
"- if H[i] <= H[j]:",
"- Ten[i] = 0",
"+for j in range(N):",
"+ for k in Michi[j]:",
"+ if H[k] >= H[j]:",
"+ Ten[j] = 0"
] | false | 0.033192 | 0.033786 | 0.982406 |
[
"s289273879",
"s460771955"
] |
u859897687
|
p03000
|
python
|
s278869029
|
s433514861
| 180 | 17 | 38,384 | 3,060 |
Accepted
|
Accepted
| 90.56 |
n,x=list(map(int,input().split()))
l=list(map(int,input().split()))
m=[0]
ans=1
for i in range(n):
m+=[m[i]+l[i]]
if m[i]+l[i]<=x:
ans+=1
print(ans)
|
n,x=list(map(int,input().split()))
l=list(map(int,input().split()))
ans=1
d=0
for i in range(n):
d+=l[i]
if d<=x:
ans+=1
print(ans)
| 9 | 9 | 158 | 141 |
n, x = list(map(int, input().split()))
l = list(map(int, input().split()))
m = [0]
ans = 1
for i in range(n):
m += [m[i] + l[i]]
if m[i] + l[i] <= x:
ans += 1
print(ans)
|
n, x = list(map(int, input().split()))
l = list(map(int, input().split()))
ans = 1
d = 0
for i in range(n):
d += l[i]
if d <= x:
ans += 1
print(ans)
| false | 0 |
[
"-m = [0]",
"+d = 0",
"- m += [m[i] + l[i]]",
"- if m[i] + l[i] <= x:",
"+ d += l[i]",
"+ if d <= x:"
] | false | 0.047569 | 0.091494 | 0.519907 |
[
"s278869029",
"s433514861"
] |
u454557108
|
p02690
|
python
|
s359852925
|
s699454623
| 160 | 71 | 67,808 | 67,448 |
Accepted
|
Accepted
| 55.62 |
x = int(eval(input()))
for i in range(-4000,4000) :
flag = 0
for j in range(-4000,i) :
if x%(i-j) != 0 :
continue
v = x//(i-j)
c = i**4+j**4+i*j*(i**2+i*j+j**2)
if v == c :
print((i,j))
flag = 1
break
if flag == 1 :
break
|
x = int(eval(input()))
for i in range(-1000,1000) :
flag = 0
for j in range(-1000,i) :
if x%(i-j) != 0 :
continue
v = x//(i-j)
c = i**4+j**4+i*j*(i**2+i*j+j**2)
if v == c :
print((i,j))
flag = 1
break
if flag == 1 :
break
| 15 | 15 | 328 | 328 |
x = int(eval(input()))
for i in range(-4000, 4000):
flag = 0
for j in range(-4000, i):
if x % (i - j) != 0:
continue
v = x // (i - j)
c = i**4 + j**4 + i * j * (i**2 + i * j + j**2)
if v == c:
print((i, j))
flag = 1
break
if flag == 1:
break
|
x = int(eval(input()))
for i in range(-1000, 1000):
flag = 0
for j in range(-1000, i):
if x % (i - j) != 0:
continue
v = x // (i - j)
c = i**4 + j**4 + i * j * (i**2 + i * j + j**2)
if v == c:
print((i, j))
flag = 1
break
if flag == 1:
break
| false | 0 |
[
"-for i in range(-4000, 4000):",
"+for i in range(-1000, 1000):",
"- for j in range(-4000, i):",
"+ for j in range(-1000, i):"
] | false | 2.116106 | 0.262995 | 8.046179 |
[
"s359852925",
"s699454623"
] |
u600402037
|
p02838
|
python
|
s367198627
|
s790985805
| 620 | 329 | 124,568 | 48,784 |
Accepted
|
Accepted
| 46.94 |
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
MOD = 10 ** 9 + 7
N = ir()
A = lr()
bit = [0 for _ in range(60)]
for a in A:
for i in range(a.bit_length()):
if (a >> i) & 1:
bit[i] += 1
answer = 0
for i, x in enumerate(bit):
answer += x * (N-x) * 2 ** i
print((answer%MOD))
# 22
|
import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
MOD = 10 ** 9 + 7
N = ir()
A = np.array(lr(), np.int64)
answer = 0
limit = int(A.max()).bit_length()
for i in range(limit):
B = (A >> i) & 1
x = np.count_nonzero(B)
y = N - x
add = (x*y) * 2 ** i % MOD
answer += add
print((answer%MOD))
| 21 | 20 | 399 | 414 |
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
MOD = 10**9 + 7
N = ir()
A = lr()
bit = [0 for _ in range(60)]
for a in A:
for i in range(a.bit_length()):
if (a >> i) & 1:
bit[i] += 1
answer = 0
for i, x in enumerate(bit):
answer += x * (N - x) * 2**i
print((answer % MOD))
# 22
|
import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
MOD = 10**9 + 7
N = ir()
A = np.array(lr(), np.int64)
answer = 0
limit = int(A.max()).bit_length()
for i in range(limit):
B = (A >> i) & 1
x = np.count_nonzero(B)
y = N - x
add = (x * y) * 2**i % MOD
answer += add
print((answer % MOD))
| false | 4.761905 |
[
"+import numpy as np",
"-A = lr()",
"-bit = [0 for _ in range(60)]",
"-for a in A:",
"- for i in range(a.bit_length()):",
"- if (a >> i) & 1:",
"- bit[i] += 1",
"+A = np.array(lr(), np.int64)",
"-for i, x in enumerate(bit):",
"- answer += x * (N - x) * 2**i",
"+limit = int(A.max()).bit_length()",
"+for i in range(limit):",
"+ B = (A >> i) & 1",
"+ x = np.count_nonzero(B)",
"+ y = N - x",
"+ add = (x * y) * 2**i % MOD",
"+ answer += add",
"-# 22"
] | false | 0.044001 | 0.285064 | 0.154354 |
[
"s367198627",
"s790985805"
] |
u296518383
|
p02850
|
python
|
s498556046
|
s557757074
| 777 | 423 | 85,976 | 80,348 |
Accepted
|
Accepted
| 45.56 |
N = int(eval(input()))
AB = [list(map(int, input().split())) for _ in range(N - 1)]
graph = [[] for _ in range(N + 1)]
for a, b in AB:
graph[a].append(b)
graph[b].append(a)
#print("graph:", graph)
order = []
stack = [1]
parent = [0] * (N + 1)
while stack:
s = stack.pop()
order.append(s)
for g in graph[s]:
if parent[s] == g:
continue
else:
parent[g] = s
stack.append(g)
#print("order:", order)
#print("parent:", parent)
color = [-1] * (N + 1)
for e in order:
ng = color[e]
c = 1
for g in graph[e]:
if parent[e] == g:
continue
if c == ng:
c += 1
color[g] = c
c += 1
#print("color:", color)
print((max(color[2:])))
for a, b in AB:
if parent[a] == b:
print((color[a]))
else:
print((color[b]))
|
import sys
input = sys.stdin.buffer.readline
N = int(eval(input()))
AB = [list(map(int, input().split())) for _ in range(N - 1)]
graph = [[] for _ in range(N + 1)]
for a, b in AB:
graph[a].append(b)
graph[b].append(a)
def make_tree(graph, root) -> (list, list, list):
INF = 10 ** 15
dist = [INF] * len(graph)
parent = [-1] * len(graph)
stack = [root]
dist[root] = 0
order = []
parent[root] = root
while stack:
s = stack.pop()
order.append(s)
for g in graph[s]:
if dist[g] > dist[s] + 1:
dist[g] = dist[s] + 1
parent[g] = s
stack.append(g)
return dist, parent, order
dist, parent, order = make_tree(graph, 1)
color = [-1] * (N + 1)
for s in order:
ng = color[s]
c = 1
for g in graph[s]:
if parent[s] == g:
continue
if c == ng:
c += 1
color[g] = c
c += 1
answer = []
for a, b in AB:
if parent[a] == b:
answer.append(color[a])
else:
answer.append(color[b])
print((max(answer)))
for a in answer:
print(a)
| 45 | 53 | 810 | 1,181 |
N = int(eval(input()))
AB = [list(map(int, input().split())) for _ in range(N - 1)]
graph = [[] for _ in range(N + 1)]
for a, b in AB:
graph[a].append(b)
graph[b].append(a)
# print("graph:", graph)
order = []
stack = [1]
parent = [0] * (N + 1)
while stack:
s = stack.pop()
order.append(s)
for g in graph[s]:
if parent[s] == g:
continue
else:
parent[g] = s
stack.append(g)
# print("order:", order)
# print("parent:", parent)
color = [-1] * (N + 1)
for e in order:
ng = color[e]
c = 1
for g in graph[e]:
if parent[e] == g:
continue
if c == ng:
c += 1
color[g] = c
c += 1
# print("color:", color)
print((max(color[2:])))
for a, b in AB:
if parent[a] == b:
print((color[a]))
else:
print((color[b]))
|
import sys
input = sys.stdin.buffer.readline
N = int(eval(input()))
AB = [list(map(int, input().split())) for _ in range(N - 1)]
graph = [[] for _ in range(N + 1)]
for a, b in AB:
graph[a].append(b)
graph[b].append(a)
def make_tree(graph, root) -> (list, list, list):
INF = 10**15
dist = [INF] * len(graph)
parent = [-1] * len(graph)
stack = [root]
dist[root] = 0
order = []
parent[root] = root
while stack:
s = stack.pop()
order.append(s)
for g in graph[s]:
if dist[g] > dist[s] + 1:
dist[g] = dist[s] + 1
parent[g] = s
stack.append(g)
return dist, parent, order
dist, parent, order = make_tree(graph, 1)
color = [-1] * (N + 1)
for s in order:
ng = color[s]
c = 1
for g in graph[s]:
if parent[s] == g:
continue
if c == ng:
c += 1
color[g] = c
c += 1
answer = []
for a, b in AB:
if parent[a] == b:
answer.append(color[a])
else:
answer.append(color[b])
print((max(answer)))
for a in answer:
print(a)
| false | 15.09434 |
[
"+import sys",
"+",
"+input = sys.stdin.buffer.readline",
"-# print(\"graph:\", graph)",
"-order = []",
"-stack = [1]",
"-parent = [0] * (N + 1)",
"-while stack:",
"- s = stack.pop()",
"- order.append(s)",
"+",
"+",
"+def make_tree(graph, root) -> (list, list, list):",
"+ INF = 10**15",
"+ dist = [INF] * len(graph)",
"+ parent = [-1] * len(graph)",
"+ stack = [root]",
"+ dist[root] = 0",
"+ order = []",
"+ parent[root] = root",
"+ while stack:",
"+ s = stack.pop()",
"+ order.append(s)",
"+ for g in graph[s]:",
"+ if dist[g] > dist[s] + 1:",
"+ dist[g] = dist[s] + 1",
"+ parent[g] = s",
"+ stack.append(g)",
"+ return dist, parent, order",
"+",
"+",
"+dist, parent, order = make_tree(graph, 1)",
"+color = [-1] * (N + 1)",
"+for s in order:",
"+ ng = color[s]",
"+ c = 1",
"- continue",
"- else:",
"- parent[g] = s",
"- stack.append(g)",
"-# print(\"order:\", order)",
"-# print(\"parent:\", parent)",
"-color = [-1] * (N + 1)",
"-for e in order:",
"- ng = color[e]",
"- c = 1",
"- for g in graph[e]:",
"- if parent[e] == g:",
"-# print(\"color:\", color)",
"-print((max(color[2:])))",
"+answer = []",
"- print((color[a]))",
"+ answer.append(color[a])",
"- print((color[b]))",
"+ answer.append(color[b])",
"+print((max(answer)))",
"+for a in answer:",
"+ print(a)"
] | false | 0.065375 | 0.006579 | 9.937453 |
[
"s498556046",
"s557757074"
] |
u595289165
|
p02973
|
python
|
s779804047
|
s416042011
| 263 | 206 | 8,828 | 12,664 |
Accepted
|
Accepted
| 21.67 |
from collections import deque
from bisect import bisect_left
n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
ans = deque([a[0]])
for a_i in a[1:]:
if ans[0] < a_i:
i = bisect_left(ans, a_i)
ans[i-1] = a_i
else:
ans.appendleft(a_i)
print((len(ans)))
|
from bisect import bisect_right
n = int(eval(input()))
color = [0] * (n+1)
for i in range(n):
a = int(eval(input()))
j = bisect_right(color, a)
color[j-1] = a+1
ans = 0
for t in color:
if t != 0:
ans += 1
print(ans)
| 15 | 16 | 302 | 247 |
from collections import deque
from bisect import bisect_left
n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
ans = deque([a[0]])
for a_i in a[1:]:
if ans[0] < a_i:
i = bisect_left(ans, a_i)
ans[i - 1] = a_i
else:
ans.appendleft(a_i)
print((len(ans)))
|
from bisect import bisect_right
n = int(eval(input()))
color = [0] * (n + 1)
for i in range(n):
a = int(eval(input()))
j = bisect_right(color, a)
color[j - 1] = a + 1
ans = 0
for t in color:
if t != 0:
ans += 1
print(ans)
| false | 6.25 |
[
"-from collections import deque",
"-from bisect import bisect_left",
"+from bisect import bisect_right",
"-a = [int(eval(input())) for _ in range(n)]",
"-ans = deque([a[0]])",
"-for a_i in a[1:]:",
"- if ans[0] < a_i:",
"- i = bisect_left(ans, a_i)",
"- ans[i - 1] = a_i",
"- else:",
"- ans.appendleft(a_i)",
"-print((len(ans)))",
"+color = [0] * (n + 1)",
"+for i in range(n):",
"+ a = int(eval(input()))",
"+ j = bisect_right(color, a)",
"+ color[j - 1] = a + 1",
"+ans = 0",
"+for t in color:",
"+ if t != 0:",
"+ ans += 1",
"+print(ans)"
] | false | 0.049974 | 0.045399 | 1.10076 |
[
"s779804047",
"s416042011"
] |
u489959379
|
p03372
|
python
|
s337543624
|
s023532801
| 1,285 | 236 | 41,484 | 39,672 |
Accepted
|
Accepted
| 81.63 |
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
class SegTree:
"""
init(init_val, ide_ele): 配列init_valで初期化 O(N)
update(k, x): k番目の値をxに更新 O(N)
query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
"""
def __init__(self, init_val, segfunc, ide_ele):
"""
init_val: 配列の初期値
segfunc: 区間にしたい操作
ide_ele: 単位元
n: 要素数
num: n以上の最小の2のべき乗
tree: セグメント木(1-index)
"""
n = len(init_val)
self.segfunc = segfunc
self.ide_ele = ide_ele
self.num = 1 << (n - 1).bit_length()
self.tree = [ide_ele] * 2 * self.num
# 配列の値を葉にセット
for i in range(n):
self.tree[self.num + i] = init_val[i]
# 構築していく
for i in range(self.num - 1, 0, -1):
self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])
def update(self, k, x):
"""
k番目の値をxに更新
k: index(0-index)
x: update value
"""
k += self.num
self.tree[k] = x
while k > 1:
self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
k >>= 1
def query(self, left, right):
"""
[left, right)のsegfuncしたものを得る
left: index(0-index)
right: index(0-index)
"""
res = self.ide_ele
left += self.num
right += self.num
while left < right:
if left & 1:
res = self.segfunc(res, self.tree[left])
left += 1
if right & 1:
res = self.segfunc(res, self.tree[right - 1])
left >>= 1
right >>= 1
return res
def resolve():
n, c = list(map(int, input().split()))
XY = [list(map(int, input().split())) for _ in range(n)]
R1 = [0]
prev = 0
for x, y in XY:
R1.append(R1[-1] + y - (x - prev))
prev = x
R2 = [0]
prev = 0
for x, y in XY[::-1]:
R2.append(R2[-1] + y - ((c - x) - prev))
prev = (c - x)
res = max(max(R1), max(R2))
seg1 = SegTree(R2, lambda x, y: max(x, y), 0)
for i in range(1, n + 1):
point1 = R1[i] - XY[i - 1][0]
point2 = seg1.query(0, n + 1 - i)
res = max(res, point1 + point2)
seg2 = SegTree(R1, lambda x, y: max(x, y), 0)
for i in range(1, n + 1):
point1 = R2[i] - (c - XY[-i][0])
point2 = seg2.query(0, n + 1 - i)
res = max(res, point1 + point2)
print(res)
if __name__ == '__main__':
resolve()
|
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n, c = list(map(int, input().split()))
XY = [list(map(int, input().split())) for _ in range(n)]
R1, R2 = [0], [0]
max1, max2 = [0], [0]
ma = 0
prev = 0
for x, y in XY:
R1.append(R1[-1] + y - (x - prev))
prev = x
if ma < R1[-1]:
ma = R1[-1]
max1.append(ma)
ma = 0
prev = 0
for x, y in XY[::-1]:
R2.append(R2[-1] + y - ((c - x) - prev))
prev = (c - x)
if ma < R2[-1]:
ma = R2[-1]
max2.append(ma)
res = max(max(R1), max(R2))
for i in range(1, n + 1):
point1 = R1[i] - XY[i - 1][0] + max2[n - i]
point2 = R2[i] - (c - XY[-i][0]) + max1[n - i]
res = max(res, point1, point2)
print(res)
if __name__ == '__main__':
resolve()
| 98 | 41 | 2,658 | 950 |
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
f_inf = float("inf")
mod = 10**9 + 7
class SegTree:
"""
init(init_val, ide_ele): 配列init_valで初期化 O(N)
update(k, x): k番目の値をxに更新 O(N)
query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
"""
def __init__(self, init_val, segfunc, ide_ele):
"""
init_val: 配列の初期値
segfunc: 区間にしたい操作
ide_ele: 単位元
n: 要素数
num: n以上の最小の2のべき乗
tree: セグメント木(1-index)
"""
n = len(init_val)
self.segfunc = segfunc
self.ide_ele = ide_ele
self.num = 1 << (n - 1).bit_length()
self.tree = [ide_ele] * 2 * self.num
# 配列の値を葉にセット
for i in range(n):
self.tree[self.num + i] = init_val[i]
# 構築していく
for i in range(self.num - 1, 0, -1):
self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])
def update(self, k, x):
"""
k番目の値をxに更新
k: index(0-index)
x: update value
"""
k += self.num
self.tree[k] = x
while k > 1:
self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
k >>= 1
def query(self, left, right):
"""
[left, right)のsegfuncしたものを得る
left: index(0-index)
right: index(0-index)
"""
res = self.ide_ele
left += self.num
right += self.num
while left < right:
if left & 1:
res = self.segfunc(res, self.tree[left])
left += 1
if right & 1:
res = self.segfunc(res, self.tree[right - 1])
left >>= 1
right >>= 1
return res
def resolve():
n, c = list(map(int, input().split()))
XY = [list(map(int, input().split())) for _ in range(n)]
R1 = [0]
prev = 0
for x, y in XY:
R1.append(R1[-1] + y - (x - prev))
prev = x
R2 = [0]
prev = 0
for x, y in XY[::-1]:
R2.append(R2[-1] + y - ((c - x) - prev))
prev = c - x
res = max(max(R1), max(R2))
seg1 = SegTree(R2, lambda x, y: max(x, y), 0)
for i in range(1, n + 1):
point1 = R1[i] - XY[i - 1][0]
point2 = seg1.query(0, n + 1 - i)
res = max(res, point1 + point2)
seg2 = SegTree(R1, lambda x, y: max(x, y), 0)
for i in range(1, n + 1):
point1 = R2[i] - (c - XY[-i][0])
point2 = seg2.query(0, n + 1 - i)
res = max(res, point1 + point2)
print(res)
if __name__ == "__main__":
resolve()
|
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
n, c = list(map(int, input().split()))
XY = [list(map(int, input().split())) for _ in range(n)]
R1, R2 = [0], [0]
max1, max2 = [0], [0]
ma = 0
prev = 0
for x, y in XY:
R1.append(R1[-1] + y - (x - prev))
prev = x
if ma < R1[-1]:
ma = R1[-1]
max1.append(ma)
ma = 0
prev = 0
for x, y in XY[::-1]:
R2.append(R2[-1] + y - ((c - x) - prev))
prev = c - x
if ma < R2[-1]:
ma = R2[-1]
max2.append(ma)
res = max(max(R1), max(R2))
for i in range(1, n + 1):
point1 = R1[i] - XY[i - 1][0] + max2[n - i]
point2 = R2[i] - (c - XY[-i][0]) + max1[n - i]
res = max(res, point1, point2)
print(res)
if __name__ == "__main__":
resolve()
| false | 58.163265 |
[
"-class SegTree:",
"- \"\"\"",
"- init(init_val, ide_ele): 配列init_valで初期化 O(N)",
"- update(k, x): k番目の値をxに更新 O(N)",
"- query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)",
"- \"\"\"",
"-",
"- def __init__(self, init_val, segfunc, ide_ele):",
"- \"\"\"",
"- init_val: 配列の初期値",
"- segfunc: 区間にしたい操作",
"- ide_ele: 単位元",
"- n: 要素数",
"- num: n以上の最小の2のべき乗",
"- tree: セグメント木(1-index)",
"- \"\"\"",
"- n = len(init_val)",
"- self.segfunc = segfunc",
"- self.ide_ele = ide_ele",
"- self.num = 1 << (n - 1).bit_length()",
"- self.tree = [ide_ele] * 2 * self.num",
"- # 配列の値を葉にセット",
"- for i in range(n):",
"- self.tree[self.num + i] = init_val[i]",
"- # 構築していく",
"- for i in range(self.num - 1, 0, -1):",
"- self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])",
"-",
"- def update(self, k, x):",
"- \"\"\"",
"- k番目の値をxに更新",
"- k: index(0-index)",
"- x: update value",
"- \"\"\"",
"- k += self.num",
"- self.tree[k] = x",
"- while k > 1:",
"- self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])",
"- k >>= 1",
"-",
"- def query(self, left, right):",
"- \"\"\"",
"- [left, right)のsegfuncしたものを得る",
"- left: index(0-index)",
"- right: index(0-index)",
"- \"\"\"",
"- res = self.ide_ele",
"- left += self.num",
"- right += self.num",
"- while left < right:",
"- if left & 1:",
"- res = self.segfunc(res, self.tree[left])",
"- left += 1",
"- if right & 1:",
"- res = self.segfunc(res, self.tree[right - 1])",
"- left >>= 1",
"- right >>= 1",
"- return res",
"-",
"-",
"- R1 = [0]",
"+ R1, R2 = [0], [0]",
"+ max1, max2 = [0], [0]",
"+ ma = 0",
"- R2 = [0]",
"+ if ma < R1[-1]:",
"+ ma = R1[-1]",
"+ max1.append(ma)",
"+ ma = 0",
"+ if ma < R2[-1]:",
"+ ma = R2[-1]",
"+ max2.append(ma)",
"- seg1 = SegTree(R2, lambda x, y: max(x, y), 0)",
"- point1 = R1[i] - XY[i - 1][0]",
"- point2 = seg1.query(0, n + 1 - i)",
"- res = max(res, point1 + point2)",
"- seg2 = SegTree(R1, lambda x, y: max(x, y), 0)",
"- for i in range(1, n + 1):",
"- point1 = R2[i] - (c - XY[-i][0])",
"- point2 = seg2.query(0, n + 1 - i)",
"- res = max(res, point1 + point2)",
"+ point1 = R1[i] - XY[i - 1][0] + max2[n - i]",
"+ point2 = R2[i] - (c - XY[-i][0]) + max1[n - i]",
"+ res = max(res, point1, point2)"
] | false | 0.068071 | 0.089813 | 0.757915 |
[
"s337543624",
"s023532801"
] |
u416011173
|
p02548
|
python
|
s321262498
|
s978800190
| 248 | 185 | 9,148 | 9,184 |
Accepted
|
Accepted
| 25.4 |
# -*- coding: utf-8 -*-
# モジュールのインポート
import math
# 標準入力を取得
N = int(eval(input()))
# 求解処理
ans = 0
for a in range(1, N):
ans += math.ceil(N / a) - 1
# 結果出力
print(ans)
|
# -*- coding: utf-8 -*-
# モジュールのインポート
import math
def get_input() -> int:
"""
標準入力を取得する.
Returns:\n
int: 標準入力
"""
N = int(eval(input()))
return N
def main(N: int) -> None:
"""
メイン処理.
Args:\n
N (int): 正整数(2 <= N <= 10**6)
"""
# 求解処理
ans = 0
for a in range(1, N):
ans += math.floor((N - 1) / a)
# 結果出力
print(ans)
if __name__ == "__main__":
# 標準入力を取得
N = get_input()
# メイン処理
main(N)
| 14 | 39 | 180 | 523 |
# -*- coding: utf-8 -*-
# モジュールのインポート
import math
# 標準入力を取得
N = int(eval(input()))
# 求解処理
ans = 0
for a in range(1, N):
ans += math.ceil(N / a) - 1
# 結果出力
print(ans)
|
# -*- coding: utf-8 -*-
# モジュールのインポート
import math
def get_input() -> int:
"""
標準入力を取得する.
Returns:\n
int: 標準入力
"""
N = int(eval(input()))
return N
def main(N: int) -> None:
"""
メイン処理.
Args:\n
N (int): 正整数(2 <= N <= 10**6)
"""
# 求解処理
ans = 0
for a in range(1, N):
ans += math.floor((N - 1) / a)
# 結果出力
print(ans)
if __name__ == "__main__":
# 標準入力を取得
N = get_input()
# メイン処理
main(N)
| false | 64.102564 |
[
"-# 標準入力を取得",
"-N = int(eval(input()))",
"-# 求解処理",
"-ans = 0",
"-for a in range(1, N):",
"- ans += math.ceil(N / a) - 1",
"-# 結果出力",
"-print(ans)",
"+",
"+def get_input() -> int:",
"+ \"\"\"",
"+ 標準入力を取得する.",
"+ Returns:\\n",
"+ int: 標準入力",
"+ \"\"\"",
"+ N = int(eval(input()))",
"+ return N",
"+",
"+",
"+def main(N: int) -> None:",
"+ \"\"\"",
"+ メイン処理.",
"+ Args:\\n",
"+ N (int): 正整数(2 <= N <= 10**6)",
"+ \"\"\"",
"+ # 求解処理",
"+ ans = 0",
"+ for a in range(1, N):",
"+ ans += math.floor((N - 1) / a)",
"+ # 結果出力",
"+ print(ans)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ # 標準入力を取得",
"+ N = get_input()",
"+ # メイン処理",
"+ main(N)"
] | false | 0.316575 | 0.158123 | 2.002084 |
[
"s321262498",
"s978800190"
] |
u906428167
|
p03682
|
python
|
s499967305
|
s765540655
| 1,879 | 1,509 | 124,192 | 123,224 |
Accepted
|
Accepted
| 19.69 |
import sys
input = sys.stdin.readline
from heapq import heappop,heappush
n = int(eval(input()))
p = []
for i in range(n):
x,y = list(map(int,input().split()))
p.append((i,x,y))
e = [[] for _ in range(n)]
p = sorted(p,key=lambda x:x[1])
n0,x0,y0 = p[0]
for i in range(n-1):
n1,x1,y1 = p[i+1]
e[n0].append([min(abs(x1-x0),abs(y1-y0)),n1])
e[n1].append([min(abs(x1-x0),abs(y1-y0)),n0])
n0,x0,y0 = n1,x1,y1
p = sorted(p,key=lambda x:x[2])
n0,x0,y0 = p[0]
for i in range(n-1):
n1,x1,y1 = p[i+1]
e[n0].append([min(abs(x1-x0),abs(y1-y0)),n1])
e[n1].append([min(abs(x1-x0),abs(y1-y0)),n0])
n0,x0,y0 = n1,x1,y1
def Prim(n,edge):
#edge[source] = [[cost_1,target_1],[cost_2,target_2],...]
used = [False] * n
q = []
#e = [cost,target]
for e in edge[0]:
heappush(q,e)
used[0] = True
res = 0
while q:
c,v = heappop(q)
if used[v]:
continue
used[v] = True
for e in edge[v]:
if not used[e[1]]:
heappush(q,e)
res += c
return res
print((Prim(n,e)))
|
from heapq import heappop,heappush
n = int(eval(input()))
p = []
for i in range(n):
x,y = list(map(int,input().split()))
p.append((i,x,y))
e = [[] for _ in range(n)]
p = sorted(p,key=lambda x:x[1])
n0,x0,y0 = p[0]
for i in range(n-1):
n1,x1,y1 = p[i+1]
e[n0].append((min(abs(x1-x0),abs(y1-y0)),n1))
e[n1].append((min(abs(x1-x0),abs(y1-y0)),n0))
n0,x0,y0 = n1,x1,y1
p = sorted(p,key=lambda x:x[2])
n0,x0,y0 = p[0]
for i in range(n-1):
n1,x1,y1 = p[i+1]
e[n0].append((min(abs(x1-x0),abs(y1-y0)),n1))
e[n1].append((min(abs(x1-x0),abs(y1-y0)),n0))
n0,x0,y0 = n1,x1,y1
def Prim(n,edge):
#edge[source] = [(cost_1,target_1),(cost_2,target_2),...]
used = [False] * n
q = []
#e = [cost,target]
for e in edge[0]:
heappush(q,e)
used[0] = True
res = 0
while q:
c,v = heappop(q)
if used[v]:
continue
used[v] = True
for e in edge[v]:
if not used[e[1]]:
heappush(q,e)
res += c
return res
print((Prim(n,e)))
| 50 | 47 | 1,135 | 1,093 |
import sys
input = sys.stdin.readline
from heapq import heappop, heappush
n = int(eval(input()))
p = []
for i in range(n):
x, y = list(map(int, input().split()))
p.append((i, x, y))
e = [[] for _ in range(n)]
p = sorted(p, key=lambda x: x[1])
n0, x0, y0 = p[0]
for i in range(n - 1):
n1, x1, y1 = p[i + 1]
e[n0].append([min(abs(x1 - x0), abs(y1 - y0)), n1])
e[n1].append([min(abs(x1 - x0), abs(y1 - y0)), n0])
n0, x0, y0 = n1, x1, y1
p = sorted(p, key=lambda x: x[2])
n0, x0, y0 = p[0]
for i in range(n - 1):
n1, x1, y1 = p[i + 1]
e[n0].append([min(abs(x1 - x0), abs(y1 - y0)), n1])
e[n1].append([min(abs(x1 - x0), abs(y1 - y0)), n0])
n0, x0, y0 = n1, x1, y1
def Prim(n, edge):
# edge[source] = [[cost_1,target_1],[cost_2,target_2],...]
used = [False] * n
q = []
# e = [cost,target]
for e in edge[0]:
heappush(q, e)
used[0] = True
res = 0
while q:
c, v = heappop(q)
if used[v]:
continue
used[v] = True
for e in edge[v]:
if not used[e[1]]:
heappush(q, e)
res += c
return res
print((Prim(n, e)))
|
from heapq import heappop, heappush
n = int(eval(input()))
p = []
for i in range(n):
x, y = list(map(int, input().split()))
p.append((i, x, y))
e = [[] for _ in range(n)]
p = sorted(p, key=lambda x: x[1])
n0, x0, y0 = p[0]
for i in range(n - 1):
n1, x1, y1 = p[i + 1]
e[n0].append((min(abs(x1 - x0), abs(y1 - y0)), n1))
e[n1].append((min(abs(x1 - x0), abs(y1 - y0)), n0))
n0, x0, y0 = n1, x1, y1
p = sorted(p, key=lambda x: x[2])
n0, x0, y0 = p[0]
for i in range(n - 1):
n1, x1, y1 = p[i + 1]
e[n0].append((min(abs(x1 - x0), abs(y1 - y0)), n1))
e[n1].append((min(abs(x1 - x0), abs(y1 - y0)), n0))
n0, x0, y0 = n1, x1, y1
def Prim(n, edge):
# edge[source] = [(cost_1,target_1),(cost_2,target_2),...]
used = [False] * n
q = []
# e = [cost,target]
for e in edge[0]:
heappush(q, e)
used[0] = True
res = 0
while q:
c, v = heappop(q)
if used[v]:
continue
used[v] = True
for e in edge[v]:
if not used[e[1]]:
heappush(q, e)
res += c
return res
print((Prim(n, e)))
| false | 6 |
[
"-import sys",
"-",
"-input = sys.stdin.readline",
"- e[n0].append([min(abs(x1 - x0), abs(y1 - y0)), n1])",
"- e[n1].append([min(abs(x1 - x0), abs(y1 - y0)), n0])",
"+ e[n0].append((min(abs(x1 - x0), abs(y1 - y0)), n1))",
"+ e[n1].append((min(abs(x1 - x0), abs(y1 - y0)), n0))",
"- e[n0].append([min(abs(x1 - x0), abs(y1 - y0)), n1])",
"- e[n1].append([min(abs(x1 - x0), abs(y1 - y0)), n0])",
"+ e[n0].append((min(abs(x1 - x0), abs(y1 - y0)), n1))",
"+ e[n1].append((min(abs(x1 - x0), abs(y1 - y0)), n0))",
"- # edge[source] = [[cost_1,target_1],[cost_2,target_2],...]",
"+ # edge[source] = [(cost_1,target_1),(cost_2,target_2),...]"
] | false | 0.042328 | 0.231265 | 0.183029 |
[
"s499967305",
"s765540655"
] |
u423966555
|
p02574
|
python
|
s900229078
|
s635679548
| 638 | 556 | 127,784 | 127,744 |
Accepted
|
Accepted
| 12.85 |
from math import gcd
from functools import reduce
N = int(eval(input()))
A = list(map(int, input().split()))
M = 10**6+1
mp = [0]*M
for a in A:
mp[a] += 1
pairwise = 1
for i in range(2,M):
if sum(mp[i::i])>1:
pairwise = 0
break
if pairwise:
print('pairwise coprime')
elif reduce(gcd, A) == 1:
print('setwise coprime')
else:
print('not coprime')
|
from math import gcd
from functools import reduce
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
M = 10**6+1
mp = [0]*M
for a in A:
mp[a] += 1
pairwise = 1
for i in range(2,M):
if sum(mp[i::i])>1:
pairwise = 0
break
if pairwise:
print('pairwise coprime')
elif reduce(gcd, A) == 1:
print('setwise coprime')
else:
print('not coprime')
if __name__ == '__main__':
main()
| 24 | 26 | 403 | 522 |
from math import gcd
from functools import reduce
N = int(eval(input()))
A = list(map(int, input().split()))
M = 10**6 + 1
mp = [0] * M
for a in A:
mp[a] += 1
pairwise = 1
for i in range(2, M):
if sum(mp[i::i]) > 1:
pairwise = 0
break
if pairwise:
print("pairwise coprime")
elif reduce(gcd, A) == 1:
print("setwise coprime")
else:
print("not coprime")
|
from math import gcd
from functools import reduce
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
M = 10**6 + 1
mp = [0] * M
for a in A:
mp[a] += 1
pairwise = 1
for i in range(2, M):
if sum(mp[i::i]) > 1:
pairwise = 0
break
if pairwise:
print("pairwise coprime")
elif reduce(gcd, A) == 1:
print("setwise coprime")
else:
print("not coprime")
if __name__ == "__main__":
main()
| false | 7.692308 |
[
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-M = 10**6 + 1",
"-mp = [0] * M",
"-for a in A:",
"- mp[a] += 1",
"-pairwise = 1",
"-for i in range(2, M):",
"- if sum(mp[i::i]) > 1:",
"- pairwise = 0",
"- break",
"-if pairwise:",
"- print(\"pairwise coprime\")",
"-elif reduce(gcd, A) == 1:",
"- print(\"setwise coprime\")",
"-else:",
"- print(\"not coprime\")",
"+",
"+def main():",
"+ N = int(eval(input()))",
"+ A = list(map(int, input().split()))",
"+ M = 10**6 + 1",
"+ mp = [0] * M",
"+ for a in A:",
"+ mp[a] += 1",
"+ pairwise = 1",
"+ for i in range(2, M):",
"+ if sum(mp[i::i]) > 1:",
"+ pairwise = 0",
"+ break",
"+ if pairwise:",
"+ print(\"pairwise coprime\")",
"+ elif reduce(gcd, A) == 1:",
"+ print(\"setwise coprime\")",
"+ else:",
"+ print(\"not coprime\")",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.69423 | 0.007982 | 86.976058 |
[
"s900229078",
"s635679548"
] |
u133936772
|
p02623
|
python
|
s437308284
|
s326740848
| 263 | 242 | 48,444 | 48,368 |
Accepted
|
Accepted
| 7.98 |
import itertools as it, bisect as bs
f=lambda:list(map(int,input().split()))
g=lambda:[0]+[*it.accumulate(f())]
n,m,k=f()
A,B=g(),g()
a,j=0,m
for i in range(n+1):
t=bs.bisect(B,k-A[i])
if t: a=max(a,i+t-1)
print(a)
|
from itertools import *
f=lambda:list(map(int,input().split()))
g=lambda:[0]+[*accumulate(f())]
n,m,k=f()
A,B=g(),g()
c,j=0,m
for i,a in enumerate(A):
while j and a+B[j]>k: j-=1
if a+B[j]<=k: c=max(c,i+j)
print(c)
| 10 | 10 | 221 | 220 |
import itertools as it, bisect as bs
f = lambda: list(map(int, input().split()))
g = lambda: [0] + [*it.accumulate(f())]
n, m, k = f()
A, B = g(), g()
a, j = 0, m
for i in range(n + 1):
t = bs.bisect(B, k - A[i])
if t:
a = max(a, i + t - 1)
print(a)
|
from itertools import *
f = lambda: list(map(int, input().split()))
g = lambda: [0] + [*accumulate(f())]
n, m, k = f()
A, B = g(), g()
c, j = 0, m
for i, a in enumerate(A):
while j and a + B[j] > k:
j -= 1
if a + B[j] <= k:
c = max(c, i + j)
print(c)
| false | 0 |
[
"-import itertools as it, bisect as bs",
"+from itertools import *",
"-g = lambda: [0] + [*it.accumulate(f())]",
"+g = lambda: [0] + [*accumulate(f())]",
"-a, j = 0, m",
"-for i in range(n + 1):",
"- t = bs.bisect(B, k - A[i])",
"- if t:",
"- a = max(a, i + t - 1)",
"-print(a)",
"+c, j = 0, m",
"+for i, a in enumerate(A):",
"+ while j and a + B[j] > k:",
"+ j -= 1",
"+ if a + B[j] <= k:",
"+ c = max(c, i + j)",
"+print(c)"
] | false | 0.049464 | 0.04675 | 1.05805 |
[
"s437308284",
"s326740848"
] |
u970449052
|
p03043
|
python
|
s453327737
|
s543991552
| 40 | 32 | 3,060 | 3,060 |
Accepted
|
Accepted
| 20 |
n,k=list(map(int,input().split()))
ans=0
for i in range(1,n+1):
tmp=1/n
if i<k:
now=i
while now<k:
now*=2
tmp/=2
ans+=tmp
print(ans)
|
import math
n,k=list(map(int,input().split()))
ans=0
for i in range(1,n+1):
if i<k:
ans+=(0.5**math.ceil(math.log2(k/i)))/n
else:
ans+=1/n
print(ans)
| 11 | 9 | 188 | 175 |
n, k = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
tmp = 1 / n
if i < k:
now = i
while now < k:
now *= 2
tmp /= 2
ans += tmp
print(ans)
|
import math
n, k = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
if i < k:
ans += (0.5 ** math.ceil(math.log2(k / i))) / n
else:
ans += 1 / n
print(ans)
| false | 18.181818 |
[
"+import math",
"+",
"- tmp = 1 / n",
"- now = i",
"- while now < k:",
"- now *= 2",
"- tmp /= 2",
"- ans += tmp",
"+ ans += (0.5 ** math.ceil(math.log2(k / i))) / n",
"+ else:",
"+ ans += 1 / n"
] | false | 0.050317 | 0.050083 | 1.004677 |
[
"s453327737",
"s543991552"
] |
u075012704
|
p03732
|
python
|
s096093570
|
s145410736
| 273 | 220 | 3,188 | 42,860 |
Accepted
|
Accepted
| 19.41 |
from itertools import accumulate
N, W = list(map(int, input().split()))
w0, w1, w2, w3 = [], [], [], []
base_w = -1
for i in range(N):
w, v = list(map(int, input().split()))
if base_w < 0:
base_w = w
# 重みごとの箱にいれる
w -= base_w
if w == 0:
w0.append(v)
elif w == 1:
w1.append(v)
elif w == 2:
w2.append(v)
else:
w3.append(v)
# 降順ソート
w0.sort(reverse=True)
w1.sort(reverse=True)
w2.sort(reverse=True)
w3.sort(reverse=True)
# 累積和
w0 = [0] + list(accumulate(w0))
w1 = [0] + list(accumulate(w1))
w2 = [0] + list(accumulate(w2))
w3 = [0] + list(accumulate(w3))
ans = 0
for i0 in range(len(w0)):
for i1 in range(len(w1)):
for i2 in range(len(w2)):
for i3 in range(len(w3)):
if base_w * i0 + (base_w + 1) * i1 + (base_w + 2) * i2 + (base_w + 3) * i3 > W:
continue
ans = max(ans, w0[i0] + w1[i1] + w2[i2] + w3[i3])
print(ans)
|
from itertools import accumulate
N, W_limit = list(map(int, input().split()))
W, V = [], []
for i in range(N):
w, v = list(map(int, input().split()))
W.append(w)
V.append(v)
# 基準となるW
base_W = W[0]
# 0 ~ 3の範囲に調節
W = [w - base_W for w in W]
# 重みごとに商品を分ける
Items = [[] for i in range(4)]
for w, v in zip(W, V):
Items[w].append(v)
# 降順ソートして累積和を取っておく
Items = [[0] + sorted(x, reverse=True) for x in Items]
Items = [list(accumulate(x)) for x in Items]
# それぞれの重さから何個選ぶかで全探索
ans = 0
for w0 in range(len(Items[0])):
for w1 in range(len(Items[1])):
for w2 in range(len(Items[2])):
for w3 in range(len(Items[3])):
tmp_W = (w0 * base_W) + (w1 * (base_W + 1)) + (w2 * (base_W + 2)) + (w3 * (base_W + 3))
if tmp_W > W_limit:
continue
tmp_V = Items[0][w0] + Items[1][w1] + Items[2][w2] + Items[3][w3]
ans = max(ans, tmp_V)
print(ans)
| 42 | 35 | 994 | 969 |
from itertools import accumulate
N, W = list(map(int, input().split()))
w0, w1, w2, w3 = [], [], [], []
base_w = -1
for i in range(N):
w, v = list(map(int, input().split()))
if base_w < 0:
base_w = w
# 重みごとの箱にいれる
w -= base_w
if w == 0:
w0.append(v)
elif w == 1:
w1.append(v)
elif w == 2:
w2.append(v)
else:
w3.append(v)
# 降順ソート
w0.sort(reverse=True)
w1.sort(reverse=True)
w2.sort(reverse=True)
w3.sort(reverse=True)
# 累積和
w0 = [0] + list(accumulate(w0))
w1 = [0] + list(accumulate(w1))
w2 = [0] + list(accumulate(w2))
w3 = [0] + list(accumulate(w3))
ans = 0
for i0 in range(len(w0)):
for i1 in range(len(w1)):
for i2 in range(len(w2)):
for i3 in range(len(w3)):
if (
base_w * i0
+ (base_w + 1) * i1
+ (base_w + 2) * i2
+ (base_w + 3) * i3
> W
):
continue
ans = max(ans, w0[i0] + w1[i1] + w2[i2] + w3[i3])
print(ans)
|
from itertools import accumulate
N, W_limit = list(map(int, input().split()))
W, V = [], []
for i in range(N):
w, v = list(map(int, input().split()))
W.append(w)
V.append(v)
# 基準となるW
base_W = W[0]
# 0 ~ 3の範囲に調節
W = [w - base_W for w in W]
# 重みごとに商品を分ける
Items = [[] for i in range(4)]
for w, v in zip(W, V):
Items[w].append(v)
# 降順ソートして累積和を取っておく
Items = [[0] + sorted(x, reverse=True) for x in Items]
Items = [list(accumulate(x)) for x in Items]
# それぞれの重さから何個選ぶかで全探索
ans = 0
for w0 in range(len(Items[0])):
for w1 in range(len(Items[1])):
for w2 in range(len(Items[2])):
for w3 in range(len(Items[3])):
tmp_W = (
(w0 * base_W)
+ (w1 * (base_W + 1))
+ (w2 * (base_W + 2))
+ (w3 * (base_W + 3))
)
if tmp_W > W_limit:
continue
tmp_V = Items[0][w0] + Items[1][w1] + Items[2][w2] + Items[3][w3]
ans = max(ans, tmp_V)
print(ans)
| false | 16.666667 |
[
"-N, W = list(map(int, input().split()))",
"-w0, w1, w2, w3 = [], [], [], []",
"-base_w = -1",
"+N, W_limit = list(map(int, input().split()))",
"+W, V = [], []",
"- if base_w < 0:",
"- base_w = w",
"- # 重みごとの箱にいれる",
"- w -= base_w",
"- if w == 0:",
"- w0.append(v)",
"- elif w == 1:",
"- w1.append(v)",
"- elif w == 2:",
"- w2.append(v)",
"- else:",
"- w3.append(v)",
"-# 降順ソート",
"-w0.sort(reverse=True)",
"-w1.sort(reverse=True)",
"-w2.sort(reverse=True)",
"-w3.sort(reverse=True)",
"-# 累積和",
"-w0 = [0] + list(accumulate(w0))",
"-w1 = [0] + list(accumulate(w1))",
"-w2 = [0] + list(accumulate(w2))",
"-w3 = [0] + list(accumulate(w3))",
"+ W.append(w)",
"+ V.append(v)",
"+# 基準となるW",
"+base_W = W[0]",
"+# 0 ~ 3の範囲に調節",
"+W = [w - base_W for w in W]",
"+# 重みごとに商品を分ける",
"+Items = [[] for i in range(4)]",
"+for w, v in zip(W, V):",
"+ Items[w].append(v)",
"+# 降順ソートして累積和を取っておく",
"+Items = [[0] + sorted(x, reverse=True) for x in Items]",
"+Items = [list(accumulate(x)) for x in Items]",
"+# それぞれの重さから何個選ぶかで全探索",
"-for i0 in range(len(w0)):",
"- for i1 in range(len(w1)):",
"- for i2 in range(len(w2)):",
"- for i3 in range(len(w3)):",
"- if (",
"- base_w * i0",
"- + (base_w + 1) * i1",
"- + (base_w + 2) * i2",
"- + (base_w + 3) * i3",
"- > W",
"- ):",
"+for w0 in range(len(Items[0])):",
"+ for w1 in range(len(Items[1])):",
"+ for w2 in range(len(Items[2])):",
"+ for w3 in range(len(Items[3])):",
"+ tmp_W = (",
"+ (w0 * base_W)",
"+ + (w1 * (base_W + 1))",
"+ + (w2 * (base_W + 2))",
"+ + (w3 * (base_W + 3))",
"+ )",
"+ if tmp_W > W_limit:",
"- ans = max(ans, w0[i0] + w1[i1] + w2[i2] + w3[i3])",
"+ tmp_V = Items[0][w0] + Items[1][w1] + Items[2][w2] + Items[3][w3]",
"+ ans = max(ans, tmp_V)"
] | false | 0.040132 | 0.042547 | 0.943231 |
[
"s096093570",
"s145410736"
] |
u623819879
|
p03264
|
python
|
s974290369
|
s821225432
| 172 | 60 | 38,412 | 61,624 |
Accepted
|
Accepted
| 65.12 |
n=int(eval(input()))
print(((n//2)**2 if n%2==0 else (n//2)*(n//2+1)))
|
k=int(eval(input()));print((-~k//2*(k//2)))
| 2 | 1 | 63 | 35 |
n = int(eval(input()))
print(((n // 2) ** 2 if n % 2 == 0 else (n // 2) * (n // 2 + 1)))
|
k = int(eval(input()))
print((-~k // 2 * (k // 2)))
| false | 50 |
[
"-n = int(eval(input()))",
"-print(((n // 2) ** 2 if n % 2 == 0 else (n // 2) * (n // 2 + 1)))",
"+k = int(eval(input()))",
"+print((-~k // 2 * (k // 2)))"
] | false | 0.046448 | 0.036028 | 1.289217 |
[
"s974290369",
"s821225432"
] |
u379629675
|
p02850
|
python
|
s040534220
|
s399839466
| 689 | 434 | 79,388 | 74,272 |
Accepted
|
Accepted
| 37.01 |
# -*- coding: utf-8 -*-
import sys
import queue
input = sys.stdin.readline
def ii(): return int(input().rstrip())
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 exit(*arg): print(*arg); sys.exit()
# template
def main():
n = ii()
g = [[] for i in range(n)]
for i in range(n - 1):
a, b = mi()
g[a - 1].append((b - 1, i))
g[b - 1].append((a - 1, i))
color = max([len(g[i]) for i in range(n)])
print(color)
q = queue.Queue()
ans = [-1 for i in range(n - 1)]
idx = 0
q.put((0, 0))
while not q.empty():
t, idx = q.get()
for e in g[t]:
if ans[e[1]] != -1:
continue
idx += 1
ans[e[1]] = idx
q.put((e[0], idx))
print(*map(lambda x: x % color + 1, ans), sep="\n")
return
if __name__ == '__main__':
main()
|
# -*- coding: utf-8 -*-
import sys
import collections
input = sys.stdin.readline
def ii(): return int(input().rstrip())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def fi(): return float(input().rstrip())
def mfi(): return map(float, input().rstrip().split())
def lmfi(): return list(map(float, input().rstrip().split()))
def li(): return list(input().rstrip())
def exit(*arg): print(*arg); sys.exit()
# template
def main():
n = ii()
g = [[] for i in range(n)]
for i in range(n - 1):
a, b = mi()
g[a - 1].append((b - 1, i))
g[b - 1].append((a - 1, i))
color = max([len(g[i]) for i in range(n)])
print(color)
q = collections.deque()
ans = [-1 for i in range(n - 1)]
idx = 0
q.append((0, 0))
while len(q):
t, idx = q.popleft()
for e in g[t]:
if ans[e[1]] != -1:
continue
idx += 1
ans[e[1]] = idx
q.append((e[0], idx))
print(*map(lambda x: x % color + 1, ans), sep="\n")
return
if __name__ == '__main__':
main()
| 42 | 42 | 1,153 | 1,177 |
# -*- coding: utf-8 -*-
import sys
import queue
input = sys.stdin.readline
def ii():
return int(input().rstrip())
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 exit(*arg):
print(*arg)
sys.exit()
# template
def main():
n = ii()
g = [[] for i in range(n)]
for i in range(n - 1):
a, b = mi()
g[a - 1].append((b - 1, i))
g[b - 1].append((a - 1, i))
color = max([len(g[i]) for i in range(n)])
print(color)
q = queue.Queue()
ans = [-1 for i in range(n - 1)]
idx = 0
q.put((0, 0))
while not q.empty():
t, idx = q.get()
for e in g[t]:
if ans[e[1]] != -1:
continue
idx += 1
ans[e[1]] = idx
q.put((e[0], idx))
print(*map(lambda x: x % color + 1, ans), sep="\n")
return
if __name__ == "__main__":
main()
|
# -*- coding: utf-8 -*-
import sys
import collections
input = sys.stdin.readline
def ii():
return int(input().rstrip())
def mi():
return map(int, input().rstrip().split())
def lmi():
return list(map(int, input().rstrip().split()))
def fi():
return float(input().rstrip())
def mfi():
return map(float, input().rstrip().split())
def lmfi():
return list(map(float, input().rstrip().split()))
def li():
return list(input().rstrip())
def exit(*arg):
print(*arg)
sys.exit()
# template
def main():
n = ii()
g = [[] for i in range(n)]
for i in range(n - 1):
a, b = mi()
g[a - 1].append((b - 1, i))
g[b - 1].append((a - 1, i))
color = max([len(g[i]) for i in range(n)])
print(color)
q = collections.deque()
ans = [-1 for i in range(n - 1)]
idx = 0
q.append((0, 0))
while len(q):
t, idx = q.popleft()
for e in g[t]:
if ans[e[1]] != -1:
continue
idx += 1
ans[e[1]] = idx
q.append((e[0], idx))
print(*map(lambda x: x % color + 1, ans), sep="\n")
return
if __name__ == "__main__":
main()
| false | 0 |
[
"-import queue",
"+import collections",
"- return float(input())",
"+ return float(input().rstrip())",
"- q = queue.Queue()",
"+ q = collections.deque()",
"- q.put((0, 0))",
"- while not q.empty():",
"- t, idx = q.get()",
"+ q.append((0, 0))",
"+ while len(q):",
"+ t, idx = q.popleft()",
"- q.put((e[0], idx))",
"+ q.append((e[0], idx))"
] | false | 0.074393 | 0.041851 | 1.777568 |
[
"s040534220",
"s399839466"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.