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
u606045429
p03178
python
s461021277
s797183924
1,648
487
3,064
44,636
Accepted
Accepted
70.45
def main(): mod = 10 ** 9 + 7 K = list(map(int, eval(input()))) D = int(eval(input())) s = 0 dp = [0] * D for k in K: ndp = [0] * D for d in range(10): for i, dpi in enumerate(dp): ndp[(i + d) % D] += dpi for d in range(k): ndp[(s + d) % D] += 1 s = (s + k) % D dp = [x % mod for x in ndp] print(((dp[0] - (s != 0)) % mod)) main()
mod = 10 ** 9 + 7 K = list(map(int, eval(input()))) D = int(eval(input())) s = 0 dp = [0] * D for k in K: ndp = [0] * D for d in range(10): for i, dpi in enumerate(dp): ndp[(i + d) % D] += dpi for d in range(k): ndp[(s + d) % D] += 1 s = (s + k) % D dp = [x % mod for x in ndp] print(((dp[0] - (s != 0)) % mod))
23
20
446
363
def main(): mod = 10**9 + 7 K = list(map(int, eval(input()))) D = int(eval(input())) s = 0 dp = [0] * D for k in K: ndp = [0] * D for d in range(10): for i, dpi in enumerate(dp): ndp[(i + d) % D] += dpi for d in range(k): ndp[(s + d) % D] += 1 s = (s + k) % D dp = [x % mod for x in ndp] print(((dp[0] - (s != 0)) % mod)) main()
mod = 10**9 + 7 K = list(map(int, eval(input()))) D = int(eval(input())) s = 0 dp = [0] * D for k in K: ndp = [0] * D for d in range(10): for i, dpi in enumerate(dp): ndp[(i + d) % D] += dpi for d in range(k): ndp[(s + d) % D] += 1 s = (s + k) % D dp = [x % mod for x in ndp] print(((dp[0] - (s != 0)) % mod))
false
13.043478
[ "-def main():", "- mod = 10**9 + 7", "- K = list(map(int, eval(input())))", "- D = int(eval(input()))", "- s = 0", "- dp = [0] * D", "- for k in K:", "- ndp = [0] * D", "- for d in range(10):", "- for i, dpi in enumerate(dp):", "- ndp[(i + d) % D] += dpi", "- for d in range(k):", "- ndp[(s + d) % D] += 1", "- s = (s + k) % D", "- dp = [x % mod for x in ndp]", "- print(((dp[0] - (s != 0)) % mod))", "-", "-", "-main()", "+mod = 10**9 + 7", "+K = list(map(int, eval(input())))", "+D = int(eval(input()))", "+s = 0", "+dp = [0] * D", "+for k in K:", "+ ndp = [0] * D", "+ for d in range(10):", "+ for i, dpi in enumerate(dp):", "+ ndp[(i + d) % D] += dpi", "+ for d in range(k):", "+ ndp[(s + d) % D] += 1", "+ s = (s + k) % D", "+ dp = [x % mod for x in ndp]", "+print(((dp[0] - (s != 0)) % mod))" ]
false
0.03769
0.046462
0.811202
[ "s461021277", "s797183924" ]
u254871849
p02725
python
s474779114
s733884792
126
97
25,124
25,124
Accepted
Accepted
23.02
import sys n, k, *a = list(map(int, sys.stdin.read().split())) a.append(n + a[0]) def main(): d = 0 for i in range(k): d = max(d, a[i+1] - a[i]) res = n - d print(res) if __name__ == "__main__": main()
import sys k, n, *a = list(map(int, sys.stdin.read().split())) a += [a[0] + k] def main(): d = [a[i+1] - a[i] for i in range(n)] print((k - max(d))) if __name__ == '__main__': main()
14
11
239
200
import sys n, k, *a = list(map(int, sys.stdin.read().split())) a.append(n + a[0]) def main(): d = 0 for i in range(k): d = max(d, a[i + 1] - a[i]) res = n - d print(res) if __name__ == "__main__": main()
import sys k, n, *a = list(map(int, sys.stdin.read().split())) a += [a[0] + k] def main(): d = [a[i + 1] - a[i] for i in range(n)] print((k - max(d))) if __name__ == "__main__": main()
false
21.428571
[ "-n, k, *a = list(map(int, sys.stdin.read().split()))", "-a.append(n + a[0])", "+k, n, *a = list(map(int, sys.stdin.read().split()))", "+a += [a[0] + k]", "- d = 0", "- for i in range(k):", "- d = max(d, a[i + 1] - a[i])", "- res = n - d", "- print(res)", "+ d = [a[i + 1] - a[i] for i in range(n)]", "+ print((k - max(d)))" ]
false
0.047293
0.040615
1.164443
[ "s474779114", "s733884792" ]
u063052907
p03853
python
s222779755
s692111974
21
19
3,060
3,060
Accepted
Accepted
9.52
# coding: utf-8 H, W = list(map(int, input().split())) for _ in range(H): l = eval(input()) print((l + "\n" + l))
# coding: utf-8 H, W = map(int, input().split()) for _ in range(H): l = input() print(l, l, sep="\n")
6
6
113
116
# coding: utf-8 H, W = list(map(int, input().split())) for _ in range(H): l = eval(input()) print((l + "\n" + l))
# coding: utf-8 H, W = map(int, input().split()) for _ in range(H): l = input() print(l, l, sep="\n")
false
0
[ "-H, W = list(map(int, input().split()))", "+H, W = map(int, input().split())", "- l = eval(input())", "- print((l + \"\\n\" + l))", "+ l = input()", "+ print(l, l, sep=\"\\n\")" ]
false
0.076175
0.043853
1.737045
[ "s222779755", "s692111974" ]
u134856634
p02983
python
s651744031
s922753903
50
45
2,940
3,060
Accepted
Accepted
10
l, r = list(map(int, input().split())) def doit(l, r): # l = l % 2019 # r = r % 2019 # if r <= l: # r += 2019 res = 2018 for x in range(l, r): for y in range(x + 1, r + 1): #print(x, y, file=sys.stderr) res = min(res, (x * y) % 2019) if res == 0: return 0 return res % 2019 print((doit(l, r)))
l, r = list(map(int, input().split())) def doit(l, r): if r - l > 2019: return 0 l = l % 2019 r = r % 2019 if l == 0: return 0 if r == 0: return 0 if r <= l: r += 2019 res = 2019 for x in range(l, r): for y in range(x + 1, r + 1): #print(x, y, file=sys.stderr) res = min(res, (x * y) % 2019) if res == 0: return 0 return res % 2019 print((doit(l, r)))
16
22
344
430
l, r = list(map(int, input().split())) def doit(l, r): # l = l % 2019 # r = r % 2019 # if r <= l: # r += 2019 res = 2018 for x in range(l, r): for y in range(x + 1, r + 1): # print(x, y, file=sys.stderr) res = min(res, (x * y) % 2019) if res == 0: return 0 return res % 2019 print((doit(l, r)))
l, r = list(map(int, input().split())) def doit(l, r): if r - l > 2019: return 0 l = l % 2019 r = r % 2019 if l == 0: return 0 if r == 0: return 0 if r <= l: r += 2019 res = 2019 for x in range(l, r): for y in range(x + 1, r + 1): # print(x, y, file=sys.stderr) res = min(res, (x * y) % 2019) if res == 0: return 0 return res % 2019 print((doit(l, r)))
false
27.272727
[ "- # l = l % 2019", "- # r = r % 2019", "- # if r <= l:", "- # r += 2019", "- res = 2018", "+ if r - l > 2019:", "+ return 0", "+ l = l % 2019", "+ r = r % 2019", "+ if l == 0:", "+ return 0", "+ if r == 0:", "+ return 0", "+ if r <= l:", "+ r += 2019", "+ res = 2019" ]
false
0.035974
0.035894
1.002219
[ "s651744031", "s922753903" ]
u777923818
p03007
python
s024013460
s329441153
464
147
99,948
21,300
Accepted
Accepted
68.32
from itertools import accumulate from bisect import bisect, bisect_left from functools import reduce from itertools import accumulate, product from operator import itemgetter, xor, mul from math import sqrt from random import randint, random from heapq import heappop, heappush from fractions import gcd from collections import Counter, deque, defaultdict import sys input = sys.stdin.readline from sys import setrecursionlimit setrecursionlimit(10**9) def inpl(): return list(map(int, input().split())) N = int(input()) A = sorted(inpl()) l = bisect_left(A, 0) if l == 0: ans = [] for i in range(N-2, 0, -1): ans.append("{} {}".format(str(A[0]), str(A[i]))) A[0] -= A[i] ans.append("{} {}".format(str(A[-1]), str(A[0]))) score = A[-1] - A[0] elif l == N: ans = [] for i in range(N-1): ans.append("{} {}".format(str(A[-1]), str(A[i]))) A[-1] -= A[i] score = A[-1] else: ans = [] for i in range(l, N-1): ans.append("{} {}".format(str(A[0]), str(A[i]))) A[0] -= A[i] for i in range(l): ans.append("{} {}".format(str(A[-1]), str(A[i]))) A[-1] -= A[i] score = A[-1] print(score) print(*ans, sep="\n")
from collections import defaultdict, deque import sys #input = sys.stdin.readline def inpl(): return list(map(int, input().split())) N = int(eval(input())) A = sorted(inpl()) if A[-1] < 0: print((A[-1] - sum(A[:-1]))) for i in range(N-2, -1, -1): print((A[-1], A[i])) A[-1] -= A[i] else: print((sum(map(abs, A[1:])) - A[0])) for i in range(N-2, 0, -1): a = A[i] if a > 0: print((A[0], a)) A[0] -= a else: print((A[-1], a)) A[-1] -= a print((A[-1], A[0]))
47
22
1,256
565
from itertools import accumulate from bisect import bisect, bisect_left from functools import reduce from itertools import accumulate, product from operator import itemgetter, xor, mul from math import sqrt from random import randint, random from heapq import heappop, heappush from fractions import gcd from collections import Counter, deque, defaultdict import sys input = sys.stdin.readline from sys import setrecursionlimit setrecursionlimit(10**9) def inpl(): return list(map(int, input().split())) N = int(input()) A = sorted(inpl()) l = bisect_left(A, 0) if l == 0: ans = [] for i in range(N - 2, 0, -1): ans.append("{} {}".format(str(A[0]), str(A[i]))) A[0] -= A[i] ans.append("{} {}".format(str(A[-1]), str(A[0]))) score = A[-1] - A[0] elif l == N: ans = [] for i in range(N - 1): ans.append("{} {}".format(str(A[-1]), str(A[i]))) A[-1] -= A[i] score = A[-1] else: ans = [] for i in range(l, N - 1): ans.append("{} {}".format(str(A[0]), str(A[i]))) A[0] -= A[i] for i in range(l): ans.append("{} {}".format(str(A[-1]), str(A[i]))) A[-1] -= A[i] score = A[-1] print(score) print(*ans, sep="\n")
from collections import defaultdict, deque import sys # input = sys.stdin.readline def inpl(): return list(map(int, input().split())) N = int(eval(input())) A = sorted(inpl()) if A[-1] < 0: print((A[-1] - sum(A[:-1]))) for i in range(N - 2, -1, -1): print((A[-1], A[i])) A[-1] -= A[i] else: print((sum(map(abs, A[1:])) - A[0])) for i in range(N - 2, 0, -1): a = A[i] if a > 0: print((A[0], a)) A[0] -= a else: print((A[-1], a)) A[-1] -= a print((A[-1], A[0]))
false
53.191489
[ "-from itertools import accumulate", "-from bisect import bisect, bisect_left", "-from functools import reduce", "-from itertools import accumulate, product", "-from operator import itemgetter, xor, mul", "-from math import sqrt", "-from random import randint, random", "-from heapq import heappop, heappush", "-from fractions import gcd", "-from collections import Counter, deque, defaultdict", "+from collections import defaultdict, deque", "-input = sys.stdin.readline", "-from sys import setrecursionlimit", "-", "-setrecursionlimit(10**9)", "-", "-", "+# input = sys.stdin.readline", "-N = int(input())", "+N = int(eval(input()))", "-l = bisect_left(A, 0)", "-if l == 0:", "- ans = []", "+if A[-1] < 0:", "+ print((A[-1] - sum(A[:-1])))", "+ for i in range(N - 2, -1, -1):", "+ print((A[-1], A[i]))", "+ A[-1] -= A[i]", "+else:", "+ print((sum(map(abs, A[1:])) - A[0]))", "- ans.append(\"{} {}\".format(str(A[0]), str(A[i])))", "- A[0] -= A[i]", "- ans.append(\"{} {}\".format(str(A[-1]), str(A[0])))", "- score = A[-1] - A[0]", "-elif l == N:", "- ans = []", "- for i in range(N - 1):", "- ans.append(\"{} {}\".format(str(A[-1]), str(A[i])))", "- A[-1] -= A[i]", "- score = A[-1]", "-else:", "- ans = []", "- for i in range(l, N - 1):", "- ans.append(\"{} {}\".format(str(A[0]), str(A[i])))", "- A[0] -= A[i]", "- for i in range(l):", "- ans.append(\"{} {}\".format(str(A[-1]), str(A[i])))", "- A[-1] -= A[i]", "- score = A[-1]", "-print(score)", "-print(*ans, sep=\"\\n\")", "+ a = A[i]", "+ if a > 0:", "+ print((A[0], a))", "+ A[0] -= a", "+ else:", "+ print((A[-1], a))", "+ A[-1] -= a", "+ print((A[-1], A[0]))" ]
false
0.056082
0.073391
0.764157
[ "s024013460", "s329441153" ]
u677121387
p02813
python
s623010978
s467592285
44
28
3,064
3,064
Accepted
Accepted
36.36
from itertools import permutations n = int(eval(input())) p = [int(i) for i in input().split()] q = [int(i) for i in input().split()] a = 0 b = 0 cnt = 0 st = 0 for i in permutations(list(range(1,n+1))): cnt += 1 if list(i) == p: a = cnt st += 1 if list(i) == q: b = cnt st += 1 if st == 2: break print((abs(a-b)))
from itertools import permutations n = int(eval(input())) p = tuple(int(i) for i in input().split()) q = tuple(int(i) for i in input().split()) a = 0 b = 0 cnt = 0 st = 0 for i in permutations(list(range(1,n+1))): cnt += 1 if i == p: a = cnt st += 1 if i == q: b = cnt st += 1 if st == 2: break print((abs(a-b)))
21
21
383
381
from itertools import permutations n = int(eval(input())) p = [int(i) for i in input().split()] q = [int(i) for i in input().split()] a = 0 b = 0 cnt = 0 st = 0 for i in permutations(list(range(1, n + 1))): cnt += 1 if list(i) == p: a = cnt st += 1 if list(i) == q: b = cnt st += 1 if st == 2: break print((abs(a - b)))
from itertools import permutations n = int(eval(input())) p = tuple(int(i) for i in input().split()) q = tuple(int(i) for i in input().split()) a = 0 b = 0 cnt = 0 st = 0 for i in permutations(list(range(1, n + 1))): cnt += 1 if i == p: a = cnt st += 1 if i == q: b = cnt st += 1 if st == 2: break print((abs(a - b)))
false
0
[ "-p = [int(i) for i in input().split()]", "-q = [int(i) for i in input().split()]", "+p = tuple(int(i) for i in input().split())", "+q = tuple(int(i) for i in input().split())", "- if list(i) == p:", "+ if i == p:", "- if list(i) == q:", "+ if i == q:" ]
false
0.040456
0.040166
1.007229
[ "s623010978", "s467592285" ]
u847923740
p02725
python
s555988633
s610891609
248
144
77,500
99,756
Accepted
Accepted
41.94
K,N=list(map(int,input().split())) A=list(map(int,input().split())) A.sort() A+=[A[0]+K] minn=K+1 for i in range(N): minn=min(minn,K-(A[i+1]-A[i])) print(minn)
# import sys input=sys.stdin.readline def main(): K,N=list(map(int,input().split())) A=list(map(int,input().split())) mind=K-(A[0]-A[-1]+K) for i in range(1,N): mind=min(mind,K-(A[i]-A[i-1])) print(mind) if __name__=="__main__": main()
8
16
164
289
K, N = list(map(int, input().split())) A = list(map(int, input().split())) A.sort() A += [A[0] + K] minn = K + 1 for i in range(N): minn = min(minn, K - (A[i + 1] - A[i])) print(minn)
# import sys input = sys.stdin.readline def main(): K, N = list(map(int, input().split())) A = list(map(int, input().split())) mind = K - (A[0] - A[-1] + K) for i in range(1, N): mind = min(mind, K - (A[i] - A[i - 1])) print(mind) if __name__ == "__main__": main()
false
50
[ "-K, N = list(map(int, input().split()))", "-A = list(map(int, input().split()))", "-A.sort()", "-A += [A[0] + K]", "-minn = K + 1", "-for i in range(N):", "- minn = min(minn, K - (A[i + 1] - A[i]))", "-print(minn)", "+#", "+import sys", "+", "+input = sys.stdin.readline", "+", "+", "+def main():", "+ K, N = list(map(int, input().split()))", "+ A = list(map(int, input().split()))", "+ mind = K - (A[0] - A[-1] + K)", "+ for i in range(1, N):", "+ mind = min(mind, K - (A[i] - A[i - 1]))", "+ print(mind)", "+", "+", "+if __name__ == \"__main__\":", "+ main()" ]
false
0.007933
0.036549
0.217051
[ "s555988633", "s610891609" ]
u780342333
p02398
python
s741609685
s627177357
30
20
7,668
5,604
Accepted
Accepted
33.33
a, b, c = list(map(int, input().split(" "))) cnt = 0 for i in range(a, b+1): if c % i == 0: cnt += 1 print (cnt)
def get_divisors(a, b, c): #get list of divisors of c res = [i for i in range(1, c+1) if c % i == 0] #filter between a and b res = [i for i in res if a <= i <= b] # return sum return len(res) if __name__ == "__main__": a, b, c = list(map(int, input().split())) print((get_divisors(a, b, c)))
6
14
116
337
a, b, c = list(map(int, input().split(" "))) cnt = 0 for i in range(a, b + 1): if c % i == 0: cnt += 1 print(cnt)
def get_divisors(a, b, c): # get list of divisors of c res = [i for i in range(1, c + 1) if c % i == 0] # filter between a and b res = [i for i in res if a <= i <= b] # return sum return len(res) if __name__ == "__main__": a, b, c = list(map(int, input().split())) print((get_divisors(a, b, c)))
false
57.142857
[ "-a, b, c = list(map(int, input().split(\" \")))", "-cnt = 0", "-for i in range(a, b + 1):", "- if c % i == 0:", "- cnt += 1", "-print(cnt)", "+def get_divisors(a, b, c):", "+ # get list of divisors of c", "+ res = [i for i in range(1, c + 1) if c % i == 0]", "+ # filter between a and b", "+ res = [i for i in res if a <= i <= b]", "+ # return sum", "+ return len(res)", "+", "+", "+if __name__ == \"__main__\":", "+ a, b, c = list(map(int, input().split()))", "+ print((get_divisors(a, b, c)))" ]
false
0.046543
0.049765
0.935262
[ "s741609685", "s627177357" ]
u091855288
p04005
python
s196565794
s125938028
1,134
156
13,668
10,536
Accepted
Accepted
86.24
import numpy as np a = list(map(int,input().split())) a = np.array(a) if len(a[a % 2==0]) > 0: print(0) else: m = max(a) a = list(a) a.remove(m) print(np.prod(np.array(a)))
import numpy as np import copy a = list(map(int,input().split())) def myfunc(a): a = np.array(a) if len(a[a % 2==0]) > 0: print(0) else: m = np.max(a) a = np.delete(a, np.where(a==m)[0][0]) print(np.prod(a)) myfunc(a)
11
15
189
252
import numpy as np a = list(map(int, input().split())) a = np.array(a) if len(a[a % 2 == 0]) > 0: print(0) else: m = max(a) a = list(a) a.remove(m) print(np.prod(np.array(a)))
import numpy as np import copy a = list(map(int, input().split())) def myfunc(a): a = np.array(a) if len(a[a % 2 == 0]) > 0: print(0) else: m = np.max(a) a = np.delete(a, np.where(a == m)[0][0]) print(np.prod(a)) myfunc(a)
false
26.666667
[ "+import copy", "-a = np.array(a)", "-if len(a[a % 2 == 0]) > 0:", "- print(0)", "-else:", "- m = max(a)", "- a = list(a)", "- a.remove(m)", "- print(np.prod(np.array(a)))", "+", "+", "+def myfunc(a):", "+ a = np.array(a)", "+ if len(a[a % 2 == 0]) > 0:", "+ print(0)", "+ else:", "+ m = np.max(a)", "+ a = np.delete(a, np.where(a == m)[0][0])", "+ print(np.prod(a))", "+", "+", "+myfunc(a)" ]
false
0.243143
0.181649
1.338533
[ "s196565794", "s125938028" ]
u891635666
p02923
python
s766619719
s161013477
128
74
14,252
14,168
Accepted
Accepted
42.19
n = int(eval(input())) nums = list(map(int, input().split())) left = 0 right = 0 res = 0 while left < n: prev = nums[left] right = left while right < n and prev >= nums[right]: right += 1 prev = nums[right - 1] res = max(res, right - left) left = right print((res - 1))
import sys input = sys.stdin.readline ri = lambda: int(eval(input())) rs = lambda: input().rstrip() ril = lambda: list(map(int, input().split())) rsl = lambda: input().rstrip().split() ris = lambda n: [ri() for _ in range(n)] rss = lambda n: [rs() for _ in range(n)] rils = lambda n: [ril() for _ in range(n)] rsls = lambda n: [rsl() for _ in range(n)] n = ri() ls = ril() res = 0 prev = ls[0] count = 0 for x in ls[1:]: if x <= prev: count += 1 else: res = max(res, count) count = 0 prev = x res = max(res, count) print(res)
15
27
312
584
n = int(eval(input())) nums = list(map(int, input().split())) left = 0 right = 0 res = 0 while left < n: prev = nums[left] right = left while right < n and prev >= nums[right]: right += 1 prev = nums[right - 1] res = max(res, right - left) left = right print((res - 1))
import sys input = sys.stdin.readline ri = lambda: int(eval(input())) rs = lambda: input().rstrip() ril = lambda: list(map(int, input().split())) rsl = lambda: input().rstrip().split() ris = lambda n: [ri() for _ in range(n)] rss = lambda n: [rs() for _ in range(n)] rils = lambda n: [ril() for _ in range(n)] rsls = lambda n: [rsl() for _ in range(n)] n = ri() ls = ril() res = 0 prev = ls[0] count = 0 for x in ls[1:]: if x <= prev: count += 1 else: res = max(res, count) count = 0 prev = x res = max(res, count) print(res)
false
44.444444
[ "-n = int(eval(input()))", "-nums = list(map(int, input().split()))", "-left = 0", "-right = 0", "+import sys", "+", "+input = sys.stdin.readline", "+ri = lambda: int(eval(input()))", "+rs = lambda: input().rstrip()", "+ril = lambda: list(map(int, input().split()))", "+rsl = lambda: input().rstrip().split()", "+ris = lambda n: [ri() for _ in range(n)]", "+rss = lambda n: [rs() for _ in range(n)]", "+rils = lambda n: [ril() for _ in range(n)]", "+rsls = lambda n: [rsl() for _ in range(n)]", "+n = ri()", "+ls = ril()", "-while left < n:", "- prev = nums[left]", "- right = left", "- while right < n and prev >= nums[right]:", "- right += 1", "- prev = nums[right - 1]", "- res = max(res, right - left)", "- left = right", "-print((res - 1))", "+prev = ls[0]", "+count = 0", "+for x in ls[1:]:", "+ if x <= prev:", "+ count += 1", "+ else:", "+ res = max(res, count)", "+ count = 0", "+ prev = x", "+res = max(res, count)", "+print(res)" ]
false
0.037266
0.037373
0.997134
[ "s766619719", "s161013477" ]
u905203728
p03418
python
s758581876
s336710956
115
95
3,060
2,940
Accepted
Accepted
17.39
n,k=list(map(int,input().split())) if k==0: print((n**2));exit() ans=0 for i in range(k+1,n+1): p=n//i q=n%i ans +=p*max(0,i-k)+max(0,q-k+1) print(ans)
n,k=list(map(int,input().split())) if k==0:print((n**2));exit() ans=0 for i in range(k+1,n+1): ans +=n//i*max(0,i-k)+max(0,n%i-k+1) print(ans)
9
6
167
143
n, k = list(map(int, input().split())) if k == 0: print((n**2)) exit() ans = 0 for i in range(k + 1, n + 1): p = n // i q = n % i ans += p * max(0, i - k) + max(0, q - k + 1) print(ans)
n, k = list(map(int, input().split())) if k == 0: print((n**2)) exit() ans = 0 for i in range(k + 1, n + 1): ans += n // i * max(0, i - k) + max(0, n % i - k + 1) print(ans)
false
33.333333
[ "- p = n // i", "- q = n % i", "- ans += p * max(0, i - k) + max(0, q - k + 1)", "+ ans += n // i * max(0, i - k) + max(0, n % i - k + 1)" ]
false
0.083645
0.046796
1.787427
[ "s758581876", "s336710956" ]
u131881594
p03212
python
s594870542
s768638100
136
93
10,372
10,256
Accepted
Accepted
31.62
from collections import Counter ls=[] def rec(n): if len(str(n))>9: return ls.append(n) rec(n*10+3) rec(n*10+5) rec(n*10+7) n=int(eval(input())) rec(3) rec(5) rec(7) cnt=0 for l in ls: temp=Counter(str(l)) if l<=n and len(list(temp.keys()))==3: cnt+=1 print(cnt)
ls=[] def rec(n): if len(str(n))>9: return ls.append(n) for i in [3,5,7]: rec(10*n+i) n=int(eval(input())) rec(0) cnt=0 for l in ls: if l<=n and all(str(l).count(i)>0 for i in "357"): cnt+=1 print(cnt)
18
11
303
221
from collections import Counter ls = [] def rec(n): if len(str(n)) > 9: return ls.append(n) rec(n * 10 + 3) rec(n * 10 + 5) rec(n * 10 + 7) n = int(eval(input())) rec(3) rec(5) rec(7) cnt = 0 for l in ls: temp = Counter(str(l)) if l <= n and len(list(temp.keys())) == 3: cnt += 1 print(cnt)
ls = [] def rec(n): if len(str(n)) > 9: return ls.append(n) for i in [3, 5, 7]: rec(10 * n + i) n = int(eval(input())) rec(0) cnt = 0 for l in ls: if l <= n and all(str(l).count(i) > 0 for i in "357"): cnt += 1 print(cnt)
false
38.888889
[ "-from collections import Counter", "-", "- rec(n * 10 + 3)", "- rec(n * 10 + 5)", "- rec(n * 10 + 7)", "+ for i in [3, 5, 7]:", "+ rec(10 * n + i)", "-rec(3)", "-rec(5)", "-rec(7)", "+rec(0)", "- temp = Counter(str(l))", "- if l <= n and len(list(temp.keys())) == 3:", "+ if l <= n and all(str(l).count(i) > 0 for i in \"357\"):" ]
false
0.152402
0.236441
0.644566
[ "s594870542", "s768638100" ]
u078042885
p00718
python
s319443061
s527405047
90
80
7,696
7,648
Accepted
Accepted
11.11
a={'m':1000,'c':100,'x':10,'i':1} for _ in range(int(eval(input()))): b,s,t=eval(input()),0,1 for x in b: if x==' ':continue if x in a:s+=a[x]*t;t=1 else:t=int(x) ans='' for k in ['m','c','x','i']: c,s=divmod(s,a[k]) if c:ans+=['',str(c)][c!=1]+k print(ans)
a={'m':1000,'c':100,'x':10,'i':1} for _ in range(int(eval(input()))): b,s,t=input().replace(' ',''),0,1 for x in b: if x in a:s+=a[x]*t;t=1 else:t=int(x) d='' for k in ['m','c','x','i']: c,s=divmod(s,a[k]) if c:d+=['',str(c)][c!=1]+k print(d)
12
11
316
298
a = {"m": 1000, "c": 100, "x": 10, "i": 1} for _ in range(int(eval(input()))): b, s, t = eval(input()), 0, 1 for x in b: if x == " ": continue if x in a: s += a[x] * t t = 1 else: t = int(x) ans = "" for k in ["m", "c", "x", "i"]: c, s = divmod(s, a[k]) if c: ans += ["", str(c)][c != 1] + k print(ans)
a = {"m": 1000, "c": 100, "x": 10, "i": 1} for _ in range(int(eval(input()))): b, s, t = input().replace(" ", ""), 0, 1 for x in b: if x in a: s += a[x] * t t = 1 else: t = int(x) d = "" for k in ["m", "c", "x", "i"]: c, s = divmod(s, a[k]) if c: d += ["", str(c)][c != 1] + k print(d)
false
8.333333
[ "- b, s, t = eval(input()), 0, 1", "+ b, s, t = input().replace(\" \", \"\"), 0, 1", "- if x == \" \":", "- continue", "- ans = \"\"", "+ d = \"\"", "- ans += [\"\", str(c)][c != 1] + k", "- print(ans)", "+ d += [\"\", str(c)][c != 1] + k", "+ print(d)" ]
false
0.102112
0.085512
1.194115
[ "s319443061", "s527405047" ]
u519939795
p02819
python
s889738137
s334794833
251
23
3,864
2,940
Accepted
Accepted
90.84
N = int(eval(input())) ans = -1 x = N while(ans == -1): if all([x % i != 0 for i in range(2, x)]): ans = x else: x += 1 print(ans)
x=int(eval(input())) f=0 if x == 2: print((2)) else: for i in range(x,10**6): for j in range(2,i//2+2): if i%j == 0: break else: f=i break print(f)
10
13
158
172
N = int(eval(input())) ans = -1 x = N while ans == -1: if all([x % i != 0 for i in range(2, x)]): ans = x else: x += 1 print(ans)
x = int(eval(input())) f = 0 if x == 2: print((2)) else: for i in range(x, 10**6): for j in range(2, i // 2 + 2): if i % j == 0: break else: f = i break print(f)
false
23.076923
[ "-N = int(eval(input()))", "-ans = -1", "-x = N", "-while ans == -1:", "- if all([x % i != 0 for i in range(2, x)]):", "- ans = x", "- else:", "- x += 1", "-print(ans)", "+x = int(eval(input()))", "+f = 0", "+if x == 2:", "+ print((2))", "+else:", "+ for i in range(x, 10**6):", "+ for j in range(2, i // 2 + 2):", "+ if i % j == 0:", "+ break", "+ else:", "+ f = i", "+ break", "+ print(f)" ]
false
0.053589
0.007269
7.372594
[ "s889738137", "s334794833" ]
u367130284
p03053
python
s563663197
s095506497
960
636
163,976
130,908
Accepted
Accepted
33.75
def main(): from collections import deque import sys;input=sys.stdin.readline h,w=list(map(int,input().split())) grid=[["#"]*(w+2)]+[list("#"+eval(input())+"#")for x in range(h)]+[["#"]*(w+2)] stack=deque() for y in range(1,h+1): for x in range(1,w+1): if grid[y][x]=="#": grid[y][x]=0 stack.append((y,x)) for i in range(h*w): tmp=deque() while stack: my,mx=stack.pop() for y,x in ([0,1],[1,0],[-1,0],[0,-1]): if grid[my+y][mx+x]==".": grid[my+y][mx+x]=i+1 tmp.append([my+y,mx+x]) stack=tmp if not tmp: print(i) break if __name__ == '__main__': main()
def main(): from collections import deque import sys;input=sys.stdin.readline h,w=list(map(int,input().split())) grid=[["#"]*(w+2)]+[list("#"+eval(input())+"#")for x in range(h)]+[["#"]*(w+2)] stack=deque() for y in range(1,h+1): for x in range(1,w+1): if grid[y][x]=="#": #grid[y][x]=0 stack.append((y,x)) for i in range(h*w): tmp=deque() while stack: my,mx=stack.pop() for y,x in ([0,1],[1,0],[-1,0],[0,-1]): if grid[my+y][mx+x]==".": #grid[my+y][mx+x]=i+1 grid[my+y][mx+x]="#" tmp.append([my+y,mx+x]) stack=tmp if not tmp: print(i) break if __name__ == '__main__': main()
28
29
789
833
def main(): from collections import deque import sys input = sys.stdin.readline h, w = list(map(int, input().split())) grid = ( [["#"] * (w + 2)] + [list("#" + eval(input()) + "#") for x in range(h)] + [["#"] * (w + 2)] ) stack = deque() for y in range(1, h + 1): for x in range(1, w + 1): if grid[y][x] == "#": grid[y][x] = 0 stack.append((y, x)) for i in range(h * w): tmp = deque() while stack: my, mx = stack.pop() for y, x in ([0, 1], [1, 0], [-1, 0], [0, -1]): if grid[my + y][mx + x] == ".": grid[my + y][mx + x] = i + 1 tmp.append([my + y, mx + x]) stack = tmp if not tmp: print(i) break if __name__ == "__main__": main()
def main(): from collections import deque import sys input = sys.stdin.readline h, w = list(map(int, input().split())) grid = ( [["#"] * (w + 2)] + [list("#" + eval(input()) + "#") for x in range(h)] + [["#"] * (w + 2)] ) stack = deque() for y in range(1, h + 1): for x in range(1, w + 1): if grid[y][x] == "#": # grid[y][x]=0 stack.append((y, x)) for i in range(h * w): tmp = deque() while stack: my, mx = stack.pop() for y, x in ([0, 1], [1, 0], [-1, 0], [0, -1]): if grid[my + y][mx + x] == ".": # grid[my+y][mx+x]=i+1 grid[my + y][mx + x] = "#" tmp.append([my + y, mx + x]) stack = tmp if not tmp: print(i) break if __name__ == "__main__": main()
false
3.448276
[ "- grid[y][x] = 0", "+ # grid[y][x]=0", "- grid[my + y][mx + x] = i + 1", "+ # grid[my+y][mx+x]=i+1", "+ grid[my + y][mx + x] = \"#\"" ]
false
0.036156
0.052876
0.683785
[ "s563663197", "s095506497" ]
u893063840
p03993
python
s841148482
s369372382
156
68
22,500
14,008
Accepted
Accepted
56.41
n = int(eval(input())) a = list(map(int, input().split())) st = set() cnt = 0 for i, e in enumerate(a, 1): pair = min(i, e), max(i, e) if pair in st: cnt += 1 else: st.add(pair) print(cnt)
n = int(eval(input())) a = list(map(int, input().split())) cnt = 0 for i, e in enumerate(a, 1): if a[e-1] == i: cnt += 1 cnt //= 2 print(cnt)
13
10
225
159
n = int(eval(input())) a = list(map(int, input().split())) st = set() cnt = 0 for i, e in enumerate(a, 1): pair = min(i, e), max(i, e) if pair in st: cnt += 1 else: st.add(pair) print(cnt)
n = int(eval(input())) a = list(map(int, input().split())) cnt = 0 for i, e in enumerate(a, 1): if a[e - 1] == i: cnt += 1 cnt //= 2 print(cnt)
false
23.076923
[ "-st = set()", "- pair = min(i, e), max(i, e)", "- if pair in st:", "+ if a[e - 1] == i:", "- else:", "- st.add(pair)", "+cnt //= 2" ]
false
0.084907
0.03774
2.249782
[ "s841148482", "s369372382" ]
u891635666
p03504
python
s789249676
s669486188
1,986
1,416
26,676
26,800
Accepted
Accepted
28.7
n, c = list(map(int, input().split())) MAX_COLS = 10**5 table = [[0 for _ in range(MAX_COLS)] for _ in range(c)] for _ in range(n): s, t, i = list(map(int, input().split())) for j in range(s - 1, t - 1): table[i - 1][j] = 1 for i in range(c): for j in range(MAX_COLS - 1): if table[i][j] == 0 and table[i][j + 1] == 1: table[i][j] = 1 res = 0 for j in range(MAX_COLS): count = 0 for i in range(c): count += table[i][j] res = max(res, count) print(res)
n, c = list(map(int, input().split())) MAX_COLS = 10**5 table = [[0 for _ in range(MAX_COLS)] for _ in range(c)] for _ in range(n): s, t, i = list(map(int, input().split())) for j in range(max(0, s - 2), t - 1): table[i - 1][j] = 1 res = 0 for j in range(MAX_COLS): count = 0 for i in range(c): count += table[i][j] res = max(res, count) print(res)
21
16
528
395
n, c = list(map(int, input().split())) MAX_COLS = 10**5 table = [[0 for _ in range(MAX_COLS)] for _ in range(c)] for _ in range(n): s, t, i = list(map(int, input().split())) for j in range(s - 1, t - 1): table[i - 1][j] = 1 for i in range(c): for j in range(MAX_COLS - 1): if table[i][j] == 0 and table[i][j + 1] == 1: table[i][j] = 1 res = 0 for j in range(MAX_COLS): count = 0 for i in range(c): count += table[i][j] res = max(res, count) print(res)
n, c = list(map(int, input().split())) MAX_COLS = 10**5 table = [[0 for _ in range(MAX_COLS)] for _ in range(c)] for _ in range(n): s, t, i = list(map(int, input().split())) for j in range(max(0, s - 2), t - 1): table[i - 1][j] = 1 res = 0 for j in range(MAX_COLS): count = 0 for i in range(c): count += table[i][j] res = max(res, count) print(res)
false
23.809524
[ "- for j in range(s - 1, t - 1):", "+ for j in range(max(0, s - 2), t - 1):", "-for i in range(c):", "- for j in range(MAX_COLS - 1):", "- if table[i][j] == 0 and table[i][j + 1] == 1:", "- table[i][j] = 1" ]
false
0.537839
0.339608
1.583705
[ "s789249676", "s669486188" ]
u617103038
p02743
python
s552959260
s684253932
35
18
5,076
2,940
Accepted
Accepted
48.57
from decimal import * def resolve(): a, b, c = list(map(int, input().split())) if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt(): print("Yes") else: print("No") resolve()
def resolve(): a, b, c = list(map(int, input().split())) if c-a-b>0 and (c-a-b)**2 > 4*a*b: print("Yes") else: print("No") resolve()
9
8
213
162
from decimal import * def resolve(): a, b, c = list(map(int, input().split())) if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt(): print("Yes") else: print("No") resolve()
def resolve(): a, b, c = list(map(int, input().split())) if c - a - b > 0 and (c - a - b) ** 2 > 4 * a * b: print("Yes") else: print("No") resolve()
false
11.111111
[ "-from decimal import *", "-", "-", "- if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():", "+ if c - a - b > 0 and (c - a - b) ** 2 > 4 * a * b:" ]
false
0.161653
0.084807
1.906129
[ "s552959260", "s684253932" ]
u612721349
p03633
python
s568705523
s052661107
407
48
70,636
5,560
Accepted
Accepted
88.21
from fractions import gcd def lcm(a, b): if a == 0 or b == 0: return 0 return int(a * b // gcd(a, b)) def solve(): n = int(eval(input())) tl = [int(eval(input())) for _ in range(n)] ans = tl[0] for elem in tl[1:]: ans = lcm(ans, elem) print(ans) if __name__=="__main__": solve()
import sys if sys.version_info < (3, 5): from fractions import gcd else: from math import gcd def lcm(a, b): if a == 0 or b == 0: return 0 return int(a * b // gcd(a, b)) def solve(): n = int(eval(input())) tl = [int(eval(input())) for _ in range(n)] ans = tl[0] for elem in tl[1:]: ans = lcm(ans, elem) print(ans) if __name__=="__main__": solve()
17
21
336
414
from fractions import gcd def lcm(a, b): if a == 0 or b == 0: return 0 return int(a * b // gcd(a, b)) def solve(): n = int(eval(input())) tl = [int(eval(input())) for _ in range(n)] ans = tl[0] for elem in tl[1:]: ans = lcm(ans, elem) print(ans) if __name__ == "__main__": solve()
import sys if sys.version_info < (3, 5): from fractions import gcd else: from math import gcd def lcm(a, b): if a == 0 or b == 0: return 0 return int(a * b // gcd(a, b)) def solve(): n = int(eval(input())) tl = [int(eval(input())) for _ in range(n)] ans = tl[0] for elem in tl[1:]: ans = lcm(ans, elem) print(ans) if __name__ == "__main__": solve()
false
19.047619
[ "-from fractions import gcd", "+import sys", "+", "+if sys.version_info < (3, 5):", "+ from fractions import gcd", "+else:", "+ from math import gcd" ]
false
0.169362
0.077204
2.193696
[ "s568705523", "s052661107" ]
u708255304
p02579
python
s776083640
s101374005
846
762
89,304
115,172
Accepted
Accepted
9.93
from collections import deque H, W = list(map(int, input().split())) # H行, W列 CY, CX = [int(x)-1 for x in input().split()] # 魔法使いの初期値 DY, DX = [int(x)-1 for x in input().split()] # 目的地 gridgraph = [eval(input()) for _ in range(H)] # print(gridgraph) q = deque() q.append((CY, CX)) # スタート地点 # 各頂点について2*2の幅優先する? adjacent = [[1, 0], [0, 1], [-1, 0], [0, -1]] # 上下左右 distant = [[10**10]*W for _ in range(H)] distant[CY][CX] = 0 warp_y = list(range(-2, 3, 1)) warp_x = list(range(-2, 3, 1)) while len(q): cy, cx = q.popleft() # 現在位置 for dy, dx in adjacent: # 新しい位置 ny = cy+dy nx = cx+dx if ny < 0 or ny >= H or nx < 0 or nx >= W: continue # 道の場合 if gridgraph[ny][nx] == "." and distant[ny][nx] > distant[cy][cx]: # 道の場合はコスト0で移動できる distant[ny][nx] = distant[cy][cx] q.appendleft((ny, nx)) # 周囲5*5の道に+1で到達する for i in warp_y: for j in warp_x: target_y, target_x = cy+i, cx+j if target_y < 0 or target_y >= H or target_x < 0 or target_x >= W: continue else: if gridgraph[target_y][target_x] == "." and distant[target_y][target_x] > distant[cy][cx]+1: distant[target_y][target_x] = distant[cy][cx]+1 q.append((target_y, target_x)) if distant[DY][DX] == 10**10: print((-1)) else: print((distant[DY][DX]))
from collections import deque H, W = list(map(int, input().split())) CY, CX = [int(x)-1 for x in input().split()] DY, DX = [int(x)-1 for x in input().split()] gridgraph = [eval(input()) for _ in range(H)] q = deque() q.append([CY, CX]) # 更新されるなら追加 adjacent = [[1, 0], [0, 1], [-1, 0], [0, -1]] INF = float("inf") distant = [[INF]*W for _ in range(H)] distant[CY][CX] = 0 while len(q): cy, cx = q.popleft() for dy, dx in adjacent: ny, nx = cy+dy, cx+dx if ny < 0 or ny >= H or nx < 0 or nx >= W: continue if gridgraph[ny][nx] == "." and distant[ny][nx] > distant[cy][cx]: distant[ny][nx] = distant[cy][cx] q.appendleft([ny, nx]) for i in range(-2, 3, 1): for j in range(-2, 3, 1): target_y, target_x = cy+i, cx+j if target_y < 0 or target_y >= H or target_x < 0 or target_x >= W: continue if gridgraph[target_y][target_x] == "." and distant[target_y][target_x] > distant[cy][cx]+1: distant[target_y][target_x] = distant[cy][cx]+1 q.append([target_y, target_x]) if distant[DY][DX] == INF: print((-1)) else: print((distant[DY][DX]))
43
34
1,474
1,230
from collections import deque H, W = list(map(int, input().split())) # H行, W列 CY, CX = [int(x) - 1 for x in input().split()] # 魔法使いの初期値 DY, DX = [int(x) - 1 for x in input().split()] # 目的地 gridgraph = [eval(input()) for _ in range(H)] # print(gridgraph) q = deque() q.append((CY, CX)) # スタート地点 # 各頂点について2*2の幅優先する? adjacent = [[1, 0], [0, 1], [-1, 0], [0, -1]] # 上下左右 distant = [[10**10] * W for _ in range(H)] distant[CY][CX] = 0 warp_y = list(range(-2, 3, 1)) warp_x = list(range(-2, 3, 1)) while len(q): cy, cx = q.popleft() # 現在位置 for dy, dx in adjacent: # 新しい位置 ny = cy + dy nx = cx + dx if ny < 0 or ny >= H or nx < 0 or nx >= W: continue # 道の場合 if gridgraph[ny][nx] == "." and distant[ny][nx] > distant[cy][cx]: # 道の場合はコスト0で移動できる distant[ny][nx] = distant[cy][cx] q.appendleft((ny, nx)) # 周囲5*5の道に+1で到達する for i in warp_y: for j in warp_x: target_y, target_x = cy + i, cx + j if target_y < 0 or target_y >= H or target_x < 0 or target_x >= W: continue else: if ( gridgraph[target_y][target_x] == "." and distant[target_y][target_x] > distant[cy][cx] + 1 ): distant[target_y][target_x] = distant[cy][cx] + 1 q.append((target_y, target_x)) if distant[DY][DX] == 10**10: print((-1)) else: print((distant[DY][DX]))
from collections import deque H, W = list(map(int, input().split())) CY, CX = [int(x) - 1 for x in input().split()] DY, DX = [int(x) - 1 for x in input().split()] gridgraph = [eval(input()) for _ in range(H)] q = deque() q.append([CY, CX]) # 更新されるなら追加 adjacent = [[1, 0], [0, 1], [-1, 0], [0, -1]] INF = float("inf") distant = [[INF] * W for _ in range(H)] distant[CY][CX] = 0 while len(q): cy, cx = q.popleft() for dy, dx in adjacent: ny, nx = cy + dy, cx + dx if ny < 0 or ny >= H or nx < 0 or nx >= W: continue if gridgraph[ny][nx] == "." and distant[ny][nx] > distant[cy][cx]: distant[ny][nx] = distant[cy][cx] q.appendleft([ny, nx]) for i in range(-2, 3, 1): for j in range(-2, 3, 1): target_y, target_x = cy + i, cx + j if target_y < 0 or target_y >= H or target_x < 0 or target_x >= W: continue if ( gridgraph[target_y][target_x] == "." and distant[target_y][target_x] > distant[cy][cx] + 1 ): distant[target_y][target_x] = distant[cy][cx] + 1 q.append([target_y, target_x]) if distant[DY][DX] == INF: print((-1)) else: print((distant[DY][DX]))
false
20.930233
[ "-H, W = list(map(int, input().split())) # H行, W列", "-CY, CX = [int(x) - 1 for x in input().split()] # 魔法使いの初期値", "-DY, DX = [int(x) - 1 for x in input().split()] # 目的地", "+H, W = list(map(int, input().split()))", "+CY, CX = [int(x) - 1 for x in input().split()]", "+DY, DX = [int(x) - 1 for x in input().split()]", "-# print(gridgraph)", "-q.append((CY, CX)) # スタート地点", "-# 各頂点について2*2の幅優先する?", "-adjacent = [[1, 0], [0, 1], [-1, 0], [0, -1]] # 上下左右", "-distant = [[10**10] * W for _ in range(H)]", "+q.append([CY, CX])", "+# 更新されるなら追加", "+adjacent = [[1, 0], [0, 1], [-1, 0], [0, -1]]", "+INF = float(\"inf\")", "+distant = [[INF] * W for _ in range(H)]", "-warp_y = list(range(-2, 3, 1))", "-warp_x = list(range(-2, 3, 1))", "- cy, cx = q.popleft() # 現在位置", "+ cy, cx = q.popleft()", "- # 新しい位置", "- ny = cy + dy", "- nx = cx + dx", "+ ny, nx = cy + dy, cx + dx", "- # 道の場合", "- # 道の場合はコスト0で移動できる", "- q.appendleft((ny, nx))", "- # 周囲5*5の道に+1で到達する", "- for i in warp_y:", "- for j in warp_x:", "+ q.appendleft([ny, nx])", "+ for i in range(-2, 3, 1):", "+ for j in range(-2, 3, 1):", "- else:", "- if (", "- gridgraph[target_y][target_x] == \".\"", "- and distant[target_y][target_x] > distant[cy][cx] + 1", "- ):", "- distant[target_y][target_x] = distant[cy][cx] + 1", "- q.append((target_y, target_x))", "-if distant[DY][DX] == 10**10:", "+ if (", "+ gridgraph[target_y][target_x] == \".\"", "+ and distant[target_y][target_x] > distant[cy][cx] + 1", "+ ):", "+ distant[target_y][target_x] = distant[cy][cx] + 1", "+ q.append([target_y, target_x])", "+if distant[DY][DX] == INF:" ]
false
0.049893
0.046452
1.074061
[ "s776083640", "s101374005" ]
u645250356
p03470
python
s820103667
s329420997
192
147
38,256
77,252
Accepted
Accepted
23.44
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools sys.setrecursionlimit(10**8) mod = 10**9+7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpln(n): return list(int(sys.stdin.readline()) for i in range(n)) n = inp() a = inpln(n) print((len(set(a))))
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) n = inp() a = [inp() for _ in range(n)] print((len(set(a))))
12
12
401
376
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools sys.setrecursionlimit(10**8) mod = 10**9 + 7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpln(n): return list(int(sys.stdin.readline()) for i in range(n)) n = inp() a = inpln(n) print((len(set(a))))
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools, fractions sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) n = inp() a = [inp() for _ in range(n)] print((len(set(a))))
false
0
[ "-import sys, bisect, math, itertools", "+import sys, bisect, math, itertools, fractions", "+INF = float(\"inf\")", "-def inpln(n):", "- return list(int(sys.stdin.readline()) for i in range(n))", "-", "-", "-a = inpln(n)", "+a = [inp() for _ in range(n)]" ]
false
0.007442
0.033828
0.219986
[ "s820103667", "s329420997" ]
u026155812
p02793
python
s237164493
s437787474
1,564
843
74,288
10,704
Accepted
Accepted
46.1
from math import gcd from functools import reduce N = int(eval(input())) A = [int(i) for i in input().split()] mod = 10**9 + 7 def lcm_base(x, y): return (x * y) // gcd(x, y) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) num = lcm_list(A) ans = 0 for a in A: ans += (num * pow(a, mod-2, mod))%mod ans %= mod print(ans)
from math import gcd from functools import reduce N = int(eval(input())) A = [int(i) for i in input().split()] mod = 10**9 + 7 def lcm_base(x, y): return (x * y) // gcd(x, y) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) num = lcm_list(A)%mod ans = 0 for a in A: ans += (num * pow(a, mod-2, mod))%mod ans %= mod print(ans)
20
20
362
366
from math import gcd from functools import reduce N = int(eval(input())) A = [int(i) for i in input().split()] mod = 10**9 + 7 def lcm_base(x, y): return (x * y) // gcd(x, y) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) num = lcm_list(A) ans = 0 for a in A: ans += (num * pow(a, mod - 2, mod)) % mod ans %= mod print(ans)
from math import gcd from functools import reduce N = int(eval(input())) A = [int(i) for i in input().split()] mod = 10**9 + 7 def lcm_base(x, y): return (x * y) // gcd(x, y) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) num = lcm_list(A) % mod ans = 0 for a in A: ans += (num * pow(a, mod - 2, mod)) % mod ans %= mod print(ans)
false
0
[ "-num = lcm_list(A)", "+num = lcm_list(A) % mod" ]
false
0.03786
0.03963
0.955345
[ "s237164493", "s437787474" ]
u863442865
p02912
python
s432754258
s749728687
399
150
68,460
14,636
Accepted
Accepted
62.41
def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque #from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby #from itertools import product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush from math import floor, ceil #from operator import itemgetter #inf = 10**17 #mod = 10**9 + 7 n,m = list(map(int, input().split())) a = list(map(int, input().split())) for i in range(n): a[i] = -a[i] heapify(a) for _ in range(m): b = heappop(a) b = -(-b // 2) heappush(a, b) print((-sum(a))) if __name__ == '__main__': main()
def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque #from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush from math import floor, ceil #from operator import itemgetter #inf = 10**17 #mod = 10**9 + 7 n,m = list(map(int, input().split())) a = list(map(int, input().split())) for i in range(n): a[i] *= -1 heapify(a) while m: b = heappop(a) b = (-b)//2 heappush(a, -b) m -= 1 print((-sum(a))) if __name__ == '__main__': main()
32
30
810
781
def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque # from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby # from itertools import product from bisect import bisect_left, bisect_right from heapq import heapify, heappop, heappush from math import floor, ceil # from operator import itemgetter # inf = 10**17 # mod = 10**9 + 7 n, m = list(map(int, input().split())) a = list(map(int, input().split())) for i in range(n): a[i] = -a[i] heapify(a) for _ in range(m): b = heappop(a) b = -(-b // 2) heappush(a, b) print((-sum(a))) if __name__ == "__main__": main()
def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque # from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left, bisect_right from heapq import heapify, heappop, heappush from math import floor, ceil # from operator import itemgetter # inf = 10**17 # mod = 10**9 + 7 n, m = list(map(int, input().split())) a = list(map(int, input().split())) for i in range(n): a[i] *= -1 heapify(a) while m: b = heappop(a) b = (-b) // 2 heappush(a, -b) m -= 1 print((-sum(a))) if __name__ == "__main__": main()
false
6.25
[ "- from itertools import combinations, permutations, accumulate, groupby", "-", "- # from itertools import product", "+ from itertools import combinations, permutations, accumulate, groupby, product", "- a[i] = -a[i]", "+ a[i] *= -1", "- for _ in range(m):", "+ while m:", "- b = -(-b // 2)", "- heappush(a, b)", "+ b = (-b) // 2", "+ heappush(a, -b)", "+ m -= 1" ]
false
0.045411
0.140288
0.323697
[ "s432754258", "s749728687" ]
u156815136
p02603
python
s984811033
s879400801
182
38
76,912
10,404
Accepted
Accepted
79.12
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations,permutations,accumulate # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Counter import decimal import re #import bisect # # d = m - k[i] - k[j] # if kk[bisect.bisect_right(kk,d) - 1] == d: # # # # pythonで無理なときは、pypyでやると正解するかも!! # # # my_round_int = lambda x:np.round((x*2 + 1)//2) # 四捨五入 import sys sys.setrecursionlimit(10000000) mod = 10**9 + 7 #mod = 9982443453 def readInts(): return list(map(int,input().split())) def I(): return int(eval(input())) n = I() A = readInts() money = 1000 kabu = 0 for i in range(1,n): if A[i-1] < A[i]: kabu = money // A[i-1] money -= kabu * A[i-1] money += kabu * A[i] kabu = 0 #print(money,kabu) print(money)
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations,permutations,accumulate, product # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Counter import decimal import re import math import bisect # # # # pythonで無理なときは、pypyでやると正解するかも!! # # # my_round_int = lambda x:np.round((x*2 + 1)//2) # 四捨五入g # # インデックス系 # int min_y = max(0, i - 2), max_y = min(h - 1, i + 2); # int min_x = max(0, j - 2), max_x = min(w - 1, j + 2); # # import sys sys.setrecursionlimit(10000000) mod = 10**9 + 7 #mod = 9982443453 #mod = 998244353 from sys import stdin readline = stdin.readline def readInts(): return list(map(int,readline().split())) def readTuples(): return tuple(map(int,readline().split())) def I(): return int(readline()) n = I() A = readInts() ans = 1000 money = 1000 kabu = 0 for i in range(1,n): if A[i-1] < A[i]: kabu = money // A[i-1] money -= kabu * A[i-1] money += kabu * A[i] kabu = 0 print(money)
41
51
966
1,174
# from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations, permutations, accumulate # (string,3) 3回 # from collections import deque from collections import deque, defaultdict, Counter import decimal import re # import bisect # # d = m - k[i] - k[j] # if kk[bisect.bisect_right(kk,d) - 1] == d: # # # # pythonで無理なときは、pypyでやると正解するかも!! # # # my_round_int = lambda x:np.round((x*2 + 1)//2) # 四捨五入 import sys sys.setrecursionlimit(10000000) mod = 10**9 + 7 # mod = 9982443453 def readInts(): return list(map(int, input().split())) def I(): return int(eval(input())) n = I() A = readInts() money = 1000 kabu = 0 for i in range(1, n): if A[i - 1] < A[i]: kabu = money // A[i - 1] money -= kabu * A[i - 1] money += kabu * A[i] kabu = 0 # print(money,kabu) print(money)
# from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations, permutations, accumulate, product # (string,3) 3回 # from collections import deque from collections import deque, defaultdict, Counter import decimal import re import math import bisect # # # # pythonで無理なときは、pypyでやると正解するかも!! # # # my_round_int = lambda x:np.round((x*2 + 1)//2) # 四捨五入g # # インデックス系 # int min_y = max(0, i - 2), max_y = min(h - 1, i + 2); # int min_x = max(0, j - 2), max_x = min(w - 1, j + 2); # # import sys sys.setrecursionlimit(10000000) mod = 10**9 + 7 # mod = 9982443453 # mod = 998244353 from sys import stdin readline = stdin.readline def readInts(): return list(map(int, readline().split())) def readTuples(): return tuple(map(int, readline().split())) def I(): return int(readline()) n = I() A = readInts() ans = 1000 money = 1000 kabu = 0 for i in range(1, n): if A[i - 1] < A[i]: kabu = money // A[i - 1] money -= kabu * A[i - 1] money += kabu * A[i] kabu = 0 print(money)
false
19.607843
[ "-from itertools import combinations, permutations, accumulate # (string,3) 3回", "+from itertools import combinations, permutations, accumulate, product # (string,3) 3回", "+import math", "+import bisect", "-# import bisect", "-#", "-# d = m - k[i] - k[j]", "-# if kk[bisect.bisect_right(kk,d) - 1] == d:", "-# 四捨五入", "+# 四捨五入g", "+#", "+# インデックス系", "+# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);", "+# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);", "+#", "+#", "+# mod = 998244353", "+from sys import stdin", "+", "+readline = stdin.readline", "+", "+", "- return list(map(int, input().split()))", "+ return list(map(int, readline().split()))", "+", "+", "+def readTuples():", "+ return tuple(map(int, readline().split()))", "- return int(eval(input()))", "+ return int(readline())", "+ans = 1000", "- # print(money,kabu)" ]
false
0.042129
0.04192
1.004993
[ "s984811033", "s879400801" ]
u077291787
p03721
python
s896786011
s209946964
312
196
28,640
30,172
Accepted
Accepted
37.18
# ABC061C - Big Array import sys input = sys.stdin.readline def main(): n, k = list(map(int, input().rstrip().split())) arr = sorted([list(map(int, input().rstrip().split())) for _ in range(n)]) cur, cnt, ans = 0, 0, 0 for i, j in arr: ans = i cnt += j if cnt >= k: break print(ans) if __name__ == "__main__": main()
# ABC061C - Big Array import sys input = sys.stdin.readline def main(): n, k = list(map(int, input().rstrip().split())) arr = [list(map(int, input().rstrip().split())) for _ in range(n)] memo = [0] * (10 ** 5 + 1) for i, j in arr: memo[i] += j cnt = 0 for i, j in enumerate(memo): cnt += j if cnt >= k: print(i) break if __name__ == "__main__": main()
18
20
396
449
# ABC061C - Big Array import sys input = sys.stdin.readline def main(): n, k = list(map(int, input().rstrip().split())) arr = sorted([list(map(int, input().rstrip().split())) for _ in range(n)]) cur, cnt, ans = 0, 0, 0 for i, j in arr: ans = i cnt += j if cnt >= k: break print(ans) if __name__ == "__main__": main()
# ABC061C - Big Array import sys input = sys.stdin.readline def main(): n, k = list(map(int, input().rstrip().split())) arr = [list(map(int, input().rstrip().split())) for _ in range(n)] memo = [0] * (10**5 + 1) for i, j in arr: memo[i] += j cnt = 0 for i, j in enumerate(memo): cnt += j if cnt >= k: print(i) break if __name__ == "__main__": main()
false
10
[ "- arr = sorted([list(map(int, input().rstrip().split())) for _ in range(n)])", "- cur, cnt, ans = 0, 0, 0", "+ arr = [list(map(int, input().rstrip().split())) for _ in range(n)]", "+ memo = [0] * (10**5 + 1)", "- ans = i", "+ memo[i] += j", "+ cnt = 0", "+ for i, j in enumerate(memo):", "+ print(i)", "- print(ans)" ]
false
0.035775
0.055935
0.639587
[ "s896786011", "s209946964" ]
u191874006
p02702
python
s795824999
s610406932
223
154
98,732
100,404
Accepted
Accepted
30.94
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations mod = 10**9 + 7 inf = float('inf') def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) s = eval(input()) n = len(s) t = [] for i in range(n): t.append(int(s[i])*pow(10,n-i-1,2019)) t = list(accumulate(t)) u = [i % 2019 for i in t] u = list(Counter(u).items()) ans = 0 for i,j in u: if i == 0: ans += j if j >= 2: ans += j*(j-1) // 2 print(ans)
#!/usr/bin/env python3 #D import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations mod = 10**9 + 7 inf = float('inf') def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) s = eval(input()) n = len(s) t = [] for i in range(n): t.append(int(s[i])*pow(10, (n-i-1), 2019) % 2019) t = list(accumulate(t)) t = [0] + [i % 2019 for i in t] ans = 0 cnt = defaultdict(int) for i in range(n+1): ans += cnt[t[i]] cnt[t[i]] += 1 print(ans)
34
33
852
837
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop, heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations mod = 10**9 + 7 inf = float("inf") def I(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) s = eval(input()) n = len(s) t = [] for i in range(n): t.append(int(s[i]) * pow(10, n - i - 1, 2019)) t = list(accumulate(t)) u = [i % 2019 for i in t] u = list(Counter(u).items()) ans = 0 for i, j in u: if i == 0: ans += j if j >= 2: ans += j * (j - 1) // 2 print(ans)
#!/usr/bin/env python3 # D import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop, heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations mod = 10**9 + 7 inf = float("inf") def I(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) s = eval(input()) n = len(s) t = [] for i in range(n): t.append(int(s[i]) * pow(10, (n - i - 1), 2019) % 2019) t = list(accumulate(t)) t = [0] + [i % 2019 for i in t] ans = 0 cnt = defaultdict(int) for i in range(n + 1): ans += cnt[t[i]] cnt[t[i]] += 1 print(ans)
false
2.941176
[ "+# D", "- t.append(int(s[i]) * pow(10, n - i - 1, 2019))", "+ t.append(int(s[i]) * pow(10, (n - i - 1), 2019) % 2019)", "-u = [i % 2019 for i in t]", "-u = list(Counter(u).items())", "+t = [0] + [i % 2019 for i in t]", "-for i, j in u:", "- if i == 0:", "- ans += j", "- if j >= 2:", "- ans += j * (j - 1) // 2", "+cnt = defaultdict(int)", "+for i in range(n + 1):", "+ ans += cnt[t[i]]", "+ cnt[t[i]] += 1" ]
false
0.048216
0.047237
1.020734
[ "s795824999", "s610406932" ]
u631277801
p03839
python
s287104409
s383406082
225
204
25,884
17,096
Accepted
Accepted
9.33
import sys stdin = sys.stdin def li(): return [int(x) for x in stdin.readline().split()] def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return [float(x) for x in stdin.readline().split()] def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(ns()) def nf(): return float(ns()) from itertools import accumulate n,k = li() a = li() a_cum = list(accumulate([0] + a)) a_pl = [ai if ai>0 else 0 for ai in a] a_left = list(accumulate([0] + a_pl)) a_right = list(accumulate([0] + a_pl[::-1])) ans = 0 for i in range(n-k+1): # a[i:i+k]を黒にするとき cand = a_cum[i+k] - a_cum[i] cand += (a_left[i] + a_right[n-(i+k)]) ans = max(ans,cand) # a[i:i+k]を白にするとき cand = 0 cand += (a_left[i] + a_right[n-(i+k)]) ans = max(ans,cand) print(ans)
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return map(int, stdin.readline().split()) def li_(): return map(lambda x: int(x)-1, stdin.readline().split()) def lf(): return 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,k = li() a = list(li()) acc_all = [0] acc_pos = [0] for ai in a: if ai > 0: acc_all.append(acc_all[-1] + ai) acc_pos.append(acc_pos[-1] + ai) else: acc_all.append(acc_all[-1] + ai) acc_pos.append(acc_pos[-1]) ans = 0 for st in range(n-k+1): black = (acc_all[st+k] - acc_all[st])\ + (acc_pos[n] - acc_pos[st+k])\ + (acc_pos[st] - acc_pos[0]) white = (acc_pos[n] - acc_pos[st+k])\ + (acc_pos[st] - acc_pos[0]) ans = max(ans, black, white) print(ans)
38
40
920
1,025
import sys stdin = sys.stdin def li(): return [int(x) for x in stdin.readline().split()] def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return [float(x) for x in stdin.readline().split()] def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(ns()) def nf(): return float(ns()) from itertools import accumulate n, k = li() a = li() a_cum = list(accumulate([0] + a)) a_pl = [ai if ai > 0 else 0 for ai in a] a_left = list(accumulate([0] + a_pl)) a_right = list(accumulate([0] + a_pl[::-1])) ans = 0 for i in range(n - k + 1): # a[i:i+k]を黒にするとき cand = a_cum[i + k] - a_cum[i] cand += a_left[i] + a_right[n - (i + k)] ans = max(ans, cand) # a[i:i+k]を白にするとき cand = 0 cand += a_left[i] + a_right[n - (i + k)] ans = max(ans, cand) print(ans)
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return map(int, stdin.readline().split()) def li_(): return map(lambda x: int(x) - 1, stdin.readline().split()) def lf(): return 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, k = li() a = list(li()) acc_all = [0] acc_pos = [0] for ai in a: if ai > 0: acc_all.append(acc_all[-1] + ai) acc_pos.append(acc_pos[-1] + ai) else: acc_all.append(acc_all[-1] + ai) acc_pos.append(acc_pos[-1]) ans = 0 for st in range(n - k + 1): black = ( (acc_all[st + k] - acc_all[st]) + (acc_pos[n] - acc_pos[st + k]) + (acc_pos[st] - acc_pos[0]) ) white = (acc_pos[n] - acc_pos[st + k]) + (acc_pos[st] - acc_pos[0]) ans = max(ans, black, white) print(ans)
false
5
[ "+sys.setrecursionlimit(10**5)", "- return [int(x) for x in stdin.readline().split()]", "+ return map(int, stdin.readline().split())", "- return [int(x) - 1 for x in stdin.readline().split()]", "+ return map(lambda x: int(x) - 1, stdin.readline().split())", "- return [float(x) for x in stdin.readline().split()]", "+ return map(float, stdin.readline().split())", "- return int(ns())", "+ return int(stdin.readline())", "- return float(ns())", "+ return float(stdin.readline())", "-from itertools import accumulate", "-", "-a = li()", "-a_cum = list(accumulate([0] + a))", "-a_pl = [ai if ai > 0 else 0 for ai in a]", "-a_left = list(accumulate([0] + a_pl))", "-a_right = list(accumulate([0] + a_pl[::-1]))", "+a = list(li())", "+acc_all = [0]", "+acc_pos = [0]", "+for ai in a:", "+ if ai > 0:", "+ acc_all.append(acc_all[-1] + ai)", "+ acc_pos.append(acc_pos[-1] + ai)", "+ else:", "+ acc_all.append(acc_all[-1] + ai)", "+ acc_pos.append(acc_pos[-1])", "-for i in range(n - k + 1):", "- # a[i:i+k]を黒にするとき", "- cand = a_cum[i + k] - a_cum[i]", "- cand += a_left[i] + a_right[n - (i + k)]", "- ans = max(ans, cand)", "- # a[i:i+k]を白にするとき", "- cand = 0", "- cand += a_left[i] + a_right[n - (i + k)]", "- ans = max(ans, cand)", "+for st in range(n - k + 1):", "+ black = (", "+ (acc_all[st + k] - acc_all[st])", "+ + (acc_pos[n] - acc_pos[st + k])", "+ + (acc_pos[st] - acc_pos[0])", "+ )", "+ white = (acc_pos[n] - acc_pos[st + k]) + (acc_pos[st] - acc_pos[0])", "+ ans = max(ans, black, white)" ]
false
0.049778
0.049536
1.004877
[ "s287104409", "s383406082" ]
u638795007
p03295
python
s579023174
s734692898
371
235
18,196
17,812
Accepted
Accepted
36.66
sortsecond = lambda val: val[1] N, M = list(map(int, input().split())) l=[] for i in range(M): t=input().split() l.append((int(t[0]),int(t[1]))) l.sort(key=sortsecond) ans = int(0) count = int(0) br = int(0) for i in range(M): if br<l[i][0]+1: count +=1 br = l[i][1] ans = count print(ans)
def examD(): N, M = LI() right = defaultdict(int) for _ in range(M): a, b = LI() right[b] = max(right[b],a) ans = 0; cur = 0 for i in range(1,N+1): if right[i]>cur: ans +=1 cur = i-1 print(ans) import sys,copy,bisect,itertools,heapq,math from heapq import heappop,heappush,heapify from collections import Counter,defaultdict,deque def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) def LSI(): return list(map(str,sys.stdin.readline().split())) def LS(): return sys.stdin.readline().split() def SI(): return sys.stdin.readline().strip() mod = 10**9 + 7 inf = float('inf') examD()
19
25
332
729
sortsecond = lambda val: val[1] N, M = list(map(int, input().split())) l = [] for i in range(M): t = input().split() l.append((int(t[0]), int(t[1]))) l.sort(key=sortsecond) ans = int(0) count = int(0) br = int(0) for i in range(M): if br < l[i][0] + 1: count += 1 br = l[i][1] ans = count print(ans)
def examD(): N, M = LI() right = defaultdict(int) for _ in range(M): a, b = LI() right[b] = max(right[b], a) ans = 0 cur = 0 for i in range(1, N + 1): if right[i] > cur: ans += 1 cur = i - 1 print(ans) import sys, copy, bisect, itertools, heapq, math from heapq import heappop, heappush, heapify from collections import Counter, defaultdict, deque def I(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LSI(): return list(map(str, sys.stdin.readline().split())) def LS(): return sys.stdin.readline().split() def SI(): return sys.stdin.readline().strip() mod = 10**9 + 7 inf = float("inf") examD()
false
24
[ "-sortsecond = lambda val: val[1]", "-N, M = list(map(int, input().split()))", "-l = []", "-for i in range(M):", "- t = input().split()", "- l.append((int(t[0]), int(t[1])))", "-l.sort(key=sortsecond)", "-ans = int(0)", "-count = int(0)", "-br = int(0)", "-for i in range(M):", "- if br < l[i][0] + 1:", "- count += 1", "- br = l[i][1]", "-ans = count", "-print(ans)", "+def examD():", "+ N, M = LI()", "+ right = defaultdict(int)", "+ for _ in range(M):", "+ a, b = LI()", "+ right[b] = max(right[b], a)", "+ ans = 0", "+ cur = 0", "+ for i in range(1, N + 1):", "+ if right[i] > cur:", "+ ans += 1", "+ cur = i - 1", "+ print(ans)", "+", "+", "+import sys, copy, bisect, itertools, heapq, math", "+from heapq import heappop, heappush, heapify", "+from collections import Counter, defaultdict, deque", "+", "+", "+def I():", "+ return int(sys.stdin.readline())", "+", "+", "+def LI():", "+ return list(map(int, sys.stdin.readline().split()))", "+", "+", "+def LSI():", "+ return list(map(str, sys.stdin.readline().split()))", "+", "+", "+def LS():", "+ return sys.stdin.readline().split()", "+", "+", "+def SI():", "+ return sys.stdin.readline().strip()", "+", "+", "+mod = 10**9 + 7", "+inf = float(\"inf\")", "+examD()" ]
false
0.036747
0.053721
0.684036
[ "s579023174", "s734692898" ]
u318029285
p03673
python
s125998874
s147989155
200
177
29,460
29,764
Accepted
Accepted
11.5
n = int(eval(input())) a = [int(i) for i in input().split()] length = len(a) b = [0] * length center = length // 2 if len(a) % 2 != 0: before = center for i in range(len(a)): if i == 0: b[center] = a[i] else: if i % 2 != 0: before = before + i else: before = before - i b[before] = a[i] else: before = center for i in range(len(a)): if i == 0: b[center] = a[i] else: if i % 2 != 0: before = before - i else: before = before + i b[before] = a[i] L = [str(v) for v in b] L = ' '.join(L) print(L)
n = int(eval(input())) a = [int(i) for i in input().split()] b = [0] * n center = n // 2 before = center if n % 2 != 0: for i in range(len(a)): if i % 2 != 0: before = before + i else: before = before - i b[before] = a[i] else: for i in range(len(a)): if i % 2 != 0: before = before - i else: before = before + i b[before] = a[i] b = " ".join(list(map(str, b))) print(b)
34
24
733
495
n = int(eval(input())) a = [int(i) for i in input().split()] length = len(a) b = [0] * length center = length // 2 if len(a) % 2 != 0: before = center for i in range(len(a)): if i == 0: b[center] = a[i] else: if i % 2 != 0: before = before + i else: before = before - i b[before] = a[i] else: before = center for i in range(len(a)): if i == 0: b[center] = a[i] else: if i % 2 != 0: before = before - i else: before = before + i b[before] = a[i] L = [str(v) for v in b] L = " ".join(L) print(L)
n = int(eval(input())) a = [int(i) for i in input().split()] b = [0] * n center = n // 2 before = center if n % 2 != 0: for i in range(len(a)): if i % 2 != 0: before = before + i else: before = before - i b[before] = a[i] else: for i in range(len(a)): if i % 2 != 0: before = before - i else: before = before + i b[before] = a[i] b = " ".join(list(map(str, b))) print(b)
false
29.411765
[ "-length = len(a)", "-b = [0] * length", "-center = length // 2", "-if len(a) % 2 != 0:", "- before = center", "+b = [0] * n", "+center = n // 2", "+before = center", "+if n % 2 != 0:", "- if i == 0:", "- b[center] = a[i]", "+ if i % 2 != 0:", "+ before = before + i", "- if i % 2 != 0:", "- before = before + i", "- else:", "- before = before - i", "- b[before] = a[i]", "+ before = before - i", "+ b[before] = a[i]", "- before = center", "- if i == 0:", "- b[center] = a[i]", "+ if i % 2 != 0:", "+ before = before - i", "- if i % 2 != 0:", "- before = before - i", "- else:", "- before = before + i", "- b[before] = a[i]", "-L = [str(v) for v in b]", "-L = \" \".join(L)", "-print(L)", "+ before = before + i", "+ b[before] = a[i]", "+b = \" \".join(list(map(str, b)))", "+print(b)" ]
false
0.110987
0.101656
1.091798
[ "s125998874", "s147989155" ]
u186838327
p03828
python
s851443948
s307687814
260
206
41,584
41,964
Accepted
Accepted
20.77
import math n = int(eval(input())) def div(m): d = {} temp = int(math.sqrt(m))+1 for i in range(2, temp): while m%i== 0: m //= i if i in d: d[i] += 1 else: d[i] = 1 if d == {}: d[m] = 1 else: if m in d: d[m] += 1 elif m != 1: d[m] =1 return d from collections import Counter d = {} for i in range(2, n+1): d = dict(Counter(d)+Counter(div(i))) #print(d) ans = 1 for i in list(d.values()): ans *= (i+1) ans %= 10**9+7 print(ans)
import math def factorize(n): d = {} temp = int(math.sqrt(n))+1 for i in range(2, temp): while n%i== 0: n //= i if i in d: d[i] += 1 else: d[i] = 1 if d == {}: d[n] = 1 else: if n in d: d[n] += 1 elif n != 1: d[n] =1 return d n = int(eval(input())) if n == 1: print((1)) exit() mod = 10**9+7 D = {} for i in range(2, n+1): d = factorize(i) for k, v in list(d.items()): if k not in D: D[k] = v else: D[k] += v ans = 1 for v in list(D.values()): ans *= (v+1) ans %= mod print(ans)
34
41
532
714
import math n = int(eval(input())) def div(m): d = {} temp = int(math.sqrt(m)) + 1 for i in range(2, temp): while m % i == 0: m //= i if i in d: d[i] += 1 else: d[i] = 1 if d == {}: d[m] = 1 else: if m in d: d[m] += 1 elif m != 1: d[m] = 1 return d from collections import Counter d = {} for i in range(2, n + 1): d = dict(Counter(d) + Counter(div(i))) # print(d) ans = 1 for i in list(d.values()): ans *= i + 1 ans %= 10**9 + 7 print(ans)
import math def factorize(n): d = {} temp = int(math.sqrt(n)) + 1 for i in range(2, temp): while n % i == 0: n //= i if i in d: d[i] += 1 else: d[i] = 1 if d == {}: d[n] = 1 else: if n in d: d[n] += 1 elif n != 1: d[n] = 1 return d n = int(eval(input())) if n == 1: print((1)) exit() mod = 10**9 + 7 D = {} for i in range(2, n + 1): d = factorize(i) for k, v in list(d.items()): if k not in D: D[k] = v else: D[k] += v ans = 1 for v in list(D.values()): ans *= v + 1 ans %= mod print(ans)
false
17.073171
[ "-n = int(eval(input()))", "-", "-def div(m):", "+def factorize(n):", "- temp = int(math.sqrt(m)) + 1", "+ temp = int(math.sqrt(n)) + 1", "- while m % i == 0:", "- m //= i", "+ while n % i == 0:", "+ n //= i", "- d[m] = 1", "+ d[n] = 1", "- if m in d:", "- d[m] += 1", "- elif m != 1:", "- d[m] = 1", "+ if n in d:", "+ d[n] += 1", "+ elif n != 1:", "+ d[n] = 1", "-from collections import Counter", "-", "-d = {}", "+n = int(eval(input()))", "+if n == 1:", "+ print((1))", "+ exit()", "+mod = 10**9 + 7", "+D = {}", "- d = dict(Counter(d) + Counter(div(i)))", "-# print(d)", "+ d = factorize(i)", "+ for k, v in list(d.items()):", "+ if k not in D:", "+ D[k] = v", "+ else:", "+ D[k] += v", "-for i in list(d.values()):", "- ans *= i + 1", "- ans %= 10**9 + 7", "+for v in list(D.values()):", "+ ans *= v + 1", "+ ans %= mod" ]
false
0.05614
0.126252
0.444662
[ "s851443948", "s307687814" ]
u439063038
p03162
python
s415746612
s893472180
463
240
50,284
100,184
Accepted
Accepted
48.16
N = int(eval(input())) abc = [list(map(int, input().split())) for _ in range(N)] dp = [[0, 0, 0]] * (N+1) for i in range(1, N+1): tmp1 = max([dp[i-1][1]+abc[i-1][0], dp[i-1][2]+abc[i-1][0]]) tmp2 = max([dp[i-1][0]+abc[i-1][1], dp[i-1][2]+abc[i-1][1]]) tmp3 = max([dp[i-1][0]+abc[i-1][2], dp[i-1][1]+abc[i-1][2]]) dp[i] = [tmp1, tmp2, tmp3] print((max(dp[N])))
N = int(eval(input())) abc = [list(map(int, input().split())) for _ in range(N)] dp = [[0, 0, 0]] * N dp[0] = abc[0] for i in range(1, N): tmp1 = max(dp[i-1][1]+abc[i][0], dp[i-1][2]+abc[i][0]) tmp2 = max(dp[i-1][0]+abc[i][1], dp[i-1][2]+abc[i][1]) tmp3 = max(dp[i-1][0]+abc[i][2], dp[i-1][1]+abc[i][2]) dp[i] = [tmp1, tmp2, tmp3] print((max(dp[N-1])))
12
13
385
376
N = int(eval(input())) abc = [list(map(int, input().split())) for _ in range(N)] dp = [[0, 0, 0]] * (N + 1) for i in range(1, N + 1): tmp1 = max([dp[i - 1][1] + abc[i - 1][0], dp[i - 1][2] + abc[i - 1][0]]) tmp2 = max([dp[i - 1][0] + abc[i - 1][1], dp[i - 1][2] + abc[i - 1][1]]) tmp3 = max([dp[i - 1][0] + abc[i - 1][2], dp[i - 1][1] + abc[i - 1][2]]) dp[i] = [tmp1, tmp2, tmp3] print((max(dp[N])))
N = int(eval(input())) abc = [list(map(int, input().split())) for _ in range(N)] dp = [[0, 0, 0]] * N dp[0] = abc[0] for i in range(1, N): tmp1 = max(dp[i - 1][1] + abc[i][0], dp[i - 1][2] + abc[i][0]) tmp2 = max(dp[i - 1][0] + abc[i][1], dp[i - 1][2] + abc[i][1]) tmp3 = max(dp[i - 1][0] + abc[i][2], dp[i - 1][1] + abc[i][2]) dp[i] = [tmp1, tmp2, tmp3] print((max(dp[N - 1])))
false
7.692308
[ "-dp = [[0, 0, 0]] * (N + 1)", "-for i in range(1, N + 1):", "- tmp1 = max([dp[i - 1][1] + abc[i - 1][0], dp[i - 1][2] + abc[i - 1][0]])", "- tmp2 = max([dp[i - 1][0] + abc[i - 1][1], dp[i - 1][2] + abc[i - 1][1]])", "- tmp3 = max([dp[i - 1][0] + abc[i - 1][2], dp[i - 1][1] + abc[i - 1][2]])", "+dp = [[0, 0, 0]] * N", "+dp[0] = abc[0]", "+for i in range(1, N):", "+ tmp1 = max(dp[i - 1][1] + abc[i][0], dp[i - 1][2] + abc[i][0])", "+ tmp2 = max(dp[i - 1][0] + abc[i][1], dp[i - 1][2] + abc[i][1])", "+ tmp3 = max(dp[i - 1][0] + abc[i][2], dp[i - 1][1] + abc[i][2])", "-print((max(dp[N])))", "+print((max(dp[N - 1])))" ]
false
0.079713
0.042152
1.89106
[ "s415746612", "s893472180" ]
u291628833
p02657
python
s457502693
s648621756
26
24
9,920
9,948
Accepted
Accepted
7.69
from decimal import * a,b = list(map(Decimal,input().split())) print((a*b))
from decimal import * a,b = list(map(Decimal,input().split())) print((int(a*b)))
3
3
69
74
from decimal import * a, b = list(map(Decimal, input().split())) print((a * b))
from decimal import * a, b = list(map(Decimal, input().split())) print((int(a * b)))
false
0
[ "-print((a * b))", "+print((int(a * b)))" ]
false
0.041234
0.103132
0.399822
[ "s457502693", "s648621756" ]
u601393594
p03795
python
s909860627
s593011138
27
24
9,084
9,048
Accepted
Accepted
11.11
# AtCoder abc055 a # 入力 n = int(eval(input())) # 処理 total_pay = n * 800 total_back = (n // 15) * 200 balance = total_pay - total_back # 出力 print(balance)
# AtCoder abc055 a # 入力 n = int(eval(input())) # 処理 # total_pay = n * 800 # total_back = (n // 15) * 200 # balance = total_pay - total_back # 出力 print(((n * 800) - ((n // 15) * 200)))
12
12
170
198
# AtCoder abc055 a # 入力 n = int(eval(input())) # 処理 total_pay = n * 800 total_back = (n // 15) * 200 balance = total_pay - total_back # 出力 print(balance)
# AtCoder abc055 a # 入力 n = int(eval(input())) # 処理 # total_pay = n * 800 # total_back = (n // 15) * 200 # balance = total_pay - total_back # 出力 print(((n * 800) - ((n // 15) * 200)))
false
0
[ "-total_pay = n * 800", "-total_back = (n // 15) * 200", "-balance = total_pay - total_back", "+# total_pay = n * 800", "+# total_back = (n // 15) * 200", "+# balance = total_pay - total_back", "-print(balance)", "+print(((n * 800) - ((n // 15) * 200)))" ]
false
0.12416
0.00592
20.972639
[ "s909860627", "s593011138" ]
u594803920
p02660
python
s391765547
s479491489
853
480
113,576
91,892
Accepted
Accepted
43.73
from numba import jit N = int(eval(input())) """nを素因数分解""" """2以上の整数n => [(素因数, 指数), ...]の2次元リスト""" @jit def factorization(n): arr = [] temp = n for i in range(2, int(n**0.5)+1): if temp%i == 0: cnt = 0 while temp%i == 0: cnt += 1 temp //= i arr.append((i, cnt)) if temp != 1: arr.append((temp, 1)) if arr == []: arr.append((n, 1)) return arr li = factorization(N) ans = 0 for i in li: k = i[1] loop = 1 while True: k -= loop if k>=0: ans += 1 else: break loop += 1 if N==1: print((0)) else: print(ans)
from numba import jit N = int(eval(input())) """nを素因数分解""" """2以上の整数n => [(素因数, 指数), ...]の2次元リスト""" def factorization(n): arr = [] temp = n for i in range(2, int(n**0.5)+1): if temp%i == 0: cnt = 0 while temp%i == 0: cnt += 1 temp //= i arr.append((i, cnt)) if temp != 1: arr.append((temp, 1)) if arr == []: arr.append((n, 1)) return arr li = factorization(N) ans = 0 for i in li: k = i[1] loop = 1 while True: k -= loop if k>=0: ans += 1 else: break loop += 1 if N==1: print((0)) else: print(ans)
39
39
735
731
from numba import jit N = int(eval(input())) """nを素因数分解""" """2以上の整数n => [(素因数, 指数), ...]の2次元リスト""" @jit def factorization(n): arr = [] temp = n for i in range(2, int(n**0.5) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append((i, cnt)) if temp != 1: arr.append((temp, 1)) if arr == []: arr.append((n, 1)) return arr li = factorization(N) ans = 0 for i in li: k = i[1] loop = 1 while True: k -= loop if k >= 0: ans += 1 else: break loop += 1 if N == 1: print((0)) else: print(ans)
from numba import jit N = int(eval(input())) """nを素因数分解""" """2以上の整数n => [(素因数, 指数), ...]の2次元リスト""" def factorization(n): arr = [] temp = n for i in range(2, int(n**0.5) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append((i, cnt)) if temp != 1: arr.append((temp, 1)) if arr == []: arr.append((n, 1)) return arr li = factorization(N) ans = 0 for i in li: k = i[1] loop = 1 while True: k -= loop if k >= 0: ans += 1 else: break loop += 1 if N == 1: print((0)) else: print(ans)
false
0
[ "-@jit" ]
false
0.041195
0.062035
0.664053
[ "s391765547", "s479491489" ]
u998169143
p02811
python
s512244533
s742467032
310
17
21,672
2,940
Accepted
Accepted
94.52
import numpy as np K, X = [int(i) for i in input().split()] if 500 * K >= X: print('Yes') else: print('No')
K, X = [int(i) for i in input().split()] if 500 * K >= X: print('Yes') else: print('No')
8
6
125
102
import numpy as np K, X = [int(i) for i in input().split()] if 500 * K >= X: print("Yes") else: print("No")
K, X = [int(i) for i in input().split()] if 500 * K >= X: print("Yes") else: print("No")
false
25
[ "-import numpy as np", "-" ]
false
0.091028
0.036054
2.524768
[ "s512244533", "s742467032" ]
u380524497
p03033
python
s339205298
s759124425
1,661
1,172
84,056
87,212
Accepted
Accepted
29.44
import sys input = sys.stdin.readline n, q = list(map(int, input().split())) events = [] for _ in range(n): start, end, pos = list(map(int, input().split())) events.append([start - pos, 1, pos]) events.append([end - pos, 0, pos]) events.sort() departures = [int(eval(input())) for _ in range(q)] idx = 0 mini = 10**10 mini_check = False candidates = set() time, is_under_construction, pos = events[idx] for departure in departures: while time <= departure: if is_under_construction: candidates.add(pos) if pos < mini: mini = pos mini_check = True else: candidates.remove(pos) if pos == mini: mini_check = False idx += 1 if idx == 2 * n: time = float('INF') break time, is_under_construction, pos = events[idx] if not candidates: print((-1)) else: if not mini_check: mini = min(candidates) mini_check = True print(mini)
import bisect import sys input = sys.stdin.readline n, q = list(map(int, input().split())) events = [list(map(int, input().split())) for _ in range(n)] events.sort(key=lambda x: x[2]) departures = [int(eval(input())) for _ in range(q)] ans = ['-1'] * q skip = [-1] * q for start, end, pos in events: left = bisect.bisect_left(departures, start-pos) right = bisect.bisect_left(departures, end-pos) while left < right: if skip[left] == -1: ans[left] = str(pos) skip[left] = right left += 1 else: left = skip[left] print(('\n'.join(ans)))
44
29
1,080
634
import sys input = sys.stdin.readline n, q = list(map(int, input().split())) events = [] for _ in range(n): start, end, pos = list(map(int, input().split())) events.append([start - pos, 1, pos]) events.append([end - pos, 0, pos]) events.sort() departures = [int(eval(input())) for _ in range(q)] idx = 0 mini = 10**10 mini_check = False candidates = set() time, is_under_construction, pos = events[idx] for departure in departures: while time <= departure: if is_under_construction: candidates.add(pos) if pos < mini: mini = pos mini_check = True else: candidates.remove(pos) if pos == mini: mini_check = False idx += 1 if idx == 2 * n: time = float("INF") break time, is_under_construction, pos = events[idx] if not candidates: print((-1)) else: if not mini_check: mini = min(candidates) mini_check = True print(mini)
import bisect import sys input = sys.stdin.readline n, q = list(map(int, input().split())) events = [list(map(int, input().split())) for _ in range(n)] events.sort(key=lambda x: x[2]) departures = [int(eval(input())) for _ in range(q)] ans = ["-1"] * q skip = [-1] * q for start, end, pos in events: left = bisect.bisect_left(departures, start - pos) right = bisect.bisect_left(departures, end - pos) while left < right: if skip[left] == -1: ans[left] = str(pos) skip[left] = right left += 1 else: left = skip[left] print(("\n".join(ans)))
false
34.090909
[ "+import bisect", "-events = []", "-for _ in range(n):", "- start, end, pos = list(map(int, input().split()))", "- events.append([start - pos, 1, pos])", "- events.append([end - pos, 0, pos])", "-events.sort()", "+events = [list(map(int, input().split())) for _ in range(n)]", "+events.sort(key=lambda x: x[2])", "-idx = 0", "-mini = 10**10", "-mini_check = False", "-candidates = set()", "-time, is_under_construction, pos = events[idx]", "-for departure in departures:", "- while time <= departure:", "- if is_under_construction:", "- candidates.add(pos)", "- if pos < mini:", "- mini = pos", "- mini_check = True", "+ans = [\"-1\"] * q", "+skip = [-1] * q", "+for start, end, pos in events:", "+ left = bisect.bisect_left(departures, start - pos)", "+ right = bisect.bisect_left(departures, end - pos)", "+ while left < right:", "+ if skip[left] == -1:", "+ ans[left] = str(pos)", "+ skip[left] = right", "+ left += 1", "- candidates.remove(pos)", "- if pos == mini:", "- mini_check = False", "- idx += 1", "- if idx == 2 * n:", "- time = float(\"INF\")", "- break", "- time, is_under_construction, pos = events[idx]", "- if not candidates:", "- print((-1))", "- else:", "- if not mini_check:", "- mini = min(candidates)", "- mini_check = True", "- print(mini)", "+ left = skip[left]", "+print((\"\\n\".join(ans)))" ]
false
0.037976
0.038351
0.990216
[ "s339205298", "s759124425" ]
u583507988
p04030
python
s104032999
s025029613
32
29
9,040
8,996
Accepted
Accepted
9.38
s = str(input()) ans = [] for i in s: if i == '0': ans.append('0') elif i == '1': ans.append('1') elif i == 'B': if ans == []: continue else: ans.pop() print(*ans, sep='')
s=input() data=[] for i in range(len(s)): if s[i]=='0': data.append('0') elif s[i]=='1': data.append('1') else: if len(data)==0: continue else: data.pop() print(*data,sep='')
14
13
219
220
s = str(input()) ans = [] for i in s: if i == "0": ans.append("0") elif i == "1": ans.append("1") elif i == "B": if ans == []: continue else: ans.pop() print(*ans, sep="")
s = input() data = [] for i in range(len(s)): if s[i] == "0": data.append("0") elif s[i] == "1": data.append("1") else: if len(data) == 0: continue else: data.pop() print(*data, sep="")
false
7.142857
[ "-s = str(input())", "-ans = []", "-for i in s:", "- if i == \"0\":", "- ans.append(\"0\")", "- elif i == \"1\":", "- ans.append(\"1\")", "- elif i == \"B\":", "- if ans == []:", "+s = input()", "+data = []", "+for i in range(len(s)):", "+ if s[i] == \"0\":", "+ data.append(\"0\")", "+ elif s[i] == \"1\":", "+ data.append(\"1\")", "+ else:", "+ if len(data) == 0:", "- ans.pop()", "-print(*ans, sep=\"\")", "+ data.pop()", "+print(*data, sep=\"\")" ]
false
0.047052
0.04755
0.989516
[ "s104032999", "s025029613" ]
u562935282
p02703
python
s421484302
s996371258
1,714
548
32,492
23,960
Accepted
Accepted
68.03
def main(): import dataclasses from heapq import heappush, heappop @dataclasses.dataclass(frozen=True) class Path: to: int fare: int travel_time: int @dataclasses.dataclass(frozen=True) class ExchangeRate: Ag: int exchange_time: int @dataclasses.dataclass(frozen=True) class Traveler: consumption_time: int remaining_Ag: int location: int def __gt__(self, other): return self.consumption_time > other.consumption_time def __eq__(self, other): return self.consumption_time == other.consumption_time INF = 1 << 60 MX_AG = 2500 N, M, S = list(map(int, input().split())) S = min(S, MX_AG) # それ以上のAgは不要 g = tuple(set() for _ in range(N)) for _ in range(M): u, v, a, b = list(map(int, input().split())) u -= 1 v -= 1 g[u].add(Path(v, a, b)) g[v].add(Path(u, a, b)) exchange = [] for _ in range(N): c, d = list(map(int, input().split())) exchange.append(ExchangeRate(c, d)) h = [Traveler(0, S, 0)] time = [[INF] * (MX_AG + 1) for _ in range(N)] time[0][S] = 0 # time[location][r_Ag]:=minimum_time_to_reach while h: t = heappop(h) for p in g[t.location]: n_Ag = t.remaining_Ag - p.fare if n_Ag < 0: continue cf = time[p.to][n_Ag] n_time = t.consumption_time + p.travel_time if cf <= n_time: continue time[p.to][n_Ag] = n_time heappush(h, Traveler(consumption_time=n_time, remaining_Ag=n_Ag, location=p.to)) e_time = t.consumption_time + exchange[t.location].exchange_time e_Ag = t.remaining_Ag + exchange[t.location].Ag if e_Ag > MX_AG: continue cf = time[t.location][e_Ag] if cf <= e_time: continue time[t.location][e_Ag] = e_time heappush(h, Traveler(consumption_time=e_time, remaining_Ag=e_Ag, location=t.location)) for to in range(1, N): print((min(time[to]))) if __name__ == '__main__': main()
def main(): from heapq import heappush, heappop INF = 1 << 60 MX_AG = 2500 N, M, S = list(map(int, input().split())) S = min(S, MX_AG) # それ以上のAgは不要 g = tuple(set() for _ in range(N)) for _ in range(M): u, v, a, b = list(map(int, input().split())) u -= 1 v -= 1 g[u].add((v, a, b)) g[v].add((u, a, b)) exchange = [] for _ in range(N): c, d = list(map(int, input().split())) exchange.append((c, d)) h = [(0, S, 0)] time = [[INF] * (MX_AG + 1) for _ in range(N)] time[0][S] = 0 # time[location][r_Ag]:=minimum_time_to_reach while h: t, ag, loc = heappop(h) for to, fare, dt in g[loc]: n_Ag = ag - fare if n_Ag < 0: continue cf = time[to][n_Ag] n_time = t + dt if cf <= n_time: continue time[to][n_Ag] = n_time heappush(h, (n_time, n_Ag, to)) e_time = t + exchange[loc][1] e_Ag = ag + exchange[loc][0] if e_Ag > MX_AG: continue cf = time[loc][e_Ag] if cf <= e_time: continue time[loc][e_Ag] = e_time heappush(h, (e_time, e_Ag, loc)) for to in range(1, N): print((min(time[to]))) if __name__ == '__main__': main()
77
53
2,180
1,337
def main(): import dataclasses from heapq import heappush, heappop @dataclasses.dataclass(frozen=True) class Path: to: int fare: int travel_time: int @dataclasses.dataclass(frozen=True) class ExchangeRate: Ag: int exchange_time: int @dataclasses.dataclass(frozen=True) class Traveler: consumption_time: int remaining_Ag: int location: int def __gt__(self, other): return self.consumption_time > other.consumption_time def __eq__(self, other): return self.consumption_time == other.consumption_time INF = 1 << 60 MX_AG = 2500 N, M, S = list(map(int, input().split())) S = min(S, MX_AG) # それ以上のAgは不要 g = tuple(set() for _ in range(N)) for _ in range(M): u, v, a, b = list(map(int, input().split())) u -= 1 v -= 1 g[u].add(Path(v, a, b)) g[v].add(Path(u, a, b)) exchange = [] for _ in range(N): c, d = list(map(int, input().split())) exchange.append(ExchangeRate(c, d)) h = [Traveler(0, S, 0)] time = [[INF] * (MX_AG + 1) for _ in range(N)] time[0][S] = 0 # time[location][r_Ag]:=minimum_time_to_reach while h: t = heappop(h) for p in g[t.location]: n_Ag = t.remaining_Ag - p.fare if n_Ag < 0: continue cf = time[p.to][n_Ag] n_time = t.consumption_time + p.travel_time if cf <= n_time: continue time[p.to][n_Ag] = n_time heappush( h, Traveler(consumption_time=n_time, remaining_Ag=n_Ag, location=p.to) ) e_time = t.consumption_time + exchange[t.location].exchange_time e_Ag = t.remaining_Ag + exchange[t.location].Ag if e_Ag > MX_AG: continue cf = time[t.location][e_Ag] if cf <= e_time: continue time[t.location][e_Ag] = e_time heappush( h, Traveler(consumption_time=e_time, remaining_Ag=e_Ag, location=t.location) ) for to in range(1, N): print((min(time[to]))) if __name__ == "__main__": main()
def main(): from heapq import heappush, heappop INF = 1 << 60 MX_AG = 2500 N, M, S = list(map(int, input().split())) S = min(S, MX_AG) # それ以上のAgは不要 g = tuple(set() for _ in range(N)) for _ in range(M): u, v, a, b = list(map(int, input().split())) u -= 1 v -= 1 g[u].add((v, a, b)) g[v].add((u, a, b)) exchange = [] for _ in range(N): c, d = list(map(int, input().split())) exchange.append((c, d)) h = [(0, S, 0)] time = [[INF] * (MX_AG + 1) for _ in range(N)] time[0][S] = 0 # time[location][r_Ag]:=minimum_time_to_reach while h: t, ag, loc = heappop(h) for to, fare, dt in g[loc]: n_Ag = ag - fare if n_Ag < 0: continue cf = time[to][n_Ag] n_time = t + dt if cf <= n_time: continue time[to][n_Ag] = n_time heappush(h, (n_time, n_Ag, to)) e_time = t + exchange[loc][1] e_Ag = ag + exchange[loc][0] if e_Ag > MX_AG: continue cf = time[loc][e_Ag] if cf <= e_time: continue time[loc][e_Ag] = e_time heappush(h, (e_time, e_Ag, loc)) for to in range(1, N): print((min(time[to]))) if __name__ == "__main__": main()
false
31.168831
[ "- import dataclasses", "-", "- @dataclasses.dataclass(frozen=True)", "- class Path:", "- to: int", "- fare: int", "- travel_time: int", "-", "- @dataclasses.dataclass(frozen=True)", "- class ExchangeRate:", "- Ag: int", "- exchange_time: int", "-", "- @dataclasses.dataclass(frozen=True)", "- class Traveler:", "- consumption_time: int", "- remaining_Ag: int", "- location: int", "-", "- def __gt__(self, other):", "- return self.consumption_time > other.consumption_time", "-", "- def __eq__(self, other):", "- return self.consumption_time == other.consumption_time", "- g[u].add(Path(v, a, b))", "- g[v].add(Path(u, a, b))", "+ g[u].add((v, a, b))", "+ g[v].add((u, a, b))", "- exchange.append(ExchangeRate(c, d))", "- h = [Traveler(0, S, 0)]", "+ exchange.append((c, d))", "+ h = [(0, S, 0)]", "- t = heappop(h)", "- for p in g[t.location]:", "- n_Ag = t.remaining_Ag - p.fare", "+ t, ag, loc = heappop(h)", "+ for to, fare, dt in g[loc]:", "+ n_Ag = ag - fare", "- cf = time[p.to][n_Ag]", "- n_time = t.consumption_time + p.travel_time", "+ cf = time[to][n_Ag]", "+ n_time = t + dt", "- time[p.to][n_Ag] = n_time", "- heappush(", "- h, Traveler(consumption_time=n_time, remaining_Ag=n_Ag, location=p.to)", "- )", "- e_time = t.consumption_time + exchange[t.location].exchange_time", "- e_Ag = t.remaining_Ag + exchange[t.location].Ag", "+ time[to][n_Ag] = n_time", "+ heappush(h, (n_time, n_Ag, to))", "+ e_time = t + exchange[loc][1]", "+ e_Ag = ag + exchange[loc][0]", "- cf = time[t.location][e_Ag]", "+ cf = time[loc][e_Ag]", "- time[t.location][e_Ag] = e_time", "- heappush(", "- h, Traveler(consumption_time=e_time, remaining_Ag=e_Ag, location=t.location)", "- )", "+ time[loc][e_Ag] = e_time", "+ heappush(h, (e_time, e_Ag, loc))" ]
false
0.488789
0.244005
2.00319
[ "s421484302", "s996371258" ]
u655110382
p02683
python
s327620633
s352393327
207
149
27,180
27,200
Accepted
Accepted
28.02
import numpy as np from itertools import product inf = int(1e20) n, m, x = list(map(int, input().split())) _ = [[int(x) for x in input().split()] for _ in range(n)] CA = np.array(_, dtype=int) ans = inf for indices in product([0, 1], repeat=n): tmp = np.zeros(m + 1, dtype=int) for idx, be_used in enumerate(indices): tmp += be_used * CA[idx] if min(tmp[1:]) >= x: ans = min(ans, tmp[0]) print((ans if ans != inf else '-1'))
import numpy as np from itertools import product inf = int(1e20) n, m, x = list(map(int, input().split())) _ = [[int(x) for x in input().split()] for _ in range(n)] CA = np.array(_, dtype=int) ans = inf for indices in product([False, True], repeat=n): sums = np.sum(CA[np.array(indices)], axis=0) if min(sums[1:]) >= x: ans = min(ans, sums[0]) print((ans if ans != inf else '-1'))
15
13
460
402
import numpy as np from itertools import product inf = int(1e20) n, m, x = list(map(int, input().split())) _ = [[int(x) for x in input().split()] for _ in range(n)] CA = np.array(_, dtype=int) ans = inf for indices in product([0, 1], repeat=n): tmp = np.zeros(m + 1, dtype=int) for idx, be_used in enumerate(indices): tmp += be_used * CA[idx] if min(tmp[1:]) >= x: ans = min(ans, tmp[0]) print((ans if ans != inf else "-1"))
import numpy as np from itertools import product inf = int(1e20) n, m, x = list(map(int, input().split())) _ = [[int(x) for x in input().split()] for _ in range(n)] CA = np.array(_, dtype=int) ans = inf for indices in product([False, True], repeat=n): sums = np.sum(CA[np.array(indices)], axis=0) if min(sums[1:]) >= x: ans = min(ans, sums[0]) print((ans if ans != inf else "-1"))
false
13.333333
[ "-for indices in product([0, 1], repeat=n):", "- tmp = np.zeros(m + 1, dtype=int)", "- for idx, be_used in enumerate(indices):", "- tmp += be_used * CA[idx]", "- if min(tmp[1:]) >= x:", "- ans = min(ans, tmp[0])", "+for indices in product([False, True], repeat=n):", "+ sums = np.sum(CA[np.array(indices)], axis=0)", "+ if min(sums[1:]) >= x:", "+ ans = min(ans, sums[0])" ]
false
0.354438
0.512164
0.69204
[ "s327620633", "s352393327" ]
u404290207
p03086
python
s550291092
s322984179
296
265
64,748
63,852
Accepted
Accepted
10.47
import sys sys.setrecursionlimit(10**6) from math import floor,ceil,sqrt,factorial,log from heapq import heappop, heappush, heappushpop from collections import Counter,defaultdict,deque from itertools import accumulate,permutations,combinations,product,combinations_with_replacement from bisect import bisect_left,bisect_right from copy import deepcopy from operator import itemgetter from fractions import gcd mod = 10 ** 9 + 7 inf = float('inf') ninf = -float('inf') #整数input def ii(): return int(sys.stdin.readline().rstrip()) #int(input()) def mii(): return list(map(int,sys.stdin.readline().rstrip().split())) def limii(): return list(mii()) #list(map(int,input().split())) def lin(n:int): return [ii() for _ in range(n)] def llint(n: int): return [limii() for _ in range(n)] #文字列input def ss(): return sys.stdin.readline().rstrip() #input() def mss(): return sys.stdin.readline().rstrip().split() def limss(): return list(mss()) #list(input().split()) def lst(n:int): return [ss() for _ in range(n)] def llstr(n: int): return [limss() for _ in range(n)] #本当に貪欲法か? DP法では?? #本当に貪欲法か? DP法では?? #本当に貪欲法か? DP法では?? s=list(ss()) arr=["A","C","G","T"] ans=0 for i in range(len(s)): for j in range(i+1,len(s)+1): cnt=0 for k in s[i:j]: if k in arr: cnt+=1 if cnt==len(s[i:j]): ans=max(ans,cnt) print(ans)
import sys sys.setrecursionlimit(10**6) from math import floor,ceil,sqrt,factorial,log from heapq import heappop, heappush, heappushpop from collections import Counter,defaultdict,deque from itertools import accumulate,permutations,combinations,product,combinations_with_replacement from bisect import bisect_left,bisect_right from copy import deepcopy from operator import itemgetter from fractions import gcd mod = 10 ** 9 + 7 inf = float('inf') ninf = -float('inf') #整数input def ii(): return int(sys.stdin.readline().rstrip()) #int(input()) def mii(): return list(map(int,sys.stdin.readline().rstrip().split())) def limii(): return list(mii()) #list(map(int,input().split())) def lin(n:int): return [ii() for _ in range(n)] def llint(n: int): return [limii() for _ in range(n)] #文字列input def ss(): return sys.stdin.readline().rstrip() #input() def mss(): return sys.stdin.readline().rstrip().split() def limss(): return list(mss()) #list(input().split()) def lst(n:int): return [ss() for _ in range(n)] def llstr(n: int): return [limss() for _ in range(n)] #本当に貪欲法か? DP法では?? #本当に貪欲法か? DP法では?? #本当に貪欲法か? DP法では?? s=list(ss()) ans=0 temp=0 for i in range(len(s)): if s[i] in ["A","C","G","T"]: temp+=1 ans=max(temp,ans) else: temp=0 print(ans)
43
44
1,408
1,320
import sys sys.setrecursionlimit(10**6) from math import floor, ceil, sqrt, factorial, log from heapq import heappop, heappush, heappushpop from collections import Counter, defaultdict, deque from itertools import ( accumulate, permutations, combinations, product, combinations_with_replacement, ) from bisect import bisect_left, bisect_right from copy import deepcopy from operator import itemgetter from fractions import gcd mod = 10**9 + 7 inf = float("inf") ninf = -float("inf") # 整数input def ii(): return int(sys.stdin.readline().rstrip()) # int(input()) def mii(): return list(map(int, sys.stdin.readline().rstrip().split())) def limii(): return list(mii()) # list(map(int,input().split())) def lin(n: int): return [ii() for _ in range(n)] def llint(n: int): return [limii() for _ in range(n)] # 文字列input def ss(): return sys.stdin.readline().rstrip() # input() def mss(): return sys.stdin.readline().rstrip().split() def limss(): return list(mss()) # list(input().split()) def lst(n: int): return [ss() for _ in range(n)] def llstr(n: int): return [limss() for _ in range(n)] # 本当に貪欲法か? DP法では?? # 本当に貪欲法か? DP法では?? # 本当に貪欲法か? DP法では?? s = list(ss()) arr = ["A", "C", "G", "T"] ans = 0 for i in range(len(s)): for j in range(i + 1, len(s) + 1): cnt = 0 for k in s[i:j]: if k in arr: cnt += 1 if cnt == len(s[i:j]): ans = max(ans, cnt) print(ans)
import sys sys.setrecursionlimit(10**6) from math import floor, ceil, sqrt, factorial, log from heapq import heappop, heappush, heappushpop from collections import Counter, defaultdict, deque from itertools import ( accumulate, permutations, combinations, product, combinations_with_replacement, ) from bisect import bisect_left, bisect_right from copy import deepcopy from operator import itemgetter from fractions import gcd mod = 10**9 + 7 inf = float("inf") ninf = -float("inf") # 整数input def ii(): return int(sys.stdin.readline().rstrip()) # int(input()) def mii(): return list(map(int, sys.stdin.readline().rstrip().split())) def limii(): return list(mii()) # list(map(int,input().split())) def lin(n: int): return [ii() for _ in range(n)] def llint(n: int): return [limii() for _ in range(n)] # 文字列input def ss(): return sys.stdin.readline().rstrip() # input() def mss(): return sys.stdin.readline().rstrip().split() def limss(): return list(mss()) # list(input().split()) def lst(n: int): return [ss() for _ in range(n)] def llstr(n: int): return [limss() for _ in range(n)] # 本当に貪欲法か? DP法では?? # 本当に貪欲法か? DP法では?? # 本当に貪欲法か? DP法では?? s = list(ss()) ans = 0 temp = 0 for i in range(len(s)): if s[i] in ["A", "C", "G", "T"]: temp += 1 ans = max(temp, ans) else: temp = 0 print(ans)
false
2.272727
[ "-arr = [\"A\", \"C\", \"G\", \"T\"]", "+temp = 0", "- for j in range(i + 1, len(s) + 1):", "- cnt = 0", "- for k in s[i:j]:", "- if k in arr:", "- cnt += 1", "- if cnt == len(s[i:j]):", "- ans = max(ans, cnt)", "+ if s[i] in [\"A\", \"C\", \"G\", \"T\"]:", "+ temp += 1", "+ ans = max(temp, ans)", "+ else:", "+ temp = 0" ]
false
0.050746
0.047487
1.068616
[ "s550291092", "s322984179" ]
u741397536
p03240
python
s285899470
s439677312
123
38
3,064
3,064
Accepted
Accepted
69.11
n = int(eval(input())) arr = [] for i in range(n): x, y, h = list(map(int, input().split())) arr.append([x, y, h]) for i in range(101): for j in range(101): for k in range(n): if arr[k][2] > 0: len1 = abs(arr[k][0] - i) + abs(arr[k][1] - j) ch = len1 + arr[k][2] break else: continue for k in range(n): lenk = abs(arr[k][0] - i) + abs(arr[k][1] - j) if max(ch - lenk, 0) == arr[k][2]: if k == n-1: print(("{} {} {}".format(i, j, ch))) else: continue else: break
N = int(eval(input())) L = [] for i in range(N): x, y, h = list(map(int, input().split())) L.append([x, y, h]) if h != 0: idx = i for i in range(101): for j in range(101): H = L[idx][2] + abs(L[idx][0]-i) + abs(L[idx][1]-j) for k in range(N): if L[k][2] == max(H - abs(L[k][0]-i) - abs(L[k][1]-j), 0): pass else: break if k == N-1: ansx = i ansy = j ansh = H print((ansx, ansy, ansh))
26
24
715
553
n = int(eval(input())) arr = [] for i in range(n): x, y, h = list(map(int, input().split())) arr.append([x, y, h]) for i in range(101): for j in range(101): for k in range(n): if arr[k][2] > 0: len1 = abs(arr[k][0] - i) + abs(arr[k][1] - j) ch = len1 + arr[k][2] break else: continue for k in range(n): lenk = abs(arr[k][0] - i) + abs(arr[k][1] - j) if max(ch - lenk, 0) == arr[k][2]: if k == n - 1: print(("{} {} {}".format(i, j, ch))) else: continue else: break
N = int(eval(input())) L = [] for i in range(N): x, y, h = list(map(int, input().split())) L.append([x, y, h]) if h != 0: idx = i for i in range(101): for j in range(101): H = L[idx][2] + abs(L[idx][0] - i) + abs(L[idx][1] - j) for k in range(N): if L[k][2] == max(H - abs(L[k][0] - i) - abs(L[k][1] - j), 0): pass else: break if k == N - 1: ansx = i ansy = j ansh = H print((ansx, ansy, ansh))
false
7.692308
[ "-n = int(eval(input()))", "-arr = []", "-for i in range(n):", "+N = int(eval(input()))", "+L = []", "+for i in range(N):", "- arr.append([x, y, h])", "+ L.append([x, y, h])", "+ if h != 0:", "+ idx = i", "- for k in range(n):", "- if arr[k][2] > 0:", "- len1 = abs(arr[k][0] - i) + abs(arr[k][1] - j)", "- ch = len1 + arr[k][2]", "- break", "- else:", "- continue", "- for k in range(n):", "- lenk = abs(arr[k][0] - i) + abs(arr[k][1] - j)", "- if max(ch - lenk, 0) == arr[k][2]:", "- if k == n - 1:", "- print((\"{} {} {}\".format(i, j, ch)))", "- else:", "- continue", "+ H = L[idx][2] + abs(L[idx][0] - i) + abs(L[idx][1] - j)", "+ for k in range(N):", "+ if L[k][2] == max(H - abs(L[k][0] - i) - abs(L[k][1] - j), 0):", "+ pass", "+ if k == N - 1:", "+ ansx = i", "+ ansy = j", "+ ansh = H", "+print((ansx, ansy, ansh))" ]
false
0.269039
0.055366
4.859295
[ "s285899470", "s439677312" ]
u706414019
p03986
python
s185227725
s089828057
72
62
9,092
9,196
Accepted
Accepted
13.89
s = eval(input()) s_cnt =0 t_cnt =0 cnt = 0 for i in range(len(s)): if s[i] == 'S': s_cnt += 1 if s[i] == 'T': t_cnt += 1 if s_cnt >0: t_cnt -= 1 s_cnt -= 1 print((t_cnt + s_cnt))
S = eval(input()) s_cnt =0 t_cnt =0 for s in S: if s == 'S': s_cnt += 1 if s == 'T': t_cnt += 1 if s_cnt >0: t_cnt -= 1 s_cnt -= 1 print((t_cnt + s_cnt))
14
13
242
215
s = eval(input()) s_cnt = 0 t_cnt = 0 cnt = 0 for i in range(len(s)): if s[i] == "S": s_cnt += 1 if s[i] == "T": t_cnt += 1 if s_cnt > 0: t_cnt -= 1 s_cnt -= 1 print((t_cnt + s_cnt))
S = eval(input()) s_cnt = 0 t_cnt = 0 for s in S: if s == "S": s_cnt += 1 if s == "T": t_cnt += 1 if s_cnt > 0: t_cnt -= 1 s_cnt -= 1 print((t_cnt + s_cnt))
false
7.142857
[ "-s = eval(input())", "+S = eval(input())", "-cnt = 0", "-for i in range(len(s)):", "- if s[i] == \"S\":", "+for s in S:", "+ if s == \"S\":", "- if s[i] == \"T\":", "+ if s == \"T\":" ]
false
0.044035
0.087601
0.502683
[ "s185227725", "s089828057" ]
u699296734
p02663
python
s021007550
s526801581
23
21
9,160
9,092
Accepted
Accepted
8.7
h1,m1,h2,m2,k=list(map(int,input().split())) res=max(h2*60+m2-h1*60-m1-k,0) print(res)
h1,m1,h2,m2,k=list(map(int,input().split())) res=h2*60+m2-h1*60-m1-k print(res)
3
3
82
75
h1, m1, h2, m2, k = list(map(int, input().split())) res = max(h2 * 60 + m2 - h1 * 60 - m1 - k, 0) print(res)
h1, m1, h2, m2, k = list(map(int, input().split())) res = h2 * 60 + m2 - h1 * 60 - m1 - k print(res)
false
0
[ "-res = max(h2 * 60 + m2 - h1 * 60 - m1 - k, 0)", "+res = h2 * 60 + m2 - h1 * 60 - m1 - k" ]
false
0.129298
0.041625
3.106236
[ "s021007550", "s526801581" ]
u937706062
p03027
python
s575692967
s901614657
1,853
1,458
44,972
47,120
Accepted
Accepted
21.32
mod = 10 ** 6 + 3 W = [1] for i in range(1, mod): W.append((W[-1] * i) % mod) def rev(a): return pow(a, mod - 2, mod) def f(x, d, n): if d == 0: return pow(x, n, mod) else: d_r = rev(d) xdr = d_r * x % mod if xdr == 0: return 0 elif (xdr + n - 1) >= mod: return 0 else: return (W[xdr + n - 1] * rev(W[xdr - 1]) % mod) * pow(d, n, mod) % mod Q = int(eval(input())) for i in range(Q): x, d, n = list(map(int, input().split())) print((f(x, d, n)))
mod = 10 ** 6 + 3 W = [1] * (mod) for i in range(mod - 1): W[i + 1] = ((i + 1) * W[i]) % mod def rev(a): return pow(a, mod - 2, mod) def f(x, d, n): if d == 0: return pow(x, n, mod) else: d_r = rev(d) xdr = d_r * x % mod if xdr == 0: return 0 elif (xdr + n - 1) >= mod: return 0 else: return (W[xdr + n - 1] * rev(W[xdr - 1]) % mod) * pow(d, n, mod) % mod ans = [] q = int(eval(input())) for _ in range(q): x,d,n = list(map(int,input().split())) ans.append(f(x,d,n)) for i in ans: print(i)
26
29
487
546
mod = 10**6 + 3 W = [1] for i in range(1, mod): W.append((W[-1] * i) % mod) def rev(a): return pow(a, mod - 2, mod) def f(x, d, n): if d == 0: return pow(x, n, mod) else: d_r = rev(d) xdr = d_r * x % mod if xdr == 0: return 0 elif (xdr + n - 1) >= mod: return 0 else: return (W[xdr + n - 1] * rev(W[xdr - 1]) % mod) * pow(d, n, mod) % mod Q = int(eval(input())) for i in range(Q): x, d, n = list(map(int, input().split())) print((f(x, d, n)))
mod = 10**6 + 3 W = [1] * (mod) for i in range(mod - 1): W[i + 1] = ((i + 1) * W[i]) % mod def rev(a): return pow(a, mod - 2, mod) def f(x, d, n): if d == 0: return pow(x, n, mod) else: d_r = rev(d) xdr = d_r * x % mod if xdr == 0: return 0 elif (xdr + n - 1) >= mod: return 0 else: return (W[xdr + n - 1] * rev(W[xdr - 1]) % mod) * pow(d, n, mod) % mod ans = [] q = int(eval(input())) for _ in range(q): x, d, n = list(map(int, input().split())) ans.append(f(x, d, n)) for i in ans: print(i)
false
10.344828
[ "-W = [1]", "-for i in range(1, mod):", "- W.append((W[-1] * i) % mod)", "+W = [1] * (mod)", "+for i in range(mod - 1):", "+ W[i + 1] = ((i + 1) * W[i]) % mod", "-Q = int(eval(input()))", "-for i in range(Q):", "+ans = []", "+q = int(eval(input()))", "+for _ in range(q):", "- print((f(x, d, n)))", "+ ans.append(f(x, d, n))", "+for i in ans:", "+ print(i)" ]
false
0.577302
1.455928
0.396518
[ "s575692967", "s901614657" ]
u262597910
p02936
python
s072257957
s895813337
1,421
1,033
73,732
73,604
Accepted
Accepted
27.3
import sys input = sys.stdin.readline n,q = list(map(int, input().split())) way = [[] for _ in range(n)] for i in range(n-1): a,b = list(map(int, input().split())) way[a-1].append(b-1) way[b-1].append(a-1) add = [0]*n for i in range(q): a,b = list(map(int, input().split())) add[a-1] += b ans = [-1]*n ans[0] = add[0] stack = [(0,add[0])] while stack: a,b = stack.pop() for i in range(len(way[a])): if (ans[way[a][i]]==-1): stack.append((way[a][i],b+add[way[a][i]])) ans[way[a][i]] = b+add[way[a][i]] print((*ans))
import sys input = sys.stdin.readline def main(): n,q = list(map(int, input().split())) way = [[] for _ in range(n)] for i in range(n-1): a,b = list(map(int, input().split())) way[a-1].append(b-1) way[b-1].append(a-1) add = [0]*n for i in range(q): a,b = list(map(int, input().split())) add[a-1] += b ans = [-1]*n ans[0] = add[0] stack = [(0,add[0])] while stack: a,b = stack.pop() for i in range(len(way[a])): if (ans[way[a][i]]==-1): stack.append((way[a][i],b+add[way[a][i]])) ans[way[a][i]] = b+add[way[a][i]] print((*ans)) if __name__=="__main__": main()
25
28
589
720
import sys input = sys.stdin.readline n, q = list(map(int, input().split())) way = [[] for _ in range(n)] for i in range(n - 1): a, b = list(map(int, input().split())) way[a - 1].append(b - 1) way[b - 1].append(a - 1) add = [0] * n for i in range(q): a, b = list(map(int, input().split())) add[a - 1] += b ans = [-1] * n ans[0] = add[0] stack = [(0, add[0])] while stack: a, b = stack.pop() for i in range(len(way[a])): if ans[way[a][i]] == -1: stack.append((way[a][i], b + add[way[a][i]])) ans[way[a][i]] = b + add[way[a][i]] print((*ans))
import sys input = sys.stdin.readline def main(): n, q = list(map(int, input().split())) way = [[] for _ in range(n)] for i in range(n - 1): a, b = list(map(int, input().split())) way[a - 1].append(b - 1) way[b - 1].append(a - 1) add = [0] * n for i in range(q): a, b = list(map(int, input().split())) add[a - 1] += b ans = [-1] * n ans[0] = add[0] stack = [(0, add[0])] while stack: a, b = stack.pop() for i in range(len(way[a])): if ans[way[a][i]] == -1: stack.append((way[a][i], b + add[way[a][i]])) ans[way[a][i]] = b + add[way[a][i]] print((*ans)) if __name__ == "__main__": main()
false
10.714286
[ "-n, q = list(map(int, input().split()))", "-way = [[] for _ in range(n)]", "-for i in range(n - 1):", "- a, b = list(map(int, input().split()))", "- way[a - 1].append(b - 1)", "- way[b - 1].append(a - 1)", "-add = [0] * n", "-for i in range(q):", "- a, b = list(map(int, input().split()))", "- add[a - 1] += b", "-ans = [-1] * n", "-ans[0] = add[0]", "-stack = [(0, add[0])]", "-while stack:", "- a, b = stack.pop()", "- for i in range(len(way[a])):", "- if ans[way[a][i]] == -1:", "- stack.append((way[a][i], b + add[way[a][i]]))", "- ans[way[a][i]] = b + add[way[a][i]]", "-print((*ans))", "+", "+", "+def main():", "+ n, q = list(map(int, input().split()))", "+ way = [[] for _ in range(n)]", "+ for i in range(n - 1):", "+ a, b = list(map(int, input().split()))", "+ way[a - 1].append(b - 1)", "+ way[b - 1].append(a - 1)", "+ add = [0] * n", "+ for i in range(q):", "+ a, b = list(map(int, input().split()))", "+ add[a - 1] += b", "+ ans = [-1] * n", "+ ans[0] = add[0]", "+ stack = [(0, add[0])]", "+ while stack:", "+ a, b = stack.pop()", "+ for i in range(len(way[a])):", "+ if ans[way[a][i]] == -1:", "+ stack.append((way[a][i], b + add[way[a][i]]))", "+ ans[way[a][i]] = b + add[way[a][i]]", "+ print((*ans))", "+", "+", "+if __name__ == \"__main__\":", "+ main()" ]
false
0.077302
0.04651
1.662036
[ "s072257957", "s895813337" ]
u103539599
p03331
python
s323975529
s250955260
19
17
2,940
2,940
Accepted
Accepted
10.53
N = int(eval(input())) if N % 10 == 0: # print(str(N)[0]) if str(N)[0] == "1": print((10)) else: print((str(N)[0])) else: print((sum(list(map(int,list(str(N)))))))
N = int(eval(input())) if N % 10 == 0 and str(N)[0] == "1": print((10)) else: print((sum(list(map(int,list(str(N)))))))
10
6
193
124
N = int(eval(input())) if N % 10 == 0: # print(str(N)[0]) if str(N)[0] == "1": print((10)) else: print((str(N)[0])) else: print((sum(list(map(int, list(str(N)))))))
N = int(eval(input())) if N % 10 == 0 and str(N)[0] == "1": print((10)) else: print((sum(list(map(int, list(str(N)))))))
false
40
[ "-if N % 10 == 0:", "- # print(str(N)[0])", "- if str(N)[0] == \"1\":", "- print((10))", "- else:", "- print((str(N)[0]))", "+if N % 10 == 0 and str(N)[0] == \"1\":", "+ print((10))" ]
false
0.061533
0.051175
1.202405
[ "s323975529", "s250955260" ]
u422291726
p03061
python
s163445213
s640399946
209
184
16,148
16,132
Accepted
Accepted
11.96
import fractions N = int(eval(input())) A = list(map(int, input().split())) L = [0] * N R = [0] * N for i in range(0, N - 1): L[i + 1] = fractions.gcd(L[i], A[i]) for i in range(N - 1, 0, -1): R[i - 1] = fractions.gcd(R[i], A[i]) ans = 1 for i in range(N): ans = max(ans, fractions.gcd(L[i], R[i])) print(ans)
import fractions N = int(eval(input())) A = list(map(int, input().split())) L = [0] * N R = [0] * N for i in range(0, N - 1): L[i + 1] = fractions.gcd(L[i], A[i]) for i in range(N - 1, 0, -1): R[i - 1] = fractions.gcd(R[i], A[i]) print((max([fractions.gcd(L[i], R[i]) for i in range(N)])))
14
11
330
301
import fractions N = int(eval(input())) A = list(map(int, input().split())) L = [0] * N R = [0] * N for i in range(0, N - 1): L[i + 1] = fractions.gcd(L[i], A[i]) for i in range(N - 1, 0, -1): R[i - 1] = fractions.gcd(R[i], A[i]) ans = 1 for i in range(N): ans = max(ans, fractions.gcd(L[i], R[i])) print(ans)
import fractions N = int(eval(input())) A = list(map(int, input().split())) L = [0] * N R = [0] * N for i in range(0, N - 1): L[i + 1] = fractions.gcd(L[i], A[i]) for i in range(N - 1, 0, -1): R[i - 1] = fractions.gcd(R[i], A[i]) print((max([fractions.gcd(L[i], R[i]) for i in range(N)])))
false
21.428571
[ "-ans = 1", "-for i in range(N):", "- ans = max(ans, fractions.gcd(L[i], R[i]))", "-print(ans)", "+print((max([fractions.gcd(L[i], R[i]) for i in range(N)])))" ]
false
0.04506
0.047638
0.945895
[ "s163445213", "s640399946" ]
u644907318
p03618
python
s643676933
s603554740
183
83
40,688
83,900
Accepted
Accepted
54.64
A = input().strip() C = {chr(i):0 for i in range(97,123)} n = len(A) for i in range(n): C[A[i]] += 1 cnt = 0 for a in C: cnt += (C[a]*(C[a]-1))//2 print((1+(n*(n-1))//2-cnt))
A = input().strip() N = len(A) tot = 1+(N*(N-1))//2 C = {chr(i):[] for i in range(97,123)} for i in range(N): C[A[i]].append(i) cnt = 0 for a in C: n = len(C[a]) cnt += (n*(n-1))//2 print((tot-cnt))
9
11
188
218
A = input().strip() C = {chr(i): 0 for i in range(97, 123)} n = len(A) for i in range(n): C[A[i]] += 1 cnt = 0 for a in C: cnt += (C[a] * (C[a] - 1)) // 2 print((1 + (n * (n - 1)) // 2 - cnt))
A = input().strip() N = len(A) tot = 1 + (N * (N - 1)) // 2 C = {chr(i): [] for i in range(97, 123)} for i in range(N): C[A[i]].append(i) cnt = 0 for a in C: n = len(C[a]) cnt += (n * (n - 1)) // 2 print((tot - cnt))
false
18.181818
[ "-C = {chr(i): 0 for i in range(97, 123)}", "-n = len(A)", "-for i in range(n):", "- C[A[i]] += 1", "+N = len(A)", "+tot = 1 + (N * (N - 1)) // 2", "+C = {chr(i): [] for i in range(97, 123)}", "+for i in range(N):", "+ C[A[i]].append(i)", "- cnt += (C[a] * (C[a] - 1)) // 2", "-print((1 + (n * (n - 1)) // 2 - cnt))", "+ n = len(C[a])", "+ cnt += (n * (n - 1)) // 2", "+print((tot - cnt))" ]
false
0.007484
0.035614
0.210129
[ "s643676933", "s603554740" ]
u714642969
p02880
python
s377326680
s270842959
168
17
38,384
2,940
Accepted
Accepted
89.88
N=int(eval(input())) for i in range(9): if N%(i+1)==0 and N//(i+1)<10: print('Yes') break else: print('No')
N=int(eval(input())) print(('YNeos'[not [i for i in range(1,10) if N%i==0 and N//i<10]::2]))
7
2
132
85
N = int(eval(input())) for i in range(9): if N % (i + 1) == 0 and N // (i + 1) < 10: print("Yes") break else: print("No")
N = int(eval(input())) print(("YNeos"[not [i for i in range(1, 10) if N % i == 0 and N // i < 10] :: 2]))
false
71.428571
[ "-for i in range(9):", "- if N % (i + 1) == 0 and N // (i + 1) < 10:", "- print(\"Yes\")", "- break", "-else:", "- print(\"No\")", "+print((\"YNeos\"[not [i for i in range(1, 10) if N % i == 0 and N // i < 10] :: 2]))" ]
false
0.110353
0.038731
2.849225
[ "s377326680", "s270842959" ]
u894934980
p02796
python
s433165849
s118876826
456
409
21,380
18,216
Accepted
Accepted
10.31
N = int(eval(input())) R = [tuple(map(int, input().split())) for _ in range(N)] # 左端でソート R.sort(key=lambda x: x[0]-x[1]) prev_L_arm = R[0][0] - R[0][1] prev_R_arm = R[0][0] + R[0][1] ans = N for i in range(1, N): L_arm = R[i][0] - R[i][1] R_arm = R[i][0] + R[i][1] if L_arm < prev_R_arm: prev_R_arm = min(prev_R_arm, R_arm) ans -= 1 else: prev_R_arm = R_arm print(ans)
# 解き直し https://atcoder.jp/contests/keyence2020/tasks/keyence2020_b N = int(eval(input())) R = [None] * N for i in range(N): X, L = list(map(int, input().split())) R[i] = (X-L, X+L) # 右端でソート R.sort(key=lambda x: x[1]) ans = N max_R = R[0][1] for i in range(1, N): if R[i][0] < max_R: ans -= 1 else: max_R = R[i][1] print(ans)
16
16
417
359
N = int(eval(input())) R = [tuple(map(int, input().split())) for _ in range(N)] # 左端でソート R.sort(key=lambda x: x[0] - x[1]) prev_L_arm = R[0][0] - R[0][1] prev_R_arm = R[0][0] + R[0][1] ans = N for i in range(1, N): L_arm = R[i][0] - R[i][1] R_arm = R[i][0] + R[i][1] if L_arm < prev_R_arm: prev_R_arm = min(prev_R_arm, R_arm) ans -= 1 else: prev_R_arm = R_arm print(ans)
# 解き直し https://atcoder.jp/contests/keyence2020/tasks/keyence2020_b N = int(eval(input())) R = [None] * N for i in range(N): X, L = list(map(int, input().split())) R[i] = (X - L, X + L) # 右端でソート R.sort(key=lambda x: x[1]) ans = N max_R = R[0][1] for i in range(1, N): if R[i][0] < max_R: ans -= 1 else: max_R = R[i][1] print(ans)
false
0
[ "+# 解き直し https://atcoder.jp/contests/keyence2020/tasks/keyence2020_b", "-R = [tuple(map(int, input().split())) for _ in range(N)]", "-# 左端でソート", "-R.sort(key=lambda x: x[0] - x[1])", "-prev_L_arm = R[0][0] - R[0][1]", "-prev_R_arm = R[0][0] + R[0][1]", "+R = [None] * N", "+for i in range(N):", "+ X, L = list(map(int, input().split()))", "+ R[i] = (X - L, X + L)", "+# 右端でソート", "+R.sort(key=lambda x: x[1])", "+max_R = R[0][1]", "- L_arm = R[i][0] - R[i][1]", "- R_arm = R[i][0] + R[i][1]", "- if L_arm < prev_R_arm:", "- prev_R_arm = min(prev_R_arm, R_arm)", "+ if R[i][0] < max_R:", "- prev_R_arm = R_arm", "+ max_R = R[i][1]" ]
false
0.051115
0.051025
1.00175
[ "s433165849", "s118876826" ]
u924467864
p03011
python
s204613449
s699339717
298
149
21,144
12,508
Accepted
Accepted
50
import numpy as np p, q, r = list(map(int, input().split())) list = [p, q, r] max_ = max(list) sum_ = sum(list) - max_ print(sum_)
import numpy as np P,Q,R = (int(x) for x in input().split()) times = [] times.append(P+Q) times.append(P+R) times.append(Q+R) print((min(times)))
12
11
142
157
import numpy as np p, q, r = list(map(int, input().split())) list = [p, q, r] max_ = max(list) sum_ = sum(list) - max_ print(sum_)
import numpy as np P, Q, R = (int(x) for x in input().split()) times = [] times.append(P + Q) times.append(P + R) times.append(Q + R) print((min(times)))
false
8.333333
[ "-p, q, r = list(map(int, input().split()))", "-list = [p, q, r]", "-max_ = max(list)", "-sum_ = sum(list) - max_", "-print(sum_)", "+P, Q, R = (int(x) for x in input().split())", "+times = []", "+times.append(P + Q)", "+times.append(P + R)", "+times.append(Q + R)", "+print((min(times)))" ]
false
0.046215
0.211775
0.218226
[ "s204613449", "s699339717" ]
u345966487
p03329
python
s474058173
s417464318
503
407
6,900
4,596
Accepted
Accepted
19.09
N = int(eval(input())) t = list(range(N+1)) for i in range(2, N+1): x = t[i-1] + 1 p6, p9 = 6, 9 while i-p6 >= 0: x = min(x, t[i-p6] + 1) p6 *= 6 while i-p9 >= 0: x = min(x, t[i-p9] + 1) p9 *= 9 t[i] = x print((t[N]))
N=int(eval(input()));t=[0]+[N]*N for i in range(1,N+1): x,a,b=t[i-1],6,9 while a<=i:x=min(x,t[i-a],t[i-b]if b<=i else N);a*=6;b*=9 t[i]=x+1 print((t[N]))
13
6
274
153
N = int(eval(input())) t = list(range(N + 1)) for i in range(2, N + 1): x = t[i - 1] + 1 p6, p9 = 6, 9 while i - p6 >= 0: x = min(x, t[i - p6] + 1) p6 *= 6 while i - p9 >= 0: x = min(x, t[i - p9] + 1) p9 *= 9 t[i] = x print((t[N]))
N = int(eval(input())) t = [0] + [N] * N for i in range(1, N + 1): x, a, b = t[i - 1], 6, 9 while a <= i: x = min(x, t[i - a], t[i - b] if b <= i else N) a *= 6 b *= 9 t[i] = x + 1 print((t[N]))
false
53.846154
[ "-t = list(range(N + 1))", "-for i in range(2, N + 1):", "- x = t[i - 1] + 1", "- p6, p9 = 6, 9", "- while i - p6 >= 0:", "- x = min(x, t[i - p6] + 1)", "- p6 *= 6", "- while i - p9 >= 0:", "- x = min(x, t[i - p9] + 1)", "- p9 *= 9", "- t[i] = x", "+t = [0] + [N] * N", "+for i in range(1, N + 1):", "+ x, a, b = t[i - 1], 6, 9", "+ while a <= i:", "+ x = min(x, t[i - a], t[i - b] if b <= i else N)", "+ a *= 6", "+ b *= 9", "+ t[i] = x + 1" ]
false
0.099137
0.215007
0.461089
[ "s474058173", "s417464318" ]
u588341295
p03566
python
s155851650
s656418937
933
421
3,064
3,188
Accepted
Accepted
54.88
# -*- coding: utf-8 -*- """ 参考:http://ferin-tech.hatenablog.com/entry/2017/10/28/231616 ・愚直に3重ループでシミュレーション """ N = int(eval(input())) tN = list(map(int, input().split())) vN = list(map(int, input().split())) # 終点の処理をしやすくするため追加 tN.append(0) vN.append(0) dist = 0 speed = 0 for i in range(N): keep = True plus = True # 小数刻みのfor文 for j in [0.5*x for x in range(tN[i]*2)]: # 現在の最大スピードに達した if speed == vN[i]: plus = False rest = tN[i] - j # 今より先で、下げきれなくなる状況がないか確認 for k in range(i+1, N+1): if vN[k] < vN[i] and rest <= speed - vN[k]: keep = False plus = False rest += tN[k] # フラグの状況に合わせて加速or維持or減速 if plus: # ここでの数値の加減は進み方が0.5刻みなので注意する dist += speed/2 speed += 0.5 dist += 0.125 elif keep: dist += speed/2 else: speed -= 0.5 dist += speed/2 dist += 0.125 print(dist)
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print('Yes') def No(): print('No') def YES(): print('YES') def NO(): print('NO') sys.setrecursionlimit(10 ** 9) INF = 10 ** 18 MOD = 10 ** 9 + 7 N = INT() # 0.5考慮のため*2、終了時0のため番兵 A = [a*2 for a in LIST()] + [1] B = [b*2 for b in LIST()] + [0] def check1(i, t): nxtt = cur for j in range(i+1, N+1): nxtt += A[j-1] dist = nxtt - t # 1つ先で+1の状態でいても大丈夫かどうか if spd + 2 - dist > B[j]: return False return True def check2(i, t): nxtt = cur for j in range(i+1, N+1): nxtt += A[j-1] dist = nxtt - t # 1つ先で今と同じ(+-0)の状態でいても大丈夫かどうか if spd + 1 - dist > B[j]: return False return True cur = spd = sm = 0 for i, a in enumerate(A[:N]): b = B[i] # 各時点tにおいて加速、維持が可能かどうか確認 for t in range(cur, cur+a): # 加速OK if spd + 1 <= b and check1(i, t): # この瞬間の加算分は増減の半分にする sm += spd + 0.5 spd += 1 # 維持OK elif spd <= b and check2(i, t): sm += spd # 減速必須 else: sm += spd - 0.5 spd -= 1 cur += a print((sm / 4))
44
64
1,054
1,722
# -*- coding: utf-8 -*- """ 参考:http://ferin-tech.hatenablog.com/entry/2017/10/28/231616 ・愚直に3重ループでシミュレーション """ N = int(eval(input())) tN = list(map(int, input().split())) vN = list(map(int, input().split())) # 終点の処理をしやすくするため追加 tN.append(0) vN.append(0) dist = 0 speed = 0 for i in range(N): keep = True plus = True # 小数刻みのfor文 for j in [0.5 * x for x in range(tN[i] * 2)]: # 現在の最大スピードに達した if speed == vN[i]: plus = False rest = tN[i] - j # 今より先で、下げきれなくなる状況がないか確認 for k in range(i + 1, N + 1): if vN[k] < vN[i] and rest <= speed - vN[k]: keep = False plus = False rest += tN[k] # フラグの状況に合わせて加速or維持or減速 if plus: # ここでの数値の加減は進み方が0.5刻みなので注意する dist += speed / 2 speed += 0.5 dist += 0.125 elif keep: dist += speed / 2 else: speed -= 0.5 dist += speed / 2 dist += 0.125 print(dist)
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print("Yes") def No(): print("No") def YES(): print("YES") def NO(): print("NO") sys.setrecursionlimit(10**9) INF = 10**18 MOD = 10**9 + 7 N = INT() # 0.5考慮のため*2、終了時0のため番兵 A = [a * 2 for a in LIST()] + [1] B = [b * 2 for b in LIST()] + [0] def check1(i, t): nxtt = cur for j in range(i + 1, N + 1): nxtt += A[j - 1] dist = nxtt - t # 1つ先で+1の状態でいても大丈夫かどうか if spd + 2 - dist > B[j]: return False return True def check2(i, t): nxtt = cur for j in range(i + 1, N + 1): nxtt += A[j - 1] dist = nxtt - t # 1つ先で今と同じ(+-0)の状態でいても大丈夫かどうか if spd + 1 - dist > B[j]: return False return True cur = spd = sm = 0 for i, a in enumerate(A[:N]): b = B[i] # 各時点tにおいて加速、維持が可能かどうか確認 for t in range(cur, cur + a): # 加速OK if spd + 1 <= b and check1(i, t): # この瞬間の加算分は増減の半分にする sm += spd + 0.5 spd += 1 # 維持OK elif spd <= b and check2(i, t): sm += spd # 減速必須 else: sm += spd - 0.5 spd -= 1 cur += a print((sm / 4))
false
31.25
[ "-\"\"\"", "-参考:http://ferin-tech.hatenablog.com/entry/2017/10/28/231616", "-・愚直に3重ループでシミュレーション", "-\"\"\"", "-N = int(eval(input()))", "-tN = list(map(int, input().split()))", "-vN = list(map(int, input().split()))", "-# 終点の処理をしやすくするため追加", "-tN.append(0)", "-vN.append(0)", "-dist = 0", "-speed = 0", "-for i in range(N):", "- keep = True", "- plus = True", "- # 小数刻みのfor文", "- for j in [0.5 * x for x in range(tN[i] * 2)]:", "- # 現在の最大スピードに達した", "- if speed == vN[i]:", "- plus = False", "- rest = tN[i] - j", "- # 今より先で、下げきれなくなる状況がないか確認", "- for k in range(i + 1, N + 1):", "- if vN[k] < vN[i] and rest <= speed - vN[k]:", "- keep = False", "- plus = False", "- rest += tN[k]", "- # フラグの状況に合わせて加速or維持or減速", "- if plus:", "- # ここでの数値の加減は進み方が0.5刻みなので注意する", "- dist += speed / 2", "- speed += 0.5", "- dist += 0.125", "- elif keep:", "- dist += speed / 2", "+import sys", "+", "+", "+def input():", "+ return sys.stdin.readline().strip()", "+", "+", "+def list2d(a, b, c):", "+ return [[c] * b for i in range(a)]", "+", "+", "+def list3d(a, b, c, d):", "+ return [[[d] * c for j in range(b)] for i in range(a)]", "+", "+", "+def list4d(a, b, c, d, e):", "+ return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]", "+", "+", "+def ceil(x, y=1):", "+ return int(-(-x // y))", "+", "+", "+def INT():", "+ return int(eval(input()))", "+", "+", "+def MAP():", "+ return list(map(int, input().split()))", "+", "+", "+def LIST(N=None):", "+ return list(MAP()) if N is None else [INT() for i in range(N)]", "+", "+", "+def Yes():", "+ print(\"Yes\")", "+", "+", "+def No():", "+ print(\"No\")", "+", "+", "+def YES():", "+ print(\"YES\")", "+", "+", "+def NO():", "+ print(\"NO\")", "+", "+", "+sys.setrecursionlimit(10**9)", "+INF = 10**18", "+MOD = 10**9 + 7", "+N = INT()", "+# 0.5考慮のため*2、終了時0のため番兵", "+A = [a * 2 for a in LIST()] + [1]", "+B = [b * 2 for b in LIST()] + [0]", "+", "+", "+def check1(i, t):", "+ nxtt = cur", "+ for j in range(i + 1, N + 1):", "+ nxtt += A[j - 1]", "+ dist = nxtt - t", "+ # 1つ先で+1の状態でいても大丈夫かどうか", "+ if spd + 2 - dist > B[j]:", "+ return False", "+ return True", "+", "+", "+def check2(i, t):", "+ nxtt = cur", "+ for j in range(i + 1, N + 1):", "+ nxtt += A[j - 1]", "+ dist = nxtt - t", "+ # 1つ先で今と同じ(+-0)の状態でいても大丈夫かどうか", "+ if spd + 1 - dist > B[j]:", "+ return False", "+ return True", "+", "+", "+cur = spd = sm = 0", "+for i, a in enumerate(A[:N]):", "+ b = B[i]", "+ # 各時点tにおいて加速、維持が可能かどうか確認", "+ for t in range(cur, cur + a):", "+ # 加速OK", "+ if spd + 1 <= b and check1(i, t):", "+ # この瞬間の加算分は増減の半分にする", "+ sm += spd + 0.5", "+ spd += 1", "+ # 維持OK", "+ elif spd <= b and check2(i, t):", "+ sm += spd", "+ # 減速必須", "- speed -= 0.5", "- dist += speed / 2", "- dist += 0.125", "-print(dist)", "+ sm += spd - 0.5", "+ spd -= 1", "+ cur += a", "+print((sm / 4))" ]
false
0.079159
0.041903
1.889116
[ "s155851650", "s656418937" ]
u509739538
p02780
python
s999876624
s324977615
1,211
251
26,624
26,624
Accepted
Accepted
79.27
import math import queue from collections import defaultdict def readInt(): return int(eval(input())) def readInts(): return list(map(int, input().split())) def readChar(): return eval(input()) def readChars(): return input().split() def factorization(n): res = [] if n%2==0: res.append(2) for i in range(3,math.floor(n//2)+1,2): if n%i==0: c = 0 for j in res: if i%j==0: c=1 if c==0: res.append(i) return res def fact2(n): p = factorization(n) res = [] for i in p: c=0 z=n while 1: if z%i==0: c+=1 z/=i else: break res.append([i,c]) return res def fact(n):#階乗 ans = 1 m=n for _i in range(n-1): ans*=m m-=1 return ans def comb(n,r):#コンビネーション if n<r: return 0 l = min(r,n-r) m=n u=1 for _i in range(l): u*=m m-=1 return u//fact(l) def combmod(n,r,mod): return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod def printQueue(q): r=qb ans=[0]*r.qsize() for i in range(r.qsize()-1,-1,-1): ans[i] = r.get() print(ans) def dq(): return queue.deque() class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1]*n def find(self, x): # root if self.parents[x]<0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self,x,y): x = self.find(x) y = self.find(y) if x==y: return if self.parents[x]>self.parents[y]: x,y = y,x self.parents[x]+=self.parents[y] self.parents[y]=x def size(self,x): return -1*self.parents[self.find(x)] def same(self,x,y): return self.find(x)==self.find(y) def members(self,x): # much time root = self.find(x) return [i for i in range(self.n) if self.find(i)==root] def roots(self): return [i for i,x in enumerate(self.parents) if x<0] def group_count(self): return len(self.roots()) def all_group_members(self): return {r: self.members(r) for r in self.roots()} # 1~n def bitArr(n):#ビット全探索 x = 1 zero = "0"*n ans = [] ans.append([0]*n) for i in range(2**n-1): ans.append(list([int(x) for x in list((zero+bin(x)[2:])[-1*n:])])) x+=1 return ans; def arrsSum(a1,a2): for i in range(len(a1)): a1[i]+=a2[i] return a1 def maxValue(a,b,v): v2 = v for i in range(v2,-1,-1): for j in range(v2//a+1): #j:aの個数 k = i-a*j if k%b==0: return i return -1 n,k = readInts() p = readInts() #print(p) maxValue = sum(p[0:k]) be = maxValue memo = p[0:k] ans = 0 for i in range(1,n-k+1): be+=-p[i-1]+p[i+k-1] if maxValue<be: maxValue = sum(p[i:i+k]) memo = p[i:i+k] for i in range(k): ans+=(memo[i]+1)/2 print(ans)
import math import queue from collections import defaultdict def readInt(): return int(eval(input())) def readInts(): return list(map(int, input().split())) def readChar(): return eval(input()) def readChars(): return input().split() def factorization(n): res = [] if n%2==0: res.append(2) for i in range(3,math.floor(n//2)+1,2): if n%i==0: c = 0 for j in res: if i%j==0: c=1 if c==0: res.append(i) return res def fact2(n): p = factorization(n) res = [] for i in p: c=0 z=n while 1: if z%i==0: c+=1 z/=i else: break res.append([i,c]) return res def fact(n):#階乗 ans = 1 m=n for _i in range(n-1): ans*=m m-=1 return ans def comb(n,r):#コンビネーション if n<r: return 0 l = min(r,n-r) m=n u=1 for _i in range(l): u*=m m-=1 return u//fact(l) def combmod(n,r,mod): return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod def printQueue(q): r=qb ans=[0]*r.qsize() for i in range(r.qsize()-1,-1,-1): ans[i] = r.get() print(ans) def dq(): return queue.deque() class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1]*n def find(self, x): # root if self.parents[x]<0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self,x,y): x = self.find(x) y = self.find(y) if x==y: return if self.parents[x]>self.parents[y]: x,y = y,x self.parents[x]+=self.parents[y] self.parents[y]=x def size(self,x): return -1*self.parents[self.find(x)] def same(self,x,y): return self.find(x)==self.find(y) def members(self,x): # much time root = self.find(x) return [i for i in range(self.n) if self.find(i)==root] def roots(self): return [i for i,x in enumerate(self.parents) if x<0] def group_count(self): return len(self.roots()) def all_group_members(self): return {r: self.members(r) for r in self.roots()} # 1~n def bitArr(n):#ビット全探索 x = 1 zero = "0"*n ans = [] ans.append([0]*n) for i in range(2**n-1): ans.append(list([int(x) for x in list((zero+bin(x)[2:])[-1*n:])])) x+=1 return ans; def arrsSum(a1,a2): for i in range(len(a1)): a1[i]+=a2[i] return a1 def maxValue(a,b,v): v2 = v for i in range(v2,-1,-1): for j in range(v2//a+1): #j:aの個数 k = i-a*j if k%b==0: return i return -1 n,k = readInts() p = readInts() s = [] s.append((p[0]+1)/2) for i in range(1,n): s.append(s[-1]+(p[i]+1)/2) ans = s[k-1] #print(s) for i in range(n-k): ans = max(ans,s[i+k]-s[i]) print(ans)
148
146
2,699
2,631
import math import queue from collections import defaultdict def readInt(): return int(eval(input())) def readInts(): return list(map(int, input().split())) def readChar(): return eval(input()) def readChars(): return input().split() def factorization(n): res = [] if n % 2 == 0: res.append(2) for i in range(3, math.floor(n // 2) + 1, 2): if n % i == 0: c = 0 for j in res: if i % j == 0: c = 1 if c == 0: res.append(i) return res def fact2(n): p = factorization(n) res = [] for i in p: c = 0 z = n while 1: if z % i == 0: c += 1 z /= i else: break res.append([i, c]) return res def fact(n): # 階乗 ans = 1 m = n for _i in range(n - 1): ans *= m m -= 1 return ans def comb(n, r): # コンビネーション if n < r: return 0 l = min(r, n - r) m = n u = 1 for _i in range(l): u *= m m -= 1 return u // fact(l) def combmod(n, r, mod): return (fact(n) / fact(n - r) * pow(fact(r), mod - 2, mod)) % mod def printQueue(q): r = qb ans = [0] * r.qsize() for i in range(r.qsize() - 1, -1, -1): ans[i] = r.get() print(ans) def dq(): return queue.deque() class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): # root if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -1 * self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): # much time root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) def all_group_members(self): return {r: self.members(r) for r in self.roots()} # 1~n def bitArr(n): # ビット全探索 x = 1 zero = "0" * n ans = [] ans.append([0] * n) for i in range(2**n - 1): ans.append(list([int(x) for x in list((zero + bin(x)[2:])[-1 * n :])])) x += 1 return ans def arrsSum(a1, a2): for i in range(len(a1)): a1[i] += a2[i] return a1 def maxValue(a, b, v): v2 = v for i in range(v2, -1, -1): for j in range(v2 // a + 1): # j:aの個数 k = i - a * j if k % b == 0: return i return -1 n, k = readInts() p = readInts() # print(p) maxValue = sum(p[0:k]) be = maxValue memo = p[0:k] ans = 0 for i in range(1, n - k + 1): be += -p[i - 1] + p[i + k - 1] if maxValue < be: maxValue = sum(p[i : i + k]) memo = p[i : i + k] for i in range(k): ans += (memo[i] + 1) / 2 print(ans)
import math import queue from collections import defaultdict def readInt(): return int(eval(input())) def readInts(): return list(map(int, input().split())) def readChar(): return eval(input()) def readChars(): return input().split() def factorization(n): res = [] if n % 2 == 0: res.append(2) for i in range(3, math.floor(n // 2) + 1, 2): if n % i == 0: c = 0 for j in res: if i % j == 0: c = 1 if c == 0: res.append(i) return res def fact2(n): p = factorization(n) res = [] for i in p: c = 0 z = n while 1: if z % i == 0: c += 1 z /= i else: break res.append([i, c]) return res def fact(n): # 階乗 ans = 1 m = n for _i in range(n - 1): ans *= m m -= 1 return ans def comb(n, r): # コンビネーション if n < r: return 0 l = min(r, n - r) m = n u = 1 for _i in range(l): u *= m m -= 1 return u // fact(l) def combmod(n, r, mod): return (fact(n) / fact(n - r) * pow(fact(r), mod - 2, mod)) % mod def printQueue(q): r = qb ans = [0] * r.qsize() for i in range(r.qsize() - 1, -1, -1): ans[i] = r.get() print(ans) def dq(): return queue.deque() class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): # root if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -1 * self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): # much time root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) def all_group_members(self): return {r: self.members(r) for r in self.roots()} # 1~n def bitArr(n): # ビット全探索 x = 1 zero = "0" * n ans = [] ans.append([0] * n) for i in range(2**n - 1): ans.append(list([int(x) for x in list((zero + bin(x)[2:])[-1 * n :])])) x += 1 return ans def arrsSum(a1, a2): for i in range(len(a1)): a1[i] += a2[i] return a1 def maxValue(a, b, v): v2 = v for i in range(v2, -1, -1): for j in range(v2 // a + 1): # j:aの個数 k = i - a * j if k % b == 0: return i return -1 n, k = readInts() p = readInts() s = [] s.append((p[0] + 1) / 2) for i in range(1, n): s.append(s[-1] + (p[i] + 1) / 2) ans = s[k - 1] # print(s) for i in range(n - k): ans = max(ans, s[i + k] - s[i]) print(ans)
false
1.351351
[ "-# print(p)", "-maxValue = sum(p[0:k])", "-be = maxValue", "-memo = p[0:k]", "-ans = 0", "-for i in range(1, n - k + 1):", "- be += -p[i - 1] + p[i + k - 1]", "- if maxValue < be:", "- maxValue = sum(p[i : i + k])", "- memo = p[i : i + k]", "-for i in range(k):", "- ans += (memo[i] + 1) / 2", "+s = []", "+s.append((p[0] + 1) / 2)", "+for i in range(1, n):", "+ s.append(s[-1] + (p[i] + 1) / 2)", "+ans = s[k - 1]", "+# print(s)", "+for i in range(n - k):", "+ ans = max(ans, s[i + k] - s[i])" ]
false
0.038821
0.036986
1.049614
[ "s999876624", "s324977615" ]
u753803401
p03478
python
s547989509
s664519875
46
37
2,940
3,060
Accepted
Accepted
19.57
n, a, b = list(map(int, input().split())) total_sum = 0 for i in range(1, n + 1): total = 0 for j in range(len(str(i))): total += int(str(i)[j]) if a <= total <= b: total_sum += i print(total_sum)
n, a, b = list(map(int, input().split())) s = 0 for i in range(1, n + 1): t = str(i) total = sum(list(map(int, list(t)))) if a <= total <= b: s += i print(s)
9
8
227
179
n, a, b = list(map(int, input().split())) total_sum = 0 for i in range(1, n + 1): total = 0 for j in range(len(str(i))): total += int(str(i)[j]) if a <= total <= b: total_sum += i print(total_sum)
n, a, b = list(map(int, input().split())) s = 0 for i in range(1, n + 1): t = str(i) total = sum(list(map(int, list(t)))) if a <= total <= b: s += i print(s)
false
11.111111
[ "-total_sum = 0", "+s = 0", "- total = 0", "- for j in range(len(str(i))):", "- total += int(str(i)[j])", "+ t = str(i)", "+ total = sum(list(map(int, list(t))))", "- total_sum += i", "-print(total_sum)", "+ s += i", "+print(s)" ]
false
0.077059
0.038242
2.015032
[ "s547989509", "s664519875" ]
u811967730
p03557
python
s414878773
s964113485
1,399
877
24,052
23,312
Accepted
Accepted
37.31
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort() C.sort() ans = 0 for b in B: l = -1 r = N while r - l > 1: m = (r + l) // 2 if A[m] < b: l = m else: r = m a_cnt = l + 1 if l != -1 else 0 l = -1 r = N while r - l > 1: m = (r + l) // 2 if C[m] > b: r = m else: l = m c_cnt = N - r ans += a_cnt * c_cnt print(ans)
import sys input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) def count_a(A, X): l = -1 r = N while r - l > 1: m = (r + l) // 2 if A[m] < b: l = m else: r = m return l + 1 def count_c(C, X): l = -1 r = N while r - l > 1: m = (r + l) // 2 if C[m] > b: r = m else: l = m return N - r A.sort() B.sort() C.sort() ans = 0 A_min = A[0] C_max = C[-1] for b in B: if b <= A_min or b >= C_max: continue a_cnt = count_a(A, b) if a_cnt == 0: continue c_cnt = count_c(C, b) ans += a_cnt * c_cnt print(ans)
35
54
578
825
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort() C.sort() ans = 0 for b in B: l = -1 r = N while r - l > 1: m = (r + l) // 2 if A[m] < b: l = m else: r = m a_cnt = l + 1 if l != -1 else 0 l = -1 r = N while r - l > 1: m = (r + l) // 2 if C[m] > b: r = m else: l = m c_cnt = N - r ans += a_cnt * c_cnt print(ans)
import sys input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) def count_a(A, X): l = -1 r = N while r - l > 1: m = (r + l) // 2 if A[m] < b: l = m else: r = m return l + 1 def count_c(C, X): l = -1 r = N while r - l > 1: m = (r + l) // 2 if C[m] > b: r = m else: l = m return N - r A.sort() B.sort() C.sort() ans = 0 A_min = A[0] C_max = C[-1] for b in B: if b <= A_min or b >= C_max: continue a_cnt = count_a(A, b) if a_cnt == 0: continue c_cnt = count_c(C, b) ans += a_cnt * c_cnt print(ans)
false
35.185185
[ "+import sys", "+", "+input = sys.stdin.readline", "-A.sort()", "-B.sort()", "-C.sort()", "-ans = 0", "-for b in B:", "+", "+", "+def count_a(A, X):", "- a_cnt = l + 1 if l != -1 else 0", "+ return l + 1", "+", "+", "+def count_c(C, X):", "- c_cnt = N - r", "+ return N - r", "+", "+", "+A.sort()", "+B.sort()", "+C.sort()", "+ans = 0", "+A_min = A[0]", "+C_max = C[-1]", "+for b in B:", "+ if b <= A_min or b >= C_max:", "+ continue", "+ a_cnt = count_a(A, b)", "+ if a_cnt == 0:", "+ continue", "+ c_cnt = count_c(C, b)" ]
false
0.041838
0.042332
0.988331
[ "s414878773", "s964113485" ]
u580697892
p03212
python
s315380775
s538918944
1,926
782
3,436
61,784
Accepted
Accepted
59.4
#coding: utf-8 from collections import Counter N = int(eval(input())) l = ["0", "3", "5", "7"] ans = ["0" for _ in range(9)] cnt = 0 for a in l: ans[0] = a for b in l: ans[1] = b for c in l: ans[2] = c for d in l: ans[3] = d for e in l: ans[4] = e for f in l: ans[5] = f for g in l: ans[6] = g for h in l: ans[7] = h for i in l: ans[8] = i ans_i = int("".join(ans)) ans_c = Counter(str(ans_i)) if ans_i <= N and "0" not in str(ans_i) and len(list(ans_c.keys())) == 3 and len(str(ans_i)) >= 3: cnt += 1 print(cnt)
#coding: utf-8 from collections import Counter N = int(eval(input())) l = ["0", "3", "5", "7"] ans = ["0"] * 9 cnt = 0 for a in l: ans[0] = a for b in l: ans[1] = b for c in l: ans[2] = c for d in l: ans[3] = d for e in l: ans[4] = e for f in l: ans[5] = f for g in l: ans[6] = g for h in l: ans[7] = h for i in l: ans[8] = i ans_i = int("".join(ans)) ans_c = Counter(str(ans_i)) if ans_i <= N and "0" not in str(ans_i) and len(list(ans_c.keys())) == 3 and len(str(ans_i)) >= 3: cnt += 1 print(cnt)
29
29
1,000
986
# coding: utf-8 from collections import Counter N = int(eval(input())) l = ["0", "3", "5", "7"] ans = ["0" for _ in range(9)] cnt = 0 for a in l: ans[0] = a for b in l: ans[1] = b for c in l: ans[2] = c for d in l: ans[3] = d for e in l: ans[4] = e for f in l: ans[5] = f for g in l: ans[6] = g for h in l: ans[7] = h for i in l: ans[8] = i ans_i = int("".join(ans)) ans_c = Counter(str(ans_i)) if ( ans_i <= N and "0" not in str(ans_i) and len(list(ans_c.keys())) == 3 and len(str(ans_i)) >= 3 ): cnt += 1 print(cnt)
# coding: utf-8 from collections import Counter N = int(eval(input())) l = ["0", "3", "5", "7"] ans = ["0"] * 9 cnt = 0 for a in l: ans[0] = a for b in l: ans[1] = b for c in l: ans[2] = c for d in l: ans[3] = d for e in l: ans[4] = e for f in l: ans[5] = f for g in l: ans[6] = g for h in l: ans[7] = h for i in l: ans[8] = i ans_i = int("".join(ans)) ans_c = Counter(str(ans_i)) if ( ans_i <= N and "0" not in str(ans_i) and len(list(ans_c.keys())) == 3 and len(str(ans_i)) >= 3 ): cnt += 1 print(cnt)
false
0
[ "-ans = [\"0\" for _ in range(9)]", "+ans = [\"0\"] * 9" ]
false
2.509825
1.628907
1.540803
[ "s315380775", "s538918944" ]
u025287757
p03634
python
s965004532
s256693535
1,647
1,030
137,884
140,540
Accepted
Accepted
37.46
import sys sys.setrecursionlimit(10**8) N = int(eval(input())) a = [[] for i in range(N)] for i in range(N-1): A, B, C = list(map(int, input().split())) a[A-1].append([B-1, C]) a[B-1].append([A-1, C]) dist = [-1]*N Q, K = list(map(int, input().split())) dist[K-1] = 0 def dfs(now): for i, dis_e in a[now]: if dist[i] == -1: dist[i] = dist[now] + dis_e dfs(i) def main(): dfs(K-1) ans = [] for i in range(Q): x, y = list(map(int, input().split())) print((dist[x-1]+dist[y-1])) #print(*ans, sep = "\n") if __name__ == "__main__": main()
import sys sys.setrecursionlimit(10**8) N = int(input()) a = [[] for i in range(N)] for i in range(N-1): A, B, C = map(int, input().split()) a[A-1].append([B-1, C]) a[B-1].append([A-1, C]) dist = [-1]*N Q, K = map(int, input().split()) dist[K-1] = 0 def dfs(now): for i, dis_e in a[now]: if dist[i] == -1: dist[i] = dist[now] + dis_e dfs(i) def main(): dfs(K-1) ans = [] for i in range(Q): x, y = map(int, input().split()) ans.append(dist[x-1]+dist[y-1]) print(*ans, sep = "\n") if __name__ == "__main__": main()
28
28
580
584
import sys sys.setrecursionlimit(10**8) N = int(eval(input())) a = [[] for i in range(N)] for i in range(N - 1): A, B, C = list(map(int, input().split())) a[A - 1].append([B - 1, C]) a[B - 1].append([A - 1, C]) dist = [-1] * N Q, K = list(map(int, input().split())) dist[K - 1] = 0 def dfs(now): for i, dis_e in a[now]: if dist[i] == -1: dist[i] = dist[now] + dis_e dfs(i) def main(): dfs(K - 1) ans = [] for i in range(Q): x, y = list(map(int, input().split())) print((dist[x - 1] + dist[y - 1])) # print(*ans, sep = "\n") if __name__ == "__main__": main()
import sys sys.setrecursionlimit(10**8) N = int(input()) a = [[] for i in range(N)] for i in range(N - 1): A, B, C = map(int, input().split()) a[A - 1].append([B - 1, C]) a[B - 1].append([A - 1, C]) dist = [-1] * N Q, K = map(int, input().split()) dist[K - 1] = 0 def dfs(now): for i, dis_e in a[now]: if dist[i] == -1: dist[i] = dist[now] + dis_e dfs(i) def main(): dfs(K - 1) ans = [] for i in range(Q): x, y = map(int, input().split()) ans.append(dist[x - 1] + dist[y - 1]) print(*ans, sep="\n") if __name__ == "__main__": main()
false
0
[ "-N = int(eval(input()))", "+N = int(input())", "- A, B, C = list(map(int, input().split()))", "+ A, B, C = map(int, input().split())", "-Q, K = list(map(int, input().split()))", "+Q, K = map(int, input().split())", "- x, y = list(map(int, input().split()))", "- print((dist[x - 1] + dist[y - 1]))", "- # print(*ans, sep = \"\\n\")", "+ x, y = map(int, input().split())", "+ ans.append(dist[x - 1] + dist[y - 1])", "+ print(*ans, sep=\"\\n\")" ]
false
0.046912
0.045709
1.026315
[ "s965004532", "s256693535" ]
u609061751
p02821
python
s330758811
s707458044
1,941
1,699
59,100
59,664
Accepted
Accepted
12.47
import sys input = sys.stdin.readline import bisect from itertools import accumulate N, M = [int(x) for x in input().split()] A = [int(x) for x in input().split()] A.sort() left = -1 right = 10 ** 6 def shake(x): cnt = 0 for i in A: cnt += N - bisect.bisect_left(A, x - i) if cnt >= M: return 1 else: return 0 while True: mid = (left + right) // 2 if shake(mid): if not shake(mid + 1): X = mid break else: left = mid else: if shake(mid - 1): X = mid - 1 break else: right = mid happy = 0 cumsum_A = list(accumulate(A)) for j in A: idx = bisect.bisect_right(A, X - j) cnt = N - idx if cnt == N: happy += cumsum_A[-1] + cnt * j else: happy += cumsum_A[-1] - cumsum_A[idx - 1] + cnt * j M -= cnt happy += M * X print(happy)
import sys input = sys.stdin.readline import bisect from itertools import accumulate N, M = [int(x) for x in input().split()] A = [int(x) for x in input().split()] A.sort() left = -1 right = 1 + 2 * 10 ** 5 def shake(x): cnt = 0 for i in A: cnt += N - bisect.bisect_left(A, x - i) if cnt >= M: return 1 else: return 0 while True: mid = (left + right) // 2 if shake(mid): if not shake(mid + 1): X = mid break else: left = mid else: if shake(mid - 1): X = mid - 1 break else: right = mid happy = 0 cumsum_A = list(accumulate(A)) for j in A: idx = bisect.bisect_right(A, X - j) cnt = N - idx if cnt == N: happy += cumsum_A[-1] + cnt * j else: happy += cumsum_A[-1] - cumsum_A[idx - 1] + cnt * j M -= cnt happy += M * X print(happy)
52
52
973
981
import sys input = sys.stdin.readline import bisect from itertools import accumulate N, M = [int(x) for x in input().split()] A = [int(x) for x in input().split()] A.sort() left = -1 right = 10**6 def shake(x): cnt = 0 for i in A: cnt += N - bisect.bisect_left(A, x - i) if cnt >= M: return 1 else: return 0 while True: mid = (left + right) // 2 if shake(mid): if not shake(mid + 1): X = mid break else: left = mid else: if shake(mid - 1): X = mid - 1 break else: right = mid happy = 0 cumsum_A = list(accumulate(A)) for j in A: idx = bisect.bisect_right(A, X - j) cnt = N - idx if cnt == N: happy += cumsum_A[-1] + cnt * j else: happy += cumsum_A[-1] - cumsum_A[idx - 1] + cnt * j M -= cnt happy += M * X print(happy)
import sys input = sys.stdin.readline import bisect from itertools import accumulate N, M = [int(x) for x in input().split()] A = [int(x) for x in input().split()] A.sort() left = -1 right = 1 + 2 * 10**5 def shake(x): cnt = 0 for i in A: cnt += N - bisect.bisect_left(A, x - i) if cnt >= M: return 1 else: return 0 while True: mid = (left + right) // 2 if shake(mid): if not shake(mid + 1): X = mid break else: left = mid else: if shake(mid - 1): X = mid - 1 break else: right = mid happy = 0 cumsum_A = list(accumulate(A)) for j in A: idx = bisect.bisect_right(A, X - j) cnt = N - idx if cnt == N: happy += cumsum_A[-1] + cnt * j else: happy += cumsum_A[-1] - cumsum_A[idx - 1] + cnt * j M -= cnt happy += M * X print(happy)
false
0
[ "-right = 10**6", "+right = 1 + 2 * 10**5" ]
false
0.045289
0.046023
0.984046
[ "s330758811", "s707458044" ]
u606878291
p04031
python
s190531707
s708502311
121
33
5,332
5,076
Accepted
Accepted
72.73
import math from functools import lru_cache @lru_cache(maxsize=4096) def get_cost(x, y): return int(math.pow((x - y), 2)) def get_costs(target, numbers): return sum([get_cost(target, n) for n in numbers]) def check(n, numbers): n_max = max(numbers) n_min = min(numbers) costs = [] for target in range(n_min, n_max + 1): costs.append(get_costs(target=target, numbers=numbers)) return min(costs) def main(): N = int(eval(input())) numbers = list(map(int, input().split())) print((check(n=N, numbers=numbers))) if __name__ == '__main__': main()
import math from decimal import Decimal, ROUND_HALF_UP def quantize(f): return int(Decimal(str(f)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)) def check(n, numbers): average = sum(numbers) / n average = quantize(average) costs = [int(math.pow(n - average, 2)) for n in numbers] return sum(costs) def main(): N = int(eval(input())) numbers = list(map(int, input().split())) print((check(n=N, numbers=numbers))) if __name__ == '__main__': main()
32
24
629
508
import math from functools import lru_cache @lru_cache(maxsize=4096) def get_cost(x, y): return int(math.pow((x - y), 2)) def get_costs(target, numbers): return sum([get_cost(target, n) for n in numbers]) def check(n, numbers): n_max = max(numbers) n_min = min(numbers) costs = [] for target in range(n_min, n_max + 1): costs.append(get_costs(target=target, numbers=numbers)) return min(costs) def main(): N = int(eval(input())) numbers = list(map(int, input().split())) print((check(n=N, numbers=numbers))) if __name__ == "__main__": main()
import math from decimal import Decimal, ROUND_HALF_UP def quantize(f): return int(Decimal(str(f)).quantize(Decimal("0"), rounding=ROUND_HALF_UP)) def check(n, numbers): average = sum(numbers) / n average = quantize(average) costs = [int(math.pow(n - average, 2)) for n in numbers] return sum(costs) def main(): N = int(eval(input())) numbers = list(map(int, input().split())) print((check(n=N, numbers=numbers))) if __name__ == "__main__": main()
false
25
[ "-from functools import lru_cache", "+from decimal import Decimal, ROUND_HALF_UP", "-@lru_cache(maxsize=4096)", "-def get_cost(x, y):", "- return int(math.pow((x - y), 2))", "-", "-", "-def get_costs(target, numbers):", "- return sum([get_cost(target, n) for n in numbers])", "+def quantize(f):", "+ return int(Decimal(str(f)).quantize(Decimal(\"0\"), rounding=ROUND_HALF_UP))", "- n_max = max(numbers)", "- n_min = min(numbers)", "- costs = []", "- for target in range(n_min, n_max + 1):", "- costs.append(get_costs(target=target, numbers=numbers))", "- return min(costs)", "+ average = sum(numbers) / n", "+ average = quantize(average)", "+ costs = [int(math.pow(n - average, 2)) for n in numbers]", "+ return sum(costs)" ]
false
0.03793
0.093083
0.407491
[ "s190531707", "s708502311" ]
u985929170
p03545
python
s986305733
s968413850
31
26
9,028
8,956
Accepted
Accepted
16.13
from itertools import product A,B,C,D = list(eval(input())) for k in list(product(['+','-'],repeat=3)): k = A + k[0] + B + k[1] + C + k[2] + D if eval(k) == 7: print(('{}=7'.format(k))) break
num_li = list(eval(input())) for i in range(2**3): li = ['+']*3 q = num_li[0] for j in range(3): if ((i>>j) & 1): li[j] = '-' q += li[j] + num_li[j+1] if eval(q) == 7: print(('{}=7'.format(q))) break
7
11
213
261
from itertools import product A, B, C, D = list(eval(input())) for k in list(product(["+", "-"], repeat=3)): k = A + k[0] + B + k[1] + C + k[2] + D if eval(k) == 7: print(("{}=7".format(k))) break
num_li = list(eval(input())) for i in range(2**3): li = ["+"] * 3 q = num_li[0] for j in range(3): if (i >> j) & 1: li[j] = "-" q += li[j] + num_li[j + 1] if eval(q) == 7: print(("{}=7".format(q))) break
false
36.363636
[ "-from itertools import product", "-", "-A, B, C, D = list(eval(input()))", "-for k in list(product([\"+\", \"-\"], repeat=3)):", "- k = A + k[0] + B + k[1] + C + k[2] + D", "- if eval(k) == 7:", "- print((\"{}=7\".format(k)))", "+num_li = list(eval(input()))", "+for i in range(2**3):", "+ li = [\"+\"] * 3", "+ q = num_li[0]", "+ for j in range(3):", "+ if (i >> j) & 1:", "+ li[j] = \"-\"", "+ q += li[j] + num_li[j + 1]", "+ if eval(q) == 7:", "+ print((\"{}=7\".format(q)))" ]
false
0.04271
0.037912
1.126539
[ "s986305733", "s968413850" ]
u729133443
p03840
python
s249365196
s303346202
169
31
38,384
9,116
Accepted
Accepted
81.66
i,o,t,j,l,s,z=list(map(int,input().split())) a=(i//2+j//2+l//2)*2 print(([a,max(a,((i-1)//2+(j-1)//2+(l-1)//2)*2+3)][(i and j and l)>0]+o))
I,O,T,J,L,S,Z=list(map(int,input().split())) print((max((~-I//2+~-J//2+~-L//2)*2+O+3*(I>0<L>0<J),(I//2+J//2+L//2)*2+O)))
3
2
133
113
i, o, t, j, l, s, z = list(map(int, input().split())) a = (i // 2 + j // 2 + l // 2) * 2 print( ( [a, max(a, ((i - 1) // 2 + (j - 1) // 2 + (l - 1) // 2) * 2 + 3)][ (i and j and l) > 0 ] + o ) )
I, O, T, J, L, S, Z = list(map(int, input().split())) print( ( max( (~-I // 2 + ~-J // 2 + ~-L // 2) * 2 + O + 3 * (I > 0 < L > 0 < J), (I // 2 + J // 2 + L // 2) * 2 + O, ) ) )
false
33.333333
[ "-i, o, t, j, l, s, z = list(map(int, input().split()))", "-a = (i // 2 + j // 2 + l // 2) * 2", "+I, O, T, J, L, S, Z = list(map(int, input().split()))", "- [a, max(a, ((i - 1) // 2 + (j - 1) // 2 + (l - 1) // 2) * 2 + 3)][", "- (i and j and l) > 0", "- ]", "- + o", "+ max(", "+ (~-I // 2 + ~-J // 2 + ~-L // 2) * 2 + O + 3 * (I > 0 < L > 0 < J),", "+ (I // 2 + J // 2 + L // 2) * 2 + O,", "+ )" ]
false
0.037972
0.035022
1.084224
[ "s249365196", "s303346202" ]
u485319545
p02727
python
s848478840
s207036849
293
215
29,732
29,672
Accepted
Accepted
26.62
x,y,a,b,c=list(map(int,input().split())) p=list(map(int,input().split())) q=list(map(int,input().split())) r=list(map(int,input().split())) p=sorted(p,reverse=True) q=sorted(q,reverse=True) r=sorted(r) p=p[:x] q=q[:y] import heapq from collections import deque heapq.heapify(p) heapq.heapify(q) r=deque(r) for i in range(c): v_p=heapq.heappop(p) v_q=heapq.heappop(q) v_r=r.pop() if v_p<=v_q: heapq.heappush(q,v_q) if v_p<v_r: heapq.heappush(p,v_r) else: heapq.heappush(p,v_p) else: heapq.heappush(p,v_p) if v_q<v_r: heapq.heappush(q,v_r) else: heapq.heappush(q,v_q) ans=sum(p)+sum(q) print(ans)
x,y,a,b,c=list(map(int,input().split())) p=list(map(int,input().split())) q=list(map(int,input().split())) r=list(map(int,input().split())) p=sorted(p,reverse=True) q=sorted(q,reverse=True) r=sorted(r) box=[] ans=0 for i in range(x): box.append(p[i]) for j in range(y): box.append(q[j]) box = box + r box=sorted(box,reverse=True) for k in range(x+y): ans+=box[k] print(ans)
39
29
749
418
x, y, a, b, c = list(map(int, input().split())) p = list(map(int, input().split())) q = list(map(int, input().split())) r = list(map(int, input().split())) p = sorted(p, reverse=True) q = sorted(q, reverse=True) r = sorted(r) p = p[:x] q = q[:y] import heapq from collections import deque heapq.heapify(p) heapq.heapify(q) r = deque(r) for i in range(c): v_p = heapq.heappop(p) v_q = heapq.heappop(q) v_r = r.pop() if v_p <= v_q: heapq.heappush(q, v_q) if v_p < v_r: heapq.heappush(p, v_r) else: heapq.heappush(p, v_p) else: heapq.heappush(p, v_p) if v_q < v_r: heapq.heappush(q, v_r) else: heapq.heappush(q, v_q) ans = sum(p) + sum(q) print(ans)
x, y, a, b, c = list(map(int, input().split())) p = list(map(int, input().split())) q = list(map(int, input().split())) r = list(map(int, input().split())) p = sorted(p, reverse=True) q = sorted(q, reverse=True) r = sorted(r) box = [] ans = 0 for i in range(x): box.append(p[i]) for j in range(y): box.append(q[j]) box = box + r box = sorted(box, reverse=True) for k in range(x + y): ans += box[k] print(ans)
false
25.641026
[ "-p = p[:x]", "-q = q[:y]", "-import heapq", "-from collections import deque", "-", "-heapq.heapify(p)", "-heapq.heapify(q)", "-r = deque(r)", "-for i in range(c):", "- v_p = heapq.heappop(p)", "- v_q = heapq.heappop(q)", "- v_r = r.pop()", "- if v_p <= v_q:", "- heapq.heappush(q, v_q)", "- if v_p < v_r:", "- heapq.heappush(p, v_r)", "- else:", "- heapq.heappush(p, v_p)", "- else:", "- heapq.heappush(p, v_p)", "- if v_q < v_r:", "- heapq.heappush(q, v_r)", "- else:", "- heapq.heappush(q, v_q)", "-ans = sum(p) + sum(q)", "+box = []", "+ans = 0", "+for i in range(x):", "+ box.append(p[i])", "+for j in range(y):", "+ box.append(q[j])", "+box = box + r", "+box = sorted(box, reverse=True)", "+for k in range(x + y):", "+ ans += box[k]" ]
false
0.082338
0.037385
2.20243
[ "s848478840", "s207036849" ]
u466335531
p03295
python
s086664082
s868149799
565
393
29,068
18,212
Accepted
Accepted
30.44
N,M=list(map(int,input().split())) request=[] for _ in range(M): request.append(list(map(int,input().split()))) request.sort(key=lambda x: x[0]) memory=request[0][1] head = request[0][0] index = 0 ans = 0 def equal(): if index == M-1: return False else: return head == request[index+1][0] while head <= N: if head == memory: ans +=1 memory = N+1 elif equal(): index +=1 memory=min(request[index][1],memory) else: head +=1 print(ans)
N,M=list(map(int,input().split())) AB=[] for _ in range(M): AB.append(tuple(map(int,input().split()))) request_max=0 request_num=0 AB.sort(key=lambda x:x[1]) for (a,b) in AB: if a>=request_max: request_num +=1 request_max = b print(request_num)
25
14
522
281
N, M = list(map(int, input().split())) request = [] for _ in range(M): request.append(list(map(int, input().split()))) request.sort(key=lambda x: x[0]) memory = request[0][1] head = request[0][0] index = 0 ans = 0 def equal(): if index == M - 1: return False else: return head == request[index + 1][0] while head <= N: if head == memory: ans += 1 memory = N + 1 elif equal(): index += 1 memory = min(request[index][1], memory) else: head += 1 print(ans)
N, M = list(map(int, input().split())) AB = [] for _ in range(M): AB.append(tuple(map(int, input().split()))) request_max = 0 request_num = 0 AB.sort(key=lambda x: x[1]) for (a, b) in AB: if a >= request_max: request_num += 1 request_max = b print(request_num)
false
44
[ "-request = []", "+AB = []", "- request.append(list(map(int, input().split())))", "-request.sort(key=lambda x: x[0])", "-memory = request[0][1]", "-head = request[0][0]", "-index = 0", "-ans = 0", "-", "-", "-def equal():", "- if index == M - 1:", "- return False", "- else:", "- return head == request[index + 1][0]", "-", "-", "-while head <= N:", "- if head == memory:", "- ans += 1", "- memory = N + 1", "- elif equal():", "- index += 1", "- memory = min(request[index][1], memory)", "- else:", "- head += 1", "-print(ans)", "+ AB.append(tuple(map(int, input().split())))", "+request_max = 0", "+request_num = 0", "+AB.sort(key=lambda x: x[1])", "+for (a, b) in AB:", "+ if a >= request_max:", "+ request_num += 1", "+ request_max = b", "+print(request_num)" ]
false
0.038647
0.038876
0.994116
[ "s086664082", "s868149799" ]
u661290476
p00018
python
s310492553
s849028088
30
20
7,652
7,624
Accepted
Accepted
33.33
a=sorted([int(i) for i in input().split()],reverse=True) print((" ".join([str(i) for i in a])))
a=sorted([int(i) for i in input().split()],reverse=True) print((*a))
2
2
94
67
a = sorted([int(i) for i in input().split()], reverse=True) print((" ".join([str(i) for i in a])))
a = sorted([int(i) for i in input().split()], reverse=True) print((*a))
false
0
[ "-print((\" \".join([str(i) for i in a])))", "+print((*a))" ]
false
0.079936
0.079105
1.010496
[ "s310492553", "s849028088" ]
u145950990
p03137
python
s562402534
s681726967
226
113
58,408
13,960
Accepted
Accepted
50
n,m = list(map(int,input().split())) x = list(map(int,input().split())) x = sorted(x) if m<=n: print((0)) else: dif = [] for i in range(m-1): dif.append(x[i+1]-x[i]) dif = sorted(dif) print((sum(dif[:m-n])))
n,m = list(map(int,input().split())) x = sorted(list(map(int,input().split()))) dif = [] for i in range(m-1): dif.append(x[i+1]-x[i]) dif.sort() print((sum(dif[:max(m-n,0)])))
11
7
235
177
n, m = list(map(int, input().split())) x = list(map(int, input().split())) x = sorted(x) if m <= n: print((0)) else: dif = [] for i in range(m - 1): dif.append(x[i + 1] - x[i]) dif = sorted(dif) print((sum(dif[: m - n])))
n, m = list(map(int, input().split())) x = sorted(list(map(int, input().split()))) dif = [] for i in range(m - 1): dif.append(x[i + 1] - x[i]) dif.sort() print((sum(dif[: max(m - n, 0)])))
false
36.363636
[ "-x = list(map(int, input().split()))", "-x = sorted(x)", "-if m <= n:", "- print((0))", "-else:", "- dif = []", "- for i in range(m - 1):", "- dif.append(x[i + 1] - x[i])", "- dif = sorted(dif)", "- print((sum(dif[: m - n])))", "+x = sorted(list(map(int, input().split())))", "+dif = []", "+for i in range(m - 1):", "+ dif.append(x[i + 1] - x[i])", "+dif.sort()", "+print((sum(dif[: max(m - n, 0)])))" ]
false
0.034926
0.035403
0.986504
[ "s562402534", "s681726967" ]
u941753895
p03103
python
s522764806
s688740048
573
456
29,052
24,932
Accepted
Accepted
20.42
class struct: def __init__(self,a,b): self.a=a self.b=b n,m=list(map(int,input().split())) l=[] for i in range(n): a,b=list(map(int,input().split())) l.append(struct(a,b)) l=sorted(l,key=lambda x:x.a) su=0 for x in l: if x.b<m: m-=x.b su+=(x.a)*(x.b) else: su+=(x.a)*m break print(su)
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 def LI(): return list(map(int,input().split())) def I(): return int(eval(input())) def LS(): return input().split() def S(): return eval(input()) def main(): n,m=LI() l=[] for _ in range(n): a,b=LI() l.append([a,b]) l=sorted(l,key=lambda x:x[0]) sm=0 for x in l: if m>x[1]: m-=x[1] sm+=x[0]*x[1] else: sm+=x[0]*m return sm print((main()))
19
31
324
555
class struct: def __init__(self, a, b): self.a = a self.b = b n, m = list(map(int, input().split())) l = [] for i in range(n): a, b = list(map(int, input().split())) l.append(struct(a, b)) l = sorted(l, key=lambda x: x.a) su = 0 for x in l: if x.b < m: m -= x.b su += (x.a) * (x.b) else: su += (x.a) * m break print(su)
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 def LI(): return list(map(int, input().split())) def I(): return int(eval(input())) def LS(): return input().split() def S(): return eval(input()) def main(): n, m = LI() l = [] for _ in range(n): a, b = LI() l.append([a, b]) l = sorted(l, key=lambda x: x[0]) sm = 0 for x in l: if m > x[1]: m -= x[1] sm += x[0] * x[1] else: sm += x[0] * m return sm print((main()))
false
38.709677
[ "-class struct:", "- def __init__(self, a, b):", "- self.a = a", "- self.b = b", "+import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time", "+", "+sys.setrecursionlimit(10**7)", "+inf = 10**20", "+mod = 10**9 + 7", "-n, m = list(map(int, input().split()))", "-l = []", "-for i in range(n):", "- a, b = list(map(int, input().split()))", "- l.append(struct(a, b))", "-l = sorted(l, key=lambda x: x.a)", "-su = 0", "-for x in l:", "- if x.b < m:", "- m -= x.b", "- su += (x.a) * (x.b)", "- else:", "- su += (x.a) * m", "- break", "-print(su)", "+def LI():", "+ return list(map(int, input().split()))", "+", "+", "+def I():", "+ return int(eval(input()))", "+", "+", "+def LS():", "+ return input().split()", "+", "+", "+def S():", "+ return eval(input())", "+", "+", "+def main():", "+ n, m = LI()", "+ l = []", "+ for _ in range(n):", "+ a, b = LI()", "+ l.append([a, b])", "+ l = sorted(l, key=lambda x: x[0])", "+ sm = 0", "+ for x in l:", "+ if m > x[1]:", "+ m -= x[1]", "+ sm += x[0] * x[1]", "+ else:", "+ sm += x[0] * m", "+ return sm", "+", "+", "+print((main()))" ]
false
0.130554
0.069955
1.86625
[ "s522764806", "s688740048" ]
u706929073
p03137
python
s425475588
s984831950
113
103
13,968
13,968
Accepted
Accepted
8.85
(n, m) = list(map(int, input().split())) x = list(map(int, input().split())) x.sort() diff = [] for i in range(1, len(x)): diff.append(x[i] - x[i-1]) diff.sort(reverse=True) sum = 0 for i in range(n - 1, len(diff)): sum += diff[i] print(sum)
n, m = list(map(int, input().split())) if n >= m: print((0)) exit(0) x = sorted(list(map(int, input().split()))) gaps = sorted([x[i] - x[i-1] for i in range(1, m)], reverse=True) print((sum(gaps[n-1:])))
11
8
253
210
(n, m) = list(map(int, input().split())) x = list(map(int, input().split())) x.sort() diff = [] for i in range(1, len(x)): diff.append(x[i] - x[i - 1]) diff.sort(reverse=True) sum = 0 for i in range(n - 1, len(diff)): sum += diff[i] print(sum)
n, m = list(map(int, input().split())) if n >= m: print((0)) exit(0) x = sorted(list(map(int, input().split()))) gaps = sorted([x[i] - x[i - 1] for i in range(1, m)], reverse=True) print((sum(gaps[n - 1 :])))
false
27.272727
[ "-(n, m) = list(map(int, input().split()))", "-x = list(map(int, input().split()))", "-x.sort()", "-diff = []", "-for i in range(1, len(x)):", "- diff.append(x[i] - x[i - 1])", "-diff.sort(reverse=True)", "-sum = 0", "-for i in range(n - 1, len(diff)):", "- sum += diff[i]", "-print(sum)", "+n, m = list(map(int, input().split()))", "+if n >= m:", "+ print((0))", "+ exit(0)", "+x = sorted(list(map(int, input().split())))", "+gaps = sorted([x[i] - x[i - 1] for i in range(1, m)], reverse=True)", "+print((sum(gaps[n - 1 :])))" ]
false
0.042867
0.043397
0.987789
[ "s425475588", "s984831950" ]
u977389981
p03632
python
s348416683
s816477403
21
18
3,316
3,060
Accepted
Accepted
14.29
a, b, c, d = list(map(int, input().split())) print((max(0, (min(b, d) - max(a, c)))))
a, b, c, d = list(map(int, input().split())) x = len(set(range(a, b + 1)) & set(range(c, d + 1))) - 1 print((x if x >= 0 else 0))
2
3
78
123
a, b, c, d = list(map(int, input().split())) print((max(0, (min(b, d) - max(a, c)))))
a, b, c, d = list(map(int, input().split())) x = len(set(range(a, b + 1)) & set(range(c, d + 1))) - 1 print((x if x >= 0 else 0))
false
33.333333
[ "-print((max(0, (min(b, d) - max(a, c)))))", "+x = len(set(range(a, b + 1)) & set(range(c, d + 1))) - 1", "+print((x if x >= 0 else 0))" ]
false
0.039339
0.04306
0.913576
[ "s348416683", "s816477403" ]
u136869985
p04045
python
s465752526
s134023085
207
182
3,064
39,792
Accepted
Accepted
12.08
def main(): n, k = list(map(int, input().split())) D = list(map(int, input().split())) while 1: f = 0 hoge = str(n) for i in range(len(hoge)): for j in range(k): if(int(hoge[i]) == D[j]): f = 1 break if f == 1: break if f == 1: break if f == 0: print(n) break n += 1 if __name__ == "__main__": main()
def main(): N, K = list(map(int, input().split())) D = list(input().split()) i = 0 while True: S = str(N) f = True for s in S: if s in D: f = False break if f: break N += 1 print(N) if __name__ == "__main__": main()
23
19
530
353
def main(): n, k = list(map(int, input().split())) D = list(map(int, input().split())) while 1: f = 0 hoge = str(n) for i in range(len(hoge)): for j in range(k): if int(hoge[i]) == D[j]: f = 1 break if f == 1: break if f == 1: break if f == 0: print(n) break n += 1 if __name__ == "__main__": main()
def main(): N, K = list(map(int, input().split())) D = list(input().split()) i = 0 while True: S = str(N) f = True for s in S: if s in D: f = False break if f: break N += 1 print(N) if __name__ == "__main__": main()
false
17.391304
[ "- n, k = list(map(int, input().split()))", "- D = list(map(int, input().split()))", "- while 1:", "- f = 0", "- hoge = str(n)", "- for i in range(len(hoge)):", "- for j in range(k):", "- if int(hoge[i]) == D[j]:", "- f = 1", "- break", "- if f == 1:", "- break", "- if f == 1:", "+ N, K = list(map(int, input().split()))", "+ D = list(input().split())", "+ i = 0", "+ while True:", "+ S = str(N)", "+ f = True", "+ for s in S:", "+ if s in D:", "+ f = False", "- if f == 0:", "- print(n)", "+ if f:", "- n += 1", "+ N += 1", "+ print(N)" ]
false
0.050807
0.037884
1.341109
[ "s465752526", "s134023085" ]
u823044869
p03814
python
s143818473
s967047844
22
18
3,756
3,500
Accepted
Accepted
18.18
import re s = eval(input()) list_s = [len(i) for i in re.findall("A.*Z", s)] print((max(list_s)))
s = eval(input()) a = s.find('A') z = s.rfind('Z') print((z-a+1))
5
6
94
65
import re s = eval(input()) list_s = [len(i) for i in re.findall("A.*Z", s)] print((max(list_s)))
s = eval(input()) a = s.find("A") z = s.rfind("Z") print((z - a + 1))
false
16.666667
[ "-import re", "-", "-list_s = [len(i) for i in re.findall(\"A.*Z\", s)]", "-print((max(list_s)))", "+a = s.find(\"A\")", "+z = s.rfind(\"Z\")", "+print((z - a + 1))" ]
false
0.038353
0.033752
1.136311
[ "s143818473", "s967047844" ]
u461836414
p03037
python
s884586904
s416492510
405
321
3,188
3,060
Accepted
Accepted
20.74
N, M = list(map(int, input().split())) L1, R1 = list(map(int, input().split())) flag = 0 def find_key(L1,R1,L2,R2): if R1 < L2 or R2 < L1: return(False) else: a = [R1,L1,R2,L2] a.sort() return(a[1],a[2]) for i in range(M - 1): L,R = list(map(int, input().split())) if find_key(L1,R1,L,R) != False: L1,R1 = find_key(L1,R1,L,R) else: flag = 1 print((0)) break if flag == 0: print((R1-L1+1))
n,m=list(map(int,input().split())) ml=0 mr=100000 for i in range(m): l,r=list(map(int,input().split())) ml=max(ml,l) mr=min(mr,r) if ml>mr: break if ml<=mr: print((mr-ml+1)) else: print((0))
21
13
475
202
N, M = list(map(int, input().split())) L1, R1 = list(map(int, input().split())) flag = 0 def find_key(L1, R1, L2, R2): if R1 < L2 or R2 < L1: return False else: a = [R1, L1, R2, L2] a.sort() return (a[1], a[2]) for i in range(M - 1): L, R = list(map(int, input().split())) if find_key(L1, R1, L, R) != False: L1, R1 = find_key(L1, R1, L, R) else: flag = 1 print((0)) break if flag == 0: print((R1 - L1 + 1))
n, m = list(map(int, input().split())) ml = 0 mr = 100000 for i in range(m): l, r = list(map(int, input().split())) ml = max(ml, l) mr = min(mr, r) if ml > mr: break if ml <= mr: print((mr - ml + 1)) else: print((0))
false
38.095238
[ "-N, M = list(map(int, input().split()))", "-L1, R1 = list(map(int, input().split()))", "-flag = 0", "-", "-", "-def find_key(L1, R1, L2, R2):", "- if R1 < L2 or R2 < L1:", "- return False", "- else:", "- a = [R1, L1, R2, L2]", "- a.sort()", "- return (a[1], a[2])", "-", "-", "-for i in range(M - 1):", "- L, R = list(map(int, input().split()))", "- if find_key(L1, R1, L, R) != False:", "- L1, R1 = find_key(L1, R1, L, R)", "- else:", "- flag = 1", "- print((0))", "+n, m = list(map(int, input().split()))", "+ml = 0", "+mr = 100000", "+for i in range(m):", "+ l, r = list(map(int, input().split()))", "+ ml = max(ml, l)", "+ mr = min(mr, r)", "+ if ml > mr:", "-if flag == 0:", "- print((R1 - L1 + 1))", "+if ml <= mr:", "+ print((mr - ml + 1))", "+else:", "+ print((0))" ]
false
0.034286
0.037825
0.906431
[ "s884586904", "s416492510" ]
u796878730
p02641
python
s013765719
s990654097
24
19
9,092
9,100
Accepted
Accepted
20.83
X,N = list(map(int,input().split())) P = list(map(int,input().split())) P_n = [i for i in range(105) if i not in P] abs_value = [abs(X-P_n[j]) for j in range(len(P_n))] min_abs = min(abs_value) for k in range(len(abs_value)): if abs_value[k] == min_abs: print((P_n[k])) break
X,N = list(map(int,input().split())) P = list(map(int,input().split())) P_n = [i for i in range(102) if i not in P] abs_value = [abs(X-P_n[j]) for j in range(len(P_n))] min_abs = min(abs_value) for k in range(len(abs_value)): if abs_value[k] == min_abs: print((P_n[k])) break
13
13
303
303
X, N = list(map(int, input().split())) P = list(map(int, input().split())) P_n = [i for i in range(105) if i not in P] abs_value = [abs(X - P_n[j]) for j in range(len(P_n))] min_abs = min(abs_value) for k in range(len(abs_value)): if abs_value[k] == min_abs: print((P_n[k])) break
X, N = list(map(int, input().split())) P = list(map(int, input().split())) P_n = [i for i in range(102) if i not in P] abs_value = [abs(X - P_n[j]) for j in range(len(P_n))] min_abs = min(abs_value) for k in range(len(abs_value)): if abs_value[k] == min_abs: print((P_n[k])) break
false
0
[ "-P_n = [i for i in range(105) if i not in P]", "+P_n = [i for i in range(102) if i not in P]" ]
false
0.007795
0.041423
0.18818
[ "s013765719", "s990654097" ]
u638282348
p03038
python
s210689701
s733105342
610
487
22,208
22,256
Accepted
Accepted
20.16
from heapq import heapify, heappush, heappop class HeapQue(object): def __init__(self, iterable, max_heap=False): self.sign = -1 if max_heap else 1 sequence = [self.sign * number for number in iterable] heapify(sequence) self.heapque = sequence def push(self, item): heappush(self.heapque, item * self.sign) def pop(self): return heappop(self.heapque) * self.sign def dump(self): return [heappop(self.heapque) * self.sign for _ in range(len(self.heapque))] N, M = list(map(int, input().split())) q = HeapQue(list(map(int, input().split()))) pairs = sorted((tuple(map(int, input().split())) for _ in range(M)), key=lambda t: t[1], reverse=True) for b, c in pairs: for _ in range(b): x = q.pop() if x < c: q.push(c) else: q.push(x) print((sum(q.dump()))) quit() print((sum(q.dump())))
from heapq import heapify, heappush, heappop N, M = list(map(int, input().split())) q = list(map(int, input().split())) heapify(q) pairs = sorted((tuple(map(int, input().split())) for _ in range(M)), key=lambda t: t[1], reverse=True) for b, c in pairs: for _ in range(b): x = heappop(q) if x < c: heappush(q, c) else: heappush(q, x) print((sum(q))) quit() print((sum(q)))
30
15
947
452
from heapq import heapify, heappush, heappop class HeapQue(object): def __init__(self, iterable, max_heap=False): self.sign = -1 if max_heap else 1 sequence = [self.sign * number for number in iterable] heapify(sequence) self.heapque = sequence def push(self, item): heappush(self.heapque, item * self.sign) def pop(self): return heappop(self.heapque) * self.sign def dump(self): return [heappop(self.heapque) * self.sign for _ in range(len(self.heapque))] N, M = list(map(int, input().split())) q = HeapQue(list(map(int, input().split()))) pairs = sorted( (tuple(map(int, input().split())) for _ in range(M)), key=lambda t: t[1], reverse=True, ) for b, c in pairs: for _ in range(b): x = q.pop() if x < c: q.push(c) else: q.push(x) print((sum(q.dump()))) quit() print((sum(q.dump())))
from heapq import heapify, heappush, heappop N, M = list(map(int, input().split())) q = list(map(int, input().split())) heapify(q) pairs = sorted( (tuple(map(int, input().split())) for _ in range(M)), key=lambda t: t[1], reverse=True, ) for b, c in pairs: for _ in range(b): x = heappop(q) if x < c: heappush(q, c) else: heappush(q, x) print((sum(q))) quit() print((sum(q)))
false
50
[ "-", "-class HeapQue(object):", "- def __init__(self, iterable, max_heap=False):", "- self.sign = -1 if max_heap else 1", "- sequence = [self.sign * number for number in iterable]", "- heapify(sequence)", "- self.heapque = sequence", "-", "- def push(self, item):", "- heappush(self.heapque, item * self.sign)", "-", "- def pop(self):", "- return heappop(self.heapque) * self.sign", "-", "- def dump(self):", "- return [heappop(self.heapque) * self.sign for _ in range(len(self.heapque))]", "-", "-", "-q = HeapQue(list(map(int, input().split())))", "+q = list(map(int, input().split()))", "+heapify(q)", "- x = q.pop()", "+ x = heappop(q)", "- q.push(c)", "+ heappush(q, c)", "- q.push(x)", "- print((sum(q.dump())))", "+ heappush(q, x)", "+ print((sum(q)))", "-print((sum(q.dump())))", "+print((sum(q)))" ]
false
0.034943
0.037922
0.921443
[ "s210689701", "s733105342" ]
u943004959
p03589
python
s019005574
s243770569
1,405
272
3,064
39,152
Accepted
Accepted
80.64
class EndLoop(Exception): pass def solve(): N = int(eval(input())) try: for h in range(1, 3501): for n in range(1, 3501): if 4 * h * n - n * N - h * N > 0: if (h * n * N) % (4 * h * n - n * N - h * N) == 0: w = int((h * n * N) / (4 * h * n - n * N - h * N)) print((h, n, int(w))) raise EndLoop except: pass solve()
class EndLoop(Exception): pass def solve(): N = int(input()) try: for h in range(1, 3500): for n in range(1, 3500): if 4 * h * n - n * N - h * N == 0: pass elif (h * n * N) % (4 * h * n - n * N - h * N) == 0 and\ (4 * h * n - n * N - h * N) > 0: w = (h * n * N) / (4 * h * n - n * N - h * N) print(h, n, int(w)) raise EndLoop except(EndLoop): pass solve()
19
22
480
570
class EndLoop(Exception): pass def solve(): N = int(eval(input())) try: for h in range(1, 3501): for n in range(1, 3501): if 4 * h * n - n * N - h * N > 0: if (h * n * N) % (4 * h * n - n * N - h * N) == 0: w = int((h * n * N) / (4 * h * n - n * N - h * N)) print((h, n, int(w))) raise EndLoop except: pass solve()
class EndLoop(Exception): pass def solve(): N = int(input()) try: for h in range(1, 3500): for n in range(1, 3500): if 4 * h * n - n * N - h * N == 0: pass elif (h * n * N) % (4 * h * n - n * N - h * N) == 0 and ( 4 * h * n - n * N - h * N ) > 0: w = (h * n * N) / (4 * h * n - n * N - h * N) print(h, n, int(w)) raise EndLoop except (EndLoop): pass solve()
false
13.636364
[ "- N = int(eval(input()))", "+ N = int(input())", "- for h in range(1, 3501):", "- for n in range(1, 3501):", "- if 4 * h * n - n * N - h * N > 0:", "- if (h * n * N) % (4 * h * n - n * N - h * N) == 0:", "- w = int((h * n * N) / (4 * h * n - n * N - h * N))", "- print((h, n, int(w)))", "- raise EndLoop", "- except:", "+ for h in range(1, 3500):", "+ for n in range(1, 3500):", "+ if 4 * h * n - n * N - h * N == 0:", "+ pass", "+ elif (h * n * N) % (4 * h * n - n * N - h * N) == 0 and (", "+ 4 * h * n - n * N - h * N", "+ ) > 0:", "+ w = (h * n * N) / (4 * h * n - n * N - h * N)", "+ print(h, n, int(w))", "+ raise EndLoop", "+ except (EndLoop):" ]
false
0.088317
0.043439
2.033104
[ "s019005574", "s243770569" ]
u908984540
p02255
python
s584798574
s381909707
30
20
5,984
5,980
Accepted
Accepted
33.33
def show_list(target): for i, item in enumerate(target): if i == len(target) - 1: print(item) else: print(item, end=" ") def insection_sort(target): for i in range(1, len(target)): show_list(target) j = i - 1 while j >= 0: if target[j] > target[j+1]: target[j], target[j+1] = target[j+1], target[j] j -= 1 else: break return target if __name__ == "__main__": n = input() a = [int(x) for x in input().split()] answer = insection_sort(a) show_list(answer)
def insertion_sort(A): for i in range(1, len(A)): v = A[i] j = i - 1 print((*A)) while j >= 0 and A[j] > v: A[j+1] = A[j] A[j] = v j -= 1 return A n = eval(input()) A = [int(x) for x in input().split()] print((*insertion_sort(A)))
24
15
642
313
def show_list(target): for i, item in enumerate(target): if i == len(target) - 1: print(item) else: print(item, end=" ") def insection_sort(target): for i in range(1, len(target)): show_list(target) j = i - 1 while j >= 0: if target[j] > target[j + 1]: target[j], target[j + 1] = target[j + 1], target[j] j -= 1 else: break return target if __name__ == "__main__": n = input() a = [int(x) for x in input().split()] answer = insection_sort(a) show_list(answer)
def insertion_sort(A): for i in range(1, len(A)): v = A[i] j = i - 1 print((*A)) while j >= 0 and A[j] > v: A[j + 1] = A[j] A[j] = v j -= 1 return A n = eval(input()) A = [int(x) for x in input().split()] print((*insertion_sort(A)))
false
37.5
[ "-def show_list(target):", "- for i, item in enumerate(target):", "- if i == len(target) - 1:", "- print(item)", "- else:", "- print(item, end=\" \")", "+def insertion_sort(A):", "+ for i in range(1, len(A)):", "+ v = A[i]", "+ j = i - 1", "+ print((*A))", "+ while j >= 0 and A[j] > v:", "+ A[j + 1] = A[j]", "+ A[j] = v", "+ j -= 1", "+ return A", "-def insection_sort(target):", "- for i in range(1, len(target)):", "- show_list(target)", "- j = i - 1", "- while j >= 0:", "- if target[j] > target[j + 1]:", "- target[j], target[j + 1] = target[j + 1], target[j]", "- j -= 1", "- else:", "- break", "- return target", "-", "-", "-if __name__ == \"__main__\":", "- n = input()", "- a = [int(x) for x in input().split()]", "- answer = insection_sort(a)", "- show_list(answer)", "+n = eval(input())", "+A = [int(x) for x in input().split()]", "+print((*insertion_sort(A)))" ]
false
0.049846
0.048248
1.033115
[ "s584798574", "s381909707" ]
u645250356
p03078
python
s500242023
s576977503
984
845
152,296
221,976
Accepted
Accepted
14.13
from collections import Counter,defaultdict,deque from heapq import heapify,heappop,heappush import sys,bisect,math,itertools,string,queue sys.setrecursionlimit(10**8) mod = 10**9+7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpl_str(): return list(sys.stdin.readline().split()) def inpln(n): return list(int(sys.stdin.readline()) for i in range(n)) x,y,z,k = inpl() a = inpl() b = inpl() c = inpl() ab = [] for i in a: for j in b: ab.append(i+j) ab.sort(reverse=True) A = min(x*y,k) res = [] # print(ab,c) for i in range(A): for j in range(z): res.append(ab[i]+c[j]) res.sort(reverse=True) for i in range(k): print((res[i]))
from collections import Counter,defaultdict,deque from heapq import heappop,heappush from bisect import bisect_left,bisect_right import sys,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) x,y,z,k = inpl() a = inpl() b = inpl() c = inpl() ab = [] for s in a: for t in b: ab.append(s+t) ab.sort(reverse = True) ab = ab[:3000] abc = [] for s in ab: for j in c: abc.append(s+j) abc.sort(reverse = True) print((*abc[:k]))
28
26
749
620
from collections import Counter, defaultdict, deque from heapq import heapify, heappop, heappush import sys, bisect, math, itertools, string, queue sys.setrecursionlimit(10**8) mod = 10**9 + 7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpl_str(): return list(sys.stdin.readline().split()) def inpln(n): return list(int(sys.stdin.readline()) for i in range(n)) x, y, z, k = inpl() a = inpl() b = inpl() c = inpl() ab = [] for i in a: for j in b: ab.append(i + j) ab.sort(reverse=True) A = min(x * y, k) res = [] # print(ab,c) for i in range(A): for j in range(z): res.append(ab[i] + c[j]) res.sort(reverse=True) for i in range(k): print((res[i]))
from collections import Counter, defaultdict, deque from heapq import heappop, heappush from bisect import bisect_left, bisect_right import sys, math, itertools, fractions, pprint sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) x, y, z, k = inpl() a = inpl() b = inpl() c = inpl() ab = [] for s in a: for t in b: ab.append(s + t) ab.sort(reverse=True) ab = ab[:3000] abc = [] for s in ab: for j in c: abc.append(s + j) abc.sort(reverse=True) print((*abc[:k]))
false
7.142857
[ "-from heapq import heapify, heappop, heappush", "-import sys, bisect, math, itertools, string, queue", "+from heapq import heappop, heappush", "+from bisect import bisect_left, bisect_right", "+import sys, math, itertools, fractions, pprint", "+INF = float(\"inf\")", "-def inpl_str():", "- return list(sys.stdin.readline().split())", "-", "-", "-def inpln(n):", "- return list(int(sys.stdin.readline()) for i in range(n))", "-", "-", "-for i in a:", "- for j in b:", "- ab.append(i + j)", "+for s in a:", "+ for t in b:", "+ ab.append(s + t)", "-A = min(x * y, k)", "-res = []", "-# print(ab,c)", "-for i in range(A):", "- for j in range(z):", "- res.append(ab[i] + c[j])", "-res.sort(reverse=True)", "-for i in range(k):", "- print((res[i]))", "+ab = ab[:3000]", "+abc = []", "+for s in ab:", "+ for j in c:", "+ abc.append(s + j)", "+abc.sort(reverse=True)", "+print((*abc[:k]))" ]
false
0.046274
0.046357
0.998197
[ "s500242023", "s576977503" ]
u970197315
p02888
python
s039426918
s617239700
1,808
1,219
3,188
9,140
Accepted
Accepted
32.58
n=int(eval(input())) l=list(map(int,input().split())) l.sort() ans=0 from bisect import bisect_left for i in range(n-2): for j in range(i+1,n-1): ab=l[i]+l[j] idx=bisect_left(l,ab) ans+=max(idx-j-1,0) print(ans)
n=int(eval(input())) l=list(map(int,input().split())) from bisect import bisect_left l.sort() ans=0 for i in range(n-2): for j in range(i+1,n-1): t=l[i]+l[j] idx=bisect_left(l,t) ans+=max(idx-j-1,0) print(ans)
11
11
230
228
n = int(eval(input())) l = list(map(int, input().split())) l.sort() ans = 0 from bisect import bisect_left for i in range(n - 2): for j in range(i + 1, n - 1): ab = l[i] + l[j] idx = bisect_left(l, ab) ans += max(idx - j - 1, 0) print(ans)
n = int(eval(input())) l = list(map(int, input().split())) from bisect import bisect_left l.sort() ans = 0 for i in range(n - 2): for j in range(i + 1, n - 1): t = l[i] + l[j] idx = bisect_left(l, t) ans += max(idx - j - 1, 0) print(ans)
false
0
[ "+from bisect import bisect_left", "+", "-from bisect import bisect_left", "-", "- ab = l[i] + l[j]", "- idx = bisect_left(l, ab)", "+ t = l[i] + l[j]", "+ idx = bisect_left(l, t)" ]
false
0.045053
0.087255
0.516334
[ "s039426918", "s617239700" ]
u761062383
p02678
python
s893652737
s805456192
1,223
641
36,540
34,688
Accepted
Accepted
47.59
def resolve(): N, M = [int(i) for i in input().split()] path = [[] for _ in range(N)] for _ in range(M): A, B = [int(i) for i in input().split()] path[A - 1].append(B - 1) path[B - 1].append(A - 1) visited = [-1] * N que = [0] visited[0] = 0 while que: v = que.pop(0) for nv in path[v]: if visited[nv] != -1: continue visited[nv] = v + 1 que.append(nv) if -1 in visited: print("No") else: print("Yes") for i in range(N - 1): print((visited[i + 1])) resolve()
def resolve(): N, M = [int(i) for i in input().split()] AB = [[] for _ in range(N + 1)] AB[0] = [1] for _ in range(M): A, B = [int(i) for i in input().split()] AB[A].append(B) AB[B].append(A) from collections import deque dq = deque([1]) ans = [-1] * (N + 1) while len(dq) > 0: p = dq.popleft() c = AB[p] for cc in c: if ans[cc] == -1: ans[cc] = p dq.append(cc) if -1 in ans[2:]: print("No") print(ans, file=sys.stderr) else: print("Yes") for a in ans[2:]: print(a) resolve()
28
28
652
681
def resolve(): N, M = [int(i) for i in input().split()] path = [[] for _ in range(N)] for _ in range(M): A, B = [int(i) for i in input().split()] path[A - 1].append(B - 1) path[B - 1].append(A - 1) visited = [-1] * N que = [0] visited[0] = 0 while que: v = que.pop(0) for nv in path[v]: if visited[nv] != -1: continue visited[nv] = v + 1 que.append(nv) if -1 in visited: print("No") else: print("Yes") for i in range(N - 1): print((visited[i + 1])) resolve()
def resolve(): N, M = [int(i) for i in input().split()] AB = [[] for _ in range(N + 1)] AB[0] = [1] for _ in range(M): A, B = [int(i) for i in input().split()] AB[A].append(B) AB[B].append(A) from collections import deque dq = deque([1]) ans = [-1] * (N + 1) while len(dq) > 0: p = dq.popleft() c = AB[p] for cc in c: if ans[cc] == -1: ans[cc] = p dq.append(cc) if -1 in ans[2:]: print("No") print(ans, file=sys.stderr) else: print("Yes") for a in ans[2:]: print(a) resolve()
false
0
[ "- path = [[] for _ in range(N)]", "+ AB = [[] for _ in range(N + 1)]", "+ AB[0] = [1]", "- path[A - 1].append(B - 1)", "- path[B - 1].append(A - 1)", "- visited = [-1] * N", "- que = [0]", "- visited[0] = 0", "- while que:", "- v = que.pop(0)", "- for nv in path[v]:", "- if visited[nv] != -1:", "- continue", "- visited[nv] = v + 1", "- que.append(nv)", "- if -1 in visited:", "+ AB[A].append(B)", "+ AB[B].append(A)", "+ from collections import deque", "+", "+ dq = deque([1])", "+ ans = [-1] * (N + 1)", "+ while len(dq) > 0:", "+ p = dq.popleft()", "+ c = AB[p]", "+ for cc in c:", "+ if ans[cc] == -1:", "+ ans[cc] = p", "+ dq.append(cc)", "+ if -1 in ans[2:]:", "+ print(ans, file=sys.stderr)", "- for i in range(N - 1):", "- print((visited[i + 1]))", "+ for a in ans[2:]:", "+ print(a)" ]
false
0.03648
0.07413
0.492115
[ "s893652737", "s805456192" ]
u812576525
p02755
python
s449561811
s769686403
91
21
3,060
3,060
Accepted
Accepted
76.92
import math A, B = list(map(int,input().split())) cnt = 0 for i in range(1,100000): X = math.floor(i * 0.08) Y = math.floor(i * 0.1) if A == X and B == Y: print(i) cnt += 1 break if cnt == 0: print((-1))
A,B = list(map(int,input().split())) import math ans = -1 for i in range(10000): if math.floor(i*0.08) == A and math.floor(i*0.1) == B: ans=i break print(ans)
15
9
266
187
import math A, B = list(map(int, input().split())) cnt = 0 for i in range(1, 100000): X = math.floor(i * 0.08) Y = math.floor(i * 0.1) if A == X and B == Y: print(i) cnt += 1 break if cnt == 0: print((-1))
A, B = list(map(int, input().split())) import math ans = -1 for i in range(10000): if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B: ans = i break print(ans)
false
40
[ "+A, B = list(map(int, input().split()))", "-A, B = list(map(int, input().split()))", "-cnt = 0", "-for i in range(1, 100000):", "- X = math.floor(i * 0.08)", "- Y = math.floor(i * 0.1)", "- if A == X and B == Y:", "- print(i)", "- cnt += 1", "+ans = -1", "+for i in range(10000):", "+ if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B:", "+ ans = i", "-if cnt == 0:", "- print((-1))", "+print(ans)" ]
false
0.111755
0.03843
2.908035
[ "s449561811", "s769686403" ]
u761320129
p03141
python
s756868639
s098138721
440
402
21,384
21,364
Accepted
Accepted
8.64
N = int(eval(input())) src = [tuple(map(int,input().split())) for i in range(N)] src.sort(key=lambda x:sum(x)) a = b = 0 for i,(x,y) in enumerate(reversed(src)): if i%2: b += y else: a += x print((a-b))
N = int(eval(input())) AB = [tuple(map(int,input().split())) for i in range(N)] AB.sort(key=lambda x:x[1]+x[0]) ans = 0 for i,(a,b) in enumerate(AB[::-1]): if i%2: ans -= b else: ans += a print(ans)
11
11
229
227
N = int(eval(input())) src = [tuple(map(int, input().split())) for i in range(N)] src.sort(key=lambda x: sum(x)) a = b = 0 for i, (x, y) in enumerate(reversed(src)): if i % 2: b += y else: a += x print((a - b))
N = int(eval(input())) AB = [tuple(map(int, input().split())) for i in range(N)] AB.sort(key=lambda x: x[1] + x[0]) ans = 0 for i, (a, b) in enumerate(AB[::-1]): if i % 2: ans -= b else: ans += a print(ans)
false
0
[ "-src = [tuple(map(int, input().split())) for i in range(N)]", "-src.sort(key=lambda x: sum(x))", "-a = b = 0", "-for i, (x, y) in enumerate(reversed(src)):", "+AB = [tuple(map(int, input().split())) for i in range(N)]", "+AB.sort(key=lambda x: x[1] + x[0])", "+ans = 0", "+for i, (a, b) in enumerate(AB[::-1]):", "- b += y", "+ ans -= b", "- a += x", "-print((a - b))", "+ ans += a", "+print(ans)" ]
false
0.038038
0.044276
0.8591
[ "s756868639", "s098138721" ]
u800258529
p04013
python
s363623194
s339269087
160
49
4,580
3,064
Accepted
Accepted
69.38
n,a=list(map(int,input().split())) x=list([int(x)-a for x in input().split()]) m=0 if min(x)>0 else min(x)*n M=1 if max(x)<0 else max(x)*n+1 dp=[[0]*(M-m) for _ in range(n)] dp[0][x[0]]+=1 dp[0][0]+=1 for i in range(n-1): for j in range(m,M): if j+x[i+1] in range(m,M):dp[i+1][j+x[i+1]]+=dp[i][j] dp[i+1][j]+=dp[i][j] print((dp[n-1][0]-1))
n,a=list(map(int,input().split())) x=list([int(x)-a for x in input().split()]) m=min(0,min(x)*n) M=max(0,max(x)*n) dp=[1]+[0]*(M-m) dp[x[0]]+=1 for i in range(n-1): l=list(range(m-x[i+1],M+1)) if x[i+1]<0 else list(range(M-x[i+1],m-1,-1)) for j in l:dp[j+x[i+1]]+=dp[j] print((dp[0]-1))
12
10
365
286
n, a = list(map(int, input().split())) x = list([int(x) - a for x in input().split()]) m = 0 if min(x) > 0 else min(x) * n M = 1 if max(x) < 0 else max(x) * n + 1 dp = [[0] * (M - m) for _ in range(n)] dp[0][x[0]] += 1 dp[0][0] += 1 for i in range(n - 1): for j in range(m, M): if j + x[i + 1] in range(m, M): dp[i + 1][j + x[i + 1]] += dp[i][j] dp[i + 1][j] += dp[i][j] print((dp[n - 1][0] - 1))
n, a = list(map(int, input().split())) x = list([int(x) - a for x in input().split()]) m = min(0, min(x) * n) M = max(0, max(x) * n) dp = [1] + [0] * (M - m) dp[x[0]] += 1 for i in range(n - 1): l = ( list(range(m - x[i + 1], M + 1)) if x[i + 1] < 0 else list(range(M - x[i + 1], m - 1, -1)) ) for j in l: dp[j + x[i + 1]] += dp[j] print((dp[0] - 1))
false
16.666667
[ "-m = 0 if min(x) > 0 else min(x) * n", "-M = 1 if max(x) < 0 else max(x) * n + 1", "-dp = [[0] * (M - m) for _ in range(n)]", "-dp[0][x[0]] += 1", "-dp[0][0] += 1", "+m = min(0, min(x) * n)", "+M = max(0, max(x) * n)", "+dp = [1] + [0] * (M - m)", "+dp[x[0]] += 1", "- for j in range(m, M):", "- if j + x[i + 1] in range(m, M):", "- dp[i + 1][j + x[i + 1]] += dp[i][j]", "- dp[i + 1][j] += dp[i][j]", "-print((dp[n - 1][0] - 1))", "+ l = (", "+ list(range(m - x[i + 1], M + 1))", "+ if x[i + 1] < 0", "+ else list(range(M - x[i + 1], m - 1, -1))", "+ )", "+ for j in l:", "+ dp[j + x[i + 1]] += dp[j]", "+print((dp[0] - 1))" ]
false
0.038265
0.040496
0.944916
[ "s363623194", "s339269087" ]
u708255304
p02844
python
s678078886
s232302952
1,738
1,281
3,064
3,064
Accepted
Accepted
26.29
N = int(eval(input())) S = eval(input()) single_flag = [False]*10 dual_flag = {} ans = {} for i in range(10): for j in range(10): dual_flag[(i, j)] = False ans[(i, j)] = set() for s in S: for i in range(10): for j in range(10): if dual_flag[i, j]: ans[(i, j)].add(int(s)) for i in range(10): if single_flag[i]: dual_flag[(i, int(s))] = True single_flag[int(s)] = True tmp = 0 for v in list(ans.values()): tmp += len(v) print(tmp)
N = int(eval(input())) S = eval(input()) single_flag = [False]*10 dual_flag = {} ans = {} for i in range(10): for j in range(10): dual_flag[(i, j)] = False ans[(i, j)] = set() for s in S: for i in range(10): for j in range(10): if dual_flag[i, j]: ans[(i, j)].add(s) for i in range(10): if single_flag[i]: dual_flag[(i, int(s))] = True single_flag[int(s)] = True tmp = 0 for v in list(ans.values()): tmp += len(v) print(tmp)
25
25
531
526
N = int(eval(input())) S = eval(input()) single_flag = [False] * 10 dual_flag = {} ans = {} for i in range(10): for j in range(10): dual_flag[(i, j)] = False ans[(i, j)] = set() for s in S: for i in range(10): for j in range(10): if dual_flag[i, j]: ans[(i, j)].add(int(s)) for i in range(10): if single_flag[i]: dual_flag[(i, int(s))] = True single_flag[int(s)] = True tmp = 0 for v in list(ans.values()): tmp += len(v) print(tmp)
N = int(eval(input())) S = eval(input()) single_flag = [False] * 10 dual_flag = {} ans = {} for i in range(10): for j in range(10): dual_flag[(i, j)] = False ans[(i, j)] = set() for s in S: for i in range(10): for j in range(10): if dual_flag[i, j]: ans[(i, j)].add(s) for i in range(10): if single_flag[i]: dual_flag[(i, int(s))] = True single_flag[int(s)] = True tmp = 0 for v in list(ans.values()): tmp += len(v) print(tmp)
false
0
[ "- ans[(i, j)].add(int(s))", "+ ans[(i, j)].add(s)" ]
false
0.043442
0.045521
0.954328
[ "s678078886", "s232302952" ]
u780342333
p02386
python
s136231522
s504080258
400
340
7,824
7,824
Accepted
Accepted
15
class Dice: def __init__(self): self.faces=[] def rotate(self, direction): tmp = self.faces.copy() if direction =="N": self.faces[5-1] = tmp[1-1] self.faces[1-1] = tmp[2-1] self.faces[2-1] = tmp[6-1] self.faces[6-1] = tmp[5-1] if direction =="S": self.faces[5-1] = tmp[6-1] self.faces[1-1] = tmp[5-1] self.faces[2-1] = tmp[1-1] self.faces[6-1] = tmp[2-1] if direction =="W": self.faces[4-1] = tmp[1-1] self.faces[1-1] = tmp[3-1] self.faces[3-1] = tmp[6-1] self.faces[6-1] = tmp[4-1] if direction =="E": self.faces[3-1] = tmp[1-1] self.faces[1-1] = tmp[4-1] self.faces[4-1] = tmp[6-1] self.faces[6-1] = tmp[3-1] return 0 def spin(self): self.faces[4-1], self.faces[2-1],self.faces[5-1],self.faces[3-1] =\ self.faces[2-1], self.faces[3-1],self.faces[4-1],self.faces[5-1] return 0 res = "Yes" dices = [] lines = int(input()) for i in range(lines): dices.append(Dice()) dices[i].faces=[int(x) for x in input().split(" ")] #set up side for i, d1 in enumerate(dices): for d2 in dices[i+1 :]: for _ in range(3): for _ in range(4): for ___ in range(4): #print("d1: {}".format(d1.faces)) #print("d2: {}".format(d2.faces)) if d1.faces == d2.faces: res = "No" break d2.spin() d2.rotate("W") d2.rotate("N") print(res)
class Dice: def __init__(self): self.faces=[] def rotate(self, direction): tmp = self.faces.copy() if direction =="N": self.faces[5-1] = tmp[1-1] self.faces[1-1] = tmp[2-1] self.faces[2-1] = tmp[6-1] self.faces[6-1] = tmp[5-1] if direction =="S": self.faces[5-1] = tmp[6-1] self.faces[1-1] = tmp[5-1] self.faces[2-1] = tmp[1-1] self.faces[6-1] = tmp[2-1] if direction =="W": self.faces[4-1] = tmp[1-1] self.faces[1-1] = tmp[3-1] self.faces[3-1] = tmp[6-1] self.faces[6-1] = tmp[4-1] if direction =="E": self.faces[3-1] = tmp[1-1] self.faces[1-1] = tmp[4-1] self.faces[4-1] = tmp[6-1] self.faces[6-1] = tmp[3-1] return 0 def spin(self): self.faces[4-1], self.faces[2-1],self.faces[5-1],self.faces[3-1] =\ self.faces[2-1], self.faces[3-1],self.faces[4-1],self.faces[5-1] return 0 dices = [] lines = int(input()) for i in range(lines): dices.append(Dice()) dices[i].faces=[int(x) for x in input().split(" ")] for i, d1 in enumerate(dices): for d2 in dices[i+1 :]: for _ in range(3): for _ in range(4): for ___ in range(4): #print("d1: {}".format(d1.faces)) #print("d2: {}".format(d2.faces)) if d1.faces == d2.faces: print("No") exit() d2.spin() d2.rotate("W") d2.rotate("N") print("Yes")
58
56
1,757
1,734
class Dice: def __init__(self): self.faces = [] def rotate(self, direction): tmp = self.faces.copy() if direction == "N": self.faces[5 - 1] = tmp[1 - 1] self.faces[1 - 1] = tmp[2 - 1] self.faces[2 - 1] = tmp[6 - 1] self.faces[6 - 1] = tmp[5 - 1] if direction == "S": self.faces[5 - 1] = tmp[6 - 1] self.faces[1 - 1] = tmp[5 - 1] self.faces[2 - 1] = tmp[1 - 1] self.faces[6 - 1] = tmp[2 - 1] if direction == "W": self.faces[4 - 1] = tmp[1 - 1] self.faces[1 - 1] = tmp[3 - 1] self.faces[3 - 1] = tmp[6 - 1] self.faces[6 - 1] = tmp[4 - 1] if direction == "E": self.faces[3 - 1] = tmp[1 - 1] self.faces[1 - 1] = tmp[4 - 1] self.faces[4 - 1] = tmp[6 - 1] self.faces[6 - 1] = tmp[3 - 1] return 0 def spin(self): self.faces[4 - 1], self.faces[2 - 1], self.faces[5 - 1], self.faces[3 - 1] = ( self.faces[2 - 1], self.faces[3 - 1], self.faces[4 - 1], self.faces[5 - 1], ) return 0 res = "Yes" dices = [] lines = int(input()) for i in range(lines): dices.append(Dice()) dices[i].faces = [int(x) for x in input().split(" ")] # set up side for i, d1 in enumerate(dices): for d2 in dices[i + 1 :]: for _ in range(3): for _ in range(4): for ___ in range(4): # print("d1: {}".format(d1.faces)) # print("d2: {}".format(d2.faces)) if d1.faces == d2.faces: res = "No" break d2.spin() d2.rotate("W") d2.rotate("N") print(res)
class Dice: def __init__(self): self.faces = [] def rotate(self, direction): tmp = self.faces.copy() if direction == "N": self.faces[5 - 1] = tmp[1 - 1] self.faces[1 - 1] = tmp[2 - 1] self.faces[2 - 1] = tmp[6 - 1] self.faces[6 - 1] = tmp[5 - 1] if direction == "S": self.faces[5 - 1] = tmp[6 - 1] self.faces[1 - 1] = tmp[5 - 1] self.faces[2 - 1] = tmp[1 - 1] self.faces[6 - 1] = tmp[2 - 1] if direction == "W": self.faces[4 - 1] = tmp[1 - 1] self.faces[1 - 1] = tmp[3 - 1] self.faces[3 - 1] = tmp[6 - 1] self.faces[6 - 1] = tmp[4 - 1] if direction == "E": self.faces[3 - 1] = tmp[1 - 1] self.faces[1 - 1] = tmp[4 - 1] self.faces[4 - 1] = tmp[6 - 1] self.faces[6 - 1] = tmp[3 - 1] return 0 def spin(self): self.faces[4 - 1], self.faces[2 - 1], self.faces[5 - 1], self.faces[3 - 1] = ( self.faces[2 - 1], self.faces[3 - 1], self.faces[4 - 1], self.faces[5 - 1], ) return 0 dices = [] lines = int(input()) for i in range(lines): dices.append(Dice()) dices[i].faces = [int(x) for x in input().split(" ")] for i, d1 in enumerate(dices): for d2 in dices[i + 1 :]: for _ in range(3): for _ in range(4): for ___ in range(4): # print("d1: {}".format(d1.faces)) # print("d2: {}".format(d2.faces)) if d1.faces == d2.faces: print("No") exit() d2.spin() d2.rotate("W") d2.rotate("N") print("Yes")
false
3.448276
[ "-res = \"Yes\"", "-# set up side", "- res = \"No\"", "- break", "+ print(\"No\")", "+ exit()", "-print(res)", "+print(\"Yes\")" ]
false
0.046828
0.039345
1.190182
[ "s136231522", "s504080258" ]
u564902833
p02945
python
s411746360
s585516940
21
17
3,316
2,940
Accepted
Accepted
19.05
A, B = list(map(int, input().split())) ans = max(A + B, A - B, A * B) print(ans)
A, B = list(map(int, input().split())) x = A+B y =A-B z =A*B if x > y: if x>z: ans = x else: ans = z else: if y>z: ans = y else: ans = z print(ans)
5
18
81
186
A, B = list(map(int, input().split())) ans = max(A + B, A - B, A * B) print(ans)
A, B = list(map(int, input().split())) x = A + B y = A - B z = A * B if x > y: if x > z: ans = x else: ans = z else: if y > z: ans = y else: ans = z print(ans)
false
72.222222
[ "-ans = max(A + B, A - B, A * B)", "+x = A + B", "+y = A - B", "+z = A * B", "+if x > y:", "+ if x > z:", "+ ans = x", "+ else:", "+ ans = z", "+else:", "+ if y > z:", "+ ans = y", "+ else:", "+ ans = z" ]
false
0.040694
0.039547
1.028987
[ "s411746360", "s585516940" ]
u312025627
p03162
python
s054754174
s528286632
675
243
85,208
104,948
Accepted
Accepted
64
def main(): N = int(eval(input())) A = [0] B = [0] C = [0] for i in range(N): a, b, c = (int(i) for i in input().split()) A.append(a) B.append(b) C.append(c) dp = [[0 for _ in range(N+1)] for _ in range(3)] dp[0][1] = A[1] dp[1][1] = B[1] dp[2][1] = C[1] for i in range(1, N): dp[2][i+1] = max(dp[0][i] + C[i+1], dp[1][i] + C[i+1]) dp[1][i+1] = max(dp[0][i] + B[i+1], dp[2][i] + B[i+1]) dp[0][i+1] = max(dp[1][i] + A[i+1], dp[2][i] + A[i+1]) print((max(dp[0][-1], dp[1][-1], dp[2][-1]))) if __name__ == '__main__': main()
def main(): N = int(eval(input())) ABC = [[int(i) for i in input().split()] for j in range(N)] dp = [[0]*3 for _ in range(N+1)] for i in range(N): for j in range(3): dp[i+1][j] = max(dp[i][(j+1) % 3], dp[i][(j+2) % 3]) + ABC[i][j] print((max(dp[N]))) if __name__ == '__main__': main()
25
14
646
338
def main(): N = int(eval(input())) A = [0] B = [0] C = [0] for i in range(N): a, b, c = (int(i) for i in input().split()) A.append(a) B.append(b) C.append(c) dp = [[0 for _ in range(N + 1)] for _ in range(3)] dp[0][1] = A[1] dp[1][1] = B[1] dp[2][1] = C[1] for i in range(1, N): dp[2][i + 1] = max(dp[0][i] + C[i + 1], dp[1][i] + C[i + 1]) dp[1][i + 1] = max(dp[0][i] + B[i + 1], dp[2][i] + B[i + 1]) dp[0][i + 1] = max(dp[1][i] + A[i + 1], dp[2][i] + A[i + 1]) print((max(dp[0][-1], dp[1][-1], dp[2][-1]))) if __name__ == "__main__": main()
def main(): N = int(eval(input())) ABC = [[int(i) for i in input().split()] for j in range(N)] dp = [[0] * 3 for _ in range(N + 1)] for i in range(N): for j in range(3): dp[i + 1][j] = max(dp[i][(j + 1) % 3], dp[i][(j + 2) % 3]) + ABC[i][j] print((max(dp[N]))) if __name__ == "__main__": main()
false
44
[ "- A = [0]", "- B = [0]", "- C = [0]", "+ ABC = [[int(i) for i in input().split()] for j in range(N)]", "+ dp = [[0] * 3 for _ in range(N + 1)]", "- a, b, c = (int(i) for i in input().split())", "- A.append(a)", "- B.append(b)", "- C.append(c)", "- dp = [[0 for _ in range(N + 1)] for _ in range(3)]", "- dp[0][1] = A[1]", "- dp[1][1] = B[1]", "- dp[2][1] = C[1]", "- for i in range(1, N):", "- dp[2][i + 1] = max(dp[0][i] + C[i + 1], dp[1][i] + C[i + 1])", "- dp[1][i + 1] = max(dp[0][i] + B[i + 1], dp[2][i] + B[i + 1])", "- dp[0][i + 1] = max(dp[1][i] + A[i + 1], dp[2][i] + A[i + 1])", "- print((max(dp[0][-1], dp[1][-1], dp[2][-1])))", "+ for j in range(3):", "+ dp[i + 1][j] = max(dp[i][(j + 1) % 3], dp[i][(j + 2) % 3]) + ABC[i][j]", "+ print((max(dp[N])))" ]
false
0.076296
0.053882
1.415975
[ "s054754174", "s528286632" ]
u057964173
p03807
python
s048795815
s209009469
54
43
14,108
14,104
Accepted
Accepted
20.37
def resolve(): n=int(eval(input())) l=list(map(int, input().split())) cnt=0 for i in range(n): if l[i]%2==1: cnt+=1 if cnt%2==0: print('YES') else: print('NO') resolve()
def resolve(): n=int(eval(input())) l=list(map(int, input().split())) if sum(l)%2==0: print('YES') else: print('NO') resolve()
12
8
234
159
def resolve(): n = int(eval(input())) l = list(map(int, input().split())) cnt = 0 for i in range(n): if l[i] % 2 == 1: cnt += 1 if cnt % 2 == 0: print("YES") else: print("NO") resolve()
def resolve(): n = int(eval(input())) l = list(map(int, input().split())) if sum(l) % 2 == 0: print("YES") else: print("NO") resolve()
false
33.333333
[ "- cnt = 0", "- for i in range(n):", "- if l[i] % 2 == 1:", "- cnt += 1", "- if cnt % 2 == 0:", "+ if sum(l) % 2 == 0:" ]
false
0.039381
0.041516
0.948562
[ "s048795815", "s209009469" ]
u796942881
p03208
python
s023531731
s429307914
236
118
7,384
14,092
Accepted
Accepted
50
INF = 1000000007 N, K = list(map(int, input().split())) h = [int(eval(input())) for i in range(N)] h.sort() ans = INF for i in range(N - K + 1): ans = min(ans, h[i + K - 1] - h[i]) print(ans)
INF = 1000000007 N, K, *h = list(map(int, open(0).read().split())) h.sort() ans = INF for i in range(N - K + 1): ans = min(ans, h[i + K - 1] - h[i]) print(ans)
13
12
201
174
INF = 1000000007 N, K = list(map(int, input().split())) h = [int(eval(input())) for i in range(N)] h.sort() ans = INF for i in range(N - K + 1): ans = min(ans, h[i + K - 1] - h[i]) print(ans)
INF = 1000000007 N, K, *h = list(map(int, open(0).read().split())) h.sort() ans = INF for i in range(N - K + 1): ans = min(ans, h[i + K - 1] - h[i]) print(ans)
false
7.692308
[ "-N, K = list(map(int, input().split()))", "-h = [int(eval(input())) for i in range(N)]", "+N, K, *h = list(map(int, open(0).read().split()))" ]
false
0.054304
0.068429
0.79359
[ "s023531731", "s429307914" ]
u281303342
p03330
python
s158003293
s922690458
1,964
189
7,696
5,620
Accepted
Accepted
90.38
N,C = list(map(int,input().split())) D = [] for i in range(C): d = list(map(int,input().split())) D.append(d) A = [] for i in range(N): a = list(map(int,input().split())) A.append(a) X0,X1,X2 = [],[],[] for i in range(N): for j in range(N): if (i+j)%3 == 0: X0.append(A[i][j]) elif (i+j)%3 == 1: X1.append(A[i][j]) else: X2.append(A[i][j]) # それぞれの集合を塗り替える場合のコストを計算 Xn = [X0,X1,X2] cost = [[0 for _ in range(C)] for _ in range(3)] for i in range(3): for c in range(1,C+1): Ans = 0 for x in Xn[i]: if x != c: Ans += D[x-1][c-1] cost[i][c-1] = Ans Y0 = cost[0] Y1 = cost[1] Y2 = cost[2] Ans = 1000000000000000 for i in range(C): for j in range(C): for k in range(C): if i != j and j != k and k != i: Ans = min(Ans, Y0[i]+Y1[j]+Y2[k]) print(Ans)
# Python3 (3.4.3) import sys input = sys.stdin.readline # ------------------------------------------------------------- # function # ------------------------------------------------------------- # ------------------------------------------------------------- # main # ------------------------------------------------------------- # 入力の C は M とする N,M = list(map(int,input().split())) D = [list(map(int,input().split())) for _ in range(M)] C = [list(map(int,input().split())) for _ in range(N)] # X[x][y] : (i+j)%3 == x の, 初期状態での色が y(0-indexed) のマスの数 X = [[0 for _ in range(M)] for _ in range(3)] for i in range(N): for j in range(N): x = (i+1 + j+1)%3 y = C[i][j] - 1 X[x][y] += 1 # Y[x][y] : (i+j)%3 == x の領域を y で塗る場合に必要なコスト Y = [[0 for _ in range(M)] for _ in range(3)] for i in range(3): for c_to in range(M): total = 0 for c_from in range(M): total += X[i][c_from] * D[c_from][c_to] Y[i][c_to] = total ans = 10**10 # 塗る色の組み合わせで全探索 for i in range(M): for j in range(M): for k in range(M): # 全ての色が異なる場合のみ考える if i != j and j != k and k != i: ans = min(ans, Y[0][i] +Y[1][j] + Y[2][k] ) print(ans)
42
44
957
1,260
N, C = list(map(int, input().split())) D = [] for i in range(C): d = list(map(int, input().split())) D.append(d) A = [] for i in range(N): a = list(map(int, input().split())) A.append(a) X0, X1, X2 = [], [], [] for i in range(N): for j in range(N): if (i + j) % 3 == 0: X0.append(A[i][j]) elif (i + j) % 3 == 1: X1.append(A[i][j]) else: X2.append(A[i][j]) # それぞれの集合を塗り替える場合のコストを計算 Xn = [X0, X1, X2] cost = [[0 for _ in range(C)] for _ in range(3)] for i in range(3): for c in range(1, C + 1): Ans = 0 for x in Xn[i]: if x != c: Ans += D[x - 1][c - 1] cost[i][c - 1] = Ans Y0 = cost[0] Y1 = cost[1] Y2 = cost[2] Ans = 1000000000000000 for i in range(C): for j in range(C): for k in range(C): if i != j and j != k and k != i: Ans = min(Ans, Y0[i] + Y1[j] + Y2[k]) print(Ans)
# Python3 (3.4.3) import sys input = sys.stdin.readline # ------------------------------------------------------------- # function # ------------------------------------------------------------- # ------------------------------------------------------------- # main # ------------------------------------------------------------- # 入力の C は M とする N, M = list(map(int, input().split())) D = [list(map(int, input().split())) for _ in range(M)] C = [list(map(int, input().split())) for _ in range(N)] # X[x][y] : (i+j)%3 == x の, 初期状態での色が y(0-indexed) のマスの数 X = [[0 for _ in range(M)] for _ in range(3)] for i in range(N): for j in range(N): x = (i + 1 + j + 1) % 3 y = C[i][j] - 1 X[x][y] += 1 # Y[x][y] : (i+j)%3 == x の領域を y で塗る場合に必要なコスト Y = [[0 for _ in range(M)] for _ in range(3)] for i in range(3): for c_to in range(M): total = 0 for c_from in range(M): total += X[i][c_from] * D[c_from][c_to] Y[i][c_to] = total ans = 10**10 # 塗る色の組み合わせで全探索 for i in range(M): for j in range(M): for k in range(M): # 全ての色が異なる場合のみ考える if i != j and j != k and k != i: ans = min(ans, Y[0][i] + Y[1][j] + Y[2][k]) print(ans)
false
4.545455
[ "-N, C = list(map(int, input().split()))", "-D = []", "-for i in range(C):", "- d = list(map(int, input().split()))", "- D.append(d)", "-A = []", "-for i in range(N):", "- a = list(map(int, input().split()))", "- A.append(a)", "-X0, X1, X2 = [], [], []", "+# Python3 (3.4.3)", "+import sys", "+", "+input = sys.stdin.readline", "+# function", "+# main", "+# 入力の C は M とする", "+N, M = list(map(int, input().split()))", "+D = [list(map(int, input().split())) for _ in range(M)]", "+C = [list(map(int, input().split())) for _ in range(N)]", "+# X[x][y] : (i+j)%3 == x の, 初期状態での色が y(0-indexed) のマスの数", "+X = [[0 for _ in range(M)] for _ in range(3)]", "- if (i + j) % 3 == 0:", "- X0.append(A[i][j])", "- elif (i + j) % 3 == 1:", "- X1.append(A[i][j])", "- else:", "- X2.append(A[i][j])", "-# それぞれの集合を塗り替える場合のコストを計算", "-Xn = [X0, X1, X2]", "-cost = [[0 for _ in range(C)] for _ in range(3)]", "+ x = (i + 1 + j + 1) % 3", "+ y = C[i][j] - 1", "+ X[x][y] += 1", "+# Y[x][y] : (i+j)%3 == x の領域を y で塗る場合に必要なコスト", "+Y = [[0 for _ in range(M)] for _ in range(3)]", "- for c in range(1, C + 1):", "- Ans = 0", "- for x in Xn[i]:", "- if x != c:", "- Ans += D[x - 1][c - 1]", "- cost[i][c - 1] = Ans", "-Y0 = cost[0]", "-Y1 = cost[1]", "-Y2 = cost[2]", "-Ans = 1000000000000000", "-for i in range(C):", "- for j in range(C):", "- for k in range(C):", "+ for c_to in range(M):", "+ total = 0", "+ for c_from in range(M):", "+ total += X[i][c_from] * D[c_from][c_to]", "+ Y[i][c_to] = total", "+ans = 10**10", "+# 塗る色の組み合わせで全探索", "+for i in range(M):", "+ for j in range(M):", "+ for k in range(M):", "+ # 全ての色が異なる場合のみ考える", "- Ans = min(Ans, Y0[i] + Y1[j] + Y2[k])", "-print(Ans)", "+ ans = min(ans, Y[0][i] + Y[1][j] + Y[2][k])", "+print(ans)" ]
false
0.037433
0.040137
0.932638
[ "s158003293", "s922690458" ]
u504277357
p03161
python
s929958135
s626123788
1,921
364
23,052
54,112
Accepted
Accepted
81.05
import sys import numpy as np # inputを高速化する。 input = sys.stdin.readline n, k = list(map(int, input().split())) h = [int(i) for i in input().split()] # dpの配列を作る。 dp = np.zeros(n, dtype=int) # hの配列を作る。 h = np.array(h) for i in range(1, n): # start は負になることはない。 start = max(0, i-k) # 行列として足し算できるのでforを使う必要がない。 dp[i] = min(dp[start: i] + np.abs(h[i] - h[start: i])) print((dp[n-1]))
import sys N,K=list(map(int,input().split())) h=list(map(int,input().split()))+[0]*100000 dp=[sys.maxsize]*(N+K+10) dp[1]=0 for i in range(1,N): for k in range(1,K+1): dp[i+k]=min(dp[i+k],dp[i]+abs(h[i+k-1]-h[i-1])) print((dp[N]))
16
13
400
264
import sys import numpy as np # inputを高速化する。 input = sys.stdin.readline n, k = list(map(int, input().split())) h = [int(i) for i in input().split()] # dpの配列を作る。 dp = np.zeros(n, dtype=int) # hの配列を作る。 h = np.array(h) for i in range(1, n): # start は負になることはない。 start = max(0, i - k) # 行列として足し算できるのでforを使う必要がない。 dp[i] = min(dp[start:i] + np.abs(h[i] - h[start:i])) print((dp[n - 1]))
import sys N, K = list(map(int, input().split())) h = list(map(int, input().split())) + [0] * 100000 dp = [sys.maxsize] * (N + K + 10) dp[1] = 0 for i in range(1, N): for k in range(1, K + 1): dp[i + k] = min(dp[i + k], dp[i] + abs(h[i + k - 1] - h[i - 1])) print((dp[N]))
false
18.75
[ "-import numpy as np", "-# inputを高速化する。", "-input = sys.stdin.readline", "-n, k = list(map(int, input().split()))", "-h = [int(i) for i in input().split()]", "-# dpの配列を作る。", "-dp = np.zeros(n, dtype=int)", "-# hの配列を作る。", "-h = np.array(h)", "-for i in range(1, n):", "- # start は負になることはない。", "- start = max(0, i - k)", "- # 行列として足し算できるのでforを使う必要がない。", "- dp[i] = min(dp[start:i] + np.abs(h[i] - h[start:i]))", "-print((dp[n - 1]))", "+N, K = list(map(int, input().split()))", "+h = list(map(int, input().split())) + [0] * 100000", "+dp = [sys.maxsize] * (N + K + 10)", "+dp[1] = 0", "+for i in range(1, N):", "+ for k in range(1, K + 1):", "+ dp[i + k] = min(dp[i + k], dp[i] + abs(h[i + k - 1] - h[i - 1]))", "+print((dp[N]))" ]
false
1.357321
0.094338
14.387903
[ "s929958135", "s626123788" ]
u287500079
p03212
python
s677469083
s436342376
278
190
60,140
38,384
Accepted
Accepted
31.65
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from fractions import gcd def input(): return sys.stdin.readline().strip() def STR(): return eval(input()) def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def S_MAP(): return list(map(str, input().split())) def LIST(): return list(map(int, input().split())) def S_LIST(): return list(map(str, input().split())) sys.setrecursionlimit(10 ** 9) inf = sys.maxsize mod = 10 ** 9 + 7 def func(a, b): if a > b: return 0 else: return 1 def solvedp(arr, ii): dp = [[0, 0] for _ in range(ii)] lenarr = len(arr) if ii == l: n0 = int(n[0]) a = lenarr for j in range(lenarr): a -= func(n0, arr[j]) dp[0][0] = a dp[0][1] = 1 if n0 in arr else 0 else: dp[0][0] = lenarr for i in range(1, ii): if ii == l: ni = int(n[i]) a = lenarr for j in range(lenarr): a -= func(ni, arr[j]) dp[i][0] = dp[i-1][0] * lenarr + dp[i-1][1] * a dp[i][1] = dp[i-1][1] if ni in arr else 0 else: dp[i][0] = dp[i-1][0] * lenarr return dp n = STR() l = len(n) ans = 0 arr = [[3], [5], [7], [3, 5], [5, 7], [7, 3], [3, 5, 7]] for ii in range(1, l + 1): dp = [[[0, 0]for _ in range(ii)]for _ in range(7)] for i in range(7): dp[i] = solvedp(arr[i], ii) res = sum(dp[6][ii-1]) for i in range(3, 6): res -= sum(dp[i][ii-1]) for i in range(3): res += sum(dp[i][ii-1]) ans += res print(ans)
def STR(): return eval(input()) def func(a, b): if a > b: return 0 else: return 1 def solve_dp(arr, ii): dp = [[0, 0] for _ in range(ii)] lenarr = len(arr) n0 = int(n[0]) a = lenarr for j in range(lenarr): a -= func(n0, arr[j]) dp[0][0] = a dp[0][1] = 1 if n0 in arr else 0 for i in range(1, ii): ni = int(n[i]) a = lenarr for j in range(lenarr): a -= func(ni, arr[j]) dp[i][0] = dp[i-1][0] * lenarr + dp[i-1][1] * a dp[i][1] = dp[i-1][1] if ni in arr else 0 return sum(dp[ii-1]) n = STR() l = len(n) ans = 0 arr = [[3], [5], [7], [3, 5], [5, 7], [7, 3], [3, 5, 7]] ans = solve_dp(arr[6], l) for i in range(3): ans += solve_dp(arr[i], l) for i in range(3, 6): ans -= solve_dp(arr[i], l) for i in range(1, l): ans += pow(3, i) + 3 - 3 * pow(2, i) print(ans)
66
39
1,922
924
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from fractions import gcd def input(): return sys.stdin.readline().strip() def STR(): return eval(input()) def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def S_MAP(): return list(map(str, input().split())) def LIST(): return list(map(int, input().split())) def S_LIST(): return list(map(str, input().split())) sys.setrecursionlimit(10**9) inf = sys.maxsize mod = 10**9 + 7 def func(a, b): if a > b: return 0 else: return 1 def solvedp(arr, ii): dp = [[0, 0] for _ in range(ii)] lenarr = len(arr) if ii == l: n0 = int(n[0]) a = lenarr for j in range(lenarr): a -= func(n0, arr[j]) dp[0][0] = a dp[0][1] = 1 if n0 in arr else 0 else: dp[0][0] = lenarr for i in range(1, ii): if ii == l: ni = int(n[i]) a = lenarr for j in range(lenarr): a -= func(ni, arr[j]) dp[i][0] = dp[i - 1][0] * lenarr + dp[i - 1][1] * a dp[i][1] = dp[i - 1][1] if ni in arr else 0 else: dp[i][0] = dp[i - 1][0] * lenarr return dp n = STR() l = len(n) ans = 0 arr = [[3], [5], [7], [3, 5], [5, 7], [7, 3], [3, 5, 7]] for ii in range(1, l + 1): dp = [[[0, 0] for _ in range(ii)] for _ in range(7)] for i in range(7): dp[i] = solvedp(arr[i], ii) res = sum(dp[6][ii - 1]) for i in range(3, 6): res -= sum(dp[i][ii - 1]) for i in range(3): res += sum(dp[i][ii - 1]) ans += res print(ans)
def STR(): return eval(input()) def func(a, b): if a > b: return 0 else: return 1 def solve_dp(arr, ii): dp = [[0, 0] for _ in range(ii)] lenarr = len(arr) n0 = int(n[0]) a = lenarr for j in range(lenarr): a -= func(n0, arr[j]) dp[0][0] = a dp[0][1] = 1 if n0 in arr else 0 for i in range(1, ii): ni = int(n[i]) a = lenarr for j in range(lenarr): a -= func(ni, arr[j]) dp[i][0] = dp[i - 1][0] * lenarr + dp[i - 1][1] * a dp[i][1] = dp[i - 1][1] if ni in arr else 0 return sum(dp[ii - 1]) n = STR() l = len(n) ans = 0 arr = [[3], [5], [7], [3, 5], [5, 7], [7, 3], [3, 5, 7]] ans = solve_dp(arr[6], l) for i in range(3): ans += solve_dp(arr[i], l) for i in range(3, 6): ans -= solve_dp(arr[i], l) for i in range(1, l): ans += pow(3, i) + 3 - 3 * pow(2, i) print(ans)
false
40.909091
[ "-import sys, re, os", "-from collections import deque, defaultdict, Counter", "-from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians", "-from itertools import permutations, combinations, product, accumulate", "-from operator import itemgetter, mul", "-from copy import deepcopy", "-from string import ascii_lowercase, ascii_uppercase, digits", "-from fractions import gcd", "-", "-", "-def input():", "- return sys.stdin.readline().strip()", "-", "-", "-", "-", "-def INT():", "- return int(eval(input()))", "-", "-", "-def MAP():", "- return list(map(int, input().split()))", "-", "-", "-def S_MAP():", "- return list(map(str, input().split()))", "-", "-", "-def LIST():", "- return list(map(int, input().split()))", "-", "-", "-def S_LIST():", "- return list(map(str, input().split()))", "-", "-", "-sys.setrecursionlimit(10**9)", "-inf = sys.maxsize", "-mod = 10**9 + 7", "-def solvedp(arr, ii):", "+def solve_dp(arr, ii):", "- if ii == l:", "- n0 = int(n[0])", "+ n0 = int(n[0])", "+ a = lenarr", "+ for j in range(lenarr):", "+ a -= func(n0, arr[j])", "+ dp[0][0] = a", "+ dp[0][1] = 1 if n0 in arr else 0", "+ for i in range(1, ii):", "+ ni = int(n[i])", "- a -= func(n0, arr[j])", "- dp[0][0] = a", "- dp[0][1] = 1 if n0 in arr else 0", "- else:", "- dp[0][0] = lenarr", "- for i in range(1, ii):", "- if ii == l:", "- ni = int(n[i])", "- a = lenarr", "- for j in range(lenarr):", "- a -= func(ni, arr[j])", "- dp[i][0] = dp[i - 1][0] * lenarr + dp[i - 1][1] * a", "- dp[i][1] = dp[i - 1][1] if ni in arr else 0", "- else:", "- dp[i][0] = dp[i - 1][0] * lenarr", "- return dp", "+ a -= func(ni, arr[j])", "+ dp[i][0] = dp[i - 1][0] * lenarr + dp[i - 1][1] * a", "+ dp[i][1] = dp[i - 1][1] if ni in arr else 0", "+ return sum(dp[ii - 1])", "-for ii in range(1, l + 1):", "- dp = [[[0, 0] for _ in range(ii)] for _ in range(7)]", "- for i in range(7):", "- dp[i] = solvedp(arr[i], ii)", "- res = sum(dp[6][ii - 1])", "- for i in range(3, 6):", "- res -= sum(dp[i][ii - 1])", "- for i in range(3):", "- res += sum(dp[i][ii - 1])", "- ans += res", "+ans = solve_dp(arr[6], l)", "+for i in range(3):", "+ ans += solve_dp(arr[i], l)", "+for i in range(3, 6):", "+ ans -= solve_dp(arr[i], l)", "+for i in range(1, l):", "+ ans += pow(3, i) + 3 - 3 * pow(2, i)" ]
false
0.071596
0.036317
1.971432
[ "s677469083", "s436342376" ]
u374103100
p03242
python
s378922744
s951690685
19
17
2,940
2,940
Accepted
Accepted
10.53
ans = [ "9" if s == "1" else "1" for s in list(eval(input()))] print(("".join(ans)))
print(("".join([ "9" if s == "1" else "1" for s in list(eval(input()))])))
2
1
77
66
ans = ["9" if s == "1" else "1" for s in list(eval(input()))] print(("".join(ans)))
print(("".join(["9" if s == "1" else "1" for s in list(eval(input()))])))
false
50
[ "-ans = [\"9\" if s == \"1\" else \"1\" for s in list(eval(input()))]", "-print((\"\".join(ans)))", "+print((\"\".join([\"9\" if s == \"1\" else \"1\" for s in list(eval(input()))])))" ]
false
0.037109
0.037013
1.002606
[ "s378922744", "s951690685" ]
u562935282
p03112
python
s780272149
s749626586
1,992
705
78,584
12,816
Accepted
Accepted
64.61
from bisect import bisect_left inf = (10 ** 10) * 2 + 10 a, b, q = list(map(int, input().split())) s = [-inf] for _ in range(a): s.append(int(eval(input()))) s.append(inf) s.sort() t = [-inf] for _ in range(b): t.append(int(eval(input()))) t.append(inf) t.sort() for _ in range(q): x = int(eval(input())) si = bisect_left(s, x) - 1 ti = bisect_left(t, x) - 1 ret = inf for sx in s[si:si + 2]: for tx in t[ti:ti + 2]: ret = min(ret, min(abs(x - sx), abs(x - tx)) + abs(sx - tx)) print(ret)
def main(): from bisect import bisect_left import sys input = sys.stdin.readline inf = (10 ** 10) * 2 + 10 a, b, q = list(map(int, input().split())) s = [-inf] + [int(eval(input())) for _ in range(a)] + [inf] # s.sort() t = [-inf] + [int(eval(input())) for _ in range(b)] + [inf] # t.sort() for _ in range(q): x = int(eval(input())) si = bisect_left(s, x) - 1 ti = bisect_left(t, x) - 1 ret = inf for sx in s[si:si + 2]: for tx in t[ti:ti + 2]: ret = min(ret, min(abs(x - sx), abs(x - tx)) + abs(sx - tx)) print(ret) if __name__ == '__main__': main()
29
30
552
685
from bisect import bisect_left inf = (10**10) * 2 + 10 a, b, q = list(map(int, input().split())) s = [-inf] for _ in range(a): s.append(int(eval(input()))) s.append(inf) s.sort() t = [-inf] for _ in range(b): t.append(int(eval(input()))) t.append(inf) t.sort() for _ in range(q): x = int(eval(input())) si = bisect_left(s, x) - 1 ti = bisect_left(t, x) - 1 ret = inf for sx in s[si : si + 2]: for tx in t[ti : ti + 2]: ret = min(ret, min(abs(x - sx), abs(x - tx)) + abs(sx - tx)) print(ret)
def main(): from bisect import bisect_left import sys input = sys.stdin.readline inf = (10**10) * 2 + 10 a, b, q = list(map(int, input().split())) s = [-inf] + [int(eval(input())) for _ in range(a)] + [inf] # s.sort() t = [-inf] + [int(eval(input())) for _ in range(b)] + [inf] # t.sort() for _ in range(q): x = int(eval(input())) si = bisect_left(s, x) - 1 ti = bisect_left(t, x) - 1 ret = inf for sx in s[si : si + 2]: for tx in t[ti : ti + 2]: ret = min(ret, min(abs(x - sx), abs(x - tx)) + abs(sx - tx)) print(ret) if __name__ == "__main__": main()
false
3.333333
[ "-from bisect import bisect_left", "+def main():", "+ from bisect import bisect_left", "+ import sys", "-inf = (10**10) * 2 + 10", "-a, b, q = list(map(int, input().split()))", "-s = [-inf]", "-for _ in range(a):", "- s.append(int(eval(input())))", "-s.append(inf)", "-s.sort()", "-t = [-inf]", "-for _ in range(b):", "- t.append(int(eval(input())))", "-t.append(inf)", "-t.sort()", "-for _ in range(q):", "- x = int(eval(input()))", "- si = bisect_left(s, x) - 1", "- ti = bisect_left(t, x) - 1", "- ret = inf", "- for sx in s[si : si + 2]:", "- for tx in t[ti : ti + 2]:", "- ret = min(ret, min(abs(x - sx), abs(x - tx)) + abs(sx - tx))", "- print(ret)", "+ input = sys.stdin.readline", "+ inf = (10**10) * 2 + 10", "+ a, b, q = list(map(int, input().split()))", "+ s = [-inf] + [int(eval(input())) for _ in range(a)] + [inf]", "+ # s.sort()", "+ t = [-inf] + [int(eval(input())) for _ in range(b)] + [inf]", "+ # t.sort()", "+ for _ in range(q):", "+ x = int(eval(input()))", "+ si = bisect_left(s, x) - 1", "+ ti = bisect_left(t, x) - 1", "+ ret = inf", "+ for sx in s[si : si + 2]:", "+ for tx in t[ti : ti + 2]:", "+ ret = min(ret, min(abs(x - sx), abs(x - tx)) + abs(sx - tx))", "+ print(ret)", "+", "+", "+if __name__ == \"__main__\":", "+ main()" ]
false
0.037936
0.052694
0.719941
[ "s780272149", "s749626586" ]
u935984175
p03044
python
s705835422
s835617631
876
478
87,284
81,056
Accepted
Accepted
45.43
import sys sys.setrecursionlimit(10**7) N = int(eval(input())) edges = [[] for _ in range(N+1)] for _ in range(N-1): u, v, w = list(map(int, input().split())) edges[u].append([v, w]) edges[v].append([u, w]) ans = [-1 for _ in range(N)] def dfs(edge, pd): for child, d in edges[edge]: if ans[child-1] != -1: continue cd = pd + d if cd % 2 == 0: ans[child-1] = 0 else: ans[child-1] = 1 dfs(child, cd) def solve(): dfs(1, 0) for i in range(N): print((ans[i])) if __name__ == '__main__': solve()
import sys from collections import deque rl = sys.stdin.readline def solve(): N = int(rl()) graph = [[] for _ in range(N)] for _ in range(N - 1): u, v, w = list(map(int, rl().split())) u -= 1 v -= 1 graph[u].append([v, w]) graph[v].append([u, w]) ans = [-1] * N stack = deque([[0, 0]]) while stack: node, dist = stack.pop() for child, weight in graph[node]: if ans[child] != -1: continue nd = dist + weight if nd % 2 == 0: ans[child] = 0 else: ans[child] = 1 stack.append([child, nd]) print(('\n'.join(map(str, ans)))) if __name__ == '__main__': solve()
32
35
628
791
import sys sys.setrecursionlimit(10**7) N = int(eval(input())) edges = [[] for _ in range(N + 1)] for _ in range(N - 1): u, v, w = list(map(int, input().split())) edges[u].append([v, w]) edges[v].append([u, w]) ans = [-1 for _ in range(N)] def dfs(edge, pd): for child, d in edges[edge]: if ans[child - 1] != -1: continue cd = pd + d if cd % 2 == 0: ans[child - 1] = 0 else: ans[child - 1] = 1 dfs(child, cd) def solve(): dfs(1, 0) for i in range(N): print((ans[i])) if __name__ == "__main__": solve()
import sys from collections import deque rl = sys.stdin.readline def solve(): N = int(rl()) graph = [[] for _ in range(N)] for _ in range(N - 1): u, v, w = list(map(int, rl().split())) u -= 1 v -= 1 graph[u].append([v, w]) graph[v].append([u, w]) ans = [-1] * N stack = deque([[0, 0]]) while stack: node, dist = stack.pop() for child, weight in graph[node]: if ans[child] != -1: continue nd = dist + weight if nd % 2 == 0: ans[child] = 0 else: ans[child] = 1 stack.append([child, nd]) print(("\n".join(map(str, ans)))) if __name__ == "__main__": solve()
false
8.571429
[ "+from collections import deque", "-sys.setrecursionlimit(10**7)", "-N = int(eval(input()))", "-edges = [[] for _ in range(N + 1)]", "-for _ in range(N - 1):", "- u, v, w = list(map(int, input().split()))", "- edges[u].append([v, w])", "- edges[v].append([u, w])", "-ans = [-1 for _ in range(N)]", "-", "-", "-def dfs(edge, pd):", "- for child, d in edges[edge]:", "- if ans[child - 1] != -1:", "- continue", "- cd = pd + d", "- if cd % 2 == 0:", "- ans[child - 1] = 0", "- else:", "- ans[child - 1] = 1", "- dfs(child, cd)", "+rl = sys.stdin.readline", "- dfs(1, 0)", "- for i in range(N):", "- print((ans[i]))", "+ N = int(rl())", "+ graph = [[] for _ in range(N)]", "+ for _ in range(N - 1):", "+ u, v, w = list(map(int, rl().split()))", "+ u -= 1", "+ v -= 1", "+ graph[u].append([v, w])", "+ graph[v].append([u, w])", "+ ans = [-1] * N", "+ stack = deque([[0, 0]])", "+ while stack:", "+ node, dist = stack.pop()", "+ for child, weight in graph[node]:", "+ if ans[child] != -1:", "+ continue", "+ nd = dist + weight", "+ if nd % 2 == 0:", "+ ans[child] = 0", "+ else:", "+ ans[child] = 1", "+ stack.append([child, nd])", "+ print((\"\\n\".join(map(str, ans))))" ]
false
0.03463
0.035298
0.981088
[ "s705835422", "s835617631" ]
u767664985
p03495
python
s998176560
s150890659
247
216
37,788
37,784
Accepted
Accepted
12.55
from collections import Counter N, K = list(map(int, input().split())) A = Counter(list(map(int, input().split()))).most_common() l = len(A) ans = 0 while l > K: ans += A[-1][1] del A[-1] l = len(A) print(ans)
from collections import Counter N, K = list(map(int, input().split())) A = Counter(list(map(int, input().split()))).most_common() ans = 0 while len(A) > K: ans += A[-1][1] del A[-1] print(ans)
10
8
216
196
from collections import Counter N, K = list(map(int, input().split())) A = Counter(list(map(int, input().split()))).most_common() l = len(A) ans = 0 while l > K: ans += A[-1][1] del A[-1] l = len(A) print(ans)
from collections import Counter N, K = list(map(int, input().split())) A = Counter(list(map(int, input().split()))).most_common() ans = 0 while len(A) > K: ans += A[-1][1] del A[-1] print(ans)
false
20
[ "-l = len(A)", "-while l > K:", "+while len(A) > K:", "- l = len(A)" ]
false
0.043903
0.043881
1.00051
[ "s998176560", "s150890659" ]
u263830634
p03311
python
s228419203
s385126713
262
208
25,200
25,744
Accepted
Accepted
20.61
#平均値に近づけるという考え方が間違い-->中央値に近づける N = int(eval(input())) A = list(map(int, input().split())) A = [A[i]-(i+1) for i in range(N)] A.sort() center1 = A[N//2] if N == 1: center2 = 10 ** 9 else: center2 = A[(N+2)//2] ans1 = 0 for i in range(N): ans1 +=abs(A[i]-center1) ans2 = 0 for j in range(N): ans2 += abs(A[j]-center2) print((min(ans1, ans2)))
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 9) MOD = 10 ** 9 + 7 N = int(eval(input())) A_ = list(map(int, input().split())) A = [A_[i] - i - 1 for i in range(N)] A.sort() tmp = A[N // 2] ans = 0 for a in A: ans += abs(tmp - a) print (ans)
24
19
387
283
# 平均値に近づけるという考え方が間違い-->中央値に近づける N = int(eval(input())) A = list(map(int, input().split())) A = [A[i] - (i + 1) for i in range(N)] A.sort() center1 = A[N // 2] if N == 1: center2 = 10**9 else: center2 = A[(N + 2) // 2] ans1 = 0 for i in range(N): ans1 += abs(A[i] - center1) ans2 = 0 for j in range(N): ans2 += abs(A[j] - center2) print((min(ans1, ans2)))
import sys input = sys.stdin.readline sys.setrecursionlimit(10**9) MOD = 10**9 + 7 N = int(eval(input())) A_ = list(map(int, input().split())) A = [A_[i] - i - 1 for i in range(N)] A.sort() tmp = A[N // 2] ans = 0 for a in A: ans += abs(tmp - a) print(ans)
false
20.833333
[ "-# 平均値に近づけるという考え方が間違い-->中央値に近づける", "+import sys", "+", "+input = sys.stdin.readline", "+sys.setrecursionlimit(10**9)", "+MOD = 10**9 + 7", "-A = list(map(int, input().split()))", "-A = [A[i] - (i + 1) for i in range(N)]", "+A_ = list(map(int, input().split()))", "+A = [A_[i] - i - 1 for i in range(N)]", "-center1 = A[N // 2]", "-if N == 1:", "- center2 = 10**9", "-else:", "- center2 = A[(N + 2) // 2]", "-ans1 = 0", "-for i in range(N):", "- ans1 += abs(A[i] - center1)", "-ans2 = 0", "-for j in range(N):", "- ans2 += abs(A[j] - center2)", "-print((min(ans1, ans2)))", "+tmp = A[N // 2]", "+ans = 0", "+for a in A:", "+ ans += abs(tmp - a)", "+print(ans)" ]
false
0.039973
0.040251
0.99311
[ "s228419203", "s385126713" ]
u254871849
p03722
python
s359855299
s155609414
1,680
1,205
3,700
3,444
Accepted
Accepted
28.27
import sys INF = 10 ** 15 n, m = list(map(int, sys.stdin.readline().split())) abc = list(map(int, sys.stdin.read().split())) abc = list(zip(*[abc] * 3)) def main(): dist = [INF] * n dist[0] = 0 for _ in range(n - 1): for a, b, c in abc: a -= 1; b -= 1; c = -c if dist[a] == INF: continue dist[b] = min(dist[b], dist[a] + c) res = dist[n-1] for _ in range(n - 1): for a, b, c in abc: a -= 1; b -= 1; c = -c if dist[a] == INF: continue dist[b] = min(dist[b], dist[a] + c) if dist[n-1] == res: return -res else: return 'inf' if __name__ == '__main__': ans = main() print(ans)
import sys inf = float('inf') n, m = list(map(int, sys.stdin.readline().split())) a = [] b = [] c = [] for _ in range(m): ai, bi, ci = list(map(int, sys.stdin.readline().split())) a.append(ai - 1) b.append(bi - 1) c.append(-ci) abc = list(zip(a, b, c)) def main(): dist = [inf] * n dist[0] = 0 for _ in range(n-1): for a, b, c in abc: dist[b] = min(dist[b], dist[a] + c) res = dist[n-1] for _ in range(n): for a, b, c in abc: dist[b] = min(dist[b], dist[a] + c) if dist[n-1] == res: return -res else: return 'inf' if __name__ == '__main__': ans = main() print(ans)
35
36
773
702
import sys INF = 10**15 n, m = list(map(int, sys.stdin.readline().split())) abc = list(map(int, sys.stdin.read().split())) abc = list(zip(*[abc] * 3)) def main(): dist = [INF] * n dist[0] = 0 for _ in range(n - 1): for a, b, c in abc: a -= 1 b -= 1 c = -c if dist[a] == INF: continue dist[b] = min(dist[b], dist[a] + c) res = dist[n - 1] for _ in range(n - 1): for a, b, c in abc: a -= 1 b -= 1 c = -c if dist[a] == INF: continue dist[b] = min(dist[b], dist[a] + c) if dist[n - 1] == res: return -res else: return "inf" if __name__ == "__main__": ans = main() print(ans)
import sys inf = float("inf") n, m = list(map(int, sys.stdin.readline().split())) a = [] b = [] c = [] for _ in range(m): ai, bi, ci = list(map(int, sys.stdin.readline().split())) a.append(ai - 1) b.append(bi - 1) c.append(-ci) abc = list(zip(a, b, c)) def main(): dist = [inf] * n dist[0] = 0 for _ in range(n - 1): for a, b, c in abc: dist[b] = min(dist[b], dist[a] + c) res = dist[n - 1] for _ in range(n): for a, b, c in abc: dist[b] = min(dist[b], dist[a] + c) if dist[n - 1] == res: return -res else: return "inf" if __name__ == "__main__": ans = main() print(ans)
false
2.777778
[ "-INF = 10**15", "+inf = float(\"inf\")", "-abc = list(map(int, sys.stdin.read().split()))", "-abc = list(zip(*[abc] * 3))", "+a = []", "+b = []", "+c = []", "+for _ in range(m):", "+ ai, bi, ci = list(map(int, sys.stdin.readline().split()))", "+ a.append(ai - 1)", "+ b.append(bi - 1)", "+ c.append(-ci)", "+abc = list(zip(a, b, c))", "- dist = [INF] * n", "+ dist = [inf] * n", "- a -= 1", "- b -= 1", "- c = -c", "- if dist[a] == INF:", "- continue", "- for _ in range(n - 1):", "+ for _ in range(n):", "- a -= 1", "- b -= 1", "- c = -c", "- if dist[a] == INF:", "- continue" ]
false
0.036091
0.064661
0.558163
[ "s359855299", "s155609414" ]
u997641430
p02971
python
s258320352
s199614172
782
634
15,628
15,660
Accepted
Accepted
18.93
N = int(eval(input())) A = [] for n in range(N): A.append(int(eval(input()))) B = [0 for n in range(N)] B[0] = A[0] for n in range(N-1): B[n+1] = max(B[n], A[n + 1]) C = [0 for n in range(N)] C[-1] = A[-1] for n in range(N - 1): C[-n-2] = max(C[-n-1], A[-n - 2]) for n in range(N): if n == 0: print((C[1])) elif n == N - 1: print((B[N - 2])) else: print((max(B[n-1], C[n+1])))
n = int(eval(input())) A = [int(eval(input())) for i in range(n)] l = 0 L = [l] for a in A: l = max(l, a) L.append(l) r = 0 R = [r] for a in A[::-1]: r = max(r, a) R.append(r) R.reverse() for i in range(n): print((max(L[i], R[i+1])))
19
18
425
260
N = int(eval(input())) A = [] for n in range(N): A.append(int(eval(input()))) B = [0 for n in range(N)] B[0] = A[0] for n in range(N - 1): B[n + 1] = max(B[n], A[n + 1]) C = [0 for n in range(N)] C[-1] = A[-1] for n in range(N - 1): C[-n - 2] = max(C[-n - 1], A[-n - 2]) for n in range(N): if n == 0: print((C[1])) elif n == N - 1: print((B[N - 2])) else: print((max(B[n - 1], C[n + 1])))
n = int(eval(input())) A = [int(eval(input())) for i in range(n)] l = 0 L = [l] for a in A: l = max(l, a) L.append(l) r = 0 R = [r] for a in A[::-1]: r = max(r, a) R.append(r) R.reverse() for i in range(n): print((max(L[i], R[i + 1])))
false
5.263158
[ "-N = int(eval(input()))", "-A = []", "-for n in range(N):", "- A.append(int(eval(input())))", "-B = [0 for n in range(N)]", "-B[0] = A[0]", "-for n in range(N - 1):", "- B[n + 1] = max(B[n], A[n + 1])", "-C = [0 for n in range(N)]", "-C[-1] = A[-1]", "-for n in range(N - 1):", "- C[-n - 2] = max(C[-n - 1], A[-n - 2])", "-for n in range(N):", "- if n == 0:", "- print((C[1]))", "- elif n == N - 1:", "- print((B[N - 2]))", "- else:", "- print((max(B[n - 1], C[n + 1])))", "+n = int(eval(input()))", "+A = [int(eval(input())) for i in range(n)]", "+l = 0", "+L = [l]", "+for a in A:", "+ l = max(l, a)", "+ L.append(l)", "+r = 0", "+R = [r]", "+for a in A[::-1]:", "+ r = max(r, a)", "+ R.append(r)", "+R.reverse()", "+for i in range(n):", "+ print((max(L[i], R[i + 1])))" ]
false
0.068527
0.049981
1.371077
[ "s258320352", "s199614172" ]
u941407962
p02803
python
s871464147
s038320354
467
269
21,732
21,868
Accepted
Accepted
42.4
H, W = list(map(int, input().split())) s="#"*W+"".join("#"+eval(input()) for _ in range(H)) f=(W+1)*(H+1) d=[[0]*f for _ in range(f)] for i in range(W,f-1): d[i][i-1]=s[i]==s[i-1]=="." d[i][i-W-1]=s[i]==s[i-W-1]=="." from scipy.sparse.csgraph import csgraph_from_dense as C,floyd_warshall as F Q=F(C(d),directed=False) r=-1 for q in Q: for x in q: if f>x: r=max(r,int(x)) print(r)
H,W=list(map(int,input().split())) s="#"*W+"".join("#"+eval(input())for _ in range(H)) f=-~W*-~H d=[[0]*f for _ in range(f)] for i in range(W,f-1): d[i][i-1]=s[i]==s[i-1]=="." d[i][i-W-1]=s[i]==s[i-W-1]=="." from scipy.sparse.csgraph import csgraph_from_dense as C,floyd_warshall as F import numpy as p Q=F(C(d),directed=False) print((int(max(Q[Q!=p.inf]))))
15
11
390
356
H, W = list(map(int, input().split())) s = "#" * W + "".join("#" + eval(input()) for _ in range(H)) f = (W + 1) * (H + 1) d = [[0] * f for _ in range(f)] for i in range(W, f - 1): d[i][i - 1] = s[i] == s[i - 1] == "." d[i][i - W - 1] = s[i] == s[i - W - 1] == "." from scipy.sparse.csgraph import csgraph_from_dense as C, floyd_warshall as F Q = F(C(d), directed=False) r = -1 for q in Q: for x in q: if f > x: r = max(r, int(x)) print(r)
H, W = list(map(int, input().split())) s = "#" * W + "".join("#" + eval(input()) for _ in range(H)) f = -~W * -~H d = [[0] * f for _ in range(f)] for i in range(W, f - 1): d[i][i - 1] = s[i] == s[i - 1] == "." d[i][i - W - 1] = s[i] == s[i - W - 1] == "." from scipy.sparse.csgraph import csgraph_from_dense as C, floyd_warshall as F import numpy as p Q = F(C(d), directed=False) print((int(max(Q[Q != p.inf]))))
false
26.666667
[ "-f = (W + 1) * (H + 1)", "+f = -~W * -~H", "+import numpy as p", "-r = -1", "-for q in Q:", "- for x in q:", "- if f > x:", "- r = max(r, int(x))", "-print(r)", "+print((int(max(Q[Q != p.inf]))))" ]
false
0.314802
0.193797
1.624389
[ "s871464147", "s038320354" ]
u651803486
p02953
python
s285370746
s312427569
116
87
14,396
15,020
Accepted
Accepted
25
N = int(eval(input())) H = list(map(int, input().split())) for i in range(N-1): if H[i] > H[i+1]: H[i] -= 1 elif H[i] == H[i+1]: if H[i]-1 >= H[i-1]: H[i] -= 1 for i in range(N-1): if H[i] > H[i+1]: print('No') exit() print('Yes')
N = int(eval(input())) H = list(map(int, input().split())) H[0] -= 1 for i in range(1, N): if H[i-1] <= H[i] - 1: H[i] -= 1 if not H[i-1] <= H[i]: print('No') exit() print('Yes')
16
14
299
225
N = int(eval(input())) H = list(map(int, input().split())) for i in range(N - 1): if H[i] > H[i + 1]: H[i] -= 1 elif H[i] == H[i + 1]: if H[i] - 1 >= H[i - 1]: H[i] -= 1 for i in range(N - 1): if H[i] > H[i + 1]: print("No") exit() print("Yes")
N = int(eval(input())) H = list(map(int, input().split())) H[0] -= 1 for i in range(1, N): if H[i - 1] <= H[i] - 1: H[i] -= 1 if not H[i - 1] <= H[i]: print("No") exit() print("Yes")
false
12.5
[ "-for i in range(N - 1):", "- if H[i] > H[i + 1]:", "+H[0] -= 1", "+for i in range(1, N):", "+ if H[i - 1] <= H[i] - 1:", "- elif H[i] == H[i + 1]:", "- if H[i] - 1 >= H[i - 1]:", "- H[i] -= 1", "-for i in range(N - 1):", "- if H[i] > H[i + 1]:", "+ if not H[i - 1] <= H[i]:" ]
false
0.036154
0.036745
0.983917
[ "s285370746", "s312427569" ]