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
u394731058
p02989
python
s904152908
s902736131
89
75
14,820
14,300
Accepted
Accepted
15.73
import sys import collections as c input = sys.stdin.readline def main(): ans = 0 n = int(eval(input())) d = list(map(int, input().split())) d.sort() g = d[n//2] items_count = c.Counter(d) gc = items_count[g] if gc == 1 or d[n//2-1] != g: ans += g - d[n//2-1] ...
import sys input = sys.stdin.readline def main(): ans = 0 n = int(eval(input())) d = list(map(int, input().split())) d.sort() ans += d[n//2] - d[n//2-1] print(ans) if __name__ == '__main__': main()
19
14
367
235
import sys import collections as c input = sys.stdin.readline def main(): ans = 0 n = int(eval(input())) d = list(map(int, input().split())) d.sort() g = d[n // 2] items_count = c.Counter(d) gc = items_count[g] if gc == 1 or d[n // 2 - 1] != g: ans += g - d[n // 2 - 1] pri...
import sys input = sys.stdin.readline def main(): ans = 0 n = int(eval(input())) d = list(map(int, input().split())) d.sort() ans += d[n // 2] - d[n // 2 - 1] print(ans) if __name__ == "__main__": main()
false
26.315789
[ "-import collections as c", "- g = d[n // 2]", "- items_count = c.Counter(d)", "- gc = items_count[g]", "- if gc == 1 or d[n // 2 - 1] != g:", "- ans += g - d[n // 2 - 1]", "+ ans += d[n // 2] - d[n // 2 - 1]" ]
false
0.040995
0.036881
1.111538
[ "s904152908", "s902736131" ]
u489959379
p03821
python
s909679828
s451918992
366
207
28,148
27,380
Accepted
Accepted
43.44
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n = int(eval(input())) AB = [list(map(int, input().split())) for _ in range(n)][::-1] res = 0 for i in range(n): a, b = AB[i] push = ((a + res + b - 1) // b) * b - a ...
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n = int(eval(input())) AB = [list(map(int, input().split())) for _ in range(n)] res = 0 for i in reversed(list(range(n))): a, b = AB[i] a += res ...
21
23
389
435
import sys sys.setrecursionlimit(10**7) f_inf = float("inf") mod = 10**9 + 7 def resolve(): n = int(eval(input())) AB = [list(map(int, input().split())) for _ in range(n)][::-1] res = 0 for i in range(n): a, b = AB[i] push = ((a + res + b - 1) // b) * b - a res = push prin...
import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline f_inf = float("inf") mod = 10**9 + 7 def resolve(): n = int(eval(input())) AB = [list(map(int, input().split())) for _ in range(n)] res = 0 for i in reversed(list(range(n))): a, b = AB[i] a += res if a % b != 0...
false
8.695652
[ "+input = sys.stdin.readline", "- AB = [list(map(int, input().split())) for _ in range(n)][::-1]", "+ AB = [list(map(int, input().split())) for _ in range(n)]", "- for i in range(n):", "+ for i in reversed(list(range(n))):", "- push = ((a + res + b - 1) // b) * b - a", "- res =...
false
0.096654
0.146992
0.657544
[ "s909679828", "s451918992" ]
u707498674
p03835
python
s785925784
s549587120
1,294
19
2,940
3,060
Accepted
Accepted
98.53
def main(): K, S = list(map(int, input().split())) ans = sum((1 for X in range(K+1) for Y in range(K+1) if S-X-Y>=0 and S-X-Y<=K)) print(ans) if __name__ == "__main__": main()
def main(): K, S = list(map(int, input().split())) ans = 0 for X in range(K+1): Y_min = max(0, S-X-K) Y_max = min(K, S-X) ans += max(0, Y_max - Y_min + 1) print(ans) if __name__ == "__main__": main()
6
10
190
246
def main(): K, S = list(map(int, input().split())) ans = sum( ( 1 for X in range(K + 1) for Y in range(K + 1) if S - X - Y >= 0 and S - X - Y <= K ) ) print(ans) if __name__ == "__main__": main()
def main(): K, S = list(map(int, input().split())) ans = 0 for X in range(K + 1): Y_min = max(0, S - X - K) Y_max = min(K, S - X) ans += max(0, Y_max - Y_min + 1) print(ans) if __name__ == "__main__": main()
false
40
[ "- ans = sum(", "- (", "- 1", "- for X in range(K + 1)", "- for Y in range(K + 1)", "- if S - X - Y >= 0 and S - X - Y <= K", "- )", "- )", "+ ans = 0", "+ for X in range(K + 1):", "+ Y_min = max(0, S - X - K)", "+ ...
false
0.049352
0.048149
1.024989
[ "s785925784", "s549587120" ]
u028973125
p03817
python
s275472582
s586609773
28
25
8,992
9,112
Accepted
Accepted
10.71
import sys x = int(sys.stdin.readline()) n = x // 11 r = x % 11 if r == 0: print((2*n)) elif r <= 6: print((2*n + 1)) else: print((2 * (n+1)))
import sys x = int(sys.stdin.readline()) n = x // 11 r = x % 11 if r == 0: print((2*n)) elif r <= 6: print((2*n+1)) else: print((2*n+2))
11
12
159
155
import sys x = int(sys.stdin.readline()) n = x // 11 r = x % 11 if r == 0: print((2 * n)) elif r <= 6: print((2 * n + 1)) else: print((2 * (n + 1)))
import sys x = int(sys.stdin.readline()) n = x // 11 r = x % 11 if r == 0: print((2 * n)) elif r <= 6: print((2 * n + 1)) else: print((2 * n + 2))
false
8.333333
[ "- print((2 * (n + 1)))", "+ print((2 * n + 2))" ]
false
0.089036
0.04642
1.918047
[ "s275472582", "s586609773" ]
u419686324
p04013
python
s382722187
s005331442
1,235
137
66,416
13,400
Accepted
Accepted
88.91
N, A = list(map(int, input().split())) X = [int(x) for x in input().split()] m = {} def f(rv, k, rest): if k == 0: if rv == 0: return 1 else: return 0 if rv < 0 or len(rest) < k: return 0 def r(rv, k, rest): fp = (rv, k, len(rest)) ...
N, A = list(map(int, input().split())) X = [int(x) - A for x in input().split()] import functools @functools.lru_cache(maxsize=None) def f(acc, left): if not left: return 0 ret = 0 y = acc + left[0] ret += 1 if y == 0 else 0 ret += f(y, left[1:]) ret += f(acc, left[1:]) return r...
24
14
589
339
N, A = list(map(int, input().split())) X = [int(x) for x in input().split()] m = {} def f(rv, k, rest): if k == 0: if rv == 0: return 1 else: return 0 if rv < 0 or len(rest) < k: return 0 def r(rv, k, rest): fp = (rv, k, len(rest)) if fp in ...
N, A = list(map(int, input().split())) X = [int(x) - A for x in input().split()] import functools @functools.lru_cache(maxsize=None) def f(acc, left): if not left: return 0 ret = 0 y = acc + left[0] ret += 1 if y == 0 else 0 ret += f(y, left[1:]) ret += f(acc, left[1:]) return ret ...
false
41.666667
[ "-X = [int(x) for x in input().split()]", "-m = {}", "+X = [int(x) - A for x in input().split()]", "+import functools", "-def f(rv, k, rest):", "- if k == 0:", "- if rv == 0:", "- return 1", "- else:", "- return 0", "- if rv < 0 or len(rest) < k:", "+@...
false
0.038535
0.040131
0.960234
[ "s382722187", "s005331442" ]
u653837719
p02769
python
s845975890
s869794896
286
257
81,264
54,128
Accepted
Accepted
10.14
n, k = list(map(int, input().split())) mod = 10 ** 9 + 7 fac = [1, 1] finv = [1, 1] inv = [0, 1] for i in range(2, n+1): fac.append(fac[-1] * i % mod) inv.append(-inv[mod%i] * (mod // i) % mod) finv.append(finv[-1] * inv[-1] % mod) ans = 0 for i in range(min(n-1, k) + 1): com1 = fac[n] ...
n, k = list(map(int, input().split())) mod = 10 ** 9 + 7 ''' fac = [1, 1] finv = [1, 1] inv = [0, 1] for i in range(2, n+1): fac.append(fac[-1] * i % mod) inv.append(-inv[mod%i] * (mod // i) % mod) finv.append(finv[-1] * inv[-1] % mod) ''' fac = [1] finv = [0]*(n+4) for i in range(n+3): ...
20
29
464
658
n, k = list(map(int, input().split())) mod = 10**9 + 7 fac = [1, 1] finv = [1, 1] inv = [0, 1] for i in range(2, n + 1): fac.append(fac[-1] * i % mod) inv.append(-inv[mod % i] * (mod // i) % mod) finv.append(finv[-1] * inv[-1] % mod) ans = 0 for i in range(min(n - 1, k) + 1): com1 = fac[n] * finv[i] * f...
n, k = list(map(int, input().split())) mod = 10**9 + 7 """ fac = [1, 1] finv = [1, 1] inv = [0, 1] for i in range(2, n+1): fac.append(fac[-1] * i % mod) inv.append(-inv[mod%i] * (mod // i) % mod) finv.append(finv[-1] * inv[-1] % mod) """ fac = [1] finv = [0] * (n + 4) for i in range(n + 3): fac.append(f...
false
31.034483
[ "+\"\"\"", "-for i in range(2, n + 1):", "+for i in range(2, n+1):", "- inv.append(-inv[mod % i] * (mod // i) % mod)", "+ inv.append(-inv[mod%i] * (mod // i) % mod)", "+\"\"\"", "+fac = [1]", "+finv = [0] * (n + 4)", "+for i in range(n + 3):", "+ fac.append(fac[-1] * (i + 1) % mod)", "+...
false
0.541428
0.305178
1.774137
[ "s845975890", "s869794896" ]
u145950990
p03013
python
s380269615
s362930070
252
224
7,700
13,216
Accepted
Accepted
11.11
n,m = list(map(int,input().split())) oks = [True]*(n+1) for i in range(m): a = int(eval(input())) oks[a] = False dp = [0]*(n+1) dp[0] = 1 for i in range(n+1): for j in range(i+1,min(n+1,i+3)): if oks[j]: dp[j] += dp[i] dp[j] %= 1000000007 print((dp[n]))
n,m = list(map(int,input().split())) a = set([int(eval(input())) for i in range(m)]) mod = 10**9+7 dp = [0]*(n+1) dp[0] = 1 for i in range(n): if i+1<n+1 and not i+1 in a: dp[i+1] += dp[i] dp[i+1] %= mod if i+2<n+1 and not i+2 in a: dp[i+2] += dp[i] dp[i+2] %= mod ...
13
15
296
321
n, m = list(map(int, input().split())) oks = [True] * (n + 1) for i in range(m): a = int(eval(input())) oks[a] = False dp = [0] * (n + 1) dp[0] = 1 for i in range(n + 1): for j in range(i + 1, min(n + 1, i + 3)): if oks[j]: dp[j] += dp[i] dp[j] %= 1000000007 print((dp[n]))
n, m = list(map(int, input().split())) a = set([int(eval(input())) for i in range(m)]) mod = 10**9 + 7 dp = [0] * (n + 1) dp[0] = 1 for i in range(n): if i + 1 < n + 1 and not i + 1 in a: dp[i + 1] += dp[i] dp[i + 1] %= mod if i + 2 < n + 1 and not i + 2 in a: dp[i + 2] += dp[i] ...
false
13.333333
[ "-oks = [True] * (n + 1)", "-for i in range(m):", "- a = int(eval(input()))", "- oks[a] = False", "+a = set([int(eval(input())) for i in range(m)])", "+mod = 10**9 + 7", "-for i in range(n + 1):", "- for j in range(i + 1, min(n + 1, i + 3)):", "- if oks[j]:", "- dp[j] +=...
false
0.033911
0.030852
1.099172
[ "s380269615", "s362930070" ]
u941284420
p02983
python
s671898079
s320043229
765
658
3,064
3,064
Accepted
Accepted
13.99
#!/usr/bin/env python3 import sys MOD = 2019 # type: int def solve(L: int, R: int): list_lr_mod = [] ans = 2018 for i, x in enumerate(range(L, R + 1)): list_lr_mod.append(x % MOD) if i + 1 >= 2019: print((0)) return if 0 in list_lr_mod: ...
#!/usr/bin/env python3 import sys MOD = 2019 # type: int def solve(L: int, R: int): list_lr_mod = [] ans = 2018 if R - L >= 2018: print((0)) return for i, x in enumerate(range(L, R + 1)): xmod = x % MOD if xmod == 0: print((0)) ...
41
43
1,030
1,063
#!/usr/bin/env python3 import sys MOD = 2019 # type: int def solve(L: int, R: int): list_lr_mod = [] ans = 2018 for i, x in enumerate(range(L, R + 1)): list_lr_mod.append(x % MOD) if i + 1 >= 2019: print((0)) return if 0 in list_lr_mod: print((0)) ...
#!/usr/bin/env python3 import sys MOD = 2019 # type: int def solve(L: int, R: int): list_lr_mod = [] ans = 2018 if R - L >= 2018: print((0)) return for i, x in enumerate(range(L, R + 1)): xmod = x % MOD if xmod == 0: print((0)) return e...
false
4.651163
[ "+ if R - L >= 2018:", "+ print((0))", "+ return", "- list_lr_mod.append(x % MOD)", "- if i + 1 >= 2019:", "+ xmod = x % MOD", "+ if xmod == 0:", "- if 0 in list_lr_mod:", "- print((0))", "- return", "+ else:", "+ ...
false
0.037
0.036759
1.006555
[ "s671898079", "s320043229" ]
u704563784
p02659
python
s925224292
s602484328
26
21
9,936
9,148
Accepted
Accepted
19.23
from decimal import * n, m = input().split() root2 = Decimal(n) * Decimal(m) n = 0 y = Decimal(str(root2)).quantize(Decimal(str(10**(n*-1))), rounding=ROUND_DOWN) print(y)
n, m = input().split() n = int(n) a, b = list(map(int, m.split('.'))) m = a*100 + b print(((n*m)//100))
6
5
178
99
from decimal import * n, m = input().split() root2 = Decimal(n) * Decimal(m) n = 0 y = Decimal(str(root2)).quantize(Decimal(str(10 ** (n * -1))), rounding=ROUND_DOWN) print(y)
n, m = input().split() n = int(n) a, b = list(map(int, m.split("."))) m = a * 100 + b print(((n * m) // 100))
false
16.666667
[ "-from decimal import *", "-", "-root2 = Decimal(n) * Decimal(m)", "-n = 0", "-y = Decimal(str(root2)).quantize(Decimal(str(10 ** (n * -1))), rounding=ROUND_DOWN)", "-print(y)", "+n = int(n)", "+a, b = list(map(int, m.split(\".\")))", "+m = a * 100 + b", "+print(((n * m) // 100))" ]
false
0.095989
0.080425
1.193521
[ "s925224292", "s602484328" ]
u342869120
p02665
python
s616016887
s329035212
84
77
86,588
86,524
Accepted
Accepted
8.33
N = int(eval(input())) *A, = list(map(int, input().split())) Asum = [a for a in A] for i in range(N-1, -1, -1): Asum[i] += Asum[i+1] ans = 0 v = 1 # 子になれる頂点数 for i in range(N+1): if v < A[i]: ans = -1 break ans += v p = v-A[i] if i < N: if p > Asum[i+1]: ...
N = int(eval(input())) *A, = list(map(int, input().split())) Asum = [a for a in A] for i in range(N-1, -1, -1): Asum[i] += Asum[i+1] ans = 0 v = 1 # 子になれる頂点数 for i in range(N+1): if v < A[i]: ans = -1 break ans += v p = v-A[i] if i < N: v = min(Asum[i+1],...
23
20
396
328
N = int(eval(input())) (*A,) = list(map(int, input().split())) Asum = [a for a in A] for i in range(N - 1, -1, -1): Asum[i] += Asum[i + 1] ans = 0 v = 1 # 子になれる頂点数 for i in range(N + 1): if v < A[i]: ans = -1 break ans += v p = v - A[i] if i < N: if p > Asum[i + 1]: ...
N = int(eval(input())) (*A,) = list(map(int, input().split())) Asum = [a for a in A] for i in range(N - 1, -1, -1): Asum[i] += Asum[i + 1] ans = 0 v = 1 # 子になれる頂点数 for i in range(N + 1): if v < A[i]: ans = -1 break ans += v p = v - A[i] if i < N: v = min(Asum[i + 1], 2 * p) ...
false
13.043478
[ "- if p > Asum[i + 1]:", "- ans = -1", "- break" ]
false
0.1057
0.119394
0.885307
[ "s616016887", "s329035212" ]
u764860452
p03031
python
s508483560
s509981009
37
23
3,064
3,188
Accepted
Accepted
37.84
def main(): N,M=list(map(int,input().split())) s=[list(map(int,input().split()))[1:] for i in range(M)] p=list(map(int,input().split())) ans=0 for i in range(2**N): flag=True for j in range(M): if not ([(i>>k-1)&1 for k in s[j]].count(1)%2==p[j]): ...
import itertools def main(): N,M=list(map(int,input().split())) sw =[list(map(int, input().split())) for _ in range(M)] p=[int(x) for x in input().split()] ans=0 for i in itertools.product([0,1],repeat=N): onof=True for j in range(M): counter=0 ...
19
23
457
551
def main(): N, M = list(map(int, input().split())) s = [list(map(int, input().split()))[1:] for i in range(M)] p = list(map(int, input().split())) ans = 0 for i in range(2**N): flag = True for j in range(M): if not ([(i >> k - 1) & 1 for k in s[j]].count(1) % 2 == p[j]): ...
import itertools def main(): N, M = list(map(int, input().split())) sw = [list(map(int, input().split())) for _ in range(M)] p = [int(x) for x in input().split()] ans = 0 for i in itertools.product([0, 1], repeat=N): onof = True for j in range(M): counter = 0 ...
false
17.391304
[ "+import itertools", "+", "+", "- s = [list(map(int, input().split()))[1:] for i in range(M)]", "- p = list(map(int, input().split()))", "+ sw = [list(map(int, input().split())) for _ in range(M)]", "+ p = [int(x) for x in input().split()]", "- for i in range(2**N):", "- flag =...
false
0.035882
0.036677
0.978344
[ "s508483560", "s509981009" ]
u389523677
p02971
python
s121650909
s232025492
557
475
14,476
26,508
Accepted
Accepted
14.72
N = int(eval(input())) A = list(int(eval(input())) for k in range(N)) mx, mxn = sorted(A, reverse=True)[:2] for i in range(N): if A[i] == mx: print(mxn) else: print(mx)
N = int(eval(input())) A = list(int(eval(input())) for k in range(N)) mx, mxn = sorted(A, reverse=True)[:2] result = [mxn if x==mx else mx for x in A] print(('\n'.join(map(str, result))))
10
7
192
181
N = int(eval(input())) A = list(int(eval(input())) for k in range(N)) mx, mxn = sorted(A, reverse=True)[:2] for i in range(N): if A[i] == mx: print(mxn) else: print(mx)
N = int(eval(input())) A = list(int(eval(input())) for k in range(N)) mx, mxn = sorted(A, reverse=True)[:2] result = [mxn if x == mx else mx for x in A] print(("\n".join(map(str, result))))
false
30
[ "-for i in range(N):", "- if A[i] == mx:", "- print(mxn)", "- else:", "- print(mx)", "+result = [mxn if x == mx else mx for x in A]", "+print((\"\\n\".join(map(str, result))))" ]
false
0.036802
0.036754
1.001293
[ "s121650909", "s232025492" ]
u298297089
p03338
python
s716471126
s388180753
213
23
43,628
3,444
Accepted
Accepted
89.2
from collections import Counter N = int(eval(input())) S = eval(input()) mx = 0 for i in range(1,N): pre = Counter(S[:i]) back = Counter(S[i:]) tmp = 0 for k in list(pre.keys()): if k in back: tmp += 1 mx = max(mx, tmp) print(mx)
from collections import Counter n = int(eval(input())) s = eval(input()) ans = 0 for i in range(1,n-1): a = Counter(s[:i]) b = Counter(s[i:]) cnt = 0 for k in list(a.keys()): if k in b: cnt += 1 if cnt > ans: ans = cnt print(ans)
13
15
264
274
from collections import Counter N = int(eval(input())) S = eval(input()) mx = 0 for i in range(1, N): pre = Counter(S[:i]) back = Counter(S[i:]) tmp = 0 for k in list(pre.keys()): if k in back: tmp += 1 mx = max(mx, tmp) print(mx)
from collections import Counter n = int(eval(input())) s = eval(input()) ans = 0 for i in range(1, n - 1): a = Counter(s[:i]) b = Counter(s[i:]) cnt = 0 for k in list(a.keys()): if k in b: cnt += 1 if cnt > ans: ans = cnt print(ans)
false
13.333333
[ "-N = int(eval(input()))", "-S = eval(input())", "-mx = 0", "-for i in range(1, N):", "- pre = Counter(S[:i])", "- back = Counter(S[i:])", "- tmp = 0", "- for k in list(pre.keys()):", "- if k in back:", "- tmp += 1", "- mx = max(mx, tmp)", "-print(mx)", "+n =...
false
0.040913
0.035352
1.157316
[ "s716471126", "s388180753" ]
u796942881
p03103
python
s168444281
s775645431
241
174
22,804
25,836
Accepted
Accepted
27.8
from sys import stdin from operator import itemgetter input = stdin.readline N, M = list(map(int, input().split())) AB = [[int(j) for j in input().split()] for i in range(N)] def main(): AB.sort(key=itemgetter(0)) num = 0 yen = 0 for i in range(N): if M < num + AB[i][1]: ...
from sys import stdin N, M = list(map(int, input().split())) *AB, = list(map(int, stdin.read().split())) def main(): A = AB[::2] B = AB[1::2] Z = list(zip(A, B)) Z = sorted(Z) num = 0 yen = 0 for a, b in Z: if M < num + b: yen += a * (M - num) ...
26
25
494
414
from sys import stdin from operator import itemgetter input = stdin.readline N, M = list(map(int, input().split())) AB = [[int(j) for j in input().split()] for i in range(N)] def main(): AB.sort(key=itemgetter(0)) num = 0 yen = 0 for i in range(N): if M < num + AB[i][1]: yen += AB...
from sys import stdin N, M = list(map(int, input().split())) (*AB,) = list(map(int, stdin.read().split())) def main(): A = AB[::2] B = AB[1::2] Z = list(zip(A, B)) Z = sorted(Z) num = 0 yen = 0 for a, b in Z: if M < num + b: yen += a * (M - num) break ...
false
3.846154
[ "-from operator import itemgetter", "-input = stdin.readline", "-AB = [[int(j) for j in input().split()] for i in range(N)]", "+(*AB,) = list(map(int, stdin.read().split()))", "- AB.sort(key=itemgetter(0))", "+ A = AB[::2]", "+ B = AB[1::2]", "+ Z = list(zip(A, B))", "+ Z = sorted(Z)"...
false
0.116594
0.114525
1.018061
[ "s168444281", "s775645431" ]
u545368057
p02973
python
s191187533
s909405257
589
278
51,108
7,068
Accepted
Accepted
52.8
""" A = a1,a2,a3,a4,... 同じ色のとき、i<jならai<aj が成り立つときの最小の色の数 2 1 4 5 3 8 5 4 3 2 1 3 2 1 5 4 3 2 3 1 2 1 """ from bisect import bisect_right prev = 10**9+7 cnt = 0 As = [-prev] n = int(eval(input())) for _ in range(n): a = int(eval(input())) update = bisect_right...
""" A = a1,a2,a3,a4,... 同じ色のとき、i<jならai<aj が成り立つときの最小の色の数 """ from bisect import bisect_right prev = 10**9+7 cnt = 0 As = [-prev] n = int(eval(input())) for _ in range(n): a = int(eval(input())) update = bisect_right(As,-a) if update-1 == cnt: As.append(-a) cnt += 1 ...
47
25
449
370
""" A = a1,a2,a3,a4,... 同じ色のとき、i<jならai<aj が成り立つときの最小の色の数 2 1 4 5 3 8 5 4 3 2 1 3 2 1 5 4 3 2 3 1 2 1 """ from bisect import bisect_right prev = 10**9 + 7 cnt = 0 As = [-prev] n = int(eval(input())) for _ in range(n): a = int(eval(input())) update = bisect_right(As, -a) if update - 1 == cnt: ...
""" A = a1,a2,a3,a4,... 同じ色のとき、i<jならai<aj が成り立つときの最小の色の数 """ from bisect import bisect_right prev = 10**9 + 7 cnt = 0 As = [-prev] n = int(eval(input())) for _ in range(n): a = int(eval(input())) update = bisect_right(As, -a) if update - 1 == cnt: As.append(-a) cnt += 1 else: As...
false
46.808511
[ "-2 1 4 5 3", "-8", "-5", "-4", "-3", "-2", "-1", "-3", "-2", "-1", "-5", "-4", "-3", "-2 3", "-1 2", "-1" ]
false
0.04617
0.060029
0.769124
[ "s191187533", "s909405257" ]
u212831449
p03295
python
s161193246
s662935580
424
259
17,012
24,716
Accepted
Accepted
38.92
n,m = list(map(int,input().split())) s = [] for i in range(m): a,b = list(map(int,input().split())) s.append((b,a)) s.sort() ans = 1 start = s[0][1] end = s[0][0] for i in range(1,m): temp_start = s[i][1] temp_end = s[i][0] if temp_start >= end: ans += 1 end = temp_...
n,m = list(map(int,input().split())) l = [] for i in range(m): a,b = list(map(int,input().split())) l.append((a,b)) l = sorted(l, reverse=False, key=lambda x: x[1]) ans = 1 tmp = l[0][1] for i in range(1,len(l)): if tmp <= l[i][0]: tmp = l[i][1] ans += 1 print(ans) ...
19
18
329
319
n, m = list(map(int, input().split())) s = [] for i in range(m): a, b = list(map(int, input().split())) s.append((b, a)) s.sort() ans = 1 start = s[0][1] end = s[0][0] for i in range(1, m): temp_start = s[i][1] temp_end = s[i][0] if temp_start >= end: ans += 1 end = temp_end print(an...
n, m = list(map(int, input().split())) l = [] for i in range(m): a, b = list(map(int, input().split())) l.append((a, b)) l = sorted(l, reverse=False, key=lambda x: x[1]) ans = 1 tmp = l[0][1] for i in range(1, len(l)): if tmp <= l[i][0]: tmp = l[i][1] ans += 1 print(ans)
false
5.263158
[ "-s = []", "+l = []", "- s.append((b, a))", "-s.sort()", "+ l.append((a, b))", "+l = sorted(l, reverse=False, key=lambda x: x[1])", "-start = s[0][1]", "-end = s[0][0]", "-for i in range(1, m):", "- temp_start = s[i][1]", "- temp_end = s[i][0]", "- if temp_start >= end:", "+tm...
false
0.047427
0.047513
0.99818
[ "s161193246", "s662935580" ]
u869919400
p03807
python
s045784610
s567111729
262
226
62,448
62,448
Accepted
Accepted
13.74
n = int(eval(input())) arr = list(map(int, input().split())) odd = 0 for i in range(n): if arr[i] % 2 != 0: odd += 1 if odd % 2 == 0: print('YES') else: print('NO')
n = int(eval(input())) arr = list(map(int, input().split())) odd = 0 for i in range(n): if arr[i] % 2 != 0: odd += 1 print(('YES' if odd % 2 == 0 else 'NO'))
12
7
191
167
n = int(eval(input())) arr = list(map(int, input().split())) odd = 0 for i in range(n): if arr[i] % 2 != 0: odd += 1 if odd % 2 == 0: print("YES") else: print("NO")
n = int(eval(input())) arr = list(map(int, input().split())) odd = 0 for i in range(n): if arr[i] % 2 != 0: odd += 1 print(("YES" if odd % 2 == 0 else "NO"))
false
41.666667
[ "-if odd % 2 == 0:", "- print(\"YES\")", "-else:", "- print(\"NO\")", "+print((\"YES\" if odd % 2 == 0 else \"NO\"))" ]
false
0.047989
0.04413
1.087439
[ "s045784610", "s567111729" ]
u814265211
p03545
python
s049146913
s888589550
177
28
38,256
9,072
Accepted
Accepted
84.18
A, B, C, D = list(map(int, list(eval(input())))) if A-B-C-D == 7: print(('{}{}{}{}{}{}{}{}'.format(A, '-', B, '-', C, '-', D, '=7'))) elif A-B-C+D == 7: print(('{}{}{}{}{}{}{}{}'.format(A, '-', B, '-', C, '+', D, '=7'))) elif A-B+C-D == 7: print(('{}{}{}{}{}{}{}{}'.format(A, '-', B, '+', C, '-', D, ...
ABCD = list(eval(input())) for i in range(2 ** 3): ptn = ['-'] * 3 for j in range(3): if (i >> j) & 1: ptn[len(ptn) - j - 1] = '+' formula = ''.join([n + op for n, op in zip(ABCD, ptn + [''])]) if eval(formula) == 7: print((formula + '=7')) exit()
18
12
765
305
A, B, C, D = list(map(int, list(eval(input())))) if A - B - C - D == 7: print(("{}{}{}{}{}{}{}{}".format(A, "-", B, "-", C, "-", D, "=7"))) elif A - B - C + D == 7: print(("{}{}{}{}{}{}{}{}".format(A, "-", B, "-", C, "+", D, "=7"))) elif A - B + C - D == 7: print(("{}{}{}{}{}{}{}{}".format(A, "-", B, "+", C...
ABCD = list(eval(input())) for i in range(2**3): ptn = ["-"] * 3 for j in range(3): if (i >> j) & 1: ptn[len(ptn) - j - 1] = "+" formula = "".join([n + op for n, op in zip(ABCD, ptn + [""])]) if eval(formula) == 7: print((formula + "=7")) exit()
false
33.333333
[ "-A, B, C, D = list(map(int, list(eval(input()))))", "-if A - B - C - D == 7:", "- print((\"{}{}{}{}{}{}{}{}\".format(A, \"-\", B, \"-\", C, \"-\", D, \"=7\")))", "-elif A - B - C + D == 7:", "- print((\"{}{}{}{}{}{}{}{}\".format(A, \"-\", B, \"-\", C, \"+\", D, \"=7\")))", "-elif A - B + C - D == 7...
false
0.091623
0.047529
1.927728
[ "s049146913", "s888589550" ]
u217627525
p03814
python
s940634489
s862868853
67
59
3,512
3,516
Accepted
Accepted
11.94
s=eval(input()) a=0 find_a=0 z=len(s)-1 find_z=0 while find_a==0 or find_z==0: if find_a==0 and s[a]=="A": find_a=1 if find_z==0 and s[z]=="Z": find_z=1 if find_a==0: a+=1 if find_z==0: z-=1 print((z-a+1))
s=eval(input()) a=0 find_a=0 z=len(s)-1 find_z=0 while find_a==0 or find_z==0: if find_a==0: if s[a]=="A": find_a=1 else: a+=1 if find_z==0: if s[z]=="Z": find_z=1 else: z-=1 print((z-a+1))
15
17
259
285
s = eval(input()) a = 0 find_a = 0 z = len(s) - 1 find_z = 0 while find_a == 0 or find_z == 0: if find_a == 0 and s[a] == "A": find_a = 1 if find_z == 0 and s[z] == "Z": find_z = 1 if find_a == 0: a += 1 if find_z == 0: z -= 1 print((z - a + 1))
s = eval(input()) a = 0 find_a = 0 z = len(s) - 1 find_z = 0 while find_a == 0 or find_z == 0: if find_a == 0: if s[a] == "A": find_a = 1 else: a += 1 if find_z == 0: if s[z] == "Z": find_z = 1 else: z -= 1 print((z - a + 1))
false
11.764706
[ "- if find_a == 0 and s[a] == \"A\":", "- find_a = 1", "- if find_z == 0 and s[z] == \"Z\":", "- find_z = 1", "- a += 1", "+ if s[a] == \"A\":", "+ find_a = 1", "+ else:", "+ a += 1", "- z -= 1", "+ if s[z] == \"Z\":", ...
false
0.085746
0.144527
0.593287
[ "s940634489", "s862868853" ]
u001769145
p03600
python
s550725362
s861638595
374
191
74,172
75,516
Accepted
Accepted
48.93
# 63 n = int(eval(input())) dp = [[int(x) for x in input().split()] for y in range(n)] del_l = [] ans = 0 for i in range(n): for j in range(i+1,n): ans += dp[i][j] for i in range(n-1): for j in range(i+1,n): for k in range(n): if k in (i,j): contin...
# 63 n = int(eval(input())) dp = [[int(x) for x in input().split()] for y in range(n)] del_l = [] ans = 0 for i in range(n-1): for j in range(i+1,n): for k in range(n): if k in (i,j): continue if dp[i][j] > dp[i][k] + dp[k][j]: print("...
25
22
538
474
# 63 n = int(eval(input())) dp = [[int(x) for x in input().split()] for y in range(n)] del_l = [] ans = 0 for i in range(n): for j in range(i + 1, n): ans += dp[i][j] for i in range(n - 1): for j in range(i + 1, n): for k in range(n): if k in (i, j): continue ...
# 63 n = int(eval(input())) dp = [[int(x) for x in input().split()] for y in range(n)] del_l = [] ans = 0 for i in range(n - 1): for j in range(i + 1, n): for k in range(n): if k in (i, j): continue if dp[i][j] > dp[i][k] + dp[k][j]: print("-1") ...
false
12
[ "-for i in range(n):", "- for j in range(i + 1, n):", "- ans += dp[i][j]", "- ans -= dp[i][j]", "+ else:", "+ ans += dp[i][j]" ]
false
0.182972
0.047217
3.875154
[ "s550725362", "s861638595" ]
u130900604
p02717
python
s342246573
s019604041
166
17
38,384
2,940
Accepted
Accepted
89.76
def MI():return list(map(int,input().split())) def LI():return list(MI()) x,y,z=MI() x,y=y,x x,z=z,x print((x,y,z))
x,y,z=list(map(int,input().split())) print((z,x,y))
9
2
118
44
def MI(): return list(map(int, input().split())) def LI(): return list(MI()) x, y, z = MI() x, y = y, x x, z = z, x print((x, y, z))
x, y, z = list(map(int, input().split())) print((z, x, y))
false
77.777778
[ "-def MI():", "- return list(map(int, input().split()))", "-", "-", "-def LI():", "- return list(MI())", "-", "-", "-x, y, z = MI()", "-x, y = y, x", "-x, z = z, x", "-print((x, y, z))", "+x, y, z = list(map(int, input().split()))", "+print((z, x, y))" ]
false
0.047182
0.046721
1.009854
[ "s342246573", "s019604041" ]
u254871849
p02793
python
s544070717
s017465251
1,561
954
131,656
4,580
Accepted
Accepted
38.89
import sys MOD = 10 ** 9 + 7 from math import floor, sqrt from bisect import bisect_right as bi_r from collections import defaultdict def prime_nums(n=10**6): sieve = set(range(2, n + 1)) non_prime = set(range(2 * 2, n + 1, 2)) sieve -= non_prime for i in range(3, floor(sqrt(n)) + 1, 2): ...
import sys from functools import reduce MOD = 10 ** 9 + 7 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, *A = list(map(int, sys.stdin.read().split())) def main(): l = reduce(lcm, A, 1) % MOD res = 0 for a in...
68
28
1,614
468
import sys MOD = 10**9 + 7 from math import floor, sqrt from bisect import bisect_right as bi_r from collections import defaultdict def prime_nums(n=10**6): sieve = set(range(2, n + 1)) non_prime = set(range(2 * 2, n + 1, 2)) sieve -= non_prime for i in range(3, floor(sqrt(n)) + 1, 2): if i i...
import sys from functools import reduce MOD = 10**9 + 7 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, *A = list(map(int, sys.stdin.read().split())) def main(): l = reduce(lcm, A, 1) % MOD res = 0 for a in A: res +=...
false
58.823529
[ "+from functools import reduce", "-from math import floor, sqrt", "-from bisect import bisect_right as bi_r", "-from collections import defaultdict", "-def prime_nums(n=10**6):", "- sieve = set(range(2, n + 1))", "- non_prime = set(range(2 * 2, n + 1, 2))", "- sieve -= non_prime", "- for...
false
1.90659
0.040558
47.009188
[ "s544070717", "s017465251" ]
u923794601
p03627
python
s735780705
s745889886
336
84
31,368
14,244
Accepted
Accepted
75
#C_Make_A_Rectangle import numpy as np def MakeRectangle(N, A): A = np.array(A) length_list = list() length_buff = 0 for length in np.sort(A)[::-1]: if len(length_list) == 2: break if length_buff == length and length != 0: length_list.append(length) ...
#C_Make_A_Rectangle def MakeRectangle(N, A): A = sorted(A, reverse=True) length_list = list() length_buff = 0 for length in A: if len(length_list) == 2: break if length_buff == length and length != 0: length_list.append(length) length_buff ...
26
25
640
617
# C_Make_A_Rectangle import numpy as np def MakeRectangle(N, A): A = np.array(A) length_list = list() length_buff = 0 for length in np.sort(A)[::-1]: if len(length_list) == 2: break if length_buff == length and length != 0: length_list.append(length) ...
# C_Make_A_Rectangle def MakeRectangle(N, A): A = sorted(A, reverse=True) length_list = list() length_buff = 0 for length in A: if len(length_list) == 2: break if length_buff == length and length != 0: length_list.append(length) length_buff = 0 ...
false
3.846154
[ "-import numpy as np", "-", "-", "- A = np.array(A)", "+ A = sorted(A, reverse=True)", "- for length in np.sort(A)[::-1]:", "+ for length in A:" ]
false
0.210333
0.110316
1.906645
[ "s735780705", "s745889886" ]
u623231048
p02958
python
s823512512
s628644852
30
17
3,444
2,940
Accepted
Accepted
43.33
import copy n = int(eval(input())) li = list(map(int,input().split())) if all([li[i] < li[i+1] for i in range(n-1)]): print('YES') exit() for i in range(n): for j in range(i+1,n): a = copy.copy(li) a[i],a[j] = a[j],a[i] if all([a[i] < a[i+1] for i in range(n-1)]): ...
n = int(eval(input())) li = list(map(int,input().split())) count = 0 for i in range(n): if li[i] != i+1: count += 1 if count <= 2: print('YES') else: print('NO')
17
12
370
189
import copy n = int(eval(input())) li = list(map(int, input().split())) if all([li[i] < li[i + 1] for i in range(n - 1)]): print("YES") exit() for i in range(n): for j in range(i + 1, n): a = copy.copy(li) a[i], a[j] = a[j], a[i] if all([a[i] < a[i + 1] for i in range(n - 1)]): ...
n = int(eval(input())) li = list(map(int, input().split())) count = 0 for i in range(n): if li[i] != i + 1: count += 1 if count <= 2: print("YES") else: print("NO")
false
29.411765
[ "-import copy", "-", "-if all([li[i] < li[i + 1] for i in range(n - 1)]):", "+count = 0", "+for i in range(n):", "+ if li[i] != i + 1:", "+ count += 1", "+if count <= 2:", "- exit()", "-for i in range(n):", "- for j in range(i + 1, n):", "- a = copy.copy(li)", "- ...
false
0.058513
0.008012
7.302995
[ "s823512512", "s628644852" ]
u785883180
p02844
python
s896962047
s807831096
664
325
132,516
132,380
Accepted
Accepted
51.05
n=int(eval(input())) s=[int(c) for c in eval(input())] count=0 for p in range(10): for q in range(10): for r in range(10): if p in s[:n-2]: inp=s.index(p) if q in s[inp+1:n-1]: inq=s[inp+1:n-1].index(q)+inp+1 if r ...
n=int(eval(input())) s=[int(c) for c in eval(input())] count=0 for p in range(10): if p in s[:n-2]: inp=s.index(p) for q in range(10): if q in s[inp+1:n-1]: inq=s[inp+1:n-1].index(q)+inp+1 for r in range(10): ...
13
13
369
389
n = int(eval(input())) s = [int(c) for c in eval(input())] count = 0 for p in range(10): for q in range(10): for r in range(10): if p in s[: n - 2]: inp = s.index(p) if q in s[inp + 1 : n - 1]: inq = s[inp + 1 : n - 1].index(q) + inp + 1 ...
n = int(eval(input())) s = [int(c) for c in eval(input())] count = 0 for p in range(10): if p in s[: n - 2]: inp = s.index(p) for q in range(10): if q in s[inp + 1 : n - 1]: inq = s[inp + 1 : n - 1].index(q) + inp + 1 for r in range(10): ...
false
0
[ "- for q in range(10):", "- for r in range(10):", "- if p in s[: n - 2]:", "- inp = s.index(p)", "- if q in s[inp + 1 : n - 1]:", "- inq = s[inp + 1 : n - 1].index(q) + inp + 1", "+ if p in s[: n - 2]:", "+ inp = s.index(p...
false
0.124297
0.117377
1.058959
[ "s896962047", "s807831096" ]
u562935282
p03212
python
s655036064
s276671284
91
83
3,060
2,940
Accepted
Accepted
8.79
def check(var): return (0 <= var <= N) and all(c in str(var) for c in '753') def dfs(x): res = 0 if check(x): res += 1 if x <= N: for v in 3, 5, 7: res += dfs(10 * x + v) return res N = int(eval(input())) print((dfs(0)))
def dfs(s): res = 0 if int(s) > N: return res if all(c in s for c in '753'): res += 1 for v in '753': res += dfs(s + v) return res N = int(eval(input())) print((dfs('0')))
15
10
271
195
def check(var): return (0 <= var <= N) and all(c in str(var) for c in "753") def dfs(x): res = 0 if check(x): res += 1 if x <= N: for v in 3, 5, 7: res += dfs(10 * x + v) return res N = int(eval(input())) print((dfs(0)))
def dfs(s): res = 0 if int(s) > N: return res if all(c in s for c in "753"): res += 1 for v in "753": res += dfs(s + v) return res N = int(eval(input())) print((dfs("0")))
false
33.333333
[ "-def check(var):", "- return (0 <= var <= N) and all(c in str(var) for c in \"753\")", "-", "-", "-def dfs(x):", "+def dfs(s):", "- if check(x):", "+ if int(s) > N:", "+ return res", "+ if all(c in s for c in \"753\"):", "- if x <= N:", "- for v in 3, 5, 7:", "-...
false
0.051267
0.060548
0.846711
[ "s655036064", "s276671284" ]
u803848678
p03326
python
s029095279
s476354619
1,998
419
3,368
21,660
Accepted
Accepted
79.03
n, m = list(map(int, input().split())) v = [list(map(int, input().split())) for i in range(n)] ans = 0 op = [-1,1] for i in range(2): for j in range(2): for k in range(2): sx, sy, sz = op[i], op[j], op[k] dp = [-float("inf")]*(m+1) dp[0] = 0 for l, (...
import numpy as np n, m = list(map(int, input().split())) v = [list(map(int, input().split())) for i in range(n)] ans = 0 op = [-1,1] for i in range(2): for j in range(2): for k in range(2): sx, sy, sz = op[i], op[j], op[k] dp = np.full(m+1, -np.inf, dtype=np.float64) ...
19
18
598
549
n, m = list(map(int, input().split())) v = [list(map(int, input().split())) for i in range(n)] ans = 0 op = [-1, 1] for i in range(2): for j in range(2): for k in range(2): sx, sy, sz = op[i], op[j], op[k] dp = [-float("inf")] * (m + 1) dp[0] = 0 for l, (x, y,...
import numpy as np n, m = list(map(int, input().split())) v = [list(map(int, input().split())) for i in range(n)] ans = 0 op = [-1, 1] for i in range(2): for j in range(2): for k in range(2): sx, sy, sz = op[i], op[j], op[k] dp = np.full(m + 1, -np.inf, dtype=np.float64) ...
false
5.263158
[ "+import numpy as np", "+", "- dp = [-float(\"inf\")] * (m + 1)", "+ dp = np.full(m + 1, -np.inf, dtype=np.float64)", "- for l, (x, y, z) in enumerate(v):", "+ for x, y, z in v:", "- score = x + y + z", "- for h in range(min(m, ...
false
0.043543
0.242985
0.179201
[ "s029095279", "s476354619" ]
u075012704
p03014
python
s589875418
s556203239
1,929
1,379
309,128
319,900
Accepted
Accepted
28.51
H, W = list(map(int, input().split())) G = [list(eval(input())) for i in range(H)] up = [[0] * W for i in range(H)] # あるマスから上に連続していくつ障害物のないマスが続くか right = [[0] * W for i in range(H)] # あるマスから右に連続していくつ障害物のないマスが続くか down = [[0] * W for i in range(H)] # あるマスから下に連続していくつ障害物のないマスが続くか left = [[0] * W for i in range(...
def main(): H, W = list(map(int, input().split())) G = [list(input()) for i in range(H)] up = [[0] * W for i in range(H)] # あるマスから上に連続していくつ障害物のないマスが続くか right = [[0] * W for i in range(H)] # あるマスから右に連続していくつ障害物のないマスが続くか down = [[0] * W for i in range(H)] # あるマスから下に連続していくつ障害物のないマスが続くか ...
47
52
1,171
1,383
H, W = list(map(int, input().split())) G = [list(eval(input())) for i in range(H)] up = [[0] * W for i in range(H)] # あるマスから上に連続していくつ障害物のないマスが続くか right = [[0] * W for i in range(H)] # あるマスから右に連続していくつ障害物のないマスが続くか down = [[0] * W for i in range(H)] # あるマスから下に連続していくつ障害物のないマスが続くか left = [[0] * W for i in range(H)] # ある...
def main(): H, W = list(map(int, input().split())) G = [list(input()) for i in range(H)] up = [[0] * W for i in range(H)] # あるマスから上に連続していくつ障害物のないマスが続くか right = [[0] * W for i in range(H)] # あるマスから右に連続していくつ障害物のないマスが続くか down = [[0] * W for i in range(H)] # あるマスから下に連続していくつ障害物のないマスが続くか left = [[0...
false
9.615385
[ "-H, W = list(map(int, input().split()))", "-G = [list(eval(input())) for i in range(H)]", "-up = [[0] * W for i in range(H)] # あるマスから上に連続していくつ障害物のないマスが続くか", "-right = [[0] * W for i in range(H)] # あるマスから右に連続していくつ障害物のないマスが続くか", "-down = [[0] * W for i in range(H)] # あるマスから下に連続していくつ障害物のないマスが続くか", "-left...
false
0.108615
0.110922
0.979207
[ "s589875418", "s556203239" ]
u733814820
p03107
python
s627055692
s746072586
35
25
3,956
3,188
Accepted
Accepted
28.57
def resolve(): S = eval(input()) arr = [] for s in S: if len(arr) != 0 and arr[-1] != s: arr.pop() else: arr.append(s) print((len(S) - len(arr))) return if __name__ == "__main__": resolve()
def resolve(): s = eval(input()) red = 0 blue = 0 for c in s: if c == '0': red += 1 else: blue += 1 print((min(red, blue) * 2)) return if __name__ == "__main__": resolve()
14
14
229
212
def resolve(): S = eval(input()) arr = [] for s in S: if len(arr) != 0 and arr[-1] != s: arr.pop() else: arr.append(s) print((len(S) - len(arr))) return if __name__ == "__main__": resolve()
def resolve(): s = eval(input()) red = 0 blue = 0 for c in s: if c == "0": red += 1 else: blue += 1 print((min(red, blue) * 2)) return if __name__ == "__main__": resolve()
false
0
[ "- S = eval(input())", "- arr = []", "- for s in S:", "- if len(arr) != 0 and arr[-1] != s:", "- arr.pop()", "+ s = eval(input())", "+ red = 0", "+ blue = 0", "+ for c in s:", "+ if c == \"0\":", "+ red += 1", "- arr.append(s)...
false
0.036888
0.036988
0.997299
[ "s627055692", "s746072586" ]
u623814058
p03475
python
s681730097
s369951818
95
84
9,212
9,120
Accepted
Accepted
11.58
N=int(eval(input())) C=[list(map(int,input().split())) for _ in range(N-1)] for i in range(N-1): c,s,f=C[i] ans=s+c for j in range(i+1,N-1): nc,ns,nf=C[j] # print('D',ans,nc,ns,nf,(ans-ns)%nf) ans=max(ans,ns) m=(ans-ns)%nf if m!=0:ans+=nf-m # prin...
N=int(eval(input())) C=[list(map(int,input().split())) for _ in range(N-1)] for i in range(N-1): c,s,f=C[i] A=s+c for j in range(i+1,N-1): nc,ns,nf=C[j] if A<ns:A=ns elif (A-ns)%nf!=0:A+=nf-(A-ns)%nf A+=nc print(A) print((0))
16
13
388
250
N = int(eval(input())) C = [list(map(int, input().split())) for _ in range(N - 1)] for i in range(N - 1): c, s, f = C[i] ans = s + c for j in range(i + 1, N - 1): nc, ns, nf = C[j] # print('D',ans,nc,ns,nf,(ans-ns)%nf) ans = max(ans, ns) m = (ans - ns) % nf if m != 0:...
N = int(eval(input())) C = [list(map(int, input().split())) for _ in range(N - 1)] for i in range(N - 1): c, s, f = C[i] A = s + c for j in range(i + 1, N - 1): nc, ns, nf = C[j] if A < ns: A = ns elif (A - ns) % nf != 0: A += nf - (A - ns) % nf A += n...
false
18.75
[ "- ans = s + c", "+ A = s + c", "- # print('D',ans,nc,ns,nf,(ans-ns)%nf)", "- ans = max(ans, ns)", "- m = (ans - ns) % nf", "- if m != 0:", "- ans += nf - m", "- # print('D',ans,nc,ns,nf,(ans-ns)%nf)", "- ans += nc", "- print(ans)", "...
false
0.040376
0.044877
0.8997
[ "s681730097", "s369951818" ]
u597374218
p03673
python
s610681761
s780175510
167
152
26,180
32,488
Accepted
Accepted
8.98
N=int(eval(input())) A=list(map(int,input().split())) print((*(A[::-2]+A[N%2::2])))
from collections import deque n=int(eval(input())) a=list(map(int,input().split())) b=deque() for i in range(n): if i%2==0: b.append(a[i]) else: b.appendleft(a[i]) if n%2==0: print((*b)) else: print((*deque(reversed(b))))
3
13
77
255
N = int(eval(input())) A = list(map(int, input().split())) print((*(A[::-2] + A[N % 2 :: 2])))
from collections import deque n = int(eval(input())) a = list(map(int, input().split())) b = deque() for i in range(n): if i % 2 == 0: b.append(a[i]) else: b.appendleft(a[i]) if n % 2 == 0: print((*b)) else: print((*deque(reversed(b))))
false
76.923077
[ "-N = int(eval(input()))", "-A = list(map(int, input().split()))", "-print((*(A[::-2] + A[N % 2 :: 2])))", "+from collections import deque", "+", "+n = int(eval(input()))", "+a = list(map(int, input().split()))", "+b = deque()", "+for i in range(n):", "+ if i % 2 == 0:", "+ b.append(a[...
false
0.038389
0.040209
0.954736
[ "s610681761", "s780175510" ]
u989345508
p02678
python
s493312982
s429487857
1,000
767
39,276
39,384
Accepted
Accepted
23.3
f=lambda:map(int,input().split());n,m=f();g=[[] for _ in range(n)] for _ in [0]*m:a,b=f();g[a-1]+=[b-1];g[b-1]+=[a-1] p=[0]*n;from queue import*;q=Queue();q.put(0) while not q.empty(): v=q.get() for c in g[v]: if p[c]<1:p[c]=v+1;q.put(c) print('Yes',*p[1:],sep='\n')
f=lambda:map(int,input().split());n,m=f();g=[[] for _ in range(n)] for _ in [0]*m:a,b=f();g[a-1]+=[b-1];g[b-1]+=[a-1] p=[0]*n;from collections import*;q=deque([0]) while q: for c in g[(v:=q.popleft())]: if p[c]<1:p[c]=v+1;q.append(c) print('Yes',*p[1:],sep='\n')
8
7
289
280
f = lambda: map(int, input().split()) n, m = f() g = [[] for _ in range(n)] for _ in [0] * m: a, b = f() g[a - 1] += [b - 1] g[b - 1] += [a - 1] p = [0] * n from queue import * q = Queue() q.put(0) while not q.empty(): v = q.get() for c in g[v]: if p[c] < 1: p[c] = v + 1 ...
f = lambda: map(int, input().split()) n, m = f() g = [[] for _ in range(n)] for _ in [0] * m: a, b = f() g[a - 1] += [b - 1] g[b - 1] += [a - 1] p = [0] * n from collections import * q = deque([0]) while q: for c in g[(v := q.popleft())]: if p[c] < 1: p[c] = v + 1 q.appe...
false
12.5
[ "-from queue import *", "+from collections import *", "-q = Queue()", "-q.put(0)", "-while not q.empty():", "- v = q.get()", "- for c in g[v]:", "+q = deque([0])", "+while q:", "+ for c in g[(v := q.popleft())]:", "- q.put(c)", "+ q.append(c)" ]
false
0.038178
0.036283
1.052239
[ "s493312982", "s429487857" ]
u600402037
p02843
python
s061548881
s565329959
1,091
17
21,228
3,060
Accepted
Accepted
98.44
import sys import numpy as np sys.setrecursionlimit(10 ** 9) stdin = sys.stdin ri = lambda: int(rs()) rl = lambda: list(map(int, stdin.readline().split())) rs = lambda: stdin.readline().rstrip() # ignore trailing spaces X = ri() q, r = divmod(X, 100) bool = True if q * 5 < r: bool = False elif X...
import sys stdin = sys.stdin ri = lambda: int(rs()) rl = lambda: list(map(int, stdin.readline().split())) rs = lambda: stdin.readline().rstrip() # ignore trailing spaces X = ri() q, r = divmod(X, 100) bool = True if q * 5 < r: bool = False print((1 if bool else 0))
49
15
1,353
288
import sys import numpy as np sys.setrecursionlimit(10**9) stdin = sys.stdin ri = lambda: int(rs()) rl = lambda: list(map(int, stdin.readline().split())) rs = lambda: stdin.readline().rstrip() # ignore trailing spaces X = ri() q, r = divmod(X, 100) bool = True if q * 5 < r: bool = False elif X > 105 * 10**6: ...
import sys stdin = sys.stdin ri = lambda: int(rs()) rl = lambda: list(map(int, stdin.readline().split())) rs = lambda: stdin.readline().rstrip() # ignore trailing spaces X = ri() q, r = divmod(X, 100) bool = True if q * 5 < r: bool = False print((1 if bool else 0))
false
69.387755
[ "-import numpy as np", "-sys.setrecursionlimit(10**9)", "-elif X > 105 * 10**6:", "- X -= 105 * 10**6", "- # パソコン使い果たす", "- q, r = divmod(X, 100)", "- if q * 4 < r:", "- bool = False", "- elif X > 104 * 10**6:", "- X -= 104 * 10**6", "- q, r = divmod(X, 100)",...
false
0.070247
0.039089
1.797103
[ "s061548881", "s565329959" ]
u868701750
p03610
python
s672518951
s588794902
39
17
4,268
3,188
Accepted
Accepted
56.41
s = list(eval(input())) ans = [] for i, _s in enumerate(s): if not i % 2: ans += [_s] print((''.join(ans)))
s = eval(input()) print((s[::2]))
6
2
117
27
s = list(eval(input())) ans = [] for i, _s in enumerate(s): if not i % 2: ans += [_s] print(("".join(ans)))
s = eval(input()) print((s[::2]))
false
66.666667
[ "-s = list(eval(input()))", "-ans = []", "-for i, _s in enumerate(s):", "- if not i % 2:", "- ans += [_s]", "-print((\"\".join(ans)))", "+s = eval(input())", "+print((s[::2]))" ]
false
0.055465
0.15351
0.361314
[ "s672518951", "s588794902" ]
u605880635
p02630
python
s238176633
s867683001
313
268
15,040
15,008
Accepted
Accepted
14.38
import sys readline = sys.stdin.readline def st(line): tmp = '' for l in line: if l == '\n': yield tmp elif l == ' ': yield tmp tmp = '' else: tmp += l N = int(eval(input())) As = st(readline()) d = dict() total...
import sys readline = sys.stdin.readline def st(line): tmp = '' for l in line: if l == '\n': yield tmp elif l == ' ': yield tmp tmp = '' else: tmp += l def solve(): N = int(eval(input())) As = st(readline()) ...
52
59
761
942
import sys readline = sys.stdin.readline def st(line): tmp = "" for l in line: if l == "\n": yield tmp elif l == " ": yield tmp tmp = "" else: tmp += l N = int(eval(input())) As = st(readline()) d = dict() total = 0 for a in As: a ...
import sys readline = sys.stdin.readline def st(line): tmp = "" for l in line: if l == "\n": yield tmp elif l == " ": yield tmp tmp = "" else: tmp += l def solve(): N = int(eval(input())) As = st(readline()) d = dict() ...
false
11.864407
[ "-N = int(eval(input()))", "-As = st(readline())", "-d = dict()", "-total = 0", "-for a in As:", "- a = int(a)", "- if a in d:", "- d[a] += 1", "- else:", "- d[a] = 1", "- total += a", "-Q = int(eval(input()))", "-queries = (list(map(int, readline().strip().split())...
false
0.039727
0.041954
0.946917
[ "s238176633", "s867683001" ]
u821251381
p02572
python
s459740401
s046751620
175
120
31,692
31,648
Accepted
Accepted
31.43
N,*A = list(map(int,open(0).read().split())) s = sum(A) CS = [0 for i in range(N+1)] CS[0] = s for i in range(len(A)): CS[i+1] = CS[i] - A[i] CS.pop(0) S = 0 for i,a in enumerate(A): S+=CS[i]*a S = (S%1000000007) print(S)
N,*A = list(map(int,open(0).read().split())) S_all = sum(A)**2 diag = sum([a**2 for a in A]) S = S_all-diag S %= 1000000007 S = (S*pow(2,-1,1000000007))%1000000007 print(S)
14
10
236
179
N, *A = list(map(int, open(0).read().split())) s = sum(A) CS = [0 for i in range(N + 1)] CS[0] = s for i in range(len(A)): CS[i + 1] = CS[i] - A[i] CS.pop(0) S = 0 for i, a in enumerate(A): S += CS[i] * a S = S % 1000000007 print(S)
N, *A = list(map(int, open(0).read().split())) S_all = sum(A) ** 2 diag = sum([a**2 for a in A]) S = S_all - diag S %= 1000000007 S = (S * pow(2, -1, 1000000007)) % 1000000007 print(S)
false
28.571429
[ "-s = sum(A)", "-CS = [0 for i in range(N + 1)]", "-CS[0] = s", "-for i in range(len(A)):", "- CS[i + 1] = CS[i] - A[i]", "-CS.pop(0)", "-S = 0", "-for i, a in enumerate(A):", "- S += CS[i] * a", "- S = S % 1000000007", "+S_all = sum(A) ** 2", "+diag = sum([a**2 for a in A])", "+S =...
false
0.03832
0.04854
0.789444
[ "s459740401", "s046751620" ]
u046187684
p02850
python
s636726133
s763908760
622
574
74,996
50,544
Accepted
Accepted
7.72
from collections import deque def solve(string): n, *ab = list(map(int, string.split())) # i != j => (ai, bi) != (aj, bj) next_ = [dict([]) for _ in range(n + 1)] color = [set([]) for _ in range(n + 1)] queue = deque([1]) for a, b in zip(*[iter(ab)] * 2): next_[a][b] = 0 ...
from collections import deque def solve(string): n, *ab = list(map(int, string.split())) next_ = [dict([]) for _ in range(n + 1)] # color = [set([]) for _ in range(n + 1)] queue = deque([1]) for a, b in zip(*[iter(ab)] * 2): next_[a][b] = 0 next_[b][a] = 0 while len(...
30
30
979
1,019
from collections import deque def solve(string): n, *ab = list(map(int, string.split())) # i != j => (ai, bi) != (aj, bj) next_ = [dict([]) for _ in range(n + 1)] color = [set([]) for _ in range(n + 1)] queue = deque([1]) for a, b in zip(*[iter(ab)] * 2): next_[a][b] = 0 next_[...
from collections import deque def solve(string): n, *ab = list(map(int, string.split())) next_ = [dict([]) for _ in range(n + 1)] # color = [set([]) for _ in range(n + 1)] queue = deque([1]) for a, b in zip(*[iter(ab)] * 2): next_[a][b] = 0 next_[b][a] = 0 while len(queue) > 0:...
false
0
[ "- # i != j => (ai, bi) != (aj, bj)", "- color = [set([]) for _ in range(n + 1)]", "+ # color = [set([]) for _ in range(n + 1)]", "- use = set(range(1, len(_next) + 1)) - color[c]", "+ # use = set(range(1, len(_next) + 1)) - color[c]", "+ use = set(range(1, len(_next) + 1)) -...
false
0.059294
0.087939
0.674256
[ "s636726133", "s763908760" ]
u606045429
p02850
python
s163599194
s244155133
634
535
69,540
53,540
Accepted
Accepted
15.62
from collections import deque N, *AB = list(map(int, open(0).read().split())) E = [set() for _ in range(N + 1)] memo = {} for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)): E[a].add(b) E[b].add(a) memo[(a, b)] = i memo[(b, a)] = i K = max(len(e) for e in E) A = [0] * (N - 1) Q = dequ...
from collections import deque N, *AB = list(map(int, open(0).read().split())) E = [set() for _ in range(N + 1)] for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)): E[a].add((b, i)) E[b].add((a, i)) K = max(len(e) for e in E) A = [0] * (N - 1) Q = deque([(-1, 1)]) while Q: p, v = Q.popleft() ...
29
24
568
516
from collections import deque N, *AB = list(map(int, open(0).read().split())) E = [set() for _ in range(N + 1)] memo = {} for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)): E[a].add(b) E[b].add(a) memo[(a, b)] = i memo[(b, a)] = i K = max(len(e) for e in E) A = [0] * (N - 1) Q = deque([(-1, 1)]) while Q...
from collections import deque N, *AB = list(map(int, open(0).read().split())) E = [set() for _ in range(N + 1)] for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)): E[a].add((b, i)) E[b].add((a, i)) K = max(len(e) for e in E) A = [0] * (N - 1) Q = deque([(-1, 1)]) while Q: p, v = Q.popleft() C = (c for c ...
false
17.241379
[ "-memo = {}", "- E[a].add(b)", "- E[b].add(a)", "- memo[(a, b)] = i", "- memo[(b, a)] = i", "+ E[a].add((b, i))", "+ E[b].add((a, i))", "- for u in E[v]:", "- E[u].remove(v)", "+ for u, i in E[v]:", "+ E[u].remove((v, i))", "- A[memo[(v, u)]] = c", ...
false
0.046078
0.037261
1.236645
[ "s163599194", "s244155133" ]
u282228874
p03244
python
s778738803
s749152814
247
87
58,988
20,700
Accepted
Accepted
64.78
n = int(eval(input())) V = list(map(int,input().split())) a = [0]*100000 b = [0]*100000 v1=[] v2=[] if len(set(V)) == 1: print((n//2)) else: for i in range(n): if i%2 == 0: a[V[i]-1] += 1 v1.append(V[i]) else: b[V[i]-1] += 1 v2.a...
from collections import Counter N = int(eval(input())) V = list(map(int,input().split())) zero = Counter(V[::2]).most_common() one = Counter(V[1::2]).most_common() if zero[0][0] != one[0][0]: print((N-zero[0][1]-one[0][1])) else: if len(zero) == 1 and len(one) == 1: print((N//2)) elif len(...
37
16
692
502
n = int(eval(input())) V = list(map(int, input().split())) a = [0] * 100000 b = [0] * 100000 v1 = [] v2 = [] if len(set(V)) == 1: print((n // 2)) else: for i in range(n): if i % 2 == 0: a[V[i] - 1] += 1 v1.append(V[i]) else: b[V[i] - 1] += 1 v2.app...
from collections import Counter N = int(eval(input())) V = list(map(int, input().split())) zero = Counter(V[::2]).most_common() one = Counter(V[1::2]).most_common() if zero[0][0] != one[0][0]: print((N - zero[0][1] - one[0][1])) else: if len(zero) == 1 and len(one) == 1: print((N // 2)) elif len(ze...
false
56.756757
[ "-n = int(eval(input()))", "+from collections import Counter", "+", "+N = int(eval(input()))", "-a = [0] * 100000", "-b = [0] * 100000", "-v1 = []", "-v2 = []", "-if len(set(V)) == 1:", "- print((n // 2))", "+zero = Counter(V[::2]).most_common()", "+one = Counter(V[1::2]).most_common()", ...
false
0.058309
0.054316
1.07351
[ "s778738803", "s749152814" ]
u457901067
p02642
python
s564611692
s788542553
605
438
33,164
33,052
Accepted
Accepted
27.6
#maspyさんを参考に import sys #import numpy as np #from numba import njit read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # この最適化がよくわからん。Numpyループなら行けるらしい # 400msくらいは最低でもかかるけど、N=10^5でも2でも変わらんと言う #@njit('(i4[::1],)', cache=True) def solve(A): # エラトステネス古...
#maspyさんを参考に import sys #import numpy as np #from numba import njit read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # この最適化がよくわからん。Numpyループなら行けるらしい # 400msくらいは最低でもかかるけど、N=10^5でも2でも変わらんと言う #@njit('(i4[::1],)', cache=True) def solve(A): # エラトステネス古...
44
44
1,053
1,061
# maspyさんを参考に import sys # import numpy as np # from numba import njit read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # この最適化がよくわからん。Numpyループなら行けるらしい # 400msくらいは最低でもかかるけど、N=10^5でも2でも変わらんと言う # @njit('(i4[::1],)', cache=True) def solve(A): # エラトステネス古いって値側のバリエ...
# maspyさんを参考に import sys # import numpy as np # from numba import njit read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # この最適化がよくわからん。Numpyループなら行けるらしい # 400msくらいは最低でもかかるけど、N=10^5でも2でも変わらんと言う # @njit('(i4[::1],)', cache=True) def solve(A): # エラトステネス古いって値側のバリエ...
false
0
[ "-print((solve2(A)))", "+print((solve2(sorted(A))))" ]
false
0.419847
0.333261
1.259812
[ "s564611692", "s788542553" ]
u033606236
p03625
python
s713776742
s128043201
105
97
14,252
18,600
Accepted
Accepted
7.62
n = int(eval(input())) a = sorted(list(map(int,input().split())),reverse=True) a += [0] b = -1 ans = [0,0] count = 0 for i in range(n+1): count += 1 if b != a[i]: if count >= 4: if ans[0]: ans[1] = b break else: ans[0]...
from collections import Counter n = int(eval(input())) a = list(map(int,input().split())) a = Counter(a) ary = [0,0] for i in a: if a[i] >= 4: ary.append(i) ary.append(i) elif a[i] >= 2: ary.append(i) ary.sort() print((ary.pop()*ary.pop()))
25
13
558
276
n = int(eval(input())) a = sorted(list(map(int, input().split())), reverse=True) a += [0] b = -1 ans = [0, 0] count = 0 for i in range(n + 1): count += 1 if b != a[i]: if count >= 4: if ans[0]: ans[1] = b break else: ans[0] = b ...
from collections import Counter n = int(eval(input())) a = list(map(int, input().split())) a = Counter(a) ary = [0, 0] for i in a: if a[i] >= 4: ary.append(i) ary.append(i) elif a[i] >= 2: ary.append(i) ary.sort() print((ary.pop() * ary.pop()))
false
48
[ "+from collections import Counter", "+", "-a = sorted(list(map(int, input().split())), reverse=True)", "-a += [0]", "-b = -1", "-ans = [0, 0]", "-count = 0", "-for i in range(n + 1):", "- count += 1", "- if b != a[i]:", "- if count >= 4:", "- if ans[0]:", "- ...
false
0.046253
0.130491
0.354457
[ "s713776742", "s128043201" ]
u692453235
p03486
python
s023238366
s344258613
33
28
9,320
8,936
Accepted
Accepted
15.15
from collections import defaultdict s = eval(input()) t = eval(input()) AL = "abcdefghijklmnopqrstuvwxyz" S = defaultdict(int) T = defaultdict(int) for al in s: S[al] += 1 for al in t: T[al] += 1 ans_s = "" for al in AL: ans_s += al*S[al] ans_t = "" for al in reversed(list(AL)): ans_t...
s = eval(input()) t = eval(input()) S = "".join(sorted(list(s))) T = "".join(sorted(list(t), reverse=True)) if S < T: print("Yes") else: print("No")
27
10
379
151
from collections import defaultdict s = eval(input()) t = eval(input()) AL = "abcdefghijklmnopqrstuvwxyz" S = defaultdict(int) T = defaultdict(int) for al in s: S[al] += 1 for al in t: T[al] += 1 ans_s = "" for al in AL: ans_s += al * S[al] ans_t = "" for al in reversed(list(AL)): ans_t += al * T[al] i...
s = eval(input()) t = eval(input()) S = "".join(sorted(list(s))) T = "".join(sorted(list(t), reverse=True)) if S < T: print("Yes") else: print("No")
false
62.962963
[ "-from collections import defaultdict", "-", "-AL = \"abcdefghijklmnopqrstuvwxyz\"", "-S = defaultdict(int)", "-T = defaultdict(int)", "-for al in s:", "- S[al] += 1", "-for al in t:", "- T[al] += 1", "-ans_s = \"\"", "-for al in AL:", "- ans_s += al * S[al]", "-ans_t = \"\"", "-f...
false
0.043404
0.041742
1.039798
[ "s023238366", "s344258613" ]
u063052907
p03774
python
s609985896
s951122380
21
18
3,064
2,940
Accepted
Accepted
14.29
# coding: utf-8 def manhattan(x1, y1, x2, y2): return abs(x1-x2) + abs(y1-y2) N, M = list(map(int, input().split())) students = [eval(input()) for _ in range(N)] c_points = [eval(input()) for _ in range(M)] for s in students: val = 400000001 ans = 0 a, b = list(map(int, s.split())) for...
# coding: utf-8 N, M = list(map(int, input().split())) students = [list(map(int, input().split())) for _ in range(N)] c_points = [list(map(int, input().split())) for _ in range(M)] for a,b in students: m_dis = [abs(a-c) + abs(b-d) for c,d in c_points] print((m_dis.index(min(m_dis)) + 1))
19
8
487
297
# coding: utf-8 def manhattan(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2) N, M = list(map(int, input().split())) students = [eval(input()) for _ in range(N)] c_points = [eval(input()) for _ in range(M)] for s in students: val = 400000001 ans = 0 a, b = list(map(int, s.split())) for j, c in...
# coding: utf-8 N, M = list(map(int, input().split())) students = [list(map(int, input().split())) for _ in range(N)] c_points = [list(map(int, input().split())) for _ in range(M)] for a, b in students: m_dis = [abs(a - c) + abs(b - d) for c, d in c_points] print((m_dis.index(min(m_dis)) + 1))
false
57.894737
[ "-def manhattan(x1, y1, x2, y2):", "- return abs(x1 - x2) + abs(y1 - y2)", "-", "-", "-students = [eval(input()) for _ in range(N)]", "-c_points = [eval(input()) for _ in range(M)]", "-for s in students:", "- val = 400000001", "- ans = 0", "- a, b = list(map(int, s.split()))", "- ...
false
0.042292
0.041878
1.009882
[ "s609985896", "s951122380" ]
u677440371
p03325
python
s798123899
s683158604
96
63
4,148
4,148
Accepted
Accepted
34.38
n = int(eval(input())) a = [int(i) for i in input().split()] a = sorted(list([x for x in a if (x % 2) == 0]), reverse=True) ans = 0 for i in a: while i % 2 == 0: i //= 2 ans += 1 print((int(ans)))
n = int(eval(input())) a = [int(i) for i in input().split()] def count(number): count = 0 while True: if number % 2 == 0: number //= 2 count += 1 else: break return count a_2 = [int(i) for i in a if i % 2 == 0] ans = 0 for i in a_2: ...
10
19
222
344
n = int(eval(input())) a = [int(i) for i in input().split()] a = sorted(list([x for x in a if (x % 2) == 0]), reverse=True) ans = 0 for i in a: while i % 2 == 0: i //= 2 ans += 1 print((int(ans)))
n = int(eval(input())) a = [int(i) for i in input().split()] def count(number): count = 0 while True: if number % 2 == 0: number //= 2 count += 1 else: break return count a_2 = [int(i) for i in a if i % 2 == 0] ans = 0 for i in a_2: ans += count(i)...
false
47.368421
[ "-a = sorted(list([x for x in a if (x % 2) == 0]), reverse=True)", "+", "+", "+def count(number):", "+ count = 0", "+ while True:", "+ if number % 2 == 0:", "+ number //= 2", "+ count += 1", "+ else:", "+ break", "+ return count", "+", ...
false
0.037143
0.051353
0.723277
[ "s798123899", "s683158604" ]
u346395915
p03013
python
s168917535
s130597861
467
151
460,020
13,848
Accepted
Accepted
67.67
n, m = list(map(int,input().split())) arr = [int(eval(input())) for _ in range(m)] broken = set(arr) mod = 10 ** 9 + 7 dp = [0] * (n+1) dp[0] = 1 for i in range(1,n+1): if i in broken: continue if i == 1: dp[1] = dp[0] continue dp[i] = dp[i-1] + dp[i-2] ...
n, m = list(map(int, input().split())) li = [int(eval(input())) for _ in range(m)] mod = 10**9 + 7 dp = [-1] * (n+1) dp[0] = 1 for i in li: dp[i] = 0 for i in range(1,n+1): if dp[i] == 0: continue if i == 1: dp[1] = 1 else: dp[i] = (dp[i-1] + dp[i-2])%mod...
20
20
329
334
n, m = list(map(int, input().split())) arr = [int(eval(input())) for _ in range(m)] broken = set(arr) mod = 10**9 + 7 dp = [0] * (n + 1) dp[0] = 1 for i in range(1, n + 1): if i in broken: continue if i == 1: dp[1] = dp[0] continue dp[i] = dp[i - 1] + dp[i - 2] print((dp[n] % mod))
n, m = list(map(int, input().split())) li = [int(eval(input())) for _ in range(m)] mod = 10**9 + 7 dp = [-1] * (n + 1) dp[0] = 1 for i in li: dp[i] = 0 for i in range(1, n + 1): if dp[i] == 0: continue if i == 1: dp[1] = 1 else: dp[i] = (dp[i - 1] + dp[i - 2]) % mod print((dp[-1]...
false
0
[ "-arr = [int(eval(input())) for _ in range(m)]", "-broken = set(arr)", "+li = [int(eval(input())) for _ in range(m)]", "-dp = [0] * (n + 1)", "+dp = [-1] * (n + 1)", "+for i in li:", "+ dp[i] = 0", "- if i in broken:", "+ if dp[i] == 0:", "- dp[1] = dp[0]", "- continue", ...
false
0.043138
0.037871
1.139083
[ "s168917535", "s130597861" ]
u437351386
p03476
python
s614348996
s824509782
732
445
16,384
21,476
Accepted
Accepted
39.21
#素数判定 import math from itertools import accumulate def sosuu(n): if n==1: return False else: for i in range(2,int(math.sqrt(n)+1)): if n%i==0: return False return True #入力 q=int(eval(input())) l=[0]*q r=[0]*q for i in range(q): l[i],r[i]=list(map(int,input().split()))...
import math from itertools import accumulate q=int(eval(input())) l=[] r=[] for i in range(q): a,b=list(map(int,input().split())) l.append(a) r.append(b) def is_prime(n): if n==1: return False elif n==2: return True else: for i in range(2,int(math.sqrt(n)+1)): if n%i==0...
39
38
649
674
# 素数判定 import math from itertools import accumulate def sosuu(n): if n == 1: return False else: for i in range(2, int(math.sqrt(n) + 1)): if n % i == 0: return False return True # 入力 q = int(eval(input())) l = [0] * q r = [0] * q for i in range(q): l[i...
import math from itertools import accumulate q = int(eval(input())) l = [] r = [] for i in range(q): a, b = list(map(int, input().split())) l.append(a) r.append(b) def is_prime(n): if n == 1: return False elif n == 2: return True else: for i in range(2, int(math.sqrt(n...
false
2.564103
[ "-# 素数判定", "+q = int(eval(input()))", "+l = []", "+r = []", "+for i in range(q):", "+ a, b = list(map(int, input().split()))", "+ l.append(a)", "+ r.append(b)", "-def sosuu(n):", "+", "+def is_prime(n):", "+ elif n == 2:", "+ return True", "- return True", "+ ...
false
0.039349
0.071412
0.551009
[ "s614348996", "s824509782" ]
u131925051
p02693
python
s231063060
s613924681
22
20
9,184
9,152
Accepted
Accepted
9.09
K = int(eval(input())) score = input().split() s1 = int(score[0]) s2 = int(score[1]) if ( s1 % K ) == 0: print('OK') elif ( s2 % K ) == 0: print('OK') elif ( s1 // K ) < ( s2 // K ): print('OK') else: print('NG')
K = int(eval(input())) A,B = list(map(int, input().split())) for i in range(A, B+1): if i % K == 0: print('OK') exit() print('NG')
12
7
225
129
K = int(eval(input())) score = input().split() s1 = int(score[0]) s2 = int(score[1]) if (s1 % K) == 0: print("OK") elif (s2 % K) == 0: print("OK") elif (s1 // K) < (s2 // K): print("OK") else: print("NG")
K = int(eval(input())) A, B = list(map(int, input().split())) for i in range(A, B + 1): if i % K == 0: print("OK") exit() print("NG")
false
41.666667
[ "-score = input().split()", "-s1 = int(score[0])", "-s2 = int(score[1])", "-if (s1 % K) == 0:", "- print(\"OK\")", "-elif (s2 % K) == 0:", "- print(\"OK\")", "-elif (s1 // K) < (s2 // K):", "- print(\"OK\")", "-else:", "- print(\"NG\")", "+A, B = list(map(int, input().split()))", ...
false
0.061847
0.078452
0.788346
[ "s231063060", "s613924681" ]
u796942881
p03111
python
s533650050
s682537875
70
18
3,064
3,064
Accepted
Accepted
74.29
INF = 1000000007 def dfs(cur, a, b, c): if cur == N: return abs(a - A) + abs(b - B) + abs(c - C) - 30\ if 0 < min(a, b, c) else INF ret1 = dfs(cur + 1, a + l[cur], b, c) + 10 ret2 = dfs(cur + 1, a, b + l[cur], c) + 10 ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10 ret4 ...
from itertools import combinations from itertools import permutations def f(x, lst, rem): d = abs(x - min(lst)) min_lst = min(lst) tpl = None for v in range(1, len(lst) - rem + 2): for t in combinations(lst, v): if abs(x - sum(t)) + 10 * (v - 1) < d: d = ...
21
37
496
877
INF = 1000000007 def dfs(cur, a, b, c): if cur == N: return abs(a - A) + abs(b - B) + abs(c - C) - 30 if 0 < min(a, b, c) else INF ret1 = dfs(cur + 1, a + l[cur], b, c) + 10 ret2 = dfs(cur + 1, a, b + l[cur], c) + 10 ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10 ret4 = dfs(cur + 1, a, b, c) ...
from itertools import combinations from itertools import permutations def f(x, lst, rem): d = abs(x - min(lst)) min_lst = min(lst) tpl = None for v in range(1, len(lst) - rem + 2): for t in combinations(lst, v): if abs(x - sum(t)) + 10 * (v - 1) < d: d = abs(x - sum...
false
43.243243
[ "-INF = 1000000007", "+from itertools import combinations", "+from itertools import permutations", "-def dfs(cur, a, b, c):", "- if cur == N:", "- return abs(a - A) + abs(b - B) + abs(c - C) - 30 if 0 < min(a, b, c) else INF", "- ret1 = dfs(cur + 1, a + l[cur], b, c) + 10", "- ret2 = d...
false
0.07252
0.036139
2.006715
[ "s533650050", "s682537875" ]
u133936772
p03041
python
s270272852
s175435042
20
17
2,940
2,940
Accepted
Accepted
15
n, k = list(map(int,input().split())) s = eval(input()) ans = '' for i in range(n): if i == k-1: ans += s[i].lower() else: ans += s[i] print(ans)
_,k=input().split() s=list(input()) k=int(k)-1 s[k]=s[k].lower() print(*s,sep='')
9
5
153
85
n, k = list(map(int, input().split())) s = eval(input()) ans = "" for i in range(n): if i == k - 1: ans += s[i].lower() else: ans += s[i] print(ans)
_, k = input().split() s = list(input()) k = int(k) - 1 s[k] = s[k].lower() print(*s, sep="")
false
44.444444
[ "-n, k = list(map(int, input().split()))", "-s = eval(input())", "-ans = \"\"", "-for i in range(n):", "- if i == k - 1:", "- ans += s[i].lower()", "- else:", "- ans += s[i]", "-print(ans)", "+_, k = input().split()", "+s = list(input())", "+k = int(k) - 1", "+s[k] = s[k]...
false
0.047615
0.049781
0.956501
[ "s270272852", "s175435042" ]
u285681431
p02629
python
s902314586
s676366806
33
30
9,092
9,064
Accepted
Accepted
9.09
n = int(eval(input())) res = "" while n: n -= 1 res += chr(ord('a') + n % 26) n //= 26 # print(n) # print(res) print((res[::-1]))
N = int(eval(input())) ans = '' while N > 0: N -= 1 ans += chr(ord('a') + N % 26) N //= 26 print((ans[::-1]))
9
7
146
120
n = int(eval(input())) res = "" while n: n -= 1 res += chr(ord("a") + n % 26) n //= 26 # print(n) # print(res) print((res[::-1]))
N = int(eval(input())) ans = "" while N > 0: N -= 1 ans += chr(ord("a") + N % 26) N //= 26 print((ans[::-1]))
false
22.222222
[ "-n = int(eval(input()))", "-res = \"\"", "-while n:", "- n -= 1", "- res += chr(ord(\"a\") + n % 26)", "- n //= 26", "- # print(n)", "-# print(res)", "-print((res[::-1]))", "+N = int(eval(input()))", "+ans = \"\"", "+while N > 0:", "+ N -= 1", "+ ans += chr(ord(\"a\") + ...
false
0.108556
0.156435
0.693939
[ "s902314586", "s676366806" ]
u606045429
p03639
python
s744169850
s335046951
70
63
14,636
14,252
Accepted
Accepted
10
from collections import Counter N = int(eval(input())) A = [int(i) for i in input().split()] C = Counter(4 if a % 4 == 0 else 2 if a % 2 == 0 else 1 for a in A) if C[2] == 0: print(("Yes" if C[1] <= C[4] + 1 else "No")) else: print(("Yes" if C[1] <= C[4] else "No"))
N = int(eval(input())) A = [int(i) for i in input().split()] def solve(): f, t, o = 0, 0, 0 for a in A: if a % 4 == 0: f += 1 elif a % 2 == 0: t += 1 else: o += 1 if t == 0: return (o <= f + 1) else: return (o ...
10
22
276
377
from collections import Counter N = int(eval(input())) A = [int(i) for i in input().split()] C = Counter(4 if a % 4 == 0 else 2 if a % 2 == 0 else 1 for a in A) if C[2] == 0: print(("Yes" if C[1] <= C[4] + 1 else "No")) else: print(("Yes" if C[1] <= C[4] else "No"))
N = int(eval(input())) A = [int(i) for i in input().split()] def solve(): f, t, o = 0, 0, 0 for a in A: if a % 4 == 0: f += 1 elif a % 2 == 0: t += 1 else: o += 1 if t == 0: return o <= f + 1 else: return o <= f if solve(): ...
false
54.545455
[ "-from collections import Counter", "-", "-C = Counter(4 if a % 4 == 0 else 2 if a % 2 == 0 else 1 for a in A)", "-if C[2] == 0:", "- print((\"Yes\" if C[1] <= C[4] + 1 else \"No\"))", "+", "+", "+def solve():", "+ f, t, o = 0, 0, 0", "+ for a in A:", "+ if a % 4 == 0:", "+ ...
false
0.041605
0.032102
1.296046
[ "s744169850", "s335046951" ]
u426534722
p02274
python
s871653865
s582680235
1,420
1,270
27,480
27,476
Accepted
Accepted
10.56
INF = float("inf") cnt = 0 def merge(A, left, mid, right): global cnt L = A[left: mid] + [INF] R = A[mid: right] + [INF] i = j = 0 limit = mid - left for k in range(left, right): if L[i] <= R[j]: A[k] = L[i] i += 1 if i >= limit: ...
INF = float("inf") cnt = 0 def merge(A, left, mid, right): global cnt L = A[left: mid] + [INF] R = A[mid: right] + [INF] i = j = 0 limit = mid - left for k in range(left, right): if L[i] <= R[j]: A[k] = L[i] i += 1 else: cnt += lim...
30
27
752
657
INF = float("inf") cnt = 0 def merge(A, left, mid, right): global cnt L = A[left:mid] + [INF] R = A[mid:right] + [INF] i = j = 0 limit = mid - left for k in range(left, right): if L[i] <= R[j]: A[k] = L[i] i += 1 if i >= limit: A[k + ...
INF = float("inf") cnt = 0 def merge(A, left, mid, right): global cnt L = A[left:mid] + [INF] R = A[mid:right] + [INF] i = j = 0 limit = mid - left for k in range(left, right): if L[i] <= R[j]: A[k] = L[i] i += 1 else: cnt += limit - i ...
false
10
[ "- if i >= limit:", "- A[k + 1 : right] = R[j:-1]", "- break" ]
false
0.046347
0.11853
0.391017
[ "s871653865", "s582680235" ]
u624475441
p03645
python
s544666204
s653746230
1,607
199
4,724
46,660
Accepted
Accepted
87.62
N,M=list(map(int,input().split())) x=y=1 for _ in[0]*M: a,b=list(map(int,input().split())) if a==1: x|=1<<b if b==N: y|=1<<a print(('IM'*(x&y==1)+'POSSIBLE'))
n,m,*T=list(map(int,open(0).read().split())) *S,=list(zip(T[::2],T[1::2])) f=lambda e:set(s[e<2]for s in S if e in s) print(('IM'*(f(1)&f(n)==set())+'POSSIBLE'))
7
4
162
150
N, M = list(map(int, input().split())) x = y = 1 for _ in [0] * M: a, b = list(map(int, input().split())) if a == 1: x |= 1 << b if b == N: y |= 1 << a print(("IM" * (x & y == 1) + "POSSIBLE"))
n, m, *T = list(map(int, open(0).read().split())) (*S,) = list(zip(T[::2], T[1::2])) f = lambda e: set(s[e < 2] for s in S if e in s) print(("IM" * (f(1) & f(n) == set()) + "POSSIBLE"))
false
42.857143
[ "-N, M = list(map(int, input().split()))", "-x = y = 1", "-for _ in [0] * M:", "- a, b = list(map(int, input().split()))", "- if a == 1:", "- x |= 1 << b", "- if b == N:", "- y |= 1 << a", "-print((\"IM\" * (x & y == 1) + \"POSSIBLE\"))", "+n, m, *T = list(map(int, open(0).r...
false
0.04565
0.058118
0.785464
[ "s544666204", "s653746230" ]
u074220993
p03485
python
s739384468
s460409084
117
26
27,080
8,976
Accepted
Accepted
77.78
import numpy as np X = np.array([int(x) for x in input().split()]) ans = np.ceil(np.mean(X)) print((int(ans)))
a, b = list(map(int, input().split())) from math import ceil print((ceil((a+b)/2)))
4
3
111
77
import numpy as np X = np.array([int(x) for x in input().split()]) ans = np.ceil(np.mean(X)) print((int(ans)))
a, b = list(map(int, input().split())) from math import ceil print((ceil((a + b) / 2)))
false
25
[ "-import numpy as np", "+a, b = list(map(int, input().split()))", "+from math import ceil", "-X = np.array([int(x) for x in input().split()])", "-ans = np.ceil(np.mean(X))", "-print((int(ans)))", "+print((ceil((a + b) / 2)))" ]
false
0.206508
0.042951
4.808028
[ "s739384468", "s460409084" ]
u254871849
p03425
python
s952250186
s927735631
45
40
11,596
10,812
Accepted
Accepted
11.11
import sys from collections import Counter from itertools import combinations MARCH = set('MARCH') n = int(sys.stdin.readline().rstrip()) s = [x[0] for x in sys.stdin.read().split() if x[0] in MARCH] def main(): c = Counter(s) ways = 0 for comb in combinations('MARCH', 3): res = 1 ...
import sys from collections import Counter from itertools import combinations n, *s = [s[0] for s in sys.stdin.read().split()] def main(): c = Counter(s) res = 0 for i, j, k in combinations('MARCH', 3): res += c[i] * c[j] * c[k] print(res) if __name__ == '__main__': main()
23
15
481
319
import sys from collections import Counter from itertools import combinations MARCH = set("MARCH") n = int(sys.stdin.readline().rstrip()) s = [x[0] for x in sys.stdin.read().split() if x[0] in MARCH] def main(): c = Counter(s) ways = 0 for comb in combinations("MARCH", 3): res = 1 for i i...
import sys from collections import Counter from itertools import combinations n, *s = [s[0] for s in sys.stdin.read().split()] def main(): c = Counter(s) res = 0 for i, j, k in combinations("MARCH", 3): res += c[i] * c[j] * c[k] print(res) if __name__ == "__main__": main()
false
34.782609
[ "-MARCH = set(\"MARCH\")", "-n = int(sys.stdin.readline().rstrip())", "-s = [x[0] for x in sys.stdin.read().split() if x[0] in MARCH]", "+n, *s = [s[0] for s in sys.stdin.read().split()]", "- ways = 0", "- for comb in combinations(\"MARCH\", 3):", "- res = 1", "- for i in comb:", ...
false
0.03563
0.037392
0.952887
[ "s952250186", "s927735631" ]
u186838327
p03325
python
s295091096
s994486274
59
28
4,212
4,140
Accepted
Accepted
52.54
n = int(eval(input())) l = list(map(int, input().split())) ans = 0 flag = 1 i = 1 while flag: y = 2**i m = list([x%y for x in l]) if 0 in m: ans += m.count(0) i += 1 else: flag = 0 print(ans)
n = int(eval(input())) A = list(map(int, input().split())) ans = 0 for i in range(n): a = A[i] ans += format(a, 'b')[::-1].find('1') print(ans)
15
7
225
152
n = int(eval(input())) l = list(map(int, input().split())) ans = 0 flag = 1 i = 1 while flag: y = 2**i m = list([x % y for x in l]) if 0 in m: ans += m.count(0) i += 1 else: flag = 0 print(ans)
n = int(eval(input())) A = list(map(int, input().split())) ans = 0 for i in range(n): a = A[i] ans += format(a, "b")[::-1].find("1") print(ans)
false
53.333333
[ "-l = list(map(int, input().split()))", "+A = list(map(int, input().split()))", "-flag = 1", "-i = 1", "-while flag:", "- y = 2**i", "- m = list([x % y for x in l])", "- if 0 in m:", "- ans += m.count(0)", "- i += 1", "- else:", "- flag = 0", "+for i in range...
false
0.036034
0.034903
1.032399
[ "s295091096", "s994486274" ]
u968166680
p02586
python
s443876109
s773872488
2,081
829
168,936
198,404
Accepted
Accepted
60.16
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): R, C, K, *RCV = list(map(int, read().split())) item = dict() for r, c, v in zip(*[iter(RCV)] * 3): item[(r - 1, ...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): R, C, K, *RCV = list(map(int, read().split())) item = [[0] * C for _ in range(R)] for r, c, v in zip(*[iter(RCV)] * 3): ...
38
38
880
895
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): R, C, K, *RCV = list(map(int, read().split())) item = dict() for r, c, v in zip(*[iter(RCV)] * 3): item[(r - 1, c - 1)] = v dp...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): R, C, K, *RCV = list(map(int, read().split())) item = [[0] * C for _ in range(R)] for r, c, v in zip(*[iter(RCV)] * 3): item[r - 1...
false
0
[ "- item = dict()", "+ item = [[0] * C for _ in range(R)]", "- item[(r - 1, c - 1)] = v", "+ item[r - 1][c - 1] = v", "- if (i, j) in item:", "+ if item[i][j] > 0:", "- if v[k + 1] < v[k] + item[(i, j)]:", "- v[k + 1] =...
false
0.06737
0.074837
0.900219
[ "s443876109", "s773872488" ]
u518042385
p03074
python
s672438189
s907753164
86
79
6,108
4,120
Accepted
Accepted
8.14
n,k=list(map(int,input().split())) l=eval(input()) b=True if l[0]=="1": b=True else: b=False l1=[] c=1 l11=l[0] for i in range(1,len(l)): if l[i]!=l[i-1]: l1.append(c) c=1 else: c+=1 l1.append(c) if b: if k>=len(l1)//2: print(n) else: l2=[] c1=0 for i in ra...
n,k=list(map(int,input().split())) w=eval(input()) l=[] c=0 w="1"+w for i in range(1,1+n): if w[i]!=w[i-1]: l.append(c) c=1 else: c+=1 l.append(c) if k>=len(l)//2: print(n) else: if w[-1]=="0": l.append(0) s=l[0] for i in range(1,1+k): s+=l[2*i]+l[2*i-1] s1=s c1=...
72
27
1,456
446
n, k = list(map(int, input().split())) l = eval(input()) b = True if l[0] == "1": b = True else: b = False l1 = [] c = 1 l11 = l[0] for i in range(1, len(l)): if l[i] != l[i - 1]: l1.append(c) c = 1 else: c += 1 l1.append(c) if b: if k >= len(l1) // 2: print(n) el...
n, k = list(map(int, input().split())) w = eval(input()) l = [] c = 0 w = "1" + w for i in range(1, 1 + n): if w[i] != w[i - 1]: l.append(c) c = 1 else: c += 1 l.append(c) if k >= len(l) // 2: print(n) else: if w[-1] == "0": l.append(0) s = l[0] for i in range(1, ...
false
62.5
[ "-l = eval(input())", "-b = True", "-if l[0] == \"1\":", "- b = True", "-else:", "- b = False", "-l1 = []", "-c = 1", "-l11 = l[0]", "-for i in range(1, len(l)):", "- if l[i] != l[i - 1]:", "- l1.append(c)", "+w = eval(input())", "+l = []", "+c = 0", "+w = \"1\" + w", ...
false
0.043652
0.084004
0.519644
[ "s672438189", "s907753164" ]
u402629484
p02642
python
s366049708
s183194628
1,270
665
51,772
51,592
Accepted
Accepted
47.64
import sys sys.setrecursionlimit(1000000000) import math from math import gcd def lcm(a, b): return a * b // gcd(a, b) from itertools import count, permutations, chain from functools import lru_cache from collections import deque, defaultdict from pprint import pprint ii = lambda: int(eval(input())) mis = lam...
''' 方針 1 ~ 10^6(Aの最大値) までの全ての数について、割り切れる数をカウント カウント == 1 ならば、他の数では割り切れないので、そのような数の個数が答え 工夫 そのままの実装では、最悪ケース : 1 1 1 1 ... で、TLEする 対策として、 1. Aを昇順ソートする 2. A[i]がA[i-1]と同じならば、2倍以上の倍数についてはスキップ とする ''' import numpy as np def main(): N = int(eval(input())) A = lis...
110
31
2,545
764
import sys sys.setrecursionlimit(1000000000) import math from math import gcd def lcm(a, b): return a * b // gcd(a, b) from itertools import count, permutations, chain from functools import lru_cache from collections import deque, defaultdict from pprint import pprint ii = lambda: int(eval(input())) mis = lam...
""" 方針 1 ~ 10^6(Aの最大値) までの全ての数について、割り切れる数をカウント カウント == 1 ならば、他の数では割り切れないので、そのような数の個数が答え 工夫 そのままの実装では、最悪ケース : 1 1 1 1 ... で、TLEする 対策として、 1. Aを昇順ソートする 2. A[i]がA[i-1]と同じならば、2倍以上の倍数についてはスキップ とする """ import numpy as np def main(): N = int(eval(input())) A = list(map(int, input()...
false
71.818182
[ "-import sys", "-", "-sys.setrecursionlimit(1000000000)", "-import math", "-from math import gcd", "-", "-", "-def lcm(a, b):", "- return a * b // gcd(a, b)", "-", "-", "-from itertools import count, permutations, chain", "-from functools import lru_cache", "-from collections import deq...
false
0.223179
0.388334
0.574708
[ "s366049708", "s183194628" ]
u415905784
p03108
python
s174957239
s215350693
738
524
36,624
36,312
Accepted
Accepted
29
N, M = list(map(int, input().split())) I = [[i, 1] for i in range(N)] B = [0] * M for i in range(M): B[M - 1 - i] = [int(x) - 1 for x in input().split()] NC = [0] * M def n2(n): return n * (n - 1) // 2 NC[-1] = n2(N) def root(a): #print(a, I[a][0]) if I[a][0] == a: return a else: I[a][0]...
N, M = list(map(int, input().split())) Bridge= [[int(i) for i in input().split()] for _ in range(M)] Parent = [int(i) for i in range(N)] Rank = [1] * N def find(x): if x == Parent[x]: return x else: Parent[x] = y = find(Parent[x]) return y def unite(x, y, Total): rx, ry = fin...
35
34
732
786
N, M = list(map(int, input().split())) I = [[i, 1] for i in range(N)] B = [0] * M for i in range(M): B[M - 1 - i] = [int(x) - 1 for x in input().split()] NC = [0] * M def n2(n): return n * (n - 1) // 2 NC[-1] = n2(N) def root(a): # print(a, I[a][0]) if I[a][0] == a: return a else: ...
N, M = list(map(int, input().split())) Bridge = [[int(i) for i in input().split()] for _ in range(M)] Parent = [int(i) for i in range(N)] Rank = [1] * N def find(x): if x == Parent[x]: return x else: Parent[x] = y = find(Parent[x]) return y def unite(x, y, Total): rx, ry = find(x...
false
2.857143
[ "-I = [[i, 1] for i in range(N)]", "-B = [0] * M", "-for i in range(M):", "- B[M - 1 - i] = [int(x) - 1 for x in input().split()]", "-NC = [0] * M", "+Bridge = [[int(i) for i in input().split()] for _ in range(M)]", "+Parent = [int(i) for i in range(N)]", "+Rank = [1] * N", "-def n2(n):", "- ...
false
0.041717
0.041551
1.004
[ "s174957239", "s215350693" ]
u062147869
p03329
python
s459930644
s713214916
649
291
3,828
3,060
Accepted
Accepted
55.16
N = int(eval(input())) A=[] A.append(1) for i in range(1,7): A.append(6**i) for i in range(1,6): A.append(9**i) A.sort() dp=[10*5+5]*(N+1) dp[0]=0 for i in range(1,N+1): for s in range(len(A)): if i-A[s]>=0: dp[i]=min(dp[i-A[s]]+1,dp[i]) print((dp[N]))
N = int(eval(input())) def shin(n,q): s = n a = 0 while(s>0): t=s%q a +=t s=(s-t)//q return a ans = N for i in range(N+1): c=shin(i,6)+shin(N-i,9) ans = min(ans,c) print(ans)
15
14
291
229
N = int(eval(input())) A = [] A.append(1) for i in range(1, 7): A.append(6**i) for i in range(1, 6): A.append(9**i) A.sort() dp = [10 * 5 + 5] * (N + 1) dp[0] = 0 for i in range(1, N + 1): for s in range(len(A)): if i - A[s] >= 0: dp[i] = min(dp[i - A[s]] + 1, dp[i]) print((dp[N]))
N = int(eval(input())) def shin(n, q): s = n a = 0 while s > 0: t = s % q a += t s = (s - t) // q return a ans = N for i in range(N + 1): c = shin(i, 6) + shin(N - i, 9) ans = min(ans, c) print(ans)
false
6.666667
[ "-A = []", "-A.append(1)", "-for i in range(1, 7):", "- A.append(6**i)", "-for i in range(1, 6):", "- A.append(9**i)", "-A.sort()", "-dp = [10 * 5 + 5] * (N + 1)", "-dp[0] = 0", "-for i in range(1, N + 1):", "- for s in range(len(A)):", "- if i - A[s] >= 0:", "- dp...
false
0.692348
0.09399
7.366186
[ "s459930644", "s713214916" ]
u150984829
p02269
python
s340748353
s460945220
5,060
4,550
38,880
40,932
Accepted
Accepted
10.08
d=set() for _ in[0]*int(eval(input())): c,g=input().split() if'i'==c[0]:d|=set([g]) else:print((['no','yes'][g in d]))
d={} for _ in[0]*int(eval(input())): c,g=input().split() if'i'==c[0]:d[g]=0 else:print((['no','yes'][g in d]))
5
5
118
110
d = set() for _ in [0] * int(eval(input())): c, g = input().split() if "i" == c[0]: d |= set([g]) else: print((["no", "yes"][g in d]))
d = {} for _ in [0] * int(eval(input())): c, g = input().split() if "i" == c[0]: d[g] = 0 else: print((["no", "yes"][g in d]))
false
0
[ "-d = set()", "+d = {}", "- d |= set([g])", "+ d[g] = 0" ]
false
0.036962
0.03663
1.009067
[ "s340748353", "s460945220" ]
u323680411
p03986
python
s619869480
s799938801
99
38
3,572
3,500
Accepted
Accepted
61.62
import sys def main() -> None: x = next_str() s_cnt = 0 ans = 0 for v in x: if v == 'S': s_cnt += 1 if v == 'T': if s_cnt == 0: ans += 1 else: s_cnt -= 1 ans += s_cnt print(ans) def nex...
import sys def main() -> None: x = eval(input()) s_cnt = 0 ans = 0 for v in x: if v == 'S': s_cnt += 1 if v == 'T': if s_cnt == 0: ans += 1 else: s_cnt -= 1 ans += s_cnt print(ans) def ...
34
34
569
566
import sys def main() -> None: x = next_str() s_cnt = 0 ans = 0 for v in x: if v == "S": s_cnt += 1 if v == "T": if s_cnt == 0: ans += 1 else: s_cnt -= 1 ans += s_cnt print(ans) def next_str() -> str: res...
import sys def main() -> None: x = eval(input()) s_cnt = 0 ans = 0 for v in x: if v == "S": s_cnt += 1 if v == "T": if s_cnt == 0: ans += 1 else: s_cnt -= 1 ans += s_cnt print(ans) def next_str() -> str: ...
false
0
[ "- x = next_str()", "+ x = eval(input())" ]
false
0.041382
0.041264
1.002857
[ "s619869480", "s799938801" ]
u353895424
p03324
python
s221847069
s535240088
174
17
38,432
2,940
Accepted
Accepted
90.23
d,n=list(map(int, input().split())) if n == 100: print((101 * n**d)) else: print((100**d * n))
d, n = list(map(int, input().split())) if n == 100: print((101*100**d)) else: print((100**d*n))
5
5
96
98
d, n = list(map(int, input().split())) if n == 100: print((101 * n**d)) else: print((100**d * n))
d, n = list(map(int, input().split())) if n == 100: print((101 * 100**d)) else: print((100**d * n))
false
0
[ "- print((101 * n**d))", "+ print((101 * 100**d))" ]
false
0.101452
0.036554
2.77542
[ "s221847069", "s535240088" ]
u620868411
p03617
python
s087687721
s135707189
40
17
3,064
2,940
Accepted
Accepted
57.5
# -*- coding: utf-8 -*- q,h,s,d = list(map(int,input().split())) n = int(eval(input())) q = 4*q h = 2*h if n%2==0: t = q*n t = min(t, h*n) t = min(t, s*n) t = min(t, d*n//2) else: t = q*n t = min(t, h*n) t = min(t, s*n) t = min(t, (n//2)*d + min(q,h,s)) print(t)
q,h,s,d = list(map(int, input().split())) n = int(eval(input())) q = 4*q h = 2*h x = min(q,h,s) print(((n//2)*min(2*x,d)+(n%2)*x))
18
8
302
125
# -*- coding: utf-8 -*- q, h, s, d = list(map(int, input().split())) n = int(eval(input())) q = 4 * q h = 2 * h if n % 2 == 0: t = q * n t = min(t, h * n) t = min(t, s * n) t = min(t, d * n // 2) else: t = q * n t = min(t, h * n) t = min(t, s * n) t = min(t, (n // 2) * d + min(q, h, s)) ...
q, h, s, d = list(map(int, input().split())) n = int(eval(input())) q = 4 * q h = 2 * h x = min(q, h, s) print(((n // 2) * min(2 * x, d) + (n % 2) * x))
false
55.555556
[ "-# -*- coding: utf-8 -*-", "-if n % 2 == 0:", "- t = q * n", "- t = min(t, h * n)", "- t = min(t, s * n)", "- t = min(t, d * n // 2)", "-else:", "- t = q * n", "- t = min(t, h * n)", "- t = min(t, s * n)", "- t = min(t, (n // 2) * d + min(q, h, s))", "-print(t)", "+x...
false
0.034855
0.035098
0.99307
[ "s087687721", "s135707189" ]
u714378447
p03805
python
s118302482
s576571199
60
47
3,064
3,064
Accepted
Accepted
21.67
import sys sys.setrecursionlimit(6000) n_node, n_path = [int(x) for x in input().split()] A = [[0]*2 for x in range(n_path)] for i in range(n_path): A[i][0], A[i][1] = [int(x) for x in input().split()] def serch(A, cur_node, old, n_node): ans = 0 if len(old) == (n_node-1): return 1 ...
N,M=list(map(int,input().split())) his=[False]*N A=[[0]*2 for i in range(M)] for i in range(M): a,b=list(map(int,input().split())) A[i][0],A[i][1] =a-1,b-1 def search(now,his,A): if all(his): return 1 else: cnt=0 for a in A: if now in a: ...
38
28
802
567
import sys sys.setrecursionlimit(6000) n_node, n_path = [int(x) for x in input().split()] A = [[0] * 2 for x in range(n_path)] for i in range(n_path): A[i][0], A[i][1] = [int(x) for x in input().split()] def serch(A, cur_node, old, n_node): ans = 0 if len(old) == (n_node - 1): return 1 for i ...
N, M = list(map(int, input().split())) his = [False] * N A = [[0] * 2 for i in range(M)] for i in range(M): a, b = list(map(int, input().split())) A[i][0], A[i][1] = a - 1, b - 1 def search(now, his, A): if all(his): return 1 else: cnt = 0 for a in A: if now in a: ...
false
26.315789
[ "-import sys", "-", "-sys.setrecursionlimit(6000)", "-n_node, n_path = [int(x) for x in input().split()]", "-A = [[0] * 2 for x in range(n_path)]", "-for i in range(n_path):", "- A[i][0], A[i][1] = [int(x) for x in input().split()]", "+N, M = list(map(int, input().split()))", "+his = [False] * N"...
false
0.040924
0.039477
1.036656
[ "s118302482", "s576571199" ]
u387774811
p02714
python
s575564130
s695777396
357
173
69,200
68,852
Accepted
Accepted
51.54
N=int(eval(input())) A=eval(input()) c=0 B1B=0 B1R=0 B1G=0 if A[0]=="B": B1B+=1 elif A[0]=="R": B1R+=1 else: B1G+=1 for i in range(N-2): B2=A[i+1] for k in range(N-i-2): B3=A[i+2+k] if (B2=="B" and B3=="R")or (B2=="R" and B3=="B"): c+=B1G if (i+2+k)<=(i+1)*2: if A[(i+1)*2-(i+2+k)]=...
N=int(eval(input())) S=eval(input()) R=0 G=1 B=2 chk=[0]*N lst=[[0 for e in range(3)] for f in range(N)] if S[N-1]=="R": chk[N-1]=0 lst[N-1][0]+=1 elif S[N-1]=="G": chk[N-1]=1 lst[N-1][1]+=1 else: chk[N-1]=2 lst[N-1][2]+=1 if N>=2: for i in range(1,N): lst[N-1-i][0]+=lst[N-i][0] lst[N-1-i]...
38
42
669
750
N = int(eval(input())) A = eval(input()) c = 0 B1B = 0 B1R = 0 B1G = 0 if A[0] == "B": B1B += 1 elif A[0] == "R": B1R += 1 else: B1G += 1 for i in range(N - 2): B2 = A[i + 1] for k in range(N - i - 2): B3 = A[i + 2 + k] if (B2 == "B" and B3 == "R") or (B2 == "R" and B3 == "B"): ...
N = int(eval(input())) S = eval(input()) R = 0 G = 1 B = 2 chk = [0] * N lst = [[0 for e in range(3)] for f in range(N)] if S[N - 1] == "R": chk[N - 1] = 0 lst[N - 1][0] += 1 elif S[N - 1] == "G": chk[N - 1] = 1 lst[N - 1][1] += 1 else: chk[N - 1] = 2 lst[N - 1][2] += 1 if N >= 2: for i in r...
false
9.52381
[ "-A = eval(input())", "-c = 0", "-B1B = 0", "-B1R = 0", "-B1G = 0", "-if A[0] == \"B\":", "- B1B += 1", "-elif A[0] == \"R\":", "- B1R += 1", "+S = eval(input())", "+R = 0", "+G = 1", "+B = 2", "+chk = [0] * N", "+lst = [[0 for e in range(3)] for f in range(N)]", "+if S[N - 1] ==...
false
0.035649
0.037696
0.945697
[ "s575564130", "s695777396" ]
u678167152
p02973
python
s916429637
s172261721
230
174
11,032
13,724
Accepted
Accepted
24.35
N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort def solve(N,A): ans = 0 lis = [] for i in range(N): ind = bisect_right(lis,-A[i]) if ind == len(lis): lis.append(...
from bisect import * def solve(): ans = 0 N = int(eval(input())) A = [-int(eval(input())) for _ in range(N)] lis = [A[0]] for i in range(1,N): if A[i]>=lis[-1]: lis.append(A[i]) else: ind = bisect_right(lis,A[i]) lis[ind] = A[i] ans...
17
15
414
351
N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort def solve(N, A): ans = 0 lis = [] for i in range(N): ind = bisect_right(lis, -A[i]) if ind == len(lis): lis.append(-A[i]) ...
from bisect import * def solve(): ans = 0 N = int(eval(input())) A = [-int(eval(input())) for _ in range(N)] lis = [A[0]] for i in range(1, N): if A[i] >= lis[-1]: lis.append(A[i]) else: ind = bisect_right(lis, A[i]) lis[ind] = A[i] ans = len...
false
11.764706
[ "-N = int(eval(input()))", "-A = [int(eval(input())) for _ in range(N)]", "-from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort", "+from bisect import *", "-def solve(N, A):", "+def solve():", "- lis = []", "- for i in range(N):", "- ind = bisect_righ...
false
0.037841
0.07797
0.485319
[ "s916429637", "s172261721" ]
u844789719
p03212
python
s802710034
s224214989
1,065
869
4,028
3,320
Accepted
Accepted
18.4
N = int(eval(input())) array = [] for i in range(10**9): res = '' digit = 0 while i: res = '0357'[i % 4] + res i //= 4 if '3' in res and '5' in res and '7' in res and '0' not in res: res = int(res) if res > 10 ** 9: break array += [res] ar...
N = int(eval(input())) def resol_a(x, a): if x < 10: return int(x >= a) d = 0 while x > 10**(d+1): d += 1 f = x // 10 ** d r = x % 10 ** d c = resol_a(r, a) b = resol_a(10 ** d - 1, a) bb = resol_a(10 ** (d - 1), a) if f > a: return b + 1 ...
18
70
414
2,382
N = int(eval(input())) array = [] for i in range(10**9): res = "" digit = 0 while i: res = "0357"[i % 4] + res i //= 4 if "3" in res and "5" in res and "7" in res and "0" not in res: res = int(res) if res > 10**9: break array += [res] array += [10**9] ...
N = int(eval(input())) def resol_a(x, a): if x < 10: return int(x >= a) d = 0 while x > 10 ** (d + 1): d += 1 f = x // 10**d r = x % 10**d c = resol_a(r, a) b = resol_a(10**d - 1, a) bb = resol_a(10 ** (d - 1), a) if f > a: return b + 1 elif f == a: ...
false
74.285714
[ "-array = []", "-for i in range(10**9):", "- res = \"\"", "- digit = 0", "- while i:", "- res = \"0357\"[i % 4] + res", "- i //= 4", "- if \"3\" in res and \"5\" in res and \"7\" in res and \"0\" not in res:", "- res = int(res)", "- if res > 10**9:", "- ...
false
2.175743
0.580212
3.749912
[ "s802710034", "s224214989" ]
u588341295
p03061
python
s926722438
s044571983
1,797
708
117,028
89,580
Accepted
Accepted
60.6
# -*- coding: utf-8 -*- import sys if sys.version_info.minor >= 5: from math import gcd else: from fractions import gcd def input(): return sys.stdin.readline().strip() def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return in...
# -*- coding: utf-8 -*- import sys if sys.version_info.minor >= 5: from math import gcd else: from fractions import gcd def input(): return sys.stdin.readline().strip() def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return in...
95
87
2,451
2,120
# -*- coding: utf-8 -*- import sys if sys.version_info.minor >= 5: from math import gcd else: from fractions import gcd def input(): return sys.stdin.readline().strip() def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) de...
# -*- coding: utf-8 -*- import sys if sys.version_info.minor >= 5: from math import gcd else: from fractions import gcd def input(): return sys.stdin.readline().strip() def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) de...
false
8.421053
[ "- return self._get_val(a, b, 1, 0, self.n2)", "-", "- def _get_val(self, a, b, k, l, r):", "- \"\"\"", "- [a, b)の値を得る内部関数", "- :param k: 現在調べている区間のtree内index", "- :param l, r: kが表す区間の左右端index [l, r)", "- :return: kが表す区間と[a, b)の共通区間内での最小値。共通区間を持たない場合は初期値", ...
false
0.041982
0.037177
1.129252
[ "s926722438", "s044571983" ]
u571281863
p02678
python
s473499423
s582174421
413
324
56,848
56,568
Accepted
Accepted
21.55
from collections import deque N,M,*AB=map(int,open(0).read().split()) to=[[] for _ in range(N+1)] for a,b in zip(*[iter(AB)]*2): to[a].append(b) to[b].append(a) q=deque([1]) r=[None]*(N+1) while q: x=q.popleft() for i in to[x]: if r[i] is None: q.append(i) r[i]=x print("Yes",*r[2:]...
from collections import deque def main(): N,M,*AB=map(int,open(0).read().split()) to=[[] for _ in range(N+1)] for a,b in zip(*[iter(AB)]*2): to[a].append(b) to[b].append(a) q=deque([1]) r=[None]*(N+1) while q: x=q.popleft() for i in to[x]: if r[i] is None: q.append(i) r[i]=x pri...
15
18
330
381
from collections import deque N, M, *AB = map(int, open(0).read().split()) to = [[] for _ in range(N + 1)] for a, b in zip(*[iter(AB)] * 2): to[a].append(b) to[b].append(a) q = deque([1]) r = [None] * (N + 1) while q: x = q.popleft() for i in to[x]: if r[i] is None: q.append(i) ...
from collections import deque def main(): N, M, *AB = map(int, open(0).read().split()) to = [[] for _ in range(N + 1)] for a, b in zip(*[iter(AB)] * 2): to[a].append(b) to[b].append(a) q = deque([1]) r = [None] * (N + 1) while q: x = q.popleft() for i in to[x]: ...
false
16.666667
[ "-N, M, *AB = map(int, open(0).read().split())", "-to = [[] for _ in range(N + 1)]", "-for a, b in zip(*[iter(AB)] * 2):", "- to[a].append(b)", "- to[b].append(a)", "-q = deque([1])", "-r = [None] * (N + 1)", "-while q:", "- x = q.popleft()", "- for i in to[x]:", "- if r[i] is...
false
0.039152
0.042186
0.928062
[ "s473499423", "s582174421" ]
u386819480
p03031
python
s858782961
s423964508
34
31
3,316
3,064
Accepted
Accepted
8.82
#!/usr/bin/env python3 MOD = 2 # type: int # Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): # Failed to predict input format N,M = list(map(int,input().split())) from...
#!/usr/bin/env python3 MOD = 2 # type: int def main(): N, M = list(map(int, input().split())) k = [] s = [] for i in range(M): l = input().split() k.append(l[0]) s.append(list(map(int, l[1:]))) p = list(map(int, input().split())) ans = 0 f...
38
40
919
782
#!/usr/bin/env python3 MOD = 2 # type: int # Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): # Failed to predict input format N, M = list(map(int, input().split())) from collectio...
#!/usr/bin/env python3 MOD = 2 # type: int def main(): N, M = list(map(int, input().split())) k = [] s = [] for i in range(M): l = input().split() k.append(l[0]) s.append(list(map(int, l[1:]))) p = list(map(int, input().split())) ans = 0 for i in range(1 << N): ...
false
5
[ "-# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)", "+", "+", "- # Failed to predict input format", "- from collections import defaultdict", "-", "- d = defaultdict()", "+ ...
false
0.056481
0.039017
1.447594
[ "s858782961", "s423964508" ]
u600065151
p02268
python
s366216704
s102498041
40
30
20,588
20,588
Accepted
Accepted
25
def binarySearch(): n = int(eval(input())) S = set(input().split()) q = int(eval(input())) T = set(input().split()) print((len(S.intersection(T)))) binarySearch()
def binarySearch(): n = int(eval(input())) S = set(input().split()) q = int(eval(input())) T = set(input().split()) print((len(S & T))) binarySearch()
9
9
182
170
def binarySearch(): n = int(eval(input())) S = set(input().split()) q = int(eval(input())) T = set(input().split()) print((len(S.intersection(T)))) binarySearch()
def binarySearch(): n = int(eval(input())) S = set(input().split()) q = int(eval(input())) T = set(input().split()) print((len(S & T))) binarySearch()
false
0
[ "- print((len(S.intersection(T))))", "+ print((len(S & T)))" ]
false
0.042638
0.045653
0.933967
[ "s366216704", "s102498041" ]
u011062360
p02900
python
s742436518
s483327420
286
150
5,276
9,132
Accepted
Accepted
47.55
import itertools a, b = list(map(int, input().split())) #約数 def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) # divisors.sort() return divisors impo...
def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) return a a, b = list(map(int, input().s...
34
21
649
435
import itertools a, b = list(map(int, input().split())) # 約数 def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) # divisors.sort() return divisors import math ...
def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) return a a, b = list(map(int, input().split())) list_A...
false
38.235294
[ "-import itertools", "+def prime_factorize(n):", "+ a = []", "+ while n % 2 == 0:", "+ a.append(2)", "+ n //= 2", "+ f = 3", "+ while f * f <= n:", "+ if n % f == 0:", "+ a.append(f)", "+ n //= f", "+ else:", "+ f += 2"...
false
0.037797
0.038432
0.983488
[ "s742436518", "s483327420" ]
u947883560
p02975
python
s233578189
s080427206
578
68
15,580
17,392
Accepted
Accepted
88.24
#!/usr/bin/env python3 import sys from bisect import bisect_left from collections import Counter INF = float("inf") KETA_MAX = 10 def yes(): print("Yes") # type: str def no(): print("No") # type: str def solve(N: int, a: "List[int]"): keta = [Counter() for _ in range(KETA_MAX)] ...
#!/usr/bin/env python3 import sys from bisect import bisect_left from collections import Counter INF = float("inf") def yes(): print("Yes") # type: str def no(): print("No") # type: str def solve(N: int, a: "List[int]"): cnt = Counter(a) v = list(cnt.values()) b = list(cnt....
86
89
2,037
2,173
#!/usr/bin/env python3 import sys from bisect import bisect_left from collections import Counter INF = float("inf") KETA_MAX = 10 def yes(): print("Yes") # type: str def no(): print("No") # type: str def solve(N: int, a: "List[int]"): keta = [Counter() for _ in range(KETA_MAX)] for i in range(N...
#!/usr/bin/env python3 import sys from bisect import bisect_left from collections import Counter INF = float("inf") def yes(): print("Yes") # type: str def no(): print("No") # type: str def solve(N: int, a: "List[int]"): cnt = Counter(a) v = list(cnt.values()) b = list(cnt.keys()) if le...
false
3.370787
[ "-KETA_MAX = 10", "- keta = [Counter() for _ in range(KETA_MAX)]", "- for i in range(N):", "- x = a[i]", "- for j in range(KETA_MAX):", "- keta[j][x & 1] += 1", "- x >>= 1", "- for cnt in keta:", "- if cnt[1] == 0:", "- continue", "-...
false
0.092581
0.04279
2.163635
[ "s233578189", "s080427206" ]
u519968172
p03592
python
s234104453
s269734162
86
29
65,896
9,060
Accepted
Accepted
66.28
n,m,k=list(map(int,input().split())) ans="No" for i in range(n//2+1): for j in range(m): o=i*j+(m-j)*(n-i) x=n*m-o if o==k or x==k: ans="Yes" print(ans)
n,m,k=list(map(int,input().split())) ans="No" for i in range(n+1): if (2*i-n)==0: if k==m*n//2: ans="Yes" else: if (k-n*m+m*i)%(2*i-n)==0 and 0<=(k-n*m+m*i)//(2*i-n)<=m: ans="Yes" print(ans)
9
10
174
217
n, m, k = list(map(int, input().split())) ans = "No" for i in range(n // 2 + 1): for j in range(m): o = i * j + (m - j) * (n - i) x = n * m - o if o == k or x == k: ans = "Yes" print(ans)
n, m, k = list(map(int, input().split())) ans = "No" for i in range(n + 1): if (2 * i - n) == 0: if k == m * n // 2: ans = "Yes" else: if (k - n * m + m * i) % (2 * i - n) == 0 and 0 <= (k - n * m + m * i) // ( 2 * i - n ) <= m: ans = "Yes" print(ans)
false
10
[ "-for i in range(n // 2 + 1):", "- for j in range(m):", "- o = i * j + (m - j) * (n - i)", "- x = n * m - o", "- if o == k or x == k:", "+for i in range(n + 1):", "+ if (2 * i - n) == 0:", "+ if k == m * n // 2:", "+ ans = \"Yes\"", "+ else:", "+ ...
false
0.035465
0.069061
0.513529
[ "s234104453", "s269734162" ]
u023127434
p03493
python
s728300616
s816154823
28
24
9,016
8,916
Accepted
Accepted
14.29
n = eval(input()) print((n.count("1")))
s = eval(input()) print((s.count("1")))
2
2
32
32
n = eval(input()) print((n.count("1")))
s = eval(input()) print((s.count("1")))
false
0
[ "-n = eval(input())", "-print((n.count(\"1\")))", "+s = eval(input())", "+print((s.count(\"1\")))" ]
false
0.047984
0.048202
0.995486
[ "s728300616", "s816154823" ]
u347640436
p03599
python
s998254048
s535390246
531
150
3,064
3,188
Accepted
Accepted
71.75
A, B, C, D, E, F = list(map(int, input().split())) w = set() for i in range(F // (100 * A) + 1): for j in range(F // (100 * B) + 1): a = (A * i + B * j) * 100 if a < F: w.add(a) w.remove(0) best_concentration = -1 best_a = -1 best_b = -1 for a in w: for i in range((F ...
A, B, C, D, E, F = list(map(int, input().split())) w = set() for i in range(F // (100 * A) + 1): for j in range(F // (100 * B) + 1): a = (A * i + B * j) * 100 if a < F: w.add(a) w.remove(0) s = set() for i in range(F // C + 1): for j in range(F // D + 1): b = C...
27
34
756
790
A, B, C, D, E, F = list(map(int, input().split())) w = set() for i in range(F // (100 * A) + 1): for j in range(F // (100 * B) + 1): a = (A * i + B * j) * 100 if a < F: w.add(a) w.remove(0) best_concentration = -1 best_a = -1 best_b = -1 for a in w: for i in range((F - a) // C + 1): ...
A, B, C, D, E, F = list(map(int, input().split())) w = set() for i in range(F // (100 * A) + 1): for j in range(F // (100 * B) + 1): a = (A * i + B * j) * 100 if a < F: w.add(a) w.remove(0) s = set() for i in range(F // C + 1): for j in range(F // D + 1): b = C * i + D * j ...
false
20.588235
[ "+s = set()", "+for i in range(F // C + 1):", "+ for j in range(F // D + 1):", "+ b = C * i + D * j", "+ if b < F:", "+ s.add(b)", "+s = list(s)", "+s.sort()", "- for i in range((F - a) // C + 1):", "- for j in range((F - a) // D + 1):", "- b = C ...
false
0.00731
0.078451
0.093179
[ "s998254048", "s535390246" ]
u561992253
p02838
python
s626989394
s620151092
532
462
122,936
122,808
Accepted
Accepted
13.16
words = lambda t : list(map(t, input().split())) n = int(eval(input())) xs = words(int) ys = [0]*60 for x in xs: for i in range(60): if x == 0: continue ys[i] += x & 1 x = x >> 1 ans = 0 for i,yi in enumerate(ys): ans += 2**(i) * yi * (n-yi) ans %= 10**...
from functools import reduce words = lambda t : list(map(t, input().split())) n = int(eval(input())) xs = words(int) def func(y, x): for i in range(60): if x == 0: continue y[i] += x & 1 x = x >> 1 return y ys = reduce(func, xs, [0]*60) ans = 0 for i,yi i...
18
21
332
398
words = lambda t: list(map(t, input().split())) n = int(eval(input())) xs = words(int) ys = [0] * 60 for x in xs: for i in range(60): if x == 0: continue ys[i] += x & 1 x = x >> 1 ans = 0 for i, yi in enumerate(ys): ans += 2 ** (i) * yi * (n - yi) ans %= 10**9 + 7 print(a...
from functools import reduce words = lambda t: list(map(t, input().split())) n = int(eval(input())) xs = words(int) def func(y, x): for i in range(60): if x == 0: continue y[i] += x & 1 x = x >> 1 return y ys = reduce(func, xs, [0] * 60) ans = 0 for i, yi in enumerate(ys...
false
14.285714
[ "+from functools import reduce", "+", "-ys = [0] * 60", "-for x in xs:", "+", "+", "+def func(y, x):", "- ys[i] += x & 1", "+ y[i] += x & 1", "+ return y", "+", "+", "+ys = reduce(func, xs, [0] * 60)" ]
false
0.039871
0.035891
1.110874
[ "s626989394", "s620151092" ]
u585482323
p03476
python
s526883595
s519054115
442
398
52,912
53,792
Accepted
Accepted
9.95
#!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 def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS():return list(map(list, ...
#!usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop from itertools import permutations import sys import math import bisect 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...
81
53
1,498
1,245
#!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 def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS(): return list(m...
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS(): return [list(...
false
34.567901
[ "-from collections import defaultdict", "-from collections import deque", "+from collections import defaultdict, deque", "+from itertools import permutations", "-import random", "- return list(map(int, sys.stdin.readline().split()))", "+ return [int(x) for x in sys.stdin.readline().split()]", "-...
false
0.999865
0.172835
5.785098
[ "s526883595", "s519054115" ]
u074220993
p03608
python
s640495665
s745262356
1,990
411
9,924
46,252
Accepted
Accepted
79.35
N, M, K = (int(x) for x in input().split()) R = [int(x)-1 for x in input().split()] dist = [[10e8 for _ in range(N)] for _ in range(N)] for i in range(N): dist[i][i] = 0 for _ in range(M): a, b, c = (int(x) for x in input().split()) dist[a-1][b-1] = dist[b-1][a-1] = c del a, b, c, K for k in range(...
from itertools import permutations import numpy as np from scipy.sparse.csgraph import dijkstra with open(0) as f: N, M, R = list(map(int, f.readline().split())) r = list(map(int, f.readline().split())) path = [tuple(map(int, line.split())) for line in f.readlines()] graph = np.full((N,N), np.inf...
24
23
668
631
N, M, K = (int(x) for x in input().split()) R = [int(x) - 1 for x in input().split()] dist = [[10e8 for _ in range(N)] for _ in range(N)] for i in range(N): dist[i][i] = 0 for _ in range(M): a, b, c = (int(x) for x in input().split()) dist[a - 1][b - 1] = dist[b - 1][a - 1] = c del a, b, c, K for k in range...
from itertools import permutations import numpy as np from scipy.sparse.csgraph import dijkstra with open(0) as f: N, M, R = list(map(int, f.readline().split())) r = list(map(int, f.readline().split())) path = [tuple(map(int, line.split())) for line in f.readlines()] graph = np.full((N, N), np.inf) for a, ...
false
4.166667
[ "-N, M, K = (int(x) for x in input().split())", "-R = [int(x) - 1 for x in input().split()]", "-dist = [[10e8 for _ in range(N)] for _ in range(N)]", "-for i in range(N):", "- dist[i][i] = 0", "-for _ in range(M):", "- a, b, c = (int(x) for x in input().split())", "- dist[a - 1][b - 1] = dist...
false
0.047941
0.29193
0.164222
[ "s640495665", "s745262356" ]
u945181840
p02762
python
s520695822
s158921961
1,302
956
58,372
58,372
Accepted
Accepted
26.57
import sys read = sys.stdin.read readline = sys.stdin.readline class UnionFind(): # 作りたい要素数nで初期化 # 使用するインスタンス変数の初期化 def __init__(self, n): self.n = n # root[x]<0ならそのノードが根かつその値が木の要素数 # rootノードでその木の要素数を記録する self.root = [-1] * (n + 1) # 木をくっつける時にアンバランスにな...
import sys read = sys.stdin.read readline = sys.stdin.readline class UnionFind(): # 作りたい要素数nで初期化 # 使用するインスタンス変数の初期化 def __init__(self, n): self.n = n # root[x]<0ならそのノードが根かつその値が木の要素数 # rootノードでその木の要素数を記録する self.root = [-1] * (n + 1) # 木をくっつける時にアンバランスにな...
82
80
2,053
2,000
import sys read = sys.stdin.read readline = sys.stdin.readline class UnionFind: # 作りたい要素数nで初期化 # 使用するインスタンス変数の初期化 def __init__(self, n): self.n = n # root[x]<0ならそのノードが根かつその値が木の要素数 # rootノードでその木の要素数を記録する self.root = [-1] * (n + 1) # 木をくっつける時にアンバランスにならないように調整する ...
import sys read = sys.stdin.read readline = sys.stdin.readline class UnionFind: # 作りたい要素数nで初期化 # 使用するインスタンス変数の初期化 def __init__(self, n): self.n = n # root[x]<0ならそのノードが根かつその値が木の要素数 # rootノードでその木の要素数を記録する self.root = [-1] * (n + 1) # 木をくっつける時にアンバランスにならないように調整する ...
false
2.439024
[ "- for j in friend[i]:", "- if F.isSameGroup(i, j):", "- cnt -= 1", "+ cnt -= len(friend[i])" ]
false
0.084252
0.066353
1.269745
[ "s520695822", "s158921961" ]
u819048695
p02883
python
s406762227
s363509551
758
532
120,140
119,500
Accepted
Accepted
29.82
# E n,k=list(map(int,input().split())) a=list(map(int,input().split())) a.sort() f=list(map(int,input().split())) f.sort(reverse=True) x=1 i=0 while i>=0: cnt=0 for j in range(n): cnt+=max(0,a[j]-x//f[j]) if cnt>k: i+=1 x=2**i else: break while i>0: ...
def f(x): cnt=0 for i in range(N): num=x//F[i] if A[i]>num: cnt+=A[i]-num return cnt N,K=list(map(int,input().split())) A=list(map(int,input().split())) F=list(map(int,input().split())) A.sort() F.sort(reverse=True) low=0 high=10**12+1 while high-low>0: m...
41
29
696
485
# E n, k = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() f = list(map(int, input().split())) f.sort(reverse=True) x = 1 i = 0 while i >= 0: cnt = 0 for j in range(n): cnt += max(0, a[j] - x // f[j]) if cnt > k: i += 1 x = 2**i else: break wh...
def f(x): cnt = 0 for i in range(N): num = x // F[i] if A[i] > num: cnt += A[i] - num return cnt N, K = list(map(int, input().split())) A = list(map(int, input().split())) F = list(map(int, input().split())) A.sort() F.sort(reverse=True) low = 0 high = 10**12 + 1 while high - l...
false
29.268293
[ "-# E", "-n, k = list(map(int, input().split()))", "-a = list(map(int, input().split()))", "-a.sort()", "-f = list(map(int, input().split()))", "-f.sort(reverse=True)", "-x = 1", "-i = 0", "-while i >= 0:", "+def f(x):", "- for j in range(n):", "- cnt += max(0, a[j] - x // f[j])", ...
false
0.05855
0.135683
0.431517
[ "s406762227", "s363509551" ]
u490642448
p03038
python
s463047591
s843421068
936
642
76,184
68,120
Accepted
Accepted
31.41
n,m = list(map(int, input().split())) a = list(map(int, input().split())) cb = [list(map(int,input().split()))[::-1] for _ in range(m) ] cb.append([-1,1]) a.sort() cb.sort() i= n-1 j = m ans = 0 remain = n while(remain > 0): if( a[i] > cb[j][0] ): ans += a[i] i -= 1 remai...
import sys input = sys.stdin.readline n,m = list(map(int, input().split())) a = list(map(int, input().split())) cb = [list(map(int,input().split()))[::-1] for _ in range(m) ] cb.append([-1,1]) a.sort() cb.sort() i= n-1 j = m ans = 0 remain = n while(remain > 0): if( a[i] > cb[j][0] ): ...
24
27
438
481
n, m = list(map(int, input().split())) a = list(map(int, input().split())) cb = [list(map(int, input().split()))[::-1] for _ in range(m)] cb.append([-1, 1]) a.sort() cb.sort() i = n - 1 j = m ans = 0 remain = n while remain > 0: if a[i] > cb[j][0]: ans += a[i] i -= 1 remain -= 1 else: ...
import sys input = sys.stdin.readline n, m = list(map(int, input().split())) a = list(map(int, input().split())) cb = [list(map(int, input().split()))[::-1] for _ in range(m)] cb.append([-1, 1]) a.sort() cb.sort() i = n - 1 j = m ans = 0 remain = n while remain > 0: if a[i] > cb[j][0]: ans += a[i] ...
false
11.111111
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.03647
0.036713
0.993383
[ "s463047591", "s843421068" ]
u846041485
p03724
python
s211885221
s663005701
279
195
11,808
3,828
Accepted
Accepted
30.11
import sys n, m = list(map(int, sys.stdin.readline().split(' '))) a = [0] * (2 * m) for i in range(m): a[2 * i], a[2 * i + 1] = list(map(int, sys.stdin.readline().split(' '))) a.sort() flag = False tmp = 0 crr = 0 for i in range(2 * m): nxt = a[i] if crr == nxt: tmp += 1 else: ...
import sys n, m = list(map(int, sys.stdin.readline().split(' '))) mlt = [0] * n for i in range(m): b, c = list(map(int, sys.stdin.readline().split(' '))) b -= 1 c -= 1 mlt[b] += 1 mlt[c] += 1 flag = False for i in range(n): if mlt[i] & 1: flag = True break if not fl...
23
18
456
354
import sys n, m = list(map(int, sys.stdin.readline().split(" "))) a = [0] * (2 * m) for i in range(m): a[2 * i], a[2 * i + 1] = list(map(int, sys.stdin.readline().split(" "))) a.sort() flag = False tmp = 0 crr = 0 for i in range(2 * m): nxt = a[i] if crr == nxt: tmp += 1 else: if tmp & ...
import sys n, m = list(map(int, sys.stdin.readline().split(" "))) mlt = [0] * n for i in range(m): b, c = list(map(int, sys.stdin.readline().split(" "))) b -= 1 c -= 1 mlt[b] += 1 mlt[c] += 1 flag = False for i in range(n): if mlt[i] & 1: flag = True break if not flag: print...
false
21.73913
[ "-a = [0] * (2 * m)", "+mlt = [0] * n", "- a[2 * i], a[2 * i + 1] = list(map(int, sys.stdin.readline().split(\" \")))", "-a.sort()", "+ b, c = list(map(int, sys.stdin.readline().split(\" \")))", "+ b -= 1", "+ c -= 1", "+ mlt[b] += 1", "+ mlt[c] += 1", "-tmp = 0", "-crr = 0", ...
false
0.060434
0.042558
1.420054
[ "s211885221", "s663005701" ]
u045939752
p03806
python
s739624014
s187653931
1,771
1,509
3,924
3,924
Accepted
Accepted
14.79
N, Ma, Mb = list(map(int, input().split())) G = [] for i in range(N): a, b, c = list(map(int, input().split())) G.append( (a,b,c) ) M = 1 + min(sum([ a for a, b, c in G ]), sum([ b for a, b, c in G ]) ) INF = 1000000000 dp = [INF] * (M * M) dp[0] = 0 for a, b, c in G: i = M - a - 1 whi...
N, Ma, Mb = list(map(int, input().split())) G = [] for i in range(N): a, b, c = list(map(int, input().split())) G.append( (a,b,c) ) M = 1 + min(sum([ a for a, b, c in G ]), sum([ b for a, b, c in G ]) ) INF = 1000000000 dp = [INF] * (M * M) dp[0] = 0 for a, b, c in G: for i in reversed(li...
29
24
595
575
N, Ma, Mb = list(map(int, input().split())) G = [] for i in range(N): a, b, c = list(map(int, input().split())) G.append((a, b, c)) M = 1 + min(sum([a for a, b, c in G]), sum([b for a, b, c in G])) INF = 1000000000 dp = [INF] * (M * M) dp[0] = 0 for a, b, c in G: i = M - a - 1 while i >= 0: j = ...
N, Ma, Mb = list(map(int, input().split())) G = [] for i in range(N): a, b, c = list(map(int, input().split())) G.append((a, b, c)) M = 1 + min(sum([a for a, b, c in G]), sum([b for a, b, c in G])) INF = 1000000000 dp = [INF] * (M * M) dp[0] = 0 for a, b, c in G: for i in reversed(list(range(0, M - a))): ...
false
17.241379
[ "- i = M - a - 1", "- while i >= 0:", "- j = M - b - 1", "- while j >= 0:", "+ for i in reversed(list(range(0, M - a))):", "+ for j in reversed(list(range(0, M - b))):", "- j -= 1", "- i -= 1" ]
false
0.049169
0.049778
0.987756
[ "s739624014", "s187653931" ]
u476386869
p02596
python
s265455886
s613600013
699
107
9,196
9,168
Accepted
Accepted
84.69
import sys input = sys.stdin.readline def main(): K = int(eval(input())) if K%2==0: print((-1)) return if K % 7: L = 9*K else: L = 9*K//7 a = 1 for i in range(1,L+1): a = (a * 10) % L if a == 1: print(i) ...
#!python3.8 # -*- coding: utf-8 -*- # abc174/abc174_c import sys s2nn = lambda s: [int(c) for c in s.split(' ')] ss2nn = lambda ss: [int(s) for s in list(ss)] ss2nnn = lambda ss: [s2nn(s) for s in list(ss)] i2s = lambda: sys.stdin.readline().rstrip() i2n = lambda: int(i2s()) i2nn = lambda: s2nn(i2s()) ii2s...
23
32
353
712
import sys input = sys.stdin.readline def main(): K = int(eval(input())) if K % 2 == 0: print((-1)) return if K % 7: L = 9 * K else: L = 9 * K // 7 a = 1 for i in range(1, L + 1): a = (a * 10) % L if a == 1: print(i) retu...
#!python3.8 # -*- coding: utf-8 -*- # abc174/abc174_c import sys s2nn = lambda s: [int(c) for c in s.split(" ")] ss2nn = lambda ss: [int(s) for s in list(ss)] ss2nnn = lambda ss: [s2nn(s) for s in list(ss)] i2s = lambda: sys.stdin.readline().rstrip() i2n = lambda: int(i2s()) i2nn = lambda: s2nn(i2s()) ii2ss = lambda n...
false
28.125
[ "+#!python3.8", "+# -*- coding: utf-8 -*-", "+# abc174/abc174_c", "-input = sys.stdin.readline", "+s2nn = lambda s: [int(c) for c in s.split(\" \")]", "+ss2nn = lambda ss: [int(s) for s in list(ss)]", "+ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]", "+i2s = lambda: sys.stdin.readline().rstrip()", ...
false
0.096848
0.055183
1.75503
[ "s265455886", "s613600013" ]
u227082700
p03589
python
s181100107
s239554093
1,511
1,350
3,060
3,060
Accepted
Accepted
10.66
N=int(eval(input())) for h in range(1,3501): for n in range(1,3501): if 1/h+1/n>=4/N:continue w=(N*h*n)/(4*h*n-N*(h+n)) if w==int(w):print((h,n,int(w)));exit()
N=int(eval(input())) for h in range(1,3501): for n in range(1,3501): if 1/h+1/n>=4/N:continue if (N*h*n)%(4*h*n-N*(h+n))==0:print((h,n,(N*h*n)//(4*h*n-N*(h+n))));exit()
6
5
170
174
N = int(eval(input())) for h in range(1, 3501): for n in range(1, 3501): if 1 / h + 1 / n >= 4 / N: continue w = (N * h * n) / (4 * h * n - N * (h + n)) if w == int(w): print((h, n, int(w))) exit()
N = int(eval(input())) for h in range(1, 3501): for n in range(1, 3501): if 1 / h + 1 / n >= 4 / N: continue if (N * h * n) % (4 * h * n - N * (h + n)) == 0: print((h, n, (N * h * n) // (4 * h * n - N * (h + n)))) exit()
false
16.666667
[ "- w = (N * h * n) / (4 * h * n - N * (h + n))", "- if w == int(w):", "- print((h, n, int(w)))", "+ if (N * h * n) % (4 * h * n - N * (h + n)) == 0:", "+ print((h, n, (N * h * n) // (4 * h * n - N * (h + n))))" ]
false
0.049063
0.046529
1.054456
[ "s181100107", "s239554093" ]
u945181840
p03732
python
s745793737
s538748490
275
34
3,064
3,064
Accepted
Accepted
87.64
import sys from itertools import accumulate, product from operator import itemgetter read = sys.stdin.read N, W, *wv = list(map(int, read().split())) w1 = wv[0] V = [[0] for _ in range(4)] for w, v in sorted(zip(*[iter(wv)] * 2), key=itemgetter(1), reverse=True): V[w - w1].append(v) V = list(map(li...
import sys from itertools import accumulate, product from operator import itemgetter read = sys.stdin.read N, W, *wv = list(map(int, read().split())) w1 = wv[0] V = [[0] for _ in range(4)] for w, v in sorted(zip(*[iter(wv)] * 2), key=itemgetter(1), reverse=True): V[w - w1].append(v) V = list(map(li...
25
27
643
676
import sys from itertools import accumulate, product from operator import itemgetter read = sys.stdin.read N, W, *wv = list(map(int, read().split())) w1 = wv[0] V = [[0] for _ in range(4)] for w, v in sorted(zip(*[iter(wv)] * 2), key=itemgetter(1), reverse=True): V[w - w1].append(v) V = list(map(list, list(map(acc...
import sys from itertools import accumulate, product from operator import itemgetter read = sys.stdin.read N, W, *wv = list(map(int, read().split())) w1 = wv[0] V = [[0] for _ in range(4)] for w, v in sorted(zip(*[iter(wv)] * 2), key=itemgetter(1), reverse=True): V[w - w1].append(v) V = list(map(list, list(map(acc...
false
7.407407
[ "-for a, b, c, d in product(", "- list(range(n[0])), list(range(n[1])), list(range(n[2])), list(range(n[3]))", "-):", "- if b + c * 2 + d * 3 + (a + b + c + d) * w1 > W:", "+for a, b, c in product(list(range(n[0])), list(range(n[1])), list(range(n[2]))):", "+ tmp = b + c * 2 + (a + b + c) * w1", ...
false
0.073766
0.040668
1.813838
[ "s745793737", "s538748490" ]
u555587832
p02594
python
s834362269
s829018170
28
24
9,148
8,992
Accepted
Accepted
14.29
a = int(eval(input())) if a >= 30: print('Yes') else: print('No')
x = int(eval(input())) if x >= 30: print('Yes') else: print('No')
5
5
72
71
a = int(eval(input())) if a >= 30: print("Yes") else: print("No")
x = int(eval(input())) if x >= 30: print("Yes") else: print("No")
false
0
[ "-a = int(eval(input()))", "-if a >= 30:", "+x = int(eval(input()))", "+if x >= 30:" ]
false
0.044919
0.048164
0.932614
[ "s834362269", "s829018170" ]
u844789719
p03061
python
s505221190
s332965982
1,382
972
128,732
122,888
Accepted
Accepted
29.67
N = int(eval(input())) A = [int(_) for _ in input().split()] class SegmentTree(): def __init__(self, array, f, e, size): """ Parameters ---------- array : list to construct segment tree from f : func binary operation of the monoid ...
class SegmentTree(): def __init__(self, array, f, ti): """ Parameters ---------- array : list to construct segment tree from f : func binary operation of the monoid ti : identity element of the monoid """ ...
61
60
1,638
1,609
N = int(eval(input())) A = [int(_) for _ in input().split()] class SegmentTree: def __init__(self, array, f, e, size): """ Parameters ---------- array : list to construct segment tree from f : func binary operation of the monoid e : ...
class SegmentTree: def __init__(self, array, f, ti): """ Parameters ---------- array : list to construct segment tree from f : func binary operation of the monoid ti : identity element of the monoid """ self.f = f ...
false
1.639344
[ "-N = int(eval(input()))", "-A = [int(_) for _ in input().split()]", "-", "-", "- def __init__(self, array, f, e, size):", "+ def __init__(self, array, f, ti):", "- e :", "+ ti :", "- size : int", "- limit for array size", "- self.e = e", "- ...
false
0.061665
0.064531
0.955592
[ "s505221190", "s332965982" ]
u896741788
p03103
python
s925758980
s787690683
518
312
28,652
87,664
Accepted
Accepted
39.77
s,p=list(map(int,input().split())) l=sorted([list(map(int,input().split())) for i in range(s)]) now,budget=0,0 for price,bottles in l: if now+bottles>=p:print((budget+price*(p-now)));break else:now+=bottles;budget+=price*bottles
N,M=list(map(int,input().split())) l=sorted(list(tuple(map(int,input().split()))for i in range(N)),key=lambda x:x[0]) c=0 ans=0 for v,k in l: ans+=min(k,M-c)*v c+=min(k,M-c) if c==M: print(ans);exit()
6
9
235
223
s, p = list(map(int, input().split())) l = sorted([list(map(int, input().split())) for i in range(s)]) now, budget = 0, 0 for price, bottles in l: if now + bottles >= p: print((budget + price * (p - now))) break else: now += bottles budget += price * bottles
N, M = list(map(int, input().split())) l = sorted(list(tuple(map(int, input().split())) for i in range(N)), key=lambda x: x[0]) c = 0 ans = 0 for v, k in l: ans += min(k, M - c) * v c += min(k, M - c) if c == M: print(ans) exit()
false
33.333333
[ "-s, p = list(map(int, input().split()))", "-l = sorted([list(map(int, input().split())) for i in range(s)])", "-now, budget = 0, 0", "-for price, bottles in l:", "- if now + bottles >= p:", "- print((budget + price * (p - now)))", "- break", "- else:", "- now += bottles",...
false
0.091713
0.116099
0.789956
[ "s925758980", "s787690683" ]
u745514010
p02679
python
s928693755
s243550971
763
584
55,076
158,816
Accepted
Accepted
23.46
from collections import defaultdict from math import gcd mod = 1000000007 n = int(eval(input())) plus = defaultdict(int) minus = defaultdict(int) a_0 = 0 b_0 = 0 a_b_0 = 0 xxx = 10 ** 10 for _ in range(n): a, b = list(map(int, input().split())) if a == 0 or b == 0: if a == 0 and b == 0: ...
MOD = 10 ** 9 + 7 from math import gcd from collections import defaultdict n = int(eval(input())) plus = defaultdict(int) minus = defaultdict(int) zero = [0, 0, 0] for _ in range(n): a, b = list(map(int, input().split())) if a * b == 0: if a == b == 0: zero[0] += 1 elif...
48
46
1,007
985
from collections import defaultdict from math import gcd mod = 1000000007 n = int(eval(input())) plus = defaultdict(int) minus = defaultdict(int) a_0 = 0 b_0 = 0 a_b_0 = 0 xxx = 10**10 for _ in range(n): a, b = list(map(int, input().split())) if a == 0 or b == 0: if a == 0 and b == 0: a_b_0...
MOD = 10**9 + 7 from math import gcd from collections import defaultdict n = int(eval(input())) plus = defaultdict(int) minus = defaultdict(int) zero = [0, 0, 0] for _ in range(n): a, b = list(map(int, input().split())) if a * b == 0: if a == b == 0: zero[0] += 1 elif a == 0: ...
false
4.166667
[ "+MOD = 10**9 + 7", "+from math import gcd", "-from math import gcd", "-mod = 1000000007", "-a_0 = 0", "-b_0 = 0", "-a_b_0 = 0", "-xxx = 10**10", "+zero = [0, 0, 0]", "- if a == 0 or b == 0:", "- if a == 0 and b == 0:", "- a_b_0 += 1", "+ if a * b == 0:", "+ ...
false
0.074602
0.037077
2.012072
[ "s928693755", "s243550971" ]
u697559326
p03160
python
s249236192
s990840239
152
126
13,884
13,592
Accepted
Accepted
17.11
import sys input = sys.stdin.readline def main(): #1:初期化 N = int(eval(input())) #h = list(map(int, input().split())) h = [int(x) for x in input().split()] inf = float("inf") dp = [inf]*(N) #2:初期値 dp[0] = 0 #3:dp実行部(貰うDP) for i in range(1,N): dp[i] = min...
import sys input = sys.stdin.readline def main(): #1:初期化 N = int(eval(input())) h = list(map(int, input().split())) #h = [int(x) for x in input().split()] inf = float("inf") dp = [inf]*(N) #2:初期値 dp[0] = 0 #3:dp実行部(貰うDP) for i in range(1,N): dp[i] = min...
32
32
754
754
import sys input = sys.stdin.readline def main(): # 1:初期化 N = int(eval(input())) # h = list(map(int, input().split())) h = [int(x) for x in input().split()] inf = float("inf") dp = [inf] * (N) # 2:初期値 dp[0] = 0 # 3:dp実行部(貰うDP) for i in range(1, N): dp[i] = min(dp[i], d...
import sys input = sys.stdin.readline def main(): # 1:初期化 N = int(eval(input())) h = list(map(int, input().split())) # h = [int(x) for x in input().split()] inf = float("inf") dp = [inf] * (N) # 2:初期値 dp[0] = 0 # 3:dp実行部(貰うDP) for i in range(1, N): dp[i] = min(dp[i], d...
false
0
[ "- # h = list(map(int, input().split()))", "- h = [int(x) for x in input().split()]", "+ h = list(map(int, input().split()))", "+ # h = [int(x) for x in input().split()]" ]
false
0.040838
0.059637
0.684767
[ "s249236192", "s990840239" ]
u238940874
p03308
python
s401830180
s095038606
21
17
3,060
2,940
Accepted
Accepted
19.05
n=int(eval(input())) a=list(map(int,input().split())) ans=0 for i in range(n): for j in range(n-1): temp=abs(a[i]-a[j]) ans=max(ans,temp) print(ans)
n=int(eval(input())) a=list(map(int,input().split())) print((max(a)-min(a)))
8
3
169
70
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 for i in range(n): for j in range(n - 1): temp = abs(a[i] - a[j]) ans = max(ans, temp) print(ans)
n = int(eval(input())) a = list(map(int, input().split())) print((max(a) - min(a)))
false
62.5
[ "-ans = 0", "-for i in range(n):", "- for j in range(n - 1):", "- temp = abs(a[i] - a[j])", "- ans = max(ans, temp)", "-print(ans)", "+print((max(a) - min(a)))" ]
false
0.047262
0.046233
1.022244
[ "s401830180", "s095038606" ]
u690326927
p03288
python
s041086256
s056762251
20
17
2,940
2,940
Accepted
Accepted
15
R = int(eval(input())) if R < 1200: print('ABC') elif 1200 <= R < 2800: print('ARC') else: print('AGC')
R = int(eval(input())) print(('ABC' if R < 1200 else 'ARC' if 1200 <= R < 2800 else 'AGC'))
8
2
117
85
R = int(eval(input())) if R < 1200: print("ABC") elif 1200 <= R < 2800: print("ARC") else: print("AGC")
R = int(eval(input())) print(("ABC" if R < 1200 else "ARC" if 1200 <= R < 2800 else "AGC"))
false
75
[ "-if R < 1200:", "- print(\"ABC\")", "-elif 1200 <= R < 2800:", "- print(\"ARC\")", "-else:", "- print(\"AGC\")", "+print((\"ABC\" if R < 1200 else \"ARC\" if 1200 <= R < 2800 else \"AGC\"))" ]
false
0.048063
0.047482
1.01223
[ "s041086256", "s056762251" ]
u086503932
p03309
python
s231941955
s390061097
186
164
26,832
30,932
Accepted
Accepted
11.83
#!/usr/bin/env python3 import math def main(): N = int(eval(input())) A = list(map(int, input().split())) A = [A[i] - i - 1 for i in range(N)] A.sort() diff = A[(N-1)//2] print((sum([abs(a-diff) for a in A]))) if __name__ == "__main__": main()
N = int(eval(input())) A = list(map(int, input().split())) for i in range(N): A[i] -= i+1 A.sort() b = A[(N-1)//2] ans = 0 for i in range(N): ans += abs(A[i]-b) print(ans)
14
11
280
182
#!/usr/bin/env python3 import math def main(): N = int(eval(input())) A = list(map(int, input().split())) A = [A[i] - i - 1 for i in range(N)] A.sort() diff = A[(N - 1) // 2] print((sum([abs(a - diff) for a in A]))) if __name__ == "__main__": main()
N = int(eval(input())) A = list(map(int, input().split())) for i in range(N): A[i] -= i + 1 A.sort() b = A[(N - 1) // 2] ans = 0 for i in range(N): ans += abs(A[i] - b) print(ans)
false
21.428571
[ "-#!/usr/bin/env python3", "-import math", "-", "-", "-def main():", "- N = int(eval(input()))", "- A = list(map(int, input().split()))", "- A = [A[i] - i - 1 for i in range(N)]", "- A.sort()", "- diff = A[(N - 1) // 2]", "- print((sum([abs(a - diff) for a in A])))", "-", "...
false
0.079786
0.043962
1.814902
[ "s231941955", "s390061097" ]
u347640436
p03167
python
s782863673
s650133955
699
256
43,648
43,632
Accepted
Accepted
63.38
def main(): divisor = 10 ** 9 + 7 h, w = list(map(int, input().split())) a = [eval(input()) for _ in range(h)] dp = [[0] * w for _ in range(h)] dp[0][0] = 1 for i in range(h): ai = a[i] dpi = dp[i] if i + 1 < h: ai1 = a[i + 1] dpi1 = dp[i + 1] for j in range(w...
def main(): divisor = 10 ** 9 + 7 h, w = list(map(int, input().split())) a = [eval(input()) for _ in range(h)] dp = [[0] * w for _ in range(h)] dp[0][0] = 1 dp0 = dp[0] a0 = a[0] for j in range(1, w): if a0[j] != '#': dp0[j] = dp0[j - 1] for i in range(1, h): dpi = dp[i] ...
19
22
528
524
def main(): divisor = 10**9 + 7 h, w = list(map(int, input().split())) a = [eval(input()) for _ in range(h)] dp = [[0] * w for _ in range(h)] dp[0][0] = 1 for i in range(h): ai = a[i] dpi = dp[i] if i + 1 < h: ai1 = a[i + 1] dpi1 = dp[i + 1] ...
def main(): divisor = 10**9 + 7 h, w = list(map(int, input().split())) a = [eval(input()) for _ in range(h)] dp = [[0] * w for _ in range(h)] dp[0][0] = 1 dp0 = dp[0] a0 = a[0] for j in range(1, w): if a0[j] != "#": dp0[j] = dp0[j - 1] for i in range(1, h): ...
false
13.636364
[ "- for i in range(h):", "+ dp0 = dp[0]", "+ a0 = a[0]", "+ for j in range(1, w):", "+ if a0[j] != \"#\":", "+ dp0[j] = dp0[j - 1]", "+ for i in range(1, h):", "+ dpi = dp[i]", "+ dpi1 = dp[i - 1]", "- dpi = dp[i]", "- if i + 1 < h:", ...
false
0.037358
0.062535
0.597404
[ "s782863673", "s650133955" ]
u941407962
p03716
python
s457826132
s397588725
1,898
553
126,552
120,592
Accepted
Accepted
70.86
# ABC140E class SegTree: def __init__(self, init_val, ide_ele, seg_func): self.segfunc = seg_func N = len(init_val) self.num = 2**(N-1).bit_length() self.ide_ele = ide_ele self.seg=[self.ide_ele]*2*self.num for i in range(N): self.seg[i+self.num-1...
from heapq import * N, = list(map(int, input().split())) A = list(map(int, input().split())) s = sum(A[:N]) rs = [s] + [0] * N l = [] for i in range(N): heappush(l, A[i]) for i in range(N, 2*N): s += A[i] heappush(l, A[i]) x = heappop(l) s -= x rs[i-N+1] = s l2 = [] s2 = 0 for i ...
93
35
2,401
659
# ABC140E class SegTree: def __init__(self, init_val, ide_ele, seg_func): self.segfunc = seg_func N = len(init_val) self.num = 2 ** (N - 1).bit_length() self.ide_ele = ide_ele self.seg = [self.ide_ele] * 2 * self.num for i in range(N): self.seg[i + self.nu...
from heapq import * (N,) = list(map(int, input().split())) A = list(map(int, input().split())) s = sum(A[:N]) rs = [s] + [0] * N l = [] for i in range(N): heappush(l, A[i]) for i in range(N, 2 * N): s += A[i] heappush(l, A[i]) x = heappop(l) s -= x rs[i - N + 1] = s l2 = [] s2 = 0 for i in rang...
false
62.365591
[ "-# ABC140E", "-class SegTree:", "- def __init__(self, init_val, ide_ele, seg_func):", "- self.segfunc = seg_func", "- N = len(init_val)", "- self.num = 2 ** (N - 1).bit_length()", "- self.ide_ele = ide_ele", "- self.seg = [self.ide_ele] * 2 * self.num", "- ...
false
0.040757
0.041087
0.99195
[ "s457826132", "s397588725" ]
u553987207
p02614
python
s216907276
s128089494
60
51
9,212
9,112
Accepted
Accepted
15
H, W, K = list(map(int, input().split())) C = [[1 if c == "#" else 0 for c in eval(input())] for _ in range(H)] ans = 0 for bith in range(1 << H): for bitw in range(1 << W): c = [x[:] for x in C] for h in range(H): if bith & (1 << h): c[h] = [0] * W for w...
H, W, K = list(map(int, input().split())) M = [[1 if c == "#" else 0 for c in eval(input())] for _ in range(H)] ans = 0 for hselection in range(1 << H): for wselection in range(1 << W): count = 0 for h in range(H): if hselection & (1 << h): continue ...
17
17
521
492
H, W, K = list(map(int, input().split())) C = [[1 if c == "#" else 0 for c in eval(input())] for _ in range(H)] ans = 0 for bith in range(1 << H): for bitw in range(1 << W): c = [x[:] for x in C] for h in range(H): if bith & (1 << h): c[h] = [0] * W for w in range...
H, W, K = list(map(int, input().split())) M = [[1 if c == "#" else 0 for c in eval(input())] for _ in range(H)] ans = 0 for hselection in range(1 << H): for wselection in range(1 << W): count = 0 for h in range(H): if hselection & (1 << h): continue for w in r...
false
0
[ "-C = [[1 if c == \"#\" else 0 for c in eval(input())] for _ in range(H)]", "+M = [[1 if c == \"#\" else 0 for c in eval(input())] for _ in range(H)]", "-for bith in range(1 << H):", "- for bitw in range(1 << W):", "- c = [x[:] for x in C]", "+for hselection in range(1 << H):", "+ for wsele...
false
0.087526
0.050052
1.748706
[ "s216907276", "s128089494" ]