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
u191394596
p02712
python
s123166769
s551286778
166
98
9,156
73,132
Accepted
Accepted
40.96
N = int(eval(input())) def fizz_buzz(n): return 0 if n % 5 == 0 or n % 3 == 0 else n print((sum( fizz_buzz(i) for i in range(1, N + 1) )))
N = int(eval(input())) print((sum( i for i in range(1, N + 1) if i % 3 != 0 and i % 5 != 0 )))
9
7
146
100
N = int(eval(input())) def fizz_buzz(n): return 0 if n % 5 == 0 or n % 3 == 0 else n print((sum(fizz_buzz(i) for i in range(1, N + 1))))
N = int(eval(input())) print((sum(i for i in range(1, N + 1) if i % 3 != 0 and i % 5 != 0)))
false
22.222222
[ "-", "-", "-def fizz_buzz(n):", "- return 0 if n % 5 == 0 or n % 3 == 0 else n", "-", "-", "-print((sum(fizz_buzz(i) for i in range(1, N + 1))))", "+print((sum(i for i in range(1, N + 1) if i % 3 != 0 and i % 5 != 0)))" ]
false
0.378218
0.097638
3.87368
[ "s123166769", "s551286778" ]
u279955105
p02390
python
s623232564
s976673961
30
20
7,660
5,588
Accepted
Accepted
33.33
t = int(eval(input())) a = int(t / 3600) b = int(t % 3600 / 60) c = int(t % 3600 % 60) print((str(a)+':'+str(b)+':'+str(c)))
Input = int(eval(input())) h = Input//3600 m = (Input % 3600)//60 s = (Input % 3600) % 60 print((str(h) + ':' + str(m) + ':' + str(s)))
5
5
120
132
t = int(eval(input())) a = int(t / 3600) b = int(t % 3600 / 60) c = int(t % 3600 % 60) print((str(a) + ":" + str(b) + ":" + str(c)))
Input = int(eval(input())) h = Input // 3600 m = (Input % 3600) // 60 s = (Input % 3600) % 60 print((str(h) + ":" + str(m) + ":" + str(s)))
false
0
[ "-t = int(eval(input()))", "-a = int(t / 3600)", "-b = int(t % 3600 / 60)", "-c = int(t % 3600 % 60)", "-print((str(a) + \":\" + str(b) + \":\" + str(c)))", "+Input = int(eval(input()))", "+h = Input // 3600", "+m = (Input % 3600) // 60", "+s = (Input % 3600) % 60", "+print((str(h) + \":\" + str(m) + \":\" + str(s)))" ]
false
0.040131
0.049741
0.806795
[ "s623232564", "s976673961" ]
u254871849
p02814
python
s822402034
s646026869
621
491
14,588
14,588
Accepted
Accepted
20.93
import sys from functools import reduce def gcd(a, b): while b: a, b = b, a % b return abs(a) def lcm(a, b): return abs(a // gcd(a, b) * b) n, m, *a = list(map(int, sys.stdin.read().split())) def main(): for i in range(n): a[i] //= 2 res = 1 while True: oe = a[0] & 1 if oe == 0: for i in range(n): if a[i] & 1 == 1: return 0 a[i] //= 2 res *= 2 else: for i in range(n): if a[i] & 1 == 0: return 0 break l = reduce(lcm, a, a[0]) * res return m // l - m // (l * 2) if __name__ == '__main__': ans = main() print(ans)
import sys from functools import reduce def gcd(a, b): while b: a, b = b, a % b return abs(a) def lcm(a, b): return abs(a // gcd(a, b) * b) def cnt_2(n): cnt = 0 while n % 2 == 0: cnt += 1 n //= 2 return cnt n, m, *a = list(map(int, sys.stdin.read().split())) def main(): for i in range(n): a[i] //= 2 cnt = cnt_2(a[0]) for i in range(1, n): if cnt_2(a[i]) != cnt: return 0 l = reduce(lcm, a, a[0]) return m // l - m // (l * 2) if __name__ == '__main__': ans = main() print(ans)
39
36
782
624
import sys from functools import reduce def gcd(a, b): while b: a, b = b, a % b return abs(a) def lcm(a, b): return abs(a // gcd(a, b) * b) n, m, *a = list(map(int, sys.stdin.read().split())) def main(): for i in range(n): a[i] //= 2 res = 1 while True: oe = a[0] & 1 if oe == 0: for i in range(n): if a[i] & 1 == 1: return 0 a[i] //= 2 res *= 2 else: for i in range(n): if a[i] & 1 == 0: return 0 break l = reduce(lcm, a, a[0]) * res return m // l - m // (l * 2) if __name__ == "__main__": ans = main() print(ans)
import sys from functools import reduce def gcd(a, b): while b: a, b = b, a % b return abs(a) def lcm(a, b): return abs(a // gcd(a, b) * b) def cnt_2(n): cnt = 0 while n % 2 == 0: cnt += 1 n //= 2 return cnt n, m, *a = list(map(int, sys.stdin.read().split())) def main(): for i in range(n): a[i] //= 2 cnt = cnt_2(a[0]) for i in range(1, n): if cnt_2(a[i]) != cnt: return 0 l = reduce(lcm, a, a[0]) return m // l - m // (l * 2) if __name__ == "__main__": ans = main() print(ans)
false
7.692308
[ "+def cnt_2(n):", "+ cnt = 0", "+ while n % 2 == 0:", "+ cnt += 1", "+ n //= 2", "+ return cnt", "+", "+", "- res = 1", "- while True:", "- oe = a[0] & 1", "- if oe == 0:", "- for i in range(n):", "- if a[i] & 1 == 1:", "- return 0", "- a[i] //= 2", "- res *= 2", "- else:", "- for i in range(n):", "- if a[i] & 1 == 0:", "- return 0", "- break", "- l = reduce(lcm, a, a[0]) * res", "+ cnt = cnt_2(a[0])", "+ for i in range(1, n):", "+ if cnt_2(a[i]) != cnt:", "+ return 0", "+ l = reduce(lcm, a, a[0])" ]
false
0.038815
0.04572
0.848975
[ "s822402034", "s646026869" ]
u733814820
p03127
python
s938532724
s875389404
91
80
16,240
20,084
Accepted
Accepted
12.09
# ABC 118 C import fractions N = int(eval(input())) a = list(map(int, input().split())) g = a[0] for i in a: g = fractions.gcd(g, i) print(g)
def gcd(x, y): if y == 0: return x else: return gcd(y, x % y) def resolve(): n = int(eval(input())) a = list(map(int, input().split())) ans = a[0] for x in a: ans = gcd(ans, x) print(ans) return if __name__ == "__main__": resolve()
14
18
159
276
# ABC 118 C import fractions N = int(eval(input())) a = list(map(int, input().split())) g = a[0] for i in a: g = fractions.gcd(g, i) print(g)
def gcd(x, y): if y == 0: return x else: return gcd(y, x % y) def resolve(): n = int(eval(input())) a = list(map(int, input().split())) ans = a[0] for x in a: ans = gcd(ans, x) print(ans) return if __name__ == "__main__": resolve()
false
22.222222
[ "-# ABC 118 C", "-import fractions", "+def gcd(x, y):", "+ if y == 0:", "+ return x", "+ else:", "+ return gcd(y, x % y)", "-N = int(eval(input()))", "-a = list(map(int, input().split()))", "-g = a[0]", "-for i in a:", "- g = fractions.gcd(g, i)", "-print(g)", "+", "+def resolve():", "+ n = int(eval(input()))", "+ a = list(map(int, input().split()))", "+ ans = a[0]", "+ for x in a:", "+ ans = gcd(ans, x)", "+ print(ans)", "+ return", "+", "+", "+if __name__ == \"__main__\":", "+ resolve()" ]
false
0.081062
0.042582
1.903641
[ "s938532724", "s875389404" ]
u906501980
p02684
python
s282847403
s488504444
688
545
175,636
184,348
Accepted
Accepted
20.78
def main(): n, k = list(map(int, input().split())) a = list(map(int, input().split())) to = [[None]*n for _ in range(60)] to[0] = a for i in range(1, 60): for j in range(n): to[i][j] = to[i-1][to[i-1][j]-1] p = 1 for i in range(59, -1, -1): num = 1 << i if k >= num: k -= num p = to[i][p-1] print(p) if __name__ == "__main__": main()
def main(): n, k = list(map(int, input().split())) a = list(map(int, input().split())) to = [[None]*n for _ in range(60)] to[0] = a[:] for i in range(1, 60): for j in range(n): to[i][j] = to[i-1][to[i-1][j]-1] p = 1 for i in range(59, -1, -1): num = 1 << i if k >= num: k -= num p = to[i][p-1] print(p) if __name__ == "__main__": main()
19
19
455
454
def main(): n, k = list(map(int, input().split())) a = list(map(int, input().split())) to = [[None] * n for _ in range(60)] to[0] = a for i in range(1, 60): for j in range(n): to[i][j] = to[i - 1][to[i - 1][j] - 1] p = 1 for i in range(59, -1, -1): num = 1 << i if k >= num: k -= num p = to[i][p - 1] print(p) if __name__ == "__main__": main()
def main(): n, k = list(map(int, input().split())) a = list(map(int, input().split())) to = [[None] * n for _ in range(60)] to[0] = a[:] for i in range(1, 60): for j in range(n): to[i][j] = to[i - 1][to[i - 1][j] - 1] p = 1 for i in range(59, -1, -1): num = 1 << i if k >= num: k -= num p = to[i][p - 1] print(p) if __name__ == "__main__": main()
false
0
[ "- to[0] = a", "+ to[0] = a[:]" ]
false
0.044287
0.04375
1.012265
[ "s282847403", "s488504444" ]
u562935282
p02775
python
s751414785
s304399395
1,161
660
14,628
20,464
Accepted
Accepted
43.15
def main(): *e, = list(map(int, eval(input()))) e.reverse() inf = 20 * len(e) dp = [0, inf] # 繰り下がり無,有 for x in e: ndp = [-1, -1] # 繰り下がり無,有 ndp[0] = min( dp[0] + x, dp[1] + ((x + 1) if x < 9 else inf) # ちょうど支払えないのでinf ) # ちょうど支払う ndp[1] = min( dp[0] + ((10 - x) if x > 0 else inf), # 繰り下がりにならないのでinf dp[1] + (10 - (x + 1)) ) # 0枚支払って繰り下がり dp = ndp print((min(dp[0], dp[1] + 1))) if __name__ == '__main__': main() # import sys # input = sys.stdin.readline # # sys.setrecursionlimit(10 ** 7) # # (int(x)-1 for x in input().split()) # rstrip() # # def binary_search(*, ok, ng, func): # while abs(ok - ng) > 1: # mid = (ok + ng) // 2 # if func(mid): # ok = mid # else: # ng = mid # return ok
# https://atcoder.jp/contests/abc155/submissions/10157837 # 写経 def main(): a = [0] a += list(map(int, eval(input()))) a.reverse() n = len(a) b = a.copy() for i in range(n): if b[i] > 5 or (b[i] == 5 and b[i + 1] >= 5): b[i] = 0 b[i + 1] += 1 cnt = sum(b) for i in range(n): if a[i] > b[i]: b[i] += 10 b[i + 1] -= 1 cnt += b[i] - a[i] print(cnt) if __name__ == '__main__': main()
45
27
917
511
def main(): (*e,) = list(map(int, eval(input()))) e.reverse() inf = 20 * len(e) dp = [0, inf] # 繰り下がり無,有 for x in e: ndp = [-1, -1] # 繰り下がり無,有 ndp[0] = min( dp[0] + x, dp[1] + ((x + 1) if x < 9 else inf) # ちょうど支払えないのでinf ) # ちょうど支払う ndp[1] = min( dp[0] + ((10 - x) if x > 0 else inf), # 繰り下がりにならないのでinf dp[1] + (10 - (x + 1)), ) # 0枚支払って繰り下がり dp = ndp print((min(dp[0], dp[1] + 1))) if __name__ == "__main__": main() # import sys # input = sys.stdin.readline # # sys.setrecursionlimit(10 ** 7) # # (int(x)-1 for x in input().split()) # rstrip() # # def binary_search(*, ok, ng, func): # while abs(ok - ng) > 1: # mid = (ok + ng) // 2 # if func(mid): # ok = mid # else: # ng = mid # return ok
# https://atcoder.jp/contests/abc155/submissions/10157837 # 写経 def main(): a = [0] a += list(map(int, eval(input()))) a.reverse() n = len(a) b = a.copy() for i in range(n): if b[i] > 5 or (b[i] == 5 and b[i + 1] >= 5): b[i] = 0 b[i + 1] += 1 cnt = sum(b) for i in range(n): if a[i] > b[i]: b[i] += 10 b[i + 1] -= 1 cnt += b[i] - a[i] print(cnt) if __name__ == "__main__": main()
false
40
[ "+# https://atcoder.jp/contests/abc155/submissions/10157837", "+# 写経", "- (*e,) = list(map(int, eval(input())))", "- e.reverse()", "- inf = 20 * len(e)", "- dp = [0, inf] # 繰り下がり無,有", "- for x in e:", "- ndp = [-1, -1] # 繰り下がり無,有", "- ndp[0] = min(", "- dp[0] + x, dp[1] + ((x + 1) if x < 9 else inf) # ちょうど支払えないのでinf", "- ) # ちょうど支払う", "- ndp[1] = min(", "- dp[0] + ((10 - x) if x > 0 else inf), # 繰り下がりにならないのでinf", "- dp[1] + (10 - (x + 1)),", "- ) # 0枚支払って繰り下がり", "- dp = ndp", "- print((min(dp[0], dp[1] + 1)))", "+ a = [0]", "+ a += list(map(int, eval(input())))", "+ a.reverse()", "+ n = len(a)", "+ b = a.copy()", "+ for i in range(n):", "+ if b[i] > 5 or (b[i] == 5 and b[i + 1] >= 5):", "+ b[i] = 0", "+ b[i + 1] += 1", "+ cnt = sum(b)", "+ for i in range(n):", "+ if a[i] > b[i]:", "+ b[i] += 10", "+ b[i + 1] -= 1", "+ cnt += b[i] - a[i]", "+ print(cnt)", "-# import sys", "-# input = sys.stdin.readline", "-#", "-# sys.setrecursionlimit(10 ** 7)", "-#", "-# (int(x)-1 for x in input().split())", "-# rstrip()", "-#", "-# def binary_search(*, ok, ng, func):", "-# while abs(ok - ng) > 1:", "-# mid = (ok + ng) // 2", "-# if func(mid):", "-# ok = mid", "-# else:", "-# ng = mid", "-# return ok" ]
false
0.06847
0.04518
1.515497
[ "s751414785", "s304399395" ]
u340781749
p03472
python
s264616302
s052829638
496
435
59,224
59,224
Accepted
Accepted
12.3
from bisect import bisect_left from itertools import accumulate, takewhile from math import ceil def solve(h, aa, bb): max_a = max(aa) bba = list(accumulate(takewhile(lambda x: x > max_a, sorted(bb, reverse=True)))) if not bba: return ceil(h / max_a) remain = h - bba[-1] if remain <= 0: return bisect_left(bba, h) + 1 return ceil(remain / max_a) + len(bba) n, h = list(map(int, input().split())) aa, bb = list(zip(*(list(map(int, input().split())) for _ in range(n)))) print((solve(h, aa, bb)))
from bisect import bisect_left, bisect from itertools import accumulate from math import ceil def solve(h, aa, bb): max_a = max(aa) bs = sorted(bb) i = bisect(bs, max_a) if i == n: return ceil(h / max_a) bba = list(accumulate(reversed(bs[i:]))) remain = h - bba[-1] if remain <= 0: return bisect_left(bba, h) + 1 return ceil(remain / max_a) + len(bba) n, h = list(map(int, input().split())) aa, bb = list(zip(*(list(map(int, input().split())) for _ in range(n)))) print((solve(h, aa, bb)))
20
22
540
544
from bisect import bisect_left from itertools import accumulate, takewhile from math import ceil def solve(h, aa, bb): max_a = max(aa) bba = list(accumulate(takewhile(lambda x: x > max_a, sorted(bb, reverse=True)))) if not bba: return ceil(h / max_a) remain = h - bba[-1] if remain <= 0: return bisect_left(bba, h) + 1 return ceil(remain / max_a) + len(bba) n, h = list(map(int, input().split())) aa, bb = list(zip(*(list(map(int, input().split())) for _ in range(n)))) print((solve(h, aa, bb)))
from bisect import bisect_left, bisect from itertools import accumulate from math import ceil def solve(h, aa, bb): max_a = max(aa) bs = sorted(bb) i = bisect(bs, max_a) if i == n: return ceil(h / max_a) bba = list(accumulate(reversed(bs[i:]))) remain = h - bba[-1] if remain <= 0: return bisect_left(bba, h) + 1 return ceil(remain / max_a) + len(bba) n, h = list(map(int, input().split())) aa, bb = list(zip(*(list(map(int, input().split())) for _ in range(n)))) print((solve(h, aa, bb)))
false
9.090909
[ "-from bisect import bisect_left", "-from itertools import accumulate, takewhile", "+from bisect import bisect_left, bisect", "+from itertools import accumulate", "- bba = list(accumulate(takewhile(lambda x: x > max_a, sorted(bb, reverse=True))))", "- if not bba:", "+ bs = sorted(bb)", "+ i = bisect(bs, max_a)", "+ if i == n:", "+ bba = list(accumulate(reversed(bs[i:])))" ]
false
0.048174
0.038347
1.256288
[ "s264616302", "s052829638" ]
u226155577
p03201
python
s044475496
s761002520
1,666
982
121,508
57,484
Accepted
Accepted
41.06
from bisect import bisect N = int(eval(input())) *A, = list(map(int, input().split())) B = {} for a in A: B[a] = B.get(a, 0) + 1 R = sorted(B.items()) C = []; D = [] for k, v in sorted(B.items()): C.append(k) D.append(v) M = len(C) j = 0 ans = 0 for i in range(M-1, -1, -1): if D[i] == 0: continue a = C[i] b = 2**(a).bit_length() j = bisect(C, b-a-1) if j < M and C[j] == b-a: if i == j: ans += D[i]//2 D[i] %= 2 else: c = min(D[i], D[j]) ans += c D[i] -= c; D[j] -= c print(ans)
from bisect import bisect N = int(eval(input())) *A, = list(map(int, input().split())) B = {} for a in A: B[a] = B.get(a, 0) + 1 R = sorted(B.items()) C = []; D = [] for k, v in sorted(B.items()): C.append(k) D.append(v) M = len(C) j = 0 ans = 0 for i in range(M-1, -1, -1): if D[i] == 0: continue a = C[i] b = 2**a.bit_length() j = bisect(C, b-a-1) if j < M and C[j] == b-a: if i == j: c = D[i]//2 else: c = min(D[i], D[j]) ans += c D[i] -= c; D[j] -= c print(ans)
29
28
612
576
from bisect import bisect N = int(eval(input())) (*A,) = list(map(int, input().split())) B = {} for a in A: B[a] = B.get(a, 0) + 1 R = sorted(B.items()) C = [] D = [] for k, v in sorted(B.items()): C.append(k) D.append(v) M = len(C) j = 0 ans = 0 for i in range(M - 1, -1, -1): if D[i] == 0: continue a = C[i] b = 2 ** (a).bit_length() j = bisect(C, b - a - 1) if j < M and C[j] == b - a: if i == j: ans += D[i] // 2 D[i] %= 2 else: c = min(D[i], D[j]) ans += c D[i] -= c D[j] -= c print(ans)
from bisect import bisect N = int(eval(input())) (*A,) = list(map(int, input().split())) B = {} for a in A: B[a] = B.get(a, 0) + 1 R = sorted(B.items()) C = [] D = [] for k, v in sorted(B.items()): C.append(k) D.append(v) M = len(C) j = 0 ans = 0 for i in range(M - 1, -1, -1): if D[i] == 0: continue a = C[i] b = 2 ** a.bit_length() j = bisect(C, b - a - 1) if j < M and C[j] == b - a: if i == j: c = D[i] // 2 else: c = min(D[i], D[j]) ans += c D[i] -= c D[j] -= c print(ans)
false
3.448276
[ "- b = 2 ** (a).bit_length()", "+ b = 2 ** a.bit_length()", "- ans += D[i] // 2", "- D[i] %= 2", "+ c = D[i] // 2", "- ans += c", "- D[i] -= c", "- D[j] -= c", "+ ans += c", "+ D[i] -= c", "+ D[j] -= c" ]
false
0.038625
0.037732
1.023667
[ "s044475496", "s761002520" ]
u689562091
p03141
python
s303344496
s928555396
427
369
7,504
7,388
Accepted
Accepted
13.58
N = int(eval(input())) l = [] sumB = 0 for i in range(N): tmp = list(map(int, input().split())) l.append(tmp[0] + tmp[1]) sumB += tmp[1] l.sort(reverse=True) A = 0 for i in range(N): if i % 2 ==0: A += l[i] print((A - sumB))
N = int(eval(input())) l = [] sumB = 0 for i in range(N): a, b = list(map(int, input().split())) l.append(a + b) sumB += b l.sort(reverse=True) A = 0 for i in range(0, N, 2): A += l[i] print((A - sumB))
13
12
252
219
N = int(eval(input())) l = [] sumB = 0 for i in range(N): tmp = list(map(int, input().split())) l.append(tmp[0] + tmp[1]) sumB += tmp[1] l.sort(reverse=True) A = 0 for i in range(N): if i % 2 == 0: A += l[i] print((A - sumB))
N = int(eval(input())) l = [] sumB = 0 for i in range(N): a, b = list(map(int, input().split())) l.append(a + b) sumB += b l.sort(reverse=True) A = 0 for i in range(0, N, 2): A += l[i] print((A - sumB))
false
7.692308
[ "- tmp = list(map(int, input().split()))", "- l.append(tmp[0] + tmp[1])", "- sumB += tmp[1]", "+ a, b = list(map(int, input().split()))", "+ l.append(a + b)", "+ sumB += b", "-for i in range(N):", "- if i % 2 == 0:", "- A += l[i]", "+for i in range(0, N, 2):", "+ A += l[i]" ]
false
0.08048
0.043249
1.86086
[ "s303344496", "s928555396" ]
u028973125
p03786
python
s224356189
s610489910
240
98
63,856
20,084
Accepted
Accepted
59.17
import sys N = int(sys.stdin.readline().strip()) A = list(map(int, sys.stdin.readline().strip().split())) A.sort() acum = 0 ans = 0 for i in range(N-1): acum += A[i] if acum * 2 >= A[i+1]: ans += 1 else: ans = 0 print((ans+1))
import sys input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) A.sort() # print(A) ans = 0 acum = 0 for i in range(N-1): acum += A[i] if acum * 2 < A[i+1]: ans = 0 else: ans += 1 print((ans + 1))
17
20
272
273
import sys N = int(sys.stdin.readline().strip()) A = list(map(int, sys.stdin.readline().strip().split())) A.sort() acum = 0 ans = 0 for i in range(N - 1): acum += A[i] if acum * 2 >= A[i + 1]: ans += 1 else: ans = 0 print((ans + 1))
import sys input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) A.sort() # print(A) ans = 0 acum = 0 for i in range(N - 1): acum += A[i] if acum * 2 < A[i + 1]: ans = 0 else: ans += 1 print((ans + 1))
false
15
[ "-N = int(sys.stdin.readline().strip())", "-A = list(map(int, sys.stdin.readline().strip().split()))", "+input = sys.stdin.readline", "+N = int(eval(input()))", "+A = list(map(int, input().split()))", "+# print(A)", "+ans = 0", "-ans = 0", "- if acum * 2 >= A[i + 1]:", "+ if acum * 2 < A[i + 1]:", "+ ans = 0", "+ else:", "- else:", "- ans = 0" ]
false
0.044723
0.065217
0.685747
[ "s224356189", "s610489910" ]
u191874006
p03853
python
s893035130
s887684835
42
18
4,608
3,060
Accepted
Accepted
57.14
#!/usr/bin/env python3 H,W = map(int,input().split()) C = [list(input()) if i%2 == 0 else [0 for j in range(W)] for i in range(2*H)] #print(C) for i in range(2*H): if i % 2 == 1: for j in range(W): C[i][j] = C[i-1][j] #print(C) for i in range(2*H): for j in range(W): if j != W-1: print(C[i][j],end='') else: print(C[i][j])
#!/usr/bin/env python3 h,w = list(map(int,input().split())) c = [list(eval(input())) if i % 2 == 0 else [] for i in range(2*h)] for i in range(h): c[2*i+1] = c[2*i] for i in range(2*h): print((''.join(c[i])))
16
9
407
213
#!/usr/bin/env python3 H, W = map(int, input().split()) C = [list(input()) if i % 2 == 0 else [0 for j in range(W)] for i in range(2 * H)] # print(C) for i in range(2 * H): if i % 2 == 1: for j in range(W): C[i][j] = C[i - 1][j] # print(C) for i in range(2 * H): for j in range(W): if j != W - 1: print(C[i][j], end="") else: print(C[i][j])
#!/usr/bin/env python3 h, w = list(map(int, input().split())) c = [list(eval(input())) if i % 2 == 0 else [] for i in range(2 * h)] for i in range(h): c[2 * i + 1] = c[2 * i] for i in range(2 * h): print(("".join(c[i])))
false
43.75
[ "-H, W = map(int, input().split())", "-C = [list(input()) if i % 2 == 0 else [0 for j in range(W)] for i in range(2 * H)]", "-# print(C)", "-for i in range(2 * H):", "- if i % 2 == 1:", "- for j in range(W):", "- C[i][j] = C[i - 1][j]", "-# print(C)", "-for i in range(2 * H):", "- for j in range(W):", "- if j != W - 1:", "- print(C[i][j], end=\"\")", "- else:", "- print(C[i][j])", "+h, w = list(map(int, input().split()))", "+c = [list(eval(input())) if i % 2 == 0 else [] for i in range(2 * h)]", "+for i in range(h):", "+ c[2 * i + 1] = c[2 * i]", "+for i in range(2 * h):", "+ print((\"\".join(c[i])))" ]
false
0.062978
0.092695
0.67941
[ "s893035130", "s887684835" ]
u402629484
p02792
python
s772694785
s422055885
243
148
5,972
5,296
Accepted
Accepted
39.09
import sys sys.setrecursionlimit(1000000000) import math from fractions import gcd from itertools import count, permutations from functools import lru_cache from collections import deque, defaultdict from pprint import pprint ii = lambda: int(eval(input())) mis = lambda: list(map(int, input().split())) lmis = lambda: list(mis()) INF = float('inf') N1097 = 10**9 + 7 def meg(f, ok, ng): while abs(ok-ng)>1: mid = (ok+ng)//2 if f(mid): ok=mid else: ng=mid return ok # def main(): N=ii() d = defaultdict(int) for i in range(1, N+1): i = str(i) a, b = i[0], i[-1] if a != 0 != b: d[(a, b)] += 1 ans = 0 for i in range(1, N+1): i = str(i) a, b = i[0], i[-1] ans += d[(b, a)] print(ans) main()
import sys sys.setrecursionlimit(1000000000) import math from fractions import gcd from itertools import count, permutations from functools import lru_cache from collections import deque, defaultdict from pprint import pprint ii = lambda: int(eval(input())) mis = lambda: list(map(int, input().split())) lmis = lambda: list(mis()) INF = float('inf') N1097 = 10**9 + 7 def meg(f, ok, ng): while abs(ok-ng)>1: mid = (ok+ng)//2 if f(mid): ok=mid else: ng=mid return ok # def main(): N=ii() d = defaultdict(int) for i in map(str, list(range(1, N+1))): i = str(i) a, b = i[0], i[-1] d[(a, b)] += 1 print((sum(d[(a, b)] * d[(b, a)] for a in map(str, list(range(1,9+1))) for b in map(str, list(range(1,9+1)))))) main()
41
34
862
812
import sys sys.setrecursionlimit(1000000000) import math from fractions import gcd from itertools import count, permutations from functools import lru_cache from collections import deque, defaultdict from pprint import pprint ii = lambda: int(eval(input())) mis = lambda: list(map(int, input().split())) lmis = lambda: list(mis()) INF = float("inf") N1097 = 10**9 + 7 def meg(f, ok, ng): while abs(ok - ng) > 1: mid = (ok + ng) // 2 if f(mid): ok = mid else: ng = mid return ok # def main(): N = ii() d = defaultdict(int) for i in range(1, N + 1): i = str(i) a, b = i[0], i[-1] if a != 0 != b: d[(a, b)] += 1 ans = 0 for i in range(1, N + 1): i = str(i) a, b = i[0], i[-1] ans += d[(b, a)] print(ans) main()
import sys sys.setrecursionlimit(1000000000) import math from fractions import gcd from itertools import count, permutations from functools import lru_cache from collections import deque, defaultdict from pprint import pprint ii = lambda: int(eval(input())) mis = lambda: list(map(int, input().split())) lmis = lambda: list(mis()) INF = float("inf") N1097 = 10**9 + 7 def meg(f, ok, ng): while abs(ok - ng) > 1: mid = (ok + ng) // 2 if f(mid): ok = mid else: ng = mid return ok # def main(): N = ii() d = defaultdict(int) for i in map(str, list(range(1, N + 1))): i = str(i) a, b = i[0], i[-1] d[(a, b)] += 1 print( ( sum( d[(a, b)] * d[(b, a)] for a in map(str, list(range(1, 9 + 1))) for b in map(str, list(range(1, 9 + 1))) ) ) ) main()
false
17.073171
[ "- for i in range(1, N + 1):", "+ for i in map(str, list(range(1, N + 1))):", "- if a != 0 != b:", "- d[(a, b)] += 1", "- ans = 0", "- for i in range(1, N + 1):", "- i = str(i)", "- a, b = i[0], i[-1]", "- ans += d[(b, a)]", "- print(ans)", "+ d[(a, b)] += 1", "+ print(", "+ (", "+ sum(", "+ d[(a, b)] * d[(b, a)]", "+ for a in map(str, list(range(1, 9 + 1)))", "+ for b in map(str, list(range(1, 9 + 1)))", "+ )", "+ )", "+ )" ]
false
0.050127
0.044577
1.124494
[ "s772694785", "s422055885" ]
u585482323
p03660
python
s142515199
s791532464
922
402
71,980
63,132
Accepted
Accepted
56.4
#!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random import queue def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS():return list(map(list, sys.stdin.readline().split())) def S(): return list(sys.stdin.readline())[:-1] def IR(n): l = [None for i in range(n)] for i in range(n):l[i] = I() return l def LIR(n): l = [None for i in range(n)] for i in range(n):l[i] = LI() return l def SR(n): l = [None for i in range(n)] for i in range(n):l[i] = S() return l def LSR(n): l = [None for i in range(n)] for i in range(n):l[i] = SR() return l mod = 1000000007 #A #B #C """ n = I() a = LI() b = [None for i in range(n-1)] for i in range(n-1): a[i+1] += a[i] for i in range(n-1): b[i] = abs(2*a[i]-a[n-1]) print(min(b)) """ #D n = I() v = [[] for i in range(n)] for i in range(n-1): a,b = LI() a -= 1 b -= 1 v[a].append(b) v[b].append(a) d_f = [-1 for i in range(n)] q = queue.Queue() q.put(0) d_f[0] = 0 while not q.empty(): x = q.get() for y in v[x]: if d_f[y] == -1: d_f[y] = d_f[x] + 1 q.put(y) d_s = [-1 for i in range(n)] q.put(n-1) d_s[n-1] = 0 while not q.empty(): x = q.get() for y in v[x]: if d_s[y] == -1: d_s[y] = d_s[x] + 1 q.put(y) f = 0 s = 0 for i in range(n): if d_f[i] <= d_s[i]: f += 1 else: s += 1 if f > s: print("Fennec") else: print("Snuke") #E #F #G #H #I #J #K #L #M #N #O #P #Q #R #S #T
#!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random import queue def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS():return list(map(list, sys.stdin.readline().split())) def S(): return list(sys.stdin.readline())[:-1] def IR(n): l = [None for i in range(n)] for i in range(n):l[i] = I() return l def LIR(n): l = [None for i in range(n)] for i in range(n):l[i] = LI() return l def SR(n): l = [None for i in range(n)] for i in range(n):l[i] = S() return l def LSR(n): l = [None for i in range(n)] for i in range(n):l[i] = SR() return l mod = 1000000007 #A #B #C """ n = I() a = LI() b = [None for i in range(n-1)] for i in range(n-1): a[i+1] += a[i] for i in range(n-1): b[i] = abs(2*a[i]-a[n-1]) print(min(b)) """ #D n = I() v = [[] for i in range(n)] for i in range(n-1): a,b = LI() a -= 1 b -= 1 v[a].append(b) v[b].append(a) d_f = [-1 for i in range(n)] q = deque() q.append(0) d_f[0] = 0 while q: x = q.pop() for y in v[x]: if d_f[y] == -1: d_f[y] = d_f[x] + 1 q.append(y) d_s = [-1 for i in range(n)] q.append(n-1) d_s[n-1] = 0 while q: x = q.pop() for y in v[x]: if d_s[y] == -1: d_s[y] = d_s[x] + 1 q.append(y) f = 0 s = 0 for i in range(n): if d_f[i] <= d_s[i]: f += 1 else: s += 1 if f > s: print("Fennec") else: print("Snuke") #E #F #G #H #I #J #K #L #M #N #O #P #Q #R #S #T
117
117
1,809
1,791
#!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random import queue def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS(): return list(map(list, sys.stdin.readline().split())) def S(): return list(sys.stdin.readline())[:-1] def IR(n): l = [None for i in range(n)] for i in range(n): l[i] = I() return l def LIR(n): l = [None for i in range(n)] for i in range(n): l[i] = LI() return l def SR(n): l = [None for i in range(n)] for i in range(n): l[i] = S() return l def LSR(n): l = [None for i in range(n)] for i in range(n): l[i] = SR() return l mod = 1000000007 # A # B # C """ n = I() a = LI() b = [None for i in range(n-1)] for i in range(n-1): a[i+1] += a[i] for i in range(n-1): b[i] = abs(2*a[i]-a[n-1]) print(min(b)) """ # D n = I() v = [[] for i in range(n)] for i in range(n - 1): a, b = LI() a -= 1 b -= 1 v[a].append(b) v[b].append(a) d_f = [-1 for i in range(n)] q = queue.Queue() q.put(0) d_f[0] = 0 while not q.empty(): x = q.get() for y in v[x]: if d_f[y] == -1: d_f[y] = d_f[x] + 1 q.put(y) d_s = [-1 for i in range(n)] q.put(n - 1) d_s[n - 1] = 0 while not q.empty(): x = q.get() for y in v[x]: if d_s[y] == -1: d_s[y] = d_s[x] + 1 q.put(y) f = 0 s = 0 for i in range(n): if d_f[i] <= d_s[i]: f += 1 else: s += 1 if f > s: print("Fennec") else: print("Snuke") # E # F # G # H # I # J # K # L # M # N # O # P # Q # R # S # T
#!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random import queue def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS(): return list(map(list, sys.stdin.readline().split())) def S(): return list(sys.stdin.readline())[:-1] def IR(n): l = [None for i in range(n)] for i in range(n): l[i] = I() return l def LIR(n): l = [None for i in range(n)] for i in range(n): l[i] = LI() return l def SR(n): l = [None for i in range(n)] for i in range(n): l[i] = S() return l def LSR(n): l = [None for i in range(n)] for i in range(n): l[i] = SR() return l mod = 1000000007 # A # B # C """ n = I() a = LI() b = [None for i in range(n-1)] for i in range(n-1): a[i+1] += a[i] for i in range(n-1): b[i] = abs(2*a[i]-a[n-1]) print(min(b)) """ # D n = I() v = [[] for i in range(n)] for i in range(n - 1): a, b = LI() a -= 1 b -= 1 v[a].append(b) v[b].append(a) d_f = [-1 for i in range(n)] q = deque() q.append(0) d_f[0] = 0 while q: x = q.pop() for y in v[x]: if d_f[y] == -1: d_f[y] = d_f[x] + 1 q.append(y) d_s = [-1 for i in range(n)] q.append(n - 1) d_s[n - 1] = 0 while q: x = q.pop() for y in v[x]: if d_s[y] == -1: d_s[y] = d_s[x] + 1 q.append(y) f = 0 s = 0 for i in range(n): if d_f[i] <= d_s[i]: f += 1 else: s += 1 if f > s: print("Fennec") else: print("Snuke") # E # F # G # H # I # J # K # L # M # N # O # P # Q # R # S # T
false
0
[ "-q = queue.Queue()", "-q.put(0)", "+q = deque()", "+q.append(0)", "-while not q.empty():", "- x = q.get()", "+while q:", "+ x = q.pop()", "- q.put(y)", "+ q.append(y)", "-q.put(n - 1)", "+q.append(n - 1)", "-while not q.empty():", "- x = q.get()", "+while q:", "+ x = q.pop()", "- q.put(y)", "+ q.append(y)" ]
false
0.044077
0.109449
0.40272
[ "s142515199", "s791532464" ]
u645250356
p03963
python
s840812521
s682665681
182
53
38,636
5,632
Accepted
Accepted
70.88
from collections import Counter,defaultdict,deque import sys,heapq,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)) n,k = inpl() res = 1 for i in range(n): if i == 0: res *= k else: res *= k-1 print(res)
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions from decimal import Decimal 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,k = inpl() res = 1 for i in range(n): if i == 0: res *= k else: res *= (k-1) print(res)
17
18
511
465
from collections import Counter, defaultdict, deque import sys, heapq, 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)) n, k = inpl() res = 1 for i in range(n): if i == 0: res *= k else: res *= k - 1 print(res)
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools, fractions from decimal import Decimal 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, k = inpl() res = 1 for i in range(n): if i == 0: res *= k else: res *= k - 1 print(res)
false
5.555556
[ "-import sys, heapq, bisect, math, itertools, string, queue", "+from heapq import heappop, heappush, heapify", "+import sys, bisect, math, itertools, fractions", "+from decimal import Decimal", "+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))", "-", "-" ]
false
0.036743
0.036422
1.008806
[ "s840812521", "s682665681" ]
u761320129
p03286
python
s355928855
s329267575
19
17
3,060
3,060
Accepted
Accepted
10.53
N = int(eval(input())) if N == 0: print((0)) exit() ans = '' while N != 0: if N%2: N -= 1 ans += '1' else: ans += '0' N //= -2 print((ans[::-1]))
N = int(eval(input())) if N == 0: print((0)) exit() ans = '' while N: if N%2: N -= 1 ans += '1' else: ans += '0' N //= -2 print((ans[::-1]))
14
16
193
192
N = int(eval(input())) if N == 0: print((0)) exit() ans = "" while N != 0: if N % 2: N -= 1 ans += "1" else: ans += "0" N //= -2 print((ans[::-1]))
N = int(eval(input())) if N == 0: print((0)) exit() ans = "" while N: if N % 2: N -= 1 ans += "1" else: ans += "0" N //= -2 print((ans[::-1]))
false
12.5
[ "-while N != 0:", "+while N:" ]
false
0.045518
0.046775
0.973125
[ "s355928855", "s329267575" ]
u172147273
p02683
python
s826713246
s569337407
88
81
68,764
68,892
Accepted
Accepted
7.95
def ip():return list(map(int,input().split())) n,m,x=map(int,input().split()) c=[] a=[] for i in range(n): temp=ip() c.append(temp[0]) a.append(temp[1:]) ans=12*10**5+1 for i in range(1,2**n): f=bin(i)[2:] sum=[0]*m while len(f)<n:f='0'+f s=0 for j in range(n): if f[j]=='1': s+=c[j] for h in range(m): sum[h]+=a[j][h] F=True for h in range(m): if sum[h]<x:F=False if F==True:ans=min(ans,s) print(ans) if ans!=12*10**5+1 else print(-1)
def ip():return list(map(int,input().split())) n,m,x=map(int,input().split()) c=[] a=[] for i in range(n): temp=ip() c.append(temp[0]) a.append(temp[1:]) ans=12*10**5+1 for i in range(1,2**n): f=bin(i)[2:] sum=[0]*m while len(f)<n:f='0'+f s=0 for j in range(n): if f[j]=='1': s+=c[j] for h in range(m): sum[h]+=a[j][h] if min(sum)>=x:ans=min(ans,s) print(ans) if ans!=12*10**5+1 else print(-1)
32
29
575
514
def ip(): return list(map(int, input().split())) n, m, x = map(int, input().split()) c = [] a = [] for i in range(n): temp = ip() c.append(temp[0]) a.append(temp[1:]) ans = 12 * 10**5 + 1 for i in range(1, 2**n): f = bin(i)[2:] sum = [0] * m while len(f) < n: f = "0" + f s = 0 for j in range(n): if f[j] == "1": s += c[j] for h in range(m): sum[h] += a[j][h] F = True for h in range(m): if sum[h] < x: F = False if F == True: ans = min(ans, s) print(ans) if ans != 12 * 10**5 + 1 else print(-1)
def ip(): return list(map(int, input().split())) n, m, x = map(int, input().split()) c = [] a = [] for i in range(n): temp = ip() c.append(temp[0]) a.append(temp[1:]) ans = 12 * 10**5 + 1 for i in range(1, 2**n): f = bin(i)[2:] sum = [0] * m while len(f) < n: f = "0" + f s = 0 for j in range(n): if f[j] == "1": s += c[j] for h in range(m): sum[h] += a[j][h] if min(sum) >= x: ans = min(ans, s) print(ans) if ans != 12 * 10**5 + 1 else print(-1)
false
9.375
[ "- F = True", "- for h in range(m):", "- if sum[h] < x:", "- F = False", "- if F == True:", "+ if min(sum) >= x:" ]
false
0.047512
0.045373
1.047138
[ "s826713246", "s569337407" ]
u996672406
p03069
python
s684501967
s961470465
114
95
4,840
3,500
Accepted
Accepted
16.67
n = int(eval(input())) s = list(eval(input())) rd = 0 for e in s: if e == ".": rd += 1 res = rd for e in s: if e == ".": rd -= 1 else: rd += 1 res = min(res, rd) print(res)
n = int(eval(input())) minv = res = rd = 0 for e in eval(input()): if e == ".": res += 1 rd -= 1 minv = min(minv, rd) else: rd += 1 print((res + minv))
17
12
220
191
n = int(eval(input())) s = list(eval(input())) rd = 0 for e in s: if e == ".": rd += 1 res = rd for e in s: if e == ".": rd -= 1 else: rd += 1 res = min(res, rd) print(res)
n = int(eval(input())) minv = res = rd = 0 for e in eval(input()): if e == ".": res += 1 rd -= 1 minv = min(minv, rd) else: rd += 1 print((res + minv))
false
29.411765
[ "-s = list(eval(input()))", "-rd = 0", "-for e in s:", "+minv = res = rd = 0", "+for e in eval(input()):", "- rd += 1", "-res = rd", "-for e in s:", "- if e == \".\":", "+ res += 1", "+ minv = min(minv, rd)", "- res = min(res, rd)", "-print(res)", "+print((res + minv))" ]
false
0.114469
0.049895
2.29419
[ "s684501967", "s961470465" ]
u102461423
p02992
python
s901601367
s358216243
493
338
22,636
13,904
Accepted
Accepted
31.44
import numpy as np N,K = list(map(int,input().split())) MOD = 10 ** 9 + 7 M = int(N**.5) # M+1以上で、商がぢょうとxになるやつ upper_cnt = np.zeros(M+1, dtype=np.int64) a = np.arange(M+1, dtype=np.int64) upper_cnt[1:] = N // a[1:] - np.maximum(M, N // (a[1:]+1)) # 数列の末端ごとの個数 # upperについては、個数にわたって合計をとる lower = np.zeros(M+1, dtype=np.int64) upper = np.zeros(M+1, dtype=np.int64) # 0項目に1を置いておくとする lower[1] = 1 for k in range(1,K+1): prev_lower = lower prev_upper = upper cum_lower = prev_lower.cumsum() % MOD cum_upper = prev_upper.cumsum() % MOD # 下側 to 下側 lower = np.zeros(M+1, dtype=np.int64) lower += (cum_lower[-1] + cum_upper[-1]) lower[1:] -= cum_upper[:-1] # 商がn-1以下だと受け付けない lower[0] = 0 # 上側 to 上側:ないはず # 下側 to 上側: upper = cum_lower * upper_cnt lower %= MOD upper %= MOD answer = (lower.sum() + upper.sum()) % MOD print(answer)
import numpy as np N,K = list(map(int,input().split())) MOD = 10 ** 9 + 7 M = int(N**.5) # M+1以上で、商がぢょうとxになるやつ upper_cnt = np.zeros(M+1, dtype=np.int64) a = np.arange(M+1, dtype=np.int64) upper_cnt[1:] = N // a[1:] - np.maximum(M, N // (a[1:]+1)) # 数列の末端ごとの個数 # upperについては、個数にわたって合計をとる lower = np.zeros(M+1, dtype=np.int64) upper = np.zeros(M+1, dtype=np.int64) # 0項目に1を置いておくとする lower[1] = 1 for k in range(1,K+1): prev_lower = lower prev_upper = upper np.cumsum(prev_lower, out = prev_lower) np.cumsum(prev_upper, out = prev_upper) prev_lower %= MOD prev_upper %= MOD # 下側 to 下側 lower = np.zeros(M+1, dtype=np.int64) lower += (prev_lower[-1] + prev_upper[-1]) lower[1:] -= prev_upper[:-1] # 商がn-1以下だと受け付けない lower[0] = 0 # 上側 to 上側:ないはず # 下側 to 上側: upper = prev_lower * upper_cnt lower %= MOD upper %= MOD answer = (lower.sum() + upper.sum()) % MOD print(answer)
34
36
908
963
import numpy as np N, K = list(map(int, input().split())) MOD = 10**9 + 7 M = int(N**0.5) # M+1以上で、商がぢょうとxになるやつ upper_cnt = np.zeros(M + 1, dtype=np.int64) a = np.arange(M + 1, dtype=np.int64) upper_cnt[1:] = N // a[1:] - np.maximum(M, N // (a[1:] + 1)) # 数列の末端ごとの個数 # upperについては、個数にわたって合計をとる lower = np.zeros(M + 1, dtype=np.int64) upper = np.zeros(M + 1, dtype=np.int64) # 0項目に1を置いておくとする lower[1] = 1 for k in range(1, K + 1): prev_lower = lower prev_upper = upper cum_lower = prev_lower.cumsum() % MOD cum_upper = prev_upper.cumsum() % MOD # 下側 to 下側 lower = np.zeros(M + 1, dtype=np.int64) lower += cum_lower[-1] + cum_upper[-1] lower[1:] -= cum_upper[:-1] # 商がn-1以下だと受け付けない lower[0] = 0 # 上側 to 上側:ないはず # 下側 to 上側: upper = cum_lower * upper_cnt lower %= MOD upper %= MOD answer = (lower.sum() + upper.sum()) % MOD print(answer)
import numpy as np N, K = list(map(int, input().split())) MOD = 10**9 + 7 M = int(N**0.5) # M+1以上で、商がぢょうとxになるやつ upper_cnt = np.zeros(M + 1, dtype=np.int64) a = np.arange(M + 1, dtype=np.int64) upper_cnt[1:] = N // a[1:] - np.maximum(M, N // (a[1:] + 1)) # 数列の末端ごとの個数 # upperについては、個数にわたって合計をとる lower = np.zeros(M + 1, dtype=np.int64) upper = np.zeros(M + 1, dtype=np.int64) # 0項目に1を置いておくとする lower[1] = 1 for k in range(1, K + 1): prev_lower = lower prev_upper = upper np.cumsum(prev_lower, out=prev_lower) np.cumsum(prev_upper, out=prev_upper) prev_lower %= MOD prev_upper %= MOD # 下側 to 下側 lower = np.zeros(M + 1, dtype=np.int64) lower += prev_lower[-1] + prev_upper[-1] lower[1:] -= prev_upper[:-1] # 商がn-1以下だと受け付けない lower[0] = 0 # 上側 to 上側:ないはず # 下側 to 上側: upper = prev_lower * upper_cnt lower %= MOD upper %= MOD answer = (lower.sum() + upper.sum()) % MOD print(answer)
false
5.555556
[ "- cum_lower = prev_lower.cumsum() % MOD", "- cum_upper = prev_upper.cumsum() % MOD", "+ np.cumsum(prev_lower, out=prev_lower)", "+ np.cumsum(prev_upper, out=prev_upper)", "+ prev_lower %= MOD", "+ prev_upper %= MOD", "- lower += cum_lower[-1] + cum_upper[-1]", "- lower[1:] -= cum_upper[:-1] # 商がn-1以下だと受け付けない", "+ lower += prev_lower[-1] + prev_upper[-1]", "+ lower[1:] -= prev_upper[:-1] # 商がn-1以下だと受け付けない", "- upper = cum_lower * upper_cnt", "+ upper = prev_lower * upper_cnt" ]
false
0.426197
0.52874
0.806062
[ "s901601367", "s358216243" ]
u602740328
p03673
python
s881162838
s623714111
157
74
34,704
27,716
Accepted
Accepted
52.87
n=int(eval(input())) a=list(map(int,input().split())) b1=[str(a[2*i]) for i in range(0,n//2)] b2=[str(a[2*i+1]) for i in range(0,n//2)] if n%2: b=[str(a[-1])]+list(reversed(b1))+b2 else: b=list(reversed(b2))+b1 print((" ".join(b)))
n=int(eval(input())) a=input().split() b1=[a[2*i] for i in range(0,n//2)] b2=[a[2*i+1] for i in range(0,n//2)] if n%2: b=[a[-1]]+list(reversed(b1))+b2 else: b=list(reversed(b2))+b1 print((" ".join(b)))
7
7
229
199
n = int(eval(input())) a = list(map(int, input().split())) b1 = [str(a[2 * i]) for i in range(0, n // 2)] b2 = [str(a[2 * i + 1]) for i in range(0, n // 2)] if n % 2: b = [str(a[-1])] + list(reversed(b1)) + b2 else: b = list(reversed(b2)) + b1 print((" ".join(b)))
n = int(eval(input())) a = input().split() b1 = [a[2 * i] for i in range(0, n // 2)] b2 = [a[2 * i + 1] for i in range(0, n // 2)] if n % 2: b = [a[-1]] + list(reversed(b1)) + b2 else: b = list(reversed(b2)) + b1 print((" ".join(b)))
false
0
[ "-a = list(map(int, input().split()))", "-b1 = [str(a[2 * i]) for i in range(0, n // 2)]", "-b2 = [str(a[2 * i + 1]) for i in range(0, n // 2)]", "+a = input().split()", "+b1 = [a[2 * i] for i in range(0, n // 2)]", "+b2 = [a[2 * i + 1] for i in range(0, n // 2)]", "- b = [str(a[-1])] + list(reversed(b1)) + b2", "+ b = [a[-1]] + list(reversed(b1)) + b2" ]
false
0.040503
0.043274
0.935963
[ "s881162838", "s623714111" ]
u083960235
p03274
python
s561735751
s907374021
124
97
16,364
15,012
Accepted
Accepted
21.77
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 = float('inf') mod = 10 ** 9 + 7 N, K = MAP() X = LIST() # dist = 0 s = [] l = [] s = deque(s) l = deque(l) for x in X: if x < 0: s.appendleft(-1 * x) else: l.append(x) # s.sort() # print(s, l) left = 0 right = 0 q = [] ans = INF for i in range(N-K+1): left = i right = i + K - 1 ans = min(ans, min(abs(X[left]), abs(X[right])) + X[right] - X[left]) print(ans)
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 heapq import heapify, heappop, heappush 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 = float('inf') mod = 10 ** 9 + 7 N, K = MAP() X = LIST() ans = INF for i in range(N-K+1): a, b = X[i], X[i+K-1] # if a <= 0 and 0 < b: if b <= 0: ans = min(abs(a), ans) elif 0 <= a: ans = min(abs(b), ans) else: tmp = min(abs(a), abs(b)) + (b - a) ans = min(ans, tmp) print(ans)
45
36
1,116
1,059
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 = float("inf") mod = 10**9 + 7 N, K = MAP() X = LIST() # dist = 0 s = [] l = [] s = deque(s) l = deque(l) for x in X: if x < 0: s.appendleft(-1 * x) else: l.append(x) # s.sort() # print(s, l) left = 0 right = 0 q = [] ans = INF for i in range(N - K + 1): left = i right = i + K - 1 ans = min(ans, min(abs(X[left]), abs(X[right])) + X[right] - X[left]) print(ans)
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 heapq import heapify, heappop, heappush 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 = float("inf") mod = 10**9 + 7 N, K = MAP() X = LIST() ans = INF for i in range(N - K + 1): a, b = X[i], X[i + K - 1] # if a <= 0 and 0 < b: if b <= 0: ans = min(abs(a), ans) elif 0 <= a: ans = min(abs(b), ans) else: tmp = min(abs(a), abs(b)) + (b - a) ans = min(ans, tmp) print(ans)
false
20
[ "-from fractions import gcd", "+from heapq import heapify, heappop, heappush", "-# dist = 0", "-s = []", "-l = []", "-s = deque(s)", "-l = deque(l)", "-for x in X:", "- if x < 0:", "- s.appendleft(-1 * x)", "- else:", "- l.append(x)", "-# s.sort()", "-# print(s, l)", "-left = 0", "-right = 0", "-q = []", "- left = i", "- right = i + K - 1", "- ans = min(ans, min(abs(X[left]), abs(X[right])) + X[right] - X[left])", "+ a, b = X[i], X[i + K - 1]", "+ # if a <= 0 and 0 < b:", "+ if b <= 0:", "+ ans = min(abs(a), ans)", "+ elif 0 <= a:", "+ ans = min(abs(b), ans)", "+ else:", "+ tmp = min(abs(a), abs(b)) + (b - a)", "+ ans = min(ans, tmp)" ]
false
0.038065
0.085351
0.445984
[ "s561735751", "s907374021" ]
u600402037
p02923
python
s143984598
s891471352
209
184
23,388
23,384
Accepted
Accepted
11.96
import numpy as np N = int(eval(input())) H = np.array(list(map(int, input().split()))) answer = 0 L1 = (H[:-1] >= H[1:]) #print(L1) answer = 0 count = 0 for l in L1: if l: count += 1 else: answer = max(answer, count) count = 0 print((max(answer, count)))
import sys import numpy as np sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N = ir() H = np.array([-10] + lr() + [10**10]) x = H[1:] <= H[:-1] temp = np.arange(len(x)) temp[x>0] = 0 np.maximum.accumulate(temp, out=temp) left = temp x_reversed = x[::-1] temp = np.arange(len(x)) temp[x_reversed > 0] = 0 np.maximum.accumulate(temp, out=temp) right = len(x) - 1 - temp[::-1] y = right y -= left + 1 y[x == 0] = 0 answer = y.max() print(answer)
21
25
305
531
import numpy as np N = int(eval(input())) H = np.array(list(map(int, input().split()))) answer = 0 L1 = H[:-1] >= H[1:] # print(L1) answer = 0 count = 0 for l in L1: if l: count += 1 else: answer = max(answer, count) count = 0 print((max(answer, count)))
import sys import numpy as np sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N = ir() H = np.array([-10] + lr() + [10**10]) x = H[1:] <= H[:-1] temp = np.arange(len(x)) temp[x > 0] = 0 np.maximum.accumulate(temp, out=temp) left = temp x_reversed = x[::-1] temp = np.arange(len(x)) temp[x_reversed > 0] = 0 np.maximum.accumulate(temp, out=temp) right = len(x) - 1 - temp[::-1] y = right y -= left + 1 y[x == 0] = 0 answer = y.max() print(answer)
false
16
[ "+import sys", "-N = int(eval(input()))", "-H = np.array(list(map(int, input().split())))", "-answer = 0", "-L1 = H[:-1] >= H[1:]", "-# print(L1)", "-answer = 0", "-count = 0", "-for l in L1:", "- if l:", "- count += 1", "- else:", "- answer = max(answer, count)", "- count = 0", "-print((max(answer, count)))", "+sr = lambda: sys.stdin.readline().rstrip()", "+ir = lambda: int(sr())", "+lr = lambda: list(map(int, sr().split()))", "+N = ir()", "+H = np.array([-10] + lr() + [10**10])", "+x = H[1:] <= H[:-1]", "+temp = np.arange(len(x))", "+temp[x > 0] = 0", "+np.maximum.accumulate(temp, out=temp)", "+left = temp", "+x_reversed = x[::-1]", "+temp = np.arange(len(x))", "+temp[x_reversed > 0] = 0", "+np.maximum.accumulate(temp, out=temp)", "+right = len(x) - 1 - temp[::-1]", "+y = right", "+y -= left + 1", "+y[x == 0] = 0", "+answer = y.max()", "+print(answer)" ]
false
0.226828
0.444459
0.510347
[ "s143984598", "s891471352" ]
u644907318
p03525
python
s588407729
s067509065
174
65
38,896
64,576
Accepted
Accepted
62.64
N = int(eval(input())) D = sorted(list(map(int,input().split()))) for i in range(0,N,2): D[i] = 24-D[i] D.insert(0,0) dmin = 24 for i in range(N): for j in range(i+1,N+1): a = D[i] b = D[j] if a>b: a,b = b,a d = b-a if d>12: d = 24-d dmin = min(dmin,d) print(dmin)
N = int(eval(input())) D = list(map(int,input().split())) s = min(D) if 12 in D: for i in range(N): if D[i]!=12: s = min(s,12-D[i]) D.remove(12) D = sorted(D) E = [] for i in range(len(D)): if i%2==0: E.append(D[i]) else: E.append(24-D[i]) for i in range(len(E)-1): for j in range(i+1,len(E)): a = E[i] b = E[j] d = abs(a-b) if d>12: d = 24-d s = min(s,d) print(s)
17
24
354
489
N = int(eval(input())) D = sorted(list(map(int, input().split()))) for i in range(0, N, 2): D[i] = 24 - D[i] D.insert(0, 0) dmin = 24 for i in range(N): for j in range(i + 1, N + 1): a = D[i] b = D[j] if a > b: a, b = b, a d = b - a if d > 12: d = 24 - d dmin = min(dmin, d) print(dmin)
N = int(eval(input())) D = list(map(int, input().split())) s = min(D) if 12 in D: for i in range(N): if D[i] != 12: s = min(s, 12 - D[i]) D.remove(12) D = sorted(D) E = [] for i in range(len(D)): if i % 2 == 0: E.append(D[i]) else: E.append(24 - D[i]) for i in range(len(E) - 1): for j in range(i + 1, len(E)): a = E[i] b = E[j] d = abs(a - b) if d > 12: d = 24 - d s = min(s, d) print(s)
false
29.166667
[ "-D = sorted(list(map(int, input().split())))", "-for i in range(0, N, 2):", "- D[i] = 24 - D[i]", "-D.insert(0, 0)", "-dmin = 24", "-for i in range(N):", "- for j in range(i + 1, N + 1):", "- a = D[i]", "- b = D[j]", "- if a > b:", "- a, b = b, a", "- d = b - a", "+D = list(map(int, input().split()))", "+s = min(D)", "+if 12 in D:", "+ for i in range(N):", "+ if D[i] != 12:", "+ s = min(s, 12 - D[i])", "+ D.remove(12)", "+D = sorted(D)", "+E = []", "+for i in range(len(D)):", "+ if i % 2 == 0:", "+ E.append(D[i])", "+ else:", "+ E.append(24 - D[i])", "+for i in range(len(E) - 1):", "+ for j in range(i + 1, len(E)):", "+ a = E[i]", "+ b = E[j]", "+ d = abs(a - b)", "- dmin = min(dmin, d)", "-print(dmin)", "+ s = min(s, d)", "+print(s)" ]
false
0.037522
0.037718
0.994815
[ "s588407729", "s067509065" ]
u704284486
p03476
python
s754971391
s474101280
955
881
5,324
6,432
Accepted
Accepted
7.75
def sieve(N):#エラトステネスの篩 prime = [0]*(N+1) isprime = [True]*(N+1) isprime[0]=isprime[1] = False num = 0 for p in range(2,N+1): if isprime[p]: prime[num] = p num += 1 for j in range(2*p,N+1,p): isprime[j] = False return prime from bisect import bisect_left as bl from bisect import bisect_right as br lis = sieve(10**5) prime = set(lis)-{0} for i in range(len(lis)): if lis[i] != 0: if (lis[i]+1)//2 in prime:continue else:lis[i] = 0 else:continue Q = int(eval(input())) lis = set(lis)-{0} lis = sorted(tuple(lis)) for _ in range(Q): l,r = list(map(int,input().split())) t = bl(lis,l) s = br(lis,r) tmp = s-t print(tmp)
def sieve(N):#エラトステネスの篩 prime = [0]*(N+1) isprime = [True]*(N+1) isprime[0]=isprime[1] = False num = 0 for p in range(2,N+1): if isprime[p]: prime[num] = p num += 1 for j in range(2*p,N+1,p): isprime[j] = False return prime lis = sieve(10**5) prime = set(lis)-{0} for i in range(len(lis)): if lis[i] != 0: if (lis[i]+1)//2 in prime:continue else:lis[i] = 0 else:continue Q = int(eval(input())) lis = set(lis)-{0} c = [0]*(10**5+1) for i in range(10**5): if i+1 in lis: c[i+1] = c[i]+1 else: c[i+1] =c[i] c = tuple(c) for _ in range(Q): l,r = list(map(int,input().split())) tmp = c[r]-c[l-1] print(tmp)
31
34
765
769
def sieve(N): # エラトステネスの篩 prime = [0] * (N + 1) isprime = [True] * (N + 1) isprime[0] = isprime[1] = False num = 0 for p in range(2, N + 1): if isprime[p]: prime[num] = p num += 1 for j in range(2 * p, N + 1, p): isprime[j] = False return prime from bisect import bisect_left as bl from bisect import bisect_right as br lis = sieve(10**5) prime = set(lis) - {0} for i in range(len(lis)): if lis[i] != 0: if (lis[i] + 1) // 2 in prime: continue else: lis[i] = 0 else: continue Q = int(eval(input())) lis = set(lis) - {0} lis = sorted(tuple(lis)) for _ in range(Q): l, r = list(map(int, input().split())) t = bl(lis, l) s = br(lis, r) tmp = s - t print(tmp)
def sieve(N): # エラトステネスの篩 prime = [0] * (N + 1) isprime = [True] * (N + 1) isprime[0] = isprime[1] = False num = 0 for p in range(2, N + 1): if isprime[p]: prime[num] = p num += 1 for j in range(2 * p, N + 1, p): isprime[j] = False return prime lis = sieve(10**5) prime = set(lis) - {0} for i in range(len(lis)): if lis[i] != 0: if (lis[i] + 1) // 2 in prime: continue else: lis[i] = 0 else: continue Q = int(eval(input())) lis = set(lis) - {0} c = [0] * (10**5 + 1) for i in range(10**5): if i + 1 in lis: c[i + 1] = c[i] + 1 else: c[i + 1] = c[i] c = tuple(c) for _ in range(Q): l, r = list(map(int, input().split())) tmp = c[r] - c[l - 1] print(tmp)
false
8.823529
[ "-from bisect import bisect_left as bl", "-from bisect import bisect_right as br", "-", "-lis = sorted(tuple(lis))", "+c = [0] * (10**5 + 1)", "+for i in range(10**5):", "+ if i + 1 in lis:", "+ c[i + 1] = c[i] + 1", "+ else:", "+ c[i + 1] = c[i]", "+c = tuple(c)", "- t = bl(lis, l)", "- s = br(lis, r)", "- tmp = s - t", "+ tmp = c[r] - c[l - 1]" ]
false
0.127861
0.202055
0.632801
[ "s754971391", "s474101280" ]
u716530146
p02971
python
s375367929
s875828480
432
209
26,628
26,620
Accepted
Accepted
51.62
n = int(eval(input())) data = [int(eval(input())) for k in range(n)] m1,m2 = sorted(data, reverse=1)[:2] b = [m2 if x==m1 else m1 for x in data] print(('\n'.join(map(str,b))))
import sys input = sys.stdin.readline n = int(eval(input())) data = [int(eval(input())) for k in range(n)] m1,m2 = sorted(data, reverse=1)[:2] b = [m2 if x==m1 else m1 for x in data] print(('\n'.join(map(str,b))))
5
8
165
207
n = int(eval(input())) data = [int(eval(input())) for k in range(n)] m1, m2 = sorted(data, reverse=1)[:2] b = [m2 if x == m1 else m1 for x in data] print(("\n".join(map(str, b))))
import sys input = sys.stdin.readline n = int(eval(input())) data = [int(eval(input())) for k in range(n)] m1, m2 = sorted(data, reverse=1)[:2] b = [m2 if x == m1 else m1 for x in data] print(("\n".join(map(str, b))))
false
37.5
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.039621
0.106448
0.372212
[ "s375367929", "s875828480" ]
u917558625
p02862
python
s418697524
s001062550
1,380
1,231
122,048
44,024
Accepted
Accepted
10.8
X,Y=list(map(int,input().split())) def cmb(n, r, mod): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod mod = 10**9+7 N = 10**6 g1 = [1, 1] g2 = [1, 1] inverse = [0, 1] for i in range( 2, N + 1 ): g1.append( ( g1[-1] * i ) % mod ) inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod ) g2.append( (g2[-1] * inverse[-1]) % mod ) if (X+Y)%3!=0: print((0)) else: n=2*Y-X m=2*X-Y if n<0 or m<0: print((0)) else: n=int(n/3) m=int(m/3) print((cmb(n+m,m,mod)))
X,Y=list(map(int,input().split())) def cmb(n, r): if n - r < r: r = n - r if r == 0: return 1 if r == 1: return n numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2,r+1): pivot = denominator[p - 1] if pivot > 1: offset = (n - r) % p for k in range(p-1,r,p): numerator[k - offset] /= pivot denominator[k] /= pivot result = 1 for k in range(r): if numerator[k] > 1: result *= int(numerator[k]) return result if (X+Y)%3!=0: print((0)) else: n=2*Y-X m=2*X-Y mod=10**9+7 if n<0 or m<0: print((0)) else: n=int(n/3) m=int(m/3) print((cmb(n+m,m)%mod))
26
31
558
769
X, Y = list(map(int, input().split())) def cmb(n, r, mod): if r < 0 or r > n: return 0 r = min(r, n - r) return g1[n] * g2[r] * g2[n - r] % mod mod = 10**9 + 7 N = 10**6 g1 = [1, 1] g2 = [1, 1] inverse = [0, 1] for i in range(2, N + 1): g1.append((g1[-1] * i) % mod) inverse.append((-inverse[mod % i] * (mod // i)) % mod) g2.append((g2[-1] * inverse[-1]) % mod) if (X + Y) % 3 != 0: print((0)) else: n = 2 * Y - X m = 2 * X - Y if n < 0 or m < 0: print((0)) else: n = int(n / 3) m = int(m / 3) print((cmb(n + m, m, mod)))
X, Y = list(map(int, input().split())) def cmb(n, r): if n - r < r: r = n - r if r == 0: return 1 if r == 1: return n numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2, r + 1): pivot = denominator[p - 1] if pivot > 1: offset = (n - r) % p for k in range(p - 1, r, p): numerator[k - offset] /= pivot denominator[k] /= pivot result = 1 for k in range(r): if numerator[k] > 1: result *= int(numerator[k]) return result if (X + Y) % 3 != 0: print((0)) else: n = 2 * Y - X m = 2 * X - Y mod = 10**9 + 7 if n < 0 or m < 0: print((0)) else: n = int(n / 3) m = int(m / 3) print((cmb(n + m, m) % mod))
false
16.129032
[ "-def cmb(n, r, mod):", "- if r < 0 or r > n:", "- return 0", "- r = min(r, n - r)", "- return g1[n] * g2[r] * g2[n - r] % mod", "+def cmb(n, r):", "+ if n - r < r:", "+ r = n - r", "+ if r == 0:", "+ return 1", "+ if r == 1:", "+ return n", "+ numerator = [n - r + k + 1 for k in range(r)]", "+ denominator = [k + 1 for k in range(r)]", "+ for p in range(2, r + 1):", "+ pivot = denominator[p - 1]", "+ if pivot > 1:", "+ offset = (n - r) % p", "+ for k in range(p - 1, r, p):", "+ numerator[k - offset] /= pivot", "+ denominator[k] /= pivot", "+ result = 1", "+ for k in range(r):", "+ if numerator[k] > 1:", "+ result *= int(numerator[k])", "+ return result", "-mod = 10**9 + 7", "-N = 10**6", "-g1 = [1, 1]", "-g2 = [1, 1]", "-inverse = [0, 1]", "-for i in range(2, N + 1):", "- g1.append((g1[-1] * i) % mod)", "- inverse.append((-inverse[mod % i] * (mod // i)) % mod)", "- g2.append((g2[-1] * inverse[-1]) % mod)", "+ mod = 10**9 + 7", "- print((cmb(n + m, m, mod)))", "+ print((cmb(n + m, m) % mod))" ]
false
1.553039
0.21826
7.115559
[ "s418697524", "s001062550" ]
u597374218
p02953
python
s619544909
s310523508
82
72
15,020
14,396
Accepted
Accepted
12.2
N=int(eval(input())) H=list(map(int,input().split()))[::-1] flag=True base=H[0] for i in range(N-1): if H[i]+1==H[i+1]: H[i+1]-=1 elif H[i]>=H[i+1]: continue else: flag=False print(("Yes" if flag else "No"))
N=int(eval(input())) H=list(map(int,input().split())) base=0 for h in H: if base>h: print("No") break base=max(base,h-1) else: print("Yes")
12
10
246
170
N = int(eval(input())) H = list(map(int, input().split()))[::-1] flag = True base = H[0] for i in range(N - 1): if H[i] + 1 == H[i + 1]: H[i + 1] -= 1 elif H[i] >= H[i + 1]: continue else: flag = False print(("Yes" if flag else "No"))
N = int(eval(input())) H = list(map(int, input().split())) base = 0 for h in H: if base > h: print("No") break base = max(base, h - 1) else: print("Yes")
false
16.666667
[ "-H = list(map(int, input().split()))[::-1]", "-flag = True", "-base = H[0]", "-for i in range(N - 1):", "- if H[i] + 1 == H[i + 1]:", "- H[i + 1] -= 1", "- elif H[i] >= H[i + 1]:", "- continue", "- else:", "- flag = False", "-print((\"Yes\" if flag else \"No\"))", "+H = list(map(int, input().split()))", "+base = 0", "+for h in H:", "+ if base > h:", "+ print(\"No\")", "+ break", "+ base = max(base, h - 1)", "+else:", "+ print(\"Yes\")" ]
false
0.03594
0.035764
1.004912
[ "s619544909", "s310523508" ]
u804180276
p02717
python
s962079431
s050456969
23
20
9,008
9,000
Accepted
Accepted
13.04
# [箱A, 箱B, 箱C] list = input().split() # 箱Aと箱B入れ替え temp = list[0] list[0] = list[1] list[1] = temp # 箱Aと箱C入れ替え temp = list[0] list[0] = list[2] list[2] = temp print((' '.join(list)))
# [箱A, 箱B, 箱C] list = input().split() # 箱Aと箱B入れ替え list[0], list[1] = list[1], list[0] # 箱Aと箱C入れ替え list[0], list[2] = list[2], list[0] print((' '.join(list)))
14
10
223
187
# [箱A, 箱B, 箱C] list = input().split() # 箱Aと箱B入れ替え temp = list[0] list[0] = list[1] list[1] = temp # 箱Aと箱C入れ替え temp = list[0] list[0] = list[2] list[2] = temp print((" ".join(list)))
# [箱A, 箱B, 箱C] list = input().split() # 箱Aと箱B入れ替え list[0], list[1] = list[1], list[0] # 箱Aと箱C入れ替え list[0], list[2] = list[2], list[0] print((" ".join(list)))
false
28.571429
[ "-temp = list[0]", "-list[0] = list[1]", "-list[1] = temp", "+list[0], list[1] = list[1], list[0]", "-temp = list[0]", "-list[0] = list[2]", "-list[2] = temp", "+list[0], list[2] = list[2], list[0]" ]
false
0.035964
0.04694
0.766183
[ "s962079431", "s050456969" ]
u796942881
p02935
python
s337268086
s285693285
22
17
3,572
2,940
Accepted
Accepted
22.73
from functools import reduce def main(): eval(input()) v = sorted(map(int, input().split())) print((reduce(lambda x, y: (x + y) * 0.5, v))) main()
def main(): eval(input()) v = sorted(map(int, input().split())) ans = v[0] for i in v[1:]: ans = (ans + i) * 0.5 print(ans) return main()
10
11
164
176
from functools import reduce def main(): eval(input()) v = sorted(map(int, input().split())) print((reduce(lambda x, y: (x + y) * 0.5, v))) main()
def main(): eval(input()) v = sorted(map(int, input().split())) ans = v[0] for i in v[1:]: ans = (ans + i) * 0.5 print(ans) return main()
false
9.090909
[ "-from functools import reduce", "-", "-", "- print((reduce(lambda x, y: (x + y) * 0.5, v)))", "+ ans = v[0]", "+ for i in v[1:]:", "+ ans = (ans + i) * 0.5", "+ print(ans)", "+ return" ]
false
0.039662
0.038513
1.029825
[ "s337268086", "s285693285" ]
u270681687
p02863
python
s820158978
s041612923
1,321
650
394,756
124,504
Accepted
Accepted
50.79
n, t = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(n)] ab.sort() a = [] b = [] for ai, bi in ab: a.append(ai) b.append(bi) dp = [[0 for j in range(t+1)] for i in range(n+1)] prev = [[(0, 0) for j in range(t+1)] for i in range(n+1)] for i in range(n): for j in range(t): if j + a[i] <= t-1: if dp[i+1][j + a[i]] < dp[i][j] + b[i]: dp[i+1][j + a[i]] = dp[i][j] + b[i] prev[i+1][j+a[i]] = (i, j) if dp[i+1][j] < dp[i][j]: dp[i+1][j] = dp[i][j] prev[i+1][j] = (i, j) happy = dp[n][t-1] i = n j = t-1 used = set([]) while i > 0 or j > 0: pi, pj = prev[i][j] if dp[pi][pj] != dp[i][j]: used.add(pi) i = pi j = pj unused = [] for i in range(n): if i not in used: unused.append(b[i]) if len(unused) == 0: ans = happy else: ans = happy + max(unused) print(ans)
n, t = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(n)] ab.sort() a = [] b = [] for ai, bi in ab: a.append(ai) b.append(bi) dp = [[0 for j in range(t+1)] for i in range(n+1)] for i in range(n): for j in range(t): if j + a[i] <= t-1: if dp[i+1][j + a[i]] < dp[i][j] + b[i]: dp[i+1][j + a[i]] = dp[i][j] + b[i] if dp[i+1][j] < dp[i][j]: dp[i+1][j] = dp[i][j] ans = 0 for i in range(n): ans = max(ans, dp[i][t-1] + b[i]) print(ans)
51
31
990
576
n, t = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(n)] ab.sort() a = [] b = [] for ai, bi in ab: a.append(ai) b.append(bi) dp = [[0 for j in range(t + 1)] for i in range(n + 1)] prev = [[(0, 0) for j in range(t + 1)] for i in range(n + 1)] for i in range(n): for j in range(t): if j + a[i] <= t - 1: if dp[i + 1][j + a[i]] < dp[i][j] + b[i]: dp[i + 1][j + a[i]] = dp[i][j] + b[i] prev[i + 1][j + a[i]] = (i, j) if dp[i + 1][j] < dp[i][j]: dp[i + 1][j] = dp[i][j] prev[i + 1][j] = (i, j) happy = dp[n][t - 1] i = n j = t - 1 used = set([]) while i > 0 or j > 0: pi, pj = prev[i][j] if dp[pi][pj] != dp[i][j]: used.add(pi) i = pi j = pj unused = [] for i in range(n): if i not in used: unused.append(b[i]) if len(unused) == 0: ans = happy else: ans = happy + max(unused) print(ans)
n, t = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(n)] ab.sort() a = [] b = [] for ai, bi in ab: a.append(ai) b.append(bi) dp = [[0 for j in range(t + 1)] for i in range(n + 1)] for i in range(n): for j in range(t): if j + a[i] <= t - 1: if dp[i + 1][j + a[i]] < dp[i][j] + b[i]: dp[i + 1][j + a[i]] = dp[i][j] + b[i] if dp[i + 1][j] < dp[i][j]: dp[i + 1][j] = dp[i][j] ans = 0 for i in range(n): ans = max(ans, dp[i][t - 1] + b[i]) print(ans)
false
39.215686
[ "-prev = [[(0, 0) for j in range(t + 1)] for i in range(n + 1)]", "- prev[i + 1][j + a[i]] = (i, j)", "- prev[i + 1][j] = (i, j)", "-happy = dp[n][t - 1]", "-i = n", "-j = t - 1", "-used = set([])", "-while i > 0 or j > 0:", "- pi, pj = prev[i][j]", "- if dp[pi][pj] != dp[i][j]:", "- used.add(pi)", "- i = pi", "- j = pj", "-unused = []", "+ans = 0", "- if i not in used:", "- unused.append(b[i])", "-if len(unused) == 0:", "- ans = happy", "-else:", "- ans = happy + max(unused)", "+ ans = max(ans, dp[i][t - 1] + b[i])" ]
false
0.083226
0.045966
1.810577
[ "s820158978", "s041612923" ]
u800058906
p02899
python
s002250307
s373668453
140
86
37,984
20,896
Accepted
Accepted
38.57
n=int(eval(input())) a=list(map(int,input().split())) num=[i for i in range(1,n+1)] order=dict(list(zip(num,a))) order2=sorted(list(order.items()),key=lambda x:x[1]) ans=[] for i in range(n): ans.append(order2[i][0]) print((' '.join([str(n) for n in ans])))
n=int(eval(input())) a=list(map(int,input().split())) ans=['-']*n for i in range(n): ans[a[i]-1]=str(i+1) print((' '.join(ans)))
15
8
259
133
n = int(eval(input())) a = list(map(int, input().split())) num = [i for i in range(1, n + 1)] order = dict(list(zip(num, a))) order2 = sorted(list(order.items()), key=lambda x: x[1]) ans = [] for i in range(n): ans.append(order2[i][0]) print((" ".join([str(n) for n in ans])))
n = int(eval(input())) a = list(map(int, input().split())) ans = ["-"] * n for i in range(n): ans[a[i] - 1] = str(i + 1) print((" ".join(ans)))
false
46.666667
[ "-num = [i for i in range(1, n + 1)]", "-order = dict(list(zip(num, a)))", "-order2 = sorted(list(order.items()), key=lambda x: x[1])", "-ans = []", "+ans = [\"-\"] * n", "- ans.append(order2[i][0])", "-print((\" \".join([str(n) for n in ans])))", "+ ans[a[i] - 1] = str(i + 1)", "+print((\" \".join(ans)))" ]
false
0.055549
0.036436
1.524584
[ "s002250307", "s373668453" ]
u814265211
p02983
python
s937683563
s290136660
729
380
153,840
81,188
Accepted
Accepted
47.87
L, R = [int(i) for i in input().split()] if R - L < 2019: print((min([(i * j) % 2019 for i in range(L, R) for j in range(L + 1, R + 1)]))) else: print((min([(i * j) % 2019 for i in range(L, L + 2019) for j in range(L, L + 2019)])))
L, R = list(map(int, input().split())) R = min(R, L+2019) print((min([i * j % 2019 for i in range(L, R+1) for j in range(i+1, R+1)])))
5
3
240
129
L, R = [int(i) for i in input().split()] if R - L < 2019: print((min([(i * j) % 2019 for i in range(L, R) for j in range(L + 1, R + 1)]))) else: print( (min([(i * j) % 2019 for i in range(L, L + 2019) for j in range(L, L + 2019)])) )
L, R = list(map(int, input().split())) R = min(R, L + 2019) print((min([i * j % 2019 for i in range(L, R + 1) for j in range(i + 1, R + 1)])))
false
40
[ "-L, R = [int(i) for i in input().split()]", "-if R - L < 2019:", "- print((min([(i * j) % 2019 for i in range(L, R) for j in range(L + 1, R + 1)])))", "-else:", "- print(", "- (min([(i * j) % 2019 for i in range(L, L + 2019) for j in range(L, L + 2019)]))", "- )", "+L, R = list(map(int, input().split()))", "+R = min(R, L + 2019)", "+print((min([i * j % 2019 for i in range(L, R + 1) for j in range(i + 1, R + 1)])))" ]
false
0.089251
0.114527
0.779299
[ "s937683563", "s290136660" ]
u077291787
p03436
python
s018051520
s595430878
26
22
3,316
3,192
Accepted
Accepted
15.38
# ABC088D - Grid Repainting import sys input = sys.stdin.readline from collections import deque def bfs() -> None: q = [(0, 0)] while q: x, y = q.pop(0) for dx, dy in dxy: nx, ny = x + dx, y + dy # next x, y if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == "." and dist[nx][ny] == 0: q.append((nx, ny)) dist[nx][ny] = dist[x][y] + 1 def main(): global H, W, S, dist, dxy H, W = tuple(map(int, input().split())) S = tuple(input().rstrip() for _ in range(H)) dist = [[0] * W for _ in range(H)] # distance from (0, 0) to (x, y) dist[0][0] = 1 dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)] bfs() white, x = sum(s.count(".") for s in S), dist[-1][-1] ans = white - x if x else -1 print(ans) if __name__ == "__main__": main()
# ABC088D - Grid Repainting import sys input = sys.stdin.readline def bfs() -> None: q = [(0, 0)] while q: x, y = q.pop(0) for dx, dy in dxy: nx, ny = x + dx, y + dy # next x, y if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == "." and dist[nx][ny] == 0: q.append((nx, ny)) dist[nx][ny] = dist[x][y] + 1 def main(): global H, W, S, dist, dxy H, W = tuple(map(int, input().split())) S = tuple(input().rstrip() for _ in range(H)) dist = [[0] * W for _ in range(H)] # distance from (0, 0) to (x, y) dist[0][0] = 1 dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)] bfs() white, x = sum(s.count(".") for s in S), dist[-1][-1] ans = white - x if x else -1 print(ans) if __name__ == "__main__": main()
32
30
876
843
# ABC088D - Grid Repainting import sys input = sys.stdin.readline from collections import deque def bfs() -> None: q = [(0, 0)] while q: x, y = q.pop(0) for dx, dy in dxy: nx, ny = x + dx, y + dy # next x, y if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == "." and dist[nx][ny] == 0: q.append((nx, ny)) dist[nx][ny] = dist[x][y] + 1 def main(): global H, W, S, dist, dxy H, W = tuple(map(int, input().split())) S = tuple(input().rstrip() for _ in range(H)) dist = [[0] * W for _ in range(H)] # distance from (0, 0) to (x, y) dist[0][0] = 1 dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)] bfs() white, x = sum(s.count(".") for s in S), dist[-1][-1] ans = white - x if x else -1 print(ans) if __name__ == "__main__": main()
# ABC088D - Grid Repainting import sys input = sys.stdin.readline def bfs() -> None: q = [(0, 0)] while q: x, y = q.pop(0) for dx, dy in dxy: nx, ny = x + dx, y + dy # next x, y if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == "." and dist[nx][ny] == 0: q.append((nx, ny)) dist[nx][ny] = dist[x][y] + 1 def main(): global H, W, S, dist, dxy H, W = tuple(map(int, input().split())) S = tuple(input().rstrip() for _ in range(H)) dist = [[0] * W for _ in range(H)] # distance from (0, 0) to (x, y) dist[0][0] = 1 dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)] bfs() white, x = sum(s.count(".") for s in S), dist[-1][-1] ans = white - x if x else -1 print(ans) if __name__ == "__main__": main()
false
6.25
[ "-from collections import deque" ]
false
0.141063
0.068461
2.060491
[ "s018051520", "s595430878" ]
u708255304
p02713
python
s560730190
s631258914
810
180
83,640
68,468
Accepted
Accepted
77.78
# コードテストする from fractions import gcd K = int(eval(input())) ans = 0 gcd_list = {} for i in range(1, K+1): for j in range(1, K+1): gcd_list[i, j] = gcd(i, j) for i in range(1, K+1): for j in range(1, K+1): hoge = gcd_list[(i, j)] for k in range(1, K+1): ans += gcd_list[(hoge, k)] print(ans)
from math import gcd K = int(eval(input())) ans = 0 for i in range(1, K+1): for j in range(1, K+1): tmp = gcd(i, j) for k in range(1, K+1): ans += gcd(tmp, k) print(ans)
15
9
344
204
# コードテストする from fractions import gcd K = int(eval(input())) ans = 0 gcd_list = {} for i in range(1, K + 1): for j in range(1, K + 1): gcd_list[i, j] = gcd(i, j) for i in range(1, K + 1): for j in range(1, K + 1): hoge = gcd_list[(i, j)] for k in range(1, K + 1): ans += gcd_list[(hoge, k)] print(ans)
from math import gcd K = int(eval(input())) ans = 0 for i in range(1, K + 1): for j in range(1, K + 1): tmp = gcd(i, j) for k in range(1, K + 1): ans += gcd(tmp, k) print(ans)
false
40
[ "-# コードテストする", "-from fractions import gcd", "+from math import gcd", "-gcd_list = {}", "- gcd_list[i, j] = gcd(i, j)", "-for i in range(1, K + 1):", "- for j in range(1, K + 1):", "- hoge = gcd_list[(i, j)]", "+ tmp = gcd(i, j)", "- ans += gcd_list[(hoge, k)]", "+ ans += gcd(tmp, k)" ]
false
0.103188
0.145539
0.709002
[ "s560730190", "s631258914" ]
u609061751
p02744
python
s731491057
s936294842
752
306
72,280
57,564
Accepted
Accepted
59.31
import sys input = sys.stdin.readline n = int(eval(input())) s = ["a"] ord_a = ord("a") ans = [] from copy import deepcopy def dfs(s): if len(s) == n: ans.append("".join(s)) return max_ord = 0 for i in s: max_ord = max(max_ord, ord(i) - ord_a) for j in range(max_ord + 2): new_s = deepcopy(s) new_s.append(chr(j + ord_a)) dfs(new_s) if n == 1: print("a") sys.exit() dfs(s) ans.sort() for i in ans: print(i)
import sys input = sys.stdin.readline n = int(eval(input())) s = ["a"] ord_a = ord("a") ans = [] def dfs(s): if len(s) == n: ans.append("".join(s)) return max_ord = 0 for i in s: max_ord = max(max_ord, ord(i) - ord_a) for j in range(max_ord + 2): new_s = s[:] new_s.append(chr(j + ord_a)) dfs(new_s) if n == 1: print("a") sys.exit() dfs(s) ans.sort() for i in ans: print(i)
32
32
522
490
import sys input = sys.stdin.readline n = int(eval(input())) s = ["a"] ord_a = ord("a") ans = [] from copy import deepcopy def dfs(s): if len(s) == n: ans.append("".join(s)) return max_ord = 0 for i in s: max_ord = max(max_ord, ord(i) - ord_a) for j in range(max_ord + 2): new_s = deepcopy(s) new_s.append(chr(j + ord_a)) dfs(new_s) if n == 1: print("a") sys.exit() dfs(s) ans.sort() for i in ans: print(i)
import sys input = sys.stdin.readline n = int(eval(input())) s = ["a"] ord_a = ord("a") ans = [] def dfs(s): if len(s) == n: ans.append("".join(s)) return max_ord = 0 for i in s: max_ord = max(max_ord, ord(i) - ord_a) for j in range(max_ord + 2): new_s = s[:] new_s.append(chr(j + ord_a)) dfs(new_s) if n == 1: print("a") sys.exit() dfs(s) ans.sort() for i in ans: print(i)
false
0
[ "-from copy import deepcopy", "- new_s = deepcopy(s)", "+ new_s = s[:]" ]
false
0.042832
0.053803
0.796083
[ "s731491057", "s936294842" ]
u638456847
p03557
python
s053325459
s998077670
351
310
29,220
22,592
Accepted
Accepted
11.68
from bisect import bisect_right import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines def main(): N = int(readline()) A = [int(i) for i in readline().split()] B = [int(i) for i in readline().split()] C = [int(i) for i in readline().split()] A.sort() B.sort() C.sort() a_ind = [] b_ind = [] for i in range(N): a_ind.append(bisect_right(B, A[i])) b_ind.append(N - bisect_right(C, B[i])) b_acc = [0] for b in b_ind: b_acc.append(b_acc[-1] + b) sum_b = b_acc[-1] ans = 0 for i in a_ind: ans += sum_b - b_acc[i] print(ans) if __name__ == "__main__": main()
from bisect import bisect_right, bisect_left import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines def main(): N = int(readline()) A = [int(i) for i in readline().split()] B = [int(i) for i in readline().split()] C = [int(i) for i in readline().split()] A.sort() B.sort() C.sort() ans = 0 for b in B: ans += bisect_left(A, b) * (N - bisect_right(C, b)) print(ans) if __name__ == "__main__": main()
38
25
740
521
from bisect import bisect_right import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines def main(): N = int(readline()) A = [int(i) for i in readline().split()] B = [int(i) for i in readline().split()] C = [int(i) for i in readline().split()] A.sort() B.sort() C.sort() a_ind = [] b_ind = [] for i in range(N): a_ind.append(bisect_right(B, A[i])) b_ind.append(N - bisect_right(C, B[i])) b_acc = [0] for b in b_ind: b_acc.append(b_acc[-1] + b) sum_b = b_acc[-1] ans = 0 for i in a_ind: ans += sum_b - b_acc[i] print(ans) if __name__ == "__main__": main()
from bisect import bisect_right, bisect_left import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines def main(): N = int(readline()) A = [int(i) for i in readline().split()] B = [int(i) for i in readline().split()] C = [int(i) for i in readline().split()] A.sort() B.sort() C.sort() ans = 0 for b in B: ans += bisect_left(A, b) * (N - bisect_right(C, b)) print(ans) if __name__ == "__main__": main()
false
34.210526
[ "-from bisect import bisect_right", "+from bisect import bisect_right, bisect_left", "- a_ind = []", "- b_ind = []", "- for i in range(N):", "- a_ind.append(bisect_right(B, A[i]))", "- b_ind.append(N - bisect_right(C, B[i]))", "- b_acc = [0]", "- for b in b_ind:", "- b_acc.append(b_acc[-1] + b)", "- sum_b = b_acc[-1]", "- for i in a_ind:", "- ans += sum_b - b_acc[i]", "+ for b in B:", "+ ans += bisect_left(A, b) * (N - bisect_right(C, b))" ]
false
0.118813
0.043713
2.717999
[ "s053325459", "s998077670" ]
u952708174
p03695
python
s255320619
s176502516
24
21
3,316
3,316
Accepted
Accepted
12.5
def c_ColorfulLeaderboard(N, A): from collections import defaultdict color = defaultdict(int) other = 0 # レート3200以上の選手の数 for a in A: if 1 <= a <= 399: color['gray'] += 1 elif 400 <= a <= 799: color['brown'] += 1 elif 800 <= a <= 1199: color['green'] += 1 elif 1200 <= a <= 1599: color['skyblue'] += 1 elif 1600 <= a <= 1999: color['blue'] += 1 elif 2000 <= a <= 2399: color['yellow'] += 1 elif 2400 <= a <= 2799: color['orange'] += 1 elif 2800 <= a <= 3199: color['red'] += 1 elif 3200 <= a: other += 1 # => 2 2,3 5,1 1 return '{} {}'.format(max(1, len(color)), len(color) + other) N=int(eval(input())) A=[int(i) for i in input().split()] print((c_ColorfulLeaderboard(N, A)))
def c_colorful_leaderboard(N, A): from collections import defaultdict rating_list = defaultdict(int) rating_color = ['gray', 'brown', 'green', 'skyblue', 'blue', 'yellow', 'orange', 'red'] # AtCoderのレート色 other = 0 # レート3200以上の選手の数 for rating in A: r = rating // 400 # レート色は400刻みで変わるため if r >= 8: # レート3200位上 other += 1 else: rating_list[rating_color[r]] += 1 ans = '{} {}'.format(max(1, len(rating_list)), len(rating_list) + other) return ans N=int(eval(input())) A=[int(i) for i in input().split()] print((c_colorful_leaderboard(N, A)))
29
18
901
647
def c_ColorfulLeaderboard(N, A): from collections import defaultdict color = defaultdict(int) other = 0 # レート3200以上の選手の数 for a in A: if 1 <= a <= 399: color["gray"] += 1 elif 400 <= a <= 799: color["brown"] += 1 elif 800 <= a <= 1199: color["green"] += 1 elif 1200 <= a <= 1599: color["skyblue"] += 1 elif 1600 <= a <= 1999: color["blue"] += 1 elif 2000 <= a <= 2399: color["yellow"] += 1 elif 2400 <= a <= 2799: color["orange"] += 1 elif 2800 <= a <= 3199: color["red"] += 1 elif 3200 <= a: other += 1 # => 2 2,3 5,1 1 return "{} {}".format(max(1, len(color)), len(color) + other) N = int(eval(input())) A = [int(i) for i in input().split()] print((c_ColorfulLeaderboard(N, A)))
def c_colorful_leaderboard(N, A): from collections import defaultdict rating_list = defaultdict(int) rating_color = [ "gray", "brown", "green", "skyblue", "blue", "yellow", "orange", "red", ] # AtCoderのレート色 other = 0 # レート3200以上の選手の数 for rating in A: r = rating // 400 # レート色は400刻みで変わるため if r >= 8: # レート3200位上 other += 1 else: rating_list[rating_color[r]] += 1 ans = "{} {}".format(max(1, len(rating_list)), len(rating_list) + other) return ans N = int(eval(input())) A = [int(i) for i in input().split()] print((c_colorful_leaderboard(N, A)))
false
37.931034
[ "-def c_ColorfulLeaderboard(N, A):", "+def c_colorful_leaderboard(N, A):", "- color = defaultdict(int)", "+ rating_list = defaultdict(int)", "+ rating_color = [", "+ \"gray\",", "+ \"brown\",", "+ \"green\",", "+ \"skyblue\",", "+ \"blue\",", "+ \"yellow\",", "+ \"orange\",", "+ \"red\",", "+ ] # AtCoderのレート色", "- for a in A:", "- if 1 <= a <= 399:", "- color[\"gray\"] += 1", "- elif 400 <= a <= 799:", "- color[\"brown\"] += 1", "- elif 800 <= a <= 1199:", "- color[\"green\"] += 1", "- elif 1200 <= a <= 1599:", "- color[\"skyblue\"] += 1", "- elif 1600 <= a <= 1999:", "- color[\"blue\"] += 1", "- elif 2000 <= a <= 2399:", "- color[\"yellow\"] += 1", "- elif 2400 <= a <= 2799:", "- color[\"orange\"] += 1", "- elif 2800 <= a <= 3199:", "- color[\"red\"] += 1", "- elif 3200 <= a:", "+ for rating in A:", "+ r = rating // 400 # レート色は400刻みで変わるため", "+ if r >= 8: # レート3200位上", "- # => 2 2,3 5,1 1", "- return \"{} {}\".format(max(1, len(color)), len(color) + other)", "+ else:", "+ rating_list[rating_color[r]] += 1", "+ ans = \"{} {}\".format(max(1, len(rating_list)), len(rating_list) + other)", "+ return ans", "-print((c_ColorfulLeaderboard(N, A)))", "+print((c_colorful_leaderboard(N, A)))" ]
false
0.034751
0.034517
1.006794
[ "s255320619", "s176502516" ]
u426534722
p02279
python
s207746177
s411509829
790
700
47,640
35,608
Accepted
Accepted
11.39
import sys readline = sys.stdin.readline class Tree: def __init__(self): self.id = 0 self.p = -1 self.depth = -1 self.type = "leaf" self.len_c = 0 self.c = [] def __str__(self): return f"node {self.id}: parent = {self.p}, depth = {self.depth}, {self.type}, {self.c}" n = int(eval(input())) li = [Tree() for _ in range(n)] for _ in range(n): id, k, *c = list(map(int, readline().split())) if k == 0: c = [] else: li[id].type = "internal node" li[id].id = id li[id].c = c for j in c: li[j].p = id root = 0 while True: a = li[root].p if a == -1: li[root].type = "root" li[root].depth = 0 break root = a dp = [(root, 0)] while dp: id, d = dp.pop() for i in li[id].c: li[i].depth = d + 1 dp.append((i, d + 1)) for i in range(n): print((li[i]))
import sys readline = sys.stdin.readline class Tree: __slots__ = ['id', 'p', 'depth', 'type', 'len_c', 'c'] def __init__(self): self.id = 0 self.p = -1 self.depth = -1 self.type = "leaf" self.len_c = 0 self.c = [] def __str__(self): return f"node {self.id}: parent = {self.p}, depth = {self.depth}, {self.type}, {self.c}" n = int(eval(input())) li = [Tree() for _ in range(n)] for _ in range(n): id, k, *c = list(map(int, readline().split())) if k == 0: c = [] else: li[id].type = "internal node" li[id].id = id li[id].c = c for j in c: li[j].p = id root = 0 while True: a = li[root].p if a == -1: li[root].type = "root" li[root].depth = 0 break root = a dp = [(root, 0)] while dp: id, d = dp.pop() for i in li[id].c: li[i].depth = d + 1 dp.append((i, d + 1)) for i in range(n): print((li[i]))
41
42
942
1,002
import sys readline = sys.stdin.readline class Tree: def __init__(self): self.id = 0 self.p = -1 self.depth = -1 self.type = "leaf" self.len_c = 0 self.c = [] def __str__(self): return f"node {self.id}: parent = {self.p}, depth = {self.depth}, {self.type}, {self.c}" n = int(eval(input())) li = [Tree() for _ in range(n)] for _ in range(n): id, k, *c = list(map(int, readline().split())) if k == 0: c = [] else: li[id].type = "internal node" li[id].id = id li[id].c = c for j in c: li[j].p = id root = 0 while True: a = li[root].p if a == -1: li[root].type = "root" li[root].depth = 0 break root = a dp = [(root, 0)] while dp: id, d = dp.pop() for i in li[id].c: li[i].depth = d + 1 dp.append((i, d + 1)) for i in range(n): print((li[i]))
import sys readline = sys.stdin.readline class Tree: __slots__ = ["id", "p", "depth", "type", "len_c", "c"] def __init__(self): self.id = 0 self.p = -1 self.depth = -1 self.type = "leaf" self.len_c = 0 self.c = [] def __str__(self): return f"node {self.id}: parent = {self.p}, depth = {self.depth}, {self.type}, {self.c}" n = int(eval(input())) li = [Tree() for _ in range(n)] for _ in range(n): id, k, *c = list(map(int, readline().split())) if k == 0: c = [] else: li[id].type = "internal node" li[id].id = id li[id].c = c for j in c: li[j].p = id root = 0 while True: a = li[root].p if a == -1: li[root].type = "root" li[root].depth = 0 break root = a dp = [(root, 0)] while dp: id, d = dp.pop() for i in li[id].c: li[i].depth = d + 1 dp.append((i, d + 1)) for i in range(n): print((li[i]))
false
2.380952
[ "+ __slots__ = [\"id\", \"p\", \"depth\", \"type\", \"len_c\", \"c\"]", "+" ]
false
0.046022
0.063582
0.723816
[ "s207746177", "s411509829" ]
u057109575
p02863
python
s967096851
s897049657
484
434
118,616
46,296
Accepted
Accepted
10.33
N, T = list(map(int, input().split())) X = [list(map(int, input().split())) for _ in range(N)] dp = [[0] * (T + 1) for _ in range(N + 1)] for i, (a, b) in enumerate(sorted(X)): for j in range(T + 1): if j == T: dp[i + 1][j] = max(dp[i][j], dp[i][j - 1] + b) elif j < a: dp[i + 1][j] = dp[i][j] else: dp[i + 1][j] = max(dp[i][j], dp[i][j - a] + b) print((dp[-1][-1]))
N, T = list(map(int, input().split())) X = [list(map(int, input().split())) for _ in range(N)] dp = [-1] * 6001 dp[0] = 0 for a, b in sorted(X): for j in reversed(list(range(T))): if dp[j] == -1: continue dp[j + a] = max(dp[j + a], dp[j] + b) print((max(dp)))
14
13
450
305
N, T = list(map(int, input().split())) X = [list(map(int, input().split())) for _ in range(N)] dp = [[0] * (T + 1) for _ in range(N + 1)] for i, (a, b) in enumerate(sorted(X)): for j in range(T + 1): if j == T: dp[i + 1][j] = max(dp[i][j], dp[i][j - 1] + b) elif j < a: dp[i + 1][j] = dp[i][j] else: dp[i + 1][j] = max(dp[i][j], dp[i][j - a] + b) print((dp[-1][-1]))
N, T = list(map(int, input().split())) X = [list(map(int, input().split())) for _ in range(N)] dp = [-1] * 6001 dp[0] = 0 for a, b in sorted(X): for j in reversed(list(range(T))): if dp[j] == -1: continue dp[j + a] = max(dp[j + a], dp[j] + b) print((max(dp)))
false
7.142857
[ "-dp = [[0] * (T + 1) for _ in range(N + 1)]", "-for i, (a, b) in enumerate(sorted(X)):", "- for j in range(T + 1):", "- if j == T:", "- dp[i + 1][j] = max(dp[i][j], dp[i][j - 1] + b)", "- elif j < a:", "- dp[i + 1][j] = dp[i][j]", "- else:", "- dp[i + 1][j] = max(dp[i][j], dp[i][j - a] + b)", "-print((dp[-1][-1]))", "+dp = [-1] * 6001", "+dp[0] = 0", "+for a, b in sorted(X):", "+ for j in reversed(list(range(T))):", "+ if dp[j] == -1:", "+ continue", "+ dp[j + a] = max(dp[j + a], dp[j] + b)", "+print((max(dp)))" ]
false
0.039689
0.039793
0.997385
[ "s967096851", "s897049657" ]
u950708010
p03240
python
s158793988
s481479179
994
424
3,064
3,064
Accepted
Accepted
57.34
import sys input = sys.stdin.readline def solve(): n = int(eval(input())) query = [] candi = [] for i in range(n): x,y,h = (int(i) for i in input().split()) query.append((x,y,h)) if n == 1: print((*[x,y,h])) exit() for cx in range(0,101): for cy in range(0,101): judge = True for j in range(n): x,y,h = query[j] if not h == 0: karih = h +abs(cx-x)+abs(cy-y) karih2 = 0 for i in range(n): nx,ny,nh = query[i] if nh == max(karih-abs(nx-cx)-abs(ny-cy),0): pass else: judge = False if judge: candi.append((cx,cy,karih)) judge = True for i in range(n-1): nx,ny,nh = query[i+1] if nh == max(karih2-abs(nx-cx)-abs(ny-cy),0): pass else: judge = False if judge: candi.append((cx,cy,karih2)) print((*candi[0])) solve()
import sys input = sys.stdin.readline def solve(): n = int(eval(input())) query = [] candi = [] for i in range(n): x,y,h = (int(i) for i in input().split()) query.append((x,y,h)) if n == 1: print((*[x,y,h])) exit() query = sorted(query,reverse = True,key=lambda x: x[2]) for cx in range(0,101): for cy in range(0,101): judge = True x,y,h = query[0] karih = h +abs(cx-x)+abs(cy-y) karih2 = 0 for i in range(n-1): nx,ny,nh = query[i+1] if nh == max(karih-abs(nx-cx)-abs(ny-cy),0): pass else: judge = False if judge: candi.append((cx,cy,karih)) print((*candi[0])) solve()
44
34
1,001
758
import sys input = sys.stdin.readline def solve(): n = int(eval(input())) query = [] candi = [] for i in range(n): x, y, h = (int(i) for i in input().split()) query.append((x, y, h)) if n == 1: print((*[x, y, h])) exit() for cx in range(0, 101): for cy in range(0, 101): judge = True for j in range(n): x, y, h = query[j] if not h == 0: karih = h + abs(cx - x) + abs(cy - y) karih2 = 0 for i in range(n): nx, ny, nh = query[i] if nh == max(karih - abs(nx - cx) - abs(ny - cy), 0): pass else: judge = False if judge: candi.append((cx, cy, karih)) judge = True for i in range(n - 1): nx, ny, nh = query[i + 1] if nh == max(karih2 - abs(nx - cx) - abs(ny - cy), 0): pass else: judge = False if judge: candi.append((cx, cy, karih2)) print((*candi[0])) solve()
import sys input = sys.stdin.readline def solve(): n = int(eval(input())) query = [] candi = [] for i in range(n): x, y, h = (int(i) for i in input().split()) query.append((x, y, h)) if n == 1: print((*[x, y, h])) exit() query = sorted(query, reverse=True, key=lambda x: x[2]) for cx in range(0, 101): for cy in range(0, 101): judge = True x, y, h = query[0] karih = h + abs(cx - x) + abs(cy - y) karih2 = 0 for i in range(n - 1): nx, ny, nh = query[i + 1] if nh == max(karih - abs(nx - cx) - abs(ny - cy), 0): pass else: judge = False if judge: candi.append((cx, cy, karih)) print((*candi[0])) solve()
false
22.727273
[ "+ query = sorted(query, reverse=True, key=lambda x: x[2])", "- for j in range(n):", "- x, y, h = query[j]", "- if not h == 0:", "- karih = h + abs(cx - x) + abs(cy - y)", "- karih2 = 0", "- for i in range(n):", "- nx, ny, nh = query[i]", "+ x, y, h = query[0]", "+ karih = h + abs(cx - x) + abs(cy - y)", "+ karih2 = 0", "+ for i in range(n - 1):", "+ nx, ny, nh = query[i + 1]", "- judge = True", "- for i in range(n - 1):", "- nx, ny, nh = query[i + 1]", "- if nh == max(karih2 - abs(nx - cx) - abs(ny - cy), 0):", "- pass", "- else:", "- judge = False", "- if judge:", "- candi.append((cx, cy, karih2))" ]
false
0.088424
0.054908
1.610414
[ "s158793988", "s481479179" ]
u086566114
p02412
python
s071960398
s207290532
180
100
6,428
6,420
Accepted
Accepted
44.44
def get_num(n, x): ans = 0 for n3 in range(min(n, x), (x + 2) / 3, -1): for n2 in range(n3 - 1, (x - n3 + 1) / 2 - 1, -1): for n1 in range(n2 - 1, 0, -1): s = n1 + n2 + n3 if s < x: break elif s == x: ans += 1 break return ans while True: [n, x] = [int(m) for m in input().split()] if [n, x] == [0, 0]: break if x == 0: print((0)) else: print((get_num(n, x)))
def get_num(n, x): ans = 0 for n3 in range(min(n, x), (x + 2) / 3, -1): for n2 in range(n3 - 1, (x - n3 + 1) / 2 - 1, -1): for n1 in range(n2 - 1, 0, -1): if n1 + n2 + n3 == x: ans += 1 break return ans while True: [n, x] = [int(m) for m in input().split()] if [n, x] == [0, 0]: break if x == 0: print((0)) else: print((get_num(n, x)))
22
19
562
483
def get_num(n, x): ans = 0 for n3 in range(min(n, x), (x + 2) / 3, -1): for n2 in range(n3 - 1, (x - n3 + 1) / 2 - 1, -1): for n1 in range(n2 - 1, 0, -1): s = n1 + n2 + n3 if s < x: break elif s == x: ans += 1 break return ans while True: [n, x] = [int(m) for m in input().split()] if [n, x] == [0, 0]: break if x == 0: print((0)) else: print((get_num(n, x)))
def get_num(n, x): ans = 0 for n3 in range(min(n, x), (x + 2) / 3, -1): for n2 in range(n3 - 1, (x - n3 + 1) / 2 - 1, -1): for n1 in range(n2 - 1, 0, -1): if n1 + n2 + n3 == x: ans += 1 break return ans while True: [n, x] = [int(m) for m in input().split()] if [n, x] == [0, 0]: break if x == 0: print((0)) else: print((get_num(n, x)))
false
13.636364
[ "- s = n1 + n2 + n3", "- if s < x:", "- break", "- elif s == x:", "+ if n1 + n2 + n3 == x:" ]
false
0.036684
0.035382
1.036795
[ "s071960398", "s207290532" ]
u576432509
p02959
python
s530482459
s572771334
198
169
19,372
18,476
Accepted
Accepted
14.65
n=int(eval(input())) ai=[] for i in map(int,input().split()): ai.append(i) bi=[] for i in map(int,input().split()): bi.append(i) asum=0 for i in range(n+1): asum=asum+ai[i] i=0 if ai[i]<=bi[i]: bi[i]=bi[i]-ai[i] ai[i]=0 else : ai[i]=ai[i]-bi[i] bi[i]=0 for i in range(1,n,1): if ai[i]<=bi[i-1]: bi[i-1]=bi[i-1]-ai[i] ai[i]=0 else : ai[i]=ai[i]-bi[i-1] bi[i-1]=0 if ai[i]<=bi[i]: bi[i]=bi[i]-ai[i] ai[i]=0 else : ai[i]=ai[i]-bi[i] bi[i]=0 i=n if ai[i]<=bi[i-1]: bi[i-1]=bi[i-1]-ai[i] ai[i]=0 else : ai[i]=ai[i]-bi[i-1] bi[i-1]=0 asum2=0 for i in range(n+1): asum2=asum2+ai[i] print((asum-asum2))
n=int(eval(input())) a=list(map(int,input().split())) b=list(map(int,input().split())) fii=min(a[0],b[0]) fij=min(a[1],b[0]-fii) icnt=fii+fij for i in range(1,n): fii=min(a[i]-fij,b[i]) fij=min(a[i+1],b[i]-fii) icnt+=fij+fii print(icnt)
45
14
778
259
n = int(eval(input())) ai = [] for i in map(int, input().split()): ai.append(i) bi = [] for i in map(int, input().split()): bi.append(i) asum = 0 for i in range(n + 1): asum = asum + ai[i] i = 0 if ai[i] <= bi[i]: bi[i] = bi[i] - ai[i] ai[i] = 0 else: ai[i] = ai[i] - bi[i] bi[i] = 0 for i in range(1, n, 1): if ai[i] <= bi[i - 1]: bi[i - 1] = bi[i - 1] - ai[i] ai[i] = 0 else: ai[i] = ai[i] - bi[i - 1] bi[i - 1] = 0 if ai[i] <= bi[i]: bi[i] = bi[i] - ai[i] ai[i] = 0 else: ai[i] = ai[i] - bi[i] bi[i] = 0 i = n if ai[i] <= bi[i - 1]: bi[i - 1] = bi[i - 1] - ai[i] ai[i] = 0 else: ai[i] = ai[i] - bi[i - 1] bi[i - 1] = 0 asum2 = 0 for i in range(n + 1): asum2 = asum2 + ai[i] print((asum - asum2))
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) fii = min(a[0], b[0]) fij = min(a[1], b[0] - fii) icnt = fii + fij for i in range(1, n): fii = min(a[i] - fij, b[i]) fij = min(a[i + 1], b[i] - fii) icnt += fij + fii print(icnt)
false
68.888889
[ "-ai = []", "-for i in map(int, input().split()):", "- ai.append(i)", "-bi = []", "-for i in map(int, input().split()):", "- bi.append(i)", "-asum = 0", "-for i in range(n + 1):", "- asum = asum + ai[i]", "-i = 0", "-if ai[i] <= bi[i]:", "- bi[i] = bi[i] - ai[i]", "- ai[i] = 0", "-else:", "- ai[i] = ai[i] - bi[i]", "- bi[i] = 0", "-for i in range(1, n, 1):", "- if ai[i] <= bi[i - 1]:", "- bi[i - 1] = bi[i - 1] - ai[i]", "- ai[i] = 0", "- else:", "- ai[i] = ai[i] - bi[i - 1]", "- bi[i - 1] = 0", "- if ai[i] <= bi[i]:", "- bi[i] = bi[i] - ai[i]", "- ai[i] = 0", "- else:", "- ai[i] = ai[i] - bi[i]", "- bi[i] = 0", "-i = n", "-if ai[i] <= bi[i - 1]:", "- bi[i - 1] = bi[i - 1] - ai[i]", "- ai[i] = 0", "-else:", "- ai[i] = ai[i] - bi[i - 1]", "- bi[i - 1] = 0", "-asum2 = 0", "-for i in range(n + 1):", "- asum2 = asum2 + ai[i]", "-print((asum - asum2))", "+a = list(map(int, input().split()))", "+b = list(map(int, input().split()))", "+fii = min(a[0], b[0])", "+fij = min(a[1], b[0] - fii)", "+icnt = fii + fij", "+for i in range(1, n):", "+ fii = min(a[i] - fij, b[i])", "+ fij = min(a[i + 1], b[i] - fii)", "+ icnt += fij + fii", "+print(icnt)" ]
false
0.041195
0.063451
0.649239
[ "s530482459", "s572771334" ]
u078042885
p01867
python
s219053407
s685789795
30
20
7,564
7,560
Accepted
Accepted
33.33
eval(input()) s=input().split('+') t=[s.count(x) for x in set(s)] a=sum(min(3*t.count(x),t.count(x)+4) for x in set(t) if x!=1)+len(t)-1+t.count(1) print(a)
eval(input()) s=input().split('+') t=[s.count(x) for x in set(s)] print((sum(min(3*t.count(x),t.count(x)+4) for x in set(t) if x!=1)+len(t)-1+t.count(1)))
5
4
154
149
eval(input()) s = input().split("+") t = [s.count(x) for x in set(s)] a = ( sum(min(3 * t.count(x), t.count(x) + 4) for x in set(t) if x != 1) + len(t) - 1 + t.count(1) ) print(a)
eval(input()) s = input().split("+") t = [s.count(x) for x in set(s)] print( ( sum(min(3 * t.count(x), t.count(x) + 4) for x in set(t) if x != 1) + len(t) - 1 + t.count(1) ) )
false
20
[ "-a = (", "- sum(min(3 * t.count(x), t.count(x) + 4) for x in set(t) if x != 1)", "- + len(t)", "- - 1", "- + t.count(1)", "+print(", "+ (", "+ sum(min(3 * t.count(x), t.count(x) + 4) for x in set(t) if x != 1)", "+ + len(t)", "+ - 1", "+ + t.count(1)", "+ )", "-print(a)" ]
false
0.033813
0.035422
0.954586
[ "s219053407", "s685789795" ]
u038021590
p03030
python
s221001184
s231627634
170
17
38,512
3,060
Accepted
Accepted
90
N = int(eval(input())) Book = [0] * N for i in range(N): s,q = input().split() p = int(q) Book[i] = (s, 100-p, i) Book.sort() for i in range(N): print((Book[i][2]+1))
N = int(eval(input())) L = [] for _ in range(N): s, p = input().split() p = int(p) L.append((s, 100 - p, _)) L.sort() for _ in range(N): print((L[_][2]+1))
13
11
191
176
N = int(eval(input())) Book = [0] * N for i in range(N): s, q = input().split() p = int(q) Book[i] = (s, 100 - p, i) Book.sort() for i in range(N): print((Book[i][2] + 1))
N = int(eval(input())) L = [] for _ in range(N): s, p = input().split() p = int(p) L.append((s, 100 - p, _)) L.sort() for _ in range(N): print((L[_][2] + 1))
false
15.384615
[ "-Book = [0] * N", "-for i in range(N):", "- s, q = input().split()", "- p = int(q)", "- Book[i] = (s, 100 - p, i)", "-Book.sort()", "-for i in range(N):", "- print((Book[i][2] + 1))", "+L = []", "+for _ in range(N):", "+ s, p = input().split()", "+ p = int(p)", "+ L.append((s, 100 - p, _))", "+L.sort()", "+for _ in range(N):", "+ print((L[_][2] + 1))" ]
false
0.121602
0.042111
2.887678
[ "s221001184", "s231627634" ]
u230621983
p02923
python
s663980892
s758645370
91
81
14,252
20,204
Accepted
Accepted
10.99
n = int(eval(input())) hs = list(map(int, input().split())) temp = 0 cnt = 0 for i in range(n-1): if hs[i] >= hs[i+1]: temp += 1 cnt = max(cnt, temp) else: temp = 0 print(cnt)
n, *h = list(map(int, open(0).read().split())) left = h[0] ans = 0 cnt = 0 for i in range(1,n): if left >= h[i]: cnt += 1 else: ans = max(ans, cnt) cnt = 0 left = h[i] print((max(ans, cnt)))
13
12
199
229
n = int(eval(input())) hs = list(map(int, input().split())) temp = 0 cnt = 0 for i in range(n - 1): if hs[i] >= hs[i + 1]: temp += 1 cnt = max(cnt, temp) else: temp = 0 print(cnt)
n, *h = list(map(int, open(0).read().split())) left = h[0] ans = 0 cnt = 0 for i in range(1, n): if left >= h[i]: cnt += 1 else: ans = max(ans, cnt) cnt = 0 left = h[i] print((max(ans, cnt)))
false
7.692308
[ "-n = int(eval(input()))", "-hs = list(map(int, input().split()))", "-temp = 0", "+n, *h = list(map(int, open(0).read().split()))", "+left = h[0]", "+ans = 0", "-for i in range(n - 1):", "- if hs[i] >= hs[i + 1]:", "- temp += 1", "- cnt = max(cnt, temp)", "+for i in range(1, n):", "+ if left >= h[i]:", "+ cnt += 1", "- temp = 0", "-print(cnt)", "+ ans = max(ans, cnt)", "+ cnt = 0", "+ left = h[i]", "+print((max(ans, cnt)))" ]
false
0.038853
0.040845
0.95122
[ "s663980892", "s758645370" ]
u729133443
p03600
python
s215707089
s379387566
1,119
973
18,624
18,628
Accepted
Accepted
13.05
import scipy.sparse as s,numpy as n f=n.loadtxt(open(0),skiprows=1) g=s.csgraph.dijkstra(f) h=n.where(g,g,1) print((int(sum(t[j]*(t[j]<t+h[j]).all()for i,t in enumerate(h)for j in range(i)))*(f==g).all()or-1))
import scipy.sparse as s,numpy as n f=n.loadtxt(open(0),skiprows=1) g=s.csgraph.dijkstra(f) h=n.where(g,g,1) print((int(sum(t[j]*all(t[j]<t+h[j])for i,t in enumerate(h)for j in range(i)))*(f==g).all()or-1))
5
5
211
208
import scipy.sparse as s, numpy as n f = n.loadtxt(open(0), skiprows=1) g = s.csgraph.dijkstra(f) h = n.where(g, g, 1) print( ( int( sum( t[j] * (t[j] < t + h[j]).all() for i, t in enumerate(h) for j in range(i) ) ) * (f == g).all() or -1 ) )
import scipy.sparse as s, numpy as n f = n.loadtxt(open(0), skiprows=1) g = s.csgraph.dijkstra(f) h = n.where(g, g, 1) print( ( int(sum(t[j] * all(t[j] < t + h[j]) for i, t in enumerate(h) for j in range(i))) * (f == g).all() or -1 ) )
false
0
[ "- int(", "- sum(", "- t[j] * (t[j] < t + h[j]).all()", "- for i, t in enumerate(h)", "- for j in range(i)", "- )", "- )", "+ int(sum(t[j] * all(t[j] < t + h[j]) for i, t in enumerate(h) for j in range(i)))" ]
false
0.337
0.341311
0.987368
[ "s215707089", "s379387566" ]
u980205854
p03147
python
s197300800
s353431306
370
71
80,308
66,628
Accepted
Accepted
80.81
N = int(eval(input())) h = list(map(int,input().split())) a = [0]*N ans = 0 for i in range(N): while a[i]<h[i]: ans += 1 for j in range(i,N): if a[j]==h[j]: break a[j] += 1 print(ans)
import sys from sys import exit from collections import deque from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値) from heapq import heapify, heappop, heappush from math import * sys.setrecursionlimit(10**6) INF = 10**20 eps = 1.0e-20 MOD = 10**9+7 def lcm(x,y): return x*y//gcd(x,y) def mint(): return map(int,input().split()) def lint(): return list(map(int,input().split())) def ilint(): return int(input()), list(map(int,input().split())) def judge(x, l=['Yes', 'No']): print(l[0] if x else l[1]) def lprint(l, sep='\n'): for x in l: print(x, end=sep) N,H = ilint() H = [0]+H[:] H = [-(H[i+1]-H[i]) for i in range(N)]+[INF] ans = 0 for l in range(N): while H[l]<0: r = 0 while r<N and H[r]<=0: r += 1 tmp = min(-H[l],H[r]) ans += tmp H[l] += tmp H[r] -= tmp print(ans)
12
40
218
942
N = int(eval(input())) h = list(map(int, input().split())) a = [0] * N ans = 0 for i in range(N): while a[i] < h[i]: ans += 1 for j in range(i, N): if a[j] == h[j]: break a[j] += 1 print(ans)
import sys from sys import exit from collections import deque from bisect import bisect_left, bisect_right, insort_left, insort_right # func(リスト,値) from heapq import heapify, heappop, heappush from math import * sys.setrecursionlimit(10**6) INF = 10**20 eps = 1.0e-20 MOD = 10**9 + 7 def lcm(x, y): return x * y // gcd(x, y) def mint(): return map(int, input().split()) def lint(): return list(map(int, input().split())) def ilint(): return int(input()), list(map(int, input().split())) def judge(x, l=["Yes", "No"]): print(l[0] if x else l[1]) def lprint(l, sep="\n"): for x in l: print(x, end=sep) N, H = ilint() H = [0] + H[:] H = [-(H[i + 1] - H[i]) for i in range(N)] + [INF] ans = 0 for l in range(N): while H[l] < 0: r = 0 while r < N and H[r] <= 0: r += 1 tmp = min(-H[l], H[r]) ans += tmp H[l] += tmp H[r] -= tmp print(ans)
false
70
[ "-N = int(eval(input()))", "-h = list(map(int, input().split()))", "-a = [0] * N", "+import sys", "+from sys import exit", "+from collections import deque", "+from bisect import bisect_left, bisect_right, insort_left, insort_right # func(リスト,値)", "+from heapq import heapify, heappop, heappush", "+from math import *", "+", "+sys.setrecursionlimit(10**6)", "+INF = 10**20", "+eps = 1.0e-20", "+MOD = 10**9 + 7", "+", "+", "+def lcm(x, y):", "+ return x * y // gcd(x, y)", "+", "+", "+def mint():", "+ return map(int, input().split())", "+", "+", "+def lint():", "+ return list(map(int, input().split()))", "+", "+", "+def ilint():", "+ return int(input()), list(map(int, input().split()))", "+", "+", "+def judge(x, l=[\"Yes\", \"No\"]):", "+ print(l[0] if x else l[1])", "+", "+", "+def lprint(l, sep=\"\\n\"):", "+ for x in l:", "+ print(x, end=sep)", "+", "+", "+N, H = ilint()", "+H = [0] + H[:]", "+H = [-(H[i + 1] - H[i]) for i in range(N)] + [INF]", "-for i in range(N):", "- while a[i] < h[i]:", "- ans += 1", "- for j in range(i, N):", "- if a[j] == h[j]:", "- break", "- a[j] += 1", "+for l in range(N):", "+ while H[l] < 0:", "+ r = 0", "+ while r < N and H[r] <= 0:", "+ r += 1", "+ tmp = min(-H[l], H[r])", "+ ans += tmp", "+ H[l] += tmp", "+ H[r] -= tmp" ]
false
0.153867
0.068958
2.231324
[ "s197300800", "s353431306" ]
u939026953
p04031
python
s537423279
s400305531
26
24
3,060
3,060
Accepted
Accepted
7.69
ans = 10 ** 9 n = int(eval(input())) A = list(map(int,input().split())) for i in range(-100,101): X = 0 for j in range(n): X += (A[j] - i) ** 2 ans = min(ans,X) print(ans)
ans = 10 ** 9 n = int(eval(input())) A = list(map(int,input().split())) for i in range(-100,101): X = 0 for j in A: X += (j - i) ** 2 ans = min(ans,X) print(ans)
9
9
183
173
ans = 10**9 n = int(eval(input())) A = list(map(int, input().split())) for i in range(-100, 101): X = 0 for j in range(n): X += (A[j] - i) ** 2 ans = min(ans, X) print(ans)
ans = 10**9 n = int(eval(input())) A = list(map(int, input().split())) for i in range(-100, 101): X = 0 for j in A: X += (j - i) ** 2 ans = min(ans, X) print(ans)
false
0
[ "- for j in range(n):", "- X += (A[j] - i) ** 2", "+ for j in A:", "+ X += (j - i) ** 2" ]
false
0.113717
0.008292
13.714715
[ "s537423279", "s400305531" ]
u128859393
p03449
python
s323043316
s052804598
150
17
12,484
3,060
Accepted
Accepted
88.67
import numpy as np N = int(eval(input())) cnt1 = np.cumsum(list(map(int, input().split()))) cnt2 = list(map(int, input().split())) cnt2 = cnt2[::-1] cnt2 = np.cumsum(cnt2) cnt2 = cnt2[::-1] max_candies = 0 for i in range(N): if max_candies <= cnt1[i] + cnt2[i]: max_candies = cnt1[i] + cnt2[i] print(max_candies)
N = int(eval(input())) cnt1 = list(map(int, input().split())) cnt2 = list(map(int, input().split())) max_candies = 0 for i in range(N): temp = sum(cnt1[:i + 1]) + sum(cnt2[i:]) max_candies = max(temp, max_candies) print(max_candies)
17
11
340
250
import numpy as np N = int(eval(input())) cnt1 = np.cumsum(list(map(int, input().split()))) cnt2 = list(map(int, input().split())) cnt2 = cnt2[::-1] cnt2 = np.cumsum(cnt2) cnt2 = cnt2[::-1] max_candies = 0 for i in range(N): if max_candies <= cnt1[i] + cnt2[i]: max_candies = cnt1[i] + cnt2[i] print(max_candies)
N = int(eval(input())) cnt1 = list(map(int, input().split())) cnt2 = list(map(int, input().split())) max_candies = 0 for i in range(N): temp = sum(cnt1[: i + 1]) + sum(cnt2[i:]) max_candies = max(temp, max_candies) print(max_candies)
false
35.294118
[ "-import numpy as np", "-", "-cnt1 = np.cumsum(list(map(int, input().split())))", "+cnt1 = list(map(int, input().split()))", "-cnt2 = cnt2[::-1]", "-cnt2 = np.cumsum(cnt2)", "-cnt2 = cnt2[::-1]", "- if max_candies <= cnt1[i] + cnt2[i]:", "- max_candies = cnt1[i] + cnt2[i]", "+ temp = sum(cnt1[: i + 1]) + sum(cnt2[i:])", "+ max_candies = max(temp, max_candies)" ]
false
0.220772
0.038149
5.787068
[ "s323043316", "s052804598" ]
u502389123
p03565
python
s507106120
s740008305
19
17
3,064
3,064
Accepted
Accepted
10.53
S = eval(input()) T = eval(input()) index = [] ss = [] flag = False for i in range(len(S)-len(T)+1): for j in range(len(T)): if S[i+j] != T[j] and S[i+j] != '?': break if j == len(T) - 1: flag = True index.append(i) if flag: for v in index: s = '' k = 0 for i in range(len(S)): if v <= i <= v + len(T) - 1: s += T[k] k += 1 continue if S[i] == '?': s += 'a' else: s += S[i] ss.append(s) ss.sort() s = ss[0] else: s = 'UNRESTORABLE' print(s)
S = eval(input()) T = eval(input()) flag = False for i in range(len(S)-len(T)+1): for j in range(len(T)): if S[i+j] != T[j] and S[i+j] != '?': break if j == len(T) - 1: flag = True index = i if flag: s = '' k = 0 for i in range(len(S)): if index <= i <= index + len(T) - 1: s += T[k] k += 1 continue if S[i] == '?': s += 'a' else: s += S[i] else: s = 'UNRESTORABLE' print(s)
35
28
687
549
S = eval(input()) T = eval(input()) index = [] ss = [] flag = False for i in range(len(S) - len(T) + 1): for j in range(len(T)): if S[i + j] != T[j] and S[i + j] != "?": break if j == len(T) - 1: flag = True index.append(i) if flag: for v in index: s = "" k = 0 for i in range(len(S)): if v <= i <= v + len(T) - 1: s += T[k] k += 1 continue if S[i] == "?": s += "a" else: s += S[i] ss.append(s) ss.sort() s = ss[0] else: s = "UNRESTORABLE" print(s)
S = eval(input()) T = eval(input()) flag = False for i in range(len(S) - len(T) + 1): for j in range(len(T)): if S[i + j] != T[j] and S[i + j] != "?": break if j == len(T) - 1: flag = True index = i if flag: s = "" k = 0 for i in range(len(S)): if index <= i <= index + len(T) - 1: s += T[k] k += 1 continue if S[i] == "?": s += "a" else: s += S[i] else: s = "UNRESTORABLE" print(s)
false
20
[ "-index = []", "-ss = []", "- index.append(i)", "+ index = i", "- for v in index:", "- s = \"\"", "- k = 0", "- for i in range(len(S)):", "- if v <= i <= v + len(T) - 1:", "- s += T[k]", "- k += 1", "- continue", "- if S[i] == \"?\":", "- s += \"a\"", "- else:", "- s += S[i]", "- ss.append(s)", "- ss.sort()", "- s = ss[0]", "+ s = \"\"", "+ k = 0", "+ for i in range(len(S)):", "+ if index <= i <= index + len(T) - 1:", "+ s += T[k]", "+ k += 1", "+ continue", "+ if S[i] == \"?\":", "+ s += \"a\"", "+ else:", "+ s += S[i]" ]
false
0.051076
0.045292
1.12772
[ "s507106120", "s740008305" ]
u784022244
p03262
python
s604190905
s478733475
286
117
23,120
16,280
Accepted
Accepted
59.09
import numpy as np N,X=list(map(int, input().split())) A=np.array(list(map(int, input().split()))) B=A-X if N==1: print((abs(B[0]))) exit() from fractions import gcd GCD=gcd(abs(B[0]),abs(B[1])) #print(B) if N>2: for i in range(2,N): GCD=gcd(GCD, abs(B[i])) print(GCD)
from fractions import gcd N,X=list(map(int, input().split())) x=list(map(int, input().split())) L=[0]*N for i in range(N): L[i]=abs(x[i]-X) g=L[0] for i in range(1,N): g=gcd(g,L[i]) print(g)
19
12
300
205
import numpy as np N, X = list(map(int, input().split())) A = np.array(list(map(int, input().split()))) B = A - X if N == 1: print((abs(B[0]))) exit() from fractions import gcd GCD = gcd(abs(B[0]), abs(B[1])) # print(B) if N > 2: for i in range(2, N): GCD = gcd(GCD, abs(B[i])) print(GCD)
from fractions import gcd N, X = list(map(int, input().split())) x = list(map(int, input().split())) L = [0] * N for i in range(N): L[i] = abs(x[i] - X) g = L[0] for i in range(1, N): g = gcd(g, L[i]) print(g)
false
36.842105
[ "-import numpy as np", "+from fractions import gcd", "-A = np.array(list(map(int, input().split())))", "-B = A - X", "-if N == 1:", "- print((abs(B[0])))", "- exit()", "-from fractions import gcd", "-", "-GCD = gcd(abs(B[0]), abs(B[1]))", "-# print(B)", "-if N > 2:", "- for i in range(2, N):", "- GCD = gcd(GCD, abs(B[i]))", "-print(GCD)", "+x = list(map(int, input().split()))", "+L = [0] * N", "+for i in range(N):", "+ L[i] = abs(x[i] - X)", "+g = L[0]", "+for i in range(1, N):", "+ g = gcd(g, L[i])", "+print(g)" ]
false
0.338876
0.048921
6.927028
[ "s604190905", "s478733475" ]
u347640436
p03201
python
s902514282
s009710859
446
403
44,560
44,560
Accepted
Accepted
9.64
from bisect import bisect_right n = int(eval(input())) d = {} for a in map(int, input().split()): if a in d: d[a] += 1 else: d[a] = 1 alist = list(sorted(list(d.keys()), reverse = True)) amax = alist[0] t = 1 power_of_two = [] while t < 2 * amax: t *= 2 power_of_two.append(t) result = 0 for a in alist: if a not in d or d[a] == 0: continue t = power_of_two[bisect_right(power_of_two, a)] - a while True: if t not in d or d[t] == 0: break if a != t: i = min(d[a], d[t]) else: i = d[a] // 2 if i == 0: break result += i d[a] -= i d[t] -= i if a not in d or d[a] == 0: break print(result)
from bisect import bisect_right n = int(eval(input())) d = {} for a in map(int, input().split()): if a in d: d[a] += 1 else: d[a] = 1 alist = list(sorted(list(d.keys()), reverse = True)) amax = alist[0] t = 1 power_of_two = [] while t < 2 * amax: t *= 2 power_of_two.append(t) result = 0 for a in alist: if d[a] == 0: continue t = power_of_two[bisect_right(power_of_two, a)] - a while True: if t not in d or d[t] == 0: break if a != t: i = min(d[a], d[t]) else: i = d[a] // 2 if i == 0: break result += i d[a] -= i d[t] -= i if d[a] == 0: break print(result)
35
35
697
669
from bisect import bisect_right n = int(eval(input())) d = {} for a in map(int, input().split()): if a in d: d[a] += 1 else: d[a] = 1 alist = list(sorted(list(d.keys()), reverse=True)) amax = alist[0] t = 1 power_of_two = [] while t < 2 * amax: t *= 2 power_of_two.append(t) result = 0 for a in alist: if a not in d or d[a] == 0: continue t = power_of_two[bisect_right(power_of_two, a)] - a while True: if t not in d or d[t] == 0: break if a != t: i = min(d[a], d[t]) else: i = d[a] // 2 if i == 0: break result += i d[a] -= i d[t] -= i if a not in d or d[a] == 0: break print(result)
from bisect import bisect_right n = int(eval(input())) d = {} for a in map(int, input().split()): if a in d: d[a] += 1 else: d[a] = 1 alist = list(sorted(list(d.keys()), reverse=True)) amax = alist[0] t = 1 power_of_two = [] while t < 2 * amax: t *= 2 power_of_two.append(t) result = 0 for a in alist: if d[a] == 0: continue t = power_of_two[bisect_right(power_of_two, a)] - a while True: if t not in d or d[t] == 0: break if a != t: i = min(d[a], d[t]) else: i = d[a] // 2 if i == 0: break result += i d[a] -= i d[t] -= i if d[a] == 0: break print(result)
false
0
[ "- if a not in d or d[a] == 0:", "+ if d[a] == 0:", "- if a not in d or d[a] == 0:", "+ if d[a] == 0:" ]
false
0.041471
0.038013
1.090959
[ "s902514282", "s009710859" ]
u334712262
p03366
python
s184229194
s237526534
1,975
481
32,612
34,064
Accepted
Accepted
75.65
from collections import Counter, defaultdict import math from decimal import Decimal, ROUND_HALF_UP, ROUND_CEILING from functools import lru_cache, reduce from itertools import combinations_with_replacement, product, combinations def read_int(): return int(input()) def read_int_n(): return list(map(int, input().split())) def read_str(): return input() def read_str_n(): return list(map(str, input().split())) def mt(f): import time import sys def wrap(*args, **kwargs): s = time.time() ret = f(*args, **kwargs) e = time.time() print(e - s, 'sec', file=sys.stderr) return ret return wrap @mt def slv(S, X, P): X_ = [[P[i], [x]] for i, x in enumerate(X)] while len(X_) != 1: if X_[0][0] >= X_[-1][0]: di = -1 li = 0 else: di = 0 li = -1 X_[li][0] += X_[di][0] X_[li][1] += X_[di][1] X_.pop(di) t = 0 pos = S p0 = S p1 = S for o in X_[0][1]: if p0 < o < p1: continue t += abs(pos - o) if o < pos: p0 = o else: p1 = o pos = o return t def main(): N, S = read_int_n() X = [] P = [] for _ in range(N): x, p = read_int_n() X.append(x) P.append(p) print(slv(S, X, P)) if __name__ == '__main__': main()
from collections import Counter, defaultdict import math import random from decimal import Decimal, ROUND_HALF_UP, ROUND_CEILING from functools import lru_cache, reduce from itertools import combinations_with_replacement, product, combinations def read_int(): return int(input()) def read_int_n(): return list(map(int, input().split())) def read_str(): return input() def read_str_n(): return list(map(str, input().split())) def mt(f): import time import sys def wrap(*args, **kwargs): s = time.time() ret = f(*args, **kwargs) e = time.time() print(e - s, 'sec', file=sys.stderr) return ret return wrap @mt def slv(S, X, P): X_ = [[P[i], [x]] for i, x in enumerate(X)] i = 0 j = len(X_) - 1 # while len(X_) != 1: while i < j: if X_[i][0] >= X_[j][0]: X_[i][0] += X_[j][0] X_[i][1] += X_[j][1] j -= 1 else: X_[j][0] += X_[i][0] X_[j][1] += X_[i][1] i += 1 t = 0 pos = S p0 = S p1 = S for o in X_[i][1]: if p0 < o < p1: continue t += abs(pos - o) if o < pos: p0 = o else: p1 = o pos = o return t def main(): N, S = read_int_n() X = [] P = [] for _ in range(N): x, p = read_int_n() X.append(x) P.append(p) # import random # N = 100000 # S = N / 2 # X = [x + 1 for x in range(N)] # P = [random.randint(1, 1000000000) for _ in range(N)] print(slv(S, X, P)) if __name__ == '__main__': main()
85
95
1,519
1,753
from collections import Counter, defaultdict import math from decimal import Decimal, ROUND_HALF_UP, ROUND_CEILING from functools import lru_cache, reduce from itertools import combinations_with_replacement, product, combinations def read_int(): return int(input()) def read_int_n(): return list(map(int, input().split())) def read_str(): return input() def read_str_n(): return list(map(str, input().split())) def mt(f): import time import sys def wrap(*args, **kwargs): s = time.time() ret = f(*args, **kwargs) e = time.time() print(e - s, "sec", file=sys.stderr) return ret return wrap @mt def slv(S, X, P): X_ = [[P[i], [x]] for i, x in enumerate(X)] while len(X_) != 1: if X_[0][0] >= X_[-1][0]: di = -1 li = 0 else: di = 0 li = -1 X_[li][0] += X_[di][0] X_[li][1] += X_[di][1] X_.pop(di) t = 0 pos = S p0 = S p1 = S for o in X_[0][1]: if p0 < o < p1: continue t += abs(pos - o) if o < pos: p0 = o else: p1 = o pos = o return t def main(): N, S = read_int_n() X = [] P = [] for _ in range(N): x, p = read_int_n() X.append(x) P.append(p) print(slv(S, X, P)) if __name__ == "__main__": main()
from collections import Counter, defaultdict import math import random from decimal import Decimal, ROUND_HALF_UP, ROUND_CEILING from functools import lru_cache, reduce from itertools import combinations_with_replacement, product, combinations def read_int(): return int(input()) def read_int_n(): return list(map(int, input().split())) def read_str(): return input() def read_str_n(): return list(map(str, input().split())) def mt(f): import time import sys def wrap(*args, **kwargs): s = time.time() ret = f(*args, **kwargs) e = time.time() print(e - s, "sec", file=sys.stderr) return ret return wrap @mt def slv(S, X, P): X_ = [[P[i], [x]] for i, x in enumerate(X)] i = 0 j = len(X_) - 1 # while len(X_) != 1: while i < j: if X_[i][0] >= X_[j][0]: X_[i][0] += X_[j][0] X_[i][1] += X_[j][1] j -= 1 else: X_[j][0] += X_[i][0] X_[j][1] += X_[i][1] i += 1 t = 0 pos = S p0 = S p1 = S for o in X_[i][1]: if p0 < o < p1: continue t += abs(pos - o) if o < pos: p0 = o else: p1 = o pos = o return t def main(): N, S = read_int_n() X = [] P = [] for _ in range(N): x, p = read_int_n() X.append(x) P.append(p) # import random # N = 100000 # S = N / 2 # X = [x + 1 for x in range(N)] # P = [random.randint(1, 1000000000) for _ in range(N)] print(slv(S, X, P)) if __name__ == "__main__": main()
false
10.526316
[ "+import random", "- while len(X_) != 1:", "- if X_[0][0] >= X_[-1][0]:", "- di = -1", "- li = 0", "+ i = 0", "+ j = len(X_) - 1", "+ # while len(X_) != 1:", "+ while i < j:", "+ if X_[i][0] >= X_[j][0]:", "+ X_[i][0] += X_[j][0]", "+ X_[i][1] += X_[j][1]", "+ j -= 1", "- di = 0", "- li = -1", "- X_[li][0] += X_[di][0]", "- X_[li][1] += X_[di][1]", "- X_.pop(di)", "+ X_[j][0] += X_[i][0]", "+ X_[j][1] += X_[i][1]", "+ i += 1", "- for o in X_[0][1]:", "+ for o in X_[i][1]:", "+ # import random", "+ # N = 100000", "+ # S = N / 2", "+ # X = [x + 1 for x in range(N)]", "+ # P = [random.randint(1, 1000000000) for _ in range(N)]" ]
false
0.084829
0.038113
2.225701
[ "s184229194", "s237526534" ]
u296518383
p02983
python
s099471091
s414224800
1,160
579
147,760
75,332
Accepted
Accepted
50.09
L,R=list(map(int,input().split())) if R-L>=2018: print((0)) else: M=[] for i in range(L,R+1): M.append(i%2019) #print(M) A=[] for i in M: for j in M: if i!=j: A.append(i*j%2019) #print(A) print((min(A)))
L, R = list(map(int, input().split())) if R - L > 2020: print((0)) else: answer = [] for i in range(L, R + 1): for j in range(i + 1, R + 1): answer.append((i * j) % 2019) print((min(answer)))
17
11
251
213
L, R = list(map(int, input().split())) if R - L >= 2018: print((0)) else: M = [] for i in range(L, R + 1): M.append(i % 2019) # print(M) A = [] for i in M: for j in M: if i != j: A.append(i * j % 2019) # print(A) print((min(A)))
L, R = list(map(int, input().split())) if R - L > 2020: print((0)) else: answer = [] for i in range(L, R + 1): for j in range(i + 1, R + 1): answer.append((i * j) % 2019) print((min(answer)))
false
35.294118
[ "-if R - L >= 2018:", "+if R - L > 2020:", "- M = []", "+ answer = []", "- M.append(i % 2019)", "- # print(M)", "- A = []", "- for i in M:", "- for j in M:", "- if i != j:", "- A.append(i * j % 2019)", "- # print(A)", "- print((min(A)))", "+ for j in range(i + 1, R + 1):", "+ answer.append((i * j) % 2019)", "+ print((min(answer)))" ]
false
0.050573
0.055555
0.91032
[ "s099471091", "s414224800" ]
u775421443
p02953
python
s525539760
s081862695
62
54
14,684
11,308
Accepted
Accepted
12.9
import sys sys.setrecursionlimit(20000000) input = sys.stdin.readline def main(): n = int(eval(input())) nums = list(map(int, input().split())) for x in reversed(list(range(1, len(nums)))): if nums[x-1] > nums[x]: nums[x-1] -= 1 if nums[x-1] > nums[x]: print('No') sys.exit() print('Yes') if __name__ == '__main__': main()
import sys input = sys.stdin.readline n = int(eval(input())) nums = list(map(int, input().split())) maxnum = 0 for x in nums: if maxnum < x: maxnum = x if maxnum - x > 1: print('No') sys.exit() print('Yes')
21
15
408
245
import sys sys.setrecursionlimit(20000000) input = sys.stdin.readline def main(): n = int(eval(input())) nums = list(map(int, input().split())) for x in reversed(list(range(1, len(nums)))): if nums[x - 1] > nums[x]: nums[x - 1] -= 1 if nums[x - 1] > nums[x]: print("No") sys.exit() print("Yes") if __name__ == "__main__": main()
import sys input = sys.stdin.readline n = int(eval(input())) nums = list(map(int, input().split())) maxnum = 0 for x in nums: if maxnum < x: maxnum = x if maxnum - x > 1: print("No") sys.exit() print("Yes")
false
28.571429
[ "-sys.setrecursionlimit(20000000)", "-", "-", "-def main():", "- n = int(eval(input()))", "- nums = list(map(int, input().split()))", "- for x in reversed(list(range(1, len(nums)))):", "- if nums[x - 1] > nums[x]:", "- nums[x - 1] -= 1", "- if nums[x - 1] > nums[x]:", "- print(\"No\")", "- sys.exit()", "- print(\"Yes\")", "-", "-", "-if __name__ == \"__main__\":", "- main()", "+n = int(eval(input()))", "+nums = list(map(int, input().split()))", "+maxnum = 0", "+for x in nums:", "+ if maxnum < x:", "+ maxnum = x", "+ if maxnum - x > 1:", "+ print(\"No\")", "+ sys.exit()", "+print(\"Yes\")" ]
false
0.045264
0.092114
0.491391
[ "s525539760", "s081862695" ]
u375616706
p02804
python
s345630930
s809687615
210
177
14,936
17,016
Accepted
Accepted
15.71
# -*- coding: utf-8 -*- class FactMod(): ''' modの値が素数の時のfactと組み合わせを求める フェルマーの小定理を用いているため、modが素数以外の時は使えない ''' def __init__(self, n, mod): ''' コンストラクタ f:nまでの i!の値を 配列に入れる inv: (i!)^-1 の値を配列に入れる ''' self.mod = mod self.f = [1]*(n+1) for i in range(1, n+1): self.f[i] = self.f[i-1]*i % mod self.inv = [pow(self.f[-1], mod-2, mod)] for i in range(1, n+1)[::-1]: self.inv.append(self.inv[-1]*i % mod) self.inv.reverse() def fact(self, n): ''' n!の値を返す ''' return self.f[n] def comb(self, n, r): ''' nCrの値を返す ''' ret = self.f[n] * self.inv[n-r]*self.inv[r] ret %= self.mod return ret def perm(self, n, r): """ nPrの値を返す """ ret = self.f[n] * self.inv[n-r] ret %= self.mod return ret N, K = list(map(int, input().split())) L = list(map(int, input().split())) L = sorted(L) MOD = 10**9+7 F = FactMod(N+1, MOD) sub = 0 add = 0 for i in reversed(list(range(K-1, N))): add += L[i]*F.comb(i, K-1) sub += L[N-i-1]*F.comb(i, K-1) print(((-sub+add+MOD) % MOD))
# -*- coding: utf-8 -*- class FactMod(): ''' modの値が素数の時のfactと組み合わせを求める フェルマーの小定理を用いているため、modが素数以外の時は使えない ''' def __init__(self, n, mod): ''' コンストラクタ f:nまでの i!の値を 配列に入れる inv: (i!)^-1 の値を配列に入れる ''' self.mod = mod self.f = [1]*(n+1) for i in range(1, n+1): self.f[i] = self.f[i-1]*i % mod self.inv = [pow(self.f[-1], mod-2, mod)] for i in range(1, n+1)[::-1]: self.inv.append(self.inv[-1]*i % mod) self.inv.reverse() def fact(self, n): ''' n!の値を返す ''' return self.f[n] def comb(self, n, r): ''' nCrの値を返す ''' ret = self.f[n] * self.inv[n-r]*self.inv[r] ret %= self.mod return ret def perm(self, n, r): """ nPrの値を返す """ ret = self.f[n] * self.inv[n-r] ret %= self.mod return ret N, K = list(map(int, input().split())) L = list(map(int, input().split())) L = sorted(L) MOD = 10**9+7 F = FactMod(N+1, MOD) print((sum([(L[i]-L[N-i-1]+MOD)*F.comb(i, K-1) % MOD for i in reversed(list(range(K-1, N)))]) % MOD))
59
54
1,276
1,231
# -*- coding: utf-8 -*- class FactMod: """ modの値が素数の時のfactと組み合わせを求める フェルマーの小定理を用いているため、modが素数以外の時は使えない """ def __init__(self, n, mod): """ コンストラクタ f:nまでの i!の値を 配列に入れる inv: (i!)^-1 の値を配列に入れる """ self.mod = mod self.f = [1] * (n + 1) for i in range(1, n + 1): self.f[i] = self.f[i - 1] * i % mod self.inv = [pow(self.f[-1], mod - 2, mod)] for i in range(1, n + 1)[::-1]: self.inv.append(self.inv[-1] * i % mod) self.inv.reverse() def fact(self, n): """ n!の値を返す """ return self.f[n] def comb(self, n, r): """ nCrの値を返す """ ret = self.f[n] * self.inv[n - r] * self.inv[r] ret %= self.mod return ret def perm(self, n, r): """ nPrの値を返す """ ret = self.f[n] * self.inv[n - r] ret %= self.mod return ret N, K = list(map(int, input().split())) L = list(map(int, input().split())) L = sorted(L) MOD = 10**9 + 7 F = FactMod(N + 1, MOD) sub = 0 add = 0 for i in reversed(list(range(K - 1, N))): add += L[i] * F.comb(i, K - 1) sub += L[N - i - 1] * F.comb(i, K - 1) print(((-sub + add + MOD) % MOD))
# -*- coding: utf-8 -*- class FactMod: """ modの値が素数の時のfactと組み合わせを求める フェルマーの小定理を用いているため、modが素数以外の時は使えない """ def __init__(self, n, mod): """ コンストラクタ f:nまでの i!の値を 配列に入れる inv: (i!)^-1 の値を配列に入れる """ self.mod = mod self.f = [1] * (n + 1) for i in range(1, n + 1): self.f[i] = self.f[i - 1] * i % mod self.inv = [pow(self.f[-1], mod - 2, mod)] for i in range(1, n + 1)[::-1]: self.inv.append(self.inv[-1] * i % mod) self.inv.reverse() def fact(self, n): """ n!の値を返す """ return self.f[n] def comb(self, n, r): """ nCrの値を返す """ ret = self.f[n] * self.inv[n - r] * self.inv[r] ret %= self.mod return ret def perm(self, n, r): """ nPrの値を返す """ ret = self.f[n] * self.inv[n - r] ret %= self.mod return ret N, K = list(map(int, input().split())) L = list(map(int, input().split())) L = sorted(L) MOD = 10**9 + 7 F = FactMod(N + 1, MOD) print( ( sum( [ (L[i] - L[N - i - 1] + MOD) * F.comb(i, K - 1) % MOD for i in reversed(list(range(K - 1, N))) ] ) % MOD ) )
false
8.474576
[ "-sub = 0", "-add = 0", "-for i in reversed(list(range(K - 1, N))):", "- add += L[i] * F.comb(i, K - 1)", "- sub += L[N - i - 1] * F.comb(i, K - 1)", "-print(((-sub + add + MOD) % MOD))", "+print(", "+ (", "+ sum(", "+ [", "+ (L[i] - L[N - i - 1] + MOD) * F.comb(i, K - 1) % MOD", "+ for i in reversed(list(range(K - 1, N)))", "+ ]", "+ )", "+ % MOD", "+ )", "+)" ]
false
0.143103
0.046023
3.109402
[ "s345630930", "s809687615" ]
u724687935
p03378
python
s433819756
s819246161
166
26
38,256
9,092
Accepted
Accepted
84.34
N, M, X = list(map(int, input().split())) A = list(map(int, input().split())) A.sort() L = 0 R = 0 for a in A: if a < X: L += 1 else: R += 1 print((min(L, R)))
N, M, X = list(map(int, input().split())) A = list(map(int, input().split())) left = 0 right = 0 for i in A: if i < X: left += 1 else: right += 1 print((min(left, right)))
13
11
190
199
N, M, X = list(map(int, input().split())) A = list(map(int, input().split())) A.sort() L = 0 R = 0 for a in A: if a < X: L += 1 else: R += 1 print((min(L, R)))
N, M, X = list(map(int, input().split())) A = list(map(int, input().split())) left = 0 right = 0 for i in A: if i < X: left += 1 else: right += 1 print((min(left, right)))
false
15.384615
[ "-A.sort()", "-L = 0", "-R = 0", "-for a in A:", "- if a < X:", "- L += 1", "+left = 0", "+right = 0", "+for i in A:", "+ if i < X:", "+ left += 1", "- R += 1", "-print((min(L, R)))", "+ right += 1", "+print((min(left, right)))" ]
false
0.038083
0.045068
0.845
[ "s433819756", "s819246161" ]
u287500079
p03449
python
s996414643
s220269475
300
268
61,292
60,012
Accepted
Accepted
10.67
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin 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 n = INT() a = [LIST() for _ in range(2)] ans = 0 for i in range(n): #下に移動するとき tmp = 0 for j in range(i + 1): tmp += a[0][j] tmp += a[1][i] for j in range(i + 1, n): tmp += a[1][j] ans = max(ans, tmp) print(ans)
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin 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 dx = [0, 0, 1, -1, 1, -1, -1, 1] dy = [1, -1, 0, 0, 1, -1, 1, -1] n = INT() a = [LIST() for _ in range(2)] ans = 0 for i in range(n): tmp = 0 for j in range(i + 1): tmp += a[0][j] for j in range(i, n): tmp += a[1][j] ans = max(ans, tmp) print(ans)
31
32
1,021
1,055
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin 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 n = INT() a = [LIST() for _ in range(2)] ans = 0 for i in range(n): # 下に移動するとき tmp = 0 for j in range(i + 1): tmp += a[0][j] tmp += a[1][i] for j in range(i + 1, n): tmp += a[1][j] ans = max(ans, tmp) print(ans)
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin 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 dx = [0, 0, 1, -1, 1, -1, -1, 1] dy = [1, -1, 0, 0, 1, -1, 1, -1] n = INT() a = [LIST() for _ in range(2)] ans = 0 for i in range(n): tmp = 0 for j in range(i + 1): tmp += a[0][j] for j in range(i, n): tmp += a[1][j] ans = max(ans, tmp) print(ans)
false
3.125
[ "+dx = [0, 0, 1, -1, 1, -1, -1, 1]", "+dy = [1, -1, 0, 0, 1, -1, 1, -1]", "-for i in range(n): # 下に移動するとき", "+for i in range(n):", "- tmp += a[1][i]", "- for j in range(i + 1, n):", "+ for j in range(i, n):" ]
false
0.077329
0.040729
1.898639
[ "s996414643", "s220269475" ]
u808427016
p03286
python
s957921133
s297537968
168
17
38,256
2,940
Accepted
Accepted
89.88
N = int(eval(input())) def solve(N): if N == 0: return "0" result = "" n = N i = 0 while n: k = (-2)**i if n & (1 << i): n -= k result = "1" + result else: result = "0" + result i += 1 return result print((solve(N)))
N = int(eval(input())) def solve(N): result = "" k = 1 while 1: c = N % 2 result = "01"[c] + result N = (N - k * c) // 2 k = -k if N == 0: break return result print((solve(N)))
19
15
329
253
N = int(eval(input())) def solve(N): if N == 0: return "0" result = "" n = N i = 0 while n: k = (-2) ** i if n & (1 << i): n -= k result = "1" + result else: result = "0" + result i += 1 return result print((solve(N)))
N = int(eval(input())) def solve(N): result = "" k = 1 while 1: c = N % 2 result = "01"[c] + result N = (N - k * c) // 2 k = -k if N == 0: break return result print((solve(N)))
false
21.052632
[ "- if N == 0:", "- return \"0\"", "- n = N", "- i = 0", "- while n:", "- k = (-2) ** i", "- if n & (1 << i):", "- n -= k", "- result = \"1\" + result", "- else:", "- result = \"0\" + result", "- i += 1", "+ k = 1", "+ while 1:", "+ c = N % 2", "+ result = \"01\"[c] + result", "+ N = (N - k * c) // 2", "+ k = -k", "+ if N == 0:", "+ break" ]
false
0.038612
0.03802
1.015582
[ "s957921133", "s297537968" ]
u513081876
p03400
python
s244328581
s566223418
19
17
3,060
2,940
Accepted
Accepted
10.53
n = int(eval(input())) d, x = list(map(int, input().split())) a = [int(eval(input())) for i in range(n)] ans = n+x for num in a: ans += (d-1)//num print(ans)
N = int(eval(input())) D, X = list(map(int, input().split())) cacao = 0 for i in range(N): A = int(eval(input())) cacao += ((D-1)//A)+1 print((cacao+X))
7
7
155
147
n = int(eval(input())) d, x = list(map(int, input().split())) a = [int(eval(input())) for i in range(n)] ans = n + x for num in a: ans += (d - 1) // num print(ans)
N = int(eval(input())) D, X = list(map(int, input().split())) cacao = 0 for i in range(N): A = int(eval(input())) cacao += ((D - 1) // A) + 1 print((cacao + X))
false
0
[ "-n = int(eval(input()))", "-d, x = list(map(int, input().split()))", "-a = [int(eval(input())) for i in range(n)]", "-ans = n + x", "-for num in a:", "- ans += (d - 1) // num", "-print(ans)", "+N = int(eval(input()))", "+D, X = list(map(int, input().split()))", "+cacao = 0", "+for i in range(N):", "+ A = int(eval(input()))", "+ cacao += ((D - 1) // A) + 1", "+print((cacao + X))" ]
false
0.038448
0.038309
1.003619
[ "s244328581", "s566223418" ]
u729133443
p02702
python
s033479839
s417269108
1,630
1,416
76,372
112,212
Accepted
Accepted
13.13
a,*d=[0]*2020 for i in map(int,eval(input())): p=[0]*2019 for j in range(2019):p[(j*10+i)%2019]+=d[j] d=p d[i]+=1 a+=d[0] print(a)
from numba import njit from numpy import int32,zeros,arange @njit('i4(i4[:])') def solve(s): a=0 d=zeros(2019,int32) for i in s: p=zeros(2019,int32) for j in range(2019):p[(j*10+i)%2019]+=d[j] d=p d[i]+=1 a+=d[0] return a print((solve(int32([*eval(input())]))))
8
14
141
322
a, *d = [0] * 2020 for i in map(int, eval(input())): p = [0] * 2019 for j in range(2019): p[(j * 10 + i) % 2019] += d[j] d = p d[i] += 1 a += d[0] print(a)
from numba import njit from numpy import int32, zeros, arange @njit("i4(i4[:])") def solve(s): a = 0 d = zeros(2019, int32) for i in s: p = zeros(2019, int32) for j in range(2019): p[(j * 10 + i) % 2019] += d[j] d = p d[i] += 1 a += d[0] return a print((solve(int32([*eval(input())]))))
false
42.857143
[ "-a, *d = [0] * 2020", "-for i in map(int, eval(input())):", "- p = [0] * 2019", "- for j in range(2019):", "- p[(j * 10 + i) % 2019] += d[j]", "- d = p", "- d[i] += 1", "- a += d[0]", "-print(a)", "+from numba import njit", "+from numpy import int32, zeros, arange", "+", "+", "+@njit(\"i4(i4[:])\")", "+def solve(s):", "+ a = 0", "+ d = zeros(2019, int32)", "+ for i in s:", "+ p = zeros(2019, int32)", "+ for j in range(2019):", "+ p[(j * 10 + i) % 2019] += d[j]", "+ d = p", "+ d[i] += 1", "+ a += d[0]", "+ return a", "+", "+", "+print((solve(int32([*eval(input())]))))" ]
false
0.035418
0.037138
0.95368
[ "s033479839", "s417269108" ]
u811967730
p03804
python
s783232084
s521855374
164
23
3,060
3,064
Accepted
Accepted
85.98
N, M = list(map(int, input().split())) A = [eval(input()) for _ in range(N)] B = [eval(input()) for _ in range(M)] ans = "No" for i in range(N - M + 1): for j in range(N - M + 1): c = 0 for x in range(M): for y in range(M): if A[x + i][y + j] == B[x][y]: c += 1 if c == M ** 2: ans = "Yes" break print(ans)
N, M = list(map(int, input().split())) A = [eval(input()) for _ in range(N)] B = [eval(input()) for _ in range(M)] ans = "No" for i in range(N - M + 1): for j in range(N - M + 1): c = 0 for x in range(M): if A[x + i][j:j + M] == B[x]: c += 1 if c == M: ans = "Yes" break else: continue break print(ans)
18
20
409
403
N, M = list(map(int, input().split())) A = [eval(input()) for _ in range(N)] B = [eval(input()) for _ in range(M)] ans = "No" for i in range(N - M + 1): for j in range(N - M + 1): c = 0 for x in range(M): for y in range(M): if A[x + i][y + j] == B[x][y]: c += 1 if c == M**2: ans = "Yes" break print(ans)
N, M = list(map(int, input().split())) A = [eval(input()) for _ in range(N)] B = [eval(input()) for _ in range(M)] ans = "No" for i in range(N - M + 1): for j in range(N - M + 1): c = 0 for x in range(M): if A[x + i][j : j + M] == B[x]: c += 1 if c == M: ans = "Yes" break else: continue break print(ans)
false
10
[ "- for y in range(M):", "- if A[x + i][y + j] == B[x][y]:", "- c += 1", "- if c == M**2:", "+ if A[x + i][j : j + M] == B[x]:", "+ c += 1", "+ if c == M:", "+ else:", "+ continue", "+ break" ]
false
0.035839
0.104531
0.342858
[ "s783232084", "s521855374" ]
u405256066
p03150
python
s550733973
s177393751
23
19
3,188
3,060
Accepted
Accepted
17.39
import re from sys import stdin N=(stdin.readline().rstrip()) for i in range(7): mae="keyence"[0:i+1] ato="keyence"[i+1:8] if re.search(".*keyencekeyence",N): if (re.sub('.*keyencekeyence', '', N)=="")==True: print("YES") break if re.search("keyencekeyence.*",N): if (re.sub('keyencekeyence.*', '', N)=="")==True: print("YES") break if (re.sub('.*keyence', '', N)=="")==True: print("YES") break if (re.sub('keyence.*', '', N)=="")==True: print("YES") break if re.match("%s.*%s"%(mae, ato),N): if (re.sub('%s.*%s'%(mae,ato) ,"", N)=="")==True: print("YES") break if i==6: print("NO")
from sys import stdin S = (stdin.readline().rstrip()) flag = False for i in range(0,len(S)+1): for j in range(0,len(S)+1): if j >= i: if S[:i]+S[j:] == "keyence": flag = True if flag: print("YES") else: print("NO")
26
12
767
273
import re from sys import stdin N = stdin.readline().rstrip() for i in range(7): mae = "keyence"[0 : i + 1] ato = "keyence"[i + 1 : 8] if re.search(".*keyencekeyence", N): if (re.sub(".*keyencekeyence", "", N) == "") == True: print("YES") break if re.search("keyencekeyence.*", N): if (re.sub("keyencekeyence.*", "", N) == "") == True: print("YES") break if (re.sub(".*keyence", "", N) == "") == True: print("YES") break if (re.sub("keyence.*", "", N) == "") == True: print("YES") break if re.match("%s.*%s" % (mae, ato), N): if (re.sub("%s.*%s" % (mae, ato), "", N) == "") == True: print("YES") break if i == 6: print("NO")
from sys import stdin S = stdin.readline().rstrip() flag = False for i in range(0, len(S) + 1): for j in range(0, len(S) + 1): if j >= i: if S[:i] + S[j:] == "keyence": flag = True if flag: print("YES") else: print("NO")
false
53.846154
[ "-import re", "-N = stdin.readline().rstrip()", "-for i in range(7):", "- mae = \"keyence\"[0 : i + 1]", "- ato = \"keyence\"[i + 1 : 8]", "- if re.search(\".*keyencekeyence\", N):", "- if (re.sub(\".*keyencekeyence\", \"\", N) == \"\") == True:", "- print(\"YES\")", "- break", "- if re.search(\"keyencekeyence.*\", N):", "- if (re.sub(\"keyencekeyence.*\", \"\", N) == \"\") == True:", "- print(\"YES\")", "- break", "- if (re.sub(\".*keyence\", \"\", N) == \"\") == True:", "- print(\"YES\")", "- break", "- if (re.sub(\"keyence.*\", \"\", N) == \"\") == True:", "- print(\"YES\")", "- break", "- if re.match(\"%s.*%s\" % (mae, ato), N):", "- if (re.sub(\"%s.*%s\" % (mae, ato), \"\", N) == \"\") == True:", "- print(\"YES\")", "- break", "-if i == 6:", "+S = stdin.readline().rstrip()", "+flag = False", "+for i in range(0, len(S) + 1):", "+ for j in range(0, len(S) + 1):", "+ if j >= i:", "+ if S[:i] + S[j:] == \"keyence\":", "+ flag = True", "+if flag:", "+ print(\"YES\")", "+else:" ]
false
0.050266
0.075315
0.667402
[ "s550733973", "s177393751" ]
u844005364
p03457
python
s413954830
s730580297
542
321
37,216
3,060
Accepted
Accepted
40.77
def difference(two_lists): return [abs(two_lists[1][i] - two_lists[0][i]) for i in range(3)] n = int(eval(input())) txy = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)] dtxy = list(map(difference, list(zip(txy, txy[1:])))) for i in range(n): dt, dx, dy = dtxy[i] if dx + dy > dt or (dt - dx - dy) % 2: print("No") exit() print("Yes")
n = int(eval(input())) for _ in range(n): t, x, y = list(map(int, input().split())) if x + y > t or (t - x - y) % 2: print("No") exit() print("Yes")
15
8
387
169
def difference(two_lists): return [abs(two_lists[1][i] - two_lists[0][i]) for i in range(3)] n = int(eval(input())) txy = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)] dtxy = list(map(difference, list(zip(txy, txy[1:])))) for i in range(n): dt, dx, dy = dtxy[i] if dx + dy > dt or (dt - dx - dy) % 2: print("No") exit() print("Yes")
n = int(eval(input())) for _ in range(n): t, x, y = list(map(int, input().split())) if x + y > t or (t - x - y) % 2: print("No") exit() print("Yes")
false
46.666667
[ "-def difference(two_lists):", "- return [abs(two_lists[1][i] - two_lists[0][i]) for i in range(3)]", "-", "-", "-txy = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)]", "-dtxy = list(map(difference, list(zip(txy, txy[1:]))))", "-for i in range(n):", "- dt, dx, dy = dtxy[i]", "- if dx + dy > dt or (dt - dx - dy) % 2:", "+for _ in range(n):", "+ t, x, y = list(map(int, input().split()))", "+ if x + y > t or (t - x - y) % 2:" ]
false
0.037058
0.069321
0.534593
[ "s413954830", "s730580297" ]
u844266921
p03286
python
s936741277
s315199269
19
17
3,188
3,064
Accepted
Accepted
10.53
n=int(eval(input())) def isdig(n): if n>=0: digit=0 while n>2**digit: n-=2**digit digit+=2 else: digit=1 while n<-2**digit: n+=2**digit digit+=2 return digit x=["0"]*(isdig(n)+1) while n!=0: digit=isdig(n) if digit%2==0: n-=2**digit else: n+=2**digit x[digit]="1" x.reverse() print(("".join(x)))
n=eval(input()) s=[] n=int(n) i=0 while n!=0: if n%2**(i+1)==0: s.append("0") else: s.append("1") n-=(-2)**i i+=1 s.reverse() if s==[]: s=["0"] print(("".join(s)))
23
15
371
189
n = int(eval(input())) def isdig(n): if n >= 0: digit = 0 while n > 2**digit: n -= 2**digit digit += 2 else: digit = 1 while n < -(2**digit): n += 2**digit digit += 2 return digit x = ["0"] * (isdig(n) + 1) while n != 0: digit = isdig(n) if digit % 2 == 0: n -= 2**digit else: n += 2**digit x[digit] = "1" x.reverse() print(("".join(x)))
n = eval(input()) s = [] n = int(n) i = 0 while n != 0: if n % 2 ** (i + 1) == 0: s.append("0") else: s.append("1") n -= (-2) ** i i += 1 s.reverse() if s == []: s = ["0"] print(("".join(s)))
false
34.782609
[ "-n = int(eval(input()))", "-", "-", "-def isdig(n):", "- if n >= 0:", "- digit = 0", "- while n > 2**digit:", "- n -= 2**digit", "- digit += 2", "+n = eval(input())", "+s = []", "+n = int(n)", "+i = 0", "+while n != 0:", "+ if n % 2 ** (i + 1) == 0:", "+ s.append(\"0\")", "- digit = 1", "- while n < -(2**digit):", "- n += 2**digit", "- digit += 2", "- return digit", "-", "-", "-x = [\"0\"] * (isdig(n) + 1)", "-while n != 0:", "- digit = isdig(n)", "- if digit % 2 == 0:", "- n -= 2**digit", "- else:", "- n += 2**digit", "- x[digit] = \"1\"", "-x.reverse()", "-print((\"\".join(x)))", "+ s.append(\"1\")", "+ n -= (-2) ** i", "+ i += 1", "+s.reverse()", "+if s == []:", "+ s = [\"0\"]", "+print((\"\".join(s)))" ]
false
0.127117
0.056393
2.254136
[ "s936741277", "s315199269" ]
u585482323
p03298
python
s035892734
s386702475
657
492
113,884
127,152
Accepted
Accepted
25.11
#!usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS():return [list(x) for x in sys.stdin.readline().split()] def S(): res = list(sys.stdin.readline()) if res[-1] == "\n": return res[:-1] return res def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] sys.setrecursionlimit(1000000) mod = 1000000007 #A def A(): return #B def B(): return #C def C(): n = I() s = S() for i in range(2*n): s[i] = ord(s[i])-96 for i in range(n>>1): s[i],s[n-i-1] = s[n-i-1],s[i] k = 27 m = 1<<n p = [1<<j for j in range(n)] d = defaultdict(lambda : 0) for i in range(m): r = 0 b = 0 for j in range(n): if i&p[j]: r *= k r += s[j] else: b *= k b += s[j] d[(r,b)] += 1 ans = 0 for i in range(m): r = 0 b = 0 for j in range(n): if i&p[j]: r *= k r += s[j+n] else: b *= k b += s[j+n] ans += d[(r,b)] print(ans) return #D def D(): return #E def E(): return #F def F(): return #Solve if __name__ == "__main__": C()
#!usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS():return [list(x) for x in sys.stdin.readline().split()] def S(): res = list(sys.stdin.readline()) if res[-1] == "\n": return res[:-1] return res def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] sys.setrecursionlimit(1000000) mod = 1000000007 #A def A(): return #B def B(): return #C def C(): n = I() s = S() for i in range(2*n): s[i] = ord(s[i])-96 k = 27 m = 1<<n p = [1<<j for j in range(n)] d = defaultdict(lambda : 0) l = [(0,0)] for i in s[:n][::-1]: l = [(x[0]*k+i, x[1]) for x in l]+[(x[0], x[1]*k+i) for x in l] for i in l: d[i] += 1 ans = 0 l = [(0,0)] for i in s[n:]: l = [(x[0]*k+i, x[1]) for x in l]+[(x[0], x[1]*k+i) for x in l] for i in l: ans += d[i] print(ans) return #D def D(): return #E def E(): return #F def F(): return #Solve if __name__ == "__main__": C()
92
78
1,690
1,420
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS(): return [list(x) for x in sys.stdin.readline().split()] def S(): res = list(sys.stdin.readline()) if res[-1] == "\n": return res[:-1] return res def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] sys.setrecursionlimit(1000000) mod = 1000000007 # A def A(): return # B def B(): return # C def C(): n = I() s = S() for i in range(2 * n): s[i] = ord(s[i]) - 96 for i in range(n >> 1): s[i], s[n - i - 1] = s[n - i - 1], s[i] k = 27 m = 1 << n p = [1 << j for j in range(n)] d = defaultdict(lambda: 0) for i in range(m): r = 0 b = 0 for j in range(n): if i & p[j]: r *= k r += s[j] else: b *= k b += s[j] d[(r, b)] += 1 ans = 0 for i in range(m): r = 0 b = 0 for j in range(n): if i & p[j]: r *= k r += s[j + n] else: b *= k b += s[j + n] ans += d[(r, b)] print(ans) return # D def D(): return # E def E(): return # F def F(): return # Solve if __name__ == "__main__": C()
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS(): return [list(x) for x in sys.stdin.readline().split()] def S(): res = list(sys.stdin.readline()) if res[-1] == "\n": return res[:-1] return res def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] sys.setrecursionlimit(1000000) mod = 1000000007 # A def A(): return # B def B(): return # C def C(): n = I() s = S() for i in range(2 * n): s[i] = ord(s[i]) - 96 k = 27 m = 1 << n p = [1 << j for j in range(n)] d = defaultdict(lambda: 0) l = [(0, 0)] for i in s[:n][::-1]: l = [(x[0] * k + i, x[1]) for x in l] + [(x[0], x[1] * k + i) for x in l] for i in l: d[i] += 1 ans = 0 l = [(0, 0)] for i in s[n:]: l = [(x[0] * k + i, x[1]) for x in l] + [(x[0], x[1] * k + i) for x in l] for i in l: ans += d[i] print(ans) return # D def D(): return # E def E(): return # F def F(): return # Solve if __name__ == "__main__": C()
false
15.217391
[ "- for i in range(n >> 1):", "- s[i], s[n - i - 1] = s[n - i - 1], s[i]", "- for i in range(m):", "- r = 0", "- b = 0", "- for j in range(n):", "- if i & p[j]:", "- r *= k", "- r += s[j]", "- else:", "- b *= k", "- b += s[j]", "- d[(r, b)] += 1", "+ l = [(0, 0)]", "+ for i in s[:n][::-1]:", "+ l = [(x[0] * k + i, x[1]) for x in l] + [(x[0], x[1] * k + i) for x in l]", "+ for i in l:", "+ d[i] += 1", "- for i in range(m):", "- r = 0", "- b = 0", "- for j in range(n):", "- if i & p[j]:", "- r *= k", "- r += s[j + n]", "- else:", "- b *= k", "- b += s[j + n]", "- ans += d[(r, b)]", "+ l = [(0, 0)]", "+ for i in s[n:]:", "+ l = [(x[0] * k + i, x[1]) for x in l] + [(x[0], x[1] * k + i) for x in l]", "+ for i in l:", "+ ans += d[i]" ]
false
0.424699
0.212403
1.9995
[ "s035892734", "s386702475" ]
u083960235
p03087
python
s559041967
s805301476
422
387
10,324
32,728
Accepted
Accepted
8.29
N,Q=list(map(int,input().split())) s=eval(input()) #a=[] l=[0]*(N) for i in range(N-1): if s[i:i+2]=='AC': l[i+1]=l[i]+1 else: l[i+1]=l[i] #print(l) ans=[] for i in range(Q): first,last=list(map(int,input().split())) ans.append(l[last-1]-l[first-1]) for i in ans: print(i)
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 = float('inf') mod = 10 ** 9 + 7 N, Q = MAP() S = eval(input()) L = [LIST() for i in range(Q)] ruiseki = [0] * (N) for i in range(N-1): if S[i+1] == "C" and S[i] == "A": #if S[i] == "A": ruiseki[i+1] += ruiseki[i] + 1 else: ruiseki[i+1] = ruiseki[i] for l, r in L: ans = ruiseki[r-1] - ruiseki[l-1] print(ans)
18
37
310
1,065
N, Q = list(map(int, input().split())) s = eval(input()) # a=[] l = [0] * (N) for i in range(N - 1): if s[i : i + 2] == "AC": l[i + 1] = l[i] + 1 else: l[i + 1] = l[i] # print(l) ans = [] for i in range(Q): first, last = list(map(int, input().split())) ans.append(l[last - 1] - l[first - 1]) for i in ans: print(i)
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 = float("inf") mod = 10**9 + 7 N, Q = MAP() S = eval(input()) L = [LIST() for i in range(Q)] ruiseki = [0] * (N) for i in range(N - 1): if S[i + 1] == "C" and S[i] == "A": # if S[i] == "A": ruiseki[i + 1] += ruiseki[i] + 1 else: ruiseki[i + 1] = ruiseki[i] for l, r in L: ans = ruiseki[r - 1] - ruiseki[l - 1] print(ans)
false
51.351351
[ "-N, Q = list(map(int, input().split()))", "-s = eval(input())", "-# a=[]", "-l = [0] * (N)", "+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 = float(\"inf\")", "+mod = 10**9 + 7", "+N, Q = MAP()", "+S = eval(input())", "+L = [LIST() for i in range(Q)]", "+ruiseki = [0] * (N)", "- if s[i : i + 2] == \"AC\":", "- l[i + 1] = l[i] + 1", "+ if S[i + 1] == \"C\" and S[i] == \"A\":", "+ # if S[i] == \"A\":", "+ ruiseki[i + 1] += ruiseki[i] + 1", "- l[i + 1] = l[i]", "-# print(l)", "-ans = []", "-for i in range(Q):", "- first, last = list(map(int, input().split()))", "- ans.append(l[last - 1] - l[first - 1])", "-for i in ans:", "- print(i)", "+ ruiseki[i + 1] = ruiseki[i]", "+for l, r in L:", "+ ans = ruiseki[r - 1] - ruiseki[l - 1]", "+ print(ans)" ]
false
0.165756
0.107024
1.548779
[ "s559041967", "s805301476" ]
u781262926
p03212
python
s121174885
s189344232
444
86
7,016
4,072
Accepted
Accepted
80.63
from itertools import product n = int(eval(input())) A = set() for x in product('753_', repeat=9): s = ''.join(x).replace('_', '') if all(d in s for d in '753') and int(s) <= n: A.add(s) print((len(A)))
n = int(eval(input())) B = [] def dfs(A): x = int(''.join(A)) if x <= n: if '7' in A and '5' in A and '3' in A: B.append(x) dfs(A + ['7']) dfs(A + ['5']) dfs(A + ['3']) dfs(['0']) print((len(B)))
8
13
217
226
from itertools import product n = int(eval(input())) A = set() for x in product("753_", repeat=9): s = "".join(x).replace("_", "") if all(d in s for d in "753") and int(s) <= n: A.add(s) print((len(A)))
n = int(eval(input())) B = [] def dfs(A): x = int("".join(A)) if x <= n: if "7" in A and "5" in A and "3" in A: B.append(x) dfs(A + ["7"]) dfs(A + ["5"]) dfs(A + ["3"]) dfs(["0"]) print((len(B)))
false
38.461538
[ "-from itertools import product", "+n = int(eval(input()))", "+B = []", "-n = int(eval(input()))", "-A = set()", "-for x in product(\"753_\", repeat=9):", "- s = \"\".join(x).replace(\"_\", \"\")", "- if all(d in s for d in \"753\") and int(s) <= n:", "- A.add(s)", "-print((len(A)))", "+", "+def dfs(A):", "+ x = int(\"\".join(A))", "+ if x <= n:", "+ if \"7\" in A and \"5\" in A and \"3\" in A:", "+ B.append(x)", "+ dfs(A + [\"7\"])", "+ dfs(A + [\"5\"])", "+ dfs(A + [\"3\"])", "+", "+", "+dfs([\"0\"])", "+print((len(B)))" ]
false
0.9688
0.048561
19.950266
[ "s121174885", "s189344232" ]
u852690916
p02991
python
s484238257
s234965236
343
252
103,396
109,448
Accepted
Accepted
26.53
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) from heapq import heappush, heappop import sys def main(N, M, G, S, T): INF = 10**10 dp = [[INF for _ in range(N)] for __ in range(3)] dp[0][S] = 0 q = [(0, S)] while q: d, v = heappop(q) for to in G[v]: if d + 1 >= dp[(d + 1) % 3][to]: continue dp[(d + 1) % 3][to] = d + 1 heappush(q, (d + 1, to)) print((dp[0][T] // 3 if dp[0][T] < INF else -1)) if __name__ == '__main__': input = sys.stdin.readline N, M = list(map(int, input().split())) G = [[] for _ in range(N)] for _ in range(M): x, y = list(map(int, input().split())) x, y = x - 1, y - 1 G[x].append(y) S, T = [int(x) - 1 for x in input().split()] main(N, M, G, S, T)
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) from collections import deque import sys def main(N, M, G, S, T): INF = 10**10 q = deque([S]) dist = [INF] * (3 * N) dist[S] = 0 while q: v = q.popleft() for to in G[v]: if dist[to] < INF: continue dist[to] = dist[v] + 1 q.append(to) print((dist[T] // 3 if dist[T] < INF else -1)) if __name__ == '__main__': input = sys.stdin.readline N, M = list(map(int, input().split())) G = [[] for _ in range(N * 3)] for _ in range(M): x, y = list(map(int, input().split())) x, y = x - 1, y - 1 G[x].append(y + N) G[x + N].append(y + N + N) G[x + N + N].append(y) S, T = [int(x) - 1 for x in input().split()] main(N, M, G, S, T)
26
28
814
823
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) from heapq import heappush, heappop import sys def main(N, M, G, S, T): INF = 10**10 dp = [[INF for _ in range(N)] for __ in range(3)] dp[0][S] = 0 q = [(0, S)] while q: d, v = heappop(q) for to in G[v]: if d + 1 >= dp[(d + 1) % 3][to]: continue dp[(d + 1) % 3][to] = d + 1 heappush(q, (d + 1, to)) print((dp[0][T] // 3 if dp[0][T] < INF else -1)) if __name__ == "__main__": input = sys.stdin.readline N, M = list(map(int, input().split())) G = [[] for _ in range(N)] for _ in range(M): x, y = list(map(int, input().split())) x, y = x - 1, y - 1 G[x].append(y) S, T = [int(x) - 1 for x in input().split()] main(N, M, G, S, T)
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) from collections import deque import sys def main(N, M, G, S, T): INF = 10**10 q = deque([S]) dist = [INF] * (3 * N) dist[S] = 0 while q: v = q.popleft() for to in G[v]: if dist[to] < INF: continue dist[to] = dist[v] + 1 q.append(to) print((dist[T] // 3 if dist[T] < INF else -1)) if __name__ == "__main__": input = sys.stdin.readline N, M = list(map(int, input().split())) G = [[] for _ in range(N * 3)] for _ in range(M): x, y = list(map(int, input().split())) x, y = x - 1, y - 1 G[x].append(y + N) G[x + N].append(y + N + N) G[x + N + N].append(y) S, T = [int(x) - 1 for x in input().split()] main(N, M, G, S, T)
false
7.142857
[ "-from heapq import heappush, heappop", "+from collections import deque", "- dp = [[INF for _ in range(N)] for __ in range(3)]", "- dp[0][S] = 0", "- q = [(0, S)]", "+ q = deque([S])", "+ dist = [INF] * (3 * N)", "+ dist[S] = 0", "- d, v = heappop(q)", "+ v = q.popleft()", "- if d + 1 >= dp[(d + 1) % 3][to]:", "+ if dist[to] < INF:", "- dp[(d + 1) % 3][to] = d + 1", "- heappush(q, (d + 1, to))", "- print((dp[0][T] // 3 if dp[0][T] < INF else -1))", "+ dist[to] = dist[v] + 1", "+ q.append(to)", "+ print((dist[T] // 3 if dist[T] < INF else -1))", "- G = [[] for _ in range(N)]", "+ G = [[] for _ in range(N * 3)]", "- G[x].append(y)", "+ G[x].append(y + N)", "+ G[x + N].append(y + N + N)", "+ G[x + N + N].append(y)" ]
false
0.038138
0.079588
0.479189
[ "s484238257", "s234965236" ]
u250362126
p02552
python
s240159295
s689245233
29
25
9,096
9,096
Accepted
Accepted
13.79
a = int(eval(input())) print((1 if a == 0 else 0))
def _print(): a = int(eval(input())) print((1 if a == 0 else 0)) if __name__ == '__main__': _print()
2
6
43
105
a = int(eval(input())) print((1 if a == 0 else 0))
def _print(): a = int(eval(input())) print((1 if a == 0 else 0)) if __name__ == "__main__": _print()
false
66.666667
[ "-a = int(eval(input()))", "-print((1 if a == 0 else 0))", "+def _print():", "+ a = int(eval(input()))", "+ print((1 if a == 0 else 0))", "+", "+", "+if __name__ == \"__main__\":", "+ _print()" ]
false
0.045902
0.082628
0.555524
[ "s240159295", "s689245233" ]
u646456209
p03246
python
s372062692
s701988823
188
139
13,636
12,472
Accepted
Accepted
26.06
maxn=10**5+10 n=int(eval(input())) a=[None]*(n+10) b=[0]*maxn c=[0]*maxn a[1:n+1]=input().split() for i in range(1,n+1): a[i]=int(a[i]) if i%2==0: b[a[i]]+=1 else: c[a[i]]+=1 max1=max2=maxp=0 for i in range(1,maxn): if b[i]>=max1: max2=max1 maxp=i max1=b[i] elif b[i]>=max2: max2=b[i] ans=n for i in range(1,maxn): res=((n+1)//2-c[i]) if i==maxp: res+=n//2-max2 else: res+=n//2-max1 ans=min(ans,res) print(ans)
maxn=10**5+10 n=int(eval(input())) b=[0]*maxn c=[0]*maxn a=input().split() for i in range(0,n): a[i]=int(a[i]) if i%2==0: b[a[i]]+=1 else: c[a[i]]+=1 max1=max(b) maxp=b.index(max1) del b[maxp] max2=max(b) ans=0 for i in range(0,maxn): ans=max(ans,c[i]+(max2 if i==maxp else max1)) print((n-ans))
33
23
540
346
maxn = 10**5 + 10 n = int(eval(input())) a = [None] * (n + 10) b = [0] * maxn c = [0] * maxn a[1 : n + 1] = input().split() for i in range(1, n + 1): a[i] = int(a[i]) if i % 2 == 0: b[a[i]] += 1 else: c[a[i]] += 1 max1 = max2 = maxp = 0 for i in range(1, maxn): if b[i] >= max1: max2 = max1 maxp = i max1 = b[i] elif b[i] >= max2: max2 = b[i] ans = n for i in range(1, maxn): res = (n + 1) // 2 - c[i] if i == maxp: res += n // 2 - max2 else: res += n // 2 - max1 ans = min(ans, res) print(ans)
maxn = 10**5 + 10 n = int(eval(input())) b = [0] * maxn c = [0] * maxn a = input().split() for i in range(0, n): a[i] = int(a[i]) if i % 2 == 0: b[a[i]] += 1 else: c[a[i]] += 1 max1 = max(b) maxp = b.index(max1) del b[maxp] max2 = max(b) ans = 0 for i in range(0, maxn): ans = max(ans, c[i] + (max2 if i == maxp else max1)) print((n - ans))
false
30.30303
[ "-a = [None] * (n + 10)", "-a[1 : n + 1] = input().split()", "-for i in range(1, n + 1):", "+a = input().split()", "+for i in range(0, n):", "-max1 = max2 = maxp = 0", "-for i in range(1, maxn):", "- if b[i] >= max1:", "- max2 = max1", "- maxp = i", "- max1 = b[i]", "- elif b[i] >= max2:", "- max2 = b[i]", "-ans = n", "-for i in range(1, maxn):", "- res = (n + 1) // 2 - c[i]", "- if i == maxp:", "- res += n // 2 - max2", "- else:", "- res += n // 2 - max1", "- ans = min(ans, res)", "-print(ans)", "+max1 = max(b)", "+maxp = b.index(max1)", "+del b[maxp]", "+max2 = max(b)", "+ans = 0", "+for i in range(0, maxn):", "+ ans = max(ans, c[i] + (max2 if i == maxp else max1))", "+print((n - ans))" ]
false
0.128767
0.090778
1.418482
[ "s372062692", "s701988823" ]
u125337618
p02861
python
s997438160
s364394662
501
18
3,064
3,064
Accepted
Accepted
96.41
from itertools import permutations from math import factorial N = int(eval(input())) coord = [] for _ in range(N): x,y = list(map(int, input().split())) coord.append((x,y)) def dist(a, b): x1, y1 = a x2, y2 = b return pow((x1-x2) ** 2 + (y1-y2) ** 2, 1/2) res = 0 div = factorial(N) idx = [i for i in range(N)] for line in permutations(idx, N): for i in range(N-1): res += dist(coord[line[i]], coord[line[i+1]]) / div print(res)
from itertools import permutations from math import factorial N = int(eval(input())) coord = [] for _ in range(N): x,y = list(map(int, input().split())) coord.append((x,y)) def dist(a, b): x1, y1 = a x2, y2 = b return pow((x1-x2) ** 2 + (y1-y2) ** 2, 1/2) res = 0 for i in range(N): for j in range(i+1, N): res += dist(coord[i], coord[j]) * 2 / N print(res)
22
20
465
393
from itertools import permutations from math import factorial N = int(eval(input())) coord = [] for _ in range(N): x, y = list(map(int, input().split())) coord.append((x, y)) def dist(a, b): x1, y1 = a x2, y2 = b return pow((x1 - x2) ** 2 + (y1 - y2) ** 2, 1 / 2) res = 0 div = factorial(N) idx = [i for i in range(N)] for line in permutations(idx, N): for i in range(N - 1): res += dist(coord[line[i]], coord[line[i + 1]]) / div print(res)
from itertools import permutations from math import factorial N = int(eval(input())) coord = [] for _ in range(N): x, y = list(map(int, input().split())) coord.append((x, y)) def dist(a, b): x1, y1 = a x2, y2 = b return pow((x1 - x2) ** 2 + (y1 - y2) ** 2, 1 / 2) res = 0 for i in range(N): for j in range(i + 1, N): res += dist(coord[i], coord[j]) * 2 / N print(res)
false
9.090909
[ "-div = factorial(N)", "-idx = [i for i in range(N)]", "-for line in permutations(idx, N):", "- for i in range(N - 1):", "- res += dist(coord[line[i]], coord[line[i + 1]]) / div", "+for i in range(N):", "+ for j in range(i + 1, N):", "+ res += dist(coord[i], coord[j]) * 2 / N" ]
false
0.07597
0.038946
1.950637
[ "s997438160", "s364394662" ]
u344655022
p02554
python
s046674141
s518904168
90
66
67,428
61,852
Accepted
Accepted
26.67
import sys input = sys.stdin.readline INF = 10**18 sys.setrecursionlimit(10**6) import itertools as it import collections as cl from collections import deque import math from functools import reduce from collections import defaultdict D = 10 ** 9 + 7 def li(): return [int(x) for x in input().split()] def modpow(a, n, mod): res = 1 while n > 0: if n & 1: res = res * a % mod a = a * a % mod n >>= 1 return res N = int(eval(input())) total = modpow(10, N, D) A = total - modpow(9, N, D) B = total - modpow(9, N, D) C = total - modpow(8, N, D) ans = (A + B - C) % D print(ans)
D = 10 ** 9 + 7 def li(): return [int(x) for x in input().split()] N = int(eval(input())) total = pow(10, N, D) A = total - pow(9, N, D) B = total - pow(9, N, D) C = total - pow(8, N, D) ans = (A + B - C) % D print(ans)
34
14
660
234
import sys input = sys.stdin.readline INF = 10**18 sys.setrecursionlimit(10**6) import itertools as it import collections as cl from collections import deque import math from functools import reduce from collections import defaultdict D = 10**9 + 7 def li(): return [int(x) for x in input().split()] def modpow(a, n, mod): res = 1 while n > 0: if n & 1: res = res * a % mod a = a * a % mod n >>= 1 return res N = int(eval(input())) total = modpow(10, N, D) A = total - modpow(9, N, D) B = total - modpow(9, N, D) C = total - modpow(8, N, D) ans = (A + B - C) % D print(ans)
D = 10**9 + 7 def li(): return [int(x) for x in input().split()] N = int(eval(input())) total = pow(10, N, D) A = total - pow(9, N, D) B = total - pow(9, N, D) C = total - pow(8, N, D) ans = (A + B - C) % D print(ans)
false
58.823529
[ "-import sys", "-", "-input = sys.stdin.readline", "-INF = 10**18", "-sys.setrecursionlimit(10**6)", "-import itertools as it", "-import collections as cl", "-from collections import deque", "-import math", "-from functools import reduce", "-from collections import defaultdict", "-", "-def modpow(a, n, mod):", "- res = 1", "- while n > 0:", "- if n & 1:", "- res = res * a % mod", "- a = a * a % mod", "- n >>= 1", "- return res", "-", "-", "-total = modpow(10, N, D)", "-A = total - modpow(9, N, D)", "-B = total - modpow(9, N, D)", "-C = total - modpow(8, N, D)", "+total = pow(10, N, D)", "+A = total - pow(9, N, D)", "+B = total - pow(9, N, D)", "+C = total - pow(8, N, D)" ]
false
0.042795
0.041736
1.025368
[ "s046674141", "s518904168" ]
u908651435
p02386
python
s143362271
s072154603
290
250
5,612
5,612
Accepted
Accepted
13.79
class Dice: def __init__(self,t,f,r,l,b,u): self.a=[[t,f,r,l,b,u]] self.direction={'S':(4,0,2,3,5,1),'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),'Y':(0,3,1,4,2,5)} def roll(self,d,n): self.a[n]=[self.a[n][i] for i in self.direction[d]] n=int(eval(input())) for i in range(n): if i==0: t, f, r, l, b, u = list(map(int, input().split())) dice = Dice(t, f, r, l, b, u) else: a = list(map(int, input().split())) dice.a.append(a) s='SSSWEEE' w='YYYY' try: for u in range(n - 1): for t in range(u + 1, n): for j in s: for r in w: if dice.a[t] == dice.a[u]: raise Exception dice.roll(r, t) dice.roll(j, t) else: print('Yes') except: print('No')
class Dice: def __init__(self,t,f,r,l,b,u): self.a=[[t,f,r,l,b,u]] self.direction={'S':(4,0,2,3,5,1),'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),'U':(5,4,2,3,1,0)} def dice_tuple(self): self.b=tuple(self.a) def roll(self,d,n): self.a[n]=[self.a[n][i] for i in self.direction[d]] def roll2(self,d,n): self.a[n]=[self.b[n][i] for i in self.direction[d]] def roll_w(self, n): self.a[n] = [self.a[n][i] for i in (0, 3, 1, 4, 2, 5)] n=int(eval(input())) for i in range(n): if i==0: t, f, r, l, b, u = list(map(int, input().split())) dice = Dice(t, f, r, l, b, u) else: a = list(map(int, input().split())) dice.a.append(a) dice.dice_tuple() s='SNEWUU' try: for u in range(n - 1): for t in range(u + 1, n): for j in s: for r in range(4): if dice.a[t] == dice.a[u]: raise Exception dice.roll_w(t) dice.roll2(j, t) else: print('Yes') except: print('No')
29
35
872
1,121
class Dice: def __init__(self, t, f, r, l, b, u): self.a = [[t, f, r, l, b, u]] self.direction = { "S": (4, 0, 2, 3, 5, 1), "N": (1, 5, 2, 3, 0, 4), "E": (3, 1, 0, 5, 4, 2), "W": (2, 1, 5, 0, 4, 3), "Y": (0, 3, 1, 4, 2, 5), } def roll(self, d, n): self.a[n] = [self.a[n][i] for i in self.direction[d]] n = int(eval(input())) for i in range(n): if i == 0: t, f, r, l, b, u = list(map(int, input().split())) dice = Dice(t, f, r, l, b, u) else: a = list(map(int, input().split())) dice.a.append(a) s = "SSSWEEE" w = "YYYY" try: for u in range(n - 1): for t in range(u + 1, n): for j in s: for r in w: if dice.a[t] == dice.a[u]: raise Exception dice.roll(r, t) dice.roll(j, t) else: print("Yes") except: print("No")
class Dice: def __init__(self, t, f, r, l, b, u): self.a = [[t, f, r, l, b, u]] self.direction = { "S": (4, 0, 2, 3, 5, 1), "N": (1, 5, 2, 3, 0, 4), "E": (3, 1, 0, 5, 4, 2), "W": (2, 1, 5, 0, 4, 3), "U": (5, 4, 2, 3, 1, 0), } def dice_tuple(self): self.b = tuple(self.a) def roll(self, d, n): self.a[n] = [self.a[n][i] for i in self.direction[d]] def roll2(self, d, n): self.a[n] = [self.b[n][i] for i in self.direction[d]] def roll_w(self, n): self.a[n] = [self.a[n][i] for i in (0, 3, 1, 4, 2, 5)] n = int(eval(input())) for i in range(n): if i == 0: t, f, r, l, b, u = list(map(int, input().split())) dice = Dice(t, f, r, l, b, u) else: a = list(map(int, input().split())) dice.a.append(a) dice.dice_tuple() s = "SNEWUU" try: for u in range(n - 1): for t in range(u + 1, n): for j in s: for r in range(4): if dice.a[t] == dice.a[u]: raise Exception dice.roll_w(t) dice.roll2(j, t) else: print("Yes") except: print("No")
false
17.142857
[ "- \"Y\": (0, 3, 1, 4, 2, 5),", "+ \"U\": (5, 4, 2, 3, 1, 0),", "+", "+ def dice_tuple(self):", "+ self.b = tuple(self.a)", "+", "+ def roll2(self, d, n):", "+ self.a[n] = [self.b[n][i] for i in self.direction[d]]", "+", "+ def roll_w(self, n):", "+ self.a[n] = [self.a[n][i] for i in (0, 3, 1, 4, 2, 5)]", "-s = \"SSSWEEE\"", "-w = \"YYYY\"", "+dice.dice_tuple()", "+s = \"SNEWUU\"", "- for r in w:", "+ for r in range(4):", "- dice.roll(r, t)", "- dice.roll(j, t)", "+ dice.roll_w(t)", "+ dice.roll2(j, t)" ]
false
0.039589
0.038502
1.028239
[ "s143362271", "s072154603" ]
u729133443
p02782
python
s367505199
s586556798
340
219
82,220
55,660
Accepted
Accepted
35.59
def main(): import sys M=10**9+7 r1,c1,r2,c2=list(map(int,sys.stdin.buffer.readline().split())) n=r2+c2+2 val=1 fac=[val] append=fac.append for i in range(1,n+1): val=val*i%M append(val) pr1=pow(fac[r1],M-2,M) pc1=pow(fac[c1],M-2,M) pr2=pow(fac[r2+1],M-2,M) pc2=pow(fac[c2+1],M-2,M) print(((fac[r2+c2+2]*pr2*pc2-fac[r2+c1+1]*pr2*pc1-fac[r1+c2+1]*pr1*pc2+fac[r1+c1]*pr1*pc1)%M)) main()
M=10**9+7 r1,c1,r2,c2=list(map(int,input().split())) n=r2+c2+2 fac=[0]*(n+1) fac[0]=val=1 for i in range(1,n+1):fac[i]=val=val*i%M pr1=pow(fac[r1],M-2,M) pc1=pow(fac[c1],M-2,M) pr2=pow(fac[r2+1],M-2,M) pc2=pow(fac[c2+1],M-2,M) a=fac[r2+c2+2]*pr2*pc2 a-=fac[r2+c1+1]*pr2*pc1 a-=fac[r1+c2+1]*pr1*pc2 a+=fac[r1+c1]*pr1*pc1 print((a%M))
17
15
426
338
def main(): import sys M = 10**9 + 7 r1, c1, r2, c2 = list(map(int, sys.stdin.buffer.readline().split())) n = r2 + c2 + 2 val = 1 fac = [val] append = fac.append for i in range(1, n + 1): val = val * i % M append(val) pr1 = pow(fac[r1], M - 2, M) pc1 = pow(fac[c1], M - 2, M) pr2 = pow(fac[r2 + 1], M - 2, M) pc2 = pow(fac[c2 + 1], M - 2, M) print( ( ( fac[r2 + c2 + 2] * pr2 * pc2 - fac[r2 + c1 + 1] * pr2 * pc1 - fac[r1 + c2 + 1] * pr1 * pc2 + fac[r1 + c1] * pr1 * pc1 ) % M ) ) main()
M = 10**9 + 7 r1, c1, r2, c2 = list(map(int, input().split())) n = r2 + c2 + 2 fac = [0] * (n + 1) fac[0] = val = 1 for i in range(1, n + 1): fac[i] = val = val * i % M pr1 = pow(fac[r1], M - 2, M) pc1 = pow(fac[c1], M - 2, M) pr2 = pow(fac[r2 + 1], M - 2, M) pc2 = pow(fac[c2 + 1], M - 2, M) a = fac[r2 + c2 + 2] * pr2 * pc2 a -= fac[r2 + c1 + 1] * pr2 * pc1 a -= fac[r1 + c2 + 1] * pr1 * pc2 a += fac[r1 + c1] * pr1 * pc1 print((a % M))
false
11.764706
[ "-def main():", "- import sys", "-", "- M = 10**9 + 7", "- r1, c1, r2, c2 = list(map(int, sys.stdin.buffer.readline().split()))", "- n = r2 + c2 + 2", "- val = 1", "- fac = [val]", "- append = fac.append", "- for i in range(1, n + 1):", "- val = val * i % M", "- append(val)", "- pr1 = pow(fac[r1], M - 2, M)", "- pc1 = pow(fac[c1], M - 2, M)", "- pr2 = pow(fac[r2 + 1], M - 2, M)", "- pc2 = pow(fac[c2 + 1], M - 2, M)", "- print(", "- (", "- (", "- fac[r2 + c2 + 2] * pr2 * pc2", "- - fac[r2 + c1 + 1] * pr2 * pc1", "- - fac[r1 + c2 + 1] * pr1 * pc2", "- + fac[r1 + c1] * pr1 * pc1", "- )", "- % M", "- )", "- )", "-", "-", "-main()", "+M = 10**9 + 7", "+r1, c1, r2, c2 = list(map(int, input().split()))", "+n = r2 + c2 + 2", "+fac = [0] * (n + 1)", "+fac[0] = val = 1", "+for i in range(1, n + 1):", "+ fac[i] = val = val * i % M", "+pr1 = pow(fac[r1], M - 2, M)", "+pc1 = pow(fac[c1], M - 2, M)", "+pr2 = pow(fac[r2 + 1], M - 2, M)", "+pc2 = pow(fac[c2 + 1], M - 2, M)", "+a = fac[r2 + c2 + 2] * pr2 * pc2", "+a -= fac[r2 + c1 + 1] * pr2 * pc1", "+a -= fac[r1 + c2 + 1] * pr1 * pc2", "+a += fac[r1 + c1] * pr1 * pc1", "+print((a % M))" ]
false
0.044066
0.04315
1.021231
[ "s367505199", "s586556798" ]
u708255304
p02695
python
s461757134
s823520853
738
345
9,348
9,100
Accepted
Accepted
53.25
import sys from copy import deepcopy sys.setrecursionlimit(10**7) def dfs(now): global ans if len(now) == N: tmp_ans = 0 for a, b, c, d in query: a -= 1 b -= 1 if now[b] - now[a] == c: tmp_ans += d ans = max(tmp_ans, ans) else: for i in range(now[-1], M+1): tmp = deepcopy(now) tmp.append(i) dfs(tmp) N, M, Q = list(map(int, input().split())) # N個の数列, 上限M, Q個のクエリ query = [list(map(int, input().split())) for _ in range(Q)] A = [1] ans = 0 dfs(A) print(ans)
# 全探索で行う N, M, Q = list(map(int, input().split())) query = [list(map(int, input().split())) for _ in range(Q)] A = [1] def dfs(now): if len(now) == N: global ans tmp_ans = 0 for a, b, c, d in query: a -= 1 b -= 1 if now[b] - now[a] == c: tmp_ans += d ans = max(ans, tmp_ans) else: for i in range(now[-1], M+1): tmp = now.copy() tmp.append(i) dfs(tmp) ans = 0 dfs(A) print(ans)
29
25
618
534
import sys from copy import deepcopy sys.setrecursionlimit(10**7) def dfs(now): global ans if len(now) == N: tmp_ans = 0 for a, b, c, d in query: a -= 1 b -= 1 if now[b] - now[a] == c: tmp_ans += d ans = max(tmp_ans, ans) else: for i in range(now[-1], M + 1): tmp = deepcopy(now) tmp.append(i) dfs(tmp) N, M, Q = list(map(int, input().split())) # N個の数列, 上限M, Q個のクエリ query = [list(map(int, input().split())) for _ in range(Q)] A = [1] ans = 0 dfs(A) print(ans)
# 全探索で行う N, M, Q = list(map(int, input().split())) query = [list(map(int, input().split())) for _ in range(Q)] A = [1] def dfs(now): if len(now) == N: global ans tmp_ans = 0 for a, b, c, d in query: a -= 1 b -= 1 if now[b] - now[a] == c: tmp_ans += d ans = max(ans, tmp_ans) else: for i in range(now[-1], M + 1): tmp = now.copy() tmp.append(i) dfs(tmp) ans = 0 dfs(A) print(ans)
false
13.793103
[ "-import sys", "-from copy import deepcopy", "-", "-sys.setrecursionlimit(10**7)", "+# 全探索で行う", "+N, M, Q = list(map(int, input().split()))", "+query = [list(map(int, input().split())) for _ in range(Q)]", "+A = [1]", "- global ans", "+ global ans", "- ans = max(tmp_ans, ans)", "+ ans = max(ans, tmp_ans)", "- tmp = deepcopy(now)", "+ tmp = now.copy()", "-N, M, Q = list(map(int, input().split())) # N個の数列, 上限M, Q個のクエリ", "-query = [list(map(int, input().split())) for _ in range(Q)]", "-A = [1]" ]
false
0.148439
0.047825
3.103764
[ "s461757134", "s823520853" ]
u316603606
p03813
python
s497787895
s135235677
29
24
9,132
8,912
Accepted
Accepted
17.24
x = int (eval(input ())) if x < 1200: print ('ABC') else: print ('ARC')
x = int (eval(input ())) if x>=1200: print ('ARC') else: print ('ABC')
5
5
74
72
x = int(eval(input())) if x < 1200: print("ABC") else: print("ARC")
x = int(eval(input())) if x >= 1200: print("ARC") else: print("ABC")
false
0
[ "-if x < 1200:", "+if x >= 1200:", "+ print(\"ARC\")", "+else:", "-else:", "- print(\"ARC\")" ]
false
0.034785
0.038802
0.89649
[ "s497787895", "s135235677" ]
u760760982
p02683
python
s649048758
s040468442
104
93
9,220
9,056
Accepted
Accepted
10.58
n,m,x = list(map(int,input().split())) c = [list(map(int,input().split())) for _ in range(n)] ans = [] #n冊の本において買うか買わないかの2通りなので2**n for i in range(2**n): #リストの中身は値段1と理解度m個 a = [0]*(m+1) com = i for j in range(n): if com >= (2**(n-j-1)): com -= 2**(n-j-1) for k in range(m+1): a[k] += c[j][k] price = a[0] del a[0] if all(a[j]>=x for j in range(m)): #print(price) ans.append(price) if len(ans) == 0: print((-1)) else: print((min(ans)))
n,m,x = list(map(int,input().split())) c = [list(map(int,input().split())) for _ in range(n)] ans = [] #n冊の本において買うか買わないかの2通りなので2**n for i in range(2**n): #リストの中身は値段1と理解度m個 a = [0]*m price = 0 for j in range(n): #n冊あるうちj冊目を買うか買わないかを判定 if ((i >> j) & 1): for k in range(m): a[k] += c[j][k+1] #j冊めを買うので、合計金額を増やす price += c[j][0] if all(j >= x for j in a): ans.append(price) if len(ans) == 0: print("-1") else: print((min(ans)))
22
22
545
542
n, m, x = list(map(int, input().split())) c = [list(map(int, input().split())) for _ in range(n)] ans = [] # n冊の本において買うか買わないかの2通りなので2**n for i in range(2**n): # リストの中身は値段1と理解度m個 a = [0] * (m + 1) com = i for j in range(n): if com >= (2 ** (n - j - 1)): com -= 2 ** (n - j - 1) for k in range(m + 1): a[k] += c[j][k] price = a[0] del a[0] if all(a[j] >= x for j in range(m)): # print(price) ans.append(price) if len(ans) == 0: print((-1)) else: print((min(ans)))
n, m, x = list(map(int, input().split())) c = [list(map(int, input().split())) for _ in range(n)] ans = [] # n冊の本において買うか買わないかの2通りなので2**n for i in range(2**n): # リストの中身は値段1と理解度m個 a = [0] * m price = 0 for j in range(n): # n冊あるうちj冊目を買うか買わないかを判定 if (i >> j) & 1: for k in range(m): a[k] += c[j][k + 1] # j冊めを買うので、合計金額を増やす price += c[j][0] if all(j >= x for j in a): ans.append(price) if len(ans) == 0: print("-1") else: print((min(ans)))
false
0
[ "- a = [0] * (m + 1)", "- com = i", "+ a = [0] * m", "+ price = 0", "- if com >= (2 ** (n - j - 1)):", "- com -= 2 ** (n - j - 1)", "- for k in range(m + 1):", "- a[k] += c[j][k]", "- price = a[0]", "- del a[0]", "- if all(a[j] >= x for j in range(m)):", "- # print(price)", "+ # n冊あるうちj冊目を買うか買わないかを判定", "+ if (i >> j) & 1:", "+ for k in range(m):", "+ a[k] += c[j][k + 1]", "+ # j冊めを買うので、合計金額を増やす", "+ price += c[j][0]", "+ if all(j >= x for j in a):", "- print((-1))", "+ print(\"-1\")" ]
false
0.049142
0.048942
1.004076
[ "s649048758", "s040468442" ]
u970899068
p02597
python
s287056241
s206846512
132
90
93,476
95,848
Accepted
Accepted
31.82
n=int(eval(input())) a=list(eval(input())) # あかのインデックス RR=[-1] # しろのインデックス WW=[] for i in range(n): if a[i]=='R': RR.append(i) else: WW.append(i) WW.append(float('inf')) if a.count('R')==0 or a.count('R')==n: print((0)) exit() if a.count('W')==1 or a.count('R')==1: print((1)) exit() for i in range(len(RR)-1): if RR[-2-i]<WW[i+1]: ans=i+1 break # 白くするコスト wc = [0] # 赤くするコスト rc = [0] import itertools a = ['R'] + a if a[-1] == 'R': a.append('W') else: a.append('R') cntr = 0 cntw = 0 flag1 = True for i in range(n + 2): if a[i] == 'W': cntr += 1 if flag1: flag1 = False else: if cntw != 0: wc.append(cntw) cntw = 0 else: if flag1: continue else: cntw += 1 if cntr != 0: rc.append(cntr) cntr = 0 wc = list(itertools.accumulate(wc)) rc = list(itertools.accumulate(rc)) for i in range(len(wc)): ans = min(ans, rc[i] + wc[-1] - wc[i]) print(ans)
n=int(eval(input())) a=list(eval(input())) # あかのインデックス RR=[] for i in range(n): if a[i]=='R': RR.append(i) v=a.count('R') ans=v for i in range(len(RR)): if RR[i]+1<=v: ans-=1 print(ans)
70
17
1,152
217
n = int(eval(input())) a = list(eval(input())) # あかのインデックス RR = [-1] # しろのインデックス WW = [] for i in range(n): if a[i] == "R": RR.append(i) else: WW.append(i) WW.append(float("inf")) if a.count("R") == 0 or a.count("R") == n: print((0)) exit() if a.count("W") == 1 or a.count("R") == 1: print((1)) exit() for i in range(len(RR) - 1): if RR[-2 - i] < WW[i + 1]: ans = i + 1 break # 白くするコスト wc = [0] # 赤くするコスト rc = [0] import itertools a = ["R"] + a if a[-1] == "R": a.append("W") else: a.append("R") cntr = 0 cntw = 0 flag1 = True for i in range(n + 2): if a[i] == "W": cntr += 1 if flag1: flag1 = False else: if cntw != 0: wc.append(cntw) cntw = 0 else: if flag1: continue else: cntw += 1 if cntr != 0: rc.append(cntr) cntr = 0 wc = list(itertools.accumulate(wc)) rc = list(itertools.accumulate(rc)) for i in range(len(wc)): ans = min(ans, rc[i] + wc[-1] - wc[i]) print(ans)
n = int(eval(input())) a = list(eval(input())) # あかのインデックス RR = [] for i in range(n): if a[i] == "R": RR.append(i) v = a.count("R") ans = v for i in range(len(RR)): if RR[i] + 1 <= v: ans -= 1 print(ans)
false
75.714286
[ "-RR = [-1]", "-# しろのインデックス", "-WW = []", "+RR = []", "- else:", "- WW.append(i)", "-WW.append(float(\"inf\"))", "-if a.count(\"R\") == 0 or a.count(\"R\") == n:", "- print((0))", "- exit()", "-if a.count(\"W\") == 1 or a.count(\"R\") == 1:", "- print((1))", "- exit()", "-for i in range(len(RR) - 1):", "- if RR[-2 - i] < WW[i + 1]:", "- ans = i + 1", "- break", "-# 白くするコスト", "-wc = [0]", "-# 赤くするコスト", "-rc = [0]", "-import itertools", "-", "-a = [\"R\"] + a", "-if a[-1] == \"R\":", "- a.append(\"W\")", "-else:", "- a.append(\"R\")", "-cntr = 0", "-cntw = 0", "-flag1 = True", "-for i in range(n + 2):", "- if a[i] == \"W\":", "- cntr += 1", "- if flag1:", "- flag1 = False", "- else:", "- if cntw != 0:", "- wc.append(cntw)", "- cntw = 0", "- else:", "- if flag1:", "- continue", "- else:", "- cntw += 1", "- if cntr != 0:", "- rc.append(cntr)", "- cntr = 0", "-wc = list(itertools.accumulate(wc))", "-rc = list(itertools.accumulate(rc))", "-for i in range(len(wc)):", "- ans = min(ans, rc[i] + wc[-1] - wc[i])", "+v = a.count(\"R\")", "+ans = v", "+for i in range(len(RR)):", "+ if RR[i] + 1 <= v:", "+ ans -= 1" ]
false
0.1852
0.231684
0.799363
[ "s287056241", "s206846512" ]
u059210959
p02713
python
s406717833
s791543433
1,980
385
10,940
10,948
Accepted
Accepted
80.56
# encoding:utf-8 import copy import random import bisect #bisect_left これで二部探索の大小検索が行える import fractions #最小公倍数などはこっち # import math import sys import collections from math import gcd mod = 10**9+7 sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000 d = collections.deque() def LI(): return list(map(int, sys.stdin.readline().split())) K = int(eval(input())) """ answer 1 ans = 0 tmp = {} for i in range(201): tmp[i] = 0 for i in range(1, K +1): for j in range(1, K +1): tmp[math.gcd(i, j)] += 1 for k in range(1, K +1): for key in tmp.keys(): ans += math.gcd(key, k) * tmp[key] print(ans) """ ans = 0 for i in range(1, K + 1): for j in range(1, K + 1): for k in range(1, K +1): ans += gcd(gcd(i,j), k) print(ans)
# encoding:utf-8 import copy import random import bisect #bisect_left これで二部探索の大小検索が行える import fractions #最小公倍数などはこっち # import math import sys import collections from math import gcd mod = 10**9+7 sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000 d = collections.deque() def LI(): return list(map(int, sys.stdin.readline().split())) K = int(eval(input())) """ answer 1 ans = 0 tmp = {} for i in range(201): tmp[i] = 0 for i in range(1, K +1): for j in range(1, K +1): tmp[math.gcd(i, j)] += 1 for k in range(1, K +1): for key in tmp.keys(): ans += math.gcd(key, k) * tmp[key] print(ans) """ """answer 2 ぎりぎり ans = 0 for i in range(1, K + 1): for j in range(1, K + 1): for k in range(1, K +1): ans += gcd(gcd(i,j), k) print(ans) """ ans = 0 # (1,2,3) for i in range(1, K +1): for j in range(i+ 1, K + 1): for k in range(j + 1, K + 1): ans += gcd(gcd(i, j), k) * 6 # (1,2,2) for i in range(1, K + 1): for j in range(i+ 1, K+1): ans += gcd(i, j) * 3 * 2 # (1,1,1) for i in range(1, K +1): ans += i print(ans)
40
62
800
1,163
# encoding:utf-8 import copy import random import bisect # bisect_left これで二部探索の大小検索が行える import fractions # 最小公倍数などはこっち # import math import sys import collections from math import gcd mod = 10**9 + 7 sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000 d = collections.deque() def LI(): return list(map(int, sys.stdin.readline().split())) K = int(eval(input())) """ answer 1 ans = 0 tmp = {} for i in range(201): tmp[i] = 0 for i in range(1, K +1): for j in range(1, K +1): tmp[math.gcd(i, j)] += 1 for k in range(1, K +1): for key in tmp.keys(): ans += math.gcd(key, k) * tmp[key] print(ans) """ ans = 0 for i in range(1, K + 1): for j in range(1, K + 1): for k in range(1, K + 1): ans += gcd(gcd(i, j), k) print(ans)
# encoding:utf-8 import copy import random import bisect # bisect_left これで二部探索の大小検索が行える import fractions # 最小公倍数などはこっち # import math import sys import collections from math import gcd mod = 10**9 + 7 sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000 d = collections.deque() def LI(): return list(map(int, sys.stdin.readline().split())) K = int(eval(input())) """ answer 1 ans = 0 tmp = {} for i in range(201): tmp[i] = 0 for i in range(1, K +1): for j in range(1, K +1): tmp[math.gcd(i, j)] += 1 for k in range(1, K +1): for key in tmp.keys(): ans += math.gcd(key, k) * tmp[key] print(ans) """ """answer 2 ぎりぎり ans = 0 for i in range(1, K + 1): for j in range(1, K + 1): for k in range(1, K +1): ans += gcd(gcd(i,j), k) print(ans) """ ans = 0 # (1,2,3) for i in range(1, K + 1): for j in range(i + 1, K + 1): for k in range(j + 1, K + 1): ans += gcd(gcd(i, j), k) * 6 # (1,2,2) for i in range(1, K + 1): for j in range(i + 1, K + 1): ans += gcd(i, j) * 3 * 2 # (1,1,1) for i in range(1, K + 1): ans += i print(ans)
false
35.483871
[ "+\"\"\"answer 2 ぎりぎり", "- for k in range(1, K + 1):", "- ans += gcd(gcd(i, j), k)", "+ for k in range(1, K +1):", "+ ans += gcd(gcd(i,j), k)", "+\"\"\"", "+ans = 0", "+# (1,2,3)", "+for i in range(1, K + 1):", "+ for j in range(i + 1, K + 1):", "+ for k in range(j + 1, K + 1):", "+ ans += gcd(gcd(i, j), k) * 6", "+# (1,2,2)", "+for i in range(1, K + 1):", "+ for j in range(i + 1, K + 1):", "+ ans += gcd(i, j) * 3 * 2", "+# (1,1,1)", "+for i in range(1, K + 1):", "+ ans += i", "+print(ans)" ]
false
0.092025
0.057113
1.611287
[ "s406717833", "s791543433" ]
u203843959
p02735
python
s102500293
s437792325
318
29
54,492
3,316
Accepted
Accepted
90.88
import heapq H,W=list(map(int,input().split())) mat=[] for i in range(H): array=[x=='.' for x in eval(input())] mat.append(array) #print(mat) #convert mat to graph #(i0,j0)->(i1,j1,dist) graph={} if mat[0][0]: graph[(0,0)]=[(1,1,0)] else: graph[(0,0)]=[(1,1,1)] for i in range(H): for j in range(W): graph[(i+1,j+1)]=[] if mat[i][j]: if i<H-1: if mat[i+1][j]: graph[(i+1,j+1)].append((i+2,j+1,0)) else: graph[(i+1,j+1)].append((i+2,j+1,1)) if j<W-1: if mat[i][j+1]: graph[(i+1,j+1)].append((i+1,j+2,0)) else: graph[(i+1,j+1)].append((i+1,j+2,1)) else: if i<H-1: graph[(i+1,j+1)].append((i+2,j+1,0)) if j<W-1: graph[(i+1,j+1)].append((i+1,j+2,0)) #print(graph) # init used,queue,dist dist={} hq=[] dist[(0,0)]=0 heapq.heappush(hq,(0,0,0)) for i in range(1,H+1): for j in range(1,W+1): dist[(i,j)]=10**9 heapq.heappush(hq,(i+j,i,j)) #print(queue) #dkjstra while(True): if len(hq)==0: break ij,ii,jj=heapq.heappop(hq) candlist=graph[(ii,jj)] for cand in candlist: xx,yy,dd=cand dist[(xx,yy)]=min(dist[(xx,yy)],dist[(ii,jj)]+dd) print((dist[(H,W)]))
import heapq H,W=list(map(int,input().split())) mat=[] for i in range(H): array=[x=='.' for x in eval(input())] mat.append(array) #print(mat) dist=[] for i in range(H): dist.append([-1]*W) if mat[0][0]: dist[0][0]=0 else: dist[0][0]=1 for i in range(1,H): if mat[i-1][0] and not mat[i][0]: dist[i][0]=dist[i-1][0]+1 else: dist[i][0]=dist[i-1][0] for j in range(1,W): if mat[0][j-1] and not mat[0][j]: dist[0][j]=dist[0][j-1]+1 else: dist[0][j]=dist[0][j-1] for i in range(1,H): for j in range(1,W): if mat[i-1][j] and not mat[i][j]: dist1=dist[i-1][j]+1 else: dist1=dist[i-1][j] if mat[i][j-1] and not mat[i][j]: dist2=dist[i][j-1]+1 else: dist2=dist[i][j-1] dist[i][j]=min(dist1,dist2) #print(dist) print((dist[H-1][W-1]))
63
47
1,272
869
import heapq H, W = list(map(int, input().split())) mat = [] for i in range(H): array = [x == "." for x in eval(input())] mat.append(array) # print(mat) # convert mat to graph # (i0,j0)->(i1,j1,dist) graph = {} if mat[0][0]: graph[(0, 0)] = [(1, 1, 0)] else: graph[(0, 0)] = [(1, 1, 1)] for i in range(H): for j in range(W): graph[(i + 1, j + 1)] = [] if mat[i][j]: if i < H - 1: if mat[i + 1][j]: graph[(i + 1, j + 1)].append((i + 2, j + 1, 0)) else: graph[(i + 1, j + 1)].append((i + 2, j + 1, 1)) if j < W - 1: if mat[i][j + 1]: graph[(i + 1, j + 1)].append((i + 1, j + 2, 0)) else: graph[(i + 1, j + 1)].append((i + 1, j + 2, 1)) else: if i < H - 1: graph[(i + 1, j + 1)].append((i + 2, j + 1, 0)) if j < W - 1: graph[(i + 1, j + 1)].append((i + 1, j + 2, 0)) # print(graph) # init used,queue,dist dist = {} hq = [] dist[(0, 0)] = 0 heapq.heappush(hq, (0, 0, 0)) for i in range(1, H + 1): for j in range(1, W + 1): dist[(i, j)] = 10**9 heapq.heappush(hq, (i + j, i, j)) # print(queue) # dkjstra while True: if len(hq) == 0: break ij, ii, jj = heapq.heappop(hq) candlist = graph[(ii, jj)] for cand in candlist: xx, yy, dd = cand dist[(xx, yy)] = min(dist[(xx, yy)], dist[(ii, jj)] + dd) print((dist[(H, W)]))
import heapq H, W = list(map(int, input().split())) mat = [] for i in range(H): array = [x == "." for x in eval(input())] mat.append(array) # print(mat) dist = [] for i in range(H): dist.append([-1] * W) if mat[0][0]: dist[0][0] = 0 else: dist[0][0] = 1 for i in range(1, H): if mat[i - 1][0] and not mat[i][0]: dist[i][0] = dist[i - 1][0] + 1 else: dist[i][0] = dist[i - 1][0] for j in range(1, W): if mat[0][j - 1] and not mat[0][j]: dist[0][j] = dist[0][j - 1] + 1 else: dist[0][j] = dist[0][j - 1] for i in range(1, H): for j in range(1, W): if mat[i - 1][j] and not mat[i][j]: dist1 = dist[i - 1][j] + 1 else: dist1 = dist[i - 1][j] if mat[i][j - 1] and not mat[i][j]: dist2 = dist[i][j - 1] + 1 else: dist2 = dist[i][j - 1] dist[i][j] = min(dist1, dist2) # print(dist) print((dist[H - 1][W - 1]))
false
25.396825
[ "-# convert mat to graph", "-# (i0,j0)->(i1,j1,dist)", "-graph = {}", "+dist = []", "+for i in range(H):", "+ dist.append([-1] * W)", "- graph[(0, 0)] = [(1, 1, 0)]", "+ dist[0][0] = 0", "- graph[(0, 0)] = [(1, 1, 1)]", "-for i in range(H):", "- for j in range(W):", "- graph[(i + 1, j + 1)] = []", "- if mat[i][j]:", "- if i < H - 1:", "- if mat[i + 1][j]:", "- graph[(i + 1, j + 1)].append((i + 2, j + 1, 0))", "- else:", "- graph[(i + 1, j + 1)].append((i + 2, j + 1, 1))", "- if j < W - 1:", "- if mat[i][j + 1]:", "- graph[(i + 1, j + 1)].append((i + 1, j + 2, 0))", "- else:", "- graph[(i + 1, j + 1)].append((i + 1, j + 2, 1))", "+ dist[0][0] = 1", "+for i in range(1, H):", "+ if mat[i - 1][0] and not mat[i][0]:", "+ dist[i][0] = dist[i - 1][0] + 1", "+ else:", "+ dist[i][0] = dist[i - 1][0]", "+for j in range(1, W):", "+ if mat[0][j - 1] and not mat[0][j]:", "+ dist[0][j] = dist[0][j - 1] + 1", "+ else:", "+ dist[0][j] = dist[0][j - 1]", "+for i in range(1, H):", "+ for j in range(1, W):", "+ if mat[i - 1][j] and not mat[i][j]:", "+ dist1 = dist[i - 1][j] + 1", "- if i < H - 1:", "- graph[(i + 1, j + 1)].append((i + 2, j + 1, 0))", "- if j < W - 1:", "- graph[(i + 1, j + 1)].append((i + 1, j + 2, 0))", "-# print(graph)", "-# init used,queue,dist", "-dist = {}", "-hq = []", "-dist[(0, 0)] = 0", "-heapq.heappush(hq, (0, 0, 0))", "-for i in range(1, H + 1):", "- for j in range(1, W + 1):", "- dist[(i, j)] = 10**9", "- heapq.heappush(hq, (i + j, i, j))", "-# print(queue)", "-# dkjstra", "-while True:", "- if len(hq) == 0:", "- break", "- ij, ii, jj = heapq.heappop(hq)", "- candlist = graph[(ii, jj)]", "- for cand in candlist:", "- xx, yy, dd = cand", "- dist[(xx, yy)] = min(dist[(xx, yy)], dist[(ii, jj)] + dd)", "-print((dist[(H, W)]))", "+ dist1 = dist[i - 1][j]", "+ if mat[i][j - 1] and not mat[i][j]:", "+ dist2 = dist[i][j - 1] + 1", "+ else:", "+ dist2 = dist[i][j - 1]", "+ dist[i][j] = min(dist1, dist2)", "+# print(dist)", "+print((dist[H - 1][W - 1]))" ]
false
0.133108
0.035566
3.742626
[ "s102500293", "s437792325" ]
u146803137
p02989
python
s760097571
s160976456
84
65
14,428
20,516
Accepted
Accepted
22.62
import math def py(): print("Yes") def pn(): print("No") def iin(): x = int(eval(input())) return x neko = 0 nya = 0 nuko = 0 n = iin() d = [int(x) for x in input().split()] d.sort() neko = int(n/2 - 1) nuko = neko + 1 if d[neko] != d[nuko]: for i in range(d[nuko]-d[neko]): nya = nya + 1 print(nya)
n = int(eval(input())) d = list(map(int,input().split())) d = sorted(d) ans = d[n//2] - d[n//2-1] print(ans)
24
5
352
107
import math def py(): print("Yes") def pn(): print("No") def iin(): x = int(eval(input())) return x neko = 0 nya = 0 nuko = 0 n = iin() d = [int(x) for x in input().split()] d.sort() neko = int(n / 2 - 1) nuko = neko + 1 if d[neko] != d[nuko]: for i in range(d[nuko] - d[neko]): nya = nya + 1 print(nya)
n = int(eval(input())) d = list(map(int, input().split())) d = sorted(d) ans = d[n // 2] - d[n // 2 - 1] print(ans)
false
79.166667
[ "-import math", "-", "-", "-def py():", "- print(\"Yes\")", "-", "-", "-def pn():", "- print(\"No\")", "-", "-", "-def iin():", "- x = int(eval(input()))", "- return x", "-", "-", "-neko = 0", "-nya = 0", "-nuko = 0", "-n = iin()", "-d = [int(x) for x in input().split()]", "-d.sort()", "-neko = int(n / 2 - 1)", "-nuko = neko + 1", "-if d[neko] != d[nuko]:", "- for i in range(d[nuko] - d[neko]):", "- nya = nya + 1", "-print(nya)", "+n = int(eval(input()))", "+d = list(map(int, input().split()))", "+d = sorted(d)", "+ans = d[n // 2] - d[n // 2 - 1]", "+print(ans)" ]
false
0.076256
0.073193
1.041849
[ "s760097571", "s160976456" ]
u463950771
p03294
python
s861572064
s896842773
94
31
3,316
3,316
Accepted
Accepted
67.02
N = eval(input()) a = list(map(int, input().split())) summ = 1 for i in a: summ *= i summ2 = 0 for i in a: summ2 += (summ-1)% i print(summ2)
N = eval(input()) a = list(map(int, input().split())) summ2 = sum(a) - int(N) print(summ2)
12
6
156
91
N = eval(input()) a = list(map(int, input().split())) summ = 1 for i in a: summ *= i summ2 = 0 for i in a: summ2 += (summ - 1) % i print(summ2)
N = eval(input()) a = list(map(int, input().split())) summ2 = sum(a) - int(N) print(summ2)
false
50
[ "-summ = 1", "-for i in a:", "- summ *= i", "-summ2 = 0", "-for i in a:", "- summ2 += (summ - 1) % i", "+summ2 = sum(a) - int(N)" ]
false
0.037302
0.075643
0.493135
[ "s861572064", "s896842773" ]
u453055089
p02837
python
s316056385
s456148053
277
256
45,788
45,296
Accepted
Accepted
7.58
n = int(eval(input())) a_list = [] xy_list = [] for i in range(n): A = int(eval(input())) a_list.append(A) xy = [list(map(int, input().split())) for _ in range(A)] xy_list.append(xy) ans = 0 for i in range(2**n): flag = True for j in range(n): # 人jについて if (i >> j) & 1 == 1: # 人jが正直ならば for k in range(a_list[j]): # 人jの証言kについて if xy_list[j][k][1] == 1: m = xy_list[j][k][0] if (i >> m-1) & 1 != 1: # 矛盾発生(正直者のjの証言で正直者と確定したmが不親切だった) flag = False break elif xy_list[j][k][1] == 0: m = xy_list[j][k][0] if (i >> m-1) & 1 == 1: flag = False break if flag: i_bin = format(i, 'b') if ans < i_bin.count('1'): ans = i_bin.count('1') print(ans)
n = int(eval(input())) a = [0]*n xy = [0]*n for i in range(n): a[i] = int(eval(input())) xy[i] = [list(map(int, input().split())) for _ in range(a[i])] ans = 0 for i in range(2**n): flag = True for j in range(n): if i >> j & 1 == 1: # 右からj番目の人は正直もの for k in range(a[j]): if xy[j][k][1] == 1 and i >> (xy[j][k][0]-1) & 1 != 1: flag = False break elif xy[j][k][1] == 0 and i >> (xy[j][k][0]-1) & 1 != 0: flag = False break else: continue break if flag and ans < str(bin(i)).count("1"): ans = str(bin(i)).count("1") print(ans)
33
27
946
741
n = int(eval(input())) a_list = [] xy_list = [] for i in range(n): A = int(eval(input())) a_list.append(A) xy = [list(map(int, input().split())) for _ in range(A)] xy_list.append(xy) ans = 0 for i in range(2**n): flag = True for j in range(n): # 人jについて if (i >> j) & 1 == 1: # 人jが正直ならば for k in range(a_list[j]): # 人jの証言kについて if xy_list[j][k][1] == 1: m = xy_list[j][k][0] if (i >> m - 1) & 1 != 1: # 矛盾発生(正直者のjの証言で正直者と確定したmが不親切だった) flag = False break elif xy_list[j][k][1] == 0: m = xy_list[j][k][0] if (i >> m - 1) & 1 == 1: flag = False break if flag: i_bin = format(i, "b") if ans < i_bin.count("1"): ans = i_bin.count("1") print(ans)
n = int(eval(input())) a = [0] * n xy = [0] * n for i in range(n): a[i] = int(eval(input())) xy[i] = [list(map(int, input().split())) for _ in range(a[i])] ans = 0 for i in range(2**n): flag = True for j in range(n): if i >> j & 1 == 1: # 右からj番目の人は正直もの for k in range(a[j]): if xy[j][k][1] == 1 and i >> (xy[j][k][0] - 1) & 1 != 1: flag = False break elif xy[j][k][1] == 0 and i >> (xy[j][k][0] - 1) & 1 != 0: flag = False break else: continue break if flag and ans < str(bin(i)).count("1"): ans = str(bin(i)).count("1") print(ans)
false
18.181818
[ "-a_list = []", "-xy_list = []", "+a = [0] * n", "+xy = [0] * n", "- A = int(eval(input()))", "- a_list.append(A)", "- xy = [list(map(int, input().split())) for _ in range(A)]", "- xy_list.append(xy)", "+ a[i] = int(eval(input()))", "+ xy[i] = [list(map(int, input().split())) for _ in range(a[i])]", "- for j in range(n): # 人jについて", "- if (i >> j) & 1 == 1: # 人jが正直ならば", "- for k in range(a_list[j]): # 人jの証言kについて", "- if xy_list[j][k][1] == 1:", "- m = xy_list[j][k][0]", "- if (i >> m - 1) & 1 != 1: # 矛盾発生(正直者のjの証言で正直者と確定したmが不親切だった)", "- flag = False", "- break", "- elif xy_list[j][k][1] == 0:", "- m = xy_list[j][k][0]", "- if (i >> m - 1) & 1 == 1:", "- flag = False", "- break", "- if flag:", "- i_bin = format(i, \"b\")", "- if ans < i_bin.count(\"1\"):", "- ans = i_bin.count(\"1\")", "+ for j in range(n):", "+ if i >> j & 1 == 1: # 右からj番目の人は正直もの", "+ for k in range(a[j]):", "+ if xy[j][k][1] == 1 and i >> (xy[j][k][0] - 1) & 1 != 1:", "+ flag = False", "+ break", "+ elif xy[j][k][1] == 0 and i >> (xy[j][k][0] - 1) & 1 != 0:", "+ flag = False", "+ break", "+ else:", "+ continue", "+ break", "+ if flag and ans < str(bin(i)).count(\"1\"):", "+ ans = str(bin(i)).count(\"1\")" ]
false
0.037732
0.044729
0.843557
[ "s316056385", "s456148053" ]
u102278909
p02848
python
s049711696
s086851630
267
207
48,496
42,472
Accepted
Accepted
22.47
# coding: utf-8 import sys import math import collections import itertools from inspect import currentframe INF = 10 ** 10 MOD = 10 ** 9 + 7 def input() : return sys.stdin.readline().strip() def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y) def lcm(x, y) : return (x * y) // gcd(x, y) def I() : return int(input()) def MI() : return map(int, input().split()) def LI() : return [int(x) for x in input().split()] def RI(N) : return [int(input()) for _ in range(N)] def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)] def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args)) N = I() S = input() alp = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] for s in S: print(alp[(alp.index(s) + N) % 26], end="")
# coding: utf-8 import sys import math import collections import itertools INF = 10 ** 10 MOD = 10 ** 9 + 7 def input() : return sys.stdin.readline().strip() def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y) def lcm(x, y) : return (x * y) // gcd(x, y) def I() : return int(input()) def LI() : return [int(x) for x in input().split()] def RI(N) : return [int(input()) for _ in range(N)] def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)] def PL(L) : print(*L, sep="\n") N = I() S = input() for s in S: print(chr(65 + (ord(s) - 65 + N) % 26), end="")
26
22
957
608
# coding: utf-8 import sys import math import collections import itertools from inspect import currentframe INF = 10**10 MOD = 10**9 + 7 def input(): return sys.stdin.readline().strip() def gcd(x, y): return y if x % y == 0 else gcd(y, x % y) def lcm(x, y): return (x * y) // gcd(x, y) def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return [int(x) for x in input().split()] def RI(N): return [int(input()) for _ in range(N)] def LRI(N): return [[int(x) for x in input().split()] for _ in range(N)] def chkprint(*args): names = {id(v): k for k, v in currentframe().f_back.f_locals.items()} print(", ".join(names.get(id(arg), "???") + " = " + repr(arg) for arg in args)) N = I() S = input() alp = [ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", ] for s in S: print(alp[(alp.index(s) + N) % 26], end="")
# coding: utf-8 import sys import math import collections import itertools INF = 10**10 MOD = 10**9 + 7 def input(): return sys.stdin.readline().strip() def gcd(x, y): return y if x % y == 0 else gcd(y, x % y) def lcm(x, y): return (x * y) // gcd(x, y) def I(): return int(input()) def LI(): return [int(x) for x in input().split()] def RI(N): return [int(input()) for _ in range(N)] def LRI(N): return [[int(x) for x in input().split()] for _ in range(N)] def PL(L): print(*L, sep="\n") N = I() S = input() for s in S: print(chr(65 + (ord(s) - 65 + N) % 26), end="")
false
15.384615
[ "-from inspect import currentframe", "-def MI():", "- return map(int, input().split())", "-", "-", "-def chkprint(*args):", "- names = {id(v): k for k, v in currentframe().f_back.f_locals.items()}", "- print(\", \".join(names.get(id(arg), \"???\") + \" = \" + repr(arg) for arg in args))", "+def PL(L):", "+ print(*L, sep=\"\\n\")", "-alp = [", "- \"A\",", "- \"B\",", "- \"C\",", "- \"D\",", "- \"E\",", "- \"F\",", "- \"G\",", "- \"H\",", "- \"I\",", "- \"J\",", "- \"K\",", "- \"L\",", "- \"M\",", "- \"N\",", "- \"O\",", "- \"P\",", "- \"Q\",", "- \"R\",", "- \"S\",", "- \"T\",", "- \"U\",", "- \"V\",", "- \"W\",", "- \"X\",", "- \"Y\",", "- \"Z\",", "-]", "- print(alp[(alp.index(s) + N) % 26], end=\"\")", "+ print(chr(65 + (ord(s) - 65 + N) % 26), end=\"\")" ]
false
0.070537
0.045617
1.546288
[ "s049711696", "s086851630" ]
u911575040
p03287
python
s301424151
s854961495
104
92
17,368
16,996
Accepted
Accepted
11.54
import collections N, M = list(map(int, input().split())) A = [int(i)%M for i in input().split()] B = [0] sum_ = 0 for a in A: sum_ = (sum_ + a) % M B.append(sum_) b = collections.Counter(B) ans = 0 for c in list(b.values()): ans += int(c * (c - 1) / 2) print(ans)
from collections import Counter from itertools import accumulate from operator import add, mul n,m=list(map(int,input().split())) a=list(map(int,input().split())) ans=0 b= list(accumulate(a, add)) b=list([x%m for x in b]) c=Counter(b) c[0]=c[0]+1 ans=0 for i in list(c.values()): ans+=i*(i-1)//2 print(ans)
13
15
276
318
import collections N, M = list(map(int, input().split())) A = [int(i) % M for i in input().split()] B = [0] sum_ = 0 for a in A: sum_ = (sum_ + a) % M B.append(sum_) b = collections.Counter(B) ans = 0 for c in list(b.values()): ans += int(c * (c - 1) / 2) print(ans)
from collections import Counter from itertools import accumulate from operator import add, mul n, m = list(map(int, input().split())) a = list(map(int, input().split())) ans = 0 b = list(accumulate(a, add)) b = list([x % m for x in b]) c = Counter(b) c[0] = c[0] + 1 ans = 0 for i in list(c.values()): ans += i * (i - 1) // 2 print(ans)
false
13.333333
[ "-import collections", "+from collections import Counter", "+from itertools import accumulate", "+from operator import add, mul", "-N, M = list(map(int, input().split()))", "-A = [int(i) % M for i in input().split()]", "-B = [0]", "-sum_ = 0", "-for a in A:", "- sum_ = (sum_ + a) % M", "- B.append(sum_)", "-b = collections.Counter(B)", "+n, m = list(map(int, input().split()))", "+a = list(map(int, input().split()))", "-for c in list(b.values()):", "- ans += int(c * (c - 1) / 2)", "+b = list(accumulate(a, add))", "+b = list([x % m for x in b])", "+c = Counter(b)", "+c[0] = c[0] + 1", "+ans = 0", "+for i in list(c.values()):", "+ ans += i * (i - 1) // 2" ]
false
0.04631
0.03835
1.207569
[ "s301424151", "s854961495" ]
u156815136
p02725
python
s160572722
s749591001
186
160
26,420
34,680
Accepted
Accepted
13.98
k,n = list(map(int, input().split())) a = list(map(int,input().split())) max_dist = 0 for i in range(n): nxt = (i + 1) %n distance = a[nxt] - a[i] if distance < 0: distance += k max_dist = max(max_dist, distance) print((k - max_dist))
#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 # # 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) # 四捨五入g import sys sys.setrecursionlimit(10000000) #mod = 10**9 + 7 #mod = 9982443453 mod = 998244353 def readInts(): return list(map(int,input().split())) def I(): return int(eval(input())) k,n = readInts() A = readInts() max_dist = 0 for i in range(n): next = (i+1)%n dist = A[next] - A[i] if dist < 0: dist += k max_dist = max(max_dist, dist) print((k - max_dist))
10
41
259
972
k, n = list(map(int, input().split())) a = list(map(int, input().split())) max_dist = 0 for i in range(n): nxt = (i + 1) % n distance = a[nxt] - a[i] if distance < 0: distance += k max_dist = max(max_dist, distance) print((k - max_dist))
# 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 # # 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) # 四捨五入g import sys sys.setrecursionlimit(10000000) # mod = 10**9 + 7 # mod = 9982443453 mod = 998244353 def readInts(): return list(map(int, input().split())) def I(): return int(eval(input())) k, n = readInts() A = readInts() max_dist = 0 for i in range(n): next = (i + 1) % n dist = A[next] - A[i] if dist < 0: dist += k max_dist = max(max_dist, dist) print((k - max_dist))
false
75.609756
[ "-k, n = list(map(int, input().split()))", "-a = list(map(int, input().split()))", "+# 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", "+#", "+# 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)", "+# 四捨五入g", "+import sys", "+", "+sys.setrecursionlimit(10000000)", "+# mod = 10**9 + 7", "+# mod = 9982443453", "+mod = 998244353", "+", "+", "+def readInts():", "+ return list(map(int, input().split()))", "+", "+", "+def I():", "+ return int(eval(input()))", "+", "+", "+k, n = readInts()", "+A = readInts()", "- nxt = (i + 1) % n", "- distance = a[nxt] - a[i]", "- if distance < 0:", "- distance += k", "- max_dist = max(max_dist, distance)", "+ next = (i + 1) % n", "+ dist = A[next] - A[i]", "+ if dist < 0:", "+ dist += k", "+ max_dist = max(max_dist, dist)" ]
false
0.036816
0.096063
0.383245
[ "s160572722", "s749591001" ]
u644907318
p02838
python
s102816843
s135708469
1,427
768
151,784
195,948
Accepted
Accepted
46.18
p = 10**9+7 N = int(eval(input())) A = list(input().split()) B = [0 for _ in range(N)] for i in range(N): a = A[i] b = bin(int(a))[2:] b = "0"*(60-len(b))+b B[i] = b C = {i:0 for i in range(60)} for j in range(60): cnt = 0 for i in range(N): if B[i][j]=="1": cnt += 1 C[j] = cnt tot = 0 for j in range(60): n = C[j] k = (N*(N-1))//2-(n*(n-1))//2-((N-n)*(N-n-1))//2 tot = (tot+k*(2**(60-1-j)))%p print(tot)
p0 = 10**9+7 def pow(x,m): if m==0: return 1 if m==1: return x if m%2==0: return (pow(x,m//2)**2)%p0 else: return (x*(pow(x,(m-1)//2)**2)%p0)%p0 N = int(eval(input())) A = list(map(int,input().split())) A = [bin(A[i])[2:] for i in range(N)] A = ["0"*(60-len(A[i]))+A[i] for i in range(N)] C = {k:0 for k in range(60)} for i in range(N): for m in range(60): if A[i][m]=="1": C[59-m] += 1 B = [0 for _ in range(60)] for k in range(60): p = C[k] m = N-C[k] B[k] = p*m cnt = 0 for k in range(60): cnt = (cnt+B[k]*pow(2,k))%p0 print(cnt)
22
29
480
643
p = 10**9 + 7 N = int(eval(input())) A = list(input().split()) B = [0 for _ in range(N)] for i in range(N): a = A[i] b = bin(int(a))[2:] b = "0" * (60 - len(b)) + b B[i] = b C = {i: 0 for i in range(60)} for j in range(60): cnt = 0 for i in range(N): if B[i][j] == "1": cnt += 1 C[j] = cnt tot = 0 for j in range(60): n = C[j] k = (N * (N - 1)) // 2 - (n * (n - 1)) // 2 - ((N - n) * (N - n - 1)) // 2 tot = (tot + k * (2 ** (60 - 1 - j))) % p print(tot)
p0 = 10**9 + 7 def pow(x, m): if m == 0: return 1 if m == 1: return x if m % 2 == 0: return (pow(x, m // 2) ** 2) % p0 else: return (x * (pow(x, (m - 1) // 2) ** 2) % p0) % p0 N = int(eval(input())) A = list(map(int, input().split())) A = [bin(A[i])[2:] for i in range(N)] A = ["0" * (60 - len(A[i])) + A[i] for i in range(N)] C = {k: 0 for k in range(60)} for i in range(N): for m in range(60): if A[i][m] == "1": C[59 - m] += 1 B = [0 for _ in range(60)] for k in range(60): p = C[k] m = N - C[k] B[k] = p * m cnt = 0 for k in range(60): cnt = (cnt + B[k] * pow(2, k)) % p0 print(cnt)
false
24.137931
[ "-p = 10**9 + 7", "+p0 = 10**9 + 7", "+", "+", "+def pow(x, m):", "+ if m == 0:", "+ return 1", "+ if m == 1:", "+ return x", "+ if m % 2 == 0:", "+ return (pow(x, m // 2) ** 2) % p0", "+ else:", "+ return (x * (pow(x, (m - 1) // 2) ** 2) % p0) % p0", "+", "+", "-A = list(input().split())", "-B = [0 for _ in range(N)]", "+A = list(map(int, input().split()))", "+A = [bin(A[i])[2:] for i in range(N)]", "+A = [\"0\" * (60 - len(A[i])) + A[i] for i in range(N)]", "+C = {k: 0 for k in range(60)}", "- a = A[i]", "- b = bin(int(a))[2:]", "- b = \"0\" * (60 - len(b)) + b", "- B[i] = b", "-C = {i: 0 for i in range(60)}", "-for j in range(60):", "- cnt = 0", "- for i in range(N):", "- if B[i][j] == \"1\":", "- cnt += 1", "- C[j] = cnt", "-tot = 0", "-for j in range(60):", "- n = C[j]", "- k = (N * (N - 1)) // 2 - (n * (n - 1)) // 2 - ((N - n) * (N - n - 1)) // 2", "- tot = (tot + k * (2 ** (60 - 1 - j))) % p", "-print(tot)", "+ for m in range(60):", "+ if A[i][m] == \"1\":", "+ C[59 - m] += 1", "+B = [0 for _ in range(60)]", "+for k in range(60):", "+ p = C[k]", "+ m = N - C[k]", "+ B[k] = p * m", "+cnt = 0", "+for k in range(60):", "+ cnt = (cnt + B[k] * pow(2, k)) % p0", "+print(cnt)" ]
false
0.037584
0.045069
0.833932
[ "s102816843", "s135708469" ]
u391675400
p02696
python
s236838013
s244995074
24
22
9,164
9,164
Accepted
Accepted
8.33
a,b,n = list(map(int,input().split())) x = min(b-1,n) print((((a * x)//b)) )
a,b,n = list(map(int,input().split())) if b > n: x = n else: x = b - 1 print((((a * x)//b)) )
6
10
79
109
a, b, n = list(map(int, input().split())) x = min(b - 1, n) print((((a * x) // b)))
a, b, n = list(map(int, input().split())) if b > n: x = n else: x = b - 1 print((((a * x) // b)))
false
40
[ "-x = min(b - 1, n)", "+if b > n:", "+ x = n", "+else:", "+ x = b - 1" ]
false
0.065286
0.080001
0.816063
[ "s236838013", "s244995074" ]
u330661451
p02773
python
s004868854
s360907760
674
541
47,668
35,936
Accepted
Accepted
19.73
from collections import Counter def main(): n = int(eval(input())) s = [eval(input()) for _ in range(n)] C = Counter(s) cl = C.most_common() mx = cl[0][1] ans = [] for c in cl: if (c[1] == mx): ans.append(c[0]) else: break ans.sort() for i in ans: print(i) if __name__ == "__main__": main()
from collections import Counter def main(): n = int(eval(input())) s = [eval(input()) for _ in range(n)] C = Counter(s) mx = max(C.values()) ans = [] for k,v in list(C.items()): if v == mx: ans.append(k) ans.sort() print(("\n".join(ans))) if __name__ == "__main__": main()
21
17
389
327
from collections import Counter def main(): n = int(eval(input())) s = [eval(input()) for _ in range(n)] C = Counter(s) cl = C.most_common() mx = cl[0][1] ans = [] for c in cl: if c[1] == mx: ans.append(c[0]) else: break ans.sort() for i in ans: print(i) if __name__ == "__main__": main()
from collections import Counter def main(): n = int(eval(input())) s = [eval(input()) for _ in range(n)] C = Counter(s) mx = max(C.values()) ans = [] for k, v in list(C.items()): if v == mx: ans.append(k) ans.sort() print(("\n".join(ans))) if __name__ == "__main__": main()
false
19.047619
[ "- cl = C.most_common()", "- mx = cl[0][1]", "+ mx = max(C.values())", "- for c in cl:", "- if c[1] == mx:", "- ans.append(c[0])", "- else:", "- break", "+ for k, v in list(C.items()):", "+ if v == mx:", "+ ans.append(k)", "- for i in ans:", "- print(i)", "+ print((\"\\n\".join(ans)))" ]
false
0.063821
0.063477
1.005414
[ "s004868854", "s360907760" ]
u333945892
p02953
python
s377182936
s347801164
90
83
15,992
14,252
Accepted
Accepted
7.78
from collections import defaultdict,deque import sys,heapq,bisect,math,itertools,string,queue,copy,time sys.setrecursionlimit(10**8) INF = float('inf') mod = 10**9+7 eps = 10**-7 def inp(): return int(eval(input())) def inpl(): return list(map(int, input().split())) def inpl_str(): return list(input().split()) N = inp() HH = inpl() HH[0] -= 1 for i in range(N-1): #print(HH) if HH[i+1]-HH[i] > 0: HH[i+1] -= 1 elif HH[i+1]-HH[i] == 0: continue else: print('No') exit() print('Yes')
N = int(eval(input())) hh = list(map(int, input().split())) for i in range(1, N): if hh[i - 1] == hh[i]: continue else: hh[i] -= 1 if hh[i - 1] > hh[i]: print("No") exit() print("Yes")
24
13
551
237
from collections import defaultdict, deque import sys, heapq, bisect, math, itertools, string, queue, copy, time sys.setrecursionlimit(10**8) INF = float("inf") mod = 10**9 + 7 eps = 10**-7 def inp(): return int(eval(input())) def inpl(): return list(map(int, input().split())) def inpl_str(): return list(input().split()) N = inp() HH = inpl() HH[0] -= 1 for i in range(N - 1): # print(HH) if HH[i + 1] - HH[i] > 0: HH[i + 1] -= 1 elif HH[i + 1] - HH[i] == 0: continue else: print("No") exit() print("Yes")
N = int(eval(input())) hh = list(map(int, input().split())) for i in range(1, N): if hh[i - 1] == hh[i]: continue else: hh[i] -= 1 if hh[i - 1] > hh[i]: print("No") exit() print("Yes")
false
45.833333
[ "-from collections import defaultdict, deque", "-import sys, heapq, bisect, math, itertools, string, queue, copy, time", "-", "-sys.setrecursionlimit(10**8)", "-INF = float(\"inf\")", "-mod = 10**9 + 7", "-eps = 10**-7", "-", "-", "-def inp():", "- return int(eval(input()))", "-", "-", "-def inpl():", "- return list(map(int, input().split()))", "-", "-", "-def inpl_str():", "- return list(input().split())", "-", "-", "-N = inp()", "-HH = inpl()", "-HH[0] -= 1", "-for i in range(N - 1):", "- # print(HH)", "- if HH[i + 1] - HH[i] > 0:", "- HH[i + 1] -= 1", "- elif HH[i + 1] - HH[i] == 0:", "+N = int(eval(input()))", "+hh = list(map(int, input().split()))", "+for i in range(1, N):", "+ if hh[i - 1] == hh[i]:", "+ hh[i] -= 1", "+ if hh[i - 1] > hh[i]:" ]
false
0.007531
0.087293
0.086271
[ "s377182936", "s347801164" ]
u077291787
p03722
python
s148633637
s592902688
542
432
3,312
3,312
Accepted
Accepted
20.3
# ABC061D - Score Attack import sys input = sys.stdin.readline def bellman_ford(N: int, M: int, E: "Array[Array[int]]") -> int or None: INF = float("inf") dist = [INF] * (N + 1) dist[1] = 0 # relax edges for i in range(N): for v, u, w in E: # w: positive -> -w if v != INF and dist[v] - w < dist[u]: dist[u] = dist[v] - w if i == N - 1 and u == N: # detect negative cycles return None return dist[-1] def main(): # reverse weights -> shortest path problem containing negative cycles N, M = tuple(map(int, input().split())) # vertices, edges E = tuple(tuple(map(int, input().split())) for _ in range(M)) ans = bellman_ford(N, M, E) flg = ans is not None print((-ans if flg else "inf")) if __name__ == "__main__": main()
# ABC061D - Score Attack import sys input = sys.stdin.readline def bellman_ford(N: int, M: int, E: "Array[Array[int]]") -> int or None: INF = float("inf") dist = [INF] * (N + 1) dist[1] = 0 # relax edges for i in range(N): for v, u, w in E: # w: positive -> -w if dist[v] - w < dist[u]: dist[u] = dist[v] - w if i == N - 1 and u == N: # detect negative cycles return None return dist[-1] def main(): # reverse weights -> shortest path problem containing negative cycles N, M = tuple(map(int, input().split())) # vertices, edges E = tuple(tuple(map(int, input().split())) for _ in range(M)) ans = bellman_ford(N, M, E) flg = ans is not None print((-ans if flg else "inf")) if __name__ == "__main__": main()
30
30
878
865
# ABC061D - Score Attack import sys input = sys.stdin.readline def bellman_ford(N: int, M: int, E: "Array[Array[int]]") -> int or None: INF = float("inf") dist = [INF] * (N + 1) dist[1] = 0 # relax edges for i in range(N): for v, u, w in E: # w: positive -> -w if v != INF and dist[v] - w < dist[u]: dist[u] = dist[v] - w if i == N - 1 and u == N: # detect negative cycles return None return dist[-1] def main(): # reverse weights -> shortest path problem containing negative cycles N, M = tuple(map(int, input().split())) # vertices, edges E = tuple(tuple(map(int, input().split())) for _ in range(M)) ans = bellman_ford(N, M, E) flg = ans is not None print((-ans if flg else "inf")) if __name__ == "__main__": main()
# ABC061D - Score Attack import sys input = sys.stdin.readline def bellman_ford(N: int, M: int, E: "Array[Array[int]]") -> int or None: INF = float("inf") dist = [INF] * (N + 1) dist[1] = 0 # relax edges for i in range(N): for v, u, w in E: # w: positive -> -w if dist[v] - w < dist[u]: dist[u] = dist[v] - w if i == N - 1 and u == N: # detect negative cycles return None return dist[-1] def main(): # reverse weights -> shortest path problem containing negative cycles N, M = tuple(map(int, input().split())) # vertices, edges E = tuple(tuple(map(int, input().split())) for _ in range(M)) ans = bellman_ford(N, M, E) flg = ans is not None print((-ans if flg else "inf")) if __name__ == "__main__": main()
false
0
[ "- if v != INF and dist[v] - w < dist[u]:", "+ if dist[v] - w < dist[u]:" ]
false
0.182726
0.097457
1.874933
[ "s148633637", "s592902688" ]
u610042046
p03290
python
s272001321
s177511236
134
123
9,212
9,132
Accepted
Accepted
8.21
d, g = list(map(int, input().split())) pc = [list(map(int,input().split())) for _ in range(d)] ans = g//100 + 1 for i in range(2**d): count = 0 total = 0 for j in range(d): if (i >> j) & 1 == 1: count += pc[j][0] total += (j+1)*100*pc[j][0] + pc[j][1] if total >= g: ans = min(ans, count) else: for k in reversed(list(range(d))): if ((i >> k) & 1) == 0: for _ in range(pc[k][0]): if total >= g: ans = min(ans, count) break count += 1 total += (k+1)*100 print(ans)
d, g = list(map(int, input().split())) pc = [list(map(int,input().split())) for _ in range(d)] ans = g//100 + 1 for i in range(2**d): count = 0 total = 0 for j in range(d): if (i >> j) & 1 == 1: count += pc[j][0] total += (j+1)*100*pc[j][0] + pc[j][1] if total >= g: ans = min(ans, count) else: for k in reversed(list(range(d))): if ((i >> k) & 1) == 0: for _ in range(pc[k][0]-1): count += 1 total += (k+1)*100 if total >= g: ans = min(ans, count) break print(ans)
25
25
682
684
d, g = list(map(int, input().split())) pc = [list(map(int, input().split())) for _ in range(d)] ans = g // 100 + 1 for i in range(2**d): count = 0 total = 0 for j in range(d): if (i >> j) & 1 == 1: count += pc[j][0] total += (j + 1) * 100 * pc[j][0] + pc[j][1] if total >= g: ans = min(ans, count) else: for k in reversed(list(range(d))): if ((i >> k) & 1) == 0: for _ in range(pc[k][0]): if total >= g: ans = min(ans, count) break count += 1 total += (k + 1) * 100 print(ans)
d, g = list(map(int, input().split())) pc = [list(map(int, input().split())) for _ in range(d)] ans = g // 100 + 1 for i in range(2**d): count = 0 total = 0 for j in range(d): if (i >> j) & 1 == 1: count += pc[j][0] total += (j + 1) * 100 * pc[j][0] + pc[j][1] if total >= g: ans = min(ans, count) else: for k in reversed(list(range(d))): if ((i >> k) & 1) == 0: for _ in range(pc[k][0] - 1): count += 1 total += (k + 1) * 100 if total >= g: ans = min(ans, count) break print(ans)
false
0
[ "- for _ in range(pc[k][0]):", "+ for _ in range(pc[k][0] - 1):", "+ count += 1", "+ total += (k + 1) * 100", "- count += 1", "- total += (k + 1) * 100" ]
false
0.109729
0.048986
2.240012
[ "s272001321", "s177511236" ]
u746419473
p03110
python
s627436734
s494342715
20
17
2,940
2,940
Accepted
Accepted
15
n = int(eval(input())) ans = 0 for _ in range(n): x, u = list(map(str, input().split())) x = float(x) if u == "JPY": ans += x elif u == "BTC": ans += x*380000.0 print(ans)
n = int(eval(input())) ans = 0 for _ in range(n): x, u = list(map(str, input().split())) x = float(x) if u == "BTC": ans += x*380000 else: ans += x print(ans)
11
11
203
190
n = int(eval(input())) ans = 0 for _ in range(n): x, u = list(map(str, input().split())) x = float(x) if u == "JPY": ans += x elif u == "BTC": ans += x * 380000.0 print(ans)
n = int(eval(input())) ans = 0 for _ in range(n): x, u = list(map(str, input().split())) x = float(x) if u == "BTC": ans += x * 380000 else: ans += x print(ans)
false
0
[ "- if u == \"JPY\":", "+ if u == \"BTC\":", "+ ans += x * 380000", "+ else:", "- elif u == \"BTC\":", "- ans += x * 380000.0" ]
false
0.04464
0.045391
0.983456
[ "s627436734", "s494342715" ]
u452512115
p02689
python
s400777019
s994432677
435
360
42,976
29,416
Accepted
Accepted
17.24
N, M = list(map(int, input().split())) H = list(map(int, input().split())) AB = [tuple(map(int, input().split())) for i in range(M)] graph = [[] for _ in range(N)] for a, b in AB: a, b = a-1, b-1 graph[a].append(b) graph[b].append(a) ans = 0 for i, h in enumerate(H): flag = True for to in graph[i]: if H[i] > H[to]: continue else: flag = False if flag: ans += 1 print(ans)
N, M = list(map(int, input().split())) H = list(map(int, input().split())) #AB = [tuple(map(int, input().split())) for i in range(M)] #丸暗記。隣接リストの初期化 graph = [[] for _ in range(N)] for _ in range(M): a, b = list(map(int, input().split())) graph[a-1].append(b-1) graph[b-1].append(a-1) ans = 0 for n in range(N): flag = True for to in graph[n]: if H[n] <= H[to]: flag = False if flag: ans += 1 print(ans)
27
26
445
457
N, M = list(map(int, input().split())) H = list(map(int, input().split())) AB = [tuple(map(int, input().split())) for i in range(M)] graph = [[] for _ in range(N)] for a, b in AB: a, b = a - 1, b - 1 graph[a].append(b) graph[b].append(a) ans = 0 for i, h in enumerate(H): flag = True for to in graph[i]: if H[i] > H[to]: continue else: flag = False if flag: ans += 1 print(ans)
N, M = list(map(int, input().split())) H = list(map(int, input().split())) # AB = [tuple(map(int, input().split())) for i in range(M)] # 丸暗記。隣接リストの初期化 graph = [[] for _ in range(N)] for _ in range(M): a, b = list(map(int, input().split())) graph[a - 1].append(b - 1) graph[b - 1].append(a - 1) ans = 0 for n in range(N): flag = True for to in graph[n]: if H[n] <= H[to]: flag = False if flag: ans += 1 print(ans)
false
3.703704
[ "-AB = [tuple(map(int, input().split())) for i in range(M)]", "+# AB = [tuple(map(int, input().split())) for i in range(M)]", "+# 丸暗記。隣接リストの初期化", "-for a, b in AB:", "- a, b = a - 1, b - 1", "- graph[a].append(b)", "- graph[b].append(a)", "+for _ in range(M):", "+ a, b = list(map(int, input().split()))", "+ graph[a - 1].append(b - 1)", "+ graph[b - 1].append(a - 1)", "-for i, h in enumerate(H):", "+for n in range(N):", "- for to in graph[i]:", "- if H[i] > H[to]:", "- continue", "- else:", "+ for to in graph[n]:", "+ if H[n] <= H[to]:" ]
false
0.039737
0.10227
0.388548
[ "s400777019", "s994432677" ]
u276115223
p02981
python
s668999024
s329115615
22
17
2,940
2,940
Accepted
Accepted
22.73
# ABC 133: A – T or T n, a, b = [int(s) for s in input().split()] print((min(a * n, b)))
# ABC 133: A – T or T n, a, b = list(map(int, input().split())) print((min(a * n, b)))
3
3
88
80
# ABC 133: A – T or T n, a, b = [int(s) for s in input().split()] print((min(a * n, b)))
# ABC 133: A – T or T n, a, b = list(map(int, input().split())) print((min(a * n, b)))
false
0
[ "-n, a, b = [int(s) for s in input().split()]", "+n, a, b = list(map(int, input().split()))" ]
false
0.045593
0.047226
0.965407
[ "s668999024", "s329115615" ]
u046187684
p02948
python
s607023958
s736444474
432
399
25,840
25,580
Accepted
Accepted
7.64
import heapq def solve(string): n, m, *ab = list(map(int, string.split())) ab = sorted([(a, b) for a, b in zip(*[iter(ab)] * 2)]) hq, index, cap, count, ans = [], 0, 1, m, 0 while index < n: _a, _b = ab[index] if _a > m: break if _a <= cap: heapq.heappush(hq, -_b) index += 1 else: ans -= heapq.heappop(hq) if len(hq) > 0 else 0 count -= 1 cap += 1 ans -= sum([heapq.heappop(hq) if len(hq) > 0 else 0 for _ in range(count)]) return str(ans) if __name__ == '__main__': n, m = list(map(int, input().split())) print((solve('{} {}\n'.format(n, m) + '\n'.join([eval(input()) for _ in range(n)]))))
import heapq def solve(string): n, m, *ab = list(map(int, string.split())) ab = sorted([(a, b) for a, b in zip(*[iter(ab)] * 2)]) hq, index, cap, count, ans = [], 0, 1, m, 0 while index < n: _a, _b = ab[index] if _a > m: break if _a <= cap: heapq.heappush(hq, -_b) index += 1 else: ans += -heapq.heappop(hq) if len(hq) > 0 else 0 count -= 1 cap += 1 ans += sum([-heapq.heappop(hq) for _ in range(count) if len(hq) > 0]) return str(ans) if __name__ == '__main__': n, m = list(map(int, input().split())) print((solve('{} {}\n'.format(n, m) + '\n'.join([eval(input()) for _ in range(n)]))))
25
25
737
732
import heapq def solve(string): n, m, *ab = list(map(int, string.split())) ab = sorted([(a, b) for a, b in zip(*[iter(ab)] * 2)]) hq, index, cap, count, ans = [], 0, 1, m, 0 while index < n: _a, _b = ab[index] if _a > m: break if _a <= cap: heapq.heappush(hq, -_b) index += 1 else: ans -= heapq.heappop(hq) if len(hq) > 0 else 0 count -= 1 cap += 1 ans -= sum([heapq.heappop(hq) if len(hq) > 0 else 0 for _ in range(count)]) return str(ans) if __name__ == "__main__": n, m = list(map(int, input().split())) print( (solve("{} {}\n".format(n, m) + "\n".join([eval(input()) for _ in range(n)]))) )
import heapq def solve(string): n, m, *ab = list(map(int, string.split())) ab = sorted([(a, b) for a, b in zip(*[iter(ab)] * 2)]) hq, index, cap, count, ans = [], 0, 1, m, 0 while index < n: _a, _b = ab[index] if _a > m: break if _a <= cap: heapq.heappush(hq, -_b) index += 1 else: ans += -heapq.heappop(hq) if len(hq) > 0 else 0 count -= 1 cap += 1 ans += sum([-heapq.heappop(hq) for _ in range(count) if len(hq) > 0]) return str(ans) if __name__ == "__main__": n, m = list(map(int, input().split())) print( (solve("{} {}\n".format(n, m) + "\n".join([eval(input()) for _ in range(n)]))) )
false
0
[ "- ans -= heapq.heappop(hq) if len(hq) > 0 else 0", "+ ans += -heapq.heappop(hq) if len(hq) > 0 else 0", "- ans -= sum([heapq.heappop(hq) if len(hq) > 0 else 0 for _ in range(count)])", "+ ans += sum([-heapq.heappop(hq) for _ in range(count) if len(hq) > 0])" ]
false
0.044564
0.045586
0.977585
[ "s607023958", "s736444474" ]
u054556734
p03854
python
s058114621
s248733933
328
275
19,644
19,764
Accepted
Accepted
16.16
import numpy as np import scipy.sparse as sps import scipy.misc as spm import collections as col import functools as func import itertools as ite import fractions as frac import math as ma from math import cos,sin,tan import cmath as cma import copy as cp import sys def sinput(): return sys.stdin.readline().strip() def iinput(): return int(sinput()) def imap(): return list(map(int, sinput().split())) def fmap(): return list(map(float, sinput().split())) def iarr(n=0): if n: return [0 for _ in range(n)] else: return list(map()) def farr(): return list(fmap()) def sarr(n=0): if n: return ["" for _ in range(n)] else: return sinput().split() def barr(n): return [False for _ in range(n)] sys.setrecursionlimit(10**7) MOD = 10**9 + 7; EPS = sys.float_info.epsilon PI = np.pi; EXP = np.e; INF = np.inf s = sinput()[::-1] a = "dream"[::-1] b = "dreamer"[::-1] c = "erase"[::-1] d = "eraser"[::-1] s = "".join(s.split(d)) s = "".join(s.split(c)) s = "".join(s.split(b)) s = "".join(s.split(a)) ans = "YES" if s=="" else "NO" print(ans)
import numpy as np import scipy.sparse as sps import scipy.misc as spm import collections as col import functools as func import itertools as ite import fractions as frac import math as ma from math import cos,sin,tan import cmath as cma import copy as cp import sys def sinput(): return sys.stdin.readline().strip() def iinput(): return int(sinput()) def imap(): return list(map(int, sinput().split())) def fmap(): return list(map(float, sinput().split())) def iarr(n=0): if n: return [0 for _ in range(n)] else: return list(map()) def farr(): return list(fmap()) def sarr(n=0): if n: return ["" for _ in range(n)] else: return sinput().split() def barr(n): return [False for _ in range(n)] sys.setrecursionlimit(10**7) MOD = 10**9 + 7; EPS = sys.float_info.epsilon PI = np.pi; EXP = np.e; INF = np.inf s = sinput() a = "dream" b = "dreamer" c = "erase" d = "eraser" s = "".join(s.split(d)) s = "".join(s.split(c)) s = "".join(s.split(b)) s = "".join(s.split(a)) ans = "YES" if s=="" else "NO" print(ans)
42
42
1,086
1,056
import numpy as np import scipy.sparse as sps import scipy.misc as spm import collections as col import functools as func import itertools as ite import fractions as frac import math as ma from math import cos, sin, tan import cmath as cma import copy as cp import sys def sinput(): return sys.stdin.readline().strip() def iinput(): return int(sinput()) def imap(): return list(map(int, sinput().split())) def fmap(): return list(map(float, sinput().split())) def iarr(n=0): if n: return [0 for _ in range(n)] else: return list(map()) def farr(): return list(fmap()) def sarr(n=0): if n: return ["" for _ in range(n)] else: return sinput().split() def barr(n): return [False for _ in range(n)] sys.setrecursionlimit(10**7) MOD = 10**9 + 7 EPS = sys.float_info.epsilon PI = np.pi EXP = np.e INF = np.inf s = sinput()[::-1] a = "dream"[::-1] b = "dreamer"[::-1] c = "erase"[::-1] d = "eraser"[::-1] s = "".join(s.split(d)) s = "".join(s.split(c)) s = "".join(s.split(b)) s = "".join(s.split(a)) ans = "YES" if s == "" else "NO" print(ans)
import numpy as np import scipy.sparse as sps import scipy.misc as spm import collections as col import functools as func import itertools as ite import fractions as frac import math as ma from math import cos, sin, tan import cmath as cma import copy as cp import sys def sinput(): return sys.stdin.readline().strip() def iinput(): return int(sinput()) def imap(): return list(map(int, sinput().split())) def fmap(): return list(map(float, sinput().split())) def iarr(n=0): if n: return [0 for _ in range(n)] else: return list(map()) def farr(): return list(fmap()) def sarr(n=0): if n: return ["" for _ in range(n)] else: return sinput().split() def barr(n): return [False for _ in range(n)] sys.setrecursionlimit(10**7) MOD = 10**9 + 7 EPS = sys.float_info.epsilon PI = np.pi EXP = np.e INF = np.inf s = sinput() a = "dream" b = "dreamer" c = "erase" d = "eraser" s = "".join(s.split(d)) s = "".join(s.split(c)) s = "".join(s.split(b)) s = "".join(s.split(a)) ans = "YES" if s == "" else "NO" print(ans)
false
0
[ "-s = sinput()[::-1]", "-a = \"dream\"[::-1]", "-b = \"dreamer\"[::-1]", "-c = \"erase\"[::-1]", "-d = \"eraser\"[::-1]", "+s = sinput()", "+a = \"dream\"", "+b = \"dreamer\"", "+c = \"erase\"", "+d = \"eraser\"" ]
false
0.31534
0.200706
1.571157
[ "s058114621", "s248733933" ]
u488401358
p02635
python
s007544899
s268271159
1,897
1,719
108,476
107,040
Accepted
Accepted
9.38
S,K=input().split() K=int(K) K=min(K,300) mod=998244353 a=[] val=0 for i in range(len(S)): if S[i]=="0": a.append(val) val=0 else: val+=1 if val!=0: a.append(val) m=len(a) K=min(sum(a),K) dp=[[[0 for i in range(K+1)] for j in range(K+1)] for k in range(m+1)] for j in range(K+1): dp[m][j][j]=1 b=[a[i] for i in range(m)] c=[a[i] for i in range(m)] for i in range(1,m): b[i]+=b[i-1] b=[0]+b for i in range(m-2,-1,-1): c[i]+=c[i+1] for i in range(m-1,-1,-1): for k in range(min(b[i],K)+1): for j in range(min(K,k+c[i])+1): M=max(k-j,-a[i]) dp[i][j][k]=sum(dp[i+1][j+l][k] for l in range(max(0,M),K-j+1))+sum(dp[i+1][j][k+l] for l in range(1,min(K-k,-M)+1)) dp[i][j][k]%=mod print((dp[0][0][0]))
S,K=input().split() K=int(K) K=min(K,300) mod=998244353 a=[] val=0 for i in range(len(S)): if S[i]=="0": a.append(val) val=0 else: val+=1 if val!=0: a.append(val) m=len(a) K=min(sum(a),K) dp=[[0 for i in range(K+1)] for j in range(K+1)] for j in range(K+1): dp[j][j]=1 b=[a[i] for i in range(m)] c=[a[i] for i in range(m)] for i in range(1,m): b[i]+=b[i-1] b=[0]+b for i in range(m-2,-1,-1): c[i]+=c[i+1] for i in range(m-1,-1,-1): ndp=[[0 for j in range(K+1)] for k in range(K+1)] for k in range(min(b[i],K)+1): for j in range(min(K,k+c[i])+1): M=max(k-j,-a[i]) ndp[j][k]=sum(dp[j+l][k] for l in range(max(0,M),K-j+1))+sum(dp[j][k+l] for l in range(1,min(K-k,-M)+1)) ndp[j][k]%=mod dp=ndp print((dp[0][0]))
38
40
828
854
S, K = input().split() K = int(K) K = min(K, 300) mod = 998244353 a = [] val = 0 for i in range(len(S)): if S[i] == "0": a.append(val) val = 0 else: val += 1 if val != 0: a.append(val) m = len(a) K = min(sum(a), K) dp = [[[0 for i in range(K + 1)] for j in range(K + 1)] for k in range(m + 1)] for j in range(K + 1): dp[m][j][j] = 1 b = [a[i] for i in range(m)] c = [a[i] for i in range(m)] for i in range(1, m): b[i] += b[i - 1] b = [0] + b for i in range(m - 2, -1, -1): c[i] += c[i + 1] for i in range(m - 1, -1, -1): for k in range(min(b[i], K) + 1): for j in range(min(K, k + c[i]) + 1): M = max(k - j, -a[i]) dp[i][j][k] = sum( dp[i + 1][j + l][k] for l in range(max(0, M), K - j + 1) ) + sum(dp[i + 1][j][k + l] for l in range(1, min(K - k, -M) + 1)) dp[i][j][k] %= mod print((dp[0][0][0]))
S, K = input().split() K = int(K) K = min(K, 300) mod = 998244353 a = [] val = 0 for i in range(len(S)): if S[i] == "0": a.append(val) val = 0 else: val += 1 if val != 0: a.append(val) m = len(a) K = min(sum(a), K) dp = [[0 for i in range(K + 1)] for j in range(K + 1)] for j in range(K + 1): dp[j][j] = 1 b = [a[i] for i in range(m)] c = [a[i] for i in range(m)] for i in range(1, m): b[i] += b[i - 1] b = [0] + b for i in range(m - 2, -1, -1): c[i] += c[i + 1] for i in range(m - 1, -1, -1): ndp = [[0 for j in range(K + 1)] for k in range(K + 1)] for k in range(min(b[i], K) + 1): for j in range(min(K, k + c[i]) + 1): M = max(k - j, -a[i]) ndp[j][k] = sum(dp[j + l][k] for l in range(max(0, M), K - j + 1)) + sum( dp[j][k + l] for l in range(1, min(K - k, -M) + 1) ) ndp[j][k] %= mod dp = ndp print((dp[0][0]))
false
5
[ "-dp = [[[0 for i in range(K + 1)] for j in range(K + 1)] for k in range(m + 1)]", "+dp = [[0 for i in range(K + 1)] for j in range(K + 1)]", "- dp[m][j][j] = 1", "+ dp[j][j] = 1", "+ ndp = [[0 for j in range(K + 1)] for k in range(K + 1)]", "- dp[i][j][k] = sum(", "- dp[i + 1][j + l][k] for l in range(max(0, M), K - j + 1)", "- ) + sum(dp[i + 1][j][k + l] for l in range(1, min(K - k, -M) + 1))", "- dp[i][j][k] %= mod", "-print((dp[0][0][0]))", "+ ndp[j][k] = sum(dp[j + l][k] for l in range(max(0, M), K - j + 1)) + sum(", "+ dp[j][k + l] for l in range(1, min(K - k, -M) + 1)", "+ )", "+ ndp[j][k] %= mod", "+ dp = ndp", "+print((dp[0][0]))" ]
false
0.059268
0.05749
1.030932
[ "s007544899", "s268271159" ]
u396495667
p03777
python
s845404019
s794915153
168
17
38,256
2,940
Accepted
Accepted
89.88
a,b = input().split() if a ==b: print('H') else: print('D')
a,b = input().split() if a == b== 'H' or a==b=='D': print('H') else: print('D')
6
5
69
87
a, b = input().split() if a == b: print("H") else: print("D")
a, b = input().split() if a == b == "H" or a == b == "D": print("H") else: print("D")
false
16.666667
[ "-if a == b:", "+if a == b == \"H\" or a == b == \"D\":" ]
false
0.106647
0.040304
2.646096
[ "s845404019", "s794915153" ]
u852690916
p03295
python
s314068922
s815075714
735
439
65,496
56,924
Accepted
Accepted
40.27
N,M=list(map(int, input().split())) AB=[] for _ in range(M): a,b=[int(x)-1 for x in input().split()] AB.append((a,b,b*10**6+a)) AB.sort(key=lambda x:x[2]) ans=0 i=0 k=0 while i<N-1 and k<M: a,b,c=AB[k] i=b-1 ans+=1 j=k+1 while j<M: a,b,c=AB[j] if i<a: break j+=1 k=j print(ans)
import sys def main(): input = sys.stdin.readline N,M=list(map(int, input().split())) AB=[tuple(map(int, input().split())) for _ in range(M)] from operator import itemgetter AB.sort(key=itemgetter(1)) ans=0 last=-1 for a,b in AB: if last<=a: ans+=1 last=b print(ans) if __name__ == '__main__': main()
20
17
350
383
N, M = list(map(int, input().split())) AB = [] for _ in range(M): a, b = [int(x) - 1 for x in input().split()] AB.append((a, b, b * 10**6 + a)) AB.sort(key=lambda x: x[2]) ans = 0 i = 0 k = 0 while i < N - 1 and k < M: a, b, c = AB[k] i = b - 1 ans += 1 j = k + 1 while j < M: a, b, c = AB[j] if i < a: break j += 1 k = j print(ans)
import sys def main(): input = sys.stdin.readline N, M = list(map(int, input().split())) AB = [tuple(map(int, input().split())) for _ in range(M)] from operator import itemgetter AB.sort(key=itemgetter(1)) ans = 0 last = -1 for a, b in AB: if last <= a: ans += 1 last = b print(ans) if __name__ == "__main__": main()
false
15
[ "-N, M = list(map(int, input().split()))", "-AB = []", "-for _ in range(M):", "- a, b = [int(x) - 1 for x in input().split()]", "- AB.append((a, b, b * 10**6 + a))", "-AB.sort(key=lambda x: x[2])", "-ans = 0", "-i = 0", "-k = 0", "-while i < N - 1 and k < M:", "- a, b, c = AB[k]", "- i = b - 1", "- ans += 1", "- j = k + 1", "- while j < M:", "- a, b, c = AB[j]", "- if i < a:", "- break", "- j += 1", "- k = j", "-print(ans)", "+import sys", "+", "+", "+def main():", "+ input = sys.stdin.readline", "+ N, M = list(map(int, input().split()))", "+ AB = [tuple(map(int, input().split())) for _ in range(M)]", "+ from operator import itemgetter", "+", "+ AB.sort(key=itemgetter(1))", "+ ans = 0", "+ last = -1", "+ for a, b in AB:", "+ if last <= a:", "+ ans += 1", "+ last = b", "+ print(ans)", "+", "+", "+if __name__ == \"__main__\":", "+ main()" ]
false
0.032475
0.034655
0.9371
[ "s314068922", "s815075714" ]