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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u941438707
|
p03013
|
python
|
s171000119
|
s215061403
| 469
| 374
| 460,020
| 460,004
|
Accepted
|
Accepted
| 20.26
|
n,m,*a=list(map(int,open(0).read().split()))
d=[1]*(n+1)
for i in a:
d[i]=0
for i in range(2,n+1):
if d[i]!=0:
d[i]=d[i-1]+d[i-2]
print((d[-1]%(10**9+7)))
|
n,m,*a=list(map(int,open(0).read().split()))
dp=[-1]*(n+1)+[0]
for i in a:
dp[i]=0
dp[0]=1
for i in range(1,n+1):
if dp[i]==-1:
dp[i]=dp[i-1]+dp[i-2]
print((dp[-2]%1000000007))
| 8
| 9
| 169
| 192
|
n, m, *a = list(map(int, open(0).read().split()))
d = [1] * (n + 1)
for i in a:
d[i] = 0
for i in range(2, n + 1):
if d[i] != 0:
d[i] = d[i - 1] + d[i - 2]
print((d[-1] % (10**9 + 7)))
|
n, m, *a = list(map(int, open(0).read().split()))
dp = [-1] * (n + 1) + [0]
for i in a:
dp[i] = 0
dp[0] = 1
for i in range(1, n + 1):
if dp[i] == -1:
dp[i] = dp[i - 1] + dp[i - 2]
print((dp[-2] % 1000000007))
| false
| 11.111111
|
[
"-d = [1] * (n + 1)",
"+dp = [-1] * (n + 1) + [0]",
"- d[i] = 0",
"-for i in range(2, n + 1):",
"- if d[i] != 0:",
"- d[i] = d[i - 1] + d[i - 2]",
"-print((d[-1] % (10**9 + 7)))",
"+ dp[i] = 0",
"+dp[0] = 1",
"+for i in range(1, n + 1):",
"+ if dp[i] == -1:",
"+ dp[i] = dp[i - 1] + dp[i - 2]",
"+print((dp[-2] % 1000000007))"
] | false
| 0.036221
| 0.03984
| 0.909172
|
[
"s171000119",
"s215061403"
] |
u729133443
|
p02744
|
python
|
s524866083
|
s454457953
| 240
| 65
| 62,556
| 15,372
|
Accepted
|
Accepted
| 72.92
|
a='a'
exec('a=[s+chr(c)for s in a for c in range(97,ord(max(s))+2)];'*~-int(eval(input())))
print((*a))
|
def main():
a='a'
for _ in~-int(eval(input()))*a:
a=[s+chr(c)for s in a for c in range(97,ord(max(s))+2)]
print(('\n'.join(a)))
main()
| 3
| 6
| 97
| 141
|
a = "a"
exec("a=[s+chr(c)for s in a for c in range(97,ord(max(s))+2)];" * ~-int(eval(input())))
print((*a))
|
def main():
a = "a"
for _ in ~-int(eval(input())) * a:
a = [s + chr(c) for s in a for c in range(97, ord(max(s)) + 2)]
print(("\n".join(a)))
main()
| false
| 50
|
[
"-a = \"a\"",
"-exec(\"a=[s+chr(c)for s in a for c in range(97,ord(max(s))+2)];\" * ~-int(eval(input())))",
"-print((*a))",
"+def main():",
"+ a = \"a\"",
"+ for _ in ~-int(eval(input())) * a:",
"+ a = [s + chr(c) for s in a for c in range(97, ord(max(s)) + 2)]",
"+ print((\"\\n\".join(a)))",
"+",
"+",
"+main()"
] | false
| 0.039289
| 0.058756
| 0.668688
|
[
"s524866083",
"s454457953"
] |
u661290476
|
p00741
|
python
|
s413701833
|
s175815749
| 90
| 80
| 9,480
| 9,512
|
Accepted
|
Accepted
| 11.11
|
import sys
sys.setrecursionlimit(10**6)
def erase(x, y):
c[y][x] = '0'
for dx, dy in ((1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)):
nx, ny = x + dx, y + dy
if 0 <= nx <= w -1 and 0 <= ny <= h - 1:
if c[ny][nx] == '1':
erase(nx, ny)
while True:
w, h = list(map(int, input().split()))
if w == h == 0:
break
c = [[i for i in input().split()] for _ in range(h)]
ans = 0
for y in range(h):
for x in range(w):
if c[y][x] == '1':
ans += 1
erase(x, y)
print(ans)
|
import sys
sys.setrecursionlimit(10**5)
def erase(x, y):
c[y][x] = '0'
for dx, dy in ((1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)):
nx, ny = x + dx, y + dy
if 0 <= nx < w and 0 <= ny < h and c[ny][nx] == '1':
erase(nx, ny)
while True:
w, h = list(map(int, input().split()))
if w == h == 0:
break
c = [[i for i in input().split()] for _ in range(h)]
ans = 0
for y in range(h):
for x in range(w):
if c[y][x] == '1':
ans += 1
erase(x, y)
print(ans)
| 23
| 22
| 633
| 607
|
import sys
sys.setrecursionlimit(10**6)
def erase(x, y):
c[y][x] = "0"
for dx, dy in (
(1, 0),
(1, 1),
(0, 1),
(-1, 1),
(-1, 0),
(-1, -1),
(0, -1),
(1, -1),
):
nx, ny = x + dx, y + dy
if 0 <= nx <= w - 1 and 0 <= ny <= h - 1:
if c[ny][nx] == "1":
erase(nx, ny)
while True:
w, h = list(map(int, input().split()))
if w == h == 0:
break
c = [[i for i in input().split()] for _ in range(h)]
ans = 0
for y in range(h):
for x in range(w):
if c[y][x] == "1":
ans += 1
erase(x, y)
print(ans)
|
import sys
sys.setrecursionlimit(10**5)
def erase(x, y):
c[y][x] = "0"
for dx, dy in (
(1, 0),
(1, 1),
(0, 1),
(-1, 1),
(-1, 0),
(-1, -1),
(0, -1),
(1, -1),
):
nx, ny = x + dx, y + dy
if 0 <= nx < w and 0 <= ny < h and c[ny][nx] == "1":
erase(nx, ny)
while True:
w, h = list(map(int, input().split()))
if w == h == 0:
break
c = [[i for i in input().split()] for _ in range(h)]
ans = 0
for y in range(h):
for x in range(w):
if c[y][x] == "1":
ans += 1
erase(x, y)
print(ans)
| false
| 4.347826
|
[
"-sys.setrecursionlimit(10**6)",
"+sys.setrecursionlimit(10**5)",
"- if 0 <= nx <= w - 1 and 0 <= ny <= h - 1:",
"- if c[ny][nx] == \"1\":",
"- erase(nx, ny)",
"+ if 0 <= nx < w and 0 <= ny < h and c[ny][nx] == \"1\":",
"+ erase(nx, ny)"
] | false
| 0.040072
| 0.040066
| 1.000154
|
[
"s413701833",
"s175815749"
] |
u649769812
|
p02548
|
python
|
s015710006
|
s596861256
| 199
| 166
| 9,052
| 9,144
|
Accepted
|
Accepted
| 16.58
|
N = int(eval(input()))
ans = 0
for i in range(1, N):
if N % i == 0:
ans += (N // i) - 1
else:
ans += N // i
print(ans)
|
N = int(eval(input()))
ans = 0
for i in range(1, N):
ans += (N-1) // i
print(ans)
| 9
| 6
| 146
| 86
|
N = int(eval(input()))
ans = 0
for i in range(1, N):
if N % i == 0:
ans += (N // i) - 1
else:
ans += N // i
print(ans)
|
N = int(eval(input()))
ans = 0
for i in range(1, N):
ans += (N - 1) // i
print(ans)
| false
| 33.333333
|
[
"- if N % i == 0:",
"- ans += (N // i) - 1",
"- else:",
"- ans += N // i",
"+ ans += (N - 1) // i"
] | false
| 0.069112
| 0.070714
| 0.977346
|
[
"s015710006",
"s596861256"
] |
u024340351
|
p02989
|
python
|
s798124764
|
s320717166
| 77
| 68
| 14,428
| 20,620
|
Accepted
|
Accepted
| 11.69
|
a = int(eval(input()))
l = list(map(int, input().split()))
length = len(l)
l = sorted(l)
if length%2==1:
print((0))
else:
print((l[a//2]-l[a//2-1]))
|
N = int(eval(input()))
D = list(map(int, input().split()))
D = sorted(D)
print((D[N//2]-D[N//2-1]))
| 9
| 6
| 149
| 99
|
a = int(eval(input()))
l = list(map(int, input().split()))
length = len(l)
l = sorted(l)
if length % 2 == 1:
print((0))
else:
print((l[a // 2] - l[a // 2 - 1]))
|
N = int(eval(input()))
D = list(map(int, input().split()))
D = sorted(D)
print((D[N // 2] - D[N // 2 - 1]))
| false
| 33.333333
|
[
"-a = int(eval(input()))",
"-l = list(map(int, input().split()))",
"-length = len(l)",
"-l = sorted(l)",
"-if length % 2 == 1:",
"- print((0))",
"-else:",
"- print((l[a // 2] - l[a // 2 - 1]))",
"+N = int(eval(input()))",
"+D = list(map(int, input().split()))",
"+D = sorted(D)",
"+print((D[N // 2] - D[N // 2 - 1]))"
] | false
| 0.040531
| 0.056136
| 0.722014
|
[
"s798124764",
"s320717166"
] |
u219197917
|
p03607
|
python
|
s647349713
|
s389224841
| 188
| 108
| 16,636
| 16,628
|
Accepted
|
Accepted
| 42.55
|
from collections import Counter
print((sum([a % 2 for a in list(Counter([int(eval(input())) for _ in range(int(eval(input())))]).values())])))
|
from collections import Counter
import sys
def read():
return sys.stdin.readline().rstrip()
n = int(read())
a = Counter([int(read()) for _ in range(n)])
print((sum([ai % 2 for ai in list(a.values())])))
| 2
| 9
| 123
| 208
|
from collections import Counter
print(
(
sum(
[
a % 2
for a in list(
Counter(
[int(eval(input())) for _ in range(int(eval(input())))]
).values()
)
]
)
)
)
|
from collections import Counter
import sys
def read():
return sys.stdin.readline().rstrip()
n = int(read())
a = Counter([int(read()) for _ in range(n)])
print((sum([ai % 2 for ai in list(a.values())])))
| false
| 77.777778
|
[
"+import sys",
"-print(",
"- (",
"- sum(",
"- [",
"- a % 2",
"- for a in list(",
"- Counter(",
"- [int(eval(input())) for _ in range(int(eval(input())))]",
"- ).values()",
"- )",
"- ]",
"- )",
"- )",
"-)",
"+",
"+def read():",
"+ return sys.stdin.readline().rstrip()",
"+",
"+",
"+n = int(read())",
"+a = Counter([int(read()) for _ in range(n)])",
"+print((sum([ai % 2 for ai in list(a.values())])))"
] | false
| 0.043947
| 0.043623
| 1.007415
|
[
"s647349713",
"s389224841"
] |
u942033906
|
p03651
|
python
|
s470069032
|
s484032328
| 206
| 71
| 16,056
| 14,104
|
Accepted
|
Accepted
| 65.53
|
import fractions
N,K = list(map(int, input().split()))
A = list(map(int,input().split()))
m = max(A)
if m < K:
print("IMPOSSIBLE")
else:
gcd = A[0]
for i in range(1,N):
gcd = fractions.gcd(A[0], A[i])
if fractions.gcd(gcd, K) == gcd:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
|
N,K = list(map(int,input().split()))
A = list(map(int, input().split()))
M = max(A)
if K > M:
print("IMPOSSIBLE")
exit()
def gcd(n,m):
if n < m:
tmp = n
n = m
m = tmp
while n % m != 0:
tmp = m
m = n % m
n = tmp
return m
g = M
for a in A:
g = gcd(g,a)
if g == 1:
break
if K % g == 0:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
| 15
| 26
| 297
| 438
|
import fractions
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
m = max(A)
if m < K:
print("IMPOSSIBLE")
else:
gcd = A[0]
for i in range(1, N):
gcd = fractions.gcd(A[0], A[i])
if fractions.gcd(gcd, K) == gcd:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
|
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
M = max(A)
if K > M:
print("IMPOSSIBLE")
exit()
def gcd(n, m):
if n < m:
tmp = n
n = m
m = tmp
while n % m != 0:
tmp = m
m = n % m
n = tmp
return m
g = M
for a in A:
g = gcd(g, a)
if g == 1:
break
if K % g == 0:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
| false
| 42.307692
|
[
"-import fractions",
"-",
"-m = max(A)",
"-if m < K:",
"+M = max(A)",
"+if K > M:",
"+ exit()",
"+",
"+",
"+def gcd(n, m):",
"+ if n < m:",
"+ tmp = n",
"+ n = m",
"+ m = tmp",
"+ while n % m != 0:",
"+ tmp = m",
"+ m = n % m",
"+ n = tmp",
"+ return m",
"+",
"+",
"+g = M",
"+for a in A:",
"+ g = gcd(g, a)",
"+ if g == 1:",
"+ break",
"+if K % g == 0:",
"+ print(\"POSSIBLE\")",
"- gcd = A[0]",
"- for i in range(1, N):",
"- gcd = fractions.gcd(A[0], A[i])",
"- if fractions.gcd(gcd, K) == gcd:",
"- print(\"POSSIBLE\")",
"- else:",
"- print(\"IMPOSSIBLE\")",
"+ print(\"IMPOSSIBLE\")"
] | false
| 0.048277
| 0.037741
| 1.279151
|
[
"s470069032",
"s484032328"
] |
u556589653
|
p03037
|
python
|
s304310978
|
s337854720
| 299
| 210
| 11,020
| 16,836
|
Accepted
|
Accepted
| 29.77
|
N,M = list(map(int,input().split()))
Left = []
Right = []
for i in range(M):
l,r = list(map(int,input().split()))
Left.append(l)
Right.append(r)
if max(Left) > min(Right):
print((0))
else:
print((min(Right)-max(Left)+1))
|
N,M = list(map(int,input().split()))
left = []
right = []
for i in range(M):
l,r = list(map(int,input().split()))
left.append(l)
right.append(r)
if max(left)>min(right):
print((0))
else:
print((min(right)-max(left)+1))
| 11
| 11
| 234
| 232
|
N, M = list(map(int, input().split()))
Left = []
Right = []
for i in range(M):
l, r = list(map(int, input().split()))
Left.append(l)
Right.append(r)
if max(Left) > min(Right):
print((0))
else:
print((min(Right) - max(Left) + 1))
|
N, M = list(map(int, input().split()))
left = []
right = []
for i in range(M):
l, r = list(map(int, input().split()))
left.append(l)
right.append(r)
if max(left) > min(right):
print((0))
else:
print((min(right) - max(left) + 1))
| false
| 0
|
[
"-Left = []",
"-Right = []",
"+left = []",
"+right = []",
"- Left.append(l)",
"- Right.append(r)",
"-if max(Left) > min(Right):",
"+ left.append(l)",
"+ right.append(r)",
"+if max(left) > min(right):",
"- print((min(Right) - max(Left) + 1))",
"+ print((min(right) - max(left) + 1))"
] | false
| 0.044099
| 0.044486
| 0.991308
|
[
"s304310978",
"s337854720"
] |
u657913472
|
p03106
|
python
|
s276255043
|
s479963647
| 21
| 17
| 3,060
| 2,940
|
Accepted
|
Accepted
| 19.05
|
a,b,k=list(map(int,input().split()))
print(([i for i in range(1,101)if a%i==0 and b%i==0][-k]))
|
a,b,k=list(map(int,input().split()))
print(([i for i in range(1,101)if a%i==b%i==0][-k]))
| 2
| 2
| 88
| 82
|
a, b, k = list(map(int, input().split()))
print(([i for i in range(1, 101) if a % i == 0 and b % i == 0][-k]))
|
a, b, k = list(map(int, input().split()))
print(([i for i in range(1, 101) if a % i == b % i == 0][-k]))
| false
| 0
|
[
"-print(([i for i in range(1, 101) if a % i == 0 and b % i == 0][-k]))",
"+print(([i for i in range(1, 101) if a % i == b % i == 0][-k]))"
] | false
| 0.062778
| 0.076698
| 0.818516
|
[
"s276255043",
"s479963647"
] |
u591503175
|
p03164
|
python
|
s043671776
|
s065079342
| 204
| 182
| 92,072
| 15,724
|
Accepted
|
Accepted
| 10.78
|
import sys
input = sys.stdin.readline
import numpy as np
def main():
N, W = [int(item) for item in input().split()]
item = np.array([[int(item) for item in input().split()] for _ in range(N)])
dp = np.full((N+1, 10**5 + 1), 10**12+1)
dp[0][0] = 0
for i in range(N):
dp[i+1] = dp[i]
w, v = item[i]
np.minimum(dp[i][v:], dp[i][:-v] + w, out=dp[i+1][v:])
print((np.where(dp[N] <= W)[0][-1]))
if __name__ == "__main__":
main()
|
import sys
input = sys.stdin.readline
import numpy as np
def main():
N, W = [int(item) for item in input().split()]
item = np.array([[int(item) for item in input().split()] for _ in range(N)])
dp = np.full(10**5 + 1, 10**12+1)
dp[0] = 0
for i in range(N):
w, v = item[i]
np.minimum(dp[v:], dp[:-v] + w, out=dp[v:])
print((np.where(dp <= W)[0][-1]))
if __name__ == "__main__":
main()
| 21
| 20
| 498
| 449
|
import sys
input = sys.stdin.readline
import numpy as np
def main():
N, W = [int(item) for item in input().split()]
item = np.array([[int(item) for item in input().split()] for _ in range(N)])
dp = np.full((N + 1, 10**5 + 1), 10**12 + 1)
dp[0][0] = 0
for i in range(N):
dp[i + 1] = dp[i]
w, v = item[i]
np.minimum(dp[i][v:], dp[i][:-v] + w, out=dp[i + 1][v:])
print((np.where(dp[N] <= W)[0][-1]))
if __name__ == "__main__":
main()
|
import sys
input = sys.stdin.readline
import numpy as np
def main():
N, W = [int(item) for item in input().split()]
item = np.array([[int(item) for item in input().split()] for _ in range(N)])
dp = np.full(10**5 + 1, 10**12 + 1)
dp[0] = 0
for i in range(N):
w, v = item[i]
np.minimum(dp[v:], dp[:-v] + w, out=dp[v:])
print((np.where(dp <= W)[0][-1]))
if __name__ == "__main__":
main()
| false
| 4.761905
|
[
"- dp = np.full((N + 1, 10**5 + 1), 10**12 + 1)",
"- dp[0][0] = 0",
"+ dp = np.full(10**5 + 1, 10**12 + 1)",
"+ dp[0] = 0",
"- dp[i + 1] = dp[i]",
"- np.minimum(dp[i][v:], dp[i][:-v] + w, out=dp[i + 1][v:])",
"- print((np.where(dp[N] <= W)[0][-1]))",
"+ np.minimum(dp[v:], dp[:-v] + w, out=dp[v:])",
"+ print((np.where(dp <= W)[0][-1]))"
] | false
| 0.225491
| 0.213986
| 1.053764
|
[
"s043671776",
"s065079342"
] |
u630281418
|
p02861
|
python
|
s933442380
|
s951673228
| 209
| 165
| 47,084
| 38,384
|
Accepted
|
Accepted
| 21.05
|
import itertools
import math
n = int(eval(input()))
xy = []
for _ in range(n):
xxyy = list(map(int, input().split()))
xy.append(xxyy)
l = [i for i in range(n)]
p = list(itertools.permutations(l))
dist = 0
for pp in p:
preppi = pp[0]
for ppi in pp[1:]:
dist += math.sqrt((xy[ppi][0] - xy[preppi][0])**2 + (xy[ppi][1] - xy[preppi][1])**2)
preppi = ppi
print((dist/len(p)))
|
import math
n = int(eval(input()))
xy = []
for _ in range(n):
xxyy = list(map(int, input().split()))
xy.append(xxyy)
dist = 0
for i, xyi in enumerate(xy):
for xyj in xy[i+1:]:
dist += math.sqrt((xyi[0] - xyj[0])**2 + (xyi[1] - xyj[1])**2)
print((dist*2/n))
| 18
| 13
| 414
| 283
|
import itertools
import math
n = int(eval(input()))
xy = []
for _ in range(n):
xxyy = list(map(int, input().split()))
xy.append(xxyy)
l = [i for i in range(n)]
p = list(itertools.permutations(l))
dist = 0
for pp in p:
preppi = pp[0]
for ppi in pp[1:]:
dist += math.sqrt(
(xy[ppi][0] - xy[preppi][0]) ** 2 + (xy[ppi][1] - xy[preppi][1]) ** 2
)
preppi = ppi
print((dist / len(p)))
|
import math
n = int(eval(input()))
xy = []
for _ in range(n):
xxyy = list(map(int, input().split()))
xy.append(xxyy)
dist = 0
for i, xyi in enumerate(xy):
for xyj in xy[i + 1 :]:
dist += math.sqrt((xyi[0] - xyj[0]) ** 2 + (xyi[1] - xyj[1]) ** 2)
print((dist * 2 / n))
| false
| 27.777778
|
[
"-import itertools",
"-l = [i for i in range(n)]",
"-p = list(itertools.permutations(l))",
"-for pp in p:",
"- preppi = pp[0]",
"- for ppi in pp[1:]:",
"- dist += math.sqrt(",
"- (xy[ppi][0] - xy[preppi][0]) ** 2 + (xy[ppi][1] - xy[preppi][1]) ** 2",
"- )",
"- preppi = ppi",
"-print((dist / len(p)))",
"+for i, xyi in enumerate(xy):",
"+ for xyj in xy[i + 1 :]:",
"+ dist += math.sqrt((xyi[0] - xyj[0]) ** 2 + (xyi[1] - xyj[1]) ** 2)",
"+print((dist * 2 / n))"
] | false
| 0.041529
| 0.067505
| 0.615203
|
[
"s933442380",
"s951673228"
] |
u888092736
|
p02911
|
python
|
s748551913
|
s228740166
| 108
| 64
| 13,940
| 14,004
|
Accepted
|
Accepted
| 40.74
|
N, K, Q, *A = map(int, open(0).read().split())
ans = [K - Q] * N
for a in A:
ans[a - 1] += 1
[print('Yes') if v > 0 else print('No') for v in ans]
|
N, K, Q, *A = list(map(int, open(0).read().split()))
ans = [K - Q] * N
for a in A:
ans[a - 1] += 1
print(('\n'.join('Yes' if v > 0 else 'No' for v in ans)))
| 5
| 5
| 154
| 156
|
N, K, Q, *A = map(int, open(0).read().split())
ans = [K - Q] * N
for a in A:
ans[a - 1] += 1
[print("Yes") if v > 0 else print("No") for v in ans]
|
N, K, Q, *A = list(map(int, open(0).read().split()))
ans = [K - Q] * N
for a in A:
ans[a - 1] += 1
print(("\n".join("Yes" if v > 0 else "No" for v in ans)))
| false
| 0
|
[
"-N, K, Q, *A = map(int, open(0).read().split())",
"+N, K, Q, *A = list(map(int, open(0).read().split()))",
"-[print(\"Yes\") if v > 0 else print(\"No\") for v in ans]",
"+print((\"\\n\".join(\"Yes\" if v > 0 else \"No\" for v in ans)))"
] | false
| 0.036578
| 0.035337
| 1.035113
|
[
"s748551913",
"s228740166"
] |
u886655280
|
p03478
|
python
|
s445007635
|
s270355577
| 47
| 38
| 3,060
| 3,060
|
Accepted
|
Accepted
| 19.15
|
N, A, B = list(map(int, input().split()))
target_total = 0
for n in range(1, N + 1):
total_each_digit = 0
n_length = len(str(n))
for i in range(n_length):
total_each_digit += int(str(n)[i])
if A <= total_each_digit <= B:
target_total += n
print(target_total)
|
N, A, B = list(map(int, input().split()))
target_total = 0 # 加算対象の数値の和
for n in range(1, N + 1):
total_each_digit = 0 # 各位の和
str_n = str(n)
n_length = len(str_n) # nの桁数
for i in range(n_length):
total_each_digit += int(str_n[i])
if A <= total_each_digit <= B:
target_total += n
print(target_total)
| 14
| 16
| 305
| 364
|
N, A, B = list(map(int, input().split()))
target_total = 0
for n in range(1, N + 1):
total_each_digit = 0
n_length = len(str(n))
for i in range(n_length):
total_each_digit += int(str(n)[i])
if A <= total_each_digit <= B:
target_total += n
print(target_total)
|
N, A, B = list(map(int, input().split()))
target_total = 0 # 加算対象の数値の和
for n in range(1, N + 1):
total_each_digit = 0 # 各位の和
str_n = str(n)
n_length = len(str_n) # nの桁数
for i in range(n_length):
total_each_digit += int(str_n[i])
if A <= total_each_digit <= B:
target_total += n
print(target_total)
| false
| 12.5
|
[
"-target_total = 0",
"+target_total = 0 # 加算対象の数値の和",
"- total_each_digit = 0",
"- n_length = len(str(n))",
"+ total_each_digit = 0 # 各位の和",
"+ str_n = str(n)",
"+ n_length = len(str_n) # nの桁数",
"- total_each_digit += int(str(n)[i])",
"+ total_each_digit += int(str_n[i])"
] | false
| 0.045276
| 0.057594
| 0.78613
|
[
"s445007635",
"s270355577"
] |
u444722572
|
p02695
|
python
|
s590750708
|
s680440304
| 1,379
| 229
| 9,188
| 46,740
|
Accepted
|
Accepted
| 83.39
|
import itertools
N,M,Q=list(map(int,input().split()))
a_b_c_d=[list(map(int,input().split())) for _ in range(Q)]
nums=[i for i in range(1,M+1)]
A_s=itertools.combinations_with_replacement(nums,N)
ans=0
for A in A_s:
tmp=0
for i in range(Q):
if A[a_b_c_d[i][1]-1]-A[a_b_c_d[i][0]-1]==a_b_c_d[i][2]:
tmp+=a_b_c_d[i][3]
if tmp>ans:
ans=tmp
print(ans)
|
import sys
import itertools
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M, Q = list(map(int, readline().split()))
A = np.array(list(itertools.combinations_with_replacement(list(range(1, M + 1)), N)))
n = len(A)
score = np.zeros(n, np.int32)
m = list(map(int, read().split()))
for a, b, c, d in zip(m, m, m, m):
cond = A[:, b - 1] - A[:, a - 1] == c
score += d * cond
print((score.max()))
| 14
| 20
| 394
| 487
|
import itertools
N, M, Q = list(map(int, input().split()))
a_b_c_d = [list(map(int, input().split())) for _ in range(Q)]
nums = [i for i in range(1, M + 1)]
A_s = itertools.combinations_with_replacement(nums, N)
ans = 0
for A in A_s:
tmp = 0
for i in range(Q):
if A[a_b_c_d[i][1] - 1] - A[a_b_c_d[i][0] - 1] == a_b_c_d[i][2]:
tmp += a_b_c_d[i][3]
if tmp > ans:
ans = tmp
print(ans)
|
import sys
import itertools
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M, Q = list(map(int, readline().split()))
A = np.array(list(itertools.combinations_with_replacement(list(range(1, M + 1)), N)))
n = len(A)
score = np.zeros(n, np.int32)
m = list(map(int, read().split()))
for a, b, c, d in zip(m, m, m, m):
cond = A[:, b - 1] - A[:, a - 1] == c
score += d * cond
print((score.max()))
| false
| 30
|
[
"+import sys",
"+import numpy as np",
"-N, M, Q = list(map(int, input().split()))",
"-a_b_c_d = [list(map(int, input().split())) for _ in range(Q)]",
"-nums = [i for i in range(1, M + 1)]",
"-A_s = itertools.combinations_with_replacement(nums, N)",
"-ans = 0",
"-for A in A_s:",
"- tmp = 0",
"- for i in range(Q):",
"- if A[a_b_c_d[i][1] - 1] - A[a_b_c_d[i][0] - 1] == a_b_c_d[i][2]:",
"- tmp += a_b_c_d[i][3]",
"- if tmp > ans:",
"- ans = tmp",
"-print(ans)",
"+read = sys.stdin.buffer.read",
"+readline = sys.stdin.buffer.readline",
"+readlines = sys.stdin.buffer.readlines",
"+N, M, Q = list(map(int, readline().split()))",
"+A = np.array(list(itertools.combinations_with_replacement(list(range(1, M + 1)), N)))",
"+n = len(A)",
"+score = np.zeros(n, np.int32)",
"+m = list(map(int, read().split()))",
"+for a, b, c, d in zip(m, m, m, m):",
"+ cond = A[:, b - 1] - A[:, a - 1] == c",
"+ score += d * cond",
"+print((score.max()))"
] | false
| 0.047382
| 0.197648
| 0.239727
|
[
"s590750708",
"s680440304"
] |
u572002343
|
p03816
|
python
|
s847529457
|
s034811518
| 90
| 64
| 22,756
| 22,756
|
Accepted
|
Accepted
| 28.89
|
from collections import defaultdict as dd
from functools import reduce
if __name__ == "__main__":
N = int(eval(input()))
arr = list(map(int, input().split()))
dic = dd(int)
for el in arr:
dic[el] += 1
count = len(dic) - len(list([x for x in list(dic.values()) if x %
2 == 0])) % 2
print(count)
|
from collections import Counter
from functools import reduce
if __name__ == "__main__":
N = int(eval(input()))
arr = list(map(int, input().split()))
dic = Counter(arr)
count = len(dic) - reduce(lambda sum, item: sum + 1, [x for x in list(dic.values()) if x % 2 == 0], 0) % 2
print(count)
| 15
| 10
| 368
| 304
|
from collections import defaultdict as dd
from functools import reduce
if __name__ == "__main__":
N = int(eval(input()))
arr = list(map(int, input().split()))
dic = dd(int)
for el in arr:
dic[el] += 1
count = len(dic) - len(list([x for x in list(dic.values()) if x % 2 == 0])) % 2
print(count)
|
from collections import Counter
from functools import reduce
if __name__ == "__main__":
N = int(eval(input()))
arr = list(map(int, input().split()))
dic = Counter(arr)
count = (
len(dic)
- reduce(
lambda sum, item: sum + 1, [x for x in list(dic.values()) if x % 2 == 0], 0
)
% 2
)
print(count)
| false
| 33.333333
|
[
"-from collections import defaultdict as dd",
"+from collections import Counter",
"- dic = dd(int)",
"- for el in arr:",
"- dic[el] += 1",
"- count = len(dic) - len(list([x for x in list(dic.values()) if x % 2 == 0])) % 2",
"+ dic = Counter(arr)",
"+ count = (",
"+ len(dic)",
"+ - reduce(",
"+ lambda sum, item: sum + 1, [x for x in list(dic.values()) if x % 2 == 0], 0",
"+ )",
"+ % 2",
"+ )"
] | false
| 0.037814
| 0.038797
| 0.974663
|
[
"s847529457",
"s034811518"
] |
u888092736
|
p03634
|
python
|
s800994110
|
s597306017
| 643
| 446
| 61,348
| 47,604
|
Accepted
|
Accepted
| 30.64
|
import sys
from collections import defaultdict
from heapq import heappush, heappop
def input():
return sys.stdin.readline().strip()
def dijkstra(adj_list, start):
n = len(adj_list)
dist = [float("inf")] * n
dist[start] = 0
pq = []
heappush(pq, (0, start))
visited = set()
while pq:
w, v = heappop(pq)
if dist[v] < w:
continue
visited.add(v)
for nv, nw in adj_list[v]:
if nv in visited:
continue
if dist[nv] > dist[v] + nw:
dist[nv] = dist[v] + nw
heappush(pq, (dist[nv], nv))
return dist
N = int(eval(input()))
g = defaultdict(list)
for _ in range(N - 1):
a, b, c = list(map(int, input().split()))
a -= 1
b -= 1
g[a].append((b, c))
g[b].append((a, c))
Q, K = list(map(int, input().split()))
K -= 1
d = dijkstra(g, K)
ans = []
for _ in range(Q):
x, y = list(map(int, input().split()))
x -= 1
y -= 1
print((d[x] + d[y]))
|
import sys
from collections import deque
def input():
return sys.stdin.readline().strip()
def bfs(start):
q = deque([start])
dist = [-1] * (N + 1)
dist[start] = 0
while q:
v = q.popleft()
for nv, nw in g[v]:
if dist[nv] > 0:
continue
dist[nv] = dist[v] + nw
q.append(nv)
return dist
N = int(eval(input()))
g = [[] for _ in range(N + 1)]
for _ in range(N - 1):
a, b, c = list(map(int, input().split()))
g[a].append((b, c))
g[b].append((a, c))
Q, K = list(map(int, input().split()))
d = bfs(K)
ans = []
for _ in range(Q):
x, y = list(map(int, input().split()))
print((d[x] + d[y]))
| 48
| 34
| 1,035
| 705
|
import sys
from collections import defaultdict
from heapq import heappush, heappop
def input():
return sys.stdin.readline().strip()
def dijkstra(adj_list, start):
n = len(adj_list)
dist = [float("inf")] * n
dist[start] = 0
pq = []
heappush(pq, (0, start))
visited = set()
while pq:
w, v = heappop(pq)
if dist[v] < w:
continue
visited.add(v)
for nv, nw in adj_list[v]:
if nv in visited:
continue
if dist[nv] > dist[v] + nw:
dist[nv] = dist[v] + nw
heappush(pq, (dist[nv], nv))
return dist
N = int(eval(input()))
g = defaultdict(list)
for _ in range(N - 1):
a, b, c = list(map(int, input().split()))
a -= 1
b -= 1
g[a].append((b, c))
g[b].append((a, c))
Q, K = list(map(int, input().split()))
K -= 1
d = dijkstra(g, K)
ans = []
for _ in range(Q):
x, y = list(map(int, input().split()))
x -= 1
y -= 1
print((d[x] + d[y]))
|
import sys
from collections import deque
def input():
return sys.stdin.readline().strip()
def bfs(start):
q = deque([start])
dist = [-1] * (N + 1)
dist[start] = 0
while q:
v = q.popleft()
for nv, nw in g[v]:
if dist[nv] > 0:
continue
dist[nv] = dist[v] + nw
q.append(nv)
return dist
N = int(eval(input()))
g = [[] for _ in range(N + 1)]
for _ in range(N - 1):
a, b, c = list(map(int, input().split()))
g[a].append((b, c))
g[b].append((a, c))
Q, K = list(map(int, input().split()))
d = bfs(K)
ans = []
for _ in range(Q):
x, y = list(map(int, input().split()))
print((d[x] + d[y]))
| false
| 29.166667
|
[
"-from collections import defaultdict",
"-from heapq import heappush, heappop",
"+from collections import deque",
"-def dijkstra(adj_list, start):",
"- n = len(adj_list)",
"- dist = [float(\"inf\")] * n",
"+def bfs(start):",
"+ q = deque([start])",
"+ dist = [-1] * (N + 1)",
"- pq = []",
"- heappush(pq, (0, start))",
"- visited = set()",
"- while pq:",
"- w, v = heappop(pq)",
"- if dist[v] < w:",
"- continue",
"- visited.add(v)",
"- for nv, nw in adj_list[v]:",
"- if nv in visited:",
"+ while q:",
"+ v = q.popleft()",
"+ for nv, nw in g[v]:",
"+ if dist[nv] > 0:",
"- if dist[nv] > dist[v] + nw:",
"- dist[nv] = dist[v] + nw",
"- heappush(pq, (dist[nv], nv))",
"+ dist[nv] = dist[v] + nw",
"+ q.append(nv)",
"-g = defaultdict(list)",
"+g = [[] for _ in range(N + 1)]",
"- a -= 1",
"- b -= 1",
"-K -= 1",
"-d = dijkstra(g, K)",
"+d = bfs(K)",
"- x -= 1",
"- y -= 1"
] | false
| 0.038864
| 0.040578
| 0.957746
|
[
"s800994110",
"s597306017"
] |
u413021823
|
p03106
|
python
|
s522137493
|
s305575745
| 170
| 70
| 38,512
| 64,900
|
Accepted
|
Accepted
| 58.82
|
import sys
from itertools import combinations
import math
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
A, B, K = LI()
temp = 0
for i in range(min(A, B), 0, -1):
if A % i == 0 and B % i == 0:
temp += 1
if temp == K:
print(i)
exit()
|
import sys
from collections import deque
from itertools import *
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
A, B, K = LI()
l = []
for i in range(1,100+1):
if A % i == 0 and B % i == 0:
l.append(i)
l.reverse()
print((l[K-1]))
| 25
| 25
| 493
| 456
|
import sys
from itertools import combinations
import math
def I():
return int(sys.stdin.readline().rstrip())
def LI():
return list(map(int, sys.stdin.readline().rstrip().split()))
def S():
return sys.stdin.readline().rstrip()
def LS():
return list(sys.stdin.readline().rstrip().split())
A, B, K = LI()
temp = 0
for i in range(min(A, B), 0, -1):
if A % i == 0 and B % i == 0:
temp += 1
if temp == K:
print(i)
exit()
|
import sys
from collections import deque
from itertools import *
def I():
return int(sys.stdin.readline().rstrip())
def LI():
return list(map(int, sys.stdin.readline().rstrip().split()))
def S():
return sys.stdin.readline().rstrip()
def LS():
return list(sys.stdin.readline().rstrip().split())
A, B, K = LI()
l = []
for i in range(1, 100 + 1):
if A % i == 0 and B % i == 0:
l.append(i)
l.reverse()
print((l[K - 1]))
| false
| 0
|
[
"-from itertools import combinations",
"-import math",
"+from collections import deque",
"+from itertools import *",
"-temp = 0",
"-for i in range(min(A, B), 0, -1):",
"+l = []",
"+for i in range(1, 100 + 1):",
"- temp += 1",
"- if temp == K:",
"- print(i)",
"- exit()",
"+ l.append(i)",
"+l.reverse()",
"+print((l[K - 1]))"
] | false
| 0.035925
| 0.053021
| 0.677565
|
[
"s522137493",
"s305575745"
] |
u845573105
|
p02735
|
python
|
s399636670
|
s309694386
| 35
| 29
| 3,192
| 3,188
|
Accepted
|
Accepted
| 17.14
|
H, W = list(map(int, input().split()))
S = [eval(input()) for _ in range(H)]
vis = [[-1 for i in range(W)] for j in range(H)]
que = [(0,0)]
itr = 0
color = "."
if S[0][0]=="#":
itr=1
color="#"
vis[0][0]=itr
while len(que)>0:
v, h = que.pop(0)
itr = vis[v][h]
if itr%2==0:
color="."
else:
color="#"
que2 = []
if v+1 < H:
if S[v+1][h]==color and vis[v+1][h]==-1:
vis[v+1][h] = itr
que2.append((v+1,h))
elif vis[v+1][h]==-1:
vis[v+1][h] = itr +1
que.append((v+1,h))
if h+1 < W:
if S[v][h+1]==color and vis[v][h+1]==-1:
vis[v][h+1] = itr
que2.append((v,h+1))
elif vis[v][h+1]==-1:
vis[v][h+1] = itr+1
que.append((v, h+1))
while len(que2)>0:
v, h = que2.pop(0)
if v+1 < H:
if S[v+1][h]==color and vis[v+1][h]==-1:
vis[v+1][h] = itr
que2.append((v+1,h))
elif vis[v+1][h]==-1:
vis[v+1][h] = itr +1
que.append((v+1,h))
if h+1 < W:
if S[v][h+1]==color and vis[v][h+1]==-1:
vis[v][h+1] = itr
que2.append((v,h+1))
elif vis[v][h+1]==-1:
vis[v][h+1] = itr+1
que.append((v, h+1))
if vis[H-1][W-1]%2 == 0:
print((vis[H-1][W-1]//2))
else:
print(((vis[H-1][W-1]+1)//2))
|
H, W = list(map(int, input().split()))
S = [eval(input()) for _ in range(H)]
vis = [[-1 for i in range(W)] for j in range(H)]
for v in range(H):
for h in range(W):
if v==0:
if h==0:
if S[v][h]=="#":
vis[v][h]=1
else:
vis[v][h]=0
else:
if S[v][h-1]=="." and S[v][h]=="#":
vis[v][h] = vis[v][h-1] + 1
else:
vis[v][h] = vis[v][h-1]
else:
if h==0:
if S[v-1][h]=="." and S[v][h]=="#":
vis[v][h] = vis[v-1][h] + 1
else:
vis[v][h] = vis[v-1][h]
else:
if S[v-1][h]=="." and S[v][h]=="#":
bufv = vis[v-1][h] + 1
else:
bufv = vis[v-1][h]
if S[v][h-1]=="." and S[v][h]=="#":
bufh = vis[v][h-1] + 1
else:
bufh = vis[v][h-1]
vis[v][h] = min(bufv, bufh)
#print(vis)
print((vis[H-1][W-1]))
| 55
| 38
| 1,293
| 939
|
H, W = list(map(int, input().split()))
S = [eval(input()) for _ in range(H)]
vis = [[-1 for i in range(W)] for j in range(H)]
que = [(0, 0)]
itr = 0
color = "."
if S[0][0] == "#":
itr = 1
color = "#"
vis[0][0] = itr
while len(que) > 0:
v, h = que.pop(0)
itr = vis[v][h]
if itr % 2 == 0:
color = "."
else:
color = "#"
que2 = []
if v + 1 < H:
if S[v + 1][h] == color and vis[v + 1][h] == -1:
vis[v + 1][h] = itr
que2.append((v + 1, h))
elif vis[v + 1][h] == -1:
vis[v + 1][h] = itr + 1
que.append((v + 1, h))
if h + 1 < W:
if S[v][h + 1] == color and vis[v][h + 1] == -1:
vis[v][h + 1] = itr
que2.append((v, h + 1))
elif vis[v][h + 1] == -1:
vis[v][h + 1] = itr + 1
que.append((v, h + 1))
while len(que2) > 0:
v, h = que2.pop(0)
if v + 1 < H:
if S[v + 1][h] == color and vis[v + 1][h] == -1:
vis[v + 1][h] = itr
que2.append((v + 1, h))
elif vis[v + 1][h] == -1:
vis[v + 1][h] = itr + 1
que.append((v + 1, h))
if h + 1 < W:
if S[v][h + 1] == color and vis[v][h + 1] == -1:
vis[v][h + 1] = itr
que2.append((v, h + 1))
elif vis[v][h + 1] == -1:
vis[v][h + 1] = itr + 1
que.append((v, h + 1))
if vis[H - 1][W - 1] % 2 == 0:
print((vis[H - 1][W - 1] // 2))
else:
print(((vis[H - 1][W - 1] + 1) // 2))
|
H, W = list(map(int, input().split()))
S = [eval(input()) for _ in range(H)]
vis = [[-1 for i in range(W)] for j in range(H)]
for v in range(H):
for h in range(W):
if v == 0:
if h == 0:
if S[v][h] == "#":
vis[v][h] = 1
else:
vis[v][h] = 0
else:
if S[v][h - 1] == "." and S[v][h] == "#":
vis[v][h] = vis[v][h - 1] + 1
else:
vis[v][h] = vis[v][h - 1]
else:
if h == 0:
if S[v - 1][h] == "." and S[v][h] == "#":
vis[v][h] = vis[v - 1][h] + 1
else:
vis[v][h] = vis[v - 1][h]
else:
if S[v - 1][h] == "." and S[v][h] == "#":
bufv = vis[v - 1][h] + 1
else:
bufv = vis[v - 1][h]
if S[v][h - 1] == "." and S[v][h] == "#":
bufh = vis[v][h - 1] + 1
else:
bufh = vis[v][h - 1]
vis[v][h] = min(bufv, bufh)
# print(vis)
print((vis[H - 1][W - 1]))
| false
| 30.909091
|
[
"-que = [(0, 0)]",
"-itr = 0",
"-color = \".\"",
"-if S[0][0] == \"#\":",
"- itr = 1",
"- color = \"#\"",
"-vis[0][0] = itr",
"-while len(que) > 0:",
"- v, h = que.pop(0)",
"- itr = vis[v][h]",
"- if itr % 2 == 0:",
"- color = \".\"",
"- else:",
"- color = \"#\"",
"- que2 = []",
"- if v + 1 < H:",
"- if S[v + 1][h] == color and vis[v + 1][h] == -1:",
"- vis[v + 1][h] = itr",
"- que2.append((v + 1, h))",
"- elif vis[v + 1][h] == -1:",
"- vis[v + 1][h] = itr + 1",
"- que.append((v + 1, h))",
"- if h + 1 < W:",
"- if S[v][h + 1] == color and vis[v][h + 1] == -1:",
"- vis[v][h + 1] = itr",
"- que2.append((v, h + 1))",
"- elif vis[v][h + 1] == -1:",
"- vis[v][h + 1] = itr + 1",
"- que.append((v, h + 1))",
"- while len(que2) > 0:",
"- v, h = que2.pop(0)",
"- if v + 1 < H:",
"- if S[v + 1][h] == color and vis[v + 1][h] == -1:",
"- vis[v + 1][h] = itr",
"- que2.append((v + 1, h))",
"- elif vis[v + 1][h] == -1:",
"- vis[v + 1][h] = itr + 1",
"- que.append((v + 1, h))",
"- if h + 1 < W:",
"- if S[v][h + 1] == color and vis[v][h + 1] == -1:",
"- vis[v][h + 1] = itr",
"- que2.append((v, h + 1))",
"- elif vis[v][h + 1] == -1:",
"- vis[v][h + 1] = itr + 1",
"- que.append((v, h + 1))",
"-if vis[H - 1][W - 1] % 2 == 0:",
"- print((vis[H - 1][W - 1] // 2))",
"-else:",
"- print(((vis[H - 1][W - 1] + 1) // 2))",
"+for v in range(H):",
"+ for h in range(W):",
"+ if v == 0:",
"+ if h == 0:",
"+ if S[v][h] == \"#\":",
"+ vis[v][h] = 1",
"+ else:",
"+ vis[v][h] = 0",
"+ else:",
"+ if S[v][h - 1] == \".\" and S[v][h] == \"#\":",
"+ vis[v][h] = vis[v][h - 1] + 1",
"+ else:",
"+ vis[v][h] = vis[v][h - 1]",
"+ else:",
"+ if h == 0:",
"+ if S[v - 1][h] == \".\" and S[v][h] == \"#\":",
"+ vis[v][h] = vis[v - 1][h] + 1",
"+ else:",
"+ vis[v][h] = vis[v - 1][h]",
"+ else:",
"+ if S[v - 1][h] == \".\" and S[v][h] == \"#\":",
"+ bufv = vis[v - 1][h] + 1",
"+ else:",
"+ bufv = vis[v - 1][h]",
"+ if S[v][h - 1] == \".\" and S[v][h] == \"#\":",
"+ bufh = vis[v][h - 1] + 1",
"+ else:",
"+ bufh = vis[v][h - 1]",
"+ vis[v][h] = min(bufv, bufh)",
"+ # print(vis)",
"+print((vis[H - 1][W - 1]))"
] | false
| 0.035939
| 0.045645
| 0.787351
|
[
"s399636670",
"s309694386"
] |
u607563136
|
p02676
|
python
|
s774954632
|
s762317658
| 29
| 25
| 9,012
| 9,056
|
Accepted
|
Accepted
| 13.79
|
k = int(eval(input()))
s = eval(input())
if len(s) <= k:
print(s)
else:
print(("{}...".format(s[:k])))
|
k = int(eval(input()))
s = eval(input())
print((s if len(s)<=k else s[:k]+"..."))
| 7
| 3
| 103
| 69
|
k = int(eval(input()))
s = eval(input())
if len(s) <= k:
print(s)
else:
print(("{}...".format(s[:k])))
|
k = int(eval(input()))
s = eval(input())
print((s if len(s) <= k else s[:k] + "..."))
| false
| 57.142857
|
[
"-if len(s) <= k:",
"- print(s)",
"-else:",
"- print((\"{}...\".format(s[:k])))",
"+print((s if len(s) <= k else s[:k] + \"...\"))"
] | false
| 0.037941
| 0.046244
| 0.820453
|
[
"s774954632",
"s762317658"
] |
u040298438
|
p02647
|
python
|
s325432367
|
s702540236
| 1,214
| 668
| 125,320
| 129,968
|
Accepted
|
Accepted
| 44.98
|
import numpy as np
from numba import njit
@njit
def myfunc(n, k, A):
for _ in range(k):
l = np.zeros((n + 1,), dtype=np.int64)
for i, a in enumerate(A[:-1]):
l[max(0, i - a)] += 1
l[min(n, i + a + 1)] -= 1
A = np.cumsum(l)
if np.all(A[:-1] == n):
break
return A
def main():
n, k = list(map(int, input().split()))
A = np.array(list(map(int, input().split())), dtype=np.int64)
A = np.append(A, 0)
print((*myfunc(n, k, A)[:-1]))
if __name__ == "__main__":
main()
|
import numpy as np
from numba import jit, i8
@jit(i8[:](i8, i8, i8[:]), nopython=True, cache=True)
def myfunc(n, k, A):
for _ in range(k):
l = np.zeros((n + 1,), dtype=np.int64)
for i, a in enumerate(A[:-1]):
l[max(0, i - a)] += 1
l[min(n, i + a + 1)] -= 1
A = np.cumsum(l)
if np.all(A[:-1] == n):
break
return A
def main():
n, k = list(map(int, input().split()))
A = np.array(list(map(int, input().split())), dtype=np.int64)
A = np.append(A, 0)
print((*myfunc(n, k, A)[:-1]))
if __name__ == "__main__":
main()
| 26
| 26
| 578
| 629
|
import numpy as np
from numba import njit
@njit
def myfunc(n, k, A):
for _ in range(k):
l = np.zeros((n + 1,), dtype=np.int64)
for i, a in enumerate(A[:-1]):
l[max(0, i - a)] += 1
l[min(n, i + a + 1)] -= 1
A = np.cumsum(l)
if np.all(A[:-1] == n):
break
return A
def main():
n, k = list(map(int, input().split()))
A = np.array(list(map(int, input().split())), dtype=np.int64)
A = np.append(A, 0)
print((*myfunc(n, k, A)[:-1]))
if __name__ == "__main__":
main()
|
import numpy as np
from numba import jit, i8
@jit(i8[:](i8, i8, i8[:]), nopython=True, cache=True)
def myfunc(n, k, A):
for _ in range(k):
l = np.zeros((n + 1,), dtype=np.int64)
for i, a in enumerate(A[:-1]):
l[max(0, i - a)] += 1
l[min(n, i + a + 1)] -= 1
A = np.cumsum(l)
if np.all(A[:-1] == n):
break
return A
def main():
n, k = list(map(int, input().split()))
A = np.array(list(map(int, input().split())), dtype=np.int64)
A = np.append(A, 0)
print((*myfunc(n, k, A)[:-1]))
if __name__ == "__main__":
main()
| false
| 0
|
[
"-from numba import njit",
"+from numba import jit, i8",
"-@njit",
"+@jit(i8[:](i8, i8, i8[:]), nopython=True, cache=True)"
] | false
| 0.195855
| 0.198407
| 0.987135
|
[
"s325432367",
"s702540236"
] |
u252828980
|
p02623
|
python
|
s720569804
|
s266673299
| 280
| 250
| 40,444
| 40,392
|
Accepted
|
Accepted
| 10.71
|
n,m,k = list(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
for i in range(1,n):
a[i] += a[i-1]
for i in range(1,m):
b[i] += b[i-1]
a = [0]+a
b = [0]+b
ans = 0
ALL = 0
j = m
for i in range(n+1):
if a[i] > k:
continue
else:
while k-a[i] < b[j] :
j -=1
ans = max(ans,i+j)
print(ans)
|
a,b,k = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
from itertools import accumulate
A = list(accumulate(A))
B = list(accumulate(B))
A = [0] + A
B = [0] + B
ans = 0
num = b
for i in range(a+1):
if A[i] > k:
continue
while True :
if A[i] + B[num] > k:
num -=1
else:
ans = max(ans,i+num)
break
print(ans)
| 22
| 23
| 394
| 446
|
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(1, n):
a[i] += a[i - 1]
for i in range(1, m):
b[i] += b[i - 1]
a = [0] + a
b = [0] + b
ans = 0
ALL = 0
j = m
for i in range(n + 1):
if a[i] > k:
continue
else:
while k - a[i] < b[j]:
j -= 1
ans = max(ans, i + j)
print(ans)
|
a, b, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
from itertools import accumulate
A = list(accumulate(A))
B = list(accumulate(B))
A = [0] + A
B = [0] + B
ans = 0
num = b
for i in range(a + 1):
if A[i] > k:
continue
while True:
if A[i] + B[num] > k:
num -= 1
else:
ans = max(ans, i + num)
break
print(ans)
| false
| 4.347826
|
[
"-n, m, k = list(map(int, input().split()))",
"-a = list(map(int, input().split()))",
"-b = list(map(int, input().split()))",
"-for i in range(1, n):",
"- a[i] += a[i - 1]",
"-for i in range(1, m):",
"- b[i] += b[i - 1]",
"-a = [0] + a",
"-b = [0] + b",
"+a, b, k = list(map(int, input().split()))",
"+A = list(map(int, input().split()))",
"+B = list(map(int, input().split()))",
"+from itertools import accumulate",
"+",
"+A = list(accumulate(A))",
"+B = list(accumulate(B))",
"+A = [0] + A",
"+B = [0] + B",
"-ALL = 0",
"-j = m",
"-for i in range(n + 1):",
"- if a[i] > k:",
"+num = b",
"+for i in range(a + 1):",
"+ if A[i] > k:",
"- else:",
"- while k - a[i] < b[j]:",
"- j -= 1",
"- ans = max(ans, i + j)",
"+ while True:",
"+ if A[i] + B[num] > k:",
"+ num -= 1",
"+ else:",
"+ ans = max(ans, i + num)",
"+ break"
] | false
| 0.04325
| 0.045836
| 0.943584
|
[
"s720569804",
"s266673299"
] |
u556589653
|
p02766
|
python
|
s446645950
|
s231517996
| 691
| 17
| 18,864
| 3,060
|
Accepted
|
Accepted
| 97.54
|
import numpy as np
N,K = list(map(int,input().split()))
print((len(np.base_repr(N,K))))
|
N,K = list(map(int,input().split()))
a = N
ans = []
solve = ""
while a>=K:
ans.append(a%K)
a = a//K
ans.append(a)
print((len(ans)))
| 3
| 9
| 84
| 135
|
import numpy as np
N, K = list(map(int, input().split()))
print((len(np.base_repr(N, K))))
|
N, K = list(map(int, input().split()))
a = N
ans = []
solve = ""
while a >= K:
ans.append(a % K)
a = a // K
ans.append(a)
print((len(ans)))
| false
| 66.666667
|
[
"-import numpy as np",
"-",
"-print((len(np.base_repr(N, K))))",
"+a = N",
"+ans = []",
"+solve = \"\"",
"+while a >= K:",
"+ ans.append(a % K)",
"+ a = a // K",
"+ans.append(a)",
"+print((len(ans)))"
] | false
| 0.43101
| 0.035312
| 12.205924
|
[
"s446645950",
"s231517996"
] |
u440566786
|
p02665
|
python
|
s365965241
|
s606974879
| 411
| 74
| 83,568
| 83,604
|
Accepted
|
Accepted
| 82
|
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
n = int(eval(input()))
A = list(map(int, input().split()))
s = sum(A)
if n == 0:
print((1 if A[0] == 1 else -1))
return
if A[0] != 0:
print((-1))
return
not_leaf = 1
# check
for d in range(n + 1):
if not_leaf < A[d]:
print((-1))
return
not_leaf -= A[d]
not_leaf *= 2
res = 0
not_leaf = 1
count = 1 # 枝分かれの個数、最大 s
for d in range(n + 1):
not_leaf -= A[d]
# 最大で not_leaf 個、枝分かれを増やせる
add = min(s - count, not_leaf)
count += add
not_leaf += add
res += not_leaf
# print(d, add)
print((res + 1))
resolve()
|
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
n = int(eval(input()))
A = list(map(int, input().split()))
res = 0
not_leaf = 1
s = sum(A)
count = 1
for d in range(n + 1):
res += not_leaf
if not_leaf < A[d]:
print((-1))
return
not_leaf -= A[d]
add = min(s - count, not_leaf)
count += add
not_leaf += add
print((res if not_leaf == 0 else -1))
resolve()
| 41
| 25
| 864
| 570
|
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda: sys.stdin.readline().rstrip()
def resolve():
n = int(eval(input()))
A = list(map(int, input().split()))
s = sum(A)
if n == 0:
print((1 if A[0] == 1 else -1))
return
if A[0] != 0:
print((-1))
return
not_leaf = 1
# check
for d in range(n + 1):
if not_leaf < A[d]:
print((-1))
return
not_leaf -= A[d]
not_leaf *= 2
res = 0
not_leaf = 1
count = 1 # 枝分かれの個数、最大 s
for d in range(n + 1):
not_leaf -= A[d]
# 最大で not_leaf 個、枝分かれを増やせる
add = min(s - count, not_leaf)
count += add
not_leaf += add
res += not_leaf
# print(d, add)
print((res + 1))
resolve()
|
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda: sys.stdin.readline().rstrip()
def resolve():
n = int(eval(input()))
A = list(map(int, input().split()))
res = 0
not_leaf = 1
s = sum(A)
count = 1
for d in range(n + 1):
res += not_leaf
if not_leaf < A[d]:
print((-1))
return
not_leaf -= A[d]
add = min(s - count, not_leaf)
count += add
not_leaf += add
print((res if not_leaf == 0 else -1))
resolve()
| false
| 39.02439
|
[
"+ res = 0",
"+ not_leaf = 1",
"- if n == 0:",
"- print((1 if A[0] == 1 else -1))",
"- return",
"- if A[0] != 0:",
"- print((-1))",
"- return",
"- not_leaf = 1",
"- # check",
"+ count = 1",
"+ res += not_leaf",
"- not_leaf *= 2",
"- res = 0",
"- not_leaf = 1",
"- count = 1 # 枝分かれの個数、最大 s",
"- for d in range(n + 1):",
"- not_leaf -= A[d]",
"- # 最大で not_leaf 個、枝分かれを増やせる",
"- res += not_leaf",
"- # print(d, add)",
"- print((res + 1))",
"+ print((res if not_leaf == 0 else -1))"
] | false
| 0.037442
| 0.04576
| 0.818223
|
[
"s365965241",
"s606974879"
] |
u077291787
|
p02813
|
python
|
s376349722
|
s066621523
| 32
| 27
| 3,060
| 8,052
|
Accepted
|
Accepted
| 15.62
|
# ABC150C - Count Order
from itertools import permutations
def main():
N, *PQ = list(map(int, open(0).read().split()))
P, Q = PQ[:N], PQ[N:]
a, b = 0, 0
for i, perm in enumerate(permutations(list(range(1, N + 1)), N), 1):
perm = list(perm)
if perm == P:
a = i
if perm == Q:
b = i
ans = abs(a - b)
print(ans)
if __name__ == "__main__":
main()
|
# ABC150C - Count Order
from itertools import permutations
def main():
N = int(eval(input()))
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
perms = list(permutations(list(range(1, N + 1))))
ans = abs(perms.index(P) - perms.index(Q))
print(ans)
if __name__ == "__main__":
main()
| 20
| 15
| 429
| 340
|
# ABC150C - Count Order
from itertools import permutations
def main():
N, *PQ = list(map(int, open(0).read().split()))
P, Q = PQ[:N], PQ[N:]
a, b = 0, 0
for i, perm in enumerate(permutations(list(range(1, N + 1)), N), 1):
perm = list(perm)
if perm == P:
a = i
if perm == Q:
b = i
ans = abs(a - b)
print(ans)
if __name__ == "__main__":
main()
|
# ABC150C - Count Order
from itertools import permutations
def main():
N = int(eval(input()))
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
perms = list(permutations(list(range(1, N + 1))))
ans = abs(perms.index(P) - perms.index(Q))
print(ans)
if __name__ == "__main__":
main()
| false
| 25
|
[
"- N, *PQ = list(map(int, open(0).read().split()))",
"- P, Q = PQ[:N], PQ[N:]",
"- a, b = 0, 0",
"- for i, perm in enumerate(permutations(list(range(1, N + 1)), N), 1):",
"- perm = list(perm)",
"- if perm == P:",
"- a = i",
"- if perm == Q:",
"- b = i",
"- ans = abs(a - b)",
"+ N = int(eval(input()))",
"+ P = tuple(map(int, input().split()))",
"+ Q = tuple(map(int, input().split()))",
"+ perms = list(permutations(list(range(1, N + 1))))",
"+ ans = abs(perms.index(P) - perms.index(Q))"
] | false
| 0.040732
| 0.038253
| 1.064792
|
[
"s376349722",
"s066621523"
] |
u332906195
|
p02762
|
python
|
s768615320
|
s257054962
| 1,862
| 1,646
| 128,084
| 66,464
|
Accepted
|
Accepted
| 11.6
|
class UnionFind:
def __init__(self, n):
# parent[x] < 0 means x is root and abs(parent[x]) == size[x]
self.parent, self.depth = [-1] * n, [0] * n
def find(self, x):
if self.parent[x] < 0:
return x
else:
self.parent[x] = self.find(self.parent[x])
return self.parent[x]
def isSame(self, x, y):
return self.find(x) == self.find(y)
def unite(self, x, y):
if self.isSame(x, y):
return
x, y = self.find(x), self.find(y)
if self.depth[x] > self.depth[y]:
self.parent[x] += self.parent[y]
self.parent[y] = x
else:
self.parent[y] += self.parent[x]
self.parent[x] = y
if self.depth[x] == self.depth[y]:
self.depth[y] += 1
def size(self, x):
return - self.parent[self.find(x)]
N, M, K = list(map(int, input().split()))
Friend, Block = {i: [] for i in range(N)}, {i: [] for i in range(N)}
union = UnionFind(N)
for _ in range(M):
A, B = list(map(int, input().split()))
union.unite(A - 1, B - 1)
Friend[A - 1].append(B - 1)
Friend[B - 1].append(A - 1)
for _ in range(K):
C, D = list(map(int, input().split()))
Block[C - 1].append(D - 1)
Block[D - 1].append(C - 1)
ans = []
for i in range(N):
nBlock = 0
for b in Block[i]:
if union.isSame(i, b):
nBlock += 1
ans.append(str(union.size(i) - 1 - len(Friend[i]) - nBlock))
print((' '.join(ans)))
|
class UnionFind:
def __init__(self, n):
self.p, self.d = [-1] * n, [0] * n
def find(self, x):
if self.p[x] < 0:
return x
else:
self.p[x] = self.find(self.p[x])
return self.p[x]
def isSame(self, x, y):
return self.find(x) == self.find(y)
def unite(self, x, y):
if self.isSame(x, y):
return
x, y = self.find(x), self.find(y)
if self.d[x] > self.d[y]:
self.p[x] += self.p[y]
self.p[y] = x
else:
self.p[y] += self.p[x]
self.p[x] = y
if self.d[x] == self.d[y]:
self.d[y] += 1
def size(self, x):
return - self.p[self.find(x)]
N, M, K = list(map(int, input().split()))
Frd, Blk = {i: [] for i in range(N)}, {i: [] for i in range(N)}
uni = UnionFind(N)
for _ in range(M):
A, B = list(map(int, input().split()))
uni.unite(A - 1, B - 1)
Frd[A - 1].append(B - 1)
Frd[B - 1].append(A - 1)
for _ in range(K):
C, D = list(map(int, input().split()))
Blk[C - 1].append(D - 1)
Blk[D - 1].append(C - 1)
ans = []
for i in range(N):
nBlk = sum([1 for b in Blk[i] if uni.isSame(i, b)])
ans.append(str(uni.size(i) - 1 - len(Frd[i]) - nBlk))
print((' '.join(ans)))
| 55
| 52
| 1,554
| 1,335
|
class UnionFind:
def __init__(self, n):
# parent[x] < 0 means x is root and abs(parent[x]) == size[x]
self.parent, self.depth = [-1] * n, [0] * n
def find(self, x):
if self.parent[x] < 0:
return x
else:
self.parent[x] = self.find(self.parent[x])
return self.parent[x]
def isSame(self, x, y):
return self.find(x) == self.find(y)
def unite(self, x, y):
if self.isSame(x, y):
return
x, y = self.find(x), self.find(y)
if self.depth[x] > self.depth[y]:
self.parent[x] += self.parent[y]
self.parent[y] = x
else:
self.parent[y] += self.parent[x]
self.parent[x] = y
if self.depth[x] == self.depth[y]:
self.depth[y] += 1
def size(self, x):
return -self.parent[self.find(x)]
N, M, K = list(map(int, input().split()))
Friend, Block = {i: [] for i in range(N)}, {i: [] for i in range(N)}
union = UnionFind(N)
for _ in range(M):
A, B = list(map(int, input().split()))
union.unite(A - 1, B - 1)
Friend[A - 1].append(B - 1)
Friend[B - 1].append(A - 1)
for _ in range(K):
C, D = list(map(int, input().split()))
Block[C - 1].append(D - 1)
Block[D - 1].append(C - 1)
ans = []
for i in range(N):
nBlock = 0
for b in Block[i]:
if union.isSame(i, b):
nBlock += 1
ans.append(str(union.size(i) - 1 - len(Friend[i]) - nBlock))
print((" ".join(ans)))
|
class UnionFind:
def __init__(self, n):
self.p, self.d = [-1] * n, [0] * n
def find(self, x):
if self.p[x] < 0:
return x
else:
self.p[x] = self.find(self.p[x])
return self.p[x]
def isSame(self, x, y):
return self.find(x) == self.find(y)
def unite(self, x, y):
if self.isSame(x, y):
return
x, y = self.find(x), self.find(y)
if self.d[x] > self.d[y]:
self.p[x] += self.p[y]
self.p[y] = x
else:
self.p[y] += self.p[x]
self.p[x] = y
if self.d[x] == self.d[y]:
self.d[y] += 1
def size(self, x):
return -self.p[self.find(x)]
N, M, K = list(map(int, input().split()))
Frd, Blk = {i: [] for i in range(N)}, {i: [] for i in range(N)}
uni = UnionFind(N)
for _ in range(M):
A, B = list(map(int, input().split()))
uni.unite(A - 1, B - 1)
Frd[A - 1].append(B - 1)
Frd[B - 1].append(A - 1)
for _ in range(K):
C, D = list(map(int, input().split()))
Blk[C - 1].append(D - 1)
Blk[D - 1].append(C - 1)
ans = []
for i in range(N):
nBlk = sum([1 for b in Blk[i] if uni.isSame(i, b)])
ans.append(str(uni.size(i) - 1 - len(Frd[i]) - nBlk))
print((" ".join(ans)))
| false
| 5.454545
|
[
"- # parent[x] < 0 means x is root and abs(parent[x]) == size[x]",
"- self.parent, self.depth = [-1] * n, [0] * n",
"+ self.p, self.d = [-1] * n, [0] * n",
"- if self.parent[x] < 0:",
"+ if self.p[x] < 0:",
"- self.parent[x] = self.find(self.parent[x])",
"- return self.parent[x]",
"+ self.p[x] = self.find(self.p[x])",
"+ return self.p[x]",
"- if self.depth[x] > self.depth[y]:",
"- self.parent[x] += self.parent[y]",
"- self.parent[y] = x",
"+ if self.d[x] > self.d[y]:",
"+ self.p[x] += self.p[y]",
"+ self.p[y] = x",
"- self.parent[y] += self.parent[x]",
"- self.parent[x] = y",
"- if self.depth[x] == self.depth[y]:",
"- self.depth[y] += 1",
"+ self.p[y] += self.p[x]",
"+ self.p[x] = y",
"+ if self.d[x] == self.d[y]:",
"+ self.d[y] += 1",
"- return -self.parent[self.find(x)]",
"+ return -self.p[self.find(x)]",
"-Friend, Block = {i: [] for i in range(N)}, {i: [] for i in range(N)}",
"-union = UnionFind(N)",
"+Frd, Blk = {i: [] for i in range(N)}, {i: [] for i in range(N)}",
"+uni = UnionFind(N)",
"- union.unite(A - 1, B - 1)",
"- Friend[A - 1].append(B - 1)",
"- Friend[B - 1].append(A - 1)",
"+ uni.unite(A - 1, B - 1)",
"+ Frd[A - 1].append(B - 1)",
"+ Frd[B - 1].append(A - 1)",
"- Block[C - 1].append(D - 1)",
"- Block[D - 1].append(C - 1)",
"+ Blk[C - 1].append(D - 1)",
"+ Blk[D - 1].append(C - 1)",
"- nBlock = 0",
"- for b in Block[i]:",
"- if union.isSame(i, b):",
"- nBlock += 1",
"- ans.append(str(union.size(i) - 1 - len(Friend[i]) - nBlock))",
"+ nBlk = sum([1 for b in Blk[i] if uni.isSame(i, b)])",
"+ ans.append(str(uni.size(i) - 1 - len(Frd[i]) - nBlk))"
] | false
| 0.089271
| 0.048816
| 1.828746
|
[
"s768615320",
"s257054962"
] |
u644907318
|
p02633
|
python
|
s373427998
|
s980388274
| 64
| 28
| 61,940
| 9,160
|
Accepted
|
Accepted
| 56.25
|
def gcd(x,y):
while y>0:
x,y = y,x%y
return x
X = int(eval(input()))
a = gcd(X,360)
Y = (X//a)*360
print((Y//X))
|
def gcd(x,y):
while y>0:
x,y = y,x%y
return x
X = int(eval(input()))
a = gcd(360,X)
b = (X//a)*360
print((b//X))
| 8
| 8
| 127
| 127
|
def gcd(x, y):
while y > 0:
x, y = y, x % y
return x
X = int(eval(input()))
a = gcd(X, 360)
Y = (X // a) * 360
print((Y // X))
|
def gcd(x, y):
while y > 0:
x, y = y, x % y
return x
X = int(eval(input()))
a = gcd(360, X)
b = (X // a) * 360
print((b // X))
| false
| 0
|
[
"-a = gcd(X, 360)",
"-Y = (X // a) * 360",
"-print((Y // X))",
"+a = gcd(360, X)",
"+b = (X // a) * 360",
"+print((b // X))"
] | false
| 0.035515
| 0.041071
| 0.864723
|
[
"s373427998",
"s980388274"
] |
u076917070
|
p02900
|
python
|
s421541677
|
s389989781
| 293
| 166
| 7,252
| 3,064
|
Accepted
|
Accepted
| 43.34
|
import sys
input=sys.stdin.readline
import fractions
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
return divisors
import math
def prime_factorize(n):
a = []
while n % 2 == 0:
a.append(2)
n //= 2
f = 3
while f * f <= n:
if n % f == 0:
a.append(f)
n //= f
else:
f += 2
if n != 1:
a.append(n)
return a
import collections
def main():
A,B = list(map(int, input().split()))
da = make_divisors(A)
db = make_divisors(B)
cds = set(da) & set (db)
P = prime_factorize(max(cds))
P.append(1)
c = list(collections.Counter(P).keys())
x = cds & set(c)
print((len(x)))
if __name__ == '__main__':
main()
|
import sys
input=sys.stdin.readline
def prime_factorize(n):
a = []
while n % 2 == 0:
a.append(2)
n //= 2
f = 3
while f * f <= n:
if n % f == 0:
a.append(f)
n //= f
else:
f += 2
if n != 1:
a.append(n)
return a
def main():
A,B = list(map(int, input().split()))
ps = set(prime_factorize(A)) & set(prime_factorize(B))
print((len(ps)+1))
if __name__ == '__main__':
main()
| 46
| 26
| 920
| 503
|
import sys
input = sys.stdin.readline
import fractions
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
return divisors
import math
def prime_factorize(n):
a = []
while n % 2 == 0:
a.append(2)
n //= 2
f = 3
while f * f <= n:
if n % f == 0:
a.append(f)
n //= f
else:
f += 2
if n != 1:
a.append(n)
return a
import collections
def main():
A, B = list(map(int, input().split()))
da = make_divisors(A)
db = make_divisors(B)
cds = set(da) & set(db)
P = prime_factorize(max(cds))
P.append(1)
c = list(collections.Counter(P).keys())
x = cds & set(c)
print((len(x)))
if __name__ == "__main__":
main()
|
import sys
input = sys.stdin.readline
def prime_factorize(n):
a = []
while n % 2 == 0:
a.append(2)
n //= 2
f = 3
while f * f <= n:
if n % f == 0:
a.append(f)
n //= f
else:
f += 2
if n != 1:
a.append(n)
return a
def main():
A, B = list(map(int, input().split()))
ps = set(prime_factorize(A)) & set(prime_factorize(B))
print((len(ps) + 1))
if __name__ == "__main__":
main()
| false
| 43.478261
|
[
"-import fractions",
"-",
"-",
"-def make_divisors(n):",
"- divisors = []",
"- for i in range(1, int(n**0.5) + 1):",
"- if n % i == 0:",
"- divisors.append(i)",
"- if i != n // i:",
"- divisors.append(n // i)",
"- return divisors",
"-",
"-",
"-import math",
"-import collections",
"-",
"-",
"- da = make_divisors(A)",
"- db = make_divisors(B)",
"- cds = set(da) & set(db)",
"- P = prime_factorize(max(cds))",
"- P.append(1)",
"- c = list(collections.Counter(P).keys())",
"- x = cds & set(c)",
"- print((len(x)))",
"+ ps = set(prime_factorize(A)) & set(prime_factorize(B))",
"+ print((len(ps) + 1))"
] | false
| 0.070538
| 0.046804
| 1.507095
|
[
"s421541677",
"s389989781"
] |
u631755487
|
p02693
|
python
|
s174403205
|
s206884897
| 22
| 20
| 9,172
| 9,084
|
Accepted
|
Accepted
| 9.09
|
k = int(eval(input()))
a, b = list(map(int, input().split()))
if k == 1:
print("OK")
else:
if b//k - a//k == 0 and a%k != 0:
print("NG")
else:
print("OK")
|
k = int(eval(input()))
a, b = list(map(int, input().split()))
if b//k - a//k == 0 and a%k != 0:
print('NG')
else:
print('OK')
| 9
| 7
| 164
| 124
|
k = int(eval(input()))
a, b = list(map(int, input().split()))
if k == 1:
print("OK")
else:
if b // k - a // k == 0 and a % k != 0:
print("NG")
else:
print("OK")
|
k = int(eval(input()))
a, b = list(map(int, input().split()))
if b // k - a // k == 0 and a % k != 0:
print("NG")
else:
print("OK")
| false
| 22.222222
|
[
"-if k == 1:",
"+if b // k - a // k == 0 and a % k != 0:",
"+ print(\"NG\")",
"+else:",
"-else:",
"- if b // k - a // k == 0 and a % k != 0:",
"- print(\"NG\")",
"- else:",
"- print(\"OK\")"
] | false
| 0.116129
| 0.045926
| 2.528618
|
[
"s174403205",
"s206884897"
] |
u143903328
|
p03160
|
python
|
s672092050
|
s629304476
| 555
| 193
| 466,376
| 13,924
|
Accepted
|
Accepted
| 65.23
|
##https://atcoder.jp/contests/dp/tasks/dp_a
N = int(eval(input()))
##N, M = map(int, input().split())
H = list(map(int, input().split()))
F = [0]*N#それぞれに対する回答を格納する箇所
C = [0]*N#Nに飛ぶ時の最小コストの格納
F[0] = 1
F[1] = 1
C[0] = 0
C[1] = abs(H[0] - H[1])
for i in range(2, N):
if C[i-2] + abs(H[i] - H[i-2]) > C[i-1] + abs(H[i] - H[i-1]):
F[i] = F[i-1]
C[i] = C[i-1] + abs(H[i] - H[i-1])
elif C[i-2] + abs(H[i] - H[i-2]) < C[i-1] + abs(H[i] - H[i-1]):
F[i] = F[i-2]
C[i] = C[i-2] + abs(H[i] - H[i-2])
else:
F[i] = F[i-2] + F[i-1]
C[i] = C[i-2] + abs(H[i] - H[i-2])
print((C[N-1]))
|
##https://atcoder.jp/contests/dp/tasks/dp_a
N = int(eval(input()))
##N, M = map(int, input().split())
H = list(map(int, input().split()))
C = [0]*N#Nに飛ぶ時の最小コストの格納
C[0] = 0
C[1] = abs(H[0] - H[1])
for i in range(2, N):
if C[i-2] + abs(H[i] - H[i-2]) > C[i-1] + abs(H[i] - H[i-1]):
C[i] = C[i-1] + abs(H[i] - H[i-1])
elif C[i-2] + abs(H[i] - H[i-2]) < C[i-1] + abs(H[i] - H[i-1]):
C[i] = C[i-2] + abs(H[i] - H[i-2])
else:
C[i] = C[i-2] + abs(H[i] - H[i-2])
print((C[N-1]))
| 25
| 20
| 656
| 531
|
##https://atcoder.jp/contests/dp/tasks/dp_a
N = int(eval(input()))
##N, M = map(int, input().split())
H = list(map(int, input().split()))
F = [0] * N # それぞれに対する回答を格納する箇所
C = [0] * N # Nに飛ぶ時の最小コストの格納
F[0] = 1
F[1] = 1
C[0] = 0
C[1] = abs(H[0] - H[1])
for i in range(2, N):
if C[i - 2] + abs(H[i] - H[i - 2]) > C[i - 1] + abs(H[i] - H[i - 1]):
F[i] = F[i - 1]
C[i] = C[i - 1] + abs(H[i] - H[i - 1])
elif C[i - 2] + abs(H[i] - H[i - 2]) < C[i - 1] + abs(H[i] - H[i - 1]):
F[i] = F[i - 2]
C[i] = C[i - 2] + abs(H[i] - H[i - 2])
else:
F[i] = F[i - 2] + F[i - 1]
C[i] = C[i - 2] + abs(H[i] - H[i - 2])
print((C[N - 1]))
|
##https://atcoder.jp/contests/dp/tasks/dp_a
N = int(eval(input()))
##N, M = map(int, input().split())
H = list(map(int, input().split()))
C = [0] * N # Nに飛ぶ時の最小コストの格納
C[0] = 0
C[1] = abs(H[0] - H[1])
for i in range(2, N):
if C[i - 2] + abs(H[i] - H[i - 2]) > C[i - 1] + abs(H[i] - H[i - 1]):
C[i] = C[i - 1] + abs(H[i] - H[i - 1])
elif C[i - 2] + abs(H[i] - H[i - 2]) < C[i - 1] + abs(H[i] - H[i - 1]):
C[i] = C[i - 2] + abs(H[i] - H[i - 2])
else:
C[i] = C[i - 2] + abs(H[i] - H[i - 2])
print((C[N - 1]))
| false
| 20
|
[
"-F = [0] * N # それぞれに対する回答を格納する箇所",
"-F[0] = 1",
"-F[1] = 1",
"- F[i] = F[i - 1]",
"- F[i] = F[i - 2]",
"- F[i] = F[i - 2] + F[i - 1]"
] | false
| 0.041215
| 0.041184
| 1.000752
|
[
"s672092050",
"s629304476"
] |
u263830634
|
p03608
|
python
|
s567171879
|
s943922200
| 614
| 384
| 25,688
| 42,460
|
Accepted
|
Accepted
| 37.46
|
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
from itertools import permutations
N, M, R = list(map(int, input().split()))
r = list(input().split())
edge = np.array([input().split() for _ in range(M)], dtype = np.int64).T
graph = csr_matrix((edge[2], (edge[:2] - 1)), (N, N))
lst = floyd_warshall(graph, directed = False)
# print (lst)
def calc(path):
cost = 0
s = int(path[0]) - 1
for i in range(1, R):
g = int(path[i]) - 1
cost += lst[s, g]
s = g
return cost
ans = 10 ** 18
for tmp in permutations(r):
# print (tmp)
ans = min(ans, calc(tmp))
print((int(ans)))
|
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7
from itertools import permutations
N, M, r = list(map(int, input().split()))
R = list(map(int, input().split()))
INF = 10 ** 9
G = [[INF] * (N + 1) for _ in range(N + 1)]
for i in range(N + 1):
G[i][i] = 0
for _ in range(M):
A, B, C = list(map(int, input().split()))
G[A][B] = C
G[B][A] = C
for k in range(N + 1):
for i in range(N + 1):
for j in range(N + 1):
G[i][j] = min(G[i][j], G[i][k] + G[k][j])
ans = INF
for tmp in permutations(R):
score = 0
for i in range(r - 1):
score += G[tmp[i]][tmp[i + 1]]
ans = min(ans, score)
print (ans)
| 27
| 34
| 689
| 714
|
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
from itertools import permutations
N, M, R = list(map(int, input().split()))
r = list(input().split())
edge = np.array([input().split() for _ in range(M)], dtype=np.int64).T
graph = csr_matrix((edge[2], (edge[:2] - 1)), (N, N))
lst = floyd_warshall(graph, directed=False)
# print (lst)
def calc(path):
cost = 0
s = int(path[0]) - 1
for i in range(1, R):
g = int(path[i]) - 1
cost += lst[s, g]
s = g
return cost
ans = 10**18
for tmp in permutations(r):
# print (tmp)
ans = min(ans, calc(tmp))
print((int(ans)))
|
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
MOD = 10**9 + 7
from itertools import permutations
N, M, r = list(map(int, input().split()))
R = list(map(int, input().split()))
INF = 10**9
G = [[INF] * (N + 1) for _ in range(N + 1)]
for i in range(N + 1):
G[i][i] = 0
for _ in range(M):
A, B, C = list(map(int, input().split()))
G[A][B] = C
G[B][A] = C
for k in range(N + 1):
for i in range(N + 1):
for j in range(N + 1):
G[i][j] = min(G[i][j], G[i][k] + G[k][j])
ans = INF
for tmp in permutations(R):
score = 0
for i in range(r - 1):
score += G[tmp[i]][tmp[i + 1]]
ans = min(ans, score)
print(ans)
| false
| 20.588235
|
[
"-import numpy as np",
"-from scipy.sparse import csr_matrix",
"-from scipy.sparse.csgraph import floyd_warshall",
"+import sys",
"+",
"+input = sys.stdin.readline",
"+sys.setrecursionlimit(10**9)",
"+MOD = 10**9 + 7",
"-N, M, R = list(map(int, input().split()))",
"-r = list(input().split())",
"-edge = np.array([input().split() for _ in range(M)], dtype=np.int64).T",
"-graph = csr_matrix((edge[2], (edge[:2] - 1)), (N, N))",
"-lst = floyd_warshall(graph, directed=False)",
"-# print (lst)",
"-def calc(path):",
"- cost = 0",
"- s = int(path[0]) - 1",
"- for i in range(1, R):",
"- g = int(path[i]) - 1",
"- cost += lst[s, g]",
"- s = g",
"- return cost",
"-",
"-",
"-ans = 10**18",
"-for tmp in permutations(r):",
"- # print (tmp)",
"- ans = min(ans, calc(tmp))",
"-print((int(ans)))",
"+N, M, r = list(map(int, input().split()))",
"+R = list(map(int, input().split()))",
"+INF = 10**9",
"+G = [[INF] * (N + 1) for _ in range(N + 1)]",
"+for i in range(N + 1):",
"+ G[i][i] = 0",
"+for _ in range(M):",
"+ A, B, C = list(map(int, input().split()))",
"+ G[A][B] = C",
"+ G[B][A] = C",
"+for k in range(N + 1):",
"+ for i in range(N + 1):",
"+ for j in range(N + 1):",
"+ G[i][j] = min(G[i][j], G[i][k] + G[k][j])",
"+ans = INF",
"+for tmp in permutations(R):",
"+ score = 0",
"+ for i in range(r - 1):",
"+ score += G[tmp[i]][tmp[i + 1]]",
"+ ans = min(ans, score)",
"+print(ans)"
] | false
| 0.233023
| 0.036395
| 6.402566
|
[
"s567171879",
"s943922200"
] |
u692336506
|
p03494
|
python
|
s798052276
|
s693514073
| 32
| 28
| 9,092
| 9,140
|
Accepted
|
Accepted
| 12.5
|
N = int(eval(input()))
A = list(map(int, input().split()))
# 操作回数
counter = 0
# 操作が行えなくなるまで操作を行う
while True:
# // 操作が行えるかどうかを判定する
can_do = True
for i in range(N):
if A[i] % 2 == 1:
can_do = False
# 操作を行えないならば、ループを打ち切る
if not can_do:
break
# 操作を行えるならば、操作を行う
for i in range(N):
A[i] //= 2
# 操作回数をカウントする
counter += 1
print(counter)
|
N = int(eval(input()))
A = list(map(int, input().split()))
counter = 0
while not 1 in [a % 2 for a in A]:
A = [a // 2 for a in A]
counter += 1
print(counter)
| 26
| 8
| 425
| 167
|
N = int(eval(input()))
A = list(map(int, input().split()))
# 操作回数
counter = 0
# 操作が行えなくなるまで操作を行う
while True:
# // 操作が行えるかどうかを判定する
can_do = True
for i in range(N):
if A[i] % 2 == 1:
can_do = False
# 操作を行えないならば、ループを打ち切る
if not can_do:
break
# 操作を行えるならば、操作を行う
for i in range(N):
A[i] //= 2
# 操作回数をカウントする
counter += 1
print(counter)
|
N = int(eval(input()))
A = list(map(int, input().split()))
counter = 0
while not 1 in [a % 2 for a in A]:
A = [a // 2 for a in A]
counter += 1
print(counter)
| false
| 69.230769
|
[
"-# 操作回数",
"-# 操作が行えなくなるまで操作を行う",
"-while True:",
"- # // 操作が行えるかどうかを判定する",
"- can_do = True",
"- for i in range(N):",
"- if A[i] % 2 == 1:",
"- can_do = False",
"- # 操作を行えないならば、ループを打ち切る",
"- if not can_do:",
"- break",
"- # 操作を行えるならば、操作を行う",
"- for i in range(N):",
"- A[i] //= 2",
"- # 操作回数をカウントする",
"+while not 1 in [a % 2 for a in A]:",
"+ A = [a // 2 for a in A]"
] | false
| 0.041379
| 0.04169
| 0.992541
|
[
"s798052276",
"s693514073"
] |
u111365362
|
p03038
|
python
|
s457261079
|
s988127057
| 931
| 776
| 82,200
| 88,820
|
Accepted
|
Accepted
| 16.65
|
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
a.sort()
d = []
for _ in range(m):
b,c = list(map(int,input().split()))
d.append([c,b])
d.sort(reverse = True)
e = []
f = 0
for j in range(m):
for k in range(d[j][1]):
e.append(d[j][0])
f += 1
if f == n:
break
else:
continue
break
else:
e += [0] * (n-len(e))
ans = 0
#print(a)
#print(e)
for i in range(n):
ans += max(a[i],e[i])
print(ans)
|
#15:40
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
a.sort()
bc = []
for _ in range(m):
bc.append(list(map(int,input().split())))
bc.sort(key=lambda x: -x[1])
d = []
dl = 0
for x in bc:
b,c = x
d += [c] * b
dl += b
if dl >= n:
break
if dl < n:
d += [0] * (n-dl)
ans = []
for i in range(n):
ans.append(max(a[i],d[i]))
#print(a)
#print(d)
#print(ans)
print((sum(ans)))
| 27
| 25
| 460
| 427
|
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
d = []
for _ in range(m):
b, c = list(map(int, input().split()))
d.append([c, b])
d.sort(reverse=True)
e = []
f = 0
for j in range(m):
for k in range(d[j][1]):
e.append(d[j][0])
f += 1
if f == n:
break
else:
continue
break
else:
e += [0] * (n - len(e))
ans = 0
# print(a)
# print(e)
for i in range(n):
ans += max(a[i], e[i])
print(ans)
|
# 15:40
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
bc = []
for _ in range(m):
bc.append(list(map(int, input().split())))
bc.sort(key=lambda x: -x[1])
d = []
dl = 0
for x in bc:
b, c = x
d += [c] * b
dl += b
if dl >= n:
break
if dl < n:
d += [0] * (n - dl)
ans = []
for i in range(n):
ans.append(max(a[i], d[i]))
# print(a)
# print(d)
# print(ans)
print((sum(ans)))
| false
| 7.407407
|
[
"+# 15:40",
"+bc = []",
"+for _ in range(m):",
"+ bc.append(list(map(int, input().split())))",
"+bc.sort(key=lambda x: -x[1])",
"-for _ in range(m):",
"- b, c = list(map(int, input().split()))",
"- d.append([c, b])",
"-d.sort(reverse=True)",
"-e = []",
"-f = 0",
"-for j in range(m):",
"- for k in range(d[j][1]):",
"- e.append(d[j][0])",
"- f += 1",
"- if f == n:",
"- break",
"- else:",
"- continue",
"- break",
"-else:",
"- e += [0] * (n - len(e))",
"-ans = 0",
"+dl = 0",
"+for x in bc:",
"+ b, c = x",
"+ d += [c] * b",
"+ dl += b",
"+ if dl >= n:",
"+ break",
"+if dl < n:",
"+ d += [0] * (n - dl)",
"+ans = []",
"+for i in range(n):",
"+ ans.append(max(a[i], d[i]))",
"-# print(e)",
"-for i in range(n):",
"- ans += max(a[i], e[i])",
"-print(ans)",
"+# print(d)",
"+# print(ans)",
"+print((sum(ans)))"
] | false
| 0.038084
| 0.037245
| 1.022511
|
[
"s457261079",
"s988127057"
] |
u693933222
|
p02954
|
python
|
s459568688
|
s047915115
| 224
| 140
| 6,672
| 4,468
|
Accepted
|
Accepted
| 37.5
|
S = input()
S = S[1:-1]
#print(S)
S = S.split("LR")
ans = []
for i in range(len(S)):
tp = "R" + S[i] + "L"
#print(tp)
rn = len(tp.split("RL")[0])+1
ln = len(tp) - rn
#print(rn,ln)
for k in range(rn-1):
ans.append(0)
ans.append(-(-rn//2) + ln//2)
ans.append(-(-ln//2) + rn//2)
for k in range(ln-1):
ans.append(0)
#print()
#print(S)
[print(str(i) + " ",end="") for i in ans]
print()
|
S = eval(input())
S = S[1:-1]
#print(S)
S = S.split("LR")
ans = ""
for i in range(len(S)):
tp = "R" + S[i] + "L"
#print(tp)
rn = len(tp.split("RL")[0])+1
ln = len(tp) - rn
#print(rn,ln)
for k in range(rn-1):
ans += "0 "
ans += str(-(-rn//2) + ln//2) +" "
ans += str(-(-ln//2) + rn//2) +" "
for k in range(ln-1):
ans += "0 "
#print()
#print(S)
print(ans)
| 23
| 22
| 461
| 427
|
S = input()
S = S[1:-1]
# print(S)
S = S.split("LR")
ans = []
for i in range(len(S)):
tp = "R" + S[i] + "L"
# print(tp)
rn = len(tp.split("RL")[0]) + 1
ln = len(tp) - rn
# print(rn,ln)
for k in range(rn - 1):
ans.append(0)
ans.append(-(-rn // 2) + ln // 2)
ans.append(-(-ln // 2) + rn // 2)
for k in range(ln - 1):
ans.append(0)
# print()
# print(S)
[print(str(i) + " ", end="") for i in ans]
print()
|
S = eval(input())
S = S[1:-1]
# print(S)
S = S.split("LR")
ans = ""
for i in range(len(S)):
tp = "R" + S[i] + "L"
# print(tp)
rn = len(tp.split("RL")[0]) + 1
ln = len(tp) - rn
# print(rn,ln)
for k in range(rn - 1):
ans += "0 "
ans += str(-(-rn // 2) + ln // 2) + " "
ans += str(-(-ln // 2) + rn // 2) + " "
for k in range(ln - 1):
ans += "0 "
# print()
# print(S)
print(ans)
| false
| 4.347826
|
[
"-S = input()",
"+S = eval(input())",
"-ans = []",
"+ans = \"\"",
"- ans.append(0)",
"- ans.append(-(-rn // 2) + ln // 2)",
"- ans.append(-(-ln // 2) + rn // 2)",
"+ ans += \"0 \"",
"+ ans += str(-(-rn // 2) + ln // 2) + \" \"",
"+ ans += str(-(-ln // 2) + rn // 2) + \" \"",
"- ans.append(0)",
"+ ans += \"0 \"",
"-[print(str(i) + \" \", end=\"\") for i in ans]",
"-print()",
"+print(ans)"
] | false
| 0.03403
| 0.033632
| 1.011829
|
[
"s459568688",
"s047915115"
] |
u777923818
|
p03289
|
python
|
s443001047
|
s718609889
| 20
| 17
| 3,316
| 3,060
|
Accepted
|
Accepted
| 15
|
from collections import Counter
S = eval(input())
C = Counter(S[2:-1])
patience = 1
for s in S[1:]:
if s == "C" and patience:
patience -= 1
continue
if s.isupper():
print("WA")
exit()
if S[0] == "A" and C["C"] == 1:
print("AC")
else:
print("WA")
|
def inpl(): return list(map(int, input().split()))
S = eval(input())
ok = False
if S[0] == "A" and S[2:-1].count("C") == 1:
u = 0
for s in S[1:]:
u += s.isupper()
if u == 1:
ok = True
if (ok):
print("AC")
else:
print("WA")
| 16
| 13
| 303
| 264
|
from collections import Counter
S = eval(input())
C = Counter(S[2:-1])
patience = 1
for s in S[1:]:
if s == "C" and patience:
patience -= 1
continue
if s.isupper():
print("WA")
exit()
if S[0] == "A" and C["C"] == 1:
print("AC")
else:
print("WA")
|
def inpl():
return list(map(int, input().split()))
S = eval(input())
ok = False
if S[0] == "A" and S[2:-1].count("C") == 1:
u = 0
for s in S[1:]:
u += s.isupper()
if u == 1:
ok = True
if ok:
print("AC")
else:
print("WA")
| false
| 18.75
|
[
"-from collections import Counter",
"+def inpl():",
"+ return list(map(int, input().split()))",
"+",
"-C = Counter(S[2:-1])",
"-patience = 1",
"-for s in S[1:]:",
"- if s == \"C\" and patience:",
"- patience -= 1",
"- continue",
"- if s.isupper():",
"- print(\"WA\")",
"- exit()",
"-if S[0] == \"A\" and C[\"C\"] == 1:",
"+ok = False",
"+if S[0] == \"A\" and S[2:-1].count(\"C\") == 1:",
"+ u = 0",
"+ for s in S[1:]:",
"+ u += s.isupper()",
"+ if u == 1:",
"+ ok = True",
"+if ok:"
] | false
| 0.093407
| 0.045956
| 2.03253
|
[
"s443001047",
"s718609889"
] |
u057109575
|
p03221
|
python
|
s634975269
|
s761136088
| 624
| 544
| 47,328
| 112,520
|
Accepted
|
Accepted
| 12.82
|
N, M = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(M)]
ans = [''] * M
num = [1] * N
for i, v in sorted(enumerate(X), key=lambda x: (x[1][0], x[1][1])):
ans[i] = '{:06}{:06}'.format(v[0], num[v[0] - 1])
num[v[0] - 1] += 1
print(('\n'.join(ans)))
|
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]
res = [""] * M
ctr = [0] * (N + 1)
for i, (p, y) in sorted(enumerate(X), key=lambda x: (x[1][0], x[1][1])):
ctr[p] += 1
res[i] = "{:0>6}{:0>6}".format(p, ctr[p])
print(*res, sep="\n")
| 10
| 11
| 299
| 294
|
N, M = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(M)]
ans = [""] * M
num = [1] * N
for i, v in sorted(enumerate(X), key=lambda x: (x[1][0], x[1][1])):
ans[i] = "{:06}{:06}".format(v[0], num[v[0] - 1])
num[v[0] - 1] += 1
print(("\n".join(ans)))
|
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]
res = [""] * M
ctr = [0] * (N + 1)
for i, (p, y) in sorted(enumerate(X), key=lambda x: (x[1][0], x[1][1])):
ctr[p] += 1
res[i] = "{:0>6}{:0>6}".format(p, ctr[p])
print(*res, sep="\n")
| false
| 9.090909
|
[
"-N, M = list(map(int, input().split()))",
"+N, M = map(int, input().split())",
"-ans = [\"\"] * M",
"-num = [1] * N",
"-for i, v in sorted(enumerate(X), key=lambda x: (x[1][0], x[1][1])):",
"- ans[i] = \"{:06}{:06}\".format(v[0], num[v[0] - 1])",
"- num[v[0] - 1] += 1",
"-print((\"\\n\".join(ans)))",
"+res = [\"\"] * M",
"+ctr = [0] * (N + 1)",
"+for i, (p, y) in sorted(enumerate(X), key=lambda x: (x[1][0], x[1][1])):",
"+ ctr[p] += 1",
"+ res[i] = \"{:0>6}{:0>6}\".format(p, ctr[p])",
"+print(*res, sep=\"\\n\")"
] | false
| 0.035669
| 0.042198
| 0.84527
|
[
"s634975269",
"s761136088"
] |
u545368057
|
p03212
|
python
|
s472506289
|
s542764442
| 85
| 55
| 3,316
| 3,064
|
Accepted
|
Accepted
| 35.29
|
from collections import deque
N = int(eval(input()))
stack = deque(["0"])
cnt = 0
while len(stack)>0:
c = stack.pop()
for s in "357":
cs = c + s
# print(cs)
if int(cs)<=N:
stack.append(cs)
if cs.count("3")*cs.count("5")*cs.count("7")>0:
cnt += 1
print(cnt)
|
"""
dfsでとき直し114
7,5,3がそれぞれ1回以上現れる
3-3-3
-5
-7
-5-3
-5
-7
-7-3
-5
-7
とかそういうヤツ
3 33 35 37 5
"""
import sys
sys.setrecursionlimit(100000)
cnt = 0
num = "0"
X = int(eval(input()))
def dfs(num,is3,is5,is7):
# print(num,is3 and is5 and is7)
global cnt
if is3 and is5 and is7:
cnt += 1
N = "357"
for n in N:
if int(num+n) > X: continue #終了条件
if n == "3":
dfs(num+n,True,is5,is7)
elif n == "5":
dfs(num+n,is3,True,is7)
elif n == "7":
dfs(num+n,is3,is5,True)
dfs("0",0,0,0)
print(cnt)
| 14
| 42
| 335
| 634
|
from collections import deque
N = int(eval(input()))
stack = deque(["0"])
cnt = 0
while len(stack) > 0:
c = stack.pop()
for s in "357":
cs = c + s
# print(cs)
if int(cs) <= N:
stack.append(cs)
if cs.count("3") * cs.count("5") * cs.count("7") > 0:
cnt += 1
print(cnt)
|
"""
dfsでとき直し114
7,5,3がそれぞれ1回以上現れる
3-3-3
-5
-7
-5-3
-5
-7
-7-3
-5
-7
とかそういうヤツ
3 33 35 37 5
"""
import sys
sys.setrecursionlimit(100000)
cnt = 0
num = "0"
X = int(eval(input()))
def dfs(num, is3, is5, is7):
# print(num,is3 and is5 and is7)
global cnt
if is3 and is5 and is7:
cnt += 1
N = "357"
for n in N:
if int(num + n) > X:
continue # 終了条件
if n == "3":
dfs(num + n, True, is5, is7)
elif n == "5":
dfs(num + n, is3, True, is7)
elif n == "7":
dfs(num + n, is3, is5, True)
dfs("0", 0, 0, 0)
print(cnt)
| false
| 66.666667
|
[
"-from collections import deque",
"+\"\"\"",
"+dfsでとき直し114",
"+7,5,3がそれぞれ1回以上現れる",
"+3-3-3",
"+ -5",
"+ -7",
"+ -5-3",
"+ -5",
"+ -7",
"+ -7-3",
"+ -5",
"+ -7",
"+とかそういうヤツ",
"+3 33 35 37 5",
"+\"\"\"",
"+import sys",
"-N = int(eval(input()))",
"-stack = deque([\"0\"])",
"+sys.setrecursionlimit(100000)",
"-while len(stack) > 0:",
"- c = stack.pop()",
"- for s in \"357\":",
"- cs = c + s",
"- # print(cs)",
"- if int(cs) <= N:",
"- stack.append(cs)",
"- if cs.count(\"3\") * cs.count(\"5\") * cs.count(\"7\") > 0:",
"- cnt += 1",
"+num = \"0\"",
"+X = int(eval(input()))",
"+",
"+",
"+def dfs(num, is3, is5, is7):",
"+ # print(num,is3 and is5 and is7)",
"+ global cnt",
"+ if is3 and is5 and is7:",
"+ cnt += 1",
"+ N = \"357\"",
"+ for n in N:",
"+ if int(num + n) > X:",
"+ continue # 終了条件",
"+ if n == \"3\":",
"+ dfs(num + n, True, is5, is7)",
"+ elif n == \"5\":",
"+ dfs(num + n, is3, True, is7)",
"+ elif n == \"7\":",
"+ dfs(num + n, is3, is5, True)",
"+",
"+",
"+dfs(\"0\", 0, 0, 0)"
] | false
| 0.048241
| 0.055266
| 0.872882
|
[
"s472506289",
"s542764442"
] |
u203843959
|
p02596
|
python
|
s180921984
|
s170759188
| 81
| 72
| 63,196
| 63,316
|
Accepted
|
Accepted
| 11.11
|
import sys
K=int(eval(input()))
if K%2==0 or K%5==0:
print((-1))
sys.exit(0)
k_mod=0
seven_k=0
for i in range(1,K+1):
k_mod=10*k_mod+7
k_mod%=K
if k_mod==0:
print(i)
break
else:
print((-1))
|
K=int(eval(input()))
k_mod=0
for i in range(1,K+1):
k_mod=(10*k_mod+7)%K
if k_mod==0:
print(i)
break
else:
print((-1))
| 17
| 10
| 217
| 134
|
import sys
K = int(eval(input()))
if K % 2 == 0 or K % 5 == 0:
print((-1))
sys.exit(0)
k_mod = 0
seven_k = 0
for i in range(1, K + 1):
k_mod = 10 * k_mod + 7
k_mod %= K
if k_mod == 0:
print(i)
break
else:
print((-1))
|
K = int(eval(input()))
k_mod = 0
for i in range(1, K + 1):
k_mod = (10 * k_mod + 7) % K
if k_mod == 0:
print(i)
break
else:
print((-1))
| false
| 41.176471
|
[
"-import sys",
"-",
"-if K % 2 == 0 or K % 5 == 0:",
"- print((-1))",
"- sys.exit(0)",
"-seven_k = 0",
"- k_mod = 10 * k_mod + 7",
"- k_mod %= K",
"+ k_mod = (10 * k_mod + 7) % K"
] | false
| 0.090696
| 0.095418
| 0.950518
|
[
"s180921984",
"s170759188"
] |
u631277801
|
p03209
|
python
|
s082374559
|
s399220633
| 19
| 17
| 3,064
| 3,064
|
Accepted
|
Accepted
| 10.53
|
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
n,x = li()
top = [4*pow(2,i) - 3 for i in range(n+1)]
med = [pow(2,i+1) - 1 for i in range(n+1)]
bot = [1 for _ in range(n+1)]
def findPattyNum(level:int, lay: int):
if level == 0 and lay == 1:
return 1
if lay == 4*pow(2,level)-3:
return pow(2,level+1) - 1
elif pow(2,level+1)-1 < lay < 4*pow(2,level)-3:
return pow(2,level) + findPattyNum(level-1, lay - (pow(2,level+1)-1))
elif lay == pow(2,level+1)-1:
return pow(2,level)
elif 1 < lay < pow(2,level+1)-1:
return findPattyNum(level-1, lay-1)
elif lay == 1:
return 0
print((findPattyNum(n,x)))
|
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x) - 1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
def rec(n: int, x: int, a: list, p: list) -> int:
if x <= 0:
raise ValueError
elif n == 0:
return 1
elif x == 1:
return 0
elif 1 < x < a[n-1] + 2:
return rec(n-1, x-1, a, p)
elif x == a[n-1] + 2:
return p[n-1] + 1
elif a[n-1] + 2 < x < 2*a[n-1] + 3:
return p[n-1] + 1 + rec(n-1, x - a[n-1] - 2, a, p)
elif x == 2*a[n-1] + 3:
return 2 * p[n-1] + 1
n,x = li()
a = [1]
p = [1]
for i in range(n):
a.append(2*a[-1]+3)
p.append(2*p[-1]+1)
print((rec(n, x, a, p)))
| 40
| 46
| 1,116
| 1,034
|
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li():
return list(map(int, stdin.readline().split()))
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return list(map(float, stdin.readline().split()))
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()
def lc():
return list(ns())
def ni():
return int(stdin.readline())
def nf():
return float(stdin.readline())
n, x = li()
top = [4 * pow(2, i) - 3 for i in range(n + 1)]
med = [pow(2, i + 1) - 1 for i in range(n + 1)]
bot = [1 for _ in range(n + 1)]
def findPattyNum(level: int, lay: int):
if level == 0 and lay == 1:
return 1
if lay == 4 * pow(2, level) - 3:
return pow(2, level + 1) - 1
elif pow(2, level + 1) - 1 < lay < 4 * pow(2, level) - 3:
return pow(2, level) + findPattyNum(level - 1, lay - (pow(2, level + 1) - 1))
elif lay == pow(2, level + 1) - 1:
return pow(2, level)
elif 1 < lay < pow(2, level + 1) - 1:
return findPattyNum(level - 1, lay - 1)
elif lay == 1:
return 0
print((findPattyNum(n, x)))
|
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**7)
def li():
return list(map(int, stdin.readline().split()))
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return list(map(float, stdin.readline().split()))
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()
def lc():
return list(ns())
def ni():
return int(stdin.readline())
def nf():
return float(stdin.readline())
def rec(n: int, x: int, a: list, p: list) -> int:
if x <= 0:
raise ValueError
elif n == 0:
return 1
elif x == 1:
return 0
elif 1 < x < a[n - 1] + 2:
return rec(n - 1, x - 1, a, p)
elif x == a[n - 1] + 2:
return p[n - 1] + 1
elif a[n - 1] + 2 < x < 2 * a[n - 1] + 3:
return p[n - 1] + 1 + rec(n - 1, x - a[n - 1] - 2, a, p)
elif x == 2 * a[n - 1] + 3:
return 2 * p[n - 1] + 1
n, x = li()
a = [1]
p = [1]
for i in range(n):
a.append(2 * a[-1] + 3)
p.append(2 * p[-1] + 1)
print((rec(n, x, a, p)))
| false
| 13.043478
|
[
"-sys.setrecursionlimit(10**5)",
"+sys.setrecursionlimit(10**7)",
"-n, x = li()",
"-top = [4 * pow(2, i) - 3 for i in range(n + 1)]",
"-med = [pow(2, i + 1) - 1 for i in range(n + 1)]",
"-bot = [1 for _ in range(n + 1)]",
"+def rec(n: int, x: int, a: list, p: list) -> int:",
"+ if x <= 0:",
"+ raise ValueError",
"+ elif n == 0:",
"+ return 1",
"+ elif x == 1:",
"+ return 0",
"+ elif 1 < x < a[n - 1] + 2:",
"+ return rec(n - 1, x - 1, a, p)",
"+ elif x == a[n - 1] + 2:",
"+ return p[n - 1] + 1",
"+ elif a[n - 1] + 2 < x < 2 * a[n - 1] + 3:",
"+ return p[n - 1] + 1 + rec(n - 1, x - a[n - 1] - 2, a, p)",
"+ elif x == 2 * a[n - 1] + 3:",
"+ return 2 * p[n - 1] + 1",
"-def findPattyNum(level: int, lay: int):",
"- if level == 0 and lay == 1:",
"- return 1",
"- if lay == 4 * pow(2, level) - 3:",
"- return pow(2, level + 1) - 1",
"- elif pow(2, level + 1) - 1 < lay < 4 * pow(2, level) - 3:",
"- return pow(2, level) + findPattyNum(level - 1, lay - (pow(2, level + 1) - 1))",
"- elif lay == pow(2, level + 1) - 1:",
"- return pow(2, level)",
"- elif 1 < lay < pow(2, level + 1) - 1:",
"- return findPattyNum(level - 1, lay - 1)",
"- elif lay == 1:",
"- return 0",
"-",
"-",
"-print((findPattyNum(n, x)))",
"+n, x = li()",
"+a = [1]",
"+p = [1]",
"+for i in range(n):",
"+ a.append(2 * a[-1] + 3)",
"+ p.append(2 * p[-1] + 1)",
"+print((rec(n, x, a, p)))"
] | false
| 0.068716
| 0.070767
| 0.971023
|
[
"s082374559",
"s399220633"
] |
u788137651
|
p03069
|
python
|
s004011809
|
s947771976
| 843
| 721
| 25,848
| 18,356
|
Accepted
|
Accepted
| 14.47
|
from numpy import cumsum
N = int(eval(input()))
S = eval(input())
ss = S.replace("#", "1").replace(".", "0")
* ls, = list(map(int, ss))
cum_ls = cumsum(ls)
first_black = -1
last_black = N
for i in range(N):
if S[i] == "#":
first_black = i
break
for i in reversed(list(range(N))):
if S[i] == "#":
last_black = i
else:
break
if first_black == -1:
print((0))
else:
# print(cum_ls)
mans = 10**10
for i in range(N):
#print(" ", cum_ls[i], (N-(i+1) - (cum_ls[-1] - cum_ls[i])))
mans = min(mans, cum_ls[i] + (N-(i+1) - (cum_ls[-1] - cum_ls[i])))
# print(mans)
ans = min(S[first_black:].count("."), S[first_black:].count(
"#"), S[:last_black].count("#"), mans)
print(ans)
|
from numpy import cumsum
N = int(eval(input()))
S = eval(input())
# 黒を1,白を0として リスト化
ss = S.replace("#", "1").replace(".", "0")
* ls, = list(map(int, ss))
# 累積和
cum_ls = cumsum(ls)
# 左から何個目に初めてblackが出てくるか
first_black = -1
for i in range(N):
if S[i] == "#":
first_black = i
break
# blackが後ろから何個まで続いているか
last_black = N
for i in reversed(list(range(N))):
if S[i] == "#":
last_black = i
else:
break
if first_black == -1:
print((0))
else:
# i番目より左をすべて白、それより右をすべて黒にしたとき何回塗り替えるか
ans_temp = 10 ** 10
for i in range(N):
ans_temp = min(ans_temp, cum_ls[i] +
(N-(i+1) - (cum_ls[-1] - cum_ls[i])))
ans = min(S[first_black:].count("."), S[first_black:].count(
"#"), S[:last_black].count("#"), ans_temp)
print(ans)
| 32
| 39
| 773
| 826
|
from numpy import cumsum
N = int(eval(input()))
S = eval(input())
ss = S.replace("#", "1").replace(".", "0")
(*ls,) = list(map(int, ss))
cum_ls = cumsum(ls)
first_black = -1
last_black = N
for i in range(N):
if S[i] == "#":
first_black = i
break
for i in reversed(list(range(N))):
if S[i] == "#":
last_black = i
else:
break
if first_black == -1:
print((0))
else:
# print(cum_ls)
mans = 10**10
for i in range(N):
# print(" ", cum_ls[i], (N-(i+1) - (cum_ls[-1] - cum_ls[i])))
mans = min(mans, cum_ls[i] + (N - (i + 1) - (cum_ls[-1] - cum_ls[i])))
# print(mans)
ans = min(
S[first_black:].count("."),
S[first_black:].count("#"),
S[:last_black].count("#"),
mans,
)
print(ans)
|
from numpy import cumsum
N = int(eval(input()))
S = eval(input())
# 黒を1,白を0として リスト化
ss = S.replace("#", "1").replace(".", "0")
(*ls,) = list(map(int, ss))
# 累積和
cum_ls = cumsum(ls)
# 左から何個目に初めてblackが出てくるか
first_black = -1
for i in range(N):
if S[i] == "#":
first_black = i
break
# blackが後ろから何個まで続いているか
last_black = N
for i in reversed(list(range(N))):
if S[i] == "#":
last_black = i
else:
break
if first_black == -1:
print((0))
else:
# i番目より左をすべて白、それより右をすべて黒にしたとき何回塗り替えるか
ans_temp = 10**10
for i in range(N):
ans_temp = min(ans_temp, cum_ls[i] + (N - (i + 1) - (cum_ls[-1] - cum_ls[i])))
ans = min(
S[first_black:].count("."),
S[first_black:].count("#"),
S[:last_black].count("#"),
ans_temp,
)
print(ans)
| false
| 17.948718
|
[
"+# 黒を1,白を0として リスト化",
"+# 累積和",
"+# 左から何個目に初めてblackが出てくるか",
"-last_black = N",
"+# blackが後ろから何個まで続いているか",
"+last_black = N",
"- # print(cum_ls)",
"- mans = 10**10",
"+ # i番目より左をすべて白、それより右をすべて黒にしたとき何回塗り替えるか",
"+ ans_temp = 10**10",
"- # print(\" \", cum_ls[i], (N-(i+1) - (cum_ls[-1] - cum_ls[i])))",
"- mans = min(mans, cum_ls[i] + (N - (i + 1) - (cum_ls[-1] - cum_ls[i])))",
"- # print(mans)",
"+ ans_temp = min(ans_temp, cum_ls[i] + (N - (i + 1) - (cum_ls[-1] - cum_ls[i])))",
"- mans,",
"+ ans_temp,"
] | false
| 0.153497
| 0.154333
| 0.994586
|
[
"s004011809",
"s947771976"
] |
u952708174
|
p03240
|
python
|
s496099438
|
s113029729
| 200
| 28
| 3,064
| 3,064
|
Accepted
|
Accepted
| 86
|
def c_pyramid(N, Pos):
from itertools import product
# 中心座標を全探索
for cx, cy in product(list(range(101)), repeat=2):
# ピラミッドの高さを求める
for x, y, h in Pos:
if h > 0:
height = h + abs(cx - x) + abs(cy - y)
# ピラミッドの高さが得られた情報に適合するか調べる
for x, y, h in Pos:
if h != max((height - abs(cx - x) - abs(cy - y)), 0):
break
else:
ans = [cx, cy, height]
break
ans = '{0} {1} {2}'.format(*ans)
return ans
N = int(eval(input()))
Pos = [[int(i) for i in input().split()] for j in range(N)]
print((c_pyramid(N, Pos)))
|
def c_pyramid():
N = int(eval(input()))
Pos = [[int(i) for i in input().split()] for j in range(N)]
# 与えられた情報から頂点座標を一意に得られるので、h=0にならない
x, y, h = sorted(Pos, key=lambda x: x[2])[-1]
# 中心座標を全探索
for cx in range(101):
for cy in range(101):
# 頂点の高さ height を決めたとき、すべての座標の情報と一致するか?
height = h + abs(x - cx) + abs(y - cy) # 定義式から逆算
if all(h_i == max(height - abs(x_i - cx) - abs(y_i - cy), 0)
for x_i, y_i, h_i in Pos):
return '{} {} {}'.format(cx, cy, height) # すべて一致した。これが解
return None
print((c_pyramid()))
| 21
| 16
| 641
| 617
|
def c_pyramid(N, Pos):
from itertools import product
# 中心座標を全探索
for cx, cy in product(list(range(101)), repeat=2):
# ピラミッドの高さを求める
for x, y, h in Pos:
if h > 0:
height = h + abs(cx - x) + abs(cy - y)
# ピラミッドの高さが得られた情報に適合するか調べる
for x, y, h in Pos:
if h != max((height - abs(cx - x) - abs(cy - y)), 0):
break
else:
ans = [cx, cy, height]
break
ans = "{0} {1} {2}".format(*ans)
return ans
N = int(eval(input()))
Pos = [[int(i) for i in input().split()] for j in range(N)]
print((c_pyramid(N, Pos)))
|
def c_pyramid():
N = int(eval(input()))
Pos = [[int(i) for i in input().split()] for j in range(N)]
# 与えられた情報から頂点座標を一意に得られるので、h=0にならない
x, y, h = sorted(Pos, key=lambda x: x[2])[-1]
# 中心座標を全探索
for cx in range(101):
for cy in range(101):
# 頂点の高さ height を決めたとき、すべての座標の情報と一致するか?
height = h + abs(x - cx) + abs(y - cy) # 定義式から逆算
if all(
h_i == max(height - abs(x_i - cx) - abs(y_i - cy), 0)
for x_i, y_i, h_i in Pos
):
return "{} {} {}".format(cx, cy, height) # すべて一致した。これが解
return None
print((c_pyramid()))
| false
| 23.809524
|
[
"-def c_pyramid(N, Pos):",
"- from itertools import product",
"-",
"+def c_pyramid():",
"+ N = int(eval(input()))",
"+ Pos = [[int(i) for i in input().split()] for j in range(N)]",
"+ # 与えられた情報から頂点座標を一意に得られるので、h=0にならない",
"+ x, y, h = sorted(Pos, key=lambda x: x[2])[-1]",
"- for cx, cy in product(list(range(101)), repeat=2):",
"- # ピラミッドの高さを求める",
"- for x, y, h in Pos:",
"- if h > 0:",
"- height = h + abs(cx - x) + abs(cy - y)",
"- # ピラミッドの高さが得られた情報に適合するか調べる",
"- for x, y, h in Pos:",
"- if h != max((height - abs(cx - x) - abs(cy - y)), 0):",
"- break",
"- else:",
"- ans = [cx, cy, height]",
"- break",
"- ans = \"{0} {1} {2}\".format(*ans)",
"- return ans",
"+ for cx in range(101):",
"+ for cy in range(101):",
"+ # 頂点の高さ height を決めたとき、すべての座標の情報と一致するか?",
"+ height = h + abs(x - cx) + abs(y - cy) # 定義式から逆算",
"+ if all(",
"+ h_i == max(height - abs(x_i - cx) - abs(y_i - cy), 0)",
"+ for x_i, y_i, h_i in Pos",
"+ ):",
"+ return \"{} {} {}\".format(cx, cy, height) # すべて一致した。これが解",
"+ return None",
"-N = int(eval(input()))",
"-Pos = [[int(i) for i in input().split()] for j in range(N)]",
"-print((c_pyramid(N, Pos)))",
"+print((c_pyramid()))"
] | false
| 0.044617
| 0.039209
| 1.137921
|
[
"s496099438",
"s113029729"
] |
u977389981
|
p03147
|
python
|
s040562131
|
s583019906
| 20
| 18
| 3,060
| 2,940
|
Accepted
|
Accepted
| 10
|
n = int(eval(input()))
H = [int(i) for i in input().split()]
count = 0
for _ in range(100):
flag = 1
for i in range(n):
if H[i] > 0:
H[i] -= 1
if flag:
count += 1
flag = 0
else:
flag = 1
print(count)
|
n = int(eval(input()))
A = [0] + [int(i) for i in input().split()]
cnt = 0
for i in range(n):
if A[i + 1] > A[i]:
cnt += A[i + 1] - A[i]
print(cnt)
| 16
| 7
| 314
| 159
|
n = int(eval(input()))
H = [int(i) for i in input().split()]
count = 0
for _ in range(100):
flag = 1
for i in range(n):
if H[i] > 0:
H[i] -= 1
if flag:
count += 1
flag = 0
else:
flag = 1
print(count)
|
n = int(eval(input()))
A = [0] + [int(i) for i in input().split()]
cnt = 0
for i in range(n):
if A[i + 1] > A[i]:
cnt += A[i + 1] - A[i]
print(cnt)
| false
| 56.25
|
[
"-H = [int(i) for i in input().split()]",
"-count = 0",
"-for _ in range(100):",
"- flag = 1",
"- for i in range(n):",
"- if H[i] > 0:",
"- H[i] -= 1",
"- if flag:",
"- count += 1",
"- flag = 0",
"- else:",
"- flag = 1",
"-print(count)",
"+A = [0] + [int(i) for i in input().split()]",
"+cnt = 0",
"+for i in range(n):",
"+ if A[i + 1] > A[i]:",
"+ cnt += A[i + 1] - A[i]",
"+print(cnt)"
] | false
| 0.036902
| 0.059351
| 0.621755
|
[
"s040562131",
"s583019906"
] |
u068862829
|
p02630
|
python
|
s353514647
|
s503387295
| 375
| 326
| 26,100
| 24,120
|
Accepted
|
Accepted
| 13.07
|
N = int(eval(input()))
A = list(map(int, input().split()))
Aset = set(A)
lst = {}
for i in Aset:
lst[i] = 0
for i in range(N):
lst[A[i]] += 1
Q = int(eval(input()))
# 最初の全てのA_iの和
ans_init = 0
for i in lst:
ans_init += i*lst[i]
# 初期値からのプラスマイナス分
ans_pm = 0
ans = []
for i in range(Q):
B, C = list(map(int, input().split()))
if B in lst:
# 更新する前に、lst中のkeyがBの個数をBnumに記憶しておく。
Bnum = lst[B]
# lstを更新
if C in lst:
lst[C] += lst[B]
lst.pop(B)
else:
lst[C] = lst[B]
lst.pop(B)
# 初期値からの増減分をここで算出。
ans_pm += Bnum*(C-B)
ans.append(ans_init + ans_pm)
else:
ans.append(ans_init + ans_pm)
for i in ans:
print(i)
|
import collections
N = int(eval(input()))
A = list(map(int, input().split()))
lst = collections.Counter(A)
Q = int(eval(input()))
# 最初の全てのA_iの和
ans_init = 0
for i in lst:
ans_init += i*lst[i]
# 初期値からのプラスマイナス分
ans_pm = 0
ans = []
for i in range(Q):
B, C = list(map(int, input().split()))
if B in lst:
# 更新する前に、lst中のkeyがBの個数をBnumに記憶しておく。
Bnum = lst[B]
# lstを更新
if C in lst:
lst[C] += lst[B]
lst.pop(B)
else:
lst[C] = lst[B]
lst.pop(B)
# 初期値からの増減分をここで算出。
ans_pm += Bnum*(C-B)
ans.append(ans_init + ans_pm)
else:
ans.append(ans_init + ans_pm)
for i in ans:
print(i)
| 43
| 38
| 792
| 739
|
N = int(eval(input()))
A = list(map(int, input().split()))
Aset = set(A)
lst = {}
for i in Aset:
lst[i] = 0
for i in range(N):
lst[A[i]] += 1
Q = int(eval(input()))
# 最初の全てのA_iの和
ans_init = 0
for i in lst:
ans_init += i * lst[i]
# 初期値からのプラスマイナス分
ans_pm = 0
ans = []
for i in range(Q):
B, C = list(map(int, input().split()))
if B in lst:
# 更新する前に、lst中のkeyがBの個数をBnumに記憶しておく。
Bnum = lst[B]
# lstを更新
if C in lst:
lst[C] += lst[B]
lst.pop(B)
else:
lst[C] = lst[B]
lst.pop(B)
# 初期値からの増減分をここで算出。
ans_pm += Bnum * (C - B)
ans.append(ans_init + ans_pm)
else:
ans.append(ans_init + ans_pm)
for i in ans:
print(i)
|
import collections
N = int(eval(input()))
A = list(map(int, input().split()))
lst = collections.Counter(A)
Q = int(eval(input()))
# 最初の全てのA_iの和
ans_init = 0
for i in lst:
ans_init += i * lst[i]
# 初期値からのプラスマイナス分
ans_pm = 0
ans = []
for i in range(Q):
B, C = list(map(int, input().split()))
if B in lst:
# 更新する前に、lst中のkeyがBの個数をBnumに記憶しておく。
Bnum = lst[B]
# lstを更新
if C in lst:
lst[C] += lst[B]
lst.pop(B)
else:
lst[C] = lst[B]
lst.pop(B)
# 初期値からの増減分をここで算出。
ans_pm += Bnum * (C - B)
ans.append(ans_init + ans_pm)
else:
ans.append(ans_init + ans_pm)
for i in ans:
print(i)
| false
| 11.627907
|
[
"+import collections",
"+",
"-Aset = set(A)",
"-lst = {}",
"-for i in Aset:",
"- lst[i] = 0",
"-for i in range(N):",
"- lst[A[i]] += 1",
"+lst = collections.Counter(A)"
] | false
| 0.053592
| 0.052752
| 1.015927
|
[
"s353514647",
"s503387295"
] |
u107077660
|
p04030
|
python
|
s679095667
|
s126661103
| 36
| 23
| 3,064
| 3,064
|
Accepted
|
Accepted
| 36.11
|
s = eval(input())
a = ""
for i in range(len(s)):
if s[i] == "0":
a += "0"
elif s[i] == "1":
a += "1"
else:
if a != "":
a = a[:len(a)-1]
print(a)
|
s = eval(input())
ans = ""
for l in s:
if l == "B":
ans = ans[:-1]
else:
ans += l
print(ans)
| 12
| 8
| 163
| 117
|
s = eval(input())
a = ""
for i in range(len(s)):
if s[i] == "0":
a += "0"
elif s[i] == "1":
a += "1"
else:
if a != "":
a = a[: len(a) - 1]
print(a)
|
s = eval(input())
ans = ""
for l in s:
if l == "B":
ans = ans[:-1]
else:
ans += l
print(ans)
| false
| 33.333333
|
[
"-a = \"\"",
"-for i in range(len(s)):",
"- if s[i] == \"0\":",
"- a += \"0\"",
"- elif s[i] == \"1\":",
"- a += \"1\"",
"+ans = \"\"",
"+for l in s:",
"+ if l == \"B\":",
"+ ans = ans[:-1]",
"- if a != \"\":",
"- a = a[: len(a) - 1]",
"-print(a)",
"+ ans += l",
"+print(ans)"
] | false
| 0.059892
| 0.042716
| 1.402118
|
[
"s679095667",
"s126661103"
] |
u517724953
|
p02911
|
python
|
s693904543
|
s206764190
| 634
| 577
| 54,244
| 51,660
|
Accepted
|
Accepted
| 8.99
|
def main():
n, k, q = list(map(int, input().split()))
point = [0]+[k-q]*n
point_add = [0]*(n+1)
for a in range(q):
a = int(eval(input()))
point[a] += 1
result = [x + y for (x, y) in zip(point, point_add)]
for i in result[1:]:
if i <= 0:
print("No")
else:
print("Yes")
if __name__ == '__main__':
main()
|
def main():
n, k, q = list(map(int, input().split()))
point = [0]+[k-q]*n
for a in range(q):
point[int(eval(input()))] += 1
for i in point[1:]:
if i <= 0:
print("No")
else:
print("Yes")
if __name__ == '__main__':
main()
| 19
| 16
| 396
| 295
|
def main():
n, k, q = list(map(int, input().split()))
point = [0] + [k - q] * n
point_add = [0] * (n + 1)
for a in range(q):
a = int(eval(input()))
point[a] += 1
result = [x + y for (x, y) in zip(point, point_add)]
for i in result[1:]:
if i <= 0:
print("No")
else:
print("Yes")
if __name__ == "__main__":
main()
|
def main():
n, k, q = list(map(int, input().split()))
point = [0] + [k - q] * n
for a in range(q):
point[int(eval(input()))] += 1
for i in point[1:]:
if i <= 0:
print("No")
else:
print("Yes")
if __name__ == "__main__":
main()
| false
| 15.789474
|
[
"- point_add = [0] * (n + 1)",
"- a = int(eval(input()))",
"- point[a] += 1",
"- result = [x + y for (x, y) in zip(point, point_add)]",
"- for i in result[1:]:",
"+ point[int(eval(input()))] += 1",
"+ for i in point[1:]:"
] | false
| 0.060745
| 0.043623
| 1.392486
|
[
"s693904543",
"s206764190"
] |
u461573913
|
p03331
|
python
|
s277325942
|
s742962375
| 268
| 18
| 3,060
| 3,064
|
Accepted
|
Accepted
| 93.28
|
def DigitsSum(n):
sum = 0
while (n != 0):
sum += (n % 10)
n = int(n / 10)
return sum
N = int(eval(input()))
min_sum = 10**5
for i in range(1, N):
sum = DigitsSum(i) + DigitsSum(N-i)
if (sum < min_sum):
min_sum = sum
print(min_sum)
|
def Digitsum(n):
sum = 0
while(n > 0):
sum += (n % 10)
n = int(n / 10)
return sum
N = int(eval(input()))
n = N
ans = 0
while(True):
if (n % 10 >= 2):
#10のべき乗ではない
ans = Digitsum(N)
break
elif (n % 10 == 1 and n >= 10):
#10のべき乗ではない
ans = Digitsum(N)
break
n = int(n / 10)
if (n == 1):
ans = 10
break
print(ans)
| 16
| 25
| 287
| 437
|
def DigitsSum(n):
sum = 0
while n != 0:
sum += n % 10
n = int(n / 10)
return sum
N = int(eval(input()))
min_sum = 10**5
for i in range(1, N):
sum = DigitsSum(i) + DigitsSum(N - i)
if sum < min_sum:
min_sum = sum
print(min_sum)
|
def Digitsum(n):
sum = 0
while n > 0:
sum += n % 10
n = int(n / 10)
return sum
N = int(eval(input()))
n = N
ans = 0
while True:
if n % 10 >= 2:
# 10のべき乗ではない
ans = Digitsum(N)
break
elif n % 10 == 1 and n >= 10:
# 10のべき乗ではない
ans = Digitsum(N)
break
n = int(n / 10)
if n == 1:
ans = 10
break
print(ans)
| false
| 36
|
[
"-def DigitsSum(n):",
"+def Digitsum(n):",
"- while n != 0:",
"+ while n > 0:",
"-min_sum = 10**5",
"-for i in range(1, N):",
"- sum = DigitsSum(i) + DigitsSum(N - i)",
"- if sum < min_sum:",
"- min_sum = sum",
"-print(min_sum)",
"+n = N",
"+ans = 0",
"+while True:",
"+ if n % 10 >= 2:",
"+ # 10のべき乗ではない",
"+ ans = Digitsum(N)",
"+ break",
"+ elif n % 10 == 1 and n >= 10:",
"+ # 10のべき乗ではない",
"+ ans = Digitsum(N)",
"+ break",
"+ n = int(n / 10)",
"+ if n == 1:",
"+ ans = 10",
"+ break",
"+print(ans)"
] | false
| 0.102194
| 0.036915
| 2.768386
|
[
"s277325942",
"s742962375"
] |
u280552586
|
p03854
|
python
|
s744528434
|
s514710921
| 57
| 32
| 9,172
| 9,060
|
Accepted
|
Accepted
| 43.86
|
s = input()[::-1]
n = len(s)
words = ['maerd', 'remaerd', 'esare', 'resare']
while True:
if s[:5] == words[0]:
s = s[5:]
continue
elif s[:7] == words[1]:
s = s[7:]
continue
elif s[:5] == words[2]:
s = s[5:]
continue
elif s[:6] == words[3]:
s = s[6:]
continue
break
print(('NO' if s else 'YES'))
|
s = eval(input())
words = ['eraser', 'erase', 'dreamer', 'dream']
for w in words:
s = s.replace(w, '')
print(('NO' if s else 'YES'))
| 18
| 5
| 394
| 134
|
s = input()[::-1]
n = len(s)
words = ["maerd", "remaerd", "esare", "resare"]
while True:
if s[:5] == words[0]:
s = s[5:]
continue
elif s[:7] == words[1]:
s = s[7:]
continue
elif s[:5] == words[2]:
s = s[5:]
continue
elif s[:6] == words[3]:
s = s[6:]
continue
break
print(("NO" if s else "YES"))
|
s = eval(input())
words = ["eraser", "erase", "dreamer", "dream"]
for w in words:
s = s.replace(w, "")
print(("NO" if s else "YES"))
| false
| 72.222222
|
[
"-s = input()[::-1]",
"-n = len(s)",
"-words = [\"maerd\", \"remaerd\", \"esare\", \"resare\"]",
"-while True:",
"- if s[:5] == words[0]:",
"- s = s[5:]",
"- continue",
"- elif s[:7] == words[1]:",
"- s = s[7:]",
"- continue",
"- elif s[:5] == words[2]:",
"- s = s[5:]",
"- continue",
"- elif s[:6] == words[3]:",
"- s = s[6:]",
"- continue",
"- break",
"+s = eval(input())",
"+words = [\"eraser\", \"erase\", \"dreamer\", \"dream\"]",
"+for w in words:",
"+ s = s.replace(w, \"\")"
] | false
| 0.03537
| 0.031378
| 1.127221
|
[
"s744528434",
"s514710921"
] |
u275934251
|
p03814
|
python
|
s787206765
|
s641769459
| 76
| 35
| 4,840
| 3,512
|
Accepted
|
Accepted
| 53.95
|
s = list(eval(input()))
a_index = 0
z_index = 0
max_z_index = 0
for i in range(len(s)):
if s[i] == "A":
a_index = i
break
for j in range(len(s)):
if j <= a_index:
continue
else:
if s[j] == "Z":
z_index = j
max_z_index = max(max_z_index, z_index)
print((max_z_index - a_index + 1))
|
s=eval(input())
a=0
z=0
for i in range(len(s)):
if s[i]=="A":
a=i
break
for i in range(len(s)-1,-1,-1):
if s[i]=="Z":
z=i
break
print((z-a+1))
| 20
| 12
| 363
| 186
|
s = list(eval(input()))
a_index = 0
z_index = 0
max_z_index = 0
for i in range(len(s)):
if s[i] == "A":
a_index = i
break
for j in range(len(s)):
if j <= a_index:
continue
else:
if s[j] == "Z":
z_index = j
max_z_index = max(max_z_index, z_index)
print((max_z_index - a_index + 1))
|
s = eval(input())
a = 0
z = 0
for i in range(len(s)):
if s[i] == "A":
a = i
break
for i in range(len(s) - 1, -1, -1):
if s[i] == "Z":
z = i
break
print((z - a + 1))
| false
| 40
|
[
"-s = list(eval(input()))",
"-a_index = 0",
"-z_index = 0",
"-max_z_index = 0",
"+s = eval(input())",
"+a = 0",
"+z = 0",
"- a_index = i",
"+ a = i",
"-for j in range(len(s)):",
"- if j <= a_index:",
"- continue",
"- else:",
"- if s[j] == \"Z\":",
"- z_index = j",
"- max_z_index = max(max_z_index, z_index)",
"-print((max_z_index - a_index + 1))",
"+for i in range(len(s) - 1, -1, -1):",
"+ if s[i] == \"Z\":",
"+ z = i",
"+ break",
"+print((z - a + 1))"
] | false
| 0.086722
| 0.036207
| 2.395165
|
[
"s787206765",
"s641769459"
] |
u755830696
|
p03128
|
python
|
s732359378
|
s279137399
| 417
| 134
| 109,148
| 20,560
|
Accepted
|
Accepted
| 67.87
|
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
dp = [[-1 for i in range(10)] for j in range(N+1)]
B = [0 for i in range(10)]
C = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
for i in range(10):
if i in A:
B[i] = C[i]
for i in range(10):
dp[N][i] = 0
for i in range(N, -1, -1):
for j in range(10):
for k in range(j+1):
if B[k] > 0 and i+B[k] <= N:
# print(i, j, k, i+B[k])
dp[i][k] = max(dp[i][k], dp[i+B[k]][j] * 10 + k)
# print(dp)
ans = 0
for i in range(10):
ans = max(ans, dp[0][i])
print(ans)
|
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [-1] * (n + 1)
dp[n] = 0
for i in range(n, -1, -1):
for j in range(m):
x = b[a[j]]
if dp[i] != -1 and i - x >= 0:
dp[i - x] = max(dp[i - x], 10 * dp[i] + a[j])
print((dp[0]))
| 28
| 14
| 634
| 342
|
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
dp = [[-1 for i in range(10)] for j in range(N + 1)]
B = [0 for i in range(10)]
C = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
for i in range(10):
if i in A:
B[i] = C[i]
for i in range(10):
dp[N][i] = 0
for i in range(N, -1, -1):
for j in range(10):
for k in range(j + 1):
if B[k] > 0 and i + B[k] <= N:
# print(i, j, k, i+B[k])
dp[i][k] = max(dp[i][k], dp[i + B[k]][j] * 10 + k)
# print(dp)
ans = 0
for i in range(10):
ans = max(ans, dp[0][i])
print(ans)
|
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [-1] * (n + 1)
dp[n] = 0
for i in range(n, -1, -1):
for j in range(m):
x = b[a[j]]
if dp[i] != -1 and i - x >= 0:
dp[i - x] = max(dp[i - x], 10 * dp[i] + a[j])
print((dp[0]))
| false
| 50
|
[
"-N, M = list(map(int, input().split()))",
"-A = list(map(int, input().split()))",
"-dp = [[-1 for i in range(10)] for j in range(N + 1)]",
"-B = [0 for i in range(10)]",
"-C = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]",
"-for i in range(10):",
"- if i in A:",
"- B[i] = C[i]",
"-for i in range(10):",
"- dp[N][i] = 0",
"-for i in range(N, -1, -1):",
"- for j in range(10):",
"- for k in range(j + 1):",
"- if B[k] > 0 and i + B[k] <= N:",
"- # print(i, j, k, i+B[k])",
"- dp[i][k] = max(dp[i][k], dp[i + B[k]][j] * 10 + k)",
"-# print(dp)",
"-ans = 0",
"-for i in range(10):",
"- ans = max(ans, dp[0][i])",
"-print(ans)",
"+n, m = list(map(int, input().split()))",
"+a = list(map(int, input().split()))",
"+b = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]",
"+dp = [-1] * (n + 1)",
"+dp[n] = 0",
"+for i in range(n, -1, -1):",
"+ for j in range(m):",
"+ x = b[a[j]]",
"+ if dp[i] != -1 and i - x >= 0:",
"+ dp[i - x] = max(dp[i - x], 10 * dp[i] + a[j])",
"+print((dp[0]))"
] | false
| 0.039294
| 0.037658
| 1.043449
|
[
"s732359378",
"s279137399"
] |
u046158516
|
p02756
|
python
|
s912159257
|
s571445992
| 662
| 312
| 7,808
| 110,312
|
Accepted
|
Accepted
| 52.87
|
S=eval(input())
# Python3 program to Split string into characters
def split(word):
return [char for char in word]
def convert(s):
# initialization of string to ""
new = ""
# traverse in the string
for x in s:
new += x
# return string
return new
# Driver code
word = S
splits=split(S)
Q=int(eval(input()))
flipcounter=0
prestring=[]
poststring=[]
for i in range(0,Q):
inputforround=eval(input())
if inputforround=='1':
flipcounter=flipcounter+1
else:
T,F,C=list(map(str,inputforround.split()))
if (int(F)+flipcounter)%2==1:
prestring.append(C)
else:
poststring.append(C)
prestring.reverse()
for j in splits:
prestring.append(j)
for k in poststring:
prestring.append(k)
if flipcounter%2==1:
prestring.reverse()
ans=convert(prestring)
print(ans)
|
S=eval(input())
# Python3 program to Split string into characters
def split(word):
return [char for char in word]
word = S
splits=split(S)
Q=int(eval(input()))
flipcounter=0
prestring=[]
poststring=[]
for i in range(0,Q):
inputforround=eval(input())
if inputforround=='1':
flipcounter=flipcounter+1
else:
T,F,C=list(map(str,inputforround.split()))
if (int(F)+flipcounter)%2==1:
prestring.append(C)
else:
poststring.append(C)
prestring.reverse()
for j in splits:
prestring.append(j)
for k in poststring:
prestring.append(k)
if flipcounter%2==1:
prestring.reverse()
ans=''.join(prestring)
print(ans)
| 44
| 29
| 878
| 650
|
S = eval(input())
# Python3 program to Split string into characters
def split(word):
return [char for char in word]
def convert(s):
# initialization of string to ""
new = ""
# traverse in the string
for x in s:
new += x
# return string
return new
# Driver code
word = S
splits = split(S)
Q = int(eval(input()))
flipcounter = 0
prestring = []
poststring = []
for i in range(0, Q):
inputforround = eval(input())
if inputforround == "1":
flipcounter = flipcounter + 1
else:
T, F, C = list(map(str, inputforround.split()))
if (int(F) + flipcounter) % 2 == 1:
prestring.append(C)
else:
poststring.append(C)
prestring.reverse()
for j in splits:
prestring.append(j)
for k in poststring:
prestring.append(k)
if flipcounter % 2 == 1:
prestring.reverse()
ans = convert(prestring)
print(ans)
|
S = eval(input())
# Python3 program to Split string into characters
def split(word):
return [char for char in word]
word = S
splits = split(S)
Q = int(eval(input()))
flipcounter = 0
prestring = []
poststring = []
for i in range(0, Q):
inputforround = eval(input())
if inputforround == "1":
flipcounter = flipcounter + 1
else:
T, F, C = list(map(str, inputforround.split()))
if (int(F) + flipcounter) % 2 == 1:
prestring.append(C)
else:
poststring.append(C)
prestring.reverse()
for j in splits:
prestring.append(j)
for k in poststring:
prestring.append(k)
if flipcounter % 2 == 1:
prestring.reverse()
ans = "".join(prestring)
print(ans)
| false
| 34.090909
|
[
"-def convert(s):",
"- # initialization of string to \"\"",
"- new = \"\"",
"- # traverse in the string",
"- for x in s:",
"- new += x",
"- # return string",
"- return new",
"-",
"-",
"-# Driver code",
"-ans = convert(prestring)",
"+ans = \"\".join(prestring)"
] | false
| 0.041547
| 0.047028
| 0.883455
|
[
"s912159257",
"s571445992"
] |
u340781749
|
p02787
|
python
|
s655681819
|
s164093052
| 404
| 82
| 14,532
| 6,256
|
Accepted
|
Accepted
| 79.7
|
import sys
import numpy as np
h, n = list(map(int, input().split()))
ab = np.array(sys.stdin.read().split(), dtype=np.int64)
aaa = ab[0::2]
bbb = ab[1::2]
dp = np.zeros(10001, dtype=np.int64)
for i in range(1, h + 1):
dp[i] = (dp[i - aaa] + bbb).min()
print((dp[h]))
|
import sys
def solve(h, n, ab):
ab.sort(key=lambda x: x[1] / x[0])
INF = 10 ** 18
cache = {}
# とりあえず一番コスパいいやつだけを使った結果を暫定最良値としておく
best = ((h - 1) // ab[0][0] + 1) * ab[0][1]
def dp(k, i=0, cost=0):
nonlocal best
if k <= 0:
return cost
if (k, i) in cache:
return cache[k, i] + cost
a, b = ab[i]
if k / a * b + cost >= best:
# どう足掻いても残りでbestより良い結果は得られない
return INF
c = (k - 1) // a + 1
if i == n - 1:
ret = cost + b * c
else:
ret = min(dp(k - a * j, i + 1, cost + b * j) for j in range(c + 1))
cache[k, i] = ret - cost
best = min(best, ret)
return ret
dp(h)
return best
sys.setrecursionlimit(10001)
h, n = list(map(int, input().split()))
ab = [tuple(map(int, line.split())) for line in sys.stdin]
print((solve(h, n, ab)))
| 12
| 38
| 276
| 947
|
import sys
import numpy as np
h, n = list(map(int, input().split()))
ab = np.array(sys.stdin.read().split(), dtype=np.int64)
aaa = ab[0::2]
bbb = ab[1::2]
dp = np.zeros(10001, dtype=np.int64)
for i in range(1, h + 1):
dp[i] = (dp[i - aaa] + bbb).min()
print((dp[h]))
|
import sys
def solve(h, n, ab):
ab.sort(key=lambda x: x[1] / x[0])
INF = 10**18
cache = {}
# とりあえず一番コスパいいやつだけを使った結果を暫定最良値としておく
best = ((h - 1) // ab[0][0] + 1) * ab[0][1]
def dp(k, i=0, cost=0):
nonlocal best
if k <= 0:
return cost
if (k, i) in cache:
return cache[k, i] + cost
a, b = ab[i]
if k / a * b + cost >= best:
# どう足掻いても残りでbestより良い結果は得られない
return INF
c = (k - 1) // a + 1
if i == n - 1:
ret = cost + b * c
else:
ret = min(dp(k - a * j, i + 1, cost + b * j) for j in range(c + 1))
cache[k, i] = ret - cost
best = min(best, ret)
return ret
dp(h)
return best
sys.setrecursionlimit(10001)
h, n = list(map(int, input().split()))
ab = [tuple(map(int, line.split())) for line in sys.stdin]
print((solve(h, n, ab)))
| false
| 68.421053
|
[
"-import numpy as np",
"+",
"+def solve(h, n, ab):",
"+ ab.sort(key=lambda x: x[1] / x[0])",
"+ INF = 10**18",
"+ cache = {}",
"+ # とりあえず一番コスパいいやつだけを使った結果を暫定最良値としておく",
"+ best = ((h - 1) // ab[0][0] + 1) * ab[0][1]",
"+",
"+ def dp(k, i=0, cost=0):",
"+ nonlocal best",
"+ if k <= 0:",
"+ return cost",
"+ if (k, i) in cache:",
"+ return cache[k, i] + cost",
"+ a, b = ab[i]",
"+ if k / a * b + cost >= best:",
"+ # どう足掻いても残りでbestより良い結果は得られない",
"+ return INF",
"+ c = (k - 1) // a + 1",
"+ if i == n - 1:",
"+ ret = cost + b * c",
"+ else:",
"+ ret = min(dp(k - a * j, i + 1, cost + b * j) for j in range(c + 1))",
"+ cache[k, i] = ret - cost",
"+ best = min(best, ret)",
"+ return ret",
"+",
"+ dp(h)",
"+ return best",
"+",
"+",
"+sys.setrecursionlimit(10001)",
"-ab = np.array(sys.stdin.read().split(), dtype=np.int64)",
"-aaa = ab[0::2]",
"-bbb = ab[1::2]",
"-dp = np.zeros(10001, dtype=np.int64)",
"-for i in range(1, h + 1):",
"- dp[i] = (dp[i - aaa] + bbb).min()",
"-print((dp[h]))",
"+ab = [tuple(map(int, line.split())) for line in sys.stdin]",
"+print((solve(h, n, ab)))"
] | false
| 0.357882
| 0.053843
| 6.64679
|
[
"s655681819",
"s164093052"
] |
u952022797
|
p03476
|
python
|
s144569573
|
s739326851
| 731
| 428
| 63,448
| 52,316
|
Accepted
|
Accepted
| 41.45
|
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
def main():
Q = int(eval(input()))
lr = []
for i in range(Q):
l, r = list(map(int,input().split()))
lr.append((l,r))
mapd = []
for i in range(0, 100001):
if i == 0:
mapd.append(0)
continue
if i == 1:
mapd.append(0)
continue
if i % 2 == 0:
mapd.append(mapd[i-1])
continue
if is_prime(i) and is_prime((i+1)/2):
mapd.append(mapd[i-1] + 1)
else:
mapd.append(mapd[i-1])
for i in lr:
l, r = i
print((mapd[r] - mapd[l-1]))
def is_prime(n):
i = 2
while i * i <=n:
if n % i == 0:
return False
i += 1
return True
if __name__ == "__main__":
main()
|
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)
##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除&その最小値を出力
# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと
##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順
# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順
##### 累乗 #####
# pow(x, y, z) -> x**y % z
def inputInt(): return int(eval(input()))
def inputMap(): return list(map(int, input().split()))
def inputList(): return list(map(int, input().split()))
inf = float('inf')
mod = 1000000007
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
def main():
Q = inputInt()
total = 0
lists = [0,0]
for i in range(2,10**5+1):
if i % 2 == 0:
lists.append(total)
continue
if is_prime(i) == True and is_prime((i+1)//2) == True:
total += 1
lists.append(total)
#print(lists)
for i in range(Q):
l,r = inputMap()
#print("{} {}".format(lists[r], lists[l]))
print((lists[r] - lists[l-1]))
def is_prime(n):
i = 2
while i * i <=n:
if n % i == 0:
return False
i += 1
return True
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# special thanks :
# https://nagiss.hateblo.jp/entry/2019/07/01/185421
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
def combination(n, r, mod=10**9+7):
r = min(r, n-r)
res = 1
for i in range(r):
res = res * (n - i) * modinv(i+1, mod) % mod
return res
def modinv(a, m):
g, x, y = egcd(a, m)
if g != 1:
raise Exception('modular inverse does not exist')
else:
return x % m
def egcd(a, b):
if a == 0:
return b, 0, 1
else:
g, y, x = egcd(b % a, a)
return g, x - (b // a) * y, y
if __name__ == "__main__":
main()
| 53
| 100
| 1,168
| 2,677
|
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
# NO, PAY-PAY
# import numpy as np
# import statistics
# from statistics import mean, median,variance,stdev
def main():
Q = int(eval(input()))
lr = []
for i in range(Q):
l, r = list(map(int, input().split()))
lr.append((l, r))
mapd = []
for i in range(0, 100001):
if i == 0:
mapd.append(0)
continue
if i == 1:
mapd.append(0)
continue
if i % 2 == 0:
mapd.append(mapd[i - 1])
continue
if is_prime(i) and is_prime((i + 1) / 2):
mapd.append(mapd[i - 1] + 1)
else:
mapd.append(mapd[i - 1])
for i in lr:
l, r = i
print((mapd[r] - mapd[l - 1]))
def is_prime(n):
i = 2
while i * i <= n:
if n % i == 0:
return False
i += 1
return True
if __name__ == "__main__":
main()
|
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)
##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除&その最小値を出力
# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと
##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順
# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順
##### 累乗 #####
# pow(x, y, z) -> x**y % z
def inputInt():
return int(eval(input()))
def inputMap():
return list(map(int, input().split()))
def inputList():
return list(map(int, input().split()))
inf = float("inf")
mod = 1000000007
# -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
def main():
Q = inputInt()
total = 0
lists = [0, 0]
for i in range(2, 10**5 + 1):
if i % 2 == 0:
lists.append(total)
continue
if is_prime(i) == True and is_prime((i + 1) // 2) == True:
total += 1
lists.append(total)
# print(lists)
for i in range(Q):
l, r = inputMap()
# print("{} {}".format(lists[r], lists[l]))
print((lists[r] - lists[l - 1]))
def is_prime(n):
i = 2
while i * i <= n:
if n % i == 0:
return False
i += 1
return True
# -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# special thanks :
# https://nagiss.hateblo.jp/entry/2019/07/01/185421
# -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
def combination(n, r, mod=10**9 + 7):
r = min(r, n - r)
res = 1
for i in range(r):
res = res * (n - i) * modinv(i + 1, mod) % mod
return res
def modinv(a, m):
g, x, y = egcd(a, m)
if g != 1:
raise Exception("modular inverse does not exist")
else:
return x % m
def egcd(a, b):
if a == 0:
return b, 0, 1
else:
g, y, x = egcd(b % a, a)
return g, x - (b // a) * y, y
if __name__ == "__main__":
main()
| false
| 47
|
[
"-import copy",
"-import collections",
"+import math",
"+import collections",
"+import copy",
"+import heapq",
"-import math",
"+import itertools",
"-# NO, PAY-PAY",
"-# import numpy as np",
"-# import statistics",
"-# from statistics import mean, median,variance,stdev",
"+input = sys.stdin.readline",
"+##### リストの 二分木検索 #####",
"+# bisect_left(lists, 3)",
"+# bisect_right(lists, 3)",
"+##### プライオリティキュー #####",
"+# heapq.heapify(a) #リストaのheap化",
"+# heapq.heappush(a,x) #heap化されたリストaに要素xを追加",
"+# heapq.heappop(a) #heap化されたリストaから最小値を削除&その最小値を出力",
"+# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう",
"+# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと",
"+##### タプルリストのソート #####",
"+# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順",
"+# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順",
"+# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順",
"+# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順",
"+# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順",
"+# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順",
"+##### 累乗 #####",
"+# pow(x, y, z) -> x**y % z",
"+def inputInt():",
"+ return int(eval(input()))",
"+",
"+",
"+def inputMap():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def inputList():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+inf = float(\"inf\")",
"+mod = 1000000007",
"+# -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-",
"- Q = int(eval(input()))",
"- lr = []",
"+ Q = inputInt()",
"+ total = 0",
"+ lists = [0, 0]",
"+ for i in range(2, 10**5 + 1):",
"+ if i % 2 == 0:",
"+ lists.append(total)",
"+ continue",
"+ if is_prime(i) == True and is_prime((i + 1) // 2) == True:",
"+ total += 1",
"+ lists.append(total)",
"+ # print(lists)",
"- l, r = list(map(int, input().split()))",
"- lr.append((l, r))",
"- mapd = []",
"- for i in range(0, 100001):",
"- if i == 0:",
"- mapd.append(0)",
"- continue",
"- if i == 1:",
"- mapd.append(0)",
"- continue",
"- if i % 2 == 0:",
"- mapd.append(mapd[i - 1])",
"- continue",
"- if is_prime(i) and is_prime((i + 1) / 2):",
"- mapd.append(mapd[i - 1] + 1)",
"- else:",
"- mapd.append(mapd[i - 1])",
"- for i in lr:",
"- l, r = i",
"- print((mapd[r] - mapd[l - 1]))",
"+ l, r = inputMap()",
"+ # print(\"{} {}\".format(lists[r], lists[l]))",
"+ print((lists[r] - lists[l - 1]))",
"+# -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-",
"+# special thanks :",
"+# https://nagiss.hateblo.jp/entry/2019/07/01/185421",
"+# -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-",
"+def combination(n, r, mod=10**9 + 7):",
"+ r = min(r, n - r)",
"+ res = 1",
"+ for i in range(r):",
"+ res = res * (n - i) * modinv(i + 1, mod) % mod",
"+ return res",
"+",
"+",
"+def modinv(a, m):",
"+ g, x, y = egcd(a, m)",
"+ if g != 1:",
"+ raise Exception(\"modular inverse does not exist\")",
"+ else:",
"+ return x % m",
"+",
"+",
"+def egcd(a, b):",
"+ if a == 0:",
"+ return b, 0, 1",
"+ else:",
"+ g, y, x = egcd(b % a, a)",
"+ return g, x - (b // a) * y, y",
"+",
"+"
] | false
| 0.682302
| 0.665438
| 1.025342
|
[
"s144569573",
"s739326851"
] |
u976225138
|
p03625
|
python
|
s953198604
|
s661078386
| 79
| 73
| 22,192
| 22,120
|
Accepted
|
Accepted
| 7.59
|
from collections import Counter as C
_ = eval(input())
a = C([int(x) for x in input().split()])
b = [0] * 2
for k, v in list(a.items()):
if 4 <= v:
b.append(k)
if 2 <= v:
b.append(k)
else:
b.sort()
print((b[-1] * b[-2]))
|
from collections import Counter as C
_ = eval(input())
a = C([int(x) for x in input().split()])
b = []
for k, v in list(a.items()):
if 4 <= v:
b.append(k)
if 2 <= v:
b.append(k)
else:
if len(b) <= 1:
print((0))
else:
b.sort()
print((b[-1] * b[-2]))
| 14
| 17
| 253
| 306
|
from collections import Counter as C
_ = eval(input())
a = C([int(x) for x in input().split()])
b = [0] * 2
for k, v in list(a.items()):
if 4 <= v:
b.append(k)
if 2 <= v:
b.append(k)
else:
b.sort()
print((b[-1] * b[-2]))
|
from collections import Counter as C
_ = eval(input())
a = C([int(x) for x in input().split()])
b = []
for k, v in list(a.items()):
if 4 <= v:
b.append(k)
if 2 <= v:
b.append(k)
else:
if len(b) <= 1:
print((0))
else:
b.sort()
print((b[-1] * b[-2]))
| false
| 17.647059
|
[
"-b = [0] * 2",
"+b = []",
"- b.sort()",
"- print((b[-1] * b[-2]))",
"+ if len(b) <= 1:",
"+ print((0))",
"+ else:",
"+ b.sort()",
"+ print((b[-1] * b[-2]))"
] | false
| 0.044584
| 0.043431
| 1.026563
|
[
"s953198604",
"s661078386"
] |
u699089116
|
p03611
|
python
|
s224998965
|
s252684645
| 313
| 226
| 111,300
| 56,900
|
Accepted
|
Accepted
| 27.8
|
from itertools import accumulate
n = int(eval(input()))
a = list(map(int, input().split()))
# 0が混ざってる場合に対応して、1ずつ足しておく
a = [i+1 for i in a]
# 10**5だと99999がコーナーケースになる
l = [0] * 10 ** 6
# いもす法
for i in a:
l[i-1] += 1
l[i+2] -= 1
b = accumulate(l)
print((max(list(b))))
|
from itertools import accumulate
n = int(eval(input()))
a = list(map(int, input().split()))
a = [i+1 for i in a]
imos = [0] * (10**5 + 3)
for i in a:
imos[i-1] += 1
imos[i+2] -= 1
i = accumulate(imos)
print((max(i)))
| 15
| 13
| 281
| 232
|
from itertools import accumulate
n = int(eval(input()))
a = list(map(int, input().split()))
# 0が混ざってる場合に対応して、1ずつ足しておく
a = [i + 1 for i in a]
# 10**5だと99999がコーナーケースになる
l = [0] * 10**6
# いもす法
for i in a:
l[i - 1] += 1
l[i + 2] -= 1
b = accumulate(l)
print((max(list(b))))
|
from itertools import accumulate
n = int(eval(input()))
a = list(map(int, input().split()))
a = [i + 1 for i in a]
imos = [0] * (10**5 + 3)
for i in a:
imos[i - 1] += 1
imos[i + 2] -= 1
i = accumulate(imos)
print((max(i)))
| false
| 13.333333
|
[
"-# 0が混ざってる場合に対応して、1ずつ足しておく",
"-# 10**5だと99999がコーナーケースになる",
"-l = [0] * 10**6",
"-# いもす法",
"+imos = [0] * (10**5 + 3)",
"- l[i - 1] += 1",
"- l[i + 2] -= 1",
"-b = accumulate(l)",
"-print((max(list(b))))",
"+ imos[i - 1] += 1",
"+ imos[i + 2] -= 1",
"+i = accumulate(imos)",
"+print((max(i)))"
] | false
| 0.515614
| 0.090952
| 5.669077
|
[
"s224998965",
"s252684645"
] |
u072717685
|
p03457
|
python
|
s291111573
|
s273349853
| 363
| 204
| 17,344
| 9,040
|
Accepted
|
Accepted
| 43.8
|
import sys
def main():
n = int(eval(input()))
txy = []
for _ in range(n):
txy.append(tuple(map(int, input().split())))
t = x = y = 0
for i1 in range(n):
txye = txy[i1]
t, dt = txye[0], txye[0] - t
x, dx = txye[1], abs(txye[1] - x)
y, dy = txye[2], abs(txye[2] - y)
if dt < (dx + dy):
print('No')
sys.exit()
elif dt > (dx + dy) and (dt - dx - dy) % 2 != 0:
print('No')
sys.exit()
print('Yes')
if __name__ == '__main__':
main()
|
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
n = int(eval(input()))
pre_t = 0
pre_x = 0
pre_y = 0
for _ in range(n):
t, x, y = list(map(int, input().split()))
d_dis = abs(x - pre_x) + abs(y - pre_y)
d_t = abs(t - pre_t)
if d_dis > d_t:
print('No')
sys.exit()
elif (d_t - d_dis) % 2 == 1:
print('No')
sys.exit()
else:
pre_t = t
pre_x = x
pre_y = y
print('Yes')
if __name__ == '__main__':
main()
| 25
| 26
| 580
| 600
|
import sys
def main():
n = int(eval(input()))
txy = []
for _ in range(n):
txy.append(tuple(map(int, input().split())))
t = x = y = 0
for i1 in range(n):
txye = txy[i1]
t, dt = txye[0], txye[0] - t
x, dx = txye[1], abs(txye[1] - x)
y, dy = txye[2], abs(txye[2] - y)
if dt < (dx + dy):
print("No")
sys.exit()
elif dt > (dx + dy) and (dt - dx - dy) % 2 != 0:
print("No")
sys.exit()
print("Yes")
if __name__ == "__main__":
main()
|
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
n = int(eval(input()))
pre_t = 0
pre_x = 0
pre_y = 0
for _ in range(n):
t, x, y = list(map(int, input().split()))
d_dis = abs(x - pre_x) + abs(y - pre_y)
d_t = abs(t - pre_t)
if d_dis > d_t:
print("No")
sys.exit()
elif (d_t - d_dis) % 2 == 1:
print("No")
sys.exit()
else:
pre_t = t
pre_x = x
pre_y = y
print("Yes")
if __name__ == "__main__":
main()
| false
| 3.846154
|
[
"+",
"+read = sys.stdin.read",
"+readlines = sys.stdin.readlines",
"- txy = []",
"+ pre_t = 0",
"+ pre_x = 0",
"+ pre_y = 0",
"- txy.append(tuple(map(int, input().split())))",
"- t = x = y = 0",
"- for i1 in range(n):",
"- txye = txy[i1]",
"- t, dt = txye[0], txye[0] - t",
"- x, dx = txye[1], abs(txye[1] - x)",
"- y, dy = txye[2], abs(txye[2] - y)",
"- if dt < (dx + dy):",
"+ t, x, y = list(map(int, input().split()))",
"+ d_dis = abs(x - pre_x) + abs(y - pre_y)",
"+ d_t = abs(t - pre_t)",
"+ if d_dis > d_t:",
"- elif dt > (dx + dy) and (dt - dx - dy) % 2 != 0:",
"+ elif (d_t - d_dis) % 2 == 1:",
"+ else:",
"+ pre_t = t",
"+ pre_x = x",
"+ pre_y = y"
] | false
| 0.074969
| 0.036822
| 2.036024
|
[
"s291111573",
"s273349853"
] |
u502731482
|
p02996
|
python
|
s467927209
|
s581813585
| 865
| 668
| 38,028
| 42,220
|
Accepted
|
Accepted
| 22.77
|
n = int(eval(input()))
data = []
for i in range(n):
a, b = list(map(int, input().split()))
data.append([a, b])
data.sort(key = lambda x: x[1])
flag = True
sum = 0
for i in range(n):
sum += data[i][0]
if sum > data[i][1]:
flag = False
break
print(("Yes" if flag == True else "No"))
|
n = int(eval(input()))
data = []
for i in range(n):
a, b = list(map(int, input().split()))
data.append([a, b])
data = sorted(data, key = lambda x: x[1])
time = 0
ans = "Yes"
for i in range(n):
if time + data[i][0] > data[i][1]:
ans = "No"
time += data[i][0]
print(ans)
| 17
| 14
| 317
| 294
|
n = int(eval(input()))
data = []
for i in range(n):
a, b = list(map(int, input().split()))
data.append([a, b])
data.sort(key=lambda x: x[1])
flag = True
sum = 0
for i in range(n):
sum += data[i][0]
if sum > data[i][1]:
flag = False
break
print(("Yes" if flag == True else "No"))
|
n = int(eval(input()))
data = []
for i in range(n):
a, b = list(map(int, input().split()))
data.append([a, b])
data = sorted(data, key=lambda x: x[1])
time = 0
ans = "Yes"
for i in range(n):
if time + data[i][0] > data[i][1]:
ans = "No"
time += data[i][0]
print(ans)
| false
| 17.647059
|
[
"-data.sort(key=lambda x: x[1])",
"-flag = True",
"-sum = 0",
"+data = sorted(data, key=lambda x: x[1])",
"+time = 0",
"+ans = \"Yes\"",
"- sum += data[i][0]",
"- if sum > data[i][1]:",
"- flag = False",
"- break",
"-print((\"Yes\" if flag == True else \"No\"))",
"+ if time + data[i][0] > data[i][1]:",
"+ ans = \"No\"",
"+ time += data[i][0]",
"+print(ans)"
] | false
| 0.041793
| 0.039033
| 1.070706
|
[
"s467927209",
"s581813585"
] |
u843768197
|
p02802
|
python
|
s566930291
|
s298761774
| 204
| 185
| 10,304
| 10,352
|
Accepted
|
Accepted
| 9.31
|
n, m = list(map(int, input().split()))
P = [0]*n
AC = [False]*n
correct = 0
penalty = 0
for i in range(m):
ans = input().split()
problem = int(ans[0])
result = ans[1]
if AC[problem-1] == False:
if result == 'AC':
AC[problem-1] = True
correct += 1
penalty += P[problem-1]
else:
P[problem-1] += 1
print((correct, penalty))
|
n, m = list(map(int, input().split()))
Penalty = [0]*(n+1)
AC = [False]*(n+1)
correct = 0
penalty = 0
for i in range(m):
ans = input().split()
problem = int(ans[0])
result = ans[1]
if AC[problem] == False:
if result == 'AC':
AC[problem] = True
correct += 1
penalty += Penalty[problem]
else:
Penalty[problem] += 1
print((correct, penalty))
| 17
| 17
| 368
| 386
|
n, m = list(map(int, input().split()))
P = [0] * n
AC = [False] * n
correct = 0
penalty = 0
for i in range(m):
ans = input().split()
problem = int(ans[0])
result = ans[1]
if AC[problem - 1] == False:
if result == "AC":
AC[problem - 1] = True
correct += 1
penalty += P[problem - 1]
else:
P[problem - 1] += 1
print((correct, penalty))
|
n, m = list(map(int, input().split()))
Penalty = [0] * (n + 1)
AC = [False] * (n + 1)
correct = 0
penalty = 0
for i in range(m):
ans = input().split()
problem = int(ans[0])
result = ans[1]
if AC[problem] == False:
if result == "AC":
AC[problem] = True
correct += 1
penalty += Penalty[problem]
else:
Penalty[problem] += 1
print((correct, penalty))
| false
| 0
|
[
"-P = [0] * n",
"-AC = [False] * n",
"+Penalty = [0] * (n + 1)",
"+AC = [False] * (n + 1)",
"- if AC[problem - 1] == False:",
"+ if AC[problem] == False:",
"- AC[problem - 1] = True",
"+ AC[problem] = True",
"- penalty += P[problem - 1]",
"+ penalty += Penalty[problem]",
"- P[problem - 1] += 1",
"+ Penalty[problem] += 1"
] | false
| 0.097128
| 0.049697
| 1.9544
|
[
"s566930291",
"s298761774"
] |
u390727364
|
p02706
|
python
|
s497578037
|
s963836329
| 109
| 59
| 27,636
| 68,160
|
Accepted
|
Accepted
| 45.87
|
import numpy as np
from sys import stdin
def main():
n, m = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
a = np.array(a)
ans = n - np.sum(a)
print(-1) if ans < 0 else print(ans)
if __name__ == "__main__":
main()
|
from sys import stdin, setrecursionlimit
def main():
input = stdin.buffer.readline
n, m = list(map(int, input().split()))
sum_a = sum(list(map(int, input().split())))
ans = n - sum_a
if ans < 0:
print((-1))
else:
print(ans)
if __name__ == "__main__":
setrecursionlimit(10000)
main()
| 17
| 17
| 294
| 343
|
import numpy as np
from sys import stdin
def main():
n, m = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
a = np.array(a)
ans = n - np.sum(a)
print(-1) if ans < 0 else print(ans)
if __name__ == "__main__":
main()
|
from sys import stdin, setrecursionlimit
def main():
input = stdin.buffer.readline
n, m = list(map(int, input().split()))
sum_a = sum(list(map(int, input().split())))
ans = n - sum_a
if ans < 0:
print((-1))
else:
print(ans)
if __name__ == "__main__":
setrecursionlimit(10000)
main()
| false
| 0
|
[
"-import numpy as np",
"-from sys import stdin",
"+from sys import stdin, setrecursionlimit",
"- n, m = map(int, stdin.readline().split())",
"- a = list(map(int, stdin.readline().split()))",
"- a = np.array(a)",
"- ans = n - np.sum(a)",
"- print(-1) if ans < 0 else print(ans)",
"+ input = stdin.buffer.readline",
"+ n, m = list(map(int, input().split()))",
"+ sum_a = sum(list(map(int, input().split())))",
"+ ans = n - sum_a",
"+ if ans < 0:",
"+ print((-1))",
"+ else:",
"+ print(ans)",
"+ setrecursionlimit(10000)"
] | false
| 0.243827
| 0.036646
| 6.6536
|
[
"s497578037",
"s963836329"
] |
u966695411
|
p03986
|
python
|
s151115967
|
s398078899
| 990
| 58
| 5,352
| 5,352
|
Accepted
|
Accepted
| 94.14
|
s = ''.join(input().split('ST'))
while 1:
i = s.find('ST')
if i > -1:
cnt = 0
for j in range(min(i, len(s)-2-i)):
if s[i-j-1] == 'S' and s[i+j+2] == 'T':
cnt += 1
else:
break
s = s[:i-cnt] + s[i+cnt+2:]
else:
break
print((len(s)))
|
s = ''.join(input().split('ST'))
cnts = 0
cnt = 0
for i in s:
if i == 'S' :
cnts += 1
elif cnts > 0:
cnts -= 1
cnt += 1
print((len(s)-cnt*2))
| 14
| 10
| 341
| 180
|
s = "".join(input().split("ST"))
while 1:
i = s.find("ST")
if i > -1:
cnt = 0
for j in range(min(i, len(s) - 2 - i)):
if s[i - j - 1] == "S" and s[i + j + 2] == "T":
cnt += 1
else:
break
s = s[: i - cnt] + s[i + cnt + 2 :]
else:
break
print((len(s)))
|
s = "".join(input().split("ST"))
cnts = 0
cnt = 0
for i in s:
if i == "S":
cnts += 1
elif cnts > 0:
cnts -= 1
cnt += 1
print((len(s) - cnt * 2))
| false
| 28.571429
|
[
"-while 1:",
"- i = s.find(\"ST\")",
"- if i > -1:",
"- cnt = 0",
"- for j in range(min(i, len(s) - 2 - i)):",
"- if s[i - j - 1] == \"S\" and s[i + j + 2] == \"T\":",
"- cnt += 1",
"- else:",
"- break",
"- s = s[: i - cnt] + s[i + cnt + 2 :]",
"- else:",
"- break",
"-print((len(s)))",
"+cnts = 0",
"+cnt = 0",
"+for i in s:",
"+ if i == \"S\":",
"+ cnts += 1",
"+ elif cnts > 0:",
"+ cnts -= 1",
"+ cnt += 1",
"+print((len(s) - cnt * 2))"
] | false
| 0.164433
| 0.033254
| 4.944762
|
[
"s151115967",
"s398078899"
] |
u982591663
|
p02959
|
python
|
s120377276
|
s150614370
| 174
| 148
| 18,624
| 19,116
|
Accepted
|
Accepted
| 14.94
|
#ABC-136-C
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
hunted_monsters = 0
for i in range(N):
#勇者iが街iのモンスターを全て倒しても余力がある場合
if A[i] < B[i]:
B[i] -= A[i]
hunted_monsters += A[i]
A[i] = 0
#街i+1のモンスターも全て倒せる場合
if A[i+1] <= B[i]:
B[i] -= A[i+1]
hunted_monsters += A[i+1]
A[i+1] = 0
#街i+1のモンスターを一部倒せる場合
else:
A[i+1] -= B[i]
hunted_monsters += B[i]
B[i] = 0
#勇者iが街iのモンスターの一部(もしくはぴったり全て)倒して余力がない場合
else:
A[i] -= B[i]
hunted_monsters += B[i]
B[i] = 0
print(hunted_monsters)
|
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
# 勇者に余力がある場合
if B[i] >= A[i]:
ans += A[i]
B[i] -= A[i]
if B[i] >= A[i+1]:
ans += A[i+1]
A[i+1] = 0
else:
ans += B[i]
A[i+1] -= B[i]
# 勇者に余力がない場合
else:
ans += B[i]
print(ans)
| 30
| 20
| 715
| 414
|
# ABC-136-C
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
hunted_monsters = 0
for i in range(N):
# 勇者iが街iのモンスターを全て倒しても余力がある場合
if A[i] < B[i]:
B[i] -= A[i]
hunted_monsters += A[i]
A[i] = 0
# 街i+1のモンスターも全て倒せる場合
if A[i + 1] <= B[i]:
B[i] -= A[i + 1]
hunted_monsters += A[i + 1]
A[i + 1] = 0
# 街i+1のモンスターを一部倒せる場合
else:
A[i + 1] -= B[i]
hunted_monsters += B[i]
B[i] = 0
# 勇者iが街iのモンスターの一部(もしくはぴったり全て)倒して余力がない場合
else:
A[i] -= B[i]
hunted_monsters += B[i]
B[i] = 0
print(hunted_monsters)
|
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
# 勇者に余力がある場合
if B[i] >= A[i]:
ans += A[i]
B[i] -= A[i]
if B[i] >= A[i + 1]:
ans += A[i + 1]
A[i + 1] = 0
else:
ans += B[i]
A[i + 1] -= B[i]
# 勇者に余力がない場合
else:
ans += B[i]
print(ans)
| false
| 33.333333
|
[
"-# ABC-136-C",
"-hunted_monsters = 0",
"+ans = 0",
"- # 勇者iが街iのモンスターを全て倒しても余力がある場合",
"- if A[i] < B[i]:",
"+ # 勇者に余力がある場合",
"+ if B[i] >= A[i]:",
"+ ans += A[i]",
"- hunted_monsters += A[i]",
"- A[i] = 0",
"- # 街i+1のモンスターも全て倒せる場合",
"- if A[i + 1] <= B[i]:",
"- B[i] -= A[i + 1]",
"- hunted_monsters += A[i + 1]",
"+ if B[i] >= A[i + 1]:",
"+ ans += A[i + 1]",
"- # 街i+1のモンスターを一部倒せる場合",
"+ ans += B[i]",
"- hunted_monsters += B[i]",
"- B[i] = 0",
"- # 勇者iが街iのモンスターの一部(もしくはぴったり全て)倒して余力がない場合",
"+ # 勇者に余力がない場合",
"- A[i] -= B[i]",
"- hunted_monsters += B[i]",
"- B[i] = 0",
"-print(hunted_monsters)",
"+ ans += B[i]",
"+print(ans)"
] | false
| 0.064966
| 0.044814
| 1.449675
|
[
"s120377276",
"s150614370"
] |
u703950586
|
p02868
|
python
|
s485463680
|
s725574408
| 1,006
| 845
| 108,424
| 109,536
|
Accepted
|
Accepted
| 16
|
import sys,queue,math,copy,itertools,bisect,collections,heapq
class Node:
def __init__(self,x):
self.data = x
self.left = None
self.right = None
def insert(node,x):
if node is None: return Node(x)
elif x < node.data:
node.left = insert(node.left,x)
else:
node.right = insert(node.right,x)
return node
def search_min(node):
if node.left is None: return node.data
return search_min(node.left)
def delete_min(node):
if node.left is None: return node.right
node.left = delete_min(node.left)
return node
def delete(node,x):
if node:
if x == node.data:
if node.left is None:
return node.right
elif node.right is None:
return node.left
else:
node.data = search_min(node.right)
node.right = delete_min(node.right)
elif x < node.data:
node.left = delete(node.left,x)
else:
node.right = delete(node.right,x)
return node
def main():
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
N,M = LI()
p = [LI() for _ in range(M)]
p.sort()
r = [[] for _ in range(N+1)]
d = 0
j = 0
root = None
for i in range(1,N):
update = False
while j < M and p[j][0] == i:
root = insert(root,d + p[j][2])
update = True
r[p[j][1]].append(d + p[j][2])
j += 1
for z in r[i]:
root = delete(root,z)
update = True
if root == None:
print((-1))
return
if update:
d = search_min(root)
print(d)
if __name__ == '__main__':
main()
|
import sys,queue,math,copy,itertools,bisect,collections,heapq
class Node:
def __init__(self,x):
self.data = x
self.count = 1
self.left = None
self.right = None
def insert(node,x):
if node is None: return Node(x)
if node.data == x:
node.count += 1
elif x < node.data:
node.left = insert(node.left,x)
else:
node.right = insert(node.right,x)
return node
def search_min(node):
if node.left is None: return node.data
return search_min(node.left)
def delete_min(node):
if node.left is None:
if node.count > 1:
node.count -= 1
else:
return node.right
else:
node.left = delete_min(node.left)
return node
def delete(node,x):
if node:
if x == node.data:
if node.count > 1:
node.count -= 1
elif node.left is None:
return node.right
elif node.right is None:
return node.left
else:
node.data = search_min(node.right)
node.right = delete_min(node.right)
elif x < node.data:
node.left = delete(node.left,x)
else:
node.right = delete(node.right,x)
return node
def main():
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
N,M = LI()
p = [LI() for _ in range(M)]
p.sort()
r = [[] for _ in range(N+1)]
d = 0
j = 0
root = None
for i in range(1,N):
update = False
while j < M and p[j][0] == i:
root = insert(root,d + p[j][2])
update = True
r[p[j][1]].append(d + p[j][2])
j += 1
for z in r[i]:
root = delete(root,z)
update = True
if root == None:
print((-1))
return
if update:
d = search_min(root)
print(d)
if __name__ == '__main__':
main()
| 74
| 84
| 1,839
| 2,079
|
import sys, queue, math, copy, itertools, bisect, collections, heapq
class Node:
def __init__(self, x):
self.data = x
self.left = None
self.right = None
def insert(node, x):
if node is None:
return Node(x)
elif x < node.data:
node.left = insert(node.left, x)
else:
node.right = insert(node.right, x)
return node
def search_min(node):
if node.left is None:
return node.data
return search_min(node.left)
def delete_min(node):
if node.left is None:
return node.right
node.left = delete_min(node.left)
return node
def delete(node, x):
if node:
if x == node.data:
if node.left is None:
return node.right
elif node.right is None:
return node.left
else:
node.data = search_min(node.right)
node.right = delete_min(node.right)
elif x < node.data:
node.left = delete(node.left, x)
else:
node.right = delete(node.right, x)
return node
def main():
sys.setrecursionlimit(10**7)
LI = lambda: [int(x) for x in sys.stdin.readline().split()]
N, M = LI()
p = [LI() for _ in range(M)]
p.sort()
r = [[] for _ in range(N + 1)]
d = 0
j = 0
root = None
for i in range(1, N):
update = False
while j < M and p[j][0] == i:
root = insert(root, d + p[j][2])
update = True
r[p[j][1]].append(d + p[j][2])
j += 1
for z in r[i]:
root = delete(root, z)
update = True
if root == None:
print((-1))
return
if update:
d = search_min(root)
print(d)
if __name__ == "__main__":
main()
|
import sys, queue, math, copy, itertools, bisect, collections, heapq
class Node:
def __init__(self, x):
self.data = x
self.count = 1
self.left = None
self.right = None
def insert(node, x):
if node is None:
return Node(x)
if node.data == x:
node.count += 1
elif x < node.data:
node.left = insert(node.left, x)
else:
node.right = insert(node.right, x)
return node
def search_min(node):
if node.left is None:
return node.data
return search_min(node.left)
def delete_min(node):
if node.left is None:
if node.count > 1:
node.count -= 1
else:
return node.right
else:
node.left = delete_min(node.left)
return node
def delete(node, x):
if node:
if x == node.data:
if node.count > 1:
node.count -= 1
elif node.left is None:
return node.right
elif node.right is None:
return node.left
else:
node.data = search_min(node.right)
node.right = delete_min(node.right)
elif x < node.data:
node.left = delete(node.left, x)
else:
node.right = delete(node.right, x)
return node
def main():
sys.setrecursionlimit(10**7)
LI = lambda: [int(x) for x in sys.stdin.readline().split()]
N, M = LI()
p = [LI() for _ in range(M)]
p.sort()
r = [[] for _ in range(N + 1)]
d = 0
j = 0
root = None
for i in range(1, N):
update = False
while j < M and p[j][0] == i:
root = insert(root, d + p[j][2])
update = True
r[p[j][1]].append(d + p[j][2])
j += 1
for z in r[i]:
root = delete(root, z)
update = True
if root == None:
print((-1))
return
if update:
d = search_min(root)
print(d)
if __name__ == "__main__":
main()
| false
| 11.904762
|
[
"+ self.count = 1",
"+ if node.data == x:",
"+ node.count += 1",
"- return node.right",
"- node.left = delete_min(node.left)",
"+ if node.count > 1:",
"+ node.count -= 1",
"+ else:",
"+ return node.right",
"+ else:",
"+ node.left = delete_min(node.left)",
"- if node.left is None:",
"+ if node.count > 1:",
"+ node.count -= 1",
"+ elif node.left is None:"
] | false
| 0.131888
| 0.04658
| 2.831414
|
[
"s485463680",
"s725574408"
] |
u451017206
|
p03945
|
python
|
s645267347
|
s831170356
| 441
| 44
| 3,444
| 3,188
|
Accepted
|
Accepted
| 90.02
|
from collections import Counter
S = eval(input())
ans = 0
c = Counter(S)
if c['W'] == 0 or c['B'] == 0:
print((0))
exit()
a = S[0]
while True:
for i, s in enumerate(S):
if s != a: break
S = S[i:]
c[a] -= i
a = S[0]
ans += 1
if c['W'] == 0 or c['B'] == 0:break
print(ans)
|
S = eval(input())
ans = 0
for i in range(len(S) - 1):
if S[i] != S[i+1]: ans+=1
print(ans)
| 17
| 5
| 318
| 92
|
from collections import Counter
S = eval(input())
ans = 0
c = Counter(S)
if c["W"] == 0 or c["B"] == 0:
print((0))
exit()
a = S[0]
while True:
for i, s in enumerate(S):
if s != a:
break
S = S[i:]
c[a] -= i
a = S[0]
ans += 1
if c["W"] == 0 or c["B"] == 0:
break
print(ans)
|
S = eval(input())
ans = 0
for i in range(len(S) - 1):
if S[i] != S[i + 1]:
ans += 1
print(ans)
| false
| 70.588235
|
[
"-from collections import Counter",
"-",
"-c = Counter(S)",
"-if c[\"W\"] == 0 or c[\"B\"] == 0:",
"- print((0))",
"- exit()",
"-a = S[0]",
"-while True:",
"- for i, s in enumerate(S):",
"- if s != a:",
"- break",
"- S = S[i:]",
"- c[a] -= i",
"- a = S[0]",
"- ans += 1",
"- if c[\"W\"] == 0 or c[\"B\"] == 0:",
"- break",
"+for i in range(len(S) - 1):",
"+ if S[i] != S[i + 1]:",
"+ ans += 1"
] | false
| 0.035785
| 0.068393
| 0.523219
|
[
"s645267347",
"s831170356"
] |
u538361257
|
p02899
|
python
|
s038130436
|
s185447778
| 373
| 187
| 66,088
| 13,812
|
Accepted
|
Accepted
| 49.87
|
N = int(input())
A = list(map(int, input().split()))
student_dic = {}
for i in range(N):
student_dic[A[i]] = i+1
tmp = sorted(student_dic.items())
for i in range(N):
if i == N-1:
print(tmp[i][1])
else:
print(tmp[i][1], end=" ")
|
N = int(input())
A = list(map(int, input().split()))
student_dic = [0 for i in range(N)]
for i in range(N):
student_dic[A[i]-1] = i+1
for i in range(N):
if i == N-1:
print(student_dic[i])
else:
print(student_dic[i], end=" ")
| 14
| 13
| 272
| 268
|
N = int(input())
A = list(map(int, input().split()))
student_dic = {}
for i in range(N):
student_dic[A[i]] = i + 1
tmp = sorted(student_dic.items())
for i in range(N):
if i == N - 1:
print(tmp[i][1])
else:
print(tmp[i][1], end=" ")
|
N = int(input())
A = list(map(int, input().split()))
student_dic = [0 for i in range(N)]
for i in range(N):
student_dic[A[i] - 1] = i + 1
for i in range(N):
if i == N - 1:
print(student_dic[i])
else:
print(student_dic[i], end=" ")
| false
| 7.142857
|
[
"-student_dic = {}",
"+student_dic = [0 for i in range(N)]",
"- student_dic[A[i]] = i + 1",
"-tmp = sorted(student_dic.items())",
"+ student_dic[A[i] - 1] = i + 1",
"- print(tmp[i][1])",
"+ print(student_dic[i])",
"- print(tmp[i][1], end=\" \")",
"+ print(student_dic[i], end=\" \")"
] | false
| 0.083272
| 0.006683
| 12.460831
|
[
"s038130436",
"s185447778"
] |
u281303342
|
p03837
|
python
|
s222343778
|
s121103789
| 257
| 172
| 18,040
| 14,252
|
Accepted
|
Accepted
| 33.07
|
# python3 (3.4.3)
import sys
input = sys.stdin.readline
# main
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
N,M = list(map(int,input().split()))
ABC = [list(map(int,input().split())) for _ in range(M)]
g = [[0 for _ in range(N)] for _ in range(N)]
for a,b,c in ABC:
g[a-1][b-1] = c
csg = csgraph_from_dense(g)
d = floyd_warshall(csg, directed=False)
ans = 0
for a,b,c in ABC:
if c != d[a-1][b-1]:
ans += 1
print(ans)
|
# Python3 (3.4.3)
import sys
input = sys.stdin.readline
# -------------------------------------------------------------
# function
# -------------------------------------------------------------
# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = list(map(int,input().split()))
ABC = [list(map(int,input().split())) for _ in range(M)]
g = [[0 for _ in range(N)] for _ in range(N)]
for a,b,c in ABC:
g[a-1][b-1] = c
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
csg = csgraph_from_dense(g)
d = floyd_warshall(csg, directed=False)
ans = 0
for a,b,c in ABC:
if c != d[a-1][b-1]:
ans += 1
print(ans)
| 23
| 30
| 477
| 753
|
# python3 (3.4.3)
import sys
input = sys.stdin.readline
# main
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
N, M = list(map(int, input().split()))
ABC = [list(map(int, input().split())) for _ in range(M)]
g = [[0 for _ in range(N)] for _ in range(N)]
for a, b, c in ABC:
g[a - 1][b - 1] = c
csg = csgraph_from_dense(g)
d = floyd_warshall(csg, directed=False)
ans = 0
for a, b, c in ABC:
if c != d[a - 1][b - 1]:
ans += 1
print(ans)
|
# Python3 (3.4.3)
import sys
input = sys.stdin.readline
# -------------------------------------------------------------
# function
# -------------------------------------------------------------
# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N, M = list(map(int, input().split()))
ABC = [list(map(int, input().split())) for _ in range(M)]
g = [[0 for _ in range(N)] for _ in range(N)]
for a, b, c in ABC:
g[a - 1][b - 1] = c
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
csg = csgraph_from_dense(g)
d = floyd_warshall(csg, directed=False)
ans = 0
for a, b, c in ABC:
if c != d[a - 1][b - 1]:
ans += 1
print(ans)
| false
| 23.333333
|
[
"-# python3 (3.4.3)",
"+# Python3 (3.4.3)",
"+# function",
"-from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall",
"-",
"+from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall",
"+"
] | false
| 0.403455
| 0.628695
| 0.641733
|
[
"s222343778",
"s121103789"
] |
u846694620
|
p03665
|
python
|
s628793791
|
s090562499
| 24
| 18
| 3,572
| 3,064
|
Accepted
|
Accepted
| 25
|
import functools
import math
@functools.lru_cache()
def combinations(n, r):
return math.factorial(n) / math.factorial(r) / math.factorial(n - r)
def main():
n, p = list(map(int, input().split()))
a = tuple([int(x) % 2 for x in input().split()])
if n == 1 and a[0] % 2 != p:
print((0))
return 0
t = len(tuple([x for x in a if x == 1]))
f = n - t
count = 0
if p == 0:
for i in range(t + 1):
if i % 2 == 0:
c = 0
for j in range(f + 1):
c += combinations(f, j)
count += combinations(t, i) * c
else:
for i in range(t + 1):
if i % 2 == 1:
c = 0
for j in range(f + 1):
c += combinations(f, j)
count += combinations(t, i) * c
print((int(count)))
return 0
if __name__ == '__main__':
main()
|
import math
def comb(n, r):
return math.factorial(n) / math.factorial(r) / math.factorial(n - r)
def main():
n, p = list(map(int, input().split()))
a = tuple([int(x) % 2 for x in input().split()])
if n == 1 and a[0] % 2 != p:
print((0))
return 0
t = len(tuple([x for x in a if x == 1]))
f = n - t
f_comb = 0
for j in range(f + 1):
f_comb += comb(f, j)
t_comb = 0
if p == 0:
for i in range(t + 1):
if i % 2 == 0:
t_comb += comb(t, i)
else:
for i in range(t + 1):
if i % 2 == 1:
t_comb += comb(t, i)
print((int(t_comb * f_comb)))
return 0
if __name__ == '__main__':
main()
| 43
| 39
| 972
| 771
|
import functools
import math
@functools.lru_cache()
def combinations(n, r):
return math.factorial(n) / math.factorial(r) / math.factorial(n - r)
def main():
n, p = list(map(int, input().split()))
a = tuple([int(x) % 2 for x in input().split()])
if n == 1 and a[0] % 2 != p:
print((0))
return 0
t = len(tuple([x for x in a if x == 1]))
f = n - t
count = 0
if p == 0:
for i in range(t + 1):
if i % 2 == 0:
c = 0
for j in range(f + 1):
c += combinations(f, j)
count += combinations(t, i) * c
else:
for i in range(t + 1):
if i % 2 == 1:
c = 0
for j in range(f + 1):
c += combinations(f, j)
count += combinations(t, i) * c
print((int(count)))
return 0
if __name__ == "__main__":
main()
|
import math
def comb(n, r):
return math.factorial(n) / math.factorial(r) / math.factorial(n - r)
def main():
n, p = list(map(int, input().split()))
a = tuple([int(x) % 2 for x in input().split()])
if n == 1 and a[0] % 2 != p:
print((0))
return 0
t = len(tuple([x for x in a if x == 1]))
f = n - t
f_comb = 0
for j in range(f + 1):
f_comb += comb(f, j)
t_comb = 0
if p == 0:
for i in range(t + 1):
if i % 2 == 0:
t_comb += comb(t, i)
else:
for i in range(t + 1):
if i % 2 == 1:
t_comb += comb(t, i)
print((int(t_comb * f_comb)))
return 0
if __name__ == "__main__":
main()
| false
| 9.302326
|
[
"-import functools",
"-@functools.lru_cache()",
"-def combinations(n, r):",
"+def comb(n, r):",
"- count = 0",
"+ f_comb = 0",
"+ for j in range(f + 1):",
"+ f_comb += comb(f, j)",
"+ t_comb = 0",
"- c = 0",
"- for j in range(f + 1):",
"- c += combinations(f, j)",
"- count += combinations(t, i) * c",
"+ t_comb += comb(t, i)",
"- c = 0",
"- for j in range(f + 1):",
"- c += combinations(f, j)",
"- count += combinations(t, i) * c",
"- print((int(count)))",
"+ t_comb += comb(t, i)",
"+ print((int(t_comb * f_comb)))"
] | false
| 0.038228
| 0.037078
| 1.031019
|
[
"s628793791",
"s090562499"
] |
u419877586
|
p02777
|
python
|
s697680804
|
s219175229
| 165
| 17
| 38,256
| 2,940
|
Accepted
|
Accepted
| 89.7
|
S, T=input().split()
A, B=list(map(int, input().split()))
U=eval(input())
if S==U:
print((A-1, B))
else:
print((A, B-1))
|
S, T = input().split()
A, B = list(map(int, input().split()))
U = eval(input())
if U == S:
print((A-1, B))
else:
print((A, B-1))
| 7
| 7
| 118
| 127
|
S, T = input().split()
A, B = list(map(int, input().split()))
U = eval(input())
if S == U:
print((A - 1, B))
else:
print((A, B - 1))
|
S, T = input().split()
A, B = list(map(int, input().split()))
U = eval(input())
if U == S:
print((A - 1, B))
else:
print((A, B - 1))
| false
| 0
|
[
"-if S == U:",
"+if U == S:"
] | false
| 0.040455
| 0.03622
| 1.116942
|
[
"s697680804",
"s219175229"
] |
u077291787
|
p03005
|
python
|
s100928627
|
s923889660
| 185
| 17
| 38,256
| 2,940
|
Accepted
|
Accepted
| 90.81
|
# div2019-2A - Ball Distribution
n, k = list(map(int, input().rstrip().split()))
print((n % k))
|
# diverta2019-2A - Ball Distribution
def main():
n, k = list(map(int, input().rstrip().split()))
print((n % k))
if __name__ == "__main__":
main()
| 3
| 8
| 95
| 158
|
# div2019-2A - Ball Distribution
n, k = list(map(int, input().rstrip().split()))
print((n % k))
|
# diverta2019-2A - Ball Distribution
def main():
n, k = list(map(int, input().rstrip().split()))
print((n % k))
if __name__ == "__main__":
main()
| false
| 62.5
|
[
"-# div2019-2A - Ball Distribution",
"-n, k = list(map(int, input().rstrip().split()))",
"-print((n % k))",
"+# diverta2019-2A - Ball Distribution",
"+def main():",
"+ n, k = list(map(int, input().rstrip().split()))",
"+ print((n % k))",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false
| 0.087059
| 0.066284
| 1.313422
|
[
"s100928627",
"s923889660"
] |
u644907318
|
p02861
|
python
|
s243753852
|
s018159047
| 239
| 208
| 41,324
| 40,812
|
Accepted
|
Accepted
| 12.97
|
from itertools import permutations
import math
def dist(x,y):
return ((x[0]-y[0])**2+(x[1]-y[1])**2)**(0.5)
N = int(eval(input()))
X = [list(map(int,input().split())) for _ in range(N)]
ans = 0
for z in permutations(list(range(N)),N):
for i in range(N-1):
ans += dist(X[z[i]],X[z[(i+1)%N]])
print((ans/math.factorial(N)))
|
from itertools import permutations
def dist(x,y):
return ((x[0]-y[0])**2+(x[1]-y[1])**2)**0.5
N = int(eval(input()))
X = [list(map(int,input().split())) for _ in range(N)]
tot = 0
cnt = 0
for z in permutations(list(range(N))):
cnt += 1
for i in range(1,N):
tot += dist(X[z[i]],X[z[i-1]])
print((tot/cnt))
| 11
| 12
| 333
| 321
|
from itertools import permutations
import math
def dist(x, y):
return ((x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2) ** (0.5)
N = int(eval(input()))
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for z in permutations(list(range(N)), N):
for i in range(N - 1):
ans += dist(X[z[i]], X[z[(i + 1) % N]])
print((ans / math.factorial(N)))
|
from itertools import permutations
def dist(x, y):
return ((x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2) ** 0.5
N = int(eval(input()))
X = [list(map(int, input().split())) for _ in range(N)]
tot = 0
cnt = 0
for z in permutations(list(range(N))):
cnt += 1
for i in range(1, N):
tot += dist(X[z[i]], X[z[i - 1]])
print((tot / cnt))
| false
| 8.333333
|
[
"-import math",
"- return ((x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2) ** (0.5)",
"+ return ((x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2) ** 0.5",
"-ans = 0",
"-for z in permutations(list(range(N)), N):",
"- for i in range(N - 1):",
"- ans += dist(X[z[i]], X[z[(i + 1) % N]])",
"-print((ans / math.factorial(N)))",
"+tot = 0",
"+cnt = 0",
"+for z in permutations(list(range(N))):",
"+ cnt += 1",
"+ for i in range(1, N):",
"+ tot += dist(X[z[i]], X[z[i - 1]])",
"+print((tot / cnt))"
] | false
| 0.047959
| 0.05473
| 0.876298
|
[
"s243753852",
"s018159047"
] |
u768896740
|
p03645
|
python
|
s965657892
|
s898493683
| 680
| 587
| 21,820
| 21,852
|
Accepted
|
Accepted
| 13.68
|
n, m = list(map(int, input().split()))
first = []
second = []
for i in range(m):
a = list(map(int, input().split()))
if a[0] == 1:
first.append(a[1])
if a[1] == n:
second.append(a[0])
if len(set(first) & set(second)) > 0:
print('POSSIBLE')
else:
print('IMPOSSIBLE')
|
n, m = list(map(int, input().split()))
a = []
b = []
for i in range(m):
x, y = list(map(int, input().split()))
if x == 1:
a.append(y)
elif y == n:
b.append(x)
if set(a) & set(b):
print('POSSIBLE')
else:
print('IMPOSSIBLE')
| 16
| 15
| 313
| 263
|
n, m = list(map(int, input().split()))
first = []
second = []
for i in range(m):
a = list(map(int, input().split()))
if a[0] == 1:
first.append(a[1])
if a[1] == n:
second.append(a[0])
if len(set(first) & set(second)) > 0:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
|
n, m = list(map(int, input().split()))
a = []
b = []
for i in range(m):
x, y = list(map(int, input().split()))
if x == 1:
a.append(y)
elif y == n:
b.append(x)
if set(a) & set(b):
print("POSSIBLE")
else:
print("IMPOSSIBLE")
| false
| 6.25
|
[
"-first = []",
"-second = []",
"+a = []",
"+b = []",
"- a = list(map(int, input().split()))",
"- if a[0] == 1:",
"- first.append(a[1])",
"- if a[1] == n:",
"- second.append(a[0])",
"-if len(set(first) & set(second)) > 0:",
"+ x, y = list(map(int, input().split()))",
"+ if x == 1:",
"+ a.append(y)",
"+ elif y == n:",
"+ b.append(x)",
"+if set(a) & set(b):"
] | false
| 0.039166
| 0.043257
| 0.905424
|
[
"s965657892",
"s898493683"
] |
u869919400
|
p02862
|
python
|
s515880329
|
s059113628
| 537
| 236
| 40,300
| 73,028
|
Accepted
|
Accepted
| 56.05
|
X, Y = list(map(int, input().split()))
mod = 10**9+7
if (X+Y) % 3 != 0:
print((0))
else:
n = (2*Y-X)//3
m = (2*X-Y)//3
'''
n*(1,2) + m*(2,1) = (x, y)
x = n+2m
y = 2n+m
2x = 2n+4m
2x-y = 3m
m = (2x-y)/3
n = (2y-x)/3
'''
if 0 > n or 0 > m:
print((0))
else:
ans = 1
for i in range(1,n+1):
ans *= (n+m+1-i)*pow(i,mod-2,mod)
ans %= mod
print(ans)
|
X, Y = list(map(int, input().split()))
m, r = divmod(2*Y-X, 3)
if r != 0:
print((0))
exit()
n = Y - 2*m
if n < 0 or m < 0:
print((0))
exit()
def modinv(a, mod=10**9+7):
return pow(a, mod-2, mod)
def combination(n, r, mod=10**9+7):
r = min(r, n-r)
res = 1
for i in range(r):
res = res * (n-i) * modinv(i+1, mod) % mod
return res
print((combination(n+m, n)))
| 25
| 24
| 470
| 417
|
X, Y = list(map(int, input().split()))
mod = 10**9 + 7
if (X + Y) % 3 != 0:
print((0))
else:
n = (2 * Y - X) // 3
m = (2 * X - Y) // 3
"""
n*(1,2) + m*(2,1) = (x, y)
x = n+2m
y = 2n+m
2x = 2n+4m
2x-y = 3m
m = (2x-y)/3
n = (2y-x)/3
"""
if 0 > n or 0 > m:
print((0))
else:
ans = 1
for i in range(1, n + 1):
ans *= (n + m + 1 - i) * pow(i, mod - 2, mod)
ans %= mod
print(ans)
|
X, Y = list(map(int, input().split()))
m, r = divmod(2 * Y - X, 3)
if r != 0:
print((0))
exit()
n = Y - 2 * m
if n < 0 or m < 0:
print((0))
exit()
def modinv(a, mod=10**9 + 7):
return pow(a, mod - 2, mod)
def combination(n, r, mod=10**9 + 7):
r = min(r, n - r)
res = 1
for i in range(r):
res = res * (n - i) * modinv(i + 1, mod) % mod
return res
print((combination(n + m, n)))
| false
| 4
|
[
"-mod = 10**9 + 7",
"-if (X + Y) % 3 != 0:",
"+m, r = divmod(2 * Y - X, 3)",
"+if r != 0:",
"-else:",
"- n = (2 * Y - X) // 3",
"- m = (2 * X - Y) // 3",
"- \"\"\"",
"- n*(1,2) + m*(2,1) = (x, y)",
"- x = n+2m",
"- y = 2n+m",
"- 2x = 2n+4m",
"- 2x-y = 3m",
"- m = (2x-y)/3",
"- n = (2y-x)/3",
"- \"\"\"",
"- if 0 > n or 0 > m:",
"- print((0))",
"- else:",
"- ans = 1",
"- for i in range(1, n + 1):",
"- ans *= (n + m + 1 - i) * pow(i, mod - 2, mod)",
"- ans %= mod",
"- print(ans)",
"+ exit()",
"+n = Y - 2 * m",
"+if n < 0 or m < 0:",
"+ print((0))",
"+ exit()",
"+",
"+",
"+def modinv(a, mod=10**9 + 7):",
"+ return pow(a, mod - 2, mod)",
"+",
"+",
"+def combination(n, r, mod=10**9 + 7):",
"+ r = min(r, n - r)",
"+ res = 1",
"+ for i in range(r):",
"+ res = res * (n - i) * modinv(i + 1, mod) % mod",
"+ return res",
"+",
"+",
"+print((combination(n + m, n)))"
] | false
| 0.414597
| 0.280781
| 1.476584
|
[
"s515880329",
"s059113628"
] |
u200887663
|
p02623
|
python
|
s427026716
|
s430660013
| 991
| 328
| 47,352
| 47,368
|
Accepted
|
Accepted
| 66.9
|
#n=int(input())
n,m,k=list(map(int,input().split()))
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
A=[0]
for i in range(n):
A.append(A[i]+al[i])
B=[0]
for i in range(m):
B.append(B[i]+bl[i])
B.append(max(B[m],k)+1)
mx=0
for i in range(n+1):
rem=k-A[i]
if rem<0:
continue
left=0;right=m+1
while right-left>1:
mid=(left+right)//2
if B[mid]>rem:
right=mid
else:
left=mid
mx=max(left+i,mx)
print(mx)
|
#n=int(input())
n,m,k=list(map(int,input().split()))
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
import bisect
A=[0]
for i in range(n):
A.append(A[i]+al[i])
B=[0]
for i in range(m):
B.append(B[i]+bl[i])
#B.append(max(B[m],k)+1)
mx=0
for i in range(n+1):
rem=k-A[i]
if rem<0:
continue
bnum=bisect.bisect_right(B,rem)-1
mx=max(mx,i+bnum)
print(mx)
| 28
| 22
| 579
| 472
|
# n=int(input())
n, m, k = list(map(int, input().split()))
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
# l=[list(map(int,input().split())) for i in range(n)]
A = [0]
for i in range(n):
A.append(A[i] + al[i])
B = [0]
for i in range(m):
B.append(B[i] + bl[i])
B.append(max(B[m], k) + 1)
mx = 0
for i in range(n + 1):
rem = k - A[i]
if rem < 0:
continue
left = 0
right = m + 1
while right - left > 1:
mid = (left + right) // 2
if B[mid] > rem:
right = mid
else:
left = mid
mx = max(left + i, mx)
print(mx)
|
# n=int(input())
n, m, k = list(map(int, input().split()))
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
# l=[list(map(int,input().split())) for i in range(n)]
import bisect
A = [0]
for i in range(n):
A.append(A[i] + al[i])
B = [0]
for i in range(m):
B.append(B[i] + bl[i])
# B.append(max(B[m],k)+1)
mx = 0
for i in range(n + 1):
rem = k - A[i]
if rem < 0:
continue
bnum = bisect.bisect_right(B, rem) - 1
mx = max(mx, i + bnum)
print(mx)
| false
| 21.428571
|
[
"+import bisect",
"+",
"-B.append(max(B[m], k) + 1)",
"+# B.append(max(B[m],k)+1)",
"- left = 0",
"- right = m + 1",
"- while right - left > 1:",
"- mid = (left + right) // 2",
"- if B[mid] > rem:",
"- right = mid",
"- else:",
"- left = mid",
"- mx = max(left + i, mx)",
"+ bnum = bisect.bisect_right(B, rem) - 1",
"+ mx = max(mx, i + bnum)"
] | false
| 0.007184
| 0.031723
| 0.226471
|
[
"s427026716",
"s430660013"
] |
u489959379
|
p04031
|
python
|
s645904749
|
s082962557
| 28
| 25
| 3,060
| 3,060
|
Accepted
|
Accepted
| 10.71
|
n = int(eval(input()))
A = list(map(int, input().split()))
res = float("inf")
for x in range(min(A), max(A) + 1):
cost = 0
for j in range(n):
y = A[j]
cost += pow(x - y, 2)
res = min(res, cost)
print(res)
|
import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n = int(eval(input()))
A = list(map(int, input().split()))
res = f_inf
for y in range(-100, 101):
cost = 0
for i in range(n):
cost += pow(abs(A[i] - y), 2)
res = min(res, cost)
print(res)
if __name__ == '__main__':
resolve()
| 11
| 22
| 238
| 402
|
n = int(eval(input()))
A = list(map(int, input().split()))
res = float("inf")
for x in range(min(A), max(A) + 1):
cost = 0
for j in range(n):
y = A[j]
cost += pow(x - y, 2)
res = min(res, cost)
print(res)
|
import sys
sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
n = int(eval(input()))
A = list(map(int, input().split()))
res = f_inf
for y in range(-100, 101):
cost = 0
for i in range(n):
cost += pow(abs(A[i] - y), 2)
res = min(res, cost)
print(res)
if __name__ == "__main__":
resolve()
| false
| 50
|
[
"-n = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-res = float(\"inf\")",
"-for x in range(min(A), max(A) + 1):",
"- cost = 0",
"- for j in range(n):",
"- y = A[j]",
"- cost += pow(x - y, 2)",
"- res = min(res, cost)",
"-print(res)",
"+import sys",
"+",
"+sys.setrecursionlimit(10**7)",
"+f_inf = float(\"inf\")",
"+mod = 10**9 + 7",
"+",
"+",
"+def resolve():",
"+ n = int(eval(input()))",
"+ A = list(map(int, input().split()))",
"+ res = f_inf",
"+ for y in range(-100, 101):",
"+ cost = 0",
"+ for i in range(n):",
"+ cost += pow(abs(A[i] - y), 2)",
"+ res = min(res, cost)",
"+ print(res)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ resolve()"
] | false
| 0.034771
| 0.080848
| 0.430073
|
[
"s645904749",
"s082962557"
] |
u497046426
|
p03624
|
python
|
s916402648
|
s442583529
| 29
| 19
| 3,188
| 3,188
|
Accepted
|
Accepted
| 34.48
|
S = eval(input())
alphabets = set(list('abcdefghijklmnopqrstuvwxyz'))
for s in S:
alphabets.discard(s)
if len(alphabets) != 0:
print((sorted(alphabets)[0]))
else:
print('None')
|
S = set(eval(input()))
diff = set('abcdefghijklmnopqrstuvwxyz') - S
if diff:
print((min(diff)))
else:
print('None')
| 10
| 6
| 191
| 120
|
S = eval(input())
alphabets = set(list("abcdefghijklmnopqrstuvwxyz"))
for s in S:
alphabets.discard(s)
if len(alphabets) != 0:
print((sorted(alphabets)[0]))
else:
print("None")
|
S = set(eval(input()))
diff = set("abcdefghijklmnopqrstuvwxyz") - S
if diff:
print((min(diff)))
else:
print("None")
| false
| 40
|
[
"-S = eval(input())",
"-alphabets = set(list(\"abcdefghijklmnopqrstuvwxyz\"))",
"-for s in S:",
"- alphabets.discard(s)",
"-if len(alphabets) != 0:",
"- print((sorted(alphabets)[0]))",
"+S = set(eval(input()))",
"+diff = set(\"abcdefghijklmnopqrstuvwxyz\") - S",
"+if diff:",
"+ print((min(diff)))"
] | false
| 0.041251
| 0.044907
| 0.918594
|
[
"s916402648",
"s442583529"
] |
u674395364
|
p03494
|
python
|
s748256224
|
s523304309
| 20
| 18
| 2,940
| 2,940
|
Accepted
|
Accepted
| 10
|
N = int(eval(input()))
As = list(map(int, input().split()))
i = 0
while True:
for a in As:
if a % pow(2, (i+1)) != 0:
break
else:
i += 1
continue
break
print(i)
|
N = int(eval(input()))
A = list(map(int, input().split()))
count = 0
div = 2
flag = False
while True:
for a in A:
if a % div != 0:
flag = True
break
if flag:
break
else:
count += 1
div *= 2
print(count)
| 13
| 17
| 189
| 248
|
N = int(eval(input()))
As = list(map(int, input().split()))
i = 0
while True:
for a in As:
if a % pow(2, (i + 1)) != 0:
break
else:
i += 1
continue
break
print(i)
|
N = int(eval(input()))
A = list(map(int, input().split()))
count = 0
div = 2
flag = False
while True:
for a in A:
if a % div != 0:
flag = True
break
if flag:
break
else:
count += 1
div *= 2
print(count)
| false
| 23.529412
|
[
"-As = list(map(int, input().split()))",
"-i = 0",
"+A = list(map(int, input().split()))",
"+count = 0",
"+div = 2",
"+flag = False",
"- for a in As:",
"- if a % pow(2, (i + 1)) != 0:",
"+ for a in A:",
"+ if a % div != 0:",
"+ flag = True",
"+ if flag:",
"+ break",
"- i += 1",
"- continue",
"- break",
"-print(i)",
"+ count += 1",
"+ div *= 2",
"+print(count)"
] | false
| 0.034401
| 0.035585
| 0.966745
|
[
"s748256224",
"s523304309"
] |
u533232830
|
p02573
|
python
|
s874865279
|
s602402323
| 686
| 465
| 158,840
| 112,240
|
Accepted
|
Accepted
| 32.22
|
from collections import deque
N, M = list(map(int, input().split()))
g = {i:set() for i in range(N)}
v = [-1 for i in range(N)]
for _ in range(M):
a, b = list(map(int, input().split()))
a, b = a-1, b-1
g[a].add(b)
g[b].add(a)
Q = deque()
ans = 0
for a in g:
if v[a]==-1:
v[a] = 1
ans_tmp = 1
Q.append(a)
while len(Q)>0:
na = Q.popleft()
for nb in g[na]:
if v[nb] == -1:
v[nb] = 1
ans_tmp += 1
Q.append(nb)
ans = max(ans, ans_tmp)
print(ans)
|
from collections import deque
N, M = list(map(int, input().split()))
friends = [[] for _ in range(N)]
for _ in range(M):
a, b = list(map(int, input().split()))
a, b = a-1, b-1
friends[a].append(b)
friends[b].append(a)
checked = [False] * N
ans = 0
for i in range(N):
if checked[i] == False:
checked[i] = True
DQ = deque(friends[i])
tmp = 1
while DQ:
f = DQ.popleft()
if checked[f] == False:
checked[f] = True
tmp += 1
for j in friends[f]:
DQ.append(j)
ans = max(ans, tmp)
print(ans)
| 27
| 29
| 537
| 651
|
from collections import deque
N, M = list(map(int, input().split()))
g = {i: set() for i in range(N)}
v = [-1 for i in range(N)]
for _ in range(M):
a, b = list(map(int, input().split()))
a, b = a - 1, b - 1
g[a].add(b)
g[b].add(a)
Q = deque()
ans = 0
for a in g:
if v[a] == -1:
v[a] = 1
ans_tmp = 1
Q.append(a)
while len(Q) > 0:
na = Q.popleft()
for nb in g[na]:
if v[nb] == -1:
v[nb] = 1
ans_tmp += 1
Q.append(nb)
ans = max(ans, ans_tmp)
print(ans)
|
from collections import deque
N, M = list(map(int, input().split()))
friends = [[] for _ in range(N)]
for _ in range(M):
a, b = list(map(int, input().split()))
a, b = a - 1, b - 1
friends[a].append(b)
friends[b].append(a)
checked = [False] * N
ans = 0
for i in range(N):
if checked[i] == False:
checked[i] = True
DQ = deque(friends[i])
tmp = 1
while DQ:
f = DQ.popleft()
if checked[f] == False:
checked[f] = True
tmp += 1
for j in friends[f]:
DQ.append(j)
ans = max(ans, tmp)
print(ans)
| false
| 6.896552
|
[
"-g = {i: set() for i in range(N)}",
"-v = [-1 for i in range(N)]",
"+friends = [[] for _ in range(N)]",
"- g[a].add(b)",
"- g[b].add(a)",
"-Q = deque()",
"+ friends[a].append(b)",
"+ friends[b].append(a)",
"+checked = [False] * N",
"-for a in g:",
"- if v[a] == -1:",
"- v[a] = 1",
"- ans_tmp = 1",
"- Q.append(a)",
"- while len(Q) > 0:",
"- na = Q.popleft()",
"- for nb in g[na]:",
"- if v[nb] == -1:",
"- v[nb] = 1",
"- ans_tmp += 1",
"- Q.append(nb)",
"- ans = max(ans, ans_tmp)",
"+for i in range(N):",
"+ if checked[i] == False:",
"+ checked[i] = True",
"+ DQ = deque(friends[i])",
"+ tmp = 1",
"+ while DQ:",
"+ f = DQ.popleft()",
"+ if checked[f] == False:",
"+ checked[f] = True",
"+ tmp += 1",
"+ for j in friends[f]:",
"+ DQ.append(j)",
"+ ans = max(ans, tmp)"
] | false
| 0.045434
| 0.0455
| 0.998536
|
[
"s874865279",
"s602402323"
] |
u476604182
|
p03808
|
python
|
s178811589
|
s017649349
| 98
| 79
| 14,068
| 14,068
|
Accepted
|
Accepted
| 19.39
|
N, *A = list(map(int, open(0).read().split()))
M = (N+1)*N//2
S = sum(A)
if S%M!=0:
print('NO')
import sys
sys.exit()
cnt = S//M
x = 0
for i in range(N):
df = A[(i+1)%N]-A[i]
if (cnt-df)%N!=0 or cnt<df:
print('NO')
break
x += (cnt-df)//N
else:
if x==cnt:
print('YES')
else:
print('NO')
|
N, *A = list(map(int, open(0).read().split()))
M = (N+1)*N//2
S = sum(A)
if S%M!=0:
print('NO')
exit()
cnt = S//M
for i in range(N):
df = A[(i+1)%N]-A[i]
if (cnt-df)%N!=0 or cnt<df:
print('NO')
break
else:
print('YES')
| 20
| 14
| 330
| 243
|
N, *A = list(map(int, open(0).read().split()))
M = (N + 1) * N // 2
S = sum(A)
if S % M != 0:
print("NO")
import sys
sys.exit()
cnt = S // M
x = 0
for i in range(N):
df = A[(i + 1) % N] - A[i]
if (cnt - df) % N != 0 or cnt < df:
print("NO")
break
x += (cnt - df) // N
else:
if x == cnt:
print("YES")
else:
print("NO")
|
N, *A = list(map(int, open(0).read().split()))
M = (N + 1) * N // 2
S = sum(A)
if S % M != 0:
print("NO")
exit()
cnt = S // M
for i in range(N):
df = A[(i + 1) % N] - A[i]
if (cnt - df) % N != 0 or cnt < df:
print("NO")
break
else:
print("YES")
| false
| 30
|
[
"- import sys",
"-",
"- sys.exit()",
"+ exit()",
"-x = 0",
"- x += (cnt - df) // N",
"- if x == cnt:",
"- print(\"YES\")",
"- else:",
"- print(\"NO\")",
"+ print(\"YES\")"
] | false
| 0.044901
| 0.007643
| 5.874839
|
[
"s178811589",
"s017649349"
] |
u028393857
|
p03389
|
python
|
s487882331
|
s006934168
| 35
| 11
| 27,884
| 2,696
|
Accepted
|
Accepted
| 68.57
|
def middle(lst):
_lst = lst
_lst.sort()
return _lst[-2]
def min_times(lst):
data = lst
times = 0
idx_even = []
idx_odd = []
for i, v in enumerate(data):
if v % 2 == 0:
idx_even.append(i)
else:
idx_odd.append(i)
odd_len = len(idx_odd)
if odd_len in (0, 3):
times += (max(data) - middle(data)) / 2
times += (max(data) - min(data)) / 2
if odd_len == 2:
for i in idx_odd:
data[i] += 1
return min_times(data) + 1
if odd_len == 1:
for i in idx_even:
data[i] += 1
return min_times(data) + 1
return times
use_data = [int(i) for i in input().split()]
print((min_times(use_data)))
|
def middle(lst):
_lst = lst
_lst.sort()
return _lst[-2]
def min_times(lst):
data = lst
times = 0
idx_even = []
idx_odd = []
for i, v in enumerate(data):
if v % 2 == 0:
idx_even.append(i)
else:
idx_odd.append(i)
odd_len = len(idx_odd)
if odd_len in (0, 3):
times += (max(data) - middle(data)) / 2
times += (max(data) - min(data)) / 2
if odd_len == 2:
for i in idx_odd:
data[i] += 1
return min_times(data) + 1
if odd_len == 1:
for i in idx_even:
data[i] += 1
return min_times(data) + 1
return times
use_data = [int(i) for i in input().strip().split()]
print((min_times(use_data)))
| 32
| 32
| 770
| 778
|
def middle(lst):
_lst = lst
_lst.sort()
return _lst[-2]
def min_times(lst):
data = lst
times = 0
idx_even = []
idx_odd = []
for i, v in enumerate(data):
if v % 2 == 0:
idx_even.append(i)
else:
idx_odd.append(i)
odd_len = len(idx_odd)
if odd_len in (0, 3):
times += (max(data) - middle(data)) / 2
times += (max(data) - min(data)) / 2
if odd_len == 2:
for i in idx_odd:
data[i] += 1
return min_times(data) + 1
if odd_len == 1:
for i in idx_even:
data[i] += 1
return min_times(data) + 1
return times
use_data = [int(i) for i in input().split()]
print((min_times(use_data)))
|
def middle(lst):
_lst = lst
_lst.sort()
return _lst[-2]
def min_times(lst):
data = lst
times = 0
idx_even = []
idx_odd = []
for i, v in enumerate(data):
if v % 2 == 0:
idx_even.append(i)
else:
idx_odd.append(i)
odd_len = len(idx_odd)
if odd_len in (0, 3):
times += (max(data) - middle(data)) / 2
times += (max(data) - min(data)) / 2
if odd_len == 2:
for i in idx_odd:
data[i] += 1
return min_times(data) + 1
if odd_len == 1:
for i in idx_even:
data[i] += 1
return min_times(data) + 1
return times
use_data = [int(i) for i in input().strip().split()]
print((min_times(use_data)))
| false
| 0
|
[
"-use_data = [int(i) for i in input().split()]",
"+use_data = [int(i) for i in input().strip().split()]"
] | false
| 0.082341
| 0.045111
| 1.825286
|
[
"s487882331",
"s006934168"
] |
u320567105
|
p03240
|
python
|
s072089190
|
s267553342
| 39
| 36
| 3,188
| 3,188
|
Accepted
|
Accepted
| 7.69
|
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18
N=ri()
xyh=[]
for i in range(N):
xyh += [rl()]
xyh.sort(reverse=True, key=lambda x:x[2])
ans=[-1]*3
for x in range(101):
if ans[0] != -1:
break
for y in range(101):
if ans[0] != -1:
break
if xyh[0][2] == 0:
h_m = xyh[0][2]+abs(x-xyh[0][0])+abs(y-xyh[0][1])
for i in range(1,N):
rst = xyh[i][2]+abs(x-xyh[i][0])+abs(y-xyh[i][1])
if h_m > rst:
h_m = rst
if h_m == 0:
break
elif i==N-1:
ans = [x,y,h_m]
else:
h = xyh[0][2]+abs(x-xyh[0][0])+abs(y-xyh[0][1])
for i in range(1,N):
if xyh[i][2] != 0:
if h != xyh[i][2]+abs(x-xyh[i][0])+abs(y-xyh[i][1]):
break
elif xyh[i][2] == 0:
if h > xyh[i][2]+abs(x-xyh[i][0])+abs(y-xyh[i][1]):
break
if i == N-1:
ans = [x,y,h]
print("{} {} {}".format(ans[0],ans[1],ans[2]))
|
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18
N=ri()
X=[0]*N
Y=[0]*N
H=[0]*N
for i in range(N):
X[i],Y[i],H[i]=rl()
xyh=list(zip(X,Y,H))
xyh.sort(reverse=True,key=lambda x:x[2])
X,Y,H = zip(*xyh)
ans=[-1]*3
for x in range(101):
if ans[0] != -1:
break
for y in range(101):
if ans[0] != -1:
break
rst = H[0]+abs(x-X[0])+abs(y-Y[0])
for i in range(1,N):
if H[i] != 0 and rst != H[i]+abs(x-X[i])+abs(y-Y[i]):
break
elif H[i] == 0 and rst > H[i]+abs(x-X[i])+abs(y-Y[i]):
break
if i == N-1:
ans = [x,y,rst]
print("{} {} {}".format(ans[0],ans[1],ans[2]))
| 42
| 33
| 1,306
| 849
|
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print("YES") if b else print("NO")
INF = 10**18
N = ri()
xyh = []
for i in range(N):
xyh += [rl()]
xyh.sort(reverse=True, key=lambda x: x[2])
ans = [-1] * 3
for x in range(101):
if ans[0] != -1:
break
for y in range(101):
if ans[0] != -1:
break
if xyh[0][2] == 0:
h_m = xyh[0][2] + abs(x - xyh[0][0]) + abs(y - xyh[0][1])
for i in range(1, N):
rst = xyh[i][2] + abs(x - xyh[i][0]) + abs(y - xyh[i][1])
if h_m > rst:
h_m = rst
if h_m == 0:
break
elif i == N - 1:
ans = [x, y, h_m]
else:
h = xyh[0][2] + abs(x - xyh[0][0]) + abs(y - xyh[0][1])
for i in range(1, N):
if xyh[i][2] != 0:
if h != xyh[i][2] + abs(x - xyh[i][0]) + abs(y - xyh[i][1]):
break
elif xyh[i][2] == 0:
if h > xyh[i][2] + abs(x - xyh[i][0]) + abs(y - xyh[i][1]):
break
if i == N - 1:
ans = [x, y, h]
print("{} {} {}".format(ans[0], ans[1], ans[2]))
|
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print("YES") if b else print("NO")
INF = 10**18
N = ri()
X = [0] * N
Y = [0] * N
H = [0] * N
for i in range(N):
X[i], Y[i], H[i] = rl()
xyh = list(zip(X, Y, H))
xyh.sort(reverse=True, key=lambda x: x[2])
X, Y, H = zip(*xyh)
ans = [-1] * 3
for x in range(101):
if ans[0] != -1:
break
for y in range(101):
if ans[0] != -1:
break
rst = H[0] + abs(x - X[0]) + abs(y - Y[0])
for i in range(1, N):
if H[i] != 0 and rst != H[i] + abs(x - X[i]) + abs(y - Y[i]):
break
elif H[i] == 0 and rst > H[i] + abs(x - X[i]) + abs(y - Y[i]):
break
if i == N - 1:
ans = [x, y, rst]
print("{} {} {}".format(ans[0], ans[1], ans[2]))
| false
| 21.428571
|
[
"-xyh = []",
"+X = [0] * N",
"+Y = [0] * N",
"+H = [0] * N",
"- xyh += [rl()]",
"+ X[i], Y[i], H[i] = rl()",
"+xyh = list(zip(X, Y, H))",
"+X, Y, H = zip(*xyh)",
"- if xyh[0][2] == 0:",
"- h_m = xyh[0][2] + abs(x - xyh[0][0]) + abs(y - xyh[0][1])",
"- for i in range(1, N):",
"- rst = xyh[i][2] + abs(x - xyh[i][0]) + abs(y - xyh[i][1])",
"- if h_m > rst:",
"- h_m = rst",
"- if h_m == 0:",
"- break",
"- elif i == N - 1:",
"- ans = [x, y, h_m]",
"- else:",
"- h = xyh[0][2] + abs(x - xyh[0][0]) + abs(y - xyh[0][1])",
"- for i in range(1, N):",
"- if xyh[i][2] != 0:",
"- if h != xyh[i][2] + abs(x - xyh[i][0]) + abs(y - xyh[i][1]):",
"- break",
"- elif xyh[i][2] == 0:",
"- if h > xyh[i][2] + abs(x - xyh[i][0]) + abs(y - xyh[i][1]):",
"- break",
"- if i == N - 1:",
"- ans = [x, y, h]",
"+ rst = H[0] + abs(x - X[0]) + abs(y - Y[0])",
"+ for i in range(1, N):",
"+ if H[i] != 0 and rst != H[i] + abs(x - X[i]) + abs(y - Y[i]):",
"+ break",
"+ elif H[i] == 0 and rst > H[i] + abs(x - X[i]) + abs(y - Y[i]):",
"+ break",
"+ if i == N - 1:",
"+ ans = [x, y, rst]"
] | false
| 0.051635
| 0.050119
| 1.030244
|
[
"s072089190",
"s267553342"
] |
u773265208
|
p03436
|
python
|
s059385166
|
s191003497
| 50
| 25
| 4,080
| 3,444
|
Accepted
|
Accepted
| 50
|
import queue
H,W = list(map(int,input().split()))
s = [ list(eval(input())) for _ in range(H)]
count = 0
for i in range(H):
for j in range(W):
if s[i][j] == '.':
count += 1
ans = [[0 for _ in range(W)] for _ in range(H)]
q = queue.Queue()
def bfs(x,y):
global q
global c
q.put([x,y])
s[y][x] = '#'
while not q.empty():
x,y = q.get()
if [x,y] == [W-1,H-1]:
return ans[H-1][W-1]
if x > 0 and s[y][x-1] == '.':
q.put([x-1,y])
ans[y][x-1] = ans[y][x] + 1
s[y][x-1] = '#'
if x < W-1 and s[y][x+1] == '.':
q.put([x+1,y])
ans[y][x+1] = ans[y][x] + 1
s[y][x+1] = '#'
if y > 0 and s[y-1][x] == '.':
q.put([x,y-1])
ans[y-1][x] = ans[y][x] + 1
s[y-1][x] = '#'
if y < H-1 and s[y+1][x] == '.':
q.put([x,y+1])
ans[y+1][x] = ans[y][x] + 1
s[y+1][x] = '#'
return -1
bfs = bfs(0,0)
if bfs == -1:
print((-1))
else:
print((count-bfs-1))
|
from collections import deque
H,W = list(map(int,input().split()))
c =[]
c.append(['#' for _ in range(W+2)])
ans = [[0 for _ in range(W+2)]for _ in range(H+2)]
score = 0
for i in range(H):
tmp = list('#'+eval(input())+'#')
c.append(tmp)
for j in range(W+2):
if tmp[j] == '.':
score += 1
c.append(['#' for _ in range(W+2)])
q = deque()
def bfs(x,y):
q.append([x,y])
while q:
x,y = q.popleft()
if [x,y] == [W,H]:
return ans[H][W]
if c[y][x-1] == '.':
q.append([x-1,y])
ans[y][x-1] = ans[y][x] + 1
c[y][x-1] = '#'
if c[y][x+1] == '.':
q.append([x+1,y])
ans[y][x+1] = ans[y][x] + 1
c[y][x+1] = '#'
if c[y-1][x] == '.':
q.append([x,y-1])
ans[y-1][x] = ans[y][x] + 1
c[y-1][x] = '#'
if c[y+1][x] == '.':
q.append([x,y+1])
ans[y+1][x] = ans[y][x] + 1
c[y+1][x] = '#'
return -1
tmp = bfs(1,1)
if tmp == -1:
print((-1))
else:
print((score - tmp - 1))
| 48
| 46
| 922
| 1,131
|
import queue
H, W = list(map(int, input().split()))
s = [list(eval(input())) for _ in range(H)]
count = 0
for i in range(H):
for j in range(W):
if s[i][j] == ".":
count += 1
ans = [[0 for _ in range(W)] for _ in range(H)]
q = queue.Queue()
def bfs(x, y):
global q
global c
q.put([x, y])
s[y][x] = "#"
while not q.empty():
x, y = q.get()
if [x, y] == [W - 1, H - 1]:
return ans[H - 1][W - 1]
if x > 0 and s[y][x - 1] == ".":
q.put([x - 1, y])
ans[y][x - 1] = ans[y][x] + 1
s[y][x - 1] = "#"
if x < W - 1 and s[y][x + 1] == ".":
q.put([x + 1, y])
ans[y][x + 1] = ans[y][x] + 1
s[y][x + 1] = "#"
if y > 0 and s[y - 1][x] == ".":
q.put([x, y - 1])
ans[y - 1][x] = ans[y][x] + 1
s[y - 1][x] = "#"
if y < H - 1 and s[y + 1][x] == ".":
q.put([x, y + 1])
ans[y + 1][x] = ans[y][x] + 1
s[y + 1][x] = "#"
return -1
bfs = bfs(0, 0)
if bfs == -1:
print((-1))
else:
print((count - bfs - 1))
|
from collections import deque
H, W = list(map(int, input().split()))
c = []
c.append(["#" for _ in range(W + 2)])
ans = [[0 for _ in range(W + 2)] for _ in range(H + 2)]
score = 0
for i in range(H):
tmp = list("#" + eval(input()) + "#")
c.append(tmp)
for j in range(W + 2):
if tmp[j] == ".":
score += 1
c.append(["#" for _ in range(W + 2)])
q = deque()
def bfs(x, y):
q.append([x, y])
while q:
x, y = q.popleft()
if [x, y] == [W, H]:
return ans[H][W]
if c[y][x - 1] == ".":
q.append([x - 1, y])
ans[y][x - 1] = ans[y][x] + 1
c[y][x - 1] = "#"
if c[y][x + 1] == ".":
q.append([x + 1, y])
ans[y][x + 1] = ans[y][x] + 1
c[y][x + 1] = "#"
if c[y - 1][x] == ".":
q.append([x, y - 1])
ans[y - 1][x] = ans[y][x] + 1
c[y - 1][x] = "#"
if c[y + 1][x] == ".":
q.append([x, y + 1])
ans[y + 1][x] = ans[y][x] + 1
c[y + 1][x] = "#"
return -1
tmp = bfs(1, 1)
if tmp == -1:
print((-1))
else:
print((score - tmp - 1))
| false
| 4.166667
|
[
"-import queue",
"+from collections import deque",
"-s = [list(eval(input())) for _ in range(H)]",
"-count = 0",
"+c = []",
"+c.append([\"#\" for _ in range(W + 2)])",
"+ans = [[0 for _ in range(W + 2)] for _ in range(H + 2)]",
"+score = 0",
"- for j in range(W):",
"- if s[i][j] == \".\":",
"- count += 1",
"-ans = [[0 for _ in range(W)] for _ in range(H)]",
"-q = queue.Queue()",
"+ tmp = list(\"#\" + eval(input()) + \"#\")",
"+ c.append(tmp)",
"+ for j in range(W + 2):",
"+ if tmp[j] == \".\":",
"+ score += 1",
"+c.append([\"#\" for _ in range(W + 2)])",
"+q = deque()",
"- global q",
"- global c",
"- q.put([x, y])",
"- s[y][x] = \"#\"",
"- while not q.empty():",
"- x, y = q.get()",
"- if [x, y] == [W - 1, H - 1]:",
"- return ans[H - 1][W - 1]",
"- if x > 0 and s[y][x - 1] == \".\":",
"- q.put([x - 1, y])",
"+ q.append([x, y])",
"+ while q:",
"+ x, y = q.popleft()",
"+ if [x, y] == [W, H]:",
"+ return ans[H][W]",
"+ if c[y][x - 1] == \".\":",
"+ q.append([x - 1, y])",
"- s[y][x - 1] = \"#\"",
"- if x < W - 1 and s[y][x + 1] == \".\":",
"- q.put([x + 1, y])",
"+ c[y][x - 1] = \"#\"",
"+ if c[y][x + 1] == \".\":",
"+ q.append([x + 1, y])",
"- s[y][x + 1] = \"#\"",
"- if y > 0 and s[y - 1][x] == \".\":",
"- q.put([x, y - 1])",
"+ c[y][x + 1] = \"#\"",
"+ if c[y - 1][x] == \".\":",
"+ q.append([x, y - 1])",
"- s[y - 1][x] = \"#\"",
"- if y < H - 1 and s[y + 1][x] == \".\":",
"- q.put([x, y + 1])",
"+ c[y - 1][x] = \"#\"",
"+ if c[y + 1][x] == \".\":",
"+ q.append([x, y + 1])",
"- s[y + 1][x] = \"#\"",
"+ c[y + 1][x] = \"#\"",
"-bfs = bfs(0, 0)",
"-if bfs == -1:",
"+tmp = bfs(1, 1)",
"+if tmp == -1:",
"- print((count - bfs - 1))",
"+ print((score - tmp - 1))"
] | false
| 0.046751
| 0.097794
| 0.478061
|
[
"s059385166",
"s191003497"
] |
u727148417
|
p02702
|
python
|
s832620052
|
s346477347
| 198
| 142
| 81,464
| 88,056
|
Accepted
|
Accepted
| 28.28
|
#import sys
from collections import deque
#def input():
# return sys.stdin.readline()[:-1]
S = deque(list(map(int, list(eval(input())))))
num = 0
dict = {}
dict[0] = 1
ans = 0
for i in range(len(S)):
num += S.pop() * pow(10,i,2019)
cand = num % 2019
if cand in list(dict.keys()):
dict[cand] += 1
else:
dict[cand] = 1
for key in list(dict.keys()):
ans += dict[key] * (dict[key] - 1) // 2
print(ans)
|
import sys
def input():
return sys.stdin.readline()[:-1]
S = list(map(int, list(eval(input()))))
num = 0
dict = {}
dict[0] = 1
ans = 0
for i , n in enumerate(S[::-1]):
num += n * pow(10,i,2019)
cand = num % 2019
if cand in list(dict.keys()):
dict[cand] += 1
else:
dict[cand] = 1
for key in list(dict.keys()):
ans += dict[key] * (dict[key] - 1) // 2
print(ans)
| 22
| 21
| 437
| 405
|
# import sys
from collections import deque
# def input():
# return sys.stdin.readline()[:-1]
S = deque(list(map(int, list(eval(input())))))
num = 0
dict = {}
dict[0] = 1
ans = 0
for i in range(len(S)):
num += S.pop() * pow(10, i, 2019)
cand = num % 2019
if cand in list(dict.keys()):
dict[cand] += 1
else:
dict[cand] = 1
for key in list(dict.keys()):
ans += dict[key] * (dict[key] - 1) // 2
print(ans)
|
import sys
def input():
return sys.stdin.readline()[:-1]
S = list(map(int, list(eval(input()))))
num = 0
dict = {}
dict[0] = 1
ans = 0
for i, n in enumerate(S[::-1]):
num += n * pow(10, i, 2019)
cand = num % 2019
if cand in list(dict.keys()):
dict[cand] += 1
else:
dict[cand] = 1
for key in list(dict.keys()):
ans += dict[key] * (dict[key] - 1) // 2
print(ans)
| false
| 4.545455
|
[
"-# import sys",
"-from collections import deque",
"+import sys",
"-# def input():",
"-# return sys.stdin.readline()[:-1]",
"-S = deque(list(map(int, list(eval(input())))))",
"+",
"+def input():",
"+ return sys.stdin.readline()[:-1]",
"+",
"+",
"+S = list(map(int, list(eval(input()))))",
"-for i in range(len(S)):",
"- num += S.pop() * pow(10, i, 2019)",
"+for i, n in enumerate(S[::-1]):",
"+ num += n * pow(10, i, 2019)"
] | false
| 0.03568
| 0.036607
| 0.974664
|
[
"s832620052",
"s346477347"
] |
u569117803
|
p03610
|
python
|
s410904303
|
s730950766
| 29
| 24
| 4,268
| 4,268
|
Accepted
|
Accepted
| 17.24
|
s = list(eval(input()))
ans_list = []
for v in range(- (-len(s)//2)):
ans_list.append(s[2 * v])
ans = "".join(ans_list)
print(ans)
|
s = list(eval(input()))
ans_list = [s[2 *i] for i in range(- (-len(s)//2))]
ans = "".join(ans_list)
print(ans)
| 7
| 5
| 139
| 113
|
s = list(eval(input()))
ans_list = []
for v in range(-(-len(s) // 2)):
ans_list.append(s[2 * v])
ans = "".join(ans_list)
print(ans)
|
s = list(eval(input()))
ans_list = [s[2 * i] for i in range(-(-len(s) // 2))]
ans = "".join(ans_list)
print(ans)
| false
| 28.571429
|
[
"-ans_list = []",
"-for v in range(-(-len(s) // 2)):",
"- ans_list.append(s[2 * v])",
"+ans_list = [s[2 * i] for i in range(-(-len(s) // 2))]"
] | false
| 0.044121
| 0.046232
| 0.954355
|
[
"s410904303",
"s730950766"
] |
u721316601
|
p02948
|
python
|
s946077265
|
s235429349
| 454
| 232
| 26,020
| 17,604
|
Accepted
|
Accepted
| 48.9
|
import heapq
N, M = list(map(int, input().split()))
AB = {}
q = []
ans = 0
for i in range(N):
A, B = list(map(int, input().split()))
if A in AB:
AB[A].append(-B)
else:
AB[A] = [-B]
for i in range(1, M+1):
if i in AB:
for B in AB[i]:
heapq.heappush(q, B)
if len(q):
ans -= heapq.heappop(q)
print(ans)
|
import sys
from heapq import heappush, heappop
input = sys.stdin.readline
def main():
N, M = list(map(int, input().split()))
A, B = [[] for i in range(M)], []
for i in range(N):
a, b = list(map(int, input().split()))
if a > M: continue
A[a-1].append(-b)
ans = 0
for i in range(M):
for a in A[i]: heappush(B, a)
if not B: continue
ans += heappop(B)
print((-ans))
if __name__ == '__main__':
main()
| 24
| 28
| 400
| 539
|
import heapq
N, M = list(map(int, input().split()))
AB = {}
q = []
ans = 0
for i in range(N):
A, B = list(map(int, input().split()))
if A in AB:
AB[A].append(-B)
else:
AB[A] = [-B]
for i in range(1, M + 1):
if i in AB:
for B in AB[i]:
heapq.heappush(q, B)
if len(q):
ans -= heapq.heappop(q)
print(ans)
|
import sys
from heapq import heappush, heappop
input = sys.stdin.readline
def main():
N, M = list(map(int, input().split()))
A, B = [[] for i in range(M)], []
for i in range(N):
a, b = list(map(int, input().split()))
if a > M:
continue
A[a - 1].append(-b)
ans = 0
for i in range(M):
for a in A[i]:
heappush(B, a)
if not B:
continue
ans += heappop(B)
print((-ans))
if __name__ == "__main__":
main()
| false
| 14.285714
|
[
"-import heapq",
"+import sys",
"+from heapq import heappush, heappop",
"-N, M = list(map(int, input().split()))",
"-AB = {}",
"-q = []",
"-ans = 0",
"-for i in range(N):",
"- A, B = list(map(int, input().split()))",
"- if A in AB:",
"- AB[A].append(-B)",
"- else:",
"- AB[A] = [-B]",
"-for i in range(1, M + 1):",
"- if i in AB:",
"- for B in AB[i]:",
"- heapq.heappush(q, B)",
"- if len(q):",
"- ans -= heapq.heappop(q)",
"-print(ans)",
"+input = sys.stdin.readline",
"+",
"+",
"+def main():",
"+ N, M = list(map(int, input().split()))",
"+ A, B = [[] for i in range(M)], []",
"+ for i in range(N):",
"+ a, b = list(map(int, input().split()))",
"+ if a > M:",
"+ continue",
"+ A[a - 1].append(-b)",
"+ ans = 0",
"+ for i in range(M):",
"+ for a in A[i]:",
"+ heappush(B, a)",
"+ if not B:",
"+ continue",
"+ ans += heappop(B)",
"+ print((-ans))",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false
| 0.052968
| 0.036502
| 1.451099
|
[
"s946077265",
"s235429349"
] |
u392319141
|
p03593
|
python
|
s990854598
|
s600287043
| 26
| 24
| 3,316
| 3,316
|
Accepted
|
Accepted
| 7.69
|
from collections import Counter
H, W = list(map(int, input().split()))
cntA = Counter()
for _ in range(H):
cntA += Counter(list(eval(input())))
if H % 2 + W % 2 == 0:
if all(c % 4 == 0 for c in list(cntA.values())):
print('Yes')
else:
print('No')
exit()
if H % 2 + W % 2 == 1:
two = (H if H % 2 == 0 else W) // 2
cntTwo = 0
for c in list(cntA.values()):
if c % 4 == 0:
continue
if c % 2 == 0:
cntTwo += 1
continue
break
else:
if cntTwo <= two:
print('Yes')
exit()
print('No')
exit()
cntTwo = 0
cntOdd = 0
for c in list(cntA.values()):
if c % 4 == 0:
continue
if c % 2 == 0:
cntTwo += 1
continue
cntOdd += 1
if cntOdd == 1 and cntTwo <= (H + W - 2) // 2:
print('Yes')
exit()
print('No')
|
from collections import Counter
H, W = list(map(int, input().split()))
cntA = Counter()
for _ in range(H):
cntA += Counter(list(eval(input())))
four = (H // 2) * (W // 2)
for a, c in list(cntA.items()):
if four <= 0:
break
while c >= 4 and four > 0:
c -= 4
four -= 1
cntA[a] = c
if four > 0:
print('No')
exit()
if H % 2 == W % 2 == 1:
for a, c in list(cntA.items()):
if c % 2 == 1:
cntA[a] -= 1
break
else:
print('No')
exit()
print(('Yes' if all(c % 2 == 0 for c in list(cntA.values())) else 'No'))
| 45
| 30
| 896
| 605
|
from collections import Counter
H, W = list(map(int, input().split()))
cntA = Counter()
for _ in range(H):
cntA += Counter(list(eval(input())))
if H % 2 + W % 2 == 0:
if all(c % 4 == 0 for c in list(cntA.values())):
print("Yes")
else:
print("No")
exit()
if H % 2 + W % 2 == 1:
two = (H if H % 2 == 0 else W) // 2
cntTwo = 0
for c in list(cntA.values()):
if c % 4 == 0:
continue
if c % 2 == 0:
cntTwo += 1
continue
break
else:
if cntTwo <= two:
print("Yes")
exit()
print("No")
exit()
cntTwo = 0
cntOdd = 0
for c in list(cntA.values()):
if c % 4 == 0:
continue
if c % 2 == 0:
cntTwo += 1
continue
cntOdd += 1
if cntOdd == 1 and cntTwo <= (H + W - 2) // 2:
print("Yes")
exit()
print("No")
|
from collections import Counter
H, W = list(map(int, input().split()))
cntA = Counter()
for _ in range(H):
cntA += Counter(list(eval(input())))
four = (H // 2) * (W // 2)
for a, c in list(cntA.items()):
if four <= 0:
break
while c >= 4 and four > 0:
c -= 4
four -= 1
cntA[a] = c
if four > 0:
print("No")
exit()
if H % 2 == W % 2 == 1:
for a, c in list(cntA.items()):
if c % 2 == 1:
cntA[a] -= 1
break
else:
print("No")
exit()
print(("Yes" if all(c % 2 == 0 for c in list(cntA.values())) else "No"))
| false
| 33.333333
|
[
"-if H % 2 + W % 2 == 0:",
"- if all(c % 4 == 0 for c in list(cntA.values())):",
"- print(\"Yes\")",
"+four = (H // 2) * (W // 2)",
"+for a, c in list(cntA.items()):",
"+ if four <= 0:",
"+ break",
"+ while c >= 4 and four > 0:",
"+ c -= 4",
"+ four -= 1",
"+ cntA[a] = c",
"+if four > 0:",
"+ print(\"No\")",
"+ exit()",
"+if H % 2 == W % 2 == 1:",
"+ for a, c in list(cntA.items()):",
"+ if c % 2 == 1:",
"+ cntA[a] -= 1",
"+ break",
"- exit()",
"-if H % 2 + W % 2 == 1:",
"- two = (H if H % 2 == 0 else W) // 2",
"- cntTwo = 0",
"- for c in list(cntA.values()):",
"- if c % 4 == 0:",
"- continue",
"- if c % 2 == 0:",
"- cntTwo += 1",
"- continue",
"- break",
"- else:",
"- if cntTwo <= two:",
"- print(\"Yes\")",
"- exit()",
"- print(\"No\")",
"- exit()",
"-cntTwo = 0",
"-cntOdd = 0",
"-for c in list(cntA.values()):",
"- if c % 4 == 0:",
"- continue",
"- if c % 2 == 0:",
"- cntTwo += 1",
"- continue",
"- cntOdd += 1",
"-if cntOdd == 1 and cntTwo <= (H + W - 2) // 2:",
"- print(\"Yes\")",
"- exit()",
"-print(\"No\")",
"+ exit()",
"+print((\"Yes\" if all(c % 2 == 0 for c in list(cntA.values())) else \"No\"))"
] | false
| 0.084175
| 0.039558
| 2.127867
|
[
"s990854598",
"s600287043"
] |
u888092736
|
p03627
|
python
|
s084191105
|
s502970035
| 94
| 70
| 24,224
| 24,232
|
Accepted
|
Accepted
| 25.53
|
from collections import Counter
N = int(eval(input()))
c = Counter(list(map(int, input().split())))
usables = sorted([(k, v) for k, v in list(c.items()) if v >= 2])
if len(usables) <= 1:
print((0))
else:
if usables[-1][1] >= 4:
print((usables[-1][0] ** 2))
else:
print((usables[-1][0] * usables[-2][0]))
|
from collections import Counter
def solve():
N = int(eval(input()))
c = Counter(list(map(int, input().split())))
usables = sorted([k for k, v in list(c.items()) if v > 1])
if len(usables) == 0:
return 0
else:
ans = usables[-1]
if c[ans] > 3:
return ans ** 2
elif len(usables) > 1:
usables.pop()
return ans * usables[-1]
else:
return 0
print((solve()))
| 13
| 22
| 322
| 466
|
from collections import Counter
N = int(eval(input()))
c = Counter(list(map(int, input().split())))
usables = sorted([(k, v) for k, v in list(c.items()) if v >= 2])
if len(usables) <= 1:
print((0))
else:
if usables[-1][1] >= 4:
print((usables[-1][0] ** 2))
else:
print((usables[-1][0] * usables[-2][0]))
|
from collections import Counter
def solve():
N = int(eval(input()))
c = Counter(list(map(int, input().split())))
usables = sorted([k for k, v in list(c.items()) if v > 1])
if len(usables) == 0:
return 0
else:
ans = usables[-1]
if c[ans] > 3:
return ans**2
elif len(usables) > 1:
usables.pop()
return ans * usables[-1]
else:
return 0
print((solve()))
| false
| 40.909091
|
[
"-N = int(eval(input()))",
"-c = Counter(list(map(int, input().split())))",
"-usables = sorted([(k, v) for k, v in list(c.items()) if v >= 2])",
"-if len(usables) <= 1:",
"- print((0))",
"-else:",
"- if usables[-1][1] >= 4:",
"- print((usables[-1][0] ** 2))",
"+",
"+def solve():",
"+ N = int(eval(input()))",
"+ c = Counter(list(map(int, input().split())))",
"+ usables = sorted([k for k, v in list(c.items()) if v > 1])",
"+ if len(usables) == 0:",
"+ return 0",
"- print((usables[-1][0] * usables[-2][0]))",
"+ ans = usables[-1]",
"+ if c[ans] > 3:",
"+ return ans**2",
"+ elif len(usables) > 1:",
"+ usables.pop()",
"+ return ans * usables[-1]",
"+ else:",
"+ return 0",
"+",
"+",
"+print((solve()))"
] | false
| 0.044654
| 0.051641
| 0.864699
|
[
"s084191105",
"s502970035"
] |
u231095456
|
p03643
|
python
|
s124646864
|
s760204348
| 28
| 25
| 9,068
| 9,136
|
Accepted
|
Accepted
| 10.71
|
print(("ABC"+eval(input())))
|
print((eval(input("ABC"))))
| 1
| 1
| 20
| 19
|
print(("ABC" + eval(input())))
|
print((eval(input("ABC"))))
| false
| 0
|
[
"-print((\"ABC\" + eval(input())))",
"+print((eval(input(\"ABC\"))))"
] | false
| 0.044793
| 0.044223
| 1.012882
|
[
"s124646864",
"s760204348"
] |
u565387531
|
p03013
|
python
|
s780348186
|
s530744988
| 1,719
| 253
| 6,900
| 6,900
|
Accepted
|
Accepted
| 85.28
|
N, M = list(map(int, input().split()))
mod_num = 10 ** 9 + 7
a = [0] * N
for i in range(M):
a[i] = int(eval(input()))
val = [0,1]
for i in range(1, N + 1):
ans = (val[0] + val[1]) % mod_num
val[0] = val[1]
val[1] = ans
if len(a) > 0:
if i == a[0]:
val[1] = 0
a.pop(0)
print(ans)
|
N, M = list(map(int, input().split()))
mod_num = 10 ** 9 + 7
a = [0] * N
for i in range(M):
a[i] = int(eval(input()))
val = [0,1]
j = 0
for i in range(1, N + 1):
ans = (val[0] + val[1]) % mod_num
val[0] = val[1]
val[1] = ans
if len(a) > 0:
if i == a[j]:
val[1] = 0
if len(a) - 1 != j:
j += 1
print(ans)
| 19
| 21
| 341
| 383
|
N, M = list(map(int, input().split()))
mod_num = 10**9 + 7
a = [0] * N
for i in range(M):
a[i] = int(eval(input()))
val = [0, 1]
for i in range(1, N + 1):
ans = (val[0] + val[1]) % mod_num
val[0] = val[1]
val[1] = ans
if len(a) > 0:
if i == a[0]:
val[1] = 0
a.pop(0)
print(ans)
|
N, M = list(map(int, input().split()))
mod_num = 10**9 + 7
a = [0] * N
for i in range(M):
a[i] = int(eval(input()))
val = [0, 1]
j = 0
for i in range(1, N + 1):
ans = (val[0] + val[1]) % mod_num
val[0] = val[1]
val[1] = ans
if len(a) > 0:
if i == a[j]:
val[1] = 0
if len(a) - 1 != j:
j += 1
print(ans)
| false
| 9.52381
|
[
"+j = 0",
"- if i == a[0]:",
"+ if i == a[j]:",
"- a.pop(0)",
"+ if len(a) - 1 != j:",
"+ j += 1"
] | false
| 0.093034
| 0.038529
| 2.414662
|
[
"s780348186",
"s530744988"
] |
u633255271
|
p02585
|
python
|
s702469022
|
s658810096
| 585
| 321
| 132,104
| 69,328
|
Accepted
|
Accepted
| 45.13
|
N, K = list(map(int, input().split()))
P = list([int(x) - 1 for x in input().split()])
C = list(map(int, input().split()))
ans = -10**9-1
for i in range(N):
seen = [-1]*N
cumsum = [0]*(N+1)
now = i
j = 0
while seen[now] == -1:
seen[now] = 1
now = P[now]
cumsum[j+1] = cumsum[j] + C[now]
j += 1
loop_size = j
if K <= loop_size:
ans = max([ans] + cumsum[1:K+1])
else:
if cumsum[loop_size] > 0:
loop_n = K//loop_size - 1
cumsum2 = cumsum[0:loop_size+1] + [x + cumsum[loop_size] for x in cumsum[1:loop_size+1]]
score = cumsum[loop_size]*loop_n + max(cumsum2[0:loop_size+K%loop_size+1])
ans = max(ans, score)
else:
ans = max([ans] + cumsum[1:loop_size+1])
print(ans)
|
from itertools import accumulate
N, K = list(map(int, input().split()))
P = list([int(x) - 1 for x in input().split()])
C = list(map(int, input().split()))
ans = -10**18-1
seen = [False]*N
for i in range(N):
if seen[i]:
continue
loop = []
now = i
while seen[now] == False:
seen[now] = True
loop.append(C[now])
now = P[now]
loop_size = len(loop)
loop_score = sum(loop)
cumsum = [0]+list(accumulate(loop+loop))
for j in range(1, min(K, loop_size)+1):
for l in range(loop_size+1):
r = l+j
subseq = cumsum[r] - cumsum[l]
ans = max(ans, subseq, subseq+loop_score*((K-j)//loop_size))
print(ans)
| 27
| 26
| 841
| 729
|
N, K = list(map(int, input().split()))
P = list([int(x) - 1 for x in input().split()])
C = list(map(int, input().split()))
ans = -(10**9) - 1
for i in range(N):
seen = [-1] * N
cumsum = [0] * (N + 1)
now = i
j = 0
while seen[now] == -1:
seen[now] = 1
now = P[now]
cumsum[j + 1] = cumsum[j] + C[now]
j += 1
loop_size = j
if K <= loop_size:
ans = max([ans] + cumsum[1 : K + 1])
else:
if cumsum[loop_size] > 0:
loop_n = K // loop_size - 1
cumsum2 = cumsum[0 : loop_size + 1] + [
x + cumsum[loop_size] for x in cumsum[1 : loop_size + 1]
]
score = cumsum[loop_size] * loop_n + max(
cumsum2[0 : loop_size + K % loop_size + 1]
)
ans = max(ans, score)
else:
ans = max([ans] + cumsum[1 : loop_size + 1])
print(ans)
|
from itertools import accumulate
N, K = list(map(int, input().split()))
P = list([int(x) - 1 for x in input().split()])
C = list(map(int, input().split()))
ans = -(10**18) - 1
seen = [False] * N
for i in range(N):
if seen[i]:
continue
loop = []
now = i
while seen[now] == False:
seen[now] = True
loop.append(C[now])
now = P[now]
loop_size = len(loop)
loop_score = sum(loop)
cumsum = [0] + list(accumulate(loop + loop))
for j in range(1, min(K, loop_size) + 1):
for l in range(loop_size + 1):
r = l + j
subseq = cumsum[r] - cumsum[l]
ans = max(ans, subseq, subseq + loop_score * ((K - j) // loop_size))
print(ans)
| false
| 3.703704
|
[
"+from itertools import accumulate",
"+",
"-ans = -(10**9) - 1",
"+ans = -(10**18) - 1",
"+seen = [False] * N",
"- seen = [-1] * N",
"- cumsum = [0] * (N + 1)",
"+ if seen[i]:",
"+ continue",
"+ loop = []",
"- j = 0",
"- while seen[now] == -1:",
"- seen[now] = 1",
"+ while seen[now] == False:",
"+ seen[now] = True",
"+ loop.append(C[now])",
"- cumsum[j + 1] = cumsum[j] + C[now]",
"- j += 1",
"- loop_size = j",
"- if K <= loop_size:",
"- ans = max([ans] + cumsum[1 : K + 1])",
"- else:",
"- if cumsum[loop_size] > 0:",
"- loop_n = K // loop_size - 1",
"- cumsum2 = cumsum[0 : loop_size + 1] + [",
"- x + cumsum[loop_size] for x in cumsum[1 : loop_size + 1]",
"- ]",
"- score = cumsum[loop_size] * loop_n + max(",
"- cumsum2[0 : loop_size + K % loop_size + 1]",
"- )",
"- ans = max(ans, score)",
"- else:",
"- ans = max([ans] + cumsum[1 : loop_size + 1])",
"+ loop_size = len(loop)",
"+ loop_score = sum(loop)",
"+ cumsum = [0] + list(accumulate(loop + loop))",
"+ for j in range(1, min(K, loop_size) + 1):",
"+ for l in range(loop_size + 1):",
"+ r = l + j",
"+ subseq = cumsum[r] - cumsum[l]",
"+ ans = max(ans, subseq, subseq + loop_score * ((K - j) // loop_size))"
] | false
| 0.057593
| 0.079753
| 0.722144
|
[
"s702469022",
"s658810096"
] |
u532966492
|
p02981
|
python
|
s003718017
|
s622335207
| 21
| 18
| 3,316
| 2,940
|
Accepted
|
Accepted
| 14.29
|
N,A,B=list(map(int,input().split()))
print((min(N*A,B)))
|
n,a,b=list(map(int,input().split()))
print((min(n*a,b)))
| 2
| 2
| 49
| 49
|
N, A, B = list(map(int, input().split()))
print((min(N * A, B)))
|
n, a, b = list(map(int, input().split()))
print((min(n * a, b)))
| false
| 0
|
[
"-N, A, B = list(map(int, input().split()))",
"-print((min(N * A, B)))",
"+n, a, b = list(map(int, input().split()))",
"+print((min(n * a, b)))"
] | false
| 0.113447
| 0.069561
| 1.630908
|
[
"s003718017",
"s622335207"
] |
u893962649
|
p02707
|
python
|
s892578784
|
s729153904
| 179
| 131
| 32,372
| 32,228
|
Accepted
|
Accepted
| 26.82
|
N = int(eval(input()))
A = list(map(int, input().split()))
man=1
cnt=0
man_list=[0]*N
A.sort()
A += [0]
for a in A:
if a != man:
man_list[man-1] = cnt
man = a
cnt=0
cnt+=1
print((*man_list))
|
N = int(eval(input()))
A = list(map(int, input().split()))
man_list=[0]*N
for a in A:
man_list[a-1] += 1
print((*man_list))
| 18
| 9
| 219
| 128
|
N = int(eval(input()))
A = list(map(int, input().split()))
man = 1
cnt = 0
man_list = [0] * N
A.sort()
A += [0]
for a in A:
if a != man:
man_list[man - 1] = cnt
man = a
cnt = 0
cnt += 1
print((*man_list))
|
N = int(eval(input()))
A = list(map(int, input().split()))
man_list = [0] * N
for a in A:
man_list[a - 1] += 1
print((*man_list))
| false
| 50
|
[
"-man = 1",
"-cnt = 0",
"-A.sort()",
"-A += [0]",
"- if a != man:",
"- man_list[man - 1] = cnt",
"- man = a",
"- cnt = 0",
"- cnt += 1",
"+ man_list[a - 1] += 1"
] | false
| 0.043335
| 0.037937
| 1.142287
|
[
"s892578784",
"s729153904"
] |
u145231176
|
p03557
|
python
|
s950478424
|
s762938335
| 537
| 391
| 119,956
| 116,156
|
Accepted
|
Accepted
| 27.19
|
def getN():
return int(eval(input()))
def getNM():
return list(map(int, input().split()))
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(eval(input())) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right
import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7
from itertools import permutations
from math import factorial, hypot
#############
# Main Code #
#############
N = getN()
top = getList()
middle = getList()
bottom = getList()
top.sort()
middle.sort()
bottom.sort()
# i未満
on_mid = [0]
for i in range(N):
index_mid = bisect_left(top, middle[i])
on_mid.append(on_mid[i] + index_mid)
ans = 0
for j in range(N):
index_bot = bisect_left(middle, bottom[j])
# on_midの最初の0を取り除いてないのでインデックスが一つずれる
ans += on_mid[index_bot]
print(ans)
|
def getN():
return int(eval(input()))
def getNM():
return list(map(int, input().split()))
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(eval(input())) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
ns = []
while len(ns) < rantime:
n = random.randint(ran1, ran2)
if not n in ns:
ns.append(n)
return sorted(ns)
def rand_query(ran1, ran2, rantime):
r_query = []
while len(r_query) < rantime:
n_q = rand_ints_nodup(ran1, ran2, 2)
if not n_q in r_query:
r_query.append(n_q)
return sorted(r_query)
from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right
import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7
#############
# Main Code #
#############
def less_than(array, x):
# arrayの中のx未満のものの個数
# arrayの中のx未満のもののうちの最大値
index = bisect_left(array, x)
if index == 0:
less_than_int = -float('inf')
else:
less_than_int = array[index - 1]
return [index, less_than_int]
N = getN()
up = getList()
up.sort()
mid = getList()
mid.sort()
low = getList()
low.sort()
# 中段のパーツに載せられる上段のパーツの数
mid_imos = [0] * N
for i in range(N):
mid_imos[i] = less_than(up, mid[i])[0]
for i in range(N - 1):
mid_imos[i + 1] += mid_imos[i]
low_imos = [0] * N
for i in range(N):
ind = less_than(mid, low[i])[0]
if ind > 0:
low_imos[i] = mid_imos[ind - 1]
print((sum(low_imos)))
| 54
| 84
| 1,150
| 1,998
|
def getN():
return int(eval(input()))
def getNM():
return list(map(int, input().split()))
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(eval(input())) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right
import sys
sys.setrecursionlimit(1000000000)
mod = 10**9 + 7
from itertools import permutations
from math import factorial, hypot
#############
# Main Code #
#############
N = getN()
top = getList()
middle = getList()
bottom = getList()
top.sort()
middle.sort()
bottom.sort()
# i未満
on_mid = [0]
for i in range(N):
index_mid = bisect_left(top, middle[i])
on_mid.append(on_mid[i] + index_mid)
ans = 0
for j in range(N):
index_bot = bisect_left(middle, bottom[j])
# on_midの最初の0を取り除いてないのでインデックスが一つずれる
ans += on_mid[index_bot]
print(ans)
|
def getN():
return int(eval(input()))
def getNM():
return list(map(int, input().split()))
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(eval(input())) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
ns = []
while len(ns) < rantime:
n = random.randint(ran1, ran2)
if not n in ns:
ns.append(n)
return sorted(ns)
def rand_query(ran1, ran2, rantime):
r_query = []
while len(r_query) < rantime:
n_q = rand_ints_nodup(ran1, ran2, 2)
if not n_q in r_query:
r_query.append(n_q)
return sorted(r_query)
from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right
import sys
sys.setrecursionlimit(1000000000)
mod = 10**9 + 7
#############
# Main Code #
#############
def less_than(array, x):
# arrayの中のx未満のものの個数
# arrayの中のx未満のもののうちの最大値
index = bisect_left(array, x)
if index == 0:
less_than_int = -float("inf")
else:
less_than_int = array[index - 1]
return [index, less_than_int]
N = getN()
up = getList()
up.sort()
mid = getList()
mid.sort()
low = getList()
low.sort()
# 中段のパーツに載せられる上段のパーツの数
mid_imos = [0] * N
for i in range(N):
mid_imos[i] = less_than(up, mid[i])[0]
for i in range(N - 1):
mid_imos[i + 1] += mid_imos[i]
low_imos = [0] * N
for i in range(N):
ind = less_than(mid, low[i])[0]
if ind > 0:
low_imos[i] = mid_imos[ind - 1]
print((sum(low_imos)))
| false
| 35.714286
|
[
"+def rand_N(ran1, ran2):",
"+ return random.randint(ran1, ran2)",
"+",
"+",
"+def rand_List(ran1, ran2, rantime):",
"+ return [random.randint(ran1, ran2) for i in range(rantime)]",
"+",
"+",
"+def rand_ints_nodup(ran1, ran2, rantime):",
"+ ns = []",
"+ while len(ns) < rantime:",
"+ n = random.randint(ran1, ran2)",
"+ if not n in ns:",
"+ ns.append(n)",
"+ return sorted(ns)",
"+",
"+",
"+def rand_query(ran1, ran2, rantime):",
"+ r_query = []",
"+ while len(r_query) < rantime:",
"+ n_q = rand_ints_nodup(ran1, ran2, 2)",
"+ if not n_q in r_query:",
"+ r_query.append(n_q)",
"+ return sorted(r_query)",
"+",
"+",
"+from decimal import *",
"+import random",
"+import string",
"-from itertools import permutations",
"+from itertools import combinations, permutations, product",
"-from itertools import permutations",
"-from math import factorial, hypot",
"-",
"+def less_than(array, x):",
"+ # arrayの中のx未満のものの個数",
"+ # arrayの中のx未満のもののうちの最大値",
"+ index = bisect_left(array, x)",
"+ if index == 0:",
"+ less_than_int = -float(\"inf\")",
"+ else:",
"+ less_than_int = array[index - 1]",
"+ return [index, less_than_int]",
"+",
"+",
"-top = getList()",
"-middle = getList()",
"-bottom = getList()",
"-top.sort()",
"-middle.sort()",
"-bottom.sort()",
"-# i未満",
"-on_mid = [0]",
"+up = getList()",
"+up.sort()",
"+mid = getList()",
"+mid.sort()",
"+low = getList()",
"+low.sort()",
"+# 中段のパーツに載せられる上段のパーツの数",
"+mid_imos = [0] * N",
"- index_mid = bisect_left(top, middle[i])",
"- on_mid.append(on_mid[i] + index_mid)",
"-ans = 0",
"-for j in range(N):",
"- index_bot = bisect_left(middle, bottom[j])",
"- # on_midの最初の0を取り除いてないのでインデックスが一つずれる",
"- ans += on_mid[index_bot]",
"-print(ans)",
"+ mid_imos[i] = less_than(up, mid[i])[0]",
"+for i in range(N - 1):",
"+ mid_imos[i + 1] += mid_imos[i]",
"+low_imos = [0] * N",
"+for i in range(N):",
"+ ind = less_than(mid, low[i])[0]",
"+ if ind > 0:",
"+ low_imos[i] = mid_imos[ind - 1]",
"+print((sum(low_imos)))"
] | false
| 0.072358
| 0.166771
| 0.433873
|
[
"s950478424",
"s762938335"
] |
u809819902
|
p02641
|
python
|
s837974082
|
s142679810
| 32
| 29
| 9,200
| 9,180
|
Accepted
|
Accepted
| 9.38
|
x,n=list(map(int,input().split()))
p=list(map(int, input().split()))
youso=[]
for i in range(-300,1000):
if not i in p:
youso+=[i]
hikaku=[]
for i in youso:
hikaku+=[(i,abs(x-i))]
hikaku1=sorted(hikaku,key=lambda x:x[1])
res=hikaku1[0][0]
print(res)
|
x,n=list(map(int,input().split()))
p=list(map(int, input().split()))
if not x in p:print(x)
else:
for i in range(500):
if not x-i in p:
print((x-i))
break
elif not x+i in p:
print((x+i))
break
| 12
| 11
| 270
| 260
|
x, n = list(map(int, input().split()))
p = list(map(int, input().split()))
youso = []
for i in range(-300, 1000):
if not i in p:
youso += [i]
hikaku = []
for i in youso:
hikaku += [(i, abs(x - i))]
hikaku1 = sorted(hikaku, key=lambda x: x[1])
res = hikaku1[0][0]
print(res)
|
x, n = list(map(int, input().split()))
p = list(map(int, input().split()))
if not x in p:
print(x)
else:
for i in range(500):
if not x - i in p:
print((x - i))
break
elif not x + i in p:
print((x + i))
break
| false
| 8.333333
|
[
"-youso = []",
"-for i in range(-300, 1000):",
"- if not i in p:",
"- youso += [i]",
"-hikaku = []",
"-for i in youso:",
"- hikaku += [(i, abs(x - i))]",
"-hikaku1 = sorted(hikaku, key=lambda x: x[1])",
"-res = hikaku1[0][0]",
"-print(res)",
"+if not x in p:",
"+ print(x)",
"+else:",
"+ for i in range(500):",
"+ if not x - i in p:",
"+ print((x - i))",
"+ break",
"+ elif not x + i in p:",
"+ print((x + i))",
"+ break"
] | false
| 0.044036
| 0.042633
| 1.032902
|
[
"s837974082",
"s142679810"
] |
u329143273
|
p03284
|
python
|
s678594042
|
s441950091
| 20
| 18
| 3,060
| 2,940
|
Accepted
|
Accepted
| 10
|
n,k=list(map(int,input().split()))
if n%k>=1:
print((1))
else:
print((0))
|
a,b=list(map(int,input().split()))
print((1 if a%b else 0))
| 5
| 2
| 71
| 52
|
n, k = list(map(int, input().split()))
if n % k >= 1:
print((1))
else:
print((0))
|
a, b = list(map(int, input().split()))
print((1 if a % b else 0))
| false
| 60
|
[
"-n, k = list(map(int, input().split()))",
"-if n % k >= 1:",
"- print((1))",
"-else:",
"- print((0))",
"+a, b = list(map(int, input().split()))",
"+print((1 if a % b else 0))"
] | false
| 0.036272
| 0.035859
| 1.011504
|
[
"s678594042",
"s441950091"
] |
u367130284
|
p03682
|
python
|
s628965863
|
s665774010
| 1,616
| 1,246
| 89,408
| 53,020
|
Accepted
|
Accepted
| 22.9
|
import sys
from heapq import*
from collections import*
input=sys.stdin.readline
p=defaultdict(lambda: -1)
class UNION_FIND(object):
def __init__(self,n):
self.parent=defaultdict(lambda: -1)
def root(self,x):
if type(self.parent[x])!=tuple:
return x
else:
self.parent[x]=self.root(self.parent[x])
return self.parent[x]
def size(self,x):
return -self.parent[self.root(x)]
def union(self,x,y):
x=self.root(x)
y=self.root(y)
if x==y:
return False
if self.size(x)<self.size(y):
x,y=y,x
self.parent[x]+=self.parent[y]
self.parent[y]=x
return True
def compute_mst_kruskal(max_v, edges, flip):
edges.sort(key=lambda x: x[2],reverse=flip)
#print(edges)
uf = UNION_FIND(max_v)
mst = []
for (a,b,c) in edges:
if uf.root(a)!= uf.root(b):
uf.union(a,b)
mst.append(c)
return mst
n = int(eval(input()))
points=[list(map(int,input().split()))for i in range(n)]
x=sorted(points,key=lambda x:x[0])
y=sorted(points,key=lambda x:x[1])
#print(x,y)
edges = []
for i in range(1,n):
(a,b),(c,d)=x[i-1],x[i]
(e,f),(g,h)=y[i-1],y[i]
heappush(edges,((a,b),(c,d),abs(a-c)))
heappush(edges,((e,f),(g,h),abs(f-h)))
#print(edges)
mst = compute_mst_kruskal(n, edges , 0) #0が最小化
print((sum(mst)))
|
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph)
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse import csr_matrix
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline #危険!基本オフにしろ!
class UNION_FIND(object):
def __init__(self,n):
self.parent=[-1 for i in range(n)]
def root(self,x):
if self.parent[x]<0:
return x
else:
self.parent[x]=self.root(self.parent[x])
return self.parent[x]
def size(self,x):
return -self.parent[self.root(x)]
def union(self,x,y):
x=self.root(x)
y=self.root(y)
if x==y:
return False
if self.size(x)<self.size(y):
x,y=y,x
self.parent[x]+=self.parent[y]
self.parent[y]=x
return True
def compute_mst_kruskal(max_v, edges, flip):
edges.sort(key=lambda x: x[2],reverse=flip)
uf = UNION_FIND(max_v)
mst = []
for (a,b,c) in edges:
if uf.root(a)!= uf.root(b):
uf.union(a,b)
mst.append(c)
return mst
def main():
n=int(eval(input()))
inp=[[i]+list(map(int,input().split()))for i in range(n)]
inpX=sorted(inp,key=lambda x:x[1])
inpY=sorted(inp,key=lambda x:x[2])
edges=[]
for i in range(1,n):
a,b,c=inpX[i]
d,e,f=inpX[i-1]
edges.append((a,d,min(abs(b-e),abs(c-f))))
a,b,c=inpY[i]
d,e,f=inpY[i-1]
edges.append((a,d,min(abs(b-e),abs(c-f))))
print((sum(compute_mst_kruskal(n, edges, 0))))
if __name__ == '__main__':
main()
| 61
| 76
| 1,472
| 2,199
|
import sys
from heapq import *
from collections import *
input = sys.stdin.readline
p = defaultdict(lambda: -1)
class UNION_FIND(object):
def __init__(self, n):
self.parent = defaultdict(lambda: -1)
def root(self, x):
if type(self.parent[x]) != tuple:
return x
else:
self.parent[x] = self.root(self.parent[x])
return self.parent[x]
def size(self, x):
return -self.parent[self.root(x)]
def union(self, x, y):
x = self.root(x)
y = self.root(y)
if x == y:
return False
if self.size(x) < self.size(y):
x, y = y, x
self.parent[x] += self.parent[y]
self.parent[y] = x
return True
def compute_mst_kruskal(max_v, edges, flip):
edges.sort(key=lambda x: x[2], reverse=flip)
# print(edges)
uf = UNION_FIND(max_v)
mst = []
for (a, b, c) in edges:
if uf.root(a) != uf.root(b):
uf.union(a, b)
mst.append(c)
return mst
n = int(eval(input()))
points = [list(map(int, input().split())) for i in range(n)]
x = sorted(points, key=lambda x: x[0])
y = sorted(points, key=lambda x: x[1])
# print(x,y)
edges = []
for i in range(1, n):
(a, b), (c, d) = x[i - 1], x[i]
(e, f), (g, h) = y[i - 1], y[i]
heappush(edges, ((a, b), (c, d), abs(a - c)))
heappush(edges, ((e, f), (g, h), abs(f - h)))
# print(edges)
mst = compute_mst_kruskal(n, edges, 0) # 0が最小化
print((sum(mst)))
|
# import numpy as np
# from numpy import*
# from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph)
# from scipy.sparse.csgraph import dijkstra
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse import csr_matrix
from collections import * # defaultdict Counter deque appendleft
from fractions import gcd
from functools import * # reduce
from itertools import * # permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul, itemgetter
from bisect import * # bisect_left bisect_right
from heapq import * # heapify heappop heappushpop
from math import factorial, pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
# input=sys.stdin.readline #危険!基本オフにしろ!
class UNION_FIND(object):
def __init__(self, n):
self.parent = [-1 for i in range(n)]
def root(self, x):
if self.parent[x] < 0:
return x
else:
self.parent[x] = self.root(self.parent[x])
return self.parent[x]
def size(self, x):
return -self.parent[self.root(x)]
def union(self, x, y):
x = self.root(x)
y = self.root(y)
if x == y:
return False
if self.size(x) < self.size(y):
x, y = y, x
self.parent[x] += self.parent[y]
self.parent[y] = x
return True
def compute_mst_kruskal(max_v, edges, flip):
edges.sort(key=lambda x: x[2], reverse=flip)
uf = UNION_FIND(max_v)
mst = []
for (a, b, c) in edges:
if uf.root(a) != uf.root(b):
uf.union(a, b)
mst.append(c)
return mst
def main():
n = int(eval(input()))
inp = [[i] + list(map(int, input().split())) for i in range(n)]
inpX = sorted(inp, key=lambda x: x[1])
inpY = sorted(inp, key=lambda x: x[2])
edges = []
for i in range(1, n):
a, b, c = inpX[i]
d, e, f = inpX[i - 1]
edges.append((a, d, min(abs(b - e), abs(c - f))))
a, b, c = inpY[i]
d, e, f = inpY[i - 1]
edges.append((a, d, min(abs(b - e), abs(c - f))))
print((sum(compute_mst_kruskal(n, edges, 0))))
if __name__ == "__main__":
main()
| false
| 19.736842
|
[
"+# import numpy as np",
"+# from numpy import*",
"+# from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph)",
"+# from scipy.sparse.csgraph import dijkstra",
"+# from scipy.sparse.csgraph import floyd_warshall",
"+# from scipy.sparse import csr_matrix",
"+from collections import * # defaultdict Counter deque appendleft",
"+from fractions import gcd",
"+from functools import * # reduce",
"+from itertools import * # permutations(\"AB\",repeat=2) combinations(\"AB\",2) product(\"AB\",2) groupby accumulate",
"+from operator import mul, itemgetter",
"+from bisect import * # bisect_left bisect_right",
"+from heapq import * # heapify heappop heappushpop",
"+from math import factorial, pi",
"+from copy import deepcopy",
"-from heapq import *",
"-from collections import *",
"-input = sys.stdin.readline",
"-p = defaultdict(lambda: -1)",
"-",
"-",
"+sys.setrecursionlimit(10**8)",
"+# input=sys.stdin.readline #危険!基本オフにしろ!",
"- self.parent = defaultdict(lambda: -1)",
"+ self.parent = [-1 for i in range(n)]",
"- if type(self.parent[x]) != tuple:",
"+ if self.parent[x] < 0:",
"- # print(edges)",
"-n = int(eval(input()))",
"-points = [list(map(int, input().split())) for i in range(n)]",
"-x = sorted(points, key=lambda x: x[0])",
"-y = sorted(points, key=lambda x: x[1])",
"-# print(x,y)",
"-edges = []",
"-for i in range(1, n):",
"- (a, b), (c, d) = x[i - 1], x[i]",
"- (e, f), (g, h) = y[i - 1], y[i]",
"- heappush(edges, ((a, b), (c, d), abs(a - c)))",
"- heappush(edges, ((e, f), (g, h), abs(f - h)))",
"-# print(edges)",
"-mst = compute_mst_kruskal(n, edges, 0) # 0が最小化",
"-print((sum(mst)))",
"+def main():",
"+ n = int(eval(input()))",
"+ inp = [[i] + list(map(int, input().split())) for i in range(n)]",
"+ inpX = sorted(inp, key=lambda x: x[1])",
"+ inpY = sorted(inp, key=lambda x: x[2])",
"+ edges = []",
"+ for i in range(1, n):",
"+ a, b, c = inpX[i]",
"+ d, e, f = inpX[i - 1]",
"+ edges.append((a, d, min(abs(b - e), abs(c - f))))",
"+ a, b, c = inpY[i]",
"+ d, e, f = inpY[i - 1]",
"+ edges.append((a, d, min(abs(b - e), abs(c - f))))",
"+ print((sum(compute_mst_kruskal(n, edges, 0))))",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false
| 0.160937
| 0.048807
| 3.297427
|
[
"s628965863",
"s665774010"
] |
u075012704
|
p03151
|
python
|
s670302349
|
s750159225
| 253
| 111
| 21,552
| 19,068
|
Accepted
|
Accepted
| 56.13
|
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# 各テストの余裕を小さい順に
margins = [[i, a - b] for i, (a, b) in enumerate(zip(A, B)) if (a - b) > 0]
margins.sort(key=lambda m: m[1])
# 調整済みA
X = A[:]
# 余裕が大きい方から使っていく
for i in range(N):
while (A[i] < B[i]) and margins:
cost = B[i] - A[i]
mi, margin = margins[-1]
if margin > cost:
margins[-1][1] -= cost
A[mi] -= cost
A[i] += cost
else:
margins.pop()
A[mi] -= margin
A[i] += margin
ans = 0
for a, b, x in zip(A, B, X):
if b - a > 0:
print((-1))
break
if a != x:
ans += 1
else:
print(ans)
|
from itertools import accumulate
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
surplus = [(a - b) for a, b in zip(A, B) if (a - b) > 0]
surplus.sort(reverse=True)
surplus_acc = [0] + list(accumulate(surplus))
short = [(b - a) for a, b in zip(A, B) if (b - a) > 0]
need = sum(short)
short_num = len(short)
if need > sum(surplus):
print((-1))
exit()
else:
for i in range(len(surplus_acc)):
if surplus_acc[i] >= need:
print((i + short_num))
exit()
| 39
| 23
| 758
| 555
|
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# 各テストの余裕を小さい順に
margins = [[i, a - b] for i, (a, b) in enumerate(zip(A, B)) if (a - b) > 0]
margins.sort(key=lambda m: m[1])
# 調整済みA
X = A[:]
# 余裕が大きい方から使っていく
for i in range(N):
while (A[i] < B[i]) and margins:
cost = B[i] - A[i]
mi, margin = margins[-1]
if margin > cost:
margins[-1][1] -= cost
A[mi] -= cost
A[i] += cost
else:
margins.pop()
A[mi] -= margin
A[i] += margin
ans = 0
for a, b, x in zip(A, B, X):
if b - a > 0:
print((-1))
break
if a != x:
ans += 1
else:
print(ans)
|
from itertools import accumulate
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
surplus = [(a - b) for a, b in zip(A, B) if (a - b) > 0]
surplus.sort(reverse=True)
surplus_acc = [0] + list(accumulate(surplus))
short = [(b - a) for a, b in zip(A, B) if (b - a) > 0]
need = sum(short)
short_num = len(short)
if need > sum(surplus):
print((-1))
exit()
else:
for i in range(len(surplus_acc)):
if surplus_acc[i] >= need:
print((i + short_num))
exit()
| false
| 41.025641
|
[
"+from itertools import accumulate",
"+",
"-# 各テストの余裕を小さい順に",
"-margins = [[i, a - b] for i, (a, b) in enumerate(zip(A, B)) if (a - b) > 0]",
"-margins.sort(key=lambda m: m[1])",
"-# 調整済みA",
"-X = A[:]",
"-# 余裕が大きい方から使っていく",
"-for i in range(N):",
"- while (A[i] < B[i]) and margins:",
"- cost = B[i] - A[i]",
"- mi, margin = margins[-1]",
"- if margin > cost:",
"- margins[-1][1] -= cost",
"- A[mi] -= cost",
"- A[i] += cost",
"- else:",
"- margins.pop()",
"- A[mi] -= margin",
"- A[i] += margin",
"-ans = 0",
"-for a, b, x in zip(A, B, X):",
"- if b - a > 0:",
"- print((-1))",
"- break",
"- if a != x:",
"- ans += 1",
"+surplus = [(a - b) for a, b in zip(A, B) if (a - b) > 0]",
"+surplus.sort(reverse=True)",
"+surplus_acc = [0] + list(accumulate(surplus))",
"+short = [(b - a) for a, b in zip(A, B) if (b - a) > 0]",
"+need = sum(short)",
"+short_num = len(short)",
"+if need > sum(surplus):",
"+ print((-1))",
"+ exit()",
"- print(ans)",
"+ for i in range(len(surplus_acc)):",
"+ if surplus_acc[i] >= need:",
"+ print((i + short_num))",
"+ exit()"
] | false
| 0.037286
| 0.036334
| 1.02621
|
[
"s670302349",
"s750159225"
] |
u724687935
|
p02787
|
python
|
s288003928
|
s286951517
| 374
| 298
| 46,172
| 40,560
|
Accepted
|
Accepted
| 20.32
|
def main():
import sys
readline = sys.stdin.readline
# readlines = sys.stdin.readlines
H, N = list(map(int, input().split()))
M = [tuple(map(int, readline().split())) for _ in range(N)]
INF = float('inf')
dp = [INF] * (H + 1)
dp[0] = 0
for i in range(N):
a, b = M[i]
for j in range(H):
nj = min(H, j + a)
dp[nj] = min(dp[nj], dp[j] + b)
print((dp[H]))
if __name__ == "__main__":
main()
|
def main():
import sys
readline = sys.stdin.readline
# readlines = sys.stdin.readlines
H, N = list(map(int, input().split()))
M = [tuple(map(int, readline().split())) for _ in range(N)]
INF = 10 ** 9
dp = [INF] * (H + 1)
dp[0] = 0
for i in range(N):
a, b = M[i]
for j in range(H):
nj = min(H, j + a)
dp[nj] = min(dp[nj], dp[j] + b)
print((dp[H]))
if __name__ == "__main__":
main()
| 21
| 21
| 490
| 485
|
def main():
import sys
readline = sys.stdin.readline
# readlines = sys.stdin.readlines
H, N = list(map(int, input().split()))
M = [tuple(map(int, readline().split())) for _ in range(N)]
INF = float("inf")
dp = [INF] * (H + 1)
dp[0] = 0
for i in range(N):
a, b = M[i]
for j in range(H):
nj = min(H, j + a)
dp[nj] = min(dp[nj], dp[j] + b)
print((dp[H]))
if __name__ == "__main__":
main()
|
def main():
import sys
readline = sys.stdin.readline
# readlines = sys.stdin.readlines
H, N = list(map(int, input().split()))
M = [tuple(map(int, readline().split())) for _ in range(N)]
INF = 10**9
dp = [INF] * (H + 1)
dp[0] = 0
for i in range(N):
a, b = M[i]
for j in range(H):
nj = min(H, j + a)
dp[nj] = min(dp[nj], dp[j] + b)
print((dp[H]))
if __name__ == "__main__":
main()
| false
| 0
|
[
"- INF = float(\"inf\")",
"+ INF = 10**9"
] | false
| 0.11891
| 0.113295
| 1.049558
|
[
"s288003928",
"s286951517"
] |
u879309973
|
p03378
|
python
|
s888289144
|
s977168181
| 11
| 10
| 2,572
| 2,568
|
Accepted
|
Accepted
| 9.09
|
n, m, x = list(map(int, input().split()))
a = [0] * (n + 1)
for _ in map(int, input().split()):
a[_ - 1] = 1
print(min(sum(a[:x - 1]), sum(a[x:])))
|
N, M, X = list(map(int, input().split()))
A = list(map(int, input().split()))
p = len([a for a in A if a < X])
q = len([a for a in A if a > X])
print(min(p, q))
| 7
| 5
| 161
| 165
|
n, m, x = list(map(int, input().split()))
a = [0] * (n + 1)
for _ in map(int, input().split()):
a[_ - 1] = 1
print(min(sum(a[: x - 1]), sum(a[x:])))
|
N, M, X = list(map(int, input().split()))
A = list(map(int, input().split()))
p = len([a for a in A if a < X])
q = len([a for a in A if a > X])
print(min(p, q))
| false
| 28.571429
|
[
"-n, m, x = list(map(int, input().split()))",
"-a = [0] * (n + 1)",
"-for _ in map(int, input().split()):",
"- a[_ - 1] = 1",
"-print(min(sum(a[: x - 1]), sum(a[x:])))",
"+N, M, X = list(map(int, input().split()))",
"+A = list(map(int, input().split()))",
"+p = len([a for a in A if a < X])",
"+q = len([a for a in A if a > X])",
"+print(min(p, q))"
] | false
| 0.04314
| 0.043607
| 0.9893
|
[
"s888289144",
"s977168181"
] |
u380524497
|
p03660
|
python
|
s491263830
|
s881212599
| 589
| 459
| 110,276
| 27,704
|
Accepted
|
Accepted
| 22.07
|
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
n = int(eval(input()))
edges = [[] for _ in range(n)]
for _ in range(n-1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
edges[a].append(b)
edges[b].append(a)
seen = [-1] * n
def dfs(node, prev):
if seen[node] != -1:
return
seen[node] = prev
for to in edges[node]:
dfs(to, node)
dfs(0, 0)
colors = [0] * n
node = n-1
goal_to_start = [n-1]
while node:
node = seen[node]
goal_to_start.append(node)
length = len(goal_to_start)
limit = (length) // 2
colors = [0] * n
for node in goal_to_start[:limit]:
colors[node] = 2
for node in goal_to_start[limit:]:
colors[node] = 1
fennec_todo = [node for node in range(n) if colors[node] == 1]
snuke_todo = [node for node in range(n) if colors[node] == 2]
def paint(todo, my_color):
while todo:
node = todo.pop()
for to in edges[node]:
if colors[to]:
continue
colors[to] = my_color
todo.append(to)
paint(fennec_todo, 1)
paint(snuke_todo, 2)
feccec_count = len([color for color in colors if color == 1])
snuke_count = len([color for color in colors if color == 2])
if feccec_count > snuke_count:
print('Fennec ')
else:
print('Snuke ')
|
import sys
input = sys.stdin.readline
n = int(eval(input()))
edges = [[] for _ in range(n)]
for _ in range(n-1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
edges[a].append(b)
edges[b].append(a)
seen = [-1] * n
todo = [(0, 0)]
while todo:
node, prev = todo.pop()
if seen[node] != -1:
continue
seen[node] = prev
for to in edges[node]:
if seen[to] != -1:
continue
todo.append((to, node))
colors = [0] * n
node = n-1
goal_to_start = [n-1]
while node:
node = seen[node]
goal_to_start.append(node)
length = len(goal_to_start)
limit = (length) // 2
colors = [0] * n
for node in goal_to_start[:limit]:
colors[node] = 2
for node in goal_to_start[limit:]:
colors[node] = 1
fennec_todo = [node for node in range(n) if colors[node] == 1]
snuke_todo = [node for node in range(n) if colors[node] == 2]
def paint(todo, my_color):
while todo:
node = todo.pop()
for to in edges[node]:
if colors[to]:
continue
colors[to] = my_color
todo.append(to)
paint(fennec_todo, 1)
paint(snuke_todo, 2)
feccec_count = len([color for color in colors if color == 1])
snuke_count = len([color for color in colors if color == 2])
if feccec_count > snuke_count:
print('Fennec ')
else:
print('Snuke ')
| 73
| 73
| 1,371
| 1,425
|
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
n = int(eval(input()))
edges = [[] for _ in range(n)]
for _ in range(n - 1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
edges[a].append(b)
edges[b].append(a)
seen = [-1] * n
def dfs(node, prev):
if seen[node] != -1:
return
seen[node] = prev
for to in edges[node]:
dfs(to, node)
dfs(0, 0)
colors = [0] * n
node = n - 1
goal_to_start = [n - 1]
while node:
node = seen[node]
goal_to_start.append(node)
length = len(goal_to_start)
limit = (length) // 2
colors = [0] * n
for node in goal_to_start[:limit]:
colors[node] = 2
for node in goal_to_start[limit:]:
colors[node] = 1
fennec_todo = [node for node in range(n) if colors[node] == 1]
snuke_todo = [node for node in range(n) if colors[node] == 2]
def paint(todo, my_color):
while todo:
node = todo.pop()
for to in edges[node]:
if colors[to]:
continue
colors[to] = my_color
todo.append(to)
paint(fennec_todo, 1)
paint(snuke_todo, 2)
feccec_count = len([color for color in colors if color == 1])
snuke_count = len([color for color in colors if color == 2])
if feccec_count > snuke_count:
print("Fennec ")
else:
print("Snuke ")
|
import sys
input = sys.stdin.readline
n = int(eval(input()))
edges = [[] for _ in range(n)]
for _ in range(n - 1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
edges[a].append(b)
edges[b].append(a)
seen = [-1] * n
todo = [(0, 0)]
while todo:
node, prev = todo.pop()
if seen[node] != -1:
continue
seen[node] = prev
for to in edges[node]:
if seen[to] != -1:
continue
todo.append((to, node))
colors = [0] * n
node = n - 1
goal_to_start = [n - 1]
while node:
node = seen[node]
goal_to_start.append(node)
length = len(goal_to_start)
limit = (length) // 2
colors = [0] * n
for node in goal_to_start[:limit]:
colors[node] = 2
for node in goal_to_start[limit:]:
colors[node] = 1
fennec_todo = [node for node in range(n) if colors[node] == 1]
snuke_todo = [node for node in range(n) if colors[node] == 2]
def paint(todo, my_color):
while todo:
node = todo.pop()
for to in edges[node]:
if colors[to]:
continue
colors[to] = my_color
todo.append(to)
paint(fennec_todo, 1)
paint(snuke_todo, 2)
feccec_count = len([color for color in colors if color == 1])
snuke_count = len([color for color in colors if color == 2])
if feccec_count > snuke_count:
print("Fennec ")
else:
print("Snuke ")
| false
| 0
|
[
"-sys.setrecursionlimit(10**6)",
"-",
"-",
"-def dfs(node, prev):",
"+todo = [(0, 0)]",
"+while todo:",
"+ node, prev = todo.pop()",
"- return",
"+ continue",
"- dfs(to, node)",
"-",
"-",
"-dfs(0, 0)",
"+ if seen[to] != -1:",
"+ continue",
"+ todo.append((to, node))"
] | false
| 0.073284
| 0.041857
| 1.750817
|
[
"s491263830",
"s881212599"
] |
u362291462
|
p03163
|
python
|
s012333372
|
s765758901
| 617
| 283
| 119,740
| 45,680
|
Accepted
|
Accepted
| 54.13
|
from sys import stdin
n,W=list(map(int,input().split()))
k=[[0 for i in range(W+1)] for i in range(2)]
for i in range(1,n+1):
w,v=list(map(int,stdin.readline().split()))
for j in range(1,W+1):
if w<=j:
k[1][j]=max(v+k[0][j-w],k[0][j])
else:
k[1][j]=k[0][j]
k[0]=[i for i in k[1]]
k[1]=[0]*(W+1)
print((k[0][-1]))
|
from sys import stdin
n,W=list(map(int,input().split()))
dp=[0 for i in range(W+1)]
for i in range(n):
w,v=list(map(int,stdin.readline().split()))
for j in range(W-w,-1,-1):
dp[j+w]=max(dp[j]+v,dp[j+w])
print((dp[-1]))
| 13
| 8
| 366
| 227
|
from sys import stdin
n, W = list(map(int, input().split()))
k = [[0 for i in range(W + 1)] for i in range(2)]
for i in range(1, n + 1):
w, v = list(map(int, stdin.readline().split()))
for j in range(1, W + 1):
if w <= j:
k[1][j] = max(v + k[0][j - w], k[0][j])
else:
k[1][j] = k[0][j]
k[0] = [i for i in k[1]]
k[1] = [0] * (W + 1)
print((k[0][-1]))
|
from sys import stdin
n, W = list(map(int, input().split()))
dp = [0 for i in range(W + 1)]
for i in range(n):
w, v = list(map(int, stdin.readline().split()))
for j in range(W - w, -1, -1):
dp[j + w] = max(dp[j] + v, dp[j + w])
print((dp[-1]))
| false
| 38.461538
|
[
"-k = [[0 for i in range(W + 1)] for i in range(2)]",
"-for i in range(1, n + 1):",
"+dp = [0 for i in range(W + 1)]",
"+for i in range(n):",
"- for j in range(1, W + 1):",
"- if w <= j:",
"- k[1][j] = max(v + k[0][j - w], k[0][j])",
"- else:",
"- k[1][j] = k[0][j]",
"- k[0] = [i for i in k[1]]",
"- k[1] = [0] * (W + 1)",
"-print((k[0][-1]))",
"+ for j in range(W - w, -1, -1):",
"+ dp[j + w] = max(dp[j] + v, dp[j + w])",
"+print((dp[-1]))"
] | false
| 0.039795
| 0.070685
| 0.562993
|
[
"s012333372",
"s765758901"
] |
u631755487
|
p02995
|
python
|
s673211975
|
s019764794
| 38
| 35
| 5,048
| 5,048
|
Accepted
|
Accepted
| 7.89
|
from fractions import gcd
a, b, c, d = list(map(int, input().split(' ')))
# cye bolunenler
c_numbers = b//c - (a-1)//c
# dye bolunenler
d_numbers = b//d - (a-1)//d
# ortak bolunenler
gcd_number = c*d // gcd(c, d)
ortak = b//(gcd_number) - (a-1)//(gcd_number)
# result
print((b-a+1-(c_numbers+d_numbers-ortak)))
|
from fractions import gcd
a, b, c, d = list(map(int, input().split(' ')))
# cye bolunenler
c_numbers = b//c - (a-1)//c
# dye bolunenler
d_numbers = b//d - (a-1)//d
# ortak bolunenler
gcd_number = c*d // gcd(c, d)
ortak = b//gcd_number - (a-1)//gcd_number
# result
print((b-a+1-(c_numbers+d_numbers-ortak)))
| 12
| 12
| 314
| 310
|
from fractions import gcd
a, b, c, d = list(map(int, input().split(" ")))
# cye bolunenler
c_numbers = b // c - (a - 1) // c
# dye bolunenler
d_numbers = b // d - (a - 1) // d
# ortak bolunenler
gcd_number = c * d // gcd(c, d)
ortak = b // (gcd_number) - (a - 1) // (gcd_number)
# result
print((b - a + 1 - (c_numbers + d_numbers - ortak)))
|
from fractions import gcd
a, b, c, d = list(map(int, input().split(" ")))
# cye bolunenler
c_numbers = b // c - (a - 1) // c
# dye bolunenler
d_numbers = b // d - (a - 1) // d
# ortak bolunenler
gcd_number = c * d // gcd(c, d)
ortak = b // gcd_number - (a - 1) // gcd_number
# result
print((b - a + 1 - (c_numbers + d_numbers - ortak)))
| false
| 0
|
[
"-ortak = b // (gcd_number) - (a - 1) // (gcd_number)",
"+ortak = b // gcd_number - (a - 1) // gcd_number"
] | false
| 0.008112
| 0.169645
| 0.047818
|
[
"s673211975",
"s019764794"
] |
u072053884
|
p02296
|
python
|
s310484994
|
s078458199
| 80
| 20
| 7,968
| 7,940
|
Accepted
|
Accepted
| 75
|
class Point:
def __init__(self, x , y):
self.x = x
self.y = y
def __sub__(self, p):
x_sub = self.x - p.x
y_sub = self.y - p.y
return Point(x_sub, y_sub)
class Vector:
def __init__(self, p):
self.x = p.x
self.y = p.y
self.norm = (p.x ** 2 + p.y ** 2) ** 0.5
def cross(v1, v2):
return v1.x * v2.y - v1.y * v2.x
def dot(v1, v2):
return v1.x * v2.x + v1.y * v2.y
def ccw(p0, p1, p2):
a = Vector(p1 - p0)
b = Vector(p2 - p0)
cross_ab = cross(a, b)
if cross_ab > 0:
return 1
elif cross_ab < 0:
return -1
elif dot(a, b) < 0:
return 1
elif a.norm < b.norm:
return -1
else:
return 0
def intersect(p1, p2, p3, p4):
if (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0) and \
(ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0):
return True
else:
return False
def getDistanceSP(sp1, sp2, p):
a = Vector(sp2 - sp1)
b = Vector(p - sp1)
if dot(a, b) < 0:
return b.norm
c = Vector(sp1 - sp2)
d = Vector(p - sp2)
if dot(c, d) < 0:
return d.norm
return abs(cross(a, b) / a.norm)
def getDistance(p1, p2, p3, p4):
if intersect(p1, p2, p3, p4):
print("0.00000000")
else:
d = min(getDistanceSP(p1, p2, p3), getDistanceSP(p1, p2, p4),
getDistanceSP(p3, p4, p1), getDistanceSP(p3, p4, p2))
print("{0:.10f}".format(d))
import sys
file_input = sys.stdin
sq = file_input.readline()
for line in file_input:
x_p0, y_p0, x_p1, y_p1, x_p2, y_p2, x_p3, y_p3 = map(int, line.split())
p0 = Point(x_p0, y_p0)
p1 = Point(x_p1, y_p1)
p2 = Point(x_p2, y_p2)
p3 = Point(x_p3, y_p3)
getDistance(p0, p1, p2, p3)
|
def cross(c1, c2):
return c1.real * c2.imag - c1.imag * c2.real
def dot(c1, c2):
return c1.real * c2.real + c1.imag * c2.imag
def ccw(p0, p1, p2):
a = p1 - p0
b = p2 - p0
cross_ab = cross(a, b)
if cross_ab > 0:
return 1
elif cross_ab < 0:
return -1
elif dot(a, b) < 0:
return 1
elif abs(a) < abs(b):
return -1
else:
return 0
def intersect(p1, p2, p3, p4):
# p1 and p2 are end points of a segment.
# p3 and p4 are end points of the other segment.
if (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0) and \
(ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0):
return True
else:
return False
def get_distance_sp(sp1, sp2, p):
a = sp2 - sp1
b = p - sp1
if dot(a, b) < 0:
return abs(b)
c = sp1 - sp2
d = p - sp2
if dot(c, d) < 0:
return abs(d)
return abs(cross(a, b)) / abs(a)
def print_distance(p1, p2, p3, p4):
# parameters are the same as intersect.
if intersect(p1, p2, p3, p4):
print("0.0000000000")
else:
d = min(get_distance_sp(p1, p2, p3), get_distance_sp(p1, p2, p4),
get_distance_sp(p3, p4, p1), get_distance_sp(p3, p4, p2))
print("{0:.10f}".format(d))
import sys
file_input = sys.stdin
sq = file_input.readline()
for line in file_input:
x_p0, y_p0, x_p1, y_p1, x_p2, y_p2, x_p3, y_p3 = map(int, line.split())
p0 = x_p0 + y_p0 * 1j
p1 = x_p1 + y_p1 * 1j
p2 = x_p2 + y_p2 * 1j
p3 = x_p3 + y_p3 * 1j
print_distance(p0, p1, p2, p3)
| 76
| 64
| 1,840
| 1,625
|
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def __sub__(self, p):
x_sub = self.x - p.x
y_sub = self.y - p.y
return Point(x_sub, y_sub)
class Vector:
def __init__(self, p):
self.x = p.x
self.y = p.y
self.norm = (p.x**2 + p.y**2) ** 0.5
def cross(v1, v2):
return v1.x * v2.y - v1.y * v2.x
def dot(v1, v2):
return v1.x * v2.x + v1.y * v2.y
def ccw(p0, p1, p2):
a = Vector(p1 - p0)
b = Vector(p2 - p0)
cross_ab = cross(a, b)
if cross_ab > 0:
return 1
elif cross_ab < 0:
return -1
elif dot(a, b) < 0:
return 1
elif a.norm < b.norm:
return -1
else:
return 0
def intersect(p1, p2, p3, p4):
if (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0) and (
ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0
):
return True
else:
return False
def getDistanceSP(sp1, sp2, p):
a = Vector(sp2 - sp1)
b = Vector(p - sp1)
if dot(a, b) < 0:
return b.norm
c = Vector(sp1 - sp2)
d = Vector(p - sp2)
if dot(c, d) < 0:
return d.norm
return abs(cross(a, b) / a.norm)
def getDistance(p1, p2, p3, p4):
if intersect(p1, p2, p3, p4):
print("0.00000000")
else:
d = min(
getDistanceSP(p1, p2, p3),
getDistanceSP(p1, p2, p4),
getDistanceSP(p3, p4, p1),
getDistanceSP(p3, p4, p2),
)
print("{0:.10f}".format(d))
import sys
file_input = sys.stdin
sq = file_input.readline()
for line in file_input:
x_p0, y_p0, x_p1, y_p1, x_p2, y_p2, x_p3, y_p3 = map(int, line.split())
p0 = Point(x_p0, y_p0)
p1 = Point(x_p1, y_p1)
p2 = Point(x_p2, y_p2)
p3 = Point(x_p3, y_p3)
getDistance(p0, p1, p2, p3)
|
def cross(c1, c2):
return c1.real * c2.imag - c1.imag * c2.real
def dot(c1, c2):
return c1.real * c2.real + c1.imag * c2.imag
def ccw(p0, p1, p2):
a = p1 - p0
b = p2 - p0
cross_ab = cross(a, b)
if cross_ab > 0:
return 1
elif cross_ab < 0:
return -1
elif dot(a, b) < 0:
return 1
elif abs(a) < abs(b):
return -1
else:
return 0
def intersect(p1, p2, p3, p4):
# p1 and p2 are end points of a segment.
# p3 and p4 are end points of the other segment.
if (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0) and (
ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0
):
return True
else:
return False
def get_distance_sp(sp1, sp2, p):
a = sp2 - sp1
b = p - sp1
if dot(a, b) < 0:
return abs(b)
c = sp1 - sp2
d = p - sp2
if dot(c, d) < 0:
return abs(d)
return abs(cross(a, b)) / abs(a)
def print_distance(p1, p2, p3, p4):
# parameters are the same as intersect.
if intersect(p1, p2, p3, p4):
print("0.0000000000")
else:
d = min(
get_distance_sp(p1, p2, p3),
get_distance_sp(p1, p2, p4),
get_distance_sp(p3, p4, p1),
get_distance_sp(p3, p4, p2),
)
print("{0:.10f}".format(d))
import sys
file_input = sys.stdin
sq = file_input.readline()
for line in file_input:
x_p0, y_p0, x_p1, y_p1, x_p2, y_p2, x_p3, y_p3 = map(int, line.split())
p0 = x_p0 + y_p0 * 1j
p1 = x_p1 + y_p1 * 1j
p2 = x_p2 + y_p2 * 1j
p3 = x_p3 + y_p3 * 1j
print_distance(p0, p1, p2, p3)
| false
| 15.789474
|
[
"-class Point:",
"- def __init__(self, x, y):",
"- self.x = x",
"- self.y = y",
"-",
"- def __sub__(self, p):",
"- x_sub = self.x - p.x",
"- y_sub = self.y - p.y",
"- return Point(x_sub, y_sub)",
"+def cross(c1, c2):",
"+ return c1.real * c2.imag - c1.imag * c2.real",
"-class Vector:",
"- def __init__(self, p):",
"- self.x = p.x",
"- self.y = p.y",
"- self.norm = (p.x**2 + p.y**2) ** 0.5",
"-",
"-",
"-def cross(v1, v2):",
"- return v1.x * v2.y - v1.y * v2.x",
"-",
"-",
"-def dot(v1, v2):",
"- return v1.x * v2.x + v1.y * v2.y",
"+def dot(c1, c2):",
"+ return c1.real * c2.real + c1.imag * c2.imag",
"- a = Vector(p1 - p0)",
"- b = Vector(p2 - p0)",
"+ a = p1 - p0",
"+ b = p2 - p0",
"- elif a.norm < b.norm:",
"+ elif abs(a) < abs(b):",
"+ # p1 and p2 are end points of a segment.",
"+ # p3 and p4 are end points of the other segment.",
"-def getDistanceSP(sp1, sp2, p):",
"- a = Vector(sp2 - sp1)",
"- b = Vector(p - sp1)",
"+def get_distance_sp(sp1, sp2, p):",
"+ a = sp2 - sp1",
"+ b = p - sp1",
"- return b.norm",
"- c = Vector(sp1 - sp2)",
"- d = Vector(p - sp2)",
"+ return abs(b)",
"+ c = sp1 - sp2",
"+ d = p - sp2",
"- return d.norm",
"- return abs(cross(a, b) / a.norm)",
"+ return abs(d)",
"+ return abs(cross(a, b)) / abs(a)",
"-def getDistance(p1, p2, p3, p4):",
"+def print_distance(p1, p2, p3, p4):",
"+ # parameters are the same as intersect.",
"- print(\"0.00000000\")",
"+ print(\"0.0000000000\")",
"- getDistanceSP(p1, p2, p3),",
"- getDistanceSP(p1, p2, p4),",
"- getDistanceSP(p3, p4, p1),",
"- getDistanceSP(p3, p4, p2),",
"+ get_distance_sp(p1, p2, p3),",
"+ get_distance_sp(p1, p2, p4),",
"+ get_distance_sp(p3, p4, p1),",
"+ get_distance_sp(p3, p4, p2),",
"- p0 = Point(x_p0, y_p0)",
"- p1 = Point(x_p1, y_p1)",
"- p2 = Point(x_p2, y_p2)",
"- p3 = Point(x_p3, y_p3)",
"- getDistance(p0, p1, p2, p3)",
"+ p0 = x_p0 + y_p0 * 1j",
"+ p1 = x_p1 + y_p1 * 1j",
"+ p2 = x_p2 + y_p2 * 1j",
"+ p3 = x_p3 + y_p3 * 1j",
"+ print_distance(p0, p1, p2, p3)"
] | false
| 0.034877
| 0.036265
| 0.961716
|
[
"s310484994",
"s078458199"
] |
u924691798
|
p02659
|
python
|
s138126404
|
s188260187
| 24
| 22
| 9,036
| 9,128
|
Accepted
|
Accepted
| 8.33
|
A, B = list(map(float, input().split()))
A = int(A)
B = int(B*100+0.1)
print((int(A*B//100)))
|
A, B = input().split()
A = int(A)
B = int(float(B)*100+0.1)
print((int(A*B//100)))
| 4
| 4
| 88
| 84
|
A, B = list(map(float, input().split()))
A = int(A)
B = int(B * 100 + 0.1)
print((int(A * B // 100)))
|
A, B = input().split()
A = int(A)
B = int(float(B) * 100 + 0.1)
print((int(A * B // 100)))
| false
| 0
|
[
"-A, B = list(map(float, input().split()))",
"+A, B = input().split()",
"-B = int(B * 100 + 0.1)",
"+B = int(float(B) * 100 + 0.1)"
] | false
| 0.036792
| 0.036505
| 1.007877
|
[
"s138126404",
"s188260187"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.